@01.software/sdk 0.1.1 → 0.1.3

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/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { C as Config, O as Order, a as OrderProduct, T as Transaction, P as ProductOption } from './payload-types-BE-5_Y2d.cjs';
2
- export { A as ApiUsage, Y as ApiUsageSelect, at as Auth, q as Author, ae as AuthorsSelect, l as Brand, B as BrandLogo, a4 as BrandLogosSelect, a3 as BrandsSelect, D as Document, ag as DocumentCategoriesSelect, t as DocumentCategory, u as DocumentImage, ah as DocumentImagesSelect, af as DocumentsSelect, F as Form, z as FormSubmission, ao as FormSubmissionsSelect, an as FormsSelect, al as GalleriesSelect, G as Gallery, y as GalleryImage, am as GalleryImagesSelect, I as IframeBlock, M as Media, N as MediaSelect, x as Music, ak as MusicsSelect, a6 as OrderProductsSelect, a5 as OrdersSelect, E as PayloadKv, ap as PayloadKvSelect, H as PayloadLockedDocument, aq as PayloadLockedDocumentsSelect, K as PayloadMigration, as as PayloadMigrationsSelect, J as PayloadPreference, ar as PayloadPreferencesSelect, b as PlayerBlock, v as Playlist, w as PlaylistImage, aj as PlaylistImagesSelect, ai as PlaylistsSelect, o as Post, ab as PostCategoriesSelect, r as PostCategory, p as PostImage, ad as PostImagesSelect, s as PostTag, ac as PostTagsSelect, aa as PostsSelect, h as Product, a0 as ProductCategoriesSelect, j as ProductCategory, i as ProductImage, a2 as ProductImagesSelect, $ as ProductOptionsSelect, k as ProductTag, a1 as ProductTagsSelect, m as ProductVariant, _ as ProductVariantsSelect, Z as ProductsSelect, R as Return, n as ReturnProduct, a8 as ReturnProductsSelect, a7 as ReturnsSelect, S as SupportedTimezones, d as Tenant, g as TenantLogo, W as TenantLogosSelect, V as TenantMetadataSelect, e as TenantMetadatum, f as TenantOgImage, X as TenantOgImagesSelect, Q as TenantsSelect, a9 as TransactionsSelect, c as User, U as UserAuthOperations, L as UsersSelect } from './payload-types-BE-5_Y2d.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-BipHkgbu.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-BipHkgbu.cjs';
1
+ import { O as Order, a as OrderProduct, T as Transaction, P as ProductOption } from './payload-types-D-pPck9V.cjs';
2
+ export { i as ApiUsage, a3 as ApiUsageSelect, A as Audience, Z as AudiencesSelect, aC as Auth, u as Author, an as AuthorsSelect, k as BillingHistory, a5 as BillingHistorySelect, p as Brand, B as BrandLogo, ad as BrandLogosSelect, ac as BrandsSelect, c as CodeBlock, C as Config, D as Document, ap as DocumentCategoriesSelect, x as DocumentCategory, y as DocumentImage, aq as DocumentImagesSelect, ao as DocumentsSelect, E as EmailLog, _ as EmailLogsSelect, K as Form, L as FormSubmission, ax as FormSubmissionsSelect, aw as FormsSelect, au as GalleriesSelect, H as Gallery, J as GalleryImage, av as GalleryImagesSelect, I as IframeBlock, M as Media, Y as MediaSelect, G as Music, at as MusicsSelect, af as OrderProductsSelect, ae as OrdersSelect, N as PayloadKv, ay as PayloadKvSelect, Q as PayloadLockedDocument, az as PayloadLockedDocumentsSelect, W as PayloadMigration, aB as PayloadMigrationsSelect, V as PayloadPreference, aA as PayloadPreferencesSelect, b as PlayerBlock, z as Playlist, F as PlaylistImage, as as PlaylistImagesSelect, ar as PlaylistsSelect, s as Post, ak as PostCategoriesSelect, v as PostCategory, t as PostImage, am as PostImagesSelect, w as PostTag, al as PostTagsSelect, aj as PostsSelect, l as Product, a9 as ProductCategoriesSelect, n as ProductCategory, m as ProductImage, ab as ProductImagesSelect, a8 as ProductOptionsSelect, o as ProductTag, aa as ProductTagsSelect, q as ProductVariant, a7 as ProductVariantsSelect, a6 as ProductsSelect, R as Return, r as ReturnProduct, ah as ReturnProductsSelect, ag as ReturnsSelect, j as Subscription, a4 as SubscriptionsSelect, S as SupportedTimezones, e as Tenant, h as TenantLogo, a1 as TenantLogosSelect, a0 as TenantMetadataSelect, f as TenantMetadatum, g as TenantOgImage, a2 as TenantOgImagesSelect, $ as TenantsSelect, ai as TransactionsSelect, d as User, U as UserAuthOperations, X as UsersSelect } from './payload-types-D-pPck9V.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-CSOqIvi_.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-CSOqIvi_.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-Dg4AkcDQ.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-Dg4AkcDQ.cjs';
7
+ import { P as PublicCollection, C as CollectionType } from './webhook-CeKIz4r5.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-CeKIz4r5.cjs';
9
9
  export { RichTextContent, RichTextContentProps, RichTextData } from './components.cjs';
10
10
  import 'payload';
11
11
  import 'react';
@@ -40,7 +40,7 @@ declare class HttpClient {
40
40
 
41
41
  declare class CollectionClient extends HttpClient {
42
42
  constructor(clientKey: string, secretKey?: string, baseUrl?: string);
43
- from<T extends Collection>(collection: T): CollectionQueryBuilder<T>;
43
+ from<T extends PublicCollection>(collection: T): CollectionQueryBuilder<T>;
44
44
  /**
45
45
  * Find documents (list query)
46
46
  * GET /api/{collection}
@@ -94,8 +94,8 @@ declare class CollectionClient extends HttpClient {
94
94
  * Read-only subset of CollectionQueryBuilder.
95
95
  * BrowserClient.from() returns this type to prevent write operations at compile time.
96
96
  */
97
- type ReadOnlyQueryBuilder<T extends Collection> = Pick<CollectionQueryBuilder<T>, 'find' | 'findById' | 'count'>;
98
- declare class CollectionQueryBuilder<T extends Collection> {
97
+ type ReadOnlyQueryBuilder<T extends PublicCollection> = Pick<CollectionQueryBuilder<T>, 'find' | 'findById' | 'count'>;
98
+ declare class CollectionQueryBuilder<T extends PublicCollection> {
99
99
  private api;
100
100
  private collection;
101
101
  constructor(api: CollectionClient, collection: T);
@@ -151,7 +151,7 @@ declare class CollectionQueryBuilder<T extends Collection> {
151
151
  removeMany(where: ApiQueryOptions['where']): Promise<PayloadFindResponse<CollectionType<T>>>;
152
152
  }
153
153
 
154
- declare function collectionKeys<T extends Collection>(collection: T): {
154
+ declare function collectionKeys<T extends PublicCollection>(collection: T): {
155
155
  all: readonly [T];
156
156
  lists: () => readonly [T, "list"];
157
157
  list: (options?: ApiQueryOptions) => readonly [T, "list", ApiQueryOptions | undefined];
@@ -160,16 +160,16 @@ declare function collectionKeys<T extends Collection>(collection: T): {
160
160
  infinites: () => readonly [T, "infinite"];
161
161
  infinite: (options?: Omit<ApiQueryOptions, "page">) => readonly [T, "infinite", Omit<ApiQueryOptions, "page"> | undefined];
162
162
  };
163
- interface CollectionQueryParams<T extends Collection> {
163
+ interface CollectionQueryParams<T extends PublicCollection> {
164
164
  collection: T;
165
165
  options?: ApiQueryOptions;
166
166
  }
167
- interface CollectionDetailQueryParams<T extends Collection> {
167
+ interface CollectionDetailQueryParams<T extends PublicCollection> {
168
168
  collection: T;
169
169
  id: string | number;
170
170
  options?: ApiQueryOptions;
171
171
  }
172
- interface CollectionInfiniteQueryParams<T extends Collection> {
172
+ interface CollectionInfiniteQueryParams<T extends PublicCollection> {
173
173
  collection: T;
174
174
  options?: Omit<ApiQueryOptions, 'page'>;
175
175
  pageSize?: number;
@@ -178,7 +178,7 @@ declare class QueryHooks {
178
178
  private queryClient;
179
179
  private collectionClient;
180
180
  constructor(queryClient: QueryClient, collectionClient: CollectionClient);
181
- useQuery<T extends Collection>(params: CollectionQueryParams<T>, options?: {
181
+ useQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
182
182
  enabled?: boolean;
183
183
  staleTime?: number;
184
184
  gcTime?: number;
@@ -187,7 +187,7 @@ declare class QueryHooks {
187
187
  refetchInterval?: number | false;
188
188
  retry?: boolean | number;
189
189
  }): _tanstack_react_query.UseQueryResult<CollectionType<T>[], Error>;
190
- useSuspenseQuery<T extends Collection>(params: CollectionQueryParams<T>, options?: {
190
+ useSuspenseQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
191
191
  staleTime?: number;
192
192
  gcTime?: number;
193
193
  refetchOnWindowFocus?: boolean;
@@ -195,7 +195,7 @@ declare class QueryHooks {
195
195
  refetchInterval?: number | false;
196
196
  retry?: boolean | number;
197
197
  }): _tanstack_react_query.UseSuspenseQueryResult<CollectionType<T>[], Error>;
198
- useQueryById<T extends Collection>(params: CollectionDetailQueryParams<T>, options?: {
198
+ useQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
199
199
  enabled?: boolean;
200
200
  staleTime?: number;
201
201
  gcTime?: number;
@@ -204,7 +204,7 @@ declare class QueryHooks {
204
204
  refetchInterval?: number | false;
205
205
  retry?: boolean | number;
206
206
  }): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<CollectionType<T>>, Error>;
207
- useSuspenseQueryById<T extends Collection>(params: CollectionDetailQueryParams<T>, options?: {
207
+ useSuspenseQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
208
208
  staleTime?: number;
209
209
  gcTime?: number;
210
210
  refetchOnWindowFocus?: boolean;
@@ -212,7 +212,7 @@ declare class QueryHooks {
212
212
  refetchInterval?: number | false;
213
213
  retry?: boolean | number;
214
214
  }): _tanstack_react_query.UseSuspenseQueryResult<CollectionType<T>, Error>;
215
- useInfiniteQuery<T extends Collection>(params: CollectionInfiniteQueryParams<T>, options?: {
215
+ useInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
216
216
  enabled?: boolean;
217
217
  staleTime?: number;
218
218
  gcTime?: number;
@@ -220,31 +220,31 @@ declare class QueryHooks {
220
220
  refetchOnMount?: boolean;
221
221
  retry?: boolean | number;
222
222
  }): _tanstack_react_query.UseInfiniteQueryResult<_tanstack_react_query.InfiniteData<PayloadFindResponse<CollectionType<T>>, unknown>, Error>;
223
- useSuspenseInfiniteQuery<T extends Collection>(params: CollectionInfiniteQueryParams<T>, options?: {
223
+ useSuspenseInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
224
224
  staleTime?: number;
225
225
  gcTime?: number;
226
226
  refetchOnWindowFocus?: boolean;
227
227
  refetchOnMount?: boolean;
228
228
  retry?: boolean | number;
229
229
  }): _tanstack_react_query.UseSuspenseInfiniteQueryResult<_tanstack_react_query.InfiniteData<PayloadFindResponse<CollectionType<T>>, unknown>, Error>;
230
- prefetchQuery<T extends Collection>(params: CollectionQueryParams<T>, options?: {
230
+ prefetchQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
231
231
  staleTime?: number;
232
232
  }): Promise<void>;
233
- prefetchQueryById<T extends Collection>(params: CollectionDetailQueryParams<T>, options?: {
233
+ prefetchQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
234
234
  staleTime?: number;
235
235
  }): Promise<void>;
236
- prefetchInfiniteQuery<T extends Collection>(params: CollectionInfiniteQueryParams<T>, options?: {
236
+ prefetchInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
237
237
  pages?: number;
238
238
  staleTime?: number;
239
239
  }): Promise<void>;
240
- useCreate<T extends Collection>(params: {
240
+ useCreate<T extends PublicCollection>(params: {
241
241
  collection: T;
242
242
  }, options?: {
243
243
  onSuccess?: (data: PayloadMutationResponse<CollectionType<T>>) => void;
244
244
  onError?: (error: Error) => void;
245
245
  onSettled?: () => void;
246
246
  }): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, Error, Partial<CollectionType<T>>, unknown>;
247
- useUpdate<T extends Collection>(params: {
247
+ useUpdate<T extends PublicCollection>(params: {
248
248
  collection: T;
249
249
  }, options?: {
250
250
  onSuccess?: (data: PayloadMutationResponse<CollectionType<T>>) => void;
@@ -254,21 +254,21 @@ declare class QueryHooks {
254
254
  id: string | number;
255
255
  data: Partial<CollectionType<T>>;
256
256
  }, unknown>;
257
- useRemove<T extends Collection>(params: {
257
+ useRemove<T extends PublicCollection>(params: {
258
258
  collection: T;
259
259
  }, options?: {
260
260
  onSuccess?: (data: CollectionType<T>) => void;
261
261
  onError?: (error: Error) => void;
262
262
  onSettled?: () => void;
263
263
  }): _tanstack_react_query.UseMutationResult<CollectionType<T>, Error, string | number, unknown>;
264
- invalidateQueries<T extends Collection>(collection: T, type?: 'list' | 'detail' | 'infinite'): Promise<void>;
265
- getQueryData<T extends Collection>(collection: T, type: 'list', options?: ApiQueryOptions): CollectionType<T>[] | undefined;
266
- getQueryData<T extends Collection>(collection: T, type: 'detail', id: string | number, options?: ApiQueryOptions): CollectionType<T> | null | undefined;
267
- setQueryData<T extends Collection>(collection: T, type: 'list', data: CollectionType<T>[], options?: ApiQueryOptions): void;
268
- setQueryData<T extends Collection>(collection: T, type: 'detail', id: string | number, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
264
+ invalidateQueries<T extends PublicCollection>(collection: T, type?: 'list' | 'detail' | 'infinite'): Promise<void>;
265
+ getQueryData<T extends PublicCollection>(collection: T, type: 'list', options?: ApiQueryOptions): CollectionType<T>[] | undefined;
266
+ getQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string | number, options?: ApiQueryOptions): CollectionType<T> | null | undefined;
267
+ setQueryData<T extends PublicCollection>(collection: T, type: 'list', data: CollectionType<T>[], options?: ApiQueryOptions): void;
268
+ setQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string | number, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
269
269
  }
270
270
 
271
- declare class BrowserClient<_Database = Config> {
271
+ declare class BrowserClient {
272
272
  query: QueryHooks;
273
273
  collections: CollectionClient;
274
274
  queryClient: QueryClient;
@@ -276,7 +276,7 @@ declare class BrowserClient<_Database = Config> {
276
276
  protected config: ClientBrowserConfig;
277
277
  protected baseUrl: string;
278
278
  constructor(options: ClientBrowserConfig);
279
- from<T extends Collection>(collection: T): ReadOnlyQueryBuilder<T>;
279
+ from<T extends PublicCollection>(collection: T): ReadOnlyQueryBuilder<T>;
280
280
  getState(): ClientState;
281
281
  }
282
282
  declare function createBrowserClient(options: ClientBrowserConfig): BrowserClient;
@@ -315,7 +315,7 @@ declare class OrderApi {
315
315
  updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
316
316
  }
317
317
 
318
- declare class ServerClient<_Database = Config> {
318
+ declare class ServerClient {
319
319
  api: OrderApi;
320
320
  query: QueryHooks;
321
321
  collections: CollectionClient;
@@ -324,7 +324,7 @@ declare class ServerClient<_Database = Config> {
324
324
  protected config: ClientServerConfig;
325
325
  protected baseUrl: string;
326
326
  constructor(options: ClientServerConfig);
327
- from<T extends Collection>(collection: T): CollectionQueryBuilder<T>;
327
+ from<T extends PublicCollection>(collection: T): CollectionQueryBuilder<T>;
328
328
  getState(): ClientState;
329
329
  getConfig(): ClientBrowserConfig;
330
330
  }
@@ -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, Config, 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 };
352
+ export { ApiQueryOptions, BrowserClient, BrowserClient as BrowserClientType, ClientBrowserConfig, ClientServerConfig, ClientState, CollectionClient, type CollectionDetailQueryParams, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType, type CreateOrderParams, Order, OrderApi, type OrderApiOptions, OrderProduct, PayloadFindResponse, PayloadMutationResponse, ProductOption, PublicCollection, 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 { C as Config, O as Order, a as OrderProduct, T as Transaction, P as ProductOption } from './payload-types-BE-5_Y2d.js';
2
- export { A as ApiUsage, Y as ApiUsageSelect, at as Auth, q as Author, ae as AuthorsSelect, l as Brand, B as BrandLogo, a4 as BrandLogosSelect, a3 as BrandsSelect, D as Document, ag as DocumentCategoriesSelect, t as DocumentCategory, u as DocumentImage, ah as DocumentImagesSelect, af as DocumentsSelect, F as Form, z as FormSubmission, ao as FormSubmissionsSelect, an as FormsSelect, al as GalleriesSelect, G as Gallery, y as GalleryImage, am as GalleryImagesSelect, I as IframeBlock, M as Media, N as MediaSelect, x as Music, ak as MusicsSelect, a6 as OrderProductsSelect, a5 as OrdersSelect, E as PayloadKv, ap as PayloadKvSelect, H as PayloadLockedDocument, aq as PayloadLockedDocumentsSelect, K as PayloadMigration, as as PayloadMigrationsSelect, J as PayloadPreference, ar as PayloadPreferencesSelect, b as PlayerBlock, v as Playlist, w as PlaylistImage, aj as PlaylistImagesSelect, ai as PlaylistsSelect, o as Post, ab as PostCategoriesSelect, r as PostCategory, p as PostImage, ad as PostImagesSelect, s as PostTag, ac as PostTagsSelect, aa as PostsSelect, h as Product, a0 as ProductCategoriesSelect, j as ProductCategory, i as ProductImage, a2 as ProductImagesSelect, $ as ProductOptionsSelect, k as ProductTag, a1 as ProductTagsSelect, m as ProductVariant, _ as ProductVariantsSelect, Z as ProductsSelect, R as Return, n as ReturnProduct, a8 as ReturnProductsSelect, a7 as ReturnsSelect, S as SupportedTimezones, d as Tenant, g as TenantLogo, W as TenantLogosSelect, V as TenantMetadataSelect, e as TenantMetadatum, f as TenantOgImage, X as TenantOgImagesSelect, Q as TenantsSelect, a9 as TransactionsSelect, c as User, U as UserAuthOperations, L as UsersSelect } from './payload-types-BE-5_Y2d.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-Brdn6voY.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-Brdn6voY.js';
1
+ import { O as Order, a as OrderProduct, T as Transaction, P as ProductOption } from './payload-types-D-pPck9V.js';
2
+ export { i as ApiUsage, a3 as ApiUsageSelect, A as Audience, Z as AudiencesSelect, aC as Auth, u as Author, an as AuthorsSelect, k as BillingHistory, a5 as BillingHistorySelect, p as Brand, B as BrandLogo, ad as BrandLogosSelect, ac as BrandsSelect, c as CodeBlock, C as Config, D as Document, ap as DocumentCategoriesSelect, x as DocumentCategory, y as DocumentImage, aq as DocumentImagesSelect, ao as DocumentsSelect, E as EmailLog, _ as EmailLogsSelect, K as Form, L as FormSubmission, ax as FormSubmissionsSelect, aw as FormsSelect, au as GalleriesSelect, H as Gallery, J as GalleryImage, av as GalleryImagesSelect, I as IframeBlock, M as Media, Y as MediaSelect, G as Music, at as MusicsSelect, af as OrderProductsSelect, ae as OrdersSelect, N as PayloadKv, ay as PayloadKvSelect, Q as PayloadLockedDocument, az as PayloadLockedDocumentsSelect, W as PayloadMigration, aB as PayloadMigrationsSelect, V as PayloadPreference, aA as PayloadPreferencesSelect, b as PlayerBlock, z as Playlist, F as PlaylistImage, as as PlaylistImagesSelect, ar as PlaylistsSelect, s as Post, ak as PostCategoriesSelect, v as PostCategory, t as PostImage, am as PostImagesSelect, w as PostTag, al as PostTagsSelect, aj as PostsSelect, l as Product, a9 as ProductCategoriesSelect, n as ProductCategory, m as ProductImage, ab as ProductImagesSelect, a8 as ProductOptionsSelect, o as ProductTag, aa as ProductTagsSelect, q as ProductVariant, a7 as ProductVariantsSelect, a6 as ProductsSelect, R as Return, r as ReturnProduct, ah as ReturnProductsSelect, ag as ReturnsSelect, j as Subscription, a4 as SubscriptionsSelect, S as SupportedTimezones, e as Tenant, h as TenantLogo, a1 as TenantLogosSelect, a0 as TenantMetadataSelect, f as TenantMetadatum, g as TenantOgImage, a2 as TenantOgImagesSelect, $ as TenantsSelect, ai as TransactionsSelect, d as User, U as UserAuthOperations, X as UsersSelect } from './payload-types-D-pPck9V.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-B5axjxA0.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-B5axjxA0.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-D13_sbzU.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-D13_sbzU.js';
7
+ import { P as PublicCollection, C as CollectionType } from './webhook-CC3SGR_a.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-CC3SGR_a.js';
9
9
  export { RichTextContent, RichTextContentProps, RichTextData } from './components.js';
10
10
  import 'payload';
11
11
  import 'react';
@@ -40,7 +40,7 @@ declare class HttpClient {
40
40
 
41
41
  declare class CollectionClient extends HttpClient {
42
42
  constructor(clientKey: string, secretKey?: string, baseUrl?: string);
43
- from<T extends Collection>(collection: T): CollectionQueryBuilder<T>;
43
+ from<T extends PublicCollection>(collection: T): CollectionQueryBuilder<T>;
44
44
  /**
45
45
  * Find documents (list query)
46
46
  * GET /api/{collection}
@@ -94,8 +94,8 @@ declare class CollectionClient extends HttpClient {
94
94
  * Read-only subset of CollectionQueryBuilder.
95
95
  * BrowserClient.from() returns this type to prevent write operations at compile time.
96
96
  */
97
- type ReadOnlyQueryBuilder<T extends Collection> = Pick<CollectionQueryBuilder<T>, 'find' | 'findById' | 'count'>;
98
- declare class CollectionQueryBuilder<T extends Collection> {
97
+ type ReadOnlyQueryBuilder<T extends PublicCollection> = Pick<CollectionQueryBuilder<T>, 'find' | 'findById' | 'count'>;
98
+ declare class CollectionQueryBuilder<T extends PublicCollection> {
99
99
  private api;
100
100
  private collection;
101
101
  constructor(api: CollectionClient, collection: T);
@@ -151,7 +151,7 @@ declare class CollectionQueryBuilder<T extends Collection> {
151
151
  removeMany(where: ApiQueryOptions['where']): Promise<PayloadFindResponse<CollectionType<T>>>;
152
152
  }
153
153
 
154
- declare function collectionKeys<T extends Collection>(collection: T): {
154
+ declare function collectionKeys<T extends PublicCollection>(collection: T): {
155
155
  all: readonly [T];
156
156
  lists: () => readonly [T, "list"];
157
157
  list: (options?: ApiQueryOptions) => readonly [T, "list", ApiQueryOptions | undefined];
@@ -160,16 +160,16 @@ declare function collectionKeys<T extends Collection>(collection: T): {
160
160
  infinites: () => readonly [T, "infinite"];
161
161
  infinite: (options?: Omit<ApiQueryOptions, "page">) => readonly [T, "infinite", Omit<ApiQueryOptions, "page"> | undefined];
162
162
  };
163
- interface CollectionQueryParams<T extends Collection> {
163
+ interface CollectionQueryParams<T extends PublicCollection> {
164
164
  collection: T;
165
165
  options?: ApiQueryOptions;
166
166
  }
167
- interface CollectionDetailQueryParams<T extends Collection> {
167
+ interface CollectionDetailQueryParams<T extends PublicCollection> {
168
168
  collection: T;
169
169
  id: string | number;
170
170
  options?: ApiQueryOptions;
171
171
  }
172
- interface CollectionInfiniteQueryParams<T extends Collection> {
172
+ interface CollectionInfiniteQueryParams<T extends PublicCollection> {
173
173
  collection: T;
174
174
  options?: Omit<ApiQueryOptions, 'page'>;
175
175
  pageSize?: number;
@@ -178,7 +178,7 @@ declare class QueryHooks {
178
178
  private queryClient;
179
179
  private collectionClient;
180
180
  constructor(queryClient: QueryClient, collectionClient: CollectionClient);
181
- useQuery<T extends Collection>(params: CollectionQueryParams<T>, options?: {
181
+ useQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
182
182
  enabled?: boolean;
183
183
  staleTime?: number;
184
184
  gcTime?: number;
@@ -187,7 +187,7 @@ declare class QueryHooks {
187
187
  refetchInterval?: number | false;
188
188
  retry?: boolean | number;
189
189
  }): _tanstack_react_query.UseQueryResult<CollectionType<T>[], Error>;
190
- useSuspenseQuery<T extends Collection>(params: CollectionQueryParams<T>, options?: {
190
+ useSuspenseQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
191
191
  staleTime?: number;
192
192
  gcTime?: number;
193
193
  refetchOnWindowFocus?: boolean;
@@ -195,7 +195,7 @@ declare class QueryHooks {
195
195
  refetchInterval?: number | false;
196
196
  retry?: boolean | number;
197
197
  }): _tanstack_react_query.UseSuspenseQueryResult<CollectionType<T>[], Error>;
198
- useQueryById<T extends Collection>(params: CollectionDetailQueryParams<T>, options?: {
198
+ useQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
199
199
  enabled?: boolean;
200
200
  staleTime?: number;
201
201
  gcTime?: number;
@@ -204,7 +204,7 @@ declare class QueryHooks {
204
204
  refetchInterval?: number | false;
205
205
  retry?: boolean | number;
206
206
  }): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<CollectionType<T>>, Error>;
207
- useSuspenseQueryById<T extends Collection>(params: CollectionDetailQueryParams<T>, options?: {
207
+ useSuspenseQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
208
208
  staleTime?: number;
209
209
  gcTime?: number;
210
210
  refetchOnWindowFocus?: boolean;
@@ -212,7 +212,7 @@ declare class QueryHooks {
212
212
  refetchInterval?: number | false;
213
213
  retry?: boolean | number;
214
214
  }): _tanstack_react_query.UseSuspenseQueryResult<CollectionType<T>, Error>;
215
- useInfiniteQuery<T extends Collection>(params: CollectionInfiniteQueryParams<T>, options?: {
215
+ useInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
216
216
  enabled?: boolean;
217
217
  staleTime?: number;
218
218
  gcTime?: number;
@@ -220,31 +220,31 @@ declare class QueryHooks {
220
220
  refetchOnMount?: boolean;
221
221
  retry?: boolean | number;
222
222
  }): _tanstack_react_query.UseInfiniteQueryResult<_tanstack_react_query.InfiniteData<PayloadFindResponse<CollectionType<T>>, unknown>, Error>;
223
- useSuspenseInfiniteQuery<T extends Collection>(params: CollectionInfiniteQueryParams<T>, options?: {
223
+ useSuspenseInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
224
224
  staleTime?: number;
225
225
  gcTime?: number;
226
226
  refetchOnWindowFocus?: boolean;
227
227
  refetchOnMount?: boolean;
228
228
  retry?: boolean | number;
229
229
  }): _tanstack_react_query.UseSuspenseInfiniteQueryResult<_tanstack_react_query.InfiniteData<PayloadFindResponse<CollectionType<T>>, unknown>, Error>;
230
- prefetchQuery<T extends Collection>(params: CollectionQueryParams<T>, options?: {
230
+ prefetchQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
231
231
  staleTime?: number;
232
232
  }): Promise<void>;
233
- prefetchQueryById<T extends Collection>(params: CollectionDetailQueryParams<T>, options?: {
233
+ prefetchQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
234
234
  staleTime?: number;
235
235
  }): Promise<void>;
236
- prefetchInfiniteQuery<T extends Collection>(params: CollectionInfiniteQueryParams<T>, options?: {
236
+ prefetchInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
237
237
  pages?: number;
238
238
  staleTime?: number;
239
239
  }): Promise<void>;
240
- useCreate<T extends Collection>(params: {
240
+ useCreate<T extends PublicCollection>(params: {
241
241
  collection: T;
242
242
  }, options?: {
243
243
  onSuccess?: (data: PayloadMutationResponse<CollectionType<T>>) => void;
244
244
  onError?: (error: Error) => void;
245
245
  onSettled?: () => void;
246
246
  }): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, Error, Partial<CollectionType<T>>, unknown>;
247
- useUpdate<T extends Collection>(params: {
247
+ useUpdate<T extends PublicCollection>(params: {
248
248
  collection: T;
249
249
  }, options?: {
250
250
  onSuccess?: (data: PayloadMutationResponse<CollectionType<T>>) => void;
@@ -254,21 +254,21 @@ declare class QueryHooks {
254
254
  id: string | number;
255
255
  data: Partial<CollectionType<T>>;
256
256
  }, unknown>;
257
- useRemove<T extends Collection>(params: {
257
+ useRemove<T extends PublicCollection>(params: {
258
258
  collection: T;
259
259
  }, options?: {
260
260
  onSuccess?: (data: CollectionType<T>) => void;
261
261
  onError?: (error: Error) => void;
262
262
  onSettled?: () => void;
263
263
  }): _tanstack_react_query.UseMutationResult<CollectionType<T>, Error, string | number, unknown>;
264
- invalidateQueries<T extends Collection>(collection: T, type?: 'list' | 'detail' | 'infinite'): Promise<void>;
265
- getQueryData<T extends Collection>(collection: T, type: 'list', options?: ApiQueryOptions): CollectionType<T>[] | undefined;
266
- getQueryData<T extends Collection>(collection: T, type: 'detail', id: string | number, options?: ApiQueryOptions): CollectionType<T> | null | undefined;
267
- setQueryData<T extends Collection>(collection: T, type: 'list', data: CollectionType<T>[], options?: ApiQueryOptions): void;
268
- setQueryData<T extends Collection>(collection: T, type: 'detail', id: string | number, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
264
+ invalidateQueries<T extends PublicCollection>(collection: T, type?: 'list' | 'detail' | 'infinite'): Promise<void>;
265
+ getQueryData<T extends PublicCollection>(collection: T, type: 'list', options?: ApiQueryOptions): CollectionType<T>[] | undefined;
266
+ getQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string | number, options?: ApiQueryOptions): CollectionType<T> | null | undefined;
267
+ setQueryData<T extends PublicCollection>(collection: T, type: 'list', data: CollectionType<T>[], options?: ApiQueryOptions): void;
268
+ setQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string | number, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
269
269
  }
270
270
 
271
- declare class BrowserClient<_Database = Config> {
271
+ declare class BrowserClient {
272
272
  query: QueryHooks;
273
273
  collections: CollectionClient;
274
274
  queryClient: QueryClient;
@@ -276,7 +276,7 @@ declare class BrowserClient<_Database = Config> {
276
276
  protected config: ClientBrowserConfig;
277
277
  protected baseUrl: string;
278
278
  constructor(options: ClientBrowserConfig);
279
- from<T extends Collection>(collection: T): ReadOnlyQueryBuilder<T>;
279
+ from<T extends PublicCollection>(collection: T): ReadOnlyQueryBuilder<T>;
280
280
  getState(): ClientState;
281
281
  }
282
282
  declare function createBrowserClient(options: ClientBrowserConfig): BrowserClient;
@@ -315,7 +315,7 @@ declare class OrderApi {
315
315
  updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
316
316
  }
317
317
 
318
- declare class ServerClient<_Database = Config> {
318
+ declare class ServerClient {
319
319
  api: OrderApi;
320
320
  query: QueryHooks;
321
321
  collections: CollectionClient;
@@ -324,7 +324,7 @@ declare class ServerClient<_Database = Config> {
324
324
  protected config: ClientServerConfig;
325
325
  protected baseUrl: string;
326
326
  constructor(options: ClientServerConfig);
327
- from<T extends Collection>(collection: T): CollectionQueryBuilder<T>;
327
+ from<T extends PublicCollection>(collection: T): CollectionQueryBuilder<T>;
328
328
  getState(): ClientState;
329
329
  getConfig(): ClientBrowserConfig;
330
330
  }
@@ -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, Config, 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 };
352
+ export { ApiQueryOptions, BrowserClient, BrowserClient as BrowserClientType, ClientBrowserConfig, ClientServerConfig, ClientState, CollectionClient, type CollectionDetailQueryParams, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType, type CreateOrderParams, Order, OrderApi, type OrderApiOptions, OrderProduct, PayloadFindResponse, PayloadMutationResponse, ProductOption, PublicCollection, 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 new Error("clientKey is required.");
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 new Error("clientKey is required.");
1072
+ throw createConfigError("clientKey is required for OrderApi.");
1072
1073
  }
1073
1074
  if (!options.secretKey) {
1074
- throw new Error("secretKey is required.");
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
- const data = yield response.json();
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
- data.error,
1105
+ errorMessage,
1093
1106
  response.status,
1094
1107
  data,
1095
- data.error,
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 new Error("clientKey is required.");
1131
+ throw createConfigError("clientKey is required.");
1119
1132
  }
1120
1133
  if (!options.secretKey) {
1121
- throw new Error("secretKey is required.");
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
- return expected === signature;
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) {