@spiffcommerce/theme-bridge 1.25.2 → 1.25.4-alpha.0

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/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ConversionDataType, OptionResource, SpiffCommerceClient, DesignCreationMessage, BundleDesignCreationMessage } from '@repo/core';
2
2
  export { ConversionDataType } from '@repo/core';
3
- import { Plugin } from 'vite';
3
+ import { ThemeInstallConfigurationGraphQl } from '@repo/types';
4
+ export { ThemeInstallConfigurationGraphQl } from '@repo/types';
4
5
 
5
6
  interface ThemeConfigurationFile {
6
7
  /**
@@ -55,7 +56,9 @@ declare enum FieldType {
55
56
  Object = "Object",
56
57
  Select = "Select",
57
58
  Text = "Text",
58
- DateRange = "DateRange"
59
+ DateRange = "DateRange",
60
+ ProductCollection = "ProductCollection",
61
+ MetafieldConfiguration = "MetafieldConfiguration"
59
62
  }
60
63
  interface ThemeConfigurationSchema {
61
64
  /**
@@ -85,8 +88,6 @@ interface ConfigurableField extends FieldBase {
85
88
  * Optional: A brief description of what the field might be used for. This is displayed beneath the field in the configuration form.
86
89
  */
87
90
  description?: string;
88
- }
89
- interface RequiredOption {
90
91
  /**
91
92
  * Optional: Set to `true` to require a value to be provided in the configuration form.
92
93
  */
@@ -108,24 +109,36 @@ interface LimitOption {
108
109
  */
109
110
  limit?: number;
110
111
  }
111
- interface GenericFieldBase extends ConfigurableField {
112
+ /**
113
+ * Generic fields which have no extra configuration and can accept default values from the Theme developer.
114
+ */
115
+ interface GenericField extends ConfigurableField, DefaultValueOption {
112
116
  type: FieldType.Boolean | FieldType.Color | FieldType.Number | FieldType.DateRange;
113
117
  }
114
- type GenericField = GenericFieldBase & RequiredOption & DefaultValueOption;
115
- interface AssetField extends ConfigurableField, RequiredOption {
118
+ declare enum AssetType {
119
+ Color = "Color",
120
+ ColorProfile = "ColorProfile",
121
+ Data = "Data",
122
+ Environment = "Environment",
123
+ Font = "Font",
124
+ Frame = "Frame",
125
+ Illustration = "Illustration",
126
+ Image = "Image",
127
+ Material = "Material",
128
+ Model = "Model",
129
+ Video = "Video"
130
+ }
131
+ interface AssetField extends ConfigurableField {
116
132
  /**
117
133
  * The type of asset, e.g. Image, Model, Font, etc.
118
134
  */
119
135
  assetType: AssetType;
120
136
  type: FieldType.Asset;
121
137
  }
122
- interface DateRangeField extends ConfigurableField {
123
- type: FieldType.DateRange;
124
- }
125
138
  interface ConversionConfigurationField extends ConfigurableField {
126
139
  type: FieldType.ConversionConfiguration;
127
140
  }
128
- interface SelectFieldBase extends ConfigurableField {
141
+ interface SelectField extends ConfigurableField, DefaultValueOption {
129
142
  /**
130
143
  * The options available for the Partner to select in the configuration form.
131
144
  */
@@ -141,15 +154,13 @@ interface SelectFieldBase extends ConfigurableField {
141
154
  }[];
142
155
  type: FieldType.Select;
143
156
  }
144
- type SelectField = SelectFieldBase & RequiredOption & DefaultValueOption;
145
- interface TextFieldBase extends ConfigurableField, LimitOption {
157
+ interface TextField extends ConfigurableField, LimitOption, DefaultValueOption {
146
158
  /**
147
159
  * Allows the Partner to configure the field in a multi-line text editor.
148
160
  */
149
161
  multiLine?: boolean;
150
162
  type: FieldType.Text;
151
163
  }
152
- type TextField = TextFieldBase & RequiredOption & DefaultValueOption;
153
164
  /**
154
165
  * Displays a heading in the Configuration Editor page in Hub.
155
166
  */
@@ -159,7 +170,7 @@ interface HeadingField extends FieldBase {
159
170
  /**
160
171
  * A list of one specific field type.
161
172
  */
162
- interface ListField extends ConfigurableField, RequiredOption, LimitOption {
173
+ interface ListField extends ConfigurableField, LimitOption {
163
174
  type: FieldType.List;
164
175
  /**
165
176
  * Defines the configuration schema for the entries in this list.
@@ -169,7 +180,7 @@ interface ListField extends ConfigurableField, RequiredOption, LimitOption {
169
180
  /**
170
181
  * A collection of any number of different fields.
171
182
  */
172
- interface ObjectField extends ConfigurableField, RequiredOption {
183
+ interface ObjectField extends ConfigurableField {
173
184
  type: FieldType.Object;
174
185
  /**
175
186
  * Defines the configuration schema for the fields in this object.
@@ -183,29 +194,36 @@ interface ObjectField extends ConfigurableField, RequiredOption {
183
194
  interface CustomObjectField extends Omit<ObjectField, "fields" | "schema"> {
184
195
  schema: string;
185
196
  }
197
+ interface ProductCollectionField extends ConfigurableField {
198
+ type: FieldType.ProductCollection;
199
+ }
200
+ declare enum MetafieldConfigurationEntityType {
201
+ Asset = "Asset",
202
+ Customer = "Customer",
203
+ Integration = "Integration",
204
+ Option = "Option",
205
+ Order = "Order",
206
+ Partner = "Partner",
207
+ Product = "Product",
208
+ ProductCollection = "ProductCollection",
209
+ Variant = "Variant",
210
+ Workflow = "Workflow",
211
+ WorkflowStep = "WorkflowStep"
212
+ }
213
+ interface MetafieldConfigurationField extends ConfigurableField {
214
+ type: FieldType.MetafieldConfiguration;
215
+ entityType: MetafieldConfigurationEntityType;
216
+ }
186
217
  /** https://stackoverflow.com/a/57103940/23523714 */
187
218
  type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
188
219
  /**
189
- * All fields that are configurable by a user in Hub.
220
+ * All field types that are configurable by a user in Hub.
190
221
  */
191
- type ThemeConfigurationConfigurableFields = GenericField | AssetField | DateRangeField | ConversionConfigurationField | SelectField | TextField | ListField | ObjectField | CustomObjectField;
222
+ type ThemeConfigurationConfigurableFields = GenericField | AssetField | ConversionConfigurationField | SelectField | TextField | ListField | ObjectField | CustomObjectField | ProductCollectionField | MetafieldConfigurationField;
192
223
  /**
193
- * All fields.
224
+ * All field types, including non-configurable ones.
194
225
  */
195
226
  type ThemeConfigurationSchemaField = ThemeConfigurationConfigurableFields | HeadingField;
196
- declare enum AssetType {
197
- Color = "Color",
198
- ColorProfile = "ColorProfile",
199
- Data = "Data",
200
- Environment = "Environment",
201
- Font = "Font",
202
- Frame = "Frame",
203
- Illustration = "Illustration",
204
- Image = "Image",
205
- Material = "Material",
206
- Model = "Model",
207
- Video = "Video"
208
- }
209
227
  declare enum CustomSchemaType {
210
228
  Object = "Object",
211
229
  Union = "Union"
@@ -367,11 +385,16 @@ interface ConversionConfiguration {
367
385
  interface ThemeInstallConfigurationFieldResource {
368
386
  key?: string;
369
387
  fallbackToDefaultConfiguration?: boolean;
370
- value?: string;
388
+ value?: string | null;
371
389
  type: FieldType;
372
- asset?: AssetResource;
373
- dateRange?: DateRange;
390
+ /** When the type is `Asset`, this will be the configured Asset resource. */
391
+ asset?: AssetResource | null;
392
+ /** When the type is `ConversionConfiguration`, this will be the configured ConversionConfiguration resource. */
374
393
  conversionConfiguration?: ConversionConfiguration;
394
+ /** When the type is `MetafieldConfiguration`, this will be the configured MetafieldConfiguration resource. */
395
+ metafieldConfiguration?: MetafieldConfigurationResource;
396
+ /** When the type is `ProductCollection`, this will be the configured ProductCollection resource. */
397
+ productCollection?: ProductCollectionResource;
375
398
  /** When the type is `List`, this will be the configured values */
376
399
  listValues?: ThemeInstallConfigurationFieldResource[];
377
400
  /** When the type is `Object`, this will be the configured field values */
@@ -389,9 +412,17 @@ interface AssetResource {
389
412
  fileLink: string;
390
413
  type: AssetType;
391
414
  }
392
- interface DateRange {
393
- start: Date;
394
- end: Date;
415
+ interface MetafieldConfigurationResource {
416
+ id: string;
417
+ name: string;
418
+ description: string | null;
419
+ metafieldType: string;
420
+ }
421
+ interface ProductCollectionResource {
422
+ id: string;
423
+ name: string;
424
+ description: string | null;
425
+ image: AssetResource | null;
395
426
  }
396
427
  /**
397
428
  * Maps a `ThemeInstallConfigurationResource`'s fields (which is essentially `{ key: string; value: string; }[]`), to the form `{ [key: string]: any }`.
@@ -533,9 +564,7 @@ type ThemeConfigurationSchemaFieldGraphQl = Omit<ThemeConfigurationSchemaFieldRe
533
564
  /** Whether this field is on the root. Otherwise this is a child. */
534
565
  root?: boolean | null;
535
566
  };
536
- type ThemeInstallConfigurationGraphQl = Omit<ThemeInstallConfigurationResource, "fields"> & {
537
- fields: ThemeInstallConfigurationFieldGraphQl[];
538
- };
567
+
539
568
  type ThemeInstallConfigurationFieldGraphQl = Omit<ThemeInstallConfigurationFieldResource, "listValues" | "objectValues"> & {
540
569
  /** When the type is `List`, this will be the indices of the configured values */
541
570
  listValues?: number[] | null;
@@ -553,33 +582,4 @@ declare function setSpiffDevOptions(container: HTMLElement | string, context: Sp
553
582
  declare function exampleThemeInstallConfig(opts?: Partial<ThemeInstallConfigurationResource>): ThemeInstallConfigurationResource;
554
583
  declare function getDefaultsForSchema(schema: ThemeConfigurationSchema, ...excludeKeys: string[]): ThemeInstallConfigurationFieldResource[];
555
584
 
556
- interface PluginOptions {
557
- /**
558
- * When `true`, will automatically insert files from the build into the `launchData.targetFiles` field.
559
- * @default true
560
- */
561
- autoGenerateTargetFiles?: boolean;
562
- /**
563
- * A configuration schema to allow installs to customize your theme.
564
- * @default undefined
565
- */
566
- configurationSchema?: ThemeConfigurationSchema;
567
- /**
568
- * Generates `targetFiles` entries with preload set to true. Only applies when `autoGenerateTargetFiles` is set to true.
569
- * By default this will only include the primary entry file(s).
570
- * @default false
571
- */
572
- includePreloadChunks?: boolean;
573
- /**
574
- * Manually add/override specific files.
575
- * @default undefined
576
- */
577
- targetFiles?: ThemeConfigurationLaunchDataTargetFile[];
578
- }
579
- /**
580
- * Automatically generates a `spiffTheme.json` file in your output directory.
581
- * @param opts Options to customize the generated file.
582
- */
583
- declare function spiffThemePlugin(opts?: PluginOptions): Plugin;
584
-
585
- export { type AssetResource, AssetType, type CompleteQuoteMessage, type ConversionConfiguration, type ConversionData, ConversionLocation, CustomSchemaType, type DateRange, FieldType, type SpiffDevOptions, type SpiffThemeLoader, type ThemeConfigurationConfigurableFields, type ThemeConfigurationFile, type ThemeConfigurationLaunchData, type ThemeConfigurationLaunchDataTargetFile, type ThemeConfigurationSchema, type ThemeConfigurationSchemaCustomSchema, type ThemeConfigurationSchemaCustomSchemaGraphQl, type ThemeConfigurationSchemaCustomSchemaResource, type ThemeConfigurationSchemaField, type ThemeConfigurationSchemaFieldGraphQl, type ThemeConfigurationSchemaFieldResource, type ThemeConfigurationSchemaGraphQl, type ThemeConfigurationSchemaResource, type ThemeContext, type ThemeContextBundle, type ThemeContextBundleOptions, type ThemeContextBundleOptionsExisting, type ThemeContextBundleOptionsNew, type ThemeContextTransaction, type ThemeContextWorkflowOptions, type ThemeContextWorkflowOptionsExternalProduct, type ThemeContextWorkflowOptionsIntegrationProduct, type ThemeContextWorkflowOptionsNewBase, type ThemeContextWorkflowOptionsTransaction, ThemeFileType, type ThemeInstallConfigurationField, type ThemeInstallConfigurationFieldGraphQl, type ThemeInstallConfigurationFieldResource, type ThemeInstallConfigurationGraphQl, type ThemeInstallConfigurationResource, type ThemeLaunchDataResource, type ThemeLaunchDataTargetFileResource, type ThemeResource, type ThemeVersionGraphQl, type ThemeVersionResource, exampleThemeInstallConfig, getDefaultsForSchema, setSpiffDevOptions, spiffThemePlugin, themeInstallConfigurationFieldsToRecordObject, themeInstallConfigurationGraphQlToResource, themeInstallConfigurationToRecordObject, themeVersionConfigurationGraphQlToResource, themeVersionGraphQlToResource };
585
+ export { type AssetResource, AssetType, type CompleteQuoteMessage, type ConversionConfiguration, type ConversionData, ConversionLocation, CustomSchemaType, FieldType, MetafieldConfigurationEntityType, type MetafieldConfigurationResource, type ProductCollectionResource, type SpiffDevOptions, type SpiffThemeLoader, type ThemeConfigurationConfigurableFields, type ThemeConfigurationFile, type ThemeConfigurationLaunchData, type ThemeConfigurationLaunchDataTargetFile, type ThemeConfigurationSchema, type ThemeConfigurationSchemaCustomSchema, type ThemeConfigurationSchemaCustomSchemaGraphQl, type ThemeConfigurationSchemaCustomSchemaResource, type ThemeConfigurationSchemaField, type ThemeConfigurationSchemaFieldGraphQl, type ThemeConfigurationSchemaFieldResource, type ThemeConfigurationSchemaGraphQl, type ThemeConfigurationSchemaResource, type ThemeContext, type ThemeContextBundle, type ThemeContextBundleOptions, type ThemeContextBundleOptionsExisting, type ThemeContextBundleOptionsNew, type ThemeContextTransaction, type ThemeContextWorkflowOptions, type ThemeContextWorkflowOptionsExternalProduct, type ThemeContextWorkflowOptionsIntegrationProduct, type ThemeContextWorkflowOptionsNewBase, type ThemeContextWorkflowOptionsTransaction, ThemeFileType, type ThemeInstallConfigurationField, type ThemeInstallConfigurationFieldGraphQl, type ThemeInstallConfigurationFieldResource, type ThemeInstallConfigurationResource, type ThemeLaunchDataResource, type ThemeLaunchDataTargetFileResource, type ThemeResource, type ThemeVersionGraphQl, type ThemeVersionResource, exampleThemeInstallConfig, getDefaultsForSchema, setSpiffDevOptions, themeInstallConfigurationFieldsToRecordObject, themeInstallConfigurationGraphQlToResource, themeInstallConfigurationToRecordObject, themeVersionConfigurationGraphQlToResource, themeVersionGraphQlToResource };