@opensaas/stack-cli 0.43.0 → 0.44.0-alpha.1
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/README.md +116 -135
- package/dist/.build-hash +1 -0
- package/dist/commands/db.d.ts +23 -0
- package/dist/commands/db.d.ts.map +1 -0
- package/dist/commands/db.js +43 -0
- package/dist/commands/db.js.map +1 -0
- package/dist/commands/dev.d.ts +12 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +519 -22
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/fk-renames.d.ts +14 -0
- package/dist/commands/fk-renames.d.ts.map +1 -0
- package/dist/commands/fk-renames.js +90 -0
- package/dist/commands/fk-renames.js.map +1 -0
- package/dist/commands/generate.d.ts +61 -4
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +225 -138
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +13 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/junction-ids.d.ts +11 -0
- package/dist/commands/junction-ids.d.ts.map +1 -0
- package/dist/commands/junction-ids.js +81 -0
- package/dist/commands/junction-ids.js.map +1 -0
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +47 -25
- package/dist/commands/migrate.js.map +1 -1
- package/dist/dev/app-runner.d.ts +70 -0
- package/dist/dev/app-runner.d.ts.map +1 -0
- package/dist/dev/app-runner.js +116 -0
- package/dist/dev/app-runner.js.map +1 -0
- package/dist/dev/control.d.ts +73 -0
- package/dist/dev/control.d.ts.map +1 -0
- package/dist/dev/control.js +251 -0
- package/dist/dev/control.js.map +1 -0
- package/dist/dev/staged-reconcile.d.ts +126 -0
- package/dist/dev/staged-reconcile.d.ts.map +1 -0
- package/dist/dev/staged-reconcile.js +289 -0
- package/dist/dev/staged-reconcile.js.map +1 -0
- package/dist/generator/config-load.d.ts +34 -0
- package/dist/generator/config-load.d.ts.map +1 -0
- package/dist/generator/config-load.js +64 -0
- package/dist/generator/config-load.js.map +1 -0
- package/dist/generator/context.d.ts +39 -3
- package/dist/generator/context.d.ts.map +1 -1
- package/dist/generator/context.js +245 -107
- package/dist/generator/context.js.map +1 -1
- package/dist/generator/contract-emit.d.ts +24 -0
- package/dist/generator/contract-emit.d.ts.map +1 -0
- package/dist/generator/contract-emit.js +34 -0
- package/dist/generator/contract-emit.js.map +1 -0
- package/dist/generator/contract-module.d.ts +39 -0
- package/dist/generator/contract-module.d.ts.map +1 -0
- package/dist/generator/contract-module.js +440 -0
- package/dist/generator/contract-module.js.map +1 -0
- package/dist/generator/extension-spaces.d.ts +142 -0
- package/dist/generator/extension-spaces.d.ts.map +1 -0
- package/dist/generator/extension-spaces.js +358 -0
- package/dist/generator/extension-spaces.js.map +1 -0
- package/dist/generator/index.d.ts +12 -4
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +7 -3
- package/dist/generator/index.js.map +1 -1
- package/dist/generator/lists.d.ts +6 -7
- package/dist/generator/lists.d.ts.map +1 -1
- package/dist/generator/lists.js +33 -13
- package/dist/generator/lists.js.map +1 -1
- package/dist/generator/output-paths.d.ts +62 -19
- package/dist/generator/output-paths.d.ts.map +1 -1
- package/dist/generator/output-paths.js +68 -30
- package/dist/generator/output-paths.js.map +1 -1
- package/dist/generator/prisma-cli.d.ts +61 -0
- package/dist/generator/prisma-cli.d.ts.map +1 -0
- package/dist/generator/prisma-cli.js +92 -0
- package/dist/generator/prisma-cli.js.map +1 -0
- package/dist/generator/prisma-config.d.ts +50 -31
- package/dist/generator/prisma-config.d.ts.map +1 -1
- package/dist/generator/prisma-config.js +72 -65
- package/dist/generator/prisma-config.js.map +1 -1
- package/dist/generator/source-text.d.ts +16 -0
- package/dist/generator/source-text.d.ts.map +1 -0
- package/dist/generator/source-text.js +35 -0
- package/dist/generator/source-text.js.map +1 -0
- package/dist/generator/tables.d.ts +5 -0
- package/dist/generator/tables.d.ts.map +1 -0
- package/dist/generator/tables.js +84 -0
- package/dist/generator/tables.js.map +1 -0
- package/dist/generator/types.d.ts +23 -3
- package/dist/generator/types.d.ts.map +1 -1
- package/dist/generator/types.js +291 -1171
- package/dist/generator/types.js.map +1 -1
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp/lib/documentation-provider.d.ts.map +1 -1
- package/dist/mcp/lib/documentation-provider.js +44 -42
- package/dist/mcp/lib/documentation-provider.js.map +1 -1
- package/dist/mcp/lib/generators/feature-generator.d.ts.map +1 -1
- package/dist/mcp/lib/generators/feature-generator.js +124 -73
- package/dist/mcp/lib/generators/feature-generator.js.map +1 -1
- package/dist/mcp/lib/wizards/migration-wizard.js +6 -6
- package/dist/mcp/lib/wizards/migration-wizard.js.map +1 -1
- package/dist/mcp/lib/wizards/wizard-engine.d.ts.map +1 -1
- package/dist/mcp/lib/wizards/wizard-engine.js +3 -2
- package/dist/mcp/lib/wizards/wizard-engine.js.map +1 -1
- package/dist/mcp/server/stack-mcp-server.js +1 -1
- package/dist/migration/fk-renames.d.ts +39 -0
- package/dist/migration/fk-renames.d.ts.map +1 -0
- package/dist/migration/fk-renames.js +79 -0
- package/dist/migration/fk-renames.js.map +1 -0
- package/dist/migration/generators/migration-generator.d.ts +11 -0
- package/dist/migration/generators/migration-generator.d.ts.map +1 -1
- package/dist/migration/generators/migration-generator.js +83 -150
- package/dist/migration/generators/migration-generator.js.map +1 -1
- package/dist/migration/introspectors/prisma-introspector.d.ts.map +1 -1
- package/dist/migration/introspectors/prisma-introspector.js +1 -0
- package/dist/migration/introspectors/prisma-introspector.js.map +1 -1
- package/dist/migration/junction-ids.d.ts +15 -0
- package/dist/migration/junction-ids.d.ts.map +1 -0
- package/dist/migration/junction-ids.js +58 -0
- package/dist/migration/junction-ids.js.map +1 -0
- package/dist/migration/types.d.ts +2 -0
- package/dist/migration/types.d.ts.map +1 -1
- package/package.json +27 -15
- package/dist/generator/node-build.d.ts +0 -53
- package/dist/generator/node-build.d.ts.map +0 -1
- package/dist/generator/node-build.js +0 -280
- package/dist/generator/node-build.js.map +0 -1
- package/dist/generator/prisma.d.ts +0 -30
- package/dist/generator/prisma.d.ts.map +0 -1
- package/dist/generator/prisma.js +0 -422
- package/dist/generator/prisma.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-introspector.js","sourceRoot":"","sources":["../../../src/migration/introspectors/prisma-introspector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,IAAI,MAAM,MAAM,CAAA;AAGvB,MAAM,OAAO,kBAAkB;IAC7B,KAAK,CAAC,UAAU,CACd,GAAW,EACX,UAAU,GAAW,sBAAsB;QAE3C,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;QAEtF,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAA;QACvD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAEnD,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;YACtC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;YAClC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;SACjC,CAAA;IACH,CAAC;IAEO,eAAe,CAAC,MAAc;QACpC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAA;QAC9E,OAAO,KAAK,CAAC,CAA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IAAI,KAAK,CAAC,IAAI,uHAAuH,CAC1J,CAAA;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,yEAAyE;QAEzE,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ContractLiteral, ContractModel } from '@opensaas/stack-core';
|
|
2
|
+
import type { LiveSchema } from './fk-renames.js';
|
|
3
|
+
export interface JunctionIdAddition {
|
|
4
|
+
schema: string;
|
|
5
|
+
table: string;
|
|
6
|
+
strategy: ContractModel['id']['strategy'];
|
|
7
|
+
type: string;
|
|
8
|
+
args?: ContractLiteral[];
|
|
9
|
+
}
|
|
10
|
+
export declare function planJunctionIds(models: ContractModel[], live: LiveSchema, defaultSchema?: string, primaryKeys?: Array<{
|
|
11
|
+
schema: string;
|
|
12
|
+
table: string;
|
|
13
|
+
}>): JunctionIdAddition[];
|
|
14
|
+
export declare function renderJunctionIdSql(additions: JunctionIdAddition[]): string;
|
|
15
|
+
//# sourceMappingURL=junction-ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"junction-ids.d.ts","sourceRoot":"","sources":["../../src/migration/junction-ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAA;IACzC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,eAAe,EAAE,CAAA;CACzB;AASD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,EAAE,UAAU,EAChB,aAAa,SAAW,EACxB,WAAW,GAAE,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAM,GACzD,kBAAkB,EAAE,CAkBtB;AAgCD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAE3E"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const UUID7_EXPRESSION = `encode(set_bit(set_bit(overlay(uuid_send(gen_random_uuid()) placing ` +
|
|
2
|
+
`substring(int8send(floor(extract(epoch from clock_timestamp()) * 1000)::bigint) from 3) ` +
|
|
3
|
+
`from 1 for 6), 52, 1), 53, 1), 'hex')::uuid`;
|
|
4
|
+
const quote = (identifier) => `"${identifier.replaceAll('"', '""')}"`;
|
|
5
|
+
export function planJunctionIds(models, live, defaultSchema = 'public', primaryKeys = []) {
|
|
6
|
+
const additions = [];
|
|
7
|
+
for (const model of models) {
|
|
8
|
+
if (model.id.strategy === 'singleton')
|
|
9
|
+
continue;
|
|
10
|
+
const schema = model.namespace ?? defaultSchema;
|
|
11
|
+
const table = model.table ?? model.name;
|
|
12
|
+
const columns = live.columns.filter((c) => c.schema === schema && c.table === table);
|
|
13
|
+
if (columns.length === 0 || columns.some((c) => c.column === 'id'))
|
|
14
|
+
continue;
|
|
15
|
+
if (primaryKeys.some((k) => k.schema === schema && k.table === table))
|
|
16
|
+
continue;
|
|
17
|
+
additions.push({
|
|
18
|
+
schema,
|
|
19
|
+
table,
|
|
20
|
+
strategy: model.id.strategy,
|
|
21
|
+
type: model.id.type.type,
|
|
22
|
+
args: model.id.type.args,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return additions;
|
|
26
|
+
}
|
|
27
|
+
function backfill(addition) {
|
|
28
|
+
const qualified = `${quote(addition.schema)}.${quote(addition.table)}`;
|
|
29
|
+
const add = (type) => `ALTER TABLE ${qualified} ADD COLUMN "id" ${type};`;
|
|
30
|
+
const fill = (expression) => `UPDATE ${qualified} SET "id" = ${expression};`;
|
|
31
|
+
const notNull = `ALTER TABLE ${qualified} ALTER COLUMN "id" SET NOT NULL;`;
|
|
32
|
+
const primaryKey = `ALTER TABLE ${qualified} ADD PRIMARY KEY ("id");`;
|
|
33
|
+
const columnType = addition.args ? `${addition.type}(${addition.args.join(', ')})` : addition.type;
|
|
34
|
+
switch (addition.strategy) {
|
|
35
|
+
case 'uuid7':
|
|
36
|
+
return [add(columnType), fill(UUID7_EXPRESSION), notNull, primaryKey];
|
|
37
|
+
case 'cuid2':
|
|
38
|
+
return [
|
|
39
|
+
add(columnType),
|
|
40
|
+
fill(`'c' || substr(replace(gen_random_uuid()::text, '-', ''), 1, 23)`),
|
|
41
|
+
notNull,
|
|
42
|
+
primaryKey,
|
|
43
|
+
];
|
|
44
|
+
case 'cuid':
|
|
45
|
+
return [
|
|
46
|
+
add(columnType),
|
|
47
|
+
fill(`'c' || substr(replace(gen_random_uuid()::text, '-', ''), 1, 24)`),
|
|
48
|
+
notNull,
|
|
49
|
+
primaryKey,
|
|
50
|
+
];
|
|
51
|
+
default:
|
|
52
|
+
return [add(addition.type === 'bigint' ? 'bigserial' : 'serial'), primaryKey];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function renderJunctionIdSql(additions) {
|
|
56
|
+
return ['BEGIN;', ...additions.flatMap(backfill), 'COMMIT;'].join('\n');
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=junction-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"junction-ids.js","sourceRoot":"","sources":["../../src/migration/junction-ids.ts"],"names":[],"mappings":"AAWA,MAAM,gBAAgB,GACpB,sEAAsE;IACtE,0FAA0F;IAC1F,6CAA6C,CAAA;AAE/C,MAAM,KAAK,GAAG,CAAC,UAAkB,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAA;AAE7E,MAAM,UAAU,eAAe,CAC7B,MAAuB,EACvB,IAAgB,E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ACZ,KAAK,EAAE,MAAM,CAAA;QACb,MAAM,EAAE,MAAM,EAAE,CAAA;QAChB,UAAU,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;IACD;;;OAGG;IACH,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,EAAE,CAAA;KACf,CAAA;CACF;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CACjD"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensaas/stack-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0-alpha.1",
|
|
4
4
|
"description": "CLI tools for OpenSaas Stack",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.18.0"
|
|
8
|
+
},
|
|
6
9
|
"main": "./dist/index.js",
|
|
7
10
|
"types": "./dist/index.d.ts",
|
|
8
11
|
"exports": {
|
|
@@ -13,10 +16,6 @@
|
|
|
13
16
|
"./generator": {
|
|
14
17
|
"types": "./dist/generator/index.d.ts",
|
|
15
18
|
"default": "./dist/generator/index.js"
|
|
16
|
-
},
|
|
17
|
-
"./generator/prisma": {
|
|
18
|
-
"types": "./dist/generator/prisma.d.ts",
|
|
19
|
-
"default": "./dist/generator/prisma.js"
|
|
20
19
|
}
|
|
21
20
|
},
|
|
22
21
|
"bin": {
|
|
@@ -44,30 +43,43 @@
|
|
|
44
43
|
"url": "https://github.com/OpenSaasAU/stack/issues"
|
|
45
44
|
},
|
|
46
45
|
"dependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
46
|
+
"@electric-sql/pglite": "0.5.8",
|
|
47
|
+
"@electric-sql/pglite-pgvector": "0.0.9",
|
|
48
|
+
"@electric-sql/pglite-socket": "0.2.11",
|
|
49
|
+
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
50
|
+
"@prisma/orm-postgres": "8.0.0-rc.21",
|
|
51
|
+
"@prisma/orm-toolchain": "8.0.0-rc.21",
|
|
49
52
|
"chalk": "^6.0.0",
|
|
50
53
|
"chokidar": "^5.0.0",
|
|
51
54
|
"commander": "^15.0.0",
|
|
52
|
-
"fs-extra": "^11.4.
|
|
53
|
-
"glob": "^
|
|
55
|
+
"fs-extra": "^11.4.1",
|
|
56
|
+
"glob": "^14.0.2",
|
|
54
57
|
"jiti": "^2.7.0",
|
|
55
58
|
"ora": "^9.4.1",
|
|
59
|
+
"pg": "^8.23.1",
|
|
60
|
+
"prisma": "8.0.0-rc.29",
|
|
56
61
|
"prompts": "^2.4.2",
|
|
57
62
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
58
|
-
"zod": "^4.5
|
|
59
|
-
"@opensaas/stack-core": "0.
|
|
63
|
+
"zod": "^4.6.5",
|
|
64
|
+
"@opensaas/stack-core": "0.44.0-alpha.1"
|
|
60
65
|
},
|
|
61
66
|
"devDependencies": {
|
|
67
|
+
"@prisma/orm-extension-pgvector": "8.0.0-rc.21",
|
|
62
68
|
"@types/fs-extra": "^11.0.4",
|
|
63
|
-
"@types/node": "^26.
|
|
69
|
+
"@types/node": "^26.6.3",
|
|
70
|
+
"@types/pg": "^8.23.1",
|
|
64
71
|
"@types/prompts": "^2.4.9",
|
|
65
|
-
"@
|
|
66
|
-
"vitest": "
|
|
72
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
73
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
74
|
+
"vitest": "5.0.5",
|
|
75
|
+
"@opensaas/stack-rag": "0.44.0-alpha.1",
|
|
76
|
+
"@opensaas/stack-storage": "0.44.0-alpha.1",
|
|
77
|
+
"@opensaas/stack-tiptap": "0.44.0-alpha.1"
|
|
67
78
|
},
|
|
68
79
|
"scripts": {
|
|
69
|
-
"build": "tsc",
|
|
80
|
+
"build": "tsc && node ../../scripts/lib/write-build-hash-cli.mjs",
|
|
70
81
|
"dev": "tsc --watch",
|
|
82
|
+
"typecheck": "tsc -p tsconfig.test.json",
|
|
71
83
|
"test": "vitest",
|
|
72
84
|
"test:ui": "vitest --ui",
|
|
73
85
|
"test:coverage": "vitest --coverage",
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export interface BuildNodeBundleOptions {
|
|
2
|
-
/**
|
|
3
|
-
* Absolute path to the resolved `.opensaas` bundle directory (the one holding
|
|
4
|
-
* `context.ts`, `prisma-client/`, etc.).
|
|
5
|
-
*/
|
|
6
|
-
opensaasDir: string;
|
|
7
|
-
/**
|
|
8
|
-
* Absolute path to the project's `opensaas.config.ts`. Compiled in as a
|
|
9
|
-
* sibling of the entry so the Node build is self-contained.
|
|
10
|
-
*/
|
|
11
|
-
configPath: string;
|
|
12
|
-
}
|
|
13
|
-
export interface BuildNodeBundleResult {
|
|
14
|
-
/** Absolute path to the emitted `<opensaasDir>/dist/` directory. */
|
|
15
|
-
distDir: string;
|
|
16
|
-
/** Absolute path to the compiled entry, `<opensaasDir>/dist/context.js`. */
|
|
17
|
-
entry: string;
|
|
18
|
-
/**
|
|
19
|
-
* Formatted `tsc` error lines surfaced during the compile (non-fatal; emit
|
|
20
|
-
* still proceeds since the Node build never sets `--noEmitOnError`).
|
|
21
|
-
*/
|
|
22
|
-
diagnostics: readonly string[];
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Rewrite any relative `../`-rooted `opensaas.config` import (of any depth) in a
|
|
26
|
-
* source string to the sibling `./opensaas.config.ts`, preserving the original
|
|
27
|
-
* quote style, so the compiled output's config import resolves inside `dist/`.
|
|
28
|
-
* Exported for unit testing of the any-depth rewrite.
|
|
29
|
-
*/
|
|
30
|
-
export declare function rewriteConfigImport(source: string): string;
|
|
31
|
-
/**
|
|
32
|
-
* Return the first relative config import that still escapes the staging/`dist`
|
|
33
|
-
* root (one-or-more `../` segments before `opensaas.config`), or `undefined` if
|
|
34
|
-
* none remains. Exported so the silent-failure guard is unit-testable.
|
|
35
|
-
*/
|
|
36
|
-
export declare function findEscapingConfigImport(source: string): string | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* Compile the Generated bundle to a plain-Node-loadable ESM build under
|
|
39
|
-
* `<opensaasDir>/dist/` (ADR-0011). Additive: the caller only invokes this when
|
|
40
|
-
* `output.buildTarget === 'node'`, and it never touches the default `.ts` form.
|
|
41
|
-
*
|
|
42
|
-
* Assumes the `.ts` bundle and the Prisma client subtree
|
|
43
|
-
* (`<opensaasDir>/prisma-client/**`) already exist on disk — i.e. it runs after
|
|
44
|
-
* the bundle is written and after `prisma generate`.
|
|
45
|
-
*/
|
|
46
|
-
export declare function buildNodeBundle(options: BuildNodeBundleOptions): BuildNodeBundleResult;
|
|
47
|
-
/**
|
|
48
|
-
* Format Node-build diagnostics into a short, human-readable list. The Node
|
|
49
|
-
* build is best-effort (`tsc` emits despite type errors here), so these are
|
|
50
|
-
* surfaced as a warning rather than a failure.
|
|
51
|
-
*/
|
|
52
|
-
export declare function formatNodeBuildDiagnostics(diagnostics: readonly string[]): string;
|
|
53
|
-
//# sourceMappingURL=node-build.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-build.d.ts","sourceRoot":"","sources":["../../src/generator/node-build.ts"],"names":[],"mappings":"AA+GA,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAA;IACf,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CAC/B;AAmBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI1D;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE3E;AAiDD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,qBAAqB,CAyEtF;AA4BD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEjF"}
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import { execFileSync } from 'child_process';
|
|
4
|
-
import { createRequire } from 'module';
|
|
5
|
-
/**
|
|
6
|
-
* Absolute path to this package's own pinned native TypeScript 7 `tsc`
|
|
7
|
-
* binary, resolved via the `@typescript/native` dependency (an alias for the
|
|
8
|
-
* real `typescript` package — the plain `typescript` dependency is itself
|
|
9
|
-
* aliased to the `@typescript/typescript6` compatibility shim so this
|
|
10
|
-
* package's own code/tests can still use the classic Program API) rather
|
|
11
|
-
* than shelled out to via `npx`. The Node build must always compile with the
|
|
12
|
-
* version `@opensaas/stack-cli` ships, not whatever (if anything) happens to
|
|
13
|
-
* be on `PATH`/installed in the target project.
|
|
14
|
-
*/
|
|
15
|
-
const tscBin = path.join(path.dirname(createRequire(import.meta.url).resolve('@typescript/native/package.json')), 'bin', 'tsc');
|
|
16
|
-
/**
|
|
17
|
-
* The **Node build** (ADR-0011): an opt-in, plain-Node-loadable form of the
|
|
18
|
-
* Generated bundle, compiled to `<opensaasDir>/dist/` alongside the default
|
|
19
|
-
* `.ts` bundler form (ADR-0008).
|
|
20
|
-
*
|
|
21
|
-
* Why this exists
|
|
22
|
-
* ---------------
|
|
23
|
-
* The default `.opensaas/` bundle ships as TypeScript with explicit `.ts`
|
|
24
|
-
* import extensions so the host's bundler traces and transpiles it. That form
|
|
25
|
-
* cannot execute under plain Node (`Cannot use import statement outside a
|
|
26
|
-
* module`, and `.ts` specifiers don't resolve). A live module that must run in
|
|
27
|
-
* BOTH a bundled and a bundler-less runtime — better-auth's Prisma adapter,
|
|
28
|
-
* imported by the Next server AND by a Playwright e2e helper / build-time
|
|
29
|
-
* script — therefore has no Node-loadable entry to point at. Setting
|
|
30
|
-
* `output: { buildTarget: 'node' }` emits one.
|
|
31
|
-
*
|
|
32
|
-
* What it emits
|
|
33
|
-
* -------------
|
|
34
|
-
* A compiled ESM build under `<opensaasDir>/dist/`:
|
|
35
|
-
* - `context.js` — the compiled entry (mirrors `<opensaasDir>/context.ts`)
|
|
36
|
-
* - `prisma-client/**` — the compiled Prisma client subtree
|
|
37
|
-
* - `opensaas.config.js` — the project config, compiled in as a sibling of
|
|
38
|
-
* `context.js` so the entry's config import resolves without reaching
|
|
39
|
-
* outside `dist/`
|
|
40
|
-
* - matching `.d.ts` declarations
|
|
41
|
-
* - `package.json` containing exactly `{"type":"module"}` so the emitted
|
|
42
|
-
* `.js` are unambiguous ESM regardless of the host package's `type`
|
|
43
|
-
*
|
|
44
|
-
* How the layout is achieved
|
|
45
|
-
* --------------------------
|
|
46
|
-
* The on-disk `context.ts` imports the project config via
|
|
47
|
-
* `../opensaas.config.ts` — one level ABOVE `<opensaasDir>`, outside the compile
|
|
48
|
-
* root. To keep the compiled entry at `<opensaasDir>/dist/context.js` (per
|
|
49
|
-
* ADR-0011) with a config import that resolves inside `dist/`, we stage the
|
|
50
|
-
* bundle plus a copy of `opensaas.config.ts` into a hidden source directory
|
|
51
|
-
* inside the bundle, rewrite the bundle's relative `opensaas.config` imports
|
|
52
|
-
* (of any `../` depth) to the sibling `./opensaas.config.ts`, and compile that
|
|
53
|
-
* staging root to
|
|
54
|
-
* `<opensaasDir>/dist/`. Staging inside the project (rather than a temp dir)
|
|
55
|
-
* keeps `node_modules` resolution intact so `@opensaas/*` and `@prisma/*`
|
|
56
|
-
* resolve during the type-check pass. The staging directory is removed after
|
|
57
|
-
* the emit.
|
|
58
|
-
*
|
|
59
|
-
* `rewriteRelativeImportExtensions` turns the bundle's `.ts`-extension imports
|
|
60
|
-
* into runnable `.js` specifiers; `skipLibCheck` + `noEmitOnError: false` keep
|
|
61
|
-
* third-party `.d.ts` noise (and the host's `@/*` path alias in the config,
|
|
62
|
-
* which is type-only and elided from JS) from blocking emit.
|
|
63
|
-
*/
|
|
64
|
-
/** Bundle files copied into the staging root before compilation. */
|
|
65
|
-
const STAGED_BUNDLE_FILES = ['context.ts', 'types.ts', 'lists.ts', 'plugin-types.ts'];
|
|
66
|
-
/** The compiled Prisma client subtree, copied wholesale into the staging root. */
|
|
67
|
-
const PRISMA_CLIENT_DIR = 'prisma-client';
|
|
68
|
-
/** Name of the project config file copied into the staging root. */
|
|
69
|
-
const CONFIG_FILENAME = 'opensaas.config.ts';
|
|
70
|
-
/** Hidden staging directory created inside the bundle during compilation. */
|
|
71
|
-
const STAGING_DIRNAME = '.node-build';
|
|
72
|
-
/** Output directory name for the compiled Node build. */
|
|
73
|
-
const DIST_DIRNAME = 'dist';
|
|
74
|
-
/**
|
|
75
|
-
* Matches a relative config specifier of ANY depth — one-or-more `../` segments
|
|
76
|
-
* followed by `opensaas.config` (with or without a `.ts`/`.js` extension), in
|
|
77
|
-
* either quote style. The generator emits that specifier from a configurable
|
|
78
|
-
* source (`configImport ?? '../opensaas.config'` in `context.ts`), so a
|
|
79
|
-
* non-default project layout (e.g. a deeper `../../opensaas.config.ts`) would
|
|
80
|
-
* otherwise make a literal-string rewrite silently no-op. Capture group 1
|
|
81
|
-
* preserves the quote style.
|
|
82
|
-
*/
|
|
83
|
-
const CONFIG_IMPORT_RE = /(['"])(?:\.\.\/)+opensaas\.config(?:\.ts|\.js)?\1/g;
|
|
84
|
-
/**
|
|
85
|
-
* The sibling specifier the config import is rewritten to so the compiled entry
|
|
86
|
-
* imports the config from inside `dist/`. Mirrors the source `.ts` extension
|
|
87
|
-
* (TypeScript's `rewriteRelativeImportExtensions` turns it into `.js` on emit).
|
|
88
|
-
*/
|
|
89
|
-
const CONFIG_IMPORT_TO = './opensaas.config.ts';
|
|
90
|
-
/**
|
|
91
|
-
* Detects a relative config import that still escapes the staging/`dist` root
|
|
92
|
-
* after the rewrite — one-or-more `../` segments followed by `opensaas.config`.
|
|
93
|
-
* Non-global so it can be used with `String.prototype.match` to capture the
|
|
94
|
-
* offending specifier for the error message.
|
|
95
|
-
*/
|
|
96
|
-
const ESCAPING_CONFIG_IMPORT_RE = /(['"])(?:\.\.\/)+opensaas\.config(?:\.ts|\.js)?\1/;
|
|
97
|
-
/**
|
|
98
|
-
* Recursively copy a directory tree. Used to stage the `prisma-client/`
|
|
99
|
-
* subtree, which is many small files.
|
|
100
|
-
*/
|
|
101
|
-
function copyDir(src, dest) {
|
|
102
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
103
|
-
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
104
|
-
const srcPath = path.join(src, entry.name);
|
|
105
|
-
const destPath = path.join(dest, entry.name);
|
|
106
|
-
if (entry.isDirectory()) {
|
|
107
|
-
copyDir(srcPath, destPath);
|
|
108
|
-
}
|
|
109
|
-
else if (entry.isFile()) {
|
|
110
|
-
fs.copyFileSync(srcPath, destPath);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Rewrite any relative `../`-rooted `opensaas.config` import (of any depth) in a
|
|
116
|
-
* source string to the sibling `./opensaas.config.ts`, preserving the original
|
|
117
|
-
* quote style, so the compiled output's config import resolves inside `dist/`.
|
|
118
|
-
* Exported for unit testing of the any-depth rewrite.
|
|
119
|
-
*/
|
|
120
|
-
export function rewriteConfigImport(source) {
|
|
121
|
-
return source.replace(CONFIG_IMPORT_RE, (_match, quote) => {
|
|
122
|
-
return `${quote}${CONFIG_IMPORT_TO}${quote}`;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Return the first relative config import that still escapes the staging/`dist`
|
|
127
|
-
* root (one-or-more `../` segments before `opensaas.config`), or `undefined` if
|
|
128
|
-
* none remains. Exported so the silent-failure guard is unit-testable.
|
|
129
|
-
*/
|
|
130
|
-
export function findEscapingConfigImport(source) {
|
|
131
|
-
return source.match(ESCAPING_CONFIG_IMPORT_RE)?.[0];
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Copy a bundle source file into the staging root, rewriting the config import
|
|
135
|
-
* to the sibling `./opensaas.config.ts`.
|
|
136
|
-
*/
|
|
137
|
-
function stageBundleFile(src, dest) {
|
|
138
|
-
const source = fs.readFileSync(src, 'utf-8');
|
|
139
|
-
fs.writeFileSync(dest, rewriteConfigImport(source));
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* The `tsconfig.json` compiler options for the Node build, as plain JSON
|
|
143
|
-
* (TypeScript 7 dropped the synchronous `ts.createProgram`/`Program#emit()`
|
|
144
|
-
* API from the `typescript` package's public surface, so the Node build now
|
|
145
|
-
* shells out to the `tsc` CLI against a generated config instead). ESM output
|
|
146
|
-
* (`esnext` + `bundler`) with the import-extension rewrite, declaration emit,
|
|
147
|
-
* and the lenient settings that keep third-party `.d.ts` noise from blocking
|
|
148
|
-
* the emit on an opt-in path.
|
|
149
|
-
*/
|
|
150
|
-
function nodeBuildCompilerOptions(outDir) {
|
|
151
|
-
return {
|
|
152
|
-
// Rewrites the bundle's explicit `.ts`-extension imports (e.g.
|
|
153
|
-
// `./prisma-client/client.ts`) to runnable `.js` specifiers.
|
|
154
|
-
rewriteRelativeImportExtensions: true,
|
|
155
|
-
// The on-disk bundle imports `.ts` extensions; permit reading them.
|
|
156
|
-
allowImportingTsExtensions: true,
|
|
157
|
-
// Emit `.d.ts` so the Node build is a fully typed import target.
|
|
158
|
-
declaration: true,
|
|
159
|
-
// ESM output. `bundler` resolution permits the `.ts`-extension imports while
|
|
160
|
-
// `esnext` keeps `import`/`export` syntax (the `{"type":"module"}` marker
|
|
161
|
-
// written into `dist/` makes the emitted `.js` unambiguous ESM).
|
|
162
|
-
module: 'esnext',
|
|
163
|
-
moduleResolution: 'bundler',
|
|
164
|
-
target: 'es2022',
|
|
165
|
-
rootDir: '.',
|
|
166
|
-
outDir,
|
|
167
|
-
// Third-party `.d.ts` (e.g. Prisma's) must not fail the type-check pass.
|
|
168
|
-
skipLibCheck: true,
|
|
169
|
-
// A production auth path must still emit even if a stray type error remains
|
|
170
|
-
// (the bundle itself type-checks clean; this guards against host-config
|
|
171
|
-
// noise like the `@/*` path alias, which is type-only and elided from JS).
|
|
172
|
-
// `tsc` already defaults to emitting on type error when `--noEmitOnError`
|
|
173
|
-
// is omitted, so no explicit option is needed here.
|
|
174
|
-
esModuleInterop: true,
|
|
175
|
-
forceConsistentCasingInFileNames: true,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Compile the Generated bundle to a plain-Node-loadable ESM build under
|
|
180
|
-
* `<opensaasDir>/dist/` (ADR-0011). Additive: the caller only invokes this when
|
|
181
|
-
* `output.buildTarget === 'node'`, and it never touches the default `.ts` form.
|
|
182
|
-
*
|
|
183
|
-
* Assumes the `.ts` bundle and the Prisma client subtree
|
|
184
|
-
* (`<opensaasDir>/prisma-client/**`) already exist on disk — i.e. it runs after
|
|
185
|
-
* the bundle is written and after `prisma generate`.
|
|
186
|
-
*/
|
|
187
|
-
export function buildNodeBundle(options) {
|
|
188
|
-
const { opensaasDir, configPath } = options;
|
|
189
|
-
const stagingDir = path.join(opensaasDir, STAGING_DIRNAME);
|
|
190
|
-
const distDir = path.join(opensaasDir, DIST_DIRNAME);
|
|
191
|
-
// Clean any prior staging/dist so re-runs are deterministic.
|
|
192
|
-
fs.rmSync(stagingDir, { recursive: true, force: true });
|
|
193
|
-
fs.rmSync(distDir, { recursive: true, force: true });
|
|
194
|
-
fs.mkdirSync(stagingDir, { recursive: true });
|
|
195
|
-
try {
|
|
196
|
-
// Stage the bundle source files, rewriting the config import to a sibling.
|
|
197
|
-
for (const file of STAGED_BUNDLE_FILES) {
|
|
198
|
-
const src = path.join(opensaasDir, file);
|
|
199
|
-
if (!fs.existsSync(src))
|
|
200
|
-
continue;
|
|
201
|
-
const dest = path.join(stagingDir, file);
|
|
202
|
-
stageBundleFile(src, dest);
|
|
203
|
-
// Silent-failure guard (`noEmitOnError: false` lets TS emit even when a
|
|
204
|
-
// config import escapes `dist/`): if a staged file STILL contains a
|
|
205
|
-
// `../`-rooted `opensaas.config` import after the rewrite, the compiled
|
|
206
|
-
// entry's config import would escape `dist/` and fail under plain Node
|
|
207
|
-
// with no error surfaced. Fail loudly instead of emitting a broken build.
|
|
208
|
-
const escaping = findEscapingConfigImport(fs.readFileSync(dest, 'utf-8'));
|
|
209
|
-
if (escaping) {
|
|
210
|
-
throw new Error(`Node build: staged bundle file "${file}" still imports the config ` +
|
|
211
|
-
`via a relative path that escapes dist/ (${escaping}). The config ` +
|
|
212
|
-
`import must be rewritten to a sibling of the entry. This is a ` +
|
|
213
|
-
`silent-failure guard — compiling it would emit a Node build whose ` +
|
|
214
|
-
`config import resolves outside dist/ and fails under plain Node.`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
// Stage the compiled Prisma client subtree as-is.
|
|
218
|
-
const prismaClientSrc = path.join(opensaasDir, PRISMA_CLIENT_DIR);
|
|
219
|
-
if (fs.existsSync(prismaClientSrc)) {
|
|
220
|
-
copyDir(prismaClientSrc, path.join(stagingDir, PRISMA_CLIENT_DIR));
|
|
221
|
-
}
|
|
222
|
-
// Stage the project config as a sibling of the entry.
|
|
223
|
-
fs.copyFileSync(configPath, path.join(stagingDir, CONFIG_FILENAME));
|
|
224
|
-
// Write a throwaway tsconfig.json for the staged compile and shell out to
|
|
225
|
-
// `tsc` (see `nodeBuildCompilerOptions` for why: TS 7 no longer exposes a
|
|
226
|
-
// synchronous, emit-to-disk Program API from the `typescript` package).
|
|
227
|
-
const tsconfigPath = path.join(stagingDir, 'tsconfig.json');
|
|
228
|
-
fs.writeFileSync(tsconfigPath, JSON.stringify({
|
|
229
|
-
compilerOptions: nodeBuildCompilerOptions(distDir),
|
|
230
|
-
include: ['**/*.ts'],
|
|
231
|
-
}, null, 2));
|
|
232
|
-
const diagnostics = runTsc(tsconfigPath, stagingDir);
|
|
233
|
-
// Write the ESM marker so the emitted `.js` are unambiguous ESM.
|
|
234
|
-
fs.writeFileSync(path.join(distDir, 'package.json'), '{"type":"module"}\n');
|
|
235
|
-
return {
|
|
236
|
-
distDir,
|
|
237
|
-
entry: path.join(distDir, 'context.js'),
|
|
238
|
-
diagnostics,
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
finally {
|
|
242
|
-
// Always remove the staging directory, even if the compile threw.
|
|
243
|
-
fs.rmSync(stagingDir, { recursive: true, force: true });
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Run `tsc -p <tsconfigPath>` and return its reported error lines. `tsc`
|
|
248
|
-
* emits on type error by default (no `--noEmitOnError` is passed), so a
|
|
249
|
-
* non-zero exit here means "compiled with diagnostics", not "failed to
|
|
250
|
-
* compile" — `execFileSync` throws on that exit code, so both the success and
|
|
251
|
-
* failure paths are handled to recover the captured stdout either way.
|
|
252
|
-
*/
|
|
253
|
-
function runTsc(tsconfigPath, cwd) {
|
|
254
|
-
let stdout;
|
|
255
|
-
try {
|
|
256
|
-
stdout = execFileSync(process.execPath, [tscBin, '-p', tsconfigPath, '--pretty', 'false'], {
|
|
257
|
-
cwd,
|
|
258
|
-
encoding: 'utf-8',
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
catch (err) {
|
|
262
|
-
const execErr = err;
|
|
263
|
-
stdout = execErr.stdout ?? '';
|
|
264
|
-
}
|
|
265
|
-
// Non-pretty `tsc` output is one diagnostic per line, e.g.
|
|
266
|
-
// `src/context.ts(12,3): error TS2304: Cannot find name 'console'.`
|
|
267
|
-
return stdout
|
|
268
|
-
.split('\n')
|
|
269
|
-
.map((line) => line.trim())
|
|
270
|
-
.filter((line) => /: error TS\d+:/.test(line));
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Format Node-build diagnostics into a short, human-readable list. The Node
|
|
274
|
-
* build is best-effort (`tsc` emits despite type errors here), so these are
|
|
275
|
-
* surfaced as a warning rather than a failure.
|
|
276
|
-
*/
|
|
277
|
-
export function formatNodeBuildDiagnostics(diagnostics) {
|
|
278
|
-
return diagnostics.join('\n');
|
|
279
|
-
}
|
|
280
|
-
//# sourceMappingURL=node-build.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-build.js","sourceRoot":"","sources":["../../src/generator/node-build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAEtC;;;;;;;;;GASG;AACH,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CACtB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC,EACvF,KAAK,EACL,KAAK,CACN,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,oEAAoE;AACpE,MAAM,mBAAmB,GAAG,CAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,CAAU,CAAA;AAE9F,kFAAkF;AAClF,MAAM,iBAAiB,GAAG,eAAe,CAAA;AAEzC,oEAAoE;AACpE,MAAM,eAAe,GAAG,oBAAoB,CAAA;AAE5C,6EAA6E;AAC7E,MAAM,eAAe,GAAG,aAAa,CAAA;AAErC,yDAAyD;AACzD,MAAM,YAAY,GAAG,MAAM,CAAA;AAE3B;;;;;;;;GAQG;AACH,M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AoE;IACpE,OAAO,MAAM;SACV,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAA8B;IACvE,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { OpenSaasConfig, ListConfig, DatabaseConfig } from '@opensaas/stack-core';
|
|
2
|
-
import type { TypeInfo } from '@opensaas/stack-core/extend';
|
|
3
|
-
/**
|
|
4
|
-
* Decide which auto-timestamp columns the generator should inject into a list's model.
|
|
5
|
-
*
|
|
6
|
-
* Auto-timestamps are OFF by default (matching Keystone 6, which never adds them
|
|
7
|
-
* automatically — see ADR-0004). They are enabled globally via `db: { timestamps: true }`
|
|
8
|
-
* and can be overridden per-list via the list's `db.timestamps` option (which takes
|
|
9
|
-
* precedence over the global setting).
|
|
10
|
-
*
|
|
11
|
-
* When timestamps resolve to enabled, the auto column is skipped for any timestamp field
|
|
12
|
-
* the list already declares itself (`createdAt`/`updatedAt`), so Prisma never sees a
|
|
13
|
-
* duplicate field (`P1012`).
|
|
14
|
-
*
|
|
15
|
-
* @returns flags indicating whether to emit each auto column.
|
|
16
|
-
*/
|
|
17
|
-
export declare function resolveListTimestamps(listConfig: ListConfig<TypeInfo>, dbConfig: DatabaseConfig): {
|
|
18
|
-
createdAt: boolean;
|
|
19
|
-
updatedAt: boolean;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* @param prismaClientOutput - Module specifier for the patched Prisma client's
|
|
23
|
-
* `generator { output }`, relative to the schema file's directory. Defaults to
|
|
24
|
-
* the legacy `../<opensaasPath>/prisma-client` so existing projects are
|
|
25
|
-
* unaffected; the output-path resolver supplies a recomputed value when the
|
|
26
|
-
* schema or `.opensaas` dir is relocated via the `output` config block.
|
|
27
|
-
*/
|
|
28
|
-
export declare function generatePrismaSchema(config: OpenSaasConfig, prismaClientOutput?: string): string;
|
|
29
|
-
export declare function writePrismaSchema(config: OpenSaasConfig, outputPath: string, prismaClientOutput?: string): void;
|
|
30
|
-
//# sourceMappingURL=prisma.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/generator/prisma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,cAAc,EAGf,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAK3D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAGnC,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,EAChC,QAAQ,EAAE,cAAc,GACvB;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAgB5C;AAqPD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,CAgShG;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,EAClB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,IAAI,CASN"}
|