@opensaas/stack-cli 0.39.2 → 0.40.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/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +0 -5
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/generate.d.ts +0 -6
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +4 -26
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts +1 -6
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -7
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +0 -2
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/migrate.d.ts +2 -17
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +3 -59
- package/dist/commands/migrate.js.map +1 -1
- package/dist/generator/context.d.ts +0 -12
- package/dist/generator/context.d.ts.map +1 -1
- package/dist/generator/context.js +5 -26
- package/dist/generator/context.js.map +1 -1
- package/dist/generator/extension.d.ts +0 -9
- package/dist/generator/extension.d.ts.map +1 -1
- package/dist/generator/extension.js +5 -37
- package/dist/generator/extension.js.map +1 -1
- package/dist/generator/lists.d.ts +2 -5
- package/dist/generator/lists.d.ts.map +1 -1
- package/dist/generator/lists.js +2 -12
- package/dist/generator/lists.js.map +1 -1
- package/dist/generator/output-paths.d.ts +2 -12
- package/dist/generator/output-paths.d.ts.map +1 -1
- package/dist/generator/output-paths.js +2 -12
- package/dist/generator/output-paths.js.map +1 -1
- package/dist/generator/plugin-types.d.ts +0 -6
- package/dist/generator/plugin-types.d.ts.map +1 -1
- package/dist/generator/plugin-types.js +3 -28
- package/dist/generator/plugin-types.js.map +1 -1
- package/dist/generator/prisma-config.d.ts +6 -25
- package/dist/generator/prisma-config.d.ts.map +1 -1
- package/dist/generator/prisma-config.js +6 -27
- package/dist/generator/prisma-config.js.map +1 -1
- package/dist/generator/prisma.d.ts +0 -8
- package/dist/generator/prisma.d.ts.map +1 -1
- package/dist/generator/prisma.js +24 -63
- package/dist/generator/prisma.js.map +1 -1
- package/dist/generator/types.d.ts +0 -6
- package/dist/generator/types.d.ts.map +1 -1
- package/dist/generator/types.js +25 -149
- package/dist/generator/types.js.map +1 -1
- package/dist/mcp/lib/documentation-provider.d.ts +0 -36
- package/dist/mcp/lib/documentation-provider.d.ts.map +1 -1
- package/dist/mcp/lib/documentation-provider.js +1 -49
- package/dist/mcp/lib/documentation-provider.js.map +1 -1
- package/dist/mcp/lib/features/catalog.d.ts +0 -15
- package/dist/mcp/lib/features/catalog.d.ts.map +1 -1
- package/dist/mcp/lib/features/catalog.js +0 -15
- package/dist/mcp/lib/features/catalog.js.map +1 -1
- package/dist/mcp/lib/generators/feature-generator.d.ts +3 -24
- package/dist/mcp/lib/generators/feature-generator.d.ts.map +1 -1
- package/dist/mcp/lib/generators/feature-generator.js +4 -38
- package/dist/mcp/lib/generators/feature-generator.js.map +1 -1
- package/dist/mcp/lib/types.d.ts +0 -3
- package/dist/mcp/lib/types.d.ts.map +1 -1
- package/dist/mcp/lib/types.js +0 -3
- package/dist/mcp/lib/types.js.map +1 -1
- package/dist/mcp/lib/wizards/migration-wizard.d.ts +0 -70
- package/dist/mcp/lib/wizards/migration-wizard.d.ts.map +1 -1
- package/dist/mcp/lib/wizards/migration-wizard.js +1 -87
- package/dist/mcp/lib/wizards/migration-wizard.js.map +1 -1
- package/dist/mcp/lib/wizards/wizard-engine.d.ts +0 -39
- package/dist/mcp/lib/wizards/wizard-engine.d.ts.map +1 -1
- package/dist/mcp/lib/wizards/wizard-engine.js +0 -49
- package/dist/mcp/lib/wizards/wizard-engine.js.map +1 -1
- package/dist/mcp/server/index.d.ts +0 -3
- package/dist/mcp/server/index.d.ts.map +1 -1
- package/dist/mcp/server/index.js +1 -9
- package/dist/mcp/server/index.js.map +1 -1
- package/dist/mcp/server/stack-mcp-server.d.ts +0 -42
- package/dist/mcp/server/stack-mcp-server.d.ts.map +1 -1
- package/dist/mcp/server/stack-mcp-server.js +1 -47
- package/dist/mcp/server/stack-mcp-server.js.map +1 -1
- package/dist/migration/generators/migration-generator.d.ts +0 -55
- package/dist/migration/generators/migration-generator.d.ts.map +1 -1
- package/dist/migration/generators/migration-generator.js +3 -97
- package/dist/migration/generators/migration-generator.js.map +1 -1
- package/dist/migration/introspectors/index.d.ts +0 -6
- package/dist/migration/introspectors/index.d.ts.map +1 -1
- package/dist/migration/introspectors/index.js +0 -6
- package/dist/migration/introspectors/index.js.map +1 -1
- package/dist/migration/introspectors/keystone-introspector.d.ts +0 -27
- package/dist/migration/introspectors/keystone-introspector.d.ts.map +1 -1
- package/dist/migration/introspectors/keystone-introspector.js +0 -40
- package/dist/migration/introspectors/keystone-introspector.js.map +1 -1
- package/dist/migration/introspectors/nextjs-introspector.d.ts +0 -36
- package/dist/migration/introspectors/nextjs-introspector.d.ts.map +1 -1
- package/dist/migration/introspectors/nextjs-introspector.js +0 -39
- package/dist/migration/introspectors/nextjs-introspector.js.map +1 -1
- package/dist/migration/introspectors/prisma-introspector.d.ts +0 -30
- package/dist/migration/introspectors/prisma-introspector.d.ts.map +1 -1
- package/dist/migration/introspectors/prisma-introspector.js +1 -42
- package/dist/migration/introspectors/prisma-introspector.js.map +1 -1
- package/dist/migration/types.d.ts +1 -5
- package/dist/migration/types.d.ts.map +1 -1
- package/dist/migration/types.js +0 -3
- package/dist/migration/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/generator/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAK1D
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/generator/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAK1D,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CA6LrF;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,CASN"}
|
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { withTsExtension } from './extension.js';
|
|
4
|
-
/**
|
|
5
|
-
* Generate context factory that abstracts Prisma client from developers
|
|
6
|
-
*
|
|
7
|
-
* Creates a simple API with getContext() and getContextWithSession(session)
|
|
8
|
-
* that internally handles Prisma singleton and config imports.
|
|
9
|
-
*/
|
|
10
4
|
export function generateContext(config, configImport) {
|
|
11
|
-
//
|
|
12
|
-
// the
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// The explicit `.ts` extension (see ./extension.ts) makes the bundle loadable
|
|
17
|
-
// by the host bundler / plain Node without an `extensionAlias`. The user's
|
|
18
|
-
// `opensaas.config.ts` is a real `.ts` file, so `.ts` names it directly.
|
|
5
|
+
// Defaults to the legacy `../opensaas.config` (bundle one level below the
|
|
6
|
+
// project root); the output-path resolver supplies a recomputed value when
|
|
7
|
+
// the bundle is relocated via the `output` config block. The `.ts`
|
|
8
|
+
// extension keeps the bundle loadable without a consumer `extensionAlias`
|
|
9
|
+
// (see ./extension.ts).
|
|
19
10
|
const configImportPath = withTsExtension(configImport ?? '../opensaas.config');
|
|
20
|
-
// Check if custom Prisma client constructor is provided
|
|
21
11
|
const hasCustomConstructor = !!config.db.prismaClientConstructor;
|
|
22
|
-
// Check if storage is configured
|
|
23
12
|
const hasStorage = !!config.storage && Object.keys(config.storage).length > 0;
|
|
24
|
-
// Generate the Prisma client instantiation code
|
|
25
13
|
// Prisma 7 requires adapters, so prismaClientConstructor must be provided
|
|
26
14
|
const prismaInstantiation = hasCustomConstructor
|
|
27
15
|
? `resolvedConfig.db.prismaClientConstructor!(PrismaClient)`
|
|
@@ -41,7 +29,6 @@ export function generateContext(config, configImport) {
|
|
|
41
29
|
'See https://www.prisma.io/docs/orm/overview/databases/database-drivers for more information.'
|
|
42
30
|
)
|
|
43
31
|
})()`;
|
|
44
|
-
// Generate storage utilities if storage is configured
|
|
45
32
|
const storageUtilities = hasStorage
|
|
46
33
|
? `
|
|
47
34
|
/**
|
|
@@ -111,7 +98,6 @@ const storage = {
|
|
|
111
98
|
},
|
|
112
99
|
}
|
|
113
100
|
`;
|
|
114
|
-
// Always use async version for consistency
|
|
115
101
|
return `/**
|
|
116
102
|
* Auto-generated context factory
|
|
117
103
|
*
|
|
@@ -200,15 +186,8 @@ export const rawOpensaasContext = (async () => {
|
|
|
200
186
|
export const config = getConfig()
|
|
201
187
|
`;
|
|
202
188
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Write context factory to file
|
|
205
|
-
*
|
|
206
|
-
* @param configImport - Optional override for the `opensaas.config` import
|
|
207
|
-
* specifier, forwarded to {@link generateContext}.
|
|
208
|
-
*/
|
|
209
189
|
export function writeContext(config, outputPath, configImport) {
|
|
210
190
|
const content = generateContext(config, configImport);
|
|
211
|
-
// Ensure directory exists
|
|
212
191
|
const dir = path.dirname(outputPath);
|
|
213
192
|
if (!fs.existsSync(dir)) {
|
|
214
193
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/generator/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/generator/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,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AAG,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,OAAO,EAAE,OAAO,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Append the explicit `.ts` extension to a relative module specifier so the
|
|
3
|
-
* Generated bundle resolves under a host bundler / plain Node without an
|
|
4
|
-
* `extensionAlias`. Idempotent: a specifier that already carries an explicit
|
|
5
|
-
* extension is returned unchanged.
|
|
6
|
-
*
|
|
7
|
-
* Only relative specifiers (`./` or `../`) are extended — bare package
|
|
8
|
-
* specifiers (e.g. `@opensaas/stack-core`) are returned untouched.
|
|
9
|
-
*/
|
|
10
1
|
export declare function withTsExtension(specifier: string): string;
|
|
11
2
|
//# sourceMappingURL=extension.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/generator/extension.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/generator/extension.ts"],"names":[],"mappings":"AAYA,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKzD"}
|
|
@@ -1,45 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `prisma-client/**` tree) ships as TypeScript whose
|
|
8
|
-
* relative imports point at real `.ts` files on disk. We emit an explicit
|
|
9
|
-
* extension so the bundle resolves identically under every consumer — and is
|
|
10
|
-
* file-traceable by a host bundler — rather than relying on a TS-aware loader's
|
|
11
|
-
* extensionless guessing (which a plain Node process and an un-aliased webpack
|
|
12
|
-
* both refuse). See ADR-0008.
|
|
13
|
-
*
|
|
14
|
-
* The extension is `.ts` rather than `.js` because the on-disk files ARE `.ts`:
|
|
15
|
-
*
|
|
16
|
-
* | loader | `.ts` | `.js` (rewrite alias) |
|
|
17
|
-
* | ------------------------------ | ----- | --------------------- |
|
|
18
|
-
* | plain `node` (strip-types) | ✅ | ❌ ERR_MODULE_NOT_FOUND |
|
|
19
|
-
* | `tsx` / vitest | ✅ | ✅ |
|
|
20
|
-
* | esbuild bundle | ✅ | ✅ |
|
|
21
|
-
* | webpack (no `extensionAlias`) | ✅ | ❌ Module not found |
|
|
22
|
-
* | webpack / Next (`.js`→`.ts`) | ✅ | ✅ |
|
|
23
|
-
*
|
|
24
|
-
* `.ts` is the only specifier that resolves everywhere without a consumer-side
|
|
25
|
-
* `extensionAlias`, because it names the literal file. This matches the
|
|
26
|
-
* `moduleResolution: "bundler"` setting the examples use (which permits
|
|
27
|
-
* importing `.ts` extensions directly). The choice was validated by resolving a
|
|
28
|
-
* fixture mirroring the bundle layout under node strip-types, tsx, esbuild, and
|
|
29
|
-
* webpack with and without `extensionAlias`.
|
|
2
|
+
* `.ts` (not extensionless or `.js`) because the Generated bundle's relative
|
|
3
|
+
* imports must resolve identically under plain Node, `tsx`, esbuild, and
|
|
4
|
+
* webpack without a consumer-side `extensionAlias` — `.ts` is the only
|
|
5
|
+
* specifier that works everywhere, since it names the literal on-disk file.
|
|
6
|
+
* See ADR-0008.
|
|
30
7
|
*/
|
|
31
8
|
const TS_EXTENSION = '.ts';
|
|
32
9
|
/** Module specifiers that already carry an explicit extension we should not touch. */
|
|
33
10
|
const EXPLICIT_EXTENSION = /\.(ts|tsx|js|jsx|mjs|cjs|json)$/;
|
|
34
|
-
/**
|
|
35
|
-
* Append the explicit `.ts` extension to a relative module specifier so the
|
|
36
|
-
* Generated bundle resolves under a host bundler / plain Node without an
|
|
37
|
-
* `extensionAlias`. Idempotent: a specifier that already carries an explicit
|
|
38
|
-
* extension is returned unchanged.
|
|
39
|
-
*
|
|
40
|
-
* Only relative specifiers (`./` or `../`) are extended — bare package
|
|
41
|
-
* specifiers (e.g. `@opensaas/stack-core`) are returned untouched.
|
|
42
|
-
*/
|
|
43
11
|
export function withTsExtension(specifier) {
|
|
44
12
|
const isRelative = specifier.startsWith('./') || specifier.startsWith('../');
|
|
45
13
|
if (!isRelative)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/generator/extension.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/generator/extension.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,KAAK,CAAA;AAE1B,sFAAsF;AACtF,MAAM,kBAAkB,GAAG,iCAAiC,CAAA;AAE5D,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IAC5E,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAA;IACjC,IAAI,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC;QAAE,OAAO,SAAS,CAAA;IACxD,OAAO,GAAG,SAAS,GAAG,YAAY,EAAE,CAAA;AACtC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OpenSaasConfig } from '@opensaas/stack-core';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Generates the `Lists` namespace: TypeInfo for each list, giving hooks
|
|
4
|
+
* strongly-typed access to Prisma input types.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
@@ -24,8 +24,5 @@ import type { OpenSaasConfig } from '@opensaas/stack-core';
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export declare function generateListsNamespace(config: OpenSaasConfig): string;
|
|
27
|
-
/**
|
|
28
|
-
* Write Lists namespace to file
|
|
29
|
-
*/
|
|
30
27
|
export declare function writeLists(config: OpenSaasConfig, outputPath: string): void;
|
|
31
28
|
//# sourceMappingURL=lists.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../../src/generator/lists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAoC1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../../src/generator/lists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAoC1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAqErE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAS3E"}
|
package/dist/generator/lists.js
CHANGED
|
@@ -30,8 +30,8 @@ function getFieldTypeImport(fieldType) {
|
|
|
30
30
|
return { module: '@opensaas/stack-core/extend', typeName: 'BaseFieldConfig' };
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
33
|
+
* Generates the `Lists` namespace: TypeInfo for each list, giving hooks
|
|
34
|
+
* strongly-typed access to Prisma input types.
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* ```typescript
|
|
@@ -55,7 +55,6 @@ function getFieldTypeImport(fieldType) {
|
|
|
55
55
|
*/
|
|
56
56
|
export function generateListsNamespace(config) {
|
|
57
57
|
const lines = [];
|
|
58
|
-
// Add header comment
|
|
59
58
|
lines.push('/**');
|
|
60
59
|
lines.push(' * Generated Lists namespace from OpenSaas configuration');
|
|
61
60
|
lines.push(' * DO NOT EDIT - This file is automatically generated');
|
|
@@ -82,16 +81,13 @@ export function generateListsNamespace(config) {
|
|
|
82
81
|
lines.push(' * ```');
|
|
83
82
|
lines.push(' */');
|
|
84
83
|
lines.push('');
|
|
85
|
-
// Start Lists namespace
|
|
86
84
|
lines.push('export declare namespace Lists {');
|
|
87
|
-
// Generate type for each list
|
|
88
85
|
for (const [listName, listConfig] of Object.entries(config.lists)) {
|
|
89
86
|
lines.push(` export type ${listName} = import('@opensaas/stack-core').ListConfig<Lists.${listName}.TypeInfo>`);
|
|
90
87
|
lines.push('');
|
|
91
88
|
lines.push(` namespace ${listName} {`);
|
|
92
89
|
lines.push(` export type Item = import('./types.ts').${listName}`);
|
|
93
90
|
lines.push('');
|
|
94
|
-
// Generate Fields type
|
|
95
91
|
lines.push(` /**`);
|
|
96
92
|
lines.push(` * Field configurations for ${listName}`);
|
|
97
93
|
lines.push(` * Maps field names to their field config types`);
|
|
@@ -103,7 +99,6 @@ export function generateListsNamespace(config) {
|
|
|
103
99
|
}
|
|
104
100
|
lines.push(` }`);
|
|
105
101
|
lines.push('');
|
|
106
|
-
// Generate TypeInfo with fields property
|
|
107
102
|
lines.push(` export type TypeInfo = {`);
|
|
108
103
|
lines.push(` key: '${listName}'`);
|
|
109
104
|
lines.push(` fields: Fields`);
|
|
@@ -116,16 +111,11 @@ export function generateListsNamespace(config) {
|
|
|
116
111
|
lines.push(` }`);
|
|
117
112
|
lines.push('');
|
|
118
113
|
}
|
|
119
|
-
// Close Lists namespace
|
|
120
114
|
lines.push('}');
|
|
121
115
|
return lines.join('\n');
|
|
122
116
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Write Lists namespace to file
|
|
125
|
-
*/
|
|
126
117
|
export function writeLists(config, outputPath) {
|
|
127
118
|
const lists = generateListsNamespace(config);
|
|
128
|
-
// Ensure directory exists
|
|
129
119
|
const dir = path.dirname(outputPath);
|
|
130
120
|
if (!fs.existsSync(dir)) {
|
|
131
121
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lists.js","sourceRoot":"","sources":["../../src/generator/lists.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B;;;;;;;GAOG;AACH,SAAS,kBAAkB,CAAC,SAAiB;IAC3C,MAAM,OAAO,GAA2B;QACtC,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE,eAAe;QACzB,SAAS,EAAE,gBAAgB;QAC3B,WAAW,EAAE,kBAAkB;QAC/B,QAAQ,EAAE,eAAe;QACzB,MAAM,EAAE,aAAa;QACrB,YAAY,EAAE,mBAAmB;QACjC,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,cAAc;KACxB,CAAA;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IACnC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,EAAE,MAAM,EAAE,6BAA6B,EAAE,QAAQ,EAAE,CAAA;IAC5D,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,6BAA6B,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAA;AAC/E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAsB;IAC3D,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,
|
|
1
|
+
{"version":3,"file":"lists.js","sourceRoot":"","sources":["../../src/generator/lists.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B;;;;;;;GAOG;AACH,SAAS,kBAAkB,CAAC,SAAiB;IAC3C,MAAM,OAAO,GAA2B;QACtC,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,c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AAC,GAAG,CAAC,CAAA;IAEf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAsB,EAAE,UAAkB;IACnE,MAAM,KAAK,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAA;IAE5C,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,KAAK,EAAE,OAAO,CAAC,CAAA;AAC9C,CAAC"}
|
|
@@ -73,7 +73,8 @@ export interface ResolvedOutputPaths {
|
|
|
73
73
|
/**
|
|
74
74
|
* Pure resolver: given the project root and the user's `output` config, compute
|
|
75
75
|
* where every generated file is written and the relative cross-references that
|
|
76
|
-
* tie them together
|
|
76
|
+
* tie them together (see {@link ResolvedCrossReferences} for what each one is
|
|
77
|
+
* for). Performs no I/O.
|
|
77
78
|
*
|
|
78
79
|
* `.opensaas` bundle directory precedence (highest first):
|
|
79
80
|
* 1. `output.opensaasDir` (the new `output` block)
|
|
@@ -82,17 +83,6 @@ export interface ResolvedOutputPaths {
|
|
|
82
83
|
* the CLI exactly as before
|
|
83
84
|
* 3. the default `.opensaas`
|
|
84
85
|
*
|
|
85
|
-
* Cross-reference computation:
|
|
86
|
-
* - `prismaConfigSchema` — the schema *directory* relative to the project root,
|
|
87
|
-
* so the top-level `prisma.config.ts` points the Prisma CLI at the relocated
|
|
88
|
-
* schema.
|
|
89
|
-
* - `prismaClientOutput` — the patched client directory relative to the schema
|
|
90
|
-
* *file's* directory, since Prisma's `generator { output }` is resolved from
|
|
91
|
-
* the schema file.
|
|
92
|
-
* - `configImport` — `opensaas.config` relative to the `.opensaas` directory,
|
|
93
|
-
* since `context.ts` lives inside the bundle and imports the project's
|
|
94
|
-
* config by relative path.
|
|
95
|
-
*
|
|
96
86
|
* @param opensaasPathFallback - The pre-existing `config.opensaasPath` value,
|
|
97
87
|
* used as the bundle directory when no `output.opensaasDir` is set.
|
|
98
88
|
*/
|
|
@@ -1 +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;aACzB,KAAK,EAAE,UAAU;aACjB,KAAK,EAAE,UAAU;aACjB,OAAO,EAAE,YAAY;aACrB,WAAW,EAAE,iBAAiB;aAC9B,YAAY,EAAE,eAAe;CACrB,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;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,CAAA;IAC1B;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,CAAA;IAC1B;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,kBAAkB,CAAA;IACzB,eAAe,EAAE,uBAAuB,CAAA;CACzC;AAoBD
|
|
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;aACzB,KAAK,EAAE,UAAU;aACjB,KAAK,EAAE,UAAU;aACjB,OAAO,EAAE,YAAY;aACrB,WAAW,EAAE,iBAAiB;aAC9B,YAAY,EAAE,eAAe;CACrB,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;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,CAAA;IAC1B;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,CAAA;IAC1B;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,kBAAkB,CAAA;IACzB,eAAe,EAAE,uBAAuB,CAAA;CACzC;AAoBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,YAAY,EACrB,oBAAoB,CAAC,EAAE,MAAM,GAC5B,mBAAmB,CAkCrB"}
|
|
@@ -38,7 +38,8 @@ function toModuleSpecifier(relative, { allowBare }) {
|
|
|
38
38
|
/**
|
|
39
39
|
* Pure resolver: given the project root and the user's `output` config, compute
|
|
40
40
|
* where every generated file is written and the relative cross-references that
|
|
41
|
-
* tie them together
|
|
41
|
+
* tie them together (see {@link ResolvedCrossReferences} for what each one is
|
|
42
|
+
* for). Performs no I/O.
|
|
42
43
|
*
|
|
43
44
|
* `.opensaas` bundle directory precedence (highest first):
|
|
44
45
|
* 1. `output.opensaasDir` (the new `output` block)
|
|
@@ -47,17 +48,6 @@ function toModuleSpecifier(relative, { allowBare }) {
|
|
|
47
48
|
* the CLI exactly as before
|
|
48
49
|
* 3. the default `.opensaas`
|
|
49
50
|
*
|
|
50
|
-
* Cross-reference computation:
|
|
51
|
-
* - `prismaConfigSchema` — the schema *directory* relative to the project root,
|
|
52
|
-
* so the top-level `prisma.config.ts` points the Prisma CLI at the relocated
|
|
53
|
-
* schema.
|
|
54
|
-
* - `prismaClientOutput` — the patched client directory relative to the schema
|
|
55
|
-
* *file's* directory, since Prisma's `generator { output }` is resolved from
|
|
56
|
-
* the schema file.
|
|
57
|
-
* - `configImport` — `opensaas.config` relative to the `.opensaas` directory,
|
|
58
|
-
* since `context.ts` lives inside the bundle and imports the project's
|
|
59
|
-
* config by relative path.
|
|
60
|
-
*
|
|
61
51
|
* @param opensaasPathFallback - The pre-existing `config.opensaasPath` value,
|
|
62
52
|
* used as the bundle directory when no `output.opensaasDir` is set.
|
|
63
53
|
*/
|
|
@@ -1 +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,W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,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;KACnE,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"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import type { OpenSaasConfig } from '@opensaas/stack-core';
|
|
2
|
-
/**
|
|
3
|
-
* Generate complete plugin types file
|
|
4
|
-
*/
|
|
5
2
|
export declare function generatePluginTypes(config: OpenSaasConfig): string;
|
|
6
|
-
/**
|
|
7
|
-
* Write plugin types to file
|
|
8
|
-
*/
|
|
9
3
|
export declare function writePluginTypes(config: OpenSaasConfig, outputPath: string): void;
|
|
10
4
|
//# sourceMappingURL=plugin-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-types.d.ts","sourceRoot":"","sources":["../../src/generator/plugin-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"plugin-types.d.ts","sourceRoot":"","sources":["../../src/generator/plugin-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AA2F1D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAmBlE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CASjF"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
/**
|
|
4
|
-
* Generate TypeScript declaration for plugin data types
|
|
5
|
-
* Creates type-safe access to config._pluginData
|
|
6
|
-
*/
|
|
7
3
|
function generatePluginDataInterface(config) {
|
|
8
4
|
const lines = [];
|
|
9
5
|
lines.push('/**');
|
|
@@ -11,13 +7,11 @@ function generatePluginDataInterface(config) {
|
|
|
11
7
|
lines.push(' * Provides type-safe access to config._pluginData');
|
|
12
8
|
lines.push(' */');
|
|
13
9
|
lines.push('export interface PluginData {');
|
|
14
|
-
// Check if we have plugin data types to generate
|
|
15
10
|
if (config._pluginData && Object.keys(config._pluginData).length > 0) {
|
|
16
11
|
for (const pluginName of Object.keys(config._pluginData)) {
|
|
17
12
|
// Skip internal keys
|
|
18
13
|
if (pluginName.startsWith('__'))
|
|
19
14
|
continue;
|
|
20
|
-
// For each plugin, we'll add a Record<string, unknown> entry
|
|
21
15
|
// TODO: In the future, plugins could export their data types for proper typing
|
|
22
16
|
lines.push(` ${pluginName}?: Record<string, unknown>`);
|
|
23
17
|
}
|
|
@@ -25,16 +19,10 @@ function generatePluginDataInterface(config) {
|
|
|
25
19
|
lines.push('}');
|
|
26
20
|
return lines.join('\n');
|
|
27
21
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Generate TypeScript declaration for plugin runtime services
|
|
30
|
-
* Creates type-safe access to context.plugins
|
|
31
|
-
*/
|
|
32
22
|
function generatePluginServicesInterface(config) {
|
|
33
23
|
const lines = [];
|
|
34
24
|
const imports = [];
|
|
35
|
-
// Check if we have plugins with runtime functions
|
|
36
25
|
const pluginsWithRuntime = (config._plugins || config.plugins || []).filter((p) => p.runtime);
|
|
37
|
-
// Collect imports from plugins that provide runtime service types
|
|
38
26
|
if (pluginsWithRuntime.length > 0) {
|
|
39
27
|
for (const plugin of pluginsWithRuntime) {
|
|
40
28
|
if (plugin.runtimeServiceTypes) {
|
|
@@ -42,7 +30,6 @@ function generatePluginServicesInterface(config) {
|
|
|
42
30
|
}
|
|
43
31
|
}
|
|
44
32
|
}
|
|
45
|
-
// Add imports at the top if any exist
|
|
46
33
|
if (imports.length > 0) {
|
|
47
34
|
lines.push(...imports);
|
|
48
35
|
lines.push('');
|
|
@@ -56,11 +43,9 @@ function generatePluginServicesInterface(config) {
|
|
|
56
43
|
if (pluginsWithRuntime.length > 0) {
|
|
57
44
|
for (const plugin of pluginsWithRuntime) {
|
|
58
45
|
if (plugin.runtimeServiceTypes) {
|
|
59
|
-
// Use typed runtime service from plugin
|
|
60
46
|
lines.push(` ${plugin.name}?: ${plugin.runtimeServiceTypes.typeName}`);
|
|
61
47
|
}
|
|
62
48
|
else {
|
|
63
|
-
// Fallback to Record<string, any> for plugins without type metadata
|
|
64
49
|
lines.push(` ${plugin.name}?: Record<string, any>`);
|
|
65
50
|
}
|
|
66
51
|
}
|
|
@@ -69,9 +54,9 @@ function generatePluginServicesInterface(config) {
|
|
|
69
54
|
return lines.join('\n');
|
|
70
55
|
}
|
|
71
56
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
57
|
+
* We cannot augment `_pluginData` or `plugins` directly due to type
|
|
58
|
+
* constraints — users must cast to `PluginServices` when accessing
|
|
59
|
+
* `context.plugins`.
|
|
75
60
|
*/
|
|
76
61
|
function generateModuleAugmentation() {
|
|
77
62
|
const lines = [];
|
|
@@ -85,12 +70,8 @@ function generateModuleAugmentation() {
|
|
|
85
70
|
lines.push('}');
|
|
86
71
|
return lines.join('\n');
|
|
87
72
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Generate complete plugin types file
|
|
90
|
-
*/
|
|
91
73
|
export function generatePluginTypes(config) {
|
|
92
74
|
const lines = [];
|
|
93
|
-
// Add header comment
|
|
94
75
|
lines.push('/**');
|
|
95
76
|
lines.push(' * Generated plugin types from OpenSaas configuration');
|
|
96
77
|
lines.push(' * DO NOT EDIT - This file is automatically generated');
|
|
@@ -100,19 +81,13 @@ export function generatePluginTypes(config) {
|
|
|
100
81
|
lines.push(' * - context.plugins - Plugin runtime services');
|
|
101
82
|
lines.push(' */');
|
|
102
83
|
lines.push('');
|
|
103
|
-
// Generate interfaces
|
|
104
84
|
lines.push(generatePluginDataInterface(config));
|
|
105
85
|
lines.push(generatePluginServicesInterface(config));
|
|
106
|
-
// Generate module augmentation
|
|
107
86
|
lines.push(generateModuleAugmentation());
|
|
108
87
|
return lines.join('\n');
|
|
109
88
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Write plugin types to file
|
|
112
|
-
*/
|
|
113
89
|
export function writePluginTypes(config, outputPath) {
|
|
114
90
|
const pluginTypes = generatePluginTypes(config);
|
|
115
|
-
// Ensure directory exists
|
|
116
91
|
const dir = path.dirname(outputPath);
|
|
117
92
|
if (!fs.existsSync(dir)) {
|
|
118
93
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-types.js","sourceRoot":"","sources":["../../src/generator/plugin-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B
|
|
1
|
+
{"version":3,"file":"plugin-types.js","sourceRoot":"","sources":["../../src/generator/plugin-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;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MAAsB,EAAE,UAAkB;IACzE,MAAM,WAAW,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAE/C,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,WAAW,EAAE,OAAO,CAAC,CAAA;AACpD,CAAC"}
|
|
@@ -1,26 +1,12 @@
|
|
|
1
1
|
import type { OpenSaasConfig } from '@opensaas/stack-core';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Prisma 7 requires a `prisma.config.ts` file at the project root for CLI
|
|
4
|
+
* commands (`prisma db push`, `migrate dev`, `migrate deploy`) — separate
|
|
5
|
+
* from the runtime config, which uses adapters in `opensaas.config.ts`.
|
|
4
6
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* opensaas.config.ts).
|
|
9
|
-
*
|
|
10
|
-
* The CLI config provides the database URL for schema operations, while the
|
|
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.
|
|
7
|
+
* The datasource URL prefers `DIRECT_DATABASE_URL`, falling back to
|
|
8
|
+
* `DATABASE_URL` (see ADR-0003 for the serverless-Postgres pooled/direct
|
|
9
|
+
* connection split this supports).
|
|
24
10
|
*
|
|
25
11
|
* @param extraDatasourceLines - Verbatim `datasource` block entries the
|
|
26
12
|
* generator does not itself manage (e.g. a host-added `shadowDatabaseUrl`),
|
|
@@ -44,14 +30,9 @@ export declare function generatePrismaConfig(_config: OpenSaasConfig, schemaPath
|
|
|
44
30
|
*/
|
|
45
31
|
export declare function extractExtraDatasourceLines(existingContent: string): string[];
|
|
46
32
|
/**
|
|
47
|
-
* Write Prisma config to file
|
|
48
|
-
*
|
|
49
33
|
* If a `prisma.config.ts` already exists at `outputPath`, its `datasource`
|
|
50
34
|
* block is read first so host-added keys the generator does not manage (e.g.
|
|
51
35
|
* `shadowDatabaseUrl`) survive the rewrite — see {@link extractExtraDatasourceLines}.
|
|
52
|
-
*
|
|
53
|
-
* @param schemaPath - Optional override for the `schema` field, forwarded to
|
|
54
|
-
* {@link generatePrismaConfig}.
|
|
55
36
|
*/
|
|
56
37
|
export declare function writePrismaConfig(config: OpenSaasConfig, outputPath: string, schemaPath?: string): void;
|
|
57
38
|
//# 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;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,cAAc,EACvB,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,GAAE,MAAM,EAAO,GAClC,MAAM,CA8BR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,CAU7E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,IAAI,CAaN"}
|
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Prisma 7 requires a `prisma.config.ts` file at the project root for CLI
|
|
5
|
+
* commands (`prisma db push`, `migrate dev`, `migrate deploy`) — separate
|
|
6
|
+
* from the runtime config, which uses adapters in `opensaas.config.ts`.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* opensaas.config.ts).
|
|
10
|
-
*
|
|
11
|
-
* The CLI config provides the database URL for schema operations, while the
|
|
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.
|
|
8
|
+
* The datasource URL prefers `DIRECT_DATABASE_URL`, falling back to
|
|
9
|
+
* `DATABASE_URL` (see ADR-0003 for the serverless-Postgres pooled/direct
|
|
10
|
+
* connection split this supports).
|
|
25
11
|
*
|
|
26
12
|
* @param extraDatasourceLines - Verbatim `datasource` block entries the
|
|
27
13
|
* generator does not itself manage (e.g. a host-added `shadowDatabaseUrl`),
|
|
@@ -35,7 +21,6 @@ export function generatePrismaConfig(_config, schemaPath, extraDatasourceLines =
|
|
|
35
21
|
// unaffected; the output-path resolver supplies the configured location when
|
|
36
22
|
// the schema is relocated via the `output` config block.
|
|
37
23
|
const schema = schemaPath ?? 'prisma';
|
|
38
|
-
// Import dotenv for environment variable loading
|
|
39
24
|
lines.push("import 'dotenv/config'");
|
|
40
25
|
lines.push("import { defineConfig } from 'prisma/config'");
|
|
41
26
|
lines.push('');
|
|
@@ -82,21 +67,15 @@ export function extractExtraDatasourceLines(existingContent) {
|
|
|
82
67
|
.filter((line) => line.length > 0 && !line.startsWith('url:'));
|
|
83
68
|
}
|
|
84
69
|
/**
|
|
85
|
-
* Write Prisma config to file
|
|
86
|
-
*
|
|
87
70
|
* If a `prisma.config.ts` already exists at `outputPath`, its `datasource`
|
|
88
71
|
* block is read first so host-added keys the generator does not manage (e.g.
|
|
89
72
|
* `shadowDatabaseUrl`) survive the rewrite — see {@link extractExtraDatasourceLines}.
|
|
90
|
-
*
|
|
91
|
-
* @param schemaPath - Optional override for the `schema` field, forwarded to
|
|
92
|
-
* {@link generatePrismaConfig}.
|
|
93
73
|
*/
|
|
94
74
|
export function writePrismaConfig(config, outputPath, schemaPath) {
|
|
95
75
|
const extraDatasourceLines = fs.existsSync(outputPath)
|
|
96
76
|
? extractExtraDatasourceLines(fs.readFileSync(outputPath, 'utf-8'))
|
|
97
77
|
: [];
|
|
98
78
|
const prismaConfig = generatePrismaConfig(config, schemaPath, extraDatasourceLines);
|
|
99
|
-
// Ensure directory exists
|
|
100
79
|
const dir = path.dirname(outputPath);
|
|
101
80
|
if (!fs.existsSync(dir)) {
|
|
102
81
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -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;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAuB,EACvB,UAAmB,EACnB,oBAAoB,GAAa,EAAE;IAEnC,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,2EAA2E;IAC3E,yEAAyE;IACzE,6EAA6E;IAC7E,yDAAyD;IACzD,MAAM,MAAM,GAAG,UAAU,IAAI,QAAQ,CAAA;IAErC,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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