@01.software/sdk 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { O as Order, a as OrderProduct, T as Transaction, b as Fulfillment, R as Return, C as CartItem, P as ProductOption } from './payload-types-BFIUYPDZ.cjs';
2
- export { k as ApiUsage, ae as ApiUsageSelect, A as Audience, aa as AudiencesSelect, b0 as Auth, m as BillingHistory, ag as BillingHistorySelect, u as Brand, B as BrandLogo, aq as BrandLogosSelect, ap as BrandsSelect, K as Cart, aG as CartItemsSelect, aF as CartsSelect, f as CodeBlock, a$ as CollectionsWidget, c as Config, w as Customer, z as CustomerAddress, aC as CustomerAddressesSelect, d as CustomerAuthOperations, x as CustomerGroup, y as CustomerGroupImage, aE as CustomerGroupImagesSelect, aD as CustomerGroupsSelect, aB as CustomersSelect, L as Discount, aH as DiscountsSelect, Y as Document, aP as DocumentCategoriesSelect, $ as DocumentCategory, _ as DocumentImage, aR as DocumentImagesSelect, Z as DocumentType, aQ as DocumentTypesSelect, aO as DocumentsSelect, E as EmailLog, ab as EmailLogsSelect, G as Exchange, H as ExchangeProduct, ax as ExchangeProductsSelect, aw as ExchangesSelect, F as Form, a3 as FormSubmission, aW as FormSubmissionsSelect, aV as FormsSelect, J as FulfillmentItem, az as FulfillmentItemsSelect, ay as FulfillmentsSelect, I as IframeBlock, M as Media, a9 as MediaSelect, a1 as Music, aT as MusicsSelect, at as OrderProductsSelect, as as OrdersSelect, a4 as PayloadKv, aX as PayloadKvSelect, a5 as PayloadLockedDocument, aY as PayloadLockedDocumentsSelect, a7 as PayloadMigration, a_ as PayloadMigrationsSelect, a6 as PayloadPreference, aZ as PayloadPreferencesSelect, e as PlayerBlock, a0 as Playlist, a2 as PlaylistImage, aU as PlaylistImagesSelect, aS as PlaylistsSelect, N as Post, V as PostAuthor, aK as PostAuthorsSelect, aL as PostCategoriesSelect, W as PostCategory, Q as PostImage, aN as PostImagesSelect, X as PostTag, aM as PostTagsSelect, aJ as PostsSelect, o as Product, am as ProductCategoriesSelect, r as ProductCategory, t as ProductCollection, ao as ProductCollectionsSelect, p as ProductImage, ar as ProductImagesSelect, al as ProductOptionsSelect, s as ProductTag, an as ProductTagsSelect, q as ProductVariant, ak as ProductVariantsSelect, aj as ProductsSelect, D as ReturnProduct, av as ReturnProductsSelect, au as ReturnsSelect, aI as ShippingPoliciesSelect, v as ShippingPolicy, l as Subscription, af as SubscriptionsSelect, S as SupportedTimezones, h as Tenant, n as TenantLogo, ah as TenantLogosSelect, ad as TenantMetadataSelect, i as TenantMetadatum, j as TenantOgImage, ai as TenantOgImagesSelect, ac as TenantsSelect, aA as TransactionsSelect, g as User, U as UserAuthOperations, a8 as UsersSelect } from './payload-types-BFIUYPDZ.cjs';
3
- import { F as FetchOptions, A as ApiQueryOptions, P as PayloadFindResponse, a as PayloadMutationResponse, C as ClientBrowserConfig, b as ClientState, c as ClientServerConfig } from './auth-DTkwMgvi.cjs';
4
- export { t as API_URLS, f as ApiError, y as ApiQueryReactOptions, w as ClientMetadata, g as ConfigError, d as DebugConfig, D as DeepPartial, s as Environment, e as ErrorLogger, E as ExtractArrayType, J as JwtPayload, N as NetworkError, x as PaginationMeta, R as RetryConfig, S as SDKError, T as TimeoutError, U as UsageLimitError, V as ValidationError, q as createApiKey, o as createServerToken, p as decodeServerToken, k as isApiError, l as isConfigError, h as isNetworkError, i as isSDKError, m as isTimeoutError, n as isUsageLimitError, j as isValidationError, r as parseApiKey, u as resolveApiUrl, v as verifyServerToken } from './auth-DTkwMgvi.cjs';
1
+ import { O as Order, a as OrderProduct, T as Transaction, b as Fulfillment, R as Return, C as CartItem, P as ProductOption } from './payload-types-D0px2DCK.cjs';
2
+ export { k as ApiUsage, ae as ApiUsageSelect, A as Audience, aa as AudiencesSelect, b0 as Auth, m as BillingHistory, ag as BillingHistorySelect, u as Brand, B as BrandLogo, aq as BrandLogosSelect, ap as BrandsSelect, K as Cart, aG as CartItemsSelect, aF as CartsSelect, f as CodeBlock, a$ as CollectionsWidget, c as Config, w as Customer, z as CustomerAddress, aC as CustomerAddressesSelect, d as CustomerAuthOperations, x as CustomerGroup, y as CustomerGroupImage, aE as CustomerGroupImagesSelect, aD as CustomerGroupsSelect, aB as CustomersSelect, L as Discount, aH as DiscountsSelect, Y as Document, aP as DocumentCategoriesSelect, $ as DocumentCategory, _ as DocumentImage, aR as DocumentImagesSelect, Z as DocumentType, aQ as DocumentTypesSelect, aO as DocumentsSelect, E as EmailLog, ab as EmailLogsSelect, G as Exchange, H as ExchangeProduct, ax as ExchangeProductsSelect, aw as ExchangesSelect, F as Form, a3 as FormSubmission, aW as FormSubmissionsSelect, aV as FormsSelect, J as FulfillmentItem, az as FulfillmentItemsSelect, ay as FulfillmentsSelect, I as IframeBlock, M as Media, a9 as MediaSelect, a1 as Music, aT as MusicsSelect, at as OrderProductsSelect, as as OrdersSelect, a4 as PayloadKv, aX as PayloadKvSelect, a5 as PayloadLockedDocument, aY as PayloadLockedDocumentsSelect, a7 as PayloadMigration, a_ as PayloadMigrationsSelect, a6 as PayloadPreference, aZ as PayloadPreferencesSelect, e as PlayerBlock, a0 as Playlist, a2 as PlaylistImage, aU as PlaylistImagesSelect, aS as PlaylistsSelect, N as Post, V as PostAuthor, aK as PostAuthorsSelect, aL as PostCategoriesSelect, W as PostCategory, Q as PostImage, aN as PostImagesSelect, X as PostTag, aM as PostTagsSelect, aJ as PostsSelect, o as Product, am as ProductCategoriesSelect, r as ProductCategory, t as ProductCollection, ao as ProductCollectionsSelect, p as ProductImage, ar as ProductImagesSelect, al as ProductOptionsSelect, s as ProductTag, an as ProductTagsSelect, q as ProductVariant, ak as ProductVariantsSelect, aj as ProductsSelect, D as ReturnProduct, av as ReturnProductsSelect, au as ReturnsSelect, aI as ShippingPoliciesSelect, v as ShippingPolicy, l as Subscription, af as SubscriptionsSelect, S as SupportedTimezones, h as Tenant, n as TenantLogo, ah as TenantLogosSelect, ad as TenantMetadataSelect, i as TenantMetadatum, j as TenantOgImage, ai as TenantOgImagesSelect, ac as TenantsSelect, aA as TransactionsSelect, g as User, U as UserAuthOperations, a8 as UsersSelect } from './payload-types-D0px2DCK.cjs';
3
+ import { F as FetchOptions, A as ApiQueryOptions, P as PayloadFindResponse, a as PayloadMutationResponse, C as ClientBrowserConfig, b as ClientState, c as ClientServerConfig } from './auth-BICuhJxS.cjs';
4
+ export { t as API_URLS, f as ApiError, y as ApiQueryReactOptions, w as ClientMetadata, g as ConfigError, d as DebugConfig, D as DeepPartial, s as Environment, e as ErrorLogger, E as ExtractArrayType, J as JwtPayload, N as NetworkError, x as PaginationMeta, R as RetryConfig, S as SDKError, T as TimeoutError, U as UsageLimitError, V as ValidationError, q as createApiKey, o as createServerToken, p as decodeServerToken, k as isApiError, l as isConfigError, h as isNetworkError, i as isSDKError, m as isTimeoutError, n as isUsageLimitError, j as isValidationError, r as parseApiKey, u as resolveApiUrl, v as verifyServerToken } from './auth-BICuhJxS.cjs';
5
5
  import * as _tanstack_react_query from '@tanstack/react-query';
6
6
  import { QueryClient } from '@tanstack/react-query';
7
- import { P as PublicCollection, C as CollectionType } from './webhook-BM5spkSP.cjs';
8
- export { b as COLLECTIONS, a as Collection, c as WebhookEvent, d as WebhookHandler, W as WebhookOperation, e as WebhookOptions, f as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-BM5spkSP.cjs';
7
+ import { P as PublicCollection, C as CollectionType } from './webhook--_n7O-Ed.cjs';
8
+ export { b as COLLECTIONS, a as Collection, c as WebhookEvent, d as WebhookHandler, W as WebhookOperation, e as WebhookOptions, f as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook--_n7O-Ed.cjs';
9
9
  import { Metadata } from 'next';
10
10
  import { GenerateMetadataOptions } from './metadata.cjs';
11
11
  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';
@@ -35,7 +35,7 @@ type UpdateTransactionParams = {
35
35
  receiptUrl: Transaction['receiptUrl'];
36
36
  };
37
37
  type CheckoutParams = {
38
- cartId: number;
38
+ cartId: string;
39
39
  paymentId: string;
40
40
  orderNumber: string;
41
41
  customerSnapshot: {
@@ -49,7 +49,7 @@ type CreateFulfillmentParams = {
49
49
  carrier?: string;
50
50
  trackingNumber?: string;
51
51
  items: Array<{
52
- orderProduct: number;
52
+ orderProduct: string;
53
53
  quantity: number;
54
54
  }>;
55
55
  };
@@ -61,13 +61,13 @@ type CreateReturnParams = {
61
61
  reason?: 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
62
62
  reasonDetail?: string;
63
63
  returnProducts: Array<{
64
- orderProduct: number;
64
+ orderProduct: string;
65
65
  quantity: number;
66
66
  }>;
67
67
  refundAmount: number;
68
68
  };
69
69
  type UpdateReturnParams = {
70
- returnId: number;
70
+ returnId: string;
71
71
  status: 'processing' | 'approved' | 'rejected' | 'completed';
72
72
  };
73
73
  type ReturnWithRefundParams = {
@@ -75,7 +75,7 @@ type ReturnWithRefundParams = {
75
75
  reason?: string;
76
76
  reasonDetail?: string;
77
77
  returnProducts: Array<{
78
- orderProduct: number;
78
+ orderProduct: string;
79
79
  quantity: number;
80
80
  }>;
81
81
  refundAmount: number;
@@ -109,18 +109,18 @@ interface CartApiOptions {
109
109
  baseUrl?: string;
110
110
  }
111
111
  type AddItemParams = {
112
- cartId: number;
113
- product: number;
114
- variant: number;
115
- option: number;
112
+ cartId: string;
113
+ product: string;
114
+ variant: string;
115
+ option: string;
116
116
  quantity: number;
117
117
  };
118
118
  type UpdateItemParams = {
119
- cartItemId: number;
119
+ cartItemId: string;
120
120
  quantity: number;
121
121
  };
122
122
  type RemoveItemParams = {
123
- cartItemId: number;
123
+ cartItemId: string;
124
124
  };
125
125
  declare class CartApi {
126
126
  private readonly clientKey;
@@ -143,12 +143,12 @@ interface ProductApiOptions {
143
143
  }
144
144
  type StockCheckParams = {
145
145
  items: Array<{
146
- optionId: number;
146
+ optionId: string;
147
147
  quantity: number;
148
148
  }>;
149
149
  };
150
150
  type StockCheckResult = {
151
- optionId: number;
151
+ optionId: string;
152
152
  available: boolean;
153
153
  availableStock: number;
154
154
  requestedQuantity: number;
@@ -343,6 +343,15 @@ interface CustomerRefreshResponse {
343
343
  token: string;
344
344
  }
345
345
  interface CustomerAuthOptions {
346
+ /**
347
+ * Automatically persist token in localStorage.
348
+ * - `true`: uses default key `'customer-token'`
349
+ * - `string`: uses the given string as localStorage key
350
+ *
351
+ * Handles SSR safely (no-op on server).
352
+ * When set, `token` and `onTokenChange` are ignored.
353
+ */
354
+ persist?: boolean | string;
346
355
  /** Initial token (e.g. from SSR cookie) */
347
356
  token?: string;
348
357
  /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { O as Order, a as OrderProduct, T as Transaction, b as Fulfillment, R as Return, C as CartItem, P as ProductOption } from './payload-types-BFIUYPDZ.js';
2
- export { k as ApiUsage, ae as ApiUsageSelect, A as Audience, aa as AudiencesSelect, b0 as Auth, m as BillingHistory, ag as BillingHistorySelect, u as Brand, B as BrandLogo, aq as BrandLogosSelect, ap as BrandsSelect, K as Cart, aG as CartItemsSelect, aF as CartsSelect, f as CodeBlock, a$ as CollectionsWidget, c as Config, w as Customer, z as CustomerAddress, aC as CustomerAddressesSelect, d as CustomerAuthOperations, x as CustomerGroup, y as CustomerGroupImage, aE as CustomerGroupImagesSelect, aD as CustomerGroupsSelect, aB as CustomersSelect, L as Discount, aH as DiscountsSelect, Y as Document, aP as DocumentCategoriesSelect, $ as DocumentCategory, _ as DocumentImage, aR as DocumentImagesSelect, Z as DocumentType, aQ as DocumentTypesSelect, aO as DocumentsSelect, E as EmailLog, ab as EmailLogsSelect, G as Exchange, H as ExchangeProduct, ax as ExchangeProductsSelect, aw as ExchangesSelect, F as Form, a3 as FormSubmission, aW as FormSubmissionsSelect, aV as FormsSelect, J as FulfillmentItem, az as FulfillmentItemsSelect, ay as FulfillmentsSelect, I as IframeBlock, M as Media, a9 as MediaSelect, a1 as Music, aT as MusicsSelect, at as OrderProductsSelect, as as OrdersSelect, a4 as PayloadKv, aX as PayloadKvSelect, a5 as PayloadLockedDocument, aY as PayloadLockedDocumentsSelect, a7 as PayloadMigration, a_ as PayloadMigrationsSelect, a6 as PayloadPreference, aZ as PayloadPreferencesSelect, e as PlayerBlock, a0 as Playlist, a2 as PlaylistImage, aU as PlaylistImagesSelect, aS as PlaylistsSelect, N as Post, V as PostAuthor, aK as PostAuthorsSelect, aL as PostCategoriesSelect, W as PostCategory, Q as PostImage, aN as PostImagesSelect, X as PostTag, aM as PostTagsSelect, aJ as PostsSelect, o as Product, am as ProductCategoriesSelect, r as ProductCategory, t as ProductCollection, ao as ProductCollectionsSelect, p as ProductImage, ar as ProductImagesSelect, al as ProductOptionsSelect, s as ProductTag, an as ProductTagsSelect, q as ProductVariant, ak as ProductVariantsSelect, aj as ProductsSelect, D as ReturnProduct, av as ReturnProductsSelect, au as ReturnsSelect, aI as ShippingPoliciesSelect, v as ShippingPolicy, l as Subscription, af as SubscriptionsSelect, S as SupportedTimezones, h as Tenant, n as TenantLogo, ah as TenantLogosSelect, ad as TenantMetadataSelect, i as TenantMetadatum, j as TenantOgImage, ai as TenantOgImagesSelect, ac as TenantsSelect, aA as TransactionsSelect, g as User, U as UserAuthOperations, a8 as UsersSelect } from './payload-types-BFIUYPDZ.js';
3
- import { F as FetchOptions, A as ApiQueryOptions, P as PayloadFindResponse, a as PayloadMutationResponse, C as ClientBrowserConfig, b as ClientState, c as ClientServerConfig } from './auth-CWsLf5vd.js';
4
- export { t as API_URLS, f as ApiError, y as ApiQueryReactOptions, w as ClientMetadata, g as ConfigError, d as DebugConfig, D as DeepPartial, s as Environment, e as ErrorLogger, E as ExtractArrayType, J as JwtPayload, N as NetworkError, x as PaginationMeta, R as RetryConfig, S as SDKError, T as TimeoutError, U as UsageLimitError, V as ValidationError, q as createApiKey, o as createServerToken, p as decodeServerToken, k as isApiError, l as isConfigError, h as isNetworkError, i as isSDKError, m as isTimeoutError, n as isUsageLimitError, j as isValidationError, r as parseApiKey, u as resolveApiUrl, v as verifyServerToken } from './auth-CWsLf5vd.js';
1
+ import { O as Order, a as OrderProduct, T as Transaction, b as Fulfillment, R as Return, C as CartItem, P as ProductOption } from './payload-types-D0px2DCK.js';
2
+ export { k as ApiUsage, ae as ApiUsageSelect, A as Audience, aa as AudiencesSelect, b0 as Auth, m as BillingHistory, ag as BillingHistorySelect, u as Brand, B as BrandLogo, aq as BrandLogosSelect, ap as BrandsSelect, K as Cart, aG as CartItemsSelect, aF as CartsSelect, f as CodeBlock, a$ as CollectionsWidget, c as Config, w as Customer, z as CustomerAddress, aC as CustomerAddressesSelect, d as CustomerAuthOperations, x as CustomerGroup, y as CustomerGroupImage, aE as CustomerGroupImagesSelect, aD as CustomerGroupsSelect, aB as CustomersSelect, L as Discount, aH as DiscountsSelect, Y as Document, aP as DocumentCategoriesSelect, $ as DocumentCategory, _ as DocumentImage, aR as DocumentImagesSelect, Z as DocumentType, aQ as DocumentTypesSelect, aO as DocumentsSelect, E as EmailLog, ab as EmailLogsSelect, G as Exchange, H as ExchangeProduct, ax as ExchangeProductsSelect, aw as ExchangesSelect, F as Form, a3 as FormSubmission, aW as FormSubmissionsSelect, aV as FormsSelect, J as FulfillmentItem, az as FulfillmentItemsSelect, ay as FulfillmentsSelect, I as IframeBlock, M as Media, a9 as MediaSelect, a1 as Music, aT as MusicsSelect, at as OrderProductsSelect, as as OrdersSelect, a4 as PayloadKv, aX as PayloadKvSelect, a5 as PayloadLockedDocument, aY as PayloadLockedDocumentsSelect, a7 as PayloadMigration, a_ as PayloadMigrationsSelect, a6 as PayloadPreference, aZ as PayloadPreferencesSelect, e as PlayerBlock, a0 as Playlist, a2 as PlaylistImage, aU as PlaylistImagesSelect, aS as PlaylistsSelect, N as Post, V as PostAuthor, aK as PostAuthorsSelect, aL as PostCategoriesSelect, W as PostCategory, Q as PostImage, aN as PostImagesSelect, X as PostTag, aM as PostTagsSelect, aJ as PostsSelect, o as Product, am as ProductCategoriesSelect, r as ProductCategory, t as ProductCollection, ao as ProductCollectionsSelect, p as ProductImage, ar as ProductImagesSelect, al as ProductOptionsSelect, s as ProductTag, an as ProductTagsSelect, q as ProductVariant, ak as ProductVariantsSelect, aj as ProductsSelect, D as ReturnProduct, av as ReturnProductsSelect, au as ReturnsSelect, aI as ShippingPoliciesSelect, v as ShippingPolicy, l as Subscription, af as SubscriptionsSelect, S as SupportedTimezones, h as Tenant, n as TenantLogo, ah as TenantLogosSelect, ad as TenantMetadataSelect, i as TenantMetadatum, j as TenantOgImage, ai as TenantOgImagesSelect, ac as TenantsSelect, aA as TransactionsSelect, g as User, U as UserAuthOperations, a8 as UsersSelect } from './payload-types-D0px2DCK.js';
3
+ import { F as FetchOptions, A as ApiQueryOptions, P as PayloadFindResponse, a as PayloadMutationResponse, C as ClientBrowserConfig, b as ClientState, c as ClientServerConfig } from './auth-Cj3nVn_P.js';
4
+ export { t as API_URLS, f as ApiError, y as ApiQueryReactOptions, w as ClientMetadata, g as ConfigError, d as DebugConfig, D as DeepPartial, s as Environment, e as ErrorLogger, E as ExtractArrayType, J as JwtPayload, N as NetworkError, x as PaginationMeta, R as RetryConfig, S as SDKError, T as TimeoutError, U as UsageLimitError, V as ValidationError, q as createApiKey, o as createServerToken, p as decodeServerToken, k as isApiError, l as isConfigError, h as isNetworkError, i as isSDKError, m as isTimeoutError, n as isUsageLimitError, j as isValidationError, r as parseApiKey, u as resolveApiUrl, v as verifyServerToken } from './auth-Cj3nVn_P.js';
5
5
  import * as _tanstack_react_query from '@tanstack/react-query';
6
6
  import { QueryClient } from '@tanstack/react-query';
7
- import { P as PublicCollection, C as CollectionType } from './webhook-BBp77Khg.js';
8
- export { b as COLLECTIONS, a as Collection, c as WebhookEvent, d as WebhookHandler, W as WebhookOperation, e as WebhookOptions, f as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-BBp77Khg.js';
7
+ import { P as PublicCollection, C as CollectionType } from './webhook-vrlAV1K7.js';
8
+ export { b as COLLECTIONS, a as Collection, c as WebhookEvent, d as WebhookHandler, W as WebhookOperation, e as WebhookOptions, f as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-vrlAV1K7.js';
9
9
  import { Metadata } from 'next';
10
10
  import { GenerateMetadataOptions } from './metadata.js';
11
11
  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';
@@ -35,7 +35,7 @@ type UpdateTransactionParams = {
35
35
  receiptUrl: Transaction['receiptUrl'];
36
36
  };
37
37
  type CheckoutParams = {
38
- cartId: number;
38
+ cartId: string;
39
39
  paymentId: string;
40
40
  orderNumber: string;
41
41
  customerSnapshot: {
@@ -49,7 +49,7 @@ type CreateFulfillmentParams = {
49
49
  carrier?: string;
50
50
  trackingNumber?: string;
51
51
  items: Array<{
52
- orderProduct: number;
52
+ orderProduct: string;
53
53
  quantity: number;
54
54
  }>;
55
55
  };
@@ -61,13 +61,13 @@ type CreateReturnParams = {
61
61
  reason?: 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
62
62
  reasonDetail?: string;
63
63
  returnProducts: Array<{
64
- orderProduct: number;
64
+ orderProduct: string;
65
65
  quantity: number;
66
66
  }>;
67
67
  refundAmount: number;
68
68
  };
69
69
  type UpdateReturnParams = {
70
- returnId: number;
70
+ returnId: string;
71
71
  status: 'processing' | 'approved' | 'rejected' | 'completed';
72
72
  };
73
73
  type ReturnWithRefundParams = {
@@ -75,7 +75,7 @@ type ReturnWithRefundParams = {
75
75
  reason?: string;
76
76
  reasonDetail?: string;
77
77
  returnProducts: Array<{
78
- orderProduct: number;
78
+ orderProduct: string;
79
79
  quantity: number;
80
80
  }>;
81
81
  refundAmount: number;
@@ -109,18 +109,18 @@ interface CartApiOptions {
109
109
  baseUrl?: string;
110
110
  }
111
111
  type AddItemParams = {
112
- cartId: number;
113
- product: number;
114
- variant: number;
115
- option: number;
112
+ cartId: string;
113
+ product: string;
114
+ variant: string;
115
+ option: string;
116
116
  quantity: number;
117
117
  };
118
118
  type UpdateItemParams = {
119
- cartItemId: number;
119
+ cartItemId: string;
120
120
  quantity: number;
121
121
  };
122
122
  type RemoveItemParams = {
123
- cartItemId: number;
123
+ cartItemId: string;
124
124
  };
125
125
  declare class CartApi {
126
126
  private readonly clientKey;
@@ -143,12 +143,12 @@ interface ProductApiOptions {
143
143
  }
144
144
  type StockCheckParams = {
145
145
  items: Array<{
146
- optionId: number;
146
+ optionId: string;
147
147
  quantity: number;
148
148
  }>;
149
149
  };
150
150
  type StockCheckResult = {
151
- optionId: number;
151
+ optionId: string;
152
152
  available: boolean;
153
153
  availableStock: number;
154
154
  requestedQuantity: number;
@@ -343,6 +343,15 @@ interface CustomerRefreshResponse {
343
343
  token: string;
344
344
  }
345
345
  interface CustomerAuthOptions {
346
+ /**
347
+ * Automatically persist token in localStorage.
348
+ * - `true`: uses default key `'customer-token'`
349
+ * - `string`: uses the given string as localStorage key
350
+ *
351
+ * Handles SSR safely (no-op on server).
352
+ * When set, `token` and `onTokenChange` are ignored.
353
+ */
354
+ persist?: boolean | string;
346
355
  /** Initial token (e.g. from SSR cookie) */
347
356
  token?: string;
348
357
  /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
package/dist/index.js CHANGED
@@ -1079,11 +1079,21 @@ var COLLECTIONS = [
1079
1079
  var DEFAULT_TIMEOUT2 = 15e3;
1080
1080
  var CustomerAuth = class {
1081
1081
  constructor(clientKey, baseUrl, options) {
1082
- var _a;
1082
+ var _a, _b;
1083
1083
  this.clientKey = clientKey;
1084
1084
  this.baseUrl = baseUrl;
1085
- this.token = (_a = options == null ? void 0 : options.token) != null ? _a : null;
1086
- this.onTokenChange = options == null ? void 0 : options.onTokenChange;
1085
+ if (options == null ? void 0 : options.persist) {
1086
+ const key = typeof options.persist === "string" ? options.persist : "customer-token";
1087
+ const isBrowser = typeof window !== "undefined";
1088
+ this.token = isBrowser ? (_a = localStorage.getItem(key)) != null ? _a : null : null;
1089
+ this.onTokenChange = isBrowser ? (token) => {
1090
+ if (token) localStorage.setItem(key, token);
1091
+ else localStorage.removeItem(key);
1092
+ } : void 0;
1093
+ } else {
1094
+ this.token = (_b = options == null ? void 0 : options.token) != null ? _b : null;
1095
+ this.onTokenChange = options == null ? void 0 : options.onTokenChange;
1096
+ }
1087
1097
  }
1088
1098
  /**
1089
1099
  * Register a new customer account
@@ -1262,7 +1272,11 @@ var CustomerAuth = class {
1262
1272
  body.error
1263
1273
  );
1264
1274
  }
1265
- return res.json();
1275
+ try {
1276
+ return yield res.json();
1277
+ } catch (e) {
1278
+ throw new ApiError("Invalid JSON response from server", res.status, void 0, "INVALID_RESPONSE");
1279
+ }
1266
1280
  });
1267
1281
  }
1268
1282
  };
@@ -1273,7 +1287,9 @@ function makeQueryClient() {
1273
1287
  return new QueryClient({
1274
1288
  defaultOptions: {
1275
1289
  queries: {
1276
- // SSR/RSC: server-fetched data doesn't auto-refetch; use refetch()/invalidate() to refresh
1290
+ // Infinite staleTime: server-fetched data persists until explicitly invalidated.
1291
+ // For browser clients needing fresher data, override per-query:
1292
+ // useQuery({ ..., staleTime: 5 * 60 * 1000 })
1277
1293
  staleTime: Number.POSITIVE_INFINITY,
1278
1294
  refetchOnWindowFocus: false
1279
1295
  },