@reopt-ai/brandapp-sdk 3.0.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/CHANGELOG.md +574 -0
- package/LICENSE +21 -0
- package/README.md +468 -0
- package/dist/ai/index.d.ts +314 -0
- package/dist/ai/index.js +7 -0
- package/dist/ai-provider/index.d.ts +196 -0
- package/dist/ai-provider/index.js +703 -0
- package/dist/auth/index.d.ts +76 -0
- package/dist/auth/index.js +40 -0
- package/dist/better-auth/client.d.ts +29 -0
- package/dist/better-auth/client.js +10 -0
- package/dist/better-auth/index.d.ts +82 -0
- package/dist/better-auth/index.js +145 -0
- package/dist/chunk-6FLYVNZI.js +32 -0
- package/dist/chunk-6KPKZ7ZB.js +49 -0
- package/dist/chunk-DI6QJPTQ.js +449 -0
- package/dist/chunk-E457LO5A.js +599 -0
- package/dist/chunk-F7BXBTZI.js +54 -0
- package/dist/chunk-J5Y2GSJF.js +443 -0
- package/dist/chunk-K3YVJE6E.js +96 -0
- package/dist/chunk-KU2LN5SE.js +350 -0
- package/dist/chunk-L4DHB36G.js +75 -0
- package/dist/chunk-PJZB4VP7.js +63 -0
- package/dist/chunk-REIKXSMY.js +7 -0
- package/dist/chunk-T2WXHAAC.js +54 -0
- package/dist/chunk-TUKIYH4Q.js +112 -0
- package/dist/chunk-WSEROZVO.js +81 -0
- package/dist/chunk-YRGLBM6V.js +157 -0
- package/dist/client-BkcO-0C2.d.ts +216 -0
- package/dist/client-CN5_tNOC.d.ts +147 -0
- package/dist/client-DttyeM_h.d.ts +102 -0
- package/dist/cms/index.d.ts +137 -0
- package/dist/cms/index.js +101 -0
- package/dist/config-CtxyJsDR.d.ts +397 -0
- package/dist/dev/index.d.ts +509 -0
- package/dist/dev/index.js +3071 -0
- package/dist/eav/coerce.d.ts +42 -0
- package/dist/eav/coerce.js +65 -0
- package/dist/eav/index.d.ts +214 -0
- package/dist/eav/index.js +147 -0
- package/dist/eav/migrate.d.ts +236 -0
- package/dist/eav/migrate.js +219 -0
- package/dist/eav/schema.d.ts +260 -0
- package/dist/eav/schema.js +656 -0
- package/dist/errors-5hd5ZR-M.d.ts +158 -0
- package/dist/feedback/index.d.ts +132 -0
- package/dist/feedback/index.js +5 -0
- package/dist/files/index.d.ts +54 -0
- package/dist/files/index.js +31 -0
- package/dist/index.d.ts +221 -0
- package/dist/index.js +84 -0
- package/dist/plans/index.d.ts +140 -0
- package/dist/plans/index.js +5 -0
- package/dist/push/index.d.ts +79 -0
- package/dist/push/index.js +5 -0
- package/dist/react/hooks.d.ts +376 -0
- package/dist/react/hooks.js +421 -0
- package/dist/terms/index.d.ts +79 -0
- package/dist/terms/index.js +5 -0
- package/dist/testing/index.d.ts +154 -0
- package/dist/testing/index.js +81 -0
- package/dist/typed-client-BxOVIiMU.d.ts +40 -0
- package/dist/types-6E3ZLL9X.d.ts +24 -0
- package/dist/types-DskYLVb8.d.ts +104 -0
- package/dist/types-ckmDDW3N.d.ts +129 -0
- package/dist/webhooks/index.d.ts +140 -0
- package/dist/webhooks/index.js +142 -0
- package/docs/api-reference.md +557 -0
- package/docs/cms.md +318 -0
- package/docs/dev-server.md +164 -0
- package/docs/environment.md +211 -0
- package/docs/errors.md +290 -0
- package/docs/files.md +272 -0
- package/docs/migration.md +315 -0
- package/docs/testing.md +163 -0
- package/package.json +173 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
type EavDataType = "string" | "textarea" | "number" | "boolean" | "date" | "email" | "url" | "select" | "multiselect";
|
|
2
|
+
/**
|
|
3
|
+
* 외부 SDK가 다루는 EAV schema host 분기.
|
|
4
|
+
*
|
|
5
|
+
* - `brandapp` (default): brandapp-scoped 자유 테이블 (EavRecord N rows).
|
|
6
|
+
* - `brandappAuthUser`: BrandappAuthUser 1:1 메타. record id = authUserId,
|
|
7
|
+
* record write/update는 BrandappAuthUser.customData JSONB로 들어간다.
|
|
8
|
+
*
|
|
9
|
+
* `customer`/`post`는 workspace 운영자 전용이라 SDK 표면에서는 노출하지 않는다.
|
|
10
|
+
*/
|
|
11
|
+
type EavSchemaLinkedTo = "brandapp" | "brandappAuthUser";
|
|
12
|
+
type EavEntity = {
|
|
13
|
+
id: string;
|
|
14
|
+
brandappId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string | null;
|
|
17
|
+
icon: string | null;
|
|
18
|
+
/** Host 분기. 1.7.0 부터 응답에 포함 (이전 SDK는 무시 가능). */
|
|
19
|
+
linkedTo: EavSchemaLinkedTo;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
};
|
|
23
|
+
type CreateEntityInput = {
|
|
24
|
+
name: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
icon?: string;
|
|
27
|
+
/** 호스트 분기. 생략 시 `'brandapp'` (자유 테이블). */
|
|
28
|
+
linkedTo?: EavSchemaLinkedTo;
|
|
29
|
+
};
|
|
30
|
+
type UpdateEntityInput = {
|
|
31
|
+
name?: string;
|
|
32
|
+
description?: string | null;
|
|
33
|
+
icon?: string | null;
|
|
34
|
+
};
|
|
35
|
+
type EavAttributeOption = {
|
|
36
|
+
value: string;
|
|
37
|
+
label: string;
|
|
38
|
+
color?: string;
|
|
39
|
+
};
|
|
40
|
+
type EavValidation = {
|
|
41
|
+
min?: number;
|
|
42
|
+
max?: number;
|
|
43
|
+
pattern?: string;
|
|
44
|
+
minLength?: number;
|
|
45
|
+
maxLength?: number;
|
|
46
|
+
customMessage?: string;
|
|
47
|
+
};
|
|
48
|
+
type EavAttribute = {
|
|
49
|
+
id: string;
|
|
50
|
+
entityId: string;
|
|
51
|
+
name: string;
|
|
52
|
+
label: string;
|
|
53
|
+
dataType: EavDataType;
|
|
54
|
+
isRequired: boolean;
|
|
55
|
+
isUnique: boolean;
|
|
56
|
+
defaultValue: string | null;
|
|
57
|
+
validation: EavValidation | null;
|
|
58
|
+
options: EavAttributeOption[] | null;
|
|
59
|
+
sortOrder: number;
|
|
60
|
+
createdAt: string;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
};
|
|
63
|
+
type CreateAttributeInput = {
|
|
64
|
+
name: string;
|
|
65
|
+
label: string;
|
|
66
|
+
dataType: EavDataType;
|
|
67
|
+
isRequired?: boolean;
|
|
68
|
+
isUnique?: boolean;
|
|
69
|
+
defaultValue?: string;
|
|
70
|
+
validation?: EavValidation;
|
|
71
|
+
options?: EavAttributeOption[];
|
|
72
|
+
sortOrder?: number;
|
|
73
|
+
};
|
|
74
|
+
type UpdateAttributeInput = {
|
|
75
|
+
name?: string;
|
|
76
|
+
label?: string;
|
|
77
|
+
dataType?: EavDataType;
|
|
78
|
+
isRequired?: boolean;
|
|
79
|
+
isUnique?: boolean;
|
|
80
|
+
defaultValue?: string | null;
|
|
81
|
+
validation?: EavValidation | null;
|
|
82
|
+
options?: EavAttributeOption[] | null;
|
|
83
|
+
sortOrder?: number;
|
|
84
|
+
};
|
|
85
|
+
type EavRecord = {
|
|
86
|
+
id: string;
|
|
87
|
+
entityId: string;
|
|
88
|
+
authUserId: string | null;
|
|
89
|
+
values: Record<string, unknown>;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
updatedAt: string;
|
|
92
|
+
};
|
|
93
|
+
type CreateRecordInput = {
|
|
94
|
+
authUserId?: string;
|
|
95
|
+
values: Record<string, unknown>;
|
|
96
|
+
};
|
|
97
|
+
type UpdateRecordInput = {
|
|
98
|
+
values: Record<string, unknown>;
|
|
99
|
+
};
|
|
100
|
+
type BulkUpdateItem = {
|
|
101
|
+
id: string;
|
|
102
|
+
values: Record<string, unknown>;
|
|
103
|
+
};
|
|
104
|
+
type AttributeFilterOperator = "eq" | "neq" | "contains" | "gt" | "lt" | "gte" | "lte" | "is_null" | "is_not_null" | "after" | "before";
|
|
105
|
+
type AttributeFilter = {
|
|
106
|
+
attributeId: string;
|
|
107
|
+
operator: AttributeFilterOperator;
|
|
108
|
+
value?: unknown;
|
|
109
|
+
};
|
|
110
|
+
type PaginatedResponse<T> = {
|
|
111
|
+
records: T[];
|
|
112
|
+
total: number;
|
|
113
|
+
page: number;
|
|
114
|
+
limit: number;
|
|
115
|
+
totalPages: number;
|
|
116
|
+
};
|
|
117
|
+
type ListRecordsQuery = {
|
|
118
|
+
page?: number;
|
|
119
|
+
limit?: number;
|
|
120
|
+
authUserId?: string;
|
|
121
|
+
sortBy?: "createdAt" | "updatedAt" | (string & {});
|
|
122
|
+
sortOrder?: "asc" | "desc";
|
|
123
|
+
filters?: AttributeFilter[];
|
|
124
|
+
};
|
|
125
|
+
type CountRecordsQuery = {
|
|
126
|
+
authUserId?: string;
|
|
127
|
+
filters?: AttributeFilter[];
|
|
128
|
+
};
|
|
129
|
+
type UpsertRecordInput = {
|
|
130
|
+
authUserId?: string;
|
|
131
|
+
filters: AttributeFilter[];
|
|
132
|
+
values: Record<string, unknown>;
|
|
133
|
+
};
|
|
134
|
+
type UpsertRecordResult<T = EavRecord> = {
|
|
135
|
+
data: T;
|
|
136
|
+
created: boolean;
|
|
137
|
+
};
|
|
138
|
+
type DeleteWhereInput = {
|
|
139
|
+
authUserId?: string;
|
|
140
|
+
filters: AttributeFilter[];
|
|
141
|
+
};
|
|
142
|
+
/** Return value of the backfill transformer per record. */
|
|
143
|
+
type BackfillTransform = (record: EavRecord) => Record<string, unknown> | null | undefined;
|
|
144
|
+
type BackfillOptions = {
|
|
145
|
+
/** Filters applied to `records.list` while iterating. */
|
|
146
|
+
filters?: AttributeFilter[];
|
|
147
|
+
/** Restricts the iteration to a single user's records. */
|
|
148
|
+
authUserId?: string;
|
|
149
|
+
/** Sort order during iteration (default: `createdAt` ascending). */
|
|
150
|
+
sortBy?: ListRecordsQuery["sortBy"];
|
|
151
|
+
sortOrder?: ListRecordsQuery["sortOrder"];
|
|
152
|
+
/** Page size used while streaming (default: 100, server max). */
|
|
153
|
+
pageSize?: number;
|
|
154
|
+
/**
|
|
155
|
+
* Records per `bulkUpdate` flush (default: 100, server max; clamped to
|
|
156
|
+
* 1..100). Transformed values are buffered and written in batched
|
|
157
|
+
* transactions instead of one PATCH per record — for a large backfill this
|
|
158
|
+
* cuts the request count ~100×. If a batch transaction fails, the SDK falls
|
|
159
|
+
* back to per-record updates for that batch so `failed[]` stays accurate and
|
|
160
|
+
* the run never aborts. Set `1` to update one record per request.
|
|
161
|
+
*/
|
|
162
|
+
batchSize?: number;
|
|
163
|
+
/** Maximum concurrent batch flushes in flight (default: 5). */
|
|
164
|
+
concurrency?: number;
|
|
165
|
+
/** Transformer — return the new partial values, or `null`/`undefined` to skip. */
|
|
166
|
+
transform: BackfillTransform;
|
|
167
|
+
/** Called after every record is processed (success, skip, or fail). */
|
|
168
|
+
onProgress?: (event: BackfillProgressEvent) => void;
|
|
169
|
+
};
|
|
170
|
+
type BackfillProgressEvent = {
|
|
171
|
+
processed: number;
|
|
172
|
+
total: number;
|
|
173
|
+
updated: number;
|
|
174
|
+
skipped: number;
|
|
175
|
+
failed: number;
|
|
176
|
+
};
|
|
177
|
+
type BackfillFailure = {
|
|
178
|
+
recordId: string;
|
|
179
|
+
error: string;
|
|
180
|
+
};
|
|
181
|
+
type BackfillResult = {
|
|
182
|
+
total: number;
|
|
183
|
+
updated: number;
|
|
184
|
+
skipped: number;
|
|
185
|
+
failed: BackfillFailure[];
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
type AttributeDef = {
|
|
189
|
+
dataType: EavDataType;
|
|
190
|
+
label: string;
|
|
191
|
+
isRequired?: boolean;
|
|
192
|
+
isUnique?: boolean;
|
|
193
|
+
defaultValue?: string;
|
|
194
|
+
validation?: EavValidation;
|
|
195
|
+
options?: readonly EavAttributeOption[];
|
|
196
|
+
sortOrder?: number;
|
|
197
|
+
/**
|
|
198
|
+
* Stable server-side ID (UUID). When set, `computeDiff` matches by this
|
|
199
|
+
* ID before falling back to name / previousNames / lockfile heuristics.
|
|
200
|
+
* Once chosen, never change this value — that's the whole point.
|
|
201
|
+
*
|
|
202
|
+
* Equivalent to Prisma's `@id` annotation: pin the row identity in the
|
|
203
|
+
* schema itself so renames and external mutations cannot orphan it.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* attributes: {
|
|
207
|
+
* level: {
|
|
208
|
+
* id: "01HX3K8Q9YZABCDEF1234567",
|
|
209
|
+
* dataType: "string",
|
|
210
|
+
* label: "Level",
|
|
211
|
+
* }
|
|
212
|
+
* }
|
|
213
|
+
*/
|
|
214
|
+
id?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Names this attribute used to have. When present, `computeDiff` matches
|
|
217
|
+
* a server attribute with one of these names and treats it as a rename
|
|
218
|
+
* (`update` action with a `name` change) instead of `delete + create`,
|
|
219
|
+
* preserving all existing record values.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* attributes: {
|
|
223
|
+
* level: {
|
|
224
|
+
* dataType: "string",
|
|
225
|
+
* label: "Level",
|
|
226
|
+
* previousNames: ["tier"], // server still has "tier" — auto-renamed
|
|
227
|
+
* }
|
|
228
|
+
* }
|
|
229
|
+
*/
|
|
230
|
+
previousNames?: readonly string[];
|
|
231
|
+
};
|
|
232
|
+
type EntityDef<A extends Record<string, AttributeDef> = Record<string, AttributeDef>> = {
|
|
233
|
+
name: string;
|
|
234
|
+
description?: string;
|
|
235
|
+
icon?: string;
|
|
236
|
+
attributes: A;
|
|
237
|
+
};
|
|
238
|
+
type SchemaDef<E extends Record<string, EntityDef> = Record<string, EntityDef>> = {
|
|
239
|
+
entities: E;
|
|
240
|
+
};
|
|
241
|
+
type InferDataType<D extends EavDataType, O> = D extends "number" ? number : D extends "boolean" ? boolean : D extends "select" ? O extends readonly {
|
|
242
|
+
value: infer V;
|
|
243
|
+
}[] ? V : string : D extends "multiselect" ? O extends readonly {
|
|
244
|
+
value: infer V;
|
|
245
|
+
}[] ? V[] : string[] : string;
|
|
246
|
+
type RequiredKeys<A extends Record<string, AttributeDef>> = {
|
|
247
|
+
[K in keyof A]: A[K] extends {
|
|
248
|
+
isRequired: true;
|
|
249
|
+
} ? K : never;
|
|
250
|
+
}[keyof A];
|
|
251
|
+
type OptionalKeys<A extends Record<string, AttributeDef>> = {
|
|
252
|
+
[K in keyof A]: A[K] extends {
|
|
253
|
+
isRequired: true;
|
|
254
|
+
} ? never : K;
|
|
255
|
+
}[keyof A];
|
|
256
|
+
type InferValues<E extends EntityDef> = {
|
|
257
|
+
[K in RequiredKeys<E["attributes"]>]: InferDataType<E["attributes"][K]["dataType"], E["attributes"][K] extends {
|
|
258
|
+
options: infer O;
|
|
259
|
+
} ? O : never>;
|
|
260
|
+
} & {
|
|
261
|
+
[K in OptionalKeys<E["attributes"]>]?: InferDataType<E["attributes"][K]["dataType"], E["attributes"][K] extends {
|
|
262
|
+
options: infer O;
|
|
263
|
+
} ? O : never>;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Three-level debug logger.
|
|
268
|
+
*
|
|
269
|
+
* - "off" — silent (default)
|
|
270
|
+
* - "info" — request/response/retry/error one-liners
|
|
271
|
+
* - "trace" — everything in "info" plus request body, response status,
|
|
272
|
+
* response body, and request id
|
|
273
|
+
*
|
|
274
|
+
* Backwards compatible: `debug: true` maps to "info", `debug: false` to "off".
|
|
275
|
+
*
|
|
276
|
+
* Auto-detection:
|
|
277
|
+
* - BRANDAPP_SDK_DEBUG=trace → trace
|
|
278
|
+
* - BRANDAPP_SDK_DEBUG=info | "1" → info
|
|
279
|
+
* - DEBUG=*brandapp* → info
|
|
280
|
+
*
|
|
281
|
+
* Set BRANDAPP_SDK_LOG_FORMAT=json for machine-readable logs (AI agent consumers).
|
|
282
|
+
*/
|
|
283
|
+
type DebugLevel = "off" | "info" | "trace";
|
|
284
|
+
type DebugLogger = {
|
|
285
|
+
level: DebugLevel;
|
|
286
|
+
request(method: string, url: string, requestId: string, body?: unknown): void;
|
|
287
|
+
response(method: string, url: string, status: number, durationMs: number, requestId: string, body?: unknown): void;
|
|
288
|
+
retry(method: string, url: string, attempt: number, reason: string): void;
|
|
289
|
+
error(method: string, url: string, error: string, requestId: string): void;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Default API host for EAV / AI / Files / CMS / Terms. Consumers can override
|
|
294
|
+
* via `config.baseUrl` or the `REOPT_BASE_URL` env var.
|
|
295
|
+
*
|
|
296
|
+
* The canonical production host is `brandapp.reopt.ai` (the brandapp data API —
|
|
297
|
+
* distinct from `{alias}.reopt.ai` brandfront sites). The legacy `brand.reopt.ai`
|
|
298
|
+
* host stays served indefinitely as a backward-compat alias, so SDK builds
|
|
299
|
+
* published before this change keep working. ⚠️ Flip takes effect only on
|
|
300
|
+
* re-publish — republish after `brandapp.reopt.ai` is live on Vercel.
|
|
301
|
+
* (dev host stays `brand.reopt.de:3443` — bound to the local hosts file + cert.)
|
|
302
|
+
*/
|
|
303
|
+
declare const REOPT_BASE_URLS: {
|
|
304
|
+
readonly production: "https://brandapp.reopt.ai";
|
|
305
|
+
readonly development: "https://brand.reopt.de:3443";
|
|
306
|
+
};
|
|
307
|
+
type ReoptSDKConfig<S extends SchemaDef = SchemaDef> = {
|
|
308
|
+
/**
|
|
309
|
+
* OAuth Client ID. Required for Basic Auth (client credentials). **Optional**
|
|
310
|
+
* when a short-lived `token` is supplied instead — that's the secure
|
|
311
|
+
* client-side pattern (see {@link assertBrowserSafe}).
|
|
312
|
+
*/
|
|
313
|
+
clientId?: string;
|
|
314
|
+
/**
|
|
315
|
+
* OAuth Client Secret — a long-lived admin credential (`scope=['*']`, can mint
|
|
316
|
+
* tokens). **Never expose it to the browser.** Required for Basic Auth;
|
|
317
|
+
* **optional** when `token` is supplied. {@link assertBrowserSafe} throws if it
|
|
318
|
+
* is present in a browser context.
|
|
319
|
+
*/
|
|
320
|
+
clientSecret?: string;
|
|
321
|
+
/** Brandapp ID (v1 API path에 사용) */
|
|
322
|
+
brandappId: string;
|
|
323
|
+
/**
|
|
324
|
+
* Short-lived service token (Phase D-2b, RFC-0006). When set, every
|
|
325
|
+
* outbound request uses `Authorization: Bearer <token>` instead of the
|
|
326
|
+
* Basic Auth header derived from clientId/clientSecret.
|
|
327
|
+
*
|
|
328
|
+
* The Basic credentials remain required by `validateConfig` — they
|
|
329
|
+
* stay around in case the caller wants to fall back (e.g. mint a fresh
|
|
330
|
+
* token after expiry, or hit `/token/mint` itself). Per-call overrides
|
|
331
|
+
* via `FetchOptions.bearerToken` still take precedence.
|
|
332
|
+
*/
|
|
333
|
+
token?: string;
|
|
334
|
+
/**
|
|
335
|
+
* true: production (https://brandapp.reopt.ai)
|
|
336
|
+
* false: development (https://brand.reopt.de:3443)
|
|
337
|
+
* undefined (default): auto-detect from `NODE_ENV === "production"`
|
|
338
|
+
*/
|
|
339
|
+
isProduction?: boolean;
|
|
340
|
+
/**
|
|
341
|
+
* Custom base URL — overrides `REOPT_BASE_URL` env, `isProduction`, and the
|
|
342
|
+
* NODE_ENV default. Use this when you need different URLs per SDK instance
|
|
343
|
+
* in the same process. For single-process apps, prefer the `REOPT_BASE_URL`
|
|
344
|
+
* env var (no need to thread `baseUrl` through every call site).
|
|
345
|
+
*/
|
|
346
|
+
baseUrl?: string;
|
|
347
|
+
/**
|
|
348
|
+
* Custom id (auth) base URL — overrides `REOPT_ID_BASE_URL` env and the URL
|
|
349
|
+
* derived from `baseUrl` / `REOPT_BASE_URL` / `isProduction`. Set this when
|
|
350
|
+
* the Better Auth handler is hosted at a non-standard origin (custom dev
|
|
351
|
+
* cluster, on-prem deploy, etc.). For standard reopt.{ai,io,de} hosts you
|
|
352
|
+
* can omit both this and the env var — it's auto-derived from the API host.
|
|
353
|
+
*/
|
|
354
|
+
idBaseUrl?: string;
|
|
355
|
+
/** Request timeout (ms), default: 15000 (AI/Files clients default to 30000) */
|
|
356
|
+
timeout?: number;
|
|
357
|
+
/**
|
|
358
|
+
* Max **total** attempts per request, including the first — *not* the number
|
|
359
|
+
* of retries. Default 3 means 1 initial call + up to 2 retries. `1` disables
|
|
360
|
+
* retries entirely.
|
|
361
|
+
*/
|
|
362
|
+
maxRetries?: number;
|
|
363
|
+
/**
|
|
364
|
+
* Opt in to retrying non-idempotent requests (POST/PATCH) on 5xx / network /
|
|
365
|
+
* timeout failures. Off by default: a mutating request that the server may
|
|
366
|
+
* have already committed (record create, AI credit charge, terms consent) is
|
|
367
|
+
* **not** retried, to avoid duplicate side effects. 429 (rate-limited, never
|
|
368
|
+
* processed) is always retried regardless of this flag. When enabled, mutating
|
|
369
|
+
* requests still carry an `Idempotency-Key` (the request id) so a server that
|
|
370
|
+
* supports it can de-duplicate retries.
|
|
371
|
+
*/
|
|
372
|
+
retryNonIdempotent?: boolean;
|
|
373
|
+
/** EAV schema for type-safe entity() client */
|
|
374
|
+
schema?: S;
|
|
375
|
+
/**
|
|
376
|
+
* Debug logging level.
|
|
377
|
+
* - `false` / `"off"` (default): silent
|
|
378
|
+
* - `true` / `"info"`: one-line per request, response, retry, error
|
|
379
|
+
* - `"trace"`: also dumps redacted request/response bodies + request ids
|
|
380
|
+
*
|
|
381
|
+
* Auto-detected from `BRANDAPP_SDK_DEBUG=trace|info|1` or `DEBUG=*brandapp*`.
|
|
382
|
+
* Set `BRANDAPP_SDK_LOG_FORMAT=json` for machine-readable structured logs.
|
|
383
|
+
*/
|
|
384
|
+
debug?: boolean | DebugLevel;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Resolve the main API base URL for the given SDK config. Priority:
|
|
388
|
+
*
|
|
389
|
+
* 1. `config.baseUrl` — explicit override
|
|
390
|
+
* 2. `REOPT_BASE_URL` env var — set this once and skip threading
|
|
391
|
+
* `baseUrl` through every `createReoptSDK()` call
|
|
392
|
+
* 3. default by `isProduction` / `NODE_ENV` (production →
|
|
393
|
+
* `brandapp.reopt.ai`, otherwise → `brand.reopt.de:3443`)
|
|
394
|
+
*/
|
|
395
|
+
declare function resolveBaseUrl(config: ReoptSDKConfig): string;
|
|
396
|
+
|
|
397
|
+
export { type AttributeDef as A, type BackfillOptions as B, type CountRecordsQuery as C, type DebugLevel as D, type EavAttribute as E, type InferValues as I, type ListRecordsQuery as L, type PaginatedResponse as P, REOPT_BASE_URLS as R, type SchemaDef as S, type UpdateAttributeInput as U, type AttributeFilter as a, type AttributeFilterOperator as b, type BackfillResult as c, type BulkUpdateItem as d, type CreateAttributeInput as e, type CreateEntityInput as f, type CreateRecordInput as g, type DebugLogger as h, type DeleteWhereInput as i, type EavAttributeOption as j, type EavDataType as k, type EavEntity as l, type EavRecord as m, type EavSchemaLinkedTo as n, type EavValidation as o, type EntityDef as p, type ReoptSDKConfig as q, type UpdateEntityInput as r, type UpdateRecordInput as s, type UpsertRecordInput as t, type UpsertRecordResult as u, resolveBaseUrl as v };
|