@reactionary/provider-commercetools 0.0.73 → 0.0.74
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.0.
|
|
3
|
+
"version": "0.0.74",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@reactionary/core": "0.0.
|
|
7
|
+
"@reactionary/core": "0.0.74",
|
|
8
8
|
"debug": "^4.4.3",
|
|
9
9
|
"zod": "4.1.9",
|
|
10
10
|
"@commercetools/ts-client": "^4.2.1",
|
|
@@ -106,61 +106,6 @@ class CommercetoolsCartProvider extends CartProvider {
|
|
|
106
106
|
const activeCartId = await this.getActiveCartId();
|
|
107
107
|
return this.getById({ cart: activeCartId });
|
|
108
108
|
}
|
|
109
|
-
async setShippingInfo(payload) {
|
|
110
|
-
const client = await this.getClient();
|
|
111
|
-
const ctId = payload.cart;
|
|
112
|
-
const actions = new Array();
|
|
113
|
-
if (payload.shippingMethod) {
|
|
114
|
-
actions.push({
|
|
115
|
-
action: "setShippingMethod",
|
|
116
|
-
shippingMethod: {
|
|
117
|
-
typeId: "shipping-method",
|
|
118
|
-
id: payload.shippingMethod.key
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
if (payload.shippingAddress) {
|
|
123
|
-
actions.push({
|
|
124
|
-
action: "setShippingAddress",
|
|
125
|
-
address: {
|
|
126
|
-
country: payload.shippingAddress.countryCode || this.context.taxJurisdiction.countryCode || "US",
|
|
127
|
-
firstName: payload.shippingAddress.firstName,
|
|
128
|
-
lastName: payload.shippingAddress.lastName,
|
|
129
|
-
city: payload.shippingAddress.city,
|
|
130
|
-
postalCode: payload.shippingAddress.postalCode,
|
|
131
|
-
streetName: payload.shippingAddress.streetAddress,
|
|
132
|
-
streetNumber: payload.shippingAddress.streetNumber
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
return this.applyActions(payload.cart, actions);
|
|
137
|
-
}
|
|
138
|
-
setBillingAddress(payload) {
|
|
139
|
-
return this.applyActions(payload.cart, [
|
|
140
|
-
{
|
|
141
|
-
action: "setBillingAddress",
|
|
142
|
-
address: {
|
|
143
|
-
email: payload.notificationEmailAddress,
|
|
144
|
-
mobile: payload.notificationPhoneNumber,
|
|
145
|
-
country: payload.billingAddress.countryCode || this.context.taxJurisdiction.countryCode || "US",
|
|
146
|
-
firstName: payload.billingAddress.firstName,
|
|
147
|
-
lastName: payload.billingAddress.lastName,
|
|
148
|
-
city: payload.billingAddress.city,
|
|
149
|
-
postalCode: payload.billingAddress.postalCode,
|
|
150
|
-
streetName: payload.billingAddress.streetAddress,
|
|
151
|
-
streetNumber: payload.billingAddress.streetNumber
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
action: "setCustomerEmail",
|
|
156
|
-
email: payload.notificationEmailAddress
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
action: "setCountry",
|
|
160
|
-
country: payload.billingAddress.countryCode || this.context.taxJurisdiction.countryCode || "US"
|
|
161
|
-
}
|
|
162
|
-
]);
|
|
163
|
-
}
|
|
164
109
|
applyCouponCode(payload) {
|
|
165
110
|
return this.applyActions(payload.cart, [
|
|
166
111
|
{
|
|
@@ -186,20 +131,6 @@ class CommercetoolsCartProvider extends CartProvider {
|
|
|
186
131
|
}
|
|
187
132
|
]);
|
|
188
133
|
}
|
|
189
|
-
async checkout(payload) {
|
|
190
|
-
const client = await this.getClient();
|
|
191
|
-
const ctId = payload.cart;
|
|
192
|
-
const orderResponse = await client.orders.post({
|
|
193
|
-
body: {
|
|
194
|
-
version: ctId.version,
|
|
195
|
-
id: ctId.key
|
|
196
|
-
}
|
|
197
|
-
}).execute();
|
|
198
|
-
return CommercetoolsOrderIdentifierSchema.parse({
|
|
199
|
-
key: orderResponse.body.id,
|
|
200
|
-
version: orderResponse.body.version || 0
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
134
|
async changeCurrency(payload) {
|
|
204
135
|
const client = await this.getClient();
|
|
205
136
|
const currentCart = await client.carts.withId({ ID: payload.cart.key }).get().execute();
|
|
@@ -399,18 +330,6 @@ __decorateClass([
|
|
|
399
330
|
outputSchema: CartSchema
|
|
400
331
|
})
|
|
401
332
|
], CommercetoolsCartProvider.prototype, "deleteCart", 1);
|
|
402
|
-
__decorateClass([
|
|
403
|
-
Reactionary({
|
|
404
|
-
inputSchema: CartMutationSetShippingInfoSchema,
|
|
405
|
-
outputSchema: CartSchema
|
|
406
|
-
})
|
|
407
|
-
], CommercetoolsCartProvider.prototype, "setShippingInfo", 1);
|
|
408
|
-
__decorateClass([
|
|
409
|
-
Reactionary({
|
|
410
|
-
inputSchema: CartMutationSetBillingAddressSchema,
|
|
411
|
-
outputSchema: CartSchema
|
|
412
|
-
})
|
|
413
|
-
], CommercetoolsCartProvider.prototype, "setBillingAddress", 1);
|
|
414
333
|
__decorateClass([
|
|
415
334
|
Reactionary({
|
|
416
335
|
inputSchema: CartMutationApplyCouponSchema,
|
|
@@ -423,12 +342,6 @@ __decorateClass([
|
|
|
423
342
|
outputSchema: CartSchema
|
|
424
343
|
})
|
|
425
344
|
], CommercetoolsCartProvider.prototype, "removeCouponCode", 1);
|
|
426
|
-
__decorateClass([
|
|
427
|
-
Reactionary({
|
|
428
|
-
inputSchema: CartMutationCheckoutSchema,
|
|
429
|
-
outputSchema: OrderIdentifierSchema
|
|
430
|
-
})
|
|
431
|
-
], CommercetoolsCartProvider.prototype, "checkout", 1);
|
|
432
345
|
__decorateClass([
|
|
433
346
|
Reactionary({
|
|
434
347
|
inputSchema: CartMutationChangeCurrencySchema,
|
|
@@ -317,9 +317,6 @@ class CommercetoolsCheckoutProvider extends CheckoutProvider {
|
|
|
317
317
|
getStaticPaymentMethods(_checkout) {
|
|
318
318
|
return this.config.paymentMethods || [];
|
|
319
319
|
}
|
|
320
|
-
getResourceName() {
|
|
321
|
-
return "checkout";
|
|
322
|
-
}
|
|
323
320
|
parseSingle(remote) {
|
|
324
321
|
const result = this.newModel();
|
|
325
322
|
result.identifier = CommercetoolsCheckoutIdentifierSchema.parse({
|
|
@@ -37,10 +37,10 @@ class CommercetoolsProductProvider extends ProductProvider {
|
|
|
37
37
|
async getById(payload) {
|
|
38
38
|
const client = await this.getClient();
|
|
39
39
|
try {
|
|
40
|
-
const remote = await client.withKey({ key: payload.
|
|
40
|
+
const remote = await client.withKey({ key: payload.identifier.key }).get().execute();
|
|
41
41
|
return this.parseSingle(remote.body);
|
|
42
42
|
} catch (error) {
|
|
43
|
-
return this.createEmptyProduct(payload.
|
|
43
|
+
return this.createEmptyProduct(payload.identifier.key);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
async getBySlug(payload) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CartProvider } from '@reactionary/core';
|
|
2
|
-
import type { CartMutationItemAdd, CartMutationItemQuantityChange, CartMutationItemRemove, CartQueryById, CartIdentifier, CartMutationApplyCoupon,
|
|
2
|
+
import type { CartMutationItemAdd, CartMutationItemQuantityChange, CartMutationItemRemove, CartQueryById, CartIdentifier, CartMutationApplyCoupon, CartMutationDeleteCart, CartMutationRemoveCoupon, CartMutationChangeCurrency, RequestContext, Cart, Cache } from '@reactionary/core';
|
|
3
3
|
import type { CommercetoolsConfiguration } from '../schema/configuration.schema.js';
|
|
4
4
|
import type { z } from 'zod';
|
|
5
5
|
import type { Cart as CTCart, MyCartUpdateAction } from '@commercetools/platform-sdk';
|
|
@@ -14,11 +14,8 @@ export declare class CommercetoolsCartProvider<T extends Cart = Cart> extends Ca
|
|
|
14
14
|
changeQuantity(payload: CartMutationItemQuantityChange): Promise<T>;
|
|
15
15
|
getActiveCartId(): Promise<CartIdentifier>;
|
|
16
16
|
deleteCart(payload: CartMutationDeleteCart): Promise<T>;
|
|
17
|
-
setShippingInfo(payload: CartMutationSetShippingInfo): Promise<T>;
|
|
18
|
-
setBillingAddress(payload: CartMutationSetBillingAddress): Promise<T>;
|
|
19
17
|
applyCouponCode(payload: CartMutationApplyCoupon): Promise<T>;
|
|
20
18
|
removeCouponCode(payload: CartMutationRemoveCoupon): Promise<T>;
|
|
21
|
-
checkout(payload: CartMutationCheckout): Promise<OrderIdentifier>;
|
|
22
19
|
changeCurrency(payload: CartMutationChangeCurrency): Promise<T>;
|
|
23
20
|
protected createCart(): Promise<CartIdentifier>;
|
|
24
21
|
protected applyActions(cart: CartIdentifier, actions: MyCartUpdateAction[]): Promise<T>;
|
|
@@ -36,7 +36,6 @@ export declare class CommercetoolsCheckoutProvider<T extends Checkout = Checkout
|
|
|
36
36
|
* @returns
|
|
37
37
|
*/
|
|
38
38
|
protected getStaticPaymentMethods(_checkout: CheckoutIdentifier): PaymentMethod[];
|
|
39
|
-
protected getResourceName(): string;
|
|
40
39
|
protected parseSingle(remote: CTCart): T;
|
|
41
40
|
protected isReadyForFinalization(checkout: T): boolean;
|
|
42
41
|
protected parsePaymentInstruction(remote: CTPayment): PaymentInstruction;
|