From e9c1560257c8852807bdb53fd4a54920b8c19712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Osorio?= Date: Wed, 17 Apr 2024 01:22:08 +0000 Subject: [PATCH 1/2] Move metafield and useApplyMetafieldsChange definition to shared --- .../admin/api/order-routing-rule/data.ts | 10 +-- .../api/order-routing-rule/metafields.ts | 67 ---------------- .../order-routing-rule/order-routing-rule.ts | 2 +- .../src/surfaces/admin/api/shared.ts | 76 +++++++++++++++++++ 4 files changed, 78 insertions(+), 77 deletions(-) delete mode 100644 packages/ui-extensions/src/surfaces/admin/api/order-routing-rule/metafields.ts 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; +} From 41f54a876685c9a45c2dc411f9554c5726d44e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Osorio?= Date: Wed, 17 Apr 2024 01:22:19 +0000 Subject: [PATCH 2/2] Add in store pickup targets's API definition --- .../ui-extensions/src/surfaces/admin/api.ts | 1 + .../admin/api/in-store-pickup/data.ts | 5 ++++ .../api/in-store-pickup/in-store-pickup.ts | 11 +++++++++ .../src/surfaces/admin/extension-targets.ts | 23 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 packages/ui-extensions/src/surfaces/admin/api/in-store-pickup/data.ts create mode 100644 packages/ui-extensions/src/surfaces/admin/api/in-store-pickup/in-store-pickup.ts diff --git a/packages/ui-extensions/src/surfaces/admin/api.ts b/packages/ui-extensions/src/surfaces/admin/api.ts index 838c4a8b8..b591f640e 100644 --- a/packages/ui-extensions/src/surfaces/admin/api.ts +++ b/packages/ui-extensions/src/surfaces/admin/api.ts @@ -8,3 +8,4 @@ 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 {InStorePickUpApi} from './api/in-store-pickup/in-store-pickup'; diff --git a/packages/ui-extensions/src/surfaces/admin/api/in-store-pickup/data.ts b/packages/ui-extensions/src/surfaces/admin/api/in-store-pickup/data.ts new file mode 100644 index 000000000..1341569a9 --- /dev/null +++ b/packages/ui-extensions/src/surfaces/admin/api/in-store-pickup/data.ts @@ -0,0 +1,5 @@ +import type {Metafield} from '../shared'; + +export interface Data { + metafields: Metafield[]; +} diff --git a/packages/ui-extensions/src/surfaces/admin/api/in-store-pickup/in-store-pickup.ts b/packages/ui-extensions/src/surfaces/admin/api/in-store-pickup/in-store-pickup.ts new file mode 100644 index 000000000..17eea0073 --- /dev/null +++ b/packages/ui-extensions/src/surfaces/admin/api/in-store-pickup/in-store-pickup.ts @@ -0,0 +1,11 @@ +import type {StandardApi} from '../standard/standard'; +import type {ExtensionTarget as AnyExtensionTarget} from '../../extension-targets'; + +import {ApplyMetafieldsChange} from '../shared'; +import {Data} from './data'; + +export interface InStorePickUpApi + extends StandardApi { + applyMetafieldsChange: ApplyMetafieldsChange; + data: Data; +} diff --git a/packages/ui-extensions/src/surfaces/admin/extension-targets.ts b/packages/ui-extensions/src/surfaces/admin/extension-targets.ts index 51349af57..bbafe30bf 100644 --- a/packages/ui-extensions/src/surfaces/admin/extension-targets.ts +++ b/packages/ui-extensions/src/surfaces/admin/extension-targets.ts @@ -9,6 +9,7 @@ import type { ProductDetailsConfigurationApi, ProductVariantDetailsConfigurationApi, OrderRoutingRuleApi, + InStorePickUpApi, ValidationSettingsApi, } from './api'; import {AnyComponentBuilder} from '../../shared'; @@ -378,6 +379,28 @@ export interface ExtensionTargets { AllComponents >; + /** + * Renders In Store Pickup Configuration on in store pick up settings (general and per location). + * + * See the [list of available components](/docs/api/admin-extensions/components). + */ + 'admin.settings.in-store-pickup.render': RenderExtension< + InStorePickUpApi<'admin.settings.in-store-pickup.render'>, + AllComponents + >; + 'admin.settings.internal-in-store-pickup.render': RenderExtension< + InStorePickUpApi<'admin.settings.internal-in-store-pickup.render'>, + AllComponents + >; + 'admin.settings.in-store-pickup-location.render': RenderExtension< + InStorePickUpApi<'admin.settings.in-store-pickup-location.render'>, + AllComponents + >; + 'admin.settings.internal-in-store-pickup-location.render': RenderExtension< + InStorePickUpApi<'admin.settings.internal-in-store-pickup-location.render'>, + AllComponents + >; + /** * Renders Validation Settings within a given validation's add and edit views. *