@01.software/sdk 0.31.0 → 0.32.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 +87 -29
- 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 +10 -46
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.js +10 -46
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-DFXXz0vk.d.cts → collection-client-CORhppPb.d.cts} +3 -3
- package/dist/{collection-client-ByzY3hWK.d.ts → collection-client-DPGXnhoF.d.ts} +3 -3
- package/dist/{const-AytzliEu.d.cts → const-Brk2Ff0q.d.cts} +1 -1
- package/dist/{const-BGCP-OJL.d.ts → const-DcY2_z9O.d.ts} +1 -1
- package/dist/index.cjs +58 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +58 -47
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-Wa4-eC6x.d.cts → payload-types-DVK1QCeU.d.cts} +8 -2
- package/dist/{payload-types-Wa4-eC6x.d.ts → payload-types-DVK1QCeU.d.ts} +8 -2
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +16 -16
- package/dist/query.d.ts +16 -16
- 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 +34 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +99 -7
- package/dist/server.d.ts +99 -7
- package/dist/server.js +34 -1
- package/dist/server.js.map +1 -1
- package/dist/{types-CmLG-7RL.d.cts → types-ByMrR_Z_.d.cts} +1 -1
- package/dist/{types-DChFjQGz.d.cts → types-CAkWqIr6.d.cts} +41 -8
- package/dist/{types-BX2mqDf6.d.ts → types-CYMSBkJC.d.ts} +41 -8
- package/dist/{types-CVA10VC-.d.ts → types-DUPC7Xn6.d.ts} +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 +48 -1
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +73 -4
- package/dist/webhook.d.ts +73 -4
- package/dist/webhook.js +48 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { d as ClientConfig, h as RootClient } from './types-
|
|
2
|
-
export { k as AddItemParams, A as ApiQueryOptions, l as ApplyDiscountParams, B as BaseApi, m as BulkImportFulfillmentsParams, n as BulkImportFulfillmentsResponse, o as CalculateShippingParams, p as CalculateShippingResult, q as CartApi, r as CartApiOptions, s as CheckoutParams, t as ClearCartParams, e as ClientMetadata, c as ClientState, C as CommerceClient, u as CommerceClientOptions, a as CommunityClient, v as CommunityClientOptions, w as CommunityPost, x as CompatibilityProductSelectionParamEvent, y as ConfirmPaymentParams, z as ConfirmPaymentResponse, F as CreateFulfillmentParams, G as
|
|
3
|
-
import { P as Product } from './payload-types-
|
|
4
|
-
export { A as Article, f as ArticleAuthor, g as ArticleCategory, h as ArticleTag, i as Cart, j as CartItem, D as Document, I as Image, O as Order, c as Post, k as PostCategory, l as ProductVariant, T as Tenant, V as Video } from './payload-types-
|
|
5
|
-
export { C as CollectionType, P as Product, a as ProductCollection } from './types-
|
|
6
|
-
export { CUSTOMER_PASSWORD_RESET_OPERATION, CustomerAuthWebhookEvent, CustomerAuthWebhookHandlers, CustomerPasswordResetWebhookData, CustomerPasswordResetWebhookEvent, WebhookEvent, WebhookHandler, WebhookOperation, WebhookOptions, createCustomerAuthWebhookHandler, createTypedWebhookHandler, handleWebhook, isCustomerPasswordResetWebhookEvent, isValidWebhookEvent } from './webhook.cjs';
|
|
7
|
-
export { a as COLLECTIONS, C as Collection, I as INTERNAL_COLLECTIONS, P as PublicCollection, S as SERVER_COLLECTIONS, b as SERVER_ONLY_COLLECTIONS } from './const-
|
|
1
|
+
import { d as ClientConfig, h as RootClient } from './types-CAkWqIr6.cjs';
|
|
2
|
+
export { k as AddItemParams, A as ApiQueryOptions, l as ApplyDiscountParams, B as BaseApi, m as BulkImportFulfillmentsParams, n as BulkImportFulfillmentsResponse, o as CalculateShippingParams, p as CalculateShippingResult, q as CartApi, r as CartApiOptions, s as CheckoutParams, t as ClearCartParams, e as ClientMetadata, c as ClientState, C as CommerceClient, u as CommerceClientOptions, a as CommunityClient, v as CommunityClientOptions, w as CommunityPost, x as CompatibilityProductSelectionParamEvent, y as ConfirmPaymentParams, z as ConfirmPaymentResponse, F as CreateFulfillmentParams, G as CreateOrderItem, H as CreateOrderParams, I as CreateReturnParams, J as CustomerAuth, K as CustomerAuthOptions, L as CustomerAuthResponse, M as CustomerLoginData, b as CustomerNamespace, N as CustomerProfile, O as CustomerRefreshResponse, Q as CustomerRegisterData, T as CustomerRegisterResponse, U as CustomerSnapshot, D as DebugConfig, f as DeepPartial, V as DiscountApi, X as DiscountApiOptions, E as ExtractArrayType, Y as LegacyProductSelectionParamEvent, Z as ListingGroupingState, _ as ListingGroupsParams, $ as NormalizedProductSelection, a0 as OrderApi, a1 as OrderApiOptions, P as PayloadFindResponse, g as PayloadMutationResponse, a2 as ProductApi, a3 as ProductApiOptions, a4 as ProductDetail, a5 as ProductDetailBrand, a6 as ProductDetailCategory, a7 as ProductDetailImage, a8 as ProductDetailImageMedia, a9 as ProductDetailListing, aa as ProductDetailMedia, ab as ProductDetailOption, ac as ProductDetailOptionValue, ad as ProductDetailParams, ae as ProductDetailTag, af as ProductDetailVariant, ag as ProductDetailVariantOptionValue, ah as ProductDetailVideo, ai as ProductHrefGroup, aj as ProductHrefOptions, ak as ProductHrefProduct, al as ProductListingCard, am as ProductListingCardPriceRange, an as ProductListingGroup, ao as ProductListingGroupSummary, ap as ProductListingGroupVariant, aq as ProductListingGroupsItem, ar as ProductListingGroupsProduct, as as ProductListingGroupsResponse, at as ProductListingProductShape, au as ProductListingProjection, av as ProductListingSwatch, aw as ProductOptionMatrix, ax as ProductOptionMatrixOption, ay as ProductOptionMatrixValue, az as ProductOptionMatrixVariant, aA as ProductOptionShape, aB as ProductOptionValueShape, aC as ProductSelectionAvailableValue, aD as ProductSelectionByOptionValue, aE as ProductSelectionCodecError, aF as ProductSelectionCodecOptions, aG as ProductSelectionInput, aH as ProductSelectionResolution, aI as ProductSelectionResolutionContext, aJ as ProductVariantShape, aK as RemoveDiscountParams, aL as RemoveItemParams, aM as RequestOptions, R as RetryConfig, aN as ReturnItem, aO as ReturnReason, aP as ReturnWithRefundParams, i as RootCollectionClient, j as RootReadOnlyQueryBuilder, aQ as ServerApiOptions, aR as ShippingApi, aS as ShippingApiOptions, S as Sort, aT as StockCheckParams, aU as StockCheckResponse, aV as StockCheckResult, aW as UpdateFulfillmentParams, aX as UpdateItemParams, aY as UpdateOrderParams, aZ as UpdateProfileData, a_ as UpdateReturnParams, a$ as UpdateTransactionParams, b0 as ValidateDiscountParams, b1 as ValidateDiscountResult, W as Where, b2 as buildProductHref, b3 as buildProductListingCard, b4 as buildProductListingGroupsByOption, b5 as buildProductListingProjection, b6 as buildProductOptionMatrix, b7 as buildProductOptionMatrixFromDetail, b8 as createProductSelectionCodec, b9 as getAvailableOptionValues, ba as getProductSelectionImages, bb as getSelectedValueByOptionId, bc as normalizeProductSelection, bd as normalizeProductSelectionFromMatrix, be as normalizeSelectedValueIds, bf as parseProductSelection, bg as resolveProductSelection, bh as resolveProductSelectionFromMatrix, bi as resolveVariantForSelection, bj as stringifyProductSelection } from './types-CAkWqIr6.cjs';
|
|
3
|
+
import { P as Product } from './payload-types-DVK1QCeU.cjs';
|
|
4
|
+
export { A as Article, f as ArticleAuthor, g as ArticleCategory, h as ArticleTag, i as Cart, j as CartItem, D as Document, I as Image, O as Order, c as Post, k as PostCategory, l as ProductVariant, T as Tenant, V as Video } from './payload-types-DVK1QCeU.cjs';
|
|
5
|
+
export { C as CollectionType, P as Product, a as ProductCollection } from './types-ByMrR_Z_.cjs';
|
|
6
|
+
export { CUSTOMER_PASSWORD_RESET_OPERATION, CollectionWebhookOperation, CustomerAuthWebhookEvent, CustomerAuthWebhookHandlers, CustomerPasswordResetWebhookData, CustomerPasswordResetWebhookEvent, ORDER_CHANGED_EVENT_TYPE, OrderChangedWebhookEvent, WebhookChange, WebhookEvent, WebhookHandler, WebhookKnownOperation, WebhookOperation, WebhookOptions, WebhookOrderChange, WebhookOrderMoved, WebhookOrderScope, createCustomerAuthWebhookHandler, createTypedWebhookHandler, handleWebhook, isCustomerPasswordResetWebhookEvent, isOrderChangedWebhookEvent, isValidWebhookEvent, isWebhookCollection, isWebhookOperation } from './webhook.cjs';
|
|
7
|
+
export { a as COLLECTIONS, C as Collection, I as INTERNAL_COLLECTIONS, P as PublicCollection, S as SERVER_COLLECTIONS, b as SERVER_ONLY_COLLECTIONS } from './const-Brk2Ff0q.cjs';
|
|
8
8
|
export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
|
|
9
9
|
export { a as IMAGE_SIZES, I as ImageData, b as ImagePalette, c as ImagePlaceholderOptions, g as getImageLqip, d as getImagePalette, e as getImagePlaceholderStyle, f as getImageSrcSet, h as getImageUrl } from './image-BDz2-AaO.cjs';
|
|
10
10
|
export { V as VideoGifOptions, a as VideoThumbnailOptions, g as getVideoGif, b as getVideoMp4Url, c as getVideoStoryboard, d as getVideoStreamUrl, e as getVideoThumbnail } from './video-WR_TFO9a.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { d as ClientConfig, h as RootClient } from './types-
|
|
2
|
-
export { k as AddItemParams, A as ApiQueryOptions, l as ApplyDiscountParams, B as BaseApi, m as BulkImportFulfillmentsParams, n as BulkImportFulfillmentsResponse, o as CalculateShippingParams, p as CalculateShippingResult, q as CartApi, r as CartApiOptions, s as CheckoutParams, t as ClearCartParams, e as ClientMetadata, c as ClientState, C as CommerceClient, u as CommerceClientOptions, a as CommunityClient, v as CommunityClientOptions, w as CommunityPost, x as CompatibilityProductSelectionParamEvent, y as ConfirmPaymentParams, z as ConfirmPaymentResponse, F as CreateFulfillmentParams, G as
|
|
3
|
-
import { P as Product } from './payload-types-
|
|
4
|
-
export { A as Article, f as ArticleAuthor, g as ArticleCategory, h as ArticleTag, i as Cart, j as CartItem, D as Document, I as Image, O as Order, c as Post, k as PostCategory, l as ProductVariant, T as Tenant, V as Video } from './payload-types-
|
|
5
|
-
export { C as CollectionType, P as Product, a as ProductCollection } from './types-
|
|
6
|
-
export { CUSTOMER_PASSWORD_RESET_OPERATION, CustomerAuthWebhookEvent, CustomerAuthWebhookHandlers, CustomerPasswordResetWebhookData, CustomerPasswordResetWebhookEvent, WebhookEvent, WebhookHandler, WebhookOperation, WebhookOptions, createCustomerAuthWebhookHandler, createTypedWebhookHandler, handleWebhook, isCustomerPasswordResetWebhookEvent, isValidWebhookEvent } from './webhook.js';
|
|
7
|
-
export { a as COLLECTIONS, C as Collection, I as INTERNAL_COLLECTIONS, P as PublicCollection, S as SERVER_COLLECTIONS, b as SERVER_ONLY_COLLECTIONS } from './const-
|
|
1
|
+
import { d as ClientConfig, h as RootClient } from './types-CYMSBkJC.js';
|
|
2
|
+
export { k as AddItemParams, A as ApiQueryOptions, l as ApplyDiscountParams, B as BaseApi, m as BulkImportFulfillmentsParams, n as BulkImportFulfillmentsResponse, o as CalculateShippingParams, p as CalculateShippingResult, q as CartApi, r as CartApiOptions, s as CheckoutParams, t as ClearCartParams, e as ClientMetadata, c as ClientState, C as CommerceClient, u as CommerceClientOptions, a as CommunityClient, v as CommunityClientOptions, w as CommunityPost, x as CompatibilityProductSelectionParamEvent, y as ConfirmPaymentParams, z as ConfirmPaymentResponse, F as CreateFulfillmentParams, G as CreateOrderItem, H as CreateOrderParams, I as CreateReturnParams, J as CustomerAuth, K as CustomerAuthOptions, L as CustomerAuthResponse, M as CustomerLoginData, b as CustomerNamespace, N as CustomerProfile, O as CustomerRefreshResponse, Q as CustomerRegisterData, T as CustomerRegisterResponse, U as CustomerSnapshot, D as DebugConfig, f as DeepPartial, V as DiscountApi, X as DiscountApiOptions, E as ExtractArrayType, Y as LegacyProductSelectionParamEvent, Z as ListingGroupingState, _ as ListingGroupsParams, $ as NormalizedProductSelection, a0 as OrderApi, a1 as OrderApiOptions, P as PayloadFindResponse, g as PayloadMutationResponse, a2 as ProductApi, a3 as ProductApiOptions, a4 as ProductDetail, a5 as ProductDetailBrand, a6 as ProductDetailCategory, a7 as ProductDetailImage, a8 as ProductDetailImageMedia, a9 as ProductDetailListing, aa as ProductDetailMedia, ab as ProductDetailOption, ac as ProductDetailOptionValue, ad as ProductDetailParams, ae as ProductDetailTag, af as ProductDetailVariant, ag as ProductDetailVariantOptionValue, ah as ProductDetailVideo, ai as ProductHrefGroup, aj as ProductHrefOptions, ak as ProductHrefProduct, al as ProductListingCard, am as ProductListingCardPriceRange, an as ProductListingGroup, ao as ProductListingGroupSummary, ap as ProductListingGroupVariant, aq as ProductListingGroupsItem, ar as ProductListingGroupsProduct, as as ProductListingGroupsResponse, at as ProductListingProductShape, au as ProductListingProjection, av as ProductListingSwatch, aw as ProductOptionMatrix, ax as ProductOptionMatrixOption, ay as ProductOptionMatrixValue, az as ProductOptionMatrixVariant, aA as ProductOptionShape, aB as ProductOptionValueShape, aC as ProductSelectionAvailableValue, aD as ProductSelectionByOptionValue, aE as ProductSelectionCodecError, aF as ProductSelectionCodecOptions, aG as ProductSelectionInput, aH as ProductSelectionResolution, aI as ProductSelectionResolutionContext, aJ as ProductVariantShape, aK as RemoveDiscountParams, aL as RemoveItemParams, aM as RequestOptions, R as RetryConfig, aN as ReturnItem, aO as ReturnReason, aP as ReturnWithRefundParams, i as RootCollectionClient, j as RootReadOnlyQueryBuilder, aQ as ServerApiOptions, aR as ShippingApi, aS as ShippingApiOptions, S as Sort, aT as StockCheckParams, aU as StockCheckResponse, aV as StockCheckResult, aW as UpdateFulfillmentParams, aX as UpdateItemParams, aY as UpdateOrderParams, aZ as UpdateProfileData, a_ as UpdateReturnParams, a$ as UpdateTransactionParams, b0 as ValidateDiscountParams, b1 as ValidateDiscountResult, W as Where, b2 as buildProductHref, b3 as buildProductListingCard, b4 as buildProductListingGroupsByOption, b5 as buildProductListingProjection, b6 as buildProductOptionMatrix, b7 as buildProductOptionMatrixFromDetail, b8 as createProductSelectionCodec, b9 as getAvailableOptionValues, ba as getProductSelectionImages, bb as getSelectedValueByOptionId, bc as normalizeProductSelection, bd as normalizeProductSelectionFromMatrix, be as normalizeSelectedValueIds, bf as parseProductSelection, bg as resolveProductSelection, bh as resolveProductSelectionFromMatrix, bi as resolveVariantForSelection, bj as stringifyProductSelection } from './types-CYMSBkJC.js';
|
|
3
|
+
import { P as Product } from './payload-types-DVK1QCeU.js';
|
|
4
|
+
export { A as Article, f as ArticleAuthor, g as ArticleCategory, h as ArticleTag, i as Cart, j as CartItem, D as Document, I as Image, O as Order, c as Post, k as PostCategory, l as ProductVariant, T as Tenant, V as Video } from './payload-types-DVK1QCeU.js';
|
|
5
|
+
export { C as CollectionType, P as Product, a as ProductCollection } from './types-DUPC7Xn6.js';
|
|
6
|
+
export { CUSTOMER_PASSWORD_RESET_OPERATION, CollectionWebhookOperation, CustomerAuthWebhookEvent, CustomerAuthWebhookHandlers, CustomerPasswordResetWebhookData, CustomerPasswordResetWebhookEvent, ORDER_CHANGED_EVENT_TYPE, OrderChangedWebhookEvent, WebhookChange, WebhookEvent, WebhookHandler, WebhookKnownOperation, WebhookOperation, WebhookOptions, WebhookOrderChange, WebhookOrderMoved, WebhookOrderScope, createCustomerAuthWebhookHandler, createTypedWebhookHandler, handleWebhook, isCustomerPasswordResetWebhookEvent, isOrderChangedWebhookEvent, isValidWebhookEvent, isWebhookCollection, isWebhookOperation } from './webhook.js';
|
|
7
|
+
export { a as COLLECTIONS, C as Collection, I as INTERNAL_COLLECTIONS, P as PublicCollection, S as SERVER_COLLECTIONS, b as SERVER_ONLY_COLLECTIONS } from './const-DcY2_z9O.js';
|
|
8
8
|
export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.js';
|
|
9
9
|
export { a as IMAGE_SIZES, I as ImageData, b as ImagePalette, c as ImagePlaceholderOptions, g as getImageLqip, d as getImagePalette, e as getImagePlaceholderStyle, f as getImageSrcSet, h as getImageUrl } from './image-BDz2-AaO.js';
|
|
10
10
|
export { V as VideoGifOptions, a as VideoThumbnailOptions, g as getVideoGif, b as getVideoMp4Url, c as getVideoStoryboard, d as getVideoStreamUrl, e as getVideoThumbnail } from './video-WR_TFO9a.js';
|
package/dist/index.js
CHANGED
|
@@ -1226,7 +1226,7 @@ var CustomerAuth = class {
|
|
|
1226
1226
|
);
|
|
1227
1227
|
return data.customer ?? null;
|
|
1228
1228
|
} catch (error) {
|
|
1229
|
-
if (error instanceof
|
|
1229
|
+
if (error instanceof SDKError && error.status === 401) {
|
|
1230
1230
|
this.setToken(null);
|
|
1231
1231
|
return null;
|
|
1232
1232
|
}
|
|
@@ -1321,51 +1321,15 @@ var CustomerAuth = class {
|
|
|
1321
1321
|
if (!headers.has("Content-Type") && init.body) {
|
|
1322
1322
|
headers.set("Content-Type", "application/json");
|
|
1323
1323
|
}
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
} catch (error) {
|
|
1334
|
-
clearTimeout(timeoutId);
|
|
1335
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
1336
|
-
throw new TimeoutError(`Request timed out after ${DEFAULT_TIMEOUT2}ms`, {
|
|
1337
|
-
url: path,
|
|
1338
|
-
timeout: DEFAULT_TIMEOUT2
|
|
1339
|
-
});
|
|
1340
|
-
}
|
|
1341
|
-
throw new NetworkError(
|
|
1342
|
-
error instanceof Error ? error.message : "Network request failed",
|
|
1343
|
-
void 0,
|
|
1344
|
-
{ url: path },
|
|
1345
|
-
"Network connection failed.",
|
|
1346
|
-
"Please check your internet connection and try again."
|
|
1347
|
-
);
|
|
1348
|
-
}
|
|
1349
|
-
clearTimeout(timeoutId);
|
|
1350
|
-
if (!res.ok) {
|
|
1351
|
-
const body = await res.json().catch(() => ({}));
|
|
1352
|
-
throw new ApiError(
|
|
1353
|
-
body.error || `HTTP ${res.status}`,
|
|
1354
|
-
res.status,
|
|
1355
|
-
body.details,
|
|
1356
|
-
body.error
|
|
1357
|
-
);
|
|
1358
|
-
}
|
|
1359
|
-
try {
|
|
1360
|
-
return await res.json();
|
|
1361
|
-
} catch {
|
|
1362
|
-
throw new ApiError(
|
|
1363
|
-
"Invalid JSON response from server",
|
|
1364
|
-
res.status,
|
|
1365
|
-
void 0,
|
|
1366
|
-
"INVALID_RESPONSE"
|
|
1367
|
-
);
|
|
1368
|
-
}
|
|
1324
|
+
const response = await httpFetch(path, {
|
|
1325
|
+
...init,
|
|
1326
|
+
apiUrl: this.baseUrl,
|
|
1327
|
+
publishableKey: this.publishableKey,
|
|
1328
|
+
headers,
|
|
1329
|
+
timeout: DEFAULT_TIMEOUT2,
|
|
1330
|
+
retry: { maxRetries: 0 }
|
|
1331
|
+
});
|
|
1332
|
+
return parseApiResponse(response, path);
|
|
1369
1333
|
}
|
|
1370
1334
|
};
|
|
1371
1335
|
|
|
@@ -1702,7 +1666,7 @@ var ProductApi = class extends BaseApi {
|
|
|
1702
1666
|
/**
|
|
1703
1667
|
* Fetch full product detail by slug or id.
|
|
1704
1668
|
* Returns `null` on 404 regardless of reason (`not_found` / `not_published` /
|
|
1705
|
-
* `
|
|
1669
|
+
* `feature_disabled`). For the reason behind a null,
|
|
1706
1670
|
* inspect `client.lastRequestId` against backend logs.
|
|
1707
1671
|
*/
|
|
1708
1672
|
async detail(params) {
|
|
@@ -1725,11 +1689,54 @@ var ProductApi = class extends BaseApi {
|
|
|
1725
1689
|
};
|
|
1726
1690
|
|
|
1727
1691
|
// src/core/webhook/index.ts
|
|
1692
|
+
var ORDER_CHANGED_EVENT_TYPE = "collection.orderChanged";
|
|
1728
1693
|
function isValidWebhookEvent(data) {
|
|
1729
1694
|
if (typeof data !== "object" || data === null) return false;
|
|
1730
1695
|
const obj = data;
|
|
1731
1696
|
return typeof obj.collection === "string" && typeof obj.operation === "string" && obj.operation.length > 0 && typeof obj.data === "object" && obj.data !== null;
|
|
1732
1697
|
}
|
|
1698
|
+
function isStringOrNumber(value) {
|
|
1699
|
+
return typeof value === "string" || typeof value === "number";
|
|
1700
|
+
}
|
|
1701
|
+
function isWebhookOrderScope(value) {
|
|
1702
|
+
if (!isRecord(value)) return false;
|
|
1703
|
+
if (value.kind === "collection") {
|
|
1704
|
+
return typeof value.collection === "string";
|
|
1705
|
+
}
|
|
1706
|
+
if (value.kind === "join") {
|
|
1707
|
+
return typeof value.collection === "string" && typeof value.field === "string" && isStringOrNumber(value.id);
|
|
1708
|
+
}
|
|
1709
|
+
return false;
|
|
1710
|
+
}
|
|
1711
|
+
function isWebhookOrderMoved(value) {
|
|
1712
|
+
if (!isRecord(value)) return false;
|
|
1713
|
+
return typeof value.collection === "string" && isStringOrNumber(value.id) && (value.relatedCollection === void 0 || typeof value.relatedCollection === "string") && (value.relatedId === void 0 || isStringOrNumber(value.relatedId));
|
|
1714
|
+
}
|
|
1715
|
+
function hasOptionalOrderValue(value, key) {
|
|
1716
|
+
return value[key] === void 0 || value[key] === null || typeof value[key] === "string";
|
|
1717
|
+
}
|
|
1718
|
+
function isWebhookOrderChange(value) {
|
|
1719
|
+
if (!isRecord(value)) return false;
|
|
1720
|
+
return value.type === "order" && value.source === "payload-orderable" && (value.orderableFieldName === void 0 || typeof value.orderableFieldName === "string") && hasOptionalOrderValue(value, "previousOrder") && hasOptionalOrderValue(value, "nextOrder") && isWebhookOrderScope(value.scope) && isWebhookOrderMoved(value.moved);
|
|
1721
|
+
}
|
|
1722
|
+
function isOrderChangedWebhookEvent(event) {
|
|
1723
|
+
if (!isValidWebhookEvent(event) || event.operation !== "update" || event.eventType !== ORDER_CHANGED_EVENT_TYPE || !isWebhookOrderChange(event.change)) {
|
|
1724
|
+
return false;
|
|
1725
|
+
}
|
|
1726
|
+
if (event.collection !== event.change.scope.collection) {
|
|
1727
|
+
return false;
|
|
1728
|
+
}
|
|
1729
|
+
if (event.change.scope.kind === "collection" && event.change.moved.collection !== event.change.scope.collection) {
|
|
1730
|
+
return false;
|
|
1731
|
+
}
|
|
1732
|
+
return true;
|
|
1733
|
+
}
|
|
1734
|
+
function isWebhookCollection(event, collection) {
|
|
1735
|
+
return isValidWebhookEvent(event) && event.collection === collection;
|
|
1736
|
+
}
|
|
1737
|
+
function isWebhookOperation(event, operation) {
|
|
1738
|
+
return isValidWebhookEvent(event) && event.operation === operation;
|
|
1739
|
+
}
|
|
1733
1740
|
var CUSTOMER_PASSWORD_RESET_OPERATION = "password-reset";
|
|
1734
1741
|
function isRecord(value) {
|
|
1735
1742
|
return typeof value === "object" && value !== null;
|
|
@@ -3506,6 +3513,7 @@ export {
|
|
|
3506
3513
|
INTERNAL_COLLECTIONS,
|
|
3507
3514
|
NetworkError,
|
|
3508
3515
|
NotFoundError,
|
|
3516
|
+
ORDER_CHANGED_EVENT_TYPE,
|
|
3509
3517
|
OrderApi,
|
|
3510
3518
|
PermissionError,
|
|
3511
3519
|
ProductApi,
|
|
@@ -3560,6 +3568,7 @@ export {
|
|
|
3560
3568
|
isGoneError,
|
|
3561
3569
|
isNetworkError,
|
|
3562
3570
|
isNotFoundError,
|
|
3571
|
+
isOrderChangedWebhookEvent,
|
|
3563
3572
|
isPermissionError,
|
|
3564
3573
|
isRateLimitError,
|
|
3565
3574
|
isSDKError,
|
|
@@ -3568,6 +3577,8 @@ export {
|
|
|
3568
3577
|
isUsageLimitError,
|
|
3569
3578
|
isValidWebhookEvent,
|
|
3570
3579
|
isValidationError,
|
|
3580
|
+
isWebhookCollection,
|
|
3581
|
+
isWebhookOperation,
|
|
3571
3582
|
normalizeProductSelection,
|
|
3572
3583
|
normalizeProductSelectionFromMatrix,
|
|
3573
3584
|
normalizeSelectedValueIds,
|