@01.software/sdk 0.20.0 → 0.22.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.
- package/README.md +6 -3
- package/dist/{const-BApEF1Hu.d.cts → const-CfcjPbOu.d.ts} +2 -2
- package/dist/{const-BNJRuk3V.d.ts → const-DraU44bA.d.cts} +2 -2
- package/dist/index.cjs +198 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1357
- package/dist/index.d.ts +13 -1357
- package/dist/index.js +198 -19
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-D7lnu9By.d.cts → payload-types-DeLBmtzd.d.cts} +77 -3
- package/dist/{payload-types-D7lnu9By.d.ts → payload-types-DeLBmtzd.d.ts} +77 -3
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/server-BARh_6zH.d.ts +1397 -0
- package/dist/server-BcQr-nGn.d.cts +1397 -0
- package/dist/server.cjs +2049 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +7 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +2044 -0
- package/dist/server.js.map +1 -0
- package/dist/types-D7iFEsPc.d.cts +23 -0
- package/dist/types-KkuKwsli.d.ts +23 -0
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.d.cts +42 -3
- package/dist/webhook.d.ts +42 -3
- package/package.json +16 -6
- package/dist/webhook-C4BwXP5T.d.cts +0 -61
- package/dist/webhook-C6vne8Ve.d.ts +0 -61
package/dist/index.d.cts
CHANGED
|
@@ -1,780 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as Article,
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { QueryClient
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
export {
|
|
9
|
-
import { P as PublicCollection } from './const-BApEF1Hu.cjs';
|
|
10
|
-
export { a as COLLECTIONS, C as Collection, I as INTERNAL_COLLECTIONS } from './const-BApEF1Hu.cjs';
|
|
11
|
-
import { UpdateTransactionParams, ReturnWithRefundParams } from '@01.software/contracts';
|
|
12
|
-
export { ReturnWithRefundParams, UpdateTransactionParams } from '@01.software/contracts';
|
|
1
|
+
import { c as Cart, d as CartItem, O as Order, e as Product } from './payload-types-DeLBmtzd.cjs';
|
|
2
|
+
export { A as Article, f as ArticleAuthor, g as ArticleCategory, h as ArticleTag, D as Document, I as Image, P as Post, i as PostCategory, j as ProductVariant, T as Tenant, V as Video } from './payload-types-DeLBmtzd.cjs';
|
|
3
|
+
import { C as CustomerAuth, a as CustomerAuthOptions, S as StockCheckParams, b as StockCheckResponse, L as ListingGroupsParams, P as ProductListingGroupsResponse, A as AddItemParams, U as UpdateItemParams, R as RemoveItemParams, c as ApplyDiscountParams, d as RemoveDiscountParams, e as ClearCartParams, f as CheckoutParams, g as PayloadFindResponse, V as ValidateDiscountParams, h as ValidateDiscountResult, i as CalculateShippingParams, j as CalculateShippingResult, k as ApiQueryOptions, l as ProductListingGroupsQueryOptions, m as ClientConfig, n as CommunityClient, o as ReadOnlyQueryHooks, p as ReadOnlyCollectionClient, q as ClientState } from './server-BcQr-nGn.cjs';
|
|
4
|
+
export { v as ApiError, z as AuthError, aT as BanCustomerParams, af as BaseApi, ap as BulkImportFulfillmentsParams, aq as BulkImportFulfillmentsResponse, aB as CartApi, aC as CartApiOptions, ac as ClientMetadata, ab as ClientServerConfig, aK as CollectionClient, b1 as CollectionDetailQueryParams, b7 as CollectionHooks, b2 as CollectionInfiniteQueryParams, aI as CollectionQueryBuilder, b0 as CollectionQueryParams, aS as CommunityBan, aO as CommunityClientOptions, aP as CommunityPost, w as ConfigError, H as ConflictError, au as CreateFulfillmentParams, an as CreateOrderParams, ar as CreateReturnParams, aV as CustomerAuthResponse, b8 as CustomerHooks, a_ as CustomerLoginData, aY as CustomerProfile, aW as CustomerRefreshResponse, aZ as CustomerRegisterData, aX as CustomerRegisterResponse, ak as CustomerSnapshot, r as DebugConfig, D as DeepPartial, ax as DiscountApi, ay as DiscountApiOptions, E as ExtractArrayType, aL as GenerateMetadataOptions, G as GoneError, b5 as InfiniteQueryOptions, aQ as ModerationApi, aR as ModerationApiOptions, N as NetworkError, F as NotFoundError, ai as OrderApi, aj as OrderApiOptions, ad as PaginationMeta, ae as PayloadMutationResponse, B as PermissionError, aD as ProductApi, aE as ProductApiOptions, bj as ProductListingGroup, aF as ProductListingGroupSummary, aG as ProductListingGroupsItem, bd as ProductListingProductShape, bi as ProductListingProjection, bh as ProductOptionMatrix, bf as ProductOptionMatrixOption, be as ProductOptionMatrixValue, bg as ProductOptionMatrixVariant, bb as ProductOptionShape, ba as ProductOptionValueShape, bc as ProductVariantShape, b9 as QueryHooks, b3 as QueryOptions, I as RateLimitError, aJ as ReadOnlyQueryBuilder, ah as RequestOptions, s as RetryConfig, am as ReturnItem, al as ReturnReason, av as ReturnWithRefundParams, t as SDKError, ag as ServerApiOptions, a9 as ServerClient, a9 as ServerClientType, aM as ServerCommerceClient, aN as ServerCommerceClientOptions, x as ServiceUnavailableError, az as ShippingApi, aA as ShippingApiOptions, aH as StockCheckResult, b6 as SuspenseInfiniteQueryOptions, b4 as SuspenseQueryOptions, T as TimeoutError, aU as UnbanCustomerParams, aw as UpdateFulfillmentParams, ao as UpdateOrderParams, a$ as UpdateProfileData, as as UpdateReturnParams, at as UpdateTransactionParams, y as UsageLimitError, u as ValidationError, bq as buildProductListingGroupsByOption, bp as buildProductListingProjection, bk as buildProductOptionMatrix, a3 as createAuthError, a6 as createConflictError, a5 as createNotFoundError, a4 as createPermissionError, a7 as createRateLimitError, a8 as createServerClient, bn as getAvailableOptionValues, bl as getSelectedValueByOptionId, O as isApiError, _ as isAuthError, Q as isConfigError, a1 as isConflictError, X as isGoneError, K as isNetworkError, a0 as isNotFoundError, $ as isPermissionError, a2 as isRateLimitError, J as isSDKError, Y as isServiceUnavailableError, W as isTimeoutError, Z as isUsageLimitError, M as isValidationError, bm as normalizeSelectedValueIds, aa as resolveApiUrl, bo as resolveVariantForSelection } from './server-BcQr-nGn.cjs';
|
|
5
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
+
export { C as CollectionType } from './types-D7iFEsPc.cjs';
|
|
7
|
+
import { P as PublicCollection } from './const-DraU44bA.cjs';
|
|
8
|
+
export { a as COLLECTIONS, C as Collection, I as INTERNAL_COLLECTIONS } from './const-DraU44bA.cjs';
|
|
13
9
|
export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
|
|
10
|
+
export { CUSTOMER_PASSWORD_RESET_OPERATION, CustomerAuthWebhookEvent, CustomerAuthWebhookHandlers, CustomerPasswordResetWebhookData, CustomerPasswordResetWebhookEvent, WebhookEvent, WebhookHandler, WebhookOperation, WebhookOptions, createCustomerAuthWebhookHandler, createTypedWebhookHandler, handleWebhook, isCustomerPasswordResetWebhookEvent, isValidWebhookEvent } from './webhook.cjs';
|
|
14
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';
|
|
15
12
|
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';
|
|
16
13
|
export { Analytics, AnalyticsConfig, createAnalytics } from './analytics.cjs';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
interface ClientConfig {
|
|
20
|
-
publishableKey: string;
|
|
21
|
-
/**
|
|
22
|
-
* Customer authentication options.
|
|
23
|
-
* Used to initialize CustomerAuth on Client.
|
|
24
|
-
*/
|
|
25
|
-
customer?: {
|
|
26
|
-
/**
|
|
27
|
-
* Persist token in localStorage. Defaults to `true`.
|
|
28
|
-
* - `true` (default): uses key `'customer-token'`
|
|
29
|
-
* - `string`: uses the given string as localStorage key
|
|
30
|
-
* - `false`: disables persistence (token/onTokenChange used instead)
|
|
31
|
-
*
|
|
32
|
-
* Handles SSR safely (no-op on server).
|
|
33
|
-
* When enabled, `token` and `onTokenChange` are ignored.
|
|
34
|
-
*/
|
|
35
|
-
persist?: boolean | string;
|
|
36
|
-
/** Initial token (e.g. from SSR cookie) */
|
|
37
|
-
token?: string;
|
|
38
|
-
/** Called when token changes (login/logout) — use to persist in localStorage/cookie */
|
|
39
|
-
onTokenChange?: (token: string | null) => void;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
interface ClientServerConfig extends ClientConfig {
|
|
43
|
-
secretKey: string;
|
|
44
|
-
}
|
|
45
|
-
interface ClientMetadata {
|
|
46
|
-
userAgent?: string;
|
|
47
|
-
timestamp: number;
|
|
48
|
-
}
|
|
49
|
-
interface ClientState {
|
|
50
|
-
metadata: ClientMetadata;
|
|
51
|
-
}
|
|
52
|
-
interface PaginationMeta {
|
|
53
|
-
page: number;
|
|
54
|
-
limit: number;
|
|
55
|
-
totalDocs: number;
|
|
56
|
-
totalPages: number;
|
|
57
|
-
hasNextPage: boolean;
|
|
58
|
-
hasPrevPage: boolean;
|
|
59
|
-
pagingCounter: number;
|
|
60
|
-
prevPage: number | null;
|
|
61
|
-
nextPage: number | null;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Payload CMS Find (List) Response
|
|
65
|
-
* GET /api/{collection}
|
|
66
|
-
*/
|
|
67
|
-
interface PayloadFindResponse<T = unknown> {
|
|
68
|
-
docs: T[];
|
|
69
|
-
totalDocs: number;
|
|
70
|
-
limit: number;
|
|
71
|
-
totalPages: number;
|
|
72
|
-
page: number;
|
|
73
|
-
pagingCounter: number;
|
|
74
|
-
hasPrevPage: boolean;
|
|
75
|
-
hasNextPage: boolean;
|
|
76
|
-
prevPage: number | null;
|
|
77
|
-
nextPage: number | null;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Payload CMS Create/Update Response
|
|
81
|
-
* POST /api/{collection}
|
|
82
|
-
* PATCH /api/{collection}/{id}
|
|
83
|
-
*/
|
|
84
|
-
interface PayloadMutationResponse<T = unknown> {
|
|
85
|
-
message: string;
|
|
86
|
-
doc: T;
|
|
87
|
-
errors?: unknown[];
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Do NOT replace with `Pick<FindOptions>` from `payload`. Payload's generic
|
|
91
|
-
* types (`JoinQuery<TSlug>`, `PopulateType`) depend on `PayloadTypes` module
|
|
92
|
-
* augmentation; external SDK consumers who skip that get degenerate types
|
|
93
|
-
* (`never` / `{}`). Only non-generic `Sort`/`Where` are safe to import.
|
|
94
|
-
* Excluded vs native: Local-API-only fields, `locale`/`fallbackLocale`.
|
|
95
|
-
*/
|
|
96
|
-
interface ApiQueryOptions {
|
|
97
|
-
page?: number;
|
|
98
|
-
limit?: number;
|
|
99
|
-
sort?: Sort;
|
|
100
|
-
where?: Where;
|
|
101
|
-
depth?: number;
|
|
102
|
-
select?: Record<string, boolean>;
|
|
103
|
-
/** Per-collection field selection for populated relationships (keyed by collection slug) */
|
|
104
|
-
populate?: Record<string, boolean | Record<string, boolean>>;
|
|
105
|
-
/** Join field control: pagination/filter per join, or false to disable */
|
|
106
|
-
joins?: Record<string, {
|
|
107
|
-
limit?: number;
|
|
108
|
-
page?: number;
|
|
109
|
-
sort?: string;
|
|
110
|
-
where?: Where;
|
|
111
|
-
count?: boolean;
|
|
112
|
-
} | false> | false;
|
|
113
|
-
/** Set to `false` to skip the count query — returns docs without totalDocs/totalPages */
|
|
114
|
-
pagination?: boolean;
|
|
115
|
-
/** Include draft versions (access control still applies on the server) */
|
|
116
|
-
draft?: boolean;
|
|
117
|
-
/** Include soft-deleted documents (requires `trash` enabled on the collection) */
|
|
118
|
-
trash?: boolean;
|
|
119
|
-
}
|
|
120
|
-
interface DebugConfig {
|
|
121
|
-
logRequests?: boolean;
|
|
122
|
-
logResponses?: boolean;
|
|
123
|
-
logErrors?: boolean;
|
|
124
|
-
}
|
|
125
|
-
interface RetryConfig {
|
|
126
|
-
maxRetries?: number;
|
|
127
|
-
retryableStatuses?: number[];
|
|
128
|
-
retryDelay?: (attempt: number) => number;
|
|
129
|
-
}
|
|
130
|
-
type DeepPartial<T> = {
|
|
131
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
132
|
-
};
|
|
133
|
-
type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
|
|
134
|
-
|
|
135
|
-
interface GenerateMetadataOptions {
|
|
136
|
-
siteName?: string;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
declare class SDKError extends Error {
|
|
140
|
-
readonly code: string;
|
|
141
|
-
readonly status?: number;
|
|
142
|
-
readonly details?: unknown;
|
|
143
|
-
readonly userMessage?: string;
|
|
144
|
-
readonly suggestion?: string;
|
|
145
|
-
readonly requestId?: string;
|
|
146
|
-
constructor(code: string, message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
|
|
147
|
-
getUserMessage(): string;
|
|
148
|
-
toJSON(): {
|
|
149
|
-
requestId?: string | undefined;
|
|
150
|
-
name: string;
|
|
151
|
-
code: string;
|
|
152
|
-
message: string;
|
|
153
|
-
status: number | undefined;
|
|
154
|
-
details: unknown;
|
|
155
|
-
userMessage: string | undefined;
|
|
156
|
-
suggestion: string | undefined;
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
declare class NetworkError extends SDKError {
|
|
160
|
-
constructor(message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
161
|
-
}
|
|
162
|
-
declare class ValidationError extends SDKError {
|
|
163
|
-
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
164
|
-
}
|
|
165
|
-
declare class ApiError extends SDKError {
|
|
166
|
-
constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
167
|
-
}
|
|
168
|
-
declare class ConfigError extends SDKError {
|
|
169
|
-
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
170
|
-
}
|
|
171
|
-
declare class TimeoutError extends SDKError {
|
|
172
|
-
constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
173
|
-
}
|
|
174
|
-
declare class GoneError extends SDKError {
|
|
175
|
-
constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
176
|
-
}
|
|
177
|
-
declare class ServiceUnavailableError extends SDKError {
|
|
178
|
-
readonly retryAfter?: number;
|
|
179
|
-
constructor(message?: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
180
|
-
}
|
|
181
|
-
declare class UsageLimitError extends SDKError {
|
|
182
|
-
readonly usage: {
|
|
183
|
-
limit: number;
|
|
184
|
-
current: number;
|
|
185
|
-
remaining: number;
|
|
186
|
-
};
|
|
187
|
-
constructor(message: string, usage: {
|
|
188
|
-
limit: number;
|
|
189
|
-
current: number;
|
|
190
|
-
remaining: number;
|
|
191
|
-
}, details?: unknown, userMessage?: string, suggestion?: string);
|
|
192
|
-
toJSON(): {
|
|
193
|
-
usage: {
|
|
194
|
-
limit: number;
|
|
195
|
-
current: number;
|
|
196
|
-
remaining: number;
|
|
197
|
-
};
|
|
198
|
-
requestId?: string | undefined;
|
|
199
|
-
name: string;
|
|
200
|
-
code: string;
|
|
201
|
-
message: string;
|
|
202
|
-
status: number | undefined;
|
|
203
|
-
details: unknown;
|
|
204
|
-
userMessage: string | undefined;
|
|
205
|
-
suggestion: string | undefined;
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
declare class AuthError extends SDKError {
|
|
209
|
-
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
|
|
210
|
-
}
|
|
211
|
-
declare class PermissionError extends SDKError {
|
|
212
|
-
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
|
|
213
|
-
}
|
|
214
|
-
declare class NotFoundError extends SDKError {
|
|
215
|
-
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
|
|
216
|
-
}
|
|
217
|
-
declare class ConflictError extends SDKError {
|
|
218
|
-
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
|
|
219
|
-
}
|
|
220
|
-
declare class RateLimitError extends SDKError {
|
|
221
|
-
readonly retryAfter?: number;
|
|
222
|
-
constructor(message: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
|
|
223
|
-
}
|
|
224
|
-
declare function isSDKError(error: unknown): error is SDKError;
|
|
225
|
-
declare function isNetworkError(error: unknown): error is NetworkError;
|
|
226
|
-
declare function isValidationError(error: unknown): error is ValidationError;
|
|
227
|
-
declare function isApiError(error: unknown): error is ApiError;
|
|
228
|
-
declare function isConfigError(error: unknown): error is ConfigError;
|
|
229
|
-
declare function isTimeoutError(error: unknown): error is TimeoutError;
|
|
230
|
-
declare function isGoneError(error: unknown): error is GoneError;
|
|
231
|
-
declare function isServiceUnavailableError(error: unknown): error is ServiceUnavailableError;
|
|
232
|
-
declare function isUsageLimitError(error: unknown): error is UsageLimitError;
|
|
233
|
-
declare function isAuthError(error: unknown): error is AuthError;
|
|
234
|
-
declare function isPermissionError(error: unknown): error is PermissionError;
|
|
235
|
-
declare function isNotFoundError(error: unknown): error is NotFoundError;
|
|
236
|
-
declare function isConflictError(error: unknown): error is ConflictError;
|
|
237
|
-
declare function isRateLimitError(error: unknown): error is RateLimitError;
|
|
238
|
-
declare const createAuthError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => AuthError;
|
|
239
|
-
declare const createPermissionError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => PermissionError;
|
|
240
|
-
declare const createNotFoundError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => NotFoundError;
|
|
241
|
-
declare const createConflictError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => ConflictError;
|
|
242
|
-
declare const createRateLimitError: (message: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => RateLimitError;
|
|
243
|
-
|
|
244
|
-
interface FetchOptions extends RequestInit {
|
|
245
|
-
publishableKey?: string;
|
|
246
|
-
secretKey?: string;
|
|
247
|
-
customerToken?: string;
|
|
248
|
-
timeout?: number;
|
|
249
|
-
debug?: boolean | DebugConfig;
|
|
250
|
-
retry?: RetryConfig;
|
|
251
|
-
/** Called on 401 when customerToken is set and reason=token_expired. Return a new token to retry, or null to fail. */
|
|
252
|
-
onUnauthorized?: () => Promise<string | null>;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
declare class HttpClient {
|
|
256
|
-
protected publishableKey: string;
|
|
257
|
-
protected secretKey?: string;
|
|
258
|
-
private getCustomerToken?;
|
|
259
|
-
private onUnauthorized?;
|
|
260
|
-
private onRequestId?;
|
|
261
|
-
constructor(publishableKey: string, secretKey?: string, getCustomerToken?: () => string | null, onUnauthorized?: () => Promise<string | null>, onRequestId?: (id: string | null) => void);
|
|
262
|
-
protected get defaultOptions(): FetchOptions;
|
|
263
|
-
protected fetchWithTracking(url: string, opts: FetchOptions): Promise<Response>;
|
|
264
|
-
protected buildUrl(endpoint: string, options?: ApiQueryOptions): string;
|
|
265
|
-
protected assertJsonResponse(response: Response): void;
|
|
266
|
-
/**
|
|
267
|
-
* Parse Payload CMS find response (list query)
|
|
268
|
-
* Returns native Payload response structure
|
|
269
|
-
*/
|
|
270
|
-
protected parseFindResponse<T>(response: Response): Promise<PayloadFindResponse<T>>;
|
|
271
|
-
/**
|
|
272
|
-
* Parse Payload CMS mutation response (create/update)
|
|
273
|
-
* Returns native Payload response structure
|
|
274
|
-
*/
|
|
275
|
-
protected parseMutationResponse<T>(response: Response): Promise<PayloadMutationResponse<T>>;
|
|
276
|
-
/**
|
|
277
|
-
* Parse Payload CMS document response (findById/delete)
|
|
278
|
-
* Returns document directly without wrapper
|
|
279
|
-
*/
|
|
280
|
-
protected parseDocumentResponse<T>(response: Response): Promise<T>;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
declare class CollectionClient extends HttpClient {
|
|
284
|
-
from<T extends PublicCollection>(collection: T): CollectionQueryBuilder<T>;
|
|
285
|
-
/**
|
|
286
|
-
* Find documents (list query)
|
|
287
|
-
* GET /api/{collection}
|
|
288
|
-
*/
|
|
289
|
-
requestFind<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<PayloadFindResponse<T>>;
|
|
290
|
-
/**
|
|
291
|
-
* Find-like response from a custom endpoint
|
|
292
|
-
* POST /api/...custom-endpoint
|
|
293
|
-
*/
|
|
294
|
-
requestFindEndpoint<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadFindResponse<T>>;
|
|
295
|
-
/**
|
|
296
|
-
* Find document by ID
|
|
297
|
-
* GET /api/{collection}/{id}
|
|
298
|
-
*/
|
|
299
|
-
requestFindById<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<T>;
|
|
300
|
-
/**
|
|
301
|
-
* Create document
|
|
302
|
-
* POST /api/{collection}
|
|
303
|
-
*/
|
|
304
|
-
requestCreate<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadMutationResponse<T>>;
|
|
305
|
-
/**
|
|
306
|
-
* Update document
|
|
307
|
-
* PATCH /api/{collection}/{id}
|
|
308
|
-
*/
|
|
309
|
-
requestUpdate<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadMutationResponse<T>>;
|
|
310
|
-
/**
|
|
311
|
-
* Count documents
|
|
312
|
-
* GET /api/{collection}/count
|
|
313
|
-
*/
|
|
314
|
-
requestCount(endpoint: string, options?: ApiQueryOptions): Promise<{
|
|
315
|
-
totalDocs: number;
|
|
316
|
-
}>;
|
|
317
|
-
/**
|
|
318
|
-
* Update multiple documents (bulk update)
|
|
319
|
-
* PATCH /api/{collection}
|
|
320
|
-
*/
|
|
321
|
-
requestUpdateMany<T = unknown>(endpoint: string, data: {
|
|
322
|
-
where?: unknown;
|
|
323
|
-
data: unknown;
|
|
324
|
-
}): Promise<PayloadFindResponse<T>>;
|
|
325
|
-
/**
|
|
326
|
-
* Delete document
|
|
327
|
-
* DELETE /api/{collection}/{id}
|
|
328
|
-
*/
|
|
329
|
-
requestDelete<T = unknown>(endpoint: string): Promise<T>;
|
|
330
|
-
/**
|
|
331
|
-
* Delete multiple documents (bulk delete)
|
|
332
|
-
* DELETE /api/{collection}
|
|
333
|
-
*/
|
|
334
|
-
requestDeleteMany<T = unknown>(endpoint: string, data: {
|
|
335
|
-
where?: unknown;
|
|
336
|
-
}): Promise<PayloadFindResponse<T>>;
|
|
337
|
-
/**
|
|
338
|
-
* Create document with file upload
|
|
339
|
-
* POST /api/{collection} (multipart/form-data)
|
|
340
|
-
*/
|
|
341
|
-
requestCreateWithFile<T = unknown>(endpoint: string, data: unknown, file: File | Blob, filename?: string): Promise<PayloadMutationResponse<T>>;
|
|
342
|
-
/**
|
|
343
|
-
* Update document with file upload
|
|
344
|
-
* PATCH /api/{collection}/{id} (multipart/form-data)
|
|
345
|
-
*/
|
|
346
|
-
requestUpdateWithFile<T = unknown>(endpoint: string, data: unknown, file: File | Blob, filename?: string): Promise<PayloadMutationResponse<T>>;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Read-only subset of CollectionQueryBuilder.
|
|
351
|
-
* Client.from() returns this type to prevent write operations at compile time.
|
|
352
|
-
*/
|
|
353
|
-
type ReadOnlyQueryBuilder<T extends PublicCollection> = Pick<CollectionQueryBuilder<T>, 'find' | 'findById' | 'count' | 'findMetadata' | 'findMetadataById'>;
|
|
354
|
-
declare class CollectionQueryBuilder<T extends PublicCollection> {
|
|
355
|
-
private api;
|
|
356
|
-
private collection;
|
|
357
|
-
constructor(api: CollectionClient, collection: T);
|
|
358
|
-
/**
|
|
359
|
-
* Find documents (list query)
|
|
360
|
-
* GET /api/{collection}
|
|
361
|
-
* @returns Payload CMS find response with docs array and pagination
|
|
362
|
-
*/
|
|
363
|
-
find(options?: ApiQueryOptions): Promise<PayloadFindResponse<CollectionType<T>>>;
|
|
364
|
-
/**
|
|
365
|
-
* Find document by ID
|
|
366
|
-
* GET /api/{collection}/{id}
|
|
367
|
-
* @returns Document object directly (no wrapper)
|
|
368
|
-
*/
|
|
369
|
-
findById(id: string | number, options?: ApiQueryOptions): Promise<CollectionType<T>>;
|
|
370
|
-
/**
|
|
371
|
-
* Create a new document
|
|
372
|
-
* POST /api/{collection}
|
|
373
|
-
* @returns Payload CMS mutation response with doc and message
|
|
374
|
-
*/
|
|
375
|
-
create(data: Partial<CollectionType<T>>, options?: {
|
|
376
|
-
file?: File | Blob;
|
|
377
|
-
filename?: string;
|
|
378
|
-
}): Promise<PayloadMutationResponse<CollectionType<T>>>;
|
|
379
|
-
/**
|
|
380
|
-
* Update a document by ID
|
|
381
|
-
* PATCH /api/{collection}/{id}
|
|
382
|
-
* @returns Payload CMS mutation response with doc and message
|
|
383
|
-
*/
|
|
384
|
-
update(id: string, data: Partial<CollectionType<T>>, options?: {
|
|
385
|
-
file?: File | Blob;
|
|
386
|
-
filename?: string;
|
|
387
|
-
}): Promise<PayloadMutationResponse<CollectionType<T>>>;
|
|
388
|
-
/**
|
|
389
|
-
* Count documents
|
|
390
|
-
* GET /api/{collection}/count
|
|
391
|
-
* @returns Count response with totalDocs
|
|
392
|
-
*/
|
|
393
|
-
count(options?: ApiQueryOptions): Promise<{
|
|
394
|
-
totalDocs: number;
|
|
395
|
-
}>;
|
|
396
|
-
/**
|
|
397
|
-
* Find first matching document and return its Next.js Metadata.
|
|
398
|
-
* Applies depth: 1 (SEO image populate) and limit: 1 automatically.
|
|
399
|
-
* @returns Metadata or null if no document matches
|
|
400
|
-
*/
|
|
401
|
-
findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
|
|
402
|
-
/**
|
|
403
|
-
* Find document by ID and return its Next.js Metadata.
|
|
404
|
-
* Applies depth: 1 (SEO image populate) automatically.
|
|
405
|
-
* @returns Metadata (throws on 404)
|
|
406
|
-
*/
|
|
407
|
-
findMetadataById(id: string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
|
|
408
|
-
/**
|
|
409
|
-
* Update multiple documents (bulk update)
|
|
410
|
-
* PATCH /api/{collection}
|
|
411
|
-
* @returns Payload CMS find response with updated docs
|
|
412
|
-
*/
|
|
413
|
-
updateMany(where: ApiQueryOptions['where'], data: Partial<CollectionType<T>>): Promise<PayloadFindResponse<CollectionType<T>>>;
|
|
414
|
-
/**
|
|
415
|
-
* Delete a document by ID
|
|
416
|
-
* DELETE /api/{collection}/{id}
|
|
417
|
-
* @returns Deleted document object directly (no wrapper)
|
|
418
|
-
*/
|
|
419
|
-
remove(id: string): Promise<CollectionType<T>>;
|
|
420
|
-
/**
|
|
421
|
-
* Delete multiple documents (bulk delete)
|
|
422
|
-
* DELETE /api/{collection}
|
|
423
|
-
* @returns Payload CMS find response with deleted docs
|
|
424
|
-
*/
|
|
425
|
-
removeMany(where: ApiQueryOptions['where']): Promise<PayloadFindResponse<CollectionType<T>>>;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
interface CommunityClientOptions {
|
|
429
|
-
publishableKey?: string;
|
|
430
|
-
secretKey?: string;
|
|
431
|
-
customerToken?: string | (() => string | null);
|
|
432
|
-
onUnauthorized?: () => Promise<string | null>;
|
|
433
|
-
onRequestId?: (id: string | null) => void;
|
|
434
|
-
}
|
|
435
|
-
interface CommunityPost {
|
|
436
|
-
id: string;
|
|
437
|
-
title: string;
|
|
438
|
-
content: unknown;
|
|
439
|
-
categories?: string[];
|
|
440
|
-
thumbnail?: string;
|
|
441
|
-
viewCount?: number;
|
|
442
|
-
createdAt?: string;
|
|
443
|
-
updatedAt?: string;
|
|
444
|
-
[key: string]: unknown;
|
|
445
|
-
}
|
|
446
|
-
interface Comment {
|
|
447
|
-
id: string;
|
|
448
|
-
body: string;
|
|
449
|
-
post?: string;
|
|
450
|
-
parent?: string;
|
|
451
|
-
rootComment?: string;
|
|
452
|
-
createdAt?: string;
|
|
453
|
-
updatedAt?: string;
|
|
454
|
-
[key: string]: unknown;
|
|
455
|
-
}
|
|
456
|
-
interface Reaction {
|
|
457
|
-
id: string;
|
|
458
|
-
post?: string;
|
|
459
|
-
comment?: string;
|
|
460
|
-
type?: string;
|
|
461
|
-
createdAt?: string;
|
|
462
|
-
[key: string]: unknown;
|
|
463
|
-
}
|
|
464
|
-
interface ReactionSummary {
|
|
465
|
-
counts: Record<string, number>;
|
|
466
|
-
total: number;
|
|
467
|
-
userReactions: string[];
|
|
468
|
-
}
|
|
469
|
-
interface Bookmark {
|
|
470
|
-
id: string;
|
|
471
|
-
post?: string;
|
|
472
|
-
createdAt?: string;
|
|
473
|
-
[key: string]: unknown;
|
|
474
|
-
}
|
|
475
|
-
interface ReactionType {
|
|
476
|
-
id: string;
|
|
477
|
-
title: string;
|
|
478
|
-
slug: string;
|
|
479
|
-
emoji?: string;
|
|
480
|
-
[key: string]: unknown;
|
|
481
|
-
}
|
|
482
|
-
interface PaginatedResponse<T> {
|
|
483
|
-
docs: T[];
|
|
484
|
-
totalDocs: number;
|
|
485
|
-
limit: number;
|
|
486
|
-
totalPages: number;
|
|
487
|
-
page: number;
|
|
488
|
-
pagingCounter: number;
|
|
489
|
-
hasPrevPage: boolean;
|
|
490
|
-
hasNextPage: boolean;
|
|
491
|
-
prevPage: number | null;
|
|
492
|
-
nextPage: number | null;
|
|
493
|
-
}
|
|
494
|
-
declare class CommunityClient {
|
|
495
|
-
private readonly publishableKey;
|
|
496
|
-
private readonly secretKey?;
|
|
497
|
-
private readonly customerToken?;
|
|
498
|
-
private readonly onUnauthorized?;
|
|
499
|
-
private readonly onRequestId?;
|
|
500
|
-
constructor(options: CommunityClientOptions);
|
|
501
|
-
private buildQuery;
|
|
502
|
-
private execute;
|
|
503
|
-
createPost(params: {
|
|
504
|
-
title: string;
|
|
505
|
-
content: unknown;
|
|
506
|
-
categories?: string[];
|
|
507
|
-
thumbnail?: string;
|
|
508
|
-
}): Promise<CommunityPost>;
|
|
509
|
-
getMyPosts(params?: {
|
|
510
|
-
page?: number;
|
|
511
|
-
limit?: number;
|
|
512
|
-
}): Promise<PaginatedResponse<CommunityPost>>;
|
|
513
|
-
getTrending(params?: {
|
|
514
|
-
page?: number;
|
|
515
|
-
limit?: number;
|
|
516
|
-
period?: string;
|
|
517
|
-
}): Promise<PaginatedResponse<CommunityPost>>;
|
|
518
|
-
incrementView(params: {
|
|
519
|
-
postId: string;
|
|
520
|
-
}): Promise<{
|
|
521
|
-
viewCount: number;
|
|
522
|
-
}>;
|
|
523
|
-
reportPost(params: {
|
|
524
|
-
postId: string;
|
|
525
|
-
reason?: string;
|
|
526
|
-
reasonDetail?: string;
|
|
527
|
-
}): Promise<{
|
|
528
|
-
success: boolean;
|
|
529
|
-
}>;
|
|
530
|
-
createComment(params: {
|
|
531
|
-
postId: string;
|
|
532
|
-
body: string;
|
|
533
|
-
parentId?: string;
|
|
534
|
-
}): Promise<Comment>;
|
|
535
|
-
listComments(params: {
|
|
536
|
-
postId: string;
|
|
537
|
-
page?: number;
|
|
538
|
-
limit?: number;
|
|
539
|
-
rootComment?: string;
|
|
540
|
-
}): Promise<PaginatedResponse<Comment>>;
|
|
541
|
-
updateComment(params: {
|
|
542
|
-
commentId: string;
|
|
543
|
-
body: string;
|
|
544
|
-
}): Promise<Comment>;
|
|
545
|
-
deleteComment(params: {
|
|
546
|
-
commentId: string;
|
|
547
|
-
}): Promise<{
|
|
548
|
-
success: boolean;
|
|
549
|
-
}>;
|
|
550
|
-
reportComment(params: {
|
|
551
|
-
commentId: string;
|
|
552
|
-
reason?: string;
|
|
553
|
-
reasonDetail?: string;
|
|
554
|
-
}): Promise<{
|
|
555
|
-
success: boolean;
|
|
556
|
-
}>;
|
|
557
|
-
addReaction(params: {
|
|
558
|
-
postId: string;
|
|
559
|
-
type: string;
|
|
560
|
-
}): Promise<Reaction>;
|
|
561
|
-
removeReaction(params: {
|
|
562
|
-
postId: string;
|
|
563
|
-
type: string;
|
|
564
|
-
}): Promise<{
|
|
565
|
-
success: boolean;
|
|
566
|
-
}>;
|
|
567
|
-
addCommentReaction(params: {
|
|
568
|
-
commentId: string;
|
|
569
|
-
type: string;
|
|
570
|
-
}): Promise<Reaction>;
|
|
571
|
-
removeCommentReaction(params: {
|
|
572
|
-
commentId: string;
|
|
573
|
-
type: string;
|
|
574
|
-
}): Promise<{
|
|
575
|
-
success: boolean;
|
|
576
|
-
}>;
|
|
577
|
-
getReactionSummary(params: {
|
|
578
|
-
postId: string;
|
|
579
|
-
}): Promise<ReactionSummary>;
|
|
580
|
-
getReactionTypes(): Promise<PaginatedResponse<ReactionType>>;
|
|
581
|
-
addBookmark(params: {
|
|
582
|
-
postId: string;
|
|
583
|
-
}): Promise<Bookmark>;
|
|
584
|
-
removeBookmark(params: {
|
|
585
|
-
postId: string;
|
|
586
|
-
}): Promise<{
|
|
587
|
-
success: boolean;
|
|
588
|
-
}>;
|
|
589
|
-
getMyBookmarks(params?: {
|
|
590
|
-
page?: number;
|
|
591
|
-
limit?: number;
|
|
592
|
-
}): Promise<PaginatedResponse<Bookmark>>;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
interface ServerApiOptions {
|
|
596
|
-
publishableKey?: string;
|
|
597
|
-
secretKey: string;
|
|
598
|
-
onRequestId?: (id: string | null) => void;
|
|
599
|
-
}
|
|
600
|
-
interface RequestOptions {
|
|
601
|
-
method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
602
|
-
headers?: Record<string, string>;
|
|
603
|
-
}
|
|
604
|
-
declare abstract class BaseApi {
|
|
605
|
-
protected readonly publishableKey: string;
|
|
606
|
-
protected readonly secretKey: string;
|
|
607
|
-
protected readonly onRequestId?: (id: string | null) => void;
|
|
608
|
-
constructor(apiName: string, options: ServerApiOptions);
|
|
609
|
-
protected request<T>(endpoint: string, body: unknown, options?: RequestOptions): Promise<T>;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
type ModerationApiOptions = ServerApiOptions;
|
|
613
|
-
interface CommunityBan {
|
|
614
|
-
id: string;
|
|
615
|
-
customer: string;
|
|
616
|
-
isPermanent?: boolean;
|
|
617
|
-
bannedUntil?: string;
|
|
618
|
-
reason?: string;
|
|
619
|
-
createdAt?: string;
|
|
620
|
-
updatedAt?: string;
|
|
621
|
-
[key: string]: unknown;
|
|
622
|
-
}
|
|
623
|
-
type BanCustomerParams = {
|
|
624
|
-
customerId: string;
|
|
625
|
-
isPermanent?: boolean;
|
|
626
|
-
bannedUntil?: string;
|
|
627
|
-
reason?: string;
|
|
628
|
-
};
|
|
629
|
-
type UnbanCustomerParams = {
|
|
630
|
-
customerId: string;
|
|
631
|
-
};
|
|
632
|
-
declare class ModerationApi extends BaseApi {
|
|
633
|
-
constructor(options: ModerationApiOptions);
|
|
634
|
-
banCustomer(params: BanCustomerParams): Promise<CommunityBan>;
|
|
635
|
-
unbanCustomer(params: UnbanCustomerParams): Promise<{
|
|
636
|
-
success: true;
|
|
637
|
-
}>;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
interface CustomerAuthResponse {
|
|
641
|
-
token: string;
|
|
642
|
-
customer: CustomerProfile;
|
|
643
|
-
}
|
|
644
|
-
interface MarketingConsentChannel {
|
|
645
|
-
isConsented?: boolean;
|
|
646
|
-
}
|
|
647
|
-
interface MarketingConsent {
|
|
648
|
-
email?: MarketingConsentChannel;
|
|
649
|
-
sms?: MarketingConsentChannel;
|
|
650
|
-
push?: MarketingConsentChannel;
|
|
651
|
-
consentSource?: string;
|
|
652
|
-
}
|
|
653
|
-
interface CustomerProfile {
|
|
654
|
-
id: string;
|
|
655
|
-
name: string;
|
|
656
|
-
email?: string | null;
|
|
657
|
-
phone?: string | null;
|
|
658
|
-
authProvider?: 'local' | 'google' | 'apple' | 'kakao' | 'naver' | null;
|
|
659
|
-
isGuest?: boolean | null;
|
|
660
|
-
marketingConsent?: MarketingConsent | null;
|
|
661
|
-
metadata?: Record<string, unknown> | null;
|
|
662
|
-
groups?: string[];
|
|
663
|
-
}
|
|
664
|
-
interface CustomerRegisterData {
|
|
665
|
-
name: string;
|
|
666
|
-
email: string;
|
|
667
|
-
password: string;
|
|
668
|
-
phone?: string;
|
|
669
|
-
}
|
|
670
|
-
interface CustomerRegisterResponse {
|
|
671
|
-
customer: CustomerProfile;
|
|
672
|
-
}
|
|
673
|
-
interface CustomerLoginData {
|
|
674
|
-
email: string;
|
|
675
|
-
password: string;
|
|
676
|
-
}
|
|
677
|
-
interface CustomerRefreshResponse {
|
|
678
|
-
token: string;
|
|
679
|
-
}
|
|
680
|
-
interface UpdateProfileData {
|
|
681
|
-
name?: string;
|
|
682
|
-
phone?: string;
|
|
683
|
-
marketingConsent?: MarketingConsent;
|
|
684
|
-
}
|
|
685
|
-
interface CustomerAuthOptions {
|
|
686
|
-
/**
|
|
687
|
-
* Persist token in localStorage. Defaults to `true`.
|
|
688
|
-
* - `true` (default): uses key `'customer-token'`
|
|
689
|
-
* - `string`: uses the given string as localStorage key
|
|
690
|
-
* - `false`: disables persistence (token/onTokenChange used instead)
|
|
691
|
-
*
|
|
692
|
-
* Handles SSR safely (no-op on server).
|
|
693
|
-
* When enabled, `token` and `onTokenChange` are ignored.
|
|
694
|
-
*/
|
|
695
|
-
persist?: boolean | string;
|
|
696
|
-
/** Initial token (e.g. from SSR cookie) */
|
|
697
|
-
token?: string;
|
|
698
|
-
/** Called when token changes (login/logout) — use to persist in localStorage/cookie */
|
|
699
|
-
onTokenChange?: (token: string | null) => void;
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* Customer authentication client.
|
|
704
|
-
*
|
|
705
|
-
* Manages customer registration, login, logout, and token lifecycle.
|
|
706
|
-
* All requests include X-Publishable-Key for tenant resolution.
|
|
707
|
-
*/
|
|
708
|
-
declare class CustomerAuth {
|
|
709
|
-
private publishableKey;
|
|
710
|
-
private baseUrl;
|
|
711
|
-
private token;
|
|
712
|
-
private onTokenChange?;
|
|
713
|
-
private refreshPromise;
|
|
714
|
-
constructor(publishableKey: string, options?: CustomerAuthOptions);
|
|
715
|
-
/**
|
|
716
|
-
* Register a new customer account
|
|
717
|
-
*/
|
|
718
|
-
register(data: CustomerRegisterData): Promise<CustomerRegisterResponse>;
|
|
719
|
-
/**
|
|
720
|
-
* Login with email and password. Stores the token internally.
|
|
721
|
-
*/
|
|
722
|
-
login(data: CustomerLoginData): Promise<CustomerAuthResponse>;
|
|
723
|
-
/**
|
|
724
|
-
* Refresh the current token. Requires a valid (non-expired) token.
|
|
725
|
-
*/
|
|
726
|
-
refreshToken(): Promise<CustomerRefreshResponse>;
|
|
727
|
-
private _doRefreshToken;
|
|
728
|
-
/**
|
|
729
|
-
* Clear the stored token
|
|
730
|
-
*/
|
|
731
|
-
logout(): void;
|
|
732
|
-
/**
|
|
733
|
-
* Get the current authenticated customer's profile
|
|
734
|
-
*/
|
|
735
|
-
me(): Promise<CustomerProfile | null>;
|
|
736
|
-
/**
|
|
737
|
-
* Request a password reset email
|
|
738
|
-
*/
|
|
739
|
-
forgotPassword(email: string): Promise<void>;
|
|
740
|
-
/**
|
|
741
|
-
* Reset password using a token from the reset email
|
|
742
|
-
*/
|
|
743
|
-
resetPassword(token: string, password: string): Promise<void>;
|
|
744
|
-
/**
|
|
745
|
-
* Update the authenticated customer's profile (name, phone, marketingConsent)
|
|
746
|
-
*/
|
|
747
|
-
updateProfile(data: UpdateProfileData): Promise<CustomerProfile>;
|
|
748
|
-
/**
|
|
749
|
-
* Change the password of the currently authenticated customer
|
|
750
|
-
*/
|
|
751
|
-
changePassword(currentPassword: string, newPassword: string): Promise<void>;
|
|
752
|
-
/**
|
|
753
|
-
* Get the authenticated customer's orders with pagination and optional status filter
|
|
754
|
-
*/
|
|
755
|
-
getMyOrders(options?: {
|
|
756
|
-
page?: number;
|
|
757
|
-
limit?: number;
|
|
758
|
-
status?: string;
|
|
759
|
-
}): Promise<PayloadFindResponse<Order>>;
|
|
760
|
-
/**
|
|
761
|
-
* Get the current token (or null if not authenticated)
|
|
762
|
-
*/
|
|
763
|
-
getToken(): string | null;
|
|
764
|
-
/**
|
|
765
|
-
* Set the token manually (e.g. from SSR)
|
|
766
|
-
*/
|
|
767
|
-
setToken(token: string | null): void;
|
|
768
|
-
/**
|
|
769
|
-
* Check if the customer is currently authenticated
|
|
770
|
-
*/
|
|
771
|
-
isAuthenticated(): boolean;
|
|
772
|
-
/**
|
|
773
|
-
* Internal: make a request with timeout and error handling.
|
|
774
|
-
* Auth endpoints don't retry — failures are final.
|
|
775
|
-
*/
|
|
776
|
-
private requestJson;
|
|
777
|
-
}
|
|
14
|
+
import 'payload';
|
|
15
|
+
import 'next';
|
|
778
16
|
|
|
779
17
|
/**
|
|
780
18
|
* Customer namespace. Currently exposes .auth; reserved for future customer-
|
|
@@ -785,336 +23,6 @@ declare class CustomerNamespace {
|
|
|
785
23
|
constructor(publishableKey: string, options?: CustomerAuthOptions);
|
|
786
24
|
}
|
|
787
25
|
|
|
788
|
-
interface CartApiOptions {
|
|
789
|
-
publishableKey?: string;
|
|
790
|
-
secretKey?: string;
|
|
791
|
-
customerToken?: string | (() => string | null);
|
|
792
|
-
onUnauthorized?: () => Promise<string | null>;
|
|
793
|
-
onRequestId?: (id: string | null) => void;
|
|
794
|
-
}
|
|
795
|
-
type AddItemParams = {
|
|
796
|
-
cartId: string;
|
|
797
|
-
product: string;
|
|
798
|
-
variant: string;
|
|
799
|
-
option: string;
|
|
800
|
-
quantity: number;
|
|
801
|
-
};
|
|
802
|
-
type UpdateItemParams = {
|
|
803
|
-
cartItemId: string;
|
|
804
|
-
quantity: number;
|
|
805
|
-
};
|
|
806
|
-
type RemoveItemParams = {
|
|
807
|
-
cartItemId: string;
|
|
808
|
-
};
|
|
809
|
-
type ApplyDiscountParams = {
|
|
810
|
-
cartId: string;
|
|
811
|
-
discountCode: string;
|
|
812
|
-
};
|
|
813
|
-
type RemoveDiscountParams = {
|
|
814
|
-
cartId: string;
|
|
815
|
-
};
|
|
816
|
-
type ClearCartParams = {
|
|
817
|
-
cartId: string;
|
|
818
|
-
};
|
|
819
|
-
declare class CartApi {
|
|
820
|
-
private readonly publishableKey;
|
|
821
|
-
private readonly secretKey?;
|
|
822
|
-
private readonly customerToken?;
|
|
823
|
-
private readonly onUnauthorized?;
|
|
824
|
-
private readonly onRequestId?;
|
|
825
|
-
constructor(options: CartApiOptions);
|
|
826
|
-
private execute;
|
|
827
|
-
getCart(cartId: string): Promise<Cart>;
|
|
828
|
-
addItem(params: AddItemParams): Promise<CartItem>;
|
|
829
|
-
updateItem(params: UpdateItemParams): Promise<CartItem>;
|
|
830
|
-
removeItem(params: RemoveItemParams): Promise<{
|
|
831
|
-
success: boolean;
|
|
832
|
-
}>;
|
|
833
|
-
applyDiscount(params: ApplyDiscountParams): Promise<Cart>;
|
|
834
|
-
removeDiscount(params: RemoveDiscountParams): Promise<Cart>;
|
|
835
|
-
clearCart(params: ClearCartParams): Promise<{
|
|
836
|
-
success: boolean;
|
|
837
|
-
}>;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
type EntityID = string;
|
|
841
|
-
type RelationshipValue = string | number | null | undefined | {
|
|
842
|
-
id?: string | number | null;
|
|
843
|
-
};
|
|
844
|
-
type MediaValue = {
|
|
845
|
-
id?: EntityID | null;
|
|
846
|
-
} | EntityID | null | undefined;
|
|
847
|
-
interface ProductOptionValueShape {
|
|
848
|
-
id?: string | number | null;
|
|
849
|
-
option?: RelationshipValue;
|
|
850
|
-
value?: string | null;
|
|
851
|
-
slug?: string | null;
|
|
852
|
-
_order?: string | null;
|
|
853
|
-
'_product-option-values_values_order'?: string | null;
|
|
854
|
-
}
|
|
855
|
-
interface ProductOptionShape {
|
|
856
|
-
id?: string | number | null;
|
|
857
|
-
title?: string | null;
|
|
858
|
-
_order?: string | null;
|
|
859
|
-
'_product-options_options_order'?: string | null;
|
|
860
|
-
values?: {
|
|
861
|
-
docs?: unknown[];
|
|
862
|
-
} | null;
|
|
863
|
-
}
|
|
864
|
-
interface ProductVariantShape {
|
|
865
|
-
id?: string | number | null;
|
|
866
|
-
optionValues?: unknown[] | null;
|
|
867
|
-
price?: number | null;
|
|
868
|
-
compareAtPrice?: number | null;
|
|
869
|
-
stock?: number | null;
|
|
870
|
-
isUnlimited?: boolean | null;
|
|
871
|
-
isActive?: boolean | null;
|
|
872
|
-
thumbnail?: MediaValue;
|
|
873
|
-
images?: MediaValue[] | null;
|
|
874
|
-
_order?: string | null;
|
|
875
|
-
}
|
|
876
|
-
interface ProductListingProductShape {
|
|
877
|
-
id?: EntityID;
|
|
878
|
-
thumbnail?: MediaValue;
|
|
879
|
-
images?: MediaValue[] | null;
|
|
880
|
-
}
|
|
881
|
-
type ProductOptionMatrixValue = {
|
|
882
|
-
id: string;
|
|
883
|
-
optionId: string;
|
|
884
|
-
label: string;
|
|
885
|
-
slug: string | null;
|
|
886
|
-
order: string;
|
|
887
|
-
};
|
|
888
|
-
type ProductOptionMatrixOption = {
|
|
889
|
-
id: string;
|
|
890
|
-
title: string;
|
|
891
|
-
order: string;
|
|
892
|
-
values: ProductOptionMatrixValue[];
|
|
893
|
-
};
|
|
894
|
-
type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVariantShape> = {
|
|
895
|
-
id: string;
|
|
896
|
-
optionValueIds: string[];
|
|
897
|
-
optionValueByOptionId: Map<string, string>;
|
|
898
|
-
source: TVariant;
|
|
899
|
-
};
|
|
900
|
-
type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
|
|
901
|
-
options: ProductOptionMatrixOption[];
|
|
902
|
-
optionIds: string[];
|
|
903
|
-
optionById: Map<string, ProductOptionMatrixOption>;
|
|
904
|
-
valueById: Map<string, ProductOptionMatrixValue>;
|
|
905
|
-
valueToOptionId: Map<string, string>;
|
|
906
|
-
variants: ProductOptionMatrixVariant<TVariant>[];
|
|
907
|
-
};
|
|
908
|
-
type ProductListingProjection = {
|
|
909
|
-
selectionHintVariant: EntityID | null;
|
|
910
|
-
primaryImage: EntityID | null;
|
|
911
|
-
minPrice: number | null;
|
|
912
|
-
maxPrice: number | null;
|
|
913
|
-
minCompareAtPrice: number | null;
|
|
914
|
-
maxCompareAtPrice: number | null;
|
|
915
|
-
isPriceRange: boolean;
|
|
916
|
-
availableForSale: boolean;
|
|
917
|
-
};
|
|
918
|
-
type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantShape> = {
|
|
919
|
-
optionId: EntityID;
|
|
920
|
-
optionTitle: string;
|
|
921
|
-
optionValueId: EntityID;
|
|
922
|
-
optionValueLabel: string;
|
|
923
|
-
optionValueSlug: string | null;
|
|
924
|
-
variantIds: EntityID[];
|
|
925
|
-
variantCount: number;
|
|
926
|
-
variants: TVariant[];
|
|
927
|
-
listing: ProductListingProjection;
|
|
928
|
-
};
|
|
929
|
-
declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
|
|
930
|
-
options: ProductOptionShape[];
|
|
931
|
-
variants?: TVariant[];
|
|
932
|
-
}): ProductOptionMatrix<TVariant>;
|
|
933
|
-
declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
|
|
934
|
-
declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
|
|
935
|
-
declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
|
|
936
|
-
declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
|
|
937
|
-
declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
|
|
938
|
-
declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
|
|
939
|
-
product: ProductListingProductShape | null | undefined;
|
|
940
|
-
options: ProductOptionShape[];
|
|
941
|
-
variants: TVariant[];
|
|
942
|
-
primaryOptionId?: string | null;
|
|
943
|
-
}): ProductListingGroup<TVariant>[];
|
|
944
|
-
|
|
945
|
-
type ProductApiOptions = ServerApiOptions;
|
|
946
|
-
type StockCheckParams = {
|
|
947
|
-
items: Array<{
|
|
948
|
-
variantId: string;
|
|
949
|
-
quantity: number;
|
|
950
|
-
}>;
|
|
951
|
-
};
|
|
952
|
-
type StockCheckResult = {
|
|
953
|
-
variantId: string;
|
|
954
|
-
available: boolean;
|
|
955
|
-
availableStock: number;
|
|
956
|
-
requestedQuantity: number;
|
|
957
|
-
error?: string;
|
|
958
|
-
};
|
|
959
|
-
type StockCheckResponse = {
|
|
960
|
-
results: StockCheckResult[];
|
|
961
|
-
allAvailable: boolean;
|
|
962
|
-
};
|
|
963
|
-
type ListingGroupsParams = {
|
|
964
|
-
productIds: string[];
|
|
965
|
-
};
|
|
966
|
-
type ProductListingGroupSummary = Omit<ProductListingGroup, 'variants'>;
|
|
967
|
-
type ProductListingGroupsItem = {
|
|
968
|
-
product: Product;
|
|
969
|
-
primaryOptionId: string | null;
|
|
970
|
-
groups: ProductListingGroupSummary[];
|
|
971
|
-
};
|
|
972
|
-
type ProductListingGroupsResponse = {
|
|
973
|
-
docs: ProductListingGroupsItem[];
|
|
974
|
-
};
|
|
975
|
-
declare class ProductApi extends BaseApi {
|
|
976
|
-
constructor(options: ProductApiOptions);
|
|
977
|
-
/**
|
|
978
|
-
* Check point-in-time stock availability for one or more product variants.
|
|
979
|
-
* Results reflect available stock at the moment of the call and are not guaranteed
|
|
980
|
-
* to remain available by the time an order is placed.
|
|
981
|
-
*/
|
|
982
|
-
stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
|
|
983
|
-
listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
type DiscountApiOptions = ServerApiOptions;
|
|
987
|
-
type ValidateDiscountParams = {
|
|
988
|
-
code: string;
|
|
989
|
-
orderAmount: number;
|
|
990
|
-
};
|
|
991
|
-
type ValidateDiscountResult = {
|
|
992
|
-
valid: boolean;
|
|
993
|
-
code: string;
|
|
994
|
-
type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
|
|
995
|
-
discountAmount: number;
|
|
996
|
-
freeShipping?: boolean;
|
|
997
|
-
reason?: string;
|
|
998
|
-
};
|
|
999
|
-
declare class DiscountApi extends BaseApi {
|
|
1000
|
-
constructor(options: DiscountApiOptions);
|
|
1001
|
-
validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
type ShippingApiOptions = ServerApiOptions;
|
|
1005
|
-
type CalculateShippingParams = {
|
|
1006
|
-
shippingPolicyId?: string;
|
|
1007
|
-
orderAmount: number;
|
|
1008
|
-
postalCode?: string;
|
|
1009
|
-
};
|
|
1010
|
-
type CalculateShippingResult = {
|
|
1011
|
-
shippingAmount: number;
|
|
1012
|
-
baseShippingAmount: number;
|
|
1013
|
-
extraShippingAmount: number;
|
|
1014
|
-
freeShipping: boolean;
|
|
1015
|
-
freeShippingMinAmount: number | null;
|
|
1016
|
-
isJeju: boolean;
|
|
1017
|
-
isRemoteIsland: boolean;
|
|
1018
|
-
};
|
|
1019
|
-
declare class ShippingApi extends BaseApi {
|
|
1020
|
-
constructor(options: ShippingApiOptions);
|
|
1021
|
-
calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
type OrderApiOptions = ServerApiOptions;
|
|
1025
|
-
type CustomerSnapshot = {
|
|
1026
|
-
name?: string;
|
|
1027
|
-
email: string;
|
|
1028
|
-
phone?: string;
|
|
1029
|
-
};
|
|
1030
|
-
type ReturnReason = 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
|
|
1031
|
-
type ReturnItem = {
|
|
1032
|
-
orderItem: string;
|
|
1033
|
-
quantity: number;
|
|
1034
|
-
};
|
|
1035
|
-
type CreateOrderParams = {
|
|
1036
|
-
orderNumber: string;
|
|
1037
|
-
customer?: string;
|
|
1038
|
-
customerSnapshot: CustomerSnapshot;
|
|
1039
|
-
shippingAddress: Order['shippingAddress'];
|
|
1040
|
-
orderItems: Pick<OrderItem$1, 'product' | 'variant' | 'quantity' | 'unitPrice' | 'totalPrice'>[];
|
|
1041
|
-
totalAmount: number;
|
|
1042
|
-
shippingAmount?: number;
|
|
1043
|
-
pgPaymentId?: string;
|
|
1044
|
-
discountCode?: string;
|
|
1045
|
-
};
|
|
1046
|
-
type UpdateOrderParams = {
|
|
1047
|
-
orderNumber: string;
|
|
1048
|
-
status: Order['status'];
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
|
-
type CheckoutParams = {
|
|
1052
|
-
cartId: string;
|
|
1053
|
-
orderNumber: string;
|
|
1054
|
-
customerSnapshot: CustomerSnapshot;
|
|
1055
|
-
pgPaymentId?: string;
|
|
1056
|
-
discountCode?: string;
|
|
1057
|
-
};
|
|
1058
|
-
type CreateFulfillmentParams = {
|
|
1059
|
-
orderNumber: string;
|
|
1060
|
-
carrier?: string;
|
|
1061
|
-
trackingNumber?: string;
|
|
1062
|
-
items: Array<{
|
|
1063
|
-
orderItem: string;
|
|
1064
|
-
quantity: number;
|
|
1065
|
-
}>;
|
|
1066
|
-
};
|
|
1067
|
-
type UpdateFulfillmentParams = {
|
|
1068
|
-
fulfillmentId: string;
|
|
1069
|
-
status: 'packed' | 'shipped' | 'delivered' | 'failed';
|
|
1070
|
-
carrier?: string;
|
|
1071
|
-
trackingNumber?: string;
|
|
1072
|
-
};
|
|
1073
|
-
type BulkImportFulfillmentsParams = {
|
|
1074
|
-
items: Array<{
|
|
1075
|
-
orderNumber: string;
|
|
1076
|
-
carrier?: string;
|
|
1077
|
-
trackingNumber?: string;
|
|
1078
|
-
}>;
|
|
1079
|
-
};
|
|
1080
|
-
type BulkImportFulfillmentsResponse = {
|
|
1081
|
-
succeeded: Array<{
|
|
1082
|
-
orderNumber: string;
|
|
1083
|
-
fulfillmentId: string;
|
|
1084
|
-
}>;
|
|
1085
|
-
failed: Array<{
|
|
1086
|
-
orderNumber: string;
|
|
1087
|
-
error: string;
|
|
1088
|
-
}>;
|
|
1089
|
-
};
|
|
1090
|
-
type CreateReturnParams = {
|
|
1091
|
-
orderNumber: string;
|
|
1092
|
-
reason?: ReturnReason;
|
|
1093
|
-
reasonDetail?: string;
|
|
1094
|
-
returnItems: ReturnItem[];
|
|
1095
|
-
refundAmount: number;
|
|
1096
|
-
};
|
|
1097
|
-
type UpdateReturnParams = {
|
|
1098
|
-
returnId: string;
|
|
1099
|
-
status: 'processing' | 'approved' | 'rejected' | 'completed';
|
|
1100
|
-
};
|
|
1101
|
-
declare class OrderApi extends BaseApi {
|
|
1102
|
-
constructor(options: OrderApiOptions);
|
|
1103
|
-
createOrder(params: CreateOrderParams): Promise<Order>;
|
|
1104
|
-
updateOrder(params: UpdateOrderParams): Promise<Order>;
|
|
1105
|
-
updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
|
|
1106
|
-
checkout(params: CheckoutParams): Promise<Order>;
|
|
1107
|
-
createFulfillment(params: CreateFulfillmentParams): Promise<Fulfillment>;
|
|
1108
|
-
updateFulfillment(params: UpdateFulfillmentParams): Promise<Fulfillment>;
|
|
1109
|
-
bulkImportFulfillments(params: BulkImportFulfillmentsParams): Promise<BulkImportFulfillmentsResponse>;
|
|
1110
|
-
returnWithRefund(params: ReturnWithRefundParams): Promise<{
|
|
1111
|
-
return: Return;
|
|
1112
|
-
transaction: Transaction | null;
|
|
1113
|
-
}>;
|
|
1114
|
-
createReturn(params: CreateReturnParams): Promise<Return>;
|
|
1115
|
-
updateReturn(params: UpdateReturnParams): Promise<Return>;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
26
|
interface CommerceClientOptions {
|
|
1119
27
|
publishableKey: string;
|
|
1120
28
|
customerToken: () => string | null;
|
|
@@ -1157,183 +65,6 @@ declare class CommerceClient {
|
|
|
1157
65
|
constructor(options: CommerceClientOptions);
|
|
1158
66
|
}
|
|
1159
67
|
|
|
1160
|
-
interface ServerCommerceClientOptions {
|
|
1161
|
-
publishableKey?: string;
|
|
1162
|
-
secretKey: string;
|
|
1163
|
-
onRequestId?: (id: string | null) => void;
|
|
1164
|
-
}
|
|
1165
|
-
declare class ServerCommerceClient {
|
|
1166
|
-
readonly product: {
|
|
1167
|
-
stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
|
|
1168
|
-
listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
|
|
1169
|
-
};
|
|
1170
|
-
readonly cart: {
|
|
1171
|
-
get: (cartId: string) => Promise<Cart>;
|
|
1172
|
-
addItem: (params: AddItemParams) => Promise<CartItem>;
|
|
1173
|
-
updateItem: (params: UpdateItemParams) => Promise<CartItem>;
|
|
1174
|
-
removeItem: (params: RemoveItemParams) => Promise<{
|
|
1175
|
-
success: boolean;
|
|
1176
|
-
}>;
|
|
1177
|
-
applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
|
|
1178
|
-
removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
|
|
1179
|
-
clear: (params: ClearCartParams) => Promise<{
|
|
1180
|
-
success: boolean;
|
|
1181
|
-
}>;
|
|
1182
|
-
};
|
|
1183
|
-
readonly orders: {
|
|
1184
|
-
checkout: (params: CheckoutParams) => Promise<Order>;
|
|
1185
|
-
create: (params: CreateOrderParams) => Promise<Order>;
|
|
1186
|
-
update: (params: UpdateOrderParams) => Promise<Order>;
|
|
1187
|
-
updateTransaction: (params: UpdateTransactionParams) => Promise<Transaction>;
|
|
1188
|
-
createFulfillment: (params: CreateFulfillmentParams) => Promise<Fulfillment>;
|
|
1189
|
-
updateFulfillment: (params: UpdateFulfillmentParams) => Promise<Fulfillment>;
|
|
1190
|
-
bulkImportFulfillments: (params: BulkImportFulfillmentsParams) => Promise<BulkImportFulfillmentsResponse>;
|
|
1191
|
-
createReturn: (params: CreateReturnParams) => Promise<Return>;
|
|
1192
|
-
updateReturn: (params: UpdateReturnParams) => Promise<Return>;
|
|
1193
|
-
returnWithRefund: (params: ReturnWithRefundParams) => Promise<{
|
|
1194
|
-
return: Return;
|
|
1195
|
-
transaction: Transaction | null;
|
|
1196
|
-
}>;
|
|
1197
|
-
};
|
|
1198
|
-
readonly discounts: {
|
|
1199
|
-
validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
|
|
1200
|
-
};
|
|
1201
|
-
readonly shipping: {
|
|
1202
|
-
calculate: (params: CalculateShippingParams) => Promise<CalculateShippingResult>;
|
|
1203
|
-
};
|
|
1204
|
-
constructor(options: ServerCommerceClientOptions);
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
interface CollectionQueryParams<T extends PublicCollection> {
|
|
1208
|
-
collection: T;
|
|
1209
|
-
options?: ApiQueryOptions;
|
|
1210
|
-
}
|
|
1211
|
-
interface CollectionDetailQueryParams<T extends PublicCollection> {
|
|
1212
|
-
collection: T;
|
|
1213
|
-
id: string;
|
|
1214
|
-
options?: ApiQueryOptions;
|
|
1215
|
-
}
|
|
1216
|
-
interface CollectionInfiniteQueryParams<T extends PublicCollection> {
|
|
1217
|
-
collection: T;
|
|
1218
|
-
options?: Omit<ApiQueryOptions, 'page'>;
|
|
1219
|
-
pageSize?: number;
|
|
1220
|
-
}
|
|
1221
|
-
interface QueryOptions<TQueryFnData = unknown, TData = TQueryFnData> {
|
|
1222
|
-
enabled?: boolean;
|
|
1223
|
-
staleTime?: number;
|
|
1224
|
-
gcTime?: number;
|
|
1225
|
-
refetchOnWindowFocus?: boolean;
|
|
1226
|
-
refetchOnMount?: boolean | 'always';
|
|
1227
|
-
refetchInterval?: number | false;
|
|
1228
|
-
retry?: boolean | number;
|
|
1229
|
-
select?: (data: TQueryFnData) => TData;
|
|
1230
|
-
placeholderData?: TQueryFnData | ((previousData: TData | undefined) => TQueryFnData | undefined);
|
|
1231
|
-
initialData?: TQueryFnData | (() => TQueryFnData);
|
|
1232
|
-
initialDataUpdatedAt?: number | (() => number | undefined);
|
|
1233
|
-
}
|
|
1234
|
-
type SuspenseQueryOptions<TQueryFnData = unknown, TData = TQueryFnData> = Omit<QueryOptions<TQueryFnData, TData>, 'enabled' | 'placeholderData'>;
|
|
1235
|
-
interface InfiniteQueryOptions<TQueryFnData = unknown, TData = InfiniteData<TQueryFnData>> {
|
|
1236
|
-
enabled?: boolean;
|
|
1237
|
-
staleTime?: number;
|
|
1238
|
-
gcTime?: number;
|
|
1239
|
-
refetchOnWindowFocus?: boolean;
|
|
1240
|
-
refetchOnMount?: boolean | 'always';
|
|
1241
|
-
refetchInterval?: number | false;
|
|
1242
|
-
retry?: boolean | number;
|
|
1243
|
-
select?: (data: InfiniteData<TQueryFnData>) => TData;
|
|
1244
|
-
}
|
|
1245
|
-
type SuspenseInfiniteQueryOptions<TQueryFnData = unknown, TData = InfiniteData<TQueryFnData>> = Omit<InfiniteQueryOptions<TQueryFnData, TData>, 'enabled'>;
|
|
1246
|
-
interface MutationCallbacks$1<TData> {
|
|
1247
|
-
onSuccess?: (data: TData) => void;
|
|
1248
|
-
onError?: (error: SDKError) => void;
|
|
1249
|
-
onSettled?: () => void;
|
|
1250
|
-
}
|
|
1251
|
-
declare class CollectionHooks {
|
|
1252
|
-
protected queryClient: QueryClient;
|
|
1253
|
-
protected collectionClient: CollectionClient;
|
|
1254
|
-
constructor(queryClient: QueryClient, collectionClient: CollectionClient);
|
|
1255
|
-
useQuery<T extends PublicCollection, TData = PayloadFindResponse<CollectionType<T>>>(params: CollectionQueryParams<T>, options?: QueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
|
|
1256
|
-
useSuspenseQuery<T extends PublicCollection, TData = PayloadFindResponse<CollectionType<T>>>(params: CollectionQueryParams<T>, options?: SuspenseQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
|
|
1257
|
-
useQueryById<T extends PublicCollection, TData = CollectionType<T>>(params: CollectionDetailQueryParams<T>, options?: QueryOptions<CollectionType<T>, TData>): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
|
|
1258
|
-
useSuspenseQueryById<T extends PublicCollection, TData = CollectionType<T>>(params: CollectionDetailQueryParams<T>, options?: SuspenseQueryOptions<CollectionType<T>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
|
|
1259
|
-
useInfiniteQuery<T extends PublicCollection, TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>>(params: CollectionInfiniteQueryParams<T>, options?: InfiniteQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseInfiniteQueryResult<TData, Error>;
|
|
1260
|
-
useSuspenseInfiniteQuery<T extends PublicCollection, TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>>(params: CollectionInfiniteQueryParams<T>, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseSuspenseInfiniteQueryResult<TData, Error>;
|
|
1261
|
-
prefetchQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
|
|
1262
|
-
staleTime?: number;
|
|
1263
|
-
}): Promise<void>;
|
|
1264
|
-
prefetchQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
|
|
1265
|
-
staleTime?: number;
|
|
1266
|
-
}): Promise<void>;
|
|
1267
|
-
prefetchInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
|
|
1268
|
-
pages?: number;
|
|
1269
|
-
staleTime?: number;
|
|
1270
|
-
}): Promise<void>;
|
|
1271
|
-
useCreate<T extends PublicCollection>(params: {
|
|
1272
|
-
collection: T;
|
|
1273
|
-
}, options?: MutationCallbacks$1<PayloadMutationResponse<CollectionType<T>>>): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, SDKError, {
|
|
1274
|
-
data: Partial<CollectionType<T>>;
|
|
1275
|
-
file?: File | Blob;
|
|
1276
|
-
filename?: string;
|
|
1277
|
-
}, unknown>;
|
|
1278
|
-
useUpdate<T extends PublicCollection>(params: {
|
|
1279
|
-
collection: T;
|
|
1280
|
-
}, options?: MutationCallbacks$1<PayloadMutationResponse<CollectionType<T>>>): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, SDKError, {
|
|
1281
|
-
id: string;
|
|
1282
|
-
data: Partial<CollectionType<T>>;
|
|
1283
|
-
file?: File | Blob;
|
|
1284
|
-
filename?: string;
|
|
1285
|
-
}, unknown>;
|
|
1286
|
-
useRemove<T extends PublicCollection>(params: {
|
|
1287
|
-
collection: T;
|
|
1288
|
-
}, options?: MutationCallbacks$1<CollectionType<T>>): _tanstack_react_query.UseMutationResult<CollectionType<T>, SDKError, string, unknown>;
|
|
1289
|
-
invalidateQueries<T extends PublicCollection>(collection: T, type?: 'list' | 'detail' | 'infinite'): Promise<void>;
|
|
1290
|
-
getQueryData<T extends PublicCollection>(collection: T, type: 'list', options?: ApiQueryOptions): PayloadFindResponse<CollectionType<T>> | undefined;
|
|
1291
|
-
getQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string, options?: ApiQueryOptions): CollectionType<T> | null | undefined;
|
|
1292
|
-
setQueryData<T extends PublicCollection>(collection: T, type: 'list', data: PayloadFindResponse<CollectionType<T>>, options?: ApiQueryOptions): void;
|
|
1293
|
-
setQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
interface MutationCallbacks<TData> {
|
|
1297
|
-
onSuccess?: (data: TData) => void;
|
|
1298
|
-
onError?: (error: SDKError) => void;
|
|
1299
|
-
onSettled?: () => void;
|
|
1300
|
-
}
|
|
1301
|
-
declare class CustomerHooks {
|
|
1302
|
-
private queryClient;
|
|
1303
|
-
private customerAuth?;
|
|
1304
|
-
constructor(queryClient: QueryClient, customerAuth?: CustomerAuth);
|
|
1305
|
-
private ensureCustomerAuth;
|
|
1306
|
-
private invalidateMe;
|
|
1307
|
-
useCustomerMe(options?: {
|
|
1308
|
-
enabled?: boolean;
|
|
1309
|
-
staleTime?: number;
|
|
1310
|
-
gcTime?: number;
|
|
1311
|
-
refetchOnWindowFocus?: boolean;
|
|
1312
|
-
refetchOnMount?: boolean | 'always';
|
|
1313
|
-
refetchInterval?: number | false;
|
|
1314
|
-
retry?: boolean | number;
|
|
1315
|
-
}): _tanstack_react_query.UseQueryResult<CustomerProfile | null, Error>;
|
|
1316
|
-
useCustomerLogin(options?: MutationCallbacks<CustomerAuthResponse>): _tanstack_react_query.UseMutationResult<CustomerAuthResponse, SDKError, CustomerLoginData, unknown>;
|
|
1317
|
-
useCustomerRegister(options?: MutationCallbacks<{
|
|
1318
|
-
customer: CustomerProfile;
|
|
1319
|
-
}>): _tanstack_react_query.UseMutationResult<CustomerRegisterResponse, SDKError, CustomerRegisterData, unknown>;
|
|
1320
|
-
useCustomerLogout(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, void, unknown>;
|
|
1321
|
-
useCustomerForgotPassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, string, unknown>;
|
|
1322
|
-
useCustomerResetPassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, {
|
|
1323
|
-
token: string;
|
|
1324
|
-
password: string;
|
|
1325
|
-
}, unknown>;
|
|
1326
|
-
useCustomerRefreshToken(options?: MutationCallbacks<CustomerRefreshResponse>): _tanstack_react_query.UseMutationResult<CustomerRefreshResponse, SDKError, unknown, unknown>;
|
|
1327
|
-
useCustomerUpdateProfile(options?: MutationCallbacks<CustomerProfile>): _tanstack_react_query.UseMutationResult<CustomerProfile, SDKError, UpdateProfileData, unknown>;
|
|
1328
|
-
useCustomerChangePassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, {
|
|
1329
|
-
currentPassword: string;
|
|
1330
|
-
newPassword: string;
|
|
1331
|
-
}, unknown>;
|
|
1332
|
-
invalidateCustomerQueries(): Promise<void>;
|
|
1333
|
-
getCustomerData(): CustomerProfile | null | undefined;
|
|
1334
|
-
setCustomerData(data: CustomerProfile | null): void;
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
68
|
declare function collectionKeys<T extends PublicCollection>(collection: T): {
|
|
1338
69
|
all: readonly [T];
|
|
1339
70
|
lists: () => readonly [T, "list"];
|
|
@@ -1352,61 +83,12 @@ declare const productKeys: {
|
|
|
1352
83
|
listingGroupsInfinite: (options?: Omit<ProductListingGroupsQueryOptions, "page" | "limit">) => readonly ["products", "listing-groups", "infinite", Omit<ProductListingGroupsQueryOptions, "limit" | "page"> | undefined];
|
|
1353
84
|
};
|
|
1354
85
|
|
|
1355
|
-
type ProductListingGroupsQueryOptions = Pick<ApiQueryOptions, 'page' | 'limit' | 'sort' | 'where'>;
|
|
1356
|
-
type ReadOnlyQueryHooks = Omit<QueryHooks, 'useCreate' | 'useUpdate' | 'useRemove'>;
|
|
1357
|
-
/**
|
|
1358
|
-
* Composes CollectionHooks + CustomerHooks into a single API surface.
|
|
1359
|
-
* All methods are delegated; no logic lives here.
|
|
1360
|
-
*/
|
|
1361
|
-
declare class QueryHooks extends CollectionHooks {
|
|
1362
|
-
private _customer;
|
|
1363
|
-
constructor(queryClient: QueryClient, collectionClient: CollectionClient, customerAuth?: CustomerAuth);
|
|
1364
|
-
useCustomerMe: CustomerHooks['useCustomerMe'];
|
|
1365
|
-
useCustomerLogin: CustomerHooks['useCustomerLogin'];
|
|
1366
|
-
useCustomerRegister: CustomerHooks['useCustomerRegister'];
|
|
1367
|
-
useCustomerLogout: CustomerHooks['useCustomerLogout'];
|
|
1368
|
-
useCustomerForgotPassword: CustomerHooks['useCustomerForgotPassword'];
|
|
1369
|
-
useCustomerResetPassword: CustomerHooks['useCustomerResetPassword'];
|
|
1370
|
-
useCustomerRefreshToken: CustomerHooks['useCustomerRefreshToken'];
|
|
1371
|
-
useCustomerUpdateProfile: CustomerHooks['useCustomerUpdateProfile'];
|
|
1372
|
-
useCustomerChangePassword: CustomerHooks['useCustomerChangePassword'];
|
|
1373
|
-
invalidateCustomerQueries: CustomerHooks['invalidateCustomerQueries'];
|
|
1374
|
-
getCustomerData: CustomerHooks['getCustomerData'];
|
|
1375
|
-
setCustomerData: CustomerHooks['setCustomerData'];
|
|
1376
|
-
useProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
|
|
1377
|
-
options?: ProductListingGroupsQueryOptions;
|
|
1378
|
-
}, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
|
|
1379
|
-
useSuspenseProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
|
|
1380
|
-
options?: ProductListingGroupsQueryOptions;
|
|
1381
|
-
}, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
|
|
1382
|
-
useInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
|
|
1383
|
-
options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
|
|
1384
|
-
pageSize?: number;
|
|
1385
|
-
}, options?: InfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseInfiniteQueryResult<TData, Error>;
|
|
1386
|
-
useSuspenseInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
|
|
1387
|
-
options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
|
|
1388
|
-
pageSize?: number;
|
|
1389
|
-
}, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseInfiniteQueryResult<TData, Error>;
|
|
1390
|
-
prefetchProductListingGroupsQuery(params: {
|
|
1391
|
-
options?: ProductListingGroupsQueryOptions;
|
|
1392
|
-
}, options?: {
|
|
1393
|
-
staleTime?: number;
|
|
1394
|
-
}): Promise<void>;
|
|
1395
|
-
prefetchInfiniteProductListingGroupsQuery(params: {
|
|
1396
|
-
options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
|
|
1397
|
-
pageSize?: number;
|
|
1398
|
-
}, options?: {
|
|
1399
|
-
pages?: number;
|
|
1400
|
-
staleTime?: number;
|
|
1401
|
-
}): Promise<void>;
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
86
|
declare class Client {
|
|
1405
87
|
commerce: CommerceClient;
|
|
1406
88
|
community: CommunityClient;
|
|
1407
89
|
customer: CustomerNamespace;
|
|
1408
90
|
query: ReadOnlyQueryHooks;
|
|
1409
|
-
collections:
|
|
91
|
+
collections: ReadOnlyCollectionClient;
|
|
1410
92
|
queryClient: QueryClient;
|
|
1411
93
|
lastRequestId: string | null;
|
|
1412
94
|
protected state: ClientState;
|
|
@@ -1422,32 +104,6 @@ declare class Client {
|
|
|
1422
104
|
*/
|
|
1423
105
|
declare function createClient(options: ClientConfig): Client;
|
|
1424
106
|
|
|
1425
|
-
declare class ServerClient {
|
|
1426
|
-
commerce: ServerCommerceClient;
|
|
1427
|
-
community: CommunityClient & {
|
|
1428
|
-
moderation: {
|
|
1429
|
-
banCustomer: (p: BanCustomerParams) => Promise<CommunityBan>;
|
|
1430
|
-
unbanCustomer: (p: UnbanCustomerParams) => Promise<{
|
|
1431
|
-
success: true;
|
|
1432
|
-
}>;
|
|
1433
|
-
};
|
|
1434
|
-
};
|
|
1435
|
-
query: QueryHooks;
|
|
1436
|
-
collections: CollectionClient;
|
|
1437
|
-
queryClient: QueryClient;
|
|
1438
|
-
lastRequestId: string | null;
|
|
1439
|
-
protected state: ClientState;
|
|
1440
|
-
protected config: ClientServerConfig;
|
|
1441
|
-
constructor(options: ClientServerConfig);
|
|
1442
|
-
getState(): ClientState;
|
|
1443
|
-
getConfig(): Omit<ClientServerConfig, 'secretKey'>;
|
|
1444
|
-
}
|
|
1445
|
-
/**
|
|
1446
|
-
* Create a server-only client with full read/write access. Requires secretKey.
|
|
1447
|
-
* For read-only usage, prefer `createClient()` (no secretKey needed).
|
|
1448
|
-
*/
|
|
1449
|
-
declare function createServerClient(options: ClientServerConfig): ServerClient;
|
|
1450
|
-
|
|
1451
107
|
declare function getQueryClient(): QueryClient;
|
|
1452
108
|
|
|
1453
109
|
declare const generateOrderNumber: () => string;
|
|
@@ -1468,4 +124,4 @@ declare const formatOrderName: (items: OrderItem[]) => string;
|
|
|
1468
124
|
*/
|
|
1469
125
|
declare const resolveRelation: <T>(ref: T | string | number | null | undefined) => T | null;
|
|
1470
126
|
|
|
1471
|
-
export {
|
|
127
|
+
export { AddItemParams, ApiQueryOptions, ApplyDiscountParams, CalculateShippingParams, CalculateShippingResult, Cart, CartItem, CheckoutParams, ClearCartParams, Client, ClientConfig, ClientState, Client as ClientType, CommerceClient, type CommerceClientOptions, CommunityClient, CustomerAuth, CustomerAuthOptions, CustomerNamespace, ListingGroupsParams, Order, PayloadFindResponse, Product, ProductListingGroupsQueryOptions, ProductListingGroupsResponse, PublicCollection, ReadOnlyCollectionClient, ReadOnlyQueryHooks, RemoveDiscountParams, RemoveItemParams, StockCheckParams, StockCheckResponse, UpdateItemParams, ValidateDiscountParams, ValidateDiscountResult, collectionKeys, createClient, customerKeys, formatOrderName, generateOrderNumber, getQueryClient, productKeys, resolveRelation };
|