@flytedesk/app-kit 0.1.3 → 0.2.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/dist/cli/profile-sync.d.ts +2 -0
- package/dist/cli/profile-sync.js +26 -0
- package/dist/cli/profile-sync.js.map +1 -0
- package/dist/cli/sync-engine.d.ts +20 -0
- package/dist/cli/sync-engine.js +392 -0
- package/dist/cli/sync-engine.js.map +1 -0
- package/dist/cli/trace-sync.js +9 -359
- package/dist/cli/trace-sync.js.map +1 -1
- package/dist/profile/index.d.ts +36 -0
- package/dist/profile/index.js +36 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/profile/plugin.d.ts +3 -0
- package/dist/profile/plugin.js +111 -0
- package/dist/profile/plugin.js.map +1 -0
- package/dist/profile/types.d.ts +76 -0
- package/dist/profile/types.js +10 -0
- package/dist/profile/types.js.map +1 -0
- package/package.json +7 -2
- package/prisma/fragments/profile.meta.json +4 -0
- package/prisma/fragments/profile.prisma +42 -0
- package/prisma/migrations/0002_app_kit_profile_init/migration.sql +15 -0
- package/prisma/migrations/manifest.json +8 -0
package/dist/cli/trace-sync.js
CHANGED
|
@@ -2,372 +2,22 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* trace-sync — the CLI half of @flytedesk/app-kit/trace (DEC-39).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* consumer's own `prisma generate` then produces one client that includes these
|
|
11
|
-
* models alongside their own.
|
|
12
|
-
*
|
|
13
|
-
* Subcommands:
|
|
14
|
-
* trace-sync init copy fragment + migration in, run `prisma validate` and
|
|
15
|
-
* `prisma db execute`, write the lock file.
|
|
16
|
-
* trace-sync diff read-only: compare this package's bundled fragment
|
|
17
|
-
* version / migration manifest against the consumer's lock
|
|
18
|
-
* file and report what's pending. Never applies anything.
|
|
19
|
-
* trace-sync apply apply pending migrations + refresh the fragment copy,
|
|
20
|
-
* update the lock file. Does not re-run `prisma validate`
|
|
21
|
-
* against a fresh init — use `init` for first install.
|
|
22
|
-
* trace-sync status read-only report: fragment version, applied migrations,
|
|
23
|
-
* and whether the consumer's copy of the fragment has been
|
|
24
|
-
* hand-edited (checksum mismatch).
|
|
25
|
-
*
|
|
26
|
-
* This is a real, runnable CLI — it shells out to the consumer's local `prisma`
|
|
27
|
-
* via `npx` and touches the consumer's real filesystem — not a stub.
|
|
28
|
-
*/
|
|
29
|
-
import { createHash } from "node:crypto";
|
|
30
|
-
import spawn from "cross-spawn";
|
|
31
|
-
import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, writeFileSync, } from "node:fs";
|
|
32
|
-
import path from "node:path";
|
|
33
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
34
|
-
// ---------------------------------------------------------------------------
|
|
35
|
-
// Package-relative paths
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
|
-
/** Root of the installed @flytedesk/app-kit package (two levels up from
|
|
38
|
-
* dist/cli/trace-sync.js — this file, once built). */
|
|
39
|
-
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
40
|
-
const fragmentSrcPath = path.join(packageRoot, "prisma", "fragments", "trace.prisma");
|
|
41
|
-
const fragmentMetaPath = path.join(packageRoot, "prisma", "fragments", "trace.meta.json");
|
|
42
|
-
const migrationsSrcDir = path.join(packageRoot, "prisma", "migrations");
|
|
43
|
-
const manifestSrcPath = path.join(migrationsSrcDir, "manifest.json");
|
|
44
|
-
const LOCK_FILE_NAME = ".app-kit-trace.lock.json";
|
|
45
|
-
class TraceSyncError extends Error {
|
|
46
|
-
}
|
|
47
|
-
function fail(message) {
|
|
48
|
-
console.error(`trace-sync: ${message}`);
|
|
49
|
-
process.exitCode = 1;
|
|
50
|
-
throw new TraceSyncError(message);
|
|
51
|
-
}
|
|
52
|
-
function readJson(filePath) {
|
|
53
|
-
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
54
|
-
}
|
|
55
|
-
function sha256(content) {
|
|
56
|
-
return `sha256:${createHash("sha256").update(content).digest("hex")}`;
|
|
57
|
-
}
|
|
58
|
-
function sha256File(filePath) {
|
|
59
|
-
return sha256(readFileSync(filePath));
|
|
60
|
-
}
|
|
61
|
-
function readFragmentMeta() {
|
|
62
|
-
return readJson(fragmentMetaPath);
|
|
63
|
-
}
|
|
64
|
-
function readManifest() {
|
|
65
|
-
return readJson(manifestSrcPath);
|
|
66
|
-
}
|
|
67
|
-
function lockFilePath(consumerRoot) {
|
|
68
|
-
return path.join(consumerRoot, LOCK_FILE_NAME);
|
|
69
|
-
}
|
|
70
|
-
function readLockFile(consumerRoot) {
|
|
71
|
-
const p = lockFilePath(consumerRoot);
|
|
72
|
-
if (!existsSync(p))
|
|
73
|
-
return null;
|
|
74
|
-
return readJson(p);
|
|
75
|
-
}
|
|
76
|
-
function writeLockFile(consumerRoot, lock) {
|
|
77
|
-
writeFileSync(lockFilePath(consumerRoot), `${JSON.stringify(lock, null, 2)}\n`, "utf8");
|
|
78
|
-
}
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
|
-
// Locating the consumer's Prisma schema folder via their prisma.config.ts
|
|
81
|
-
// ---------------------------------------------------------------------------
|
|
82
|
-
const CONSUMER_CONFIG_CANDIDATES = [
|
|
83
|
-
"prisma.config.ts",
|
|
84
|
-
"prisma.config.mts",
|
|
85
|
-
"prisma.config.js",
|
|
86
|
-
"prisma.config.mjs",
|
|
87
|
-
];
|
|
88
|
-
function findConsumerConfigFile(consumerRoot) {
|
|
89
|
-
for (const candidate of CONSUMER_CONFIG_CANDIDATES) {
|
|
90
|
-
const p = path.join(consumerRoot, candidate);
|
|
91
|
-
if (existsSync(p))
|
|
92
|
-
return p;
|
|
93
|
-
}
|
|
94
|
-
fail(`could not find a prisma.config.{ts,mts,js,mjs} in ${consumerRoot}. ` +
|
|
95
|
-
`trace-sync reads this file to find your Prisma schema folder — it does not assume a path.`);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Best-effort read of the consumer's `schema` setting out of their
|
|
99
|
-
* prisma.config.ts default export. Supports the shapes Prisma's config API has
|
|
100
|
-
* used: a bare string path (file or folder), or `{ path: string }`. Relies on
|
|
101
|
-
* Node's native TypeScript type-stripping (unflagged as of the Node 24 baseline
|
|
102
|
-
* this package requires) to import a .ts file directly — if the consumer's
|
|
103
|
-
* config uses syntax that isn't erasable (enums, namespaces, parameter
|
|
104
|
-
* properties, etc.) this import will fail, and that failure is surfaced as-is
|
|
105
|
-
* rather than swallowed.
|
|
5
|
+
* A thin wrapper around the generalized sync engine in ./sync-engine.js — see that
|
|
6
|
+
* file's doc comment for the full subcommand reference (init/diff/apply/status) and
|
|
7
|
+
* how fragments/migrations/lock files work. This file only supplies the "trace"
|
|
8
|
+
* fragment name and the "trace-sync" bin name; profile-sync.ts is the same wrapper
|
|
9
|
+
* for the profile fragment.
|
|
106
10
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
let mod;
|
|
110
|
-
try {
|
|
111
|
-
mod = await import(pathToFileURL(configFile).href);
|
|
112
|
-
}
|
|
113
|
-
catch (err) {
|
|
114
|
-
fail(`failed to load ${configFile}: ${err.message}\n` +
|
|
115
|
-
`If this config file uses TypeScript syntax that Node can't type-strip natively ` +
|
|
116
|
-
`(enums, namespaces, decorators, ...), trace-sync can't import it directly.`);
|
|
117
|
-
}
|
|
118
|
-
const config = mod.default ?? mod;
|
|
119
|
-
const schema = config?.schema;
|
|
120
|
-
let schemaPath;
|
|
121
|
-
if (typeof schema === "string") {
|
|
122
|
-
schemaPath = schema;
|
|
123
|
-
}
|
|
124
|
-
else if (schema &&
|
|
125
|
-
typeof schema === "object" &&
|
|
126
|
-
typeof schema.path === "string") {
|
|
127
|
-
schemaPath = schema.path;
|
|
128
|
-
}
|
|
129
|
-
if (!schemaPath) {
|
|
130
|
-
fail(`could not find a "schema" path in ${configFile}'s default export. ` +
|
|
131
|
-
`Expected \`defineConfig({ schema: "prisma/schema" })\` (or a { path } object).`);
|
|
132
|
-
}
|
|
133
|
-
return path.resolve(path.dirname(configFile), schemaPath);
|
|
134
|
-
}
|
|
135
|
-
/** Resolve the folder trace.prisma gets copied into, from the config's schema
|
|
136
|
-
* path (which may point at the folder itself, or at a single schema file
|
|
137
|
-
* inside it, e.g. "prisma/schema.prisma"). */
|
|
138
|
-
function resolveSchemaFolder(schemaPath) {
|
|
139
|
-
if (schemaPath.endsWith(".prisma")) {
|
|
140
|
-
return path.dirname(schemaPath);
|
|
141
|
-
}
|
|
142
|
-
return schemaPath;
|
|
143
|
-
}
|
|
144
|
-
/** The conventional "prisma root" a schema folder sits under, used to locate
|
|
145
|
-
* (or create) the sibling `migrations/` directory. For the common multi-file
|
|
146
|
-
* layout `prisma/schema/*.prisma`, that's `prisma/`; for a flat
|
|
147
|
-
* `prisma/schema.prisma` layout, `resolveSchemaFolder` already returned
|
|
148
|
-
* `prisma/`, so this is a no-op. */
|
|
149
|
-
function resolvePrismaRoot(schemaFolder) {
|
|
150
|
-
return path.basename(schemaFolder) === "schema"
|
|
151
|
-
? path.dirname(schemaFolder)
|
|
152
|
-
: schemaFolder;
|
|
153
|
-
}
|
|
154
|
-
// ---------------------------------------------------------------------------
|
|
155
|
-
// Shelling out to the consumer's local `prisma`
|
|
156
|
-
// ---------------------------------------------------------------------------
|
|
157
|
-
function runPrisma(args, cwd) {
|
|
158
|
-
// On Windows, npx resolves to npx.cmd, a shell script — node:child_process's
|
|
159
|
-
// spawnSync can't exec it directly (EINVAL) without shell:true, and shell:true
|
|
160
|
-
// with an argument array is an unescaped-concatenation footgun (path arguments
|
|
161
|
-
// here can contain spaces). cross-spawn resolves and correctly quotes .cmd/.bat
|
|
162
|
-
// executables on Windows without going through a shell at all.
|
|
163
|
-
const result = spawn.sync("npx", ["prisma", ...args], { cwd, stdio: "inherit" });
|
|
164
|
-
if (result.error) {
|
|
165
|
-
fail(`failed to run "npx prisma ${args.join(" ")}": ${result.error.message}`);
|
|
166
|
-
}
|
|
167
|
-
if (result.status !== 0) {
|
|
168
|
-
fail(`"npx prisma ${args.join(" ")}" exited with code ${result.status}`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
// ---------------------------------------------------------------------------
|
|
172
|
-
// File copying
|
|
173
|
-
// ---------------------------------------------------------------------------
|
|
174
|
-
function copyFragment(schemaFolder) {
|
|
175
|
-
mkdirSync(schemaFolder, { recursive: true });
|
|
176
|
-
copyFileSync(fragmentSrcPath, path.join(schemaFolder, "trace.prisma"));
|
|
177
|
-
}
|
|
178
|
-
function copyMigration(migrationId, migrationsDestDir) {
|
|
179
|
-
const srcDir = path.join(migrationsSrcDir, migrationId);
|
|
180
|
-
const destDir = path.join(migrationsDestDir, migrationId);
|
|
181
|
-
mkdirSync(destDir, { recursive: true });
|
|
182
|
-
cpSync(srcDir, destDir, { recursive: true });
|
|
183
|
-
}
|
|
184
|
-
// ---------------------------------------------------------------------------
|
|
185
|
-
// Subcommands
|
|
186
|
-
// ---------------------------------------------------------------------------
|
|
187
|
-
async function cmdInit(consumerRoot) {
|
|
188
|
-
const schemaPath = await loadConsumerSchemaPath(consumerRoot);
|
|
189
|
-
const schemaFolder = resolveSchemaFolder(schemaPath);
|
|
190
|
-
const prismaRoot = resolvePrismaRoot(schemaFolder);
|
|
191
|
-
const migrationsDestDir = path.join(prismaRoot, "migrations");
|
|
192
|
-
console.log(`trace-sync: copying trace.prisma into ${schemaFolder}`);
|
|
193
|
-
copyFragment(schemaFolder);
|
|
194
|
-
console.log(`trace-sync: running "npx prisma validate" against ${consumerRoot}`);
|
|
195
|
-
runPrisma(["validate"], consumerRoot);
|
|
196
|
-
const manifest = readManifest();
|
|
197
|
-
const appliedMigrations = [];
|
|
198
|
-
for (const entry of manifest) {
|
|
199
|
-
console.log(`trace-sync: copying migration ${entry.id} into ${migrationsDestDir}`);
|
|
200
|
-
copyMigration(entry.id, migrationsDestDir);
|
|
201
|
-
const migrationSqlPath = path.join(migrationsDestDir, entry.id, "migration.sql");
|
|
202
|
-
console.log(`trace-sync: applying ${entry.id} via "npx prisma db execute"`);
|
|
203
|
-
runPrisma(
|
|
204
|
-
// Prisma ORM v7's `db execute` no longer accepts `--schema` at all — the
|
|
205
|
-
// datasource URL comes only from the consumer's prisma.config.ts now (same
|
|
206
|
-
// "config file, not CLI flags" migration documented on flytedesk-id's own
|
|
207
|
-
// prisma.config.ts). Passing --schema here is a hard CLI usage error
|
|
208
|
-
// ("unknown or unexpected option: --schema") against a real Prisma 7 install,
|
|
209
|
-
// confirmed while building examples/hello-world.
|
|
210
|
-
["db", "execute", "--file", migrationSqlPath], consumerRoot);
|
|
211
|
-
appliedMigrations.push(entry.id);
|
|
212
|
-
}
|
|
213
|
-
const meta = readFragmentMeta();
|
|
214
|
-
writeLockFile(consumerRoot, {
|
|
215
|
-
fragmentVersion: meta.fragmentVersion,
|
|
216
|
-
fragmentChecksum: sha256File(fragmentSrcPath),
|
|
217
|
-
appliedMigrations,
|
|
218
|
-
lastSyncedAt: new Date().toISOString(),
|
|
219
|
-
});
|
|
220
|
-
console.log(`trace-sync: wrote ${lockFilePath(consumerRoot)}`);
|
|
221
|
-
console.log("trace-sync: init complete.");
|
|
222
|
-
}
|
|
223
|
-
function computePending(consumerRoot) {
|
|
224
|
-
const lock = readLockFile(consumerRoot);
|
|
225
|
-
if (!lock) {
|
|
226
|
-
fail(`no ${LOCK_FILE_NAME} found at ${consumerRoot}. Run "trace-sync init" first.`);
|
|
227
|
-
}
|
|
228
|
-
const meta = readFragmentMeta();
|
|
229
|
-
const manifest = readManifest();
|
|
230
|
-
const applied = new Set(lock.appliedMigrations);
|
|
231
|
-
const pendingMigrations = manifest.filter((entry) => !applied.has(entry.id));
|
|
232
|
-
return {
|
|
233
|
-
fragmentVersionCurrent: meta.fragmentVersion,
|
|
234
|
-
fragmentVersionInstalled: lock.fragmentVersion,
|
|
235
|
-
fragmentVersionChanged: meta.fragmentVersion !== lock.fragmentVersion,
|
|
236
|
-
pendingMigrations,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
function cmdDiff(consumerRoot) {
|
|
240
|
-
const report = computePending(consumerRoot);
|
|
241
|
-
if (report.fragmentVersionChanged) {
|
|
242
|
-
console.log(`fragment version: ${report.fragmentVersionInstalled} -> ${report.fragmentVersionCurrent} (changed)`);
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
console.log(`fragment version: ${report.fragmentVersionCurrent} (up to date)`);
|
|
246
|
-
}
|
|
247
|
-
if (report.pendingMigrations.length === 0) {
|
|
248
|
-
console.log("migrations: up to date, nothing pending.");
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
console.log(`migrations: ${report.pendingMigrations.length} pending:`);
|
|
252
|
-
for (const entry of report.pendingMigrations) {
|
|
253
|
-
console.log(` - ${entry.id} (introduced in fragment ${entry.introducedInFragmentVersion})`);
|
|
254
|
-
}
|
|
255
|
-
console.log('trace-sync diff is read-only. Run "trace-sync apply" to apply these.');
|
|
256
|
-
}
|
|
257
|
-
async function cmdApply(consumerRoot) {
|
|
258
|
-
const report = computePending(consumerRoot);
|
|
259
|
-
const schemaPath = await loadConsumerSchemaPath(consumerRoot);
|
|
260
|
-
const schemaFolder = resolveSchemaFolder(schemaPath);
|
|
261
|
-
const prismaRoot = resolvePrismaRoot(schemaFolder);
|
|
262
|
-
const migrationsDestDir = path.join(prismaRoot, "migrations");
|
|
263
|
-
console.log(`trace-sync: refreshing trace.prisma in ${schemaFolder}`);
|
|
264
|
-
copyFragment(schemaFolder);
|
|
265
|
-
const lock = readLockFile(consumerRoot);
|
|
266
|
-
if (!lock) {
|
|
267
|
-
fail(`no ${LOCK_FILE_NAME} found at ${consumerRoot}. Run "trace-sync init" first.`);
|
|
268
|
-
}
|
|
269
|
-
const appliedMigrations = [...lock.appliedMigrations];
|
|
270
|
-
if (report.pendingMigrations.length === 0) {
|
|
271
|
-
console.log("trace-sync: no pending migrations to apply.");
|
|
272
|
-
}
|
|
273
|
-
for (const entry of report.pendingMigrations) {
|
|
274
|
-
console.log(`trace-sync: copying migration ${entry.id} into ${migrationsDestDir}`);
|
|
275
|
-
copyMigration(entry.id, migrationsDestDir);
|
|
276
|
-
const migrationSqlPath = path.join(migrationsDestDir, entry.id, "migration.sql");
|
|
277
|
-
console.log(`trace-sync: applying ${entry.id} via "npx prisma db execute"`);
|
|
278
|
-
runPrisma(
|
|
279
|
-
// Prisma ORM v7's `db execute` no longer accepts `--schema` at all — the
|
|
280
|
-
// datasource URL comes only from the consumer's prisma.config.ts now (same
|
|
281
|
-
// "config file, not CLI flags" migration documented on flytedesk-id's own
|
|
282
|
-
// prisma.config.ts). Passing --schema here is a hard CLI usage error
|
|
283
|
-
// ("unknown or unexpected option: --schema") against a real Prisma 7 install,
|
|
284
|
-
// confirmed while building examples/hello-world.
|
|
285
|
-
["db", "execute", "--file", migrationSqlPath], consumerRoot);
|
|
286
|
-
appliedMigrations.push(entry.id);
|
|
287
|
-
}
|
|
288
|
-
const meta = readFragmentMeta();
|
|
289
|
-
writeLockFile(consumerRoot, {
|
|
290
|
-
fragmentVersion: meta.fragmentVersion,
|
|
291
|
-
fragmentChecksum: sha256File(fragmentSrcPath),
|
|
292
|
-
appliedMigrations,
|
|
293
|
-
lastSyncedAt: new Date().toISOString(),
|
|
294
|
-
});
|
|
295
|
-
console.log(`trace-sync: wrote ${lockFilePath(consumerRoot)}`);
|
|
296
|
-
console.log("trace-sync: apply complete.");
|
|
297
|
-
}
|
|
298
|
-
async function cmdStatus(consumerRoot) {
|
|
299
|
-
const lock = readLockFile(consumerRoot);
|
|
300
|
-
if (!lock) {
|
|
301
|
-
console.log(`no ${LOCK_FILE_NAME} found at ${consumerRoot}. Not yet initialized — run "trace-sync init".`);
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
console.log(`fragment version (installed): ${lock.fragmentVersion}`);
|
|
305
|
-
console.log(`fragment version (package): ${readFragmentMeta().fragmentVersion}`);
|
|
306
|
-
console.log(`last synced: ${lock.lastSyncedAt}`);
|
|
307
|
-
console.log(`applied migrations (${lock.appliedMigrations.length}):`);
|
|
308
|
-
for (const id of lock.appliedMigrations) {
|
|
309
|
-
console.log(` - ${id}`);
|
|
310
|
-
}
|
|
311
|
-
try {
|
|
312
|
-
const schemaPath = await loadConsumerSchemaPath(consumerRoot);
|
|
313
|
-
const schemaFolder = resolveSchemaFolder(schemaPath);
|
|
314
|
-
const copiedFragmentPath = path.join(schemaFolder, "trace.prisma");
|
|
315
|
-
if (!existsSync(copiedFragmentPath)) {
|
|
316
|
-
console.log(`fragment copy: MISSING at ${copiedFragmentPath}`);
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
const installedChecksum = sha256File(copiedFragmentPath);
|
|
320
|
-
if (installedChecksum === lock.fragmentChecksum) {
|
|
321
|
-
console.log("fragment copy: unmodified");
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
console.log(`fragment copy: CHECKSUM MISMATCH — ${copiedFragmentPath} has been hand-edited ` +
|
|
325
|
-
`(or is out of sync with the lock file)`);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
catch (err) {
|
|
329
|
-
console.log(`fragment copy: could not verify (${err.message})`);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
// ---------------------------------------------------------------------------
|
|
333
|
-
// Entry point
|
|
334
|
-
// ---------------------------------------------------------------------------
|
|
335
|
-
const SUBCOMMANDS = ["init", "diff", "apply", "status"];
|
|
336
|
-
function isSubcommand(value) {
|
|
337
|
-
return SUBCOMMANDS.includes(value);
|
|
338
|
-
}
|
|
11
|
+
import { pathToFileURL } from "node:url";
|
|
12
|
+
import { runSyncCli, SyncCliError } from "./sync-engine.js";
|
|
339
13
|
export async function main(argv) {
|
|
340
|
-
|
|
341
|
-
if (!isSubcommand(subcommand)) {
|
|
342
|
-
console.error(`usage: trace-sync <${SUBCOMMANDS.join("|")}>`);
|
|
343
|
-
process.exitCode = 1;
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
// Reserved for a future --cwd override; today trace-sync always operates on
|
|
347
|
-
// the directory it's invoked from, which is how `npx trace-sync ...` /
|
|
348
|
-
// an npm script in the consumer's own package.json will run it.
|
|
349
|
-
void rest;
|
|
350
|
-
const consumerRoot = process.cwd();
|
|
351
|
-
switch (subcommand) {
|
|
352
|
-
case "init":
|
|
353
|
-
await cmdInit(consumerRoot);
|
|
354
|
-
break;
|
|
355
|
-
case "diff":
|
|
356
|
-
cmdDiff(consumerRoot);
|
|
357
|
-
break;
|
|
358
|
-
case "apply":
|
|
359
|
-
await cmdApply(consumerRoot);
|
|
360
|
-
break;
|
|
361
|
-
case "status":
|
|
362
|
-
await cmdStatus(consumerRoot);
|
|
363
|
-
break;
|
|
364
|
-
}
|
|
14
|
+
return runSyncCli(argv, { name: "trace", binName: "trace-sync" });
|
|
365
15
|
}
|
|
366
16
|
const isMainModule = process.argv[1] !== undefined &&
|
|
367
17
|
import.meta.url === pathToFileURL(process.argv[1]).href;
|
|
368
18
|
if (isMainModule) {
|
|
369
19
|
main(process.argv.slice(2)).catch((err) => {
|
|
370
|
-
if (!(err instanceof
|
|
20
|
+
if (!(err instanceof SyncCliError)) {
|
|
371
21
|
console.error(err);
|
|
372
22
|
}
|
|
373
23
|
process.exitCode = process.exitCode ?? 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace-sync.js","sourceRoot":"","sources":["../../src/cli/trace-sync.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EACL,YAAY,EACZ,MAAM,EACN,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEx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CAAC;AAED,MAAM,YAAY,GAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS;IAC7B,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE1D,IAAI,YAAY,EAAE,CAAC;IACjB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QACjD,IAAI,CAAC,CAAC,GAAG,YAAY,YAAY,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic self-service "edit my own profile fields" module (title/phone/timezone/
|
|
3
|
+
* bio) — DEC-39, DEC-52. Ships a Prisma schema fragment + a raw SQL migration + a
|
|
4
|
+
* `profile-sync` CLI (all generalized from @flytedesk/app-kit/trace's DEC-39
|
|
5
|
+
* machinery — see prisma/fragments/profile.prisma and src/cli/profile-sync.ts) plus
|
|
6
|
+
* a real Fastify plugin with GET/PATCH routes, so flytedesk-id (and other flytedesk
|
|
7
|
+
* apps after it) don't each hand-roll their own GET/PATCH /me route + migration for
|
|
8
|
+
* this.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
*
|
|
12
|
+
* import Fastify from "fastify";
|
|
13
|
+
* import { flytedeskAuth } from "@flytedesk/app-kit/auth";
|
|
14
|
+
* import { appKitProfile } from "@flytedesk/app-kit/profile";
|
|
15
|
+
*
|
|
16
|
+
* const app = Fastify();
|
|
17
|
+
* await app.register(flytedeskAuth, { ...authOptions });
|
|
18
|
+
* // Must come after flytedeskAuth (or whatever else decorates request.authUser)
|
|
19
|
+
* // — see plugin.ts's registration-time check.
|
|
20
|
+
* await app.register(appKitProfile, {
|
|
21
|
+
* store: {
|
|
22
|
+
* findByUserId: (userId) => prisma.appKitUserProfile.findUnique({ where: { userId } }),
|
|
23
|
+
* upsert: (userId, patch) =>
|
|
24
|
+
* prisma.appKitUserProfile.upsert({
|
|
25
|
+
* where: { userId },
|
|
26
|
+
* create: { userId, ...patch },
|
|
27
|
+
* update: patch,
|
|
28
|
+
* }),
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // GET /profile -> { userId, title, phone, timezone, bio, updatedAt }
|
|
33
|
+
* // PATCH /profile { title?, phone?, timezone?, bio? } -> same shape
|
|
34
|
+
*/
|
|
35
|
+
export { appKitProfile } from "./plugin.js";
|
|
36
|
+
export type { AppKitProfileOptions, ProfileFields, ProfilePatch, ProfileResponseBody, ProfileRow, ProfileStore, } from "./types.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic self-service "edit my own profile fields" module (title/phone/timezone/
|
|
3
|
+
* bio) — DEC-39, DEC-52. Ships a Prisma schema fragment + a raw SQL migration + a
|
|
4
|
+
* `profile-sync` CLI (all generalized from @flytedesk/app-kit/trace's DEC-39
|
|
5
|
+
* machinery — see prisma/fragments/profile.prisma and src/cli/profile-sync.ts) plus
|
|
6
|
+
* a real Fastify plugin with GET/PATCH routes, so flytedesk-id (and other flytedesk
|
|
7
|
+
* apps after it) don't each hand-roll their own GET/PATCH /me route + migration for
|
|
8
|
+
* this.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
*
|
|
12
|
+
* import Fastify from "fastify";
|
|
13
|
+
* import { flytedeskAuth } from "@flytedesk/app-kit/auth";
|
|
14
|
+
* import { appKitProfile } from "@flytedesk/app-kit/profile";
|
|
15
|
+
*
|
|
16
|
+
* const app = Fastify();
|
|
17
|
+
* await app.register(flytedeskAuth, { ...authOptions });
|
|
18
|
+
* // Must come after flytedeskAuth (or whatever else decorates request.authUser)
|
|
19
|
+
* // — see plugin.ts's registration-time check.
|
|
20
|
+
* await app.register(appKitProfile, {
|
|
21
|
+
* store: {
|
|
22
|
+
* findByUserId: (userId) => prisma.appKitUserProfile.findUnique({ where: { userId } }),
|
|
23
|
+
* upsert: (userId, patch) =>
|
|
24
|
+
* prisma.appKitUserProfile.upsert({
|
|
25
|
+
* where: { userId },
|
|
26
|
+
* create: { userId, ...patch },
|
|
27
|
+
* update: patch,
|
|
28
|
+
* }),
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // GET /profile -> { userId, title, phone, timezone, bio, updatedAt }
|
|
33
|
+
* // PATCH /profile { title?, phone?, timezone?, bio? } -> same shape
|
|
34
|
+
*/
|
|
35
|
+
export { appKitProfile } from "./plugin.js";
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/profile/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import fp from "fastify-plugin";
|
|
2
|
+
const DEFAULT_ROUTE_PREFIX = "/profile";
|
|
3
|
+
const PATCHABLE_FIELDS = ["title", "phone", "timezone", "bio"];
|
|
4
|
+
function assertRequiredOptions(options) {
|
|
5
|
+
if (!options.store) {
|
|
6
|
+
throw new Error('@flytedesk/app-kit/profile: missing required option "store"');
|
|
7
|
+
}
|
|
8
|
+
if (typeof options.store.findByUserId !== "function" ||
|
|
9
|
+
typeof options.store.upsert !== "function") {
|
|
10
|
+
throw new Error('@flytedesk/app-kit/profile: options.store must implement findByUserId(userId) and upsert(userId, patch)');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function toResponseBody(userId, row) {
|
|
14
|
+
if (!row) {
|
|
15
|
+
return { userId, title: null, phone: null, timezone: null, bio: null, updatedAt: null };
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
userId: row.userId,
|
|
19
|
+
title: row.title,
|
|
20
|
+
phone: row.phone,
|
|
21
|
+
timezone: row.timezone,
|
|
22
|
+
bio: row.bio,
|
|
23
|
+
updatedAt: row.updatedAt.toISOString(),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parses/validates a PATCH request body into a ProfilePatch, or returns an error
|
|
28
|
+
* message. Unknown keys are silently ignored (a permissive PATCH — only the four
|
|
29
|
+
* known fields are ever read or written); every *known* key present in the body
|
|
30
|
+
* must be a string, or the whole request is rejected with 400 rather than silently
|
|
31
|
+
* dropping the bad field.
|
|
32
|
+
*/
|
|
33
|
+
function parsePatchBody(body) {
|
|
34
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) {
|
|
35
|
+
return { error: "Request body must be a JSON object" };
|
|
36
|
+
}
|
|
37
|
+
const input = body;
|
|
38
|
+
const patch = {};
|
|
39
|
+
for (const field of PATCHABLE_FIELDS) {
|
|
40
|
+
if (!(field in input))
|
|
41
|
+
continue;
|
|
42
|
+
const value = input[field];
|
|
43
|
+
if (typeof value !== "string") {
|
|
44
|
+
return { error: `"${field}" must be a string` };
|
|
45
|
+
}
|
|
46
|
+
patch[field] = value;
|
|
47
|
+
}
|
|
48
|
+
return patch;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Not exported: this plugin's own minimal 401 check on `request.authUser`, kept
|
|
52
|
+
* local (rather than importing ../auth/guards.js's requireAuth) so this module has
|
|
53
|
+
* no hard dependency on the auth module's internals beyond the `authUser`
|
|
54
|
+
* decoration contract it documents (declare module "fastify" in ../auth/plugin.ts)
|
|
55
|
+
* — any consumer populating request.authUser some other way (not necessarily via
|
|
56
|
+
* @flytedesk/app-kit/auth) still works. Mirrors requireAuth's shape in
|
|
57
|
+
* ../auth/guards.ts: returns whether the request may proceed, and the route
|
|
58
|
+
* handler reads `request.authUser!` afterward, same as that module's own
|
|
59
|
+
* requirePermission does.
|
|
60
|
+
*/
|
|
61
|
+
function requireAuthUser(request, reply) {
|
|
62
|
+
if (!request.authUser) {
|
|
63
|
+
reply.code(401).send({ error: "Authentication required", code: "unauthenticated" });
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
const appKitProfilePlugin = async (fastify, options) => {
|
|
69
|
+
assertRequiredOptions(options);
|
|
70
|
+
// request.authUser is decorated by @flytedesk/app-kit/auth's flytedeskAuth plugin
|
|
71
|
+
// (see ../auth/plugin.ts's `declare module "fastify"` block) or by whatever the
|
|
72
|
+
// consuming app uses in its place. Both GET and PATCH below resolve "the current
|
|
73
|
+
// user" from request.authUser.id, so this plugin is unusable without it — rather
|
|
74
|
+
// than silently reading `undefined` and letting every request 401 in a confusing
|
|
75
|
+
// way, fail loudly and immediately at registration time if the decorator was never
|
|
76
|
+
// installed. This means: register @flytedesk/app-kit/auth (or your own equivalent)
|
|
77
|
+
// BEFORE this plugin.
|
|
78
|
+
if (!fastify.hasRequestDecorator("authUser")) {
|
|
79
|
+
throw new Error('@flytedesk/app-kit/profile: request.authUser is not decorated on this Fastify instance yet. ' +
|
|
80
|
+
"This plugin resolves the caller from request.authUser and must be registered AFTER " +
|
|
81
|
+
"whatever populates it — @flytedesk/app-kit/auth's flytedeskAuth plugin, or the " +
|
|
82
|
+
"consuming app's own equivalent decorator.");
|
|
83
|
+
}
|
|
84
|
+
const routePrefix = options.routePrefix ?? DEFAULT_ROUTE_PREFIX;
|
|
85
|
+
const store = options.store;
|
|
86
|
+
/** GET {routePrefix} — the caller's own profile. Never 404s: a user with no row
|
|
87
|
+
* yet still gets a 200 with every field null (see ProfileStore.findByUserId). */
|
|
88
|
+
fastify.get(routePrefix, async (request, reply) => {
|
|
89
|
+
if (!requireAuthUser(request, reply))
|
|
90
|
+
return;
|
|
91
|
+
const row = await store.findByUserId(request.authUser.id);
|
|
92
|
+
return toResponseBody(request.authUser.id, row);
|
|
93
|
+
});
|
|
94
|
+
/** PATCH {routePrefix} — upserts whatever subset of {title, phone, timezone, bio}
|
|
95
|
+
* is present in the body, scoped to the caller's own row (request.authUser.id is
|
|
96
|
+
* the only id this handler ever reads or writes — never a caller-supplied one). */
|
|
97
|
+
fastify.patch(routePrefix, async (request, reply) => {
|
|
98
|
+
if (!requireAuthUser(request, reply))
|
|
99
|
+
return;
|
|
100
|
+
const parsed = parsePatchBody(request.body);
|
|
101
|
+
if ("error" in parsed) {
|
|
102
|
+
return reply.code(400).send({ error: parsed.error, code: "invalid_body" });
|
|
103
|
+
}
|
|
104
|
+
const row = await store.upsert(request.authUser.id, parsed);
|
|
105
|
+
return toResponseBody(request.authUser.id, row);
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
export const appKitProfile = fp(appKitProfilePlugin, {
|
|
109
|
+
name: "@flytedesk/app-kit/profile",
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/profile/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAShC,MAAM,oBAAoB,GAAG,UAAU,CAAC;AAExC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAE5D,CAAC;AAEF,SAAS,qBAAqB,CAAC,OAA6B;IAC1D,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,IACE,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,KAAK,UAAU;QAChD,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,UAAU,EAC1C,CAAC;QACD,MAAM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