@powerlines/plugin-prisma 0.4.286 → 0.4.288

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.
@@ -0,0 +1,74 @@
1
+ import { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig } from "@powerlines/plugin-pulumi";
2
+ import { ResolvedConfig, UserConfig } from "powerlines";
3
+ import { Options, Options as PowerPlantPrismaOptions } from "@power-plant/prisma";
4
+ import { PrismaSchema, PrismaSchema as PrismaSchema$1 } from "@power-plant/prisma-schema";
5
+ import { PowerPlantPluginContext, PowerPlantPluginResolvedConfig } from "@powerlines/plugin-power-plant/types/plugin";
6
+ //#region src/types/plugin.d.ts
7
+ interface PrismaPostgresPrismaPluginOptions {
8
+ /**
9
+ * The Prisma project name
10
+ *
11
+ * @defaultValue "\{name\}"
12
+ */
13
+ projectId?: string;
14
+ /**
15
+ * The region to deploy the database to
16
+ *
17
+ * @defaultValue "us-east-1"
18
+ */
19
+ region?: "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "af-south-1" | "ap-east-1" | "ap-south-1" | "ap-south-2" | "ap-southeast-1" | "ap-southeast-2" | "ap-southeast-3" | "ap-southeast-4" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "ca-west-1" | "eu-central-1" | "eu-central-2" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "eu-south-1" | "eu-south-2" | "il-central-1" | "me-south-1" | "me-central-1" | "sa-east-1";
20
+ /**
21
+ * The database name
22
+ *
23
+ * @defaultValue "\{region\}.\{mode\}.\{name\}"
24
+ */
25
+ databaseName?: string;
26
+ }
27
+ /**
28
+ * Options for the Prisma Powerlines plugin.
29
+ */
30
+ type PrismaPluginOptions = Partial<Omit<Options, "schemaPath">> & {
31
+ /**
32
+ * Path to the Prisma schema file (or directory) used by `@power-plant/prisma`.
33
+ *
34
+ * @remarks
35
+ * Maps to the Power Plant generator `schemaPath` option. This field allows
36
+ * the use of the "\{projectRoot\}" token to refer to the project's root
37
+ * directory - the value will be replaced with the correct file path by the
38
+ * plugin.
39
+ *
40
+ * @defaultValue "\{projectRoot\}/prisma"
41
+ */
42
+ schema?: string;
43
+ /**
44
+ * The service token to use for the Prisma API
45
+ */
46
+ serviceToken?: string;
47
+ /**
48
+ * Configuration parameters to manage a Prisma Postgres database
49
+ */
50
+ prismaPostgres?: PrismaPostgresPrismaPluginOptions | true;
51
+ /**
52
+ * The configuration options for Pulumi.
53
+ */
54
+ pulumi?: PulumiPluginOptions;
55
+ };
56
+ type PrismaPluginUserConfig = UserConfig & PulumiPluginUserConfig & {
57
+ prisma?: PrismaPluginOptions;
58
+ };
59
+ type PrismaPluginResolvedConfig = ResolvedConfig & PulumiPluginResolvedConfig & PowerPlantPluginResolvedConfig<PrismaSchema$1, Options> & {
60
+ prisma: Omit<PrismaPluginOptions, "schema" | "prismaPostgres"> & {
61
+ /**
62
+ * Path to the Prisma schema file (or directory).
63
+ */
64
+ schema: string;
65
+ /**
66
+ * Configuration parameters to manage a Prisma Postgres database
67
+ */
68
+ prismaPostgres?: Required<PrismaPostgresPrismaPluginOptions>;
69
+ };
70
+ };
71
+ type PrismaPluginContext<TResolvedConfig extends PrismaPluginResolvedConfig = PrismaPluginResolvedConfig> = PowerPlantPluginContext<PrismaSchema$1, Options, TResolvedConfig> & PulumiPluginContext;
72
+ //#endregion
73
+ export { type PowerPlantPrismaOptions, PrismaPluginContext, PrismaPluginOptions, PrismaPluginResolvedConfig, PrismaPluginUserConfig, PrismaPostgresPrismaPluginOptions, type PrismaSchema };
74
+ //# sourceMappingURL=plugin.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-prisma",
3
- "version": "0.4.286",
3
+ "version": "0.4.288",
4
4
  "private": false,
5
5
  "description": "A Powerlines plugin to generate project code and a Prisma client from a Prisma schema (PSL).",
6
6
  "keywords": ["prisma", "powerlines", "storm-software", "powerlines-plugin"],
@@ -54,76 +54,6 @@
54
54
  "default": "./dist/index.mjs"
55
55
  }
56
56
  },
57
- "./helpers": {
58
- "require": {
59
- "types": "./dist/helpers/index.d.cts",
60
- "default": "./dist/helpers/index.cjs"
61
- },
62
- "import": {
63
- "types": "./dist/helpers/index.d.mts",
64
- "default": "./dist/helpers/index.mjs"
65
- },
66
- "default": {
67
- "types": "./dist/helpers/index.d.mts",
68
- "default": "./dist/helpers/index.mjs"
69
- }
70
- },
71
- "./helpers/client-generator": {
72
- "require": {
73
- "types": "./dist/helpers/client-generator.d.cts",
74
- "default": "./dist/helpers/client-generator.cjs"
75
- },
76
- "import": {
77
- "types": "./dist/helpers/client-generator.d.mts",
78
- "default": "./dist/helpers/client-generator.mjs"
79
- },
80
- "default": {
81
- "types": "./dist/helpers/client-generator.d.mts",
82
- "default": "./dist/helpers/client-generator.mjs"
83
- }
84
- },
85
- "./helpers/get-schema": {
86
- "require": {
87
- "types": "./dist/helpers/get-schema.d.cts",
88
- "default": "./dist/helpers/get-schema.cjs"
89
- },
90
- "import": {
91
- "types": "./dist/helpers/get-schema.d.mts",
92
- "default": "./dist/helpers/get-schema.mjs"
93
- },
94
- "default": {
95
- "types": "./dist/helpers/get-schema.d.mts",
96
- "default": "./dist/helpers/get-schema.mjs"
97
- }
98
- },
99
- "./helpers/schema-creator": {
100
- "require": {
101
- "types": "./dist/helpers/schema-creator.d.cts",
102
- "default": "./dist/helpers/schema-creator.cjs"
103
- },
104
- "import": {
105
- "types": "./dist/helpers/schema-creator.d.mts",
106
- "default": "./dist/helpers/schema-creator.mjs"
107
- },
108
- "default": {
109
- "types": "./dist/helpers/schema-creator.d.mts",
110
- "default": "./dist/helpers/schema-creator.mjs"
111
- }
112
- },
113
- "./helpers/typed-sql": {
114
- "require": {
115
- "types": "./dist/helpers/typed-sql.d.cts",
116
- "default": "./dist/helpers/typed-sql.cjs"
117
- },
118
- "import": {
119
- "types": "./dist/helpers/typed-sql.d.mts",
120
- "default": "./dist/helpers/typed-sql.mjs"
121
- },
122
- "default": {
123
- "types": "./dist/helpers/typed-sql.d.mts",
124
- "default": "./dist/helpers/typed-sql.mjs"
125
- }
126
- },
127
57
  "./package.json": "./package.json",
128
58
  "./types": {
129
59
  "require": {
@@ -152,20 +82,6 @@
152
82
  "types": "./dist/types/plugin.d.mts",
153
83
  "default": "./dist/types/plugin.mjs"
154
84
  }
155
- },
156
- "./types/prisma": {
157
- "require": {
158
- "types": "./dist/types/prisma.d.cts",
159
- "default": "./dist/types/prisma.cjs"
160
- },
161
- "import": {
162
- "types": "./dist/types/prisma.d.mts",
163
- "default": "./dist/types/prisma.mjs"
164
- },
165
- "default": {
166
- "types": "./dist/types/prisma.d.mts",
167
- "default": "./dist/types/prisma.mjs"
168
- }
169
85
  }
170
86
  },
171
87
  "main": "./dist/index.cjs",
@@ -174,34 +90,21 @@
174
90
  "typings": "dist/index.d.mts",
175
91
  "files": ["dist/**/*"],
176
92
  "dependencies": {
177
- "@powerlines/plugin-pulumi": "0.6.245",
178
- "@prisma/client-generator-registry": "7.6.0",
179
- "@prisma/config": "7.6.0",
180
- "@prisma/dmmf": "7.6.0",
181
- "@prisma/generator-helper": "7.6.0",
182
- "@prisma/get-platform": "6.19.3",
183
- "@prisma/migrate": "7.6.0",
184
- "@prisma/prisma-schema-wasm": "6.19.0-26.2ba551f319ab1df4bc874a89965d8b3641056773",
185
- "@stryke/cli": "^0.13.68",
186
- "@stryke/convert": "^0.7.26",
187
- "@stryke/fs": "^0.33.96",
188
- "@stryke/path": "^0.29.22",
189
- "@stryke/string-format": "^0.17.37",
190
- "@stryke/type-checks": "^0.6.28",
191
- "@stryke/types": "^0.12.23",
93
+ "@power-plant/core": "^0.0.23",
94
+ "@power-plant/prisma": "^0.0.4",
95
+ "@power-plant/prisma-schema": "^0.0.1",
96
+ "@powerlines/plugin-power-plant": "^0.1.1",
97
+ "@powerlines/plugin-pulumi": "^0.6.247",
98
+ "@stryke/path": "^0.29.23",
99
+ "@stryke/string-format": "^0.17.38",
192
100
  "defu": "^6.1.7",
193
- "fp-ts": "^2.16.11",
194
- "jiti": "^2.7.0",
195
- "powerlines": "0.47.143",
196
- "prisma-util": "^2.1.1",
197
- "ts-pattern": "^5.9.0"
101
+ "powerlines": "^0.47.145"
198
102
  },
199
103
  "devDependencies": {
200
- "@powerlines/plugin-plugin": "0.12.555",
201
- "@prisma/client-generator-ts": "7.6.0",
202
- "@pulumi/pulumi": "^3.251.0",
104
+ "@powerlines/plugin-plugin": "^0.12.557",
105
+ "@pulumi/pulumi": "^3.253.0",
203
106
  "@types/node": "^25.9.5"
204
107
  },
205
108
  "publishConfig": { "access": "public" },
206
- "gitHead": "cea2b02d3fb6556ff2e53576b6a17787b4e28d67"
109
+ "gitHead": "d81170b608c0b80e7726e129c3edd1b7b6ca2605"
207
110
  }
@@ -1,152 +0,0 @@
1
- let _stryke_path_find = require("@stryke/path/find");
2
- let _prisma_client_generator_ts = require("@prisma/client-generator-ts");
3
- let _prisma_engines_version = require("@prisma/engines-version");
4
- let _stryke_convert_buffer_to_string = require("@stryke/convert/buffer-to-string");
5
- let _stryke_path_replace = require("@stryke/path/replace");
6
- let _stryke_type_checks_is_buffer = require("@stryke/type-checks/is-buffer");
7
- let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
8
-
9
- //#region package.json
10
- var version = "0.4.285";
11
-
12
- //#endregion
13
- //#region src/helpers/client-generator.ts
14
- var PowerlinesClientGenerator = class {
15
- context;
16
- #options;
17
- name = "powerlines-client";
18
- constructor(context) {
19
- this.context = context;
20
- this.#options = {
21
- name: this.name,
22
- output: null,
23
- config: {},
24
- provider: {
25
- fromEnvVar: "POWERLINES_CLIENT_PROVIDER",
26
- value: this.name
27
- },
28
- binaryTargets: [],
29
- previewFeatures: this.context.prisma.previewFeatures,
30
- sourceFilePath: this.context.prisma.schema.schemaRootDir
31
- };
32
- }
33
- async getManifest(_config) {
34
- return Promise.resolve({
35
- defaultOutput: "./generated",
36
- prettyName: "Powerlines Client",
37
- version,
38
- requiresEngines: [],
39
- requiresEngineVersion: _prisma_engines_version.enginesVersion
40
- });
41
- }
42
- async generate() {
43
- const { prismaClientDmmf, fileMap } = (0, _prisma_client_generator_ts.buildClient)({
44
- datamodel: this.context.prisma.schema.schemas.map((s) => s.content).join("\n"),
45
- schemaPath: this.context.prisma.schema.schemaPath,
46
- binaryPaths: {},
47
- datasources: this.context.prisma.schema.datasources,
48
- outputDir: this.context.config.prisma.outputPath,
49
- runtimeBase: "@prisma/client/runtime",
50
- dmmf: this.context.prisma.dmmf,
51
- generator: this.#options,
52
- engineVersion: _prisma_engines_version.enginesVersion,
53
- clientVersion: version,
54
- activeProvider: this.context.prisma.schema.primaryDatasource?.activeProvider,
55
- typedSql: this.context.prisma.typedSql,
56
- target: this.context.config.prisma.runtime,
57
- generatedFileExtension: "ts",
58
- importFileExtension: "ts",
59
- moduleFormat: "esm",
60
- tsNoCheckPreamble: true,
61
- compilerBuild: "fast"
62
- });
63
- const errorArray = [];
64
- const denylists = {
65
- models: [
66
- "PrismaClient",
67
- "Prisma",
68
- "async",
69
- "await",
70
- "break",
71
- "case",
72
- "catch",
73
- "class",
74
- "const",
75
- "continue",
76
- "debugger",
77
- "default",
78
- "delete",
79
- "do",
80
- "else",
81
- "enum",
82
- "export",
83
- "extends",
84
- "false",
85
- "finally",
86
- "for",
87
- "function",
88
- "if",
89
- "implements",
90
- "import",
91
- "in",
92
- "instanceof",
93
- "interface",
94
- "let",
95
- "new",
96
- "null",
97
- "package",
98
- "private",
99
- "protected",
100
- "public",
101
- "return",
102
- "super",
103
- "switch",
104
- "this",
105
- "throw",
106
- "true",
107
- "try",
108
- "using",
109
- "typeof",
110
- "var",
111
- "void",
112
- "while",
113
- "with",
114
- "yield"
115
- ],
116
- fields: [
117
- "AND",
118
- "OR",
119
- "NOT"
120
- ],
121
- dynamic: []
122
- };
123
- if (prismaClientDmmf.datamodel.enums) {
124
- for (const it of prismaClientDmmf.datamodel.enums) if (denylists.models.includes(it.name) || denylists.fields.includes(it.name)) errorArray.push(/* @__PURE__ */ new Error(`"enum ${it.name}"`));
125
- }
126
- if (prismaClientDmmf.datamodel.models) {
127
- for (const it of prismaClientDmmf.datamodel.models) if (denylists.models.includes(it.name) || denylists.fields.includes(it.name)) errorArray.push(/* @__PURE__ */ new Error(`"model ${it.name}"`));
128
- }
129
- if (errorArray.length > 0) {
130
- let message = `Error: The schema at "${this.context.prisma.schema.schemaPath}" contains reserved keywords.\n Rename the following items:`;
131
- for (const error of errorArray) message += `\n - ${error.message}`;
132
- throw new Error(`${message}\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`);
133
- }
134
- await this.writeFileMap(fileMap);
135
- }
136
- stop() {}
137
- async writeFileMap(fileMap) {
138
- return Promise.all(Object.entries(fileMap).map(async ([fileName, content]) => {
139
- if ((0, _stryke_type_checks_is_string.isString)(content)) this.context.emitBuiltinSync(content, `prisma/${(0, _stryke_path_replace.replaceExtension)(fileName)}`, { extension: (0, _stryke_path_find.findFileExtension)(fileName) || "ts" });
140
- else if ((0, _stryke_type_checks_is_buffer.isBuffer)(content)) this.context.emitBuiltinSync((0, _stryke_convert_buffer_to_string.bufferToString)(content), `prisma/${(0, _stryke_path_replace.replaceExtension)(fileName)}`, { extension: (0, _stryke_path_find.findFileExtension)(fileName) || "ts" });
141
- else await this.writeFileMap(content);
142
- }));
143
- }
144
- };
145
-
146
- //#endregion
147
- Object.defineProperty(exports, 'PowerlinesClientGenerator', {
148
- enumerable: true,
149
- get: function () {
150
- return PowerlinesClientGenerator;
151
- }
152
- });
@@ -1,147 +0,0 @@
1
- import { findFileExtension } from "@stryke/path/find";
2
- import { buildClient } from "@prisma/client-generator-ts";
3
- import { enginesVersion } from "@prisma/engines-version";
4
- import { bufferToString } from "@stryke/convert/buffer-to-string";
5
- import { replaceExtension } from "@stryke/path/replace";
6
- import { isBuffer } from "@stryke/type-checks/is-buffer";
7
- import { isString } from "@stryke/type-checks/is-string";
8
-
9
- //#region package.json
10
- var version = "0.4.285";
11
-
12
- //#endregion
13
- //#region src/helpers/client-generator.ts
14
- var PowerlinesClientGenerator = class {
15
- context;
16
- #options;
17
- name = "powerlines-client";
18
- constructor(context) {
19
- this.context = context;
20
- this.#options = {
21
- name: this.name,
22
- output: null,
23
- config: {},
24
- provider: {
25
- fromEnvVar: "POWERLINES_CLIENT_PROVIDER",
26
- value: this.name
27
- },
28
- binaryTargets: [],
29
- previewFeatures: this.context.prisma.previewFeatures,
30
- sourceFilePath: this.context.prisma.schema.schemaRootDir
31
- };
32
- }
33
- async getManifest(_config) {
34
- return Promise.resolve({
35
- defaultOutput: "./generated",
36
- prettyName: "Powerlines Client",
37
- version,
38
- requiresEngines: [],
39
- requiresEngineVersion: enginesVersion
40
- });
41
- }
42
- async generate() {
43
- const { prismaClientDmmf, fileMap } = buildClient({
44
- datamodel: this.context.prisma.schema.schemas.map((s) => s.content).join("\n"),
45
- schemaPath: this.context.prisma.schema.schemaPath,
46
- binaryPaths: {},
47
- datasources: this.context.prisma.schema.datasources,
48
- outputDir: this.context.config.prisma.outputPath,
49
- runtimeBase: "@prisma/client/runtime",
50
- dmmf: this.context.prisma.dmmf,
51
- generator: this.#options,
52
- engineVersion: enginesVersion,
53
- clientVersion: version,
54
- activeProvider: this.context.prisma.schema.primaryDatasource?.activeProvider,
55
- typedSql: this.context.prisma.typedSql,
56
- target: this.context.config.prisma.runtime,
57
- generatedFileExtension: "ts",
58
- importFileExtension: "ts",
59
- moduleFormat: "esm",
60
- tsNoCheckPreamble: true,
61
- compilerBuild: "fast"
62
- });
63
- const errorArray = [];
64
- const denylists = {
65
- models: [
66
- "PrismaClient",
67
- "Prisma",
68
- "async",
69
- "await",
70
- "break",
71
- "case",
72
- "catch",
73
- "class",
74
- "const",
75
- "continue",
76
- "debugger",
77
- "default",
78
- "delete",
79
- "do",
80
- "else",
81
- "enum",
82
- "export",
83
- "extends",
84
- "false",
85
- "finally",
86
- "for",
87
- "function",
88
- "if",
89
- "implements",
90
- "import",
91
- "in",
92
- "instanceof",
93
- "interface",
94
- "let",
95
- "new",
96
- "null",
97
- "package",
98
- "private",
99
- "protected",
100
- "public",
101
- "return",
102
- "super",
103
- "switch",
104
- "this",
105
- "throw",
106
- "true",
107
- "try",
108
- "using",
109
- "typeof",
110
- "var",
111
- "void",
112
- "while",
113
- "with",
114
- "yield"
115
- ],
116
- fields: [
117
- "AND",
118
- "OR",
119
- "NOT"
120
- ],
121
- dynamic: []
122
- };
123
- if (prismaClientDmmf.datamodel.enums) {
124
- for (const it of prismaClientDmmf.datamodel.enums) if (denylists.models.includes(it.name) || denylists.fields.includes(it.name)) errorArray.push(/* @__PURE__ */ new Error(`"enum ${it.name}"`));
125
- }
126
- if (prismaClientDmmf.datamodel.models) {
127
- for (const it of prismaClientDmmf.datamodel.models) if (denylists.models.includes(it.name) || denylists.fields.includes(it.name)) errorArray.push(/* @__PURE__ */ new Error(`"model ${it.name}"`));
128
- }
129
- if (errorArray.length > 0) {
130
- let message = `Error: The schema at "${this.context.prisma.schema.schemaPath}" contains reserved keywords.\n Rename the following items:`;
131
- for (const error of errorArray) message += `\n - ${error.message}`;
132
- throw new Error(`${message}\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`);
133
- }
134
- await this.writeFileMap(fileMap);
135
- }
136
- stop() {}
137
- async writeFileMap(fileMap) {
138
- return Promise.all(Object.entries(fileMap).map(async ([fileName, content]) => {
139
- if (isString(content)) this.context.emitBuiltinSync(content, `prisma/${replaceExtension(fileName)}`, { extension: findFileExtension(fileName) || "ts" });
140
- else if (isBuffer(content)) this.context.emitBuiltinSync(bufferToString(content), `prisma/${replaceExtension(fileName)}`, { extension: findFileExtension(fileName) || "ts" });
141
- else await this.writeFileMap(content);
142
- }));
143
- }
144
- };
145
-
146
- //#endregion
147
- export { PowerlinesClientGenerator as t };
@@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_client_generator = require('../client-generator-BSF1Jhxh.cjs');
3
-
4
- exports.PowerlinesClientGenerator = require_client_generator.PowerlinesClientGenerator;
@@ -1,3 +0,0 @@
1
- import { t as PowerlinesClientGenerator } from "../client-generator-Cjt43B68.mjs";
2
-
3
- export { PowerlinesClientGenerator };
@@ -1,102 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_rolldown_runtime = require('../rolldown-runtime-C_NdSu1c.cjs');
3
- let _prisma_get_platform = require("@prisma/get-platform");
4
- let _prisma_prisma_schema_wasm = require("@prisma/prisma-schema-wasm");
5
- _prisma_prisma_schema_wasm = require_rolldown_runtime.__toESM(_prisma_prisma_schema_wasm, 1);
6
- let fp_ts_Either = require("fp-ts/Either");
7
- fp_ts_Either = require_rolldown_runtime.__toESM(fp_ts_Either, 1);
8
- let fp_ts_lib_function = require("fp-ts/lib/function");
9
- let ts_pattern = require("ts-pattern");
10
-
11
- //#region src/helpers/get-schema.ts
12
- async function resolveBinaryTargets(generator) {
13
- for (const binaryTarget of generator.binaryTargets) {
14
- if (binaryTarget.fromEnvVar && process.env[binaryTarget.fromEnvVar]) {
15
- const value = JSON.parse(process.env[binaryTarget.fromEnvVar]);
16
- if (Array.isArray(value)) {
17
- generator.binaryTargets = value.map((v) => ({
18
- fromEnvVar: null,
19
- value: v
20
- }));
21
- await resolveBinaryTargets(generator);
22
- } else binaryTarget.value = value;
23
- }
24
- if (binaryTarget.value === "native") {
25
- binaryTarget.value = await (0, _prisma_get_platform.getBinaryTargetForCurrentPlatform)();
26
- binaryTarget.native = true;
27
- }
28
- }
29
- if (generator.binaryTargets.length === 0) generator.binaryTargets = [{
30
- fromEnvVar: null,
31
- value: await (0, _prisma_get_platform.getBinaryTargetForCurrentPlatform)(),
32
- native: true
33
- }];
34
- }
35
- /**
36
- * Retrieves the Prisma schema using the provided options.
37
- *
38
- * @param schemaPath - The path to the Prisma schema file.
39
- * @returns The Prisma schema.
40
- */
41
- async function resolveDataModel(schemaPath) {
42
- const configEither = (0, fp_ts_lib_function.pipe)(fp_ts_Either.tryCatch(() => {
43
- if (process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG) _prisma_prisma_schema_wasm.default.debug_panic();
44
- const params = JSON.stringify({
45
- prismaSchema: schemaPath,
46
- datasourceOverrides: {},
47
- ignoreEnvVarErrors: true,
48
- env: process.env
49
- });
50
- return _prisma_prisma_schema_wasm.default.get_config(params);
51
- }, (e) => ({
52
- type: "wasm-error",
53
- reason: "(get-config wasm)",
54
- error: e
55
- })), fp_ts_Either.map((result) => ({ result })), fp_ts_Either.chainW(({ result }) => fp_ts_Either.tryCatch(() => JSON.parse(result), (e) => ({
56
- type: "parse-json",
57
- reason: "Unable to parse JSON",
58
- error: e
59
- }))), fp_ts_Either.chainW((response) => {
60
- if (response.errors.length > 0) return fp_ts_Either.left({
61
- type: "validation-error",
62
- reason: "(get-config wasm)",
63
- error: response.errors
64
- });
65
- return fp_ts_Either.right(response.config);
66
- }));
67
- if (fp_ts_Either.isRight(configEither)) {
68
- const { right: data } = configEither;
69
- for (const generator of data.generators) await resolveBinaryTargets(generator);
70
- return Promise.resolve(data);
71
- }
72
- throw (0, ts_pattern.match)(configEither.left).with({ type: "wasm-error" }, (e) => {
73
- return /* @__PURE__ */ new Error(`Prisma get-config Wasm runtime error: ${e.error.message}`);
74
- }).with({ type: "validation-error" }, (e) => {
75
- return /* @__PURE__ */ new Error(`Prisma get-config validation error: ${e.error.map((err) => err.message).join(", ")}`);
76
- }).otherwise((e) => {
77
- return /* @__PURE__ */ new Error(`Prisma get-config unknown error: ${e.reason} - ${e.error.message}`);
78
- });
79
- }
80
- /**
81
- * Retrieves the Prisma schema using the provided path.
82
- *
83
- * @param path - The path to the Prisma schema file.
84
- * @returns The Prisma schema.
85
- */
86
- async function getSchema(path) {
87
- const schema = {
88
- path,
89
- content: "",
90
- generators: [],
91
- datasources: [],
92
- warnings: []
93
- };
94
- const dataModel = await resolveDataModel(path);
95
- return {
96
- ...schema,
97
- ...dataModel
98
- };
99
- }
100
-
101
- //#endregion
102
- exports.getSchema = getSchema;