@01.software/sdk 0.1.1 → 0.1.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-BipHkgbu.d.cts → auth-AVOXtnYN.d.cts} +1 -1
- package/dist/{auth-Brdn6voY.d.ts → auth-c2UWJjPa.d.ts} +1 -1
- package/dist/auth.d.cts +2 -2
- package/dist/auth.d.ts +2 -2
- package/dist/index.cjs +27 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +27 -9
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-BE-5_Y2d.d.cts → payload-types-DFzDtXGO.d.cts} +247 -18
- package/dist/{payload-types-BE-5_Y2d.d.ts → payload-types-DFzDtXGO.d.ts} +247 -18
- package/dist/{webhook-D13_sbzU.d.ts → webhook-CGpSMkNA.d.ts} +1 -1
- package/dist/{webhook-Dg4AkcDQ.d.cts → webhook-DJCQSO6S.d.cts} +1 -1
- package/dist/webhook.cjs +6 -1
- 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 +6 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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, P as ProductOption } from './payload-types-DFzDtXGO.cjs';
|
|
2
|
+
export { i as ApiUsage, a1 as ApiUsageSelect, A as Audience, X as AudiencesSelect, ay as Auth, s as Author, aj as AuthorsSelect, n as Brand, B as BrandLogo, a9 as BrandLogosSelect, a8 as BrandsSelect, c as CodeBlock, C as Config, D as Document, al as DocumentCategoriesSelect, v as DocumentCategory, w as DocumentImage, am as DocumentImagesSelect, ak as DocumentsSelect, E as EmailLog, Y as EmailLogsSelect, H as Form, J as FormSubmission, at as FormSubmissionsSelect, as as FormsSelect, aq as GalleriesSelect, G as Gallery, F as GalleryImage, ar as GalleryImagesSelect, I as IframeBlock, M as Media, W as MediaSelect, z as Music, ap as MusicsSelect, ab as OrderProductsSelect, aa as OrdersSelect, K as PayloadKv, au as PayloadKvSelect, L as PayloadLockedDocument, av as PayloadLockedDocumentsSelect, Q as PayloadMigration, ax as PayloadMigrationsSelect, N as PayloadPreference, aw as PayloadPreferencesSelect, b as PlayerBlock, x as Playlist, y as PlaylistImage, ao as PlaylistImagesSelect, an as PlaylistsSelect, q as Post, ag as PostCategoriesSelect, t as PostCategory, r as PostImage, ai as PostImagesSelect, u as PostTag, ah as PostTagsSelect, af as PostsSelect, j as Product, a5 as ProductCategoriesSelect, l as ProductCategory, k as ProductImage, a7 as ProductImagesSelect, a4 as ProductOptionsSelect, m as ProductTag, a6 as ProductTagsSelect, o as ProductVariant, a3 as ProductVariantsSelect, a2 as ProductsSelect, R as Return, p as ReturnProduct, ad as ReturnProductsSelect, ac as ReturnsSelect, S as SupportedTimezones, e as Tenant, h as TenantLogo, $ as TenantLogosSelect, _ as TenantMetadataSelect, f as TenantMetadatum, g as TenantOgImage, a0 as TenantOgImagesSelect, Z as TenantsSelect, ae as TransactionsSelect, d as User, U as UserAuthOperations, V as UsersSelect } from './payload-types-DFzDtXGO.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-AVOXtnYN.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-AVOXtnYN.cjs';
|
|
5
5
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
6
|
import { QueryClient } from '@tanstack/react-query';
|
|
7
|
-
import { C as Collection, a as CollectionType } from './webhook-
|
|
8
|
-
export { b as COLLECTIONS, P as PublicCollection, 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 { C as Collection, a as CollectionType } from './webhook-DJCQSO6S.cjs';
|
|
8
|
+
export { b as COLLECTIONS, P as PublicCollection, c as WebhookEvent, d as WebhookHandler, W as WebhookOperation, e as WebhookOptions, f as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-DJCQSO6S.cjs';
|
|
9
9
|
export { RichTextContent, RichTextContentProps, RichTextData } from './components.cjs';
|
|
10
10
|
import 'payload';
|
|
11
11
|
import 'react';
|
|
@@ -268,7 +268,7 @@ declare class QueryHooks {
|
|
|
268
268
|
setQueryData<T extends Collection>(collection: T, type: 'detail', id: string | number, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
declare class BrowserClient
|
|
271
|
+
declare class BrowserClient {
|
|
272
272
|
query: QueryHooks;
|
|
273
273
|
collections: CollectionClient;
|
|
274
274
|
queryClient: QueryClient;
|
|
@@ -315,7 +315,7 @@ declare class OrderApi {
|
|
|
315
315
|
updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
declare class ServerClient
|
|
318
|
+
declare class ServerClient {
|
|
319
319
|
api: OrderApi;
|
|
320
320
|
query: QueryHooks;
|
|
321
321
|
collections: CollectionClient;
|
|
@@ -349,4 +349,4 @@ declare const resolveRelation: <T>(ref: T | number | null | undefined) => T | nu
|
|
|
349
349
|
/** @deprecated Use `resolveRelation` instead */
|
|
350
350
|
declare const objectFor: <T>(ref: T | number | null | undefined) => T | null;
|
|
351
351
|
|
|
352
|
-
export { ApiQueryOptions, BrowserClient, BrowserClient as BrowserClientType, ClientBrowserConfig, ClientServerConfig, ClientState, Collection, CollectionClient, type CollectionDetailQueryParams, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType,
|
|
352
|
+
export { ApiQueryOptions, BrowserClient, BrowserClient as BrowserClientType, ClientBrowserConfig, ClientServerConfig, ClientState, Collection, CollectionClient, type CollectionDetailQueryParams, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType, type CreateOrderParams, Order, OrderApi, type OrderApiOptions, OrderProduct, PayloadFindResponse, PayloadMutationResponse, ProductOption, QueryHooks, type ReadOnlyQueryBuilder, ServerClient, ServerClient as ServerClientType, Transaction, type UpdateOrderParams, type UpdateTransactionParams, collectionKeys, createBrowserClient, createServerClient, formatOrderName, generateOrderNumber, getQueryClient, objectFor, resolveRelation };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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, P as ProductOption } from './payload-types-DFzDtXGO.js';
|
|
2
|
+
export { i as ApiUsage, a1 as ApiUsageSelect, A as Audience, X as AudiencesSelect, ay as Auth, s as Author, aj as AuthorsSelect, n as Brand, B as BrandLogo, a9 as BrandLogosSelect, a8 as BrandsSelect, c as CodeBlock, C as Config, D as Document, al as DocumentCategoriesSelect, v as DocumentCategory, w as DocumentImage, am as DocumentImagesSelect, ak as DocumentsSelect, E as EmailLog, Y as EmailLogsSelect, H as Form, J as FormSubmission, at as FormSubmissionsSelect, as as FormsSelect, aq as GalleriesSelect, G as Gallery, F as GalleryImage, ar as GalleryImagesSelect, I as IframeBlock, M as Media, W as MediaSelect, z as Music, ap as MusicsSelect, ab as OrderProductsSelect, aa as OrdersSelect, K as PayloadKv, au as PayloadKvSelect, L as PayloadLockedDocument, av as PayloadLockedDocumentsSelect, Q as PayloadMigration, ax as PayloadMigrationsSelect, N as PayloadPreference, aw as PayloadPreferencesSelect, b as PlayerBlock, x as Playlist, y as PlaylistImage, ao as PlaylistImagesSelect, an as PlaylistsSelect, q as Post, ag as PostCategoriesSelect, t as PostCategory, r as PostImage, ai as PostImagesSelect, u as PostTag, ah as PostTagsSelect, af as PostsSelect, j as Product, a5 as ProductCategoriesSelect, l as ProductCategory, k as ProductImage, a7 as ProductImagesSelect, a4 as ProductOptionsSelect, m as ProductTag, a6 as ProductTagsSelect, o as ProductVariant, a3 as ProductVariantsSelect, a2 as ProductsSelect, R as Return, p as ReturnProduct, ad as ReturnProductsSelect, ac as ReturnsSelect, S as SupportedTimezones, e as Tenant, h as TenantLogo, $ as TenantLogosSelect, _ as TenantMetadataSelect, f as TenantMetadatum, g as TenantOgImage, a0 as TenantOgImagesSelect, Z as TenantsSelect, ae as TransactionsSelect, d as User, U as UserAuthOperations, V as UsersSelect } from './payload-types-DFzDtXGO.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-c2UWJjPa.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-c2UWJjPa.js';
|
|
5
5
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
6
|
import { QueryClient } from '@tanstack/react-query';
|
|
7
|
-
import { C as Collection, a as CollectionType } from './webhook-
|
|
8
|
-
export { b as COLLECTIONS, P as PublicCollection, 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 { C as Collection, a as CollectionType } from './webhook-CGpSMkNA.js';
|
|
8
|
+
export { b as COLLECTIONS, P as PublicCollection, c as WebhookEvent, d as WebhookHandler, W as WebhookOperation, e as WebhookOptions, f as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-CGpSMkNA.js';
|
|
9
9
|
export { RichTextContent, RichTextContentProps, RichTextData } from './components.js';
|
|
10
10
|
import 'payload';
|
|
11
11
|
import 'react';
|
|
@@ -268,7 +268,7 @@ declare class QueryHooks {
|
|
|
268
268
|
setQueryData<T extends Collection>(collection: T, type: 'detail', id: string | number, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
declare class BrowserClient
|
|
271
|
+
declare class BrowserClient {
|
|
272
272
|
query: QueryHooks;
|
|
273
273
|
collections: CollectionClient;
|
|
274
274
|
queryClient: QueryClient;
|
|
@@ -315,7 +315,7 @@ declare class OrderApi {
|
|
|
315
315
|
updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
declare class ServerClient
|
|
318
|
+
declare class ServerClient {
|
|
319
319
|
api: OrderApi;
|
|
320
320
|
query: QueryHooks;
|
|
321
321
|
collections: CollectionClient;
|
|
@@ -349,4 +349,4 @@ declare const resolveRelation: <T>(ref: T | number | null | undefined) => T | nu
|
|
|
349
349
|
/** @deprecated Use `resolveRelation` instead */
|
|
350
350
|
declare const objectFor: <T>(ref: T | number | null | undefined) => T | null;
|
|
351
351
|
|
|
352
|
-
export { ApiQueryOptions, BrowserClient, BrowserClient as BrowserClientType, ClientBrowserConfig, ClientServerConfig, ClientState, Collection, CollectionClient, type CollectionDetailQueryParams, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType,
|
|
352
|
+
export { ApiQueryOptions, BrowserClient, BrowserClient as BrowserClientType, ClientBrowserConfig, ClientServerConfig, ClientState, Collection, CollectionClient, type CollectionDetailQueryParams, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType, type CreateOrderParams, Order, OrderApi, type OrderApiOptions, OrderProduct, PayloadFindResponse, PayloadMutationResponse, ProductOption, QueryHooks, type ReadOnlyQueryBuilder, ServerClient, ServerClient as ServerClientType, Transaction, type UpdateOrderParams, type UpdateTransactionParams, collectionKeys, createBrowserClient, createServerClient, formatOrderName, generateOrderNumber, getQueryClient, objectFor, resolveRelation };
|
package/dist/index.js
CHANGED
|
@@ -260,6 +260,7 @@ function isUsageLimitError(error) {
|
|
|
260
260
|
var createNetworkError = (message, status, details, userMessage, suggestion) => new NetworkError(message, status, details, userMessage, suggestion);
|
|
261
261
|
var createValidationError = (message, details, userMessage, suggestion) => new ValidationError(message, details, userMessage, suggestion);
|
|
262
262
|
var createApiError = (message, status, details, userMessage, suggestion) => new ApiError(message, status, details, userMessage, suggestion);
|
|
263
|
+
var createConfigError = (message, details, userMessage, suggestion) => new ConfigError(message, details, userMessage, suggestion);
|
|
263
264
|
var createTimeoutError = (message, details, userMessage, suggestion) => new TimeoutError(message, details, userMessage, suggestion);
|
|
264
265
|
var createUsageLimitError = (message, usage, details, userMessage, suggestion) => new UsageLimitError(message, usage, details, userMessage, suggestion);
|
|
265
266
|
|
|
@@ -1040,7 +1041,7 @@ var BrowserClient = class {
|
|
|
1040
1041
|
constructor(options) {
|
|
1041
1042
|
var _a;
|
|
1042
1043
|
if (!options.clientKey) {
|
|
1043
|
-
throw
|
|
1044
|
+
throw createConfigError("clientKey is required.");
|
|
1044
1045
|
}
|
|
1045
1046
|
this.config = __spreadValues({}, options);
|
|
1046
1047
|
this.baseUrl = resolveApiUrl(options);
|
|
@@ -1068,10 +1069,10 @@ function createBrowserClient(options) {
|
|
|
1068
1069
|
var OrderApi = class {
|
|
1069
1070
|
constructor(options) {
|
|
1070
1071
|
if (!options.clientKey) {
|
|
1071
|
-
throw
|
|
1072
|
+
throw createConfigError("clientKey is required for OrderApi.");
|
|
1072
1073
|
}
|
|
1073
1074
|
if (!options.secretKey) {
|
|
1074
|
-
throw
|
|
1075
|
+
throw createConfigError("secretKey is required for OrderApi.");
|
|
1075
1076
|
}
|
|
1076
1077
|
this.clientKey = options.clientKey;
|
|
1077
1078
|
this.secretKey = options.secretKey;
|
|
@@ -1086,13 +1087,25 @@ var OrderApi = class {
|
|
|
1086
1087
|
baseUrl: this.baseUrl,
|
|
1087
1088
|
body: JSON.stringify(body)
|
|
1088
1089
|
});
|
|
1089
|
-
|
|
1090
|
+
let data;
|
|
1091
|
+
try {
|
|
1092
|
+
data = yield response.json();
|
|
1093
|
+
} catch (e) {
|
|
1094
|
+
throw createApiError(
|
|
1095
|
+
`Invalid JSON response from ${endpoint}`,
|
|
1096
|
+
response.status,
|
|
1097
|
+
void 0,
|
|
1098
|
+
"Server returned an invalid response.",
|
|
1099
|
+
"Check if the API endpoint is available."
|
|
1100
|
+
);
|
|
1101
|
+
}
|
|
1090
1102
|
if (data.error) {
|
|
1103
|
+
const errorMessage = typeof data.error === "string" ? data.error : "Unknown API error";
|
|
1091
1104
|
throw createApiError(
|
|
1092
|
-
|
|
1105
|
+
errorMessage,
|
|
1093
1106
|
response.status,
|
|
1094
1107
|
data,
|
|
1095
|
-
|
|
1108
|
+
errorMessage,
|
|
1096
1109
|
"An error occurred while processing the request."
|
|
1097
1110
|
);
|
|
1098
1111
|
}
|
|
@@ -1115,10 +1128,10 @@ var ServerClient = class {
|
|
|
1115
1128
|
constructor(options) {
|
|
1116
1129
|
var _a;
|
|
1117
1130
|
if (!options.clientKey) {
|
|
1118
|
-
throw
|
|
1131
|
+
throw createConfigError("clientKey is required.");
|
|
1119
1132
|
}
|
|
1120
1133
|
if (!options.secretKey) {
|
|
1121
|
-
throw
|
|
1134
|
+
throw createConfigError("secretKey is required.");
|
|
1122
1135
|
}
|
|
1123
1136
|
this.config = __spreadValues({}, options);
|
|
1124
1137
|
this.baseUrl = resolveApiUrl(options);
|
|
@@ -1173,7 +1186,12 @@ function verifySignature(payload, secret, signature) {
|
|
|
1173
1186
|
);
|
|
1174
1187
|
const sig = yield crypto.subtle.sign("HMAC", key, encoder.encode(payload));
|
|
1175
1188
|
const expected = Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1176
|
-
|
|
1189
|
+
if (expected.length !== signature.length) return false;
|
|
1190
|
+
let result = 0;
|
|
1191
|
+
for (let i = 0; i < expected.length; i++) {
|
|
1192
|
+
result |= expected.charCodeAt(i) ^ signature.charCodeAt(i);
|
|
1193
|
+
}
|
|
1194
|
+
return result === 0;
|
|
1177
1195
|
});
|
|
1178
1196
|
}
|
|
1179
1197
|
function handleWebhook(request, handler, options) {
|