@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.
- package/CHANGELOG.md +115 -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-61ldOHMz.js +503 -0
- package/dist/client-7PCoxVhZ.js +28 -0
- package/dist/client-B7rZQ8Zi.d.ts +272 -0
- package/dist/client-BGGd_cpV.d.ts +103 -0
- package/dist/client-BoIuyx4S.js +273 -0
- package/dist/client-BruP5_nU.d.ts +147 -0
- package/dist/client-BxtZt405.js +305 -0
- package/dist/client-ByN3EQdk.js +83 -0
- package/dist/client-CAghoGD_.js +53 -0
- package/dist/client-C_pHsPlj.js +81 -0
- package/dist/client-D0eBxh8j.d.ts +284 -0
- package/dist/client-D6gs61w8.d.ts +53 -0
- package/dist/client-DDw5yz_h.d.ts +53 -0
- package/dist/client-Dxg8_DIH.d.ts +71 -0
- package/dist/client-aMR4CRB8.d.ts +211 -0
- package/dist/client-lk6wBu_0.d.ts +48 -0
- package/dist/client-wEVKLdly.js +55 -0
- package/dist/client-zF1RG2uA.js +86 -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-aml9oQpX.js +487 -0
- package/dist/dev/index.d.ts +2 -528
- package/dist/dev/index.js +3047 -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-BZc2mngq.js +386 -0
- package/dist/index-1j_738qk.d.ts +470 -0
- package/dist/index-CeOLGdyL.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-xWqtfkvR.js +35 -0
- package/dist/react/hooks.d.ts +157 -100
- package/dist/react/hooks.js +862 -406
- 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 +121 -8
- package/docs/errors.md +19 -0
- package/docs/files.md +165 -7
- package/package.json +7 -6
- 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/migrate.js
CHANGED
|
@@ -1,219 +1,253 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/eav/migrate/define.ts
|
|
2
|
+
/**
|
|
3
|
+
* Branded factory for a forward (and optional reverse) EAV schema migration.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { defineMigration } from "@reopt-ai/brandapp-sdk/eav/migrate";
|
|
8
|
+
*
|
|
9
|
+
* export default defineMigration({
|
|
10
|
+
* name: "rename_tier_to_level",
|
|
11
|
+
* up: async ({ schema, records }) => {
|
|
12
|
+
* await schema.addAttribute("contacts", "level", {
|
|
13
|
+
* dataType: "string",
|
|
14
|
+
* label: "Level",
|
|
15
|
+
* });
|
|
16
|
+
* await records.backfill("contacts", {
|
|
17
|
+
* transform: (r) => ({ level: r.values.tier ?? "free" }),
|
|
18
|
+
* });
|
|
19
|
+
* await schema.removeAttribute("contacts", "tier");
|
|
20
|
+
* },
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
2
24
|
function defineMigration(spec) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
if (spec.down !== void 0 && typeof spec.down !== "function") {
|
|
15
|
-
throw new Error(
|
|
16
|
-
`defineMigration("${spec.name}"): \`down\` must be an async function when provided`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
name: spec.name,
|
|
21
|
-
up: spec.up,
|
|
22
|
-
down: spec.down,
|
|
23
|
-
__brand: "ReoptEavMigration"
|
|
24
|
-
};
|
|
25
|
+
if (!spec || typeof spec !== "object") throw new Error("defineMigration: spec must be an object");
|
|
26
|
+
if (typeof spec.name !== "string" || spec.name.trim().length === 0) throw new Error("defineMigration: `name` must be a non-empty string");
|
|
27
|
+
if (typeof spec.up !== "function") throw new Error(`defineMigration("${spec.name}"): \`up\` must be an async function`);
|
|
28
|
+
if (spec.down !== void 0 && typeof spec.down !== "function") throw new Error(`defineMigration("${spec.name}"): \`down\` must be an async function when provided`);
|
|
29
|
+
return {
|
|
30
|
+
name: spec.name,
|
|
31
|
+
up: spec.up,
|
|
32
|
+
down: spec.down,
|
|
33
|
+
__brand: "ReoptEavMigration"
|
|
34
|
+
};
|
|
25
35
|
}
|
|
36
|
+
/** Type guard — returns true when `value` was produced by `defineMigration`. */
|
|
26
37
|
function isMigration(value) {
|
|
27
|
-
|
|
38
|
+
return typeof value === "object" && value !== null && value.__brand === "ReoptEavMigration";
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/eav/migrate/context.ts
|
|
31
43
|
async function findEntityIdByName(eav, entityName) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
throw new Error(
|
|
36
|
-
`Migration: entity "${entityName}" not found on server. Use schema.addEntity() first or check the entity name.`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
return match.id;
|
|
44
|
+
const match = (await eav.entities.list()).find((e) => e.name === entityName);
|
|
45
|
+
if (!match) throw new Error(`Migration: entity "${entityName}" not found on server. Use schema.addEntity() first or check the entity name.`);
|
|
46
|
+
return match.id;
|
|
40
47
|
}
|
|
41
48
|
async function findAttributeIdByName(eav, entityId, attributeName) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
throw new Error(
|
|
46
|
-
`Migration: attribute "${attributeName}" not found on entity ${entityId}.`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return attr.id;
|
|
49
|
+
const attr = (await eav.entities.get(entityId)).attributes.find((a) => a.name === attributeName);
|
|
50
|
+
if (!attr) throw new Error(`Migration: attribute "${attributeName}" not found on entity ${entityId}.`);
|
|
51
|
+
return attr.id;
|
|
50
52
|
}
|
|
51
53
|
function createSchemaClient(eav, log) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
54
|
+
return {
|
|
55
|
+
async addEntity(name, def) {
|
|
56
|
+
log(`addEntity ${name}`);
|
|
57
|
+
await eav.entities.create({
|
|
58
|
+
name,
|
|
59
|
+
description: def.description,
|
|
60
|
+
icon: def.icon
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
async removeEntity(name) {
|
|
64
|
+
log(`removeEntity ${name}`);
|
|
65
|
+
const id = await findEntityIdByName(eav, name);
|
|
66
|
+
await eav.entities.delete(id);
|
|
67
|
+
},
|
|
68
|
+
async addAttribute(entity, name, def) {
|
|
69
|
+
log(`addAttribute ${entity}.${name} (${def.dataType})`);
|
|
70
|
+
const entityId = await findEntityIdByName(eav, entity);
|
|
71
|
+
await eav.attributes.create(entityId, {
|
|
72
|
+
name,
|
|
73
|
+
label: def.label,
|
|
74
|
+
dataType: def.dataType,
|
|
75
|
+
isRequired: def.isRequired,
|
|
76
|
+
isUnique: def.isUnique,
|
|
77
|
+
defaultValue: def.defaultValue,
|
|
78
|
+
validation: def.validation,
|
|
79
|
+
options: def.options ? [...def.options] : void 0,
|
|
80
|
+
sortOrder: def.sortOrder
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
async removeAttribute(entity, name) {
|
|
84
|
+
log(`removeAttribute ${entity}.${name}`);
|
|
85
|
+
const entityId = await findEntityIdByName(eav, entity);
|
|
86
|
+
const attrId = await findAttributeIdByName(eav, entityId, name);
|
|
87
|
+
await eav.attributes.delete(entityId, attrId);
|
|
88
|
+
},
|
|
89
|
+
async renameAttribute(entity, oldName, newName) {
|
|
90
|
+
log(`renameAttribute ${entity}.${oldName} → ${newName}`);
|
|
91
|
+
const entityId = await findEntityIdByName(eav, entity);
|
|
92
|
+
const attrId = await findAttributeIdByName(eav, entityId, oldName);
|
|
93
|
+
await eav.attributes.update(entityId, attrId, { name: newName });
|
|
94
|
+
}
|
|
95
|
+
};
|
|
94
96
|
}
|
|
95
97
|
function createRecordsClient(eav) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
98
|
+
return {
|
|
99
|
+
list: eav.records.list,
|
|
100
|
+
listAll: eav.records.listAll,
|
|
101
|
+
count: eav.records.count,
|
|
102
|
+
create: eav.records.create,
|
|
103
|
+
update: eav.records.update,
|
|
104
|
+
upsert: eav.records.upsert,
|
|
105
|
+
delete: eav.records.delete,
|
|
106
|
+
bulkCreate: eav.records.bulkCreate,
|
|
107
|
+
bulkUpdate: eav.records.bulkUpdate,
|
|
108
|
+
bulkDelete: eav.records.bulkDelete,
|
|
109
|
+
deleteWhere: eav.records.deleteWhere,
|
|
110
|
+
findOne: eav.records.findOne,
|
|
111
|
+
backfill: eav.records.backfill
|
|
112
|
+
};
|
|
111
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Build the `MigrationContext` consumed by `migration.up`/`down`.
|
|
116
|
+
*
|
|
117
|
+
* Wraps an existing `ReoptEavClient`:
|
|
118
|
+
* - `schema.*` operates on entity/attribute *names*, resolving to IDs lazily.
|
|
119
|
+
* - `records.*` is a strict subset of `eav.records` (read + mutate by ID).
|
|
120
|
+
* - `log` is whatever the caller passes (CLI prints, dev server captures).
|
|
121
|
+
*/
|
|
112
122
|
function createMigrationContext(eav, opts = {}) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
};
|
|
123
|
+
const log = opts.log ?? (() => {});
|
|
124
|
+
return {
|
|
125
|
+
schema: createSchemaClient(eav, log),
|
|
126
|
+
records: createRecordsClient(eav),
|
|
127
|
+
log
|
|
128
|
+
};
|
|
120
129
|
}
|
|
121
130
|
|
|
122
|
-
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/eav/migrate/runner.ts
|
|
133
|
+
/**
|
|
134
|
+
* Execute a single migration's `up` (or `down`) function.
|
|
135
|
+
*
|
|
136
|
+
* Pure SDK-level — does NOT record applied state on the server. The CLI
|
|
137
|
+
* (`reopt brandapp eav migrate run`) is responsible for calling
|
|
138
|
+
* `client.migrations.create(...)` after `runMigration` resolves.
|
|
139
|
+
*
|
|
140
|
+
* Splitting "execute the function" from "record the row" lets the dev server
|
|
141
|
+
* + tests reuse the runner without touching a remote audit log.
|
|
142
|
+
*/
|
|
123
143
|
async function runMigration(eav, migration, opts) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return {
|
|
147
|
-
name: migration.name,
|
|
148
|
-
checksum: opts.checksum,
|
|
149
|
-
durationMs,
|
|
150
|
-
alreadyApplied: false
|
|
151
|
-
};
|
|
152
|
-
} finally {
|
|
153
|
-
if (opts.lock) {
|
|
154
|
-
await opts.lock.release().catch(() => void 0);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
144
|
+
if (!isMigration(migration)) throw new Error(`runMigration: expected a migration created with defineMigration(), got ${typeof migration}`);
|
|
145
|
+
const direction = opts.direction ?? "up";
|
|
146
|
+
const fn = direction === "up" ? migration.up : migration.down;
|
|
147
|
+
if (!fn) throw new Error(`runMigration("${migration.name}"): no \`${direction}\` function defined`);
|
|
148
|
+
const log = opts.onLog ?? (() => {});
|
|
149
|
+
const ctx = createMigrationContext(eav, { log });
|
|
150
|
+
if (opts.lock) await opts.lock.acquire();
|
|
151
|
+
const startedAt = Date.now();
|
|
152
|
+
try {
|
|
153
|
+
log(`▶ ${migration.name} (${direction})`);
|
|
154
|
+
await fn(ctx);
|
|
155
|
+
const durationMs = Date.now() - startedAt;
|
|
156
|
+
log(`✓ ${migration.name} (${direction}) — ${durationMs}ms`);
|
|
157
|
+
return {
|
|
158
|
+
name: migration.name,
|
|
159
|
+
checksum: opts.checksum,
|
|
160
|
+
durationMs,
|
|
161
|
+
alreadyApplied: false
|
|
162
|
+
};
|
|
163
|
+
} finally {
|
|
164
|
+
if (opts.lock) await opts.lock.release().catch(() => void 0);
|
|
165
|
+
}
|
|
157
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Run a migration's `up`/`down` function with a buffering schema client so
|
|
169
|
+
* the consumer can apply the whole operation set atomically (e.g. via the
|
|
170
|
+
* server's `POST /v1/brandapp/{id}/migrations/apply` route, which wraps the
|
|
171
|
+
* whole array in a single `prisma.$transaction`).
|
|
172
|
+
*
|
|
173
|
+
* Key differences vs. `runMigration`:
|
|
174
|
+
* - **Schema ops are buffered, not sent.** The returned `operations` array
|
|
175
|
+
* is the only side effect on the schema layer.
|
|
176
|
+
* - **Records.* still execute immediately.** Backfills run against the
|
|
177
|
+
* *current* server state — they cannot read attributes that this
|
|
178
|
+
* migration is about to create. If a backfill depends on a new attribute,
|
|
179
|
+
* place it in a follow-up migration.
|
|
180
|
+
* - **No checksum / lock plumbing.** Audit + lock are the caller's job
|
|
181
|
+
* (CLI handles both today).
|
|
182
|
+
*
|
|
183
|
+
* Introduced by Phase A.5 (RFC-0005 ADR-2). The legacy `runMigration` is
|
|
184
|
+
* retained for callers that have not yet adopted the batch endpoint.
|
|
185
|
+
*/
|
|
158
186
|
async function runMigrationCollecting(eav, migration, opts = {}) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
187
|
+
if (!isMigration(migration)) throw new Error(`runMigrationCollecting: expected a migration created with defineMigration(), got ${typeof migration}`);
|
|
188
|
+
const direction = opts.direction ?? "up";
|
|
189
|
+
const fn = direction === "up" ? migration.up : migration.down;
|
|
190
|
+
if (!fn) throw new Error(`runMigrationCollecting("${migration.name}"): no \`${direction}\` function defined`);
|
|
191
|
+
const log = opts.onLog ?? (() => {});
|
|
192
|
+
const operations = [];
|
|
193
|
+
const collectingCtx = {
|
|
194
|
+
schema: {
|
|
195
|
+
async addEntity(name, def) {
|
|
196
|
+
operations.push({
|
|
197
|
+
kind: "addEntity",
|
|
198
|
+
name,
|
|
199
|
+
def
|
|
200
|
+
});
|
|
201
|
+
log(`buffer addEntity ${name}`);
|
|
202
|
+
},
|
|
203
|
+
async removeEntity(name) {
|
|
204
|
+
operations.push({
|
|
205
|
+
kind: "removeEntity",
|
|
206
|
+
name
|
|
207
|
+
});
|
|
208
|
+
log(`buffer removeEntity ${name}`);
|
|
209
|
+
},
|
|
210
|
+
async addAttribute(entity, name, def) {
|
|
211
|
+
operations.push({
|
|
212
|
+
kind: "addAttribute",
|
|
213
|
+
entity,
|
|
214
|
+
name,
|
|
215
|
+
def
|
|
216
|
+
});
|
|
217
|
+
log(`buffer addAttribute ${entity}.${name} (${def.dataType})`);
|
|
218
|
+
},
|
|
219
|
+
async removeAttribute(entity, name) {
|
|
220
|
+
operations.push({
|
|
221
|
+
kind: "removeAttribute",
|
|
222
|
+
entity,
|
|
223
|
+
name
|
|
224
|
+
});
|
|
225
|
+
log(`buffer removeAttribute ${entity}.${name}`);
|
|
226
|
+
},
|
|
227
|
+
async renameAttribute(entity, oldName, newName) {
|
|
228
|
+
operations.push({
|
|
229
|
+
kind: "renameAttribute",
|
|
230
|
+
entity,
|
|
231
|
+
oldName,
|
|
232
|
+
newName
|
|
233
|
+
});
|
|
234
|
+
log(`buffer renameAttribute ${entity}.${oldName} → ${newName}`);
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
records: createMigrationContext(eav, { log }).records,
|
|
238
|
+
log
|
|
239
|
+
};
|
|
240
|
+
const startedAt = Date.now();
|
|
241
|
+
log(`▶ ${migration.name} (${direction}, collecting)`);
|
|
242
|
+
await fn(collectingCtx);
|
|
243
|
+
const durationMs = Date.now() - startedAt;
|
|
244
|
+
log(`✓ ${migration.name} (${direction}, collecting) — ${operations.length} op(s) in ${durationMs}ms`);
|
|
245
|
+
return {
|
|
246
|
+
operations,
|
|
247
|
+
durationMs
|
|
248
|
+
};
|
|
215
249
|
}
|
|
216
250
|
|
|
251
|
+
//#endregion
|
|
217
252
|
export { createMigrationContext, defineMigration, isMigration, runMigration, runMigrationCollecting };
|
|
218
|
-
//# sourceMappingURL=migrate.js.map
|
|
219
253
|
//# sourceMappingURL=migrate.js.map
|