@01.software/sdk 0.21.0 → 0.22.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.
@@ -0,0 +1,1397 @@
1
+ import * as _tanstack_react_query from '@tanstack/react-query';
2
+ import { QueryClient, InfiniteData } from '@tanstack/react-query';
3
+ import { O as Order, c as Cart, d as CartItem, e as Product, k as OrderItem, l as Transaction, m as Fulfillment, n as Return } from './payload-types-DeLBmtzd.js';
4
+ import { Sort, Where } from 'payload';
5
+ import { Metadata } from 'next';
6
+ import { C as CollectionType } from './types-KkuKwsli.js';
7
+ import { P as PublicCollection } from './const-CfcjPbOu.js';
8
+
9
+ declare function resolveApiUrl(): string;
10
+ interface ClientConfig {
11
+ publishableKey: string;
12
+ /**
13
+ * Customer authentication options.
14
+ * Used to initialize CustomerAuth on Client.
15
+ */
16
+ customer?: {
17
+ /**
18
+ * Persist token in localStorage. Defaults to `true`.
19
+ * - `true` (default): uses key `'customer-token'`
20
+ * - `string`: uses the given string as localStorage key
21
+ * - `false`: disables persistence (token/onTokenChange used instead)
22
+ *
23
+ * Handles SSR safely (no-op on server).
24
+ * When enabled, `token` and `onTokenChange` are ignored.
25
+ */
26
+ persist?: boolean | string;
27
+ /** Initial token (e.g. from SSR cookie) */
28
+ token?: string;
29
+ /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
30
+ onTokenChange?: (token: string | null) => void;
31
+ };
32
+ }
33
+ interface ClientServerConfig extends ClientConfig {
34
+ secretKey: string;
35
+ }
36
+ interface ClientMetadata {
37
+ userAgent?: string;
38
+ timestamp: number;
39
+ }
40
+ interface ClientState {
41
+ metadata: ClientMetadata;
42
+ }
43
+ interface PaginationMeta {
44
+ page: number;
45
+ limit: number;
46
+ totalDocs: number;
47
+ totalPages: number;
48
+ hasNextPage: boolean;
49
+ hasPrevPage: boolean;
50
+ pagingCounter: number;
51
+ prevPage: number | null;
52
+ nextPage: number | null;
53
+ }
54
+ /**
55
+ * Payload CMS Find (List) Response
56
+ * GET /api/{collection}
57
+ */
58
+ interface PayloadFindResponse<T = unknown> {
59
+ docs: T[];
60
+ totalDocs: number;
61
+ limit: number;
62
+ totalPages: number;
63
+ page: number;
64
+ pagingCounter: number;
65
+ hasPrevPage: boolean;
66
+ hasNextPage: boolean;
67
+ prevPage: number | null;
68
+ nextPage: number | null;
69
+ }
70
+ /**
71
+ * Payload CMS Create/Update Response
72
+ * POST /api/{collection}
73
+ * PATCH /api/{collection}/{id}
74
+ */
75
+ interface PayloadMutationResponse<T = unknown> {
76
+ message: string;
77
+ doc: T;
78
+ errors?: unknown[];
79
+ }
80
+ /**
81
+ * Do NOT replace with `Pick<FindOptions>` from `payload`. Payload's generic
82
+ * types (`JoinQuery<TSlug>`, `PopulateType`) depend on `PayloadTypes` module
83
+ * augmentation; external SDK consumers who skip that get degenerate types
84
+ * (`never` / `{}`). Only non-generic `Sort`/`Where` are safe to import.
85
+ * Excluded vs native: Local-API-only fields, `locale`/`fallbackLocale`.
86
+ */
87
+ interface ApiQueryOptions {
88
+ page?: number;
89
+ limit?: number;
90
+ sort?: Sort;
91
+ where?: Where;
92
+ depth?: number;
93
+ select?: Record<string, boolean>;
94
+ /** Per-collection field selection for populated relationships (keyed by collection slug) */
95
+ populate?: Record<string, boolean | Record<string, boolean>>;
96
+ /** Join field control: pagination/filter per join, or false to disable */
97
+ joins?: Record<string, {
98
+ limit?: number;
99
+ page?: number;
100
+ sort?: string;
101
+ where?: Where;
102
+ count?: boolean;
103
+ } | false> | false;
104
+ /** Set to `false` to skip the count query — returns docs without totalDocs/totalPages */
105
+ pagination?: boolean;
106
+ /** Include draft versions (access control still applies on the server) */
107
+ draft?: boolean;
108
+ /** Include soft-deleted documents (requires `trash` enabled on the collection) */
109
+ trash?: boolean;
110
+ }
111
+ interface DebugConfig {
112
+ logRequests?: boolean;
113
+ logResponses?: boolean;
114
+ logErrors?: boolean;
115
+ }
116
+ interface RetryConfig {
117
+ maxRetries?: number;
118
+ retryableStatuses?: number[];
119
+ retryDelay?: (attempt: number) => number;
120
+ }
121
+ type DeepPartial<T> = {
122
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
123
+ };
124
+ type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
125
+
126
+ interface GenerateMetadataOptions {
127
+ siteName?: string;
128
+ }
129
+
130
+ declare class SDKError extends Error {
131
+ readonly code: string;
132
+ readonly status?: number;
133
+ readonly details?: unknown;
134
+ readonly userMessage?: string;
135
+ readonly suggestion?: string;
136
+ readonly requestId?: string;
137
+ constructor(code: string, message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
138
+ getUserMessage(): string;
139
+ toJSON(): {
140
+ requestId?: string | undefined;
141
+ name: string;
142
+ code: string;
143
+ message: string;
144
+ status: number | undefined;
145
+ details: unknown;
146
+ userMessage: string | undefined;
147
+ suggestion: string | undefined;
148
+ };
149
+ }
150
+ declare class NetworkError extends SDKError {
151
+ constructor(message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
152
+ }
153
+ declare class ValidationError extends SDKError {
154
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, status?: number);
155
+ }
156
+ declare class ApiError extends SDKError {
157
+ constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string);
158
+ }
159
+ declare class ConfigError extends SDKError {
160
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
161
+ }
162
+ declare class TimeoutError extends SDKError {
163
+ constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
164
+ }
165
+ declare class GoneError extends SDKError {
166
+ constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
167
+ }
168
+ declare class ServiceUnavailableError extends SDKError {
169
+ readonly retryAfter?: number;
170
+ constructor(message?: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string);
171
+ }
172
+ declare class UsageLimitError extends SDKError {
173
+ readonly usage: {
174
+ limit: number;
175
+ current: number;
176
+ remaining: number;
177
+ };
178
+ constructor(message: string, usage: {
179
+ limit: number;
180
+ current: number;
181
+ remaining: number;
182
+ }, details?: unknown, userMessage?: string, suggestion?: string);
183
+ toJSON(): {
184
+ usage: {
185
+ limit: number;
186
+ current: number;
187
+ remaining: number;
188
+ };
189
+ requestId?: string | undefined;
190
+ name: string;
191
+ code: string;
192
+ message: string;
193
+ status: number | undefined;
194
+ details: unknown;
195
+ userMessage: string | undefined;
196
+ suggestion: string | undefined;
197
+ };
198
+ }
199
+ declare class AuthError extends SDKError {
200
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
201
+ }
202
+ declare class PermissionError extends SDKError {
203
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
204
+ }
205
+ declare class NotFoundError extends SDKError {
206
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
207
+ }
208
+ declare class ConflictError extends SDKError {
209
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
210
+ }
211
+ declare class RateLimitError extends SDKError {
212
+ readonly retryAfter?: number;
213
+ constructor(message: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
214
+ }
215
+ declare function isSDKError(error: unknown): error is SDKError;
216
+ declare function isNetworkError(error: unknown): error is NetworkError;
217
+ declare function isValidationError(error: unknown): error is ValidationError;
218
+ declare function isApiError(error: unknown): error is ApiError;
219
+ declare function isConfigError(error: unknown): error is ConfigError;
220
+ declare function isTimeoutError(error: unknown): error is TimeoutError;
221
+ declare function isGoneError(error: unknown): error is GoneError;
222
+ declare function isServiceUnavailableError(error: unknown): error is ServiceUnavailableError;
223
+ declare function isUsageLimitError(error: unknown): error is UsageLimitError;
224
+ declare function isAuthError(error: unknown): error is AuthError;
225
+ declare function isPermissionError(error: unknown): error is PermissionError;
226
+ declare function isNotFoundError(error: unknown): error is NotFoundError;
227
+ declare function isConflictError(error: unknown): error is ConflictError;
228
+ declare function isRateLimitError(error: unknown): error is RateLimitError;
229
+ declare const createAuthError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => AuthError;
230
+ declare const createPermissionError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => PermissionError;
231
+ declare const createNotFoundError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => NotFoundError;
232
+ declare const createConflictError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => ConflictError;
233
+ declare const createRateLimitError: (message: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => RateLimitError;
234
+
235
+ interface FetchOptions extends RequestInit {
236
+ publishableKey?: string;
237
+ secretKey?: string;
238
+ customerToken?: string;
239
+ timeout?: number;
240
+ debug?: boolean | DebugConfig;
241
+ retry?: RetryConfig;
242
+ /** Called on 401 when customerToken is set and reason=token_expired. Return a new token to retry, or null to fail. */
243
+ onUnauthorized?: () => Promise<string | null>;
244
+ }
245
+
246
+ declare class HttpClient {
247
+ protected publishableKey: string;
248
+ protected secretKey?: string;
249
+ private getCustomerToken?;
250
+ private onUnauthorized?;
251
+ private onRequestId?;
252
+ constructor(publishableKey: string, secretKey?: string, getCustomerToken?: () => string | null, onUnauthorized?: () => Promise<string | null>, onRequestId?: (id: string | null) => void);
253
+ protected get defaultOptions(): FetchOptions;
254
+ protected fetchWithTracking(url: string, opts: FetchOptions): Promise<Response>;
255
+ protected buildUrl(endpoint: string, options?: ApiQueryOptions): string;
256
+ protected assertJsonResponse(response: Response): void;
257
+ /**
258
+ * Parse Payload CMS find response (list query)
259
+ * Returns native Payload response structure
260
+ */
261
+ protected parseFindResponse<T>(response: Response): Promise<PayloadFindResponse<T>>;
262
+ /**
263
+ * Parse Payload CMS mutation response (create/update)
264
+ * Returns native Payload response structure
265
+ */
266
+ protected parseMutationResponse<T>(response: Response): Promise<PayloadMutationResponse<T>>;
267
+ /**
268
+ * Parse Payload CMS document response (findById/delete)
269
+ * Returns document directly without wrapper
270
+ */
271
+ protected parseDocumentResponse<T>(response: Response): Promise<T>;
272
+ }
273
+
274
+ declare class CollectionClient extends HttpClient {
275
+ from<T extends PublicCollection>(collection: T): CollectionQueryBuilder<T>;
276
+ /**
277
+ * Find documents (list query)
278
+ * GET /api/{collection}
279
+ */
280
+ requestFind<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<PayloadFindResponse<T>>;
281
+ /**
282
+ * Find-like response from a custom endpoint
283
+ * POST /api/...custom-endpoint
284
+ */
285
+ requestFindEndpoint<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadFindResponse<T>>;
286
+ /**
287
+ * Find document by ID
288
+ * GET /api/{collection}/{id}
289
+ */
290
+ requestFindById<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<T>;
291
+ /**
292
+ * Create document
293
+ * POST /api/{collection}
294
+ */
295
+ requestCreate<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadMutationResponse<T>>;
296
+ /**
297
+ * Update document
298
+ * PATCH /api/{collection}/{id}
299
+ */
300
+ requestUpdate<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadMutationResponse<T>>;
301
+ /**
302
+ * Count documents
303
+ * GET /api/{collection}/count
304
+ */
305
+ requestCount(endpoint: string, options?: ApiQueryOptions): Promise<{
306
+ totalDocs: number;
307
+ }>;
308
+ /**
309
+ * Update multiple documents (bulk update)
310
+ * PATCH /api/{collection}
311
+ */
312
+ requestUpdateMany<T = unknown>(endpoint: string, data: {
313
+ where?: unknown;
314
+ data: unknown;
315
+ }): Promise<PayloadFindResponse<T>>;
316
+ /**
317
+ * Delete document
318
+ * DELETE /api/{collection}/{id}
319
+ */
320
+ requestDelete<T = unknown>(endpoint: string): Promise<T>;
321
+ /**
322
+ * Delete multiple documents (bulk delete)
323
+ * DELETE /api/{collection}
324
+ */
325
+ requestDeleteMany<T = unknown>(endpoint: string, data: {
326
+ where?: unknown;
327
+ }): Promise<PayloadFindResponse<T>>;
328
+ /**
329
+ * Create document with file upload
330
+ * POST /api/{collection} (multipart/form-data)
331
+ */
332
+ requestCreateWithFile<T = unknown>(endpoint: string, data: unknown, file: File | Blob, filename?: string): Promise<PayloadMutationResponse<T>>;
333
+ /**
334
+ * Update document with file upload
335
+ * PATCH /api/{collection}/{id} (multipart/form-data)
336
+ */
337
+ requestUpdateWithFile<T = unknown>(endpoint: string, data: unknown, file: File | Blob, filename?: string): Promise<PayloadMutationResponse<T>>;
338
+ }
339
+ declare class ReadOnlyCollectionClient extends HttpClient {
340
+ from<T extends PublicCollection>(collection: T): ReadOnlyQueryBuilder<T>;
341
+ requestFind<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<PayloadFindResponse<T>>;
342
+ requestFindById<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<T>;
343
+ requestCount(endpoint: string, options?: ApiQueryOptions): Promise<{
344
+ totalDocs: number;
345
+ }>;
346
+ }
347
+
348
+ type ReadOnlyCollectionApi = Pick<CollectionClient, 'requestFind' | 'requestFindById' | 'requestCount'>;
349
+ /**
350
+ * Read-only subset of CollectionQueryBuilder.
351
+ * Client.from() returns this type to prevent write operations at compile time.
352
+ */
353
+ type ReadOnlyQueryBuilder<T extends PublicCollection> = ReadOnlyCollectionQueryBuilder<T>;
354
+ declare class ReadOnlyCollectionQueryBuilder<T extends PublicCollection> {
355
+ private api;
356
+ private collection;
357
+ constructor(api: ReadOnlyCollectionApi, collection: T);
358
+ find(options?: ApiQueryOptions): Promise<PayloadFindResponse<CollectionType<T>>>;
359
+ findById(id: string | number, options?: ApiQueryOptions): Promise<CollectionType<T>>;
360
+ count(options?: ApiQueryOptions): Promise<{
361
+ totalDocs: number;
362
+ }>;
363
+ findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
364
+ findMetadataById(id: string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
365
+ }
366
+ declare class CollectionQueryBuilder<T extends PublicCollection> {
367
+ private api;
368
+ private collection;
369
+ constructor(api: CollectionClient, collection: T);
370
+ /**
371
+ * Find documents (list query)
372
+ * GET /api/{collection}
373
+ * @returns Payload CMS find response with docs array and pagination
374
+ */
375
+ find(options?: ApiQueryOptions): Promise<PayloadFindResponse<CollectionType<T>>>;
376
+ /**
377
+ * Find document by ID
378
+ * GET /api/{collection}/{id}
379
+ * @returns Document object directly (no wrapper)
380
+ */
381
+ findById(id: string | number, options?: ApiQueryOptions): Promise<CollectionType<T>>;
382
+ /**
383
+ * Create a new document
384
+ * POST /api/{collection}
385
+ * @returns Payload CMS mutation response with doc and message
386
+ */
387
+ create(data: Partial<CollectionType<T>>, options?: {
388
+ file?: File | Blob;
389
+ filename?: string;
390
+ }): Promise<PayloadMutationResponse<CollectionType<T>>>;
391
+ /**
392
+ * Update a document by ID
393
+ * PATCH /api/{collection}/{id}
394
+ * @returns Payload CMS mutation response with doc and message
395
+ */
396
+ update(id: string, data: Partial<CollectionType<T>>, options?: {
397
+ file?: File | Blob;
398
+ filename?: string;
399
+ }): Promise<PayloadMutationResponse<CollectionType<T>>>;
400
+ /**
401
+ * Count documents
402
+ * GET /api/{collection}/count
403
+ * @returns Count response with totalDocs
404
+ */
405
+ count(options?: ApiQueryOptions): Promise<{
406
+ totalDocs: number;
407
+ }>;
408
+ /**
409
+ * Find first matching document and return its Next.js Metadata.
410
+ * Applies depth: 1 (SEO image populate) and limit: 1 automatically.
411
+ * @returns Metadata or null if no document matches
412
+ */
413
+ findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
414
+ /**
415
+ * Find document by ID and return its Next.js Metadata.
416
+ * Applies depth: 1 (SEO image populate) automatically.
417
+ * @returns Metadata (throws on 404)
418
+ */
419
+ findMetadataById(id: string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
420
+ /**
421
+ * Update multiple documents (bulk update)
422
+ * PATCH /api/{collection}
423
+ * @returns Payload CMS find response with updated docs
424
+ */
425
+ updateMany(where: ApiQueryOptions['where'], data: Partial<CollectionType<T>>): Promise<PayloadFindResponse<CollectionType<T>>>;
426
+ /**
427
+ * Delete a document by ID
428
+ * DELETE /api/{collection}/{id}
429
+ * @returns Deleted document object directly (no wrapper)
430
+ */
431
+ remove(id: string): Promise<CollectionType<T>>;
432
+ /**
433
+ * Delete multiple documents (bulk delete)
434
+ * DELETE /api/{collection}
435
+ * @returns Payload CMS find response with deleted docs
436
+ */
437
+ removeMany(where: ApiQueryOptions['where']): Promise<PayloadFindResponse<CollectionType<T>>>;
438
+ }
439
+
440
+ interface CommunityClientOptions {
441
+ publishableKey?: string;
442
+ secretKey?: string;
443
+ customerToken?: string | (() => string | null);
444
+ onUnauthorized?: () => Promise<string | null>;
445
+ onRequestId?: (id: string | null) => void;
446
+ }
447
+ interface CommunityPost {
448
+ id: string;
449
+ title: string;
450
+ content: unknown;
451
+ categories?: string[];
452
+ thumbnail?: string;
453
+ viewCount?: number;
454
+ createdAt?: string;
455
+ updatedAt?: string;
456
+ [key: string]: unknown;
457
+ }
458
+ interface Comment {
459
+ id: string;
460
+ body: string;
461
+ post?: string;
462
+ parent?: string;
463
+ rootComment?: string;
464
+ createdAt?: string;
465
+ updatedAt?: string;
466
+ [key: string]: unknown;
467
+ }
468
+ interface Reaction {
469
+ id: string;
470
+ post?: string;
471
+ comment?: string;
472
+ type?: string;
473
+ createdAt?: string;
474
+ [key: string]: unknown;
475
+ }
476
+ interface ReactionSummary {
477
+ counts: Record<string, number>;
478
+ total: number;
479
+ userReactions: string[];
480
+ }
481
+ interface Bookmark {
482
+ id: string;
483
+ post?: string;
484
+ createdAt?: string;
485
+ [key: string]: unknown;
486
+ }
487
+ interface ReactionType {
488
+ id: string;
489
+ title: string;
490
+ slug: string;
491
+ emoji?: string;
492
+ [key: string]: unknown;
493
+ }
494
+ interface PaginatedResponse<T> {
495
+ docs: T[];
496
+ totalDocs: number;
497
+ limit: number;
498
+ totalPages: number;
499
+ page: number;
500
+ pagingCounter: number;
501
+ hasPrevPage: boolean;
502
+ hasNextPage: boolean;
503
+ prevPage: number | null;
504
+ nextPage: number | null;
505
+ }
506
+ declare class CommunityClient {
507
+ private readonly publishableKey;
508
+ private readonly secretKey?;
509
+ private readonly customerToken?;
510
+ private readonly onUnauthorized?;
511
+ private readonly onRequestId?;
512
+ constructor(options: CommunityClientOptions);
513
+ private buildQuery;
514
+ private execute;
515
+ createPost(params: {
516
+ title: string;
517
+ content: unknown;
518
+ categories?: string[];
519
+ thumbnail?: string;
520
+ }): Promise<CommunityPost>;
521
+ getMyPosts(params?: {
522
+ page?: number;
523
+ limit?: number;
524
+ }): Promise<PaginatedResponse<CommunityPost>>;
525
+ getTrending(params?: {
526
+ page?: number;
527
+ limit?: number;
528
+ period?: string;
529
+ }): Promise<PaginatedResponse<CommunityPost>>;
530
+ incrementView(params: {
531
+ postId: string;
532
+ }): Promise<{
533
+ viewCount: number;
534
+ }>;
535
+ reportPost(params: {
536
+ postId: string;
537
+ reason?: string;
538
+ reasonDetail?: string;
539
+ }): Promise<{
540
+ success: boolean;
541
+ }>;
542
+ createComment(params: {
543
+ postId: string;
544
+ body: string;
545
+ parentId?: string;
546
+ }): Promise<Comment>;
547
+ listComments(params: {
548
+ postId: string;
549
+ page?: number;
550
+ limit?: number;
551
+ rootComment?: string;
552
+ }): Promise<PaginatedResponse<Comment>>;
553
+ updateComment(params: {
554
+ commentId: string;
555
+ body: string;
556
+ }): Promise<Comment>;
557
+ deleteComment(params: {
558
+ commentId: string;
559
+ }): Promise<{
560
+ success: boolean;
561
+ }>;
562
+ reportComment(params: {
563
+ commentId: string;
564
+ reason?: string;
565
+ reasonDetail?: string;
566
+ }): Promise<{
567
+ success: boolean;
568
+ }>;
569
+ addReaction(params: {
570
+ postId: string;
571
+ type: string;
572
+ }): Promise<Reaction>;
573
+ removeReaction(params: {
574
+ postId: string;
575
+ type: string;
576
+ }): Promise<{
577
+ success: boolean;
578
+ }>;
579
+ addCommentReaction(params: {
580
+ commentId: string;
581
+ type: string;
582
+ }): Promise<Reaction>;
583
+ removeCommentReaction(params: {
584
+ commentId: string;
585
+ type: string;
586
+ }): Promise<{
587
+ success: boolean;
588
+ }>;
589
+ getReactionSummary(params: {
590
+ postId: string;
591
+ }): Promise<ReactionSummary>;
592
+ getReactionTypes(): Promise<PaginatedResponse<ReactionType>>;
593
+ addBookmark(params: {
594
+ postId: string;
595
+ }): Promise<Bookmark>;
596
+ removeBookmark(params: {
597
+ postId: string;
598
+ }): Promise<{
599
+ success: boolean;
600
+ }>;
601
+ getMyBookmarks(params?: {
602
+ page?: number;
603
+ limit?: number;
604
+ }): Promise<PaginatedResponse<Bookmark>>;
605
+ }
606
+
607
+ interface ServerApiOptions {
608
+ publishableKey?: string;
609
+ secretKey: string;
610
+ onRequestId?: (id: string | null) => void;
611
+ }
612
+ interface RequestOptions {
613
+ method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
614
+ headers?: Record<string, string>;
615
+ }
616
+ declare abstract class BaseApi {
617
+ protected readonly publishableKey: string;
618
+ protected readonly secretKey: string;
619
+ protected readonly onRequestId?: (id: string | null) => void;
620
+ constructor(apiName: string, options: ServerApiOptions);
621
+ protected request<T>(endpoint: string, body: unknown, options?: RequestOptions): Promise<T>;
622
+ }
623
+
624
+ type ModerationApiOptions = ServerApiOptions;
625
+ interface CommunityBan {
626
+ id: string;
627
+ customer: string;
628
+ isPermanent?: boolean;
629
+ bannedUntil?: string;
630
+ reason?: string;
631
+ createdAt?: string;
632
+ updatedAt?: string;
633
+ [key: string]: unknown;
634
+ }
635
+ type BanCustomerParams = {
636
+ customerId: string;
637
+ isPermanent?: boolean;
638
+ bannedUntil?: string;
639
+ reason?: string;
640
+ };
641
+ type UnbanCustomerParams = {
642
+ customerId: string;
643
+ };
644
+ declare class ModerationApi extends BaseApi {
645
+ constructor(options: ModerationApiOptions);
646
+ banCustomer(params: BanCustomerParams): Promise<CommunityBan>;
647
+ unbanCustomer(params: UnbanCustomerParams): Promise<{
648
+ success: true;
649
+ }>;
650
+ }
651
+
652
+ interface CustomerAuthResponse {
653
+ token: string;
654
+ customer: CustomerProfile;
655
+ }
656
+ interface MarketingConsentChannel {
657
+ isConsented?: boolean;
658
+ }
659
+ interface MarketingConsent {
660
+ email?: MarketingConsentChannel;
661
+ sms?: MarketingConsentChannel;
662
+ push?: MarketingConsentChannel;
663
+ consentSource?: string;
664
+ }
665
+ interface CustomerProfile {
666
+ id: string;
667
+ name: string;
668
+ email?: string | null;
669
+ phone?: string | null;
670
+ authProvider?: 'local' | 'google' | 'apple' | 'kakao' | 'naver' | null;
671
+ isGuest?: boolean | null;
672
+ marketingConsent?: MarketingConsent | null;
673
+ metadata?: Record<string, unknown> | null;
674
+ groups?: string[];
675
+ }
676
+ interface CustomerRegisterData {
677
+ name: string;
678
+ email: string;
679
+ password: string;
680
+ phone?: string;
681
+ }
682
+ interface CustomerRegisterResponse {
683
+ customer: CustomerProfile;
684
+ }
685
+ interface CustomerLoginData {
686
+ email: string;
687
+ password: string;
688
+ }
689
+ interface CustomerRefreshResponse {
690
+ token: string;
691
+ }
692
+ interface UpdateProfileData {
693
+ name?: string;
694
+ phone?: string;
695
+ marketingConsent?: MarketingConsent;
696
+ }
697
+ interface CustomerAuthOptions {
698
+ /**
699
+ * Persist token in localStorage. Defaults to `true`.
700
+ * - `true` (default): uses key `'customer-token'`
701
+ * - `string`: uses the given string as localStorage key
702
+ * - `false`: disables persistence (token/onTokenChange used instead)
703
+ *
704
+ * Handles SSR safely (no-op on server).
705
+ * When enabled, `token` and `onTokenChange` are ignored.
706
+ */
707
+ persist?: boolean | string;
708
+ /** Initial token (e.g. from SSR cookie) */
709
+ token?: string;
710
+ /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
711
+ onTokenChange?: (token: string | null) => void;
712
+ }
713
+
714
+ /**
715
+ * Customer authentication client.
716
+ *
717
+ * Manages customer registration, login, logout, and token lifecycle.
718
+ * All requests include X-Publishable-Key for tenant resolution.
719
+ */
720
+ declare class CustomerAuth {
721
+ private publishableKey;
722
+ private baseUrl;
723
+ private token;
724
+ private onTokenChange?;
725
+ private refreshPromise;
726
+ constructor(publishableKey: string, options?: CustomerAuthOptions);
727
+ /**
728
+ * Register a new customer account
729
+ */
730
+ register(data: CustomerRegisterData): Promise<CustomerRegisterResponse>;
731
+ /**
732
+ * Login with email and password. Stores the token internally.
733
+ */
734
+ login(data: CustomerLoginData): Promise<CustomerAuthResponse>;
735
+ /**
736
+ * Refresh the current token. Requires a valid (non-expired) token.
737
+ */
738
+ refreshToken(): Promise<CustomerRefreshResponse>;
739
+ private _doRefreshToken;
740
+ /**
741
+ * Clear the stored token
742
+ */
743
+ logout(): void;
744
+ /**
745
+ * Get the current authenticated customer's profile
746
+ */
747
+ me(): Promise<CustomerProfile | null>;
748
+ /**
749
+ * Request a password reset email
750
+ */
751
+ forgotPassword(email: string): Promise<void>;
752
+ /**
753
+ * Reset password using a token from the reset email
754
+ */
755
+ resetPassword(token: string, password: string): Promise<void>;
756
+ /**
757
+ * Update the authenticated customer's profile (name, phone, marketingConsent)
758
+ */
759
+ updateProfile(data: UpdateProfileData): Promise<CustomerProfile>;
760
+ /**
761
+ * Change the password of the currently authenticated customer
762
+ */
763
+ changePassword(currentPassword: string, newPassword: string): Promise<void>;
764
+ /**
765
+ * Get the authenticated customer's orders with pagination and optional status filter
766
+ */
767
+ getMyOrders(options?: {
768
+ page?: number;
769
+ limit?: number;
770
+ status?: string;
771
+ }): Promise<PayloadFindResponse<Order>>;
772
+ /**
773
+ * Get the current token (or null if not authenticated)
774
+ */
775
+ getToken(): string | null;
776
+ /**
777
+ * Set the token manually (e.g. from SSR)
778
+ */
779
+ setToken(token: string | null): void;
780
+ /**
781
+ * Check if the customer is currently authenticated
782
+ */
783
+ isAuthenticated(): boolean;
784
+ /**
785
+ * Internal: make a request with timeout and error handling.
786
+ * Auth endpoints don't retry — failures are final.
787
+ */
788
+ private requestJson;
789
+ }
790
+
791
+ interface CartApiOptions {
792
+ publishableKey?: string;
793
+ secretKey?: string;
794
+ customerToken?: string | (() => string | null);
795
+ onUnauthorized?: () => Promise<string | null>;
796
+ onRequestId?: (id: string | null) => void;
797
+ }
798
+ type AddItemParams = {
799
+ cartId: string;
800
+ product: string;
801
+ variant: string;
802
+ option: string;
803
+ quantity: number;
804
+ };
805
+ type UpdateItemParams = {
806
+ cartItemId: string;
807
+ quantity: number;
808
+ };
809
+ type RemoveItemParams = {
810
+ cartItemId: string;
811
+ };
812
+ type ApplyDiscountParams = {
813
+ cartId: string;
814
+ discountCode: string;
815
+ };
816
+ type RemoveDiscountParams = {
817
+ cartId: string;
818
+ };
819
+ type ClearCartParams = {
820
+ cartId: string;
821
+ };
822
+ declare class CartApi {
823
+ private readonly publishableKey;
824
+ private readonly secretKey?;
825
+ private readonly customerToken?;
826
+ private readonly onUnauthorized?;
827
+ private readonly onRequestId?;
828
+ constructor(options: CartApiOptions);
829
+ private execute;
830
+ getCart(cartId: string): Promise<Cart>;
831
+ addItem(params: AddItemParams): Promise<CartItem>;
832
+ updateItem(params: UpdateItemParams): Promise<CartItem>;
833
+ removeItem(params: RemoveItemParams): Promise<{
834
+ success: boolean;
835
+ }>;
836
+ applyDiscount(params: ApplyDiscountParams): Promise<Cart>;
837
+ removeDiscount(params: RemoveDiscountParams): Promise<Cart>;
838
+ clearCart(params: ClearCartParams): Promise<{
839
+ success: boolean;
840
+ }>;
841
+ }
842
+
843
+ type EntityID = string;
844
+ type RelationshipValue = string | number | null | undefined | {
845
+ id?: string | number | null;
846
+ };
847
+ type MediaValue = {
848
+ id?: EntityID | null;
849
+ } | EntityID | null | undefined;
850
+ interface ProductOptionValueShape {
851
+ id?: string | number | null;
852
+ option?: RelationshipValue;
853
+ value?: string | null;
854
+ slug?: string | null;
855
+ _order?: string | null;
856
+ '_product-option-values_values_order'?: string | null;
857
+ }
858
+ interface ProductOptionShape {
859
+ id?: string | number | null;
860
+ title?: string | null;
861
+ _order?: string | null;
862
+ '_product-options_options_order'?: string | null;
863
+ values?: {
864
+ docs?: unknown[];
865
+ } | null;
866
+ }
867
+ interface ProductVariantShape {
868
+ id?: string | number | null;
869
+ optionValues?: unknown[] | null;
870
+ price?: number | null;
871
+ compareAtPrice?: number | null;
872
+ stock?: number | null;
873
+ isUnlimited?: boolean | null;
874
+ isActive?: boolean | null;
875
+ thumbnail?: MediaValue;
876
+ images?: MediaValue[] | null;
877
+ _order?: string | null;
878
+ }
879
+ interface ProductListingProductShape {
880
+ id?: EntityID;
881
+ thumbnail?: MediaValue;
882
+ images?: MediaValue[] | null;
883
+ }
884
+ type ProductOptionMatrixValue = {
885
+ id: string;
886
+ optionId: string;
887
+ label: string;
888
+ slug: string | null;
889
+ order: string;
890
+ };
891
+ type ProductOptionMatrixOption = {
892
+ id: string;
893
+ title: string;
894
+ order: string;
895
+ values: ProductOptionMatrixValue[];
896
+ };
897
+ type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVariantShape> = {
898
+ id: string;
899
+ optionValueIds: string[];
900
+ optionValueByOptionId: Map<string, string>;
901
+ source: TVariant;
902
+ };
903
+ type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
904
+ options: ProductOptionMatrixOption[];
905
+ optionIds: string[];
906
+ optionById: Map<string, ProductOptionMatrixOption>;
907
+ valueById: Map<string, ProductOptionMatrixValue>;
908
+ valueToOptionId: Map<string, string>;
909
+ variants: ProductOptionMatrixVariant<TVariant>[];
910
+ };
911
+ type ProductListingProjection = {
912
+ selectionHintVariant: EntityID | null;
913
+ primaryImage: EntityID | null;
914
+ minPrice: number | null;
915
+ maxPrice: number | null;
916
+ minCompareAtPrice: number | null;
917
+ maxCompareAtPrice: number | null;
918
+ isPriceRange: boolean;
919
+ availableForSale: boolean;
920
+ };
921
+ type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantShape> = {
922
+ optionId: EntityID;
923
+ optionTitle: string;
924
+ optionValueId: EntityID;
925
+ optionValueLabel: string;
926
+ optionValueSlug: string | null;
927
+ variantIds: EntityID[];
928
+ variantCount: number;
929
+ variants: TVariant[];
930
+ listing: ProductListingProjection;
931
+ };
932
+ declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
933
+ options: ProductOptionShape[];
934
+ variants?: TVariant[];
935
+ }): ProductOptionMatrix<TVariant>;
936
+ declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
937
+ declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
938
+ declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
939
+ declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
940
+ declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
941
+ declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
942
+ product: ProductListingProductShape | null | undefined;
943
+ options: ProductOptionShape[];
944
+ variants: TVariant[];
945
+ primaryOptionId?: string | null;
946
+ }): ProductListingGroup<TVariant>[];
947
+
948
+ type ProductApiOptions = ServerApiOptions;
949
+ type StockCheckParams = {
950
+ items: Array<{
951
+ variantId: string;
952
+ quantity: number;
953
+ }>;
954
+ };
955
+ type StockCheckResult = {
956
+ variantId: string;
957
+ available: boolean;
958
+ availableStock: number;
959
+ requestedQuantity: number;
960
+ error?: string;
961
+ };
962
+ type StockCheckResponse = {
963
+ results: StockCheckResult[];
964
+ allAvailable: boolean;
965
+ };
966
+ type ListingGroupsParams = {
967
+ productIds: string[];
968
+ };
969
+ type ProductListingGroupSummary = Omit<ProductListingGroup, 'variants'>;
970
+ type ProductListingGroupsItem = {
971
+ product: Product;
972
+ primaryOptionId: string | null;
973
+ groups: ProductListingGroupSummary[];
974
+ };
975
+ type ProductListingGroupsResponse = {
976
+ docs: ProductListingGroupsItem[];
977
+ };
978
+ declare class ProductApi extends BaseApi {
979
+ constructor(options: ProductApiOptions);
980
+ /**
981
+ * Check point-in-time stock availability for one or more product variants.
982
+ * Results reflect available stock at the moment of the call and are not guaranteed
983
+ * to remain available by the time an order is placed.
984
+ */
985
+ stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
986
+ listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
987
+ }
988
+
989
+ type DiscountApiOptions = ServerApiOptions;
990
+ type ValidateDiscountParams = {
991
+ code: string;
992
+ orderAmount: number;
993
+ };
994
+ type ValidateDiscountResult = {
995
+ valid: boolean;
996
+ code: string;
997
+ type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
998
+ discountAmount: number;
999
+ freeShipping?: boolean;
1000
+ reason?: string;
1001
+ };
1002
+ declare class DiscountApi extends BaseApi {
1003
+ constructor(options: DiscountApiOptions);
1004
+ validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
1005
+ }
1006
+
1007
+ type ShippingApiOptions = ServerApiOptions;
1008
+ type CalculateShippingParams = {
1009
+ shippingPolicyId?: string;
1010
+ orderAmount: number;
1011
+ postalCode?: string;
1012
+ };
1013
+ type CalculateShippingResult = {
1014
+ shippingAmount: number;
1015
+ baseShippingAmount: number;
1016
+ extraShippingAmount: number;
1017
+ freeShipping: boolean;
1018
+ freeShippingMinAmount: number | null;
1019
+ isJeju: boolean;
1020
+ isRemoteIsland: boolean;
1021
+ };
1022
+ declare class ShippingApi extends BaseApi {
1023
+ constructor(options: ShippingApiOptions);
1024
+ calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
1025
+ }
1026
+
1027
+ type OrderApiOptions = ServerApiOptions;
1028
+ type CustomerSnapshot = {
1029
+ name?: string;
1030
+ email: string;
1031
+ phone?: string;
1032
+ };
1033
+ type ReturnReason = 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
1034
+ type ReturnItem = {
1035
+ orderItem: string;
1036
+ quantity: number;
1037
+ };
1038
+ type CreateOrderParams = {
1039
+ orderNumber: string;
1040
+ customer?: string;
1041
+ customerSnapshot: CustomerSnapshot;
1042
+ shippingAddress: Order['shippingAddress'];
1043
+ orderItems: Pick<OrderItem, 'product' | 'variant' | 'quantity' | 'unitPrice' | 'totalPrice'>[];
1044
+ totalAmount: number;
1045
+ shippingAmount?: number;
1046
+ pgPaymentId?: string;
1047
+ discountCode?: string;
1048
+ };
1049
+ type UpdateOrderParams = {
1050
+ orderNumber: string;
1051
+ status: Order['status'];
1052
+ };
1053
+ type TransactionStatus = 'pending' | 'paid' | 'failed' | 'canceled';
1054
+ type UpdateTransactionParams = {
1055
+ pgPaymentId: string;
1056
+ status: TransactionStatus;
1057
+ paymentMethod?: string;
1058
+ receiptUrl?: string;
1059
+ paymentKey?: string;
1060
+ amount?: number;
1061
+ };
1062
+ type RestockAction = 'return_to_stock' | 'discard';
1063
+ type ReturnWithRefundItem = {
1064
+ orderItem: string | number;
1065
+ quantity: number;
1066
+ restockAction?: RestockAction;
1067
+ };
1068
+ type ReturnWithRefundParams = {
1069
+ orderNumber: string;
1070
+ reason?: ReturnReason;
1071
+ reasonDetail?: string;
1072
+ returnItems: ReturnWithRefundItem[];
1073
+ refundAmount: number;
1074
+ pgPaymentId: string;
1075
+ paymentKey?: string;
1076
+ refundReceiptUrl?: string;
1077
+ };
1078
+ type CheckoutParams = {
1079
+ cartId: string;
1080
+ orderNumber: string;
1081
+ customerSnapshot: CustomerSnapshot;
1082
+ pgPaymentId?: string;
1083
+ discountCode?: string;
1084
+ };
1085
+ type CreateFulfillmentParams = {
1086
+ orderNumber: string;
1087
+ carrier?: string;
1088
+ trackingNumber?: string;
1089
+ items: Array<{
1090
+ orderItem: string;
1091
+ quantity: number;
1092
+ }>;
1093
+ };
1094
+ type UpdateFulfillmentParams = {
1095
+ fulfillmentId: string;
1096
+ status: 'packed' | 'shipped' | 'delivered' | 'failed';
1097
+ carrier?: string;
1098
+ trackingNumber?: string;
1099
+ };
1100
+ type BulkImportFulfillmentsParams = {
1101
+ items: Array<{
1102
+ orderNumber: string;
1103
+ carrier?: string;
1104
+ trackingNumber?: string;
1105
+ }>;
1106
+ };
1107
+ type BulkImportFulfillmentsResponse = {
1108
+ succeeded: Array<{
1109
+ orderNumber: string;
1110
+ fulfillmentId: string;
1111
+ }>;
1112
+ failed: Array<{
1113
+ orderNumber: string;
1114
+ error: string;
1115
+ }>;
1116
+ };
1117
+ type CreateReturnParams = {
1118
+ orderNumber: string;
1119
+ reason?: ReturnReason;
1120
+ reasonDetail?: string;
1121
+ returnItems: ReturnItem[];
1122
+ refundAmount: number;
1123
+ };
1124
+ type UpdateReturnParams = {
1125
+ returnId: string;
1126
+ status: 'processing' | 'approved' | 'rejected' | 'completed';
1127
+ };
1128
+ declare class OrderApi extends BaseApi {
1129
+ constructor(options: OrderApiOptions);
1130
+ createOrder(params: CreateOrderParams): Promise<Order>;
1131
+ updateOrder(params: UpdateOrderParams): Promise<Order>;
1132
+ updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
1133
+ checkout(params: CheckoutParams): Promise<Order>;
1134
+ createFulfillment(params: CreateFulfillmentParams): Promise<Fulfillment>;
1135
+ updateFulfillment(params: UpdateFulfillmentParams): Promise<Fulfillment>;
1136
+ bulkImportFulfillments(params: BulkImportFulfillmentsParams): Promise<BulkImportFulfillmentsResponse>;
1137
+ returnWithRefund(params: ReturnWithRefundParams): Promise<{
1138
+ return: Return;
1139
+ transaction: Transaction | null;
1140
+ }>;
1141
+ createReturn(params: CreateReturnParams): Promise<Return>;
1142
+ updateReturn(params: UpdateReturnParams): Promise<Return>;
1143
+ }
1144
+
1145
+ interface ServerCommerceClientOptions {
1146
+ publishableKey?: string;
1147
+ secretKey: string;
1148
+ onRequestId?: (id: string | null) => void;
1149
+ }
1150
+ declare class ServerCommerceClient {
1151
+ readonly product: {
1152
+ stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1153
+ listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1154
+ };
1155
+ readonly cart: {
1156
+ get: (cartId: string) => Promise<Cart>;
1157
+ addItem: (params: AddItemParams) => Promise<CartItem>;
1158
+ updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1159
+ removeItem: (params: RemoveItemParams) => Promise<{
1160
+ success: boolean;
1161
+ }>;
1162
+ applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1163
+ removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1164
+ clear: (params: ClearCartParams) => Promise<{
1165
+ success: boolean;
1166
+ }>;
1167
+ };
1168
+ readonly orders: {
1169
+ checkout: (params: CheckoutParams) => Promise<Order>;
1170
+ create: (params: CreateOrderParams) => Promise<Order>;
1171
+ update: (params: UpdateOrderParams) => Promise<Order>;
1172
+ updateTransaction: (params: UpdateTransactionParams) => Promise<Transaction>;
1173
+ createFulfillment: (params: CreateFulfillmentParams) => Promise<Fulfillment>;
1174
+ updateFulfillment: (params: UpdateFulfillmentParams) => Promise<Fulfillment>;
1175
+ bulkImportFulfillments: (params: BulkImportFulfillmentsParams) => Promise<BulkImportFulfillmentsResponse>;
1176
+ createReturn: (params: CreateReturnParams) => Promise<Return>;
1177
+ updateReturn: (params: UpdateReturnParams) => Promise<Return>;
1178
+ returnWithRefund: (params: ReturnWithRefundParams) => Promise<{
1179
+ return: Return;
1180
+ transaction: Transaction | null;
1181
+ }>;
1182
+ };
1183
+ readonly discounts: {
1184
+ validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
1185
+ };
1186
+ readonly shipping: {
1187
+ calculate: (params: CalculateShippingParams) => Promise<CalculateShippingResult>;
1188
+ };
1189
+ constructor(options: ServerCommerceClientOptions);
1190
+ }
1191
+
1192
+ interface CollectionQueryParams<T extends PublicCollection> {
1193
+ collection: T;
1194
+ options?: ApiQueryOptions;
1195
+ }
1196
+ interface CollectionDetailQueryParams<T extends PublicCollection> {
1197
+ collection: T;
1198
+ id: string;
1199
+ options?: ApiQueryOptions;
1200
+ }
1201
+ interface CollectionInfiniteQueryParams<T extends PublicCollection> {
1202
+ collection: T;
1203
+ options?: Omit<ApiQueryOptions, 'page'>;
1204
+ pageSize?: number;
1205
+ }
1206
+ interface QueryOptions<TQueryFnData = unknown, TData = TQueryFnData> {
1207
+ enabled?: boolean;
1208
+ staleTime?: number;
1209
+ gcTime?: number;
1210
+ refetchOnWindowFocus?: boolean;
1211
+ refetchOnMount?: boolean | 'always';
1212
+ refetchInterval?: number | false;
1213
+ retry?: boolean | number;
1214
+ select?: (data: TQueryFnData) => TData;
1215
+ placeholderData?: TQueryFnData | ((previousData: TData | undefined) => TQueryFnData | undefined);
1216
+ initialData?: TQueryFnData | (() => TQueryFnData);
1217
+ initialDataUpdatedAt?: number | (() => number | undefined);
1218
+ }
1219
+ type SuspenseQueryOptions<TQueryFnData = unknown, TData = TQueryFnData> = Omit<QueryOptions<TQueryFnData, TData>, 'enabled' | 'placeholderData'>;
1220
+ interface InfiniteQueryOptions<TQueryFnData = unknown, TData = InfiniteData<TQueryFnData>> {
1221
+ enabled?: boolean;
1222
+ staleTime?: number;
1223
+ gcTime?: number;
1224
+ refetchOnWindowFocus?: boolean;
1225
+ refetchOnMount?: boolean | 'always';
1226
+ refetchInterval?: number | false;
1227
+ retry?: boolean | number;
1228
+ select?: (data: InfiniteData<TQueryFnData>) => TData;
1229
+ }
1230
+ type SuspenseInfiniteQueryOptions<TQueryFnData = unknown, TData = InfiniteData<TQueryFnData>> = Omit<InfiniteQueryOptions<TQueryFnData, TData>, 'enabled'>;
1231
+ interface MutationCallbacks$1<TData> {
1232
+ onSuccess?: (data: TData) => void;
1233
+ onError?: (error: SDKError) => void;
1234
+ onSettled?: () => void;
1235
+ }
1236
+ declare class CollectionHooks {
1237
+ protected queryClient: QueryClient;
1238
+ protected collectionClient: CollectionClient;
1239
+ constructor(queryClient: QueryClient, collectionClient: CollectionClient);
1240
+ useQuery<T extends PublicCollection, TData = PayloadFindResponse<CollectionType<T>>>(params: CollectionQueryParams<T>, options?: QueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
1241
+ useSuspenseQuery<T extends PublicCollection, TData = PayloadFindResponse<CollectionType<T>>>(params: CollectionQueryParams<T>, options?: SuspenseQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1242
+ useQueryById<T extends PublicCollection, TData = CollectionType<T>>(params: CollectionDetailQueryParams<T>, options?: QueryOptions<CollectionType<T>, TData>): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
1243
+ useSuspenseQueryById<T extends PublicCollection, TData = CollectionType<T>>(params: CollectionDetailQueryParams<T>, options?: SuspenseQueryOptions<CollectionType<T>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1244
+ useInfiniteQuery<T extends PublicCollection, TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>>(params: CollectionInfiniteQueryParams<T>, options?: InfiniteQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseInfiniteQueryResult<TData, Error>;
1245
+ useSuspenseInfiniteQuery<T extends PublicCollection, TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>>(params: CollectionInfiniteQueryParams<T>, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseSuspenseInfiniteQueryResult<TData, Error>;
1246
+ prefetchQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
1247
+ staleTime?: number;
1248
+ }): Promise<void>;
1249
+ prefetchQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
1250
+ staleTime?: number;
1251
+ }): Promise<void>;
1252
+ prefetchInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
1253
+ pages?: number;
1254
+ staleTime?: number;
1255
+ }): Promise<void>;
1256
+ useCreate<T extends PublicCollection>(params: {
1257
+ collection: T;
1258
+ }, options?: MutationCallbacks$1<PayloadMutationResponse<CollectionType<T>>>): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, SDKError, {
1259
+ data: Partial<CollectionType<T>>;
1260
+ file?: File | Blob;
1261
+ filename?: string;
1262
+ }, unknown>;
1263
+ useUpdate<T extends PublicCollection>(params: {
1264
+ collection: T;
1265
+ }, options?: MutationCallbacks$1<PayloadMutationResponse<CollectionType<T>>>): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, SDKError, {
1266
+ id: string;
1267
+ data: Partial<CollectionType<T>>;
1268
+ file?: File | Blob;
1269
+ filename?: string;
1270
+ }, unknown>;
1271
+ useRemove<T extends PublicCollection>(params: {
1272
+ collection: T;
1273
+ }, options?: MutationCallbacks$1<CollectionType<T>>): _tanstack_react_query.UseMutationResult<CollectionType<T>, SDKError, string, unknown>;
1274
+ invalidateQueries<T extends PublicCollection>(collection: T, type?: 'list' | 'detail' | 'infinite'): Promise<void>;
1275
+ getQueryData<T extends PublicCollection>(collection: T, type: 'list', options?: ApiQueryOptions): PayloadFindResponse<CollectionType<T>> | undefined;
1276
+ getQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string, options?: ApiQueryOptions): CollectionType<T> | null | undefined;
1277
+ setQueryData<T extends PublicCollection>(collection: T, type: 'list', data: PayloadFindResponse<CollectionType<T>>, options?: ApiQueryOptions): void;
1278
+ setQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
1279
+ }
1280
+
1281
+ interface MutationCallbacks<TData> {
1282
+ onSuccess?: (data: TData) => void;
1283
+ onError?: (error: SDKError) => void;
1284
+ onSettled?: () => void;
1285
+ }
1286
+ declare class CustomerHooks {
1287
+ private queryClient;
1288
+ private customerAuth?;
1289
+ constructor(queryClient: QueryClient, customerAuth?: CustomerAuth);
1290
+ private ensureCustomerAuth;
1291
+ private invalidateMe;
1292
+ useCustomerMe(options?: {
1293
+ enabled?: boolean;
1294
+ staleTime?: number;
1295
+ gcTime?: number;
1296
+ refetchOnWindowFocus?: boolean;
1297
+ refetchOnMount?: boolean | 'always';
1298
+ refetchInterval?: number | false;
1299
+ retry?: boolean | number;
1300
+ }): _tanstack_react_query.UseQueryResult<CustomerProfile | null, Error>;
1301
+ useCustomerLogin(options?: MutationCallbacks<CustomerAuthResponse>): _tanstack_react_query.UseMutationResult<CustomerAuthResponse, SDKError, CustomerLoginData, unknown>;
1302
+ useCustomerRegister(options?: MutationCallbacks<{
1303
+ customer: CustomerProfile;
1304
+ }>): _tanstack_react_query.UseMutationResult<CustomerRegisterResponse, SDKError, CustomerRegisterData, unknown>;
1305
+ useCustomerLogout(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, void, unknown>;
1306
+ useCustomerForgotPassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, string, unknown>;
1307
+ useCustomerResetPassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, {
1308
+ token: string;
1309
+ password: string;
1310
+ }, unknown>;
1311
+ useCustomerRefreshToken(options?: MutationCallbacks<CustomerRefreshResponse>): _tanstack_react_query.UseMutationResult<CustomerRefreshResponse, SDKError, unknown, unknown>;
1312
+ useCustomerUpdateProfile(options?: MutationCallbacks<CustomerProfile>): _tanstack_react_query.UseMutationResult<CustomerProfile, SDKError, UpdateProfileData, unknown>;
1313
+ useCustomerChangePassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, {
1314
+ currentPassword: string;
1315
+ newPassword: string;
1316
+ }, unknown>;
1317
+ invalidateCustomerQueries(): Promise<void>;
1318
+ getCustomerData(): CustomerProfile | null | undefined;
1319
+ setCustomerData(data: CustomerProfile | null): void;
1320
+ }
1321
+
1322
+ type ProductListingGroupsQueryOptions = Pick<ApiQueryOptions, 'page' | 'limit' | 'sort' | 'where'>;
1323
+ type ReadOnlyQueryHooks = Omit<QueryHooks, 'useCreate' | 'useUpdate' | 'useRemove'>;
1324
+ /**
1325
+ * Composes CollectionHooks + CustomerHooks into a single API surface.
1326
+ * All methods are delegated; no logic lives here.
1327
+ */
1328
+ declare class QueryHooks extends CollectionHooks {
1329
+ private _customer;
1330
+ constructor(queryClient: QueryClient, collectionClient: CollectionClient, customerAuth?: CustomerAuth);
1331
+ useCustomerMe: CustomerHooks['useCustomerMe'];
1332
+ useCustomerLogin: CustomerHooks['useCustomerLogin'];
1333
+ useCustomerRegister: CustomerHooks['useCustomerRegister'];
1334
+ useCustomerLogout: CustomerHooks['useCustomerLogout'];
1335
+ useCustomerForgotPassword: CustomerHooks['useCustomerForgotPassword'];
1336
+ useCustomerResetPassword: CustomerHooks['useCustomerResetPassword'];
1337
+ useCustomerRefreshToken: CustomerHooks['useCustomerRefreshToken'];
1338
+ useCustomerUpdateProfile: CustomerHooks['useCustomerUpdateProfile'];
1339
+ useCustomerChangePassword: CustomerHooks['useCustomerChangePassword'];
1340
+ invalidateCustomerQueries: CustomerHooks['invalidateCustomerQueries'];
1341
+ getCustomerData: CustomerHooks['getCustomerData'];
1342
+ setCustomerData: CustomerHooks['setCustomerData'];
1343
+ useProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
1344
+ options?: ProductListingGroupsQueryOptions;
1345
+ }, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
1346
+ useSuspenseProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
1347
+ options?: ProductListingGroupsQueryOptions;
1348
+ }, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1349
+ useInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
1350
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1351
+ pageSize?: number;
1352
+ }, options?: InfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseInfiniteQueryResult<TData, Error>;
1353
+ useSuspenseInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
1354
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1355
+ pageSize?: number;
1356
+ }, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseInfiniteQueryResult<TData, Error>;
1357
+ prefetchProductListingGroupsQuery(params: {
1358
+ options?: ProductListingGroupsQueryOptions;
1359
+ }, options?: {
1360
+ staleTime?: number;
1361
+ }): Promise<void>;
1362
+ prefetchInfiniteProductListingGroupsQuery(params: {
1363
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1364
+ pageSize?: number;
1365
+ }, options?: {
1366
+ pages?: number;
1367
+ staleTime?: number;
1368
+ }): Promise<void>;
1369
+ }
1370
+
1371
+ declare class ServerClient {
1372
+ commerce: ServerCommerceClient;
1373
+ community: CommunityClient & {
1374
+ moderation: {
1375
+ banCustomer: (p: BanCustomerParams) => Promise<CommunityBan>;
1376
+ unbanCustomer: (p: UnbanCustomerParams) => Promise<{
1377
+ success: true;
1378
+ }>;
1379
+ };
1380
+ };
1381
+ query: QueryHooks;
1382
+ collections: CollectionClient;
1383
+ queryClient: QueryClient;
1384
+ lastRequestId: string | null;
1385
+ protected state: ClientState;
1386
+ protected config: ClientServerConfig;
1387
+ constructor(options: ClientServerConfig);
1388
+ getState(): ClientState;
1389
+ getConfig(): Omit<ClientServerConfig, 'secretKey'>;
1390
+ }
1391
+ /**
1392
+ * Create a server-only client with full read/write access. Requires secretKey.
1393
+ * For read-only usage, prefer `createClient()` (no secretKey needed).
1394
+ */
1395
+ declare function createServerClient(options: ClientServerConfig): ServerClient;
1396
+
1397
+ export { isPermissionError as $, type AddItemParams as A, PermissionError as B, CustomerAuth as C, type DeepPartial as D, type ExtractArrayType as E, NotFoundError as F, GoneError as G, ConflictError as H, RateLimitError as I, isSDKError as J, isNetworkError as K, type ListingGroupsParams as L, isValidationError as M, NetworkError as N, isApiError as O, type ProductListingGroupsResponse as P, isConfigError as Q, type RemoveItemParams as R, type StockCheckParams as S, TimeoutError as T, type UpdateItemParams as U, type ValidateDiscountParams as V, isTimeoutError as W, isGoneError as X, isServiceUnavailableError as Y, isUsageLimitError as Z, isAuthError as _, type CustomerAuthOptions as a, type UpdateProfileData as a$, isNotFoundError as a0, isConflictError as a1, isRateLimitError as a2, createAuthError as a3, createPermissionError as a4, createNotFoundError as a5, createConflictError as a6, createRateLimitError as a7, createServerClient as a8, ServerClient as a9, type ShippingApiOptions as aA, CartApi as aB, type CartApiOptions as aC, ProductApi as aD, type ProductApiOptions as aE, type ProductListingGroupSummary as aF, type ProductListingGroupsItem as aG, type StockCheckResult as aH, CollectionQueryBuilder as aI, type ReadOnlyQueryBuilder as aJ, CollectionClient as aK, type GenerateMetadataOptions as aL, ServerCommerceClient as aM, type ServerCommerceClientOptions as aN, type CommunityClientOptions as aO, type CommunityPost as aP, ModerationApi as aQ, type ModerationApiOptions as aR, type CommunityBan as aS, type BanCustomerParams as aT, type UnbanCustomerParams as aU, type CustomerAuthResponse as aV, type CustomerRefreshResponse as aW, type CustomerRegisterResponse as aX, type CustomerProfile as aY, type CustomerRegisterData as aZ, type CustomerLoginData as a_, resolveApiUrl as aa, type ClientServerConfig as ab, type ClientMetadata as ac, type PaginationMeta as ad, type PayloadMutationResponse as ae, BaseApi as af, type ServerApiOptions as ag, type RequestOptions as ah, OrderApi as ai, type OrderApiOptions as aj, type CustomerSnapshot as ak, type ReturnReason as al, type ReturnItem as am, type CreateOrderParams as an, type UpdateOrderParams as ao, type BulkImportFulfillmentsParams as ap, type BulkImportFulfillmentsResponse as aq, type CreateReturnParams as ar, type UpdateReturnParams as as, type UpdateTransactionParams as at, type CreateFulfillmentParams as au, type ReturnWithRefundParams as av, type UpdateFulfillmentParams as aw, DiscountApi as ax, type DiscountApiOptions as ay, ShippingApi as az, type StockCheckResponse as b, type CollectionQueryParams as b0, type CollectionDetailQueryParams as b1, type CollectionInfiniteQueryParams as b2, type QueryOptions as b3, type SuspenseQueryOptions as b4, type InfiniteQueryOptions as b5, type SuspenseInfiniteQueryOptions as b6, CollectionHooks as b7, CustomerHooks as b8, QueryHooks as b9, type ProductOptionValueShape as ba, type ProductOptionShape as bb, type ProductVariantShape as bc, type ProductListingProductShape as bd, type ProductOptionMatrixValue as be, type ProductOptionMatrixOption as bf, type ProductOptionMatrixVariant as bg, type ProductOptionMatrix as bh, type ProductListingProjection as bi, type ProductListingGroup as bj, buildProductOptionMatrix as bk, getSelectedValueByOptionId as bl, normalizeSelectedValueIds as bm, getAvailableOptionValues as bn, resolveVariantForSelection as bo, buildProductListingProjection as bp, buildProductListingGroupsByOption as bq, type ApplyDiscountParams as c, type RemoveDiscountParams as d, type ClearCartParams as e, type CheckoutParams as f, type PayloadFindResponse as g, type ValidateDiscountResult as h, type CalculateShippingParams as i, type CalculateShippingResult as j, type ApiQueryOptions as k, type ProductListingGroupsQueryOptions as l, type ClientConfig as m, CommunityClient as n, type ReadOnlyQueryHooks as o, ReadOnlyCollectionClient as p, type ClientState as q, type DebugConfig as r, type RetryConfig as s, SDKError as t, ValidationError as u, ApiError as v, ConfigError as w, ServiceUnavailableError as x, UsageLimitError as y, AuthError as z };