@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.
Files changed (76) hide show
  1. package/CHANGELOG.md +574 -0
  2. package/LICENSE +21 -0
  3. package/README.md +468 -0
  4. package/dist/ai/index.d.ts +314 -0
  5. package/dist/ai/index.js +7 -0
  6. package/dist/ai-provider/index.d.ts +196 -0
  7. package/dist/ai-provider/index.js +703 -0
  8. package/dist/auth/index.d.ts +76 -0
  9. package/dist/auth/index.js +40 -0
  10. package/dist/better-auth/client.d.ts +29 -0
  11. package/dist/better-auth/client.js +10 -0
  12. package/dist/better-auth/index.d.ts +82 -0
  13. package/dist/better-auth/index.js +145 -0
  14. package/dist/chunk-6FLYVNZI.js +32 -0
  15. package/dist/chunk-6KPKZ7ZB.js +49 -0
  16. package/dist/chunk-DI6QJPTQ.js +449 -0
  17. package/dist/chunk-E457LO5A.js +599 -0
  18. package/dist/chunk-F7BXBTZI.js +54 -0
  19. package/dist/chunk-J5Y2GSJF.js +443 -0
  20. package/dist/chunk-K3YVJE6E.js +96 -0
  21. package/dist/chunk-KU2LN5SE.js +350 -0
  22. package/dist/chunk-L4DHB36G.js +75 -0
  23. package/dist/chunk-PJZB4VP7.js +63 -0
  24. package/dist/chunk-REIKXSMY.js +7 -0
  25. package/dist/chunk-T2WXHAAC.js +54 -0
  26. package/dist/chunk-TUKIYH4Q.js +112 -0
  27. package/dist/chunk-WSEROZVO.js +81 -0
  28. package/dist/chunk-YRGLBM6V.js +157 -0
  29. package/dist/client-BkcO-0C2.d.ts +216 -0
  30. package/dist/client-CN5_tNOC.d.ts +147 -0
  31. package/dist/client-DttyeM_h.d.ts +102 -0
  32. package/dist/cms/index.d.ts +137 -0
  33. package/dist/cms/index.js +101 -0
  34. package/dist/config-CtxyJsDR.d.ts +397 -0
  35. package/dist/dev/index.d.ts +509 -0
  36. package/dist/dev/index.js +3071 -0
  37. package/dist/eav/coerce.d.ts +42 -0
  38. package/dist/eav/coerce.js +65 -0
  39. package/dist/eav/index.d.ts +214 -0
  40. package/dist/eav/index.js +147 -0
  41. package/dist/eav/migrate.d.ts +236 -0
  42. package/dist/eav/migrate.js +219 -0
  43. package/dist/eav/schema.d.ts +260 -0
  44. package/dist/eav/schema.js +656 -0
  45. package/dist/errors-5hd5ZR-M.d.ts +158 -0
  46. package/dist/feedback/index.d.ts +132 -0
  47. package/dist/feedback/index.js +5 -0
  48. package/dist/files/index.d.ts +54 -0
  49. package/dist/files/index.js +31 -0
  50. package/dist/index.d.ts +221 -0
  51. package/dist/index.js +84 -0
  52. package/dist/plans/index.d.ts +140 -0
  53. package/dist/plans/index.js +5 -0
  54. package/dist/push/index.d.ts +79 -0
  55. package/dist/push/index.js +5 -0
  56. package/dist/react/hooks.d.ts +376 -0
  57. package/dist/react/hooks.js +421 -0
  58. package/dist/terms/index.d.ts +79 -0
  59. package/dist/terms/index.js +5 -0
  60. package/dist/testing/index.d.ts +154 -0
  61. package/dist/testing/index.js +81 -0
  62. package/dist/typed-client-BxOVIiMU.d.ts +40 -0
  63. package/dist/types-6E3ZLL9X.d.ts +24 -0
  64. package/dist/types-DskYLVb8.d.ts +104 -0
  65. package/dist/types-ckmDDW3N.d.ts +129 -0
  66. package/dist/webhooks/index.d.ts +140 -0
  67. package/dist/webhooks/index.js +142 -0
  68. package/docs/api-reference.md +557 -0
  69. package/docs/cms.md +318 -0
  70. package/docs/dev-server.md +164 -0
  71. package/docs/environment.md +211 -0
  72. package/docs/errors.md +290 -0
  73. package/docs/files.md +272 -0
  74. package/docs/migration.md +315 -0
  75. package/docs/testing.md +163 -0
  76. package/package.json +173 -0
@@ -0,0 +1,260 @@
1
+ import { A as AttributeDef, p as EntityDef, S as SchemaDef, l as EavEntity, E as EavAttribute, k as EavDataType } from '../config-CtxyJsDR.js';
2
+ export { I as InferValues } from '../config-CtxyJsDR.js';
3
+ import { R as ReoptEavClient } from '../client-BkcO-0C2.js';
4
+ import '../typed-client-BxOVIiMU.js';
5
+
6
+ declare function defineEntity<const A extends Record<string, AttributeDef>>(def: EntityDef<A>): EntityDef<A>;
7
+ declare function defineSchema<const E extends Record<string, EntityDef>>(def: SchemaDef<E>): SchemaDef<E>;
8
+
9
+ type AttributeAction = {
10
+ type: "create";
11
+ name: string;
12
+ def: AttributeDef;
13
+ } | {
14
+ type: "update";
15
+ name: string;
16
+ attributeId: string;
17
+ changes: Record<string, unknown>;
18
+ oldValues: Record<string, unknown>;
19
+ } | {
20
+ type: "delete";
21
+ name: string;
22
+ attributeId: string;
23
+ } | {
24
+ type: "unchanged";
25
+ name: string;
26
+ attributeId: string;
27
+ };
28
+ type EntityAction = {
29
+ type: "create";
30
+ key: string;
31
+ def: EntityDef;
32
+ attributes: AttributeAction[];
33
+ } | {
34
+ type: "update";
35
+ key: string;
36
+ entityId: string;
37
+ changes: Record<string, unknown>;
38
+ attributes: AttributeAction[];
39
+ } | {
40
+ type: "unchanged";
41
+ key: string;
42
+ entityId: string;
43
+ attributes: AttributeAction[];
44
+ } | {
45
+ type: "delete";
46
+ key: string;
47
+ entityId: string;
48
+ };
49
+ type DiffResult = {
50
+ entities: EntityAction[];
51
+ hasChanges: boolean;
52
+ };
53
+ /** Lockfile entity/attribute ID mappings for stable matching across renames */
54
+ type LockfileData = {
55
+ entities: Record<string, {
56
+ id: string;
57
+ attributes: Record<string, string>;
58
+ }>;
59
+ };
60
+ type ServerEntity = EavEntity & {
61
+ attributes: EavAttribute[];
62
+ };
63
+ /**
64
+ * Compute diff between a local schema definition and server entities.
65
+ *
66
+ * @param schema - Local schema definition
67
+ * @param serverEntities - Server entities with attributes (from entities.list + get)
68
+ * @param options.deleteOrphans - Delete server entities/attributes not in schema
69
+ * @param options.lockfile - Lockfile data for stable ID-based matching
70
+ */
71
+ declare function computeDiff(schema: SchemaDef, serverEntities: ServerEntity[], options?: {
72
+ deleteOrphans?: boolean;
73
+ lockfile?: LockfileData | null;
74
+ }): DiffResult;
75
+
76
+ /**
77
+ * SchemaDef → JSON Schema 변환
78
+ *
79
+ * EAV 스키마 정의를 표준 JSON Schema (draft-07)로 변환합니다.
80
+ * AI structured output, 폼 빌더, 밸리데이터 등에서 활용 가능.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * import { defineSchema, defineEntity } from "@reopt-ai/brandapp-sdk/eav/schema";
85
+ * import { schemaToJsonSchema, entityToJsonSchema } from "@reopt-ai/brandapp-sdk/eav/schema";
86
+ *
87
+ * const schema = defineSchema({ entities: { contacts } });
88
+ * const jsonSchema = schemaToJsonSchema(schema);
89
+ * // → { type: "object", properties: { contacts: { ... } } }
90
+ *
91
+ * const contactsSchema = entityToJsonSchema(contacts);
92
+ * // → { type: "object", properties: { name: { type: "string" }, ... }, required: ["name"] }
93
+ * ```
94
+ */
95
+
96
+ type JSONSchema7 = {
97
+ $schema?: string;
98
+ title?: string;
99
+ description?: string;
100
+ type?: string;
101
+ properties?: Record<string, JSONSchema7>;
102
+ required?: string[];
103
+ items?: JSONSchema7;
104
+ enum?: unknown[];
105
+ format?: string;
106
+ minimum?: number;
107
+ maximum?: number;
108
+ minLength?: number;
109
+ maxLength?: number;
110
+ pattern?: string;
111
+ default?: unknown;
112
+ [key: string]: unknown;
113
+ };
114
+ /**
115
+ * 단일 엔티티를 JSON Schema로 변환
116
+ */
117
+ declare function entityToJsonSchema(entity: EntityDef): JSONSchema7;
118
+ /**
119
+ * 전체 스키마를 JSON Schema로 변환
120
+ *
121
+ * 각 엔티티가 properties의 키로 들어갑니다.
122
+ */
123
+ declare function schemaToJsonSchema(schema: SchemaDef): JSONSchema7;
124
+
125
+ /**
126
+ * dataType compatibility matrix.
127
+ *
128
+ * Used by the safety classifier to decide whether a dataType change is
129
+ * destructive (data loss likely) or merely a warning (storage column stays
130
+ * the same, only validation rules change).
131
+ *
132
+ * The matrix is intentionally conservative — only conversions that share
133
+ * the same underlying server storage column AND whose semantics relax
134
+ * (not tighten) are listed here. Anything tightening validation
135
+ * (string → email, string → number, etc.) stays destructive because
136
+ * existing rows can fail the new check.
137
+ *
138
+ * Storage notes (server side):
139
+ * - string / textarea / email / url / select → textValue
140
+ * - multiselect → textValue (JSON array)
141
+ * - number → numericValue
142
+ * - boolean → booleanValue
143
+ * - date → dateValue
144
+ */
145
+
146
+ /**
147
+ * Returns `true` when the dataType change preserves the existing values
148
+ * without server-side conversion or validation rejection.
149
+ *
150
+ * Identity (`from === to`) is treated as compatible.
151
+ */
152
+ declare function isCompatibleDataTypeChange(from: EavDataType, to: EavDataType): boolean;
153
+
154
+ type CompatibilitySeverity = "warning" | "destructive";
155
+ type CompatibilityIssue = {
156
+ severity: CompatibilitySeverity;
157
+ /** Entity key from the schema (or server name when deleting). */
158
+ entityKey: string;
159
+ /** Attribute name when the issue is attribute-scoped. */
160
+ attributeName?: string;
161
+ /** Short machine-readable code (e.g. "ENTITY_DELETE", "INCOMPATIBLE_DATATYPE"). */
162
+ code: string;
163
+ /** Human-readable explanation. */
164
+ message: string;
165
+ /** Suggested mitigation. */
166
+ fix: string;
167
+ };
168
+ /**
169
+ * Inspect a {@link DiffResult} and return every change that risks data loss
170
+ * or row rejection. Pair with {@link syncSchema}'s `allowDestructive` option
171
+ * to gate destructive deploys behind explicit opt-in.
172
+ *
173
+ * Categorisation:
174
+ * - `destructive` — entity deletion, attribute deletion, incompatible
175
+ * dataType migration, optional → required, non-unique → unique.
176
+ * - `warning` — compatible dataType migration, options removed (existing
177
+ * rows may have stored a now-unknown enum value).
178
+ */
179
+ declare function assessCompatibility(diff: DiffResult): CompatibilityIssue[];
180
+
181
+ type SyncedEntity = {
182
+ key: string;
183
+ entityId: string;
184
+ attributes: SyncedAttribute[];
185
+ };
186
+ type SyncedAttribute = {
187
+ name: string;
188
+ attributeId: string;
189
+ };
190
+ type SyncResult = {
191
+ entities: SyncedEntity[];
192
+ errors: SyncError[];
193
+ /**
194
+ * Compatibility issues detected before applying the diff. Always populated
195
+ * — both `warning` (informational) and `destructive` (blocked unless
196
+ * `allowDestructive: true`) entries appear here.
197
+ */
198
+ warnings: CompatibilityIssue[];
199
+ };
200
+ /**
201
+ * Thrown by {@link syncSchema} when the diff contains destructive changes
202
+ * and `allowDestructive` was not opted into. Inspect `error.issues` for the
203
+ * full list of risks; pass `allowDestructive: true` to override.
204
+ */
205
+ declare class SchemaCompatibilityError extends Error {
206
+ readonly issues: CompatibilityIssue[];
207
+ constructor(issues: CompatibilityIssue[]);
208
+ }
209
+ type SyncError = {
210
+ key: string;
211
+ message: string;
212
+ };
213
+ type SyncProgressEvent = {
214
+ type: "created" | "updated" | "deleted" | "unchanged" | "error";
215
+ key: string;
216
+ detail: string;
217
+ };
218
+ type SyncOptions = {
219
+ deleteOrphans?: boolean;
220
+ lockfile?: LockfileData | null;
221
+ onProgress?: (event: SyncProgressEvent) => void;
222
+ /**
223
+ * Allow destructive changes (entity/attribute deletions, incompatible
224
+ * dataType migrations, optional → required, non-unique → unique). When
225
+ * false (default), `syncSchema` throws {@link SchemaCompatibilityError}
226
+ * before touching the server; when true, the changes apply unchecked
227
+ * but the issues still appear in `result.warnings`.
228
+ */
229
+ allowDestructive?: boolean;
230
+ };
231
+ /**
232
+ * Apply a diff result to the server — execute creates, updates, and deletes.
233
+ *
234
+ * @example
235
+ * ```ts
236
+ * import { computeDiff } from "@reopt-ai/brandapp-sdk/eav/schema";
237
+ *
238
+ * const diff = computeDiff(schema, serverEntities);
239
+ * const result = await applySync(eav, diff, (event) => {
240
+ * console.log(`[${event.type}] ${event.detail}`);
241
+ * });
242
+ * ```
243
+ */
244
+ declare function applySync(eav: ReoptEavClient, diff: DiffResult, onProgress?: SyncOptions["onProgress"]): Promise<SyncResult>;
245
+ /**
246
+ * Sync a schema definition to the server.
247
+ *
248
+ * Fetches current server state, computes diff, and applies changes.
249
+ *
250
+ * @example
251
+ * ```ts
252
+ * import { syncSchema } from "@reopt-ai/brandapp-sdk/eav/schema";
253
+ *
254
+ * const result = await syncSchema(eav, schema);
255
+ * console.log(result.entities); // [{ key: "contacts", entityId: "...", attributes: [...] }]
256
+ * ```
257
+ */
258
+ declare function syncSchema(eav: ReoptEavClient, schema: SchemaDef, options?: SyncOptions): Promise<SyncResult>;
259
+
260
+ export { type AttributeAction, AttributeDef, type CompatibilityIssue, type CompatibilitySeverity, type DiffResult, type EntityAction, EntityDef, type LockfileData, SchemaCompatibilityError, SchemaDef, type SyncError, type SyncOptions, type SyncProgressEvent, type SyncResult, type SyncedAttribute, type SyncedEntity, applySync, assessCompatibility, computeDiff, defineEntity, defineSchema, entityToJsonSchema, isCompatibleDataTypeChange, schemaToJsonSchema, syncSchema };