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