From 455155af3aab2d68d4bb0c2c81dbd3dd1b21fa10 Mon Sep 17 00:00:00 2001 From: Kyle Brumm Date: Fri, 13 Dec 2024 16:01:25 -0600 Subject: [PATCH] reorganize and add new metaobject detail types --- .../ui-extensions/src/surfaces/admin/api.ts | 2 ++ .../metafields.ts | 8 +++++ .../api/custom-data/metaobject-details.ts | 29 +++++++++++++++++++ .../admin/api/order-routing-rule/data.ts | 10 +------ .../order-routing-rule/order-routing-rule.ts | 2 +- .../src/surfaces/admin/extension-targets.ts | 6 ++-- 6 files changed, 45 insertions(+), 12 deletions(-) rename packages/ui-extensions/src/surfaces/admin/api/{order-routing-rule => custom-data}/metafields.ts (90%) create mode 100644 packages/ui-extensions/src/surfaces/admin/api/custom-data/metaobject-details.ts diff --git a/packages/ui-extensions/src/surfaces/admin/api.ts b/packages/ui-extensions/src/surfaces/admin/api.ts index 995aeb523..9c84627ba 100644 --- a/packages/ui-extensions/src/surfaces/admin/api.ts +++ b/packages/ui-extensions/src/surfaces/admin/api.ts @@ -9,3 +9,5 @@ export type {ProductDetailsConfigurationApi} from './api/product-configuration/p export type {ProductVariantDetailsConfigurationApi} from './api/product-configuration/product-variant-details-configuration'; export type {OrderRoutingRuleApi} from './api/order-routing-rule/order-routing-rule'; export type {ValidationSettingsApi} from './api/checkout-rules/validation-settings'; +export type {MetaobjectDetailsBlockApi} from './api/custom-data/metaobject-details'; +export type {MetaobjectDetailsActionApi} from './api/custom-data/metaobject-details'; diff --git a/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/metafields.ts b/packages/ui-extensions/src/surfaces/admin/api/custom-data/metafields.ts similarity index 90% rename from packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/metafields.ts rename to packages/ui-extensions/src/surfaces/admin/api/custom-data/metafields.ts index 5f13c3552..095a6c9a1 100644 --- a/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/metafields.ts +++ b/packages/ui-extensions/src/surfaces/admin/api/custom-data/metafields.ts @@ -65,3 +65,11 @@ type MetafieldsChange = export type SupportedDefinitionType = (typeof supportedDefinitionTypes)[number]; export type ApplyMetafieldsChange = (changes: MetafieldsChange[]) => void; + +export interface Metafield { + id?: string | null; + key: string; + value?: string | null; + namespace?: string; + type?: SupportedDefinitionType; +} diff --git a/packages/ui-extensions/src/surfaces/admin/api/custom-data/metaobject-details.ts b/packages/ui-extensions/src/surfaces/admin/api/custom-data/metaobject-details.ts new file mode 100644 index 000000000..3e7c460b9 --- /dev/null +++ b/packages/ui-extensions/src/surfaces/admin/api/custom-data/metaobject-details.ts @@ -0,0 +1,29 @@ +import {BlockExtensionApi} from '../block/block'; +import type {ExtensionTarget as AnyExtensionTarget} from '../../extension-targets'; +import {ActionExtensionApi} from '../action/action'; + +import {ApplyMetafieldsChange} from './metafields'; + +export interface MetaobjectDetailsBlockApi< + ExtensionTarget extends AnyExtensionTarget, +> extends BlockExtensionApi { + applyMetafieldsChange: ApplyMetafieldsChange; + data: { + selected: { + id: string; + definitionType: string; + }[]; + }; +} + +export interface MetaobjectDetailsActionApi< + ExtensionTarget extends AnyExtensionTarget, +> extends ActionExtensionApi { + applyMetafieldsChange: ApplyMetafieldsChange; + data: { + selected: { + id: string; + definitionType: string; + }[]; + }; +} diff --git a/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/data.ts b/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/data.ts index 1a82329fa..da1bd413d 100644 --- a/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/data.ts +++ b/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/data.ts @@ -1,12 +1,4 @@ -import type {SupportedDefinitionType} from './metafields'; - -interface Metafield { - id?: string | null; - key: string; - value?: string | null; - namespace?: string; - type?: SupportedDefinitionType; -} +import type {Metafield} from '../custom-data/metafields'; interface OrderRoutingRule { label: string; diff --git a/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/order-routing-rule.ts b/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/order-routing-rule.ts index d3ef37e0f..ec3632fd5 100644 --- a/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/order-routing-rule.ts +++ b/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/order-routing-rule.ts @@ -1,7 +1,7 @@ import type {StandardApi} from '../standard/standard'; import type {ExtensionTarget as AnyExtensionTarget} from '../../extension-targets'; -import {ApplyMetafieldsChange} from './metafields'; +import {ApplyMetafieldsChange} from '../custom-data/metafields'; import {Data} from './data'; export interface OrderRoutingRuleApi diff --git a/packages/ui-extensions/src/surfaces/admin/extension-targets.ts b/packages/ui-extensions/src/surfaces/admin/extension-targets.ts index 7a2427adf..8a80ad8e8 100644 --- a/packages/ui-extensions/src/surfaces/admin/extension-targets.ts +++ b/packages/ui-extensions/src/surfaces/admin/extension-targets.ts @@ -11,6 +11,8 @@ import type { ProductVariantDetailsConfigurationApi, OrderRoutingRuleApi, ValidationSettingsApi, + MetaobjectDetailsBlockApi, + MetaobjectDetailsActionApi, } from './api'; import {AnyComponentBuilder} from '../../shared'; import {PurchaseOptionsCardConfigurationApi} from './api/purchase-options-card-action/purchase-options-card-action'; @@ -185,7 +187,7 @@ export interface ExtensionTargets { * See the [list of available components](/docs/api/admin-extensions/components). */ 'admin.metaobject-details.block.render': RenderExtension< - BlockExtensionApi<'admin.metaobject-details.block.render'>, + MetaobjectDetailsBlockApi<'admin.metaobject-details.block.render'>, AllComponents | CustomDataComponents >; @@ -296,7 +298,7 @@ export interface ExtensionTargets { * See the [list of available components](/docs/api/admin-extensions/components). */ 'admin.metaobject-details.action.render': RenderExtension< - ActionExtensionApi<'admin.metaobject-details.action.render'>, + MetaobjectDetailsActionApi<'admin.metaobject-details.action.render'>, AllComponents | CustomDataComponents >;