@powerlines/plugin-prisma 0.4.287 → 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.
- package/dist/{rolldown-runtime-C_NdSu1c.cjs → _virtual/_rolldown/runtime.cjs} +1 -6
- package/dist/index.cjs +81 -130
- package/dist/index.d.cts +22 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +22 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +80 -128
- package/dist/index.mjs.map +1 -0
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.d.cts +74 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +74 -0
- package/dist/types/plugin.d.mts.map +1 -0
- package/package.json +11 -108
- package/dist/client-generator-BXFg7x5g.mjs +0 -147
- package/dist/client-generator-D-QRNVDz.cjs +0 -152
- package/dist/client-generator-DzDgrDsT.cjs +0 -152
- package/dist/client-generator-dDrR9dv_.mjs +0 -147
- package/dist/helpers/client-generator.cjs +0 -4
- package/dist/helpers/client-generator.mjs +0 -3
- package/dist/helpers/get-schema.cjs +0 -102
- package/dist/helpers/get-schema.mjs +0 -98
- package/dist/helpers/index.cjs +0 -10
- package/dist/helpers/index.mjs +0 -6
- package/dist/helpers/schema-creator.cjs +0 -61
- package/dist/helpers/schema-creator.mjs +0 -60
- package/dist/helpers/typed-sql.cjs +0 -37
- package/dist/helpers/typed-sql.mjs +0 -36
- package/dist/types/prisma.cjs +0 -0
- package/dist/types/prisma.mjs +0 -1
|
@@ -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.
|
|
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
|
-
"@
|
|
178
|
-
"@prisma
|
|
179
|
-
"@prisma
|
|
180
|
-
"@
|
|
181
|
-
"@
|
|
182
|
-
"@
|
|
183
|
-
"@
|
|
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
|
-
"
|
|
194
|
-
"jiti": "^2.7.0",
|
|
195
|
-
"powerlines": "^0.47.144",
|
|
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.
|
|
201
|
-
"@prisma/client-generator-ts": "7.6.0",
|
|
104
|
+
"@powerlines/plugin-plugin": "^0.12.557",
|
|
202
105
|
"@pulumi/pulumi": "^3.253.0",
|
|
203
106
|
"@types/node": "^25.9.5"
|
|
204
107
|
},
|
|
205
108
|
"publishConfig": { "access": "public" },
|
|
206
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "d81170b608c0b80e7726e129c3edd1b7b6ca2605"
|
|
207
110
|
}
|
|
@@ -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.287";
|
|
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,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.286";
|
|
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,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.287";
|
|
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
|
-
});
|