@powerlines/plugin-prisma 0.4.82 → 0.4.84

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.
Files changed (61) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/helpers/client-generator.cjs +143 -2
  3. package/dist/helpers/client-generator.d.cts +17 -0
  4. package/dist/helpers/client-generator.d.cts.map +1 -0
  5. package/dist/helpers/client-generator.d.mts +17 -0
  6. package/dist/helpers/client-generator.d.mts.map +1 -0
  7. package/dist/helpers/client-generator.mjs +143 -2
  8. package/dist/helpers/client-generator.mjs.map +1 -0
  9. package/dist/helpers/get-schema.cjs +100 -2
  10. package/dist/helpers/get-schema.d.cts +13 -0
  11. package/dist/helpers/get-schema.d.cts.map +1 -0
  12. package/dist/helpers/get-schema.d.mts +13 -0
  13. package/dist/helpers/get-schema.d.mts.map +1 -0
  14. package/dist/helpers/get-schema.mjs +2 -1
  15. package/dist/helpers/get-schema.mjs.map +1 -0
  16. package/dist/helpers/index.cjs +4 -4
  17. package/dist/helpers/index.d.cts +5 -0
  18. package/dist/helpers/index.d.mts +5 -0
  19. package/dist/helpers/index.mjs +1 -1
  20. package/dist/helpers/schema-creator.cjs +1 -1
  21. package/dist/helpers/schema-creator.d.cts +20 -0
  22. package/dist/helpers/schema-creator.d.cts.map +1 -0
  23. package/dist/helpers/schema-creator.d.mts +20 -0
  24. package/dist/helpers/schema-creator.d.mts.map +1 -0
  25. package/dist/helpers/schema-creator.mjs +2 -1
  26. package/dist/helpers/schema-creator.mjs.map +1 -0
  27. package/dist/helpers/typed-sql.cjs +1 -1
  28. package/dist/helpers/typed-sql.d.cts +7 -0
  29. package/dist/helpers/typed-sql.d.cts.map +1 -0
  30. package/dist/helpers/typed-sql.d.mts +7 -0
  31. package/dist/helpers/typed-sql.d.mts.map +1 -0
  32. package/dist/helpers/typed-sql.mjs +2 -1
  33. package/dist/helpers/typed-sql.mjs.map +1 -0
  34. package/dist/index.cjs +10 -9
  35. package/dist/index.d.cts +20 -0
  36. package/dist/index.d.cts.map +1 -0
  37. package/dist/index.d.mts +20 -0
  38. package/dist/index.d.mts.map +1 -0
  39. package/dist/index.mjs +4 -3
  40. package/dist/index.mjs.map +1 -0
  41. package/dist/package.cjs +11 -0
  42. package/dist/package.mjs +6 -0
  43. package/dist/package.mjs.map +1 -0
  44. package/dist/types/index.cjs +0 -2
  45. package/dist/types/index.d.cts +3 -0
  46. package/dist/types/index.d.mts +3 -0
  47. package/dist/types/index.mjs +0 -3
  48. package/dist/types/plugin.d.cts +111 -0
  49. package/dist/types/plugin.d.cts.map +1 -0
  50. package/dist/types/plugin.d.mts +111 -0
  51. package/dist/types/plugin.d.mts.map +1 -0
  52. package/dist/types/prisma.d.cts +94 -0
  53. package/dist/types/prisma.d.cts.map +1 -0
  54. package/dist/types/prisma.d.mts +94 -0
  55. package/dist/types/prisma.d.mts.map +1 -0
  56. package/package.json +5 -5
  57. package/dist/client-generator-CMCbRxho.cjs +0 -152
  58. package/dist/client-generator-CxKIlqpl.mjs +0 -146
  59. package/dist/client-generator-DXEkvyAB.mjs +0 -146
  60. package/dist/client-generator-pMt54S7D.cjs +0 -152
  61. package/dist/get-schema-OhMkdmwI.cjs +0 -138
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma.d.cts","names":[],"sources":["../../src/types/prisma.ts"],"mappings":";;;KAuBY,eAAA,GAAkB,KAAA,EAAO,QAAA,UAAkB,OAAA;AAAA,KAC3C,eAAA,aAA4B,QAAA,UAAkB,OAAA;AAAA,KAE9C,aAAA;AAAA,KAUA,mBAAA,GAAsB,OAAA,CAChC,aAAA;AAAA,UAIe,QAAA;EACf,UAAA;EACA,KAAA;AAAA;AAAA,UAGe,UAAA;EACf,IAAA;EACA,QAAA,EAAU,aAAA;EAEV,cAAA,EAAgB,mBAAA;EAChB,GAAA,EAAK,QAAA;EACL,SAAA,GAAY,QAAA;EACZ,OAAA;EACA,cAAA;AAAA;AAAA,UAGe,iBAAA;EACf,MAAA,EAAQ,YAAA;EACR,MAAA,EAAQ,wBAAA;AAAA;AAAA,UAGO,QAAA;EACf,UAAA;EACA,KAAA;AAAA;AAAA,UAGe,QAAA;EACf,WAAA;EACA,aAAA;AAAA;AAAA,UAGe,qBAAA;EACf,UAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,UAGe,eAAA;EACf,IAAA;EACA,MAAA,EAAQ,QAAA;EACR,cAAA;EACA,QAAA,EAAU,QAAA;EACV,MAAA;IApCA,4FAsCE,MAAA,UArCQ;IAuCR,QAAA,UArCc;IAuCd,aAAA,UAtCG;IAwCH,eAAA;EAAA;IAAA,CAEC,GAAA;EAAA;EAEH,aAAA,EAAe,qBAAA;EACf,eAAA;EACA,QAAA,GAAW,QAAA;EACX,cAAA;AAAA;AAAA,KAGU,UAAA,IAAc,IAAA,UAAc,OAAA;AAAA,UAEvB,YAAA;EACf,IAAA;EACA,OAAA;EACA,WAAA,EAAa,UAAA;EACb,UAAA,EAAY,eAAA;EACZ,QAAA;AAAA;AAAA,UAGQ,wBAAA;EACR,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,gBAAA;EACf,SAAA,EAAW,eAAA;EACX,kBAAA;AAAA;;AA9CF;;KAoDY,YAAA,GAAe,QAAA,CAAS,IAAA,CAAK,cAAA,mBACvC,IAAA,CAAK,cAAA;EACH,UAAA,EAAY,QAAA,CAAS,IAAA,CAAK,UAAA,YAAsB,IAAA,CAAK,UAAA;AAAA;AAAA"}
@@ -0,0 +1,94 @@
1
+ import { Datasource, PrismaConfig as PrismaConfig$1 } from "@prisma/config";
2
+
3
+ //#region src/types/prisma.d.ts
4
+ type MultipleSchemas = Array<[filename: string, content: string]>;
5
+ type SchemaFileInput = string | [filename: string, content: string];
6
+ type ConnectorType = "mysql" | "mongodb" | "sqlite" | "postgresql" | "postgres" | "prisma+postgres" | "sqlserver" | "cockroachdb";
7
+ type ActiveConnectorType = Exclude<ConnectorType, "postgres" | "prisma+postgres">;
8
+ interface EnvValue {
9
+ fromEnvVar: null | string;
10
+ value: null | string;
11
+ }
12
+ interface DataSource {
13
+ name: string;
14
+ provider: ConnectorType;
15
+ activeProvider: ActiveConnectorType;
16
+ url: EnvValue;
17
+ directUrl?: EnvValue;
18
+ schemas: string[] | [];
19
+ sourceFilePath: string;
20
+ }
21
+ interface GetSchemaResponse {
22
+ config: PrismaSchema;
23
+ errors: GetSchemaValidationError[];
24
+ }
25
+ interface EnvValue {
26
+ fromEnvVar: null | string;
27
+ value: null | string;
28
+ }
29
+ interface EnvPaths {
30
+ rootEnvPath: string | null;
31
+ schemaEnvPath: string | undefined;
32
+ }
33
+ interface BinaryTargetsEnvValue {
34
+ fromEnvVar: string | null;
35
+ value: string;
36
+ native?: boolean;
37
+ }
38
+ interface GeneratorConfig {
39
+ name: string;
40
+ output: EnvValue | null;
41
+ isCustomOutput?: boolean;
42
+ provider: EnvValue;
43
+ config: {
44
+ /** `output` is a reserved name and will only be available directly at `generator.output` */output?: never; /** `provider` is a reserved name and will only be available directly at `generator.provider` */
45
+ provider?: never; /** `binaryTargets` is a reserved name and will only be available directly at `generator.binaryTargets` */
46
+ binaryTargets?: never; /** `previewFeatures` is a reserved name and will only be available directly at `generator.previewFeatures` */
47
+ previewFeatures?: never;
48
+ } & {
49
+ [key: string]: string | string[] | undefined;
50
+ };
51
+ binaryTargets: BinaryTargetsEnvValue[];
52
+ previewFeatures: string[];
53
+ envPaths?: EnvPaths;
54
+ sourceFilePath: string;
55
+ }
56
+ type LoadedFile = [path: string, content: string];
57
+ interface PrismaSchema {
58
+ path: string;
59
+ content: string;
60
+ datasources: DataSource[];
61
+ generators: GeneratorConfig[];
62
+ warnings: string[];
63
+ }
64
+ interface GetSchemaValidationError {
65
+ fileName: string | null;
66
+ message: string;
67
+ }
68
+ interface GetSchemaOptions {
69
+ datamodel: SchemaFileInput;
70
+ ignoreEnvVarErrors?: boolean;
71
+ }
72
+ /**
73
+ * A Prisma Config that has been validated w.r.t. the command that is being executed.
74
+ */
75
+ type PrismaConfig = Required<Pick<PrismaConfig$1, "datasource">> & Omit<PrismaConfig$1, "datasource"> & {
76
+ datasource: Required<Pick<Datasource, "url">> & Omit<Datasource, "url">;
77
+ };
78
+ declare type __ΩMultipleSchemas = any[];
79
+ declare type __ΩSchemaFileInput = any[];
80
+ declare type __ΩConnectorType = any[];
81
+ declare type __ΩActiveConnectorType = any[];
82
+ declare type __ΩEnvValue = any[];
83
+ declare type __ΩDataSource = any[];
84
+ declare type __ΩGetSchemaResponse = any[];
85
+ declare type __ΩEnvPaths = any[];
86
+ declare type __ΩBinaryTargetsEnvValue = any[];
87
+ declare type __ΩGeneratorConfig = any[];
88
+ declare type __ΩLoadedFile = any[];
89
+ declare type __ΩPrismaSchema = any[];
90
+ declare type __ΩGetSchemaOptions = any[];
91
+ declare type __ΩPrismaConfig = any[];
92
+ //#endregion
93
+ export { ActiveConnectorType, BinaryTargetsEnvValue, ConnectorType, DataSource, EnvPaths, EnvValue, GeneratorConfig, GetSchemaOptions, GetSchemaResponse, LoadedFile, MultipleSchemas, PrismaConfig, PrismaSchema, SchemaFileInput, __ΩActiveConnectorType, __ΩBinaryTargetsEnvValue, __ΩConnectorType, __ΩDataSource, __ΩEnvPaths, __ΩEnvValue, __ΩGeneratorConfig, __ΩGetSchemaOptions, __ΩGetSchemaResponse, __ΩLoadedFile, __ΩMultipleSchemas, __ΩPrismaConfig, __ΩPrismaSchema, __ΩSchemaFileInput };
94
+ //# sourceMappingURL=prisma.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma.d.mts","names":[],"sources":["../../src/types/prisma.ts"],"mappings":";;;KAuBY,eAAA,GAAkB,KAAA,EAAO,QAAA,UAAkB,OAAA;AAAA,KAC3C,eAAA,aAA4B,QAAA,UAAkB,OAAA;AAAA,KAE9C,aAAA;AAAA,KAUA,mBAAA,GAAsB,OAAA,CAChC,aAAA;AAAA,UAIe,QAAA;EACf,UAAA;EACA,KAAA;AAAA;AAAA,UAGe,UAAA;EACf,IAAA;EACA,QAAA,EAAU,aAAA;EAEV,cAAA,EAAgB,mBAAA;EAChB,GAAA,EAAK,QAAA;EACL,SAAA,GAAY,QAAA;EACZ,OAAA;EACA,cAAA;AAAA;AAAA,UAGe,iBAAA;EACf,MAAA,EAAQ,YAAA;EACR,MAAA,EAAQ,wBAAA;AAAA;AAAA,UAGO,QAAA;EACf,UAAA;EACA,KAAA;AAAA;AAAA,UAGe,QAAA;EACf,WAAA;EACA,aAAA;AAAA;AAAA,UAGe,qBAAA;EACf,UAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,UAGe,eAAA;EACf,IAAA;EACA,MAAA,EAAQ,QAAA;EACR,cAAA;EACA,QAAA,EAAU,QAAA;EACV,MAAA;IApCA,4FAsCE,MAAA,UArCQ;IAuCR,QAAA,UArCc;IAuCd,aAAA,UAtCG;IAwCH,eAAA;EAAA;IAAA,CAEC,GAAA;EAAA;EAEH,aAAA,EAAe,qBAAA;EACf,eAAA;EACA,QAAA,GAAW,QAAA;EACX,cAAA;AAAA;AAAA,KAGU,UAAA,IAAc,IAAA,UAAc,OAAA;AAAA,UAEvB,YAAA;EACf,IAAA;EACA,OAAA;EACA,WAAA,EAAa,UAAA;EACb,UAAA,EAAY,eAAA;EACZ,QAAA;AAAA;AAAA,UAGQ,wBAAA;EACR,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,gBAAA;EACf,SAAA,EAAW,eAAA;EACX,kBAAA;AAAA;;AA9CF;;KAoDY,YAAA,GAAe,QAAA,CAAS,IAAA,CAAK,cAAA,mBACvC,IAAA,CAAK,cAAA;EACH,UAAA,EAAY,QAAA,CAAS,IAAA,CAAK,UAAA,YAAsB,IAAA,CAAK,UAAA;AAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-prisma",
3
- "version": "0.4.82",
3
+ "version": "0.4.84",
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"],
@@ -174,7 +174,7 @@
174
174
  "typings": "dist/index.d.mts",
175
175
  "files": ["dist/**/*"],
176
176
  "dependencies": {
177
- "@powerlines/plugin-pulumi": "^0.6.41",
177
+ "@powerlines/plugin-pulumi": "^0.6.43",
178
178
  "@prisma/client-generator-registry": "7.6.0",
179
179
  "@prisma/config": "7.6.0",
180
180
  "@prisma/dmmf": "7.6.0",
@@ -192,16 +192,16 @@
192
192
  "defu": "^6.1.7",
193
193
  "fp-ts": "^2.16.11",
194
194
  "jiti": "^2.6.1",
195
- "powerlines": "^0.42.41",
195
+ "powerlines": "^0.43.1",
196
196
  "prisma-util": "^2.1.1",
197
197
  "ts-pattern": "^5.9.0"
198
198
  },
199
199
  "devDependencies": {
200
- "@powerlines/plugin-plugin": "^0.12.351",
200
+ "@powerlines/plugin-plugin": "^0.12.353",
201
201
  "@prisma/client-generator-ts": "7.6.0",
202
202
  "@pulumi/pulumi": "^3.231.0",
203
203
  "@types/node": "^25.6.0"
204
204
  },
205
205
  "publishConfig": { "access": "public" },
206
- "gitHead": "10e11a88d7fa6920f7139649cd74470cab2fd514"
206
+ "gitHead": "0b0428286336ad582b5c70e69dfd97ba6b586b59"
207
207
  }
@@ -1,152 +0,0 @@
1
- const require_get_schema = require('./get-schema-OhMkdmwI.cjs');
2
- let _stryke_path_find = require("@stryke/path/find");
3
- let _prisma_client_generator_ts = require("@prisma/client-generator-ts");
4
- let _prisma_engines_version = require("@prisma/engines-version");
5
- let _stryke_convert_buffer_to_string = require("@stryke/convert/buffer-to-string");
6
- let _stryke_path_replace = require("@stryke/path/replace");
7
- let _stryke_type_checks_is_buffer = require("@stryke/type-checks/is-buffer");
8
- let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
9
-
10
- //#region package.json
11
- var version = "0.4.81";
12
-
13
- //#endregion
14
- //#region src/helpers/client-generator.ts
15
- var PowerlinesClientGenerator = class {
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,146 +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.81";
11
-
12
- //#endregion
13
- //#region src/helpers/client-generator.ts
14
- var PowerlinesClientGenerator = class {
15
- #options;
16
- name = "powerlines-client";
17
- constructor(context) {
18
- this.context = context;
19
- this.#options = {
20
- name: this.name,
21
- output: null,
22
- config: {},
23
- provider: {
24
- fromEnvVar: "POWERLINES_CLIENT_PROVIDER",
25
- value: this.name
26
- },
27
- binaryTargets: [],
28
- previewFeatures: this.context.prisma.previewFeatures,
29
- sourceFilePath: this.context.prisma.schema.schemaRootDir
30
- };
31
- }
32
- async getManifest(_config) {
33
- return Promise.resolve({
34
- defaultOutput: "./generated",
35
- prettyName: "Powerlines Client",
36
- version,
37
- requiresEngines: [],
38
- requiresEngineVersion: enginesVersion
39
- });
40
- }
41
- async generate() {
42
- const { prismaClientDmmf, fileMap } = buildClient({
43
- datamodel: this.context.prisma.schema.schemas.map((s) => s.content).join("\n"),
44
- schemaPath: this.context.prisma.schema.schemaPath,
45
- binaryPaths: {},
46
- datasources: this.context.prisma.schema.datasources,
47
- outputDir: this.context.config.prisma.outputPath,
48
- runtimeBase: "@prisma/client/runtime",
49
- dmmf: this.context.prisma.dmmf,
50
- generator: this.#options,
51
- engineVersion: enginesVersion,
52
- clientVersion: version,
53
- activeProvider: this.context.prisma.schema.primaryDatasource?.activeProvider,
54
- typedSql: this.context.prisma.typedSql,
55
- target: this.context.config.prisma.runtime,
56
- generatedFileExtension: "ts",
57
- importFileExtension: "ts",
58
- moduleFormat: "esm",
59
- tsNoCheckPreamble: true,
60
- compilerBuild: "fast"
61
- });
62
- const errorArray = [];
63
- const denylists = {
64
- models: [
65
- "PrismaClient",
66
- "Prisma",
67
- "async",
68
- "await",
69
- "break",
70
- "case",
71
- "catch",
72
- "class",
73
- "const",
74
- "continue",
75
- "debugger",
76
- "default",
77
- "delete",
78
- "do",
79
- "else",
80
- "enum",
81
- "export",
82
- "extends",
83
- "false",
84
- "finally",
85
- "for",
86
- "function",
87
- "if",
88
- "implements",
89
- "import",
90
- "in",
91
- "instanceof",
92
- "interface",
93
- "let",
94
- "new",
95
- "null",
96
- "package",
97
- "private",
98
- "protected",
99
- "public",
100
- "return",
101
- "super",
102
- "switch",
103
- "this",
104
- "throw",
105
- "true",
106
- "try",
107
- "using",
108
- "typeof",
109
- "var",
110
- "void",
111
- "while",
112
- "with",
113
- "yield"
114
- ],
115
- fields: [
116
- "AND",
117
- "OR",
118
- "NOT"
119
- ],
120
- dynamic: []
121
- };
122
- if (prismaClientDmmf.datamodel.enums) {
123
- 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}"`));
124
- }
125
- if (prismaClientDmmf.datamodel.models) {
126
- 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}"`));
127
- }
128
- if (errorArray.length > 0) {
129
- let message = `Error: The schema at "${this.context.prisma.schema.schemaPath}" contains reserved keywords.\n Rename the following items:`;
130
- for (const error of errorArray) message += `\n - ${error.message}`;
131
- throw new Error(`${message}\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`);
132
- }
133
- await this.writeFileMap(fileMap);
134
- }
135
- stop() {}
136
- async writeFileMap(fileMap) {
137
- return Promise.all(Object.entries(fileMap).map(async ([fileName, content]) => {
138
- if (isString(content)) this.context.emitBuiltinSync(content, `prisma/${replaceExtension(fileName)}`, { extension: findFileExtension(fileName) || "ts" });
139
- else if (isBuffer(content)) this.context.emitBuiltinSync(bufferToString(content), `prisma/${replaceExtension(fileName)}`, { extension: findFileExtension(fileName) || "ts" });
140
- else await this.writeFileMap(content);
141
- }));
142
- }
143
- };
144
-
145
- //#endregion
146
- export { PowerlinesClientGenerator as t };
@@ -1,146 +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.82";
11
-
12
- //#endregion
13
- //#region src/helpers/client-generator.ts
14
- var PowerlinesClientGenerator = class {
15
- #options;
16
- name = "powerlines-client";
17
- constructor(context) {
18
- this.context = context;
19
- this.#options = {
20
- name: this.name,
21
- output: null,
22
- config: {},
23
- provider: {
24
- fromEnvVar: "POWERLINES_CLIENT_PROVIDER",
25
- value: this.name
26
- },
27
- binaryTargets: [],
28
- previewFeatures: this.context.prisma.previewFeatures,
29
- sourceFilePath: this.context.prisma.schema.schemaRootDir
30
- };
31
- }
32
- async getManifest(_config) {
33
- return Promise.resolve({
34
- defaultOutput: "./generated",
35
- prettyName: "Powerlines Client",
36
- version,
37
- requiresEngines: [],
38
- requiresEngineVersion: enginesVersion
39
- });
40
- }
41
- async generate() {
42
- const { prismaClientDmmf, fileMap } = buildClient({
43
- datamodel: this.context.prisma.schema.schemas.map((s) => s.content).join("\n"),
44
- schemaPath: this.context.prisma.schema.schemaPath,
45
- binaryPaths: {},
46
- datasources: this.context.prisma.schema.datasources,
47
- outputDir: this.context.config.prisma.outputPath,
48
- runtimeBase: "@prisma/client/runtime",
49
- dmmf: this.context.prisma.dmmf,
50
- generator: this.#options,
51
- engineVersion: enginesVersion,
52
- clientVersion: version,
53
- activeProvider: this.context.prisma.schema.primaryDatasource?.activeProvider,
54
- typedSql: this.context.prisma.typedSql,
55
- target: this.context.config.prisma.runtime,
56
- generatedFileExtension: "ts",
57
- importFileExtension: "ts",
58
- moduleFormat: "esm",
59
- tsNoCheckPreamble: true,
60
- compilerBuild: "fast"
61
- });
62
- const errorArray = [];
63
- const denylists = {
64
- models: [
65
- "PrismaClient",
66
- "Prisma",
67
- "async",
68
- "await",
69
- "break",
70
- "case",
71
- "catch",
72
- "class",
73
- "const",
74
- "continue",
75
- "debugger",
76
- "default",
77
- "delete",
78
- "do",
79
- "else",
80
- "enum",
81
- "export",
82
- "extends",
83
- "false",
84
- "finally",
85
- "for",
86
- "function",
87
- "if",
88
- "implements",
89
- "import",
90
- "in",
91
- "instanceof",
92
- "interface",
93
- "let",
94
- "new",
95
- "null",
96
- "package",
97
- "private",
98
- "protected",
99
- "public",
100
- "return",
101
- "super",
102
- "switch",
103
- "this",
104
- "throw",
105
- "true",
106
- "try",
107
- "using",
108
- "typeof",
109
- "var",
110
- "void",
111
- "while",
112
- "with",
113
- "yield"
114
- ],
115
- fields: [
116
- "AND",
117
- "OR",
118
- "NOT"
119
- ],
120
- dynamic: []
121
- };
122
- if (prismaClientDmmf.datamodel.enums) {
123
- 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}"`));
124
- }
125
- if (prismaClientDmmf.datamodel.models) {
126
- 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}"`));
127
- }
128
- if (errorArray.length > 0) {
129
- let message = `Error: The schema at "${this.context.prisma.schema.schemaPath}" contains reserved keywords.\n Rename the following items:`;
130
- for (const error of errorArray) message += `\n - ${error.message}`;
131
- throw new Error(`${message}\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`);
132
- }
133
- await this.writeFileMap(fileMap);
134
- }
135
- stop() {}
136
- async writeFileMap(fileMap) {
137
- return Promise.all(Object.entries(fileMap).map(async ([fileName, content]) => {
138
- if (isString(content)) this.context.emitBuiltinSync(content, `prisma/${replaceExtension(fileName)}`, { extension: findFileExtension(fileName) || "ts" });
139
- else if (isBuffer(content)) this.context.emitBuiltinSync(bufferToString(content), `prisma/${replaceExtension(fileName)}`, { extension: findFileExtension(fileName) || "ts" });
140
- else await this.writeFileMap(content);
141
- }));
142
- }
143
- };
144
-
145
- //#endregion
146
- export { PowerlinesClientGenerator as t };