@01.software/sdk 0.12.0 → 0.13.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.
Files changed (38) hide show
  1. package/README.md +94 -57
  2. package/dist/{const-CWbOFesW.d.ts → const-DSTPrI77.d.ts} +1 -1
  3. package/dist/{const-DBZBjsZH.d.cts → const-DqcpKgSA.d.cts} +1 -1
  4. package/dist/index.cjs +794 -504
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +639 -439
  7. package/dist/index.d.ts +639 -439
  8. package/dist/index.js +794 -504
  9. package/dist/index.js.map +1 -1
  10. package/dist/{payload-types-BX9al1wy.d.cts → payload-types-DqX4iuTW.d.cts} +5 -1
  11. package/dist/{payload-types-BX9al1wy.d.ts → payload-types-DqX4iuTW.d.ts} +5 -1
  12. package/dist/realtime.cjs.map +1 -1
  13. package/dist/realtime.d.cts +2 -2
  14. package/dist/realtime.d.ts +2 -2
  15. package/dist/realtime.js.map +1 -1
  16. package/dist/{server-JR9TvKZ5.d.cts → server-DLdbWJVv.d.cts} +5 -3
  17. package/dist/{server-JR9TvKZ5.d.ts → server-DLdbWJVv.d.ts} +5 -3
  18. package/dist/ui/canvas/server.cjs +4 -4
  19. package/dist/ui/canvas/server.cjs.map +1 -1
  20. package/dist/ui/canvas/server.d.cts +1 -1
  21. package/dist/ui/canvas/server.d.ts +1 -1
  22. package/dist/ui/canvas/server.js +4 -4
  23. package/dist/ui/canvas/server.js.map +1 -1
  24. package/dist/ui/canvas.cjs +4 -4
  25. package/dist/ui/canvas.cjs.map +1 -1
  26. package/dist/ui/canvas.d.cts +2 -2
  27. package/dist/ui/canvas.d.ts +2 -2
  28. package/dist/ui/canvas.js +4 -4
  29. package/dist/ui/canvas.js.map +1 -1
  30. package/dist/ui/form.d.cts +1 -1
  31. package/dist/ui/form.d.ts +1 -1
  32. package/dist/ui/video.d.cts +1 -1
  33. package/dist/ui/video.d.ts +1 -1
  34. package/dist/{webhook-I-iZO5-K.d.ts → webhook-CX21PpBt.d.ts} +2 -2
  35. package/dist/{webhook-Bqek9sBP.d.cts → webhook-mXjcW86I.d.cts} +2 -2
  36. package/dist/webhook.d.cts +3 -3
  37. package/dist/webhook.d.ts +3 -3
  38. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,22 +1,17 @@
1
- import { O as Order, a as OrderItem$1, T as Transaction, b as Fulfillment, R as Return, c as Cart, d as CartItem, P as Product } from './payload-types-BX9al1wy.js';
2
- export { D as Document, I as Image, e as Post, f as PostCategory, g as PostTag, h as ProductVariant, i as Tenant, V as Video } from './payload-types-BX9al1wy.js';
1
+ import { O as Order, a as Cart, b as CartItem, P as Product, c as OrderItem$1, T as Transaction, d as Fulfillment, R as Return } from './payload-types-DqX4iuTW.js';
2
+ export { D as Document, I as Image, e as Post, f as PostCategory, g as PostTag, h as ProductVariant, i as Tenant, V as Video } from './payload-types-DqX4iuTW.js';
3
3
  import { Sort, Where } from 'payload';
4
4
  import * as _tanstack_react_query from '@tanstack/react-query';
5
5
  import { QueryClient, InfiniteData } from '@tanstack/react-query';
6
6
  import { Metadata } from 'next';
7
- import { P as PublicCollection } from './const-CWbOFesW.js';
8
- export { a as COLLECTIONS, C as Collection } from './const-CWbOFesW.js';
9
- import { C as CollectionType } from './webhook-I-iZO5-K.js';
10
- export { a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, d as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-I-iZO5-K.js';
7
+ import { C as CollectionType } from './webhook-CX21PpBt.js';
8
+ export { a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, d as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-CX21PpBt.js';
9
+ import { P as PublicCollection } from './const-DSTPrI77.js';
10
+ export { a as COLLECTIONS, C as Collection } from './const-DSTPrI77.js';
11
11
  export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.js';
12
12
  export { b as IMAGE_SIZES, I as ImageData, a as ImagePalette, f as ImagePlaceholderOptions, d as getImageLqip, e as getImagePalette, h as getImagePlaceholderStyle, c as getImageSrcSet, g as getImageUrl } from './image-TT8lTsk5.js';
13
13
  export { e as VideoGifOptions, V as VideoThumbnailOptions, a as getVideoGif, c as getVideoMp4Url, d as getVideoStoryboard, b as getVideoStreamUrl, g as getVideoThumbnail } from './video-DbLL8yuc.js';
14
14
 
15
- /**
16
- * API URL을 반환합니다.
17
- * 환경변수 SOFTWARE_API_URL 또는 NEXT_PUBLIC_SOFTWARE_API_URL로 오버라이드 가능.
18
- * 빌드 시 버전에 따라 기본값 결정: dev 빌드 → api-dev, 정식 → api.01.software
19
- */
20
15
  declare function resolveApiUrl(): string;
21
16
  interface ClientConfig {
22
17
  publishableKey: string;
@@ -43,6 +38,13 @@ interface ClientConfig {
43
38
  }
44
39
  interface ClientServerConfig extends ClientConfig {
45
40
  secretKey: string;
41
+ /**
42
+ * Tenant ID for pat01_ API keys. When provided alongside a pat01_ key,
43
+ * every server request includes X-Tenant-Id so the API can scope the
44
+ * request to the correct tenant. Not needed for sk01_ keys (tenant is
45
+ * encoded in the key itself).
46
+ */
47
+ tenantId?: string;
46
48
  }
47
49
  interface ClientMetadata {
48
50
  userAgent?: string;
@@ -88,6 +90,13 @@ interface PayloadMutationResponse<T = unknown> {
88
90
  doc: T;
89
91
  errors?: unknown[];
90
92
  }
93
+ /**
94
+ * Do NOT replace with `Pick<FindOptions>` from `payload`. Payload's generic
95
+ * types (`JoinQuery<TSlug>`, `PopulateType`) depend on `PayloadTypes` module
96
+ * augmentation; external SDK consumers who skip that get degenerate types
97
+ * (`never` / `{}`). Only non-generic `Sort`/`Where` are safe to import.
98
+ * Excluded vs native: Local-API-only fields, `locale`/`fallbackLocale`.
99
+ */
91
100
  interface ApiQueryOptions {
92
101
  page?: number;
93
102
  limit?: number;
@@ -105,6 +114,12 @@ interface ApiQueryOptions {
105
114
  where?: Where;
106
115
  count?: boolean;
107
116
  } | false> | false;
117
+ /** Set to `false` to skip the count query — returns docs without totalDocs/totalPages */
118
+ pagination?: boolean;
119
+ /** Include draft versions (access control still applies on the server) */
120
+ draft?: boolean;
121
+ /** Include soft-deleted documents (requires `trash` enabled on the collection) */
122
+ trash?: boolean;
108
123
  }
109
124
  interface DebugConfig {
110
125
  logRequests?: boolean;
@@ -121,357 +136,137 @@ type DeepPartial<T> = {
121
136
  };
122
137
  type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
123
138
 
124
- interface ServerApiOptions {
125
- publishableKey?: string;
126
- secretKey: string;
127
- }
128
- interface RequestOptions {
129
- method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
130
- headers?: Record<string, string>;
131
- }
132
- declare abstract class BaseApi {
133
- protected readonly publishableKey: string;
134
- protected readonly secretKey: string;
135
- constructor(apiName: string, options: ServerApiOptions);
136
- protected request<T>(endpoint: string, body: unknown, options?: RequestOptions): Promise<T>;
137
- }
138
-
139
- type OrderApiOptions = ServerApiOptions;
140
- type CustomerSnapshot = {
141
- name?: string;
142
- email: string;
143
- phone?: string;
144
- };
145
- type ReturnReason = 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
146
- type ReturnProductItem = {
147
- orderItem: string;
148
- quantity: number;
149
- };
150
- type CreateOrderParams = {
151
- orderNumber: string;
152
- customer?: string;
153
- customerSnapshot: CustomerSnapshot;
154
- shippingAddress: Order['shippingAddress'];
155
- orderProducts: Pick<OrderItem$1, 'product' | 'variant' | 'quantity' | 'unitPrice' | 'totalPrice'>[];
156
- totalAmount: number;
157
- shippingFee?: number;
158
- paymentId?: string;
159
- discountCode?: string;
160
- };
161
- type UpdateOrderParams = {
162
- orderNumber: string;
163
- status: Order['status'];
164
- };
165
- type UpdateTransactionParams = {
166
- paymentId: string;
167
- status: Transaction['status'];
168
- paymentMethod?: string;
169
- receiptUrl?: string;
170
- };
171
- type CheckoutParams = {
172
- cartId: string;
173
- orderNumber: string;
174
- customerSnapshot: CustomerSnapshot;
175
- paymentId?: string;
176
- discountCode?: string;
177
- };
178
- type ValidateDiscountParams = {
179
- code: string;
180
- orderAmount: number;
181
- customerId?: string;
182
- };
183
- type ValidateDiscountResult = {
184
- valid: boolean;
185
- code: string;
186
- type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
187
- discountAmount: number;
188
- freeShipping?: boolean;
189
- reason?: string;
190
- };
191
- type CalculateShippingParams = {
192
- shippingPolicyId?: string;
193
- orderAmount: number;
194
- postalCode?: string;
195
- };
196
- type CalculateShippingResult = {
197
- shippingFee: number;
198
- baseAmount: number;
199
- extraFee: number;
200
- freeShipping: boolean;
201
- freeShippingMinAmount: number | null;
202
- isJeju: boolean;
203
- isRemoteIsland: boolean;
204
- };
205
- type CreateFulfillmentParams = {
206
- orderNumber: string;
207
- carrier?: string;
208
- trackingNumber?: string;
209
- items: Array<{
210
- orderItem: string;
211
- quantity: number;
212
- }>;
213
- };
214
- type UpdateFulfillmentParams = {
215
- fulfillmentId: string;
216
- status: 'packed' | 'shipped' | 'delivered' | 'failed';
217
- carrier?: string;
218
- trackingNumber?: string;
219
- };
220
- type GetOrderParams = {
221
- orderNumber: string;
222
- };
223
- type CreateReturnParams = {
224
- orderNumber: string;
225
- reason?: ReturnReason;
226
- reasonDetail?: string;
227
- returnProducts: ReturnProductItem[];
228
- refundAmount: number;
229
- };
230
- type UpdateReturnParams = {
231
- returnId: string;
232
- status: 'processing' | 'approved' | 'rejected' | 'completed';
233
- };
234
- type ReturnWithRefundParams = {
235
- orderNumber: string;
236
- reason?: ReturnReason;
237
- reasonDetail?: string;
238
- returnProducts: ReturnProductItem[];
239
- refundAmount: number;
240
- paymentId: string;
241
- refundReceiptUrl?: string;
242
- };
243
- declare class OrderApi extends BaseApi {
244
- constructor(options: OrderApiOptions);
245
- createOrder(params: CreateOrderParams): Promise<Order>;
246
- updateOrder(params: UpdateOrderParams): Promise<Order>;
247
- getOrder(params: GetOrderParams): Promise<Order>;
248
- updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
249
- checkout(params: CheckoutParams): Promise<Order>;
250
- createFulfillment(params: CreateFulfillmentParams): Promise<Fulfillment>;
251
- updateFulfillment(params: UpdateFulfillmentParams): Promise<Fulfillment>;
252
- returnWithRefund(params: ReturnWithRefundParams): Promise<{
253
- return: Return;
254
- transaction: Transaction | null;
255
- }>;
256
- createReturn(params: CreateReturnParams): Promise<Return>;
257
- updateReturn(params: UpdateReturnParams): Promise<Return>;
258
- validateDiscount(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
259
- calculateShipping(params: CalculateShippingParams): Promise<CalculateShippingResult>;
260
- }
261
-
262
- interface CartApiOptions {
263
- publishableKey?: string;
264
- secretKey?: string;
265
- customerToken?: string | (() => string | null);
266
- onUnauthorized?: () => Promise<string | null>;
267
- }
268
- type AddItemParams = {
269
- cartId: string;
270
- product: string;
271
- variant: string;
272
- option: string;
273
- quantity: number;
274
- };
275
- type UpdateItemParams = {
276
- cartItemId: string;
277
- quantity: number;
278
- };
279
- type RemoveItemParams = {
280
- cartItemId: string;
281
- };
282
- type ApplyDiscountParams = {
283
- cartId: string;
284
- discountCode: string;
285
- };
286
- type RemoveDiscountParams = {
287
- cartId: string;
288
- };
289
- type ClearCartParams = {
290
- cartId: string;
291
- };
292
- declare class CartApi {
293
- private readonly publishableKey;
294
- private readonly secretKey?;
295
- private readonly customerToken?;
296
- private readonly onUnauthorized?;
297
- constructor(options: CartApiOptions);
298
- private execute;
299
- getCart(cartId: string): Promise<Cart>;
300
- addItem(params: AddItemParams): Promise<CartItem>;
301
- updateItem(params: UpdateItemParams): Promise<CartItem>;
302
- removeItem(params: RemoveItemParams): Promise<{
303
- success: boolean;
304
- }>;
305
- applyDiscount(params: ApplyDiscountParams): Promise<Cart>;
306
- removeDiscount(params: RemoveDiscountParams): Promise<Cart>;
307
- clearCart(params: ClearCartParams): Promise<{
308
- success: boolean;
309
- }>;
139
+ interface GenerateMetadataOptions {
140
+ siteName?: string;
310
141
  }
311
142
 
312
- type EntityID = string;
313
- type RelationshipValue = string | number | null | undefined | {
314
- id?: string | number | null;
315
- };
316
- type MediaValue = {
317
- id?: EntityID | null;
318
- } | EntityID | null | undefined;
319
- interface ProductOptionValueShape {
320
- id?: string | number | null;
321
- option?: RelationshipValue;
322
- value?: string | null;
323
- slug?: string | null;
324
- _order?: string | null;
325
- '_product-option-values_values_order'?: string | null;
326
- }
327
- interface ProductOptionShape {
328
- id?: string | number | null;
329
- title?: string | null;
330
- _order?: string | null;
331
- '_product-options_options_order'?: string | null;
332
- values?: {
333
- docs?: unknown[];
334
- } | null;
335
- }
336
- interface ProductVariantShape {
337
- id?: string | number | null;
338
- optionValues?: unknown[] | null;
339
- price?: number | null;
340
- compareAtPrice?: number | null;
341
- stock?: number | null;
342
- isUnlimited?: boolean | null;
343
- isActive?: boolean | null;
344
- thumbnail?: MediaValue;
345
- images?: MediaValue[] | null;
346
- _order?: string | null;
347
- }
348
- interface ProductListingProductShape {
349
- id?: EntityID;
350
- thumbnail?: MediaValue;
351
- images?: MediaValue[] | null;
352
- }
353
- type ProductOptionMatrixValue = {
354
- id: string;
355
- optionId: string;
356
- label: string;
357
- slug: string | null;
358
- order: string;
359
- };
360
- type ProductOptionMatrixOption = {
361
- id: string;
362
- title: string;
363
- order: string;
364
- values: ProductOptionMatrixValue[];
365
- };
366
- type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVariantShape> = {
367
- id: string;
368
- optionValueIds: string[];
369
- optionValueByOptionId: Map<string, string>;
370
- source: TVariant;
371
- };
372
- type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
373
- options: ProductOptionMatrixOption[];
374
- optionIds: string[];
375
- optionById: Map<string, ProductOptionMatrixOption>;
376
- valueById: Map<string, ProductOptionMatrixValue>;
377
- valueToOptionId: Map<string, string>;
378
- variants: ProductOptionMatrixVariant<TVariant>[];
379
- };
380
- type ProductListingProjection = {
381
- selectionHintVariant: EntityID | null;
382
- primaryImage: EntityID | null;
383
- minPrice: number | null;
384
- maxPrice: number | null;
385
- minCompareAtPrice: number | null;
386
- maxCompareAtPrice: number | null;
387
- isPriceRange: boolean;
388
- availableForSale: boolean;
389
- };
390
- type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantShape> = {
391
- optionId: EntityID;
392
- optionTitle: string;
393
- optionValueId: EntityID;
394
- optionValueLabel: string;
395
- optionValueSlug: string | null;
396
- variantIds: EntityID[];
397
- variantCount: number;
398
- variants: TVariant[];
399
- listing: ProductListingProjection;
400
- };
401
- declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
402
- options: ProductOptionShape[];
403
- variants?: TVariant[];
404
- }): ProductOptionMatrix<TVariant>;
405
- declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
406
- declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
407
- declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
408
- declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
409
- declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
410
- declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
411
- product: ProductListingProductShape | null | undefined;
412
- options: ProductOptionShape[];
413
- variants: TVariant[];
414
- primaryOptionId?: string | null;
415
- }): ProductListingGroup<TVariant>[];
416
-
417
- type ProductApiOptions = ServerApiOptions;
418
- type StockCheckParams = {
419
- items: Array<{
420
- variantId: string;
421
- quantity: number;
422
- }>;
423
- };
424
- type StockCheckResult = {
425
- variantId: string;
426
- available: boolean;
427
- availableStock: number;
428
- requestedQuantity: number;
429
- error?: string;
430
- };
431
- type StockCheckResponse = {
432
- results: StockCheckResult[];
433
- allAvailable: boolean;
434
- };
435
- type ListingGroupsParams = {
436
- productIds: string[];
437
- };
438
- type ProductListingGroupSummary = Omit<ProductListingGroup, 'variants'>;
439
- type ProductListingGroupsItem = {
440
- product: Product;
441
- primaryOptionId: string | null;
442
- groups: ProductListingGroupSummary[];
443
- };
444
- type ProductListingGroupsResponse = {
445
- docs: ProductListingGroupsItem[];
446
- };
447
- declare class ProductApi extends BaseApi {
448
- constructor(options: ProductApiOptions);
449
- stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
450
- listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
143
+ declare class SDKError extends Error {
144
+ readonly code: string;
145
+ readonly status?: number;
146
+ readonly details?: unknown;
147
+ readonly userMessage?: string;
148
+ readonly suggestion?: string;
149
+ readonly requestId?: string;
150
+ constructor(code: string, message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
151
+ getUserMessage(): string;
152
+ toJSON(): {
153
+ requestId?: string | undefined;
154
+ name: string;
155
+ code: string;
156
+ message: string;
157
+ status: number | undefined;
158
+ details: unknown;
159
+ userMessage: string | undefined;
160
+ suggestion: string | undefined;
161
+ };
451
162
  }
452
-
453
- interface GenerateMetadataOptions {
454
- siteName?: string;
163
+ declare class NetworkError extends SDKError {
164
+ constructor(message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
165
+ }
166
+ declare class ValidationError extends SDKError {
167
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
168
+ }
169
+ declare class ApiError extends SDKError {
170
+ constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string);
171
+ }
172
+ declare class ConfigError extends SDKError {
173
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
174
+ }
175
+ declare class TimeoutError extends SDKError {
176
+ constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
177
+ }
178
+ declare class GoneError extends SDKError {
179
+ constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
180
+ }
181
+ declare class ServiceUnavailableError extends SDKError {
182
+ readonly retryAfter?: number;
183
+ constructor(message?: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string);
184
+ }
185
+ declare class UsageLimitError extends SDKError {
186
+ readonly usage: {
187
+ limit: number;
188
+ current: number;
189
+ remaining: number;
190
+ };
191
+ constructor(message: string, usage: {
192
+ limit: number;
193
+ current: number;
194
+ remaining: number;
195
+ }, details?: unknown, userMessage?: string, suggestion?: string);
196
+ toJSON(): {
197
+ usage: {
198
+ limit: number;
199
+ current: number;
200
+ remaining: number;
201
+ };
202
+ requestId?: string | undefined;
203
+ name: string;
204
+ code: string;
205
+ message: string;
206
+ status: number | undefined;
207
+ details: unknown;
208
+ userMessage: string | undefined;
209
+ suggestion: string | undefined;
210
+ };
211
+ }
212
+ declare class AuthError extends SDKError {
213
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
455
214
  }
215
+ declare class PermissionError extends SDKError {
216
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
217
+ }
218
+ declare class NotFoundError extends SDKError {
219
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
220
+ }
221
+ declare class ConflictError extends SDKError {
222
+ constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
223
+ }
224
+ declare class RateLimitError extends SDKError {
225
+ readonly retryAfter?: number;
226
+ constructor(message: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
227
+ }
228
+ declare function isSDKError(error: unknown): error is SDKError;
229
+ declare function isNetworkError(error: unknown): error is NetworkError;
230
+ declare function isValidationError(error: unknown): error is ValidationError;
231
+ declare function isApiError(error: unknown): error is ApiError;
232
+ declare function isConfigError(error: unknown): error is ConfigError;
233
+ declare function isTimeoutError(error: unknown): error is TimeoutError;
234
+ declare function isGoneError(error: unknown): error is GoneError;
235
+ declare function isServiceUnavailableError(error: unknown): error is ServiceUnavailableError;
236
+ declare function isUsageLimitError(error: unknown): error is UsageLimitError;
237
+ declare function isAuthError(error: unknown): error is AuthError;
238
+ declare function isPermissionError(error: unknown): error is PermissionError;
239
+ declare function isNotFoundError(error: unknown): error is NotFoundError;
240
+ declare function isConflictError(error: unknown): error is ConflictError;
241
+ declare function isRateLimitError(error: unknown): error is RateLimitError;
242
+ declare const createAuthError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => AuthError;
243
+ declare const createPermissionError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => PermissionError;
244
+ declare const createNotFoundError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => NotFoundError;
245
+ declare const createConflictError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => ConflictError;
246
+ declare const createRateLimitError: (message: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => RateLimitError;
456
247
 
457
248
  interface FetchOptions extends RequestInit {
458
249
  publishableKey?: string;
459
250
  secretKey?: string;
460
251
  customerToken?: string;
252
+ tenantId?: string;
461
253
  timeout?: number;
462
254
  debug?: boolean | DebugConfig;
463
255
  retry?: RetryConfig;
464
- /** Called on 401 when customerToken is set. Return a new token to retry, or null to fail. */
256
+ /** Called on 401 when customerToken is set and reason=token_expired. Return a new token to retry, or null to fail. */
465
257
  onUnauthorized?: () => Promise<string | null>;
466
258
  }
467
259
 
468
260
  declare class HttpClient {
469
261
  protected publishableKey: string;
470
262
  protected secretKey?: string;
263
+ protected tenantId?: string;
471
264
  private getCustomerToken?;
472
265
  private onUnauthorized?;
473
- constructor(publishableKey: string, secretKey?: string, getCustomerToken?: () => string | null, onUnauthorized?: () => Promise<string | null>);
266
+ private onRequestId?;
267
+ constructor(publishableKey: string, secretKey?: string, getCustomerToken?: () => string | null, onUnauthorized?: () => Promise<string | null>, onRequestId?: (id: string | null) => void, tenantId?: string);
474
268
  protected get defaultOptions(): FetchOptions;
269
+ protected fetchWithTracking(url: string, opts: FetchOptions): Promise<Response>;
475
270
  protected buildUrl(endpoint: string, options?: ApiQueryOptions): string;
476
271
  protected assertJsonResponse(response: Response): void;
477
272
  /**
@@ -639,8 +434,10 @@ declare class CollectionQueryBuilder<T extends PublicCollection> {
639
434
  interface CommunityClientOptions {
640
435
  publishableKey?: string;
641
436
  secretKey?: string;
437
+ tenantId?: string;
642
438
  customerToken?: string | (() => string | null);
643
439
  onUnauthorized?: () => Promise<string | null>;
440
+ onRequestId?: (id: string | null) => void;
644
441
  }
645
442
  interface Thread {
646
443
  id: string;
@@ -689,16 +486,6 @@ interface ReactionType {
689
486
  emoji?: string;
690
487
  [key: string]: unknown;
691
488
  }
692
- interface CommunityBan {
693
- id: string;
694
- customer: string;
695
- isPermanent?: boolean;
696
- bannedUntil?: string;
697
- reason?: string;
698
- createdAt?: string;
699
- updatedAt?: string;
700
- [key: string]: unknown;
701
- }
702
489
  interface PaginatedResponse<T> {
703
490
  docs: T[];
704
491
  totalDocs: number;
@@ -714,9 +501,12 @@ interface PaginatedResponse<T> {
714
501
  declare class CommunityClient {
715
502
  private readonly publishableKey;
716
503
  private readonly secretKey?;
504
+ private readonly tenantId?;
717
505
  private readonly customerToken?;
718
506
  private readonly onUnauthorized?;
507
+ private readonly onRequestId?;
719
508
  constructor(options: CommunityClientOptions);
509
+ private buildQuery;
720
510
  private execute;
721
511
  createThread(params: {
722
512
  title: string;
@@ -808,16 +598,52 @@ declare class CommunityClient {
808
598
  page?: number;
809
599
  limit?: number;
810
600
  }): Promise<PaginatedResponse<Bookmark>>;
811
- banCustomer(params: {
812
- customerId: string;
813
- isPermanent?: boolean;
814
- bannedUntil?: string;
815
- reason?: string;
816
- }): Promise<CommunityBan>;
817
- unbanCustomer(params: {
818
- customerId: string;
819
- }): Promise<{
820
- success: boolean;
601
+ }
602
+
603
+ interface ServerApiOptions {
604
+ publishableKey?: string;
605
+ secretKey: string;
606
+ tenantId?: string;
607
+ onRequestId?: (id: string | null) => void;
608
+ }
609
+ interface RequestOptions {
610
+ method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
611
+ headers?: Record<string, string>;
612
+ }
613
+ declare abstract class BaseApi {
614
+ protected readonly publishableKey: string;
615
+ protected readonly secretKey: string;
616
+ protected readonly tenantId?: string;
617
+ protected readonly onRequestId?: (id: string | null) => void;
618
+ constructor(apiName: string, options: ServerApiOptions);
619
+ protected request<T>(endpoint: string, body: unknown, options?: RequestOptions): Promise<T>;
620
+ }
621
+
622
+ type ModerationApiOptions = ServerApiOptions;
623
+ interface CommunityBan {
624
+ id: string;
625
+ customer: string;
626
+ isPermanent?: boolean;
627
+ bannedUntil?: string;
628
+ reason?: string;
629
+ createdAt?: string;
630
+ updatedAt?: string;
631
+ [key: string]: unknown;
632
+ }
633
+ type BanCustomerParams = {
634
+ customerId: string;
635
+ isPermanent?: boolean;
636
+ bannedUntil?: string;
637
+ reason?: string;
638
+ };
639
+ type UnbanCustomerParams = {
640
+ customerId: string;
641
+ };
642
+ declare class ModerationApi extends BaseApi {
643
+ constructor(options: ModerationApiOptions);
644
+ banCustomer(params: BanCustomerParams): Promise<CommunityBan>;
645
+ unbanCustomer(params: UnbanCustomerParams): Promise<{
646
+ success: true;
821
647
  }>;
822
648
  }
823
649
 
@@ -961,87 +787,456 @@ declare class CustomerAuth {
961
787
  */
962
788
  isAuthenticated(): boolean;
963
789
  /**
964
- * Internal: make a request with timeout and error handling.
965
- * Auth endpoints don't retry — failures are final.
790
+ * Internal: make a request with timeout and error handling.
791
+ * Auth endpoints don't retry — failures are final.
792
+ */
793
+ private requestJson;
794
+ }
795
+
796
+ /**
797
+ * Customer namespace. Currently exposes .auth; reserved for future customer-
798
+ * scoped capabilities (addresses, preferences, etc.).
799
+ */
800
+ declare class CustomerNamespace {
801
+ readonly auth: CustomerAuth;
802
+ constructor(publishableKey: string, options?: CustomerAuthOptions);
803
+ }
804
+
805
+ interface CartApiOptions {
806
+ publishableKey?: string;
807
+ secretKey?: string;
808
+ tenantId?: string;
809
+ customerToken?: string | (() => string | null);
810
+ onUnauthorized?: () => Promise<string | null>;
811
+ onRequestId?: (id: string | null) => void;
812
+ }
813
+ type AddItemParams = {
814
+ cartId: string;
815
+ product: string;
816
+ variant: string;
817
+ option: string;
818
+ quantity: number;
819
+ };
820
+ type UpdateItemParams = {
821
+ cartItemId: string;
822
+ quantity: number;
823
+ };
824
+ type RemoveItemParams = {
825
+ cartItemId: string;
826
+ };
827
+ type ApplyDiscountParams = {
828
+ cartId: string;
829
+ discountCode: string;
830
+ };
831
+ type RemoveDiscountParams = {
832
+ cartId: string;
833
+ };
834
+ type ClearCartParams = {
835
+ cartId: string;
836
+ };
837
+ declare class CartApi {
838
+ private readonly publishableKey;
839
+ private readonly secretKey?;
840
+ private readonly tenantId?;
841
+ private readonly customerToken?;
842
+ private readonly onUnauthorized?;
843
+ private readonly onRequestId?;
844
+ constructor(options: CartApiOptions);
845
+ private execute;
846
+ getCart(cartId: string): Promise<Cart>;
847
+ addItem(params: AddItemParams): Promise<CartItem>;
848
+ updateItem(params: UpdateItemParams): Promise<CartItem>;
849
+ removeItem(params: RemoveItemParams): Promise<{
850
+ success: boolean;
851
+ }>;
852
+ applyDiscount(params: ApplyDiscountParams): Promise<Cart>;
853
+ removeDiscount(params: RemoveDiscountParams): Promise<Cart>;
854
+ clearCart(params: ClearCartParams): Promise<{
855
+ success: boolean;
856
+ }>;
857
+ }
858
+
859
+ type EntityID = string;
860
+ type RelationshipValue = string | number | null | undefined | {
861
+ id?: string | number | null;
862
+ };
863
+ type MediaValue = {
864
+ id?: EntityID | null;
865
+ } | EntityID | null | undefined;
866
+ interface ProductOptionValueShape {
867
+ id?: string | number | null;
868
+ option?: RelationshipValue;
869
+ value?: string | null;
870
+ slug?: string | null;
871
+ _order?: string | null;
872
+ '_product-option-values_values_order'?: string | null;
873
+ }
874
+ interface ProductOptionShape {
875
+ id?: string | number | null;
876
+ title?: string | null;
877
+ _order?: string | null;
878
+ '_product-options_options_order'?: string | null;
879
+ values?: {
880
+ docs?: unknown[];
881
+ } | null;
882
+ }
883
+ interface ProductVariantShape {
884
+ id?: string | number | null;
885
+ optionValues?: unknown[] | null;
886
+ price?: number | null;
887
+ compareAtPrice?: number | null;
888
+ stock?: number | null;
889
+ isUnlimited?: boolean | null;
890
+ isActive?: boolean | null;
891
+ thumbnail?: MediaValue;
892
+ images?: MediaValue[] | null;
893
+ _order?: string | null;
894
+ }
895
+ interface ProductListingProductShape {
896
+ id?: EntityID;
897
+ thumbnail?: MediaValue;
898
+ images?: MediaValue[] | null;
899
+ }
900
+ type ProductOptionMatrixValue = {
901
+ id: string;
902
+ optionId: string;
903
+ label: string;
904
+ slug: string | null;
905
+ order: string;
906
+ };
907
+ type ProductOptionMatrixOption = {
908
+ id: string;
909
+ title: string;
910
+ order: string;
911
+ values: ProductOptionMatrixValue[];
912
+ };
913
+ type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVariantShape> = {
914
+ id: string;
915
+ optionValueIds: string[];
916
+ optionValueByOptionId: Map<string, string>;
917
+ source: TVariant;
918
+ };
919
+ type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
920
+ options: ProductOptionMatrixOption[];
921
+ optionIds: string[];
922
+ optionById: Map<string, ProductOptionMatrixOption>;
923
+ valueById: Map<string, ProductOptionMatrixValue>;
924
+ valueToOptionId: Map<string, string>;
925
+ variants: ProductOptionMatrixVariant<TVariant>[];
926
+ };
927
+ type ProductListingProjection = {
928
+ selectionHintVariant: EntityID | null;
929
+ primaryImage: EntityID | null;
930
+ minPrice: number | null;
931
+ maxPrice: number | null;
932
+ minCompareAtPrice: number | null;
933
+ maxCompareAtPrice: number | null;
934
+ isPriceRange: boolean;
935
+ availableForSale: boolean;
936
+ };
937
+ type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantShape> = {
938
+ optionId: EntityID;
939
+ optionTitle: string;
940
+ optionValueId: EntityID;
941
+ optionValueLabel: string;
942
+ optionValueSlug: string | 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
+ declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
958
+ product: ProductListingProductShape | null | undefined;
959
+ options: ProductOptionShape[];
960
+ variants: TVariant[];
961
+ primaryOptionId?: string | null;
962
+ }): ProductListingGroup<TVariant>[];
963
+
964
+ type ProductApiOptions = ServerApiOptions;
965
+ type StockCheckParams = {
966
+ items: Array<{
967
+ variantId: string;
968
+ quantity: number;
969
+ }>;
970
+ };
971
+ type StockCheckResult = {
972
+ variantId: string;
973
+ available: boolean;
974
+ availableStock: number;
975
+ requestedQuantity: number;
976
+ error?: string;
977
+ };
978
+ type StockCheckResponse = {
979
+ results: StockCheckResult[];
980
+ allAvailable: boolean;
981
+ };
982
+ type ListingGroupsParams = {
983
+ productIds: string[];
984
+ };
985
+ type ProductListingGroupSummary = Omit<ProductListingGroup, 'variants'>;
986
+ type ProductListingGroupsItem = {
987
+ product: Product;
988
+ primaryOptionId: string | null;
989
+ groups: ProductListingGroupSummary[];
990
+ };
991
+ type ProductListingGroupsResponse = {
992
+ docs: ProductListingGroupsItem[];
993
+ };
994
+ declare class ProductApi extends BaseApi {
995
+ constructor(options: ProductApiOptions);
996
+ /**
997
+ * Check point-in-time stock availability for one or more product variants.
998
+ * Results reflect available stock at the moment of the call and are not guaranteed
999
+ * to remain available by the time an order is placed.
966
1000
  */
967
- private requestJson;
1001
+ stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
1002
+ listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
968
1003
  }
969
1004
 
970
- declare class SDKError extends Error {
971
- readonly code: string;
972
- readonly status?: number;
973
- readonly details?: unknown;
974
- readonly userMessage?: string;
975
- readonly suggestion?: string;
976
- constructor(code: string, message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
977
- getUserMessage(): string;
978
- toJSON(): {
979
- name: string;
980
- code: string;
981
- message: string;
982
- status: number | undefined;
983
- details: unknown;
984
- userMessage: string | undefined;
985
- suggestion: string | undefined;
986
- };
987
- }
988
- declare class NetworkError extends SDKError {
989
- constructor(message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
990
- }
991
- declare class ValidationError extends SDKError {
992
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
1005
+ type DiscountApiOptions = ServerApiOptions;
1006
+ type ValidateDiscountParams = {
1007
+ code: string;
1008
+ orderAmount: number;
1009
+ };
1010
+ type ValidateDiscountResult = {
1011
+ valid: boolean;
1012
+ code: string;
1013
+ type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
1014
+ discountAmount: number;
1015
+ freeShipping?: boolean;
1016
+ reason?: string;
1017
+ };
1018
+ declare class DiscountApi extends BaseApi {
1019
+ constructor(options: DiscountApiOptions);
1020
+ validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
993
1021
  }
994
- declare class ApiError extends SDKError {
995
- constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string);
1022
+
1023
+ type ShippingApiOptions = ServerApiOptions;
1024
+ type CalculateShippingParams = {
1025
+ shippingPolicyId?: string;
1026
+ orderAmount: number;
1027
+ postalCode?: string;
1028
+ };
1029
+ type CalculateShippingResult = {
1030
+ shippingAmount: number;
1031
+ baseShippingAmount: number;
1032
+ extraShippingAmount: number;
1033
+ freeShipping: boolean;
1034
+ freeShippingMinAmount: number | null;
1035
+ isJeju: boolean;
1036
+ isRemoteIsland: boolean;
1037
+ };
1038
+ declare class ShippingApi extends BaseApi {
1039
+ constructor(options: ShippingApiOptions);
1040
+ calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
996
1041
  }
997
- declare class ConfigError extends SDKError {
998
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
1042
+
1043
+ type OrderApiOptions = ServerApiOptions;
1044
+ type CustomerSnapshot = {
1045
+ name?: string;
1046
+ email: string;
1047
+ phone?: string;
1048
+ };
1049
+ type ReturnReason = 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
1050
+ type ReturnItem = {
1051
+ orderItem: string;
1052
+ quantity: number;
1053
+ };
1054
+ type CreateOrderParams = {
1055
+ orderNumber: string;
1056
+ customer?: string;
1057
+ customerSnapshot: CustomerSnapshot;
1058
+ shippingAddress: Order['shippingAddress'];
1059
+ orderItems: Pick<OrderItem$1, 'product' | 'variant' | 'quantity' | 'unitPrice' | 'totalPrice'>[];
1060
+ totalAmount: number;
1061
+ shippingAmount?: number;
1062
+ pgPaymentId?: string;
1063
+ discountCode?: string;
1064
+ };
1065
+ type UpdateOrderParams = {
1066
+ orderNumber: string;
1067
+ status: Order['status'];
1068
+ };
1069
+ type UpdateTransactionParams = {
1070
+ pgPaymentId: string;
1071
+ status: Transaction['status'];
1072
+ paymentMethod?: string;
1073
+ receiptUrl?: string;
1074
+ };
1075
+ type CheckoutParams = {
1076
+ cartId: string;
1077
+ orderNumber: string;
1078
+ customerSnapshot: CustomerSnapshot;
1079
+ pgPaymentId?: string;
1080
+ discountCode?: string;
1081
+ };
1082
+ type CreateFulfillmentParams = {
1083
+ orderNumber: string;
1084
+ carrier?: string;
1085
+ trackingNumber?: string;
1086
+ items: Array<{
1087
+ orderItem: string;
1088
+ quantity: number;
1089
+ }>;
1090
+ };
1091
+ type UpdateFulfillmentParams = {
1092
+ fulfillmentId: string;
1093
+ status: 'packed' | 'shipped' | 'delivered' | 'failed';
1094
+ carrier?: string;
1095
+ trackingNumber?: string;
1096
+ };
1097
+ type BulkImportFulfillmentsParams = {
1098
+ items: Array<{
1099
+ orderNumber: string;
1100
+ carrier?: string;
1101
+ trackingNumber?: string;
1102
+ }>;
1103
+ };
1104
+ type BulkImportFulfillmentsResponse = {
1105
+ succeeded: Array<{
1106
+ orderNumber: string;
1107
+ fulfillmentId: string;
1108
+ }>;
1109
+ failed: Array<{
1110
+ orderNumber: string;
1111
+ error: string;
1112
+ }>;
1113
+ };
1114
+ type CreateReturnParams = {
1115
+ orderNumber: string;
1116
+ reason?: ReturnReason;
1117
+ reasonDetail?: string;
1118
+ returnItems: ReturnItem[];
1119
+ refundAmount: number;
1120
+ };
1121
+ type UpdateReturnParams = {
1122
+ returnId: string;
1123
+ status: 'processing' | 'approved' | 'rejected' | 'completed';
1124
+ };
1125
+ type ReturnWithRefundParams = {
1126
+ orderNumber: string;
1127
+ reason?: ReturnReason;
1128
+ reasonDetail?: string;
1129
+ returnItems: ReturnItem[];
1130
+ refundAmount: number;
1131
+ pgPaymentId: string;
1132
+ refundReceiptUrl?: string;
1133
+ };
1134
+ declare class OrderApi extends BaseApi {
1135
+ constructor(options: OrderApiOptions);
1136
+ createOrder(params: CreateOrderParams): Promise<Order>;
1137
+ updateOrder(params: UpdateOrderParams): Promise<Order>;
1138
+ updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
1139
+ checkout(params: CheckoutParams): Promise<Order>;
1140
+ createFulfillment(params: CreateFulfillmentParams): Promise<Fulfillment>;
1141
+ updateFulfillment(params: UpdateFulfillmentParams): Promise<Fulfillment>;
1142
+ bulkImportFulfillments(params: BulkImportFulfillmentsParams): Promise<BulkImportFulfillmentsResponse>;
1143
+ returnWithRefund(params: ReturnWithRefundParams): Promise<{
1144
+ return: Return;
1145
+ transaction: Transaction | null;
1146
+ }>;
1147
+ createReturn(params: CreateReturnParams): Promise<Return>;
1148
+ updateReturn(params: UpdateReturnParams): Promise<Return>;
999
1149
  }
1000
- declare class TimeoutError extends SDKError {
1001
- constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
1150
+
1151
+ interface CommerceClientOptions {
1152
+ publishableKey: string;
1153
+ customerToken: () => string | null;
1154
+ onUnauthorized?: () => Promise<string | null>;
1155
+ onRequestId?: (id: string | null) => void;
1156
+ customerAuth: CustomerAuth;
1002
1157
  }
1003
- declare class GoneError extends SDKError {
1004
- constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
1158
+ declare class CommerceClient {
1159
+ readonly product: {
1160
+ stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1161
+ listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1162
+ };
1163
+ readonly cart: {
1164
+ get: (cartId: string) => Promise<Cart>;
1165
+ addItem: (params: AddItemParams) => Promise<CartItem>;
1166
+ updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1167
+ removeItem: (params: RemoveItemParams) => Promise<{
1168
+ success: boolean;
1169
+ }>;
1170
+ applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1171
+ removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1172
+ clear: (params: ClearCartParams) => Promise<{
1173
+ success: boolean;
1174
+ }>;
1175
+ };
1176
+ readonly orders: {
1177
+ checkout: (params: CheckoutParams) => Promise<Order>;
1178
+ listMine: (options?: {
1179
+ page?: number;
1180
+ limit?: number;
1181
+ status?: string;
1182
+ }) => Promise<PayloadFindResponse<Order>>;
1183
+ };
1184
+ readonly discounts: {
1185
+ validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
1186
+ };
1187
+ readonly shipping: {
1188
+ calculate: (params: CalculateShippingParams) => Promise<CalculateShippingResult>;
1189
+ };
1190
+ constructor(options: CommerceClientOptions);
1005
1191
  }
1006
- declare class ServiceUnavailableError extends SDKError {
1007
- readonly retryAfter?: number;
1008
- constructor(message?: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string);
1192
+
1193
+ interface ServerCommerceClientOptions {
1194
+ publishableKey?: string;
1195
+ secretKey: string;
1196
+ tenantId?: string;
1197
+ onRequestId?: (id: string | null) => void;
1009
1198
  }
1010
- declare class UsageLimitError extends SDKError {
1011
- readonly usage: {
1012
- limit: number;
1013
- current: number;
1014
- remaining: number;
1199
+ declare class ServerCommerceClient {
1200
+ readonly product: {
1201
+ stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1202
+ listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1015
1203
  };
1016
- constructor(message: string, usage: {
1017
- limit: number;
1018
- current: number;
1019
- remaining: number;
1020
- }, details?: unknown, userMessage?: string, suggestion?: string);
1021
- toJSON(): {
1022
- usage: {
1023
- limit: number;
1024
- current: number;
1025
- remaining: number;
1026
- };
1027
- name: string;
1028
- code: string;
1029
- message: string;
1030
- status: number | undefined;
1031
- details: unknown;
1032
- userMessage: string | undefined;
1033
- suggestion: string | undefined;
1204
+ readonly cart: {
1205
+ get: (cartId: string) => Promise<Cart>;
1206
+ addItem: (params: AddItemParams) => Promise<CartItem>;
1207
+ updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1208
+ removeItem: (params: RemoveItemParams) => Promise<{
1209
+ success: boolean;
1210
+ }>;
1211
+ applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1212
+ removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1213
+ clear: (params: ClearCartParams) => Promise<{
1214
+ success: boolean;
1215
+ }>;
1034
1216
  };
1217
+ readonly orders: {
1218
+ checkout: (params: CheckoutParams) => Promise<Order>;
1219
+ create: (params: CreateOrderParams) => Promise<Order>;
1220
+ update: (params: UpdateOrderParams) => Promise<Order>;
1221
+ updateTransaction: (params: UpdateTransactionParams) => Promise<Transaction>;
1222
+ createFulfillment: (params: CreateFulfillmentParams) => Promise<Fulfillment>;
1223
+ updateFulfillment: (params: UpdateFulfillmentParams) => Promise<Fulfillment>;
1224
+ bulkImportFulfillments: (params: BulkImportFulfillmentsParams) => Promise<BulkImportFulfillmentsResponse>;
1225
+ createReturn: (params: CreateReturnParams) => Promise<Return>;
1226
+ updateReturn: (params: UpdateReturnParams) => Promise<Return>;
1227
+ returnWithRefund: (params: ReturnWithRefundParams) => Promise<{
1228
+ return: Return;
1229
+ transaction: Transaction | null;
1230
+ }>;
1231
+ };
1232
+ readonly discounts: {
1233
+ validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
1234
+ };
1235
+ readonly shipping: {
1236
+ calculate: (params: CalculateShippingParams) => Promise<CalculateShippingResult>;
1237
+ };
1238
+ constructor(options: ServerCommerceClientOptions);
1035
1239
  }
1036
- declare function isSDKError(error: unknown): error is SDKError;
1037
- declare function isNetworkError(error: unknown): error is NetworkError;
1038
- declare function isValidationError(error: unknown): error is ValidationError;
1039
- declare function isApiError(error: unknown): error is ApiError;
1040
- declare function isConfigError(error: unknown): error is ConfigError;
1041
- declare function isTimeoutError(error: unknown): error is TimeoutError;
1042
- declare function isGoneError(error: unknown): error is GoneError;
1043
- declare function isServiceUnavailableError(error: unknown): error is ServiceUnavailableError;
1044
- declare function isUsageLimitError(error: unknown): error is UsageLimitError;
1045
1240
 
1046
1241
  interface CollectionQueryParams<T extends PublicCollection> {
1047
1242
  collection: T;
@@ -1243,16 +1438,16 @@ declare class QueryHooks extends CollectionHooks {
1243
1438
  }
1244
1439
 
1245
1440
  declare class Client {
1246
- cart: CartApi;
1441
+ commerce: CommerceClient;
1247
1442
  community: CommunityClient;
1443
+ customer: CustomerNamespace;
1248
1444
  query: ReadOnlyQueryHooks;
1249
1445
  collections: CollectionClient;
1250
1446
  queryClient: QueryClient;
1251
- customer: CustomerAuth;
1447
+ lastRequestId: string | null;
1252
1448
  protected state: ClientState;
1253
1449
  protected config: ClientConfig;
1254
1450
  constructor(options: ClientConfig);
1255
- from<T extends PublicCollection>(collection: T): ReadOnlyQueryBuilder<T>;
1256
1451
  getState(): ClientState;
1257
1452
  getConfig(): ClientConfig;
1258
1453
  }
@@ -1264,17 +1459,22 @@ declare class Client {
1264
1459
  declare function createClient(options: ClientConfig): Client;
1265
1460
 
1266
1461
  declare class ServerClient {
1267
- api: OrderApi;
1268
- cart: CartApi;
1269
- community: CommunityClient;
1270
- product: ProductApi;
1462
+ commerce: ServerCommerceClient;
1463
+ community: CommunityClient & {
1464
+ moderation: {
1465
+ banCustomer: (p: BanCustomerParams) => Promise<CommunityBan>;
1466
+ unbanCustomer: (p: UnbanCustomerParams) => Promise<{
1467
+ success: true;
1468
+ }>;
1469
+ };
1470
+ };
1271
1471
  query: QueryHooks;
1272
1472
  collections: CollectionClient;
1273
1473
  queryClient: QueryClient;
1474
+ lastRequestId: string | null;
1274
1475
  protected state: ClientState;
1275
1476
  protected config: ClientServerConfig;
1276
1477
  constructor(options: ClientServerConfig);
1277
- from<T extends PublicCollection>(collection: T): CollectionQueryBuilder<T>;
1278
1478
  getState(): ClientState;
1279
1479
  getConfig(): Omit<ClientServerConfig, 'secretKey'>;
1280
1480
  }
@@ -1304,4 +1504,4 @@ declare const formatOrderName: (items: OrderItem[]) => string;
1304
1504
  */
1305
1505
  declare const resolveRelation: <T>(ref: T | string | number | null | undefined) => T | null;
1306
1506
 
1307
- export { type AddItemParams, ApiError, type ApiQueryOptions, type ApplyDiscountParams, BaseApi, type CalculateShippingParams, type CalculateShippingResult, Cart, CartApi, type CartApiOptions, CartItem, type CheckoutParams, type ClearCartParams, Client, type ClientConfig, type ClientMetadata, type ClientServerConfig, type ClientState, Client as ClientType, CollectionClient, type CollectionDetailQueryParams, CollectionHooks, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType, CommunityClient, type CommunityClientOptions, ConfigError, type CreateFulfillmentParams, type CreateOrderParams, type CreateReturnParams, CustomerAuth, type CustomerAuthOptions, type CustomerAuthResponse, CustomerHooks, type CustomerLoginData, type CustomerProfile, type CustomerRefreshResponse, type CustomerRegisterData, type CustomerRegisterResponse, type CustomerSnapshot, type DebugConfig, type DeepPartial, type ExtractArrayType, type GenerateMetadataOptions, type GetOrderParams, GoneError, type InfiniteQueryOptions, type ListingGroupsParams, NetworkError, Order, OrderApi, type OrderApiOptions, type PaginationMeta, type PayloadFindResponse, type PayloadMutationResponse, Product, ProductApi, type ProductApiOptions, type ProductListingGroup, type ProductListingGroupSummary, type ProductListingGroupsItem, type ProductListingGroupsQueryOptions, type ProductListingGroupsResponse, type ProductListingProductShape, type ProductListingProjection, type ProductOptionMatrix, type ProductOptionMatrixOption, type ProductOptionMatrixValue, type ProductOptionMatrixVariant, type ProductOptionShape, type ProductOptionValueShape, type ProductVariantShape, PublicCollection, QueryHooks, type QueryOptions, type ReadOnlyQueryBuilder, type ReadOnlyQueryHooks, type RemoveDiscountParams, type RemoveItemParams, type RequestOptions, type RetryConfig, type ReturnProductItem, type ReturnReason, type ReturnWithRefundParams, SDKError, type ServerApiOptions, ServerClient, ServerClient as ServerClientType, ServiceUnavailableError, type StockCheckParams, type StockCheckResponse, type StockCheckResult, type SuspenseInfiniteQueryOptions, type SuspenseQueryOptions, TimeoutError, type UpdateFulfillmentParams, type UpdateItemParams, type UpdateOrderParams, type UpdateProfileData, type UpdateReturnParams, type UpdateTransactionParams, UsageLimitError, type ValidateDiscountParams, type ValidateDiscountResult, ValidationError, buildProductListingGroupsByOption, buildProductListingProjection, buildProductOptionMatrix, collectionKeys, createClient, createServerClient, customerKeys, formatOrderName, generateOrderNumber, getAvailableOptionValues, getQueryClient, getSelectedValueByOptionId, isApiError, isConfigError, isGoneError, isNetworkError, isSDKError, isServiceUnavailableError, isTimeoutError, isUsageLimitError, isValidationError, normalizeSelectedValueIds, productKeys, resolveApiUrl, resolveRelation, resolveVariantForSelection };
1507
+ export { type AddItemParams, ApiError, type ApiQueryOptions, type ApplyDiscountParams, AuthError, type BanCustomerParams, BaseApi, type BulkImportFulfillmentsParams, type BulkImportFulfillmentsResponse, type CalculateShippingParams, type CalculateShippingResult, Cart, CartApi, type CartApiOptions, CartItem, type CheckoutParams, type ClearCartParams, Client, type ClientConfig, type ClientMetadata, type ClientServerConfig, type ClientState, Client as ClientType, CollectionClient, type CollectionDetailQueryParams, CollectionHooks, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType, CommerceClient, type CommerceClientOptions, type CommunityBan, CommunityClient, type CommunityClientOptions, ConfigError, ConflictError, type CreateFulfillmentParams, type CreateOrderParams, type CreateReturnParams, CustomerAuth, type CustomerAuthOptions, type CustomerAuthResponse, CustomerHooks, type CustomerLoginData, CustomerNamespace, type CustomerProfile, type CustomerRefreshResponse, type CustomerRegisterData, type CustomerRegisterResponse, type CustomerSnapshot, type DebugConfig, type DeepPartial, DiscountApi, type DiscountApiOptions, type ExtractArrayType, type GenerateMetadataOptions, GoneError, type InfiniteQueryOptions, type ListingGroupsParams, ModerationApi, type ModerationApiOptions, NetworkError, NotFoundError, Order, OrderApi, type OrderApiOptions, type PaginationMeta, type PayloadFindResponse, type PayloadMutationResponse, PermissionError, Product, ProductApi, type ProductApiOptions, type ProductListingGroup, type ProductListingGroupSummary, type ProductListingGroupsItem, type ProductListingGroupsQueryOptions, type ProductListingGroupsResponse, type ProductListingProductShape, type ProductListingProjection, type ProductOptionMatrix, type ProductOptionMatrixOption, type ProductOptionMatrixValue, type ProductOptionMatrixVariant, type ProductOptionShape, type ProductOptionValueShape, type ProductVariantShape, PublicCollection, QueryHooks, type QueryOptions, RateLimitError, type ReadOnlyQueryBuilder, type ReadOnlyQueryHooks, type RemoveDiscountParams, type RemoveItemParams, type RequestOptions, type RetryConfig, type ReturnItem, type ReturnReason, type ReturnWithRefundParams, SDKError, type ServerApiOptions, ServerClient, ServerClient as ServerClientType, ServerCommerceClient, type ServerCommerceClientOptions, ServiceUnavailableError, ShippingApi, type ShippingApiOptions, type StockCheckParams, type StockCheckResponse, type StockCheckResult, type SuspenseInfiniteQueryOptions, type SuspenseQueryOptions, TimeoutError, type UnbanCustomerParams, type UpdateFulfillmentParams, type UpdateItemParams, type UpdateOrderParams, type UpdateProfileData, type UpdateReturnParams, type UpdateTransactionParams, UsageLimitError, type ValidateDiscountParams, type ValidateDiscountResult, ValidationError, buildProductListingGroupsByOption, buildProductListingProjection, buildProductOptionMatrix, collectionKeys, createAuthError, createClient, createConflictError, createNotFoundError, createPermissionError, createRateLimitError, createServerClient, customerKeys, formatOrderName, generateOrderNumber, getAvailableOptionValues, getQueryClient, getSelectedValueByOptionId, isApiError, isAuthError, isConfigError, isConflictError, isGoneError, isNetworkError, isNotFoundError, isPermissionError, isRateLimitError, isSDKError, isServiceUnavailableError, isTimeoutError, isUsageLimitError, isValidationError, normalizeSelectedValueIds, productKeys, resolveApiUrl, resolveRelation, resolveVariantForSelection };