@reopt-ai/brandapp-sdk 3.3.0 → 3.5.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +10 -1
  3. package/dist/abort--nOBFN4M.js +50 -0
  4. package/dist/ai/index.d.ts +2 -314
  5. package/dist/ai/index.js +3 -8
  6. package/dist/ai-provider/index.d.ts +79 -163
  7. package/dist/ai-provider/index.js +752 -685
  8. package/dist/auth/index.d.ts +27 -27
  9. package/dist/auth/index.js +41 -34
  10. package/dist/better-auth/client.d.ts +6 -5
  11. package/dist/better-auth/client.js +28 -5
  12. package/dist/better-auth/index.d.ts +19 -17
  13. package/dist/better-auth/index.js +180 -144
  14. package/dist/client-61ldOHMz.js +503 -0
  15. package/dist/client-7PCoxVhZ.js +28 -0
  16. package/dist/client-B7rZQ8Zi.d.ts +272 -0
  17. package/dist/client-BGGd_cpV.d.ts +103 -0
  18. package/dist/client-BoIuyx4S.js +273 -0
  19. package/dist/client-BruP5_nU.d.ts +147 -0
  20. package/dist/client-BxtZt405.js +305 -0
  21. package/dist/client-ByN3EQdk.js +83 -0
  22. package/dist/client-CAghoGD_.js +53 -0
  23. package/dist/client-C_pHsPlj.js +81 -0
  24. package/dist/client-D0eBxh8j.d.ts +284 -0
  25. package/dist/client-D6gs61w8.d.ts +53 -0
  26. package/dist/client-DDw5yz_h.d.ts +53 -0
  27. package/dist/client-Dxg8_DIH.d.ts +71 -0
  28. package/dist/client-aMR4CRB8.d.ts +211 -0
  29. package/dist/client-lk6wBu_0.d.ts +48 -0
  30. package/dist/client-wEVKLdly.js +55 -0
  31. package/dist/client-zF1RG2uA.js +86 -0
  32. package/dist/cms/index.d.ts +52 -108
  33. package/dist/cms/index.js +103 -86
  34. package/dist/config-CRytOPPl.d.ts +394 -0
  35. package/dist/config-aml9oQpX.js +487 -0
  36. package/dist/dev/index.d.ts +2 -528
  37. package/dist/dev/index.js +3047 -2967
  38. package/dist/eav/coerce.d.ts +3 -1
  39. package/dist/eav/coerce.js +72 -46
  40. package/dist/eav/index.d.ts +72 -100
  41. package/dist/eav/index.js +158 -126
  42. package/dist/eav/migrate.d.ts +112 -109
  43. package/dist/eav/migrate.js +230 -196
  44. package/dist/eav/schema.d.ts +111 -150
  45. package/dist/eav/schema.js +624 -603
  46. package/dist/encoding-Bwfm3iaE.js +21 -0
  47. package/dist/{errors-BjDFIyA6.d.ts → errors-CRCcErNC.d.ts} +55 -53
  48. package/dist/feedback/index.d.ts +2 -132
  49. package/dist/feedback/index.js +3 -6
  50. package/dist/files/index.d.ts +14 -14
  51. package/dist/files/index.js +41 -25
  52. package/dist/http-client-BZc2mngq.js +386 -0
  53. package/dist/index-1j_738qk.d.ts +470 -0
  54. package/dist/index-CeOLGdyL.d.ts +169 -0
  55. package/dist/index.d.ts +6 -230
  56. package/dist/index.js +119 -71
  57. package/dist/logout/index.d.ts +56 -53
  58. package/dist/logout/index.js +232 -289
  59. package/dist/plans/index.d.ts +2 -236
  60. package/dist/plans/index.js +3 -6
  61. package/dist/push/index.d.ts +2 -79
  62. package/dist/push/index.js +3 -6
  63. package/dist/query-xWqtfkvR.js +35 -0
  64. package/dist/react/hooks.d.ts +157 -100
  65. package/dist/react/hooks.js +862 -406
  66. package/dist/sse-parser-FMjxM7sY.js +86 -0
  67. package/dist/terms/index.d.ts +3 -79
  68. package/dist/terms/index.js +3 -6
  69. package/dist/testing/index.d.ts +52 -104
  70. package/dist/testing/index.js +94 -72
  71. package/dist/types-B-SMkH6s.d.ts +26 -0
  72. package/dist/types-BXDcoJHG.d.ts +131 -0
  73. package/dist/types-BrghN2rJ.d.ts +105 -0
  74. package/dist/types-DjDRszNj.js +11 -0
  75. package/dist/webhooks/index.d.ts +77 -50
  76. package/dist/webhooks/index.js +150 -127
  77. package/docs/api-reference.md +121 -8
  78. package/docs/errors.md +19 -0
  79. package/docs/files.md +165 -7
  80. package/package.json +7 -6
  81. package/dist/chunk-2LSCQHAU.js +0 -21
  82. package/dist/chunk-4U4ZPPL4.js +0 -599
  83. package/dist/chunk-55KHY5GH.js +0 -96
  84. package/dist/chunk-C5VTRZWX.js +0 -458
  85. package/dist/chunk-F7BXBTZI.js +0 -54
  86. package/dist/chunk-FJUCWXX3.js +0 -350
  87. package/dist/chunk-H33OTQEN.js +0 -112
  88. package/dist/chunk-L4DHB36G.js +0 -75
  89. package/dist/chunk-OG7R3UAR.js +0 -105
  90. package/dist/chunk-PF24XU54.js +0 -32
  91. package/dist/chunk-QN3QD67K.js +0 -49
  92. package/dist/chunk-REIKXSMY.js +0 -7
  93. package/dist/chunk-UGBBXCZE.js +0 -157
  94. package/dist/chunk-UVT2E6KD.js +0 -81
  95. package/dist/chunk-YPLT3RFL.js +0 -63
  96. package/dist/chunk-YTKSAWV2.js +0 -463
  97. package/dist/client-BkcO-0C2.d.ts +0 -216
  98. package/dist/client-CN5_tNOC.d.ts +0 -147
  99. package/dist/client-DttyeM_h.d.ts +0 -102
  100. package/dist/config-CtxyJsDR.d.ts +0 -397
  101. package/dist/typed-client-BxOVIiMU.d.ts +0 -40
  102. package/dist/types-6E3ZLL9X.d.ts +0 -24
  103. package/dist/types-DskYLVb8.d.ts +0 -104
  104. package/dist/types-ckmDDW3N.d.ts +0 -129
@@ -0,0 +1,470 @@
1
+ import { n as EditorSpec } from "./types-BXDcoJHG.js";
2
+ import { c as TermsJurisdiction } from "./types-BrghN2rJ.js";
3
+ //#region src/dev/store.d.ts
4
+ type DevEntity = {
5
+ id: string;
6
+ brandappId: string;
7
+ name: string;
8
+ description: string | null;
9
+ icon: string;
10
+ /** Host 분기. dev-server는 backend의 'brandapp' / 'brandappAuthUser'만 미러. */
11
+ linkedTo: "brandapp" | "brandappAuthUser";
12
+ maxRecords: number;
13
+ createdAt: Date;
14
+ updatedAt: Date;
15
+ };
16
+ type DevAttribute = {
17
+ id: string;
18
+ entityId: string;
19
+ name: string;
20
+ label: string;
21
+ dataType: string;
22
+ isRequired: boolean;
23
+ isUnique: boolean;
24
+ defaultValue: string | null;
25
+ validation: unknown | null;
26
+ options: unknown | null;
27
+ sortOrder: number;
28
+ createdAt: Date;
29
+ updatedAt: Date;
30
+ };
31
+ type DevValue = {
32
+ recordId: string;
33
+ attributeId: string;
34
+ value: string;
35
+ };
36
+ type DevRecord = {
37
+ id: string;
38
+ entityId: string;
39
+ brandappAuthUserId: string | null;
40
+ createdAt: Date;
41
+ updatedAt: Date;
42
+ values: DevValue[];
43
+ };
44
+ type DevAuthUser = {
45
+ id: string;
46
+ brandappId: string;
47
+ email: string;
48
+ emailVerified: boolean;
49
+ name: string | null;
50
+ image: string | null;
51
+ createdAt: Date;
52
+ updatedAt: Date;
53
+ };
54
+ type DevAuthSession = {
55
+ id: string;
56
+ userId: string;
57
+ brandappId: string;
58
+ token: string;
59
+ expiresAt: Date;
60
+ ipAddress: string | null;
61
+ userAgent: string | null;
62
+ createdAt: Date;
63
+ updatedAt: Date;
64
+ };
65
+ type DevAuthAccount = {
66
+ id: string;
67
+ userId: string;
68
+ brandappId: string;
69
+ providerId: string;
70
+ accountId: string;
71
+ accessToken: string | null;
72
+ refreshToken: string | null;
73
+ accessTokenExpiresAt: Date | null;
74
+ refreshTokenExpiresAt: Date | null;
75
+ idToken: string | null;
76
+ scope: string | null;
77
+ password: string | null;
78
+ createdAt: Date;
79
+ updatedAt: Date;
80
+ };
81
+ type DevAuthVerification = {
82
+ id: string;
83
+ brandappId: string;
84
+ identifier: string;
85
+ value: string;
86
+ expiresAt: Date;
87
+ createdAt: Date;
88
+ updatedAt: Date;
89
+ };
90
+ type DevFile = {
91
+ id: string;
92
+ brandappId: string;
93
+ name: string;
94
+ contentType: string;
95
+ size: number;
96
+ url: string;
97
+ /** 소속 폴더 ID (루트면 null) — production FileInfo.folderId 미러 */
98
+ folderId: string | null;
99
+ createdAt: Date;
100
+ updatedAt: Date;
101
+ };
102
+ /** production FolderInfo 미러 — 카운트는 응답 시점에 계산 */
103
+ type DevFolder = {
104
+ id: string;
105
+ brandappId: string;
106
+ name: string;
107
+ parentId: string | null;
108
+ createdAt: Date;
109
+ updatedAt: Date;
110
+ };
111
+ /**
112
+ * DevPost mirrors production `Post`/`PostDetail` shape so dev-server responses are
113
+ * indistinguishable from the remote API after the cms-handler maps them.
114
+ * Dates remain as `Date` objects in-memory and are stringified at the boundary.
115
+ */
116
+ type DevPost = {
117
+ id: string;
118
+ brandappId: string;
119
+ slug: string;
120
+ title: string;
121
+ /** Plain-text content (검색용). */
122
+ content: string;
123
+ /** EditorSpec — opt-editor 호환 rich content. dev seeder가 MDX→EditorSpec 변환해서 넣음. */
124
+ contentRich: EditorSpec | null;
125
+ status: string;
126
+ groupId: string | null;
127
+ /** Publish 시각 (status='published' or 'scheduled'에서 의미 있음). */
128
+ publishedAt: Date | null;
129
+ /** Cover image (id + URL). dev에서는 외부 URL 또는 placeholder 권장. */
130
+ coverImage: {
131
+ id: string;
132
+ url: string | null;
133
+ } | null;
134
+ /** Author info. */
135
+ author: {
136
+ id: string;
137
+ name: string;
138
+ image: string | null;
139
+ };
140
+ /** Document icon (emoji 또는 URL). */
141
+ icon: string | null;
142
+ /** Tags as `{id, text}` references — production SDK Tag와 동일. */
143
+ tags: {
144
+ id: string;
145
+ text: string;
146
+ }[];
147
+ /** SEO meta. */
148
+ seo: {
149
+ metaTitle: string | null;
150
+ metaDescription: string | null;
151
+ metaKeywords: string | null;
152
+ };
153
+ createdAt: Date;
154
+ updatedAt: Date;
155
+ };
156
+ type DevPostGroup = {
157
+ id: string;
158
+ brandappId: string;
159
+ /** 브랜드 내 안정적 식별자 (production PostGroup.slug 미러). null 허용. */
160
+ slug: string | null;
161
+ name: string;
162
+ description: string | null;
163
+ color: string;
164
+ /** Brand reference (dev에서는 brandappId를 brand id로 사용해도 OK). */
165
+ brand: {
166
+ id: string;
167
+ name: string;
168
+ } | null;
169
+ createdAt: Date;
170
+ updatedAt: Date;
171
+ };
172
+ type DevTerms = {
173
+ id: string;
174
+ brandappId: string;
175
+ title: string;
176
+ type: "termsOfService" | "privacyPolicy" | "marketingConsent" | "custom";
177
+ jurisdiction: TermsJurisdiction;
178
+ isRequired: boolean;
179
+ isActive: boolean;
180
+ sortOrder: number;
181
+ createdAt: Date;
182
+ updatedAt: Date;
183
+ };
184
+ type DevTermsVersion = {
185
+ id: string;
186
+ termsId: string;
187
+ version: number;
188
+ locale: string;
189
+ content: string;
190
+ changeSummary: string | null;
191
+ publishedAt: Date;
192
+ isCurrent: boolean;
193
+ reConsentDeadline: Date | null;
194
+ createdAt: Date;
195
+ };
196
+ type DevTermsConsent = {
197
+ id: string;
198
+ versionId: string;
199
+ customerId: string;
200
+ status: "granted" | "withdrawn" | "pendingReConsent";
201
+ consentedAt: Date;
202
+ withdrawnAt: Date | null;
203
+ source: string | null;
204
+ ipAddress: string | null;
205
+ userAgent: string | null;
206
+ consentCountry: string | null;
207
+ consentLocale: string | null;
208
+ createdAt: Date;
209
+ };
210
+ type StoreSnapshot = {
211
+ entities: DevEntity[];
212
+ attributes: DevAttribute[];
213
+ records: DevRecord[];
214
+ authUsers: DevAuthUser[];
215
+ authSessions: DevAuthSession[];
216
+ authAccounts: DevAuthAccount[];
217
+ authVerifications: DevAuthVerification[];
218
+ files: DevFile[];
219
+ /** 스냅샷 하위 호환 — 폴더 도입 전 스냅샷엔 없다 */
220
+ folders?: DevFolder[];
221
+ posts: DevPost[];
222
+ postGroups: DevPostGroup[];
223
+ terms: DevTerms[];
224
+ termsVersions: DevTermsVersion[];
225
+ termsConsents: DevTermsConsent[];
226
+ };
227
+ declare class InMemoryStore {
228
+ entities: Map<string, DevEntity>;
229
+ attributes: Map<string, DevAttribute>;
230
+ records: Map<string, DevRecord>;
231
+ authUsers: Map<string, DevAuthUser>;
232
+ authSessions: Map<string, DevAuthSession>;
233
+ authAccounts: Map<string, DevAuthAccount>;
234
+ authVerifications: Map<string, DevAuthVerification>;
235
+ files: Map<string, DevFile>;
236
+ folders: Map<string, DevFolder>;
237
+ posts: Map<string, DevPost>;
238
+ postGroups: Map<string, DevPostGroup>;
239
+ terms: Map<string, DevTerms>;
240
+ termsVersions: Map<string, DevTermsVersion>;
241
+ termsConsents: Map<string, DevTermsConsent>;
242
+ generateId(): string;
243
+ now(): Date;
244
+ findMany<T>(map: Map<string, T>, predicate: (item: T) => boolean): T[];
245
+ findFirst<T>(map: Map<string, T>, predicate: (item: T) => boolean): T | null;
246
+ count<T>(map: Map<string, T>, predicate: (item: T) => boolean): number;
247
+ getEntitiesByBrandapp(brandappId: string): DevEntity[];
248
+ getAttributesByEntity(entityId: string): DevAttribute[];
249
+ getRecordsByEntity(entityId: string): DevRecord[];
250
+ getRecordValues(recordId: string): DevValue[];
251
+ /**
252
+ * Produce a snapshot that is safe to mutate without affecting the store.
253
+ * Dates are preserved by reconstructing them after a structuredClone.
254
+ */
255
+ toSnapshot(): StoreSnapshot;
256
+ toJSON(): string;
257
+ fromSnapshot(snapshot: StoreSnapshot): void;
258
+ fromJSON(json: string): void;
259
+ clear(): void;
260
+ }
261
+ //#endregion
262
+ //#region src/dev/oidc-signing.d.ts
263
+ type MintLogoutTokenInput = {
264
+ /** The RP's OAuth client_id — becomes the logout_token `aud`. */
265
+ clientId: string;
266
+ /** The IdP session id being revoked — becomes `sid` (RP session-termination key). */
267
+ sessionId: string;
268
+ /** Optional subject (`sub`). */
269
+ userId?: string;
270
+ /** Override `iat` (epoch ms) — for testing max-age/expiry branches. */
271
+ issuedAtMs?: number;
272
+ };
273
+ //#endregion
274
+ //#region src/dev/markdown-to-editor-spec.d.ts
275
+ /**
276
+ * Convert a single markdown string to EditorSpec.
277
+ *
278
+ * Throws if `@reopt-ai/opt-editor` is not installed.
279
+ */
280
+ declare function markdownToEditorSpec(markdown: string): Promise<EditorSpec>;
281
+ /**
282
+ * Batch helper — converts multiple markdown bodies in one go.
283
+ * Useful when seeding many posts from MDX files.
284
+ */
285
+ declare function markdownToEditorSpecMany(markdowns: string[]): Promise<EditorSpec[]>;
286
+ //#endregion
287
+ //#region src/dev/index.d.ts
288
+ type ProxyConfig = {
289
+ /** Remote Reopt server URL (e.g. "https://brand.reopt.de:3443") */
290
+ remoteUrl: string;
291
+ /** Remote OAuth credentials */
292
+ remoteCredentials: {
293
+ clientId: string;
294
+ clientSecret: string;
295
+ brandappId: string;
296
+ };
297
+ /** Per-module proxy strategy: "local" (in-memory) or "passthrough" (remote) */
298
+ routes?: {
299
+ eav?: "local" | "passthrough";
300
+ ai?: "local" | "passthrough";
301
+ files?: "local" | "passthrough";
302
+ auth?: "local" | "passthrough";
303
+ cms?: "local" | "passthrough";
304
+ terms?: "local" | "passthrough";
305
+ };
306
+ };
307
+ type DevServerOptions = {
308
+ /** Port to listen on (default: 0 = auto-assign) */
309
+ port?: number;
310
+ /** BrandApp ID for dev context (default: "dev-brandapp") */
311
+ brandappId?: string;
312
+ /** Path to persist data across restarts (default: none) */
313
+ dataPath?: string;
314
+ /** Auto-seed entities from EAV schema definition */
315
+ schema?: DevSchema;
316
+ /** Enable verbose logging */
317
+ verbose?: boolean;
318
+ /** Proxy configuration — forward selected API calls to remote server */
319
+ proxy?: ProxyConfig;
320
+ };
321
+ type DevSchema = {
322
+ entities: Record<string, {
323
+ name?: string;
324
+ description?: string;
325
+ icon?: string;
326
+ maxRecords?: number;
327
+ attributes: Record<string, {
328
+ label?: string;
329
+ dataType?: string;
330
+ isRequired?: boolean;
331
+ isUnique?: boolean;
332
+ defaultValue?: string;
333
+ options?: Array<{
334
+ value: string;
335
+ label: string;
336
+ color?: string;
337
+ }>;
338
+ }>;
339
+ }>;
340
+ };
341
+ type SeedRecordInput = {
342
+ authUserId?: string;
343
+ values: Record<string, unknown>;
344
+ /**
345
+ * Per-record upsert key. Defaults to the entity's provided unique
346
+ * attributes, then falls back to all provided value keys in upsert mode.
347
+ */
348
+ upsertKey?: string | string[];
349
+ };
350
+ type SeedData = Record<string, SeedRecordInput[]>;
351
+ type SeedOptions = {
352
+ /** Append preserves legacy behaviour; upsert refreshes matching records. */
353
+ mode?: "append" | "upsert";
354
+ /** Global upsert key for every record in this seed call. */
355
+ upsertKey?: string | string[];
356
+ };
357
+ type SeedTermsItem = {
358
+ title: string;
359
+ type?: "termsOfService" | "privacyPolicy" | "marketingConsent" | "custom";
360
+ jurisdiction?: TermsJurisdiction;
361
+ isRequired?: boolean;
362
+ /** Defaults to inserting order, ascending. */
363
+ sortOrder?: number;
364
+ /** BCP 47 locale of the current published version. */
365
+ locale?: string;
366
+ /** Markdown / plain-text body of the current published version. */
367
+ content: string;
368
+ changeSummary?: string;
369
+ };
370
+ /**
371
+ * Idempotent PostGroup seed. `(brandappId, slug)` is the upsert key.
372
+ * The server generates `id` on first insert; subsequent calls with the same
373
+ * slug update name/description/color in place.
374
+ */
375
+ type SeedPostGroupInput = {
376
+ /** 브랜드 내 안정적 식별자. SDK consumer가 이 값으로 그룹을 참조한다. */
377
+ slug: string;
378
+ name: string;
379
+ description?: string;
380
+ color?: string;
381
+ };
382
+ type SeedPostInput = {
383
+ /** 소속 PostGroup의 slug. seedPostGroups로 먼저 만들어두거나 함께 시드 가능. */
384
+ groupSlug: string;
385
+ /** 그룹 내 안정적 식별자 (URL slug). 같은 groupSlug+slug 조합으로 upsert. */
386
+ slug: string;
387
+ title: string;
388
+ /** Plain-text content (검색용). */
389
+ content?: string;
390
+ /** EditorSpec — opt-editor 호환. MDX seed는 dev seeder에서 변환 후 여기에 넣음. */
391
+ contentRich?: EditorSpec | null;
392
+ status?: "draft" | "scheduled" | "published" | "archived";
393
+ publishedAt?: string | Date | null;
394
+ coverImage?: {
395
+ id?: string;
396
+ url: string | null;
397
+ } | null;
398
+ author?: Partial<{
399
+ id: string;
400
+ name: string;
401
+ image: string | null;
402
+ }>;
403
+ icon?: string | null;
404
+ /** Tags 입력 — 문자열은 dev seeder가 `{id: 'tag:<text>', text}` 형태로 정규화. */
405
+ tags?: Array<string | {
406
+ id: string;
407
+ text: string;
408
+ }>;
409
+ seo?: {
410
+ metaTitle?: string | null;
411
+ metaDescription?: string | null;
412
+ metaKeywords?: string | null;
413
+ };
414
+ };
415
+ /**
416
+ * Unified seed input for `dev.seedAll()`. Each field is optional and applied
417
+ * in order: postGroups → posts → entities → terms.
418
+ */
419
+ type SeedAllInput = {
420
+ postGroups?: SeedPostGroupInput[];
421
+ posts?: SeedPostInput[];
422
+ /** EAV records keyed by entity name — backward-compatible with `dev.seed()`. */
423
+ entities?: SeedData;
424
+ terms?: SeedTermsItem[];
425
+ };
426
+ type DevServer = {
427
+ /** Base URL of the running server */
428
+ url: string;
429
+ /** Port the server is listening on */
430
+ port: number;
431
+ /** The underlying in-memory store */
432
+ store: InMemoryStore;
433
+ /** Seed records into entities by name */
434
+ seed: (data: SeedData, options?: SeedOptions) => Promise<void>;
435
+ /** Seed BrandApp terms with their initial published version */
436
+ seedTerms: (items: SeedTermsItem[]) => Promise<void>;
437
+ /**
438
+ * Seed PostGroups identified by slug. Idempotent — running twice with the
439
+ * same slug updates name/description/color in place.
440
+ */
441
+ seedPostGroups: (items: SeedPostGroupInput[]) => Promise<void>;
442
+ /**
443
+ * Seed Posts identified by `(groupSlug, slug)`. Idempotent. The PostGroup
444
+ * referenced by `groupSlug` must exist (call `seedPostGroups` first or use
445
+ * `seedAll`).
446
+ */
447
+ seedPosts: (items: SeedPostInput[]) => Promise<void>;
448
+ /** One-shot seeder that applies postGroups → posts → entities → terms in order. */
449
+ seedAll: (input: SeedAllInput) => Promise<void>;
450
+ /** Reset all data (optionally re-seed schema) */
451
+ reset: () => Promise<void>;
452
+ /** Save current state to a JSON file */
453
+ snapshot: (path: string) => Promise<void>;
454
+ /** Restore state from a JSON file */
455
+ restore: (path: string) => Promise<void>;
456
+ /**
457
+ * Mint a spec-compliant `logout_token` signed by the dev IdP, so you can
458
+ * exercise a `createBackchannelLogoutHandler` end-to-end against this server
459
+ * (which serves the matching JWKS at `/api/auth/jwks`). Point the SDK's logout
460
+ * verifier at `dev.url` as `idBaseUrl`. Rejects if the runtime lacks Ed25519
461
+ * Web Crypto (Node 20+).
462
+ */
463
+ mintLogoutToken: (input: MintLogoutTokenInput) => Promise<string>;
464
+ /** Stop the dev server */
465
+ close: () => Promise<void>;
466
+ };
467
+ declare function createDevServer(options?: DevServerOptions): Promise<DevServer>;
468
+ //#endregion
469
+ export { DevPost as _, SeedAllInput as a, InMemoryStore as b, SeedPostGroupInput as c, SeedTermsItem as d, createDevServer as f, DevEntity as g, DevAttribute as h, ProxyConfig as i, SeedPostInput as l, markdownToEditorSpecMany as m, DevServer as n, SeedData as o, markdownToEditorSpec as p, DevServerOptions as r, SeedOptions as s, DevSchema as t, SeedRecordInput as u, DevPostGroup as v, StoreSnapshot as x, DevRecord as y };
470
+ //# sourceMappingURL=index-1j_738qk.d.ts.map
@@ -0,0 +1,169 @@
1
+ import { l as SchemaDef, n as ReoptSDKConfig } from "./config-CRytOPPl.js";
2
+ import { t as ReoptAiClient } from "./client-D0eBxh8j.js";
3
+ import { t as ReoptAuthClient } from "./client-Dxg8_DIH.js";
4
+ import { t as ReoptCmsClient } from "./client-DDw5yz_h.js";
5
+ import { t as ReoptEavClient } from "./client-BGGd_cpV.js";
6
+ import { t as ReoptFeedbackClient } from "./client-BruP5_nU.js";
7
+ import { t as ReoptFileClient } from "./client-B7rZQ8Zi.js";
8
+ import { t as ReoptPlansClient } from "./client-aMR4CRB8.js";
9
+ import { t as ReoptPushClient } from "./client-D6gs61w8.js";
10
+ import { t as ReoptTermsClient } from "./client-lk6wBu_0.js";
11
+ //#region src/core/http-client.d.ts
12
+ type FetchOptions = {
13
+ /** Abort the request via an external AbortSignal (merged with timeout signal). */
14
+ signal?: AbortSignal;
15
+ /** Override the client-level timeout for this call only (ms). */
16
+ timeout?: number;
17
+ /**
18
+ * Swap the default Basic Auth header for `Authorization: Bearer <token>` on
19
+ * this call only. Used by user-scoped endpoints (e.g. `/external-auth`,
20
+ * OIDC userinfo) where the caller supplies an OAuth access token rather
21
+ * than client credentials.
22
+ */
23
+ bearerToken?: string;
24
+ /**
25
+ * Treat this request as idempotent for retry purposes even when the HTTP
26
+ * method is POST/PATCH. Use for read-style operations tunneled over POST
27
+ * (e.g. the Better Auth adapter's `findOne`/`findMany`/`count`) so transient
28
+ * 5xx / network / timeout failures are retried without opting the whole
29
+ * client into `retryNonIdempotent`. **Never** set this on a mutation — a
30
+ * retried write may duplicate a committed side effect.
31
+ */
32
+ idempotent?: boolean;
33
+ };
34
+ type BaseHttpClientOptions = {
35
+ /**
36
+ * Route requests at the id (auth) server instead of the main API host.
37
+ * Used for OIDC userinfo, Better Auth, and other `/api/auth/*` endpoints
38
+ * that only exist on `id.reopt.ai`.
39
+ */
40
+ useIdServer?: boolean;
41
+ };
42
+ declare class BaseHttpClient {
43
+ private readonly baseUrl;
44
+ private readonly authHeader;
45
+ private readonly timeout;
46
+ private readonly maxRetries;
47
+ private readonly retryNonIdempotent;
48
+ private readonly debug;
49
+ constructor(config: ReoptSDKConfig, pathPrefix: string, options?: BaseHttpClientOptions);
50
+ /**
51
+ * Resolved request origin + path prefix
52
+ * (e.g. `https://brandapp.reopt.ai/api/v1/brandapp/{id}/ai`). Exposed so domain
53
+ * clients that must hand-roll `fetch` (SSE streaming, multipart upload) reuse
54
+ * the same resolved host instead of re-deriving it.
55
+ */
56
+ get requestBaseUrl(): string;
57
+ /** The default `Authorization` header value (Basic or pre-minted Bearer). */
58
+ get authorizationHeader(): string;
59
+ /** Configured request timeout in ms. */
60
+ get timeoutMs(): number;
61
+ fetch<T>(method: string, path: string, body?: unknown, options?: FetchOptions): Promise<T>;
62
+ }
63
+ //#endregion
64
+ //#region src/singleton.d.ts
65
+ /**
66
+ * Create a lazy SDK instance that initializes on first property access.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * import { createLazySDK } from "@reopt-ai/brandapp-sdk";
71
+ * import schema from "./eav.schema";
72
+ *
73
+ * export const sdk = createLazySDK(() => ({
74
+ * clientId: process.env.BRANDAPP_CLIENT_ID!,
75
+ * clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
76
+ * brandappId: process.env.BRANDAPP_ID!,
77
+ * schema,
78
+ * }));
79
+ *
80
+ * // First property access triggers initialization
81
+ * await sdk.eav.entity("contacts").records.list();
82
+ * ```
83
+ */
84
+ declare function createLazySDK<S extends SchemaDef = SchemaDef>(configFactory: () => ReoptSDKConfig<S>): ReoptSDK<S>;
85
+ /**
86
+ * Initialize the global SDK singleton with explicit config.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * import { initReoptSDK } from "@reopt-ai/brandapp-sdk";
91
+ *
92
+ * initReoptSDK({
93
+ * clientId: process.env.BRANDAPP_CLIENT_ID!,
94
+ * clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
95
+ * brandappId: process.env.BRANDAPP_ID!,
96
+ * });
97
+ * ```
98
+ */
99
+ declare function initReoptSDK<S extends SchemaDef = SchemaDef>(config: ReoptSDKConfig<S>): ReoptSDK<S>;
100
+ /**
101
+ * Get the global SDK singleton.
102
+ *
103
+ * Returns the instance set by `initReoptSDK()`, or auto-creates one
104
+ * from environment variables (`BRANDAPP_CLIENT_ID`, `BRANDAPP_CLIENT_SECRET`,
105
+ * `BRANDAPP_ID`).
106
+ *
107
+ * ⚠️ **Schema generic is not carried here.** A single module-global variable
108
+ * structurally cannot preserve a per-call schema type, so this always returns
109
+ * the default-schema `ReoptSDK` — `sdk.eav.entity(name)` falls back to untyped
110
+ * access (no autocomplete / `InferValues`). For type-safe EAV, prefer
111
+ * {@link createLazySDK} (or `createReoptSDK`) with your `schema`, which keeps
112
+ * the generic intact.
113
+ *
114
+ * @throws {Error} If no instance exists and env vars are missing
115
+ */
116
+ declare function getReoptSDK(): ReoptSDK;
117
+ /** Reset the global SDK singleton. Useful for testing. */
118
+ declare function resetSDK(): void;
119
+ //#endregion
120
+ //#region src/index.d.ts
121
+ /**
122
+ * Create a unified Reopt SDK instance
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * import { createReoptSDK } from "@reopt-ai/brandapp-sdk";
127
+ *
128
+ * const sdk = createReoptSDK({
129
+ * clientId: process.env.BRANDAPP_CLIENT_ID!,
130
+ * clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
131
+ * brandappId: process.env.BRANDAPP_ID!,
132
+ * });
133
+ *
134
+ * // EAV client
135
+ * const entities = await sdk.eav.entities.list();
136
+ *
137
+ * // AI client
138
+ * const result = await sdk.ai.complete({
139
+ * messages: [{ role: "user", content: "Hello" }],
140
+ * });
141
+ *
142
+ * // File client
143
+ * const { data: files } = await sdk.files.list();
144
+ * const uploaded = await sdk.files.upload(blob, { name: "banner.png" });
145
+ *
146
+ * // CMS client
147
+ * const { records: posts } = await sdk.cms.posts.list({ status: "published" });
148
+ * const post = await sdk.cms.posts.get(postId);
149
+ * ```
150
+ */
151
+ type ReoptSDK<S extends SchemaDef = SchemaDef> = {
152
+ config: {
153
+ brandappId: string;
154
+ debug: NonNullable<ReoptSDKConfig["debug"]>;
155
+ };
156
+ ai: ReoptAiClient;
157
+ auth: ReoptAuthClient;
158
+ cms: ReoptCmsClient;
159
+ eav: ReoptEavClient<S>;
160
+ feedback: ReoptFeedbackClient;
161
+ files: ReoptFileClient;
162
+ plans: ReoptPlansClient;
163
+ push: ReoptPushClient;
164
+ terms: ReoptTermsClient;
165
+ };
166
+ declare function createReoptSDK<S extends SchemaDef = SchemaDef>(config: ReoptSDKConfig<S>): ReoptSDK<S>;
167
+ //#endregion
168
+ export { initReoptSDK as a, getReoptSDK as i, createReoptSDK as n, resetSDK as o, createLazySDK as r, BaseHttpClient as s, ReoptSDK as t };
169
+ //# sourceMappingURL=index-CeOLGdyL.d.ts.map