Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefine types for validations in a way that works for doc generation #1840

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
import {Metafield} from './metafields';
interface Metafield {
description?: string;
id: string;
namespace: string;
key: string;
value: string;
type: string;
}

interface Validation {
/**
* the validation's gid when active in a shop
*/
id: string;
/**
* the metafields owned by the validation
*/
metafields: Metafield[];
}

interface ShopifyFunction {
/**
* the validation function's unique identifier
*/
id: string;
}

/**
* The object that exposes the validation with its settings.
*/
export interface ValidationData {
validation?: {
/**
* the validation's gid when active in a shop
*/
id: string;
/**
* the metafields owned by the validation
*/
metafields: Metafield[];
};
shopifyFunction: {
/**
* the validation function's unique identifier
*/
id: string;
};
validation?: Validation;
shopifyFunction: ShopifyFunction;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ const supportedDefinitionTypes = [

export type SupportedDefinitionType = typeof supportedDefinitionTypes[number];

export interface Metafield {
description?: string;
id: string;
namespace: string;
key: string;
value: string;
type: string;
}

interface MetafieldUpdateChange {
type: 'updateMetafield';
key: string;
Expand All @@ -80,6 +71,6 @@ type MetafieldChangeResult =
| MetafieldChangeSuccess
| MetafieldChangeResultError;

export interface ApplyMetafieldChange {
(change: MetafieldChange): Promise<MetafieldChangeResult>;
}
export type ApplyMetafieldChange = (
change: MetafieldChange,
) => Promise<MetafieldChangeResult>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';

const data: ReferenceEntityTemplateSchema = {
name: 'Validation Settings API',
description:
'This API is available Validation Settings extensions. Refer to the [tutorial](/docs/apps/checkout/validation/create-complex-validation-rules) for more information. Note that the [`FunctionSettings`](/docs/api/admin-extensions/components/forms/functionsettings) component is required to build Validation Settings extensions.',
isVisualComponent: false,
type: 'API',
definitions: [
{
title: 'applyMetafieldChange',
description: 'Applies a change to the validation settings.',
type: 'ApplyMetafieldChange',
},
{
title: 'data',
description: 'The object that exposes the validation with its settings.',
type: 'ValidationData',
},
],
category: 'API',
related: [],
};

export default data;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {ValidationData} from './launch-options';
export interface ValidationSettingsApi<
ExtensionTarget extends AnyExtensionTarget,
> extends StandardApi<ExtensionTarget> {
/**
* Applies a change to the validation settings.
*/
applyMetafieldChange: ApplyMetafieldChange;
data: ValidationData;
}
Loading