@01.software/sdk 0.2.9-dev.260310.cf511cb → 0.2.9-dev.260311.892250f
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 +21 -8
- package/dist/auth.cjs +3 -1
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +36 -3
- package/dist/auth.d.ts +36 -3
- package/dist/auth.js +3 -1
- package/dist/auth.js.map +1 -1
- package/dist/index.cjs +214 -231
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +321 -155
- package/dist/index.d.ts +321 -155
- package/dist/index.js +217 -231
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-Cq93wqIe.d.cts → payload-types-BjvBwB8Z.d.cts} +1601 -1373
- package/dist/{payload-types-Cq93wqIe.d.ts → payload-types-BjvBwB8Z.d.ts} +1601 -1373
- package/dist/ui/code-block.cjs +182 -0
- package/dist/ui/code-block.cjs.map +1 -0
- package/dist/ui/code-block.d.cts +62 -0
- package/dist/ui/code-block.d.ts +62 -0
- package/dist/ui/code-block.js +152 -0
- package/dist/ui/code-block.js.map +1 -0
- package/dist/{flow.cjs → ui/flow.cjs} +120 -96
- package/dist/ui/flow.cjs.map +1 -0
- package/dist/{flow.d.cts → ui/flow.d.cts} +27 -11
- package/dist/{flow.d.ts → ui/flow.d.ts} +27 -11
- package/dist/{flow.js → ui/flow.js} +119 -94
- package/dist/ui/flow.js.map +1 -0
- package/dist/{components.cjs → ui/form.cjs} +27 -520
- package/dist/ui/form.cjs.map +1 -0
- package/dist/ui/form.d.cts +37 -0
- package/dist/ui/form.d.ts +37 -0
- package/dist/{components.js → ui/form.js} +20 -516
- package/dist/ui/form.js.map +1 -0
- package/dist/ui/image.cjs +208 -0
- package/dist/ui/image.cjs.map +1 -0
- package/dist/ui/image.d.cts +44 -0
- package/dist/ui/image.d.ts +44 -0
- package/dist/ui/image.js +180 -0
- package/dist/ui/image.js.map +1 -0
- package/dist/ui/rich-text.cjs +258 -0
- package/dist/ui/rich-text.cjs.map +1 -0
- package/dist/ui/rich-text.d.cts +110 -0
- package/dist/ui/rich-text.d.ts +110 -0
- package/dist/ui/rich-text.js +235 -0
- package/dist/ui/rich-text.js.map +1 -0
- package/dist/{webhook-NRdVwXN7.d.cts → webhook-CszIpUKn.d.cts} +2 -2
- package/dist/{webhook-C_7s0K66.d.ts → webhook-_LdLdjGa.d.ts} +2 -2
- package/dist/webhook.d.cts +2 -2
- package/dist/webhook.d.ts +2 -2
- package/package.json +47 -12
- package/dist/auth-CVVo5UT5.d.ts +0 -298
- package/dist/auth-CqgrT1qd.d.cts +0 -298
- package/dist/components.cjs.map +0 -1
- package/dist/components.d.cts +0 -240
- package/dist/components.d.ts +0 -240
- package/dist/components.js.map +0 -1
- package/dist/flow.cjs.map +0 -1
- package/dist/flow.js.map +0 -1
package/dist/auth-CVVo5UT5.d.ts
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import { Sort, Where } from 'payload';
|
|
2
|
-
import './payload-types-Cq93wqIe.js';
|
|
3
|
-
|
|
4
|
-
declare class SDKError extends Error {
|
|
5
|
-
readonly code: string;
|
|
6
|
-
readonly status?: number;
|
|
7
|
-
readonly details?: unknown;
|
|
8
|
-
readonly userMessage?: string;
|
|
9
|
-
readonly suggestion?: string;
|
|
10
|
-
constructor(code: string, message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
11
|
-
getUserMessage(): string;
|
|
12
|
-
toJSON(): {
|
|
13
|
-
name: string;
|
|
14
|
-
code: string;
|
|
15
|
-
message: string;
|
|
16
|
-
status: number | undefined;
|
|
17
|
-
details: unknown;
|
|
18
|
-
userMessage: string | undefined;
|
|
19
|
-
suggestion: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
declare class NetworkError extends SDKError {
|
|
23
|
-
constructor(message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
24
|
-
}
|
|
25
|
-
declare class ValidationError extends SDKError {
|
|
26
|
-
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
27
|
-
}
|
|
28
|
-
declare class ApiError extends SDKError {
|
|
29
|
-
constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
30
|
-
}
|
|
31
|
-
declare class ConfigError extends SDKError {
|
|
32
|
-
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
33
|
-
}
|
|
34
|
-
declare class TimeoutError extends SDKError {
|
|
35
|
-
constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
36
|
-
}
|
|
37
|
-
declare class GoneError extends SDKError {
|
|
38
|
-
constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
39
|
-
}
|
|
40
|
-
declare class ServiceUnavailableError extends SDKError {
|
|
41
|
-
readonly retryAfter?: number;
|
|
42
|
-
constructor(message?: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
43
|
-
}
|
|
44
|
-
declare class UsageLimitError extends SDKError {
|
|
45
|
-
readonly usage: {
|
|
46
|
-
limit: number;
|
|
47
|
-
current: number;
|
|
48
|
-
remaining: number;
|
|
49
|
-
};
|
|
50
|
-
constructor(message: string, usage: {
|
|
51
|
-
limit: number;
|
|
52
|
-
current: number;
|
|
53
|
-
remaining: number;
|
|
54
|
-
}, details?: unknown, userMessage?: string, suggestion?: string);
|
|
55
|
-
toJSON(): {
|
|
56
|
-
usage: {
|
|
57
|
-
limit: number;
|
|
58
|
-
current: number;
|
|
59
|
-
remaining: number;
|
|
60
|
-
};
|
|
61
|
-
name: string;
|
|
62
|
-
code: string;
|
|
63
|
-
message: string;
|
|
64
|
-
status: number | undefined;
|
|
65
|
-
details: unknown;
|
|
66
|
-
userMessage: string | undefined;
|
|
67
|
-
suggestion: string | undefined;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
declare function isSDKError(error: unknown): error is SDKError;
|
|
71
|
-
declare function isNetworkError(error: unknown): error is NetworkError;
|
|
72
|
-
declare function isValidationError(error: unknown): error is ValidationError;
|
|
73
|
-
declare function isApiError(error: unknown): error is ApiError;
|
|
74
|
-
declare function isConfigError(error: unknown): error is ConfigError;
|
|
75
|
-
declare function isTimeoutError(error: unknown): error is TimeoutError;
|
|
76
|
-
declare function isGoneError(error: unknown): error is GoneError;
|
|
77
|
-
declare function isServiceUnavailableError(error: unknown): error is ServiceUnavailableError;
|
|
78
|
-
declare function isUsageLimitError(error: unknown): error is UsageLimitError;
|
|
79
|
-
|
|
80
|
-
type Environment = 'local' | 'development' | 'staging' | 'production';
|
|
81
|
-
declare const API_URLS: Record<Environment, string>;
|
|
82
|
-
/**
|
|
83
|
-
* 환경에 맞는 API URL을 반환합니다.
|
|
84
|
-
* 우선순위: baseUrl > environment > 환경변수 > 기본값(production)
|
|
85
|
-
*/
|
|
86
|
-
declare function resolveApiUrl(config?: {
|
|
87
|
-
baseUrl?: string;
|
|
88
|
-
environment?: Environment;
|
|
89
|
-
}): string;
|
|
90
|
-
interface ClientBrowserConfig {
|
|
91
|
-
clientKey: string;
|
|
92
|
-
/**
|
|
93
|
-
* API 환경 설정.
|
|
94
|
-
* - 'local': localhost:3000
|
|
95
|
-
* - 'development': dev.01.software
|
|
96
|
-
* - 'staging': stg.01.software
|
|
97
|
-
* - 'production': api.01.software
|
|
98
|
-
*
|
|
99
|
-
* baseUrl이 설정되면 이 값은 무시됩니다.
|
|
100
|
-
* @default 'production'
|
|
101
|
-
*/
|
|
102
|
-
environment?: Environment;
|
|
103
|
-
/**
|
|
104
|
-
* 커스텀 API URL. 설정 시 environment 값은 무시됩니다.
|
|
105
|
-
* @example 'https://my-custom-api.example.com'
|
|
106
|
-
*/
|
|
107
|
-
baseUrl?: string;
|
|
108
|
-
/**
|
|
109
|
-
* Customer authentication options.
|
|
110
|
-
* Used to initialize CustomerAuth on BrowserClient.
|
|
111
|
-
*/
|
|
112
|
-
customer?: {
|
|
113
|
-
/**
|
|
114
|
-
* Automatically persist token in localStorage.
|
|
115
|
-
* - `true`: uses default key `'customer-token'`
|
|
116
|
-
* - `string`: uses the given string as localStorage key
|
|
117
|
-
*
|
|
118
|
-
* Handles SSR safely (no-op on server).
|
|
119
|
-
* When set, `token` and `onTokenChange` are ignored.
|
|
120
|
-
*/
|
|
121
|
-
persist?: boolean | string;
|
|
122
|
-
/** Initial token (e.g. from SSR cookie) */
|
|
123
|
-
token?: string;
|
|
124
|
-
/** Called when token changes (login/logout) — use to persist in localStorage/cookie */
|
|
125
|
-
onTokenChange?: (token: string | null) => void;
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
interface ClientServerConfig extends ClientBrowserConfig {
|
|
129
|
-
secretKey: string;
|
|
130
|
-
}
|
|
131
|
-
interface ClientMetadata {
|
|
132
|
-
userAgent?: string;
|
|
133
|
-
timestamp: number;
|
|
134
|
-
}
|
|
135
|
-
interface ClientState {
|
|
136
|
-
metadata: ClientMetadata;
|
|
137
|
-
}
|
|
138
|
-
interface PaginationMeta {
|
|
139
|
-
page: number;
|
|
140
|
-
limit: number;
|
|
141
|
-
totalDocs: number;
|
|
142
|
-
totalPages: number;
|
|
143
|
-
hasNextPage: boolean;
|
|
144
|
-
hasPrevPage: boolean;
|
|
145
|
-
pagingCounter: number;
|
|
146
|
-
prevPage: number | null;
|
|
147
|
-
nextPage: number | null;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Payload CMS Find (List) Response
|
|
151
|
-
* GET /api/{collection}
|
|
152
|
-
*/
|
|
153
|
-
interface PayloadFindResponse<T = unknown> {
|
|
154
|
-
docs: T[];
|
|
155
|
-
totalDocs: number;
|
|
156
|
-
limit: number;
|
|
157
|
-
totalPages: number;
|
|
158
|
-
page: number;
|
|
159
|
-
pagingCounter: number;
|
|
160
|
-
hasPrevPage: boolean;
|
|
161
|
-
hasNextPage: boolean;
|
|
162
|
-
prevPage: number | null;
|
|
163
|
-
nextPage: number | null;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Payload CMS Create/Update Response
|
|
167
|
-
* POST /api/{collection}
|
|
168
|
-
* PATCH /api/{collection}/{id}
|
|
169
|
-
*/
|
|
170
|
-
interface PayloadMutationResponse<T = unknown> {
|
|
171
|
-
message: string;
|
|
172
|
-
doc: T;
|
|
173
|
-
errors?: unknown[];
|
|
174
|
-
}
|
|
175
|
-
interface ApiQueryOptions {
|
|
176
|
-
page?: number;
|
|
177
|
-
limit?: number;
|
|
178
|
-
sort?: Sort;
|
|
179
|
-
where?: Where;
|
|
180
|
-
depth?: number;
|
|
181
|
-
select?: Record<string, boolean>;
|
|
182
|
-
}
|
|
183
|
-
interface ApiQueryReactOptions {
|
|
184
|
-
keepPreviousData?: boolean;
|
|
185
|
-
}
|
|
186
|
-
interface DebugConfig {
|
|
187
|
-
logRequests?: boolean;
|
|
188
|
-
logResponses?: boolean;
|
|
189
|
-
logErrors?: boolean;
|
|
190
|
-
}
|
|
191
|
-
interface RetryConfig {
|
|
192
|
-
maxRetries?: number;
|
|
193
|
-
retryableStatuses?: number[];
|
|
194
|
-
retryDelay?: (attempt: number) => number;
|
|
195
|
-
}
|
|
196
|
-
interface ErrorLogger {
|
|
197
|
-
log(error: SDKError | Error, context?: Record<string, unknown>): void;
|
|
198
|
-
}
|
|
199
|
-
type DeepPartial<T> = {
|
|
200
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
201
|
-
};
|
|
202
|
-
type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
|
|
203
|
-
|
|
204
|
-
interface FetchOptions extends RequestInit {
|
|
205
|
-
clientKey?: string;
|
|
206
|
-
secretKey?: string;
|
|
207
|
-
customerToken?: string;
|
|
208
|
-
timeout?: number;
|
|
209
|
-
baseUrl?: string;
|
|
210
|
-
debug?: boolean | DebugConfig;
|
|
211
|
-
retry?: RetryConfig;
|
|
212
|
-
/** Called on 401 when customerToken is set. Return a new token to retry, or null to fail. */
|
|
213
|
-
onUnauthorized?: () => Promise<string | null>;
|
|
214
|
-
}
|
|
215
|
-
interface JwtPayload {
|
|
216
|
-
clientKey: string;
|
|
217
|
-
iat?: number;
|
|
218
|
-
exp?: number;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Creates a JWT token for server-side authentication.
|
|
222
|
-
* The token is valid for 1 hour by default.
|
|
223
|
-
*
|
|
224
|
-
* @param clientKey - Client API key
|
|
225
|
-
* @param secretKey - Secret key used for signing
|
|
226
|
-
* @param expiresIn - Token expiration time (default: '1h')
|
|
227
|
-
* @returns Promise<string> JWT token
|
|
228
|
-
*
|
|
229
|
-
* @example
|
|
230
|
-
* ```typescript
|
|
231
|
-
* const token = await createServerToken('client-key', 'secret-key')
|
|
232
|
-
* // Use in Authorization header: `Bearer ${token}`
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
declare function createServerToken(clientKey: string, secretKey: string, expiresIn?: string): Promise<string>;
|
|
236
|
-
/**
|
|
237
|
-
* Verifies a JWT token and returns the payload.
|
|
238
|
-
*
|
|
239
|
-
* @param token - JWT token to verify
|
|
240
|
-
* @param secretKey - Secret key used for verification
|
|
241
|
-
* @returns Promise<JwtPayload> Verified payload containing clientKey
|
|
242
|
-
* @throws Error if token is invalid or expired
|
|
243
|
-
*
|
|
244
|
-
* @example
|
|
245
|
-
* ```typescript
|
|
246
|
-
* const payload = await verifyServerToken(token, 'secret-key')
|
|
247
|
-
* console.log(payload.clientKey)
|
|
248
|
-
* ```
|
|
249
|
-
*/
|
|
250
|
-
declare function verifyServerToken(token: string, secretKey: string): Promise<JwtPayload>;
|
|
251
|
-
/**
|
|
252
|
-
* Decodes a JWT token without verification.
|
|
253
|
-
* WARNING: Use this only when you need to inspect token contents.
|
|
254
|
-
* Always use verifyServerToken for authentication.
|
|
255
|
-
*
|
|
256
|
-
* @param token - JWT token to decode
|
|
257
|
-
* @returns JwtPayload Decoded payload (unverified)
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
* ```typescript
|
|
261
|
-
* const payload = decodeServerToken(token)
|
|
262
|
-
* console.log(payload.clientKey) // Unverified!
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
declare function decodeServerToken(token: string): JwtPayload;
|
|
266
|
-
/**
|
|
267
|
-
* Creates a Base64-encoded API key from clientKey and secretKey.
|
|
268
|
-
* Use this for MCP server authentication.
|
|
269
|
-
*
|
|
270
|
-
* @param clientKey - Client API key
|
|
271
|
-
* @param secretKey - Secret key
|
|
272
|
-
* @returns Base64-encoded API key
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* ```typescript
|
|
276
|
-
* const apiKey = createApiKey('client-key', 'secret-key')
|
|
277
|
-
* // Use in x-api-key header
|
|
278
|
-
* ```
|
|
279
|
-
*/
|
|
280
|
-
declare function createApiKey(clientKey: string, secretKey: string): string;
|
|
281
|
-
/**
|
|
282
|
-
* Parses a Base64-encoded API key to extract clientKey and secretKey.
|
|
283
|
-
*
|
|
284
|
-
* @param apiKey - Base64-encoded API key
|
|
285
|
-
* @returns Object containing clientKey and secretKey
|
|
286
|
-
* @throws Error if API key is invalid
|
|
287
|
-
*
|
|
288
|
-
* @example
|
|
289
|
-
* ```typescript
|
|
290
|
-
* const { clientKey, secretKey } = parseApiKey(apiKey)
|
|
291
|
-
* ```
|
|
292
|
-
*/
|
|
293
|
-
declare function parseApiKey(apiKey: string): {
|
|
294
|
-
clientKey: string;
|
|
295
|
-
secretKey: string;
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
export { type ApiQueryOptions as A, type PaginationMeta as B, type ClientBrowserConfig as C, type DeepPartial as D, type ExtractArrayType as E, type FetchOptions as F, GoneError as G, type ApiQueryReactOptions as H, type JwtPayload as J, NetworkError as N, type PayloadFindResponse as P, type RetryConfig as R, SDKError as S, TimeoutError as T, UsageLimitError as U, ValidationError as V, type PayloadMutationResponse as a, type ClientState as b, type ClientServerConfig as c, type DebugConfig as d, type ErrorLogger as e, ApiError as f, ConfigError as g, ServiceUnavailableError as h, isSDKError as i, isNetworkError as j, isValidationError as k, isApiError as l, isConfigError as m, isTimeoutError as n, isGoneError as o, isServiceUnavailableError as p, isUsageLimitError as q, createServerToken as r, decodeServerToken as s, createApiKey as t, parseApiKey as u, verifyServerToken as v, type Environment as w, API_URLS as x, resolveApiUrl as y, type ClientMetadata as z };
|
package/dist/auth-CqgrT1qd.d.cts
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import { Sort, Where } from 'payload';
|
|
2
|
-
import './payload-types-Cq93wqIe.cjs';
|
|
3
|
-
|
|
4
|
-
declare class SDKError extends Error {
|
|
5
|
-
readonly code: string;
|
|
6
|
-
readonly status?: number;
|
|
7
|
-
readonly details?: unknown;
|
|
8
|
-
readonly userMessage?: string;
|
|
9
|
-
readonly suggestion?: string;
|
|
10
|
-
constructor(code: string, message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
11
|
-
getUserMessage(): string;
|
|
12
|
-
toJSON(): {
|
|
13
|
-
name: string;
|
|
14
|
-
code: string;
|
|
15
|
-
message: string;
|
|
16
|
-
status: number | undefined;
|
|
17
|
-
details: unknown;
|
|
18
|
-
userMessage: string | undefined;
|
|
19
|
-
suggestion: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
declare class NetworkError extends SDKError {
|
|
23
|
-
constructor(message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
24
|
-
}
|
|
25
|
-
declare class ValidationError extends SDKError {
|
|
26
|
-
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
27
|
-
}
|
|
28
|
-
declare class ApiError extends SDKError {
|
|
29
|
-
constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
30
|
-
}
|
|
31
|
-
declare class ConfigError extends SDKError {
|
|
32
|
-
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
33
|
-
}
|
|
34
|
-
declare class TimeoutError extends SDKError {
|
|
35
|
-
constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
36
|
-
}
|
|
37
|
-
declare class GoneError extends SDKError {
|
|
38
|
-
constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
39
|
-
}
|
|
40
|
-
declare class ServiceUnavailableError extends SDKError {
|
|
41
|
-
readonly retryAfter?: number;
|
|
42
|
-
constructor(message?: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
43
|
-
}
|
|
44
|
-
declare class UsageLimitError extends SDKError {
|
|
45
|
-
readonly usage: {
|
|
46
|
-
limit: number;
|
|
47
|
-
current: number;
|
|
48
|
-
remaining: number;
|
|
49
|
-
};
|
|
50
|
-
constructor(message: string, usage: {
|
|
51
|
-
limit: number;
|
|
52
|
-
current: number;
|
|
53
|
-
remaining: number;
|
|
54
|
-
}, details?: unknown, userMessage?: string, suggestion?: string);
|
|
55
|
-
toJSON(): {
|
|
56
|
-
usage: {
|
|
57
|
-
limit: number;
|
|
58
|
-
current: number;
|
|
59
|
-
remaining: number;
|
|
60
|
-
};
|
|
61
|
-
name: string;
|
|
62
|
-
code: string;
|
|
63
|
-
message: string;
|
|
64
|
-
status: number | undefined;
|
|
65
|
-
details: unknown;
|
|
66
|
-
userMessage: string | undefined;
|
|
67
|
-
suggestion: string | undefined;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
declare function isSDKError(error: unknown): error is SDKError;
|
|
71
|
-
declare function isNetworkError(error: unknown): error is NetworkError;
|
|
72
|
-
declare function isValidationError(error: unknown): error is ValidationError;
|
|
73
|
-
declare function isApiError(error: unknown): error is ApiError;
|
|
74
|
-
declare function isConfigError(error: unknown): error is ConfigError;
|
|
75
|
-
declare function isTimeoutError(error: unknown): error is TimeoutError;
|
|
76
|
-
declare function isGoneError(error: unknown): error is GoneError;
|
|
77
|
-
declare function isServiceUnavailableError(error: unknown): error is ServiceUnavailableError;
|
|
78
|
-
declare function isUsageLimitError(error: unknown): error is UsageLimitError;
|
|
79
|
-
|
|
80
|
-
type Environment = 'local' | 'development' | 'staging' | 'production';
|
|
81
|
-
declare const API_URLS: Record<Environment, string>;
|
|
82
|
-
/**
|
|
83
|
-
* 환경에 맞는 API URL을 반환합니다.
|
|
84
|
-
* 우선순위: baseUrl > environment > 환경변수 > 기본값(production)
|
|
85
|
-
*/
|
|
86
|
-
declare function resolveApiUrl(config?: {
|
|
87
|
-
baseUrl?: string;
|
|
88
|
-
environment?: Environment;
|
|
89
|
-
}): string;
|
|
90
|
-
interface ClientBrowserConfig {
|
|
91
|
-
clientKey: string;
|
|
92
|
-
/**
|
|
93
|
-
* API 환경 설정.
|
|
94
|
-
* - 'local': localhost:3000
|
|
95
|
-
* - 'development': dev.01.software
|
|
96
|
-
* - 'staging': stg.01.software
|
|
97
|
-
* - 'production': api.01.software
|
|
98
|
-
*
|
|
99
|
-
* baseUrl이 설정되면 이 값은 무시됩니다.
|
|
100
|
-
* @default 'production'
|
|
101
|
-
*/
|
|
102
|
-
environment?: Environment;
|
|
103
|
-
/**
|
|
104
|
-
* 커스텀 API URL. 설정 시 environment 값은 무시됩니다.
|
|
105
|
-
* @example 'https://my-custom-api.example.com'
|
|
106
|
-
*/
|
|
107
|
-
baseUrl?: string;
|
|
108
|
-
/**
|
|
109
|
-
* Customer authentication options.
|
|
110
|
-
* Used to initialize CustomerAuth on BrowserClient.
|
|
111
|
-
*/
|
|
112
|
-
customer?: {
|
|
113
|
-
/**
|
|
114
|
-
* Automatically persist token in localStorage.
|
|
115
|
-
* - `true`: uses default key `'customer-token'`
|
|
116
|
-
* - `string`: uses the given string as localStorage key
|
|
117
|
-
*
|
|
118
|
-
* Handles SSR safely (no-op on server).
|
|
119
|
-
* When set, `token` and `onTokenChange` are ignored.
|
|
120
|
-
*/
|
|
121
|
-
persist?: boolean | string;
|
|
122
|
-
/** Initial token (e.g. from SSR cookie) */
|
|
123
|
-
token?: string;
|
|
124
|
-
/** Called when token changes (login/logout) — use to persist in localStorage/cookie */
|
|
125
|
-
onTokenChange?: (token: string | null) => void;
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
interface ClientServerConfig extends ClientBrowserConfig {
|
|
129
|
-
secretKey: string;
|
|
130
|
-
}
|
|
131
|
-
interface ClientMetadata {
|
|
132
|
-
userAgent?: string;
|
|
133
|
-
timestamp: number;
|
|
134
|
-
}
|
|
135
|
-
interface ClientState {
|
|
136
|
-
metadata: ClientMetadata;
|
|
137
|
-
}
|
|
138
|
-
interface PaginationMeta {
|
|
139
|
-
page: number;
|
|
140
|
-
limit: number;
|
|
141
|
-
totalDocs: number;
|
|
142
|
-
totalPages: number;
|
|
143
|
-
hasNextPage: boolean;
|
|
144
|
-
hasPrevPage: boolean;
|
|
145
|
-
pagingCounter: number;
|
|
146
|
-
prevPage: number | null;
|
|
147
|
-
nextPage: number | null;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Payload CMS Find (List) Response
|
|
151
|
-
* GET /api/{collection}
|
|
152
|
-
*/
|
|
153
|
-
interface PayloadFindResponse<T = unknown> {
|
|
154
|
-
docs: T[];
|
|
155
|
-
totalDocs: number;
|
|
156
|
-
limit: number;
|
|
157
|
-
totalPages: number;
|
|
158
|
-
page: number;
|
|
159
|
-
pagingCounter: number;
|
|
160
|
-
hasPrevPage: boolean;
|
|
161
|
-
hasNextPage: boolean;
|
|
162
|
-
prevPage: number | null;
|
|
163
|
-
nextPage: number | null;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Payload CMS Create/Update Response
|
|
167
|
-
* POST /api/{collection}
|
|
168
|
-
* PATCH /api/{collection}/{id}
|
|
169
|
-
*/
|
|
170
|
-
interface PayloadMutationResponse<T = unknown> {
|
|
171
|
-
message: string;
|
|
172
|
-
doc: T;
|
|
173
|
-
errors?: unknown[];
|
|
174
|
-
}
|
|
175
|
-
interface ApiQueryOptions {
|
|
176
|
-
page?: number;
|
|
177
|
-
limit?: number;
|
|
178
|
-
sort?: Sort;
|
|
179
|
-
where?: Where;
|
|
180
|
-
depth?: number;
|
|
181
|
-
select?: Record<string, boolean>;
|
|
182
|
-
}
|
|
183
|
-
interface ApiQueryReactOptions {
|
|
184
|
-
keepPreviousData?: boolean;
|
|
185
|
-
}
|
|
186
|
-
interface DebugConfig {
|
|
187
|
-
logRequests?: boolean;
|
|
188
|
-
logResponses?: boolean;
|
|
189
|
-
logErrors?: boolean;
|
|
190
|
-
}
|
|
191
|
-
interface RetryConfig {
|
|
192
|
-
maxRetries?: number;
|
|
193
|
-
retryableStatuses?: number[];
|
|
194
|
-
retryDelay?: (attempt: number) => number;
|
|
195
|
-
}
|
|
196
|
-
interface ErrorLogger {
|
|
197
|
-
log(error: SDKError | Error, context?: Record<string, unknown>): void;
|
|
198
|
-
}
|
|
199
|
-
type DeepPartial<T> = {
|
|
200
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
201
|
-
};
|
|
202
|
-
type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
|
|
203
|
-
|
|
204
|
-
interface FetchOptions extends RequestInit {
|
|
205
|
-
clientKey?: string;
|
|
206
|
-
secretKey?: string;
|
|
207
|
-
customerToken?: string;
|
|
208
|
-
timeout?: number;
|
|
209
|
-
baseUrl?: string;
|
|
210
|
-
debug?: boolean | DebugConfig;
|
|
211
|
-
retry?: RetryConfig;
|
|
212
|
-
/** Called on 401 when customerToken is set. Return a new token to retry, or null to fail. */
|
|
213
|
-
onUnauthorized?: () => Promise<string | null>;
|
|
214
|
-
}
|
|
215
|
-
interface JwtPayload {
|
|
216
|
-
clientKey: string;
|
|
217
|
-
iat?: number;
|
|
218
|
-
exp?: number;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Creates a JWT token for server-side authentication.
|
|
222
|
-
* The token is valid for 1 hour by default.
|
|
223
|
-
*
|
|
224
|
-
* @param clientKey - Client API key
|
|
225
|
-
* @param secretKey - Secret key used for signing
|
|
226
|
-
* @param expiresIn - Token expiration time (default: '1h')
|
|
227
|
-
* @returns Promise<string> JWT token
|
|
228
|
-
*
|
|
229
|
-
* @example
|
|
230
|
-
* ```typescript
|
|
231
|
-
* const token = await createServerToken('client-key', 'secret-key')
|
|
232
|
-
* // Use in Authorization header: `Bearer ${token}`
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
declare function createServerToken(clientKey: string, secretKey: string, expiresIn?: string): Promise<string>;
|
|
236
|
-
/**
|
|
237
|
-
* Verifies a JWT token and returns the payload.
|
|
238
|
-
*
|
|
239
|
-
* @param token - JWT token to verify
|
|
240
|
-
* @param secretKey - Secret key used for verification
|
|
241
|
-
* @returns Promise<JwtPayload> Verified payload containing clientKey
|
|
242
|
-
* @throws Error if token is invalid or expired
|
|
243
|
-
*
|
|
244
|
-
* @example
|
|
245
|
-
* ```typescript
|
|
246
|
-
* const payload = await verifyServerToken(token, 'secret-key')
|
|
247
|
-
* console.log(payload.clientKey)
|
|
248
|
-
* ```
|
|
249
|
-
*/
|
|
250
|
-
declare function verifyServerToken(token: string, secretKey: string): Promise<JwtPayload>;
|
|
251
|
-
/**
|
|
252
|
-
* Decodes a JWT token without verification.
|
|
253
|
-
* WARNING: Use this only when you need to inspect token contents.
|
|
254
|
-
* Always use verifyServerToken for authentication.
|
|
255
|
-
*
|
|
256
|
-
* @param token - JWT token to decode
|
|
257
|
-
* @returns JwtPayload Decoded payload (unverified)
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
* ```typescript
|
|
261
|
-
* const payload = decodeServerToken(token)
|
|
262
|
-
* console.log(payload.clientKey) // Unverified!
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
declare function decodeServerToken(token: string): JwtPayload;
|
|
266
|
-
/**
|
|
267
|
-
* Creates a Base64-encoded API key from clientKey and secretKey.
|
|
268
|
-
* Use this for MCP server authentication.
|
|
269
|
-
*
|
|
270
|
-
* @param clientKey - Client API key
|
|
271
|
-
* @param secretKey - Secret key
|
|
272
|
-
* @returns Base64-encoded API key
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* ```typescript
|
|
276
|
-
* const apiKey = createApiKey('client-key', 'secret-key')
|
|
277
|
-
* // Use in x-api-key header
|
|
278
|
-
* ```
|
|
279
|
-
*/
|
|
280
|
-
declare function createApiKey(clientKey: string, secretKey: string): string;
|
|
281
|
-
/**
|
|
282
|
-
* Parses a Base64-encoded API key to extract clientKey and secretKey.
|
|
283
|
-
*
|
|
284
|
-
* @param apiKey - Base64-encoded API key
|
|
285
|
-
* @returns Object containing clientKey and secretKey
|
|
286
|
-
* @throws Error if API key is invalid
|
|
287
|
-
*
|
|
288
|
-
* @example
|
|
289
|
-
* ```typescript
|
|
290
|
-
* const { clientKey, secretKey } = parseApiKey(apiKey)
|
|
291
|
-
* ```
|
|
292
|
-
*/
|
|
293
|
-
declare function parseApiKey(apiKey: string): {
|
|
294
|
-
clientKey: string;
|
|
295
|
-
secretKey: string;
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
export { type ApiQueryOptions as A, type PaginationMeta as B, type ClientBrowserConfig as C, type DeepPartial as D, type ExtractArrayType as E, type FetchOptions as F, GoneError as G, type ApiQueryReactOptions as H, type JwtPayload as J, NetworkError as N, type PayloadFindResponse as P, type RetryConfig as R, SDKError as S, TimeoutError as T, UsageLimitError as U, ValidationError as V, type PayloadMutationResponse as a, type ClientState as b, type ClientServerConfig as c, type DebugConfig as d, type ErrorLogger as e, ApiError as f, ConfigError as g, ServiceUnavailableError as h, isSDKError as i, isNetworkError as j, isValidationError as k, isApiError as l, isConfigError as m, isTimeoutError as n, isGoneError as o, isServiceUnavailableError as p, isUsageLimitError as q, createServerToken as r, decodeServerToken as s, createApiKey as t, parseApiKey as u, verifyServerToken as v, type Environment as w, API_URLS as x, resolveApiUrl as y, type ClientMetadata as z };
|