@01.software/sdk 0.41.1 → 0.43.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 +246 -0
- package/README.md +88 -19
- 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 +233 -47
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +9 -6
- package/dist/client.d.ts +9 -6
- package/dist/client.js +233 -47
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-Bk--pNzW.d.cts → collection-client-U70KizLf.d.cts} +3 -3
- package/dist/{collection-client-BdcxkW7l.d.ts → collection-client-gWsA7BVP.d.ts} +3 -3
- package/dist/{const-qGGI7Uii.d.cts → const-BBynifk0.d.cts} +5 -5
- package/dist/{const-HwdntWtG.d.ts → const-_WWHU-gX.d.ts} +5 -5
- package/dist/{index-B1oW50RY.d.ts → index-DPi5NWU8.d.ts} +4 -4
- package/dist/{index-DiXtjVab.d.cts → index-Dg4Y6Aq7.d.cts} +4 -4
- package/dist/index.cjs +225 -358
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -8
- package/dist/index.d.ts +41 -8
- package/dist/index.js +225 -358
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-CqJOgON7.d.cts → payload-types-DLxkB7Mv.d.cts} +561 -123
- package/dist/{payload-types-CqJOgON7.d.ts → payload-types-DLxkB7Mv.d.ts} +561 -123
- package/dist/query.cjs +59 -7
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +5 -5
- package/dist/query.d.ts +5 -5
- package/dist/query.js +59 -7
- package/dist/query.js.map +1 -1
- 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 +318 -61
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +12 -7
- package/dist/server.d.ts +12 -7
- package/dist/server.js +318 -61
- package/dist/server.js.map +1 -1
- package/dist/{types-ByLSG-O3.d.cts → types-B1ngKbWI.d.cts} +1 -1
- package/dist/{types-BKa9z9s2.d.cts → types-B9lGhZlB.d.ts} +229 -15
- package/dist/{types-BMI3M0nb.d.ts → types-BiKNBwRA.d.ts} +1 -1
- package/dist/{types-DgfXb7iV.d.ts → types-Bpx5sYKo.d.cts} +229 -15
- 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.cjs +3 -1
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +4 -4
- package/dist/webhook.d.ts +4 -4
- package/dist/webhook.js +3 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22,7 +22,6 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
ApiError: () => ApiError,
|
|
24
24
|
AuthError: () => AuthError,
|
|
25
|
-
BaseApi: () => BaseApi,
|
|
26
25
|
COLLECTIONS: () => COLLECTIONS,
|
|
27
26
|
COMMERCE_NOTIFICATION_EVENTS: () => COMMERCE_NOTIFICATION_EVENTS,
|
|
28
27
|
COMMERCE_NOTIFICATION_EVENT_TYPE: () => COMMERCE_NOTIFICATION_EVENT_TYPE,
|
|
@@ -36,7 +35,6 @@ __export(src_exports, {
|
|
|
36
35
|
ContentClient: () => ContentClient,
|
|
37
36
|
CustomerAuth: () => CustomerAuth,
|
|
38
37
|
CustomerNamespace: () => CustomerNamespace,
|
|
39
|
-
DiscountApi: () => DiscountApi,
|
|
40
38
|
EventsClient: () => EventsClient,
|
|
41
39
|
GoneError: () => GoneError,
|
|
42
40
|
IMAGE_SIZES: () => IMAGE_SIZES,
|
|
@@ -44,12 +42,10 @@ __export(src_exports, {
|
|
|
44
42
|
NetworkError: () => NetworkError,
|
|
45
43
|
NotFoundError: () => NotFoundError,
|
|
46
44
|
ORDER_CHANGED_EVENT_TYPE: () => ORDER_CHANGED_EVENT_TYPE,
|
|
47
|
-
OrderApi: () => OrderApi,
|
|
48
45
|
PRODUCT_PLP_FIND_OPTIONS: () => PRODUCT_PLP_FIND_OPTIONS,
|
|
49
46
|
PRODUCT_UPSERT_READONLY_FIELD_REASON: () => PRODUCT_UPSERT_READONLY_FIELD_REASON,
|
|
50
47
|
PRODUCT_UPSERT_UNKNOWN_FIELD_REASON: () => PRODUCT_UPSERT_UNKNOWN_FIELD_REASON,
|
|
51
48
|
PermissionError: () => PermissionError,
|
|
52
|
-
ProductApi: () => ProductApi,
|
|
53
49
|
ProductSelectionCodecError: () => ProductSelectionCodecError,
|
|
54
50
|
RateLimitError: () => RateLimitError,
|
|
55
51
|
RealtimeConnection: () => RealtimeConnection,
|
|
@@ -57,7 +53,6 @@ __export(src_exports, {
|
|
|
57
53
|
SERVER_COLLECTIONS: () => SERVER_COLLECTIONS,
|
|
58
54
|
SERVER_ONLY_COLLECTIONS: () => SERVER_ONLY_COLLECTIONS,
|
|
59
55
|
ServiceUnavailableError: () => ServiceUnavailableError,
|
|
60
|
-
ShippingApi: () => ShippingApi,
|
|
61
56
|
TimeoutError: () => TimeoutError,
|
|
62
57
|
UsageLimitError: () => UsageLimitError,
|
|
63
58
|
ValidationError: () => ValidationError,
|
|
@@ -360,6 +355,14 @@ var createValidationError = (message, details, userMessage, suggestion, status)
|
|
|
360
355
|
var createApiError = (message, status, details, userMessage, suggestion, requestId) => new ApiError(message, status, details, userMessage, suggestion, requestId);
|
|
361
356
|
var createConfigError = (message, details, userMessage, suggestion) => new ConfigError(message, details, userMessage, suggestion);
|
|
362
357
|
var createTimeoutError = (message, details, userMessage, suggestion) => new TimeoutError(message, details, userMessage, suggestion);
|
|
358
|
+
var createGoneError = (message, details, userMessage, suggestion) => new GoneError(message, details, userMessage, suggestion);
|
|
359
|
+
var createServiceUnavailableError = (message, retryAfter, details, userMessage, suggestion) => new ServiceUnavailableError(
|
|
360
|
+
message,
|
|
361
|
+
retryAfter,
|
|
362
|
+
details,
|
|
363
|
+
userMessage,
|
|
364
|
+
suggestion
|
|
365
|
+
);
|
|
363
366
|
var createUsageLimitError = (message, usage, details, userMessage, suggestion) => new UsageLimitError(message, usage, details, userMessage, suggestion);
|
|
364
367
|
var createAuthError = (message, details, userMessage, suggestion, requestId) => new AuthError(message, details, userMessage, suggestion, requestId);
|
|
365
368
|
var createPermissionError = (message, details, userMessage, suggestion, requestId) => new PermissionError(message, details, userMessage, suggestion, requestId);
|
|
@@ -384,7 +387,7 @@ function requirePublishableKeyForSecret(apiName, publishableKey, secretKey) {
|
|
|
384
387
|
return publishableKey ?? "";
|
|
385
388
|
}
|
|
386
389
|
|
|
387
|
-
// src/core/
|
|
390
|
+
// src/core/internal/utils/api-url.ts
|
|
388
391
|
function resolveApiUrl(apiUrl) {
|
|
389
392
|
if (apiUrl) {
|
|
390
393
|
return apiUrl.replace(/\/$/, "");
|
|
@@ -401,7 +404,7 @@ function resolveApiUrl(apiUrl) {
|
|
|
401
404
|
// src/core/internal/utils/http.ts
|
|
402
405
|
var DEFAULT_TIMEOUT = 3e4;
|
|
403
406
|
var STOREFRONT_BROWSER_TIMEOUT = 15e3;
|
|
404
|
-
var DEFAULT_RETRYABLE_STATUSES = [408,
|
|
407
|
+
var DEFAULT_RETRYABLE_STATUSES = [408, 500, 502, 503, 504];
|
|
405
408
|
var NON_RETRYABLE_STATUSES = [400, 401, 403, 404, 409, 422];
|
|
406
409
|
var SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
|
|
407
410
|
var DEFAULT_MAX_RETRIES = 3;
|
|
@@ -518,7 +521,12 @@ function attachRequestId(err, id) {
|
|
|
518
521
|
if (id) err.requestId = id;
|
|
519
522
|
return err;
|
|
520
523
|
}
|
|
521
|
-
function
|
|
524
|
+
function parseRetryAfter(response) {
|
|
525
|
+
const raw = response.headers.get("Retry-After");
|
|
526
|
+
if (!raw) return void 0;
|
|
527
|
+
return parseInt(raw, 10) || void 0;
|
|
528
|
+
}
|
|
529
|
+
function mapResponseToError(status, parsed, details, requestId, retryAfter) {
|
|
522
530
|
const errorDetails = {
|
|
523
531
|
...details,
|
|
524
532
|
...parsed.errors && { errors: parsed.errors },
|
|
@@ -581,6 +589,41 @@ function createHttpStatusError(status, parsed, details, requestId) {
|
|
|
581
589
|
requestId
|
|
582
590
|
);
|
|
583
591
|
}
|
|
592
|
+
if (status === 410) {
|
|
593
|
+
return attachRequestId(
|
|
594
|
+
createGoneError(
|
|
595
|
+
parsed.errorMessage,
|
|
596
|
+
errorDetails,
|
|
597
|
+
parsed.userMessage,
|
|
598
|
+
suggestion
|
|
599
|
+
),
|
|
600
|
+
requestId
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
if (status === 429) {
|
|
604
|
+
return attachRequestId(
|
|
605
|
+
createRateLimitError(
|
|
606
|
+
parsed.errorMessage,
|
|
607
|
+
retryAfter,
|
|
608
|
+
errorDetails,
|
|
609
|
+
parsed.userMessage,
|
|
610
|
+
suggestion
|
|
611
|
+
),
|
|
612
|
+
requestId
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
if (status === 503) {
|
|
616
|
+
return attachRequestId(
|
|
617
|
+
createServiceUnavailableError(
|
|
618
|
+
parsed.errorMessage,
|
|
619
|
+
retryAfter,
|
|
620
|
+
errorDetails,
|
|
621
|
+
parsed.userMessage,
|
|
622
|
+
suggestion
|
|
623
|
+
),
|
|
624
|
+
requestId
|
|
625
|
+
);
|
|
626
|
+
}
|
|
584
627
|
return attachRequestId(
|
|
585
628
|
createNetworkError(
|
|
586
629
|
parsed.errorMessage,
|
|
@@ -699,26 +742,17 @@ async function httpFetch(url, options) {
|
|
|
699
742
|
method: requestInit.method || "GET",
|
|
700
743
|
attempt: attempt + 1
|
|
701
744
|
};
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
}
|
|
710
|
-
const error = attachRequestId(
|
|
711
|
-
createNetworkError(
|
|
712
|
-
parsed.errorMessage,
|
|
713
|
-
response.status,
|
|
714
|
-
details,
|
|
715
|
-
parsed.userMessage,
|
|
716
|
-
getErrorSuggestion(response.status)
|
|
717
|
-
),
|
|
718
|
-
requestId
|
|
745
|
+
const retryAfter = parseRetryAfter(response);
|
|
746
|
+
const error = mapResponseToError(
|
|
747
|
+
response.status,
|
|
748
|
+
parsed,
|
|
749
|
+
details,
|
|
750
|
+
requestId,
|
|
751
|
+
retryAfter
|
|
719
752
|
);
|
|
720
753
|
const method2 = (requestInit.method || "GET").toUpperCase();
|
|
721
|
-
|
|
754
|
+
const isTerminal = error instanceof RateLimitError || error instanceof UsageLimitError;
|
|
755
|
+
if (attempt < retryConfig.maxRetries && SAFE_METHODS.includes(method2) && !isTerminal && !NON_RETRYABLE_STATUSES.includes(response.status) && retryConfig.retryableStatuses.includes(response.status)) {
|
|
722
756
|
lastError = error;
|
|
723
757
|
const retryDelay = retryConfig.retryDelay(attempt);
|
|
724
758
|
debugLog(debug, "error", `Retrying in ${retryDelay}ms...`, error);
|
|
@@ -790,6 +824,64 @@ async function httpFetch(url, options) {
|
|
|
790
824
|
throw lastError ?? new NetworkError("Request failed after retries");
|
|
791
825
|
}
|
|
792
826
|
|
|
827
|
+
// src/core/api/endpoints.ts
|
|
828
|
+
var COMMERCE_ENDPOINTS = {
|
|
829
|
+
orders: {
|
|
830
|
+
create: "/api/orders/create",
|
|
831
|
+
update: "/api/orders/update",
|
|
832
|
+
confirmPayment: "/api/orders/confirm-payment",
|
|
833
|
+
byPayment: "/api/orders/by-payment",
|
|
834
|
+
cancel: "/api/orders/cancel",
|
|
835
|
+
resolveCancelRefund: "/api/orders/resolve-cancel-refund",
|
|
836
|
+
checkout: "/api/orders/checkout",
|
|
837
|
+
createFulfillment: "/api/orders/create-fulfillment",
|
|
838
|
+
updateFulfillment: "/api/orders/update-fulfillment"
|
|
839
|
+
},
|
|
840
|
+
transactions: {
|
|
841
|
+
update: "/api/transactions/update"
|
|
842
|
+
},
|
|
843
|
+
returns: {
|
|
844
|
+
create: "/api/returns/create",
|
|
845
|
+
update: "/api/returns/update",
|
|
846
|
+
returnRefund: "/api/returns/return-refund"
|
|
847
|
+
},
|
|
848
|
+
fulfillmentOrders: {
|
|
849
|
+
prepare: "/api/fulfillment-orders/prepare-fulfillment-order"
|
|
850
|
+
},
|
|
851
|
+
fulfillments: {
|
|
852
|
+
bulkImport: "/api/fulfillments/bulk-import"
|
|
853
|
+
},
|
|
854
|
+
carts: {
|
|
855
|
+
mine: "/api/carts/mine",
|
|
856
|
+
merge: "/api/carts/merge",
|
|
857
|
+
addItem: "/api/carts/add-item",
|
|
858
|
+
updateItem: "/api/carts/update-item",
|
|
859
|
+
removeItem: "/api/carts/remove-item",
|
|
860
|
+
applyDiscount: "/api/carts/apply-discount",
|
|
861
|
+
removeDiscount: "/api/carts/remove-discount",
|
|
862
|
+
clear: "/api/carts/clear"
|
|
863
|
+
},
|
|
864
|
+
products: {
|
|
865
|
+
stockCheck: "/api/products/stock-check",
|
|
866
|
+
stockSnapshot: "/api/products/stock",
|
|
867
|
+
listingGroups: "/api/products/listing-groups",
|
|
868
|
+
listingGroupsCatalog: "/api/products/listing-groups/catalog",
|
|
869
|
+
listingGroupsQuery: "/api/products/listing-groups/query",
|
|
870
|
+
listingGroupsQueryCatalog: "/api/products/listing-groups/query/catalog",
|
|
871
|
+
detail: "/api/products/detail",
|
|
872
|
+
detailCatalog: "/api/products/detail/catalog",
|
|
873
|
+
upsert: "/api/products/upsert"
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
var COMMERCE_ENDPOINT_PATHS = Object.values(
|
|
877
|
+
COMMERCE_ENDPOINTS
|
|
878
|
+
).flatMap((group) => Object.values(group));
|
|
879
|
+
var MEMBERSHIP_ENDPOINTS = {
|
|
880
|
+
subscribe: "/api/memberships/subscribe",
|
|
881
|
+
cancel: (id) => `/api/memberships/${id}/cancel`,
|
|
882
|
+
me: "/api/memberships/me"
|
|
883
|
+
};
|
|
884
|
+
|
|
793
885
|
// src/core/internal/utils/query-string.ts
|
|
794
886
|
function productDetailQuery(params) {
|
|
795
887
|
const search = new URLSearchParams();
|
|
@@ -798,7 +890,7 @@ function productDetailQuery(params) {
|
|
|
798
890
|
} else {
|
|
799
891
|
search.set("id", params.id);
|
|
800
892
|
}
|
|
801
|
-
return
|
|
893
|
+
return `${COMMERCE_ENDPOINTS.products.detail}?${search}`;
|
|
802
894
|
}
|
|
803
895
|
function productDetailCatalogQuery(params) {
|
|
804
896
|
const search = new URLSearchParams();
|
|
@@ -807,23 +899,17 @@ function productDetailCatalogQuery(params) {
|
|
|
807
899
|
} else {
|
|
808
900
|
search.set("id", params.id);
|
|
809
901
|
}
|
|
810
|
-
return
|
|
811
|
-
}
|
|
812
|
-
function listingGroupsQuery(params) {
|
|
813
|
-
return `/api/products/listing-groups?ids=${params.productIds.map(encodeURIComponent).join(",")}`;
|
|
902
|
+
return `${COMMERCE_ENDPOINTS.products.detailCatalog}?${search}`;
|
|
814
903
|
}
|
|
815
904
|
function listingGroupsCatalogQuery(params) {
|
|
816
|
-
return
|
|
905
|
+
return `${COMMERCE_ENDPOINTS.products.listingGroupsCatalog}?ids=${params.productIds.map(encodeURIComponent).join(",")}`;
|
|
817
906
|
}
|
|
818
907
|
function appendListingGroupsQuerySearchParams(search, options) {
|
|
819
908
|
if (options?.page != null) search.set("page", String(options.page));
|
|
820
909
|
if (options?.limit != null) search.set("limit", String(options.limit));
|
|
821
910
|
if (options?.sort != null) {
|
|
822
911
|
const sort = options.sort;
|
|
823
|
-
search.set(
|
|
824
|
-
"sort",
|
|
825
|
-
Array.isArray(sort) ? sort.join(",") : sort
|
|
826
|
-
);
|
|
912
|
+
search.set("sort", Array.isArray(sort) ? sort.join(",") : sort);
|
|
827
913
|
}
|
|
828
914
|
if (options?.where != null) {
|
|
829
915
|
search.set("whereJson", JSON.stringify(options.where));
|
|
@@ -833,16 +919,16 @@ function listingGroupsQueryUrl(options) {
|
|
|
833
919
|
const search = new URLSearchParams();
|
|
834
920
|
appendListingGroupsQuerySearchParams(search, options);
|
|
835
921
|
const query = search.toString();
|
|
836
|
-
return
|
|
922
|
+
return `${COMMERCE_ENDPOINTS.products.listingGroupsQuery}${query ? `?${query}` : ""}`;
|
|
837
923
|
}
|
|
838
924
|
function listingGroupsQueryCatalogUrl(options) {
|
|
839
925
|
const search = new URLSearchParams();
|
|
840
926
|
appendListingGroupsQuerySearchParams(search, options);
|
|
841
927
|
const query = search.toString();
|
|
842
|
-
return
|
|
928
|
+
return `${COMMERCE_ENDPOINTS.products.listingGroupsQueryCatalog}${query ? `?${query}` : ""}`;
|
|
843
929
|
}
|
|
844
930
|
function stockSnapshotQuery(params) {
|
|
845
|
-
return
|
|
931
|
+
return `${COMMERCE_ENDPOINTS.products.stockSnapshot}?variantIds=${params.variantIds.map(encodeURIComponent).join(",")}`;
|
|
846
932
|
}
|
|
847
933
|
|
|
848
934
|
// src/core/collection/http-client.ts
|
|
@@ -1741,78 +1827,81 @@ var CustomerNamespace = class {
|
|
|
1741
1827
|
// src/core/api/cart-api.ts
|
|
1742
1828
|
var CartApi = class extends CustomerScopedApi {
|
|
1743
1829
|
constructor(options) {
|
|
1744
|
-
super("CartApi", options);
|
|
1830
|
+
super("CartApi", { ...options, requiresCredential: false });
|
|
1745
1831
|
}
|
|
1746
1832
|
async execute(endpoint, method, body) {
|
|
1747
1833
|
return this.request(endpoint, { method, body });
|
|
1748
1834
|
}
|
|
1749
|
-
|
|
1835
|
+
/**
|
|
1836
|
+
* Create a cart and receive its `cartToken`. Store the token and pass it to
|
|
1837
|
+
* every subsequent cart operation.
|
|
1838
|
+
*/
|
|
1839
|
+
createCart(params = {}) {
|
|
1840
|
+
return this.execute("/api/carts/create", "POST", params);
|
|
1841
|
+
}
|
|
1842
|
+
getCart(cartToken) {
|
|
1843
|
+
return this.execute("/api/carts/get", "POST", { cartToken });
|
|
1844
|
+
}
|
|
1845
|
+
merge(params) {
|
|
1750
1846
|
return this.execute(
|
|
1751
|
-
|
|
1752
|
-
"
|
|
1847
|
+
COMMERCE_ENDPOINTS.carts.merge,
|
|
1848
|
+
"POST",
|
|
1849
|
+
params
|
|
1850
|
+
);
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Resolve the authenticated customer's active cart by JWT (no `cartToken`
|
|
1854
|
+
* required). Returns the cart and its capability handle, or both `null` when
|
|
1855
|
+
* the customer has no active cart. Requires a customer token.
|
|
1856
|
+
*/
|
|
1857
|
+
mine() {
|
|
1858
|
+
return this.execute(
|
|
1859
|
+
COMMERCE_ENDPOINTS.carts.mine,
|
|
1860
|
+
"POST",
|
|
1861
|
+
{}
|
|
1753
1862
|
);
|
|
1754
1863
|
}
|
|
1755
1864
|
addItem(params) {
|
|
1756
|
-
return this.execute(
|
|
1865
|
+
return this.execute(
|
|
1866
|
+
COMMERCE_ENDPOINTS.carts.addItem,
|
|
1867
|
+
"POST",
|
|
1868
|
+
params
|
|
1869
|
+
);
|
|
1757
1870
|
}
|
|
1758
1871
|
updateItem(params) {
|
|
1759
|
-
return this.execute(
|
|
1872
|
+
return this.execute(
|
|
1873
|
+
COMMERCE_ENDPOINTS.carts.updateItem,
|
|
1874
|
+
"POST",
|
|
1875
|
+
params
|
|
1876
|
+
);
|
|
1760
1877
|
}
|
|
1761
1878
|
removeItem(params) {
|
|
1762
1879
|
return this.execute(
|
|
1763
|
-
|
|
1880
|
+
COMMERCE_ENDPOINTS.carts.removeItem,
|
|
1764
1881
|
"POST",
|
|
1765
1882
|
params
|
|
1766
1883
|
);
|
|
1767
1884
|
}
|
|
1768
1885
|
applyDiscount(params) {
|
|
1769
|
-
return this.execute(
|
|
1886
|
+
return this.execute(
|
|
1887
|
+
COMMERCE_ENDPOINTS.carts.applyDiscount,
|
|
1888
|
+
"POST",
|
|
1889
|
+
params
|
|
1890
|
+
);
|
|
1770
1891
|
}
|
|
1771
1892
|
removeDiscount(params) {
|
|
1772
|
-
return this.execute("/api/carts/remove-discount", "POST", params);
|
|
1773
|
-
}
|
|
1774
|
-
clearCart(params) {
|
|
1775
1893
|
return this.execute(
|
|
1776
|
-
|
|
1894
|
+
COMMERCE_ENDPOINTS.carts.removeDiscount,
|
|
1777
1895
|
"POST",
|
|
1778
1896
|
params
|
|
1779
1897
|
);
|
|
1780
1898
|
}
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
if (!options.secretKey) {
|
|
1787
|
-
throw createConfigError(`secretKey is required for ${apiName}.`);
|
|
1788
|
-
}
|
|
1789
|
-
this.publishableKey = requirePublishableKeyForSecret(
|
|
1790
|
-
apiName,
|
|
1791
|
-
options.publishableKey,
|
|
1792
|
-
options.secretKey
|
|
1899
|
+
clearCart(params) {
|
|
1900
|
+
return this.execute(
|
|
1901
|
+
COMMERCE_ENDPOINTS.carts.clear,
|
|
1902
|
+
"POST",
|
|
1903
|
+
params
|
|
1793
1904
|
);
|
|
1794
|
-
this.secretKey = options.secretKey;
|
|
1795
|
-
this.apiUrl = options.apiUrl;
|
|
1796
|
-
this.onRequestId = options.onRequestId;
|
|
1797
|
-
}
|
|
1798
|
-
async request(endpoint, body, options) {
|
|
1799
|
-
const method = options?.method ?? "POST";
|
|
1800
|
-
try {
|
|
1801
|
-
const response = await httpFetch(endpoint, {
|
|
1802
|
-
method,
|
|
1803
|
-
apiUrl: this.apiUrl,
|
|
1804
|
-
publishableKey: this.publishableKey,
|
|
1805
|
-
secretKey: this.secretKey,
|
|
1806
|
-
...body !== void 0 && { body: JSON.stringify(body) },
|
|
1807
|
-
...options?.headers && { headers: options.headers }
|
|
1808
|
-
});
|
|
1809
|
-
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1810
|
-
return parseApiResponse(response, endpoint);
|
|
1811
|
-
} catch (err) {
|
|
1812
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1813
|
-
this.onRequestId?.(id);
|
|
1814
|
-
throw err;
|
|
1815
|
-
}
|
|
1816
1905
|
}
|
|
1817
1906
|
};
|
|
1818
1907
|
|
|
@@ -3261,6 +3350,7 @@ function compareVariantOrder(a, b) {
|
|
|
3261
3350
|
function getVariantAvailableForSale(variant) {
|
|
3262
3351
|
if (variant.isActive === false) return false;
|
|
3263
3352
|
if (variant.isUnlimited) return true;
|
|
3353
|
+
if (variant.inventoryPolicy === "continue") return true;
|
|
3264
3354
|
return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
|
|
3265
3355
|
}
|
|
3266
3356
|
function getVariantAvailableStock(variant) {
|
|
@@ -3621,37 +3711,6 @@ function withProductListingCards(response, options) {
|
|
|
3621
3711
|
cards: response.docs.map((item) => buildProductListingCard(item, options))
|
|
3622
3712
|
};
|
|
3623
3713
|
}
|
|
3624
|
-
function rejectLegacyOptionValueSwatchColor(value) {
|
|
3625
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
3626
|
-
value,
|
|
3627
|
-
"swatchColor"
|
|
3628
|
-
)) {
|
|
3629
|
-
throw new TypeError(
|
|
3630
|
-
'Product upsert option values no longer accept removed flat "swatchColor"; use nested "swatch" instead.'
|
|
3631
|
-
);
|
|
3632
|
-
}
|
|
3633
|
-
}
|
|
3634
|
-
function normalizeProductUpsertOptionValue(value) {
|
|
3635
|
-
rejectLegacyOptionValueSwatchColor(value);
|
|
3636
|
-
return value;
|
|
3637
|
-
}
|
|
3638
|
-
function normalizeProductUpsertParams(params) {
|
|
3639
|
-
const options = params.options ?? [];
|
|
3640
|
-
const variants = params.variants ?? [];
|
|
3641
|
-
if (!options.length) {
|
|
3642
|
-
return { ...params, options, variants };
|
|
3643
|
-
}
|
|
3644
|
-
return {
|
|
3645
|
-
...params,
|
|
3646
|
-
options: options.map((option) => ({
|
|
3647
|
-
...option,
|
|
3648
|
-
values: option.values.map(
|
|
3649
|
-
(value) => normalizeProductUpsertOptionValue(value)
|
|
3650
|
-
)
|
|
3651
|
-
})),
|
|
3652
|
-
variants
|
|
3653
|
-
};
|
|
3654
|
-
}
|
|
3655
3714
|
var PRODUCT_UPSERT_UNKNOWN_FIELD_REASON = "unknown_field";
|
|
3656
3715
|
var PRODUCT_UPSERT_READONLY_FIELD_REASON = "product_field_readonly";
|
|
3657
3716
|
function isProductUpsertFieldValidationErrorBody(value) {
|
|
@@ -3660,98 +3719,6 @@ function isProductUpsertFieldValidationErrorBody(value) {
|
|
|
3660
3719
|
const reason = body.reason;
|
|
3661
3720
|
return typeof body.error === "string" && typeof body.field === "string" && (reason === PRODUCT_UPSERT_UNKNOWN_FIELD_REASON || reason === PRODUCT_UPSERT_READONLY_FIELD_REASON);
|
|
3662
3721
|
}
|
|
3663
|
-
var ProductApi = class extends BaseApi {
|
|
3664
|
-
constructor(options) {
|
|
3665
|
-
super("ProductApi", options);
|
|
3666
|
-
}
|
|
3667
|
-
/**
|
|
3668
|
-
* Check point-in-time stock availability for one or more product variants.
|
|
3669
|
-
* Results reflect available stock at the moment of the call and are not guaranteed
|
|
3670
|
-
* to remain available by the time an order is placed.
|
|
3671
|
-
*/
|
|
3672
|
-
stockCheck(params) {
|
|
3673
|
-
return this.request("/api/products/stock-check", params);
|
|
3674
|
-
}
|
|
3675
|
-
stockSnapshot(params) {
|
|
3676
|
-
return this.request(
|
|
3677
|
-
stockSnapshotQuery(params),
|
|
3678
|
-
void 0,
|
|
3679
|
-
{ method: "GET" }
|
|
3680
|
-
);
|
|
3681
|
-
}
|
|
3682
|
-
listingGroups(params) {
|
|
3683
|
-
return this.request(
|
|
3684
|
-
listingGroupsQuery(params),
|
|
3685
|
-
void 0,
|
|
3686
|
-
{ method: "GET" }
|
|
3687
|
-
);
|
|
3688
|
-
}
|
|
3689
|
-
listingGroupsCatalog(params) {
|
|
3690
|
-
return this.request(
|
|
3691
|
-
listingGroupsCatalogQuery(params),
|
|
3692
|
-
void 0,
|
|
3693
|
-
{ method: "GET" }
|
|
3694
|
-
);
|
|
3695
|
-
}
|
|
3696
|
-
async listingPage(params = {}) {
|
|
3697
|
-
if (params.mode === "full") {
|
|
3698
|
-
const response2 = await this.request(buildProductListingPageUrl(params), void 0, { method: "GET" });
|
|
3699
|
-
return withProductListingCards(response2, params);
|
|
3700
|
-
}
|
|
3701
|
-
const response = await this.request(buildProductListingPageUrl(params), void 0, { method: "GET" });
|
|
3702
|
-
return withProductListingCards(response, params);
|
|
3703
|
-
}
|
|
3704
|
-
/**
|
|
3705
|
-
* Fetch full product detail by slug or id.
|
|
3706
|
-
* Returns a discriminated result so storefronts can distinguish missing,
|
|
3707
|
-
* unpublished, and feature-disabled products.
|
|
3708
|
-
*
|
|
3709
|
-
* Only product-detail 404 responses carrying one of those allowlisted reasons
|
|
3710
|
-
* are mapped to `{ found: false, reason }`. Unknown or uncoded 404s, plus
|
|
3711
|
-
* permission/auth errors such as tenant mismatch, continue to throw typed SDK
|
|
3712
|
-
* errors instead of being collapsed into a storefront absence result.
|
|
3713
|
-
*/
|
|
3714
|
-
async detail(params) {
|
|
3715
|
-
try {
|
|
3716
|
-
const product = await this.request(
|
|
3717
|
-
productDetailQuery(params),
|
|
3718
|
-
void 0,
|
|
3719
|
-
{ method: "GET" }
|
|
3720
|
-
);
|
|
3721
|
-
return { found: true, product };
|
|
3722
|
-
} catch (err) {
|
|
3723
|
-
const notFoundResult = productDetailResultFromError(err);
|
|
3724
|
-
if (notFoundResult) return notFoundResult;
|
|
3725
|
-
throw err;
|
|
3726
|
-
}
|
|
3727
|
-
}
|
|
3728
|
-
async detailCatalog(params) {
|
|
3729
|
-
try {
|
|
3730
|
-
const product = await this.request(
|
|
3731
|
-
productDetailCatalogQuery(params),
|
|
3732
|
-
void 0,
|
|
3733
|
-
{ method: "GET" }
|
|
3734
|
-
);
|
|
3735
|
-
return { found: true, product };
|
|
3736
|
-
} catch (err) {
|
|
3737
|
-
const notFoundResult = productDetailResultFromError(err);
|
|
3738
|
-
if (notFoundResult?.found === false) return notFoundResult;
|
|
3739
|
-
throw err;
|
|
3740
|
-
}
|
|
3741
|
-
}
|
|
3742
|
-
/**
|
|
3743
|
-
* Atomically create or update a product together with its options,
|
|
3744
|
-
* option-values, and variants in a single transaction. Mirrors Shopify's
|
|
3745
|
-
* `productSet` shape and is the canonical write path for the MCP
|
|
3746
|
-
* `product-upsert` tool.
|
|
3747
|
-
*/
|
|
3748
|
-
upsert(params) {
|
|
3749
|
-
return this.request(
|
|
3750
|
-
"/api/products/upsert",
|
|
3751
|
-
normalizeProductUpsertParams(params)
|
|
3752
|
-
);
|
|
3753
|
-
}
|
|
3754
|
-
};
|
|
3755
3722
|
|
|
3756
3723
|
// src/core/api/order-api.ts
|
|
3757
3724
|
function idempotencyRequestOptions(idempotencyKey) {
|
|
@@ -3761,126 +3728,6 @@ function splitIdempotencyKey(params) {
|
|
|
3761
3728
|
const { idempotencyKey, ...body } = params;
|
|
3762
3729
|
return { body, idempotencyKey };
|
|
3763
3730
|
}
|
|
3764
|
-
function normalizeCreateOrderBody(params) {
|
|
3765
|
-
if (params.items !== void 0) {
|
|
3766
|
-
const { idempotencyKey: _idempotencyKey2, items, ...rest } = params;
|
|
3767
|
-
return { ...rest, orderItems: items };
|
|
3768
|
-
}
|
|
3769
|
-
const { idempotencyKey: _idempotencyKey, ...body } = params;
|
|
3770
|
-
return body;
|
|
3771
|
-
}
|
|
3772
|
-
var OrderApi = class extends BaseApi {
|
|
3773
|
-
constructor(options) {
|
|
3774
|
-
super("OrderApi", options);
|
|
3775
|
-
}
|
|
3776
|
-
createOrder(params) {
|
|
3777
|
-
const { idempotencyKey } = params;
|
|
3778
|
-
const normalizedBody = normalizeCreateOrderBody(params);
|
|
3779
|
-
return this.request(
|
|
3780
|
-
"/api/orders/create",
|
|
3781
|
-
normalizedBody,
|
|
3782
|
-
idempotencyRequestOptions(idempotencyKey)
|
|
3783
|
-
);
|
|
3784
|
-
}
|
|
3785
|
-
updateOrder(params) {
|
|
3786
|
-
return this.request("/api/orders/update", params);
|
|
3787
|
-
}
|
|
3788
|
-
updateTransaction(params) {
|
|
3789
|
-
return this.request("/api/transactions/update", params);
|
|
3790
|
-
}
|
|
3791
|
-
confirmPayment(params) {
|
|
3792
|
-
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
3793
|
-
const headerKey = idempotencyKey ?? params.providerEventId;
|
|
3794
|
-
return this.request(
|
|
3795
|
-
"/api/orders/confirm-payment",
|
|
3796
|
-
body,
|
|
3797
|
-
idempotencyRequestOptions(headerKey)
|
|
3798
|
-
);
|
|
3799
|
-
}
|
|
3800
|
-
cancelOrder(params) {
|
|
3801
|
-
const { idempotencyKey } = params;
|
|
3802
|
-
const body = {
|
|
3803
|
-
orderNumber: params.orderNumber,
|
|
3804
|
-
reasonCode: params.reasonCode,
|
|
3805
|
-
reasonDetail: params.reasonDetail
|
|
3806
|
-
};
|
|
3807
|
-
return this.request(
|
|
3808
|
-
"/api/orders/cancel",
|
|
3809
|
-
body,
|
|
3810
|
-
idempotencyKey ? { headers: { "X-Idempotency-Key": idempotencyKey } } : void 0
|
|
3811
|
-
);
|
|
3812
|
-
}
|
|
3813
|
-
resolveCancelRefund(params) {
|
|
3814
|
-
return this.request(
|
|
3815
|
-
"/api/orders/resolve-cancel-refund",
|
|
3816
|
-
{
|
|
3817
|
-
orderNumber: params.orderNumber,
|
|
3818
|
-
idempotencyKey: params.idempotencyKey,
|
|
3819
|
-
outcome: params.outcome,
|
|
3820
|
-
refundedAmount: params.refundedAmount,
|
|
3821
|
-
pgProvider: params.pgProvider,
|
|
3822
|
-
...params.pgRefundId ? { pgRefundId: params.pgRefundId } : {}
|
|
3823
|
-
},
|
|
3824
|
-
idempotencyRequestOptions(params.idempotencyKey)
|
|
3825
|
-
);
|
|
3826
|
-
}
|
|
3827
|
-
/**
|
|
3828
|
-
* Returns a `PublicOrder`-compatible shape even when the server backs the
|
|
3829
|
-
* response with a Checkout (checkout/order separation, #1285). `orderNumber`
|
|
3830
|
-
* stays the stable cross-window key. A breaking `PublicCheckout` split is a
|
|
3831
|
-
* deferred follow-up (design D10 / Q3-b); do not change this return type here.
|
|
3832
|
-
*/
|
|
3833
|
-
checkout(params) {
|
|
3834
|
-
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
3835
|
-
return this.request(
|
|
3836
|
-
"/api/orders/checkout",
|
|
3837
|
-
body,
|
|
3838
|
-
idempotencyRequestOptions(idempotencyKey)
|
|
3839
|
-
);
|
|
3840
|
-
}
|
|
3841
|
-
createFulfillment(params) {
|
|
3842
|
-
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
3843
|
-
return this.request(
|
|
3844
|
-
"/api/orders/create-fulfillment",
|
|
3845
|
-
body,
|
|
3846
|
-
idempotencyRequestOptions(idempotencyKey)
|
|
3847
|
-
);
|
|
3848
|
-
}
|
|
3849
|
-
prepareFulfillmentOrder(params) {
|
|
3850
|
-
return this.request(
|
|
3851
|
-
"/api/fulfillment-orders/prepare-fulfillment-order",
|
|
3852
|
-
params
|
|
3853
|
-
);
|
|
3854
|
-
}
|
|
3855
|
-
updateFulfillment(params) {
|
|
3856
|
-
return this.request("/api/orders/update-fulfillment", params);
|
|
3857
|
-
}
|
|
3858
|
-
bulkImportFulfillments(params) {
|
|
3859
|
-
return this.request(
|
|
3860
|
-
"/api/fulfillments/bulk-import",
|
|
3861
|
-
params
|
|
3862
|
-
);
|
|
3863
|
-
}
|
|
3864
|
-
returnWithRefund(params) {
|
|
3865
|
-
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
3866
|
-
return this.request(
|
|
3867
|
-
"/api/returns/return-refund",
|
|
3868
|
-
body,
|
|
3869
|
-
idempotencyRequestOptions(idempotencyKey)
|
|
3870
|
-
);
|
|
3871
|
-
}
|
|
3872
|
-
createReturn(params) {
|
|
3873
|
-
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
3874
|
-
return this.request(
|
|
3875
|
-
"/api/returns/create",
|
|
3876
|
-
body,
|
|
3877
|
-
idempotencyRequestOptions(idempotencyKey)
|
|
3878
|
-
);
|
|
3879
|
-
}
|
|
3880
|
-
updateReturn(params) {
|
|
3881
|
-
return this.request("/api/returns/update", params);
|
|
3882
|
-
}
|
|
3883
|
-
};
|
|
3884
3731
|
|
|
3885
3732
|
// src/core/commerce/commerce-client.ts
|
|
3886
3733
|
var BrowserCommerceApi = class extends CustomerScopedApi {
|
|
@@ -3912,7 +3759,10 @@ var CommerceClient = class {
|
|
|
3912
3759
|
onRequestId: options.onRequestId
|
|
3913
3760
|
});
|
|
3914
3761
|
this.product = {
|
|
3915
|
-
stockCheck: (params) => api.post(
|
|
3762
|
+
stockCheck: (params) => api.post(
|
|
3763
|
+
COMMERCE_ENDPOINTS.products.stockCheck,
|
|
3764
|
+
params
|
|
3765
|
+
),
|
|
3916
3766
|
stockSnapshot: (params) => api.get(stockSnapshotQuery(params)),
|
|
3917
3767
|
listingGroups: (params) => api.get(
|
|
3918
3768
|
listingGroupsCatalogQuery(params)
|
|
@@ -3930,7 +3780,9 @@ var CommerceClient = class {
|
|
|
3930
3780
|
},
|
|
3931
3781
|
detail: async (params) => {
|
|
3932
3782
|
try {
|
|
3933
|
-
const product = await api.get(
|
|
3783
|
+
const product = await api.get(
|
|
3784
|
+
productDetailQuery(params)
|
|
3785
|
+
);
|
|
3934
3786
|
return { found: true, product };
|
|
3935
3787
|
} catch (err) {
|
|
3936
3788
|
const notFoundResult = productDetailResultFromError(err);
|
|
@@ -3952,13 +3804,16 @@ var CommerceClient = class {
|
|
|
3952
3804
|
}
|
|
3953
3805
|
};
|
|
3954
3806
|
this.cart = {
|
|
3807
|
+
create: cartApi.createCart.bind(cartApi),
|
|
3955
3808
|
get: cartApi.getCart.bind(cartApi),
|
|
3956
3809
|
addItem: cartApi.addItem.bind(cartApi),
|
|
3957
3810
|
updateItem: cartApi.updateItem.bind(cartApi),
|
|
3958
3811
|
removeItem: cartApi.removeItem.bind(cartApi),
|
|
3959
3812
|
applyDiscount: cartApi.applyDiscount.bind(cartApi),
|
|
3960
3813
|
removeDiscount: cartApi.removeDiscount.bind(cartApi),
|
|
3961
|
-
clear: cartApi.clearCart.bind(cartApi)
|
|
3814
|
+
clear: cartApi.clearCart.bind(cartApi),
|
|
3815
|
+
merge: cartApi.merge.bind(cartApi),
|
|
3816
|
+
mine: cartApi.mine.bind(cartApi)
|
|
3962
3817
|
};
|
|
3963
3818
|
this.orders = {
|
|
3964
3819
|
checkout: (params) => {
|
|
@@ -3975,7 +3830,10 @@ var CommerceClient = class {
|
|
|
3975
3830
|
validate: (params) => api.post("/api/discounts/validate", params)
|
|
3976
3831
|
};
|
|
3977
3832
|
this.shipping = {
|
|
3978
|
-
calculate: (params) => api.post(
|
|
3833
|
+
calculate: (params) => api.post(
|
|
3834
|
+
"/api/shipping-policies/calculate",
|
|
3835
|
+
params
|
|
3836
|
+
)
|
|
3979
3837
|
};
|
|
3980
3838
|
}
|
|
3981
3839
|
};
|
|
@@ -4064,8 +3922,12 @@ function buildGuestCancelRequestBody(token, params) {
|
|
|
4064
3922
|
}
|
|
4065
3923
|
function buildRangeEndpoint(params) {
|
|
4066
3924
|
const urlParams = new URLSearchParams();
|
|
4067
|
-
|
|
4068
|
-
|
|
3925
|
+
if (params.start !== void 0) {
|
|
3926
|
+
urlParams.set("start", formatDateParam(params.start));
|
|
3927
|
+
}
|
|
3928
|
+
if (params.end !== void 0) {
|
|
3929
|
+
urlParams.set("end", formatDateParam(params.end));
|
|
3930
|
+
}
|
|
4069
3931
|
if (params.limit !== void 0) urlParams.set("limit", String(params.limit));
|
|
4070
3932
|
if (params.page !== void 0) urlParams.set("page", String(params.page));
|
|
4071
3933
|
appendValues(urlParams, "calendar", params.calendar);
|
|
@@ -4088,6 +3950,13 @@ function appendValues(params, key, value) {
|
|
|
4088
3950
|
}
|
|
4089
3951
|
|
|
4090
3952
|
// src/core/client/client.ts
|
|
3953
|
+
var BrowserMembershipApi = class extends CustomerScopedApi {
|
|
3954
|
+
me() {
|
|
3955
|
+
return this.request(MEMBERSHIP_ENDPOINTS.me, {
|
|
3956
|
+
method: "GET"
|
|
3957
|
+
});
|
|
3958
|
+
}
|
|
3959
|
+
};
|
|
4091
3960
|
var Client = class {
|
|
4092
3961
|
constructor(options) {
|
|
4093
3962
|
this.lastRequestId = null;
|
|
@@ -4152,6 +4021,16 @@ var Client = class {
|
|
|
4152
4021
|
onRequestId,
|
|
4153
4022
|
this.config.apiUrl
|
|
4154
4023
|
);
|
|
4024
|
+
const membershipApi = new BrowserMembershipApi("MembershipApi", {
|
|
4025
|
+
publishableKey: this.config.publishableKey,
|
|
4026
|
+
apiUrl: this.config.apiUrl,
|
|
4027
|
+
customerToken: () => this.customer.auth.getToken(),
|
|
4028
|
+
onUnauthorized,
|
|
4029
|
+
onRequestId
|
|
4030
|
+
});
|
|
4031
|
+
this.memberships = {
|
|
4032
|
+
me: membershipApi.me.bind(membershipApi)
|
|
4033
|
+
};
|
|
4155
4034
|
}
|
|
4156
4035
|
getState() {
|
|
4157
4036
|
return { ...this.state };
|
|
@@ -4164,26 +4043,6 @@ function createClient(options) {
|
|
|
4164
4043
|
return new Client(options);
|
|
4165
4044
|
}
|
|
4166
4045
|
|
|
4167
|
-
// src/core/api/discount-api.ts
|
|
4168
|
-
var DiscountApi = class extends BaseApi {
|
|
4169
|
-
constructor(options) {
|
|
4170
|
-
super("DiscountApi", options);
|
|
4171
|
-
}
|
|
4172
|
-
validate(params) {
|
|
4173
|
-
return this.request("/api/discounts/validate", params);
|
|
4174
|
-
}
|
|
4175
|
-
};
|
|
4176
|
-
|
|
4177
|
-
// src/core/api/shipping-api.ts
|
|
4178
|
-
var ShippingApi = class extends BaseApi {
|
|
4179
|
-
constructor(options) {
|
|
4180
|
-
super("ShippingApi", options);
|
|
4181
|
-
}
|
|
4182
|
-
calculate(params) {
|
|
4183
|
-
return this.request("/api/shipping-policies/calculate", params);
|
|
4184
|
-
}
|
|
4185
|
-
};
|
|
4186
|
-
|
|
4187
4046
|
// src/core/commerce/merge-catalog-stock.ts
|
|
4188
4047
|
function mergeProductDetailWithStock(catalog, snapshot) {
|
|
4189
4048
|
const snapshotByVariantId = new Map(
|
|
@@ -4239,6 +4098,8 @@ var COMMERCE_NOTIFICATION_EVENTS = [
|
|
|
4239
4098
|
"fulfillmentShipped",
|
|
4240
4099
|
"orderDelivered",
|
|
4241
4100
|
"returnRequested",
|
|
4101
|
+
"returnApproved",
|
|
4102
|
+
"returnRejected",
|
|
4242
4103
|
"returnCompleted"
|
|
4243
4104
|
];
|
|
4244
4105
|
function isStringOrNumber(value) {
|
|
@@ -4327,7 +4188,7 @@ function isCommerceNotificationWebhookEvent(event) {
|
|
|
4327
4188
|
if (notification.event === "fulfillmentShipped") {
|
|
4328
4189
|
return sourceCollection === "fulfillments" && matchesOptionalId(data.fulfillmentId, sourceId) && typeof notification.fulfillmentId === "string" && notification.fulfillmentId.length > 0 && matchesOptionalId(notification.fulfillmentId, sourceId) && matchesOptionalId(data.fulfillmentId, notification.fulfillmentId) && matchesOptionalId(changeSourceId, notification.fulfillmentId);
|
|
4329
4190
|
}
|
|
4330
|
-
if (notification.event === "returnRequested" || notification.event === "returnCompleted") {
|
|
4191
|
+
if (notification.event === "returnRequested" || notification.event === "returnApproved" || notification.event === "returnRejected" || notification.event === "returnCompleted") {
|
|
4331
4192
|
return sourceCollection === "returns" && matchesOptionalId(data.returnId, sourceId) && typeof notification.returnId === "string" && notification.returnId.length > 0 && matchesOptionalId(notification.returnId, sourceId) && matchesOptionalId(data.returnId, notification.returnId) && matchesOptionalId(changeSourceId, notification.returnId);
|
|
4332
4193
|
}
|
|
4333
4194
|
return false;
|
|
@@ -4510,7 +4371,9 @@ var INTERNAL_COLLECTIONS = [
|
|
|
4510
4371
|
"audit-logs",
|
|
4511
4372
|
"plans",
|
|
4512
4373
|
"webhooks",
|
|
4513
|
-
"event-registrations"
|
|
4374
|
+
"event-registrations",
|
|
4375
|
+
"customer-payment-methods",
|
|
4376
|
+
"tenant-payment-credentials"
|
|
4514
4377
|
];
|
|
4515
4378
|
var COLLECTIONS = [
|
|
4516
4379
|
"tenants",
|
|
@@ -4522,6 +4385,7 @@ var COLLECTIONS = [
|
|
|
4522
4385
|
"product-categories",
|
|
4523
4386
|
"product-tags",
|
|
4524
4387
|
"product-collections",
|
|
4388
|
+
"markets",
|
|
4525
4389
|
"brands",
|
|
4526
4390
|
"customer-profiles",
|
|
4527
4391
|
"customer-profile-stats",
|
|
@@ -4566,7 +4430,9 @@ var COLLECTIONS = [
|
|
|
4566
4430
|
"events",
|
|
4567
4431
|
"event-categories",
|
|
4568
4432
|
"event-occurrences",
|
|
4569
|
-
"event-tags"
|
|
4433
|
+
"event-tags",
|
|
4434
|
+
"membership-plans",
|
|
4435
|
+
"customer-memberships"
|
|
4570
4436
|
];
|
|
4571
4437
|
var SERVER_ONLY_COLLECTIONS = [
|
|
4572
4438
|
"tenant-logos",
|
|
@@ -4599,7 +4465,8 @@ var SERVER_ONLY_COLLECTIONS = [
|
|
|
4599
4465
|
"customer-groups",
|
|
4600
4466
|
"reports",
|
|
4601
4467
|
"community-bans",
|
|
4602
|
-
"order-export-profiles"
|
|
4468
|
+
"order-export-profiles",
|
|
4469
|
+
"membership-charges"
|
|
4603
4470
|
];
|
|
4604
4471
|
var SERVER_COLLECTIONS = [
|
|
4605
4472
|
...COLLECTIONS,
|