@scayle/storefront-core 8.12.3 → 8.13.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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Expose `OrderStatus` and `OrderItem` interfaces from `order` types.
8
+ - Enhance the `OrderSummary` component by integrating the `OrderStatus` type
9
+ from the order `Order` interface. This update provides a more accurate and
10
+ detailed representation of the order status for users.
11
+ - Enhance order `detailedStatus` code type for `billing`, `order` and `shipping` properties and
12
+ expose `OrderStatusCode`, `BillingStatusCode` and `ShippingStatusCode`.
13
+
14
+ ### Patch Changes
15
+
16
+ - Added `fishery@>=2.2.3` as `peerDependencies`.
17
+
3
18
  ## 8.12.3
4
19
 
5
20
  ### Patch Changes
@@ -6,71 +6,7 @@ import type { Order } from '../types';
6
6
  *
7
7
  * @returns An array of unique order items.
8
8
  */
9
- export declare const getUniqueItemsFromOrder: (order: Order) => {
10
- id?: string;
11
- availableQuantity?: number;
12
- currency?: string;
13
- customData?: {
14
- [k: string]: unknown;
15
- };
16
- deliveryForecast?: import("../types").DeliveryForecastFromWarehouse;
17
- isManuallyReturnedByCci?: boolean;
18
- itemGroup?: null | {
19
- id: string;
20
- isMainItem: boolean;
21
- isRequired: boolean;
22
- };
23
- key: string;
24
- lowestPriorPrice?: null | {
25
- relativeDifferenceToPrice: number;
26
- withTax: import("@scayle/storefront-api/dist/shared/storefront-api.CrBb99Bp").C;
27
- };
28
- merchant?: {
29
- id: number;
30
- [k: string]: unknown;
31
- };
32
- packageId: import("../types").PackageReference;
33
- price: {
34
- appliedReductions?: {
35
- amount: {
36
- absoluteWithTax: import("@scayle/storefront-api/dist/shared/storefront-api.CrBb99Bp").C;
37
- relative: number;
38
- };
39
- category: "sale" | "campaign" | "voucher";
40
- code?: string;
41
- type: "relative" | "absolute";
42
- }[];
43
- overrideWithoutTax?: number;
44
- overrideWithTax?: number;
45
- reference?: {
46
- size?: string;
47
- unit?: string;
48
- withTax?: number;
49
- };
50
- tax: {
51
- [k: string]: {
52
- amount: number;
53
- rate: number;
54
- };
55
- };
56
- undiscountedWithOutTax?: number;
57
- undiscountedWithTax?: number;
58
- withoutTax: import("@scayle/storefront-api/dist/shared/storefront-api.CrBb99Bp").C;
59
- withTax: import("@scayle/storefront-api/dist/shared/storefront-api.CrBb99Bp").C;
60
- };
61
- product: {
62
- [k: string]: unknown;
63
- };
64
- reservationKey?: string;
65
- status: "available" | "cancelled" | "delivered" | "returned" | "unavailable";
66
- variant: {
67
- [k: string]: unknown;
68
- };
69
- warehouseId?: null | number;
70
- warehousePackageGroupId?: null | number;
71
- createdAt: string;
72
- updatedAt: string;
73
- }[] | undefined;
9
+ export declare const getUniqueItemsFromOrder: (order: Order) => import("../types").OrderItem[] | undefined;
74
10
  /**
75
11
  * Gets the quantity of a specific item in an order based on its variant ID.
76
12
  *
@@ -36,7 +36,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
36
36
  carrier,
37
37
  basketId: context.basketKey,
38
38
  campaignKey
39
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.12.3"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
39
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.13.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
40
40
  return {
41
41
  accessToken: refreshedAccessToken,
42
42
  checkoutJwt
@@ -1,3 +1,4 @@
1
+ import type { Gender } from '../user';
1
2
  import type { CentAmount } from './product';
2
3
  /**
3
4
  * Items are grouped by package, depending on the item's supplier configuration. The `packageId` references an entry in the packages list with delivery estimates and expected carrier.
@@ -99,6 +100,129 @@ export interface OrderForwardAddress {
99
100
  type?: OrderAddressRecipientType;
100
101
  };
101
102
  }
103
+ export type OrderStatus = 'order_open' | 'payment_pending' | 'payment_reserved' | 'invoice_completed' | 'cancellation_pending' | 'cancellation_completed' | 'invoice_partially_completed';
104
+ export type OrderStatusCode = 'order_created' | 'order_open' | 'order_pended' | 'order_confirmed' | 'order_delegated' | 'order_shipped' | 'order_invoiced' | 'order_aborted' | 'order_cancelled' | 'order_imported' | 'order_invoice_error';
105
+ export type BillingStatusCode = 'billing_open' | 'billing_pending' | 'billing_payment_pending' | 'billing_completed' | 'billing_payment_cancelled' | 'billing_partially_refunded' | 'billing_refunded';
106
+ export type ShippingStatusCode = 'shipping_open' | 'shipping_not_deliveable' | 'shipping_ordered' | 'shipping_delivered' | 'shipping_cancelled' | 'shipping_undeliverable' | 'shipping_returned' | 'shipping_partially_returned' | 'shipping_partially_undeliverable';
107
+ export interface OrderItem {
108
+ id?: string;
109
+ /**
110
+ * The number of deliverable items available in the warehouse for immediate shipping.
111
+ */
112
+ availableQuantity?: number;
113
+ /**
114
+ * The three character [ISO-4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code that identifies the currency. The currency is defined on the configuration of the shop, and can be modified in the cloud panel.
115
+ */
116
+ currency?: string;
117
+ /**
118
+ * customData allows the tenant to attach data to an item. The data will remain attached to the item from the basket through the process of order creation and delegation and may be displayed to the customer during the order lifecycle.
119
+ */
120
+ customData?: {
121
+ [k: string]: unknown;
122
+ };
123
+ deliveryForecast?: DeliveryForecastFromWarehouse;
124
+ /**
125
+ * Whether the return shipment got triggered manually. Is missing in case there is no return shipment.
126
+ */
127
+ isManuallyReturnedByCci?: boolean;
128
+ itemGroup?: null | {
129
+ /**
130
+ * Item group ID
131
+ */
132
+ id: string;
133
+ /**
134
+ * Specifies the main item in the group (true for only one item in a group)
135
+ */
136
+ isMainItem: boolean;
137
+ /**
138
+ * Specifies if the item is mandatory or optional
139
+ */
140
+ isRequired: boolean;
141
+ };
142
+ key: string;
143
+ lowestPriorPrice?: null | {
144
+ /**
145
+ * Difference to the current price
146
+ */
147
+ relativeDifferenceToPrice: number;
148
+ /**
149
+ * Lowest price including taxes
150
+ */
151
+ withTax: CentAmount;
152
+ };
153
+ /**
154
+ * the merchant id to which the item belongs.
155
+ */
156
+ merchant?: {
157
+ id: number;
158
+ [k: string]: unknown;
159
+ };
160
+ packageId: PackageReference;
161
+ /**
162
+ * The price is provided in a currency's lowest denomination (e.g. cent for EUR). In a multi-supplier environment, the price displayed on an item is dictated by the supplier order of preference, which is configured in the cloud panel.
163
+ */
164
+ price: {
165
+ /**
166
+ * The discounts detail the reductions included in the final `price.withTax` and `price.withoutTax` calculation.
167
+ */
168
+ appliedReductions?: {
169
+ amount: {
170
+ absoluteWithTax: CentAmount;
171
+ /**
172
+ * The `rate` is calculated on the basis of the reduction in relation to the `preDiscountPrice` price.
173
+ */
174
+ relative: number;
175
+ };
176
+ category: 'sale' | 'campaign' | 'voucher';
177
+ code?: string;
178
+ type: 'relative' | 'absolute';
179
+ }[];
180
+ overrideWithoutTax?: number;
181
+ overrideWithTax?: number;
182
+ reference?: {
183
+ size?: string;
184
+ unit?: string;
185
+ withTax?: number;
186
+ };
187
+ /**
188
+ * List of all taxes applied in calculating the `price.withTax`
189
+ */
190
+ tax: {
191
+ [k: string]: {
192
+ amount: number;
193
+ rate: number;
194
+ };
195
+ };
196
+ undiscountedWithOutTax?: number;
197
+ undiscountedWithTax?: number;
198
+ /**
199
+ * This price excludes taxes, but also includes all applicable reductions.
200
+ */
201
+ withoutTax: CentAmount;
202
+ /**
203
+ * The price is calculated including taxes and all applicable reductions such as discounts for sale and campaigns (should a campaign key be provided on the request).
204
+ */
205
+ withTax: CentAmount;
206
+ };
207
+ product: {
208
+ [k: string]: unknown;
209
+ };
210
+ /**
211
+ * Reference set in the checkout when an item was reserved successfully.
212
+ */
213
+ reservationKey?: string;
214
+ status: 'available' | 'cancelled' | 'delivered' | 'undeliverable' | 'returned' | 'unavailable';
215
+ variant: {
216
+ [k: string]: unknown;
217
+ };
218
+ /**
219
+ * The warehouse id where the item are being picking from.
220
+ */
221
+ warehouseId?: null | number;
222
+ warehousePackageGroupId?: null | number;
223
+ createdAt: string;
224
+ updatedAt: string;
225
+ }
102
226
  export interface Order {
103
227
  /**
104
228
  * The `id` can be applied as a parameter on the url to retrieve an individual order in the [Fetch Order by ID](#fetch-order-by-id) endpoint.
@@ -220,7 +344,7 @@ export interface Order {
220
344
  };
221
345
  email?: string;
222
346
  firstName?: string;
223
- gender?: 'm' | 'f' | 'd';
347
+ gender?: Gender;
224
348
  groups?: string[];
225
349
  ipAddress?: string;
226
350
  lastName: string;
@@ -245,143 +369,25 @@ export interface Order {
245
369
  updatedAt: string;
246
370
  };
247
371
  detailedStatus: {
248
- billing: {
249
- code: string;
372
+ order: {
373
+ code: OrderStatusCode;
250
374
  name: string;
251
375
  [k: string]: unknown;
252
376
  };
253
- order: {
254
- code: string;
377
+ billing: {
378
+ code: BillingStatusCode;
255
379
  name: string;
256
380
  [k: string]: unknown;
257
381
  };
258
382
  shipping: {
259
- code: string;
383
+ code: ShippingStatusCode;
260
384
  name: string;
261
385
  [k: string]: unknown;
262
386
  };
263
387
  [k: string]: unknown;
264
388
  };
265
389
  invoicedAt?: string;
266
- items?: {
267
- id?: string;
268
- /**
269
- * The number of deliverable items available in the warehouse for immediate shipping.
270
- */
271
- availableQuantity?: number;
272
- /**
273
- * The three character [ISO-4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code that identifies the currency. The currency is defined on the configuration of the shop, and can be modified in the cloud panel.
274
- */
275
- currency?: string;
276
- /**
277
- * customData allows the tenant to attach data to an item. The data will remain attached to the item from the basket through the process of order creation and delegation and may be displayed to the customer during the order lifecycle.
278
- */
279
- customData?: {
280
- [k: string]: unknown;
281
- };
282
- deliveryForecast?: DeliveryForecastFromWarehouse;
283
- /**
284
- * Whether the return shipment got triggered manually. Is missing in case there is no return shipment.
285
- */
286
- isManuallyReturnedByCci?: boolean;
287
- itemGroup?: null | {
288
- /**
289
- * Item group ID
290
- */
291
- id: string;
292
- /**
293
- * Specifies the main item in the group (true for only one item in a group)
294
- */
295
- isMainItem: boolean;
296
- /**
297
- * Specifies if the item is mandatory or optional
298
- */
299
- isRequired: boolean;
300
- };
301
- key: string;
302
- lowestPriorPrice?: null | {
303
- /**
304
- * Difference to the current price
305
- */
306
- relativeDifferenceToPrice: number;
307
- /**
308
- * Lowest price including taxes
309
- */
310
- withTax: CentAmount;
311
- };
312
- /**
313
- * the merchant id to which the item belongs.
314
- */
315
- merchant?: {
316
- id: number;
317
- [k: string]: unknown;
318
- };
319
- packageId: PackageReference;
320
- /**
321
- * The price is provided in a currency's lowest denomination (e.g. cent for EUR). In a multi-supplier environment, the price displayed on an item is dictated by the supplier order of preference, which is configured in the cloud panel.
322
- */
323
- price: {
324
- /**
325
- * The discounts detail the reductions included in the final `price.withTax` and `price.withoutTax` calculation.
326
- */
327
- appliedReductions?: {
328
- amount: {
329
- absoluteWithTax: CentAmount;
330
- /**
331
- * The `rate` is calculated on the basis of the reduction in relation to the `preDiscountPrice` price.
332
- */
333
- relative: number;
334
- };
335
- category: 'sale' | 'campaign' | 'voucher';
336
- code?: string;
337
- type: 'relative' | 'absolute';
338
- }[];
339
- overrideWithoutTax?: number;
340
- overrideWithTax?: number;
341
- reference?: {
342
- size?: string;
343
- unit?: string;
344
- withTax?: number;
345
- };
346
- /**
347
- * List of all taxes applied in calculating the `price.withTax`
348
- */
349
- tax: {
350
- [k: string]: {
351
- amount: number;
352
- rate: number;
353
- };
354
- };
355
- undiscountedWithOutTax?: number;
356
- undiscountedWithTax?: number;
357
- /**
358
- * This price excludes taxes, but also includes all applicable reductions.
359
- */
360
- withoutTax: CentAmount;
361
- /**
362
- * The price is calculated including taxes and all applicable reductions such as discounts for sale and campaigns (should a campaign key be provided on the request).
363
- */
364
- withTax: CentAmount;
365
- };
366
- product: {
367
- [k: string]: unknown;
368
- };
369
- /**
370
- * Reference set in the checkout when an item was reserved successfully.
371
- */
372
- reservationKey?: string;
373
- status: 'available' | 'cancelled' | 'delivered' | 'returned' | 'unavailable';
374
- variant: {
375
- [k: string]: unknown;
376
- };
377
- /**
378
- * The warehouse id where the item are being picking from.
379
- */
380
- warehouseId?: null | number;
381
- warehousePackageGroupId?: null | number;
382
- createdAt: string;
383
- updatedAt: string;
384
- }[];
390
+ items?: OrderItem[];
385
391
  loyaltyCard?: {
386
392
  cardNumber?: string;
387
393
  points: number;
@@ -436,7 +442,7 @@ export interface Order {
436
442
  */
437
443
  language: string;
438
444
  };
439
- status: 'order_open' | 'payment_pending' | 'payment_reserved' | 'invoice_completed' | 'cancellation_pending' | 'cancellation_completed' | 'invoice_partially_completed';
445
+ status: OrderStatus;
440
446
  vouchers?: {
441
447
  id: number;
442
448
  applicableItems?: {
@@ -1,4 +1,5 @@
1
1
  import type { UseBasketParams } from './sapi/basket';
2
+ import type { OrderStatus } from './sapi/order';
2
3
  import type { UseWishlistParams } from './sapi/wishlist';
3
4
  /**
4
5
  * Represents the gender of a user.
@@ -64,7 +65,7 @@ export interface OrderSummary {
64
65
  /** The ID of the shop associated with the order. */
65
66
  shopId: number;
66
67
  /** The current status of the order. */
67
- status?: string;
68
+ status?: OrderStatus;
68
69
  }
69
70
  /**
70
71
  * Represents the status of a shop user.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "8.12.3",
3
+ "version": "8.13.0",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -8,6 +8,9 @@
8
8
  "access": "public",
9
9
  "registry": "https://registry.npmjs.org/"
10
10
  },
11
+ "repository": {
12
+ "url": "git+https://github.com/scayle/storefront-core.git"
13
+ },
11
14
  "website": "https://scayle.dev/en/storefront-guide/developer-guide/getting-started/about-storefront",
12
15
  "sideEffects": false,
13
16
  "exports": {
@@ -55,6 +58,9 @@
55
58
  "test": "vitest --run --passWithNoTests",
56
59
  "test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit --outputFile=./coverage/junit.xml"
57
60
  },
61
+ "peerDependencies": {
62
+ "fishery": "^2.2.3"
63
+ },
58
64
  "dependencies": {
59
65
  "@scayle/storefront-api": "18.1.0",
60
66
  "@scayle/unstorage-scayle-kv-driver": "0.1.1",
@@ -69,12 +75,13 @@
69
75
  "devDependencies": {
70
76
  "@scayle/eslint-config-storefront": "4.4.1",
71
77
  "@types/crypto-js": "4.2.2",
72
- "@types/node": "22.13.9",
78
+ "@types/node": "22.13.10",
73
79
  "@types/webpack-env": "1.18.8",
74
80
  "@vitest/coverage-v8": "2.1.9",
75
81
  "dprint": "0.49.0",
76
- "eslint": "9.21.0",
82
+ "eslint": "9.22.0",
77
83
  "eslint-formatter-gitlab": "5.1.0",
84
+ "fishery": "2.2.3",
78
85
  "publint": "0.2.12",
79
86
  "rimraf": "6.0.1",
80
87
  "typescript": "5.8.2",