@spiffcommerce/theme-bridge 1.27.0 → 1.27.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configurationTypes-6D808idm.js.map +1 -1
- package/dist/configurationTypes-Bt8NVGKp.cjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +130 -33
- package/dist/plugin.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurationTypes-6D808idm.js","sources":["../src/configurationTypes.ts"],"sourcesContent":["export interface ThemeConfigurationFile {\n /**\n * Information the theme loader needs in order to launch your theme.\n */\n launchData: ThemeConfigurationLaunchData;\n /**\n * An object that describes information that's configurable by a Partner when they install your theme.\n */\n configurationSchema?: ThemeConfigurationSchema;\n}\n\nexport enum ThemeFileType {\n Javascript = \"Javascript\",\n CSS = \"CSS\",\n}\n\nexport interface ThemeConfigurationLaunchData {\n /**\n * Files that will be loaded when launching the theme.\n */\n targetFiles: ThemeConfigurationLaunchDataTargetFile[];\n}\n\ninterface LaunchFileBase {\n /**\n * The local path to the file.\n */\n filename: string;\n /**\n * The MIME type of the file.\n */\n mimeType: string;\n}\n\ninterface GenericLaunchFile extends LaunchFileBase {\n type: ThemeFileType.CSS;\n}\n\ninterface JavascriptLaunchFile extends LaunchFileBase {\n /**\n * When `false`, the file will be loaded immediately. When `true`, the file will instead be pre-loaded.\n * With javascript files, this will insert them into the page as `<link rel=\"modulepreload\" ... >`.\n */\n preload?: boolean;\n type: ThemeFileType.Javascript;\n}\n\nexport type ThemeConfigurationLaunchDataTargetFile = GenericLaunchFile | JavascriptLaunchFile;\n\nexport enum FieldType {\n Asset = \"Asset\",\n Boolean = \"Boolean\",\n Color = \"Color\",\n ConversionConfiguration = \"ConversionConfiguration\",\n Heading = \"Heading\",\n List = \"List\",\n Number = \"Number\",\n Object = \"Object\",\n Select = \"Select\",\n Text = \"Text\",\n DateRange = \"DateRange\",\n ProductCollection = \"ProductCollection\",\n MetafieldConfiguration = \"MetafieldConfiguration\",\n}\n\nexport interface ThemeConfigurationSchema {\n /**\n * An array of fields that a Partner can configure when they install the theme.\n */\n fields: ThemeConfigurationSchemaField[];\n\n /**\n * An array of custom schemas that can be reused anywhere on any field.\n */\n customSchemas?: ThemeConfigurationSchemaCustomSchema[];\n}\n\ninterface FieldBase {\n /**\n * The display name for the field. When `type` is `\"Heading\"`, this is the heading string.\n */\n title: string;\n}\n\n/**\n * Base type for a field that is actually configurable by a user.\n */\ninterface ConfigurableField extends FieldBase {\n /**\n * A locally unique identifier for the field.\n */\n key: string;\n /**\n * Optional: A brief description of what the field might be used for. This is displayed beneath the field in the configuration form.\n */\n description?: string;\n}\n\ninterface RequiredOption {\n /**\n * Optional: Set to `true` to require a value to be provided in the configuration form.\n */\n required?: boolean;\n /** Cannot combine required and defaultValue options. */\n readonly defaultValue?: undefined;\n}\n\ntype RequiredOrDefault =\n | RequiredOption\n | {\n /**\n * Optional: A default value to supply. Values are always supplied as strings.\n * When the `type` is `\"Select\"`, this should be one of the `key` fields in the `options` array.\n */\n defaultValue?: string;\n /** Cannot combine required and defaultValue options. */\n readonly required?: undefined;\n };\n\ninterface LimitOption {\n /**\n * Optional: A limit to impose on the input.\n * When the `type` is `\"Text\"`, this is a character limit.\n * When the `type` is `\"List\"`, this is a limit to the number of items in the list.\n * When this value is < 1, or not supplied, it is ignored.\n */\n limit?: number;\n}\n\n/**\n * Generic fields which have no extra configuration and can accept default values from the Theme developer.\n */\ninterface GenericFieldBase extends ConfigurableField {\n type: FieldType.Boolean | FieldType.Color | FieldType.Number | FieldType.DateRange;\n}\n\ntype GenericField = GenericFieldBase & RequiredOrDefault;\n\nexport enum AssetType {\n Color = \"Color\",\n ColorProfile = \"ColorProfile\",\n Data = \"Data\",\n Environment = \"Environment\",\n Font = \"Font\",\n Frame = \"Frame\",\n Illustration = \"Illustration\",\n Image = \"Image\",\n Material = \"Material\",\n Model = \"Model\",\n Video = \"Video\",\n}\n\ninterface AssetField extends ConfigurableField, RequiredOption {\n /**\n * The type of asset, e.g. Image, Model, Font, etc.\n */\n assetType: AssetType;\n type: FieldType.Asset;\n}\n\ninterface ConversionConfigurationField extends ConfigurableField {\n type: FieldType.ConversionConfiguration;\n}\n\ninterface SelectFieldBase extends ConfigurableField {\n /**\n * The options available for the Partner to select in the configuration form.\n */\n options: {\n /**\n * A locally unique identifier (within this set of options).\n */\n key: string;\n /**\n * The string that is displayed visually in the menu item.\n */\n value: string;\n }[];\n type: FieldType.Select;\n}\n\ntype SelectField = SelectFieldBase & RequiredOrDefault;\n\ninterface TextFieldBase extends ConfigurableField, LimitOption {\n /**\n * Allows the Partner to configure the field in a multi-line text editor.\n */\n multiLine?: boolean;\n type: FieldType.Text;\n}\n\ntype TextField = TextFieldBase & RequiredOrDefault;\n\n/**\n * Displays a heading in the Configuration Editor page in Hub.\n */\ninterface HeadingField extends FieldBase {\n type: FieldType.Heading;\n}\n\n/**\n * A list of one specific field type.\n */\ninterface ListField extends ConfigurableField, RequiredOption, LimitOption {\n type: FieldType.List;\n /**\n * Defines the configuration schema for the entries in this list.\n */\n items: DistributiveOmit<ThemeConfigurationConfigurableFields, \"key\" | \"title\" | \"description\">;\n}\n\n/**\n * A collection of any number of different fields.\n */\ninterface ObjectField extends ConfigurableField, RequiredOption {\n type: FieldType.Object;\n /**\n * Defines the configuration schema for the fields in this object.\n */\n fields: ThemeConfigurationSchemaField[];\n /**\n * The schema to use from the `customSchemas` field. Leave this undefined when not using a pre-defined schema.\n */\n schema?: undefined;\n}\n\ninterface CustomObjectField extends Omit<ObjectField, \"fields\" | \"schema\"> {\n schema: string;\n}\n\ninterface ProductCollectionField extends ConfigurableField {\n type: FieldType.ProductCollection;\n}\n\nexport enum MetafieldConfigurationEntityType {\n Asset = \"Asset\",\n Customer = \"Customer\",\n Integration = \"Integration\",\n Option = \"Option\",\n Order = \"Order\",\n Partner = \"Partner\",\n Product = \"Product\",\n ProductCollection = \"ProductCollection\",\n Variant = \"Variant\",\n Workflow = \"Workflow\",\n WorkflowStep = \"WorkflowStep\",\n}\n\ninterface MetafieldConfigurationField extends ConfigurableField {\n type: FieldType.MetafieldConfiguration;\n entityType: MetafieldConfigurationEntityType;\n}\n\n/** https://stackoverflow.com/a/57103940/23523714 */\ntype DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;\n\n/**\n * All field types that are configurable by a user in Hub.\n */\nexport type ThemeConfigurationConfigurableFields =\n | GenericField\n | AssetField\n | ConversionConfigurationField\n | SelectField\n | TextField\n | ListField\n | ObjectField\n | CustomObjectField\n | ProductCollectionField\n | MetafieldConfigurationField;\n\n/**\n * All field types, including non-configurable ones.\n */\nexport type ThemeConfigurationSchemaField = ThemeConfigurationConfigurableFields | HeadingField;\n\nexport enum CustomSchemaType {\n Object = \"Object\",\n Union = \"Union\",\n}\n\ninterface CustomSchemaBase {\n /**\n * A unique name for the schema.\n */\n name: string;\n}\n\n/**\n * A schema for a reusable custom object. This is effectively the same as an ObjectField.\n */\ninterface ObjectCustomSchema extends CustomSchemaBase {\n type: CustomSchemaType.Object;\n /**\n * The text displayed when selecting this type in the configuration UI (when part of a Union)\n */\n title?: string;\n /**\n * Defines the configuration schema for the fields in this object.\n */\n fields: ThemeConfigurationSchemaField[];\n /**\n * Optional: Allows your schema to extend from other object schemas.\n * Useful when you have a base type and want to create variants.\n */\n extends?: string[];\n}\n\n/**\n * A schema for a reusable union of multiple custom object schemas.\n */\ninterface UnionCustomSchema extends CustomSchemaBase {\n type: CustomSchemaType.Union;\n /**\n * All schemas that can be selected for this union.\n */\n schemas: string[];\n}\n\nexport type ThemeConfigurationSchemaCustomSchema = ObjectCustomSchema | UnionCustomSchema;\n\n// TODO: Absolutely need a way to generate a schema from a typescript type.\n"],"names":["ThemeFileType","FieldType","AssetType","MetafieldConfigurationEntityType","CustomSchemaType"],"mappings":"AAWO,IAAKA,sBAAAA,OACRA,EAAA,aAAa,cACbA,EAAA,MAAM,OAFEA,IAAAA,KAAA,CAAA,CAAA,GAsCAC,sBAAAA,OACRA,EAAA,QAAQ,SACRA,EAAA,UAAU,WACVA,EAAA,QAAQ,SACRA,EAAA,0BAA0B,2BAC1BA,EAAA,UAAU,WACVA,EAAA,OAAO,QACPA,EAAA,SAAS,UACTA,EAAA,SAAS,UACTA,EAAA,SAAS,UACTA,EAAA,OAAO,QACPA,EAAA,YAAY,aACZA,EAAA,oBAAoB,qBACpBA,EAAA,yBAAyB,0BAbjBA,IAAAA,KAAA,CAAA,CAAA,GAyFAC,sBAAAA,OACRA,EAAA,QAAQ,SACRA,EAAA,eAAe,gBACfA,EAAA,OAAO,QACPA,EAAA,cAAc,eACdA,EAAA,OAAO,QACPA,EAAA,QAAQ,SACRA,EAAA,eAAe,gBACfA,EAAA,QAAQ,SACRA,EAAA,WAAW,YACXA,EAAA,QAAQ,SACRA,EAAA,QAAQ,SAXAA,IAAAA,KAAA,CAAA,CAAA,GAgGAC,sBAAAA,OACRA,EAAA,QAAQ,SACRA,EAAA,WAAW,YACXA,EAAA,cAAc,eACdA,EAAA,SAAS,UACTA,EAAA,QAAQ,SACRA,EAAA,UAAU,WACVA,EAAA,UAAU,WACVA,EAAA,oBAAoB,qBACpBA,EAAA,UAAU,WACVA,EAAA,WAAW,YACXA,EAAA,eAAe,gBAXPA,IAAAA,KAAA,CAAA,CAAA,GA0CAC,sBAAAA,OACRA,EAAA,SAAS,UACTA,EAAA,QAAQ,SAFAA,IAAAA,KAAA,CAAA,CAAA;"}
|
|
1
|
+
{"version":3,"file":"configurationTypes-6D808idm.js","sources":["../src/configurationTypes.ts"],"sourcesContent":["export interface ThemeConfigurationFile {\n /**\n * Information the theme loader needs in order to launch your theme.\n */\n launchData: ThemeConfigurationLaunchData;\n /**\n * An object that describes information that's configurable by a Partner when they install your theme.\n */\n configurationSchema?: ThemeConfigurationSchema;\n /**\n * Optional: Settings for how the Spiff Hub displays your theme's configuration fields.\n * If this is not present, all of your fields will be placed in an auto-generated `Misc` page.\n */\n pageSettings?: ThemeConfigurationPageSettings;\n}\n\nexport interface ThemeConfigurationPageSettings {\n /**\n * Settings for each page to display in the Spiff Hub. Use this to group large sections of fields together.\n * Any fields not configured into these pages will be placed in an auto-generated `Misc` page.\n */\n items: ThemeConfigurationPageItem[];\n /**\n * Optional: configuration for which pages can be reordered.\n * All pages which fall between `start` and `end` (inclusive) will be reorderable by the user.\n */\n reorderablePageSettings?: {\n /** The key of the first page which can be reordered. */\n start: string;\n /** The key of the final page which can be reordered. */\n end: string;\n };\n}\n\nexport interface ThemeConfigurationPageItem {\n /**\n * An identifier used for the system to reference this page by.\n * You may also use this to reference the page in your theme at runtime.\n */\n key: string;\n /**\n * The heading to display in the configuration page.\n * This will also be displayed in summary views.\n */\n title: string;\n /**\n * Optional: A sub-heading to display in the configuration page.\n */\n subtitle?: string | null;\n /**\n * Groups of configuration fields to be editable on this page.\n */\n sections: ThemeConfigurationPageSection[];\n /**\n * Whether this page can be disabled/enabled/hidden/visible.\n * Note that fields on page will still be configurable by the user.\n */\n toggleable: boolean;\n /**\n * When true, this page will not be active by default.\n * Note that if you specify `toggleable: true`, this only acts as a default value.\n */\n disabled?: boolean;\n}\n\nexport interface ThemeConfigurationPageSection {\n /** A heading to group these fields by. */\n title: string;\n /** Optional: Sub-heading to display underneath the heading. */\n subtitle?: string | null;\n /**\n * The `key` names of the fields to display in this section.\n * These **must** be static fields.\n */\n fields: string[];\n}\n\nexport enum ThemeFileType {\n Javascript = \"Javascript\",\n CSS = \"CSS\",\n}\n\nexport interface ThemeConfigurationLaunchData {\n /**\n * Files that will be loaded when launching the theme.\n */\n targetFiles: ThemeConfigurationLaunchDataTargetFile[];\n}\n\ninterface LaunchFileBase {\n /**\n * The local path to the file.\n */\n filename: string;\n /**\n * The MIME type of the file.\n */\n mimeType: string;\n}\n\ninterface GenericLaunchFile extends LaunchFileBase {\n type: ThemeFileType.CSS;\n}\n\ninterface JavascriptLaunchFile extends LaunchFileBase {\n /**\n * When `false`, the file will be loaded immediately. When `true`, the file will instead be pre-loaded.\n * With javascript files, this will insert them into the page as `<link rel=\"modulepreload\" ... >`.\n */\n preload?: boolean;\n type: ThemeFileType.Javascript;\n}\n\nexport type ThemeConfigurationLaunchDataTargetFile = GenericLaunchFile | JavascriptLaunchFile;\n\nexport enum FieldType {\n Asset = \"Asset\",\n Boolean = \"Boolean\",\n Color = \"Color\",\n ConversionConfiguration = \"ConversionConfiguration\",\n Heading = \"Heading\",\n List = \"List\",\n Number = \"Number\",\n Object = \"Object\",\n Select = \"Select\",\n Text = \"Text\",\n DateRange = \"DateRange\",\n ProductCollection = \"ProductCollection\",\n MetafieldConfiguration = \"MetafieldConfiguration\",\n}\n\nexport interface ThemeConfigurationSchema {\n /**\n * An array of fields that a Partner can configure when they install the theme.\n */\n fields: ThemeConfigurationSchemaField[];\n\n /**\n * An array of custom schemas that can be reused anywhere on any field.\n */\n customSchemas?: ThemeConfigurationSchemaCustomSchema[];\n}\n\ninterface FieldBase {\n /**\n * The display name for the field. When `type` is `\"Heading\"`, this is the heading string.\n */\n title: string;\n}\n\n/**\n * Base type for a field that is actually configurable by a user.\n */\ninterface ConfigurableField extends FieldBase {\n /**\n * A locally unique identifier for the field.\n */\n key: string;\n /**\n * Optional: A brief description of what the field might be used for. This is displayed beneath the field in the configuration form.\n */\n description?: string;\n}\n\ninterface RequiredOption {\n /**\n * Optional: Set to `true` to require a value to be provided in the configuration form.\n */\n required?: boolean;\n /** Cannot combine required and defaultValue options. */\n readonly defaultValue?: undefined;\n}\n\ntype RequiredOrDefault =\n | RequiredOption\n | {\n /**\n * Optional: A default value to supply. Values are always supplied as strings.\n * When the `type` is `\"Select\"`, this should be one of the `key` fields in the `options` array.\n */\n defaultValue?: string;\n /** Cannot combine required and defaultValue options. */\n readonly required?: undefined;\n };\n\ninterface LimitOption {\n /**\n * Optional: A limit to impose on the input.\n * When the `type` is `\"Text\"`, this is a character limit.\n * When the `type` is `\"List\"`, this is a limit to the number of items in the list.\n * When this value is < 1, or not supplied, it is ignored.\n */\n limit?: number;\n}\n\n/**\n * Generic fields which have no extra configuration and can accept default values from the Theme developer.\n */\ninterface GenericFieldBase extends ConfigurableField {\n type: FieldType.Boolean | FieldType.Color | FieldType.Number | FieldType.DateRange;\n}\n\ntype GenericField = GenericFieldBase & RequiredOrDefault;\n\nexport enum AssetType {\n Color = \"Color\",\n ColorProfile = \"ColorProfile\",\n Data = \"Data\",\n Environment = \"Environment\",\n Font = \"Font\",\n Frame = \"Frame\",\n Illustration = \"Illustration\",\n Image = \"Image\",\n Material = \"Material\",\n Model = \"Model\",\n Video = \"Video\",\n}\n\ninterface AssetField extends ConfigurableField, RequiredOption {\n /**\n * The type of asset, e.g. Image, Model, Font, etc.\n */\n assetType: AssetType;\n type: FieldType.Asset;\n}\n\ninterface ConversionConfigurationField extends ConfigurableField {\n type: FieldType.ConversionConfiguration;\n}\n\ninterface SelectFieldBase extends ConfigurableField {\n /**\n * The options available for the Partner to select in the configuration form.\n */\n options: {\n /**\n * A locally unique identifier (within this set of options).\n */\n key: string;\n /**\n * The string that is displayed visually in the menu item.\n */\n value: string;\n }[];\n type: FieldType.Select;\n}\n\ntype SelectField = SelectFieldBase & RequiredOrDefault;\n\ninterface TextFieldBase extends ConfigurableField, LimitOption {\n /**\n * Allows the Partner to configure the field in a multi-line text editor.\n */\n multiLine?: boolean;\n type: FieldType.Text;\n}\n\ntype TextField = TextFieldBase & RequiredOrDefault;\n\n/**\n * Displays a heading in the Configuration Editor page in Hub.\n */\ninterface HeadingField extends FieldBase {\n type: FieldType.Heading;\n}\n\n/**\n * A list of one specific field type.\n */\ninterface ListField extends ConfigurableField, RequiredOption, LimitOption {\n type: FieldType.List;\n /**\n * Defines the configuration schema for the entries in this list.\n */\n items: DistributiveOmit<ThemeConfigurationConfigurableFields, \"key\" | \"title\" | \"description\">;\n}\n\n/**\n * A collection of any number of different fields.\n */\ninterface ObjectField extends ConfigurableField, RequiredOption {\n type: FieldType.Object;\n /**\n * Defines the configuration schema for the fields in this object.\n */\n fields: ThemeConfigurationSchemaField[];\n /**\n * The schema to use from the `customSchemas` field. Leave this undefined when not using a pre-defined schema.\n */\n schema?: undefined;\n}\n\ninterface CustomObjectField extends Omit<ObjectField, \"fields\" | \"schema\"> {\n schema: string;\n}\n\ninterface ProductCollectionField extends ConfigurableField {\n type: FieldType.ProductCollection;\n}\n\nexport enum MetafieldConfigurationEntityType {\n Asset = \"Asset\",\n Customer = \"Customer\",\n Integration = \"Integration\",\n Option = \"Option\",\n Order = \"Order\",\n Partner = \"Partner\",\n Product = \"Product\",\n ProductCollection = \"ProductCollection\",\n Variant = \"Variant\",\n Workflow = \"Workflow\",\n WorkflowStep = \"WorkflowStep\",\n}\n\ninterface MetafieldConfigurationField extends ConfigurableField {\n type: FieldType.MetafieldConfiguration;\n entityType: MetafieldConfigurationEntityType;\n}\n\n/** https://stackoverflow.com/a/57103940/23523714 */\ntype DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;\n\n/**\n * All field types that are configurable by a user in Hub.\n */\nexport type ThemeConfigurationConfigurableFields =\n | GenericField\n | AssetField\n | ConversionConfigurationField\n | SelectField\n | TextField\n | ListField\n | ObjectField\n | CustomObjectField\n | ProductCollectionField\n | MetafieldConfigurationField;\n\n/**\n * All field types, including non-configurable ones.\n */\nexport type ThemeConfigurationSchemaField = ThemeConfigurationConfigurableFields | HeadingField;\n\nexport enum CustomSchemaType {\n Object = \"Object\",\n Union = \"Union\",\n}\n\ninterface CustomSchemaBase {\n /**\n * A unique name for the schema.\n */\n name: string;\n}\n\n/**\n * A schema for a reusable custom object. This is effectively the same as an ObjectField.\n */\ninterface ObjectCustomSchema extends CustomSchemaBase {\n type: CustomSchemaType.Object;\n /**\n * The text displayed when selecting this type in the configuration UI (when part of a Union)\n */\n title?: string;\n /**\n * Defines the configuration schema for the fields in this object.\n */\n fields: ThemeConfigurationSchemaField[];\n /**\n * Optional: Allows your schema to extend from other object schemas.\n * Useful when you have a base type and want to create variants.\n */\n extends?: string[];\n}\n\n/**\n * A schema for a reusable union of multiple custom object schemas.\n */\ninterface UnionCustomSchema extends CustomSchemaBase {\n type: CustomSchemaType.Union;\n /**\n * All schemas that can be selected for this union.\n */\n schemas: string[];\n}\n\nexport type ThemeConfigurationSchemaCustomSchema = ObjectCustomSchema | UnionCustomSchema;\n\n// TODO: Absolutely need a way to generate a schema from a typescript type.\n"],"names":["ThemeFileType","FieldType","AssetType","MetafieldConfigurationEntityType","CustomSchemaType"],"mappings":"AA6EO,IAAKA,sBAAAA,OACRA,EAAA,aAAa,cACbA,EAAA,MAAM,OAFEA,IAAAA,KAAA,CAAA,CAAA,GAsCAC,sBAAAA,OACRA,EAAA,QAAQ,SACRA,EAAA,UAAU,WACVA,EAAA,QAAQ,SACRA,EAAA,0BAA0B,2BAC1BA,EAAA,UAAU,WACVA,EAAA,OAAO,QACPA,EAAA,SAAS,UACTA,EAAA,SAAS,UACTA,EAAA,SAAS,UACTA,EAAA,OAAO,QACPA,EAAA,YAAY,aACZA,EAAA,oBAAoB,qBACpBA,EAAA,yBAAyB,0BAbjBA,IAAAA,KAAA,CAAA,CAAA,GAyFAC,sBAAAA,OACRA,EAAA,QAAQ,SACRA,EAAA,eAAe,gBACfA,EAAA,OAAO,QACPA,EAAA,cAAc,eACdA,EAAA,OAAO,QACPA,EAAA,QAAQ,SACRA,EAAA,eAAe,gBACfA,EAAA,QAAQ,SACRA,EAAA,WAAW,YACXA,EAAA,QAAQ,SACRA,EAAA,QAAQ,SAXAA,IAAAA,KAAA,CAAA,CAAA,GAgGAC,sBAAAA,OACRA,EAAA,QAAQ,SACRA,EAAA,WAAW,YACXA,EAAA,cAAc,eACdA,EAAA,SAAS,UACTA,EAAA,QAAQ,SACRA,EAAA,UAAU,WACVA,EAAA,UAAU,WACVA,EAAA,oBAAoB,qBACpBA,EAAA,UAAU,WACVA,EAAA,WAAW,YACXA,EAAA,eAAe,gBAXPA,IAAAA,KAAA,CAAA,CAAA,GA0CAC,sBAAAA,OACRA,EAAA,SAAS,UACTA,EAAA,QAAQ,SAFAA,IAAAA,KAAA,CAAA,CAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurationTypes-Bt8NVGKp.cjs","sources":["../src/configurationTypes.ts"],"sourcesContent":["export interface ThemeConfigurationFile {\n /**\n * Information the theme loader needs in order to launch your theme.\n */\n launchData: ThemeConfigurationLaunchData;\n /**\n * An object that describes information that's configurable by a Partner when they install your theme.\n */\n configurationSchema?: ThemeConfigurationSchema;\n}\n\nexport enum ThemeFileType {\n Javascript = \"Javascript\",\n CSS = \"CSS\",\n}\n\nexport interface ThemeConfigurationLaunchData {\n /**\n * Files that will be loaded when launching the theme.\n */\n targetFiles: ThemeConfigurationLaunchDataTargetFile[];\n}\n\ninterface LaunchFileBase {\n /**\n * The local path to the file.\n */\n filename: string;\n /**\n * The MIME type of the file.\n */\n mimeType: string;\n}\n\ninterface GenericLaunchFile extends LaunchFileBase {\n type: ThemeFileType.CSS;\n}\n\ninterface JavascriptLaunchFile extends LaunchFileBase {\n /**\n * When `false`, the file will be loaded immediately. When `true`, the file will instead be pre-loaded.\n * With javascript files, this will insert them into the page as `<link rel=\"modulepreload\" ... >`.\n */\n preload?: boolean;\n type: ThemeFileType.Javascript;\n}\n\nexport type ThemeConfigurationLaunchDataTargetFile = GenericLaunchFile | JavascriptLaunchFile;\n\nexport enum FieldType {\n Asset = \"Asset\",\n Boolean = \"Boolean\",\n Color = \"Color\",\n ConversionConfiguration = \"ConversionConfiguration\",\n Heading = \"Heading\",\n List = \"List\",\n Number = \"Number\",\n Object = \"Object\",\n Select = \"Select\",\n Text = \"Text\",\n DateRange = \"DateRange\",\n ProductCollection = \"ProductCollection\",\n MetafieldConfiguration = \"MetafieldConfiguration\",\n}\n\nexport interface ThemeConfigurationSchema {\n /**\n * An array of fields that a Partner can configure when they install the theme.\n */\n fields: ThemeConfigurationSchemaField[];\n\n /**\n * An array of custom schemas that can be reused anywhere on any field.\n */\n customSchemas?: ThemeConfigurationSchemaCustomSchema[];\n}\n\ninterface FieldBase {\n /**\n * The display name for the field. When `type` is `\"Heading\"`, this is the heading string.\n */\n title: string;\n}\n\n/**\n * Base type for a field that is actually configurable by a user.\n */\ninterface ConfigurableField extends FieldBase {\n /**\n * A locally unique identifier for the field.\n */\n key: string;\n /**\n * Optional: A brief description of what the field might be used for. This is displayed beneath the field in the configuration form.\n */\n description?: string;\n}\n\ninterface RequiredOption {\n /**\n * Optional: Set to `true` to require a value to be provided in the configuration form.\n */\n required?: boolean;\n /** Cannot combine required and defaultValue options. */\n readonly defaultValue?: undefined;\n}\n\ntype RequiredOrDefault =\n | RequiredOption\n | {\n /**\n * Optional: A default value to supply. Values are always supplied as strings.\n * When the `type` is `\"Select\"`, this should be one of the `key` fields in the `options` array.\n */\n defaultValue?: string;\n /** Cannot combine required and defaultValue options. */\n readonly required?: undefined;\n };\n\ninterface LimitOption {\n /**\n * Optional: A limit to impose on the input.\n * When the `type` is `\"Text\"`, this is a character limit.\n * When the `type` is `\"List\"`, this is a limit to the number of items in the list.\n * When this value is < 1, or not supplied, it is ignored.\n */\n limit?: number;\n}\n\n/**\n * Generic fields which have no extra configuration and can accept default values from the Theme developer.\n */\ninterface GenericFieldBase extends ConfigurableField {\n type: FieldType.Boolean | FieldType.Color | FieldType.Number | FieldType.DateRange;\n}\n\ntype GenericField = GenericFieldBase & RequiredOrDefault;\n\nexport enum AssetType {\n Color = \"Color\",\n ColorProfile = \"ColorProfile\",\n Data = \"Data\",\n Environment = \"Environment\",\n Font = \"Font\",\n Frame = \"Frame\",\n Illustration = \"Illustration\",\n Image = \"Image\",\n Material = \"Material\",\n Model = \"Model\",\n Video = \"Video\",\n}\n\ninterface AssetField extends ConfigurableField, RequiredOption {\n /**\n * The type of asset, e.g. Image, Model, Font, etc.\n */\n assetType: AssetType;\n type: FieldType.Asset;\n}\n\ninterface ConversionConfigurationField extends ConfigurableField {\n type: FieldType.ConversionConfiguration;\n}\n\ninterface SelectFieldBase extends ConfigurableField {\n /**\n * The options available for the Partner to select in the configuration form.\n */\n options: {\n /**\n * A locally unique identifier (within this set of options).\n */\n key: string;\n /**\n * The string that is displayed visually in the menu item.\n */\n value: string;\n }[];\n type: FieldType.Select;\n}\n\ntype SelectField = SelectFieldBase & RequiredOrDefault;\n\ninterface TextFieldBase extends ConfigurableField, LimitOption {\n /**\n * Allows the Partner to configure the field in a multi-line text editor.\n */\n multiLine?: boolean;\n type: FieldType.Text;\n}\n\ntype TextField = TextFieldBase & RequiredOrDefault;\n\n/**\n * Displays a heading in the Configuration Editor page in Hub.\n */\ninterface HeadingField extends FieldBase {\n type: FieldType.Heading;\n}\n\n/**\n * A list of one specific field type.\n */\ninterface ListField extends ConfigurableField, RequiredOption, LimitOption {\n type: FieldType.List;\n /**\n * Defines the configuration schema for the entries in this list.\n */\n items: DistributiveOmit<ThemeConfigurationConfigurableFields, \"key\" | \"title\" | \"description\">;\n}\n\n/**\n * A collection of any number of different fields.\n */\ninterface ObjectField extends ConfigurableField, RequiredOption {\n type: FieldType.Object;\n /**\n * Defines the configuration schema for the fields in this object.\n */\n fields: ThemeConfigurationSchemaField[];\n /**\n * The schema to use from the `customSchemas` field. Leave this undefined when not using a pre-defined schema.\n */\n schema?: undefined;\n}\n\ninterface CustomObjectField extends Omit<ObjectField, \"fields\" | \"schema\"> {\n schema: string;\n}\n\ninterface ProductCollectionField extends ConfigurableField {\n type: FieldType.ProductCollection;\n}\n\nexport enum MetafieldConfigurationEntityType {\n Asset = \"Asset\",\n Customer = \"Customer\",\n Integration = \"Integration\",\n Option = \"Option\",\n Order = \"Order\",\n Partner = \"Partner\",\n Product = \"Product\",\n ProductCollection = \"ProductCollection\",\n Variant = \"Variant\",\n Workflow = \"Workflow\",\n WorkflowStep = \"WorkflowStep\",\n}\n\ninterface MetafieldConfigurationField extends ConfigurableField {\n type: FieldType.MetafieldConfiguration;\n entityType: MetafieldConfigurationEntityType;\n}\n\n/** https://stackoverflow.com/a/57103940/23523714 */\ntype DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;\n\n/**\n * All field types that are configurable by a user in Hub.\n */\nexport type ThemeConfigurationConfigurableFields =\n | GenericField\n | AssetField\n | ConversionConfigurationField\n | SelectField\n | TextField\n | ListField\n | ObjectField\n | CustomObjectField\n | ProductCollectionField\n | MetafieldConfigurationField;\n\n/**\n * All field types, including non-configurable ones.\n */\nexport type ThemeConfigurationSchemaField = ThemeConfigurationConfigurableFields | HeadingField;\n\nexport enum CustomSchemaType {\n Object = \"Object\",\n Union = \"Union\",\n}\n\ninterface CustomSchemaBase {\n /**\n * A unique name for the schema.\n */\n name: string;\n}\n\n/**\n * A schema for a reusable custom object. This is effectively the same as an ObjectField.\n */\ninterface ObjectCustomSchema extends CustomSchemaBase {\n type: CustomSchemaType.Object;\n /**\n * The text displayed when selecting this type in the configuration UI (when part of a Union)\n */\n title?: string;\n /**\n * Defines the configuration schema for the fields in this object.\n */\n fields: ThemeConfigurationSchemaField[];\n /**\n * Optional: Allows your schema to extend from other object schemas.\n * Useful when you have a base type and want to create variants.\n */\n extends?: string[];\n}\n\n/**\n * A schema for a reusable union of multiple custom object schemas.\n */\ninterface UnionCustomSchema extends CustomSchemaBase {\n type: CustomSchemaType.Union;\n /**\n * All schemas that can be selected for this union.\n */\n schemas: string[];\n}\n\nexport type ThemeConfigurationSchemaCustomSchema = ObjectCustomSchema | UnionCustomSchema;\n\n// TODO: Absolutely need a way to generate a schema from a typescript type.\n"],"names":["ThemeFileType","FieldType","AssetType","MetafieldConfigurationEntityType","CustomSchemaType"],"mappings":"aAWO,IAAKA,GAAAA,IACRA,EAAA,WAAa,aACbA,EAAA,IAAM,MAFEA,IAAAA,GAAA,CAAA,CAAA,EAsCAC,GAAAA,IACRA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,MAAQ,QACRA,EAAA,wBAA0B,0BAC1BA,EAAA,QAAU,UACVA,EAAA,KAAO,OACPA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,KAAO,OACPA,EAAA,UAAY,YACZA,EAAA,kBAAoB,oBACpBA,EAAA,uBAAyB,yBAbjBA,IAAAA,GAAA,CAAA,CAAA,EAyFAC,GAAAA,IACRA,EAAA,MAAQ,QACRA,EAAA,aAAe,eACfA,EAAA,KAAO,OACPA,EAAA,YAAc,cACdA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,aAAe,eACfA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,MAAQ,QACRA,EAAA,MAAQ,QAXAA,IAAAA,GAAA,CAAA,CAAA,EAgGAC,GAAAA,IACRA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,YAAc,cACdA,EAAA,OAAS,SACTA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,QAAU,UACVA,EAAA,kBAAoB,oBACpBA,EAAA,QAAU,UACVA,EAAA,SAAW,WACXA,EAAA,aAAe,eAXPA,IAAAA,GAAA,CAAA,CAAA,EA0CAC,GAAAA,IACRA,EAAA,OAAS,SACTA,EAAA,MAAQ,QAFAA,IAAAA,GAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"configurationTypes-Bt8NVGKp.cjs","sources":["../src/configurationTypes.ts"],"sourcesContent":["export interface ThemeConfigurationFile {\n /**\n * Information the theme loader needs in order to launch your theme.\n */\n launchData: ThemeConfigurationLaunchData;\n /**\n * An object that describes information that's configurable by a Partner when they install your theme.\n */\n configurationSchema?: ThemeConfigurationSchema;\n /**\n * Optional: Settings for how the Spiff Hub displays your theme's configuration fields.\n * If this is not present, all of your fields will be placed in an auto-generated `Misc` page.\n */\n pageSettings?: ThemeConfigurationPageSettings;\n}\n\nexport interface ThemeConfigurationPageSettings {\n /**\n * Settings for each page to display in the Spiff Hub. Use this to group large sections of fields together.\n * Any fields not configured into these pages will be placed in an auto-generated `Misc` page.\n */\n items: ThemeConfigurationPageItem[];\n /**\n * Optional: configuration for which pages can be reordered.\n * All pages which fall between `start` and `end` (inclusive) will be reorderable by the user.\n */\n reorderablePageSettings?: {\n /** The key of the first page which can be reordered. */\n start: string;\n /** The key of the final page which can be reordered. */\n end: string;\n };\n}\n\nexport interface ThemeConfigurationPageItem {\n /**\n * An identifier used for the system to reference this page by.\n * You may also use this to reference the page in your theme at runtime.\n */\n key: string;\n /**\n * The heading to display in the configuration page.\n * This will also be displayed in summary views.\n */\n title: string;\n /**\n * Optional: A sub-heading to display in the configuration page.\n */\n subtitle?: string | null;\n /**\n * Groups of configuration fields to be editable on this page.\n */\n sections: ThemeConfigurationPageSection[];\n /**\n * Whether this page can be disabled/enabled/hidden/visible.\n * Note that fields on page will still be configurable by the user.\n */\n toggleable: boolean;\n /**\n * When true, this page will not be active by default.\n * Note that if you specify `toggleable: true`, this only acts as a default value.\n */\n disabled?: boolean;\n}\n\nexport interface ThemeConfigurationPageSection {\n /** A heading to group these fields by. */\n title: string;\n /** Optional: Sub-heading to display underneath the heading. */\n subtitle?: string | null;\n /**\n * The `key` names of the fields to display in this section.\n * These **must** be static fields.\n */\n fields: string[];\n}\n\nexport enum ThemeFileType {\n Javascript = \"Javascript\",\n CSS = \"CSS\",\n}\n\nexport interface ThemeConfigurationLaunchData {\n /**\n * Files that will be loaded when launching the theme.\n */\n targetFiles: ThemeConfigurationLaunchDataTargetFile[];\n}\n\ninterface LaunchFileBase {\n /**\n * The local path to the file.\n */\n filename: string;\n /**\n * The MIME type of the file.\n */\n mimeType: string;\n}\n\ninterface GenericLaunchFile extends LaunchFileBase {\n type: ThemeFileType.CSS;\n}\n\ninterface JavascriptLaunchFile extends LaunchFileBase {\n /**\n * When `false`, the file will be loaded immediately. When `true`, the file will instead be pre-loaded.\n * With javascript files, this will insert them into the page as `<link rel=\"modulepreload\" ... >`.\n */\n preload?: boolean;\n type: ThemeFileType.Javascript;\n}\n\nexport type ThemeConfigurationLaunchDataTargetFile = GenericLaunchFile | JavascriptLaunchFile;\n\nexport enum FieldType {\n Asset = \"Asset\",\n Boolean = \"Boolean\",\n Color = \"Color\",\n ConversionConfiguration = \"ConversionConfiguration\",\n Heading = \"Heading\",\n List = \"List\",\n Number = \"Number\",\n Object = \"Object\",\n Select = \"Select\",\n Text = \"Text\",\n DateRange = \"DateRange\",\n ProductCollection = \"ProductCollection\",\n MetafieldConfiguration = \"MetafieldConfiguration\",\n}\n\nexport interface ThemeConfigurationSchema {\n /**\n * An array of fields that a Partner can configure when they install the theme.\n */\n fields: ThemeConfigurationSchemaField[];\n\n /**\n * An array of custom schemas that can be reused anywhere on any field.\n */\n customSchemas?: ThemeConfigurationSchemaCustomSchema[];\n}\n\ninterface FieldBase {\n /**\n * The display name for the field. When `type` is `\"Heading\"`, this is the heading string.\n */\n title: string;\n}\n\n/**\n * Base type for a field that is actually configurable by a user.\n */\ninterface ConfigurableField extends FieldBase {\n /**\n * A locally unique identifier for the field.\n */\n key: string;\n /**\n * Optional: A brief description of what the field might be used for. This is displayed beneath the field in the configuration form.\n */\n description?: string;\n}\n\ninterface RequiredOption {\n /**\n * Optional: Set to `true` to require a value to be provided in the configuration form.\n */\n required?: boolean;\n /** Cannot combine required and defaultValue options. */\n readonly defaultValue?: undefined;\n}\n\ntype RequiredOrDefault =\n | RequiredOption\n | {\n /**\n * Optional: A default value to supply. Values are always supplied as strings.\n * When the `type` is `\"Select\"`, this should be one of the `key` fields in the `options` array.\n */\n defaultValue?: string;\n /** Cannot combine required and defaultValue options. */\n readonly required?: undefined;\n };\n\ninterface LimitOption {\n /**\n * Optional: A limit to impose on the input.\n * When the `type` is `\"Text\"`, this is a character limit.\n * When the `type` is `\"List\"`, this is a limit to the number of items in the list.\n * When this value is < 1, or not supplied, it is ignored.\n */\n limit?: number;\n}\n\n/**\n * Generic fields which have no extra configuration and can accept default values from the Theme developer.\n */\ninterface GenericFieldBase extends ConfigurableField {\n type: FieldType.Boolean | FieldType.Color | FieldType.Number | FieldType.DateRange;\n}\n\ntype GenericField = GenericFieldBase & RequiredOrDefault;\n\nexport enum AssetType {\n Color = \"Color\",\n ColorProfile = \"ColorProfile\",\n Data = \"Data\",\n Environment = \"Environment\",\n Font = \"Font\",\n Frame = \"Frame\",\n Illustration = \"Illustration\",\n Image = \"Image\",\n Material = \"Material\",\n Model = \"Model\",\n Video = \"Video\",\n}\n\ninterface AssetField extends ConfigurableField, RequiredOption {\n /**\n * The type of asset, e.g. Image, Model, Font, etc.\n */\n assetType: AssetType;\n type: FieldType.Asset;\n}\n\ninterface ConversionConfigurationField extends ConfigurableField {\n type: FieldType.ConversionConfiguration;\n}\n\ninterface SelectFieldBase extends ConfigurableField {\n /**\n * The options available for the Partner to select in the configuration form.\n */\n options: {\n /**\n * A locally unique identifier (within this set of options).\n */\n key: string;\n /**\n * The string that is displayed visually in the menu item.\n */\n value: string;\n }[];\n type: FieldType.Select;\n}\n\ntype SelectField = SelectFieldBase & RequiredOrDefault;\n\ninterface TextFieldBase extends ConfigurableField, LimitOption {\n /**\n * Allows the Partner to configure the field in a multi-line text editor.\n */\n multiLine?: boolean;\n type: FieldType.Text;\n}\n\ntype TextField = TextFieldBase & RequiredOrDefault;\n\n/**\n * Displays a heading in the Configuration Editor page in Hub.\n */\ninterface HeadingField extends FieldBase {\n type: FieldType.Heading;\n}\n\n/**\n * A list of one specific field type.\n */\ninterface ListField extends ConfigurableField, RequiredOption, LimitOption {\n type: FieldType.List;\n /**\n * Defines the configuration schema for the entries in this list.\n */\n items: DistributiveOmit<ThemeConfigurationConfigurableFields, \"key\" | \"title\" | \"description\">;\n}\n\n/**\n * A collection of any number of different fields.\n */\ninterface ObjectField extends ConfigurableField, RequiredOption {\n type: FieldType.Object;\n /**\n * Defines the configuration schema for the fields in this object.\n */\n fields: ThemeConfigurationSchemaField[];\n /**\n * The schema to use from the `customSchemas` field. Leave this undefined when not using a pre-defined schema.\n */\n schema?: undefined;\n}\n\ninterface CustomObjectField extends Omit<ObjectField, \"fields\" | \"schema\"> {\n schema: string;\n}\n\ninterface ProductCollectionField extends ConfigurableField {\n type: FieldType.ProductCollection;\n}\n\nexport enum MetafieldConfigurationEntityType {\n Asset = \"Asset\",\n Customer = \"Customer\",\n Integration = \"Integration\",\n Option = \"Option\",\n Order = \"Order\",\n Partner = \"Partner\",\n Product = \"Product\",\n ProductCollection = \"ProductCollection\",\n Variant = \"Variant\",\n Workflow = \"Workflow\",\n WorkflowStep = \"WorkflowStep\",\n}\n\ninterface MetafieldConfigurationField extends ConfigurableField {\n type: FieldType.MetafieldConfiguration;\n entityType: MetafieldConfigurationEntityType;\n}\n\n/** https://stackoverflow.com/a/57103940/23523714 */\ntype DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;\n\n/**\n * All field types that are configurable by a user in Hub.\n */\nexport type ThemeConfigurationConfigurableFields =\n | GenericField\n | AssetField\n | ConversionConfigurationField\n | SelectField\n | TextField\n | ListField\n | ObjectField\n | CustomObjectField\n | ProductCollectionField\n | MetafieldConfigurationField;\n\n/**\n * All field types, including non-configurable ones.\n */\nexport type ThemeConfigurationSchemaField = ThemeConfigurationConfigurableFields | HeadingField;\n\nexport enum CustomSchemaType {\n Object = \"Object\",\n Union = \"Union\",\n}\n\ninterface CustomSchemaBase {\n /**\n * A unique name for the schema.\n */\n name: string;\n}\n\n/**\n * A schema for a reusable custom object. This is effectively the same as an ObjectField.\n */\ninterface ObjectCustomSchema extends CustomSchemaBase {\n type: CustomSchemaType.Object;\n /**\n * The text displayed when selecting this type in the configuration UI (when part of a Union)\n */\n title?: string;\n /**\n * Defines the configuration schema for the fields in this object.\n */\n fields: ThemeConfigurationSchemaField[];\n /**\n * Optional: Allows your schema to extend from other object schemas.\n * Useful when you have a base type and want to create variants.\n */\n extends?: string[];\n}\n\n/**\n * A schema for a reusable union of multiple custom object schemas.\n */\ninterface UnionCustomSchema extends CustomSchemaBase {\n type: CustomSchemaType.Union;\n /**\n * All schemas that can be selected for this union.\n */\n schemas: string[];\n}\n\nexport type ThemeConfigurationSchemaCustomSchema = ObjectCustomSchema | UnionCustomSchema;\n\n// TODO: Absolutely need a way to generate a schema from a typescript type.\n"],"names":["ThemeFileType","FieldType","AssetType","MetafieldConfigurationEntityType","CustomSchemaType"],"mappings":"aA6EO,IAAKA,GAAAA,IACRA,EAAA,WAAa,aACbA,EAAA,IAAM,MAFEA,IAAAA,GAAA,CAAA,CAAA,EAsCAC,GAAAA,IACRA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,MAAQ,QACRA,EAAA,wBAA0B,0BAC1BA,EAAA,QAAU,UACVA,EAAA,KAAO,OACPA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,KAAO,OACPA,EAAA,UAAY,YACZA,EAAA,kBAAoB,oBACpBA,EAAA,uBAAyB,yBAbjBA,IAAAA,GAAA,CAAA,CAAA,EAyFAC,GAAAA,IACRA,EAAA,MAAQ,QACRA,EAAA,aAAe,eACfA,EAAA,KAAO,OACPA,EAAA,YAAc,cACdA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,aAAe,eACfA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,MAAQ,QACRA,EAAA,MAAQ,QAXAA,IAAAA,GAAA,CAAA,CAAA,EAgGAC,GAAAA,IACRA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,YAAc,cACdA,EAAA,OAAS,SACTA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,QAAU,UACVA,EAAA,kBAAoB,oBACpBA,EAAA,QAAU,UACVA,EAAA,SAAW,WACXA,EAAA,aAAe,eAXPA,IAAAA,GAAA,CAAA,CAAA,EA0CAC,GAAAA,IACRA,EAAA,OAAS,SACTA,EAAA,MAAQ,QAFAA,IAAAA,GAAA,CAAA,CAAA"}
|