@spiffcommerce/core 21.0.0 → 21.0.2-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/CHANGELOG.md ADDED
@@ -0,0 +1,135 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [21.0.1] - 13-03-2024
9
+
10
+ ### Fixed
11
+
12
+ - Package now supplies this `CHANGELOG.md` in published releases.
13
+
14
+ ## [21.0.0] - 13-03-2024
15
+
16
+ ### Added
17
+
18
+ - `DesignCreationMessage` now has `quantity: number | undefined`.
19
+
20
+ ### Changed
21
+
22
+ - `Bundle.finish()` no longer returns an array of `DesignCreationMessage` objects, but instead returns a `BundleDesignCreationMessage` object which wraps the array of `DesignCreationMessage` entries.
23
+
24
+ ## [20.5.1] - 12-03-2024
25
+
26
+ ### Fixed
27
+
28
+ - `WorkflowExperience.getSelectionPriceSubunits()` (and consequently `getTotalPriceSubunits()`) can no longer return `NaN`.
29
+
30
+ ## [20.5.0] - 12-03-2024
31
+
32
+ ### Added
33
+
34
+ - `WorkflowManager.injectIntoPreviewService()` now has a second argument `refocusCamera`, a boolean which allows you to disable the automatic refocusing of the camera when the model is loaded. This requires `@spiffcommerce/preview@^5.7.0`.
35
+
36
+ ## [20.4.5] - 08-03-2024
37
+
38
+ ### Added
39
+
40
+ - `RenderableScene` objects will now contain a `workflowScene: WorkflowScene` field. This is only provided for backwards compatibility and is considered deprecated functionality.
41
+
42
+ ## [20.4.4] - 08-03-2024
43
+
44
+ ### Fixed
45
+
46
+ - Updating quantity via `WorkflowExperience.setQuantity()` will now correctly update on the server.
47
+
48
+ ## [20.4.3] - 08-03-2024
49
+
50
+ ### Changed
51
+
52
+ - `WorkflowExperience.setQuantity()` now returns a promise that resolves once the quantity has been updated on the server.
53
+
54
+ ## [20.4.0] - 08-03-2024
55
+
56
+ ### Added
57
+
58
+ - `Transaction` entities now have `quantity: number | undefined`.
59
+ - New functions on `WorkflowExperience` for managing quantity:
60
+ - `getQuantity()`: The amount that was, or will be, ordered of the underlying `Transaction`. This will default to `1` if the value is undefined. If you want to read the raw value, use `getWorkflowManager().getTransaction().quantity`.
61
+ - `setQuantity(<number>)`: Updates the quantity value on the underlying `Transaction` entity. Must be >= 1.
62
+ - New events functionality on `WorkflowExperience`. Currently the only event is `QuantityChanged`.
63
+ - `addEventListener(<type>, <callback>)`: Registers a callback function to be called when the specified event is raised. The associated `WorkflowExperience` is passed as a parameter to the callback function.
64
+ - `removeEventListener(<type>, <callback>)`: Removes a previously registered callback.
65
+
66
+ ## [20.3.0] - 07-03-2024
67
+
68
+ ### Added
69
+
70
+ - `CollectionProduct.getCurrentIntegration()`: returns the `IntegrationProductResource` associated with the product that is linked to the current Integration (resolved via the application key).
71
+
72
+ ## [20.2.2] - 05-03-2024
73
+
74
+ ### Changed
75
+
76
+ - `WorkflowExperience.getStepById(<string>)` now internally caches the `StepHandle` objects that it creates. This resolves an issue with functional rendering systems that re-render when the object reference changes, where they would re-renderer whenever this function was called even if the object was identical.
77
+
78
+ ## [20.2.1] - 29-02-2024
79
+
80
+ ### Changed
81
+
82
+ - The union type `GetWorkflowOptions` has some of its entries wrapped in another union. The types that will create a brand new `Transaction` are now nested under `GetNewWorkflowOptions`:
83
+ ```ts
84
+ // Before
85
+ export type GetWorkflowOptions = GetWorkflowFromTransactionOptions | GetWorkflowFromIntegrationProductOptions | GetWorkflowFromExternalProductOptions;
86
+
87
+ // After
88
+ export type GetNewWorkflowOptions = GetWorkflowFromIntegrationProductOptions | GetWorkflowFromExternalProductOptions;
89
+
90
+ export type GetWorkflowOptions = GetWorkflowFromTransactionOptions | GetNewWorkflowOptions;
91
+ ```
92
+ ## [20.2.0] - 29-02-2024
93
+
94
+ ### Added
95
+
96
+ - `SpiffCommerceClient.getIntegrationProduct(<options>)`: Fetches an `IntegrationProduct` object. Essentially a wrapper for the functions `getIntegrationProductById` and `getIntegrationProductFromExternalIds`. The options object type is as follows:
97
+ ```ts
98
+ {
99
+ type: "integration";
100
+ integrationProductId: string;
101
+ } | {
102
+ type: "external";
103
+ externalIntegrationId: string;
104
+ externalProductId: string;
105
+ }
106
+ ```
107
+
108
+ ## [20.1.0] - 23-02-2024
109
+
110
+ ### Added
111
+
112
+ - `IntegrationProduct.getAllWorkflows()`: Returns an array of `ProductWorkflow`, ordered by their internal `index` value (matches the order seen on the SpiffCommerce Hub).
113
+
114
+ ## [20.0.1] - 23-02-2024
115
+
116
+ ### Changed
117
+
118
+ - `StepHandle.executeAnimations()` now logs a warning to the console when the associated `WorkflowManager` is not associated with a `ThreeDPreviewService`.
119
+
120
+ ## [20.0.0] - 15-02-2024
121
+
122
+ ### Added
123
+
124
+ - Additional configuration options for GraphQL on bundles.
125
+ - A separate fetchProducts function on the ProductCollection interface.
126
+
127
+ ### Changed
128
+
129
+ - Removed async on getProducts call.
130
+
131
+ ### Removed
132
+
133
+ - Unused normalize.css file.
134
+ - Identical links assigned in each translation file.
135
+ - Duplicate index file for the english version.
package/README.md CHANGED
@@ -7,6 +7,6 @@ This is the Spiff Commerce Javascript client API.
7
7
  - The Client API manages the heavy lifting related to setting up, executing & finishing a workflow experience. It is a wrapper around the Workflow Manager,
8
8
  which is responsible for executing workflow steps and managing things like state and conditions.
9
9
 
10
- - Whilst the workflow manager is exposed we recommened getting started with a "Workflow Experience" instead.
10
+ - Whilst the workflow manager is exposed we recommend getting started with a "Workflow Experience" instead.
11
11
 
12
12
  ## Getting Started
package/dist/index.d.ts CHANGED
@@ -836,6 +836,28 @@ interface Product {
836
836
  * The Spiff SKU code for the product.
837
837
  */
838
838
  skuCode?: string;
839
+ /**
840
+ * Price breaks for this product when dealing with quantity.
841
+ */
842
+ priceBreaks?: ProductPriceBreak[];
843
+ }
844
+ /**
845
+ * A price break represents a minimum quantity of a product and the price that will be charged for that quantity.
846
+ * This can be seen as an override for the base price of the product.
847
+ */
848
+ interface ProductPriceBreak {
849
+ /**
850
+ * The id of this price breal.
851
+ */
852
+ id: string;
853
+ /**
854
+ * The minimum quantity of this price break. A positive integer.
855
+ */
856
+ minQty: number;
857
+ /**
858
+ * A percentage to apply to the overall price. A value between 0-1 where 1 retains 100% of the original price and 0 completely discounts it to free.
859
+ */
860
+ percentage: number;
839
861
  }
840
862
  interface ProductTag {
841
863
  id: string;
@@ -1422,6 +1444,14 @@ interface ExperienceOptions {
1422
1444
  * should get an instance of this class from a Client you have constructed previously.
1423
1445
  */
1424
1446
  interface WorkflowExperience {
1447
+ /**
1448
+ * Get the bundle this experience is part of. May be undefined.
1449
+ */
1450
+ getBundle(): Bundle | undefined;
1451
+ /**
1452
+ * Set the bundle this experience is part of. Can be cleared using undefined.
1453
+ */
1454
+ setBundle(bundle: Bundle | undefined): any;
1425
1455
  /**
1426
1456
  * Returns the client that was responsible for spawning this experience.
1427
1457
  */
@@ -1582,10 +1612,16 @@ declare class WorkflowExperienceImpl implements WorkflowExperience {
1582
1612
  readonly workflowManager: WorkflowManager;
1583
1613
  readonly isReadOnly: boolean;
1584
1614
  readonly cachedStepHandles: Map<string, StepHandle<any>>;
1615
+ /**
1616
+ * Bundle this experience has been added to.
1617
+ */
1618
+ private bundle?;
1585
1619
  private renderableScenes;
1586
1620
  private renderableSceneCallbacks;
1587
1621
  private eventCallbacks;
1588
1622
  constructor(client: SpiffCommerceClient, experienceOptions: ExperienceOptions);
1623
+ getBundle(): Bundle | undefined;
1624
+ setBundle(bundle: Bundle): void;
1589
1625
  getClient(): SpiffCommerceClient;
1590
1626
  getIsReadOnly(): boolean;
1591
1627
  getCommandContext(): CommandContext;
@@ -1598,6 +1634,7 @@ declare class WorkflowExperienceImpl implements WorkflowExperience {
1598
1634
  getBasePriceSubunits(includeAdditionalProduct?: boolean): number;
1599
1635
  getAdditionalProductPriceSubunits(): number | undefined;
1600
1636
  getTotalPriceSubunits(): number;
1637
+ private getPriceSubUnitsAfterPriceBreaks;
1601
1638
  copySelectionsViaGlobalConfiguration(bundle: Bundle, experience: WorkflowExperience, filter?: StepHandle<AnyStepData>[]): Promise<void>;
1602
1639
  getStepByName(name: string): TextStepHandle | FrameStepHandle | ShapeStepHandle | InformationStepHandle | IllustrationStepHandle | MaterialStepHandle | ModelStepHandle | PictureStepHandle | QuestionStepHandle | undefined;
1603
1640
  getStepsByType(type: StepType): StepHandle<AnyStepData>[];