@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/README.md +1 -3
- package/dist/{auth-DTkwMgvi.d.cts → auth-BICuhJxS.d.cts} +10 -1
- package/dist/{auth-CWsLf5vd.d.ts → auth-Cj3nVn_P.d.ts} +10 -1
- package/dist/auth.d.cts +2 -2
- package/dist/auth.d.ts +2 -2
- package/dist/components.cjs +51 -29
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +10 -4
- package/dist/components.d.ts +10 -4
- package/dist/components.js +52 -30
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +21 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -19
- package/dist/index.d.ts +28 -19
- package/dist/index.js +21 -5
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.cts +1 -1
- package/dist/metadata.d.ts +1 -1
- package/dist/{payload-types-BFIUYPDZ.d.cts → payload-types-D0px2DCK.d.cts} +72 -2
- package/dist/{payload-types-BFIUYPDZ.d.ts → payload-types-D0px2DCK.d.ts} +72 -2
- package/dist/{webhook-BM5spkSP.d.cts → webhook--_n7O-Ed.d.cts} +1 -1
- package/dist/{webhook-BBp77Khg.d.ts → webhook-vrlAV1K7.d.ts} +1 -1
- package/dist/webhook.d.cts +2 -2
- package/dist/webhook.d.ts +2 -2
- package/package.json +1 -1
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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:
|
|
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:
|
|
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:
|
|
64
|
+
orderProduct: string;
|
|
65
65
|
quantity: number;
|
|
66
66
|
}>;
|
|
67
67
|
refundAmount: number;
|
|
68
68
|
};
|
|
69
69
|
type UpdateReturnParams = {
|
|
70
|
-
returnId:
|
|
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:
|
|
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:
|
|
113
|
-
product:
|
|
114
|
-
variant:
|
|
115
|
-
option:
|
|
112
|
+
cartId: string;
|
|
113
|
+
product: string;
|
|
114
|
+
variant: string;
|
|
115
|
+
option: string;
|
|
116
116
|
quantity: number;
|
|
117
117
|
};
|
|
118
118
|
type UpdateItemParams = {
|
|
119
|
-
cartItemId:
|
|
119
|
+
cartItemId: string;
|
|
120
120
|
quantity: number;
|
|
121
121
|
};
|
|
122
122
|
type RemoveItemParams = {
|
|
123
|
-
cartItemId:
|
|
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:
|
|
146
|
+
optionId: string;
|
|
147
147
|
quantity: number;
|
|
148
148
|
}>;
|
|
149
149
|
};
|
|
150
150
|
type StockCheckResult = {
|
|
151
|
-
optionId:
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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:
|
|
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:
|
|
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:
|
|
64
|
+
orderProduct: string;
|
|
65
65
|
quantity: number;
|
|
66
66
|
}>;
|
|
67
67
|
refundAmount: number;
|
|
68
68
|
};
|
|
69
69
|
type UpdateReturnParams = {
|
|
70
|
-
returnId:
|
|
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:
|
|
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:
|
|
113
|
-
product:
|
|
114
|
-
variant:
|
|
115
|
-
option:
|
|
112
|
+
cartId: string;
|
|
113
|
+
product: string;
|
|
114
|
+
variant: string;
|
|
115
|
+
option: string;
|
|
116
116
|
quantity: number;
|
|
117
117
|
};
|
|
118
118
|
type UpdateItemParams = {
|
|
119
|
-
cartItemId:
|
|
119
|
+
cartItemId: string;
|
|
120
120
|
quantity: number;
|
|
121
121
|
};
|
|
122
122
|
type RemoveItemParams = {
|
|
123
|
-
cartItemId:
|
|
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:
|
|
146
|
+
optionId: string;
|
|
147
147
|
quantity: number;
|
|
148
148
|
}>;
|
|
149
149
|
};
|
|
150
150
|
type StockCheckResult = {
|
|
151
|
-
optionId:
|
|
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
|
-
|
|
1086
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
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
|
},
|