Skip to content

Commit

Permalink
reorganize and add new metaobject detail types
Browse files Browse the repository at this point in the history
  • Loading branch information
kjbrum committed Dec 13, 2024
1 parent 54c26b2 commit 455155a
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 12 deletions.
2 changes: 2 additions & 0 deletions packages/ui-extensions/src/surfaces/admin/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<ExtensionTarget> {
applyMetafieldsChange: ApplyMetafieldsChange;
data: {
selected: {
id: string;
definitionType: string;
}[];
};
}

export interface MetaobjectDetailsActionApi<
ExtensionTarget extends AnyExtensionTarget,
> extends ActionExtensionApi<ExtensionTarget> {
applyMetafieldsChange: ApplyMetafieldsChange;
data: {
selected: {
id: string;
definitionType: string;
}[];
};
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ExtensionTarget extends AnyExtensionTarget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
>;

Expand Down Expand Up @@ -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
>;

Expand Down

0 comments on commit 455155a

Please sign in to comment.