@01.software/sdk 0.4.0 → 0.4.2
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/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/{const-BpirbGBD.d.cts → const-CWZ70tFe.d.cts} +1 -1
- package/dist/{const-qZSQiSSC.d.ts → const-nftKBzYp.d.ts} +1 -1
- package/dist/index.cjs +73 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +73 -9
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-CZiaL4Wr.d.cts → payload-types-BbEEk9Ji.d.cts} +68 -3
- package/dist/{payload-types-CZiaL4Wr.d.ts → payload-types-BbEEk9Ji.d.ts} +68 -3
- package/dist/realtime.cjs +5 -3
- 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 +5 -3
- package/dist/realtime.js.map +1 -1
- package/dist/ui/flow.cjs +264 -36
- package/dist/ui/flow.cjs.map +1 -1
- package/dist/ui/flow.d.cts +105 -4
- package/dist/ui/flow.d.ts +105 -4
- package/dist/ui/flow.js +252 -21
- package/dist/ui/flow.js.map +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/rich-text.cjs +8 -1
- package/dist/ui/rich-text.cjs.map +1 -1
- package/dist/ui/rich-text.d.cts +20 -1
- package/dist/ui/rich-text.d.ts +20 -1
- package/dist/ui/rich-text.js +8 -1
- package/dist/ui/rich-text.js.map +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/{webhook-DuTqrH9x.d.ts → webhook-C4nmpBmQ.d.ts} +2 -2
- package/dist/{webhook-3iL9OEyq.d.cts → webhook-DRGm9rPn.d.cts} +2 -2
- package/dist/webhook.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { O as Order, a as OrderProduct, T as Transaction, b as Fulfillment, R as Return, E as Exchange, c as Cart, d as CartItem, P as Product } from './payload-types-
|
|
2
|
-
export { o as ApiUsage, as as ApiUsageSelect, A as Audience, ao as AudiencesSelect, bo as Auth, q as BillingHistory, au as BillingHistorySelect, y as Brand, B as BrandLogo, aD as BrandLogosSelect, aC as BrandsSelect, aT as CartItemsSelect, aS as CartsSelect, g as CodeBlock, bn as CollectionsWidget, C as Config, G as Customer, J as CustomerAddress, aQ as CustomerAddressesSelect, e as CustomerAuthOperations, H as CustomerGroup, aR as CustomerGroupsSelect, aP as CustomersSelect, W as Discount, aU as DiscountsSelect, $ as Document, a_ as DocumentCategoriesSelect, a1 as DocumentCategory, a0 as DocumentType, a$ as DocumentTypesSelect, aZ as DocumentsSelect, m as EmailLog, ap as EmailLogsSelect, N as ExchangeProduct, aN as ExchangeProductsSelect, aM as ExchangesSelect, j as FieldConfig, al as FieldConfigsSelect, aa as Flow, bb as FlowCategoriesSelect, ab as FlowCategory, ae as FlowEdgeType, ba as FlowEdgeTypesSelect, ad as FlowNodeType, b9 as FlowNodeTypesSelect, ac as FlowTag, bc as FlowTagsSelect, b8 as FlowsSelect, F as Form, af as FormSubmission, bi as FormSubmissionsSelect, bh as FormsSelect, K as FulfillmentItem, aJ as FulfillmentItemsSelect, aI as FulfillmentsSelect, b4 as GalleriesSelect, a6 as Gallery, b5 as GalleryCategoriesSelect, a7 as GalleryCategory, a9 as GalleryItem, b7 as GalleryItemsSelect, a8 as GalleryTag, b6 as GalleryTagsSelect, I as IframeBlock, k as Image, am as ImagesSelect, L as LiveStream, bg as LiveStreamsSelect, a5 as Music, b3 as MusicsSelect, aF as OrderProductsSelect, Q as OrderStatusLog, aH as OrderStatusLogsSelect, aE as OrdersSelect, ag as PayloadKv, bj as PayloadKvSelect, ah as PayloadLockedDocument, bk as PayloadLockedDocumentsSelect, aj as PayloadMigration, bm as PayloadMigrationsSelect, ai as PayloadPreference, bl as PayloadPreferencesSelect, f as PlayerBlock, a2 as Playlist, b1 as PlaylistCategoriesSelect, a3 as PlaylistCategory, a4 as PlaylistTag, b2 as PlaylistTagsSelect, b0 as PlaylistsSelect, X as Post, Y as PostAuthor, aW as PostAuthorsSelect, aX as PostCategoriesSelect, Z as PostCategory, _ as PostTag, aY as PostTagsSelect, aV as PostsSelect, az as ProductCategoriesSelect, w as ProductCategory, D as ProductCollection, aB as ProductCollectionsSelect, v as ProductOption, ay as ProductOptionsSelect, x as ProductTag, aA as ProductTagsSelect, u as ProductVariant, ax as ProductVariantsSelect, aw as ProductsSelect, M as ReturnProduct, aL as ReturnProductsSelect, aK as ReturnsSelect, aO as ShippingPoliciesSelect, z as ShippingPolicy, p as Subscription, at as SubscriptionsSelect, S as SupportedTimezones, l as SystemMedia, an as SystemMediaSelect, i as Tenant, r as TenantLogo, av as TenantLogosSelect, ar as TenantMetadataSelect, n as TenantMetadatum, aq as TenantsSelect, aG as TransactionsSelect, h as User, U as UserAuthOperations, ak as UsersSelect, V as Video, be as VideoCategoriesSelect, s as VideoCategory, t as VideoTag, bf as VideoTagsSelect, bd as VideosSelect } from './payload-types-
|
|
1
|
+
import { O as Order, a as OrderProduct, T as Transaction, b as Fulfillment, R as Return, E as Exchange, c as Cart, d as CartItem, P as Product } from './payload-types-BbEEk9Ji.cjs';
|
|
2
|
+
export { o as ApiUsage, as as ApiUsageSelect, A as Audience, ao as AudiencesSelect, bo as Auth, q as BillingHistory, au as BillingHistorySelect, y as Brand, B as BrandLogo, aD as BrandLogosSelect, aC as BrandsSelect, aT as CartItemsSelect, aS as CartsSelect, g as CodeBlock, bn as CollectionsWidget, C as Config, G as Customer, J as CustomerAddress, aQ as CustomerAddressesSelect, e as CustomerAuthOperations, H as CustomerGroup, aR as CustomerGroupsSelect, aP as CustomersSelect, W as Discount, aU as DiscountsSelect, $ as Document, a_ as DocumentCategoriesSelect, a1 as DocumentCategory, a0 as DocumentType, a$ as DocumentTypesSelect, aZ as DocumentsSelect, m as EmailLog, ap as EmailLogsSelect, N as ExchangeProduct, aN as ExchangeProductsSelect, aM as ExchangesSelect, j as FieldConfig, al as FieldConfigsSelect, aa as Flow, bb as FlowCategoriesSelect, ab as FlowCategory, ae as FlowEdgeType, ba as FlowEdgeTypesSelect, ad as FlowNodeType, b9 as FlowNodeTypesSelect, ac as FlowTag, bc as FlowTagsSelect, b8 as FlowsSelect, F as Form, af as FormSubmission, bi as FormSubmissionsSelect, bh as FormsSelect, K as FulfillmentItem, aJ as FulfillmentItemsSelect, aI as FulfillmentsSelect, b4 as GalleriesSelect, a6 as Gallery, b5 as GalleryCategoriesSelect, a7 as GalleryCategory, a9 as GalleryItem, b7 as GalleryItemsSelect, a8 as GalleryTag, b6 as GalleryTagsSelect, I as IframeBlock, k as Image, am as ImagesSelect, L as LiveStream, bg as LiveStreamsSelect, a5 as Music, b3 as MusicsSelect, aF as OrderProductsSelect, Q as OrderStatusLog, aH as OrderStatusLogsSelect, aE as OrdersSelect, ag as PayloadKv, bj as PayloadKvSelect, ah as PayloadLockedDocument, bk as PayloadLockedDocumentsSelect, aj as PayloadMigration, bm as PayloadMigrationsSelect, ai as PayloadPreference, bl as PayloadPreferencesSelect, f as PlayerBlock, a2 as Playlist, b1 as PlaylistCategoriesSelect, a3 as PlaylistCategory, a4 as PlaylistTag, b2 as PlaylistTagsSelect, b0 as PlaylistsSelect, X as Post, Y as PostAuthor, aW as PostAuthorsSelect, aX as PostCategoriesSelect, Z as PostCategory, _ as PostTag, aY as PostTagsSelect, aV as PostsSelect, az as ProductCategoriesSelect, w as ProductCategory, D as ProductCollection, aB as ProductCollectionsSelect, v as ProductOption, ay as ProductOptionsSelect, x as ProductTag, aA as ProductTagsSelect, u as ProductVariant, ax as ProductVariantsSelect, aw as ProductsSelect, M as ReturnProduct, aL as ReturnProductsSelect, aK as ReturnsSelect, aO as ShippingPoliciesSelect, z as ShippingPolicy, p as Subscription, at as SubscriptionsSelect, S as SupportedTimezones, l as SystemMedia, an as SystemMediaSelect, i as Tenant, r as TenantLogo, av as TenantLogosSelect, ar as TenantMetadataSelect, n as TenantMetadatum, aq as TenantsSelect, aG as TransactionsSelect, h as User, U as UserAuthOperations, ak as UsersSelect, V as Video, be as VideoCategoriesSelect, s as VideoCategory, t as VideoTag, bf as VideoTagsSelect, bd as VideosSelect } from './payload-types-BbEEk9Ji.cjs';
|
|
3
3
|
import { Sort, Where } from 'payload';
|
|
4
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
5
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
-
import { P as PublicCollection } from './const-
|
|
7
|
-
export { a as COLLECTIONS, C as Collection } from './const-
|
|
6
|
+
import { P as PublicCollection } from './const-CWZ70tFe.cjs';
|
|
7
|
+
export { a as COLLECTIONS, C as Collection } from './const-CWZ70tFe.cjs';
|
|
8
8
|
import { Metadata } from 'next';
|
|
9
|
-
import { C as CollectionType } from './webhook-
|
|
10
|
-
export { a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, d as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-
|
|
9
|
+
import { C as CollectionType } from './webhook-DRGm9rPn.cjs';
|
|
10
|
+
export { a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, d as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-DRGm9rPn.cjs';
|
|
11
11
|
export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-DupPIYx-.cjs';
|
|
12
12
|
export { b as IMAGE_SIZES, I as ImageData, a as ImagePalette, f as ImagePlaceholderOptions, d as getImageLqip, e as getImagePalette, h as getImagePlaceholderStyle, c as getImageSrcSet, g as getImageUrl } from './image-TT8lTsk5.cjs';
|
|
13
13
|
export { e as VideoGifOptions, V as VideoThumbnailOptions, a as getVideoGif, c as getVideoMp4Url, d as getVideoStoryboard, b as getVideoStreamUrl, g as getVideoThumbnail } from './video-DbLL8yuc.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { O as Order, a as OrderProduct, T as Transaction, b as Fulfillment, R as Return, E as Exchange, c as Cart, d as CartItem, P as Product } from './payload-types-
|
|
2
|
-
export { o as ApiUsage, as as ApiUsageSelect, A as Audience, ao as AudiencesSelect, bo as Auth, q as BillingHistory, au as BillingHistorySelect, y as Brand, B as BrandLogo, aD as BrandLogosSelect, aC as BrandsSelect, aT as CartItemsSelect, aS as CartsSelect, g as CodeBlock, bn as CollectionsWidget, C as Config, G as Customer, J as CustomerAddress, aQ as CustomerAddressesSelect, e as CustomerAuthOperations, H as CustomerGroup, aR as CustomerGroupsSelect, aP as CustomersSelect, W as Discount, aU as DiscountsSelect, $ as Document, a_ as DocumentCategoriesSelect, a1 as DocumentCategory, a0 as DocumentType, a$ as DocumentTypesSelect, aZ as DocumentsSelect, m as EmailLog, ap as EmailLogsSelect, N as ExchangeProduct, aN as ExchangeProductsSelect, aM as ExchangesSelect, j as FieldConfig, al as FieldConfigsSelect, aa as Flow, bb as FlowCategoriesSelect, ab as FlowCategory, ae as FlowEdgeType, ba as FlowEdgeTypesSelect, ad as FlowNodeType, b9 as FlowNodeTypesSelect, ac as FlowTag, bc as FlowTagsSelect, b8 as FlowsSelect, F as Form, af as FormSubmission, bi as FormSubmissionsSelect, bh as FormsSelect, K as FulfillmentItem, aJ as FulfillmentItemsSelect, aI as FulfillmentsSelect, b4 as GalleriesSelect, a6 as Gallery, b5 as GalleryCategoriesSelect, a7 as GalleryCategory, a9 as GalleryItem, b7 as GalleryItemsSelect, a8 as GalleryTag, b6 as GalleryTagsSelect, I as IframeBlock, k as Image, am as ImagesSelect, L as LiveStream, bg as LiveStreamsSelect, a5 as Music, b3 as MusicsSelect, aF as OrderProductsSelect, Q as OrderStatusLog, aH as OrderStatusLogsSelect, aE as OrdersSelect, ag as PayloadKv, bj as PayloadKvSelect, ah as PayloadLockedDocument, bk as PayloadLockedDocumentsSelect, aj as PayloadMigration, bm as PayloadMigrationsSelect, ai as PayloadPreference, bl as PayloadPreferencesSelect, f as PlayerBlock, a2 as Playlist, b1 as PlaylistCategoriesSelect, a3 as PlaylistCategory, a4 as PlaylistTag, b2 as PlaylistTagsSelect, b0 as PlaylistsSelect, X as Post, Y as PostAuthor, aW as PostAuthorsSelect, aX as PostCategoriesSelect, Z as PostCategory, _ as PostTag, aY as PostTagsSelect, aV as PostsSelect, az as ProductCategoriesSelect, w as ProductCategory, D as ProductCollection, aB as ProductCollectionsSelect, v as ProductOption, ay as ProductOptionsSelect, x as ProductTag, aA as ProductTagsSelect, u as ProductVariant, ax as ProductVariantsSelect, aw as ProductsSelect, M as ReturnProduct, aL as ReturnProductsSelect, aK as ReturnsSelect, aO as ShippingPoliciesSelect, z as ShippingPolicy, p as Subscription, at as SubscriptionsSelect, S as SupportedTimezones, l as SystemMedia, an as SystemMediaSelect, i as Tenant, r as TenantLogo, av as TenantLogosSelect, ar as TenantMetadataSelect, n as TenantMetadatum, aq as TenantsSelect, aG as TransactionsSelect, h as User, U as UserAuthOperations, ak as UsersSelect, V as Video, be as VideoCategoriesSelect, s as VideoCategory, t as VideoTag, bf as VideoTagsSelect, bd as VideosSelect } from './payload-types-
|
|
1
|
+
import { O as Order, a as OrderProduct, T as Transaction, b as Fulfillment, R as Return, E as Exchange, c as Cart, d as CartItem, P as Product } from './payload-types-BbEEk9Ji.js';
|
|
2
|
+
export { o as ApiUsage, as as ApiUsageSelect, A as Audience, ao as AudiencesSelect, bo as Auth, q as BillingHistory, au as BillingHistorySelect, y as Brand, B as BrandLogo, aD as BrandLogosSelect, aC as BrandsSelect, aT as CartItemsSelect, aS as CartsSelect, g as CodeBlock, bn as CollectionsWidget, C as Config, G as Customer, J as CustomerAddress, aQ as CustomerAddressesSelect, e as CustomerAuthOperations, H as CustomerGroup, aR as CustomerGroupsSelect, aP as CustomersSelect, W as Discount, aU as DiscountsSelect, $ as Document, a_ as DocumentCategoriesSelect, a1 as DocumentCategory, a0 as DocumentType, a$ as DocumentTypesSelect, aZ as DocumentsSelect, m as EmailLog, ap as EmailLogsSelect, N as ExchangeProduct, aN as ExchangeProductsSelect, aM as ExchangesSelect, j as FieldConfig, al as FieldConfigsSelect, aa as Flow, bb as FlowCategoriesSelect, ab as FlowCategory, ae as FlowEdgeType, ba as FlowEdgeTypesSelect, ad as FlowNodeType, b9 as FlowNodeTypesSelect, ac as FlowTag, bc as FlowTagsSelect, b8 as FlowsSelect, F as Form, af as FormSubmission, bi as FormSubmissionsSelect, bh as FormsSelect, K as FulfillmentItem, aJ as FulfillmentItemsSelect, aI as FulfillmentsSelect, b4 as GalleriesSelect, a6 as Gallery, b5 as GalleryCategoriesSelect, a7 as GalleryCategory, a9 as GalleryItem, b7 as GalleryItemsSelect, a8 as GalleryTag, b6 as GalleryTagsSelect, I as IframeBlock, k as Image, am as ImagesSelect, L as LiveStream, bg as LiveStreamsSelect, a5 as Music, b3 as MusicsSelect, aF as OrderProductsSelect, Q as OrderStatusLog, aH as OrderStatusLogsSelect, aE as OrdersSelect, ag as PayloadKv, bj as PayloadKvSelect, ah as PayloadLockedDocument, bk as PayloadLockedDocumentsSelect, aj as PayloadMigration, bm as PayloadMigrationsSelect, ai as PayloadPreference, bl as PayloadPreferencesSelect, f as PlayerBlock, a2 as Playlist, b1 as PlaylistCategoriesSelect, a3 as PlaylistCategory, a4 as PlaylistTag, b2 as PlaylistTagsSelect, b0 as PlaylistsSelect, X as Post, Y as PostAuthor, aW as PostAuthorsSelect, aX as PostCategoriesSelect, Z as PostCategory, _ as PostTag, aY as PostTagsSelect, aV as PostsSelect, az as ProductCategoriesSelect, w as ProductCategory, D as ProductCollection, aB as ProductCollectionsSelect, v as ProductOption, ay as ProductOptionsSelect, x as ProductTag, aA as ProductTagsSelect, u as ProductVariant, ax as ProductVariantsSelect, aw as ProductsSelect, M as ReturnProduct, aL as ReturnProductsSelect, aK as ReturnsSelect, aO as ShippingPoliciesSelect, z as ShippingPolicy, p as Subscription, at as SubscriptionsSelect, S as SupportedTimezones, l as SystemMedia, an as SystemMediaSelect, i as Tenant, r as TenantLogo, av as TenantLogosSelect, ar as TenantMetadataSelect, n as TenantMetadatum, aq as TenantsSelect, aG as TransactionsSelect, h as User, U as UserAuthOperations, ak as UsersSelect, V as Video, be as VideoCategoriesSelect, s as VideoCategory, t as VideoTag, bf as VideoTagsSelect, bd as VideosSelect } from './payload-types-BbEEk9Ji.js';
|
|
3
3
|
import { Sort, Where } from 'payload';
|
|
4
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
5
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
-
import { P as PublicCollection } from './const-
|
|
7
|
-
export { a as COLLECTIONS, C as Collection } from './const-
|
|
6
|
+
import { P as PublicCollection } from './const-nftKBzYp.js';
|
|
7
|
+
export { a as COLLECTIONS, C as Collection } from './const-nftKBzYp.js';
|
|
8
8
|
import { Metadata } from 'next';
|
|
9
|
-
import { C as CollectionType } from './webhook-
|
|
10
|
-
export { a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, d as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-
|
|
9
|
+
import { C as CollectionType } from './webhook-C4nmpBmQ.js';
|
|
10
|
+
export { a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, d as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-C4nmpBmQ.js';
|
|
11
11
|
export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-DupPIYx-.js';
|
|
12
12
|
export { b as IMAGE_SIZES, I as ImageData, a as ImagePalette, f as ImagePlaceholderOptions, d as getImageLqip, e as getImagePalette, h as getImagePlaceholderStyle, c as getImageSrcSet, g as getImageUrl } from './image-TT8lTsk5.js';
|
|
13
13
|
export { e as VideoGifOptions, V as VideoThumbnailOptions, a as getVideoGif, c as getVideoMp4Url, d as getVideoStoryboard, b as getVideoStreamUrl, g as getVideoThumbnail } from './video-DbLL8yuc.js';
|
package/dist/index.js
CHANGED
|
@@ -261,9 +261,11 @@ var createUsageLimitError = (message, usage, details, userMessage, suggestion) =
|
|
|
261
261
|
|
|
262
262
|
// src/core/client/types.ts
|
|
263
263
|
function resolveApiUrl() {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
if (typeof process !== "undefined" && process.env) {
|
|
265
|
+
const envUrl = process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL;
|
|
266
|
+
if (envUrl) {
|
|
267
|
+
return envUrl.replace(/\/$/, "");
|
|
268
|
+
}
|
|
267
269
|
}
|
|
268
270
|
return "https://api.01.software";
|
|
269
271
|
}
|
|
@@ -271,7 +273,7 @@ function resolveApiUrl() {
|
|
|
271
273
|
// src/core/internal/utils/http.ts
|
|
272
274
|
var DEFAULT_TIMEOUT = 3e4;
|
|
273
275
|
var DEFAULT_RETRYABLE_STATUSES = [408, 429, 500, 502, 503, 504];
|
|
274
|
-
var NON_RETRYABLE_STATUSES = [401, 403, 404, 422];
|
|
276
|
+
var NON_RETRYABLE_STATUSES = [400, 401, 403, 404, 422];
|
|
275
277
|
var SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
|
|
276
278
|
function debugLog(debug, type, message, data) {
|
|
277
279
|
if (!debug) return;
|
|
@@ -283,11 +285,66 @@ function debugLog(debug, type, message, data) {
|
|
|
283
285
|
}
|
|
284
286
|
}
|
|
285
287
|
function getErrorSuggestion(status) {
|
|
288
|
+
if (status === 400) return "The request data failed validation. Check field values and types.";
|
|
286
289
|
if (status === 401) return "Please check your authentication credentials.";
|
|
290
|
+
if (status === 403) return "Access denied. Check your credentials or permissions.";
|
|
287
291
|
if (status === 404) return "The requested resource was not found.";
|
|
292
|
+
if (status === 422) return "The request data failed validation.";
|
|
288
293
|
if (status >= 500) return "A server error occurred. Please try again later.";
|
|
289
294
|
return void 0;
|
|
290
295
|
}
|
|
296
|
+
function parseErrorBody(response) {
|
|
297
|
+
return __async(this, null, function* () {
|
|
298
|
+
var _a;
|
|
299
|
+
const fallback = {
|
|
300
|
+
errorMessage: `HTTP ${response.status}: ${response.statusText}`,
|
|
301
|
+
userMessage: `Request failed (status: ${response.status})`
|
|
302
|
+
};
|
|
303
|
+
try {
|
|
304
|
+
const body = yield response.json();
|
|
305
|
+
if (body.errors && Array.isArray(body.errors)) {
|
|
306
|
+
const fieldErrors = [];
|
|
307
|
+
for (const e of body.errors) {
|
|
308
|
+
if (((_a = e.data) == null ? void 0 : _a.errors) && Array.isArray(e.data.errors) && e.data.errors.length > 0) {
|
|
309
|
+
for (const fe of e.data.errors) {
|
|
310
|
+
fieldErrors.push({
|
|
311
|
+
field: fe.path || fe.field,
|
|
312
|
+
message: fe.message
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
} else if (e.field || e.message) {
|
|
316
|
+
fieldErrors.push({ field: e.field, message: e.message });
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const details = (fieldErrors.length > 0 ? fieldErrors : body.errors).map(
|
|
320
|
+
(e) => e.field ? `${e.field}: ${e.message}` : e.message
|
|
321
|
+
).filter(Boolean).join("; ");
|
|
322
|
+
if (details) {
|
|
323
|
+
return {
|
|
324
|
+
errorMessage: `HTTP ${response.status}: ${details}`,
|
|
325
|
+
userMessage: details,
|
|
326
|
+
errors: fieldErrors.length > 0 ? fieldErrors : body.errors
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (typeof body.error === "string") {
|
|
331
|
+
return {
|
|
332
|
+
errorMessage: `HTTP ${response.status}: ${body.error}`,
|
|
333
|
+
userMessage: body.error
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
if (body.message) {
|
|
337
|
+
return {
|
|
338
|
+
errorMessage: `HTTP ${response.status}: ${body.message}`,
|
|
339
|
+
userMessage: body.message
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
return fallback;
|
|
343
|
+
} catch (e) {
|
|
344
|
+
return fallback;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
291
348
|
function delay(ms) {
|
|
292
349
|
return __async(this, null, function* () {
|
|
293
350
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -396,19 +453,26 @@ function httpFetch(url, options) {
|
|
|
396
453
|
}
|
|
397
454
|
}
|
|
398
455
|
if (NON_RETRYABLE_STATUSES.includes(response.status)) {
|
|
456
|
+
const parsed2 = yield parseErrorBody(response);
|
|
457
|
+
const details = __spreadValues({
|
|
458
|
+
url,
|
|
459
|
+
method: requestInit.method || "GET",
|
|
460
|
+
attempt: attempt + 1
|
|
461
|
+
}, parsed2.errors && { errors: parsed2.errors });
|
|
399
462
|
throw createNetworkError(
|
|
400
|
-
|
|
463
|
+
parsed2.errorMessage,
|
|
401
464
|
response.status,
|
|
402
|
-
|
|
403
|
-
|
|
465
|
+
details,
|
|
466
|
+
parsed2.userMessage,
|
|
404
467
|
getErrorSuggestion(response.status)
|
|
405
468
|
);
|
|
406
469
|
}
|
|
470
|
+
const parsed = yield parseErrorBody(response);
|
|
407
471
|
const error = createNetworkError(
|
|
408
|
-
|
|
472
|
+
parsed.errorMessage,
|
|
409
473
|
response.status,
|
|
410
474
|
{ url, method: requestInit.method || "GET", attempt: attempt + 1 },
|
|
411
|
-
|
|
475
|
+
parsed.userMessage,
|
|
412
476
|
getErrorSuggestion(response.status)
|
|
413
477
|
);
|
|
414
478
|
const method = (requestInit.method || "GET").toUpperCase();
|