@01.software/sdk 0.21.0 → 0.23.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,1420 @@
1
+ import * as _tanstack_react_query from '@tanstack/react-query';
2
+ import { QueryClient, InfiniteData } from '@tanstack/react-query';
3
+ import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-D8-G1PiT.js';
4
+ import { Sort, Where } from 'payload';
5
+ import { Metadata } from 'next';
6
+ import { C as CollectionType } from './types-BQqfXbB2.js';
7
+ import { P as PublicCollection, S as ServerCollection } from './const-CMdmNgEs.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<TCollection extends string = PublicCollection> extends HttpClient {
275
+ from<T extends TCollection>(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 ServerCollectionClient extends CollectionClient<ServerCollection> {
340
+ from<T extends ServerCollection>(collection: T): ServerCollectionQueryBuilder<T>;
341
+ }
342
+ declare class ReadOnlyCollectionClient extends HttpClient {
343
+ from<T extends PublicCollection>(collection: T): ReadOnlyQueryBuilder<T>;
344
+ requestFind<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<PayloadFindResponse<T>>;
345
+ requestFindById<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<T>;
346
+ requestCount(endpoint: string, options?: ApiQueryOptions): Promise<{
347
+ totalDocs: number;
348
+ }>;
349
+ }
350
+
351
+ type ReadOnlyCollectionApi = Pick<CollectionClient, 'requestFind' | 'requestFindById' | 'requestCount'>;
352
+ /**
353
+ * Read-only subset of CollectionQueryBuilder.
354
+ * Client.from() returns this type to prevent write operations at compile time.
355
+ */
356
+ type ReadOnlyQueryBuilder<T extends PublicCollection> = ReadOnlyCollectionQueryBuilder<T>;
357
+ declare class ReadOnlyCollectionQueryBuilder<T extends PublicCollection> {
358
+ private api;
359
+ private collection;
360
+ constructor(api: ReadOnlyCollectionApi, collection: T);
361
+ find(options?: ApiQueryOptions): Promise<PayloadFindResponse<CollectionType<T>>>;
362
+ findById(id: string | number, options?: ApiQueryOptions): Promise<CollectionType<T>>;
363
+ count(options?: ApiQueryOptions): Promise<{
364
+ totalDocs: number;
365
+ }>;
366
+ findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
367
+ findMetadataById(id: string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
368
+ }
369
+ declare class CollectionQueryBuilder<T extends string> {
370
+ private api;
371
+ private collection;
372
+ constructor(api: CollectionClient, collection: T);
373
+ /**
374
+ * Find documents (list query)
375
+ * GET /api/{collection}
376
+ * @returns Payload CMS find response with docs array and pagination
377
+ */
378
+ find(options?: ApiQueryOptions): Promise<PayloadFindResponse<CollectionType<T>>>;
379
+ /**
380
+ * Find document by ID
381
+ * GET /api/{collection}/{id}
382
+ * @returns Document object directly (no wrapper)
383
+ */
384
+ findById(id: string | number, options?: ApiQueryOptions): Promise<CollectionType<T>>;
385
+ /**
386
+ * Create a new document
387
+ * POST /api/{collection}
388
+ * @returns Payload CMS mutation response with doc and message
389
+ */
390
+ create(data: Partial<CollectionType<T>>, options?: {
391
+ file?: File | Blob;
392
+ filename?: string;
393
+ }): Promise<PayloadMutationResponse<CollectionType<T>>>;
394
+ /**
395
+ * Update a document by ID
396
+ * PATCH /api/{collection}/{id}
397
+ * @returns Payload CMS mutation response with doc and message
398
+ */
399
+ update(id: string, data: Partial<CollectionType<T>>, options?: {
400
+ file?: File | Blob;
401
+ filename?: string;
402
+ }): Promise<PayloadMutationResponse<CollectionType<T>>>;
403
+ /**
404
+ * Count documents
405
+ * GET /api/{collection}/count
406
+ * @returns Count response with totalDocs
407
+ */
408
+ count(options?: ApiQueryOptions): Promise<{
409
+ totalDocs: number;
410
+ }>;
411
+ /**
412
+ * Find first matching document and return its Next.js Metadata.
413
+ * Applies depth: 1 (SEO image populate) and limit: 1 automatically.
414
+ * @returns Metadata or null if no document matches
415
+ */
416
+ findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
417
+ /**
418
+ * Find document by ID and return its Next.js Metadata.
419
+ * Applies depth: 1 (SEO image populate) automatically.
420
+ * @returns Metadata (throws on 404)
421
+ */
422
+ findMetadataById(id: string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
423
+ /**
424
+ * Update multiple documents (bulk update)
425
+ * PATCH /api/{collection}
426
+ * @returns Payload CMS find response with updated docs
427
+ */
428
+ updateMany(where: ApiQueryOptions['where'], data: Partial<CollectionType<T>>): Promise<PayloadFindResponse<CollectionType<T>>>;
429
+ /**
430
+ * Delete a document by ID
431
+ * DELETE /api/{collection}/{id}
432
+ * @returns Deleted document object directly (no wrapper)
433
+ */
434
+ remove(id: string): Promise<CollectionType<T>>;
435
+ /**
436
+ * Delete multiple documents (bulk delete)
437
+ * DELETE /api/{collection}
438
+ * @returns Payload CMS find response with deleted docs
439
+ */
440
+ removeMany(where: ApiQueryOptions['where']): Promise<PayloadFindResponse<CollectionType<T>>>;
441
+ }
442
+ declare class ServerCollectionQueryBuilder<T extends ServerCollection> extends CollectionQueryBuilder<T> {
443
+ }
444
+
445
+ interface CommunityClientOptions {
446
+ publishableKey?: string;
447
+ secretKey?: string;
448
+ customerToken?: string | (() => string | null);
449
+ onUnauthorized?: () => Promise<string | null>;
450
+ onRequestId?: (id: string | null) => void;
451
+ }
452
+ interface CommunityPost {
453
+ id: string;
454
+ title?: string | null;
455
+ displayTitle?: string | null;
456
+ content?: unknown;
457
+ categories?: string[];
458
+ thumbnail?: string;
459
+ viewCount?: number;
460
+ createdAt?: string;
461
+ updatedAt?: string;
462
+ [key: string]: unknown;
463
+ }
464
+ interface Comment {
465
+ id: string;
466
+ body: string;
467
+ post?: string;
468
+ parent?: string;
469
+ rootComment?: string;
470
+ createdAt?: string;
471
+ updatedAt?: string;
472
+ [key: string]: unknown;
473
+ }
474
+ interface Reaction {
475
+ id: string;
476
+ post?: string;
477
+ comment?: string;
478
+ type?: string;
479
+ createdAt?: string;
480
+ [key: string]: unknown;
481
+ }
482
+ interface ReactionSummary {
483
+ counts: Record<string, number>;
484
+ total: number;
485
+ userReactions: string[];
486
+ }
487
+ interface Bookmark {
488
+ id: string;
489
+ post?: string;
490
+ createdAt?: string;
491
+ [key: string]: unknown;
492
+ }
493
+ interface ReactionType {
494
+ id: string;
495
+ title: string;
496
+ slug: string;
497
+ emoji?: string;
498
+ [key: string]: unknown;
499
+ }
500
+ interface PaginatedResponse<T> {
501
+ docs: T[];
502
+ totalDocs: number;
503
+ limit: number;
504
+ totalPages: number;
505
+ page: number;
506
+ pagingCounter: number;
507
+ hasPrevPage: boolean;
508
+ hasNextPage: boolean;
509
+ prevPage: number | null;
510
+ nextPage: number | null;
511
+ }
512
+ declare class CommunityClient {
513
+ private readonly publishableKey;
514
+ private readonly secretKey?;
515
+ private readonly customerToken?;
516
+ private readonly onUnauthorized?;
517
+ private readonly onRequestId?;
518
+ constructor(options: CommunityClientOptions);
519
+ private buildQuery;
520
+ private execute;
521
+ createPost(params: {
522
+ title?: string | null;
523
+ content?: unknown;
524
+ categories?: string[];
525
+ thumbnail?: string;
526
+ }): Promise<CommunityPost>;
527
+ getMyPosts(params?: {
528
+ page?: number;
529
+ limit?: number;
530
+ }): Promise<PaginatedResponse<CommunityPost>>;
531
+ getTrending(params?: {
532
+ page?: number;
533
+ limit?: number;
534
+ period?: string;
535
+ }): Promise<PaginatedResponse<CommunityPost>>;
536
+ incrementView(params: {
537
+ postId: string;
538
+ }): Promise<{
539
+ viewCount: number;
540
+ }>;
541
+ reportPost(params: {
542
+ postId: string;
543
+ reason?: string;
544
+ reasonDetail?: string;
545
+ }): Promise<{
546
+ success: boolean;
547
+ }>;
548
+ createComment(params: {
549
+ postId: string;
550
+ body: string;
551
+ parentId?: string;
552
+ }): Promise<Comment>;
553
+ listComments(params: {
554
+ postId: string;
555
+ page?: number;
556
+ limit?: number;
557
+ rootComment?: string;
558
+ }): Promise<PaginatedResponse<Comment>>;
559
+ updateComment(params: {
560
+ commentId: string;
561
+ body: string;
562
+ }): Promise<Comment>;
563
+ deleteComment(params: {
564
+ commentId: string;
565
+ }): Promise<{
566
+ success: boolean;
567
+ }>;
568
+ reportComment(params: {
569
+ commentId: string;
570
+ reason?: string;
571
+ reasonDetail?: string;
572
+ }): Promise<{
573
+ success: boolean;
574
+ }>;
575
+ addReaction(params: {
576
+ postId: string;
577
+ type: string;
578
+ }): Promise<Reaction>;
579
+ removeReaction(params: {
580
+ postId: string;
581
+ type: string;
582
+ }): Promise<{
583
+ success: boolean;
584
+ }>;
585
+ addCommentReaction(params: {
586
+ commentId: string;
587
+ type: string;
588
+ }): Promise<Reaction>;
589
+ removeCommentReaction(params: {
590
+ commentId: string;
591
+ type: string;
592
+ }): Promise<{
593
+ success: boolean;
594
+ }>;
595
+ getReactionSummary(params: {
596
+ postId: string;
597
+ }): Promise<ReactionSummary>;
598
+ getReactionTypes(): Promise<PaginatedResponse<ReactionType>>;
599
+ addBookmark(params: {
600
+ postId: string;
601
+ }): Promise<Bookmark>;
602
+ removeBookmark(params: {
603
+ postId: string;
604
+ }): Promise<{
605
+ success: boolean;
606
+ }>;
607
+ getMyBookmarks(params?: {
608
+ page?: number;
609
+ limit?: number;
610
+ }): Promise<PaginatedResponse<Bookmark>>;
611
+ }
612
+
613
+ interface ServerApiOptions {
614
+ publishableKey?: string;
615
+ secretKey: string;
616
+ onRequestId?: (id: string | null) => void;
617
+ }
618
+ interface RequestOptions {
619
+ method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
620
+ headers?: Record<string, string>;
621
+ }
622
+ declare abstract class BaseApi {
623
+ protected readonly publishableKey: string;
624
+ protected readonly secretKey: string;
625
+ protected readonly onRequestId?: (id: string | null) => void;
626
+ constructor(apiName: string, options: ServerApiOptions);
627
+ protected request<T>(endpoint: string, body: unknown, options?: RequestOptions): Promise<T>;
628
+ }
629
+
630
+ type ModerationApiOptions = ServerApiOptions;
631
+ interface CommunityBan {
632
+ id: string;
633
+ customer: string;
634
+ isPermanent?: boolean;
635
+ bannedUntil?: string;
636
+ reason?: string;
637
+ createdAt?: string;
638
+ updatedAt?: string;
639
+ [key: string]: unknown;
640
+ }
641
+ type BanCustomerParams = {
642
+ customerId: string;
643
+ isPermanent?: boolean;
644
+ bannedUntil?: string;
645
+ reason?: string;
646
+ };
647
+ type UnbanCustomerParams = {
648
+ customerId: string;
649
+ };
650
+ declare class ModerationApi extends BaseApi {
651
+ constructor(options: ModerationApiOptions);
652
+ banCustomer(params: BanCustomerParams): Promise<CommunityBan>;
653
+ unbanCustomer(params: UnbanCustomerParams): Promise<{
654
+ success: true;
655
+ }>;
656
+ }
657
+
658
+ interface CustomerAuthResponse {
659
+ token: string;
660
+ customer: CustomerProfile;
661
+ }
662
+ interface MarketingConsentChannel {
663
+ isConsented?: boolean;
664
+ }
665
+ interface MarketingConsent {
666
+ email?: MarketingConsentChannel;
667
+ sms?: MarketingConsentChannel;
668
+ push?: MarketingConsentChannel;
669
+ consentSource?: string;
670
+ }
671
+ interface CustomerProfile {
672
+ id: string;
673
+ name: string;
674
+ email?: string | null;
675
+ phone?: string | null;
676
+ authProvider?: 'local' | 'google' | 'apple' | 'kakao' | 'naver' | null;
677
+ isGuest?: boolean | null;
678
+ marketingConsent?: MarketingConsent | null;
679
+ metadata?: Record<string, unknown> | null;
680
+ groups?: string[];
681
+ }
682
+ interface CustomerRegisterData {
683
+ name: string;
684
+ email: string;
685
+ password: string;
686
+ phone?: string;
687
+ }
688
+ interface CustomerRegisterResponse {
689
+ customer: CustomerProfile;
690
+ }
691
+ interface CustomerLoginData {
692
+ email: string;
693
+ password: string;
694
+ }
695
+ interface CustomerRefreshResponse {
696
+ token: string;
697
+ }
698
+ interface UpdateProfileData {
699
+ name?: string;
700
+ phone?: string;
701
+ marketingConsent?: MarketingConsent;
702
+ }
703
+ interface CustomerAuthOptions {
704
+ /**
705
+ * Persist token in localStorage. Defaults to `true`.
706
+ * - `true` (default): uses key `'customer-token'`
707
+ * - `string`: uses the given string as localStorage key
708
+ * - `false`: disables persistence (token/onTokenChange used instead)
709
+ *
710
+ * Handles SSR safely (no-op on server).
711
+ * When enabled, `token` and `onTokenChange` are ignored.
712
+ */
713
+ persist?: boolean | string;
714
+ /** Initial token (e.g. from SSR cookie) */
715
+ token?: string;
716
+ /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
717
+ onTokenChange?: (token: string | null) => void;
718
+ }
719
+
720
+ /**
721
+ * Customer authentication client.
722
+ *
723
+ * Manages customer registration, login, logout, and token lifecycle.
724
+ * All requests include X-Publishable-Key for tenant resolution.
725
+ */
726
+ declare class CustomerAuth {
727
+ private publishableKey;
728
+ private baseUrl;
729
+ private token;
730
+ private onTokenChange?;
731
+ private refreshPromise;
732
+ constructor(publishableKey: string, options?: CustomerAuthOptions);
733
+ /**
734
+ * Register a new customer account
735
+ */
736
+ register(data: CustomerRegisterData): Promise<CustomerRegisterResponse>;
737
+ /**
738
+ * Login with email and password. Stores the token internally.
739
+ */
740
+ login(data: CustomerLoginData): Promise<CustomerAuthResponse>;
741
+ /**
742
+ * Refresh the current token. Requires a valid (non-expired) token.
743
+ */
744
+ refreshToken(): Promise<CustomerRefreshResponse>;
745
+ private _doRefreshToken;
746
+ /**
747
+ * Clear the stored token
748
+ */
749
+ logout(): void;
750
+ /**
751
+ * Get the current authenticated customer's profile
752
+ */
753
+ me(): Promise<CustomerProfile | null>;
754
+ /**
755
+ * Request a password reset email
756
+ */
757
+ forgotPassword(email: string): Promise<void>;
758
+ /**
759
+ * Reset password using a token from the reset email
760
+ */
761
+ resetPassword(token: string, password: string): Promise<void>;
762
+ /**
763
+ * Update the authenticated customer's profile (name, phone, marketingConsent)
764
+ */
765
+ updateProfile(data: UpdateProfileData): Promise<CustomerProfile>;
766
+ /**
767
+ * Change the password of the currently authenticated customer
768
+ */
769
+ changePassword(currentPassword: string, newPassword: string): Promise<void>;
770
+ /**
771
+ * Get the authenticated customer's orders with pagination and optional status filter
772
+ */
773
+ getMyOrders(options?: {
774
+ page?: number;
775
+ limit?: number;
776
+ status?: string;
777
+ }): Promise<PayloadFindResponse<Order>>;
778
+ /**
779
+ * Get the current token (or null if not authenticated)
780
+ */
781
+ getToken(): string | null;
782
+ /**
783
+ * Set the token manually (e.g. from SSR)
784
+ */
785
+ setToken(token: string | null): void;
786
+ /**
787
+ * Check if the customer is currently authenticated
788
+ */
789
+ isAuthenticated(): boolean;
790
+ /**
791
+ * Internal: make a request with timeout and error handling.
792
+ * Auth endpoints don't retry — failures are final.
793
+ */
794
+ private requestJson;
795
+ }
796
+
797
+ interface CartApiOptions {
798
+ publishableKey?: string;
799
+ secretKey?: string;
800
+ customerToken?: string | (() => string | null);
801
+ onUnauthorized?: () => Promise<string | null>;
802
+ onRequestId?: (id: string | null) => void;
803
+ }
804
+ type AddItemParams = {
805
+ cartId: string;
806
+ product: string;
807
+ variant: string;
808
+ option: string;
809
+ quantity: number;
810
+ };
811
+ type UpdateItemParams = {
812
+ cartItemId: string;
813
+ quantity: number;
814
+ };
815
+ type RemoveItemParams = {
816
+ cartItemId: string;
817
+ };
818
+ type ApplyDiscountParams = {
819
+ cartId: string;
820
+ discountCode: string;
821
+ };
822
+ type RemoveDiscountParams = {
823
+ cartId: string;
824
+ };
825
+ type ClearCartParams = {
826
+ cartId: string;
827
+ };
828
+ declare class CartApi {
829
+ private readonly publishableKey;
830
+ private readonly secretKey?;
831
+ private readonly customerToken?;
832
+ private readonly onUnauthorized?;
833
+ private readonly onRequestId?;
834
+ constructor(options: CartApiOptions);
835
+ private execute;
836
+ getCart(cartId: string): Promise<Cart>;
837
+ addItem(params: AddItemParams): Promise<CartItem>;
838
+ updateItem(params: UpdateItemParams): Promise<CartItem>;
839
+ removeItem(params: RemoveItemParams): Promise<{
840
+ success: boolean;
841
+ }>;
842
+ applyDiscount(params: ApplyDiscountParams): Promise<Cart>;
843
+ removeDiscount(params: RemoveDiscountParams): Promise<Cart>;
844
+ clearCart(params: ClearCartParams): Promise<{
845
+ success: boolean;
846
+ }>;
847
+ }
848
+
849
+ type EntityID = string;
850
+ type RelationshipValue = string | number | null | undefined | {
851
+ id?: string | number | null;
852
+ };
853
+ type MediaValue = {
854
+ id?: EntityID | null;
855
+ } | EntityID | null | undefined;
856
+ interface ProductOptionValueShape {
857
+ id?: string | number | null;
858
+ option?: RelationshipValue;
859
+ value?: string | null;
860
+ slug?: string | null;
861
+ swatchColor?: string | null;
862
+ thumbnail?: MediaValue;
863
+ images?: MediaValue[] | null;
864
+ _order?: string | null;
865
+ '_product-option-values_values_order'?: string | null;
866
+ }
867
+ interface ProductOptionShape {
868
+ id?: string | number | null;
869
+ title?: string | null;
870
+ _order?: string | null;
871
+ '_product-options_options_order'?: string | null;
872
+ values?: {
873
+ docs?: unknown[];
874
+ } | null;
875
+ }
876
+ interface ProductVariantShape {
877
+ id?: string | number | null;
878
+ optionValues?: unknown[] | null;
879
+ price?: number | null;
880
+ compareAtPrice?: number | null;
881
+ stock?: number | null;
882
+ reservedStock?: number | null;
883
+ isUnlimited?: boolean | null;
884
+ isActive?: boolean | null;
885
+ thumbnail?: MediaValue;
886
+ images?: MediaValue[] | null;
887
+ _order?: string | null;
888
+ }
889
+ interface ProductListingProductShape {
890
+ id?: EntityID;
891
+ thumbnail?: MediaValue;
892
+ images?: MediaValue[] | null;
893
+ }
894
+ type ProductOptionMatrixValue = {
895
+ id: string;
896
+ optionId: string;
897
+ label: string;
898
+ slug: string | null;
899
+ swatchColor?: string | null;
900
+ thumbnail?: MediaValue;
901
+ images?: MediaValue[] | null;
902
+ order: string;
903
+ };
904
+ type ProductOptionMatrixOption = {
905
+ id: string;
906
+ title: string;
907
+ order: string;
908
+ values: ProductOptionMatrixValue[];
909
+ };
910
+ type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVariantShape> = {
911
+ id: string;
912
+ optionValueIds: string[];
913
+ optionValueByOptionId: Map<string, string>;
914
+ source: TVariant;
915
+ };
916
+ type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
917
+ options: ProductOptionMatrixOption[];
918
+ optionIds: string[];
919
+ optionById: Map<string, ProductOptionMatrixOption>;
920
+ valueById: Map<string, ProductOptionMatrixValue>;
921
+ valueToOptionId: Map<string, string>;
922
+ variants: ProductOptionMatrixVariant<TVariant>[];
923
+ };
924
+ type ProductListingProjection = {
925
+ selectionHintVariant: EntityID | null;
926
+ primaryImage: EntityID | null;
927
+ minPrice: number | null;
928
+ maxPrice: number | null;
929
+ minCompareAtPrice: number | null;
930
+ maxCompareAtPrice: number | null;
931
+ isPriceRange: boolean;
932
+ availableForSale: boolean;
933
+ };
934
+ type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantShape> = {
935
+ optionId: EntityID;
936
+ optionTitle: string;
937
+ optionValueId: EntityID;
938
+ optionValueLabel: string;
939
+ optionValueSlug: string | null;
940
+ optionValueSwatchColor?: string | null;
941
+ optionValueThumbnail?: MediaValue;
942
+ optionValueImages?: MediaValue[] | null;
943
+ variantIds: EntityID[];
944
+ variantCount: number;
945
+ variants: TVariant[];
946
+ listing: ProductListingProjection;
947
+ };
948
+ declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
949
+ options: ProductOptionShape[];
950
+ variants?: TVariant[];
951
+ }): ProductOptionMatrix<TVariant>;
952
+ declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
953
+ declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
954
+ declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
955
+ declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
956
+ declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
957
+ /**
958
+ * Builds product-first listing groups for one primary option.
959
+ *
960
+ * The returned groups are intended for product cards with nested swatches or
961
+ * option-value sections. They do not make a product-paginated API response into
962
+ * an expanded-card paginator; one product can still emit several groups.
963
+ */
964
+ declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
965
+ product: ProductListingProductShape | null | undefined;
966
+ options: ProductOptionShape[];
967
+ variants: TVariant[];
968
+ primaryOptionId?: string | null;
969
+ }): ProductListingGroup<TVariant>[];
970
+
971
+ type ProductApiOptions = ServerApiOptions;
972
+ type StockCheckParams = {
973
+ items: Array<{
974
+ variantId: string;
975
+ quantity: number;
976
+ }>;
977
+ };
978
+ type StockCheckResult = {
979
+ variantId: string;
980
+ available: boolean;
981
+ availableStock: number;
982
+ requestedQuantity: number;
983
+ error?: string;
984
+ };
985
+ type StockCheckResponse = {
986
+ results: StockCheckResult[];
987
+ allAvailable: boolean;
988
+ };
989
+ type ListingGroupsParams = {
990
+ productIds: string[];
991
+ };
992
+ type ProductListingGroupSummary = Omit<ProductListingGroup, 'variants'>;
993
+ type ProductListingGroupsItem = {
994
+ product: Product;
995
+ primaryOptionId: string | null;
996
+ groups: ProductListingGroupSummary[];
997
+ };
998
+ type ProductListingGroupsResponse = {
999
+ docs: ProductListingGroupsItem[];
1000
+ };
1001
+ declare class ProductApi extends BaseApi {
1002
+ constructor(options: ProductApiOptions);
1003
+ /**
1004
+ * Check point-in-time stock availability for one or more product variants.
1005
+ * Results reflect available stock at the moment of the call and are not guaranteed
1006
+ * to remain available by the time an order is placed.
1007
+ */
1008
+ stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
1009
+ listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
1010
+ }
1011
+
1012
+ type DiscountApiOptions = ServerApiOptions;
1013
+ type ValidateDiscountParams = {
1014
+ code: string;
1015
+ orderAmount: number;
1016
+ };
1017
+ type ValidateDiscountResult = {
1018
+ valid: boolean;
1019
+ code: string;
1020
+ type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
1021
+ discountAmount: number;
1022
+ freeShipping?: boolean;
1023
+ reason?: string;
1024
+ };
1025
+ declare class DiscountApi extends BaseApi {
1026
+ constructor(options: DiscountApiOptions);
1027
+ validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
1028
+ }
1029
+
1030
+ type ShippingApiOptions = ServerApiOptions;
1031
+ type CalculateShippingParams = {
1032
+ shippingPolicyId?: string;
1033
+ orderAmount: number;
1034
+ postalCode?: string;
1035
+ };
1036
+ type CalculateShippingResult = {
1037
+ shippingAmount: number;
1038
+ baseShippingAmount: number;
1039
+ extraShippingAmount: number;
1040
+ freeShipping: boolean;
1041
+ freeShippingMinAmount: number | null;
1042
+ isJeju: boolean;
1043
+ isRemoteIsland: boolean;
1044
+ };
1045
+ declare class ShippingApi extends BaseApi {
1046
+ constructor(options: ShippingApiOptions);
1047
+ calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
1048
+ }
1049
+
1050
+ type OrderApiOptions = ServerApiOptions;
1051
+ type CustomerSnapshot = {
1052
+ name?: string;
1053
+ email: string;
1054
+ phone?: string;
1055
+ };
1056
+ type ReturnReason = 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
1057
+ type ReturnItem = {
1058
+ orderItem: string;
1059
+ quantity: number;
1060
+ };
1061
+ type CreateOrderParams = {
1062
+ orderNumber: string;
1063
+ customer?: string;
1064
+ customerSnapshot: CustomerSnapshot;
1065
+ shippingAddress: Order['shippingAddress'];
1066
+ orderItems: Pick<OrderItem, 'product' | 'variant' | 'quantity' | 'unitPrice' | 'totalPrice'>[];
1067
+ totalAmount: number;
1068
+ shippingAmount?: number;
1069
+ pgPaymentId?: string;
1070
+ discountCode?: string;
1071
+ };
1072
+ type UpdateOrderParams = {
1073
+ orderNumber: string;
1074
+ status: Order['status'];
1075
+ };
1076
+ type TransactionStatus = 'pending' | 'paid' | 'failed' | 'canceled';
1077
+ type UpdateTransactionParams = {
1078
+ pgPaymentId: string;
1079
+ status: TransactionStatus;
1080
+ paymentMethod?: string;
1081
+ receiptUrl?: string;
1082
+ paymentKey?: string;
1083
+ amount?: number;
1084
+ };
1085
+ type RestockAction = 'return_to_stock' | 'discard';
1086
+ type ReturnWithRefundItem = {
1087
+ orderItem: string | number;
1088
+ quantity: number;
1089
+ restockAction?: RestockAction;
1090
+ };
1091
+ type ReturnWithRefundParams = {
1092
+ orderNumber: string;
1093
+ reason?: ReturnReason;
1094
+ reasonDetail?: string;
1095
+ returnItems: ReturnWithRefundItem[];
1096
+ refundAmount: number;
1097
+ pgPaymentId: string;
1098
+ paymentKey?: string;
1099
+ refundReceiptUrl?: string;
1100
+ };
1101
+ type CheckoutParams = {
1102
+ cartId: string;
1103
+ orderNumber: string;
1104
+ customerSnapshot: CustomerSnapshot;
1105
+ pgPaymentId?: string;
1106
+ discountCode?: string;
1107
+ };
1108
+ type CreateFulfillmentParams = {
1109
+ orderNumber: string;
1110
+ carrier?: string;
1111
+ trackingNumber?: string;
1112
+ items: Array<{
1113
+ orderItem: string;
1114
+ quantity: number;
1115
+ }>;
1116
+ };
1117
+ type UpdateFulfillmentParams = {
1118
+ fulfillmentId: string;
1119
+ status: 'packed' | 'shipped' | 'delivered' | 'failed';
1120
+ carrier?: string;
1121
+ trackingNumber?: string;
1122
+ };
1123
+ type BulkImportFulfillmentsParams = {
1124
+ items: Array<{
1125
+ orderNumber: string;
1126
+ carrier?: string;
1127
+ trackingNumber?: string;
1128
+ }>;
1129
+ };
1130
+ type BulkImportFulfillmentsResponse = {
1131
+ succeeded: Array<{
1132
+ orderNumber: string;
1133
+ fulfillmentId: string;
1134
+ }>;
1135
+ failed: Array<{
1136
+ orderNumber: string;
1137
+ error: string;
1138
+ }>;
1139
+ };
1140
+ type CreateReturnParams = {
1141
+ orderNumber: string;
1142
+ reason?: ReturnReason;
1143
+ reasonDetail?: string;
1144
+ returnItems: ReturnItem[];
1145
+ refundAmount: number;
1146
+ };
1147
+ type UpdateReturnParams = {
1148
+ returnId: string;
1149
+ status: 'processing' | 'approved' | 'rejected' | 'completed';
1150
+ };
1151
+ declare class OrderApi extends BaseApi {
1152
+ constructor(options: OrderApiOptions);
1153
+ createOrder(params: CreateOrderParams): Promise<Order>;
1154
+ updateOrder(params: UpdateOrderParams): Promise<Order>;
1155
+ updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
1156
+ checkout(params: CheckoutParams): Promise<Order>;
1157
+ createFulfillment(params: CreateFulfillmentParams): Promise<Fulfillment>;
1158
+ updateFulfillment(params: UpdateFulfillmentParams): Promise<Fulfillment>;
1159
+ bulkImportFulfillments(params: BulkImportFulfillmentsParams): Promise<BulkImportFulfillmentsResponse>;
1160
+ returnWithRefund(params: ReturnWithRefundParams): Promise<{
1161
+ return: Return;
1162
+ transaction: Transaction | null;
1163
+ }>;
1164
+ createReturn(params: CreateReturnParams): Promise<Return>;
1165
+ updateReturn(params: UpdateReturnParams): Promise<Return>;
1166
+ }
1167
+
1168
+ interface ServerCommerceClientOptions {
1169
+ publishableKey?: string;
1170
+ secretKey: string;
1171
+ onRequestId?: (id: string | null) => void;
1172
+ }
1173
+ declare class ServerCommerceClient {
1174
+ readonly product: {
1175
+ stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1176
+ listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1177
+ };
1178
+ readonly cart: {
1179
+ get: (cartId: string) => Promise<Cart>;
1180
+ addItem: (params: AddItemParams) => Promise<CartItem>;
1181
+ updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1182
+ removeItem: (params: RemoveItemParams) => Promise<{
1183
+ success: boolean;
1184
+ }>;
1185
+ applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1186
+ removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1187
+ clear: (params: ClearCartParams) => Promise<{
1188
+ success: boolean;
1189
+ }>;
1190
+ };
1191
+ readonly orders: {
1192
+ checkout: (params: CheckoutParams) => Promise<Order>;
1193
+ create: (params: CreateOrderParams) => Promise<Order>;
1194
+ update: (params: UpdateOrderParams) => Promise<Order>;
1195
+ updateTransaction: (params: UpdateTransactionParams) => Promise<Transaction>;
1196
+ createFulfillment: (params: CreateFulfillmentParams) => Promise<Fulfillment>;
1197
+ updateFulfillment: (params: UpdateFulfillmentParams) => Promise<Fulfillment>;
1198
+ bulkImportFulfillments: (params: BulkImportFulfillmentsParams) => Promise<BulkImportFulfillmentsResponse>;
1199
+ createReturn: (params: CreateReturnParams) => Promise<Return>;
1200
+ updateReturn: (params: UpdateReturnParams) => Promise<Return>;
1201
+ returnWithRefund: (params: ReturnWithRefundParams) => Promise<{
1202
+ return: Return;
1203
+ transaction: Transaction | null;
1204
+ }>;
1205
+ };
1206
+ readonly discounts: {
1207
+ validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
1208
+ };
1209
+ readonly shipping: {
1210
+ calculate: (params: CalculateShippingParams) => Promise<CalculateShippingResult>;
1211
+ };
1212
+ constructor(options: ServerCommerceClientOptions);
1213
+ }
1214
+
1215
+ interface CollectionQueryParams<T extends PublicCollection> {
1216
+ collection: T;
1217
+ options?: ApiQueryOptions;
1218
+ }
1219
+ interface CollectionDetailQueryParams<T extends PublicCollection> {
1220
+ collection: T;
1221
+ id: string;
1222
+ options?: ApiQueryOptions;
1223
+ }
1224
+ interface CollectionInfiniteQueryParams<T extends PublicCollection> {
1225
+ collection: T;
1226
+ options?: Omit<ApiQueryOptions, 'page'>;
1227
+ pageSize?: number;
1228
+ }
1229
+ interface QueryOptions<TQueryFnData = unknown, TData = TQueryFnData> {
1230
+ enabled?: boolean;
1231
+ staleTime?: number;
1232
+ gcTime?: number;
1233
+ refetchOnWindowFocus?: boolean;
1234
+ refetchOnMount?: boolean | 'always';
1235
+ refetchInterval?: number | false;
1236
+ retry?: boolean | number;
1237
+ select?: (data: TQueryFnData) => TData;
1238
+ placeholderData?: TQueryFnData | ((previousData: TData | undefined) => TQueryFnData | undefined);
1239
+ initialData?: TQueryFnData | (() => TQueryFnData);
1240
+ initialDataUpdatedAt?: number | (() => number | undefined);
1241
+ }
1242
+ type SuspenseQueryOptions<TQueryFnData = unknown, TData = TQueryFnData> = Omit<QueryOptions<TQueryFnData, TData>, 'enabled' | 'placeholderData'>;
1243
+ interface InfiniteQueryOptions<TQueryFnData = unknown, TData = InfiniteData<TQueryFnData>> {
1244
+ enabled?: boolean;
1245
+ staleTime?: number;
1246
+ gcTime?: number;
1247
+ refetchOnWindowFocus?: boolean;
1248
+ refetchOnMount?: boolean | 'always';
1249
+ refetchInterval?: number | false;
1250
+ retry?: boolean | number;
1251
+ select?: (data: InfiniteData<TQueryFnData>) => TData;
1252
+ }
1253
+ type SuspenseInfiniteQueryOptions<TQueryFnData = unknown, TData = InfiniteData<TQueryFnData>> = Omit<InfiniteQueryOptions<TQueryFnData, TData>, 'enabled'>;
1254
+ interface MutationCallbacks$1<TData> {
1255
+ onSuccess?: (data: TData) => void;
1256
+ onError?: (error: SDKError) => void;
1257
+ onSettled?: () => void;
1258
+ }
1259
+ declare class CollectionHooks {
1260
+ protected queryClient: QueryClient;
1261
+ protected collectionClient: CollectionClient;
1262
+ constructor(queryClient: QueryClient, collectionClient: CollectionClient);
1263
+ 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>;
1264
+ useSuspenseQuery<T extends PublicCollection, TData = PayloadFindResponse<CollectionType<T>>>(params: CollectionQueryParams<T>, options?: SuspenseQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1265
+ 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>;
1266
+ useSuspenseQueryById<T extends PublicCollection, TData = CollectionType<T>>(params: CollectionDetailQueryParams<T>, options?: SuspenseQueryOptions<CollectionType<T>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1267
+ useInfiniteQuery<T extends PublicCollection, TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>>(params: CollectionInfiniteQueryParams<T>, options?: InfiniteQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseInfiniteQueryResult<TData, Error>;
1268
+ useSuspenseInfiniteQuery<T extends PublicCollection, TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>>(params: CollectionInfiniteQueryParams<T>, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseSuspenseInfiniteQueryResult<TData, Error>;
1269
+ prefetchQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
1270
+ staleTime?: number;
1271
+ }): Promise<void>;
1272
+ prefetchQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
1273
+ staleTime?: number;
1274
+ }): Promise<void>;
1275
+ prefetchInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
1276
+ pages?: number;
1277
+ staleTime?: number;
1278
+ }): Promise<void>;
1279
+ useCreate<T extends PublicCollection>(params: {
1280
+ collection: T;
1281
+ }, options?: MutationCallbacks$1<PayloadMutationResponse<CollectionType<T>>>): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, SDKError, {
1282
+ data: Partial<CollectionType<T>>;
1283
+ file?: File | Blob;
1284
+ filename?: string;
1285
+ }, unknown>;
1286
+ useUpdate<T extends PublicCollection>(params: {
1287
+ collection: T;
1288
+ }, options?: MutationCallbacks$1<PayloadMutationResponse<CollectionType<T>>>): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, SDKError, {
1289
+ id: string;
1290
+ data: Partial<CollectionType<T>>;
1291
+ file?: File | Blob;
1292
+ filename?: string;
1293
+ }, unknown>;
1294
+ useRemove<T extends PublicCollection>(params: {
1295
+ collection: T;
1296
+ }, options?: MutationCallbacks$1<CollectionType<T>>): _tanstack_react_query.UseMutationResult<CollectionType<T>, SDKError, string, unknown>;
1297
+ invalidateQueries<T extends PublicCollection>(collection: T, type?: 'list' | 'detail' | 'infinite'): Promise<void>;
1298
+ getQueryData<T extends PublicCollection>(collection: T, type: 'list', options?: ApiQueryOptions): PayloadFindResponse<CollectionType<T>> | undefined;
1299
+ getQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string, options?: ApiQueryOptions): CollectionType<T> | null | undefined;
1300
+ setQueryData<T extends PublicCollection>(collection: T, type: 'list', data: PayloadFindResponse<CollectionType<T>>, options?: ApiQueryOptions): void;
1301
+ setQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
1302
+ }
1303
+
1304
+ interface MutationCallbacks<TData> {
1305
+ onSuccess?: (data: TData) => void;
1306
+ onError?: (error: SDKError) => void;
1307
+ onSettled?: () => void;
1308
+ }
1309
+ declare class CustomerHooks {
1310
+ private queryClient;
1311
+ private customerAuth?;
1312
+ constructor(queryClient: QueryClient, customerAuth?: CustomerAuth);
1313
+ private ensureCustomerAuth;
1314
+ private invalidateMe;
1315
+ useCustomerMe(options?: {
1316
+ enabled?: boolean;
1317
+ staleTime?: number;
1318
+ gcTime?: number;
1319
+ refetchOnWindowFocus?: boolean;
1320
+ refetchOnMount?: boolean | 'always';
1321
+ refetchInterval?: number | false;
1322
+ retry?: boolean | number;
1323
+ }): _tanstack_react_query.UseQueryResult<CustomerProfile | null, Error>;
1324
+ useCustomerLogin(options?: MutationCallbacks<CustomerAuthResponse>): _tanstack_react_query.UseMutationResult<CustomerAuthResponse, SDKError, CustomerLoginData, unknown>;
1325
+ useCustomerRegister(options?: MutationCallbacks<{
1326
+ customer: CustomerProfile;
1327
+ }>): _tanstack_react_query.UseMutationResult<CustomerRegisterResponse, SDKError, CustomerRegisterData, unknown>;
1328
+ useCustomerLogout(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, void, unknown>;
1329
+ useCustomerForgotPassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, string, unknown>;
1330
+ useCustomerResetPassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, {
1331
+ token: string;
1332
+ password: string;
1333
+ }, unknown>;
1334
+ useCustomerRefreshToken(options?: MutationCallbacks<CustomerRefreshResponse>): _tanstack_react_query.UseMutationResult<CustomerRefreshResponse, SDKError, unknown, unknown>;
1335
+ useCustomerUpdateProfile(options?: MutationCallbacks<CustomerProfile>): _tanstack_react_query.UseMutationResult<CustomerProfile, SDKError, UpdateProfileData, unknown>;
1336
+ useCustomerChangePassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, {
1337
+ currentPassword: string;
1338
+ newPassword: string;
1339
+ }, unknown>;
1340
+ invalidateCustomerQueries(): Promise<void>;
1341
+ getCustomerData(): CustomerProfile | null | undefined;
1342
+ setCustomerData(data: CustomerProfile | null): void;
1343
+ }
1344
+
1345
+ type ProductListingGroupsQueryOptions = Pick<ApiQueryOptions, 'page' | 'limit' | 'sort' | 'where'>;
1346
+ type ReadOnlyQueryHooks = Omit<QueryHooks, 'useCreate' | 'useUpdate' | 'useRemove'>;
1347
+ /**
1348
+ * Composes CollectionHooks + CustomerHooks into a single API surface.
1349
+ * All methods are delegated; no logic lives here.
1350
+ */
1351
+ declare class QueryHooks extends CollectionHooks {
1352
+ private _customer;
1353
+ constructor(queryClient: QueryClient, collectionClient: CollectionClient, customerAuth?: CustomerAuth);
1354
+ useCustomerMe: CustomerHooks['useCustomerMe'];
1355
+ useCustomerLogin: CustomerHooks['useCustomerLogin'];
1356
+ useCustomerRegister: CustomerHooks['useCustomerRegister'];
1357
+ useCustomerLogout: CustomerHooks['useCustomerLogout'];
1358
+ useCustomerForgotPassword: CustomerHooks['useCustomerForgotPassword'];
1359
+ useCustomerResetPassword: CustomerHooks['useCustomerResetPassword'];
1360
+ useCustomerRefreshToken: CustomerHooks['useCustomerRefreshToken'];
1361
+ useCustomerUpdateProfile: CustomerHooks['useCustomerUpdateProfile'];
1362
+ useCustomerChangePassword: CustomerHooks['useCustomerChangePassword'];
1363
+ invalidateCustomerQueries: CustomerHooks['invalidateCustomerQueries'];
1364
+ getCustomerData: CustomerHooks['getCustomerData'];
1365
+ setCustomerData: CustomerHooks['setCustomerData'];
1366
+ useProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
1367
+ options?: ProductListingGroupsQueryOptions;
1368
+ }, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
1369
+ useSuspenseProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
1370
+ options?: ProductListingGroupsQueryOptions;
1371
+ }, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1372
+ useInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
1373
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1374
+ pageSize?: number;
1375
+ }, options?: InfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseInfiniteQueryResult<TData, Error>;
1376
+ useSuspenseInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
1377
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1378
+ pageSize?: number;
1379
+ }, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseInfiniteQueryResult<TData, Error>;
1380
+ prefetchProductListingGroupsQuery(params: {
1381
+ options?: ProductListingGroupsQueryOptions;
1382
+ }, options?: {
1383
+ staleTime?: number;
1384
+ }): Promise<void>;
1385
+ prefetchInfiniteProductListingGroupsQuery(params: {
1386
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1387
+ pageSize?: number;
1388
+ }, options?: {
1389
+ pages?: number;
1390
+ staleTime?: number;
1391
+ }): Promise<void>;
1392
+ }
1393
+
1394
+ declare class ServerClient {
1395
+ commerce: ServerCommerceClient;
1396
+ community: CommunityClient & {
1397
+ moderation: {
1398
+ banCustomer: (p: BanCustomerParams) => Promise<CommunityBan>;
1399
+ unbanCustomer: (p: UnbanCustomerParams) => Promise<{
1400
+ success: true;
1401
+ }>;
1402
+ };
1403
+ };
1404
+ query: QueryHooks;
1405
+ collections: ServerCollectionClient;
1406
+ queryClient: QueryClient;
1407
+ lastRequestId: string | null;
1408
+ protected state: ClientState;
1409
+ protected config: ClientServerConfig;
1410
+ constructor(options: ClientServerConfig);
1411
+ getState(): ClientState;
1412
+ getConfig(): Omit<ClientServerConfig, 'secretKey'>;
1413
+ }
1414
+ /**
1415
+ * Create a server-only client with full read/write access. Requires secretKey.
1416
+ * For read-only usage, prefer `createClient()` (no secretKey needed).
1417
+ */
1418
+ declare function createServerClient(options: ClientServerConfig): ServerClient;
1419
+
1420
+ 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 CustomerRegisterData 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, ServerCollectionQueryBuilder as aJ, type ReadOnlyQueryBuilder as aK, CollectionClient as aL, ServerCollectionClient as aM, type GenerateMetadataOptions as aN, ServerCommerceClient as aO, type ServerCommerceClientOptions as aP, type CommunityClientOptions as aQ, type CommunityPost as aR, ModerationApi as aS, type ModerationApiOptions as aT, type CommunityBan as aU, type BanCustomerParams as aV, type UnbanCustomerParams as aW, type CustomerAuthResponse as aX, type CustomerRefreshResponse as aY, type CustomerRegisterResponse as aZ, type CustomerProfile 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 CustomerLoginData as b0, type UpdateProfileData as b1, type CollectionQueryParams as b2, type CollectionDetailQueryParams as b3, type CollectionInfiniteQueryParams as b4, type QueryOptions as b5, type SuspenseQueryOptions as b6, type InfiniteQueryOptions as b7, type SuspenseInfiniteQueryOptions as b8, CollectionHooks as b9, CustomerHooks as ba, QueryHooks as bb, type ProductOptionValueShape as bc, type ProductOptionShape as bd, type ProductVariantShape as be, type ProductListingProductShape as bf, type ProductOptionMatrixValue as bg, type ProductOptionMatrixOption as bh, type ProductOptionMatrixVariant as bi, type ProductOptionMatrix as bj, type ProductListingProjection as bk, type ProductListingGroup as bl, buildProductOptionMatrix as bm, getSelectedValueByOptionId as bn, normalizeSelectedValueIds as bo, getAvailableOptionValues as bp, resolveVariantForSelection as bq, buildProductListingProjection as br, buildProductListingGroupsByOption as bs, 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 };