@shopfront/bridge 1.20.0 → 1.20.2

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.
@@ -1,7 +1,9 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <module type="WEB_MODULE" version="4">
3
3
  <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$" />
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/lib" />
6
+ </content>
5
7
  <orderEntry type="inheritedJdk" />
6
8
  <orderEntry type="sourceFolder" forTests="false" />
7
9
  </component>
package/.idea/modules.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <project version="4">
3
3
  <component name="ProjectModuleManager">
4
4
  <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/shopfront-embedded-bridge.iml" filepath="$PROJECT_DIR$/.idea/shopfront-embedded-bridge.iml" />
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/embedded-bridge.iml" filepath="$PROJECT_DIR$/.idea/embedded-bridge.iml" />
6
6
  </modules>
7
7
  </component>
8
8
  </project>
@@ -26,7 +26,13 @@ export interface OrderItem {
26
26
  image?: string;
27
27
  name: string;
28
28
  quantity: number;
29
- packSize: number;
29
+ packSize: number | {
30
+ id?: number;
31
+ barcode?: "auto" | number;
32
+ mdbId?: number;
33
+ supplierCodes?: number;
34
+ defaultTo: number;
35
+ };
30
36
  price: number;
31
37
  comment?: string;
32
38
  match?: OrderItemMatch;
@@ -125,7 +125,7 @@ export declare class CurrentSale extends BaseSale {
125
125
  */
126
126
  setMetaData(metaData: Record<string, unknown>): Promise<void>;
127
127
  /**
128
- * Update a product's details, currently this only updates the top-level meta data
128
+ * Update a product's details, currently this can update quantity, price and metadata
129
129
  * @param product
130
130
  */
131
131
  updateProduct(product: SaleProduct): Promise<void>;
@@ -196,15 +196,25 @@ class CurrentSale extends BaseSale_1.BaseSale {
196
196
  }));
197
197
  }
198
198
  /**
199
- * Update a product's details, currently this only updates the top-level meta data
199
+ * Update a product's details, currently this can update quantity, price and metadata
200
200
  * @param product
201
201
  */
202
202
  updateProduct(product) {
203
- return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("PRODUCT_UPDATE", {
203
+ const updateData = {
204
204
  id: product.getId(),
205
- indexAddress: product.getIndexAddress(),
206
- metaData: product.getMetaData(),
207
- }));
205
+ indexAddress: product.getIndexAddress()
206
+ };
207
+ if (product.wasQuantityModified()) {
208
+ updateData.quantity = product.getQuantity();
209
+ }
210
+ if (product.wasPriceModified()) {
211
+ updateData.price = product.getPrice();
212
+ }
213
+ if (product.wasMetaDataModified()) {
214
+ updateData.metaData = product.getMetaData();
215
+ }
216
+ product.clearModificationFlags();
217
+ return this.sendSaleUpdate(new SaleUpdate_1.SaleUpdate("PRODUCT_UPDATE", updateData));
208
218
  }
209
219
  }
210
220
  exports.CurrentSale = CurrentSale;
@@ -15,6 +15,9 @@ export declare class SaleProduct {
15
15
  protected promotions: ShopfrontSaleProductPromotions;
16
16
  protected metaData: Record<string, unknown>;
17
17
  protected mapped?: string;
18
+ protected quantityModified: boolean;
19
+ protected priceModified: boolean;
20
+ protected metaDataModified: boolean;
18
21
  constructor(id: string, quantity: number, price?: number, indexAddress?: Array<number>);
19
22
  /**
20
23
  * Hydrate a sale product from the SaleState.
@@ -58,11 +61,19 @@ export declare class SaleProduct {
58
61
  * @returns {number}
59
62
  */
60
63
  getQuantity(): number;
64
+ /**
65
+ * Sets the current sale quantity of the product
66
+ */
67
+ setQuantity(quantity: number): void;
61
68
  /**
62
69
  * Get the current price of the product.
63
70
  * @returns {number | undefined}
64
71
  */
65
72
  getPrice(): number | undefined;
73
+ /**
74
+ * Sets the current price of the product
75
+ */
76
+ setPrice(price: number): void;
66
77
  /**
67
78
  * Get the index address of the product.
68
79
  * This is the internal address of where the product is in the sale.
@@ -116,9 +127,9 @@ export declare class SaleProduct {
116
127
  */
117
128
  getCaseQuantity(): number | undefined;
118
129
  /**
119
- * Get the promotions for the product.
130
+ * Get the current active promotions for the product.
120
131
  *
121
- * @returns {Record<string, unknown>}
132
+ * @returns {ShopfrontSaleProductPromotions}
122
133
  */
123
134
  getPromotions(): ShopfrontSaleProductPromotions;
124
135
  /**
@@ -133,4 +144,28 @@ export declare class SaleProduct {
133
144
  * @param value
134
145
  */
135
146
  setMetaData(key: string, value: unknown): void;
147
+ /**
148
+ * Returns whether the product's quantity was modified externally
149
+ *
150
+ * @internal
151
+ */
152
+ wasQuantityModified(): boolean;
153
+ /**
154
+ * Returns whether the product's price was modified externally
155
+ *
156
+ * @internal
157
+ */
158
+ wasPriceModified(): boolean;
159
+ /**
160
+ * Returns whether the product's metaData was modified externally
161
+ *
162
+ * @internal
163
+ */
164
+ wasMetaDataModified(): boolean;
165
+ /**
166
+ * Sets a product's modification flags to false
167
+ *
168
+ * @internal
169
+ */
170
+ clearModificationFlags(): void;
136
171
  }
@@ -17,6 +17,9 @@ class SaleProduct {
17
17
  this.contains = [];
18
18
  this.edited = typeof price !== "undefined";
19
19
  this.note = "";
20
+ this.quantityModified = false;
21
+ this.priceModified = false;
22
+ this.metaDataModified = false;
20
23
  }
21
24
  /**
22
25
  * Hydrate a sale product from the SaleState.
@@ -88,6 +91,13 @@ class SaleProduct {
88
91
  getQuantity() {
89
92
  return this.quantity;
90
93
  }
94
+ /**
95
+ * Sets the current sale quantity of the product
96
+ */
97
+ setQuantity(quantity) {
98
+ this.quantity = quantity;
99
+ this.quantityModified = true;
100
+ }
91
101
  /**
92
102
  * Get the current price of the product.
93
103
  * @returns {number | undefined}
@@ -95,6 +105,13 @@ class SaleProduct {
95
105
  getPrice() {
96
106
  return this.price;
97
107
  }
108
+ /**
109
+ * Sets the current price of the product
110
+ */
111
+ setPrice(price) {
112
+ this.price = price;
113
+ this.priceModified = true;
114
+ }
98
115
  /**
99
116
  * Get the index address of the product.
100
117
  * This is the internal address of where the product is in the sale.
@@ -164,9 +181,9 @@ class SaleProduct {
164
181
  return this.caseQuantity;
165
182
  }
166
183
  /**
167
- * Get the promotions for the product.
184
+ * Get the current active promotions for the product.
168
185
  *
169
- * @returns {Record<string, unknown>}
186
+ * @returns {ShopfrontSaleProductPromotions}
170
187
  */
171
188
  getPromotions() {
172
189
  return this.promotions;
@@ -186,6 +203,41 @@ class SaleProduct {
186
203
  */
187
204
  setMetaData(key, value) {
188
205
  this.metaData[key] = value;
206
+ this.metaDataModified = true;
207
+ }
208
+ /**
209
+ * Returns whether the product's quantity was modified externally
210
+ *
211
+ * @internal
212
+ */
213
+ wasQuantityModified() {
214
+ return this.quantityModified;
215
+ }
216
+ /**
217
+ * Returns whether the product's price was modified externally
218
+ *
219
+ * @internal
220
+ */
221
+ wasPriceModified() {
222
+ return this.priceModified;
223
+ }
224
+ /**
225
+ * Returns whether the product's metaData was modified externally
226
+ *
227
+ * @internal
228
+ */
229
+ wasMetaDataModified() {
230
+ return this.metaDataModified;
231
+ }
232
+ /**
233
+ * Sets a product's modification flags to false
234
+ *
235
+ * @internal
236
+ */
237
+ clearModificationFlags() {
238
+ this.quantityModified = false;
239
+ this.priceModified = false;
240
+ this.metaDataModified = false;
189
241
  }
190
242
  }
191
243
  exports.SaleProduct = SaleProduct;
@@ -48,7 +48,9 @@ export interface SaleUpdateChanges {
48
48
  PRODUCT_UPDATE: {
49
49
  id: string;
50
50
  indexAddress: Array<number>;
51
- metaData: Record<string, unknown>;
51
+ quantity?: number;
52
+ price?: number;
53
+ metaData?: Record<string, unknown>;
52
54
  };
53
55
  }
54
56
  export declare class SaleUpdate<K extends keyof SaleUpdateChanges> extends BaseAction<SaleUpdate<K>> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopfront/bridge",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "main": "./lib/index.js",
5
5
  "license": "ISC",
6
6
  "description": "The bridge used to embed your application within Shopfront",
@@ -1,10 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <JSCodeStyleSettings version="0">
4
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
5
- </JSCodeStyleSettings>
6
- <TypeScriptCodeStyleSettings version="0">
7
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
8
- </TypeScriptCodeStyleSettings>
9
- </code_scheme>
10
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
- </state>
5
- </component>
@@ -1,15 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="GitToolBoxProjectSettings">
4
- <option name="commitMessageIssueKeyValidationOverride">
5
- <BoolValueOverride>
6
- <option name="enabled" value="true" />
7
- </BoolValueOverride>
8
- </option>
9
- <option name="commitMessageValidationEnabledOverride">
10
- <BoolValueOverride>
11
- <option name="enabled" value="true" />
12
- </BoolValueOverride>
13
- </option>
14
- </component>
15
- </project>