@01.software/sdk 0.41.0 → 0.42.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 +222 -0
- package/README.md +81 -18
- package/dist/analytics/react.cjs +71 -3
- package/dist/analytics/react.cjs.map +1 -1
- package/dist/analytics/react.d.cts +18 -2
- package/dist/analytics/react.d.ts +18 -2
- package/dist/analytics/react.js +67 -3
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics.cjs +6 -2
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.d.cts +17 -4
- package/dist/analytics.d.ts +17 -4
- package/dist/analytics.js +6 -2
- package/dist/analytics.js.map +1 -1
- package/dist/client.cjs +176 -32
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.js +176 -32
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-Bymfni8u.d.cts → collection-client-B-qVIBnJ.d.cts} +5 -5
- package/dist/{collection-client-CN4lj6gi.d.ts → collection-client-BhCMwIus.d.ts} +5 -5
- package/dist/{const-4BUtUdGU.d.cts → const-BiDujixF.d.cts} +1 -1
- package/dist/{const-ymprfiPf.d.ts → const-pmHlwm3E.d.ts} +1 -1
- package/dist/{index-w36lpSkU.d.ts → index-B1UBDaKz.d.ts} +3 -3
- package/dist/{index-Dquv4xTL.d.cts → index-D78ki6Ij.d.cts} +3 -3
- package/dist/index.cjs +156 -339
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +156 -339
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-DC0xzR9i.d.cts → payload-types-C7Ul4ElL.d.cts} +181 -118
- package/dist/{payload-types-DC0xzR9i.d.ts → payload-types-C7Ul4ElL.d.ts} +181 -118
- package/dist/query.d.cts +5 -5
- package/dist/query.d.ts +5 -5
- package/dist/realtime.cjs +1 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js +1 -1
- package/dist/realtime.js.map +1 -1
- package/dist/server.cjs +236 -50
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.js +236 -50
- package/dist/server.js.map +1 -1
- package/dist/{types-CHrzs2GB.d.ts → types-BL7M-EUV.d.cts} +140 -14
- package/dist/{types-Bh2p-EMc.d.ts → types-Bf2iCjy8.d.ts} +1 -1
- package/dist/{types-BvpjooU-.d.cts → types-ChV1t4ei.d.cts} +1 -1
- package/dist/{types-Bl-m9ttd.d.cts → types-D5dSNIGs.d.ts} +140 -14
- package/dist/ui/canvas.cjs.map +1 -1
- package/dist/ui/canvas.js.map +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.d.cts +4 -4
- package/dist/webhook.d.ts +4 -4
- package/package.json +3 -3
package/dist/server.cjs
CHANGED
|
@@ -105,6 +105,26 @@ var TimeoutError = class extends SDKError {
|
|
|
105
105
|
this.name = "TimeoutError";
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
|
+
var GoneError = class extends SDKError {
|
|
109
|
+
constructor(message = "The requested resource is no longer available.", details, userMessage, suggestion) {
|
|
110
|
+
super("GONE_ERROR", message, 410, details, userMessage, suggestion);
|
|
111
|
+
this.name = "GoneError";
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var ServiceUnavailableError = class extends SDKError {
|
|
115
|
+
constructor(message = "Service temporarily unavailable.", retryAfter, details, userMessage, suggestion) {
|
|
116
|
+
super(
|
|
117
|
+
"SERVICE_UNAVAILABLE_ERROR",
|
|
118
|
+
message,
|
|
119
|
+
503,
|
|
120
|
+
details,
|
|
121
|
+
userMessage,
|
|
122
|
+
suggestion
|
|
123
|
+
);
|
|
124
|
+
this.name = "ServiceUnavailableError";
|
|
125
|
+
this.retryAfter = retryAfter;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
108
128
|
var UsageLimitError = class extends SDKError {
|
|
109
129
|
constructor(message, usage, details, userMessage, suggestion) {
|
|
110
130
|
super("USAGE_LIMIT_ERROR", message, 429, details, userMessage, suggestion);
|
|
@@ -186,6 +206,14 @@ var createValidationError = (message, details, userMessage, suggestion, status)
|
|
|
186
206
|
var createApiError = (message, status, details, userMessage, suggestion, requestId) => new ApiError(message, status, details, userMessage, suggestion, requestId);
|
|
187
207
|
var createConfigError = (message, details, userMessage, suggestion) => new ConfigError(message, details, userMessage, suggestion);
|
|
188
208
|
var createTimeoutError = (message, details, userMessage, suggestion) => new TimeoutError(message, details, userMessage, suggestion);
|
|
209
|
+
var createGoneError = (message, details, userMessage, suggestion) => new GoneError(message, details, userMessage, suggestion);
|
|
210
|
+
var createServiceUnavailableError = (message, retryAfter, details, userMessage, suggestion) => new ServiceUnavailableError(
|
|
211
|
+
message,
|
|
212
|
+
retryAfter,
|
|
213
|
+
details,
|
|
214
|
+
userMessage,
|
|
215
|
+
suggestion
|
|
216
|
+
);
|
|
189
217
|
var createUsageLimitError = (message, usage, details, userMessage, suggestion) => new UsageLimitError(message, usage, details, userMessage, suggestion);
|
|
190
218
|
var createAuthError = (message, details, userMessage, suggestion, requestId) => new AuthError(message, details, userMessage, suggestion, requestId);
|
|
191
219
|
var createPermissionError = (message, details, userMessage, suggestion, requestId) => new PermissionError(message, details, userMessage, suggestion, requestId);
|
|
@@ -210,7 +238,7 @@ function requirePublishableKeyForSecret(apiName, publishableKey, secretKey) {
|
|
|
210
238
|
return publishableKey ?? "";
|
|
211
239
|
}
|
|
212
240
|
|
|
213
|
-
// src/core/
|
|
241
|
+
// src/core/internal/utils/api-url.ts
|
|
214
242
|
function resolveApiUrl(apiUrl) {
|
|
215
243
|
if (apiUrl) {
|
|
216
244
|
return apiUrl.replace(/\/$/, "");
|
|
@@ -227,7 +255,7 @@ function resolveApiUrl(apiUrl) {
|
|
|
227
255
|
// src/core/internal/utils/http.ts
|
|
228
256
|
var DEFAULT_TIMEOUT = 3e4;
|
|
229
257
|
var STOREFRONT_BROWSER_TIMEOUT = 15e3;
|
|
230
|
-
var DEFAULT_RETRYABLE_STATUSES = [408,
|
|
258
|
+
var DEFAULT_RETRYABLE_STATUSES = [408, 500, 502, 503, 504];
|
|
231
259
|
var NON_RETRYABLE_STATUSES = [400, 401, 403, 404, 409, 422];
|
|
232
260
|
var SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
|
|
233
261
|
var DEFAULT_MAX_RETRIES = 3;
|
|
@@ -344,7 +372,12 @@ function attachRequestId(err, id) {
|
|
|
344
372
|
if (id) err.requestId = id;
|
|
345
373
|
return err;
|
|
346
374
|
}
|
|
347
|
-
function
|
|
375
|
+
function parseRetryAfter(response) {
|
|
376
|
+
const raw = response.headers.get("Retry-After");
|
|
377
|
+
if (!raw) return void 0;
|
|
378
|
+
return parseInt(raw, 10) || void 0;
|
|
379
|
+
}
|
|
380
|
+
function mapResponseToError(status, parsed, details, requestId, retryAfter) {
|
|
348
381
|
const errorDetails = {
|
|
349
382
|
...details,
|
|
350
383
|
...parsed.errors && { errors: parsed.errors },
|
|
@@ -407,6 +440,41 @@ function createHttpStatusError(status, parsed, details, requestId) {
|
|
|
407
440
|
requestId
|
|
408
441
|
);
|
|
409
442
|
}
|
|
443
|
+
if (status === 410) {
|
|
444
|
+
return attachRequestId(
|
|
445
|
+
createGoneError(
|
|
446
|
+
parsed.errorMessage,
|
|
447
|
+
errorDetails,
|
|
448
|
+
parsed.userMessage,
|
|
449
|
+
suggestion
|
|
450
|
+
),
|
|
451
|
+
requestId
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
if (status === 429) {
|
|
455
|
+
return attachRequestId(
|
|
456
|
+
createRateLimitError(
|
|
457
|
+
parsed.errorMessage,
|
|
458
|
+
retryAfter,
|
|
459
|
+
errorDetails,
|
|
460
|
+
parsed.userMessage,
|
|
461
|
+
suggestion
|
|
462
|
+
),
|
|
463
|
+
requestId
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
if (status === 503) {
|
|
467
|
+
return attachRequestId(
|
|
468
|
+
createServiceUnavailableError(
|
|
469
|
+
parsed.errorMessage,
|
|
470
|
+
retryAfter,
|
|
471
|
+
errorDetails,
|
|
472
|
+
parsed.userMessage,
|
|
473
|
+
suggestion
|
|
474
|
+
),
|
|
475
|
+
requestId
|
|
476
|
+
);
|
|
477
|
+
}
|
|
410
478
|
return attachRequestId(
|
|
411
479
|
createNetworkError(
|
|
412
480
|
parsed.errorMessage,
|
|
@@ -525,26 +593,17 @@ async function httpFetch(url, options) {
|
|
|
525
593
|
method: requestInit.method || "GET",
|
|
526
594
|
attempt: attempt + 1
|
|
527
595
|
};
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
const error = attachRequestId(
|
|
537
|
-
createNetworkError(
|
|
538
|
-
parsed.errorMessage,
|
|
539
|
-
response.status,
|
|
540
|
-
details,
|
|
541
|
-
parsed.userMessage,
|
|
542
|
-
getErrorSuggestion(response.status)
|
|
543
|
-
),
|
|
544
|
-
requestId
|
|
596
|
+
const retryAfter = parseRetryAfter(response);
|
|
597
|
+
const error = mapResponseToError(
|
|
598
|
+
response.status,
|
|
599
|
+
parsed,
|
|
600
|
+
details,
|
|
601
|
+
requestId,
|
|
602
|
+
retryAfter
|
|
545
603
|
);
|
|
546
604
|
const method2 = (requestInit.method || "GET").toUpperCase();
|
|
547
|
-
|
|
605
|
+
const isTerminal = error instanceof RateLimitError || error instanceof UsageLimitError;
|
|
606
|
+
if (attempt < retryConfig.maxRetries && SAFE_METHODS.includes(method2) && !isTerminal && !NON_RETRYABLE_STATUSES.includes(response.status) && retryConfig.retryableStatuses.includes(response.status)) {
|
|
548
607
|
lastError = error;
|
|
549
608
|
const retryDelay = retryConfig.retryDelay(attempt);
|
|
550
609
|
debugLog(debug, "error", `Retrying in ${retryDelay}ms...`, error);
|
|
@@ -986,9 +1045,10 @@ var CollectionQueryBuilder = class {
|
|
|
986
1045
|
* DELETE /api/{collection}/{id}
|
|
987
1046
|
* @returns Deleted document object directly (no wrapper)
|
|
988
1047
|
*/
|
|
989
|
-
async remove(id) {
|
|
1048
|
+
async remove(id, options) {
|
|
990
1049
|
return this.api.requestDelete(
|
|
991
|
-
`/api/${String(this.collection)}/${String(id)}
|
|
1050
|
+
`/api/${String(this.collection)}/${String(id)}`,
|
|
1051
|
+
options
|
|
992
1052
|
);
|
|
993
1053
|
}
|
|
994
1054
|
/**
|
|
@@ -1120,8 +1180,9 @@ var CollectionClient = class extends HttpClient {
|
|
|
1120
1180
|
* Delete document
|
|
1121
1181
|
* DELETE /api/{collection}/{id}
|
|
1122
1182
|
*/
|
|
1123
|
-
async requestDelete(endpoint) {
|
|
1124
|
-
const
|
|
1183
|
+
async requestDelete(endpoint, options) {
|
|
1184
|
+
const url = this.buildUrl(endpoint, options);
|
|
1185
|
+
const response = await this.fetchWithTracking(url, {
|
|
1125
1186
|
...this.defaultOptions,
|
|
1126
1187
|
method: "DELETE"
|
|
1127
1188
|
});
|
|
@@ -1612,42 +1673,123 @@ var ModerationApi = class extends BaseApi {
|
|
|
1612
1673
|
}
|
|
1613
1674
|
};
|
|
1614
1675
|
|
|
1676
|
+
// src/core/api/endpoints.ts
|
|
1677
|
+
var COMMERCE_ENDPOINTS = {
|
|
1678
|
+
orders: {
|
|
1679
|
+
create: "/api/orders/create",
|
|
1680
|
+
update: "/api/orders/update",
|
|
1681
|
+
confirmPayment: "/api/orders/confirm-payment",
|
|
1682
|
+
byPayment: "/api/orders/by-payment",
|
|
1683
|
+
cancel: "/api/orders/cancel",
|
|
1684
|
+
resolveCancelRefund: "/api/orders/resolve-cancel-refund",
|
|
1685
|
+
checkout: "/api/orders/checkout",
|
|
1686
|
+
createFulfillment: "/api/orders/create-fulfillment",
|
|
1687
|
+
updateFulfillment: "/api/orders/update-fulfillment"
|
|
1688
|
+
},
|
|
1689
|
+
transactions: {
|
|
1690
|
+
update: "/api/transactions/update"
|
|
1691
|
+
},
|
|
1692
|
+
returns: {
|
|
1693
|
+
create: "/api/returns/create",
|
|
1694
|
+
update: "/api/returns/update",
|
|
1695
|
+
returnRefund: "/api/returns/return-refund"
|
|
1696
|
+
},
|
|
1697
|
+
fulfillmentOrders: {
|
|
1698
|
+
prepare: "/api/fulfillment-orders/prepare-fulfillment-order"
|
|
1699
|
+
},
|
|
1700
|
+
fulfillments: {
|
|
1701
|
+
bulkImport: "/api/fulfillments/bulk-import"
|
|
1702
|
+
},
|
|
1703
|
+
carts: {
|
|
1704
|
+
mine: "/api/carts/mine",
|
|
1705
|
+
merge: "/api/carts/merge",
|
|
1706
|
+
addItem: "/api/carts/add-item",
|
|
1707
|
+
updateItem: "/api/carts/update-item",
|
|
1708
|
+
removeItem: "/api/carts/remove-item",
|
|
1709
|
+
applyDiscount: "/api/carts/apply-discount",
|
|
1710
|
+
removeDiscount: "/api/carts/remove-discount",
|
|
1711
|
+
clear: "/api/carts/clear"
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
var COMMERCE_ENDPOINT_PATHS = Object.values(
|
|
1715
|
+
COMMERCE_ENDPOINTS
|
|
1716
|
+
).flatMap((group) => Object.values(group));
|
|
1717
|
+
|
|
1615
1718
|
// src/core/api/cart-api.ts
|
|
1616
1719
|
var CartApi = class extends CustomerScopedApi {
|
|
1617
1720
|
constructor(options) {
|
|
1618
|
-
super("CartApi", options);
|
|
1721
|
+
super("CartApi", { ...options, requiresCredential: false });
|
|
1619
1722
|
}
|
|
1620
1723
|
async execute(endpoint, method, body) {
|
|
1621
1724
|
return this.request(endpoint, { method, body });
|
|
1622
1725
|
}
|
|
1623
|
-
|
|
1726
|
+
/**
|
|
1727
|
+
* Create a cart and receive its `cartToken`. Store the token and pass it to
|
|
1728
|
+
* every subsequent cart operation.
|
|
1729
|
+
*/
|
|
1730
|
+
createCart(params = {}) {
|
|
1731
|
+
return this.execute("/api/carts/create", "POST", params);
|
|
1732
|
+
}
|
|
1733
|
+
getCart(cartToken) {
|
|
1734
|
+
return this.execute("/api/carts/get", "POST", { cartToken });
|
|
1735
|
+
}
|
|
1736
|
+
merge(params) {
|
|
1624
1737
|
return this.execute(
|
|
1625
|
-
|
|
1626
|
-
"
|
|
1738
|
+
COMMERCE_ENDPOINTS.carts.merge,
|
|
1739
|
+
"POST",
|
|
1740
|
+
params
|
|
1741
|
+
);
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Resolve the authenticated customer's active cart by JWT (no `cartToken`
|
|
1745
|
+
* required). Returns the cart and its capability handle, or both `null` when
|
|
1746
|
+
* the customer has no active cart. Requires a customer token.
|
|
1747
|
+
*/
|
|
1748
|
+
mine() {
|
|
1749
|
+
return this.execute(
|
|
1750
|
+
COMMERCE_ENDPOINTS.carts.mine,
|
|
1751
|
+
"POST",
|
|
1752
|
+
{}
|
|
1627
1753
|
);
|
|
1628
1754
|
}
|
|
1629
1755
|
addItem(params) {
|
|
1630
|
-
return this.execute(
|
|
1756
|
+
return this.execute(
|
|
1757
|
+
COMMERCE_ENDPOINTS.carts.addItem,
|
|
1758
|
+
"POST",
|
|
1759
|
+
params
|
|
1760
|
+
);
|
|
1631
1761
|
}
|
|
1632
1762
|
updateItem(params) {
|
|
1633
|
-
return this.execute(
|
|
1763
|
+
return this.execute(
|
|
1764
|
+
COMMERCE_ENDPOINTS.carts.updateItem,
|
|
1765
|
+
"POST",
|
|
1766
|
+
params
|
|
1767
|
+
);
|
|
1634
1768
|
}
|
|
1635
1769
|
removeItem(params) {
|
|
1636
1770
|
return this.execute(
|
|
1637
|
-
|
|
1771
|
+
COMMERCE_ENDPOINTS.carts.removeItem,
|
|
1638
1772
|
"POST",
|
|
1639
1773
|
params
|
|
1640
1774
|
);
|
|
1641
1775
|
}
|
|
1642
1776
|
applyDiscount(params) {
|
|
1643
|
-
return this.execute(
|
|
1777
|
+
return this.execute(
|
|
1778
|
+
COMMERCE_ENDPOINTS.carts.applyDiscount,
|
|
1779
|
+
"POST",
|
|
1780
|
+
params
|
|
1781
|
+
);
|
|
1644
1782
|
}
|
|
1645
1783
|
removeDiscount(params) {
|
|
1646
|
-
return this.execute(
|
|
1784
|
+
return this.execute(
|
|
1785
|
+
COMMERCE_ENDPOINTS.carts.removeDiscount,
|
|
1786
|
+
"POST",
|
|
1787
|
+
params
|
|
1788
|
+
);
|
|
1647
1789
|
}
|
|
1648
1790
|
clearCart(params) {
|
|
1649
1791
|
return this.execute(
|
|
1650
|
-
|
|
1792
|
+
COMMERCE_ENDPOINTS.carts.clear,
|
|
1651
1793
|
"POST",
|
|
1652
1794
|
params
|
|
1653
1795
|
);
|
|
@@ -2458,6 +2600,7 @@ function compareVariantOrder(a, b) {
|
|
|
2458
2600
|
function getVariantAvailableForSale(variant) {
|
|
2459
2601
|
if (variant.isActive === false) return false;
|
|
2460
2602
|
if (variant.isUnlimited) return true;
|
|
2603
|
+
if (variant.inventoryPolicy === "continue") return true;
|
|
2461
2604
|
return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
|
|
2462
2605
|
}
|
|
2463
2606
|
function isVariantAvailableForSale(variant) {
|
|
@@ -2923,26 +3066,61 @@ var OrderApi = class extends BaseApi {
|
|
|
2923
3066
|
const { idempotencyKey } = params;
|
|
2924
3067
|
const normalizedBody = normalizeCreateOrderBody(params);
|
|
2925
3068
|
return this.request(
|
|
2926
|
-
|
|
3069
|
+
COMMERCE_ENDPOINTS.orders.create,
|
|
2927
3070
|
normalizedBody,
|
|
2928
3071
|
idempotencyRequestOptions(idempotencyKey)
|
|
2929
3072
|
);
|
|
2930
3073
|
}
|
|
2931
3074
|
updateOrder(params) {
|
|
2932
|
-
return this.request(
|
|
3075
|
+
return this.request(COMMERCE_ENDPOINTS.orders.update, params);
|
|
2933
3076
|
}
|
|
2934
3077
|
updateTransaction(params) {
|
|
2935
|
-
return this.request(
|
|
3078
|
+
return this.request(
|
|
3079
|
+
COMMERCE_ENDPOINTS.transactions.update,
|
|
3080
|
+
params
|
|
3081
|
+
);
|
|
2936
3082
|
}
|
|
2937
3083
|
confirmPayment(params) {
|
|
2938
3084
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
2939
3085
|
const headerKey = idempotencyKey ?? params.providerEventId;
|
|
2940
3086
|
return this.request(
|
|
2941
|
-
|
|
3087
|
+
COMMERCE_ENDPOINTS.orders.confirmPayment,
|
|
2942
3088
|
body,
|
|
2943
3089
|
idempotencyRequestOptions(headerKey)
|
|
2944
3090
|
);
|
|
2945
3091
|
}
|
|
3092
|
+
/**
|
|
3093
|
+
* Resolve an order + its payment transaction by PG payment id. Replaces raw
|
|
3094
|
+
* `transactions.find({ where: { pgPaymentId } })` + a local file index in
|
|
3095
|
+
* storefronts. Server-only (sk01_) read of the full populated Order.
|
|
3096
|
+
*/
|
|
3097
|
+
getByPaymentId(params) {
|
|
3098
|
+
const query = new URLSearchParams({
|
|
3099
|
+
pgProvider: params.pgProvider,
|
|
3100
|
+
pgPaymentId: params.pgPaymentId
|
|
3101
|
+
}).toString();
|
|
3102
|
+
return this.request(
|
|
3103
|
+
`${COMMERCE_ENDPOINTS.orders.byPayment}?${query}`,
|
|
3104
|
+
void 0,
|
|
3105
|
+
{ method: "GET" }
|
|
3106
|
+
);
|
|
3107
|
+
}
|
|
3108
|
+
/**
|
|
3109
|
+
* Composed facade: confirm a provider payment, then resolve the
|
|
3110
|
+
* depth-populated order/transaction by the same payment id. `confirmPayment`'s
|
|
3111
|
+
* wire response carries only IDs (its contract is `.strict()`); this returns
|
|
3112
|
+
* the populated `Order` so storefronts stop reconstructing order state
|
|
3113
|
+
* locally. Two round trips by design — the alternative (widening the strict
|
|
3114
|
+
* confirm-payment wire contract to embed a full Order) is rejected.
|
|
3115
|
+
*/
|
|
3116
|
+
async confirmPaymentReturningOrder(params) {
|
|
3117
|
+
const confirmation = await this.confirmPayment(params);
|
|
3118
|
+
const { order, transaction } = await this.getByPaymentId({
|
|
3119
|
+
pgProvider: params.pgProvider,
|
|
3120
|
+
pgPaymentId: params.pgPaymentId
|
|
3121
|
+
});
|
|
3122
|
+
return { ...confirmation, order, transaction };
|
|
3123
|
+
}
|
|
2946
3124
|
cancelOrder(params) {
|
|
2947
3125
|
const { idempotencyKey } = params;
|
|
2948
3126
|
const body = {
|
|
@@ -2951,14 +3129,14 @@ var OrderApi = class extends BaseApi {
|
|
|
2951
3129
|
reasonDetail: params.reasonDetail
|
|
2952
3130
|
};
|
|
2953
3131
|
return this.request(
|
|
2954
|
-
|
|
3132
|
+
COMMERCE_ENDPOINTS.orders.cancel,
|
|
2955
3133
|
body,
|
|
2956
3134
|
idempotencyKey ? { headers: { "X-Idempotency-Key": idempotencyKey } } : void 0
|
|
2957
3135
|
);
|
|
2958
3136
|
}
|
|
2959
3137
|
resolveCancelRefund(params) {
|
|
2960
3138
|
return this.request(
|
|
2961
|
-
|
|
3139
|
+
COMMERCE_ENDPOINTS.orders.resolveCancelRefund,
|
|
2962
3140
|
{
|
|
2963
3141
|
orderNumber: params.orderNumber,
|
|
2964
3142
|
idempotencyKey: params.idempotencyKey,
|
|
@@ -2979,7 +3157,7 @@ var OrderApi = class extends BaseApi {
|
|
|
2979
3157
|
checkout(params) {
|
|
2980
3158
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
2981
3159
|
return this.request(
|
|
2982
|
-
|
|
3160
|
+
COMMERCE_ENDPOINTS.orders.checkout,
|
|
2983
3161
|
body,
|
|
2984
3162
|
idempotencyRequestOptions(idempotencyKey)
|
|
2985
3163
|
);
|
|
@@ -2987,30 +3165,33 @@ var OrderApi = class extends BaseApi {
|
|
|
2987
3165
|
createFulfillment(params) {
|
|
2988
3166
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
2989
3167
|
return this.request(
|
|
2990
|
-
|
|
3168
|
+
COMMERCE_ENDPOINTS.orders.createFulfillment,
|
|
2991
3169
|
body,
|
|
2992
3170
|
idempotencyRequestOptions(idempotencyKey)
|
|
2993
3171
|
);
|
|
2994
3172
|
}
|
|
2995
3173
|
prepareFulfillmentOrder(params) {
|
|
2996
3174
|
return this.request(
|
|
2997
|
-
|
|
3175
|
+
COMMERCE_ENDPOINTS.fulfillmentOrders.prepare,
|
|
2998
3176
|
params
|
|
2999
3177
|
);
|
|
3000
3178
|
}
|
|
3001
3179
|
updateFulfillment(params) {
|
|
3002
|
-
return this.request(
|
|
3180
|
+
return this.request(
|
|
3181
|
+
COMMERCE_ENDPOINTS.orders.updateFulfillment,
|
|
3182
|
+
params
|
|
3183
|
+
);
|
|
3003
3184
|
}
|
|
3004
3185
|
bulkImportFulfillments(params) {
|
|
3005
3186
|
return this.request(
|
|
3006
|
-
|
|
3187
|
+
COMMERCE_ENDPOINTS.fulfillments.bulkImport,
|
|
3007
3188
|
params
|
|
3008
3189
|
);
|
|
3009
3190
|
}
|
|
3010
3191
|
returnWithRefund(params) {
|
|
3011
3192
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
3012
3193
|
return this.request(
|
|
3013
|
-
|
|
3194
|
+
COMMERCE_ENDPOINTS.returns.returnRefund,
|
|
3014
3195
|
body,
|
|
3015
3196
|
idempotencyRequestOptions(idempotencyKey)
|
|
3016
3197
|
);
|
|
@@ -3018,13 +3199,13 @@ var OrderApi = class extends BaseApi {
|
|
|
3018
3199
|
createReturn(params) {
|
|
3019
3200
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
3020
3201
|
return this.request(
|
|
3021
|
-
|
|
3202
|
+
COMMERCE_ENDPOINTS.returns.create,
|
|
3022
3203
|
body,
|
|
3023
3204
|
idempotencyRequestOptions(idempotencyKey)
|
|
3024
3205
|
);
|
|
3025
3206
|
}
|
|
3026
3207
|
updateReturn(params) {
|
|
3027
|
-
return this.request(
|
|
3208
|
+
return this.request(COMMERCE_ENDPOINTS.returns.update, params);
|
|
3028
3209
|
}
|
|
3029
3210
|
};
|
|
3030
3211
|
|
|
@@ -3110,13 +3291,16 @@ var ServerCommerceClient = class {
|
|
|
3110
3291
|
upsert: productApi.upsert.bind(productApi)
|
|
3111
3292
|
};
|
|
3112
3293
|
this.cart = {
|
|
3294
|
+
create: cartApi.createCart.bind(cartApi),
|
|
3113
3295
|
get: cartApi.getCart.bind(cartApi),
|
|
3114
3296
|
addItem: cartApi.addItem.bind(cartApi),
|
|
3115
3297
|
updateItem: cartApi.updateItem.bind(cartApi),
|
|
3116
3298
|
removeItem: cartApi.removeItem.bind(cartApi),
|
|
3117
3299
|
applyDiscount: cartApi.applyDiscount.bind(cartApi),
|
|
3118
3300
|
removeDiscount: cartApi.removeDiscount.bind(cartApi),
|
|
3119
|
-
clear: cartApi.clearCart.bind(cartApi)
|
|
3301
|
+
clear: cartApi.clearCart.bind(cartApi),
|
|
3302
|
+
merge: cartApi.merge.bind(cartApi),
|
|
3303
|
+
mine: cartApi.mine.bind(cartApi)
|
|
3120
3304
|
};
|
|
3121
3305
|
this.orders = {
|
|
3122
3306
|
checkout: orderApi.checkout.bind(orderApi),
|
|
@@ -3124,6 +3308,8 @@ var ServerCommerceClient = class {
|
|
|
3124
3308
|
update: orderApi.updateOrder.bind(orderApi),
|
|
3125
3309
|
updateTransaction: orderApi.updateTransaction.bind(orderApi),
|
|
3126
3310
|
confirmPayment: orderApi.confirmPayment.bind(orderApi),
|
|
3311
|
+
confirmPaymentReturningOrder: orderApi.confirmPaymentReturningOrder.bind(orderApi),
|
|
3312
|
+
getByPaymentId: orderApi.getByPaymentId.bind(orderApi),
|
|
3127
3313
|
cancelOrder: orderApi.cancelOrder.bind(orderApi),
|
|
3128
3314
|
resolveCancelRefund: orderApi.resolveCancelRefund.bind(orderApi),
|
|
3129
3315
|
createFulfillment: orderApi.createFulfillment.bind(orderApi),
|