import { ZodSchemaType, BaseConfigType } from './schemas.js'; import { ExtensionInstance } from './extension-instance.js'; import { SpecsAppConfiguration } from './specifications/types/app_config.js'; import { Flag } from '../../services/dev/fetch.js'; import { Result } from '@shopify/cli-kit/node/result'; import { zod } from '@shopify/cli-kit/node/schema'; export type ExtensionFeature = 'ui_preview' | 'function' | 'theme' | 'bundling' | 'cart_url' | 'esbuild' | 'single_js_entry_path'; export interface TransformationConfig { [key: string]: string; } export interface CustomTransformationConfig { forward?: (obj: object, options?: { flags?: Flag[]; }) => object; reverse?: (obj: object, options?: { flags?: Flag[]; }) => object; } export interface SimplifyConfig { simplify?: (obj: SpecsAppConfiguration) => SpecsAppConfiguration; } export type ExtensionExperience = 'extension' | 'configuration'; /** * Extension specification with all the needed properties and methods to load an extension. */ export interface ExtensionSpecification { identifier: string; externalIdentifier: string; externalName: string; group?: string; additionalIdentifiers: string[]; partnersWebIdentifier: string; surface: string; registrationLimit: number; experience: ExtensionExperience; dependency?: string; graphQLType?: string; schema: ZodSchemaType; getBundleExtensionStdinContent?: (config: TConfiguration) => string; deployConfig?: (config: TConfiguration, directory: string, apiKey: string, moduleId?: string) => Promise<{ [key: string]: unknown; } | undefined>; validate?: (config: TConfiguration, configPath: string, directory: string) => Promise>; preDeployValidation?: (extension: ExtensionInstance) => Promise; buildValidation?: (extension: ExtensionInstance) => Promise; hasExtensionPointTarget?(config: TConfiguration, target: string): boolean; appModuleFeatures: (config?: TConfiguration) => ExtensionFeature[]; transform?: (content: object) => object; reverseTransform?: (content: object, options?: { flags?: Flag[]; }) => object; simplify?: (remoteConfig: SpecsAppConfiguration) => SpecsAppConfiguration; } /** * These fields are forbidden when creating a new ExtensionSpec * They belong to the ExtensionSpec interface, but the values are obtained from the API * and should not be set by us locally */ export type ForbiddenFields = 'registrationLimit' | 'category' | 'externalIdentifier' | 'externalName' | 'name' | 'surface'; /** * Partial ExtensionSpec type used when creating a new ExtensionSpec, the only mandatory field is the identifier */ export interface CreateExtensionSpecType extends Partial, ForbiddenFields>> { identifier: string; appModuleFeatures: (config?: TConfiguration) => ExtensionFeature[]; } /** * Create a new ui extension spec. * * Everything but "identifer" is optional. * ```ts * identifier: string // unique identifier for the extension type * externalIdentifier: string // identifier used externally (default: same as "identifier") * partnersWebIdentifier: string // identifier used in the partners web UI (default: same as "identifier") * surface?: string // surface where the extension is going to be rendered (default: 'unknown') * dependency?: {name: string; version: string} // dependency to be added to the extension's package.json * graphQLType?: string // GraphQL type of the extension (default: same as "identifier") * schema?: ZodSchemaType // schema used to validate the extension's configuration (default: BaseUIExtensionSchema) * getBundleExtensionStdinContent?: (configuration: TConfiguration) => string // function to generate the content of the stdin file used to bundle the extension * validate?: (configuration: TConfiguration, directory: string) => Promise> // function to validate the extension's configuration * preDeployValidation?: (configuration: TConfiguration) => Promise // function to validate the extension's configuration before deploying it * deployConfig?: (configuration: TConfiguration, directory: string) => Promise<{[key: string]: unknown}> // function to generate the extensions configuration payload to be deployed * hasExtensionPointTarget?: (configuration: TConfiguration, target: string) => boolean // function to determine if the extension has a given extension point target * ``` */ export declare function createExtensionSpecification(spec: CreateExtensionSpecType): ExtensionSpecification; /** * Create a new app config extension spec. This factory method for creating app config extensions is created for two * reasons: * - schema needs to be casted to ZodSchemaType * - App config extensions have default transform and reverseTransform functions */ export declare function createConfigExtensionSpecification(spec: { identifier: string; schema: zod.ZodObject; appModuleFeatures?: (config?: TConfiguration) => ExtensionFeature[]; transformConfig?: TransformationConfig | CustomTransformationConfig; simplify?: SimplifyConfig; }): ExtensionSpecification;