@01.software/sdk 0.2.3 → 0.2.5
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-C7hwnGOb.d.cts → auth-CP8gKMvj.d.cts} +10 -1
- package/dist/{auth-C-9PVtsp.d.ts → auth-j2yUrezU.d.ts} +10 -1
- package/dist/auth.d.cts +2 -2
- package/dist/auth.d.ts +2 -2
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/index.cjs +23 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -23
- package/dist/index.d.ts +32 -23
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/dist/metadata.cjs +2 -1
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +1 -1
- package/dist/metadata.d.ts +1 -1
- package/dist/metadata.js +2 -1
- package/dist/metadata.js.map +1 -1
- package/dist/{payload-types-COjt2QTn.d.cts → payload-types-BFIUYPDZ.d.cts} +587 -574
- package/dist/{payload-types-COjt2QTn.d.ts → payload-types-BFIUYPDZ.d.ts} +587 -574
- package/dist/{webhook-DhK15oyO.d.ts → webhook-BBp77Khg.d.ts} +1 -1
- package/dist/{webhook-CxTZjVol.d.cts → webhook-BM5spkSP.d.cts} +1 -1
- package/dist/webhook.d.cts +2 -2
- package/dist/webhook.d.ts +2 -2
- package/package.json +3 -3
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 {
|
|
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-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-CP8gKMvj.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-CP8gKMvj.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-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';
|
|
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 */
|
|
@@ -644,15 +653,15 @@ declare const formatOrderName: (options: ProductOption[]) => string;
|
|
|
644
653
|
|
|
645
654
|
/**
|
|
646
655
|
* Resolves a Payload CMS relation field value.
|
|
647
|
-
* When depth is 0, relation fields return just the ID (number).
|
|
656
|
+
* When depth is 0, relation fields return just the ID (string or number).
|
|
648
657
|
* When depth > 0, they return the full document object (T).
|
|
649
658
|
* This utility normalizes both cases to T | null.
|
|
650
659
|
*
|
|
651
|
-
* @param ref - The relation field value (T, number, null, or undefined)
|
|
660
|
+
* @param ref - The relation field value (T, string, number, null, or undefined)
|
|
652
661
|
* @returns The resolved document object, or null if not populated
|
|
653
662
|
*/
|
|
654
|
-
declare const resolveRelation: <T>(ref: T | number | null | undefined) => T | null;
|
|
663
|
+
declare const resolveRelation: <T>(ref: T | string | number | null | undefined) => T | null;
|
|
655
664
|
/** @deprecated Use `resolveRelation` instead */
|
|
656
|
-
declare const objectFor: <T>(ref: T | number | null | undefined) => T | null;
|
|
665
|
+
declare const objectFor: <T>(ref: T | string | number | null | undefined) => T | null;
|
|
657
666
|
|
|
658
667
|
export { type AddItemParams, ApiQueryOptions, BrowserClient, BrowserClient as BrowserClientType, CartApi, type CartApiOptions, CartItem, type CheckoutParams, ClientBrowserConfig, ClientServerConfig, ClientState, CollectionClient, type CollectionDetailQueryParams, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType, type CreateFulfillmentParams, type CreateOrderParams, type CreateReturnParams, CustomerAuth, type CustomerAuthOptions, type CustomerAuthResponse, type CustomerLoginData, type CustomerProfile, type CustomerRefreshResponse, type CustomerRegisterData, Fulfillment, type GetOrderParams, Order, OrderApi, type OrderApiOptions, OrderProduct, PayloadFindResponse, PayloadMutationResponse, ProductApi, type ProductApiOptions, ProductOption, PublicCollection, QueryHooks, type ReadOnlyQueryBuilder, type ReadOnlyQueryHooks, type RemoveItemParams, Return, type ReturnWithRefundParams, ServerClient, ServerClient as ServerClientType, type StockCheckParams, type StockCheckResponse, type StockCheckResult, Transaction, type UpdateItemParams, type UpdateOrderParams, type UpdateReturnParams, type UpdateTransactionParams, collectionKeys, createBrowserClient, createServerClient, customerKeys, formatOrderName, generateOrderNumber, getQueryClient, objectFor, resolveRelation };
|
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 {
|
|
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-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-j2yUrezU.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-j2yUrezU.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-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';
|
|
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 */
|
|
@@ -644,15 +653,15 @@ declare const formatOrderName: (options: ProductOption[]) => string;
|
|
|
644
653
|
|
|
645
654
|
/**
|
|
646
655
|
* Resolves a Payload CMS relation field value.
|
|
647
|
-
* When depth is 0, relation fields return just the ID (number).
|
|
656
|
+
* When depth is 0, relation fields return just the ID (string or number).
|
|
648
657
|
* When depth > 0, they return the full document object (T).
|
|
649
658
|
* This utility normalizes both cases to T | null.
|
|
650
659
|
*
|
|
651
|
-
* @param ref - The relation field value (T, number, null, or undefined)
|
|
660
|
+
* @param ref - The relation field value (T, string, number, null, or undefined)
|
|
652
661
|
* @returns The resolved document object, or null if not populated
|
|
653
662
|
*/
|
|
654
|
-
declare const resolveRelation: <T>(ref: T | number | null | undefined) => T | null;
|
|
663
|
+
declare const resolveRelation: <T>(ref: T | string | number | null | undefined) => T | null;
|
|
655
664
|
/** @deprecated Use `resolveRelation` instead */
|
|
656
|
-
declare const objectFor: <T>(ref: T | number | null | undefined) => T | null;
|
|
665
|
+
declare const objectFor: <T>(ref: T | string | number | null | undefined) => T | null;
|
|
657
666
|
|
|
658
667
|
export { type AddItemParams, ApiQueryOptions, BrowserClient, BrowserClient as BrowserClientType, CartApi, type CartApiOptions, CartItem, type CheckoutParams, ClientBrowserConfig, ClientServerConfig, ClientState, CollectionClient, type CollectionDetailQueryParams, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType, type CreateFulfillmentParams, type CreateOrderParams, type CreateReturnParams, CustomerAuth, type CustomerAuthOptions, type CustomerAuthResponse, type CustomerLoginData, type CustomerProfile, type CustomerRefreshResponse, type CustomerRegisterData, Fulfillment, type GetOrderParams, Order, OrderApi, type OrderApiOptions, OrderProduct, PayloadFindResponse, PayloadMutationResponse, ProductApi, type ProductApiOptions, ProductOption, PublicCollection, QueryHooks, type ReadOnlyQueryBuilder, type ReadOnlyQueryHooks, type RemoveItemParams, Return, type ReturnWithRefundParams, ServerClient, ServerClient as ServerClientType, type StockCheckParams, type StockCheckResponse, type StockCheckResult, Transaction, type UpdateItemParams, type UpdateOrderParams, type UpdateReturnParams, type UpdateTransactionParams, collectionKeys, createBrowserClient, createServerClient, customerKeys, formatOrderName, generateOrderNumber, getQueryClient, objectFor, resolveRelation };
|
package/dist/index.js
CHANGED
|
@@ -633,7 +633,8 @@ var ProductApi = class {
|
|
|
633
633
|
|
|
634
634
|
// src/utils/types.ts
|
|
635
635
|
var resolveRelation = (ref) => {
|
|
636
|
-
if (typeof ref === "number" || ref === null || ref === void 0)
|
|
636
|
+
if (typeof ref === "string" || typeof ref === "number" || ref === null || ref === void 0)
|
|
637
|
+
return null;
|
|
637
638
|
return ref;
|
|
638
639
|
};
|
|
639
640
|
var objectFor = resolveRelation;
|
|
@@ -1078,11 +1079,21 @@ var COLLECTIONS = [
|
|
|
1078
1079
|
var DEFAULT_TIMEOUT2 = 15e3;
|
|
1079
1080
|
var CustomerAuth = class {
|
|
1080
1081
|
constructor(clientKey, baseUrl, options) {
|
|
1081
|
-
var _a;
|
|
1082
|
+
var _a, _b;
|
|
1082
1083
|
this.clientKey = clientKey;
|
|
1083
1084
|
this.baseUrl = baseUrl;
|
|
1084
|
-
|
|
1085
|
-
|
|
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
|
+
}
|
|
1086
1097
|
}
|
|
1087
1098
|
/**
|
|
1088
1099
|
* Register a new customer account
|
|
@@ -1261,7 +1272,11 @@ var CustomerAuth = class {
|
|
|
1261
1272
|
body.error
|
|
1262
1273
|
);
|
|
1263
1274
|
}
|
|
1264
|
-
|
|
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
|
+
}
|
|
1265
1280
|
});
|
|
1266
1281
|
}
|
|
1267
1282
|
};
|
|
@@ -1272,7 +1287,9 @@ function makeQueryClient() {
|
|
|
1272
1287
|
return new QueryClient({
|
|
1273
1288
|
defaultOptions: {
|
|
1274
1289
|
queries: {
|
|
1275
|
-
//
|
|
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 })
|
|
1276
1293
|
staleTime: Number.POSITIVE_INFINITY,
|
|
1277
1294
|
refetchOnWindowFocus: false
|
|
1278
1295
|
},
|