@reactionary/provider-commercetools 0.2.19 → 0.3.1

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/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@reactionary/provider-commercetools",
3
- "version": "0.2.19",
3
+ "version": "0.3.1",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
7
- "@reactionary/core": "0.2.19",
7
+ "@reactionary/core": "0.3.1",
8
8
  "debug": "^4.4.3",
9
9
  "zod": "4.1.9",
10
10
  "@commercetools/ts-client": "^4.2.1",
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import {
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import {
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import {
@@ -440,12 +441,17 @@ class CommercetoolsCheckoutProvider extends CheckoutProvider {
440
441
  return result;
441
442
  }
442
443
  isReadyForFinalization(price, paymentInstructions, billingAddress, shippingAddress, shippingInstruction) {
443
- if (!billingAddress) return false;
444
- if (!shippingInstruction) return false;
445
- if (!shippingAddress && !shippingInstruction.pickupPoint) return false;
446
- if (paymentInstructions.length === 0) return false;
444
+ if (!billingAddress)
445
+ return false;
446
+ if (!shippingInstruction)
447
+ return false;
448
+ if (!shippingAddress && !shippingInstruction.pickupPoint)
449
+ return false;
450
+ if (paymentInstructions.length === 0)
451
+ return false;
447
452
  const authorizedPayments = paymentInstructions.filter((pi) => pi.status === "authorized").map((x) => x.amount.value).reduce((a, b) => a + b, 0);
448
- if (price.grandTotal.value !== authorizedPayments) return false;
453
+ if (price.grandTotal.value !== authorizedPayments)
454
+ return false;
449
455
  return true;
450
456
  }
451
457
  parsePaymentInstruction(remote) {
@@ -502,7 +508,8 @@ class CommercetoolsCheckoutProvider extends CheckoutProvider {
502
508
  };
503
509
  }
504
510
  parseShippingInstruction(remote) {
505
- if (!remote.shippingInfo) return void 0;
511
+ if (!remote.shippingInfo)
512
+ return void 0;
506
513
  const instructions = remote.custom?.fields["shippingInstruction"] || "";
507
514
  const consentForUnattendedDelivery = remote.custom?.fields["consentForUnattendedDelivery"] === "true" || false;
508
515
  const pickupPoint = remote.custom?.fields["pickupPointId"] || "";
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import {
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import { InventoryProvider, InventoryQueryBySKUSchema, InventorySchema, Reactionary, success, error } from "@reactionary/core";
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import {
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import { OrderProvider, OrderQueryByIdSchema, OrderSchema, Reactionary, success, error } from "@reactionary/core";
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import {
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import {
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import {
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import {
@@ -162,10 +163,7 @@ class CommercetoolsProfileProvider extends ProfileProvider {
162
163
  if (addressToMakeDefault.id === customer.defaultBillingAddressId) {
163
164
  return error({
164
165
  type: "InvalidInput",
165
- error: {
166
- field: "addressIdentifier",
167
- message: "Cannot set shipping address as default billing address"
168
- }
166
+ error: "Cannot set shipping address as default billing address"
169
167
  });
170
168
  }
171
169
  const updateResponse = await client.me().post({
@@ -5,7 +5,8 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
8
+ if (kind && result)
9
+ __defProp(target, key, result);
9
10
  return result;
10
11
  };
11
12
  import { Reactionary, StoreProvider, StoreQueryByProximitySchema, StoreSchema, success, error } from "@reactionary/core";
@@ -33,46 +33,14 @@ export declare class CommercetoolsCategoryProvider extends CategoryProvider {
33
33
  pageSize: number;
34
34
  totalCount: number;
35
35
  totalPages: number;
36
- items: {
37
- identifier: {
38
- key: string;
39
- };
40
- name: string;
41
- slug: string;
42
- text: string;
43
- images: {
44
- sourceUrl: string;
45
- altText: string;
46
- width: number;
47
- height: number;
48
- }[];
49
- parentCategory?: {
50
- key: string;
51
- } | undefined;
52
- }[];
36
+ items: Category[];
53
37
  }>>;
54
38
  findTopCategories(payload: CategoryQueryForTopCategories): Promise<import("@reactionary/core").Ok<{
55
39
  pageNumber: number;
56
40
  pageSize: number;
57
41
  totalCount: number;
58
42
  totalPages: number;
59
- items: {
60
- identifier: {
61
- key: string;
62
- };
63
- name: string;
64
- slug: string;
65
- text: string;
66
- images: {
67
- sourceUrl: string;
68
- altText: string;
69
- width: number;
70
- height: number;
71
- }[];
72
- parentCategory?: {
73
- key: string;
74
- } | undefined;
75
- }[];
43
+ items: Category[];
76
44
  }>>;
77
45
  /**
78
46
  * Handler for parsing a response from a remote provider and converting it
@@ -84,22 +52,6 @@ export declare class CommercetoolsCategoryProvider extends CategoryProvider {
84
52
  pageSize: number;
85
53
  totalCount: number;
86
54
  totalPages: number;
87
- items: {
88
- identifier: {
89
- key: string;
90
- };
91
- name: string;
92
- slug: string;
93
- text: string;
94
- images: {
95
- sourceUrl: string;
96
- altText: string;
97
- width: number;
98
- height: number;
99
- }[];
100
- parentCategory?: {
101
- key: string;
102
- } | undefined;
103
- }[];
55
+ items: Category[];
104
56
  };
105
57
  }
@@ -1,5 +1,5 @@
1
- import type { RequestContext, Cache, OrderSearchQueryByTerm, OrderSearchResult, Result } from '@reactionary/core';
2
- import { OrderSearchProvider } from '@reactionary/core';
1
+ import type { RequestContext, Cache, OrderSearchQueryByTerm, OrderSearchResult, Result, MonetaryAmount, IdentityIdentifier } from '@reactionary/core';
2
+ import { OrderSearchProvider, type OrderSearchResultItem } from '@reactionary/core';
3
3
  import type { CommercetoolsConfiguration } from '../schema/configuration.schema.js';
4
4
  import type { CommercetoolsAPI } from '../core/client.js';
5
5
  import type { Order as CTOrder, Address as CTAddress, OrderPagedQueryResponse } from '@commercetools/platform-sdk';
@@ -26,9 +26,7 @@ export declare class CommercetoolsOrderSearchProvider extends OrderSearchProvide
26
26
  identifier: {
27
27
  key: string;
28
28
  };
29
- userId: {
30
- userId: string;
31
- };
29
+ userId: IdentityIdentifier;
32
30
  customerName: string;
33
31
  shippingAddress: {
34
32
  countryCode: string;
@@ -46,10 +44,7 @@ export declare class CommercetoolsOrderSearchProvider extends OrderSearchProvide
46
44
  orderDate: string;
47
45
  orderStatus: "AwaitingPayment" | "ReleasedToFulfillment" | "Shipped";
48
46
  inventoryStatus: "NotAllocated" | "Allocated";
49
- totalAmount: {
50
- value: number;
51
- currency: "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BOV" | "BRL" | "BSD" | "BTN" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CHE" | "CHF" | "CHW" | "CLF" | "CLP" | "CNY" | "COP" | "COU" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MKD" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MXV" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLE" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TVD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "USN" | "UYI" | "UYU" | "UYW" | "UZS" | "VED" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XAG" | "XAU" | "XBA" | "XBB" | "XBC" | "XBD" | "XCD" | "XDR" | "XOF" | "XPD" | "XPF" | "XPT" | "XSU" | "XTS" | "XUA" | "XXX" | "YER" | "ZAR" | "ZMW" | "ZWL";
52
- };
47
+ totalAmount: MonetaryAmount;
53
48
  };
54
49
  protected parsePaginatedResult(body: OrderPagedQueryResponse, query: OrderSearchQueryByTerm): {
55
50
  identifier: {
@@ -71,34 +66,6 @@ export declare class CommercetoolsOrderSearchProvider extends OrderSearchProvide
71
66
  pageSize: number;
72
67
  totalCount: number;
73
68
  totalPages: number;
74
- items: {
75
- identifier: {
76
- key: string;
77
- };
78
- userId: {
79
- userId: string;
80
- };
81
- customerName: string;
82
- orderDate: string;
83
- orderStatus: "AwaitingPayment" | "ReleasedToFulfillment" | "Shipped" | "Cancelled";
84
- inventoryStatus: "NotAllocated" | "Allocated" | "Backordered" | "Preordered";
85
- totalAmount: {
86
- value: number;
87
- currency: "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BOV" | "BRL" | "BSD" | "BTN" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CHE" | "CHF" | "CHW" | "CLF" | "CLP" | "CNY" | "COP" | "COU" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MKD" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MXV" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLE" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TVD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "USN" | "UYI" | "UYU" | "UYW" | "UZS" | "VED" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XAG" | "XAU" | "XBA" | "XBB" | "XBC" | "XBD" | "XCD" | "XDR" | "XOF" | "XPD" | "XPF" | "XPT" | "XSU" | "XTS" | "XUA" | "XXX" | "YER" | "ZAR" | "ZMW" | "ZWL";
88
- };
89
- shippingAddress?: {
90
- identifier: {
91
- nickName: string;
92
- };
93
- firstName: string;
94
- lastName: string;
95
- streetAddress: string;
96
- streetNumber: string;
97
- city: string;
98
- region: string;
99
- postalCode: string;
100
- countryCode: string;
101
- } | undefined;
102
- }[];
69
+ items: OrderSearchResultItem[];
103
70
  };
104
71
  }
@@ -1,5 +1,5 @@
1
1
  import type { ProductSearchFacetResult as CTProductSearchFacetResult, ProductVariant as CTProductVariant, ProductPagedSearchResponse, ProductProjection, ProductSearchFacetExpression } from '@commercetools/platform-sdk';
2
- import type { Cache, FacetIdentifier, FacetValueIdentifier, ProductSearchQueryByTerm, ProductSearchQueryCreateNavigationFilter, ProductSearchResult, ProductSearchResultFacet, ProductSearchResultFacetValue, ProductSearchResultItemVariant, RequestContext, Result } from '@reactionary/core';
2
+ import type { Cache, FacetIdentifier, FacetValueIdentifier, ProductSearchQueryByTerm, ProductSearchQueryCreateNavigationFilter, ProductSearchResult, ProductSearchResultFacet, ProductSearchResultFacetValue, ProductSearchResultItem, ProductSearchResultItemVariant, RequestContext, Result } from '@reactionary/core';
3
3
  import { ProductSearchProvider } from '@reactionary/core';
4
4
  import type { CommercetoolsConfiguration } from '../schema/configuration.schema.js';
5
5
  import type { CommercetoolsAPI } from '../core/client.js';
@@ -83,32 +83,7 @@ export declare class CommercetoolsSearchProvider extends ProductSearchProvider {
83
83
  };
84
84
  name: string;
85
85
  slug: string;
86
- variants: {
87
- variant: {
88
- sku: string;
89
- };
90
- image: {
91
- sourceUrl: string;
92
- altText: string;
93
- width?: number | undefined;
94
- height?: number | undefined;
95
- };
96
- options?: {
97
- identifier: {
98
- key: string;
99
- };
100
- name: string;
101
- value: {
102
- identifier: {
103
- option: {
104
- key: string;
105
- };
106
- key: string;
107
- };
108
- label: string;
109
- };
110
- } | undefined;
111
- }[];
86
+ variants: ProductSearchResultItemVariant[];
112
87
  };
113
88
  protected parsePaginatedResult(body: ProductPagedSearchResponse, query: ProductSearchQueryByTerm): {
114
89
  identifier: {
@@ -135,56 +110,8 @@ export declare class CommercetoolsSearchProvider extends ProductSearchProvider {
135
110
  pageSize: number;
136
111
  totalCount: number;
137
112
  totalPages: number;
138
- items: {
139
- identifier: {
140
- key: string;
141
- };
142
- name: string;
143
- slug: string;
144
- variants: {
145
- variant: {
146
- sku: string;
147
- };
148
- image: {
149
- sourceUrl: string;
150
- altText: string;
151
- width?: number | undefined;
152
- height?: number | undefined;
153
- };
154
- options?: {
155
- identifier: {
156
- key: string;
157
- };
158
- name: string;
159
- value: {
160
- identifier: {
161
- option: {
162
- key: string;
163
- };
164
- key: string;
165
- };
166
- label: string;
167
- };
168
- } | undefined;
169
- }[];
170
- }[];
171
- facets: {
172
- identifier: {
173
- key: string;
174
- };
175
- name: string;
176
- values: {
177
- identifier: {
178
- facet: {
179
- key: string;
180
- };
181
- key: string;
182
- };
183
- name: string;
184
- count: number;
185
- active: boolean;
186
- }[];
187
- }[];
113
+ items: ProductSearchResultItem[];
114
+ facets: ProductSearchResultFacet[];
188
115
  };
189
116
  /**
190
117
  * See version 0.0.81 for ProductProjection based facet parsing
@@ -2,9 +2,9 @@ import type { z } from 'zod';
2
2
  export declare const CommercetoolsCapabilitiesSchema: z.ZodObject<{
3
3
  price: z.ZodOptional<z.ZodBoolean>;
4
4
  product: z.ZodOptional<z.ZodBoolean>;
5
+ order: z.ZodOptional<z.ZodBoolean>;
5
6
  cart: z.ZodOptional<z.ZodBoolean>;
6
7
  checkout: z.ZodOptional<z.ZodBoolean>;
7
- order: z.ZodOptional<z.ZodBoolean>;
8
8
  identity: z.ZodOptional<z.ZodBoolean>;
9
9
  inventory: z.ZodOptional<z.ZodBoolean>;
10
10
  category: z.ZodOptional<z.ZodBoolean>;