@01.software/sdk 0.48.0 → 0.51.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 +157 -1
- package/MIGRATION.md +56 -0
- package/README.md +276 -49
- package/dist/client.cjs +375 -161
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +7 -6
- package/dist/client.d.ts +7 -6
- package/dist/client.js +375 -161
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-CBup9yOx.d.cts → collection-client-CWAeuzV4.d.cts} +6 -4
- package/dist/{collection-client-D3ExJU-7.d.ts → collection-client-hYvVfHIm.d.ts} +6 -4
- package/dist/{const-k9gHylYa.d.ts → const-D8LixhAJ.d.cts} +5 -5
- package/dist/{const-BXEi1Kix.d.cts → const-JD8obaKg.d.ts} +5 -5
- package/dist/embedded-admin/server.cjs +306 -0
- package/dist/embedded-admin/server.cjs.map +1 -0
- package/dist/embedded-admin/server.d.cts +33 -0
- package/dist/embedded-admin/server.d.ts +33 -0
- package/dist/embedded-admin/server.js +288 -0
- package/dist/embedded-admin/server.js.map +1 -0
- package/dist/embedded-admin.cjs +400 -0
- package/dist/embedded-admin.cjs.map +1 -0
- package/dist/embedded-admin.d.cts +61 -0
- package/dist/embedded-admin.d.ts +61 -0
- package/dist/embedded-admin.js +377 -0
- package/dist/embedded-admin.js.map +1 -0
- package/dist/errors.cjs +64 -15
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +13 -4
- package/dist/errors.d.ts +13 -4
- package/dist/errors.js +64 -15
- package/dist/errors.js.map +1 -1
- package/dist/{index-BCM9CTL7.d.cts → index-B0Hjh3Ey.d.ts} +72 -10
- package/dist/{index-CHGGkcLj.d.ts → index-Bu0kCc6o.d.cts} +72 -10
- package/dist/index.cjs +470 -429
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -67
- package/dist/index.d.ts +9 -67
- package/dist/index.js +470 -429
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-B6AZQcB7.d.cts → payload-types-BOsckg8B.d.cts} +396 -57
- package/dist/{payload-types-B6AZQcB7.d.ts → payload-types-BOsckg8B.d.ts} +396 -57
- package/dist/query.cjs +115 -70
- 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 +115 -70
- package/dist/query.js.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/server.cjs +591 -186
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +8 -7
- package/dist/server.d.ts +8 -7
- package/dist/server.js +591 -186
- package/dist/server.js.map +1 -1
- package/dist/storefront-cache.cjs +22 -0
- package/dist/storefront-cache.cjs.map +1 -1
- package/dist/storefront-cache.js +22 -0
- package/dist/storefront-cache.js.map +1 -1
- package/dist/{types-ByD2zii1.d.ts → types-5ZlcAFuU.d.ts} +2 -2
- package/dist/{types-8us-_C-Q.d.cts → types-B14sEt1z.d.cts} +2 -2
- package/dist/{types-CM2je9Kw.d.cts → types-Bj8j7VHU.d.ts} +107 -26
- package/dist/{types-DbA5V3mt.d.ts → types-CM5qiR2k.d.cts} +107 -26
- 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 +124 -80
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +21 -5
- package/dist/webhook.d.ts +21 -5
- package/dist/webhook.js +124 -80
- package/dist/webhook.js.map +1 -1
- package/package.json +27 -5
package/dist/query.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
2
|
import { QueryClient, UseQueryResult, UseSuspenseQueryResult, InfiniteData, UseInfiniteQueryResult, UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';
|
|
3
|
-
import { i as ApiQueryOptions, P as PayloadFindResponse,
|
|
4
|
-
import './payload-types-
|
|
5
|
-
import { S as ServerCollection, P as PublicCollection } from './const-
|
|
6
|
-
import { C as CollectionClient } from './collection-client-
|
|
7
|
-
import { C as CollectionType } from './types-
|
|
3
|
+
import { i as ApiQueryOptions, P as PayloadFindResponse, c4 as PublicReadQueryOptions, L as PayloadMutationResponse, c5 as CustomerAuth, c6 as CustomerProfile, c7 as CustomerAuthResponse, c8 as CustomerLoginData, c9 as CustomerRegisterResponse, ca as CustomerRegisterData, cb as CustomerRefreshResponse, cc as UpdateProfileData, cd as ProductListingPageParams, ce as ProductListingPageBaseParams, cf as ProductDetailParams, cg as ProductDetailCatalogResult, ch as ProductListingPageCatalogParams, ci as ProductListingPageResult, cj as ProductListingGroupsCatalogItem, ck as ProductListingPageFullParams, cl as ProductListingGroupsItem, al as RootClient, bL as RootServerClient } from './types-CM5qiR2k.cjs';
|
|
4
|
+
import './payload-types-BOsckg8B.cjs';
|
|
5
|
+
import { S as ServerCollection, P as PublicCollection } from './const-D8LixhAJ.cjs';
|
|
6
|
+
import { C as CollectionClient } from './collection-client-CWAeuzV4.cjs';
|
|
7
|
+
import { C as CollectionType } from './types-B14sEt1z.cjs';
|
|
8
8
|
import { SDKError } from './errors.cjs';
|
|
9
9
|
export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
|
|
10
10
|
import './metadata.cjs';
|
package/dist/query.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
2
|
import { QueryClient, UseQueryResult, UseSuspenseQueryResult, InfiniteData, UseInfiniteQueryResult, UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';
|
|
3
|
-
import { i as ApiQueryOptions, P as PayloadFindResponse,
|
|
4
|
-
import './payload-types-
|
|
5
|
-
import { S as ServerCollection, P as PublicCollection } from './const-
|
|
6
|
-
import { C as CollectionClient } from './collection-client-
|
|
7
|
-
import { C as CollectionType } from './types-
|
|
3
|
+
import { i as ApiQueryOptions, P as PayloadFindResponse, c4 as PublicReadQueryOptions, L as PayloadMutationResponse, c5 as CustomerAuth, c6 as CustomerProfile, c7 as CustomerAuthResponse, c8 as CustomerLoginData, c9 as CustomerRegisterResponse, ca as CustomerRegisterData, cb as CustomerRefreshResponse, cc as UpdateProfileData, cd as ProductListingPageParams, ce as ProductListingPageBaseParams, cf as ProductDetailParams, cg as ProductDetailCatalogResult, ch as ProductListingPageCatalogParams, ci as ProductListingPageResult, cj as ProductListingGroupsCatalogItem, ck as ProductListingPageFullParams, cl as ProductListingGroupsItem, al as RootClient, bL as RootServerClient } from './types-Bj8j7VHU.js';
|
|
4
|
+
import './payload-types-BOsckg8B.js';
|
|
5
|
+
import { S as ServerCollection, P as PublicCollection } from './const-JD8obaKg.js';
|
|
6
|
+
import { C as CollectionClient } from './collection-client-hYvVfHIm.js';
|
|
7
|
+
import { C as CollectionType } from './types-5ZlcAFuU.js';
|
|
8
8
|
import { SDKError } from './errors.js';
|
|
9
9
|
export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.js';
|
|
10
10
|
import './metadata.js';
|
package/dist/query.js
CHANGED
|
@@ -475,6 +475,24 @@ import {
|
|
|
475
475
|
} from "@tanstack/react-query";
|
|
476
476
|
|
|
477
477
|
// src/core/errors.ts
|
|
478
|
+
var SDK_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@01.software/sdk/SDKError");
|
|
479
|
+
var SDK_ERROR_TYPE_BRAND = /* @__PURE__ */ Symbol.for("@01.software/sdk/SDKError.type");
|
|
480
|
+
function defineSDKErrorBrand(error) {
|
|
481
|
+
Object.defineProperty(error, SDK_ERROR_BRAND, {
|
|
482
|
+
value: true,
|
|
483
|
+
enumerable: false,
|
|
484
|
+
configurable: false,
|
|
485
|
+
writable: false
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
function defineSDKErrorType(error, type) {
|
|
489
|
+
Object.defineProperty(error, SDK_ERROR_TYPE_BRAND, {
|
|
490
|
+
value: type,
|
|
491
|
+
enumerable: false,
|
|
492
|
+
configurable: false,
|
|
493
|
+
writable: false
|
|
494
|
+
});
|
|
495
|
+
}
|
|
478
496
|
var SDKError = class extends Error {
|
|
479
497
|
constructor(code, message, status, details, userMessage, suggestion, requestId) {
|
|
480
498
|
super(message);
|
|
@@ -485,6 +503,7 @@ var SDKError = class extends Error {
|
|
|
485
503
|
this.userMessage = userMessage;
|
|
486
504
|
this.suggestion = suggestion;
|
|
487
505
|
this.requestId = requestId;
|
|
506
|
+
defineSDKErrorBrand(this);
|
|
488
507
|
if (Error.captureStackTrace) {
|
|
489
508
|
Error.captureStackTrace(this, new.target);
|
|
490
509
|
}
|
|
@@ -505,6 +524,7 @@ var SDKError = class extends Error {
|
|
|
505
524
|
...this.kind !== void 0 && { kind: this.kind },
|
|
506
525
|
...this.reason !== void 0 && { reason: this.reason },
|
|
507
526
|
...this.rawReason !== void 0 && { rawReason: this.rawReason },
|
|
527
|
+
...this.apiReason !== void 0 && { apiReason: this.apiReason },
|
|
508
528
|
...this.retryable !== void 0 && { retryable: this.retryable },
|
|
509
529
|
...this.retryAfter !== void 0 && { retryAfter: this.retryAfter }
|
|
510
530
|
};
|
|
@@ -550,6 +570,7 @@ var COMMERCE_ERROR_CODES = [
|
|
|
550
570
|
"payment_session_not_cancelable",
|
|
551
571
|
"payment_session_conflict",
|
|
552
572
|
"provider_identity_mismatch",
|
|
573
|
+
"managed_refund_attestation_forbidden",
|
|
553
574
|
"payment_method_unavailable",
|
|
554
575
|
"provider_unavailable",
|
|
555
576
|
"lock_timeout",
|
|
@@ -621,6 +642,7 @@ var ConfigError = class extends SDKError {
|
|
|
621
642
|
constructor(message, details, userMessage, suggestion) {
|
|
622
643
|
super("CONFIG_ERROR", message, void 0, details, userMessage, suggestion);
|
|
623
644
|
this.name = "ConfigError";
|
|
645
|
+
defineSDKErrorType(this, "ConfigError");
|
|
624
646
|
}
|
|
625
647
|
};
|
|
626
648
|
var createConfigError = (message, details, userMessage, suggestion) => new ConfigError(message, details, userMessage, suggestion);
|
|
@@ -790,6 +812,10 @@ var operation = (collection, method, path, errorFamily) => Object.freeze({
|
|
|
790
812
|
...errorFamily && { errorFamily }
|
|
791
813
|
});
|
|
792
814
|
var strictCommerceOperation = (collection, method, path) => operation(collection, method, path, "commerce");
|
|
815
|
+
var selectiveCommerceOperation = (collection, method, path, typedCommerceErrorReasons) => Object.freeze({
|
|
816
|
+
...operation(collection, method, path),
|
|
817
|
+
typedCommerceErrorReasons: Object.freeze([...typedCommerceErrorReasons])
|
|
818
|
+
});
|
|
793
819
|
var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
794
820
|
products: {
|
|
795
821
|
detail: operation("products", "get", "/detail"),
|
|
@@ -821,7 +847,12 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
821
847
|
confirmPayment: operation("orders", "post", "/confirm-payment"),
|
|
822
848
|
byPayment: operation("orders", "get", "/by-payment"),
|
|
823
849
|
cancel: operation("orders", "post", "/cancel"),
|
|
824
|
-
resolveCancelRefund:
|
|
850
|
+
resolveCancelRefund: selectiveCommerceOperation(
|
|
851
|
+
"orders",
|
|
852
|
+
"post",
|
|
853
|
+
"/resolve-cancel-refund",
|
|
854
|
+
["managed_refund_attestation_forbidden"]
|
|
855
|
+
),
|
|
825
856
|
checkout: strictCommerceOperation("orders", "post", "/checkout"),
|
|
826
857
|
createFulfillment: operation("orders", "post", "/create-fulfillment"),
|
|
827
858
|
updateFulfillment: operation("orders", "post", "/update-fulfillment")
|
|
@@ -892,6 +923,16 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
892
923
|
"payment-sessions",
|
|
893
924
|
"post",
|
|
894
925
|
"/server/confirm"
|
|
926
|
+
),
|
|
927
|
+
findPortOne: strictCommerceOperation(
|
|
928
|
+
"payment-sessions",
|
|
929
|
+
"post",
|
|
930
|
+
"/server/portone/find"
|
|
931
|
+
),
|
|
932
|
+
reconcilePortOne: strictCommerceOperation(
|
|
933
|
+
"payment-sessions",
|
|
934
|
+
"post",
|
|
935
|
+
"/server/portone/reconcile"
|
|
895
936
|
)
|
|
896
937
|
},
|
|
897
938
|
custom: {
|
|
@@ -911,12 +952,26 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
911
952
|
validate: operation("discounts", "post", "/validate")
|
|
912
953
|
}
|
|
913
954
|
};
|
|
955
|
+
var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
|
|
956
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create,
|
|
957
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve,
|
|
958
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create,
|
|
959
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve
|
|
960
|
+
]);
|
|
914
961
|
var MEMBERSHIP_ENDPOINT_OPERATIONS = {
|
|
915
962
|
subscribe: operation(null, "post", "/memberships/subscribe"),
|
|
916
963
|
cancel: operation(null, "post", "/memberships/:id/cancel"),
|
|
917
964
|
me: operation(null, "get", "/memberships/me")
|
|
918
965
|
};
|
|
966
|
+
var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
|
|
967
|
+
show: operation("tenants", "get", "/embedded-admin-app"),
|
|
968
|
+
configure: operation("tenants", "patch", "/embedded-admin-app"),
|
|
969
|
+
disable: operation("tenants", "delete", "/embedded-admin-app")
|
|
970
|
+
};
|
|
919
971
|
var EVENTS_ENDPOINT_OPERATIONS = {
|
|
972
|
+
events: {
|
|
973
|
+
convertSchedule: operation("events", "post", "/:id/schedule")
|
|
974
|
+
},
|
|
920
975
|
occurrences: {
|
|
921
976
|
range: operation("event-occurrences", "get", "/range"),
|
|
922
977
|
admissionAvailability: operation(
|
|
@@ -954,40 +1009,48 @@ function resolveOperationPath(descriptor, options) {
|
|
|
954
1009
|
}
|
|
955
1010
|
|
|
956
1011
|
// src/core/api/endpoints.ts
|
|
957
|
-
var endpoint = (method, path) => ({ method, path });
|
|
958
1012
|
var sharedEndpoint = (descriptor) => descriptor;
|
|
959
|
-
function resolveOperationPath2(descriptor, options) {
|
|
960
|
-
if ("collection" in descriptor) {
|
|
961
|
-
return resolveOperationPath(descriptor, options);
|
|
962
|
-
}
|
|
963
|
-
const query = options?.query?.toString().replace(/^\?/, "");
|
|
964
|
-
return query ? `${descriptor.path}?${query}` : descriptor.path;
|
|
965
|
-
}
|
|
966
1013
|
var COMMERCE_ENDPOINTS = {
|
|
967
1014
|
products: {
|
|
968
|
-
detail:
|
|
969
|
-
detailCatalog:
|
|
970
|
-
|
|
971
|
-
listingGroupsCatalog: endpoint(
|
|
972
|
-
"GET",
|
|
973
|
-
"/api/products/listing-groups/catalog"
|
|
1015
|
+
detail: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.detail),
|
|
1016
|
+
detailCatalog: sharedEndpoint(
|
|
1017
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.detailCatalog
|
|
974
1018
|
),
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
"GET",
|
|
978
|
-
"/api/products/listing-groups/query/catalog"
|
|
1019
|
+
listingGroups: sharedEndpoint(
|
|
1020
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroups
|
|
979
1021
|
),
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
1022
|
+
listingGroupsCatalog: sharedEndpoint(
|
|
1023
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsCatalog
|
|
1024
|
+
),
|
|
1025
|
+
// The manifest keeps the GET read and the POST body-query apart; this
|
|
1026
|
+
// semantic name has always resolved to the GET one.
|
|
1027
|
+
listingGroupsQuery: sharedEndpoint(
|
|
1028
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryGet
|
|
1029
|
+
),
|
|
1030
|
+
listingGroupsQueryCatalog: sharedEndpoint(
|
|
1031
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog
|
|
1032
|
+
),
|
|
1033
|
+
stockCheck: sharedEndpoint(
|
|
1034
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.stockCheck
|
|
1035
|
+
),
|
|
1036
|
+
stockSnapshot: sharedEndpoint(
|
|
1037
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.stockSnapshot
|
|
1038
|
+
),
|
|
1039
|
+
upsert: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.upsert)
|
|
983
1040
|
},
|
|
984
1041
|
orders: {
|
|
985
|
-
update:
|
|
986
|
-
byPayment:
|
|
987
|
-
cancel:
|
|
988
|
-
resolveCancelRefund:
|
|
989
|
-
|
|
990
|
-
|
|
1042
|
+
update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.update),
|
|
1043
|
+
byPayment: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.byPayment),
|
|
1044
|
+
cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.cancel),
|
|
1045
|
+
resolveCancelRefund: sharedEndpoint(
|
|
1046
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.resolveCancelRefund
|
|
1047
|
+
),
|
|
1048
|
+
createFulfillment: sharedEndpoint(
|
|
1049
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.createFulfillment
|
|
1050
|
+
),
|
|
1051
|
+
updateFulfillment: sharedEndpoint(
|
|
1052
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.updateFulfillment
|
|
1053
|
+
)
|
|
991
1054
|
},
|
|
992
1055
|
checkouts: {
|
|
993
1056
|
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
|
|
@@ -999,18 +1062,21 @@ var COMMERCE_ENDPOINTS = {
|
|
|
999
1062
|
}
|
|
1000
1063
|
},
|
|
1001
1064
|
returns: {
|
|
1002
|
-
create:
|
|
1003
|
-
update:
|
|
1004
|
-
returnRefund:
|
|
1065
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.create),
|
|
1066
|
+
update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.update),
|
|
1067
|
+
returnRefund: sharedEndpoint(
|
|
1068
|
+
COMMERCE_ENDPOINT_OPERATIONS.returns.returnRefund
|
|
1069
|
+
)
|
|
1005
1070
|
},
|
|
1006
1071
|
fulfillmentOrders: {
|
|
1007
|
-
prepare:
|
|
1008
|
-
|
|
1009
|
-
"/api/fulfillment-orders/prepare-fulfillment-order"
|
|
1072
|
+
prepare: sharedEndpoint(
|
|
1073
|
+
COMMERCE_ENDPOINT_OPERATIONS.fulfillmentOrders.prepare
|
|
1010
1074
|
)
|
|
1011
1075
|
},
|
|
1012
1076
|
fulfillments: {
|
|
1013
|
-
bulkImport:
|
|
1077
|
+
bulkImport: sharedEndpoint(
|
|
1078
|
+
COMMERCE_ENDPOINT_OPERATIONS.fulfillments.bulkImport
|
|
1079
|
+
)
|
|
1014
1080
|
},
|
|
1015
1081
|
carts: {
|
|
1016
1082
|
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
|
|
@@ -1075,57 +1141,36 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1075
1141
|
),
|
|
1076
1142
|
confirm: sharedEndpoint(
|
|
1077
1143
|
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm
|
|
1144
|
+
),
|
|
1145
|
+
findPortOne: sharedEndpoint(
|
|
1146
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.findPortOne
|
|
1147
|
+
),
|
|
1148
|
+
reconcilePortOne: sharedEndpoint(
|
|
1149
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.reconcilePortOne
|
|
1078
1150
|
)
|
|
1079
1151
|
}
|
|
1080
1152
|
},
|
|
1081
1153
|
shippingPolicies: {
|
|
1082
|
-
calculate:
|
|
1154
|
+
calculate: sharedEndpoint(
|
|
1155
|
+
COMMERCE_ENDPOINT_OPERATIONS.shippingPolicies.calculate
|
|
1156
|
+
)
|
|
1083
1157
|
}
|
|
1084
1158
|
};
|
|
1085
|
-
function isCommerceEndpointDescriptor(value) {
|
|
1086
|
-
if (!value || typeof value !== "object") return false;
|
|
1087
|
-
const candidate = value;
|
|
1088
|
-
return typeof candidate.method === "string" && typeof candidate.path === "string";
|
|
1089
|
-
}
|
|
1090
|
-
function flattenEndpointPaths(value) {
|
|
1091
|
-
if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
|
|
1092
|
-
if (!value || typeof value !== "object") return [];
|
|
1093
|
-
return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
|
|
1094
|
-
}
|
|
1095
|
-
function flattenEndpointDescriptors(value) {
|
|
1096
|
-
if (isCommerceEndpointDescriptor(value)) return [value];
|
|
1097
|
-
if (!value || typeof value !== "object") return [];
|
|
1098
|
-
return Object.values(value).flatMap(
|
|
1099
|
-
(entry) => flattenEndpointDescriptors(entry)
|
|
1100
|
-
);
|
|
1101
|
-
}
|
|
1102
|
-
var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
|
|
1103
|
-
var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
|
|
1104
|
-
var MEMBERSHIP_ENDPOINTS = {
|
|
1105
|
-
subscribe: "/api/memberships/subscribe",
|
|
1106
|
-
cancel: (id) => `/api/memberships/${id}/cancel`,
|
|
1107
|
-
me: "/api/memberships/me"
|
|
1108
|
-
};
|
|
1109
|
-
var MEMBERSHIP_ENDPOINT_PATHS = [
|
|
1110
|
-
MEMBERSHIP_ENDPOINTS.subscribe,
|
|
1111
|
-
MEMBERSHIP_ENDPOINTS.cancel(":id"),
|
|
1112
|
-
MEMBERSHIP_ENDPOINTS.me
|
|
1113
|
-
];
|
|
1114
1159
|
|
|
1115
1160
|
// src/core/query/query-hooks.ts
|
|
1116
1161
|
function normalizeMarket(market) {
|
|
1117
1162
|
const normalized = market?.trim();
|
|
1118
1163
|
return normalized || void 0;
|
|
1119
1164
|
}
|
|
1120
|
-
function requestCommerceFindEndpoint(collectionClient,
|
|
1121
|
-
const path =
|
|
1122
|
-
if (
|
|
1165
|
+
function requestCommerceFindEndpoint(collectionClient, endpoint, options) {
|
|
1166
|
+
const path = resolveOperationPath(endpoint, { query: options?.query });
|
|
1167
|
+
if (endpoint.method === "get") {
|
|
1123
1168
|
return collectionClient.requestFindEndpointGet(path);
|
|
1124
1169
|
}
|
|
1125
|
-
if (
|
|
1170
|
+
if (endpoint.method === "post") {
|
|
1126
1171
|
return collectionClient.requestFindEndpoint(path, options?.data);
|
|
1127
1172
|
}
|
|
1128
|
-
throw new TypeError(`Unsupported find endpoint method: ${
|
|
1173
|
+
throw new TypeError(`Unsupported find endpoint method: ${endpoint.method}`);
|
|
1129
1174
|
}
|
|
1130
1175
|
function withDefaultMarket(params, market) {
|
|
1131
1176
|
const defaultMarket = normalizeMarket(market);
|