@reopt-ai/brandapp-sdk 3.3.0 → 3.4.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 +67 -0
- package/README.md +10 -1
- package/dist/abort--nOBFN4M.js +50 -0
- package/dist/ai/index.d.ts +2 -314
- package/dist/ai/index.js +3 -8
- package/dist/ai-provider/index.d.ts +79 -163
- package/dist/ai-provider/index.js +752 -685
- package/dist/auth/index.d.ts +27 -27
- package/dist/auth/index.js +41 -34
- package/dist/better-auth/client.d.ts +6 -5
- package/dist/better-auth/client.js +28 -5
- package/dist/better-auth/index.d.ts +19 -17
- package/dist/better-auth/index.js +180 -144
- package/dist/client-B1q5P8rv.js +83 -0
- package/dist/client-B9QHVhdM.js +77 -0
- package/dist/client-BGGd_cpV.d.ts +103 -0
- package/dist/client-BJcy1V1a.js +140 -0
- package/dist/client-Beivhucf.js +55 -0
- package/dist/client-BruP5_nU.d.ts +147 -0
- package/dist/client-D-yNxNfk.js +28 -0
- package/dist/client-D0eBxh8j.d.ts +284 -0
- package/dist/client-D3RHHUUW.d.ts +207 -0
- package/dist/client-D6gs61w8.d.ts +53 -0
- package/dist/client-DBnK7ooQ.js +86 -0
- package/dist/client-DDw5yz_h.d.ts +53 -0
- package/dist/client-DPmoKuR9.js +305 -0
- package/dist/client-DsdakibF.js +503 -0
- package/dist/client-Dxg8_DIH.d.ts +71 -0
- package/dist/client-EbhUIhHq.js +53 -0
- package/dist/client-lk6wBu_0.d.ts +48 -0
- package/dist/client-p49ol9pg.d.ts +124 -0
- package/dist/cms/index.d.ts +52 -108
- package/dist/cms/index.js +103 -86
- package/dist/config-CRytOPPl.d.ts +394 -0
- package/dist/config-Cw0a3-C8.js +487 -0
- package/dist/dev/index.d.ts +2 -528
- package/dist/dev/index.js +2731 -2967
- package/dist/eav/coerce.d.ts +3 -1
- package/dist/eav/coerce.js +72 -46
- package/dist/eav/index.d.ts +72 -100
- package/dist/eav/index.js +158 -126
- package/dist/eav/migrate.d.ts +112 -109
- package/dist/eav/migrate.js +230 -196
- package/dist/eav/schema.d.ts +111 -150
- package/dist/eav/schema.js +624 -603
- package/dist/encoding-Bwfm3iaE.js +21 -0
- package/dist/{errors-BjDFIyA6.d.ts → errors-CRCcErNC.d.ts} +55 -53
- package/dist/feedback/index.d.ts +2 -132
- package/dist/feedback/index.js +3 -6
- package/dist/files/index.d.ts +14 -14
- package/dist/files/index.js +41 -25
- package/dist/http-client-QKUvvirs.js +386 -0
- package/dist/index-DrVaKfhs.d.ts +456 -0
- package/dist/index-Z6OGcurJ.d.ts +169 -0
- package/dist/index.d.ts +6 -230
- package/dist/index.js +119 -71
- package/dist/logout/index.d.ts +56 -53
- package/dist/logout/index.js +232 -289
- package/dist/plans/index.d.ts +2 -236
- package/dist/plans/index.js +3 -6
- package/dist/push/index.d.ts +2 -79
- package/dist/push/index.js +3 -6
- package/dist/query-BvbCiGWb.js +35 -0
- package/dist/react/hooks.d.ts +97 -99
- package/dist/react/hooks.js +742 -404
- package/dist/sse-parser-FMjxM7sY.js +86 -0
- package/dist/terms/index.d.ts +3 -79
- package/dist/terms/index.js +3 -6
- package/dist/testing/index.d.ts +52 -104
- package/dist/testing/index.js +94 -72
- package/dist/types-B-SMkH6s.d.ts +26 -0
- package/dist/types-BXDcoJHG.d.ts +131 -0
- package/dist/types-BrghN2rJ.d.ts +105 -0
- package/dist/types-DjDRszNj.js +11 -0
- package/dist/webhooks/index.d.ts +77 -50
- package/dist/webhooks/index.js +150 -127
- package/docs/api-reference.md +87 -6
- package/package.json +6 -5
- package/dist/chunk-2LSCQHAU.js +0 -21
- package/dist/chunk-4U4ZPPL4.js +0 -599
- package/dist/chunk-55KHY5GH.js +0 -96
- package/dist/chunk-C5VTRZWX.js +0 -458
- package/dist/chunk-F7BXBTZI.js +0 -54
- package/dist/chunk-FJUCWXX3.js +0 -350
- package/dist/chunk-H33OTQEN.js +0 -112
- package/dist/chunk-L4DHB36G.js +0 -75
- package/dist/chunk-OG7R3UAR.js +0 -105
- package/dist/chunk-PF24XU54.js +0 -32
- package/dist/chunk-QN3QD67K.js +0 -49
- package/dist/chunk-REIKXSMY.js +0 -7
- package/dist/chunk-UGBBXCZE.js +0 -157
- package/dist/chunk-UVT2E6KD.js +0 -81
- package/dist/chunk-YPLT3RFL.js +0 -63
- package/dist/chunk-YTKSAWV2.js +0 -463
- package/dist/client-BkcO-0C2.d.ts +0 -216
- package/dist/client-CN5_tNOC.d.ts +0 -147
- package/dist/client-DttyeM_h.d.ts +0 -102
- package/dist/config-CtxyJsDR.d.ts +0 -397
- package/dist/typed-client-BxOVIiMU.d.ts +0 -40
- package/dist/types-6E3ZLL9X.d.ts +0 -24
- package/dist/types-DskYLVb8.d.ts +0 -104
- package/dist/types-ckmDDW3N.d.ts +0 -129
|
@@ -0,0 +1,456 @@
|
|
|
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
|
+
createdAt: Date;
|
|
98
|
+
updatedAt: Date;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* DevPost mirrors production `Post`/`PostDetail` shape so dev-server responses are
|
|
102
|
+
* indistinguishable from the remote API after the cms-handler maps them.
|
|
103
|
+
* Dates remain as `Date` objects in-memory and are stringified at the boundary.
|
|
104
|
+
*/
|
|
105
|
+
type DevPost = {
|
|
106
|
+
id: string;
|
|
107
|
+
brandappId: string;
|
|
108
|
+
slug: string;
|
|
109
|
+
title: string;
|
|
110
|
+
/** Plain-text content (검색용). */
|
|
111
|
+
content: string;
|
|
112
|
+
/** EditorSpec — opt-editor 호환 rich content. dev seeder가 MDX→EditorSpec 변환해서 넣음. */
|
|
113
|
+
contentRich: EditorSpec | null;
|
|
114
|
+
status: string;
|
|
115
|
+
groupId: string | null;
|
|
116
|
+
/** Publish 시각 (status='published' or 'scheduled'에서 의미 있음). */
|
|
117
|
+
publishedAt: Date | null;
|
|
118
|
+
/** Cover image (id + URL). dev에서는 외부 URL 또는 placeholder 권장. */
|
|
119
|
+
coverImage: {
|
|
120
|
+
id: string;
|
|
121
|
+
url: string | null;
|
|
122
|
+
} | null;
|
|
123
|
+
/** Author info. */
|
|
124
|
+
author: {
|
|
125
|
+
id: string;
|
|
126
|
+
name: string;
|
|
127
|
+
image: string | null;
|
|
128
|
+
};
|
|
129
|
+
/** Document icon (emoji 또는 URL). */
|
|
130
|
+
icon: string | null;
|
|
131
|
+
/** Tags as `{id, text}` references — production SDK Tag와 동일. */
|
|
132
|
+
tags: {
|
|
133
|
+
id: string;
|
|
134
|
+
text: string;
|
|
135
|
+
}[];
|
|
136
|
+
/** SEO meta. */
|
|
137
|
+
seo: {
|
|
138
|
+
metaTitle: string | null;
|
|
139
|
+
metaDescription: string | null;
|
|
140
|
+
metaKeywords: string | null;
|
|
141
|
+
};
|
|
142
|
+
createdAt: Date;
|
|
143
|
+
updatedAt: Date;
|
|
144
|
+
};
|
|
145
|
+
type DevPostGroup = {
|
|
146
|
+
id: string;
|
|
147
|
+
brandappId: string;
|
|
148
|
+
/** 브랜드 내 안정적 식별자 (production PostGroup.slug 미러). null 허용. */
|
|
149
|
+
slug: string | null;
|
|
150
|
+
name: string;
|
|
151
|
+
description: string | null;
|
|
152
|
+
color: string;
|
|
153
|
+
/** Brand reference (dev에서는 brandappId를 brand id로 사용해도 OK). */
|
|
154
|
+
brand: {
|
|
155
|
+
id: string;
|
|
156
|
+
name: string;
|
|
157
|
+
} | null;
|
|
158
|
+
createdAt: Date;
|
|
159
|
+
updatedAt: Date;
|
|
160
|
+
};
|
|
161
|
+
type DevTerms = {
|
|
162
|
+
id: string;
|
|
163
|
+
brandappId: string;
|
|
164
|
+
title: string;
|
|
165
|
+
type: "termsOfService" | "privacyPolicy" | "marketingConsent" | "custom";
|
|
166
|
+
jurisdiction: TermsJurisdiction;
|
|
167
|
+
isRequired: boolean;
|
|
168
|
+
isActive: boolean;
|
|
169
|
+
sortOrder: number;
|
|
170
|
+
createdAt: Date;
|
|
171
|
+
updatedAt: Date;
|
|
172
|
+
};
|
|
173
|
+
type DevTermsVersion = {
|
|
174
|
+
id: string;
|
|
175
|
+
termsId: string;
|
|
176
|
+
version: number;
|
|
177
|
+
locale: string;
|
|
178
|
+
content: string;
|
|
179
|
+
changeSummary: string | null;
|
|
180
|
+
publishedAt: Date;
|
|
181
|
+
isCurrent: boolean;
|
|
182
|
+
reConsentDeadline: Date | null;
|
|
183
|
+
createdAt: Date;
|
|
184
|
+
};
|
|
185
|
+
type DevTermsConsent = {
|
|
186
|
+
id: string;
|
|
187
|
+
versionId: string;
|
|
188
|
+
customerId: string;
|
|
189
|
+
status: "granted" | "withdrawn" | "pendingReConsent";
|
|
190
|
+
consentedAt: Date;
|
|
191
|
+
withdrawnAt: Date | null;
|
|
192
|
+
source: string | null;
|
|
193
|
+
ipAddress: string | null;
|
|
194
|
+
userAgent: string | null;
|
|
195
|
+
consentCountry: string | null;
|
|
196
|
+
consentLocale: string | null;
|
|
197
|
+
createdAt: Date;
|
|
198
|
+
};
|
|
199
|
+
type StoreSnapshot = {
|
|
200
|
+
entities: DevEntity[];
|
|
201
|
+
attributes: DevAttribute[];
|
|
202
|
+
records: DevRecord[];
|
|
203
|
+
authUsers: DevAuthUser[];
|
|
204
|
+
authSessions: DevAuthSession[];
|
|
205
|
+
authAccounts: DevAuthAccount[];
|
|
206
|
+
authVerifications: DevAuthVerification[];
|
|
207
|
+
files: DevFile[];
|
|
208
|
+
posts: DevPost[];
|
|
209
|
+
postGroups: DevPostGroup[];
|
|
210
|
+
terms: DevTerms[];
|
|
211
|
+
termsVersions: DevTermsVersion[];
|
|
212
|
+
termsConsents: DevTermsConsent[];
|
|
213
|
+
};
|
|
214
|
+
declare class InMemoryStore {
|
|
215
|
+
entities: Map<string, DevEntity>;
|
|
216
|
+
attributes: Map<string, DevAttribute>;
|
|
217
|
+
records: Map<string, DevRecord>;
|
|
218
|
+
authUsers: Map<string, DevAuthUser>;
|
|
219
|
+
authSessions: Map<string, DevAuthSession>;
|
|
220
|
+
authAccounts: Map<string, DevAuthAccount>;
|
|
221
|
+
authVerifications: Map<string, DevAuthVerification>;
|
|
222
|
+
files: Map<string, DevFile>;
|
|
223
|
+
posts: Map<string, DevPost>;
|
|
224
|
+
postGroups: Map<string, DevPostGroup>;
|
|
225
|
+
terms: Map<string, DevTerms>;
|
|
226
|
+
termsVersions: Map<string, DevTermsVersion>;
|
|
227
|
+
termsConsents: Map<string, DevTermsConsent>;
|
|
228
|
+
generateId(): string;
|
|
229
|
+
now(): Date;
|
|
230
|
+
findMany<T>(map: Map<string, T>, predicate: (item: T) => boolean): T[];
|
|
231
|
+
findFirst<T>(map: Map<string, T>, predicate: (item: T) => boolean): T | null;
|
|
232
|
+
count<T>(map: Map<string, T>, predicate: (item: T) => boolean): number;
|
|
233
|
+
getEntitiesByBrandapp(brandappId: string): DevEntity[];
|
|
234
|
+
getAttributesByEntity(entityId: string): DevAttribute[];
|
|
235
|
+
getRecordsByEntity(entityId: string): DevRecord[];
|
|
236
|
+
getRecordValues(recordId: string): DevValue[];
|
|
237
|
+
/**
|
|
238
|
+
* Produce a snapshot that is safe to mutate without affecting the store.
|
|
239
|
+
* Dates are preserved by reconstructing them after a structuredClone.
|
|
240
|
+
*/
|
|
241
|
+
toSnapshot(): StoreSnapshot;
|
|
242
|
+
toJSON(): string;
|
|
243
|
+
fromSnapshot(snapshot: StoreSnapshot): void;
|
|
244
|
+
fromJSON(json: string): void;
|
|
245
|
+
clear(): void;
|
|
246
|
+
}
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/dev/oidc-signing.d.ts
|
|
249
|
+
type MintLogoutTokenInput = {
|
|
250
|
+
/** The RP's OAuth client_id — becomes the logout_token `aud`. */
|
|
251
|
+
clientId: string;
|
|
252
|
+
/** The IdP session id being revoked — becomes `sid` (RP session-termination key). */
|
|
253
|
+
sessionId: string;
|
|
254
|
+
/** Optional subject (`sub`). */
|
|
255
|
+
userId?: string;
|
|
256
|
+
/** Override `iat` (epoch ms) — for testing max-age/expiry branches. */
|
|
257
|
+
issuedAtMs?: number;
|
|
258
|
+
};
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/dev/markdown-to-editor-spec.d.ts
|
|
261
|
+
/**
|
|
262
|
+
* Convert a single markdown string to EditorSpec.
|
|
263
|
+
*
|
|
264
|
+
* Throws if `@reopt-ai/opt-editor` is not installed.
|
|
265
|
+
*/
|
|
266
|
+
declare function markdownToEditorSpec(markdown: string): Promise<EditorSpec>;
|
|
267
|
+
/**
|
|
268
|
+
* Batch helper — converts multiple markdown bodies in one go.
|
|
269
|
+
* Useful when seeding many posts from MDX files.
|
|
270
|
+
*/
|
|
271
|
+
declare function markdownToEditorSpecMany(markdowns: string[]): Promise<EditorSpec[]>;
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/dev/index.d.ts
|
|
274
|
+
type ProxyConfig = {
|
|
275
|
+
/** Remote Reopt server URL (e.g. "https://brand.reopt.de:3443") */
|
|
276
|
+
remoteUrl: string;
|
|
277
|
+
/** Remote OAuth credentials */
|
|
278
|
+
remoteCredentials: {
|
|
279
|
+
clientId: string;
|
|
280
|
+
clientSecret: string;
|
|
281
|
+
brandappId: string;
|
|
282
|
+
};
|
|
283
|
+
/** Per-module proxy strategy: "local" (in-memory) or "passthrough" (remote) */
|
|
284
|
+
routes?: {
|
|
285
|
+
eav?: "local" | "passthrough";
|
|
286
|
+
ai?: "local" | "passthrough";
|
|
287
|
+
files?: "local" | "passthrough";
|
|
288
|
+
auth?: "local" | "passthrough";
|
|
289
|
+
cms?: "local" | "passthrough";
|
|
290
|
+
terms?: "local" | "passthrough";
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
type DevServerOptions = {
|
|
294
|
+
/** Port to listen on (default: 0 = auto-assign) */
|
|
295
|
+
port?: number;
|
|
296
|
+
/** BrandApp ID for dev context (default: "dev-brandapp") */
|
|
297
|
+
brandappId?: string;
|
|
298
|
+
/** Path to persist data across restarts (default: none) */
|
|
299
|
+
dataPath?: string;
|
|
300
|
+
/** Auto-seed entities from EAV schema definition */
|
|
301
|
+
schema?: DevSchema;
|
|
302
|
+
/** Enable verbose logging */
|
|
303
|
+
verbose?: boolean;
|
|
304
|
+
/** Proxy configuration — forward selected API calls to remote server */
|
|
305
|
+
proxy?: ProxyConfig;
|
|
306
|
+
};
|
|
307
|
+
type DevSchema = {
|
|
308
|
+
entities: Record<string, {
|
|
309
|
+
name?: string;
|
|
310
|
+
description?: string;
|
|
311
|
+
icon?: string;
|
|
312
|
+
maxRecords?: number;
|
|
313
|
+
attributes: Record<string, {
|
|
314
|
+
label?: string;
|
|
315
|
+
dataType?: string;
|
|
316
|
+
isRequired?: boolean;
|
|
317
|
+
isUnique?: boolean;
|
|
318
|
+
defaultValue?: string;
|
|
319
|
+
options?: Array<{
|
|
320
|
+
value: string;
|
|
321
|
+
label: string;
|
|
322
|
+
color?: string;
|
|
323
|
+
}>;
|
|
324
|
+
}>;
|
|
325
|
+
}>;
|
|
326
|
+
};
|
|
327
|
+
type SeedRecordInput = {
|
|
328
|
+
authUserId?: string;
|
|
329
|
+
values: Record<string, unknown>;
|
|
330
|
+
/**
|
|
331
|
+
* Per-record upsert key. Defaults to the entity's provided unique
|
|
332
|
+
* attributes, then falls back to all provided value keys in upsert mode.
|
|
333
|
+
*/
|
|
334
|
+
upsertKey?: string | string[];
|
|
335
|
+
};
|
|
336
|
+
type SeedData = Record<string, SeedRecordInput[]>;
|
|
337
|
+
type SeedOptions = {
|
|
338
|
+
/** Append preserves legacy behaviour; upsert refreshes matching records. */
|
|
339
|
+
mode?: "append" | "upsert";
|
|
340
|
+
/** Global upsert key for every record in this seed call. */
|
|
341
|
+
upsertKey?: string | string[];
|
|
342
|
+
};
|
|
343
|
+
type SeedTermsItem = {
|
|
344
|
+
title: string;
|
|
345
|
+
type?: "termsOfService" | "privacyPolicy" | "marketingConsent" | "custom";
|
|
346
|
+
jurisdiction?: TermsJurisdiction;
|
|
347
|
+
isRequired?: boolean;
|
|
348
|
+
/** Defaults to inserting order, ascending. */
|
|
349
|
+
sortOrder?: number;
|
|
350
|
+
/** BCP 47 locale of the current published version. */
|
|
351
|
+
locale?: string;
|
|
352
|
+
/** Markdown / plain-text body of the current published version. */
|
|
353
|
+
content: string;
|
|
354
|
+
changeSummary?: string;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Idempotent PostGroup seed. `(brandappId, slug)` is the upsert key.
|
|
358
|
+
* The server generates `id` on first insert; subsequent calls with the same
|
|
359
|
+
* slug update name/description/color in place.
|
|
360
|
+
*/
|
|
361
|
+
type SeedPostGroupInput = {
|
|
362
|
+
/** 브랜드 내 안정적 식별자. SDK consumer가 이 값으로 그룹을 참조한다. */
|
|
363
|
+
slug: string;
|
|
364
|
+
name: string;
|
|
365
|
+
description?: string;
|
|
366
|
+
color?: string;
|
|
367
|
+
};
|
|
368
|
+
type SeedPostInput = {
|
|
369
|
+
/** 소속 PostGroup의 slug. seedPostGroups로 먼저 만들어두거나 함께 시드 가능. */
|
|
370
|
+
groupSlug: string;
|
|
371
|
+
/** 그룹 내 안정적 식별자 (URL slug). 같은 groupSlug+slug 조합으로 upsert. */
|
|
372
|
+
slug: string;
|
|
373
|
+
title: string;
|
|
374
|
+
/** Plain-text content (검색용). */
|
|
375
|
+
content?: string;
|
|
376
|
+
/** EditorSpec — opt-editor 호환. MDX seed는 dev seeder에서 변환 후 여기에 넣음. */
|
|
377
|
+
contentRich?: EditorSpec | null;
|
|
378
|
+
status?: "draft" | "scheduled" | "published" | "archived";
|
|
379
|
+
publishedAt?: string | Date | null;
|
|
380
|
+
coverImage?: {
|
|
381
|
+
id?: string;
|
|
382
|
+
url: string | null;
|
|
383
|
+
} | null;
|
|
384
|
+
author?: Partial<{
|
|
385
|
+
id: string;
|
|
386
|
+
name: string;
|
|
387
|
+
image: string | null;
|
|
388
|
+
}>;
|
|
389
|
+
icon?: string | null;
|
|
390
|
+
/** Tags 입력 — 문자열은 dev seeder가 `{id: 'tag:<text>', text}` 형태로 정규화. */
|
|
391
|
+
tags?: Array<string | {
|
|
392
|
+
id: string;
|
|
393
|
+
text: string;
|
|
394
|
+
}>;
|
|
395
|
+
seo?: {
|
|
396
|
+
metaTitle?: string | null;
|
|
397
|
+
metaDescription?: string | null;
|
|
398
|
+
metaKeywords?: string | null;
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* Unified seed input for `dev.seedAll()`. Each field is optional and applied
|
|
403
|
+
* in order: postGroups → posts → entities → terms.
|
|
404
|
+
*/
|
|
405
|
+
type SeedAllInput = {
|
|
406
|
+
postGroups?: SeedPostGroupInput[];
|
|
407
|
+
posts?: SeedPostInput[];
|
|
408
|
+
/** EAV records keyed by entity name — backward-compatible with `dev.seed()`. */
|
|
409
|
+
entities?: SeedData;
|
|
410
|
+
terms?: SeedTermsItem[];
|
|
411
|
+
};
|
|
412
|
+
type DevServer = {
|
|
413
|
+
/** Base URL of the running server */
|
|
414
|
+
url: string;
|
|
415
|
+
/** Port the server is listening on */
|
|
416
|
+
port: number;
|
|
417
|
+
/** The underlying in-memory store */
|
|
418
|
+
store: InMemoryStore;
|
|
419
|
+
/** Seed records into entities by name */
|
|
420
|
+
seed: (data: SeedData, options?: SeedOptions) => Promise<void>;
|
|
421
|
+
/** Seed BrandApp terms with their initial published version */
|
|
422
|
+
seedTerms: (items: SeedTermsItem[]) => Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* Seed PostGroups identified by slug. Idempotent — running twice with the
|
|
425
|
+
* same slug updates name/description/color in place.
|
|
426
|
+
*/
|
|
427
|
+
seedPostGroups: (items: SeedPostGroupInput[]) => Promise<void>;
|
|
428
|
+
/**
|
|
429
|
+
* Seed Posts identified by `(groupSlug, slug)`. Idempotent. The PostGroup
|
|
430
|
+
* referenced by `groupSlug` must exist (call `seedPostGroups` first or use
|
|
431
|
+
* `seedAll`).
|
|
432
|
+
*/
|
|
433
|
+
seedPosts: (items: SeedPostInput[]) => Promise<void>;
|
|
434
|
+
/** One-shot seeder that applies postGroups → posts → entities → terms in order. */
|
|
435
|
+
seedAll: (input: SeedAllInput) => Promise<void>;
|
|
436
|
+
/** Reset all data (optionally re-seed schema) */
|
|
437
|
+
reset: () => Promise<void>;
|
|
438
|
+
/** Save current state to a JSON file */
|
|
439
|
+
snapshot: (path: string) => Promise<void>;
|
|
440
|
+
/** Restore state from a JSON file */
|
|
441
|
+
restore: (path: string) => Promise<void>;
|
|
442
|
+
/**
|
|
443
|
+
* Mint a spec-compliant `logout_token` signed by the dev IdP, so you can
|
|
444
|
+
* exercise a `createBackchannelLogoutHandler` end-to-end against this server
|
|
445
|
+
* (which serves the matching JWKS at `/api/auth/jwks`). Point the SDK's logout
|
|
446
|
+
* verifier at `dev.url` as `idBaseUrl`. Rejects if the runtime lacks Ed25519
|
|
447
|
+
* Web Crypto (Node 20+).
|
|
448
|
+
*/
|
|
449
|
+
mintLogoutToken: (input: MintLogoutTokenInput) => Promise<string>;
|
|
450
|
+
/** Stop the dev server */
|
|
451
|
+
close: () => Promise<void>;
|
|
452
|
+
};
|
|
453
|
+
declare function createDevServer(options?: DevServerOptions): Promise<DevServer>;
|
|
454
|
+
//#endregion
|
|
455
|
+
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 };
|
|
456
|
+
//# sourceMappingURL=index-DrVaKfhs.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-p49ol9pg.js";
|
|
8
|
+
import { t as ReoptPlansClient } from "./client-D3RHHUUW.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-Z6OGcurJ.d.ts.map
|