@01.software/sdk 0.44.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 +358 -2
- package/MIGRATION.md +89 -10
- package/README.md +441 -98
- 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-Dyl-CDcj.d.cts → collection-client-BSo7VXQE.d.cts} +8 -5
- package/dist/{collection-client-DWooaiTr.d.ts → collection-client-Ckfusuee.d.ts} +8 -5
- package/dist/{const-pGDnsy0o.d.ts → const-BAG0MH0u.d.cts} +13 -10
- package/dist/{const-1vleZ6ov.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-DUNySyxV.d.ts → index-BNICJxBL.d.ts} +4 -4
- package/dist/{index-a6g7vqAD.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-CDsuOEfM.d.cts → payload-types-CJZuXcgF.d.cts} +6671 -4001
- package/dist/{payload-types-CDsuOEfM.d.ts → payload-types-CJZuXcgF.d.ts} +6671 -4001
- 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-CDND3hzq.d.cts → types-BlOvjoTX.d.ts} +1095 -509
- package/dist/{types-Dt9FJisi.d.ts → types-C4WuJfw7.d.cts} +1095 -509
- 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-SoXsbKhj.d.cts +0 -33
- package/dist/types-oiae_LMm.d.ts +0 -33
package/dist/query.js
CHANGED
|
@@ -84,8 +84,14 @@ function canonicalProductListingPageParams(params = {}, limit) {
|
|
|
84
84
|
canonicalFilters.availableForSale = filters.availableForSale;
|
|
85
85
|
}
|
|
86
86
|
const search = params.search?.trim();
|
|
87
|
+
const market = params.market?.trim();
|
|
87
88
|
return {
|
|
88
89
|
mode: params.mode ?? "catalog",
|
|
90
|
+
...market && { market },
|
|
91
|
+
...params.locale != null && { locale: params.locale },
|
|
92
|
+
...params.fallbackLocale !== void 0 && {
|
|
93
|
+
fallbackLocale: params.fallbackLocale
|
|
94
|
+
},
|
|
89
95
|
...params.page != null && { page: params.page },
|
|
90
96
|
...limit != null ? { limit } : params.limit != null ? { limit: params.limit } : {},
|
|
91
97
|
...search && { search },
|
|
@@ -94,13 +100,50 @@ function canonicalProductListingPageParams(params = {}, limit) {
|
|
|
94
100
|
filters: canonicalFilters
|
|
95
101
|
},
|
|
96
102
|
...params.basePath != null && { basePath: params.basePath },
|
|
97
|
-
...params.trailingSlash != null && {
|
|
103
|
+
...params.trailingSlash != null && {
|
|
104
|
+
trailingSlash: params.trailingSlash
|
|
105
|
+
},
|
|
98
106
|
...params.emit != null && { emit: params.emit },
|
|
99
107
|
...params.preferCompleteVariantFromHint != null && {
|
|
100
108
|
preferCompleteVariantFromHint: params.preferCompleteVariantFromHint
|
|
101
109
|
}
|
|
102
110
|
};
|
|
103
111
|
}
|
|
112
|
+
function canonicalMarket(value) {
|
|
113
|
+
const market = value?.trim();
|
|
114
|
+
return market || void 0;
|
|
115
|
+
}
|
|
116
|
+
function canonicalProductListingGroupsQueryOptions(options, limit) {
|
|
117
|
+
const { market: rawMarket, ...rest } = options ?? {};
|
|
118
|
+
const market = canonicalMarket(rawMarket);
|
|
119
|
+
const canonical = {
|
|
120
|
+
...rest,
|
|
121
|
+
...limit !== void 0 ? { limit } : {},
|
|
122
|
+
...market ? { market } : {}
|
|
123
|
+
};
|
|
124
|
+
return Object.keys(canonical).length > 0 ? canonical : void 0;
|
|
125
|
+
}
|
|
126
|
+
function canonicalProductDetailParams(params) {
|
|
127
|
+
const market = params.market?.trim();
|
|
128
|
+
const localeOptions = {
|
|
129
|
+
...params.locale != null && { locale: params.locale },
|
|
130
|
+
...params.fallbackLocale !== void 0 && {
|
|
131
|
+
fallbackLocale: params.fallbackLocale
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
if ("slug" in params) {
|
|
135
|
+
return {
|
|
136
|
+
slug: params.slug,
|
|
137
|
+
...market ? { market } : {},
|
|
138
|
+
...localeOptions
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
id: params.id,
|
|
143
|
+
...market ? { market } : {},
|
|
144
|
+
...localeOptions
|
|
145
|
+
};
|
|
146
|
+
}
|
|
104
147
|
function collectionKeys(collection) {
|
|
105
148
|
return {
|
|
106
149
|
all: [collection],
|
|
@@ -121,22 +164,36 @@ var customerKeys = {
|
|
|
121
164
|
me: () => ["customer", "me"]
|
|
122
165
|
};
|
|
123
166
|
var productKeys = {
|
|
124
|
-
listingGroups: (options) => [
|
|
125
|
-
|
|
167
|
+
listingGroups: (options) => [
|
|
168
|
+
"products",
|
|
169
|
+
"listing-groups",
|
|
170
|
+
"list",
|
|
171
|
+
canonicalProductListingGroupsQueryOptions(options)
|
|
172
|
+
],
|
|
173
|
+
listingGroupsCatalog: (options) => [
|
|
174
|
+
"products",
|
|
175
|
+
"listing-groups",
|
|
176
|
+
"catalog",
|
|
177
|
+
canonicalProductListingGroupsQueryOptions(options)
|
|
178
|
+
],
|
|
126
179
|
listingGroupsInfinite: (options, pageSize) => [
|
|
127
180
|
"products",
|
|
128
181
|
"listing-groups",
|
|
129
182
|
"infinite",
|
|
130
|
-
|
|
183
|
+
canonicalProductListingGroupsQueryOptions(options, pageSize)
|
|
131
184
|
],
|
|
132
185
|
listingGroupsCatalogInfinite: (options, pageSize) => [
|
|
133
186
|
"products",
|
|
134
187
|
"listing-groups",
|
|
135
188
|
"catalog",
|
|
136
189
|
"infinite",
|
|
137
|
-
|
|
190
|
+
canonicalProductListingGroupsQueryOptions(options, pageSize)
|
|
191
|
+
],
|
|
192
|
+
listingPage: (params) => [
|
|
193
|
+
"products",
|
|
194
|
+
"listing-page",
|
|
195
|
+
canonicalProductListingPageParams(params)
|
|
138
196
|
],
|
|
139
|
-
listingPage: (params) => ["products", "listing-page", canonicalProductListingPageParams(params)],
|
|
140
197
|
listingPageInfinite: (params, pageSize) => [
|
|
141
198
|
"products",
|
|
142
199
|
"listing-page",
|
|
@@ -146,7 +203,7 @@ var productKeys = {
|
|
|
146
203
|
pageSize
|
|
147
204
|
)
|
|
148
205
|
],
|
|
149
|
-
detail: (params) => ["products", "detail", params],
|
|
206
|
+
detail: (params) => ["products", "detail", canonicalProductDetailParams(params)],
|
|
150
207
|
detailAll: () => ["products", "detail"]
|
|
151
208
|
};
|
|
152
209
|
|
|
@@ -444,10 +501,74 @@ var SDKError = class extends Error {
|
|
|
444
501
|
details: this.details,
|
|
445
502
|
userMessage: this.userMessage,
|
|
446
503
|
suggestion: this.suggestion,
|
|
447
|
-
...this.requestId !== void 0 && { requestId: this.requestId }
|
|
504
|
+
...this.requestId !== void 0 && { requestId: this.requestId },
|
|
505
|
+
...this.kind !== void 0 && { kind: this.kind },
|
|
506
|
+
...this.reason !== void 0 && { reason: this.reason },
|
|
507
|
+
...this.rawReason !== void 0 && { rawReason: this.rawReason },
|
|
508
|
+
...this.retryable !== void 0 && { retryable: this.retryable },
|
|
509
|
+
...this.retryAfter !== void 0 && { retryAfter: this.retryAfter }
|
|
448
510
|
};
|
|
449
511
|
}
|
|
450
512
|
};
|
|
513
|
+
var COMMERCE_ERROR_CODES = [
|
|
514
|
+
"validation_failed",
|
|
515
|
+
"unauthorized",
|
|
516
|
+
"forbidden",
|
|
517
|
+
"token_expired",
|
|
518
|
+
"origin_not_allowed",
|
|
519
|
+
"server_credentials_required",
|
|
520
|
+
"not_found",
|
|
521
|
+
"conflict",
|
|
522
|
+
"cart_revision_conflict",
|
|
523
|
+
"rate_limit_exceeded",
|
|
524
|
+
"usage_limit_exceeded",
|
|
525
|
+
"service_unavailable",
|
|
526
|
+
"idempotency_conflict",
|
|
527
|
+
"idempotency_in_progress",
|
|
528
|
+
"cart_not_active",
|
|
529
|
+
"cart_locked",
|
|
530
|
+
"cart_empty",
|
|
531
|
+
"cart_market_unavailable",
|
|
532
|
+
"cart_market_mismatch",
|
|
533
|
+
"checkout_not_open",
|
|
534
|
+
"payment_slot_held",
|
|
535
|
+
"reservation_expired",
|
|
536
|
+
"payment_session_not_cancelable",
|
|
537
|
+
"provider_identity_mismatch",
|
|
538
|
+
"provider_unavailable",
|
|
539
|
+
"lock_timeout",
|
|
540
|
+
"price_changed",
|
|
541
|
+
"pricing_fact_in_use",
|
|
542
|
+
"insufficient_stock",
|
|
543
|
+
"market_not_found",
|
|
544
|
+
"market_shipping_currency_unsupported",
|
|
545
|
+
"missing_market_rate",
|
|
546
|
+
"missing_shipping_amount",
|
|
547
|
+
"no_enabled_payment_provider",
|
|
548
|
+
"product_market_unavailable",
|
|
549
|
+
"unsupported_currency",
|
|
550
|
+
"missing_price_row",
|
|
551
|
+
"payment_provider_currency_unsupported",
|
|
552
|
+
"discount_code_not_found",
|
|
553
|
+
"discount_not_started",
|
|
554
|
+
"discount_expired",
|
|
555
|
+
"discount_usage_limit",
|
|
556
|
+
"discount_per_customer_limit",
|
|
557
|
+
"discount_customer_required",
|
|
558
|
+
"discount_first_order_only",
|
|
559
|
+
"discount_customer_not_eligible",
|
|
560
|
+
"discount_customer_excluded",
|
|
561
|
+
"discount_items_required",
|
|
562
|
+
"discount_product_not_eligible",
|
|
563
|
+
"discount_product_excluded",
|
|
564
|
+
"discount_min_order_amount",
|
|
565
|
+
"discount_currency_scope_required",
|
|
566
|
+
"discount_allocation_method_unsupported",
|
|
567
|
+
"currency_mismatch"
|
|
568
|
+
];
|
|
569
|
+
var COMMERCE_ERROR_CODE_SET = new Set(
|
|
570
|
+
COMMERCE_ERROR_CODES
|
|
571
|
+
);
|
|
451
572
|
var ConfigError = class extends SDKError {
|
|
452
573
|
constructor(message, details, userMessage, suggestion) {
|
|
453
574
|
super("CONFIG_ERROR", message, void 0, details, userMessage, suggestion);
|
|
@@ -577,100 +698,379 @@ import {
|
|
|
577
698
|
useSuspenseQuery as useSuspenseQueryOriginal2
|
|
578
699
|
} from "@tanstack/react-query";
|
|
579
700
|
|
|
580
|
-
// src/core/
|
|
581
|
-
|
|
701
|
+
// src/core/internal/utils/query-string.ts
|
|
702
|
+
function normalizedMarket(value) {
|
|
703
|
+
const market = value?.trim();
|
|
704
|
+
return market || void 0;
|
|
705
|
+
}
|
|
706
|
+
function appendProductLocaleSearchParams(search, options) {
|
|
707
|
+
if (options?.locale) search.set("locale", options.locale);
|
|
708
|
+
if (options?.fallbackLocale !== void 0) {
|
|
709
|
+
search.set(
|
|
710
|
+
"fallbackLocale",
|
|
711
|
+
options.fallbackLocale === false ? "none" : options.fallbackLocale
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
function appendListingGroupsQuerySearchParams(search, options) {
|
|
716
|
+
const market = normalizedMarket(options?.market);
|
|
717
|
+
if (market) search.set("market", market);
|
|
718
|
+
appendProductLocaleSearchParams(search, options);
|
|
719
|
+
if (options?.page != null) search.set("page", String(options.page));
|
|
720
|
+
if (options?.limit != null) search.set("limit", String(options.limit));
|
|
721
|
+
if (options?.sort != null) {
|
|
722
|
+
const sort = options.sort;
|
|
723
|
+
search.set("sort", Array.isArray(sort) ? sort.join(",") : sort);
|
|
724
|
+
}
|
|
725
|
+
if (options?.where != null) {
|
|
726
|
+
search.set("whereJson", JSON.stringify(options.where));
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
function listingPageSearchParams(options) {
|
|
730
|
+
const search = new URLSearchParams();
|
|
731
|
+
appendListingGroupsQuerySearchParams(search, options);
|
|
732
|
+
return search.toString();
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// ../../internal/http-contracts/src/index.ts
|
|
736
|
+
var operationBrand = /* @__PURE__ */ Symbol("sdk-http-operation");
|
|
737
|
+
var operation = (collection, method, path) => Object.freeze({
|
|
738
|
+
[operationBrand]: true,
|
|
739
|
+
collection,
|
|
740
|
+
method,
|
|
741
|
+
path
|
|
742
|
+
});
|
|
743
|
+
var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
744
|
+
products: {
|
|
745
|
+
detail: operation("products", "get", "/detail"),
|
|
746
|
+
detailCatalog: operation("products", "get", "/detail/catalog"),
|
|
747
|
+
listingGroups: operation("products", "get", "/listing-groups"),
|
|
748
|
+
listingGroupsCatalog: operation(
|
|
749
|
+
"products",
|
|
750
|
+
"get",
|
|
751
|
+
"/listing-groups/catalog"
|
|
752
|
+
),
|
|
753
|
+
listingGroupsQuery: operation("products", "post", "/listing-groups/query"),
|
|
754
|
+
listingGroupsQueryGet: operation(
|
|
755
|
+
"products",
|
|
756
|
+
"get",
|
|
757
|
+
"/listing-groups/query"
|
|
758
|
+
),
|
|
759
|
+
listingGroupsQueryCatalog: operation(
|
|
760
|
+
"products",
|
|
761
|
+
"get",
|
|
762
|
+
"/listing-groups/query/catalog"
|
|
763
|
+
),
|
|
764
|
+
stockCheck: operation("products", "post", "/stock-check"),
|
|
765
|
+
stockSnapshot: operation("products", "get", "/stock"),
|
|
766
|
+
upsert: operation("products", "post", "/upsert")
|
|
767
|
+
},
|
|
582
768
|
orders: {
|
|
583
|
-
create: "
|
|
584
|
-
update: "
|
|
585
|
-
confirmPayment: "
|
|
586
|
-
byPayment: "
|
|
587
|
-
cancel: "
|
|
588
|
-
resolveCancelRefund: "
|
|
589
|
-
checkout: "
|
|
590
|
-
createFulfillment: "
|
|
591
|
-
updateFulfillment: "
|
|
769
|
+
create: operation("orders", "post", "/create"),
|
|
770
|
+
update: operation("orders", "post", "/update"),
|
|
771
|
+
confirmPayment: operation("orders", "post", "/confirm-payment"),
|
|
772
|
+
byPayment: operation("orders", "get", "/by-payment"),
|
|
773
|
+
cancel: operation("orders", "post", "/cancel"),
|
|
774
|
+
resolveCancelRefund: operation("orders", "post", "/resolve-cancel-refund"),
|
|
775
|
+
checkout: operation("orders", "post", "/checkout"),
|
|
776
|
+
createFulfillment: operation("orders", "post", "/create-fulfillment"),
|
|
777
|
+
updateFulfillment: operation("orders", "post", "/update-fulfillment")
|
|
778
|
+
},
|
|
779
|
+
checkouts: {
|
|
780
|
+
detail: operation("checkouts", "post", "/detail"),
|
|
781
|
+
query: operation("checkouts", "post", "/query")
|
|
592
782
|
},
|
|
593
783
|
transactions: {
|
|
594
|
-
update: "
|
|
784
|
+
update: operation("transactions", "post", "/update")
|
|
595
785
|
},
|
|
596
786
|
returns: {
|
|
597
|
-
create: "
|
|
598
|
-
update: "
|
|
599
|
-
returnRefund: "
|
|
787
|
+
create: operation("returns", "post", "/create"),
|
|
788
|
+
update: operation("returns", "post", "/update"),
|
|
789
|
+
returnRefund: operation("returns", "post", "/return-refund")
|
|
600
790
|
},
|
|
601
791
|
fulfillmentOrders: {
|
|
602
|
-
prepare:
|
|
792
|
+
prepare: operation(
|
|
793
|
+
"fulfillment-orders",
|
|
794
|
+
"post",
|
|
795
|
+
"/prepare-fulfillment-order"
|
|
796
|
+
)
|
|
603
797
|
},
|
|
604
798
|
fulfillments: {
|
|
605
|
-
bulkImport: "
|
|
799
|
+
bulkImport: operation("fulfillments", "post", "/bulk-import")
|
|
606
800
|
},
|
|
607
801
|
carts: {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
802
|
+
create: operation("carts", "post", "/create"),
|
|
803
|
+
retrieve: operation("carts", "post", "/retrieve"),
|
|
804
|
+
mine: operation("carts", "post", "/mine"),
|
|
805
|
+
merge: operation("carts", "post", "/merge"),
|
|
806
|
+
addItem: operation("carts", "post", "/add-item"),
|
|
807
|
+
updateItem: operation("carts", "post", "/update-item"),
|
|
808
|
+
removeItem: operation("carts", "post", "/remove-item"),
|
|
809
|
+
updateDiscountCodes: operation("carts", "post", "/update-discount-codes"),
|
|
810
|
+
updateAttributes: operation("carts", "post", "/update-attributes"),
|
|
811
|
+
clear: operation("carts", "post", "/clear")
|
|
616
812
|
},
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
813
|
+
paymentSessions: {
|
|
814
|
+
create: operation("payment-sessions", "post", "/create"),
|
|
815
|
+
retrieve: operation("payment-sessions", "post", "/retrieve"),
|
|
816
|
+
cancel: operation("payment-sessions", "post", "/cancel"),
|
|
817
|
+
server: {
|
|
818
|
+
create: operation("payment-sessions", "post", "/server/create"),
|
|
819
|
+
retrieve: operation("payment-sessions", "post", "/server/retrieve"),
|
|
820
|
+
cancel: operation("payment-sessions", "post", "/server/cancel"),
|
|
821
|
+
confirm: operation("payment-sessions", "post", "/server/confirm")
|
|
822
|
+
},
|
|
823
|
+
custom: {
|
|
824
|
+
create: operation("orders", "post", "/custom-payment-sessions"),
|
|
825
|
+
confirm: operation("orders", "post", "/custom-payment-sessions/confirm")
|
|
826
|
+
}
|
|
827
|
+
},
|
|
828
|
+
shippingPolicies: {
|
|
829
|
+
calculate: operation("shipping-policies", "post", "/calculate")
|
|
830
|
+
},
|
|
831
|
+
discounts: {
|
|
832
|
+
validate: operation("discounts", "post", "/validate")
|
|
627
833
|
}
|
|
628
834
|
};
|
|
629
|
-
var
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
835
|
+
var MEMBERSHIP_ENDPOINT_OPERATIONS = {
|
|
836
|
+
subscribe: operation(null, "post", "/memberships/subscribe"),
|
|
837
|
+
cancel: operation(null, "post", "/memberships/:id/cancel"),
|
|
838
|
+
me: operation(null, "get", "/memberships/me")
|
|
839
|
+
};
|
|
840
|
+
var EVENTS_ENDPOINT_OPERATIONS = {
|
|
841
|
+
occurrences: {
|
|
842
|
+
range: operation("event-occurrences", "get", "/range"),
|
|
843
|
+
admissionAvailability: operation(
|
|
844
|
+
"event-occurrences",
|
|
845
|
+
"get",
|
|
846
|
+
"/admission-availability"
|
|
847
|
+
)
|
|
640
848
|
}
|
|
641
|
-
|
|
642
|
-
|
|
849
|
+
};
|
|
850
|
+
function resolveOperationTemplate(descriptor) {
|
|
851
|
+
return descriptor.collection ? `/api/${descriptor.collection}${descriptor.path}` : `/api${descriptor.path}`;
|
|
852
|
+
}
|
|
853
|
+
function resolveOperationPath(descriptor, options) {
|
|
854
|
+
const path = resolveOperationTemplate(descriptor).replace(
|
|
855
|
+
/:([A-Za-z][A-Za-z0-9_]*)/g,
|
|
856
|
+
(_, key) => {
|
|
857
|
+
const value = options?.pathParams?.[key];
|
|
858
|
+
if (value === void 0) {
|
|
859
|
+
throw new TypeError(`Missing path parameter: ${key}`);
|
|
860
|
+
}
|
|
861
|
+
return encodeURIComponent(value);
|
|
862
|
+
}
|
|
863
|
+
);
|
|
864
|
+
const unresolved = path.match(/:([A-Za-z][A-Za-z0-9_]*)/);
|
|
865
|
+
if (unresolved) {
|
|
866
|
+
throw new TypeError(`Missing path parameter: ${unresolved[1]}`);
|
|
643
867
|
}
|
|
868
|
+
const query = options?.query?.toString().replace(/^\?/, "");
|
|
869
|
+
return query ? `${path}?${query}` : path;
|
|
644
870
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
871
|
+
|
|
872
|
+
// src/core/api/endpoints.ts
|
|
873
|
+
var endpoint = (method, path) => ({ method, path });
|
|
874
|
+
var sharedEndpoint = (descriptor) => descriptor;
|
|
875
|
+
function resolveOperationPath2(descriptor, options) {
|
|
876
|
+
if ("collection" in descriptor) {
|
|
877
|
+
return resolveOperationPath(descriptor, options);
|
|
878
|
+
}
|
|
879
|
+
const query = options?.query?.toString().replace(/^\?/, "");
|
|
880
|
+
return query ? `${descriptor.path}?${query}` : descriptor.path;
|
|
881
|
+
}
|
|
882
|
+
var COMMERCE_ENDPOINTS = {
|
|
883
|
+
products: {
|
|
884
|
+
detail: endpoint("GET", "/api/products/detail"),
|
|
885
|
+
detailCatalog: endpoint("GET", "/api/products/detail/catalog"),
|
|
886
|
+
listingGroups: endpoint("GET", "/api/products/listing-groups"),
|
|
887
|
+
listingGroupsCatalog: endpoint(
|
|
888
|
+
"GET",
|
|
889
|
+
"/api/products/listing-groups/catalog"
|
|
890
|
+
),
|
|
891
|
+
listingGroupsQuery: endpoint("GET", "/api/products/listing-groups/query"),
|
|
892
|
+
listingGroupsQueryCatalog: endpoint(
|
|
893
|
+
"GET",
|
|
894
|
+
"/api/products/listing-groups/query/catalog"
|
|
895
|
+
),
|
|
896
|
+
stockCheck: endpoint("POST", "/api/products/stock-check"),
|
|
897
|
+
stockSnapshot: endpoint("GET", "/api/products/stock"),
|
|
898
|
+
upsert: endpoint("POST", "/api/products/upsert")
|
|
899
|
+
},
|
|
900
|
+
orders: {
|
|
901
|
+
update: endpoint("POST", "/api/orders/update"),
|
|
902
|
+
byPayment: endpoint("GET", "/api/orders/by-payment"),
|
|
903
|
+
cancel: endpoint("POST", "/api/orders/cancel"),
|
|
904
|
+
resolveCancelRefund: endpoint("POST", "/api/orders/resolve-cancel-refund"),
|
|
905
|
+
createFulfillment: endpoint("POST", "/api/orders/create-fulfillment"),
|
|
906
|
+
updateFulfillment: endpoint("POST", "/api/orders/update-fulfillment")
|
|
907
|
+
},
|
|
908
|
+
checkouts: {
|
|
909
|
+
create: endpoint("POST", "/api/orders/checkout"),
|
|
910
|
+
retrieve: endpoint("POST", "/api/checkouts/detail"),
|
|
911
|
+
server: {
|
|
912
|
+
create: endpoint("POST", "/api/orders/checkout"),
|
|
913
|
+
retrieve: endpoint("POST", "/api/checkouts/detail"),
|
|
914
|
+
query: endpoint("POST", "/api/checkouts/query")
|
|
915
|
+
}
|
|
916
|
+
},
|
|
917
|
+
returns: {
|
|
918
|
+
create: endpoint("POST", "/api/returns/create"),
|
|
919
|
+
update: endpoint("POST", "/api/returns/update"),
|
|
920
|
+
returnRefund: endpoint("POST", "/api/returns/return-refund")
|
|
921
|
+
},
|
|
922
|
+
fulfillmentOrders: {
|
|
923
|
+
prepare: endpoint(
|
|
924
|
+
"POST",
|
|
925
|
+
"/api/fulfillment-orders/prepare-fulfillment-order"
|
|
926
|
+
)
|
|
927
|
+
},
|
|
928
|
+
fulfillments: {
|
|
929
|
+
bulkImport: endpoint("POST", "/api/fulfillments/bulk-import")
|
|
930
|
+
},
|
|
931
|
+
carts: {
|
|
932
|
+
create: endpoint("POST", "/api/carts/create"),
|
|
933
|
+
retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.retrieve),
|
|
934
|
+
mine: endpoint("POST", "/api/carts/mine"),
|
|
935
|
+
merge: endpoint("POST", "/api/carts/merge"),
|
|
936
|
+
server: {
|
|
937
|
+
// Server credentials are an authorization lane, not a second Cart
|
|
938
|
+
// transport. These must stay bound to the registered shared operations.
|
|
939
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
|
|
940
|
+
retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.retrieve),
|
|
941
|
+
mine: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.mine),
|
|
942
|
+
merge: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.merge),
|
|
943
|
+
addItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.addItem),
|
|
944
|
+
updateItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.updateItem),
|
|
945
|
+
removeItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.removeItem),
|
|
946
|
+
updateDiscountCodes: sharedEndpoint(
|
|
947
|
+
COMMERCE_ENDPOINT_OPERATIONS.carts.updateDiscountCodes
|
|
948
|
+
),
|
|
949
|
+
updateAttributes: sharedEndpoint(
|
|
950
|
+
COMMERCE_ENDPOINT_OPERATIONS.carts.updateAttributes
|
|
951
|
+
),
|
|
952
|
+
clear: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.clear)
|
|
953
|
+
},
|
|
954
|
+
addItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.addItem),
|
|
955
|
+
updateItem: endpoint("POST", "/api/carts/update-item"),
|
|
956
|
+
removeItem: endpoint("POST", "/api/carts/remove-item"),
|
|
957
|
+
updateDiscountCodes: endpoint("POST", "/api/carts/update-discount-codes"),
|
|
958
|
+
updateAttributes: endpoint("POST", "/api/carts/update-attributes"),
|
|
959
|
+
clear: endpoint("POST", "/api/carts/clear")
|
|
960
|
+
},
|
|
961
|
+
paymentSessions: {
|
|
962
|
+
create: endpoint("POST", "/api/payment-sessions/create"),
|
|
963
|
+
retrieve: endpoint("POST", "/api/payment-sessions/retrieve"),
|
|
964
|
+
cancel: endpoint("POST", "/api/payment-sessions/cancel"),
|
|
965
|
+
server: {
|
|
966
|
+
create: endpoint("POST", "/api/payment-sessions/server/create"),
|
|
967
|
+
retrieve: endpoint("POST", "/api/payment-sessions/server/retrieve"),
|
|
968
|
+
cancel: endpoint("POST", "/api/payment-sessions/server/cancel"),
|
|
969
|
+
confirm: endpoint("POST", "/api/payment-sessions/server/confirm")
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
shippingPolicies: {
|
|
973
|
+
calculate: endpoint("POST", "/api/shipping-policies/calculate")
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
function isCommerceEndpointDescriptor(value) {
|
|
977
|
+
if (!value || typeof value !== "object") return false;
|
|
978
|
+
const candidate = value;
|
|
979
|
+
return typeof candidate.method === "string" && typeof candidate.path === "string";
|
|
980
|
+
}
|
|
981
|
+
function flattenEndpointPaths(value) {
|
|
982
|
+
if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
|
|
983
|
+
if (!value || typeof value !== "object") return [];
|
|
984
|
+
return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
|
|
650
985
|
}
|
|
986
|
+
function flattenEndpointDescriptors(value) {
|
|
987
|
+
if (isCommerceEndpointDescriptor(value)) return [value];
|
|
988
|
+
if (!value || typeof value !== "object") return [];
|
|
989
|
+
return Object.values(value).flatMap(
|
|
990
|
+
(entry) => flattenEndpointDescriptors(entry)
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
|
|
994
|
+
var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
|
|
995
|
+
var MEMBERSHIP_ENDPOINTS = {
|
|
996
|
+
subscribe: "/api/memberships/subscribe",
|
|
997
|
+
cancel: (id) => `/api/memberships/${id}/cancel`,
|
|
998
|
+
me: "/api/memberships/me"
|
|
999
|
+
};
|
|
1000
|
+
var MEMBERSHIP_ENDPOINT_PATHS = [
|
|
1001
|
+
MEMBERSHIP_ENDPOINTS.subscribe,
|
|
1002
|
+
MEMBERSHIP_ENDPOINTS.cancel(":id"),
|
|
1003
|
+
MEMBERSHIP_ENDPOINTS.me
|
|
1004
|
+
];
|
|
651
1005
|
|
|
652
1006
|
// src/core/query/query-hooks.ts
|
|
653
|
-
|
|
1007
|
+
function normalizeMarket(market) {
|
|
1008
|
+
const normalized = market?.trim();
|
|
1009
|
+
return normalized || void 0;
|
|
1010
|
+
}
|
|
1011
|
+
function requestCommerceFindEndpoint(collectionClient, endpoint2, options) {
|
|
1012
|
+
const path = resolveOperationPath2(endpoint2, { query: options?.query });
|
|
1013
|
+
if (endpoint2.method === "get") {
|
|
1014
|
+
return collectionClient.requestFindEndpointGet(path);
|
|
1015
|
+
}
|
|
1016
|
+
if (endpoint2.method === "post") {
|
|
1017
|
+
return collectionClient.requestFindEndpoint(path, options?.data);
|
|
1018
|
+
}
|
|
1019
|
+
throw new TypeError(`Unsupported find endpoint method: ${endpoint2.method}`);
|
|
1020
|
+
}
|
|
1021
|
+
function withDefaultMarket(params, market) {
|
|
1022
|
+
const defaultMarket = normalizeMarket(market);
|
|
1023
|
+
if (!defaultMarket || normalizeMarket(params?.market)) return params;
|
|
1024
|
+
return { ...params ?? {}, market: defaultMarket };
|
|
1025
|
+
}
|
|
1026
|
+
function resolveProductMarket(commerceClient, context) {
|
|
1027
|
+
return normalizeMarket(context?.market) ?? normalizeMarket(commerceClient.getDefaultMarket?.());
|
|
1028
|
+
}
|
|
1029
|
+
function splitListingGroupsQueryOptions(queryOptions) {
|
|
1030
|
+
const normalized = canonicalProductListingGroupsQueryOptions(queryOptions);
|
|
1031
|
+
if (!normalized) return { market: void 0, options: void 0 };
|
|
1032
|
+
const { market, ...options } = normalized;
|
|
1033
|
+
return {
|
|
1034
|
+
market,
|
|
1035
|
+
options: Object.keys(options).length > 0 ? options : void 0
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
654
1038
|
function fetchProductListingGroupsQuery(collectionClient, queryOptions) {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
1039
|
+
const { market, options } = splitListingGroupsQueryOptions(queryOptions);
|
|
1040
|
+
return requestCommerceFindEndpoint(
|
|
1041
|
+
collectionClient,
|
|
1042
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQuery,
|
|
1043
|
+
{
|
|
1044
|
+
data: {
|
|
1045
|
+
...market ? { market } : {},
|
|
1046
|
+
...options ? { options } : {}
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
658
1049
|
);
|
|
659
1050
|
}
|
|
660
1051
|
function fetchProductListingGroupsCatalogQuery(collectionClient, queryOptions) {
|
|
661
|
-
return
|
|
662
|
-
|
|
1052
|
+
return requestCommerceFindEndpoint(
|
|
1053
|
+
collectionClient,
|
|
1054
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog,
|
|
1055
|
+
{ query: listingPageSearchParams(queryOptions) }
|
|
663
1056
|
);
|
|
664
1057
|
}
|
|
665
|
-
function productListingPageQueryOptions(commerceClient, params = {}) {
|
|
1058
|
+
function productListingPageQueryOptions(commerceClient, params = {}, context) {
|
|
1059
|
+
const effectiveParams = withDefaultMarket(
|
|
1060
|
+
params,
|
|
1061
|
+
resolveProductMarket(
|
|
1062
|
+
commerceClient,
|
|
1063
|
+
context
|
|
1064
|
+
)
|
|
1065
|
+
) ?? params;
|
|
666
1066
|
return {
|
|
667
|
-
queryKey: productKeys.listingPage(
|
|
1067
|
+
queryKey: productKeys.listingPage(effectiveParams),
|
|
668
1068
|
queryFn: () => commerceClient.product.listingPage(
|
|
669
|
-
|
|
1069
|
+
effectiveParams
|
|
670
1070
|
)
|
|
671
1071
|
};
|
|
672
1072
|
}
|
|
673
|
-
function productListingPageInfiniteQueryOptions(commerceClient, params = {}) {
|
|
1073
|
+
function productListingPageInfiniteQueryOptions(commerceClient, params = {}, context) {
|
|
674
1074
|
const {
|
|
675
1075
|
pageSize: explicitPageSize,
|
|
676
1076
|
page: _page,
|
|
@@ -678,10 +1078,20 @@ function productListingPageInfiniteQueryOptions(commerceClient, params = {}) {
|
|
|
678
1078
|
...pageParams
|
|
679
1079
|
} = params;
|
|
680
1080
|
const pageSize = explicitPageSize ?? 20;
|
|
1081
|
+
const effectivePageParams = withDefaultMarket(
|
|
1082
|
+
pageParams,
|
|
1083
|
+
resolveProductMarket(
|
|
1084
|
+
commerceClient,
|
|
1085
|
+
context
|
|
1086
|
+
)
|
|
1087
|
+
) ?? pageParams;
|
|
681
1088
|
return {
|
|
682
|
-
queryKey: productKeys.listingPageInfinite(
|
|
1089
|
+
queryKey: productKeys.listingPageInfinite(
|
|
1090
|
+
effectivePageParams,
|
|
1091
|
+
explicitPageSize
|
|
1092
|
+
),
|
|
683
1093
|
queryFn: ({ pageParam }) => commerceClient.product.listingPage({
|
|
684
|
-
...
|
|
1094
|
+
...effectivePageParams,
|
|
685
1095
|
page: pageParam,
|
|
686
1096
|
limit: pageSize
|
|
687
1097
|
}),
|
|
@@ -689,27 +1099,29 @@ function productListingPageInfiniteQueryOptions(commerceClient, params = {}) {
|
|
|
689
1099
|
getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0
|
|
690
1100
|
};
|
|
691
1101
|
}
|
|
692
|
-
function prefetchProductListingPage(queryClient, commerceClient, params = {}, options) {
|
|
1102
|
+
function prefetchProductListingPage(queryClient, commerceClient, params = {}, options, context) {
|
|
693
1103
|
return queryClient.prefetchQuery({
|
|
694
1104
|
...productListingPageQueryOptions(
|
|
695
1105
|
commerceClient,
|
|
696
|
-
params
|
|
1106
|
+
params,
|
|
1107
|
+
context
|
|
697
1108
|
),
|
|
698
1109
|
...options
|
|
699
1110
|
});
|
|
700
1111
|
}
|
|
701
|
-
function prefetchInfiniteProductListingPage(queryClient, commerceClient, params = {}, options) {
|
|
1112
|
+
function prefetchInfiniteProductListingPage(queryClient, commerceClient, params = {}, options, context) {
|
|
702
1113
|
return queryClient.prefetchInfiniteQuery({
|
|
703
1114
|
...productListingPageInfiniteQueryOptions(
|
|
704
1115
|
commerceClient,
|
|
705
|
-
params
|
|
1116
|
+
params,
|
|
1117
|
+
context
|
|
706
1118
|
),
|
|
707
1119
|
pages: options?.pages ?? 1,
|
|
708
1120
|
staleTime: options?.staleTime
|
|
709
1121
|
});
|
|
710
1122
|
}
|
|
711
1123
|
var QueryHooks = class extends CollectionHooks {
|
|
712
|
-
constructor(queryClient, collectionClient, customerAuth, commerceClient) {
|
|
1124
|
+
constructor(queryClient, collectionClient, customerAuth, commerceClient, market) {
|
|
713
1125
|
super(queryClient, collectionClient);
|
|
714
1126
|
// --- Customer hooks delegation ---
|
|
715
1127
|
this.useCustomerMe = (...args) => this._customer.useCustomerMe(...args);
|
|
@@ -727,6 +1139,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
727
1139
|
this.setCustomerData = (data) => this._customer.setCustomerData(data);
|
|
728
1140
|
this._customer = new CustomerHooks(queryClient, customerAuth);
|
|
729
1141
|
this._commerce = commerceClient;
|
|
1142
|
+
this.market = normalizeMarket(market);
|
|
730
1143
|
}
|
|
731
1144
|
ensureCommerce() {
|
|
732
1145
|
if (!this._commerce) {
|
|
@@ -736,8 +1149,11 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
736
1149
|
}
|
|
737
1150
|
return this._commerce;
|
|
738
1151
|
}
|
|
1152
|
+
withProductMarket(params) {
|
|
1153
|
+
return withDefaultMarket(params, this.market);
|
|
1154
|
+
}
|
|
739
1155
|
useProductListingGroupsQuery(params, options) {
|
|
740
|
-
const queryOptions = params.options;
|
|
1156
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
741
1157
|
const { placeholderData, ...restOptions } = options ?? {};
|
|
742
1158
|
return useQueryOriginal3({
|
|
743
1159
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
@@ -749,7 +1165,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
749
1165
|
});
|
|
750
1166
|
}
|
|
751
1167
|
useProductListingGroupsCatalogQuery(params, options) {
|
|
752
|
-
const queryOptions = params.options;
|
|
1168
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
753
1169
|
const { placeholderData, ...restOptions } = options ?? {};
|
|
754
1170
|
return useQueryOriginal3({
|
|
755
1171
|
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
@@ -764,7 +1180,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
764
1180
|
});
|
|
765
1181
|
}
|
|
766
1182
|
useSuspenseProductListingGroupsQuery(params, options) {
|
|
767
|
-
const queryOptions = params.options;
|
|
1183
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
768
1184
|
return useSuspenseQueryOriginal2({
|
|
769
1185
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
770
1186
|
queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
|
|
@@ -772,7 +1188,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
772
1188
|
});
|
|
773
1189
|
}
|
|
774
1190
|
useSuspenseProductListingGroupsCatalogQuery(params, options) {
|
|
775
|
-
const queryOptions = params.options;
|
|
1191
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
776
1192
|
return useSuspenseQueryOriginal2({
|
|
777
1193
|
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
778
1194
|
queryFn: async () => fetchProductListingGroupsCatalogQuery(
|
|
@@ -783,7 +1199,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
783
1199
|
});
|
|
784
1200
|
}
|
|
785
1201
|
useInfiniteProductListingGroupsQuery(params, options) {
|
|
786
|
-
const
|
|
1202
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
787
1203
|
const explicitPageSize = params.pageSize;
|
|
788
1204
|
const pageSize = explicitPageSize ?? 20;
|
|
789
1205
|
return useInfiniteQueryOriginal2({
|
|
@@ -802,7 +1218,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
802
1218
|
});
|
|
803
1219
|
}
|
|
804
1220
|
useInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
805
|
-
const
|
|
1221
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
806
1222
|
const explicitPageSize = params.pageSize;
|
|
807
1223
|
const pageSize = explicitPageSize ?? 20;
|
|
808
1224
|
return useInfiniteQueryOriginal2({
|
|
@@ -821,7 +1237,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
821
1237
|
});
|
|
822
1238
|
}
|
|
823
1239
|
useSuspenseInfiniteProductListingGroupsQuery(params, options) {
|
|
824
|
-
const
|
|
1240
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
825
1241
|
const explicitPageSize = params.pageSize;
|
|
826
1242
|
const pageSize = explicitPageSize ?? 20;
|
|
827
1243
|
return useSuspenseInfiniteQueryOriginal2({
|
|
@@ -840,7 +1256,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
840
1256
|
});
|
|
841
1257
|
}
|
|
842
1258
|
useSuspenseInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
843
|
-
const
|
|
1259
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
844
1260
|
const explicitPageSize = params.pageSize;
|
|
845
1261
|
const pageSize = explicitPageSize ?? 20;
|
|
846
1262
|
return useSuspenseInfiniteQueryOriginal2({
|
|
@@ -859,7 +1275,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
859
1275
|
});
|
|
860
1276
|
}
|
|
861
1277
|
async prefetchProductListingGroupsQuery(params, options) {
|
|
862
|
-
const queryOptions = params.options;
|
|
1278
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
863
1279
|
return this.queryClient.prefetchQuery({
|
|
864
1280
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
865
1281
|
queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
|
|
@@ -867,7 +1283,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
867
1283
|
});
|
|
868
1284
|
}
|
|
869
1285
|
async prefetchProductListingGroupsCatalogQuery(params, options) {
|
|
870
|
-
const queryOptions = params.options;
|
|
1286
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
871
1287
|
return this.queryClient.prefetchQuery({
|
|
872
1288
|
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
873
1289
|
queryFn: async () => fetchProductListingGroupsCatalogQuery(
|
|
@@ -878,7 +1294,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
878
1294
|
});
|
|
879
1295
|
}
|
|
880
1296
|
async prefetchInfiniteProductListingGroupsQuery(params, options) {
|
|
881
|
-
const
|
|
1297
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
882
1298
|
const explicitPageSize = params.pageSize;
|
|
883
1299
|
const pageSize = explicitPageSize ?? 20;
|
|
884
1300
|
return this.queryClient.prefetchInfiniteQuery({
|
|
@@ -898,7 +1314,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
898
1314
|
});
|
|
899
1315
|
}
|
|
900
1316
|
async prefetchInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
901
|
-
const
|
|
1317
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
902
1318
|
const explicitPageSize = params.pageSize;
|
|
903
1319
|
const pageSize = explicitPageSize ?? 20;
|
|
904
1320
|
return this.queryClient.prefetchInfiniteQuery({
|
|
@@ -920,7 +1336,9 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
920
1336
|
useProductListingPage(params = {}, options) {
|
|
921
1337
|
const { placeholderData, ...restOptions } = options ?? {};
|
|
922
1338
|
return useQueryOriginal3({
|
|
923
|
-
...productListingPageQueryOptions(this.ensureCommerce(), params
|
|
1339
|
+
...productListingPageQueryOptions(this.ensureCommerce(), params, {
|
|
1340
|
+
market: this.market
|
|
1341
|
+
}),
|
|
924
1342
|
...restOptions,
|
|
925
1343
|
...placeholderData !== void 0 && {
|
|
926
1344
|
placeholderData
|
|
@@ -930,13 +1348,17 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
930
1348
|
useSuspenseProductListingPage(params = {}, options) {
|
|
931
1349
|
const suspenseOptions = options;
|
|
932
1350
|
return useSuspenseQueryOriginal2({
|
|
933
|
-
...productListingPageQueryOptions(this.ensureCommerce(), params
|
|
1351
|
+
...productListingPageQueryOptions(this.ensureCommerce(), params, {
|
|
1352
|
+
market: this.market
|
|
1353
|
+
}),
|
|
934
1354
|
...suspenseOptions
|
|
935
1355
|
});
|
|
936
1356
|
}
|
|
937
1357
|
useInfiniteProductListingPage(params = {}, options) {
|
|
938
1358
|
return useInfiniteQueryOriginal2({
|
|
939
|
-
...productListingPageInfiniteQueryOptions(this.ensureCommerce(), params
|
|
1359
|
+
...productListingPageInfiniteQueryOptions(this.ensureCommerce(), params, {
|
|
1360
|
+
market: this.market
|
|
1361
|
+
}),
|
|
940
1362
|
...options
|
|
941
1363
|
});
|
|
942
1364
|
}
|
|
@@ -945,7 +1367,8 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
945
1367
|
this.queryClient,
|
|
946
1368
|
this.ensureCommerce(),
|
|
947
1369
|
params,
|
|
948
|
-
options
|
|
1370
|
+
options,
|
|
1371
|
+
{ market: this.market }
|
|
949
1372
|
);
|
|
950
1373
|
}
|
|
951
1374
|
async prefetchInfiniteProductListingPage(params = {}, options) {
|
|
@@ -953,25 +1376,45 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
953
1376
|
this.queryClient,
|
|
954
1377
|
this.ensureCommerce(),
|
|
955
1378
|
params,
|
|
956
|
-
options
|
|
1379
|
+
options,
|
|
1380
|
+
{ market: this.market }
|
|
957
1381
|
);
|
|
958
1382
|
}
|
|
959
1383
|
useProductDetail(params, options) {
|
|
960
1384
|
const discriminator = "slug" in params ? params.slug : params.id;
|
|
961
1385
|
const { enabled, ...restOptions } = options ?? {};
|
|
962
1386
|
const queryEnabled = enabled !== false && Boolean(discriminator);
|
|
1387
|
+
const effectiveParams = this.withProductMarket(params) ?? params;
|
|
963
1388
|
return useQueryOriginal3({
|
|
964
|
-
queryKey: productKeys.detail(
|
|
965
|
-
queryFn: () => this._commerce.product.detail(
|
|
1389
|
+
queryKey: productKeys.detail(effectiveParams),
|
|
1390
|
+
queryFn: () => this._commerce.product.detail(effectiveParams),
|
|
966
1391
|
enabled: queryEnabled,
|
|
967
1392
|
...restOptions
|
|
968
1393
|
});
|
|
969
1394
|
}
|
|
970
1395
|
useProductDetailBySlug(slug, options) {
|
|
971
|
-
|
|
1396
|
+
const { market, locale, fallbackLocale, ...queryOptions } = options ?? {};
|
|
1397
|
+
return this.useProductDetail(
|
|
1398
|
+
{
|
|
1399
|
+
slug,
|
|
1400
|
+
...market ? { market } : {},
|
|
1401
|
+
...locale ? { locale } : {},
|
|
1402
|
+
...fallbackLocale !== void 0 ? { fallbackLocale } : {}
|
|
1403
|
+
},
|
|
1404
|
+
queryOptions
|
|
1405
|
+
);
|
|
972
1406
|
}
|
|
973
1407
|
useProductDetailById(id, options) {
|
|
974
|
-
|
|
1408
|
+
const { market, locale, fallbackLocale, ...queryOptions } = options ?? {};
|
|
1409
|
+
return this.useProductDetail(
|
|
1410
|
+
{
|
|
1411
|
+
id,
|
|
1412
|
+
...market ? { market } : {},
|
|
1413
|
+
...locale ? { locale } : {},
|
|
1414
|
+
...fallbackLocale !== void 0 ? { fallbackLocale } : {}
|
|
1415
|
+
},
|
|
1416
|
+
queryOptions
|
|
1417
|
+
);
|
|
975
1418
|
}
|
|
976
1419
|
};
|
|
977
1420
|
|
|
@@ -1121,6 +1564,9 @@ var RealtimeConnection = class {
|
|
|
1121
1564
|
};
|
|
1122
1565
|
|
|
1123
1566
|
// src/core/query/query-client.ts
|
|
1567
|
+
function getClientMarket(client) {
|
|
1568
|
+
return client.getConfig?.().market;
|
|
1569
|
+
}
|
|
1124
1570
|
function createReadOnlyQueryHooksFacade(hooks) {
|
|
1125
1571
|
return {
|
|
1126
1572
|
useQuery: hooks.useQuery.bind(hooks),
|
|
@@ -1168,7 +1614,8 @@ function createQueryHooks(client, queryClient = getQueryClient()) {
|
|
|
1168
1614
|
queryClient,
|
|
1169
1615
|
client.collections,
|
|
1170
1616
|
client.customer.auth,
|
|
1171
|
-
client.commerce
|
|
1617
|
+
client.commerce,
|
|
1618
|
+
getClientMarket(client)
|
|
1172
1619
|
);
|
|
1173
1620
|
return createReadOnlyQueryHooksFacade(hooks);
|
|
1174
1621
|
}
|
|
@@ -1177,7 +1624,8 @@ function createServerQueryHooks(client, queryClient = getQueryClient()) {
|
|
|
1177
1624
|
queryClient,
|
|
1178
1625
|
client.collections,
|
|
1179
1626
|
void 0,
|
|
1180
|
-
client.commerce
|
|
1627
|
+
client.commerce,
|
|
1628
|
+
getClientMarket(client)
|
|
1181
1629
|
);
|
|
1182
1630
|
}
|
|
1183
1631
|
export {
|
|
@@ -1185,6 +1633,7 @@ export {
|
|
|
1185
1633
|
CustomerHooks,
|
|
1186
1634
|
QueryHooks,
|
|
1187
1635
|
RealtimeConnection,
|
|
1636
|
+
canonicalProductListingGroupsQueryOptions,
|
|
1188
1637
|
collectionKeys,
|
|
1189
1638
|
createQueryHooks,
|
|
1190
1639
|
createServerQueryHooks,
|