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..396cede36 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 '../shared'; interface OrderRoutingRule { label: string; diff --git a/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/metafields.ts b/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/metafields.ts deleted file mode 100644 index 8840c3272..000000000 --- a/packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/metafields.ts +++ /dev/null @@ -1,67 +0,0 @@ -const supportedDefinitionTypes = [ - 'boolean', - 'collection_reference', - 'color', - 'date', - 'date_time', - 'dimension', - 'file_reference', - 'json', - 'metaobject_reference', - 'mixed_reference', - 'money', - 'multi_line_text_field', - 'number_decimal', - 'number_integer', - 'page_reference', - 'product_reference', - 'rating', - 'rich_text_field', - 'single_line_text_field', - 'product_taxonomy_value_reference', - 'url', - 'variant_reference', - 'volume', - 'weight', - 'list.collection_reference', - 'list.color', - 'list.date', - 'list.date_time', - 'list.dimension', - 'list.file_reference', - 'list.metaobject_reference', - 'list.mixed_reference', - 'list.number_decimal', - 'list.number_integer', - 'list.page_reference', - 'list.product_reference', - 'list.rating', - 'list.single_line_text_field', - 'list.url', - 'list.variant_reference', - 'list.volume', - 'list.weight', -] as const; - -interface MetafieldUpdateChange { - type: 'updateMetafield'; - key: string; - namespace?: string; - value: string | number; - valueType?: SupportedDefinitionType; -} - -interface MetafieldRemoveChange { - type: 'removeMetafield'; - key: string; - namespace: string; -} - -type MetafieldsChange = - | MetafieldUpdateChange - | MetafieldRemoveChange - | MetafieldUpdateChange[] - | MetafieldRemoveChange[]; - -export type SupportedDefinitionType = typeof supportedDefinitionTypes[number]; -export type ApplyMetafieldsChange = (changes: MetafieldsChange[]) => void; 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..c37ecce7a 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 '../shared'; import {Data} from './data'; export interface OrderRoutingRuleApi diff --git a/packages/ui-extensions/src/surfaces/admin/api/shared.ts b/packages/ui-extensions/src/surfaces/admin/api/shared.ts index 62de98989..752ccd731 100644 --- a/packages/ui-extensions/src/surfaces/admin/api/shared.ts +++ b/packages/ui-extensions/src/surfaces/admin/api/shared.ts @@ -4,3 +4,79 @@ export interface Data { */ selected: {id: string}[]; } + +const supportedDefinitionTypes = [ + 'boolean', + 'collection_reference', + 'color', + 'date', + 'date_time', + 'dimension', + 'file_reference', + 'json', + 'metaobject_reference', + 'mixed_reference', + 'money', + 'multi_line_text_field', + 'number_decimal', + 'number_integer', + 'page_reference', + 'product_reference', + 'rating', + 'rich_text_field', + 'single_line_text_field', + 'product_taxonomy_value_reference', + 'url', + 'variant_reference', + 'volume', + 'weight', + 'list.collection_reference', + 'list.color', + 'list.date', + 'list.date_time', + 'list.dimension', + 'list.file_reference', + 'list.metaobject_reference', + 'list.mixed_reference', + 'list.number_decimal', + 'list.number_integer', + 'list.page_reference', + 'list.product_reference', + 'list.rating', + 'list.single_line_text_field', + 'list.url', + 'list.variant_reference', + 'list.volume', + 'list.weight', +] as const; + +interface MetafieldUpdateChange { + type: 'updateMetafield'; + key: string; + namespace?: string; + value: string | number; + valueType?: SupportedDefinitionType; +} + +interface MetafieldRemoveChange { + type: 'removeMetafield'; + key: string; + namespace: string; +} + +type MetafieldsChange = + | MetafieldUpdateChange + | MetafieldRemoveChange + | MetafieldUpdateChange[] + | MetafieldRemoveChange[]; + +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; +}