@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
package/dist/eav/index.js
CHANGED
|
@@ -1,148 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import '../chunk-YTKSAWV2.js';
|
|
4
|
-
import '../chunk-2LSCQHAU.js';
|
|
5
|
-
export { AuthUserNotFoundError, AuthUserRecordExistsError, DuplicateAuthUserError, LimitExceededError } from '../chunk-C5VTRZWX.js';
|
|
1
|
+
import { c as AuthUserNotFoundError, g as LimitExceededError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError } from "../config-Cw0a3-C8.js";
|
|
2
|
+
import { t as createReoptEavClient } from "../client-DsdakibF.js";
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
//#region src/eav/verify.ts
|
|
8
5
|
async function verifyEavSchema(input) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
};
|
|
6
|
+
const remote = await input.client.schemaHash();
|
|
7
|
+
const ok = remote.hash === input.localHash && input.localHash.length > 0;
|
|
8
|
+
return {
|
|
9
|
+
ok,
|
|
10
|
+
localHash: input.localHash,
|
|
11
|
+
remoteHash: remote.hash,
|
|
12
|
+
schemaCount: remote.schemaCount,
|
|
13
|
+
fieldCount: remote.fieldCount,
|
|
14
|
+
generatedAt: remote.generatedAt,
|
|
15
|
+
...ok ? {} : { drift: !input.localHash ? `EAV health check could not run: localHash is empty. Set NEXT_PUBLIC_BRANDAPP_EAV_HASH (or your build's equivalent) so this route has something to compare.` : `EAV schema drift detected: local ${input.localHash.slice(0, 12)}... ≠ server ${remote.hash.slice(0, 12)}... Re-deploy after running pending migrations.` }
|
|
16
|
+
};
|
|
22
17
|
}
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/eav/hash.ts
|
|
21
|
+
/**
|
|
22
|
+
* Sort entities by name and fields by `(sortOrder, name)`, then return the
|
|
23
|
+
* canonical JSON string. This is the *only* place ordering and field selection
|
|
24
|
+
* are decided — keep the rules in this file when extending.
|
|
25
|
+
*/
|
|
25
26
|
function canonicalizeEavSchemas(schemas) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
const sortedSchemas = schemas.slice().sort((a, b) => a.name.localeCompare(b.name)).map((s) => ({
|
|
28
|
+
name: s.name,
|
|
29
|
+
description: s.description ?? null,
|
|
30
|
+
icon: s.icon ?? null,
|
|
31
|
+
linkedTo: s.linkedTo,
|
|
32
|
+
fields: s.fields.slice().sort((a, b) => {
|
|
33
|
+
if (a.sortOrder !== b.sortOrder) return a.sortOrder - b.sortOrder;
|
|
34
|
+
return a.name.localeCompare(b.name);
|
|
35
|
+
}).map((f) => ({
|
|
36
|
+
name: f.name,
|
|
37
|
+
label: f.label,
|
|
38
|
+
dataType: f.dataType,
|
|
39
|
+
isRequired: f.isRequired,
|
|
40
|
+
isUnique: f.isUnique,
|
|
41
|
+
defaultValue: f.defaultValue ?? null,
|
|
42
|
+
validation: f.validation ?? null,
|
|
43
|
+
options: f.options ?? null,
|
|
44
|
+
sortOrder: f.sortOrder
|
|
45
|
+
}))
|
|
46
|
+
}));
|
|
47
|
+
return JSON.stringify(sortedSchemas);
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* SHA-256 of the canonical string. Uses Web Crypto so the same call works in
|
|
51
|
+
* Node 20+, browsers, and Vercel edge runtime without extra deps.
|
|
52
|
+
*/
|
|
48
53
|
async function hashCanonicalString(canonical) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
return hex;
|
|
54
|
+
const data = new TextEncoder().encode(canonical);
|
|
55
|
+
const buf = await globalThis.crypto.subtle.digest("SHA-256", data);
|
|
56
|
+
const bytes = new Uint8Array(buf);
|
|
57
|
+
let hex = "";
|
|
58
|
+
for (let i = 0; i < bytes.length; i++) hex += bytes[i].toString(16).padStart(2, "0");
|
|
59
|
+
return hex;
|
|
57
60
|
}
|
|
61
|
+
/** Convenience wrapper — canonicalize, then hash. */
|
|
58
62
|
async function computeEavSchemaHash(schemas) {
|
|
59
|
-
|
|
63
|
+
return hashCanonicalString(canonicalizeEavSchemas(schemas));
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/eav/helpers.ts
|
|
68
|
+
/**
|
|
69
|
+
* Collect all items from an async generator into an array.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const allRecords = await collectAll(sdk.eav.records.listAll("entity-id"));
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
63
76
|
async function collectAll(gen) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return items;
|
|
77
|
+
const items = [];
|
|
78
|
+
for await (const item of gen) items.push(item);
|
|
79
|
+
return items;
|
|
69
80
|
}
|
|
70
81
|
|
|
71
|
-
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/eav/filter-builder.ts
|
|
72
84
|
var FilterExpression = class {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
);
|
|
129
|
-
}
|
|
85
|
+
attributeId;
|
|
86
|
+
constructor(attributeId) {
|
|
87
|
+
this.attributeId = attributeId;
|
|
88
|
+
}
|
|
89
|
+
make(operator, value) {
|
|
90
|
+
return {
|
|
91
|
+
attributeId: this.attributeId,
|
|
92
|
+
operator,
|
|
93
|
+
value
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** 값이 같은 레코드 */
|
|
97
|
+
eq(value) {
|
|
98
|
+
return this.make("eq", value);
|
|
99
|
+
}
|
|
100
|
+
/** 값이 다른 레코드 */
|
|
101
|
+
neq(value) {
|
|
102
|
+
return this.make("neq", value);
|
|
103
|
+
}
|
|
104
|
+
/** 값에 문자열을 포함하는 레코드 */
|
|
105
|
+
contains(value) {
|
|
106
|
+
return this.make("contains", value);
|
|
107
|
+
}
|
|
108
|
+
/** 값이 큰 레코드 (숫자) */
|
|
109
|
+
gt(value) {
|
|
110
|
+
return this.make("gt", value);
|
|
111
|
+
}
|
|
112
|
+
/** 값이 작은 레코드 (숫자) */
|
|
113
|
+
lt(value) {
|
|
114
|
+
return this.make("lt", value);
|
|
115
|
+
}
|
|
116
|
+
/** 값이 크거나 같은 레코드 (숫자) */
|
|
117
|
+
gte(value) {
|
|
118
|
+
return this.make("gte", value);
|
|
119
|
+
}
|
|
120
|
+
/** 값이 작거나 같은 레코드 (숫자) */
|
|
121
|
+
lte(value) {
|
|
122
|
+
return this.make("lte", value);
|
|
123
|
+
}
|
|
124
|
+
/** 값이 null인 레코드 */
|
|
125
|
+
isNull() {
|
|
126
|
+
return this.make("is_null");
|
|
127
|
+
}
|
|
128
|
+
/** 값이 null이 아닌 레코드 */
|
|
129
|
+
isNotNull() {
|
|
130
|
+
return this.make("is_not_null");
|
|
131
|
+
}
|
|
132
|
+
/** 날짜 이후 레코드 */
|
|
133
|
+
after(value) {
|
|
134
|
+
return this.make("after", value instanceof Date ? value.toISOString() : value);
|
|
135
|
+
}
|
|
136
|
+
/** 날짜 이전 레코드 */
|
|
137
|
+
before(value) {
|
|
138
|
+
return this.make("before", value instanceof Date ? value.toISOString() : value);
|
|
139
|
+
}
|
|
130
140
|
};
|
|
141
|
+
/**
|
|
142
|
+
* 필터 표현식 생성 — attribute name을 ID로 직접 사용
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* where("status").eq("active")
|
|
147
|
+
* where("age").gte(18)
|
|
148
|
+
* where("deletedAt").isNull()
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
131
151
|
function where(attributeNameOrId) {
|
|
132
|
-
|
|
152
|
+
return new FilterExpression(attributeNameOrId);
|
|
133
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* 스키마에서 생성된 ATTRIBUTE_IDS 맵 기반의 타입 안전 필터 빌더
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* // lib/generated/eav.ts에서 생성된 상수
|
|
160
|
+
* const ATTRIBUTE_IDS = {
|
|
161
|
+
* contacts: { name: "attr-uuid-1", email: "attr-uuid-2", status: "attr-uuid-3" }
|
|
162
|
+
* };
|
|
163
|
+
*
|
|
164
|
+
* const w = createFilterBuilder(ATTRIBUTE_IDS.contacts);
|
|
165
|
+
* w("status").eq("active") // attributeId: "attr-uuid-3"
|
|
166
|
+
* w("email").contains("@") // attributeId: "attr-uuid-2"
|
|
167
|
+
* w("unknown") // TypeScript 에러!
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
134
170
|
function createFilterBuilder(attributeIdMap) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
return new FilterExpression(id);
|
|
143
|
-
};
|
|
171
|
+
return (name) => {
|
|
172
|
+
const id = attributeIdMap[name];
|
|
173
|
+
if (!id) throw new Error(`Unknown attribute: "${name}". Available: ${Object.keys(attributeIdMap).join(", ")}`);
|
|
174
|
+
return new FilterExpression(id);
|
|
175
|
+
};
|
|
144
176
|
}
|
|
145
177
|
|
|
146
|
-
|
|
147
|
-
|
|
178
|
+
//#endregion
|
|
179
|
+
export { AuthUserNotFoundError, AuthUserRecordExistsError, DuplicateAuthUserError, FilterExpression, LimitExceededError, canonicalizeEavSchemas, collectAll, computeEavSchemaHash, createFilterBuilder, createReoptEavClient, hashCanonicalString, verifyEavSchema, where };
|
|
148
180
|
//# sourceMappingURL=index.js.map
|
package/dist/eav/migrate.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { o as AttributeDef, s as EntityDef } from "../config-CRytOPPl.js";
|
|
2
|
+
import { t as ReoptEavClient } from "../client-BGGd_cpV.js";
|
|
3
|
+
//#region src/eav/migrate/types.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Subset of `ReoptEavClient.records` exposed inside a migration's `up`/`down`.
|
|
7
6
|
*
|
|
@@ -18,78 +17,78 @@ type MigrationRecordsClient = Pick<ReoptEavClient["records"], "list" | "listAll"
|
|
|
18
17
|
* UUIDs.
|
|
19
18
|
*/
|
|
20
19
|
type MigrationSchemaClient = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
/** Add a new entity. Fails if an entity with the same name already exists. */
|
|
21
|
+
addEntity(name: string, def: Omit<EntityDef, "name" | "attributes">): Promise<void>;
|
|
22
|
+
/** Delete an entity (and all its attributes/records). */
|
|
23
|
+
removeEntity(name: string): Promise<void>;
|
|
24
|
+
/** Add a new attribute to an entity. */
|
|
25
|
+
addAttribute(entity: string, name: string, def: AttributeDef): Promise<void>;
|
|
26
|
+
/** Delete an attribute and all its values. */
|
|
27
|
+
removeAttribute(entity: string, name: string): Promise<void>;
|
|
28
|
+
/** Rename an attribute, preserving values. */
|
|
29
|
+
renameAttribute(entity: string, oldName: string, newName: string): Promise<void>;
|
|
31
30
|
};
|
|
32
31
|
/**
|
|
33
32
|
* Context object passed to a migration's `up`/`down` function.
|
|
34
33
|
*/
|
|
35
34
|
type MigrationContext = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
schema: MigrationSchemaClient;
|
|
36
|
+
records: MigrationRecordsClient;
|
|
37
|
+
/** Structured log channel — runner pipes this to CLI output. */
|
|
38
|
+
log: (msg: string) => void;
|
|
40
39
|
};
|
|
41
40
|
type MigrationDirection = "up" | "down";
|
|
42
41
|
type MigrationFn = (ctx: MigrationContext) => Promise<void>;
|
|
43
42
|
type MigrationSpec = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Stable migration name. Convention: matches the file name without
|
|
45
|
+
* extension and timestamp suffix (`20260427120000_rename_tier_to_level`).
|
|
46
|
+
*/
|
|
47
|
+
name: string;
|
|
48
|
+
/** Forward migration. Required. */
|
|
49
|
+
up: MigrationFn;
|
|
50
|
+
/**
|
|
51
|
+
* Optional reverse migration. Forward-only is the recommended default —
|
|
52
|
+
* only declare `down` for trivially invertible changes.
|
|
53
|
+
*/
|
|
54
|
+
down?: MigrationFn;
|
|
56
55
|
};
|
|
57
56
|
type Migration = MigrationSpec & {
|
|
58
|
-
|
|
57
|
+
readonly __brand: "ReoptEavMigration";
|
|
59
58
|
};
|
|
60
59
|
type AppliedMigrationRecord = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
id: string;
|
|
61
|
+
brandappId: string;
|
|
62
|
+
name: string;
|
|
63
|
+
checksum: string;
|
|
64
|
+
appliedAt: string;
|
|
65
|
+
appliedBy: string | null;
|
|
66
|
+
durationMs: number | null;
|
|
68
67
|
};
|
|
69
68
|
type MigrationStatus = {
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
state: "pending";
|
|
70
|
+
name: string;
|
|
72
71
|
} | {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
state: "applied";
|
|
73
|
+
name: string;
|
|
74
|
+
checksum: string;
|
|
75
|
+
appliedAt: string;
|
|
77
76
|
} | {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
state: "drift";
|
|
78
|
+
name: string;
|
|
79
|
+
localChecksum: string;
|
|
80
|
+
serverChecksum: string;
|
|
81
|
+
appliedAt: string;
|
|
83
82
|
};
|
|
84
83
|
type MigrationRunResult = {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
/** Migration name that was just applied. */
|
|
85
|
+
name: string;
|
|
86
|
+
/** SHA-256 checksum of the file content. */
|
|
87
|
+
checksum: string;
|
|
88
|
+
/** Wall-clock duration of the `up` function in milliseconds. */
|
|
89
|
+
durationMs: number;
|
|
90
|
+
/** True when the runner skipped because the migration was already applied. */
|
|
91
|
+
alreadyApplied: boolean;
|
|
93
92
|
};
|
|
94
93
|
/**
|
|
95
94
|
* One schema-level operation captured during a batched migration run.
|
|
@@ -103,32 +102,33 @@ type MigrationRunResult = {
|
|
|
103
102
|
* outside the transaction.
|
|
104
103
|
*/
|
|
105
104
|
type MigrationOperation = {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
105
|
+
kind: "addEntity";
|
|
106
|
+
name: string;
|
|
107
|
+
def?: {
|
|
108
|
+
description?: string | null;
|
|
109
|
+
icon?: string | null;
|
|
110
|
+
linkedTo?: "brandapp" | "brandappAuthUser";
|
|
111
|
+
};
|
|
113
112
|
} | {
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
kind: "removeEntity";
|
|
114
|
+
name: string;
|
|
116
115
|
} | {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
kind: "addAttribute";
|
|
117
|
+
entity: string;
|
|
118
|
+
name: string;
|
|
119
|
+
def: AttributeDef;
|
|
121
120
|
} | {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
kind: "removeAttribute";
|
|
122
|
+
entity: string;
|
|
123
|
+
name: string;
|
|
125
124
|
} | {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
kind: "renameAttribute";
|
|
126
|
+
entity: string;
|
|
127
|
+
oldName: string;
|
|
128
|
+
newName: string;
|
|
130
129
|
};
|
|
131
|
-
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/eav/migrate/define.d.ts
|
|
132
132
|
/**
|
|
133
133
|
* Branded factory for a forward (and optional reverse) EAV schema migration.
|
|
134
134
|
*
|
|
@@ -154,10 +154,11 @@ type MigrationOperation = {
|
|
|
154
154
|
declare function defineMigration(spec: MigrationSpec): Migration;
|
|
155
155
|
/** Type guard — returns true when `value` was produced by `defineMigration`. */
|
|
156
156
|
declare function isMigration(value: unknown): value is Migration;
|
|
157
|
-
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/eav/migrate/context.d.ts
|
|
158
159
|
type CreateMigrationContextOptions = {
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
/** Override the log channel. Defaults to no-op (runner pipes through). */
|
|
161
|
+
log?: (msg: string) => void;
|
|
161
162
|
};
|
|
162
163
|
/**
|
|
163
164
|
* Build the `MigrationContext` consumed by `migration.up`/`down`.
|
|
@@ -168,26 +169,27 @@ type CreateMigrationContextOptions = {
|
|
|
168
169
|
* - `log` is whatever the caller passes (CLI prints, dev server captures).
|
|
169
170
|
*/
|
|
170
171
|
declare function createMigrationContext(eav: ReoptEavClient, opts?: CreateMigrationContextOptions): MigrationContext;
|
|
171
|
-
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/eav/migrate/runner.d.ts
|
|
172
174
|
type RunMigrationOptions = {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
175
|
+
/** Direction — defaults to `up`. `down` requires `migration.down` to exist. */
|
|
176
|
+
direction?: MigrationDirection;
|
|
177
|
+
/** Pre-computed SHA-256 of the migration file. Surfaced in the result. */
|
|
178
|
+
checksum: string;
|
|
179
|
+
/**
|
|
180
|
+
* Hook called whenever the migration emits `ctx.log(...)`. Defaults to
|
|
181
|
+
* a no-op so the SDK stays quiet by default; the CLI plugs in a printer.
|
|
182
|
+
*/
|
|
183
|
+
onLog?: (msg: string) => void;
|
|
184
|
+
/**
|
|
185
|
+
* Acquire/release a server-side advisory lock around the run. Phase 3 first
|
|
186
|
+
* PR ships **no** real lock — the runner just calls these hooks if provided.
|
|
187
|
+
* The next PR wires them into the server.
|
|
188
|
+
*/
|
|
189
|
+
lock?: {
|
|
190
|
+
acquire: () => Promise<void>;
|
|
191
|
+
release: () => Promise<void>;
|
|
192
|
+
};
|
|
191
193
|
};
|
|
192
194
|
/**
|
|
193
195
|
* Execute a single migration's `up` (or `down`) function.
|
|
@@ -201,16 +203,16 @@ type RunMigrationOptions = {
|
|
|
201
203
|
*/
|
|
202
204
|
declare function runMigration(eav: ReoptEavClient, migration: Migration, opts: RunMigrationOptions): Promise<MigrationRunResult>;
|
|
203
205
|
type CollectMigrationOptions = {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
/** Defaults to `up`. */
|
|
207
|
+
direction?: MigrationDirection;
|
|
208
|
+
/** Forwarded to `ctx.log`. */
|
|
209
|
+
onLog?: (msg: string) => void;
|
|
208
210
|
};
|
|
209
211
|
type CollectMigrationResult = {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
/** Schema operations captured from `ctx.schema.*` calls, in invocation order. */
|
|
213
|
+
operations: MigrationOperation[];
|
|
214
|
+
/** Wall-clock duration of the `up` function (ms). */
|
|
215
|
+
durationMs: number;
|
|
214
216
|
};
|
|
215
217
|
/**
|
|
216
218
|
* Run a migration's `up`/`down` function with a buffering schema client so
|
|
@@ -232,5 +234,6 @@ type CollectMigrationResult = {
|
|
|
232
234
|
* retained for callers that have not yet adopted the batch endpoint.
|
|
233
235
|
*/
|
|
234
236
|
declare function runMigrationCollecting(eav: ReoptEavClient, migration: Migration, opts?: CollectMigrationOptions): Promise<CollectMigrationResult>;
|
|
235
|
-
|
|
237
|
+
//#endregion
|
|
236
238
|
export { type AppliedMigrationRecord, type CollectMigrationOptions, type CollectMigrationResult, type CreateMigrationContextOptions, type Migration, type MigrationContext, type MigrationDirection, type MigrationFn, type MigrationOperation, type MigrationRecordsClient, type MigrationRunResult, type MigrationSchemaClient, type MigrationSpec, type MigrationStatus, type RunMigrationOptions, createMigrationContext, defineMigration, isMigration, runMigration, runMigrationCollecting };
|
|
239
|
+
//# sourceMappingURL=migrate.d.ts.map
|