@opensaas/stack-cli 0.42.3 → 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
|
@@ -2,28 +2,48 @@ import type { OutputConfig } from '@opensaas/stack-core';
|
|
|
2
2
|
/**
|
|
3
3
|
* Default output locations, relative to the project root. Keeping these here
|
|
4
4
|
* (rather than scattering string literals across the generator) means the
|
|
5
|
-
* "no `output` block" path is
|
|
5
|
+
* "no `output` block" path is one decision in one place.
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const DEFAULT_CONTRACT_MODULE = "prisma/contract.ts";
|
|
8
8
|
export declare const DEFAULT_OPENSAAS_DIR = ".opensaas";
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
* only the directory that holds them moves.
|
|
10
|
+
* The files written into the `.opensaas` bundle directory. These names are
|
|
11
|
+
* not configurable — only the directory that holds them moves.
|
|
13
12
|
*/
|
|
14
13
|
export declare const OPENSAAS_FILES: {
|
|
15
14
|
readonly types: 'types.ts';
|
|
16
15
|
readonly lists: 'lists.ts';
|
|
17
16
|
readonly context: 'context.ts';
|
|
18
17
|
readonly pluginTypes: 'plugin-types.ts';
|
|
19
|
-
readonly
|
|
18
|
+
readonly tables: 'tables.ts';
|
|
20
19
|
};
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
21
|
+
* Inside a staging directory: the project-root-shaped `prisma.config.ts` a
|
|
22
|
+
* staged generation holds back. The staged run's own `prisma.config.ts` names
|
|
23
|
+
* absolute staged paths and cannot stand in for it, so the two are separate
|
|
24
|
+
* files and only this one is promoted.
|
|
25
|
+
*/
|
|
26
|
+
export declare const STAGED_ROOT_PRISMA_CONFIG = "prisma.config.root.ts";
|
|
27
|
+
/**
|
|
28
|
+
* The two artifacts `prisma contract emit` writes beside the Contract module.
|
|
29
|
+
*/
|
|
30
|
+
export declare const CONTRACT_ARTIFACTS: {
|
|
31
|
+
readonly json: 'contract.json';
|
|
32
|
+
readonly types: 'contract.d.ts';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Absolute write paths for every file the generator emits, plus the two the
|
|
36
|
+
* Prisma CLI emits on its behalf.
|
|
23
37
|
*/
|
|
24
38
|
export interface ResolvedWritePaths {
|
|
25
|
-
/** Absolute path to the
|
|
26
|
-
|
|
39
|
+
/** Absolute path to the generated Contract module (`prisma/contract.ts`). */
|
|
40
|
+
contractModule: string;
|
|
41
|
+
/** Absolute path to the directory holding the Contract module and its artifacts. */
|
|
42
|
+
contractDir: string;
|
|
43
|
+
/** Absolute path to `<contractDir>/contract.json`, written by `prisma contract emit`. */
|
|
44
|
+
contractJson: string;
|
|
45
|
+
/** Absolute path to `<contractDir>/contract.d.ts`, written by `prisma contract emit`. */
|
|
46
|
+
contractTypes: string;
|
|
27
47
|
/** Absolute path to the top-level `prisma.config.ts` (never relocated). */
|
|
28
48
|
prismaConfig: string;
|
|
29
49
|
/** Absolute path to the resolved `.opensaas` bundle directory. */
|
|
@@ -36,26 +56,33 @@ export interface ResolvedWritePaths {
|
|
|
36
56
|
context: string;
|
|
37
57
|
/** Absolute path to `<opensaasDir>/plugin-types.ts`. */
|
|
38
58
|
pluginTypes: string;
|
|
59
|
+
/** Absolute path to `<opensaasDir>/tables.ts` — the dependency-set table and constraint map. */
|
|
60
|
+
tables: string;
|
|
39
61
|
}
|
|
40
62
|
/**
|
|
41
63
|
* Relative cross-references baked into the generated files. These follow the
|
|
42
64
|
* configured locations so the emitted code resolves regardless of where the
|
|
43
|
-
*
|
|
65
|
+
* Contract module and bundle live.
|
|
44
66
|
*/
|
|
45
67
|
export interface ResolvedCrossReferences {
|
|
46
68
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @example "prisma" | "prisma-opensaas"
|
|
69
|
+
* `prisma.config.ts`'s `contract` field — the Contract module relative to the
|
|
70
|
+
* project root, POSIX-separated and explicitly relative.
|
|
71
|
+
* @example "./prisma/contract.ts"
|
|
51
72
|
*/
|
|
52
|
-
|
|
73
|
+
prismaConfigContract: string;
|
|
53
74
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @example "
|
|
75
|
+
* `prisma.config.ts`'s `output` field — the directory `contract.json` and
|
|
76
|
+
* `contract.d.ts` land in, which is the Contract module's own directory.
|
|
77
|
+
* @example "./prisma"
|
|
57
78
|
*/
|
|
58
|
-
|
|
79
|
+
prismaConfigOutput: string;
|
|
80
|
+
/**
|
|
81
|
+
* Module specifier for importing the emitted `contract.json` from inside the
|
|
82
|
+
* bundle (used by `context.ts`) — relative to the `.opensaas` directory.
|
|
83
|
+
* @example "../prisma/contract.json"
|
|
84
|
+
*/
|
|
85
|
+
contractJsonImport: string;
|
|
59
86
|
/**
|
|
60
87
|
* Module specifier for importing `opensaas.config` from inside the bundle
|
|
61
88
|
* (used by `context.ts`) — relative to the `.opensaas` directory.
|
|
@@ -87,4 +114,20 @@ export interface ResolvedOutputPaths {
|
|
|
87
114
|
* used as the bundle directory when no `output.opensaasDir` is set.
|
|
88
115
|
*/
|
|
89
116
|
export declare function resolveOutputPaths(cwd: string, output?: OutputConfig, opensaasPathFallback?: string): ResolvedOutputPaths;
|
|
117
|
+
/**
|
|
118
|
+
* The same set of files, redirected under a staging directory: the Contract
|
|
119
|
+
* module and the two artifacts `prisma contract emit` writes beside it in one
|
|
120
|
+
* subdirectory, the bundle in another, and the Prisma config that drives the
|
|
121
|
+
* staged emission at the top.
|
|
122
|
+
*
|
|
123
|
+
* The two subdirectories keep a Contract module named after a bundle file from
|
|
124
|
+
* landing on top of it, since both sets are flattened into one place here.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const staged = stageWritePaths(paths, path.join(cwd, '.opensaas', 'staged'))
|
|
129
|
+
* writeContractModule(contractData, staged.contractModule)
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare function stageWritePaths(paths: ResolvedWritePaths, stagingDir: string): ResolvedWritePaths;
|
|
90
133
|
//# sourceMappingURL=output-paths.d.ts.map
|
|
@@ -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,
|
|
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,uBAAuB,uBAAuB,CAAA;AAC3D,eAAO,MAAM,oBAAoB,cAAc,CAAA;AAE/C;;;GAGG;AACH,eAAO,MAAM,cAAc;aACzB,KAAK,EAAE,UAAU;aACjB,KAAK,EAAE,UAAU;aACjB,OAAO,EAAE,YAAY;aACrB,WAAW,EAAE,iBAAiB;aAC9B,MAAM,EAAE,WAAW;CACX,CAAA;AAEV;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,0BAA0B,CAAA;AAEhE;;GAEG;AACH,eAAO,MAAM,kBAAkB;aAC7B,IAAI,EAAE,eAAe;aACrB,KAAK,EAAE,eAAe;CACd,CAAA;AAEV;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,cAAc,EAAE,MAAM,CAAA;IACtB,oFAAoF;IACpF,WAAW,EAAE,MAAM,CAAA;IACnB,yFAAyF;IACzF,YAAY,EAAE,MAAM,CAAA;IACpB,yFAAyF;IACzF,aAAa,EAAE,MAAM,CAAA;IACrB,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,gGAAgG;IAChG,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,CAAA;IAC5B;;;;OAIG;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;AAYD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,YAAY,EACrB,oBAAoB,CAAC,EAAE,MAAM,GAC5B,mBAAmB,CAiCrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,GAAG,kBAAkB,CAiBjG"}
|
|
@@ -2,37 +2,43 @@ import * as path from 'path';
|
|
|
2
2
|
/**
|
|
3
3
|
* Default output locations, relative to the project root. Keeping these here
|
|
4
4
|
* (rather than scattering string literals across the generator) means the
|
|
5
|
-
* "no `output` block" path is
|
|
5
|
+
* "no `output` block" path is one decision in one place.
|
|
6
6
|
*/
|
|
7
|
-
export const
|
|
7
|
+
export const DEFAULT_CONTRACT_MODULE = 'prisma/contract.ts';
|
|
8
8
|
export const DEFAULT_OPENSAAS_DIR = '.opensaas';
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
* only the directory that holds them moves.
|
|
10
|
+
* The files written into the `.opensaas` bundle directory. These names are
|
|
11
|
+
* not configurable — only the directory that holds them moves.
|
|
13
12
|
*/
|
|
14
13
|
export const OPENSAAS_FILES = {
|
|
15
14
|
types: 'types.ts',
|
|
16
15
|
lists: 'lists.ts',
|
|
17
16
|
context: 'context.ts',
|
|
18
17
|
pluginTypes: 'plugin-types.ts',
|
|
19
|
-
|
|
18
|
+
tables: 'tables.ts',
|
|
20
19
|
};
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* Inside a staging directory: the project-root-shaped `prisma.config.ts` a
|
|
22
|
+
* staged generation holds back. The staged run's own `prisma.config.ts` names
|
|
23
|
+
* absolute staged paths and cannot stand in for it, so the two are separate
|
|
24
|
+
* files and only this one is promoted.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
export const STAGED_ROOT_PRISMA_CONFIG = 'prisma.config.root.ts';
|
|
27
|
+
/**
|
|
28
|
+
* The two artifacts `prisma contract emit` writes beside the Contract module.
|
|
29
|
+
*/
|
|
30
|
+
export const CONTRACT_ARTIFACTS = {
|
|
31
|
+
json: 'contract.json',
|
|
32
|
+
types: 'contract.d.ts',
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Convert a (possibly Windows) relative path into a POSIX module specifier,
|
|
36
|
+
* kept explicitly relative so it is never read as a bare package specifier.
|
|
37
|
+
*/
|
|
38
|
+
function toModuleSpecifier(relative) {
|
|
27
39
|
const posix = relative.split(path.sep).join('/');
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
// but a schema at the project root yields an empty relative path, which
|
|
31
|
-
// Prisma would reject; emit `.` instead.
|
|
32
|
-
return posix === '' ? '.' : posix;
|
|
33
|
-
}
|
|
34
|
-
// An import specifier — must be explicitly relative so it isn't treated as a
|
|
35
|
-
// node_modules package.
|
|
40
|
+
if (posix === '')
|
|
41
|
+
return '.';
|
|
36
42
|
return posix.startsWith('.') ? posix : `./${posix}`;
|
|
37
43
|
}
|
|
38
44
|
/**
|
|
@@ -52,14 +58,16 @@ function toModuleSpecifier(relative, { allowBare }) {
|
|
|
52
58
|
* used as the bundle directory when no `output.opensaasDir` is set.
|
|
53
59
|
*/
|
|
54
60
|
export function resolveOutputPaths(cwd, output, opensaasPathFallback) {
|
|
55
|
-
const
|
|
61
|
+
const contractModuleRel = output?.contractModule ?? DEFAULT_CONTRACT_MODULE;
|
|
56
62
|
const opensaasDirRel = output?.opensaasDir ?? opensaasPathFallback ?? DEFAULT_OPENSAAS_DIR;
|
|
57
|
-
const
|
|
63
|
+
const contractModuleAbs = path.resolve(cwd, contractModuleRel);
|
|
64
|
+
const contractDirAbs = path.dirname(contractModuleAbs);
|
|
58
65
|
const opensaasDirAbs = path.resolve(cwd, opensaasDirRel);
|
|
59
|
-
const schemaDirAbs = path.dirname(prismaSchemaAbs);
|
|
60
|
-
const prismaClientAbs = path.join(opensaasDirAbs, OPENSAAS_FILES.prismaClient);
|
|
61
66
|
const paths = {
|
|
62
|
-
|
|
67
|
+
contractModule: contractModuleAbs,
|
|
68
|
+
contractDir: contractDirAbs,
|
|
69
|
+
contractJson: path.join(contractDirAbs, CONTRACT_ARTIFACTS.json),
|
|
70
|
+
contractTypes: path.join(contractDirAbs, CONTRACT_ARTIFACTS.types),
|
|
63
71
|
// prisma.config.ts is always written at the project root (not configurable).
|
|
64
72
|
prismaConfig: path.resolve(cwd, 'prisma.config.ts'),
|
|
65
73
|
opensaasDir: opensaasDirAbs,
|
|
@@ -67,16 +75,46 @@ export function resolveOutputPaths(cwd, output, opensaasPathFallback) {
|
|
|
67
75
|
lists: path.join(opensaasDirAbs, OPENSAAS_FILES.lists),
|
|
68
76
|
context: path.join(opensaasDirAbs, OPENSAAS_FILES.context),
|
|
69
77
|
pluginTypes: path.join(opensaasDirAbs, OPENSAAS_FILES.pluginTypes),
|
|
78
|
+
tables: path.join(opensaasDirAbs, OPENSAAS_FILES.tables),
|
|
70
79
|
};
|
|
71
80
|
const crossReferences = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
configImport: toModuleSpecifier(path.join(path.relative(opensaasDirAbs, cwd), 'opensaas.config'), {
|
|
77
|
-
allowBare: false,
|
|
78
|
-
}),
|
|
81
|
+
prismaConfigContract: toModuleSpecifier(path.relative(cwd, contractModuleAbs)),
|
|
82
|
+
prismaConfigOutput: toModuleSpecifier(path.relative(cwd, contractDirAbs)),
|
|
83
|
+
contractJsonImport: toModuleSpecifier(path.relative(opensaasDirAbs, paths.contractJson)),
|
|
84
|
+
configImport: toModuleSpecifier(path.join(path.relative(opensaasDirAbs, cwd), 'opensaas.config')),
|
|
79
85
|
};
|
|
80
86
|
return { paths, crossReferences };
|
|
81
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* The same set of files, redirected under a staging directory: the Contract
|
|
90
|
+
* module and the two artifacts `prisma contract emit` writes beside it in one
|
|
91
|
+
* subdirectory, the bundle in another, and the Prisma config that drives the
|
|
92
|
+
* staged emission at the top.
|
|
93
|
+
*
|
|
94
|
+
* The two subdirectories keep a Contract module named after a bundle file from
|
|
95
|
+
* landing on top of it, since both sets are flattened into one place here.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const staged = stageWritePaths(paths, path.join(cwd, '.opensaas', 'staged'))
|
|
100
|
+
* writeContractModule(contractData, staged.contractModule)
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export function stageWritePaths(paths, stagingDir) {
|
|
104
|
+
const contractDir = path.join(stagingDir, 'contract');
|
|
105
|
+
const bundleDir = path.join(stagingDir, 'bundle');
|
|
106
|
+
return {
|
|
107
|
+
contractModule: path.join(contractDir, path.basename(paths.contractModule)),
|
|
108
|
+
contractDir,
|
|
109
|
+
contractJson: path.join(contractDir, CONTRACT_ARTIFACTS.json),
|
|
110
|
+
contractTypes: path.join(contractDir, CONTRACT_ARTIFACTS.types),
|
|
111
|
+
prismaConfig: path.join(stagingDir, 'prisma.config.ts'),
|
|
112
|
+
opensaasDir: bundleDir,
|
|
113
|
+
types: path.join(bundleDir, OPENSAAS_FILES.types),
|
|
114
|
+
lists: path.join(bundleDir, OPENSAAS_FILES.lists),
|
|
115
|
+
context: path.join(bundleDir, OPENSAAS_FILES.context),
|
|
116
|
+
pluginTypes: path.join(bundleDir, OPENSAAS_FILES.pluginTypes),
|
|
117
|
+
tables: path.join(bundleDir, OPENSAAS_FILES.tables),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
82
120
|
//# sourceMappingURL=output-paths.js.map
|
|
@@ -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,
|
|
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,uBAAuB,GAAG,oBAAoB,CAAA;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAA;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,YAAY;IACrB,WAAW,EAAE,iBAAiB;IAC9B,MAAM,EAAE,WAAW;CACX,CAAA;AAEV;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAA;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,eAAe;CACd,CAAA;AAuEV;;;GAGG;AACH,SAAS,iBAA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,kBAAkB,CAAC,IAAI,CAAC;QAC7D,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,KAAK,CAAC;QAC/D,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC;QACvD,WAAW,EAAE,SAAS;QACtB,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,KAAK,CAAC;QACjD,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,KAAK,CAAC;QACjD,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,OAAO,CAAC;QACrD,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,WAAW,CAAC;QAC7D,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC;KACpD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pinned `prisma` CLI from the project's own dependency tree, so a command
|
|
3
|
+
* runs the toolchain version the project depends on rather than whatever `npx`
|
|
4
|
+
* would fetch. Resolving the package (rather than looking only in `<cwd>`)
|
|
5
|
+
* finds it wherever the installer put it — a pnpm workspace hoists it to the
|
|
6
|
+
* workspace root, and a monorepo sub-app has no local `node_modules` at all.
|
|
7
|
+
*
|
|
8
|
+
* The entry comes off the resolved manifest's `bin` rather than an assumed
|
|
9
|
+
* path, so a layout change between prereleases surfaces as the real error
|
|
10
|
+
* instead of "prisma is not installed" immediately after resolution succeeded.
|
|
11
|
+
* It is preferred over `node_modules/.bin/prisma` because it is a `.js` file
|
|
12
|
+
* this process can run with `process.execPath` on every platform, where the
|
|
13
|
+
* shim is an `sh` script that spawning without a shell cannot run on Windows.
|
|
14
|
+
*
|
|
15
|
+
* Known limits:
|
|
16
|
+
* - The `.bin` shim fallback is POSIX-only. It is reached only when `prisma`
|
|
17
|
+
* is installed but not resolvable as a package from `cwd`, which the
|
|
18
|
+
* manifest lookup covers for every normal install.
|
|
19
|
+
*
|
|
20
|
+
* @throws when the project has no `prisma` installed, naming the package.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolvePrismaBinary(cwd: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* How a Prisma CLI run is wired to this process:
|
|
25
|
+
*
|
|
26
|
+
* - `'capture'` closes stdin and collects the CLI's own output for an error
|
|
27
|
+
* message.
|
|
28
|
+
* - `'interactive'` hands the CLI this process's terminal, which is what lets
|
|
29
|
+
* a destructive `db update` reach the user with its consent prompt
|
|
30
|
+
* (ADR-0063).
|
|
31
|
+
*/
|
|
32
|
+
export type PrismaCliStdio = 'capture' | 'interactive';
|
|
33
|
+
/** How a Prisma CLI run ended. */
|
|
34
|
+
export interface PrismaCliRun {
|
|
35
|
+
readonly exitCode: number | null;
|
|
36
|
+
readonly signal: string | null;
|
|
37
|
+
/** Combined stdout and stderr; empty for an `'interactive'` run. */
|
|
38
|
+
readonly output: string;
|
|
39
|
+
/**
|
|
40
|
+
* Stdout alone, where `--json`'s newline-delimited envelopes arrive
|
|
41
|
+
* unmixed with the CLI's commentary.
|
|
42
|
+
*/
|
|
43
|
+
readonly stdout: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Run one Prisma CLI command in the project and resolve when it exits.
|
|
47
|
+
*
|
|
48
|
+
* Asynchronous, always: a `spawnSync` blocks the event loop the Dev database's
|
|
49
|
+
* socket server is served on, which deadlocks the first `db update` the dev
|
|
50
|
+
* loop runs against its own sidecar (ADR-0063). A `'capture'` run also closes
|
|
51
|
+
* stdin rather than piping it, because the rc.12 CLI blocks forever on a
|
|
52
|
+
* piped-but-unwritten stdin even with no prompt to answer.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const run = await runPrismaCli(cwd, ['db', 'update'], 'interactive')
|
|
57
|
+
* if (run.exitCode !== 0) throw new Error('reconciliation failed')
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function runPrismaCli(cwd: string, args: readonly string[], stdio?: PrismaCliStdio): Promise<PrismaCliRun>;
|
|
61
|
+
//# sourceMappingURL=prisma-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-cli.d.ts","sourceRoot":"","sources":["../../src/generator/prisma-cli.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAwBvD;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,aAAa,CAAA;AAEtD,kCAAkC;AAClC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,KAAK,GAAE,cAA0B,GAChC,OAAO,CAAC,YAAY,CAAC,CA2BvB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
/**
|
|
6
|
+
* The pinned `prisma` CLI from the project's own dependency tree, so a command
|
|
7
|
+
* runs the toolchain version the project depends on rather than whatever `npx`
|
|
8
|
+
* would fetch. Resolving the package (rather than looking only in `<cwd>`)
|
|
9
|
+
* finds it wherever the installer put it — a pnpm workspace hoists it to the
|
|
10
|
+
* workspace root, and a monorepo sub-app has no local `node_modules` at all.
|
|
11
|
+
*
|
|
12
|
+
* The entry comes off the resolved manifest's `bin` rather than an assumed
|
|
13
|
+
* path, so a layout change between prereleases surfaces as the real error
|
|
14
|
+
* instead of "prisma is not installed" immediately after resolution succeeded.
|
|
15
|
+
* It is preferred over `node_modules/.bin/prisma` because it is a `.js` file
|
|
16
|
+
* this process can run with `process.execPath` on every platform, where the
|
|
17
|
+
* shim is an `sh` script that spawning without a shell cannot run on Windows.
|
|
18
|
+
*
|
|
19
|
+
* Known limits:
|
|
20
|
+
* - The `.bin` shim fallback is POSIX-only. It is reached only when `prisma`
|
|
21
|
+
* is installed but not resolvable as a package from `cwd`, which the
|
|
22
|
+
* manifest lookup covers for every normal install.
|
|
23
|
+
*
|
|
24
|
+
* @throws when the project has no `prisma` installed, naming the package.
|
|
25
|
+
*/
|
|
26
|
+
export function resolvePrismaBinary(cwd) {
|
|
27
|
+
try {
|
|
28
|
+
const require = createRequire(path.join(cwd, 'noop.js'));
|
|
29
|
+
const packageJson = require.resolve('prisma/package.json');
|
|
30
|
+
const manifest = require(packageJson);
|
|
31
|
+
const entry = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin?.prisma;
|
|
32
|
+
if (entry !== undefined) {
|
|
33
|
+
const binary = path.join(path.dirname(packageJson), entry);
|
|
34
|
+
if (fs.existsSync(binary))
|
|
35
|
+
return binary;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// A resolution failure and a missing file are the same problem for the
|
|
40
|
+
// caller: fall through to the shim, then to the error below.
|
|
41
|
+
}
|
|
42
|
+
if (process.platform !== 'win32') {
|
|
43
|
+
const shim = path.join(cwd, 'node_modules', '.bin', 'prisma');
|
|
44
|
+
if (fs.existsSync(shim))
|
|
45
|
+
return shim;
|
|
46
|
+
}
|
|
47
|
+
throw new Error('The `prisma` CLI is not installed in this project. Add it as a dependency ' +
|
|
48
|
+
'(`pnpm add -D prisma`) so `opensaas generate` can emit the contract artifacts.');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Run one Prisma CLI command in the project and resolve when it exits.
|
|
52
|
+
*
|
|
53
|
+
* Asynchronous, always: a `spawnSync` blocks the event loop the Dev database's
|
|
54
|
+
* socket server is served on, which deadlocks the first `db update` the dev
|
|
55
|
+
* loop runs against its own sidecar (ADR-0063). A `'capture'` run also closes
|
|
56
|
+
* stdin rather than piping it, because the rc.12 CLI blocks forever on a
|
|
57
|
+
* piped-but-unwritten stdin even with no prompt to answer.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const run = await runPrismaCli(cwd, ['db', 'update'], 'interactive')
|
|
62
|
+
* if (run.exitCode !== 0) throw new Error('reconciliation failed')
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export async function runPrismaCli(cwd, args, stdio = 'capture') {
|
|
66
|
+
const binary = resolvePrismaBinary(cwd);
|
|
67
|
+
const isScript = /\.[mc]?js$/.test(binary);
|
|
68
|
+
const command = isScript ? process.execPath : binary;
|
|
69
|
+
const commandArgs = isScript ? [binary, ...args] : [...args];
|
|
70
|
+
return await new Promise((resolve, reject) => {
|
|
71
|
+
const child = spawn(command, commandArgs, {
|
|
72
|
+
cwd,
|
|
73
|
+
stdio: stdio === 'interactive' ? 'inherit' : ['ignore', 'pipe', 'pipe'],
|
|
74
|
+
});
|
|
75
|
+
let output = '';
|
|
76
|
+
let stdout = '';
|
|
77
|
+
for (const stream of [child.stdout, child.stderr]) {
|
|
78
|
+
if (stream === null)
|
|
79
|
+
continue;
|
|
80
|
+
const isStdout = stream === child.stdout;
|
|
81
|
+
stream.setEncoding('utf-8');
|
|
82
|
+
stream.on('data', (chunk) => {
|
|
83
|
+
output += chunk;
|
|
84
|
+
if (isStdout)
|
|
85
|
+
stdout += chunk;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
child.once('error', reject);
|
|
89
|
+
child.once('close', (exitCode, signal) => resolve({ exitCode, signal, output, stdout }));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=prisma-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-cli.js","sourceRoot":"","sources":["../../src/generator/prisma-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAEtC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAA;QACxD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA;QAC1D,MAAM,QAAQ,GAA8C,OAAO,CAAC,WAAW,CAAC,CAAA;QAChF,MAAM,KAAK,GAAG,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;QACpF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,CAAA;YAC1D,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;gBAAE,OAAO,MAAM,CAAA;QAC1C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,uEAAuE;QACvE,6DAA6D;IAC/D,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,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,IAAI;gBAAE,SAAQ;YAC7B,MAAM,QAAQ,GAAG,MAAM,KAAK,KAAK,CAAC,MAAM,CAAA;YACxC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;YAC3B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;gBAClC,MAAM,IAAI,KAAK,CAAA;gBACf,IAAI,QAAQ;oBAAE,MAAM,IAAI,KAAK,CAAA;YAC/B,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAC3B,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IAC1F,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,38 +1,57 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContractData } from '@opensaas/stack-core';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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).
|
|
10
|
-
*
|
|
11
|
-
* @param extraDatasourceLines - Verbatim `datasource` block entries the
|
|
12
|
-
* generator does not itself manage (e.g. a host-added `shadowDatabaseUrl`),
|
|
13
|
-
* extracted from a pre-existing file by {@link extractExtraDatasourceLines}.
|
|
14
|
-
* Re-emitted after the managed `url` key so a re-generate does not drop them.
|
|
3
|
+
* What a config written somewhere other than the project root has to say
|
|
4
|
+
* outright, because its own directory no longer answers it: which migrations
|
|
5
|
+
* graph it shares, and whose `.env` it loads.
|
|
15
6
|
*/
|
|
16
|
-
export
|
|
7
|
+
export interface PrismaConfigLocationOverrides {
|
|
8
|
+
/**
|
|
9
|
+
* The migrations directory. Omitted, the CLI takes its own default beside
|
|
10
|
+
* the config file — right for the project-root config, wrong for a staged
|
|
11
|
+
* one, which must share the project's graph rather than start a private one.
|
|
12
|
+
*/
|
|
13
|
+
migrationsDir?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The directory whose `.env` is loaded. Defaults to the config file's own
|
|
16
|
+
* directory.
|
|
17
|
+
*/
|
|
18
|
+
envDir?: string;
|
|
19
|
+
}
|
|
17
20
|
/**
|
|
18
|
-
*
|
|
19
|
-
* `prisma.config.ts` file, so a re-generate can preserve them instead of
|
|
20
|
-
* clobbering the block wholesale.
|
|
21
|
+
* Render the project-root `prisma.config.ts` the Prisma 8 CLI reads.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* The file wires four things and nothing else: the Contract module's path, the
|
|
24
|
+
* directory the emitted artifacts land in beside it, each declared extension
|
|
25
|
+
* pack's control façade, and the database connection. It never imports
|
|
26
|
+
* `opensaas.config.ts` — the CLI evaluates this file for every command, and a
|
|
27
|
+
* config import would drag the app's plugins, hooks and environment reads onto
|
|
28
|
+
* that path (ADR-0040).
|
|
25
29
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
30
|
+
* The connection is resolved here, so this is also where the project's `.env`
|
|
31
|
+
* is loaded: Prisma's config evaluation loads no dotenv of its own, and
|
|
32
|
+
* ADR-0040's ban on environment reads covers the Contract module, not this
|
|
33
|
+
* file.
|
|
34
|
+
*
|
|
35
|
+
* `definePrismaConfig` stamps the version marker the rc.12 CLI requires; the
|
|
36
|
+
* ORM's own options live under its `orm` section.
|
|
37
|
+
*
|
|
38
|
+
* @param data - The derived contract, read only for its declared extensions.
|
|
39
|
+
* @param contractModule - The Contract module's path relative to the project
|
|
40
|
+
* root, POSIX-separated (e.g. `./prisma/contract.ts`).
|
|
41
|
+
* @param outputDir - Where `contract.json` and `contract.d.ts` are written —
|
|
42
|
+
* the Contract module's own directory.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* writePrismaConfig(deriveContract(config), '/app/prisma.config.ts', {
|
|
47
|
+
* contractModule: './prisma/contract.ts',
|
|
48
|
+
* outputDir: './prisma',
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
36
51
|
*/
|
|
37
|
-
export declare function
|
|
52
|
+
export declare function generatePrismaConfig(data: ContractData, contractModule: string, outputDir: string, overrides?: PrismaConfigLocationOverrides): string;
|
|
53
|
+
export declare function writePrismaConfig(data: ContractData, outputPath: string, references: {
|
|
54
|
+
contractModule: string;
|
|
55
|
+
outputDir: string;
|
|
56
|
+
} & PrismaConfigLocationOverrides): void;
|
|
38
57
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"prisma-config.d.ts","sourceRoot":"","sources":["../../src/generator/prisma-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAexD;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,YAAY,EAClB,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,6BAAkC,GAC5C,MAAM,CAoCR;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,YAAY,EAClB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,6BAA6B,GACxF,IAAI,CAYN"}
|