@01.software/sdk 0.43.0 → 0.45.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 +375 -2
- package/MIGRATION.md +89 -10
- package/README.md +451 -109
- package/dist/{server-nXOezi4b.d.cts → catalog-mappers-sIshKNb3.d.cts} +14 -3
- package/dist/{server-nXOezi4b.d.ts → catalog-mappers-sIshKNb3.d.ts} +14 -3
- package/dist/client.cjs +2680 -345
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +10 -7
- package/dist/client.d.ts +10 -7
- package/dist/client.js +2680 -345
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-U70KizLf.d.cts → collection-client-BSo7VXQE.d.cts} +8 -5
- package/dist/{collection-client-gWsA7BVP.d.ts → collection-client-Ckfusuee.d.ts} +8 -5
- package/dist/{const-_WWHU-gX.d.ts → const-BAG0MH0u.d.cts} +13 -10
- package/dist/{const-BBynifk0.d.cts → const-CaPq2AE4.d.ts} +13 -10
- package/dist/errors.cjs +74 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +38 -1
- package/dist/errors.d.ts +38 -1
- package/dist/errors.js +74 -1
- package/dist/errors.js.map +1 -1
- package/dist/{index-DPi5NWU8.d.ts → index-BNICJxBL.d.ts} +4 -4
- package/dist/{index-Dg4Y6Aq7.d.cts → index-YGrZrxNn.d.cts} +4 -4
- package/dist/index.cjs +2741 -368
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -19
- package/dist/index.d.ts +18 -19
- package/dist/index.js +2741 -368
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-DLxkB7Mv.d.cts → payload-types-CJZuXcgF.d.cts} +6873 -4208
- package/dist/{payload-types-DLxkB7Mv.d.ts → payload-types-CJZuXcgF.d.ts} +6873 -4208
- package/dist/query.cjs +550 -101
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +43 -45
- package/dist/query.d.ts +43 -45
- package/dist/query.js +550 -101
- package/dist/query.js.map +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.map +1 -1
- package/dist/server.cjs +2252 -444
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +11 -10
- package/dist/server.d.ts +11 -10
- package/dist/server.js +2252 -444
- package/dist/server.js.map +1 -1
- package/dist/storefront-cache.cjs +65 -1
- package/dist/storefront-cache.cjs.map +1 -1
- package/dist/storefront-cache.js +65 -1
- package/dist/storefront-cache.js.map +1 -1
- package/dist/types-BC6rVmJa.d.ts +47 -0
- package/dist/{types-B9lGhZlB.d.ts → types-BlOvjoTX.d.ts} +1095 -504
- package/dist/{types-Bpx5sYKo.d.cts → types-C4WuJfw7.d.cts} +1095 -504
- package/dist/types-D5p7-m1l.d.cts +47 -0
- package/dist/ui/canvas/server.cjs +244 -2
- package/dist/ui/canvas/server.cjs.map +1 -1
- package/dist/ui/canvas/server.d.cts +27 -1
- package/dist/ui/canvas/server.d.ts +27 -1
- package/dist/ui/canvas/server.js +244 -2
- package/dist/ui/canvas/server.js.map +1 -1
- package/dist/ui/canvas.cjs +419 -103
- package/dist/ui/canvas.cjs.map +1 -1
- package/dist/ui/canvas.d.cts +19 -7
- package/dist/ui/canvas.d.ts +19 -7
- package/dist/ui/canvas.js +419 -103
- 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 +2 -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 +2 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +12 -11
- package/dist/types-B1ngKbWI.d.cts +0 -33
- package/dist/types-BiKNBwRA.d.ts +0 -33
package/dist/query.cjs
CHANGED
|
@@ -24,6 +24,7 @@ __export(query_exports, {
|
|
|
24
24
|
CustomerHooks: () => CustomerHooks,
|
|
25
25
|
QueryHooks: () => QueryHooks,
|
|
26
26
|
RealtimeConnection: () => RealtimeConnection,
|
|
27
|
+
canonicalProductListingGroupsQueryOptions: () => canonicalProductListingGroupsQueryOptions,
|
|
27
28
|
collectionKeys: () => collectionKeys,
|
|
28
29
|
createQueryHooks: () => createQueryHooks,
|
|
29
30
|
createServerQueryHooks: () => createServerQueryHooks,
|
|
@@ -120,8 +121,14 @@ function canonicalProductListingPageParams(params = {}, limit) {
|
|
|
120
121
|
canonicalFilters.availableForSale = filters.availableForSale;
|
|
121
122
|
}
|
|
122
123
|
const search = params.search?.trim();
|
|
124
|
+
const market = params.market?.trim();
|
|
123
125
|
return {
|
|
124
126
|
mode: params.mode ?? "catalog",
|
|
127
|
+
...market && { market },
|
|
128
|
+
...params.locale != null && { locale: params.locale },
|
|
129
|
+
...params.fallbackLocale !== void 0 && {
|
|
130
|
+
fallbackLocale: params.fallbackLocale
|
|
131
|
+
},
|
|
125
132
|
...params.page != null && { page: params.page },
|
|
126
133
|
...limit != null ? { limit } : params.limit != null ? { limit: params.limit } : {},
|
|
127
134
|
...search && { search },
|
|
@@ -130,13 +137,50 @@ function canonicalProductListingPageParams(params = {}, limit) {
|
|
|
130
137
|
filters: canonicalFilters
|
|
131
138
|
},
|
|
132
139
|
...params.basePath != null && { basePath: params.basePath },
|
|
133
|
-
...params.trailingSlash != null && {
|
|
140
|
+
...params.trailingSlash != null && {
|
|
141
|
+
trailingSlash: params.trailingSlash
|
|
142
|
+
},
|
|
134
143
|
...params.emit != null && { emit: params.emit },
|
|
135
144
|
...params.preferCompleteVariantFromHint != null && {
|
|
136
145
|
preferCompleteVariantFromHint: params.preferCompleteVariantFromHint
|
|
137
146
|
}
|
|
138
147
|
};
|
|
139
148
|
}
|
|
149
|
+
function canonicalMarket(value) {
|
|
150
|
+
const market = value?.trim();
|
|
151
|
+
return market || void 0;
|
|
152
|
+
}
|
|
153
|
+
function canonicalProductListingGroupsQueryOptions(options, limit) {
|
|
154
|
+
const { market: rawMarket, ...rest } = options ?? {};
|
|
155
|
+
const market = canonicalMarket(rawMarket);
|
|
156
|
+
const canonical = {
|
|
157
|
+
...rest,
|
|
158
|
+
...limit !== void 0 ? { limit } : {},
|
|
159
|
+
...market ? { market } : {}
|
|
160
|
+
};
|
|
161
|
+
return Object.keys(canonical).length > 0 ? canonical : void 0;
|
|
162
|
+
}
|
|
163
|
+
function canonicalProductDetailParams(params) {
|
|
164
|
+
const market = params.market?.trim();
|
|
165
|
+
const localeOptions = {
|
|
166
|
+
...params.locale != null && { locale: params.locale },
|
|
167
|
+
...params.fallbackLocale !== void 0 && {
|
|
168
|
+
fallbackLocale: params.fallbackLocale
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
if ("slug" in params) {
|
|
172
|
+
return {
|
|
173
|
+
slug: params.slug,
|
|
174
|
+
...market ? { market } : {},
|
|
175
|
+
...localeOptions
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
id: params.id,
|
|
180
|
+
...market ? { market } : {},
|
|
181
|
+
...localeOptions
|
|
182
|
+
};
|
|
183
|
+
}
|
|
140
184
|
function collectionKeys(collection) {
|
|
141
185
|
return {
|
|
142
186
|
all: [collection],
|
|
@@ -157,22 +201,36 @@ var customerKeys = {
|
|
|
157
201
|
me: () => ["customer", "me"]
|
|
158
202
|
};
|
|
159
203
|
var productKeys = {
|
|
160
|
-
listingGroups: (options) => [
|
|
161
|
-
|
|
204
|
+
listingGroups: (options) => [
|
|
205
|
+
"products",
|
|
206
|
+
"listing-groups",
|
|
207
|
+
"list",
|
|
208
|
+
canonicalProductListingGroupsQueryOptions(options)
|
|
209
|
+
],
|
|
210
|
+
listingGroupsCatalog: (options) => [
|
|
211
|
+
"products",
|
|
212
|
+
"listing-groups",
|
|
213
|
+
"catalog",
|
|
214
|
+
canonicalProductListingGroupsQueryOptions(options)
|
|
215
|
+
],
|
|
162
216
|
listingGroupsInfinite: (options, pageSize) => [
|
|
163
217
|
"products",
|
|
164
218
|
"listing-groups",
|
|
165
219
|
"infinite",
|
|
166
|
-
|
|
220
|
+
canonicalProductListingGroupsQueryOptions(options, pageSize)
|
|
167
221
|
],
|
|
168
222
|
listingGroupsCatalogInfinite: (options, pageSize) => [
|
|
169
223
|
"products",
|
|
170
224
|
"listing-groups",
|
|
171
225
|
"catalog",
|
|
172
226
|
"infinite",
|
|
173
|
-
|
|
227
|
+
canonicalProductListingGroupsQueryOptions(options, pageSize)
|
|
228
|
+
],
|
|
229
|
+
listingPage: (params) => [
|
|
230
|
+
"products",
|
|
231
|
+
"listing-page",
|
|
232
|
+
canonicalProductListingPageParams(params)
|
|
174
233
|
],
|
|
175
|
-
listingPage: (params) => ["products", "listing-page", canonicalProductListingPageParams(params)],
|
|
176
234
|
listingPageInfinite: (params, pageSize) => [
|
|
177
235
|
"products",
|
|
178
236
|
"listing-page",
|
|
@@ -182,7 +240,7 @@ var productKeys = {
|
|
|
182
240
|
pageSize
|
|
183
241
|
)
|
|
184
242
|
],
|
|
185
|
-
detail: (params) => ["products", "detail", params],
|
|
243
|
+
detail: (params) => ["products", "detail", canonicalProductDetailParams(params)],
|
|
186
244
|
detailAll: () => ["products", "detail"]
|
|
187
245
|
};
|
|
188
246
|
|
|
@@ -471,10 +529,74 @@ var SDKError = class extends Error {
|
|
|
471
529
|
details: this.details,
|
|
472
530
|
userMessage: this.userMessage,
|
|
473
531
|
suggestion: this.suggestion,
|
|
474
|
-
...this.requestId !== void 0 && { requestId: this.requestId }
|
|
532
|
+
...this.requestId !== void 0 && { requestId: this.requestId },
|
|
533
|
+
...this.kind !== void 0 && { kind: this.kind },
|
|
534
|
+
...this.reason !== void 0 && { reason: this.reason },
|
|
535
|
+
...this.rawReason !== void 0 && { rawReason: this.rawReason },
|
|
536
|
+
...this.retryable !== void 0 && { retryable: this.retryable },
|
|
537
|
+
...this.retryAfter !== void 0 && { retryAfter: this.retryAfter }
|
|
475
538
|
};
|
|
476
539
|
}
|
|
477
540
|
};
|
|
541
|
+
var COMMERCE_ERROR_CODES = [
|
|
542
|
+
"validation_failed",
|
|
543
|
+
"unauthorized",
|
|
544
|
+
"forbidden",
|
|
545
|
+
"token_expired",
|
|
546
|
+
"origin_not_allowed",
|
|
547
|
+
"server_credentials_required",
|
|
548
|
+
"not_found",
|
|
549
|
+
"conflict",
|
|
550
|
+
"cart_revision_conflict",
|
|
551
|
+
"rate_limit_exceeded",
|
|
552
|
+
"usage_limit_exceeded",
|
|
553
|
+
"service_unavailable",
|
|
554
|
+
"idempotency_conflict",
|
|
555
|
+
"idempotency_in_progress",
|
|
556
|
+
"cart_not_active",
|
|
557
|
+
"cart_locked",
|
|
558
|
+
"cart_empty",
|
|
559
|
+
"cart_market_unavailable",
|
|
560
|
+
"cart_market_mismatch",
|
|
561
|
+
"checkout_not_open",
|
|
562
|
+
"payment_slot_held",
|
|
563
|
+
"reservation_expired",
|
|
564
|
+
"payment_session_not_cancelable",
|
|
565
|
+
"provider_identity_mismatch",
|
|
566
|
+
"provider_unavailable",
|
|
567
|
+
"lock_timeout",
|
|
568
|
+
"price_changed",
|
|
569
|
+
"pricing_fact_in_use",
|
|
570
|
+
"insufficient_stock",
|
|
571
|
+
"market_not_found",
|
|
572
|
+
"market_shipping_currency_unsupported",
|
|
573
|
+
"missing_market_rate",
|
|
574
|
+
"missing_shipping_amount",
|
|
575
|
+
"no_enabled_payment_provider",
|
|
576
|
+
"product_market_unavailable",
|
|
577
|
+
"unsupported_currency",
|
|
578
|
+
"missing_price_row",
|
|
579
|
+
"payment_provider_currency_unsupported",
|
|
580
|
+
"discount_code_not_found",
|
|
581
|
+
"discount_not_started",
|
|
582
|
+
"discount_expired",
|
|
583
|
+
"discount_usage_limit",
|
|
584
|
+
"discount_per_customer_limit",
|
|
585
|
+
"discount_customer_required",
|
|
586
|
+
"discount_first_order_only",
|
|
587
|
+
"discount_customer_not_eligible",
|
|
588
|
+
"discount_customer_excluded",
|
|
589
|
+
"discount_items_required",
|
|
590
|
+
"discount_product_not_eligible",
|
|
591
|
+
"discount_product_excluded",
|
|
592
|
+
"discount_min_order_amount",
|
|
593
|
+
"discount_currency_scope_required",
|
|
594
|
+
"discount_allocation_method_unsupported",
|
|
595
|
+
"currency_mismatch"
|
|
596
|
+
];
|
|
597
|
+
var COMMERCE_ERROR_CODE_SET = new Set(
|
|
598
|
+
COMMERCE_ERROR_CODES
|
|
599
|
+
);
|
|
478
600
|
var ConfigError = class extends SDKError {
|
|
479
601
|
constructor(message, details, userMessage, suggestion) {
|
|
480
602
|
super("CONFIG_ERROR", message, void 0, details, userMessage, suggestion);
|
|
@@ -599,100 +721,379 @@ var CustomerHooks = class {
|
|
|
599
721
|
// src/core/query/query-hooks.ts
|
|
600
722
|
var import_react_query4 = require("@tanstack/react-query");
|
|
601
723
|
|
|
602
|
-
// src/core/
|
|
603
|
-
|
|
724
|
+
// src/core/internal/utils/query-string.ts
|
|
725
|
+
function normalizedMarket(value) {
|
|
726
|
+
const market = value?.trim();
|
|
727
|
+
return market || void 0;
|
|
728
|
+
}
|
|
729
|
+
function appendProductLocaleSearchParams(search, options) {
|
|
730
|
+
if (options?.locale) search.set("locale", options.locale);
|
|
731
|
+
if (options?.fallbackLocale !== void 0) {
|
|
732
|
+
search.set(
|
|
733
|
+
"fallbackLocale",
|
|
734
|
+
options.fallbackLocale === false ? "none" : options.fallbackLocale
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function appendListingGroupsQuerySearchParams(search, options) {
|
|
739
|
+
const market = normalizedMarket(options?.market);
|
|
740
|
+
if (market) search.set("market", market);
|
|
741
|
+
appendProductLocaleSearchParams(search, options);
|
|
742
|
+
if (options?.page != null) search.set("page", String(options.page));
|
|
743
|
+
if (options?.limit != null) search.set("limit", String(options.limit));
|
|
744
|
+
if (options?.sort != null) {
|
|
745
|
+
const sort = options.sort;
|
|
746
|
+
search.set("sort", Array.isArray(sort) ? sort.join(",") : sort);
|
|
747
|
+
}
|
|
748
|
+
if (options?.where != null) {
|
|
749
|
+
search.set("whereJson", JSON.stringify(options.where));
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function listingPageSearchParams(options) {
|
|
753
|
+
const search = new URLSearchParams();
|
|
754
|
+
appendListingGroupsQuerySearchParams(search, options);
|
|
755
|
+
return search.toString();
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
// ../../internal/http-contracts/src/index.ts
|
|
759
|
+
var operationBrand = /* @__PURE__ */ Symbol("sdk-http-operation");
|
|
760
|
+
var operation = (collection, method, path) => Object.freeze({
|
|
761
|
+
[operationBrand]: true,
|
|
762
|
+
collection,
|
|
763
|
+
method,
|
|
764
|
+
path
|
|
765
|
+
});
|
|
766
|
+
var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
767
|
+
products: {
|
|
768
|
+
detail: operation("products", "get", "/detail"),
|
|
769
|
+
detailCatalog: operation("products", "get", "/detail/catalog"),
|
|
770
|
+
listingGroups: operation("products", "get", "/listing-groups"),
|
|
771
|
+
listingGroupsCatalog: operation(
|
|
772
|
+
"products",
|
|
773
|
+
"get",
|
|
774
|
+
"/listing-groups/catalog"
|
|
775
|
+
),
|
|
776
|
+
listingGroupsQuery: operation("products", "post", "/listing-groups/query"),
|
|
777
|
+
listingGroupsQueryGet: operation(
|
|
778
|
+
"products",
|
|
779
|
+
"get",
|
|
780
|
+
"/listing-groups/query"
|
|
781
|
+
),
|
|
782
|
+
listingGroupsQueryCatalog: operation(
|
|
783
|
+
"products",
|
|
784
|
+
"get",
|
|
785
|
+
"/listing-groups/query/catalog"
|
|
786
|
+
),
|
|
787
|
+
stockCheck: operation("products", "post", "/stock-check"),
|
|
788
|
+
stockSnapshot: operation("products", "get", "/stock"),
|
|
789
|
+
upsert: operation("products", "post", "/upsert")
|
|
790
|
+
},
|
|
604
791
|
orders: {
|
|
605
|
-
create: "
|
|
606
|
-
update: "
|
|
607
|
-
confirmPayment: "
|
|
608
|
-
byPayment: "
|
|
609
|
-
cancel: "
|
|
610
|
-
resolveCancelRefund: "
|
|
611
|
-
checkout: "
|
|
612
|
-
createFulfillment: "
|
|
613
|
-
updateFulfillment: "
|
|
792
|
+
create: operation("orders", "post", "/create"),
|
|
793
|
+
update: operation("orders", "post", "/update"),
|
|
794
|
+
confirmPayment: operation("orders", "post", "/confirm-payment"),
|
|
795
|
+
byPayment: operation("orders", "get", "/by-payment"),
|
|
796
|
+
cancel: operation("orders", "post", "/cancel"),
|
|
797
|
+
resolveCancelRefund: operation("orders", "post", "/resolve-cancel-refund"),
|
|
798
|
+
checkout: operation("orders", "post", "/checkout"),
|
|
799
|
+
createFulfillment: operation("orders", "post", "/create-fulfillment"),
|
|
800
|
+
updateFulfillment: operation("orders", "post", "/update-fulfillment")
|
|
801
|
+
},
|
|
802
|
+
checkouts: {
|
|
803
|
+
detail: operation("checkouts", "post", "/detail"),
|
|
804
|
+
query: operation("checkouts", "post", "/query")
|
|
614
805
|
},
|
|
615
806
|
transactions: {
|
|
616
|
-
update: "
|
|
807
|
+
update: operation("transactions", "post", "/update")
|
|
617
808
|
},
|
|
618
809
|
returns: {
|
|
619
|
-
create: "
|
|
620
|
-
update: "
|
|
621
|
-
returnRefund: "
|
|
810
|
+
create: operation("returns", "post", "/create"),
|
|
811
|
+
update: operation("returns", "post", "/update"),
|
|
812
|
+
returnRefund: operation("returns", "post", "/return-refund")
|
|
622
813
|
},
|
|
623
814
|
fulfillmentOrders: {
|
|
624
|
-
prepare:
|
|
815
|
+
prepare: operation(
|
|
816
|
+
"fulfillment-orders",
|
|
817
|
+
"post",
|
|
818
|
+
"/prepare-fulfillment-order"
|
|
819
|
+
)
|
|
625
820
|
},
|
|
626
821
|
fulfillments: {
|
|
627
|
-
bulkImport: "
|
|
822
|
+
bulkImport: operation("fulfillments", "post", "/bulk-import")
|
|
628
823
|
},
|
|
629
824
|
carts: {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
825
|
+
create: operation("carts", "post", "/create"),
|
|
826
|
+
retrieve: operation("carts", "post", "/retrieve"),
|
|
827
|
+
mine: operation("carts", "post", "/mine"),
|
|
828
|
+
merge: operation("carts", "post", "/merge"),
|
|
829
|
+
addItem: operation("carts", "post", "/add-item"),
|
|
830
|
+
updateItem: operation("carts", "post", "/update-item"),
|
|
831
|
+
removeItem: operation("carts", "post", "/remove-item"),
|
|
832
|
+
updateDiscountCodes: operation("carts", "post", "/update-discount-codes"),
|
|
833
|
+
updateAttributes: operation("carts", "post", "/update-attributes"),
|
|
834
|
+
clear: operation("carts", "post", "/clear")
|
|
638
835
|
},
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
836
|
+
paymentSessions: {
|
|
837
|
+
create: operation("payment-sessions", "post", "/create"),
|
|
838
|
+
retrieve: operation("payment-sessions", "post", "/retrieve"),
|
|
839
|
+
cancel: operation("payment-sessions", "post", "/cancel"),
|
|
840
|
+
server: {
|
|
841
|
+
create: operation("payment-sessions", "post", "/server/create"),
|
|
842
|
+
retrieve: operation("payment-sessions", "post", "/server/retrieve"),
|
|
843
|
+
cancel: operation("payment-sessions", "post", "/server/cancel"),
|
|
844
|
+
confirm: operation("payment-sessions", "post", "/server/confirm")
|
|
845
|
+
},
|
|
846
|
+
custom: {
|
|
847
|
+
create: operation("orders", "post", "/custom-payment-sessions"),
|
|
848
|
+
confirm: operation("orders", "post", "/custom-payment-sessions/confirm")
|
|
849
|
+
}
|
|
850
|
+
},
|
|
851
|
+
shippingPolicies: {
|
|
852
|
+
calculate: operation("shipping-policies", "post", "/calculate")
|
|
853
|
+
},
|
|
854
|
+
discounts: {
|
|
855
|
+
validate: operation("discounts", "post", "/validate")
|
|
649
856
|
}
|
|
650
857
|
};
|
|
651
|
-
var
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
858
|
+
var MEMBERSHIP_ENDPOINT_OPERATIONS = {
|
|
859
|
+
subscribe: operation(null, "post", "/memberships/subscribe"),
|
|
860
|
+
cancel: operation(null, "post", "/memberships/:id/cancel"),
|
|
861
|
+
me: operation(null, "get", "/memberships/me")
|
|
862
|
+
};
|
|
863
|
+
var EVENTS_ENDPOINT_OPERATIONS = {
|
|
864
|
+
occurrences: {
|
|
865
|
+
range: operation("event-occurrences", "get", "/range"),
|
|
866
|
+
admissionAvailability: operation(
|
|
867
|
+
"event-occurrences",
|
|
868
|
+
"get",
|
|
869
|
+
"/admission-availability"
|
|
870
|
+
)
|
|
662
871
|
}
|
|
663
|
-
|
|
664
|
-
|
|
872
|
+
};
|
|
873
|
+
function resolveOperationTemplate(descriptor) {
|
|
874
|
+
return descriptor.collection ? `/api/${descriptor.collection}${descriptor.path}` : `/api${descriptor.path}`;
|
|
875
|
+
}
|
|
876
|
+
function resolveOperationPath(descriptor, options) {
|
|
877
|
+
const path = resolveOperationTemplate(descriptor).replace(
|
|
878
|
+
/:([A-Za-z][A-Za-z0-9_]*)/g,
|
|
879
|
+
(_, key) => {
|
|
880
|
+
const value = options?.pathParams?.[key];
|
|
881
|
+
if (value === void 0) {
|
|
882
|
+
throw new TypeError(`Missing path parameter: ${key}`);
|
|
883
|
+
}
|
|
884
|
+
return encodeURIComponent(value);
|
|
885
|
+
}
|
|
886
|
+
);
|
|
887
|
+
const unresolved = path.match(/:([A-Za-z][A-Za-z0-9_]*)/);
|
|
888
|
+
if (unresolved) {
|
|
889
|
+
throw new TypeError(`Missing path parameter: ${unresolved[1]}`);
|
|
665
890
|
}
|
|
891
|
+
const query = options?.query?.toString().replace(/^\?/, "");
|
|
892
|
+
return query ? `${path}?${query}` : path;
|
|
666
893
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
894
|
+
|
|
895
|
+
// src/core/api/endpoints.ts
|
|
896
|
+
var endpoint = (method, path) => ({ method, path });
|
|
897
|
+
var sharedEndpoint = (descriptor) => descriptor;
|
|
898
|
+
function resolveOperationPath2(descriptor, options) {
|
|
899
|
+
if ("collection" in descriptor) {
|
|
900
|
+
return resolveOperationPath(descriptor, options);
|
|
901
|
+
}
|
|
902
|
+
const query = options?.query?.toString().replace(/^\?/, "");
|
|
903
|
+
return query ? `${descriptor.path}?${query}` : descriptor.path;
|
|
904
|
+
}
|
|
905
|
+
var COMMERCE_ENDPOINTS = {
|
|
906
|
+
products: {
|
|
907
|
+
detail: endpoint("GET", "/api/products/detail"),
|
|
908
|
+
detailCatalog: endpoint("GET", "/api/products/detail/catalog"),
|
|
909
|
+
listingGroups: endpoint("GET", "/api/products/listing-groups"),
|
|
910
|
+
listingGroupsCatalog: endpoint(
|
|
911
|
+
"GET",
|
|
912
|
+
"/api/products/listing-groups/catalog"
|
|
913
|
+
),
|
|
914
|
+
listingGroupsQuery: endpoint("GET", "/api/products/listing-groups/query"),
|
|
915
|
+
listingGroupsQueryCatalog: endpoint(
|
|
916
|
+
"GET",
|
|
917
|
+
"/api/products/listing-groups/query/catalog"
|
|
918
|
+
),
|
|
919
|
+
stockCheck: endpoint("POST", "/api/products/stock-check"),
|
|
920
|
+
stockSnapshot: endpoint("GET", "/api/products/stock"),
|
|
921
|
+
upsert: endpoint("POST", "/api/products/upsert")
|
|
922
|
+
},
|
|
923
|
+
orders: {
|
|
924
|
+
update: endpoint("POST", "/api/orders/update"),
|
|
925
|
+
byPayment: endpoint("GET", "/api/orders/by-payment"),
|
|
926
|
+
cancel: endpoint("POST", "/api/orders/cancel"),
|
|
927
|
+
resolveCancelRefund: endpoint("POST", "/api/orders/resolve-cancel-refund"),
|
|
928
|
+
createFulfillment: endpoint("POST", "/api/orders/create-fulfillment"),
|
|
929
|
+
updateFulfillment: endpoint("POST", "/api/orders/update-fulfillment")
|
|
930
|
+
},
|
|
931
|
+
checkouts: {
|
|
932
|
+
create: endpoint("POST", "/api/orders/checkout"),
|
|
933
|
+
retrieve: endpoint("POST", "/api/checkouts/detail"),
|
|
934
|
+
server: {
|
|
935
|
+
create: endpoint("POST", "/api/orders/checkout"),
|
|
936
|
+
retrieve: endpoint("POST", "/api/checkouts/detail"),
|
|
937
|
+
query: endpoint("POST", "/api/checkouts/query")
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
returns: {
|
|
941
|
+
create: endpoint("POST", "/api/returns/create"),
|
|
942
|
+
update: endpoint("POST", "/api/returns/update"),
|
|
943
|
+
returnRefund: endpoint("POST", "/api/returns/return-refund")
|
|
944
|
+
},
|
|
945
|
+
fulfillmentOrders: {
|
|
946
|
+
prepare: endpoint(
|
|
947
|
+
"POST",
|
|
948
|
+
"/api/fulfillment-orders/prepare-fulfillment-order"
|
|
949
|
+
)
|
|
950
|
+
},
|
|
951
|
+
fulfillments: {
|
|
952
|
+
bulkImport: endpoint("POST", "/api/fulfillments/bulk-import")
|
|
953
|
+
},
|
|
954
|
+
carts: {
|
|
955
|
+
create: endpoint("POST", "/api/carts/create"),
|
|
956
|
+
retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.retrieve),
|
|
957
|
+
mine: endpoint("POST", "/api/carts/mine"),
|
|
958
|
+
merge: endpoint("POST", "/api/carts/merge"),
|
|
959
|
+
server: {
|
|
960
|
+
// Server credentials are an authorization lane, not a second Cart
|
|
961
|
+
// transport. These must stay bound to the registered shared operations.
|
|
962
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
|
|
963
|
+
retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.retrieve),
|
|
964
|
+
mine: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.mine),
|
|
965
|
+
merge: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.merge),
|
|
966
|
+
addItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.addItem),
|
|
967
|
+
updateItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.updateItem),
|
|
968
|
+
removeItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.removeItem),
|
|
969
|
+
updateDiscountCodes: sharedEndpoint(
|
|
970
|
+
COMMERCE_ENDPOINT_OPERATIONS.carts.updateDiscountCodes
|
|
971
|
+
),
|
|
972
|
+
updateAttributes: sharedEndpoint(
|
|
973
|
+
COMMERCE_ENDPOINT_OPERATIONS.carts.updateAttributes
|
|
974
|
+
),
|
|
975
|
+
clear: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.clear)
|
|
976
|
+
},
|
|
977
|
+
addItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.addItem),
|
|
978
|
+
updateItem: endpoint("POST", "/api/carts/update-item"),
|
|
979
|
+
removeItem: endpoint("POST", "/api/carts/remove-item"),
|
|
980
|
+
updateDiscountCodes: endpoint("POST", "/api/carts/update-discount-codes"),
|
|
981
|
+
updateAttributes: endpoint("POST", "/api/carts/update-attributes"),
|
|
982
|
+
clear: endpoint("POST", "/api/carts/clear")
|
|
983
|
+
},
|
|
984
|
+
paymentSessions: {
|
|
985
|
+
create: endpoint("POST", "/api/payment-sessions/create"),
|
|
986
|
+
retrieve: endpoint("POST", "/api/payment-sessions/retrieve"),
|
|
987
|
+
cancel: endpoint("POST", "/api/payment-sessions/cancel"),
|
|
988
|
+
server: {
|
|
989
|
+
create: endpoint("POST", "/api/payment-sessions/server/create"),
|
|
990
|
+
retrieve: endpoint("POST", "/api/payment-sessions/server/retrieve"),
|
|
991
|
+
cancel: endpoint("POST", "/api/payment-sessions/server/cancel"),
|
|
992
|
+
confirm: endpoint("POST", "/api/payment-sessions/server/confirm")
|
|
993
|
+
}
|
|
994
|
+
},
|
|
995
|
+
shippingPolicies: {
|
|
996
|
+
calculate: endpoint("POST", "/api/shipping-policies/calculate")
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
function isCommerceEndpointDescriptor(value) {
|
|
1000
|
+
if (!value || typeof value !== "object") return false;
|
|
1001
|
+
const candidate = value;
|
|
1002
|
+
return typeof candidate.method === "string" && typeof candidate.path === "string";
|
|
672
1003
|
}
|
|
1004
|
+
function flattenEndpointPaths(value) {
|
|
1005
|
+
if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
|
|
1006
|
+
if (!value || typeof value !== "object") return [];
|
|
1007
|
+
return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
|
|
1008
|
+
}
|
|
1009
|
+
function flattenEndpointDescriptors(value) {
|
|
1010
|
+
if (isCommerceEndpointDescriptor(value)) return [value];
|
|
1011
|
+
if (!value || typeof value !== "object") return [];
|
|
1012
|
+
return Object.values(value).flatMap(
|
|
1013
|
+
(entry) => flattenEndpointDescriptors(entry)
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
|
|
1017
|
+
var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
|
|
1018
|
+
var MEMBERSHIP_ENDPOINTS = {
|
|
1019
|
+
subscribe: "/api/memberships/subscribe",
|
|
1020
|
+
cancel: (id) => `/api/memberships/${id}/cancel`,
|
|
1021
|
+
me: "/api/memberships/me"
|
|
1022
|
+
};
|
|
1023
|
+
var MEMBERSHIP_ENDPOINT_PATHS = [
|
|
1024
|
+
MEMBERSHIP_ENDPOINTS.subscribe,
|
|
1025
|
+
MEMBERSHIP_ENDPOINTS.cancel(":id"),
|
|
1026
|
+
MEMBERSHIP_ENDPOINTS.me
|
|
1027
|
+
];
|
|
673
1028
|
|
|
674
1029
|
// src/core/query/query-hooks.ts
|
|
675
|
-
|
|
1030
|
+
function normalizeMarket(market) {
|
|
1031
|
+
const normalized = market?.trim();
|
|
1032
|
+
return normalized || void 0;
|
|
1033
|
+
}
|
|
1034
|
+
function requestCommerceFindEndpoint(collectionClient, endpoint2, options) {
|
|
1035
|
+
const path = resolveOperationPath2(endpoint2, { query: options?.query });
|
|
1036
|
+
if (endpoint2.method === "get") {
|
|
1037
|
+
return collectionClient.requestFindEndpointGet(path);
|
|
1038
|
+
}
|
|
1039
|
+
if (endpoint2.method === "post") {
|
|
1040
|
+
return collectionClient.requestFindEndpoint(path, options?.data);
|
|
1041
|
+
}
|
|
1042
|
+
throw new TypeError(`Unsupported find endpoint method: ${endpoint2.method}`);
|
|
1043
|
+
}
|
|
1044
|
+
function withDefaultMarket(params, market) {
|
|
1045
|
+
const defaultMarket = normalizeMarket(market);
|
|
1046
|
+
if (!defaultMarket || normalizeMarket(params?.market)) return params;
|
|
1047
|
+
return { ...params ?? {}, market: defaultMarket };
|
|
1048
|
+
}
|
|
1049
|
+
function resolveProductMarket(commerceClient, context) {
|
|
1050
|
+
return normalizeMarket(context?.market) ?? normalizeMarket(commerceClient.getDefaultMarket?.());
|
|
1051
|
+
}
|
|
1052
|
+
function splitListingGroupsQueryOptions(queryOptions) {
|
|
1053
|
+
const normalized = canonicalProductListingGroupsQueryOptions(queryOptions);
|
|
1054
|
+
if (!normalized) return { market: void 0, options: void 0 };
|
|
1055
|
+
const { market, ...options } = normalized;
|
|
1056
|
+
return {
|
|
1057
|
+
market,
|
|
1058
|
+
options: Object.keys(options).length > 0 ? options : void 0
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
676
1061
|
function fetchProductListingGroupsQuery(collectionClient, queryOptions) {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
1062
|
+
const { market, options } = splitListingGroupsQueryOptions(queryOptions);
|
|
1063
|
+
return requestCommerceFindEndpoint(
|
|
1064
|
+
collectionClient,
|
|
1065
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQuery,
|
|
1066
|
+
{
|
|
1067
|
+
data: {
|
|
1068
|
+
...market ? { market } : {},
|
|
1069
|
+
...options ? { options } : {}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
680
1072
|
);
|
|
681
1073
|
}
|
|
682
1074
|
function fetchProductListingGroupsCatalogQuery(collectionClient, queryOptions) {
|
|
683
|
-
return
|
|
684
|
-
|
|
1075
|
+
return requestCommerceFindEndpoint(
|
|
1076
|
+
collectionClient,
|
|
1077
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog,
|
|
1078
|
+
{ query: listingPageSearchParams(queryOptions) }
|
|
685
1079
|
);
|
|
686
1080
|
}
|
|
687
|
-
function productListingPageQueryOptions(commerceClient, params = {}) {
|
|
1081
|
+
function productListingPageQueryOptions(commerceClient, params = {}, context) {
|
|
1082
|
+
const effectiveParams = withDefaultMarket(
|
|
1083
|
+
params,
|
|
1084
|
+
resolveProductMarket(
|
|
1085
|
+
commerceClient,
|
|
1086
|
+
context
|
|
1087
|
+
)
|
|
1088
|
+
) ?? params;
|
|
688
1089
|
return {
|
|
689
|
-
queryKey: productKeys.listingPage(
|
|
1090
|
+
queryKey: productKeys.listingPage(effectiveParams),
|
|
690
1091
|
queryFn: () => commerceClient.product.listingPage(
|
|
691
|
-
|
|
1092
|
+
effectiveParams
|
|
692
1093
|
)
|
|
693
1094
|
};
|
|
694
1095
|
}
|
|
695
|
-
function productListingPageInfiniteQueryOptions(commerceClient, params = {}) {
|
|
1096
|
+
function productListingPageInfiniteQueryOptions(commerceClient, params = {}, context) {
|
|
696
1097
|
const {
|
|
697
1098
|
pageSize: explicitPageSize,
|
|
698
1099
|
page: _page,
|
|
@@ -700,10 +1101,20 @@ function productListingPageInfiniteQueryOptions(commerceClient, params = {}) {
|
|
|
700
1101
|
...pageParams
|
|
701
1102
|
} = params;
|
|
702
1103
|
const pageSize = explicitPageSize ?? 20;
|
|
1104
|
+
const effectivePageParams = withDefaultMarket(
|
|
1105
|
+
pageParams,
|
|
1106
|
+
resolveProductMarket(
|
|
1107
|
+
commerceClient,
|
|
1108
|
+
context
|
|
1109
|
+
)
|
|
1110
|
+
) ?? pageParams;
|
|
703
1111
|
return {
|
|
704
|
-
queryKey: productKeys.listingPageInfinite(
|
|
1112
|
+
queryKey: productKeys.listingPageInfinite(
|
|
1113
|
+
effectivePageParams,
|
|
1114
|
+
explicitPageSize
|
|
1115
|
+
),
|
|
705
1116
|
queryFn: ({ pageParam }) => commerceClient.product.listingPage({
|
|
706
|
-
...
|
|
1117
|
+
...effectivePageParams,
|
|
707
1118
|
page: pageParam,
|
|
708
1119
|
limit: pageSize
|
|
709
1120
|
}),
|
|
@@ -711,27 +1122,29 @@ function productListingPageInfiniteQueryOptions(commerceClient, params = {}) {
|
|
|
711
1122
|
getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0
|
|
712
1123
|
};
|
|
713
1124
|
}
|
|
714
|
-
function prefetchProductListingPage(queryClient, commerceClient, params = {}, options) {
|
|
1125
|
+
function prefetchProductListingPage(queryClient, commerceClient, params = {}, options, context) {
|
|
715
1126
|
return queryClient.prefetchQuery({
|
|
716
1127
|
...productListingPageQueryOptions(
|
|
717
1128
|
commerceClient,
|
|
718
|
-
params
|
|
1129
|
+
params,
|
|
1130
|
+
context
|
|
719
1131
|
),
|
|
720
1132
|
...options
|
|
721
1133
|
});
|
|
722
1134
|
}
|
|
723
|
-
function prefetchInfiniteProductListingPage(queryClient, commerceClient, params = {}, options) {
|
|
1135
|
+
function prefetchInfiniteProductListingPage(queryClient, commerceClient, params = {}, options, context) {
|
|
724
1136
|
return queryClient.prefetchInfiniteQuery({
|
|
725
1137
|
...productListingPageInfiniteQueryOptions(
|
|
726
1138
|
commerceClient,
|
|
727
|
-
params
|
|
1139
|
+
params,
|
|
1140
|
+
context
|
|
728
1141
|
),
|
|
729
1142
|
pages: options?.pages ?? 1,
|
|
730
1143
|
staleTime: options?.staleTime
|
|
731
1144
|
});
|
|
732
1145
|
}
|
|
733
1146
|
var QueryHooks = class extends CollectionHooks {
|
|
734
|
-
constructor(queryClient, collectionClient, customerAuth, commerceClient) {
|
|
1147
|
+
constructor(queryClient, collectionClient, customerAuth, commerceClient, market) {
|
|
735
1148
|
super(queryClient, collectionClient);
|
|
736
1149
|
// --- Customer hooks delegation ---
|
|
737
1150
|
this.useCustomerMe = (...args) => this._customer.useCustomerMe(...args);
|
|
@@ -749,6 +1162,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
749
1162
|
this.setCustomerData = (data) => this._customer.setCustomerData(data);
|
|
750
1163
|
this._customer = new CustomerHooks(queryClient, customerAuth);
|
|
751
1164
|
this._commerce = commerceClient;
|
|
1165
|
+
this.market = normalizeMarket(market);
|
|
752
1166
|
}
|
|
753
1167
|
ensureCommerce() {
|
|
754
1168
|
if (!this._commerce) {
|
|
@@ -758,8 +1172,11 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
758
1172
|
}
|
|
759
1173
|
return this._commerce;
|
|
760
1174
|
}
|
|
1175
|
+
withProductMarket(params) {
|
|
1176
|
+
return withDefaultMarket(params, this.market);
|
|
1177
|
+
}
|
|
761
1178
|
useProductListingGroupsQuery(params, options) {
|
|
762
|
-
const queryOptions = params.options;
|
|
1179
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
763
1180
|
const { placeholderData, ...restOptions } = options ?? {};
|
|
764
1181
|
return (0, import_react_query4.useQuery)({
|
|
765
1182
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
@@ -771,7 +1188,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
771
1188
|
});
|
|
772
1189
|
}
|
|
773
1190
|
useProductListingGroupsCatalogQuery(params, options) {
|
|
774
|
-
const queryOptions = params.options;
|
|
1191
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
775
1192
|
const { placeholderData, ...restOptions } = options ?? {};
|
|
776
1193
|
return (0, import_react_query4.useQuery)({
|
|
777
1194
|
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
@@ -786,7 +1203,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
786
1203
|
});
|
|
787
1204
|
}
|
|
788
1205
|
useSuspenseProductListingGroupsQuery(params, options) {
|
|
789
|
-
const queryOptions = params.options;
|
|
1206
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
790
1207
|
return (0, import_react_query4.useSuspenseQuery)({
|
|
791
1208
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
792
1209
|
queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
|
|
@@ -794,7 +1211,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
794
1211
|
});
|
|
795
1212
|
}
|
|
796
1213
|
useSuspenseProductListingGroupsCatalogQuery(params, options) {
|
|
797
|
-
const queryOptions = params.options;
|
|
1214
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
798
1215
|
return (0, import_react_query4.useSuspenseQuery)({
|
|
799
1216
|
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
800
1217
|
queryFn: async () => fetchProductListingGroupsCatalogQuery(
|
|
@@ -805,7 +1222,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
805
1222
|
});
|
|
806
1223
|
}
|
|
807
1224
|
useInfiniteProductListingGroupsQuery(params, options) {
|
|
808
|
-
const
|
|
1225
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
809
1226
|
const explicitPageSize = params.pageSize;
|
|
810
1227
|
const pageSize = explicitPageSize ?? 20;
|
|
811
1228
|
return (0, import_react_query4.useInfiniteQuery)({
|
|
@@ -824,7 +1241,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
824
1241
|
});
|
|
825
1242
|
}
|
|
826
1243
|
useInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
827
|
-
const
|
|
1244
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
828
1245
|
const explicitPageSize = params.pageSize;
|
|
829
1246
|
const pageSize = explicitPageSize ?? 20;
|
|
830
1247
|
return (0, import_react_query4.useInfiniteQuery)({
|
|
@@ -843,7 +1260,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
843
1260
|
});
|
|
844
1261
|
}
|
|
845
1262
|
useSuspenseInfiniteProductListingGroupsQuery(params, options) {
|
|
846
|
-
const
|
|
1263
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
847
1264
|
const explicitPageSize = params.pageSize;
|
|
848
1265
|
const pageSize = explicitPageSize ?? 20;
|
|
849
1266
|
return (0, import_react_query4.useSuspenseInfiniteQuery)({
|
|
@@ -862,7 +1279,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
862
1279
|
});
|
|
863
1280
|
}
|
|
864
1281
|
useSuspenseInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
865
|
-
const
|
|
1282
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
866
1283
|
const explicitPageSize = params.pageSize;
|
|
867
1284
|
const pageSize = explicitPageSize ?? 20;
|
|
868
1285
|
return (0, import_react_query4.useSuspenseInfiniteQuery)({
|
|
@@ -881,7 +1298,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
881
1298
|
});
|
|
882
1299
|
}
|
|
883
1300
|
async prefetchProductListingGroupsQuery(params, options) {
|
|
884
|
-
const queryOptions = params.options;
|
|
1301
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
885
1302
|
return this.queryClient.prefetchQuery({
|
|
886
1303
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
887
1304
|
queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
|
|
@@ -889,7 +1306,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
889
1306
|
});
|
|
890
1307
|
}
|
|
891
1308
|
async prefetchProductListingGroupsCatalogQuery(params, options) {
|
|
892
|
-
const queryOptions = params.options;
|
|
1309
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
893
1310
|
return this.queryClient.prefetchQuery({
|
|
894
1311
|
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
895
1312
|
queryFn: async () => fetchProductListingGroupsCatalogQuery(
|
|
@@ -900,7 +1317,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
900
1317
|
});
|
|
901
1318
|
}
|
|
902
1319
|
async prefetchInfiniteProductListingGroupsQuery(params, options) {
|
|
903
|
-
const
|
|
1320
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
904
1321
|
const explicitPageSize = params.pageSize;
|
|
905
1322
|
const pageSize = explicitPageSize ?? 20;
|
|
906
1323
|
return this.queryClient.prefetchInfiniteQuery({
|
|
@@ -920,7 +1337,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
920
1337
|
});
|
|
921
1338
|
}
|
|
922
1339
|
async prefetchInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
923
|
-
const
|
|
1340
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
924
1341
|
const explicitPageSize = params.pageSize;
|
|
925
1342
|
const pageSize = explicitPageSize ?? 20;
|
|
926
1343
|
return this.queryClient.prefetchInfiniteQuery({
|
|
@@ -942,7 +1359,9 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
942
1359
|
useProductListingPage(params = {}, options) {
|
|
943
1360
|
const { placeholderData, ...restOptions } = options ?? {};
|
|
944
1361
|
return (0, import_react_query4.useQuery)({
|
|
945
|
-
...productListingPageQueryOptions(this.ensureCommerce(), params
|
|
1362
|
+
...productListingPageQueryOptions(this.ensureCommerce(), params, {
|
|
1363
|
+
market: this.market
|
|
1364
|
+
}),
|
|
946
1365
|
...restOptions,
|
|
947
1366
|
...placeholderData !== void 0 && {
|
|
948
1367
|
placeholderData
|
|
@@ -952,13 +1371,17 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
952
1371
|
useSuspenseProductListingPage(params = {}, options) {
|
|
953
1372
|
const suspenseOptions = options;
|
|
954
1373
|
return (0, import_react_query4.useSuspenseQuery)({
|
|
955
|
-
...productListingPageQueryOptions(this.ensureCommerce(), params
|
|
1374
|
+
...productListingPageQueryOptions(this.ensureCommerce(), params, {
|
|
1375
|
+
market: this.market
|
|
1376
|
+
}),
|
|
956
1377
|
...suspenseOptions
|
|
957
1378
|
});
|
|
958
1379
|
}
|
|
959
1380
|
useInfiniteProductListingPage(params = {}, options) {
|
|
960
1381
|
return (0, import_react_query4.useInfiniteQuery)({
|
|
961
|
-
...productListingPageInfiniteQueryOptions(this.ensureCommerce(), params
|
|
1382
|
+
...productListingPageInfiniteQueryOptions(this.ensureCommerce(), params, {
|
|
1383
|
+
market: this.market
|
|
1384
|
+
}),
|
|
962
1385
|
...options
|
|
963
1386
|
});
|
|
964
1387
|
}
|
|
@@ -967,7 +1390,8 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
967
1390
|
this.queryClient,
|
|
968
1391
|
this.ensureCommerce(),
|
|
969
1392
|
params,
|
|
970
|
-
options
|
|
1393
|
+
options,
|
|
1394
|
+
{ market: this.market }
|
|
971
1395
|
);
|
|
972
1396
|
}
|
|
973
1397
|
async prefetchInfiniteProductListingPage(params = {}, options) {
|
|
@@ -975,25 +1399,45 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
975
1399
|
this.queryClient,
|
|
976
1400
|
this.ensureCommerce(),
|
|
977
1401
|
params,
|
|
978
|
-
options
|
|
1402
|
+
options,
|
|
1403
|
+
{ market: this.market }
|
|
979
1404
|
);
|
|
980
1405
|
}
|
|
981
1406
|
useProductDetail(params, options) {
|
|
982
1407
|
const discriminator = "slug" in params ? params.slug : params.id;
|
|
983
1408
|
const { enabled, ...restOptions } = options ?? {};
|
|
984
1409
|
const queryEnabled = enabled !== false && Boolean(discriminator);
|
|
1410
|
+
const effectiveParams = this.withProductMarket(params) ?? params;
|
|
985
1411
|
return (0, import_react_query4.useQuery)({
|
|
986
|
-
queryKey: productKeys.detail(
|
|
987
|
-
queryFn: () => this._commerce.product.detail(
|
|
1412
|
+
queryKey: productKeys.detail(effectiveParams),
|
|
1413
|
+
queryFn: () => this._commerce.product.detail(effectiveParams),
|
|
988
1414
|
enabled: queryEnabled,
|
|
989
1415
|
...restOptions
|
|
990
1416
|
});
|
|
991
1417
|
}
|
|
992
1418
|
useProductDetailBySlug(slug, options) {
|
|
993
|
-
|
|
1419
|
+
const { market, locale, fallbackLocale, ...queryOptions } = options ?? {};
|
|
1420
|
+
return this.useProductDetail(
|
|
1421
|
+
{
|
|
1422
|
+
slug,
|
|
1423
|
+
...market ? { market } : {},
|
|
1424
|
+
...locale ? { locale } : {},
|
|
1425
|
+
...fallbackLocale !== void 0 ? { fallbackLocale } : {}
|
|
1426
|
+
},
|
|
1427
|
+
queryOptions
|
|
1428
|
+
);
|
|
994
1429
|
}
|
|
995
1430
|
useProductDetailById(id, options) {
|
|
996
|
-
|
|
1431
|
+
const { market, locale, fallbackLocale, ...queryOptions } = options ?? {};
|
|
1432
|
+
return this.useProductDetail(
|
|
1433
|
+
{
|
|
1434
|
+
id,
|
|
1435
|
+
...market ? { market } : {},
|
|
1436
|
+
...locale ? { locale } : {},
|
|
1437
|
+
...fallbackLocale !== void 0 ? { fallbackLocale } : {}
|
|
1438
|
+
},
|
|
1439
|
+
queryOptions
|
|
1440
|
+
);
|
|
997
1441
|
}
|
|
998
1442
|
};
|
|
999
1443
|
|
|
@@ -1143,6 +1587,9 @@ var RealtimeConnection = class {
|
|
|
1143
1587
|
};
|
|
1144
1588
|
|
|
1145
1589
|
// src/core/query/query-client.ts
|
|
1590
|
+
function getClientMarket(client) {
|
|
1591
|
+
return client.getConfig?.().market;
|
|
1592
|
+
}
|
|
1146
1593
|
function createReadOnlyQueryHooksFacade(hooks) {
|
|
1147
1594
|
return {
|
|
1148
1595
|
useQuery: hooks.useQuery.bind(hooks),
|
|
@@ -1190,7 +1637,8 @@ function createQueryHooks(client, queryClient = getQueryClient()) {
|
|
|
1190
1637
|
queryClient,
|
|
1191
1638
|
client.collections,
|
|
1192
1639
|
client.customer.auth,
|
|
1193
|
-
client.commerce
|
|
1640
|
+
client.commerce,
|
|
1641
|
+
getClientMarket(client)
|
|
1194
1642
|
);
|
|
1195
1643
|
return createReadOnlyQueryHooksFacade(hooks);
|
|
1196
1644
|
}
|
|
@@ -1199,7 +1647,8 @@ function createServerQueryHooks(client, queryClient = getQueryClient()) {
|
|
|
1199
1647
|
queryClient,
|
|
1200
1648
|
client.collections,
|
|
1201
1649
|
void 0,
|
|
1202
|
-
client.commerce
|
|
1650
|
+
client.commerce,
|
|
1651
|
+
getClientMarket(client)
|
|
1203
1652
|
);
|
|
1204
1653
|
}
|
|
1205
1654
|
//# sourceMappingURL=query.cjs.map
|