@opensaas/stack-cli 0.20.1 → 0.22.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/README.md +1 -1
- package/dist/commands/generate.d.ts +8 -0
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +53 -13
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/migrate.d.ts +25 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +54 -3
- package/dist/commands/migrate.js.map +1 -1
- package/dist/generator/context.d.ts +5 -2
- package/dist/generator/context.d.ts.map +1 -1
- package/dist/generator/context.js +14 -8
- package/dist/generator/context.js.map +1 -1
- package/dist/generator/index.d.ts +2 -0
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +1 -0
- package/dist/generator/index.js.map +1 -1
- package/dist/generator/lists.d.ts.map +1 -1
- package/dist/generator/lists.js +16 -5
- package/dist/generator/lists.js.map +1 -1
- package/dist/generator/output-paths.d.ts +104 -0
- package/dist/generator/output-paths.d.ts.map +1 -0
- package/dist/generator/output-paths.js +94 -0
- package/dist/generator/output-paths.js.map +1 -0
- package/dist/generator/prisma-config.d.ts +20 -4
- package/dist/generator/prisma-config.d.ts.map +1 -1
- package/dist/generator/prisma-config.js +35 -8
- package/dist/generator/prisma-config.js.map +1 -1
- package/dist/generator/prisma-extensions.d.ts +5 -2
- package/dist/generator/prisma-extensions.d.ts.map +1 -1
- package/dist/generator/prisma-extensions.js +12 -4
- package/dist/generator/prisma-extensions.js.map +1 -1
- package/dist/generator/prisma.d.ts +31 -3
- package/dist/generator/prisma.d.ts.map +1 -1
- package/dist/generator/prisma.js +174 -387
- package/dist/generator/prisma.js.map +1 -1
- package/dist/generator/types.d.ts.map +1 -1
- package/dist/generator/types.js +34 -8
- package/dist/generator/types.js.map +1 -1
- package/dist/mcp/lib/documentation-provider.d.ts.map +1 -1
- package/dist/mcp/lib/documentation-provider.js +36 -39
- package/dist/mcp/lib/documentation-provider.js.map +1 -1
- package/dist/mcp/lib/wizards/migration-wizard.d.ts.map +1 -1
- package/dist/mcp/lib/wizards/migration-wizard.js +2 -1
- package/dist/mcp/lib/wizards/migration-wizard.js.map +1 -1
- package/dist/migration/generators/migration-generator.d.ts.map +1 -1
- package/dist/migration/generators/migration-generator.js +6 -4
- package/dist/migration/generators/migration-generator.js.map +1 -1
- package/dist/migration/introspectors/keystone-introspector.d.ts.map +1 -1
- package/dist/migration/introspectors/keystone-introspector.js +6 -1
- package/dist/migration/introspectors/keystone-introspector.js.map +1 -1
- package/dist/migration/introspectors/prisma-introspector.d.ts.map +1 -1
- package/dist/migration/introspectors/prisma-introspector.js +4 -1
- package/dist/migration/introspectors/prisma-introspector.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { OutputConfig } from '@opensaas/stack-core';
|
|
2
|
+
/**
|
|
3
|
+
* Default output locations, relative to the project root. Keeping these here
|
|
4
|
+
* (rather than scattering string literals across the generator) means the
|
|
5
|
+
* "no `output` block" path is byte-identical to the historical behaviour.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_PRISMA_SCHEMA = "prisma/schema.prisma";
|
|
8
|
+
export declare const DEFAULT_OPENSAAS_DIR = ".opensaas";
|
|
9
|
+
/**
|
|
10
|
+
* The five files written into the `.opensaas` bundle directory, plus the
|
|
11
|
+
* sub-path of the patched Prisma client. These names are not configurable —
|
|
12
|
+
* only the directory that holds them moves.
|
|
13
|
+
*/
|
|
14
|
+
export declare const OPENSAAS_FILES: {
|
|
15
|
+
readonly types: "types.ts";
|
|
16
|
+
readonly lists: "lists.ts";
|
|
17
|
+
readonly context: "context.ts";
|
|
18
|
+
readonly pluginTypes: "plugin-types.ts";
|
|
19
|
+
readonly prismaExtensions: "prisma-extensions.ts";
|
|
20
|
+
readonly prismaClient: "prisma-client";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Absolute write paths for every file the generator emits.
|
|
24
|
+
*/
|
|
25
|
+
export interface ResolvedWritePaths {
|
|
26
|
+
/** Absolute path to the Prisma schema file. */
|
|
27
|
+
prismaSchema: string;
|
|
28
|
+
/** Absolute path to the top-level `prisma.config.ts` (never relocated). */
|
|
29
|
+
prismaConfig: string;
|
|
30
|
+
/** Absolute path to the resolved `.opensaas` bundle directory. */
|
|
31
|
+
opensaasDir: string;
|
|
32
|
+
/** Absolute path to `<opensaasDir>/types.ts`. */
|
|
33
|
+
types: string;
|
|
34
|
+
/** Absolute path to `<opensaasDir>/lists.ts`. */
|
|
35
|
+
lists: string;
|
|
36
|
+
/** Absolute path to `<opensaasDir>/context.ts`. */
|
|
37
|
+
context: string;
|
|
38
|
+
/** Absolute path to `<opensaasDir>/plugin-types.ts`. */
|
|
39
|
+
pluginTypes: string;
|
|
40
|
+
/** Absolute path to `<opensaasDir>/prisma-extensions.ts`. */
|
|
41
|
+
prismaExtensions: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Relative cross-references baked into the generated files. These follow the
|
|
45
|
+
* configured locations so the emitted code resolves regardless of where the
|
|
46
|
+
* schema and bundle live.
|
|
47
|
+
*/
|
|
48
|
+
export interface ResolvedCrossReferences {
|
|
49
|
+
/**
|
|
50
|
+
* Module specifier for `prisma.config.ts`'s `schema` field — the schema
|
|
51
|
+
* *directory* relative to the project root (Prisma resolves a directory or a
|
|
52
|
+
* `.prisma` file). POSIX separators so the value is stable across platforms.
|
|
53
|
+
* @example "prisma" | "prisma-opensaas"
|
|
54
|
+
*/
|
|
55
|
+
prismaConfigSchema: string;
|
|
56
|
+
/**
|
|
57
|
+
* Module specifier for the Prisma client `generator { output }` block — the
|
|
58
|
+
* patched client directory relative to the schema *file's* directory.
|
|
59
|
+
* @example "../.opensaas/prisma-client"
|
|
60
|
+
*/
|
|
61
|
+
prismaClientOutput: string;
|
|
62
|
+
/**
|
|
63
|
+
* Module specifier for importing `opensaas.config` from inside the bundle
|
|
64
|
+
* (used by `context.ts` and `prisma-extensions.ts`) — relative to the
|
|
65
|
+
* `.opensaas` directory.
|
|
66
|
+
* @example "../opensaas.config"
|
|
67
|
+
*/
|
|
68
|
+
configImport: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Resolved output paths plus the cross-references the generated files embed.
|
|
72
|
+
*/
|
|
73
|
+
export interface ResolvedOutputPaths {
|
|
74
|
+
paths: ResolvedWritePaths;
|
|
75
|
+
crossReferences: ResolvedCrossReferences;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Pure resolver: given the project root and the user's `output` config, compute
|
|
79
|
+
* where every generated file is written and the relative cross-references that
|
|
80
|
+
* tie them together. Performs no I/O.
|
|
81
|
+
*
|
|
82
|
+
* `.opensaas` bundle directory precedence (highest first):
|
|
83
|
+
* 1. `output.opensaasDir` (the new `output` block)
|
|
84
|
+
* 2. `opensaasPathFallback` — the pre-existing top-level `config.opensaasPath`
|
|
85
|
+
* option, preserved so setting it alone still relocates the bundle through
|
|
86
|
+
* the CLI exactly as before
|
|
87
|
+
* 3. the default `.opensaas`
|
|
88
|
+
*
|
|
89
|
+
* Cross-reference computation:
|
|
90
|
+
* - `prismaConfigSchema` — the schema *directory* relative to the project root,
|
|
91
|
+
* so the top-level `prisma.config.ts` points the Prisma CLI at the relocated
|
|
92
|
+
* schema.
|
|
93
|
+
* - `prismaClientOutput` — the patched client directory relative to the schema
|
|
94
|
+
* *file's* directory, since Prisma's `generator { output }` is resolved from
|
|
95
|
+
* the schema file.
|
|
96
|
+
* - `configImport` — `opensaas.config` relative to the `.opensaas` directory,
|
|
97
|
+
* since `context.ts`/`prisma-extensions.ts` live inside the bundle and import
|
|
98
|
+
* the project's config by relative path.
|
|
99
|
+
*
|
|
100
|
+
* @param opensaasPathFallback - The pre-existing `config.opensaasPath` value,
|
|
101
|
+
* used as the bundle directory when no `output.opensaasDir` is set.
|
|
102
|
+
*/
|
|
103
|
+
export declare function resolveOutputPaths(cwd: string, output?: OutputConfig, opensaasPathFallback?: string): ResolvedOutputPaths;
|
|
104
|
+
//# sourceMappingURL=output-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-paths.d.ts","sourceRoot":"","sources":["../../src/generator/output-paths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,yBAAyB,CAAA;AAC3D,eAAO,MAAM,oBAAoB,cAAc,CAAA;AAE/C;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;;CAOjB,CAAA;AAEV;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAA;IACpB,2EAA2E;IAC3E,YAAY,EAAE,MAAM,CAAA;IACpB,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAA;IACnB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAA;IACb,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAA;IACb,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAA;IACf,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAA;IACnB,6DAA6D;IAC7D,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,CAAA;IAC1B;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,CAAA;IAC1B;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,kBAAkB,CAAA;IACzB,eAAe,EAAE,uBAAuB,CAAA;CACzC;AAoBD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,YAAY,EACrB,oBAAoB,CAAC,EAAE,MAAM,GAC5B,mBAAmB,CAmCrB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
/**
|
|
3
|
+
* Default output locations, relative to the project root. Keeping these here
|
|
4
|
+
* (rather than scattering string literals across the generator) means the
|
|
5
|
+
* "no `output` block" path is byte-identical to the historical behaviour.
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_PRISMA_SCHEMA = 'prisma/schema.prisma';
|
|
8
|
+
export const DEFAULT_OPENSAAS_DIR = '.opensaas';
|
|
9
|
+
/**
|
|
10
|
+
* The five files written into the `.opensaas` bundle directory, plus the
|
|
11
|
+
* sub-path of the patched Prisma client. These names are not configurable —
|
|
12
|
+
* only the directory that holds them moves.
|
|
13
|
+
*/
|
|
14
|
+
export const OPENSAAS_FILES = {
|
|
15
|
+
types: 'types.ts',
|
|
16
|
+
lists: 'lists.ts',
|
|
17
|
+
context: 'context.ts',
|
|
18
|
+
pluginTypes: 'plugin-types.ts',
|
|
19
|
+
prismaExtensions: 'prisma-extensions.ts',
|
|
20
|
+
prismaClient: 'prisma-client',
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Convert a (possibly Windows) relative path into a POSIX module specifier and
|
|
24
|
+
* ensure it stays explicitly relative where a bare segment would otherwise be
|
|
25
|
+
* read as a bare module specifier.
|
|
26
|
+
*/
|
|
27
|
+
function toModuleSpecifier(relative, { allowBare }) {
|
|
28
|
+
const posix = relative.split(path.sep).join('/');
|
|
29
|
+
if (allowBare) {
|
|
30
|
+
// A directory reference for prisma.config's `schema` field — bare is fine,
|
|
31
|
+
// but a schema at the project root yields an empty relative path, which
|
|
32
|
+
// Prisma would reject; emit `.` instead.
|
|
33
|
+
return posix === '' ? '.' : posix;
|
|
34
|
+
}
|
|
35
|
+
// An import specifier — must be explicitly relative so it isn't treated as a
|
|
36
|
+
// node_modules package.
|
|
37
|
+
return posix.startsWith('.') ? posix : `./${posix}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Pure resolver: given the project root and the user's `output` config, compute
|
|
41
|
+
* where every generated file is written and the relative cross-references that
|
|
42
|
+
* tie them together. Performs no I/O.
|
|
43
|
+
*
|
|
44
|
+
* `.opensaas` bundle directory precedence (highest first):
|
|
45
|
+
* 1. `output.opensaasDir` (the new `output` block)
|
|
46
|
+
* 2. `opensaasPathFallback` — the pre-existing top-level `config.opensaasPath`
|
|
47
|
+
* option, preserved so setting it alone still relocates the bundle through
|
|
48
|
+
* the CLI exactly as before
|
|
49
|
+
* 3. the default `.opensaas`
|
|
50
|
+
*
|
|
51
|
+
* Cross-reference computation:
|
|
52
|
+
* - `prismaConfigSchema` — the schema *directory* relative to the project root,
|
|
53
|
+
* so the top-level `prisma.config.ts` points the Prisma CLI at the relocated
|
|
54
|
+
* schema.
|
|
55
|
+
* - `prismaClientOutput` — the patched client directory relative to the schema
|
|
56
|
+
* *file's* directory, since Prisma's `generator { output }` is resolved from
|
|
57
|
+
* the schema file.
|
|
58
|
+
* - `configImport` — `opensaas.config` relative to the `.opensaas` directory,
|
|
59
|
+
* since `context.ts`/`prisma-extensions.ts` live inside the bundle and import
|
|
60
|
+
* the project's config by relative path.
|
|
61
|
+
*
|
|
62
|
+
* @param opensaasPathFallback - The pre-existing `config.opensaasPath` value,
|
|
63
|
+
* used as the bundle directory when no `output.opensaasDir` is set.
|
|
64
|
+
*/
|
|
65
|
+
export function resolveOutputPaths(cwd, output, opensaasPathFallback) {
|
|
66
|
+
const prismaSchemaRel = output?.prismaSchema ?? DEFAULT_PRISMA_SCHEMA;
|
|
67
|
+
const opensaasDirRel = output?.opensaasDir ?? opensaasPathFallback ?? DEFAULT_OPENSAAS_DIR;
|
|
68
|
+
const prismaSchemaAbs = path.resolve(cwd, prismaSchemaRel);
|
|
69
|
+
const opensaasDirAbs = path.resolve(cwd, opensaasDirRel);
|
|
70
|
+
const schemaDirAbs = path.dirname(prismaSchemaAbs);
|
|
71
|
+
const prismaClientAbs = path.join(opensaasDirAbs, OPENSAAS_FILES.prismaClient);
|
|
72
|
+
const paths = {
|
|
73
|
+
prismaSchema: prismaSchemaAbs,
|
|
74
|
+
// prisma.config.ts is always written at the project root (not configurable).
|
|
75
|
+
prismaConfig: path.resolve(cwd, 'prisma.config.ts'),
|
|
76
|
+
opensaasDir: opensaasDirAbs,
|
|
77
|
+
types: path.join(opensaasDirAbs, OPENSAAS_FILES.types),
|
|
78
|
+
lists: path.join(opensaasDirAbs, OPENSAAS_FILES.lists),
|
|
79
|
+
context: path.join(opensaasDirAbs, OPENSAAS_FILES.context),
|
|
80
|
+
pluginTypes: path.join(opensaasDirAbs, OPENSAAS_FILES.pluginTypes),
|
|
81
|
+
prismaExtensions: path.join(opensaasDirAbs, OPENSAAS_FILES.prismaExtensions),
|
|
82
|
+
};
|
|
83
|
+
const crossReferences = {
|
|
84
|
+
prismaConfigSchema: toModuleSpecifier(path.relative(cwd, schemaDirAbs), { allowBare: true }),
|
|
85
|
+
prismaClientOutput: toModuleSpecifier(path.relative(schemaDirAbs, prismaClientAbs), {
|
|
86
|
+
allowBare: false,
|
|
87
|
+
}),
|
|
88
|
+
configImport: toModuleSpecifier(path.join(path.relative(opensaasDirAbs, cwd), 'opensaas.config'), {
|
|
89
|
+
allowBare: false,
|
|
90
|
+
}),
|
|
91
|
+
};
|
|
92
|
+
return { paths, crossReferences };
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=output-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-paths.js","sourceRoot":"","sources":["../../src/generator/output-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAG5B;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAA;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAA;AAE/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,UAA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GAAuB;QAChC,YAAY,EAAE,eAAe;QAC7B,6EAA6E;QAC7E,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC;QACnD,WAAW,EAAE,cAAc;QAC3B,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,KAAK,CAAC;QACtD,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,KAAK,CAAC;QACtD,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,OAAO,CAAC;QAC1D,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,WAAW,CAAC;QAClE,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC;KAC7E,CAAA;IAED,MAAM,eAAe,GAA4B;QAC/C,kBAAkB,EAAE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC5F,kBAAkB,EAAE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC,EAAE;YAClF,SAAS,EAAE,KAAK;SACjB,CAAC;QACF,YAAY,EAAE,iBAAiB,CAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,GAAG,CAAC,EAAE,iBAAiB,CAAC,EAChE;YACE,SAAS,EAAE,KAAK;SACjB,CACF;KACF,CAAA;IAED,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,CAAA;AACnC,CAAC"}
|
|
@@ -3,15 +3,31 @@ import type { OpenSaasConfig } from '@opensaas/stack-core';
|
|
|
3
3
|
* Generate Prisma config file for CLI commands
|
|
4
4
|
*
|
|
5
5
|
* Prisma 7 requires a prisma.config.ts file at the project root for CLI commands
|
|
6
|
-
* like `prisma db push` and `prisma migrate
|
|
7
|
-
* runtime configuration (which uses adapters in
|
|
6
|
+
* like `prisma db push`, `prisma migrate dev`, and `prisma migrate deploy`. This
|
|
7
|
+
* is separate from the runtime configuration (which uses adapters in
|
|
8
|
+
* opensaas.config.ts).
|
|
8
9
|
*
|
|
9
10
|
* The CLI config provides the database URL for schema operations, while the
|
|
10
11
|
* runtime config provides adapters for actual query execution.
|
|
12
|
+
*
|
|
13
|
+
* The datasource URL prefers `DIRECT_DATABASE_URL` and falls back to
|
|
14
|
+
* `DATABASE_URL`. On serverless Postgres (e.g. Neon) the running app connects
|
|
15
|
+
* through a pooled `DATABASE_URL`, while migrations need a direct (non-pooled)
|
|
16
|
+
* connection — set `DIRECT_DATABASE_URL` to that direct URL. Local SQLite is
|
|
17
|
+
* untouched: with `DIRECT_DATABASE_URL` unset, the expression falls back to
|
|
18
|
+
* `DATABASE_URL`.
|
|
19
|
+
*
|
|
20
|
+
* Note: a local `env` helper is emitted instead of the one from `prisma/config`
|
|
21
|
+
* because the upstream helper throws when a variable is unset, which would break
|
|
22
|
+
* the `??` fallback. The local helper returns `undefined` for missing variables
|
|
23
|
+
* so the fallback can take effect.
|
|
11
24
|
*/
|
|
12
|
-
export declare function generatePrismaConfig(_config: OpenSaasConfig): string;
|
|
25
|
+
export declare function generatePrismaConfig(_config: OpenSaasConfig, schemaPath?: string): string;
|
|
13
26
|
/**
|
|
14
27
|
* Write Prisma config to file
|
|
28
|
+
*
|
|
29
|
+
* @param schemaPath - Optional override for the `schema` field, forwarded to
|
|
30
|
+
* {@link generatePrismaConfig}.
|
|
15
31
|
*/
|
|
16
|
-
export declare function writePrismaConfig(config: OpenSaasConfig, outputPath: string): void;
|
|
32
|
+
export declare function writePrismaConfig(config: OpenSaasConfig, outputPath: string, schemaPath?: string): void;
|
|
17
33
|
//# sourceMappingURL=prisma-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-config.d.ts","sourceRoot":"","sources":["../../src/generator/prisma-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAI1D
|
|
1
|
+
{"version":3,"file":"prisma-config.d.ts","sourceRoot":"","sources":["../../src/generator/prisma-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAI1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CA4BzF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,IAAI,CAUN"}
|
|
@@ -4,22 +4,46 @@ import * as path from 'path';
|
|
|
4
4
|
* Generate Prisma config file for CLI commands
|
|
5
5
|
*
|
|
6
6
|
* Prisma 7 requires a prisma.config.ts file at the project root for CLI commands
|
|
7
|
-
* like `prisma db push` and `prisma migrate
|
|
8
|
-
* runtime configuration (which uses adapters in
|
|
7
|
+
* like `prisma db push`, `prisma migrate dev`, and `prisma migrate deploy`. This
|
|
8
|
+
* is separate from the runtime configuration (which uses adapters in
|
|
9
|
+
* opensaas.config.ts).
|
|
9
10
|
*
|
|
10
11
|
* The CLI config provides the database URL for schema operations, while the
|
|
11
12
|
* runtime config provides adapters for actual query execution.
|
|
13
|
+
*
|
|
14
|
+
* The datasource URL prefers `DIRECT_DATABASE_URL` and falls back to
|
|
15
|
+
* `DATABASE_URL`. On serverless Postgres (e.g. Neon) the running app connects
|
|
16
|
+
* through a pooled `DATABASE_URL`, while migrations need a direct (non-pooled)
|
|
17
|
+
* connection — set `DIRECT_DATABASE_URL` to that direct URL. Local SQLite is
|
|
18
|
+
* untouched: with `DIRECT_DATABASE_URL` unset, the expression falls back to
|
|
19
|
+
* `DATABASE_URL`.
|
|
20
|
+
*
|
|
21
|
+
* Note: a local `env` helper is emitted instead of the one from `prisma/config`
|
|
22
|
+
* because the upstream helper throws when a variable is unset, which would break
|
|
23
|
+
* the `??` fallback. The local helper returns `undefined` for missing variables
|
|
24
|
+
* so the fallback can take effect.
|
|
12
25
|
*/
|
|
13
|
-
export function generatePrismaConfig(_config) {
|
|
26
|
+
export function generatePrismaConfig(_config, schemaPath) {
|
|
14
27
|
const lines = [];
|
|
28
|
+
// The schema path Prisma's CLI resolves (a directory or a `.prisma` file).
|
|
29
|
+
// Defaults to the historical `prisma` directory so existing projects are
|
|
30
|
+
// unaffected; the output-path resolver supplies the configured location when
|
|
31
|
+
// the schema is relocated via the `output` config block.
|
|
32
|
+
const schema = schemaPath ?? 'prisma';
|
|
15
33
|
// Import dotenv for environment variable loading
|
|
16
34
|
lines.push("import 'dotenv/config'");
|
|
17
|
-
lines.push("import { defineConfig
|
|
35
|
+
lines.push("import { defineConfig } from 'prisma/config'");
|
|
36
|
+
lines.push('');
|
|
37
|
+
lines.push('// Read an environment variable, returning undefined when unset so the');
|
|
38
|
+
lines.push('// `??` fallback below can take effect. (The `env` helper from');
|
|
39
|
+
lines.push("// 'prisma/config' throws on missing variables, which would break the");
|
|
40
|
+
lines.push('// fallback.)');
|
|
41
|
+
lines.push('const env = (name: string): string | undefined => process.env[name]');
|
|
18
42
|
lines.push('');
|
|
19
43
|
lines.push('export default defineConfig({');
|
|
20
|
-
lines.push(
|
|
44
|
+
lines.push(` schema: '${schema}',`);
|
|
21
45
|
lines.push(' datasource: {');
|
|
22
|
-
lines.push(" url: env('DATABASE_URL'),");
|
|
46
|
+
lines.push(" url: env('DIRECT_DATABASE_URL') ?? env('DATABASE_URL'),");
|
|
23
47
|
lines.push(' },');
|
|
24
48
|
lines.push('})');
|
|
25
49
|
lines.push('');
|
|
@@ -27,9 +51,12 @@ export function generatePrismaConfig(_config) {
|
|
|
27
51
|
}
|
|
28
52
|
/**
|
|
29
53
|
* Write Prisma config to file
|
|
54
|
+
*
|
|
55
|
+
* @param schemaPath - Optional override for the `schema` field, forwarded to
|
|
56
|
+
* {@link generatePrismaConfig}.
|
|
30
57
|
*/
|
|
31
|
-
export function writePrismaConfig(config, outputPath) {
|
|
32
|
-
const prismaConfig = generatePrismaConfig(config);
|
|
58
|
+
export function writePrismaConfig(config, outputPath, schemaPath) {
|
|
59
|
+
const prismaConfig = generatePrismaConfig(config, schemaPath);
|
|
33
60
|
// Ensure directory exists
|
|
34
61
|
const dir = path.dirname(outputPath);
|
|
35
62
|
if (!fs.existsSync(dir)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-config.js","sourceRoot":"","sources":["../../src/generator/prisma-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B
|
|
1
|
+
{"version":3,"file":"prisma-config.js","sourceRoot":"","sources":["../../src/generator/prisma-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAuB,EAAE,UAAmB;IAC/E,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,2EAA2E;IAC3E,yEAAyE;IACzE,6EAA6E;IAC7E,yDAAyD;IACzD,MAAM,MAAM,GAAG,UAAU,IAAI,QAAQ,CAAA;IAErC,iDAAiD;IACjD,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;IACpC,KAAK,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAA;IAC1D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACd,KAAK,CAAC,IAAI,CAAC,wEAAwE,CAAC,CAAA;IACpF,KAAK,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAA;IAC5E,KAAK,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAA;IACnF,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAC3B,KAAK,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAA;IACjF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACd,KAAK,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA;IAC3C,KAAK,CAAC,IAAI,CAAC,cAAc,MAAM,IAAI,CAAC,CAAA;IACpC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IAC7B,KAAK,CAAC,IAAI,CAAC,6DAA6D,CAAC,CAAA;IACzE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAClB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAsB,EACtB,UAAkB,EAClB,UAAmB;IAEnB,MAAM,YAAY,GAAG,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAE7D,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACpC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACxC,CAAC;IAED,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;AACrD,CAAC"}
|
|
@@ -3,9 +3,12 @@ import type { OpenSaasConfig } from '@opensaas/stack-core';
|
|
|
3
3
|
* Generate Prisma result extensions configuration
|
|
4
4
|
* This creates a Prisma client extension that calls field resolveOutput hooks
|
|
5
5
|
*/
|
|
6
|
-
export declare function generatePrismaExtensions(config: OpenSaasConfig): string;
|
|
6
|
+
export declare function generatePrismaExtensions(config: OpenSaasConfig, configImport?: string): string;
|
|
7
7
|
/**
|
|
8
8
|
* Write Prisma extensions configuration to file
|
|
9
|
+
*
|
|
10
|
+
* @param configImport - Optional override for the `opensaas.config` import
|
|
11
|
+
* specifier, forwarded to {@link generatePrismaExtensions}.
|
|
9
12
|
*/
|
|
10
|
-
export declare function writePrismaExtensions(config: OpenSaasConfig, outputPath: string): void;
|
|
13
|
+
export declare function writePrismaExtensions(config: OpenSaasConfig, outputPath: string, configImport?: string): void;
|
|
11
14
|
//# sourceMappingURL=prisma-extensions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-extensions.d.ts","sourceRoot":"","sources":["../../src/generator/prisma-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,sBAAsB,CAAA;AAIvE;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"prisma-extensions.d.ts","sourceRoot":"","sources":["../../src/generator/prisma-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,sBAAsB,CAAA;AAIvE;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CA6I9F;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,CAUN"}
|
|
@@ -4,8 +4,13 @@ import * as path from 'path';
|
|
|
4
4
|
* Generate Prisma result extensions configuration
|
|
5
5
|
* This creates a Prisma client extension that calls field resolveOutput hooks
|
|
6
6
|
*/
|
|
7
|
-
export function generatePrismaExtensions(config) {
|
|
7
|
+
export function generatePrismaExtensions(config, configImport) {
|
|
8
8
|
const lines = [];
|
|
9
|
+
// Module specifier for importing the project's opensaas.config from inside
|
|
10
|
+
// the `.opensaas` bundle. Defaults to the legacy `../opensaas.config`; the
|
|
11
|
+
// output-path resolver supplies a recomputed value when the bundle is
|
|
12
|
+
// relocated via the `output` config block.
|
|
13
|
+
const configImportPath = configImport ?? '../opensaas.config';
|
|
9
14
|
// Add header comment
|
|
10
15
|
lines.push('/**');
|
|
11
16
|
lines.push(' * Generated Prisma result extensions from OpenSaas configuration');
|
|
@@ -14,7 +19,7 @@ export function generatePrismaExtensions(config) {
|
|
|
14
19
|
lines.push('');
|
|
15
20
|
// Add imports
|
|
16
21
|
lines.push("import { Prisma } from './prisma-client/client'");
|
|
17
|
-
lines.push(
|
|
22
|
+
lines.push(`import configOrPromise from '${configImportPath}'`);
|
|
18
23
|
lines.push('');
|
|
19
24
|
// Resolve config synchronously if possible (will be resolved by context.ts anyway)
|
|
20
25
|
lines.push('// Resolve config - may be a promise if plugins are present');
|
|
@@ -121,9 +126,12 @@ export function generatePrismaExtensions(config) {
|
|
|
121
126
|
}
|
|
122
127
|
/**
|
|
123
128
|
* Write Prisma extensions configuration to file
|
|
129
|
+
*
|
|
130
|
+
* @param configImport - Optional override for the `opensaas.config` import
|
|
131
|
+
* specifier, forwarded to {@link generatePrismaExtensions}.
|
|
124
132
|
*/
|
|
125
|
-
export function writePrismaExtensions(config, outputPath) {
|
|
126
|
-
const extensions = generatePrismaExtensions(config);
|
|
133
|
+
export function writePrismaExtensions(config, outputPath, configImport) {
|
|
134
|
+
const extensions = generatePrismaExtensions(config, configImport);
|
|
127
135
|
// Ensure directory exists
|
|
128
136
|
const dir = path.dirname(outputPath);
|
|
129
137
|
if (!fs.existsSync(dir)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-extensions.js","sourceRoot":"","sources":["../../src/generator/prisma-extensions.ts"],"names":[],"mappings":"AACA,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,CAAC,CAAA;YACtC,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YACxB,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACxB,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAClB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAAsB,EACtB,UAAkB,EAClB,YAAqB;IAErB,MAAM,UAAU,GAAG,wBAAwB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAEjE,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACpC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACxC,CAAC;IAED,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;AACnD,CAAC"}
|
|
@@ -1,10 +1,38 @@
|
|
|
1
|
-
import type { OpenSaasConfig } from '@opensaas/stack-core';
|
|
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
|
+
};
|
|
2
21
|
/**
|
|
3
22
|
* Generate Prisma schema from OpenSaas config
|
|
23
|
+
*
|
|
24
|
+
* @param prismaClientOutput - Module specifier for the patched Prisma client's
|
|
25
|
+
* `generator { output }`, relative to the schema file's directory. Defaults to
|
|
26
|
+
* the legacy `../<opensaasPath>/prisma-client` so existing projects are
|
|
27
|
+
* unaffected; the output-path resolver supplies a recomputed value when the
|
|
28
|
+
* schema or `.opensaas` dir is relocated via the `output` config block.
|
|
4
29
|
*/
|
|
5
|
-
export declare function generatePrismaSchema(config: OpenSaasConfig): string;
|
|
30
|
+
export declare function generatePrismaSchema(config: OpenSaasConfig, prismaClientOutput?: string): string;
|
|
6
31
|
/**
|
|
7
32
|
* Write Prisma schema to file
|
|
33
|
+
*
|
|
34
|
+
* @param prismaClientOutput - Optional override for the patched Prisma client
|
|
35
|
+
* output path, forwarded to {@link generatePrismaSchema}.
|
|
8
36
|
*/
|
|
9
|
-
export declare function writePrismaSchema(config: OpenSaasConfig, outputPath: string): void;
|
|
37
|
+
export declare function writePrismaSchema(config: OpenSaasConfig, outputPath: string, prismaClientOutput?: string): void;
|
|
10
38
|
//# sourceMappingURL=prisma.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/generator/prisma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/generator/prisma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAe,MAAM,sBAAsB,CAAA;AACnG,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,CAkB5C;AA0CD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,CAqQhG;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,EAClB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,IAAI,CAUN"}
|