@spiffcommerce/core 4.0.0 → 5.0.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/types.d.ts CHANGED
@@ -1308,6 +1308,53 @@ export const AdvancedEditor: FunctionComponent<{
1308
1308
  variationRecord: null | VariationRecord;
1309
1309
  workflow: _Workflow1;
1310
1310
  }>;
1311
+ /**
1312
+ * A wrapping component that provides a simple interface for interacting with a variant.
1313
+ */
1314
+ declare class Variant {
1315
+ constructor(variant: _VariantResource1);
1316
+ /**
1317
+ * @returns The unique identifier for the variant.
1318
+ */
1319
+ getId(): string;
1320
+ /**
1321
+ * @returns The configured name of the variant. Generally a human readable value.
1322
+ */
1323
+ getName(): string;
1324
+ /**
1325
+ * @returns The price modifier for this variant. This is the amount that will be added to the base price of the product.
1326
+ */
1327
+ getPriceFormatted(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions | undefined): string;
1328
+ /**
1329
+ * @returns The price modifier for this variant. This is the amount that will be added to the base price of the product.
1330
+ * Presented in subunits of the currency of the option. For example, if the option is configured to use USD, the price modifier will be in cents.
1331
+ */
1332
+ getPrice(): number;
1333
+ /**
1334
+ * @returns The URL for the base asset resource configured on this variant
1335
+ */
1336
+ getAsset(): string | undefined;
1337
+ /**
1338
+ * @returns The URL for a thumbnail resource configured on this variant. When no thumbnail is configured explicitly we fall back to the base asset and see if a thumbnail is genererated for that.
1339
+ */
1340
+ getThumbnail(): string | undefined;
1341
+ /**
1342
+ * @returns The URL for the display image configured on this variant. Can be used for things like size charts.
1343
+ */
1344
+ getDisplayImage(): string | undefined;
1345
+ /**
1346
+ * @returns When this variant is configured to have a color, this will return the hex value for that color.
1347
+ */
1348
+ getColor(): string | undefined;
1349
+ /**
1350
+ * @returns True when the variant is the default for its containing option. False otherwise.
1351
+ */
1352
+ isDefault(): boolean;
1353
+ /**
1354
+ * @returns The underlying variant resource. Generally not needed but made available just incase.
1355
+ */
1356
+ getResource(): _VariantResource1;
1357
+ }
1311
1358
  /**
1312
1359
  * A StepHandle allows for managing the state of a specific step in a workflow. This class
1313
1360
  * abstracts away the complexities of dealing with a step directly and allows for using high level
@@ -1336,18 +1383,18 @@ export abstract class StepHandle<T extends _AnyStepData1> {
1336
1383
  /**
1337
1384
  * Gets the currently selected variant, or undefined if no variant is selected.
1338
1385
  */
1339
- getCurrentVariant(): Promise<_VariantResource1>;
1386
+ getCurrentVariant(): Variant | undefined;
1340
1387
  /**
1341
1388
  * Returns a list of valid variants for this step.
1342
1389
  */
1343
- getAvailableVariants(): Promise<_VariantResource1[]>;
1390
+ getAvailableVariants(): Variant[];
1344
1391
  /**
1345
1392
  * Most step types have a base option type that variants can be selected for.
1346
1393
  * Selects a specific variant for this step. This will execute all required changes to
1347
1394
  * the design and update the metadata to include the new selection. Any conditions
1348
1395
  * that would be triggered will also be executed.
1349
1396
  */
1350
- abstract selectVariant(variant: _VariantResource1): Promise<void>;
1397
+ abstract selectVariant(variant: Variant): Promise<void>;
1351
1398
  /**
1352
1399
  * @returns A unique identifier for this step within the workflow.
1353
1400
  */
@@ -1399,7 +1446,7 @@ export class IllustrationStepHandle extends StepHandle<_IllustrationStepData1> {
1399
1446
  * @param variant The new vector variant to use for this step.
1400
1447
  * @returns A promise that can be awaited to know when the new vector asset has been updated on the design.
1401
1448
  */
1402
- selectVariant(variant: _VariantResource1): Promise<void>;
1449
+ selectVariant(variant: Variant): Promise<void>;
1403
1450
  /**
1404
1451
  * Get colors for the illustration.
1405
1452
  * @returns A list of color definitions that are currently applied to the illustration.
@@ -1415,7 +1462,7 @@ export class IllustrationStepHandle extends StepHandle<_IllustrationStepData1> {
1415
1462
  getAvailableColors(): Promise<{
1416
1463
  fill: string | undefined;
1417
1464
  stroke: string | undefined;
1418
- variant: _VariantResource1;
1465
+ variant: import("@spiffcommerce/papyrus").VariantResource;
1419
1466
  }[] | undefined>;
1420
1467
  hasVaryingSelection(): boolean | undefined;
1421
1468
  hasVaryingColors(): boolean | undefined;
@@ -1423,11 +1470,11 @@ export class IllustrationStepHandle extends StepHandle<_IllustrationStepData1> {
1423
1470
  }
1424
1471
  export class MaterialStepHandle extends StepHandle<_MaterialStepData1> {
1425
1472
  constructor(manager: WorkflowManager, step: _Step1<_MaterialStepData1>);
1426
- selectVariant(variant: _VariantResource1): Promise<void>;
1473
+ selectVariant(variant: Variant): Promise<void>;
1427
1474
  }
1428
1475
  export class ModelStepHandle extends StepHandle<_ModelStepData1> {
1429
1476
  constructor(manager: WorkflowManager, step: _Step1<_ModelStepData1>);
1430
- selectVariant(variant: _VariantResource1): Promise<void>;
1477
+ selectVariant(variant: Variant): Promise<void>;
1431
1478
  }
1432
1479
  export class PictureStepHandle extends StepHandle<_PictureStepData1> {
1433
1480
  constructor(manager: WorkflowManager, step: _Step1<_PictureStepData1>);
@@ -1436,11 +1483,11 @@ export class PictureStepHandle extends StepHandle<_PictureStepData1> {
1436
1483
  * @param variant The new image variant to use.
1437
1484
  * @returns A promise that can be awaited to ensure the new image asset has been updated on the design.
1438
1485
  */
1439
- selectVariant(variant: _VariantResource1): Promise<void>;
1486
+ selectVariant(variant: Variant): Promise<void>;
1440
1487
  }
1441
1488
  export class QuestionStepHandle extends StepHandle<_QuestionStepData1> {
1442
1489
  constructor(manager: WorkflowManager, step: _Step1<_QuestionStepData1>);
1443
- selectVariant(variant: _VariantResource1): Promise<void>;
1490
+ selectVariant(variant: Variant): Promise<void>;
1444
1491
  /**
1445
1492
  * The way that this step expects to be rendered.
1446
1493
  */
@@ -1448,7 +1495,7 @@ export class QuestionStepHandle extends StepHandle<_QuestionStepData1> {
1448
1495
  }
1449
1496
  export class ShapeStepHandle extends StepHandle<_ShapeStepData1> {
1450
1497
  constructor(manager: WorkflowManager, step: _Step1<_ShapeStepData1>);
1451
- selectVariant(_: _VariantResource1): Promise<void>;
1498
+ selectVariant(_: Variant): Promise<void>;
1452
1499
  /**
1453
1500
  * Sets the color of the shape.
1454
1501
  * @param color The color option to use.
@@ -1462,7 +1509,7 @@ export class ShapeStepHandle extends StepHandle<_ShapeStepData1> {
1462
1509
  getColors(): Promise<{
1463
1510
  fill: string | undefined;
1464
1511
  stroke: string | undefined;
1465
- variant: _VariantResource1;
1512
+ variant: import("@spiffcommerce/papyrus").VariantResource;
1466
1513
  }[]>;
1467
1514
  }
1468
1515
  interface TextChangeResult {
@@ -1476,7 +1523,7 @@ export class TextStepHandle extends StepHandle<_TextStepData1> {
1476
1523
  * Allows for select a font from the available fonts configured on this steps base option.
1477
1524
  * @param variant The font variant to use.
1478
1525
  */
1479
- selectVariant(variant: _VariantResource1): Promise<void>;
1526
+ selectVariant(variant: Variant): Promise<void>;
1480
1527
  /**
1481
1528
  * @returns A list of colors that can be used to fill the text.
1482
1529
  */
@@ -1877,7 +1924,7 @@ export enum FrameStep {
1877
1924
  }
1878
1925
  export class FrameStepHandle extends StepHandle<_FrameStepData1> {
1879
1926
  constructor(manager: WorkflowManager, step: _Step1<_FrameStepData1>);
1880
- selectVariant(variant: _VariantResource1): Promise<void>;
1927
+ selectVariant(variant: Variant): Promise<void>;
1881
1928
  onFrameDataChanged(callback: (frameData: _FrameData1) => void): void;
1882
1929
  selectImage(asset: _Asset1): void;
1883
1930
  getImageData(): PatternImageData | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "Core client API for interacting with the Spiff Commerce backend.",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",