@01.software/sdk 0.1.7 → 0.1.9
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 +14 -2
- package/dist/{auth-Cl6xQinU.d.cts → auth-BnCTXZG0.d.cts} +1 -1
- package/dist/{auth-u5YEtV1J.d.ts → auth-Cxfq94pG.d.ts} +1 -1
- package/dist/auth.d.cts +2 -2
- package/dist/auth.d.ts +2 -2
- package/dist/index.cjs +65 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -7
- package/dist/index.d.ts +21 -7
- package/dist/index.js +65 -12
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.cts +1 -1
- package/dist/metadata.d.ts +1 -1
- package/dist/{payload-types-9ZTBbiqb.d.cts → payload-types-DcOQUD4x.d.cts} +192 -190
- package/dist/{payload-types-9ZTBbiqb.d.ts → payload-types-DcOQUD4x.d.ts} +192 -190
- package/dist/{webhook-Cdv7bup2.d.cts → webhook-E1YlE_k1.d.cts} +1 -1
- package/dist/{webhook-c_A4J8UH.d.ts → webhook-xdgxEN8s.d.ts} +1 -1
- package/dist/webhook.cjs +4 -5
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +2 -2
- package/dist/webhook.d.ts +2 -2
- package/dist/webhook.js +4 -5
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { O as Order, a as OrderProduct, T as Transaction, F as Fulfillment, R as Return, C as CartItem, P as ProductOption } from './payload-types-
|
|
2
|
-
export { k as ApiUsage, ag as ApiUsageSelect, A as Audience, aa as AudiencesSelect, a$ as Auth, N as Author, aM as AuthorsSelect, m as BillingHistory, ai as BillingHistorySelect,
|
|
3
|
-
import { F as FetchOptions, A as ApiQueryOptions, P as PayloadFindResponse, a as PayloadMutationResponse, C as ClientBrowserConfig, b as ClientState, c as ClientServerConfig } from './auth-
|
|
4
|
-
export { t as API_URLS, f as ApiError, y as ApiQueryReactOptions, w as ClientMetadata, g as ConfigError, d as DebugConfig, D as DeepPartial, s as Environment, e as ErrorLogger, E as ExtractArrayType, J as JwtPayload, N as NetworkError, x as PaginationMeta, R as RetryConfig, S as SDKError, T as TimeoutError, U as UsageLimitError, V as ValidationError, q as createApiKey, o as createServerToken, p as decodeServerToken, k as isApiError, l as isConfigError, h as isNetworkError, i as isSDKError, m as isTimeoutError, n as isUsageLimitError, j as isValidationError, r as parseApiKey, u as resolveApiUrl, v as verifyServerToken } from './auth-
|
|
1
|
+
import { O as Order, a as OrderProduct, T as Transaction, F as Fulfillment, R as Return, C as CartItem, P as ProductOption } from './payload-types-DcOQUD4x.cjs';
|
|
2
|
+
export { k as ApiUsage, ag as ApiUsageSelect, A as Audience, aa as AudiencesSelect, a$ as Auth, N as Author, aM as AuthorsSelect, m as BillingHistory, ai as BillingHistorySelect, s as Brand, B as BrandLogo, aq as BrandLogosSelect, ap as BrandsSelect, H as Cart, aF as CartItemsSelect, aE as CartsSelect, e as CodeBlock, b as Config, u as Customer, x as CustomerAddress, aB as CustomerAddressesSelect, c as CustomerAuthOperations, v as CustomerGroup, w as CustomerGroupImage, aD as CustomerGroupImagesSelect, aC as CustomerGroupsSelect, aA as CustomersSelect, J as Discount, aG as DiscountsSelect, W as Document, aO as DocumentCategoriesSelect, X as DocumentCategory, Y as DocumentImage, aP as DocumentImagesSelect, aN as DocumentsSelect, E as EmailLog, ab as EmailLogsSelect, z as Exchange, D as ExchangeProduct, aw as ExchangeProductsSelect, av as ExchangesSelect, a2 as Form, a3 as FormSubmission, aW as FormSubmissionsSelect, aV as FormsSelect, G as FulfillmentItem, ay as FulfillmentItemsSelect, ax as FulfillmentsSelect, aT as GalleriesSelect, a0 as Gallery, a1 as GalleryImage, aU as GalleryImagesSelect, I as IframeBlock, M as Media, a9 as MediaSelect, _ as Music, aS as MusicsSelect, as as OrderProductsSelect, ar as OrdersSelect, a4 as PayloadKv, aX as PayloadKvSelect, a5 as PayloadLockedDocument, aY as PayloadLockedDocumentsSelect, a7 as PayloadMigration, a_ as PayloadMigrationsSelect, a6 as PayloadPreference, aZ as PayloadPreferencesSelect, d as PlayerBlock, Z as Playlist, $ as PlaylistImage, aR as PlaylistImagesSelect, aQ as PlaylistsSelect, K as Post, aJ as PostCategoriesSelect, Q as PostCategory, L as PostImage, aL as PostImagesSelect, V as PostTag, aK as PostTagsSelect, aI as PostsSelect, n as Product, am as ProductCategoriesSelect, q as ProductCategory, o as ProductImage, ao as ProductImagesSelect, al as ProductOptionsSelect, r as ProductTag, an as ProductTagsSelect, p as ProductVariant, ak as ProductVariantsSelect, aj as ProductsSelect, y as ReturnProduct, au as ReturnProductsSelect, at as ReturnsSelect, aH as ShippingPoliciesSelect, t as ShippingPolicy, l as Subscription, ah as SubscriptionsSelect, S as SupportedTimezones, g as Tenant, j as TenantLogo, ae as TenantLogosSelect, ad as TenantMetadataSelect, h as TenantMetadatum, i as TenantOgImage, af as TenantOgImagesSelect, ac as TenantsSelect, az as TransactionsSelect, f as User, U as UserAuthOperations, a8 as UsersSelect } from './payload-types-DcOQUD4x.cjs';
|
|
3
|
+
import { F as FetchOptions, A as ApiQueryOptions, P as PayloadFindResponse, a as PayloadMutationResponse, C as ClientBrowserConfig, b as ClientState, c as ClientServerConfig } from './auth-BnCTXZG0.cjs';
|
|
4
|
+
export { t as API_URLS, f as ApiError, y as ApiQueryReactOptions, w as ClientMetadata, g as ConfigError, d as DebugConfig, D as DeepPartial, s as Environment, e as ErrorLogger, E as ExtractArrayType, J as JwtPayload, N as NetworkError, x as PaginationMeta, R as RetryConfig, S as SDKError, T as TimeoutError, U as UsageLimitError, V as ValidationError, q as createApiKey, o as createServerToken, p as decodeServerToken, k as isApiError, l as isConfigError, h as isNetworkError, i as isSDKError, m as isTimeoutError, n as isUsageLimitError, j as isValidationError, r as parseApiKey, u as resolveApiUrl, v as verifyServerToken } from './auth-BnCTXZG0.cjs';
|
|
5
5
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
6
|
import { QueryClient } from '@tanstack/react-query';
|
|
7
|
-
import { P as PublicCollection, C as CollectionType } from './webhook-
|
|
8
|
-
export { b as COLLECTIONS, a as Collection, c as WebhookEvent, d as WebhookHandler, W as WebhookOperation, e as WebhookOptions, f as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-
|
|
7
|
+
import { P as PublicCollection, C as CollectionType } from './webhook-E1YlE_k1.cjs';
|
|
8
|
+
export { b as COLLECTIONS, a as Collection, c as WebhookEvent, d as WebhookHandler, W as WebhookOperation, e as WebhookOptions, f as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-E1YlE_k1.cjs';
|
|
9
|
+
import { Metadata } from 'next';
|
|
10
|
+
import { GenerateMetadataOptions } from './metadata.cjs';
|
|
9
11
|
export { RichTextContent, RichTextContentProps, RichTextData } from './components.cjs';
|
|
10
12
|
import 'payload';
|
|
11
13
|
import 'react';
|
|
@@ -251,7 +253,7 @@ declare class CollectionClient extends HttpClient {
|
|
|
251
253
|
* Read-only subset of CollectionQueryBuilder.
|
|
252
254
|
* BrowserClient.from() returns this type to prevent write operations at compile time.
|
|
253
255
|
*/
|
|
254
|
-
type ReadOnlyQueryBuilder<T extends PublicCollection> = Pick<CollectionQueryBuilder<T>, 'find' | 'findById' | 'count'>;
|
|
256
|
+
type ReadOnlyQueryBuilder<T extends PublicCollection> = Pick<CollectionQueryBuilder<T>, 'find' | 'findById' | 'count' | 'findMetadata' | 'findMetadataById'>;
|
|
255
257
|
declare class CollectionQueryBuilder<T extends PublicCollection> {
|
|
256
258
|
private api;
|
|
257
259
|
private collection;
|
|
@@ -288,6 +290,18 @@ declare class CollectionQueryBuilder<T extends PublicCollection> {
|
|
|
288
290
|
count(options?: ApiQueryOptions): Promise<{
|
|
289
291
|
totalDocs: number;
|
|
290
292
|
}>;
|
|
293
|
+
/**
|
|
294
|
+
* Find first matching document and return its Next.js Metadata.
|
|
295
|
+
* Applies depth: 1 (image populate) and limit: 1 automatically.
|
|
296
|
+
* @returns Metadata or null if no document matches
|
|
297
|
+
*/
|
|
298
|
+
findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
|
|
299
|
+
/**
|
|
300
|
+
* Find document by ID and return its Next.js Metadata.
|
|
301
|
+
* Applies depth: 1 (image populate) automatically.
|
|
302
|
+
* @returns Metadata (throws on 404)
|
|
303
|
+
*/
|
|
304
|
+
findMetadataById(id: number | string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
|
|
291
305
|
/**
|
|
292
306
|
* Update multiple documents (bulk update)
|
|
293
307
|
* PATCH /api/{collection}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { O as Order, a as OrderProduct, T as Transaction, F as Fulfillment, R as Return, C as CartItem, P as ProductOption } from './payload-types-
|
|
2
|
-
export { k as ApiUsage, ag as ApiUsageSelect, A as Audience, aa as AudiencesSelect, a$ as Auth, N as Author, aM as AuthorsSelect, m as BillingHistory, ai as BillingHistorySelect,
|
|
3
|
-
import { F as FetchOptions, A as ApiQueryOptions, P as PayloadFindResponse, a as PayloadMutationResponse, C as ClientBrowserConfig, b as ClientState, c as ClientServerConfig } from './auth-
|
|
4
|
-
export { t as API_URLS, f as ApiError, y as ApiQueryReactOptions, w as ClientMetadata, g as ConfigError, d as DebugConfig, D as DeepPartial, s as Environment, e as ErrorLogger, E as ExtractArrayType, J as JwtPayload, N as NetworkError, x as PaginationMeta, R as RetryConfig, S as SDKError, T as TimeoutError, U as UsageLimitError, V as ValidationError, q as createApiKey, o as createServerToken, p as decodeServerToken, k as isApiError, l as isConfigError, h as isNetworkError, i as isSDKError, m as isTimeoutError, n as isUsageLimitError, j as isValidationError, r as parseApiKey, u as resolveApiUrl, v as verifyServerToken } from './auth-
|
|
1
|
+
import { O as Order, a as OrderProduct, T as Transaction, F as Fulfillment, R as Return, C as CartItem, P as ProductOption } from './payload-types-DcOQUD4x.js';
|
|
2
|
+
export { k as ApiUsage, ag as ApiUsageSelect, A as Audience, aa as AudiencesSelect, a$ as Auth, N as Author, aM as AuthorsSelect, m as BillingHistory, ai as BillingHistorySelect, s as Brand, B as BrandLogo, aq as BrandLogosSelect, ap as BrandsSelect, H as Cart, aF as CartItemsSelect, aE as CartsSelect, e as CodeBlock, b as Config, u as Customer, x as CustomerAddress, aB as CustomerAddressesSelect, c as CustomerAuthOperations, v as CustomerGroup, w as CustomerGroupImage, aD as CustomerGroupImagesSelect, aC as CustomerGroupsSelect, aA as CustomersSelect, J as Discount, aG as DiscountsSelect, W as Document, aO as DocumentCategoriesSelect, X as DocumentCategory, Y as DocumentImage, aP as DocumentImagesSelect, aN as DocumentsSelect, E as EmailLog, ab as EmailLogsSelect, z as Exchange, D as ExchangeProduct, aw as ExchangeProductsSelect, av as ExchangesSelect, a2 as Form, a3 as FormSubmission, aW as FormSubmissionsSelect, aV as FormsSelect, G as FulfillmentItem, ay as FulfillmentItemsSelect, ax as FulfillmentsSelect, aT as GalleriesSelect, a0 as Gallery, a1 as GalleryImage, aU as GalleryImagesSelect, I as IframeBlock, M as Media, a9 as MediaSelect, _ as Music, aS as MusicsSelect, as as OrderProductsSelect, ar as OrdersSelect, a4 as PayloadKv, aX as PayloadKvSelect, a5 as PayloadLockedDocument, aY as PayloadLockedDocumentsSelect, a7 as PayloadMigration, a_ as PayloadMigrationsSelect, a6 as PayloadPreference, aZ as PayloadPreferencesSelect, d as PlayerBlock, Z as Playlist, $ as PlaylistImage, aR as PlaylistImagesSelect, aQ as PlaylistsSelect, K as Post, aJ as PostCategoriesSelect, Q as PostCategory, L as PostImage, aL as PostImagesSelect, V as PostTag, aK as PostTagsSelect, aI as PostsSelect, n as Product, am as ProductCategoriesSelect, q as ProductCategory, o as ProductImage, ao as ProductImagesSelect, al as ProductOptionsSelect, r as ProductTag, an as ProductTagsSelect, p as ProductVariant, ak as ProductVariantsSelect, aj as ProductsSelect, y as ReturnProduct, au as ReturnProductsSelect, at as ReturnsSelect, aH as ShippingPoliciesSelect, t as ShippingPolicy, l as Subscription, ah as SubscriptionsSelect, S as SupportedTimezones, g as Tenant, j as TenantLogo, ae as TenantLogosSelect, ad as TenantMetadataSelect, h as TenantMetadatum, i as TenantOgImage, af as TenantOgImagesSelect, ac as TenantsSelect, az as TransactionsSelect, f as User, U as UserAuthOperations, a8 as UsersSelect } from './payload-types-DcOQUD4x.js';
|
|
3
|
+
import { F as FetchOptions, A as ApiQueryOptions, P as PayloadFindResponse, a as PayloadMutationResponse, C as ClientBrowserConfig, b as ClientState, c as ClientServerConfig } from './auth-Cxfq94pG.js';
|
|
4
|
+
export { t as API_URLS, f as ApiError, y as ApiQueryReactOptions, w as ClientMetadata, g as ConfigError, d as DebugConfig, D as DeepPartial, s as Environment, e as ErrorLogger, E as ExtractArrayType, J as JwtPayload, N as NetworkError, x as PaginationMeta, R as RetryConfig, S as SDKError, T as TimeoutError, U as UsageLimitError, V as ValidationError, q as createApiKey, o as createServerToken, p as decodeServerToken, k as isApiError, l as isConfigError, h as isNetworkError, i as isSDKError, m as isTimeoutError, n as isUsageLimitError, j as isValidationError, r as parseApiKey, u as resolveApiUrl, v as verifyServerToken } from './auth-Cxfq94pG.js';
|
|
5
5
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
6
|
import { QueryClient } from '@tanstack/react-query';
|
|
7
|
-
import { P as PublicCollection, C as CollectionType } from './webhook-
|
|
8
|
-
export { b as COLLECTIONS, a as Collection, c as WebhookEvent, d as WebhookHandler, W as WebhookOperation, e as WebhookOptions, f as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-
|
|
7
|
+
import { P as PublicCollection, C as CollectionType } from './webhook-xdgxEN8s.js';
|
|
8
|
+
export { b as COLLECTIONS, a as Collection, c as WebhookEvent, d as WebhookHandler, W as WebhookOperation, e as WebhookOptions, f as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-xdgxEN8s.js';
|
|
9
|
+
import { Metadata } from 'next';
|
|
10
|
+
import { GenerateMetadataOptions } from './metadata.js';
|
|
9
11
|
export { RichTextContent, RichTextContentProps, RichTextData } from './components.js';
|
|
10
12
|
import 'payload';
|
|
11
13
|
import 'react';
|
|
@@ -251,7 +253,7 @@ declare class CollectionClient extends HttpClient {
|
|
|
251
253
|
* Read-only subset of CollectionQueryBuilder.
|
|
252
254
|
* BrowserClient.from() returns this type to prevent write operations at compile time.
|
|
253
255
|
*/
|
|
254
|
-
type ReadOnlyQueryBuilder<T extends PublicCollection> = Pick<CollectionQueryBuilder<T>, 'find' | 'findById' | 'count'>;
|
|
256
|
+
type ReadOnlyQueryBuilder<T extends PublicCollection> = Pick<CollectionQueryBuilder<T>, 'find' | 'findById' | 'count' | 'findMetadata' | 'findMetadataById'>;
|
|
255
257
|
declare class CollectionQueryBuilder<T extends PublicCollection> {
|
|
256
258
|
private api;
|
|
257
259
|
private collection;
|
|
@@ -288,6 +290,18 @@ declare class CollectionQueryBuilder<T extends PublicCollection> {
|
|
|
288
290
|
count(options?: ApiQueryOptions): Promise<{
|
|
289
291
|
totalDocs: number;
|
|
290
292
|
}>;
|
|
293
|
+
/**
|
|
294
|
+
* Find first matching document and return its Next.js Metadata.
|
|
295
|
+
* Applies depth: 1 (image populate) and limit: 1 automatically.
|
|
296
|
+
* @returns Metadata or null if no document matches
|
|
297
|
+
*/
|
|
298
|
+
findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
|
|
299
|
+
/**
|
|
300
|
+
* Find document by ID and return its Next.js Metadata.
|
|
301
|
+
* Applies depth: 1 (image populate) automatically.
|
|
302
|
+
* @returns Metadata (throws on 404)
|
|
303
|
+
*/
|
|
304
|
+
findMetadataById(id: number | string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
|
|
291
305
|
/**
|
|
292
306
|
* Update multiple documents (bulk update)
|
|
293
307
|
* PATCH /api/{collection}
|
package/dist/index.js
CHANGED
|
@@ -631,6 +631,37 @@ var ProductApi = class {
|
|
|
631
631
|
}
|
|
632
632
|
};
|
|
633
633
|
|
|
634
|
+
// src/utils/types.ts
|
|
635
|
+
var resolveRelation = (ref) => {
|
|
636
|
+
if (typeof ref === "number" || ref === null || ref === void 0) return null;
|
|
637
|
+
return ref;
|
|
638
|
+
};
|
|
639
|
+
var objectFor = resolveRelation;
|
|
640
|
+
|
|
641
|
+
// src/core/metadata/index.ts
|
|
642
|
+
function generateMetadata(doc, options) {
|
|
643
|
+
var _a, _b, _c, _d;
|
|
644
|
+
const meta = doc == null ? void 0 : doc.meta;
|
|
645
|
+
const title = (_b = (_a = meta == null ? void 0 : meta.title) != null ? _a : options == null ? void 0 : options.title) != null ? _b : void 0;
|
|
646
|
+
const description = (_d = (_c = meta == null ? void 0 : meta.description) != null ? _c : options == null ? void 0 : options.description) != null ? _d : void 0;
|
|
647
|
+
const image = resolveMetaImage(meta == null ? void 0 : meta.image);
|
|
648
|
+
return {
|
|
649
|
+
title,
|
|
650
|
+
description,
|
|
651
|
+
openGraph: __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, title && { title }), description && { description }), (options == null ? void 0 : options.siteName) && { siteName: options.siteName }), image && { images: [image] }),
|
|
652
|
+
twitter: __spreadValues(__spreadValues(__spreadValues({
|
|
653
|
+
card: image ? "summary_large_image" : "summary"
|
|
654
|
+
}, title && { title }), description && { description }), image && { images: [image.url] })
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
function resolveMetaImage(ref) {
|
|
658
|
+
const media = resolveRelation(ref);
|
|
659
|
+
if (!(media == null ? void 0 : media.url)) return null;
|
|
660
|
+
return __spreadValues(__spreadValues(__spreadValues({
|
|
661
|
+
url: media.url
|
|
662
|
+
}, media.width && { width: media.width }), media.height && { height: media.height }), media.alt && { alt: media.alt });
|
|
663
|
+
}
|
|
664
|
+
|
|
634
665
|
// src/core/collection/query-builder.ts
|
|
635
666
|
var CollectionQueryBuilder = class {
|
|
636
667
|
constructor(api, collection) {
|
|
@@ -702,6 +733,36 @@ var CollectionQueryBuilder = class {
|
|
|
702
733
|
);
|
|
703
734
|
});
|
|
704
735
|
}
|
|
736
|
+
/**
|
|
737
|
+
* Find first matching document and return its Next.js Metadata.
|
|
738
|
+
* Applies depth: 1 (image populate) and limit: 1 automatically.
|
|
739
|
+
* @returns Metadata or null if no document matches
|
|
740
|
+
*/
|
|
741
|
+
findMetadata(options, metadataOptions) {
|
|
742
|
+
return __async(this, null, function* () {
|
|
743
|
+
const { docs } = yield this.find(__spreadProps(__spreadValues({}, options), { limit: 1, depth: 1 }));
|
|
744
|
+
const doc = docs[0];
|
|
745
|
+
if (!doc) return null;
|
|
746
|
+
return generateMetadata(
|
|
747
|
+
doc,
|
|
748
|
+
metadataOptions
|
|
749
|
+
);
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Find document by ID and return its Next.js Metadata.
|
|
754
|
+
* Applies depth: 1 (image populate) automatically.
|
|
755
|
+
* @returns Metadata (throws on 404)
|
|
756
|
+
*/
|
|
757
|
+
findMetadataById(id, metadataOptions) {
|
|
758
|
+
return __async(this, null, function* () {
|
|
759
|
+
const doc = yield this.findById(id, { depth: 1 });
|
|
760
|
+
return generateMetadata(
|
|
761
|
+
doc,
|
|
762
|
+
metadataOptions
|
|
763
|
+
);
|
|
764
|
+
});
|
|
765
|
+
}
|
|
705
766
|
/**
|
|
706
767
|
* Update multiple documents (bulk update)
|
|
707
768
|
* PATCH /api/{collection}
|
|
@@ -1710,11 +1771,6 @@ function handleWebhook(request, handler, options) {
|
|
|
1710
1771
|
return __async(this, null, function* () {
|
|
1711
1772
|
try {
|
|
1712
1773
|
const rawBody = yield request.text();
|
|
1713
|
-
if (!(options == null ? void 0 : options.secret)) {
|
|
1714
|
-
console.warn(
|
|
1715
|
-
"[@01.software/sdk] Webhook signature verification is skipped because no secret was provided. Pass { secret } to handleWebhook() to enable signature verification."
|
|
1716
|
-
);
|
|
1717
|
-
}
|
|
1718
1774
|
if (options == null ? void 0 : options.secret) {
|
|
1719
1775
|
const signature = request.headers.get("x-webhook-signature") || "";
|
|
1720
1776
|
const valid = yield verifySignature(rawBody, options.secret, signature);
|
|
@@ -1724,6 +1780,10 @@ function handleWebhook(request, handler, options) {
|
|
|
1724
1780
|
{ status: 401, headers: { "Content-Type": "application/json" } }
|
|
1725
1781
|
);
|
|
1726
1782
|
}
|
|
1783
|
+
} else {
|
|
1784
|
+
console.warn(
|
|
1785
|
+
"[@01.software/sdk] Webhook signature verification is disabled. Set { secret } in handleWebhook() options to enable HMAC-SHA256 verification."
|
|
1786
|
+
);
|
|
1727
1787
|
}
|
|
1728
1788
|
const body = JSON.parse(rawBody);
|
|
1729
1789
|
if (!isValidWebhookEvent(body)) {
|
|
@@ -1767,13 +1827,6 @@ var generateOrderNumber = () => {
|
|
|
1767
1827
|
return `${year}${month}${day}${random}`;
|
|
1768
1828
|
};
|
|
1769
1829
|
|
|
1770
|
-
// src/utils/types.ts
|
|
1771
|
-
var resolveRelation = (ref) => {
|
|
1772
|
-
if (typeof ref === "number" || ref === null || ref === void 0) return null;
|
|
1773
|
-
return ref;
|
|
1774
|
-
};
|
|
1775
|
-
var objectFor = resolveRelation;
|
|
1776
|
-
|
|
1777
1830
|
// src/utils/order/formatOrderName.ts
|
|
1778
1831
|
var formatOrderName = (options) => {
|
|
1779
1832
|
var _a, _b;
|