@01.software/sdk 0.44.0 → 0.46.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 +366 -2
- package/MIGRATION.md +108 -10
- package/README.md +486 -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 +2693 -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 +2693 -345
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-DWooaiTr.d.ts → collection-client-D6kKrYdq.d.ts} +8 -5
- package/dist/{collection-client-Dyl-CDcj.d.cts → collection-client-DolMjCoC.d.cts} +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 +2754 -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 +2754 -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 +558 -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 +558 -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 +2343 -437
- 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 +2343 -437
- 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-C60vHIkY.d.ts} +1134 -509
- package/dist/types-D5p7-m1l.d.cts +47 -0
- package/dist/{types-Dt9FJisi.d.ts → types-xlqBeW2N.d.cts} +1134 -509
- 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 +10 -9
- 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,387 @@ 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
|
+
custom: {
|
|
966
|
+
create: sharedEndpoint(
|
|
967
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.create
|
|
968
|
+
),
|
|
969
|
+
confirm: sharedEndpoint(
|
|
970
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.confirm
|
|
971
|
+
)
|
|
972
|
+
},
|
|
973
|
+
server: {
|
|
974
|
+
create: endpoint("POST", "/api/payment-sessions/server/create"),
|
|
975
|
+
retrieve: endpoint("POST", "/api/payment-sessions/server/retrieve"),
|
|
976
|
+
cancel: endpoint("POST", "/api/payment-sessions/server/cancel"),
|
|
977
|
+
confirm: endpoint("POST", "/api/payment-sessions/server/confirm")
|
|
978
|
+
}
|
|
979
|
+
},
|
|
980
|
+
shippingPolicies: {
|
|
981
|
+
calculate: endpoint("POST", "/api/shipping-policies/calculate")
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
function isCommerceEndpointDescriptor(value) {
|
|
985
|
+
if (!value || typeof value !== "object") return false;
|
|
986
|
+
const candidate = value;
|
|
987
|
+
return typeof candidate.method === "string" && typeof candidate.path === "string";
|
|
650
988
|
}
|
|
989
|
+
function flattenEndpointPaths(value) {
|
|
990
|
+
if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
|
|
991
|
+
if (!value || typeof value !== "object") return [];
|
|
992
|
+
return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
|
|
993
|
+
}
|
|
994
|
+
function flattenEndpointDescriptors(value) {
|
|
995
|
+
if (isCommerceEndpointDescriptor(value)) return [value];
|
|
996
|
+
if (!value || typeof value !== "object") return [];
|
|
997
|
+
return Object.values(value).flatMap(
|
|
998
|
+
(entry) => flattenEndpointDescriptors(entry)
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
|
|
1002
|
+
var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
|
|
1003
|
+
var MEMBERSHIP_ENDPOINTS = {
|
|
1004
|
+
subscribe: "/api/memberships/subscribe",
|
|
1005
|
+
cancel: (id) => `/api/memberships/${id}/cancel`,
|
|
1006
|
+
me: "/api/memberships/me"
|
|
1007
|
+
};
|
|
1008
|
+
var MEMBERSHIP_ENDPOINT_PATHS = [
|
|
1009
|
+
MEMBERSHIP_ENDPOINTS.subscribe,
|
|
1010
|
+
MEMBERSHIP_ENDPOINTS.cancel(":id"),
|
|
1011
|
+
MEMBERSHIP_ENDPOINTS.me
|
|
1012
|
+
];
|
|
651
1013
|
|
|
652
1014
|
// src/core/query/query-hooks.ts
|
|
653
|
-
|
|
1015
|
+
function normalizeMarket(market) {
|
|
1016
|
+
const normalized = market?.trim();
|
|
1017
|
+
return normalized || void 0;
|
|
1018
|
+
}
|
|
1019
|
+
function requestCommerceFindEndpoint(collectionClient, endpoint2, options) {
|
|
1020
|
+
const path = resolveOperationPath2(endpoint2, { query: options?.query });
|
|
1021
|
+
if (endpoint2.method === "get") {
|
|
1022
|
+
return collectionClient.requestFindEndpointGet(path);
|
|
1023
|
+
}
|
|
1024
|
+
if (endpoint2.method === "post") {
|
|
1025
|
+
return collectionClient.requestFindEndpoint(path, options?.data);
|
|
1026
|
+
}
|
|
1027
|
+
throw new TypeError(`Unsupported find endpoint method: ${endpoint2.method}`);
|
|
1028
|
+
}
|
|
1029
|
+
function withDefaultMarket(params, market) {
|
|
1030
|
+
const defaultMarket = normalizeMarket(market);
|
|
1031
|
+
if (!defaultMarket || normalizeMarket(params?.market)) return params;
|
|
1032
|
+
return { ...params ?? {}, market: defaultMarket };
|
|
1033
|
+
}
|
|
1034
|
+
function resolveProductMarket(commerceClient, context) {
|
|
1035
|
+
return normalizeMarket(context?.market) ?? normalizeMarket(commerceClient.getDefaultMarket?.());
|
|
1036
|
+
}
|
|
1037
|
+
function splitListingGroupsQueryOptions(queryOptions) {
|
|
1038
|
+
const normalized = canonicalProductListingGroupsQueryOptions(queryOptions);
|
|
1039
|
+
if (!normalized) return { market: void 0, options: void 0 };
|
|
1040
|
+
const { market, ...options } = normalized;
|
|
1041
|
+
return {
|
|
1042
|
+
market,
|
|
1043
|
+
options: Object.keys(options).length > 0 ? options : void 0
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
654
1046
|
function fetchProductListingGroupsQuery(collectionClient, queryOptions) {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
1047
|
+
const { market, options } = splitListingGroupsQueryOptions(queryOptions);
|
|
1048
|
+
return requestCommerceFindEndpoint(
|
|
1049
|
+
collectionClient,
|
|
1050
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQuery,
|
|
1051
|
+
{
|
|
1052
|
+
data: {
|
|
1053
|
+
...market ? { market } : {},
|
|
1054
|
+
...options ? { options } : {}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
658
1057
|
);
|
|
659
1058
|
}
|
|
660
1059
|
function fetchProductListingGroupsCatalogQuery(collectionClient, queryOptions) {
|
|
661
|
-
return
|
|
662
|
-
|
|
1060
|
+
return requestCommerceFindEndpoint(
|
|
1061
|
+
collectionClient,
|
|
1062
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog,
|
|
1063
|
+
{ query: listingPageSearchParams(queryOptions) }
|
|
663
1064
|
);
|
|
664
1065
|
}
|
|
665
|
-
function productListingPageQueryOptions(commerceClient, params = {}) {
|
|
1066
|
+
function productListingPageQueryOptions(commerceClient, params = {}, context) {
|
|
1067
|
+
const effectiveParams = withDefaultMarket(
|
|
1068
|
+
params,
|
|
1069
|
+
resolveProductMarket(
|
|
1070
|
+
commerceClient,
|
|
1071
|
+
context
|
|
1072
|
+
)
|
|
1073
|
+
) ?? params;
|
|
666
1074
|
return {
|
|
667
|
-
queryKey: productKeys.listingPage(
|
|
1075
|
+
queryKey: productKeys.listingPage(effectiveParams),
|
|
668
1076
|
queryFn: () => commerceClient.product.listingPage(
|
|
669
|
-
|
|
1077
|
+
effectiveParams
|
|
670
1078
|
)
|
|
671
1079
|
};
|
|
672
1080
|
}
|
|
673
|
-
function productListingPageInfiniteQueryOptions(commerceClient, params = {}) {
|
|
1081
|
+
function productListingPageInfiniteQueryOptions(commerceClient, params = {}, context) {
|
|
674
1082
|
const {
|
|
675
1083
|
pageSize: explicitPageSize,
|
|
676
1084
|
page: _page,
|
|
@@ -678,10 +1086,20 @@ function productListingPageInfiniteQueryOptions(commerceClient, params = {}) {
|
|
|
678
1086
|
...pageParams
|
|
679
1087
|
} = params;
|
|
680
1088
|
const pageSize = explicitPageSize ?? 20;
|
|
1089
|
+
const effectivePageParams = withDefaultMarket(
|
|
1090
|
+
pageParams,
|
|
1091
|
+
resolveProductMarket(
|
|
1092
|
+
commerceClient,
|
|
1093
|
+
context
|
|
1094
|
+
)
|
|
1095
|
+
) ?? pageParams;
|
|
681
1096
|
return {
|
|
682
|
-
queryKey: productKeys.listingPageInfinite(
|
|
1097
|
+
queryKey: productKeys.listingPageInfinite(
|
|
1098
|
+
effectivePageParams,
|
|
1099
|
+
explicitPageSize
|
|
1100
|
+
),
|
|
683
1101
|
queryFn: ({ pageParam }) => commerceClient.product.listingPage({
|
|
684
|
-
...
|
|
1102
|
+
...effectivePageParams,
|
|
685
1103
|
page: pageParam,
|
|
686
1104
|
limit: pageSize
|
|
687
1105
|
}),
|
|
@@ -689,27 +1107,29 @@ function productListingPageInfiniteQueryOptions(commerceClient, params = {}) {
|
|
|
689
1107
|
getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0
|
|
690
1108
|
};
|
|
691
1109
|
}
|
|
692
|
-
function prefetchProductListingPage(queryClient, commerceClient, params = {}, options) {
|
|
1110
|
+
function prefetchProductListingPage(queryClient, commerceClient, params = {}, options, context) {
|
|
693
1111
|
return queryClient.prefetchQuery({
|
|
694
1112
|
...productListingPageQueryOptions(
|
|
695
1113
|
commerceClient,
|
|
696
|
-
params
|
|
1114
|
+
params,
|
|
1115
|
+
context
|
|
697
1116
|
),
|
|
698
1117
|
...options
|
|
699
1118
|
});
|
|
700
1119
|
}
|
|
701
|
-
function prefetchInfiniteProductListingPage(queryClient, commerceClient, params = {}, options) {
|
|
1120
|
+
function prefetchInfiniteProductListingPage(queryClient, commerceClient, params = {}, options, context) {
|
|
702
1121
|
return queryClient.prefetchInfiniteQuery({
|
|
703
1122
|
...productListingPageInfiniteQueryOptions(
|
|
704
1123
|
commerceClient,
|
|
705
|
-
params
|
|
1124
|
+
params,
|
|
1125
|
+
context
|
|
706
1126
|
),
|
|
707
1127
|
pages: options?.pages ?? 1,
|
|
708
1128
|
staleTime: options?.staleTime
|
|
709
1129
|
});
|
|
710
1130
|
}
|
|
711
1131
|
var QueryHooks = class extends CollectionHooks {
|
|
712
|
-
constructor(queryClient, collectionClient, customerAuth, commerceClient) {
|
|
1132
|
+
constructor(queryClient, collectionClient, customerAuth, commerceClient, market) {
|
|
713
1133
|
super(queryClient, collectionClient);
|
|
714
1134
|
// --- Customer hooks delegation ---
|
|
715
1135
|
this.useCustomerMe = (...args) => this._customer.useCustomerMe(...args);
|
|
@@ -727,6 +1147,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
727
1147
|
this.setCustomerData = (data) => this._customer.setCustomerData(data);
|
|
728
1148
|
this._customer = new CustomerHooks(queryClient, customerAuth);
|
|
729
1149
|
this._commerce = commerceClient;
|
|
1150
|
+
this.market = normalizeMarket(market);
|
|
730
1151
|
}
|
|
731
1152
|
ensureCommerce() {
|
|
732
1153
|
if (!this._commerce) {
|
|
@@ -736,8 +1157,11 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
736
1157
|
}
|
|
737
1158
|
return this._commerce;
|
|
738
1159
|
}
|
|
1160
|
+
withProductMarket(params) {
|
|
1161
|
+
return withDefaultMarket(params, this.market);
|
|
1162
|
+
}
|
|
739
1163
|
useProductListingGroupsQuery(params, options) {
|
|
740
|
-
const queryOptions = params.options;
|
|
1164
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
741
1165
|
const { placeholderData, ...restOptions } = options ?? {};
|
|
742
1166
|
return useQueryOriginal3({
|
|
743
1167
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
@@ -749,7 +1173,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
749
1173
|
});
|
|
750
1174
|
}
|
|
751
1175
|
useProductListingGroupsCatalogQuery(params, options) {
|
|
752
|
-
const queryOptions = params.options;
|
|
1176
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
753
1177
|
const { placeholderData, ...restOptions } = options ?? {};
|
|
754
1178
|
return useQueryOriginal3({
|
|
755
1179
|
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
@@ -764,7 +1188,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
764
1188
|
});
|
|
765
1189
|
}
|
|
766
1190
|
useSuspenseProductListingGroupsQuery(params, options) {
|
|
767
|
-
const queryOptions = params.options;
|
|
1191
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
768
1192
|
return useSuspenseQueryOriginal2({
|
|
769
1193
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
770
1194
|
queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
|
|
@@ -772,7 +1196,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
772
1196
|
});
|
|
773
1197
|
}
|
|
774
1198
|
useSuspenseProductListingGroupsCatalogQuery(params, options) {
|
|
775
|
-
const queryOptions = params.options;
|
|
1199
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
776
1200
|
return useSuspenseQueryOriginal2({
|
|
777
1201
|
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
778
1202
|
queryFn: async () => fetchProductListingGroupsCatalogQuery(
|
|
@@ -783,7 +1207,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
783
1207
|
});
|
|
784
1208
|
}
|
|
785
1209
|
useInfiniteProductListingGroupsQuery(params, options) {
|
|
786
|
-
const
|
|
1210
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
787
1211
|
const explicitPageSize = params.pageSize;
|
|
788
1212
|
const pageSize = explicitPageSize ?? 20;
|
|
789
1213
|
return useInfiniteQueryOriginal2({
|
|
@@ -802,7 +1226,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
802
1226
|
});
|
|
803
1227
|
}
|
|
804
1228
|
useInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
805
|
-
const
|
|
1229
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
806
1230
|
const explicitPageSize = params.pageSize;
|
|
807
1231
|
const pageSize = explicitPageSize ?? 20;
|
|
808
1232
|
return useInfiniteQueryOriginal2({
|
|
@@ -821,7 +1245,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
821
1245
|
});
|
|
822
1246
|
}
|
|
823
1247
|
useSuspenseInfiniteProductListingGroupsQuery(params, options) {
|
|
824
|
-
const
|
|
1248
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
825
1249
|
const explicitPageSize = params.pageSize;
|
|
826
1250
|
const pageSize = explicitPageSize ?? 20;
|
|
827
1251
|
return useSuspenseInfiniteQueryOriginal2({
|
|
@@ -840,7 +1264,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
840
1264
|
});
|
|
841
1265
|
}
|
|
842
1266
|
useSuspenseInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
843
|
-
const
|
|
1267
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
844
1268
|
const explicitPageSize = params.pageSize;
|
|
845
1269
|
const pageSize = explicitPageSize ?? 20;
|
|
846
1270
|
return useSuspenseInfiniteQueryOriginal2({
|
|
@@ -859,7 +1283,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
859
1283
|
});
|
|
860
1284
|
}
|
|
861
1285
|
async prefetchProductListingGroupsQuery(params, options) {
|
|
862
|
-
const queryOptions = params.options;
|
|
1286
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
863
1287
|
return this.queryClient.prefetchQuery({
|
|
864
1288
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
865
1289
|
queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
|
|
@@ -867,7 +1291,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
867
1291
|
});
|
|
868
1292
|
}
|
|
869
1293
|
async prefetchProductListingGroupsCatalogQuery(params, options) {
|
|
870
|
-
const queryOptions = params.options;
|
|
1294
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
871
1295
|
return this.queryClient.prefetchQuery({
|
|
872
1296
|
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
873
1297
|
queryFn: async () => fetchProductListingGroupsCatalogQuery(
|
|
@@ -878,7 +1302,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
878
1302
|
});
|
|
879
1303
|
}
|
|
880
1304
|
async prefetchInfiniteProductListingGroupsQuery(params, options) {
|
|
881
|
-
const
|
|
1305
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
882
1306
|
const explicitPageSize = params.pageSize;
|
|
883
1307
|
const pageSize = explicitPageSize ?? 20;
|
|
884
1308
|
return this.queryClient.prefetchInfiniteQuery({
|
|
@@ -898,7 +1322,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
898
1322
|
});
|
|
899
1323
|
}
|
|
900
1324
|
async prefetchInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
901
|
-
const
|
|
1325
|
+
const queryOptions = this.withProductMarket(params.options);
|
|
902
1326
|
const explicitPageSize = params.pageSize;
|
|
903
1327
|
const pageSize = explicitPageSize ?? 20;
|
|
904
1328
|
return this.queryClient.prefetchInfiniteQuery({
|
|
@@ -920,7 +1344,9 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
920
1344
|
useProductListingPage(params = {}, options) {
|
|
921
1345
|
const { placeholderData, ...restOptions } = options ?? {};
|
|
922
1346
|
return useQueryOriginal3({
|
|
923
|
-
...productListingPageQueryOptions(this.ensureCommerce(), params
|
|
1347
|
+
...productListingPageQueryOptions(this.ensureCommerce(), params, {
|
|
1348
|
+
market: this.market
|
|
1349
|
+
}),
|
|
924
1350
|
...restOptions,
|
|
925
1351
|
...placeholderData !== void 0 && {
|
|
926
1352
|
placeholderData
|
|
@@ -930,13 +1356,17 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
930
1356
|
useSuspenseProductListingPage(params = {}, options) {
|
|
931
1357
|
const suspenseOptions = options;
|
|
932
1358
|
return useSuspenseQueryOriginal2({
|
|
933
|
-
...productListingPageQueryOptions(this.ensureCommerce(), params
|
|
1359
|
+
...productListingPageQueryOptions(this.ensureCommerce(), params, {
|
|
1360
|
+
market: this.market
|
|
1361
|
+
}),
|
|
934
1362
|
...suspenseOptions
|
|
935
1363
|
});
|
|
936
1364
|
}
|
|
937
1365
|
useInfiniteProductListingPage(params = {}, options) {
|
|
938
1366
|
return useInfiniteQueryOriginal2({
|
|
939
|
-
...productListingPageInfiniteQueryOptions(this.ensureCommerce(), params
|
|
1367
|
+
...productListingPageInfiniteQueryOptions(this.ensureCommerce(), params, {
|
|
1368
|
+
market: this.market
|
|
1369
|
+
}),
|
|
940
1370
|
...options
|
|
941
1371
|
});
|
|
942
1372
|
}
|
|
@@ -945,7 +1375,8 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
945
1375
|
this.queryClient,
|
|
946
1376
|
this.ensureCommerce(),
|
|
947
1377
|
params,
|
|
948
|
-
options
|
|
1378
|
+
options,
|
|
1379
|
+
{ market: this.market }
|
|
949
1380
|
);
|
|
950
1381
|
}
|
|
951
1382
|
async prefetchInfiniteProductListingPage(params = {}, options) {
|
|
@@ -953,25 +1384,45 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
953
1384
|
this.queryClient,
|
|
954
1385
|
this.ensureCommerce(),
|
|
955
1386
|
params,
|
|
956
|
-
options
|
|
1387
|
+
options,
|
|
1388
|
+
{ market: this.market }
|
|
957
1389
|
);
|
|
958
1390
|
}
|
|
959
1391
|
useProductDetail(params, options) {
|
|
960
1392
|
const discriminator = "slug" in params ? params.slug : params.id;
|
|
961
1393
|
const { enabled, ...restOptions } = options ?? {};
|
|
962
1394
|
const queryEnabled = enabled !== false && Boolean(discriminator);
|
|
1395
|
+
const effectiveParams = this.withProductMarket(params) ?? params;
|
|
963
1396
|
return useQueryOriginal3({
|
|
964
|
-
queryKey: productKeys.detail(
|
|
965
|
-
queryFn: () => this._commerce.product.detail(
|
|
1397
|
+
queryKey: productKeys.detail(effectiveParams),
|
|
1398
|
+
queryFn: () => this._commerce.product.detail(effectiveParams),
|
|
966
1399
|
enabled: queryEnabled,
|
|
967
1400
|
...restOptions
|
|
968
1401
|
});
|
|
969
1402
|
}
|
|
970
1403
|
useProductDetailBySlug(slug, options) {
|
|
971
|
-
|
|
1404
|
+
const { market, locale, fallbackLocale, ...queryOptions } = options ?? {};
|
|
1405
|
+
return this.useProductDetail(
|
|
1406
|
+
{
|
|
1407
|
+
slug,
|
|
1408
|
+
...market ? { market } : {},
|
|
1409
|
+
...locale ? { locale } : {},
|
|
1410
|
+
...fallbackLocale !== void 0 ? { fallbackLocale } : {}
|
|
1411
|
+
},
|
|
1412
|
+
queryOptions
|
|
1413
|
+
);
|
|
972
1414
|
}
|
|
973
1415
|
useProductDetailById(id, options) {
|
|
974
|
-
|
|
1416
|
+
const { market, locale, fallbackLocale, ...queryOptions } = options ?? {};
|
|
1417
|
+
return this.useProductDetail(
|
|
1418
|
+
{
|
|
1419
|
+
id,
|
|
1420
|
+
...market ? { market } : {},
|
|
1421
|
+
...locale ? { locale } : {},
|
|
1422
|
+
...fallbackLocale !== void 0 ? { fallbackLocale } : {}
|
|
1423
|
+
},
|
|
1424
|
+
queryOptions
|
|
1425
|
+
);
|
|
975
1426
|
}
|
|
976
1427
|
};
|
|
977
1428
|
|
|
@@ -1121,6 +1572,9 @@ var RealtimeConnection = class {
|
|
|
1121
1572
|
};
|
|
1122
1573
|
|
|
1123
1574
|
// src/core/query/query-client.ts
|
|
1575
|
+
function getClientMarket(client) {
|
|
1576
|
+
return client.getConfig?.().market;
|
|
1577
|
+
}
|
|
1124
1578
|
function createReadOnlyQueryHooksFacade(hooks) {
|
|
1125
1579
|
return {
|
|
1126
1580
|
useQuery: hooks.useQuery.bind(hooks),
|
|
@@ -1168,7 +1622,8 @@ function createQueryHooks(client, queryClient = getQueryClient()) {
|
|
|
1168
1622
|
queryClient,
|
|
1169
1623
|
client.collections,
|
|
1170
1624
|
client.customer.auth,
|
|
1171
|
-
client.commerce
|
|
1625
|
+
client.commerce,
|
|
1626
|
+
getClientMarket(client)
|
|
1172
1627
|
);
|
|
1173
1628
|
return createReadOnlyQueryHooksFacade(hooks);
|
|
1174
1629
|
}
|
|
@@ -1177,7 +1632,8 @@ function createServerQueryHooks(client, queryClient = getQueryClient()) {
|
|
|
1177
1632
|
queryClient,
|
|
1178
1633
|
client.collections,
|
|
1179
1634
|
void 0,
|
|
1180
|
-
client.commerce
|
|
1635
|
+
client.commerce,
|
|
1636
|
+
getClientMarket(client)
|
|
1181
1637
|
);
|
|
1182
1638
|
}
|
|
1183
1639
|
export {
|
|
@@ -1185,6 +1641,7 @@ export {
|
|
|
1185
1641
|
CustomerHooks,
|
|
1186
1642
|
QueryHooks,
|
|
1187
1643
|
RealtimeConnection,
|
|
1644
|
+
canonicalProductListingGroupsQueryOptions,
|
|
1188
1645
|
collectionKeys,
|
|
1189
1646
|
createQueryHooks,
|
|
1190
1647
|
createServerQueryHooks,
|