@01.software/sdk 0.32.0 → 0.34.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/README.md +253 -38
- package/dist/analytics/react.cjs.map +1 -1
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/client.cjs +368 -24
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +7 -6
- package/dist/client.d.ts +7 -6
- package/dist/client.js +368 -24
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-CORhppPb.d.cts → collection-client-CR2B8c1v.d.cts} +7 -3
- package/dist/{collection-client-DPGXnhoF.d.ts → collection-client-DkREjhQ9.d.ts} +7 -3
- package/dist/{const-DcY2_z9O.d.ts → const-BTvdrXtY.d.cts} +5 -5
- package/dist/{const-Brk2Ff0q.d.cts → const-CdqCauHQ.d.ts} +5 -5
- package/dist/index-CjA3U6X3.d.cts +186 -0
- package/dist/index-DK8_NXkh.d.ts +186 -0
- package/dist/index.cjs +1651 -260
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -9
- package/dist/index.d.ts +74 -9
- package/dist/index.js +1651 -260
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-DVK1QCeU.d.cts → payload-types-C7tb7Xbs.d.cts} +2115 -1833
- package/dist/{payload-types-DVK1QCeU.d.ts → payload-types-C7tb7Xbs.d.ts} +2115 -1833
- package/dist/query.cjs +194 -35
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +45 -18
- package/dist/query.d.ts +45 -18
- package/dist/query.js +194 -35
- 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-CrsPyqEc.d.cts → server-nXOezi4b.d.cts} +22 -6
- package/dist/{server-CrsPyqEc.d.ts → server-nXOezi4b.d.ts} +22 -6
- package/dist/server.cjs +474 -36
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +11 -179
- package/dist/server.d.ts +11 -179
- package/dist/server.js +474 -36
- package/dist/server.js.map +1 -1
- package/dist/{types-DUPC7Xn6.d.ts → types-1ylMrCuW.d.ts} +1 -1
- package/dist/{types-ByMrR_Z_.d.cts → types-Bx558PU6.d.cts} +1 -1
- package/dist/{types-CYMSBkJC.d.ts → types-Byo_Rty4.d.ts} +728 -75
- package/dist/{types-CAkWqIr6.d.cts → types-DDhtZI6E.d.cts} +728 -75
- package/dist/ui/canvas/server.cjs +231 -38
- package/dist/ui/canvas/server.cjs.map +1 -1
- package/dist/ui/canvas/server.d.cts +1 -1
- package/dist/ui/canvas/server.d.ts +1 -1
- package/dist/ui/canvas/server.js +221 -38
- package/dist/ui/canvas/server.js.map +1 -1
- package/dist/ui/canvas.cjs +320 -257
- package/dist/ui/canvas.cjs.map +1 -1
- package/dist/ui/canvas.d.cts +5 -19
- package/dist/ui/canvas.d.ts +5 -19
- package/dist/ui/canvas.js +323 -260
- 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 +95 -0
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +20 -104
- package/dist/webhook.d.ts +20 -104
- package/dist/webhook.js +95 -0
- package/dist/webhook.js.map +1 -1
- package/package.json +4 -5
package/dist/query.cjs
CHANGED
|
@@ -29,6 +29,7 @@ __export(query_exports, {
|
|
|
29
29
|
createServerQueryHooks: () => createServerQueryHooks,
|
|
30
30
|
customerKeys: () => customerKeys,
|
|
31
31
|
getQueryClient: () => getQueryClient,
|
|
32
|
+
getStorefrontQueryClient: () => getStorefrontQueryClient,
|
|
32
33
|
productKeys: () => productKeys
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(query_exports);
|
|
@@ -53,6 +54,7 @@ function makeQueryClient() {
|
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
var browserQueryClient;
|
|
57
|
+
var browserStorefrontQueryClient;
|
|
56
58
|
function getQueryClient() {
|
|
57
59
|
if (import_react_query.isServer) {
|
|
58
60
|
return makeQueryClient();
|
|
@@ -62,6 +64,30 @@ function getQueryClient() {
|
|
|
62
64
|
}
|
|
63
65
|
return browserQueryClient;
|
|
64
66
|
}
|
|
67
|
+
var STOREFRONT_STALE_TIME_MS = 6e4;
|
|
68
|
+
function makeStorefrontQueryClient() {
|
|
69
|
+
return new import_react_query.QueryClient({
|
|
70
|
+
defaultOptions: {
|
|
71
|
+
queries: {
|
|
72
|
+
staleTime: STOREFRONT_STALE_TIME_MS,
|
|
73
|
+
refetchOnWindowFocus: false
|
|
74
|
+
},
|
|
75
|
+
dehydrate: {
|
|
76
|
+
shouldDehydrateQuery: (query) => (0, import_react_query.defaultShouldDehydrateQuery)(query) || query.state.status === "pending",
|
|
77
|
+
shouldRedactErrors: () => false
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function getStorefrontQueryClient() {
|
|
83
|
+
if (import_react_query.isServer) {
|
|
84
|
+
return makeStorefrontQueryClient();
|
|
85
|
+
}
|
|
86
|
+
if (!browserStorefrontQueryClient) {
|
|
87
|
+
browserStorefrontQueryClient = makeStorefrontQueryClient();
|
|
88
|
+
}
|
|
89
|
+
return browserStorefrontQueryClient;
|
|
90
|
+
}
|
|
65
91
|
|
|
66
92
|
// src/core/query/query-keys.ts
|
|
67
93
|
function collectionKeys(collection) {
|
|
@@ -81,7 +107,9 @@ var customerKeys = {
|
|
|
81
107
|
};
|
|
82
108
|
var productKeys = {
|
|
83
109
|
listingGroups: (options) => ["products", "listing-groups", "list", options],
|
|
110
|
+
listingGroupsCatalog: (options) => ["products", "listing-groups", "catalog", options],
|
|
84
111
|
listingGroupsInfinite: (options) => ["products", "listing-groups", "infinite", options],
|
|
112
|
+
listingGroupsCatalogInfinite: (options) => ["products", "listing-groups", "catalog", "infinite", options],
|
|
85
113
|
detail: (params) => ["products", "detail", params],
|
|
86
114
|
detailAll: () => ["products", "detail"]
|
|
87
115
|
};
|
|
@@ -597,6 +625,42 @@ var CustomerHooks = class {
|
|
|
597
625
|
|
|
598
626
|
// src/core/query/query-hooks.ts
|
|
599
627
|
var import_react_query4 = require("@tanstack/react-query");
|
|
628
|
+
|
|
629
|
+
// src/core/internal/utils/query-string.ts
|
|
630
|
+
function appendListingGroupsQuerySearchParams(search, options) {
|
|
631
|
+
if (options?.page != null) search.set("page", String(options.page));
|
|
632
|
+
if (options?.limit != null) search.set("limit", String(options.limit));
|
|
633
|
+
if (options?.sort != null) {
|
|
634
|
+
const sort = options.sort;
|
|
635
|
+
search.set(
|
|
636
|
+
"sort",
|
|
637
|
+
Array.isArray(sort) ? sort.join(",") : sort
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
if (options?.where != null) {
|
|
641
|
+
search.set("whereJson", JSON.stringify(options.where));
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
function listingGroupsQueryCatalogUrl(options) {
|
|
645
|
+
const search = new URLSearchParams();
|
|
646
|
+
appendListingGroupsQuerySearchParams(search, options);
|
|
647
|
+
const query = search.toString();
|
|
648
|
+
return `/api/products/listing-groups/query/catalog${query ? `?${query}` : ""}`;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// src/core/query/query-hooks.ts
|
|
652
|
+
var LISTING_GROUPS_QUERY_PATH = "/api/products/listing-groups/query";
|
|
653
|
+
function fetchProductListingGroupsQuery(collectionClient, queryOptions) {
|
|
654
|
+
return collectionClient.requestFindEndpoint(
|
|
655
|
+
LISTING_GROUPS_QUERY_PATH,
|
|
656
|
+
{ options: queryOptions }
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
function fetchProductListingGroupsCatalogQuery(collectionClient, queryOptions) {
|
|
660
|
+
return collectionClient.requestFindEndpointGet(
|
|
661
|
+
listingGroupsQueryCatalogUrl(queryOptions)
|
|
662
|
+
);
|
|
663
|
+
}
|
|
600
664
|
var QueryHooks = class extends CollectionHooks {
|
|
601
665
|
constructor(queryClient, collectionClient, customerAuth, commerceClient) {
|
|
602
666
|
super(queryClient, collectionClient);
|
|
@@ -622,9 +686,21 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
622
686
|
const { placeholderData, ...restOptions } = options ?? {};
|
|
623
687
|
return (0, import_react_query4.useQuery)({
|
|
624
688
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
625
|
-
queryFn: async () => this.collectionClient
|
|
626
|
-
|
|
627
|
-
|
|
689
|
+
queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
|
|
690
|
+
...restOptions,
|
|
691
|
+
...placeholderData !== void 0 && {
|
|
692
|
+
placeholderData
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
useProductListingGroupsCatalogQuery(params, options) {
|
|
697
|
+
const queryOptions = params.options;
|
|
698
|
+
const { placeholderData, ...restOptions } = options ?? {};
|
|
699
|
+
return (0, import_react_query4.useQuery)({
|
|
700
|
+
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
701
|
+
queryFn: async () => fetchProductListingGroupsCatalogQuery(
|
|
702
|
+
this.collectionClient,
|
|
703
|
+
queryOptions
|
|
628
704
|
),
|
|
629
705
|
...restOptions,
|
|
630
706
|
...placeholderData !== void 0 && {
|
|
@@ -636,9 +712,17 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
636
712
|
const queryOptions = params.options;
|
|
637
713
|
return (0, import_react_query4.useSuspenseQuery)({
|
|
638
714
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
639
|
-
queryFn: async () => this.collectionClient
|
|
640
|
-
|
|
641
|
-
|
|
715
|
+
queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
|
|
716
|
+
...options
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
useSuspenseProductListingGroupsCatalogQuery(params, options) {
|
|
720
|
+
const queryOptions = params.options;
|
|
721
|
+
return (0, import_react_query4.useSuspenseQuery)({
|
|
722
|
+
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
723
|
+
queryFn: async () => fetchProductListingGroupsCatalogQuery(
|
|
724
|
+
this.collectionClient,
|
|
725
|
+
queryOptions
|
|
642
726
|
),
|
|
643
727
|
...options
|
|
644
728
|
});
|
|
@@ -650,12 +734,28 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
650
734
|
} = params;
|
|
651
735
|
return (0, import_react_query4.useInfiniteQuery)({
|
|
652
736
|
queryKey: productKeys.listingGroupsInfinite(queryOptions),
|
|
653
|
-
queryFn: async ({ pageParam }) => this.collectionClient
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
737
|
+
queryFn: async ({ pageParam }) => fetchProductListingGroupsQuery(this.collectionClient, {
|
|
738
|
+
...queryOptions,
|
|
739
|
+
page: pageParam,
|
|
740
|
+
limit: pageSize
|
|
741
|
+
}),
|
|
742
|
+
initialPageParam: 1,
|
|
743
|
+
getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
|
|
744
|
+
...options
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
useInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
748
|
+
const {
|
|
749
|
+
options: queryOptions,
|
|
750
|
+
pageSize = 20
|
|
751
|
+
} = params;
|
|
752
|
+
return (0, import_react_query4.useInfiniteQuery)({
|
|
753
|
+
queryKey: productKeys.listingGroupsCatalogInfinite(queryOptions),
|
|
754
|
+
queryFn: async ({ pageParam }) => fetchProductListingGroupsCatalogQuery(this.collectionClient, {
|
|
755
|
+
...queryOptions,
|
|
756
|
+
page: pageParam,
|
|
757
|
+
limit: pageSize
|
|
758
|
+
}),
|
|
659
759
|
initialPageParam: 1,
|
|
660
760
|
getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
|
|
661
761
|
...options
|
|
@@ -668,12 +768,28 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
668
768
|
} = params;
|
|
669
769
|
return (0, import_react_query4.useSuspenseInfiniteQuery)({
|
|
670
770
|
queryKey: productKeys.listingGroupsInfinite(queryOptions),
|
|
671
|
-
queryFn: async ({ pageParam }) => this.collectionClient
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
771
|
+
queryFn: async ({ pageParam }) => fetchProductListingGroupsQuery(this.collectionClient, {
|
|
772
|
+
...queryOptions,
|
|
773
|
+
page: pageParam,
|
|
774
|
+
limit: pageSize
|
|
775
|
+
}),
|
|
776
|
+
initialPageParam: 1,
|
|
777
|
+
getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
|
|
778
|
+
...options
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
useSuspenseInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
782
|
+
const {
|
|
783
|
+
options: queryOptions,
|
|
784
|
+
pageSize = 20
|
|
785
|
+
} = params;
|
|
786
|
+
return (0, import_react_query4.useSuspenseInfiniteQuery)({
|
|
787
|
+
queryKey: productKeys.listingGroupsCatalogInfinite(queryOptions),
|
|
788
|
+
queryFn: async ({ pageParam }) => fetchProductListingGroupsCatalogQuery(this.collectionClient, {
|
|
789
|
+
...queryOptions,
|
|
790
|
+
page: pageParam,
|
|
791
|
+
limit: pageSize
|
|
792
|
+
}),
|
|
677
793
|
initialPageParam: 1,
|
|
678
794
|
getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
|
|
679
795
|
...options
|
|
@@ -683,9 +799,17 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
683
799
|
const queryOptions = params.options;
|
|
684
800
|
return this.queryClient.prefetchQuery({
|
|
685
801
|
queryKey: productKeys.listingGroups(queryOptions),
|
|
686
|
-
queryFn: async () => this.collectionClient
|
|
687
|
-
|
|
688
|
-
|
|
802
|
+
queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
|
|
803
|
+
...options
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
async prefetchProductListingGroupsCatalogQuery(params, options) {
|
|
807
|
+
const queryOptions = params.options;
|
|
808
|
+
return this.queryClient.prefetchQuery({
|
|
809
|
+
queryKey: productKeys.listingGroupsCatalog(queryOptions),
|
|
810
|
+
queryFn: async () => fetchProductListingGroupsCatalogQuery(
|
|
811
|
+
this.collectionClient,
|
|
812
|
+
queryOptions
|
|
689
813
|
),
|
|
690
814
|
...options
|
|
691
815
|
});
|
|
@@ -697,12 +821,29 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
697
821
|
} = params;
|
|
698
822
|
return this.queryClient.prefetchInfiniteQuery({
|
|
699
823
|
queryKey: productKeys.listingGroupsInfinite(queryOptions),
|
|
700
|
-
queryFn: async ({ pageParam }) => this.collectionClient
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
824
|
+
queryFn: async ({ pageParam }) => fetchProductListingGroupsQuery(this.collectionClient, {
|
|
825
|
+
...queryOptions,
|
|
826
|
+
page: pageParam,
|
|
827
|
+
limit: pageSize
|
|
828
|
+
}),
|
|
829
|
+
initialPageParam: 1,
|
|
830
|
+
getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
|
|
831
|
+
pages: options?.pages ?? 1,
|
|
832
|
+
staleTime: options?.staleTime
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
async prefetchInfiniteProductListingGroupsCatalogQuery(params, options) {
|
|
836
|
+
const {
|
|
837
|
+
options: queryOptions,
|
|
838
|
+
pageSize = 20
|
|
839
|
+
} = params;
|
|
840
|
+
return this.queryClient.prefetchInfiniteQuery({
|
|
841
|
+
queryKey: productKeys.listingGroupsCatalogInfinite(queryOptions),
|
|
842
|
+
queryFn: async ({ pageParam }) => fetchProductListingGroupsCatalogQuery(this.collectionClient, {
|
|
843
|
+
...queryOptions,
|
|
844
|
+
page: pageParam,
|
|
845
|
+
limit: pageSize
|
|
846
|
+
}),
|
|
706
847
|
initialPageParam: 1,
|
|
707
848
|
getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
|
|
708
849
|
pages: options?.pages ?? 1,
|
|
@@ -711,11 +852,13 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
711
852
|
}
|
|
712
853
|
useProductDetail(params, options) {
|
|
713
854
|
const discriminator = "slug" in params ? params.slug : params.id;
|
|
714
|
-
const enabled = options
|
|
855
|
+
const { enabled, ...restOptions } = options ?? {};
|
|
856
|
+
const queryEnabled = enabled !== false && Boolean(discriminator);
|
|
715
857
|
return (0, import_react_query4.useQuery)({
|
|
716
858
|
queryKey: productKeys.detail(params),
|
|
717
859
|
queryFn: () => this._commerce.product.detail(params),
|
|
718
|
-
enabled
|
|
860
|
+
enabled: queryEnabled,
|
|
861
|
+
...restOptions
|
|
719
862
|
});
|
|
720
863
|
}
|
|
721
864
|
useProductDetailBySlug(slug, options) {
|
|
@@ -1097,9 +1240,12 @@ function resolveApiUrl(apiUrl) {
|
|
|
1097
1240
|
|
|
1098
1241
|
// src/core/internal/utils/http.ts
|
|
1099
1242
|
var DEFAULT_TIMEOUT = 3e4;
|
|
1243
|
+
var STOREFRONT_BROWSER_TIMEOUT = 15e3;
|
|
1100
1244
|
var DEFAULT_RETRYABLE_STATUSES = [408, 429, 500, 502, 503, 504];
|
|
1101
1245
|
var NON_RETRYABLE_STATUSES = [400, 401, 403, 404, 409, 422];
|
|
1102
1246
|
var SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
|
|
1247
|
+
var DEFAULT_MAX_RETRIES = 3;
|
|
1248
|
+
var STOREFRONT_BROWSER_MAX_RETRIES = 1;
|
|
1103
1249
|
function debugLog(debug, type, message, data) {
|
|
1104
1250
|
if (!debug) return;
|
|
1105
1251
|
const shouldLog = debug === true || type === "request" && debug.logRequests || type === "response" && debug.logResponses || type === "error" && debug.logErrors;
|
|
@@ -1292,15 +1438,18 @@ async function httpFetch(url, options) {
|
|
|
1292
1438
|
publishableKey,
|
|
1293
1439
|
secretKey,
|
|
1294
1440
|
customerToken,
|
|
1295
|
-
timeout = DEFAULT_TIMEOUT,
|
|
1441
|
+
timeout: timeoutOption = DEFAULT_TIMEOUT,
|
|
1296
1442
|
debug,
|
|
1297
1443
|
retry,
|
|
1298
1444
|
onUnauthorized,
|
|
1299
1445
|
...requestInit
|
|
1300
1446
|
} = options || {};
|
|
1301
1447
|
const baseUrl = resolveApiUrl(apiUrl);
|
|
1448
|
+
const method = (requestInit.method || "GET").toUpperCase();
|
|
1449
|
+
const isPublishableKeyBrowserGet = typeof window !== "undefined" && !secretKey && !customerToken && Boolean(publishableKey) && SAFE_METHODS.includes(method);
|
|
1450
|
+
const timeout = timeoutOption === DEFAULT_TIMEOUT && isPublishableKeyBrowserGet ? STOREFRONT_BROWSER_TIMEOUT : timeoutOption;
|
|
1302
1451
|
const retryConfig = {
|
|
1303
|
-
maxRetries: retry?.maxRetries ??
|
|
1452
|
+
maxRetries: retry?.maxRetries ?? (isPublishableKeyBrowserGet ? STOREFRONT_BROWSER_MAX_RETRIES : DEFAULT_MAX_RETRIES),
|
|
1304
1453
|
retryableStatuses: retry?.retryableStatuses ?? DEFAULT_RETRYABLE_STATUSES,
|
|
1305
1454
|
retryDelay: retry?.retryDelay ?? ((attempt) => Math.min(1e3 * 2 ** attempt, 1e4))
|
|
1306
1455
|
};
|
|
@@ -1408,8 +1557,8 @@ async function httpFetch(url, options) {
|
|
|
1408
1557
|
),
|
|
1409
1558
|
requestId
|
|
1410
1559
|
);
|
|
1411
|
-
const
|
|
1412
|
-
if (attempt < retryConfig.maxRetries && SAFE_METHODS.includes(
|
|
1560
|
+
const method2 = (requestInit.method || "GET").toUpperCase();
|
|
1561
|
+
if (attempt < retryConfig.maxRetries && SAFE_METHODS.includes(method2) && retryConfig.retryableStatuses.includes(response.status)) {
|
|
1413
1562
|
lastError = error;
|
|
1414
1563
|
const retryDelay = retryConfig.retryDelay(attempt);
|
|
1415
1564
|
debugLog(debug, "error", `Retrying in ${retryDelay}ms...`, error);
|
|
@@ -1421,8 +1570,8 @@ async function httpFetch(url, options) {
|
|
|
1421
1570
|
return response;
|
|
1422
1571
|
} catch (error) {
|
|
1423
1572
|
debugLog(debug, "error", url, error);
|
|
1424
|
-
const
|
|
1425
|
-
const isSafe = SAFE_METHODS.includes(
|
|
1573
|
+
const method2 = (requestInit.method || "GET").toUpperCase();
|
|
1574
|
+
const isSafe = SAFE_METHODS.includes(method2);
|
|
1426
1575
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1427
1576
|
const timeoutError = createTimeoutError(
|
|
1428
1577
|
`Request timed out after ${timeout}ms.`,
|
|
@@ -1655,6 +1804,16 @@ var CollectionClient = class extends HttpClient {
|
|
|
1655
1804
|
});
|
|
1656
1805
|
return this.parseFindResponse(response);
|
|
1657
1806
|
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Find-like response from a cacheable GET custom endpoint.
|
|
1809
|
+
*/
|
|
1810
|
+
async requestFindEndpointGet(endpoint) {
|
|
1811
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1812
|
+
...this.defaultOptions,
|
|
1813
|
+
method: "GET"
|
|
1814
|
+
});
|
|
1815
|
+
return this.parseFindResponse(response);
|
|
1816
|
+
}
|
|
1658
1817
|
/**
|
|
1659
1818
|
* Find document by ID
|
|
1660
1819
|
* GET /api/{collection}/{id}
|