@powerlines/plugin-prisma 0.4.111 → 0.4.113
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/client-generator-B7ixcoYG.mjs +2 -0
- package/dist/client-generator-CXGC6qf4.cjs +2 -0
- package/dist/client-generator-CxSJThTu.mjs +2 -0
- package/dist/client-generator-DP-c-kAJ.cjs +2 -0
- package/dist/get-schema-BUxb6ANl.cjs +1 -0
- package/dist/helpers/client-generator.cjs +1 -4
- package/dist/helpers/client-generator.mjs +1 -3
- package/dist/helpers/get-schema.cjs +1 -4
- package/dist/helpers/get-schema.mjs +1 -98
- package/dist/helpers/index.cjs +1 -10
- package/dist/helpers/index.mjs +1 -6
- package/dist/helpers/schema-creator.cjs +12 -60
- package/dist/helpers/schema-creator.mjs +12 -58
- package/dist/helpers/typed-sql.cjs +3 -38
- package/dist/helpers/typed-sql.mjs +3 -36
- package/dist/index.cjs +1 -149
- package/dist/index.mjs +1 -144
- package/dist/types/index.cjs +1 -2
- package/dist/types/index.mjs +1 -4
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/prisma.mjs +1 -1
- package/package.json +5 -5
- package/dist/client-generator-CKfvwlAl.mjs +0 -146
- package/dist/client-generator-DGm0RhWT.cjs +0 -152
- package/dist/client-generator-DxSrveMa.mjs +0 -146
- package/dist/client-generator-VnXV260K.cjs +0 -152
- package/dist/get-schema-OhMkdmwI.cjs +0 -138
package/dist/index.mjs
CHANGED
|
@@ -1,144 +1 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { getSchema } from "./helpers/get-schema.mjs";
|
|
3
|
-
import { PrismaSchemaCreator } from "./helpers/schema-creator.mjs";
|
|
4
|
-
import { introspectSql } from "./helpers/typed-sql.mjs";
|
|
5
|
-
import pulumi from "@powerlines/plugin-pulumi";
|
|
6
|
-
import { defaultRegistry } from "@prisma/client-generator-registry";
|
|
7
|
-
import { enginesVersion } from "@prisma/engines";
|
|
8
|
-
import { extractPreviewFeatures, getDMMF, getGenerators, validatePrismaConfigWithDatasource } from "@prisma/internals";
|
|
9
|
-
import * as prismaPostgres from "@pulumi/prisma-postgres";
|
|
10
|
-
import { toArray } from "@stryke/convert/to-array";
|
|
11
|
-
import { appendPath } from "@stryke/path/append";
|
|
12
|
-
import { findBasePath } from "@stryke/path/common";
|
|
13
|
-
import { relativePath } from "@stryke/path/find";
|
|
14
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
15
|
-
import { constantCase } from "@stryke/string-format/constant-case";
|
|
16
|
-
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
17
|
-
import defu from "defu";
|
|
18
|
-
import { getConfigPath, replacePathTokens } from "powerlines/plugin-utils";
|
|
19
|
-
|
|
20
|
-
//#region src/index.ts
|
|
21
|
-
/**
|
|
22
|
-
* A Powerlines plugin to integrate Prisma for code generation.
|
|
23
|
-
*
|
|
24
|
-
* @param options - The plugin options.
|
|
25
|
-
* @returns A Powerlines plugin instance.
|
|
26
|
-
*/
|
|
27
|
-
const plugin = (options = {}) => {
|
|
28
|
-
return [...pulumi(options.pulumi), {
|
|
29
|
-
name: "prisma",
|
|
30
|
-
config() {
|
|
31
|
-
return { prisma: defu(options, {
|
|
32
|
-
schema: joinPaths(this.config.root, "prisma", "*.prisma"),
|
|
33
|
-
configFile: options.configFile || getConfigPath(this, "prisma.config"),
|
|
34
|
-
runtime: options.runtime || "nodejs",
|
|
35
|
-
outputPath: joinPaths("{builtinPath}", "prisma"),
|
|
36
|
-
prismaPostgres: options.prismaPostgres ? {
|
|
37
|
-
projectId: this.config.name,
|
|
38
|
-
region: "us-east-1"
|
|
39
|
-
} : void 0
|
|
40
|
-
}) };
|
|
41
|
-
},
|
|
42
|
-
async configResolved() {
|
|
43
|
-
this.dependencies["@prisma/ppg"] = "latest";
|
|
44
|
-
this.config.prisma.configFile = replacePathTokens(this, this.config.prisma.configFile);
|
|
45
|
-
if (!this.config.prisma.schema) throw new Error(`Prisma schema path is not defined. Please specify a valid path in the plugin configuration.`);
|
|
46
|
-
this.config.prisma.schema = toArray(this.config.prisma.schema).map((schemaPath) => replacePathTokens(this, schemaPath));
|
|
47
|
-
if (!this.config.prisma.outputPath) throw new Error(`Prisma generated path is not defined. Please specify a valid path in the plugin configuration.`);
|
|
48
|
-
this.config.prisma.outputPath = replacePathTokens(this, this.config.prisma.outputPath);
|
|
49
|
-
this.prisma ??= {};
|
|
50
|
-
this.prisma.config = validatePrismaConfigWithDatasource({
|
|
51
|
-
config: this.config.prisma,
|
|
52
|
-
cmd: "generate --sql"
|
|
53
|
-
});
|
|
54
|
-
const schemaRootDir = appendPath(appendPath(findBasePath(this.config.prisma.schema), this.config.root), this.config.cwd);
|
|
55
|
-
this.prisma.schema ??= {
|
|
56
|
-
schemaRootDir,
|
|
57
|
-
loadedFromPathForLogMessages: relativePath(this.config.root, schemaRootDir),
|
|
58
|
-
schemaPath: schemaRootDir,
|
|
59
|
-
schemas: [],
|
|
60
|
-
schemaFiles: [],
|
|
61
|
-
generators: [],
|
|
62
|
-
datasources: [],
|
|
63
|
-
warnings: [],
|
|
64
|
-
primaryDatasource: void 0
|
|
65
|
-
};
|
|
66
|
-
this.prisma.schema.schemas = await Promise.all((await this.fs.glob(this.config.prisma.schema.map((schema) => schema.includes("*") || this.fs.isFileSync(schema) ? schema : joinPaths(schema, "**/*.prisma")))).map(async (schema) => getSchema(schema)));
|
|
67
|
-
this.prisma.schema = this.prisma.schema.schemas.reduce((ret, schema) => {
|
|
68
|
-
ret.datasources.push(...schema.datasources);
|
|
69
|
-
ret.generators.push(...schema.generators);
|
|
70
|
-
ret.warnings.push(...schema.warnings);
|
|
71
|
-
ret.schemaFiles.push([schema.path, schema.content]);
|
|
72
|
-
return ret;
|
|
73
|
-
}, this.prisma.schema);
|
|
74
|
-
this.prisma.schema.primaryDatasource = this.prisma.schema.datasources.at(0);
|
|
75
|
-
this.prisma.schema.schemaPath = this.prisma.schema.schemas.at(0).path;
|
|
76
|
-
this.prisma.builder = new PrismaSchemaCreator(this);
|
|
77
|
-
},
|
|
78
|
-
async prepare() {
|
|
79
|
-
await this.prisma.builder.write();
|
|
80
|
-
this.prisma.previewFeatures = extractPreviewFeatures(this.prisma.schema.generators);
|
|
81
|
-
this.prisma.dmmf = await getDMMF({
|
|
82
|
-
datamodel: this.prisma.schema.schemaFiles,
|
|
83
|
-
previewFeatures: this.prisma.previewFeatures
|
|
84
|
-
});
|
|
85
|
-
const typedSql = await introspectSql(this);
|
|
86
|
-
let generators = await getGenerators({
|
|
87
|
-
schemaContext: this.prisma.schema,
|
|
88
|
-
printDownloadProgress: true,
|
|
89
|
-
version: enginesVersion,
|
|
90
|
-
typedSql,
|
|
91
|
-
allowNoModels: true,
|
|
92
|
-
registry: defaultRegistry.toInternal()
|
|
93
|
-
});
|
|
94
|
-
if (!generators || !generators.some((gen) => [
|
|
95
|
-
"prisma-client",
|
|
96
|
-
"prisma-client-js",
|
|
97
|
-
"prisma-client-ts"
|
|
98
|
-
].includes(gen.name || gen.getProvider()))) {
|
|
99
|
-
generators ??= [];
|
|
100
|
-
generators.push(new PowerlinesClientGenerator(this));
|
|
101
|
-
} else generators = generators.map((generator) => [
|
|
102
|
-
"prisma-client",
|
|
103
|
-
"prisma-client-js",
|
|
104
|
-
"prisma-client-ts"
|
|
105
|
-
].includes(generator.name || generator.getProvider()) ? new PowerlinesClientGenerator(this) : generator);
|
|
106
|
-
for (const generator of generators) try {
|
|
107
|
-
await generator.generate();
|
|
108
|
-
generator.stop();
|
|
109
|
-
} catch (err) {
|
|
110
|
-
generator.stop();
|
|
111
|
-
this.error(`Error while generating with ${generator.name || generator.getProvider()}: ${err instanceof Error ? err.message : String(err)}`);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
pulumi: { async deploy() {
|
|
115
|
-
if (this.config.prisma.prismaPostgres) {
|
|
116
|
-
let serviceToken = process.env.PRISMA_SERVICE_TOKEN;
|
|
117
|
-
if (!serviceToken) {
|
|
118
|
-
serviceToken = options.serviceToken;
|
|
119
|
-
if (serviceToken) this.warn("If possible, please use the `PRISMA_SERVICE_TOKEN` environment variable instead of using the `serviceToken` option directly. The `serviceToken` option will work; however, this is a less secure method of configuration.");
|
|
120
|
-
else throw new Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");
|
|
121
|
-
}
|
|
122
|
-
await this.pulumi.workspace.installPlugin("registry.terraform.io/prisma/prisma-postgres", "v0.2.0");
|
|
123
|
-
const project = new prismaPostgres.Project("project", { name: `${this.config.prisma.prismaPostgres?.projectId || this.config.name}` });
|
|
124
|
-
const database = new prismaPostgres.Database("database", {
|
|
125
|
-
projectId: project.id,
|
|
126
|
-
name: `${this.config.prisma.prismaPostgres?.databaseName || `${kebabCase(this.config.name)}.${this.config.mode}.${this.config.prisma.prismaPostgres?.region}`}`,
|
|
127
|
-
region: `${this.config.prisma.prismaPostgres?.region}`
|
|
128
|
-
});
|
|
129
|
-
return {
|
|
130
|
-
project,
|
|
131
|
-
database,
|
|
132
|
-
connection: new prismaPostgres.Connection("connection", {
|
|
133
|
-
databaseId: database.id,
|
|
134
|
-
name: `${constantCase(this.config.name)}_API_KEY`
|
|
135
|
-
})
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
return null;
|
|
139
|
-
} }
|
|
140
|
-
}];
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
//#endregion
|
|
144
|
-
export { plugin as default, plugin };
|
|
1
|
+
import{t as e}from"./client-generator-CxSJThTu.mjs";import{getSchema as t}from"./helpers/get-schema.mjs";import{PrismaSchemaCreator as n}from"./helpers/schema-creator.mjs";import{introspectSql as r}from"./helpers/typed-sql.mjs";import i from"@powerlines/plugin-pulumi";import{defaultRegistry as a}from"@prisma/client-generator-registry";import{enginesVersion as o}from"@prisma/engines";import{extractPreviewFeatures as s,getDMMF as c,getGenerators as l,validatePrismaConfigWithDatasource as u}from"@prisma/internals";import*as d from"@pulumi/prisma-postgres";import{toArray as f}from"@stryke/convert/to-array";import{appendPath as p}from"@stryke/path/append";import{findBasePath as m}from"@stryke/path/common";import{relativePath as h}from"@stryke/path/find";import{joinPaths as g}from"@stryke/path/join-paths";import{constantCase as _}from"@stryke/string-format/constant-case";import{kebabCase as v}from"@stryke/string-format/kebab-case";import y from"defu";import{getConfigPath as b,replacePathTokens as x}from"powerlines/plugin-utils";const S=(S={})=>[...i(S.pulumi),{name:`prisma`,config(){return{prisma:y(S,{schema:g(this.config.root,`prisma`,`*.prisma`),configFile:S.configFile||b(this,`prisma.config`),runtime:S.runtime||`nodejs`,outputPath:g(`{builtinPath}`,`prisma`),prismaPostgres:S.prismaPostgres?{projectId:this.config.name,region:`us-east-1`}:void 0})}},async configResolved(){if(this.dependencies[`@prisma/ppg`]=`latest`,this.config.prisma.configFile=x(this,this.config.prisma.configFile),!this.config.prisma.schema)throw Error(`Prisma schema path is not defined. Please specify a valid path in the plugin configuration.`);if(this.config.prisma.schema=f(this.config.prisma.schema).map(e=>x(this,e)),!this.config.prisma.outputPath)throw Error(`Prisma generated path is not defined. Please specify a valid path in the plugin configuration.`);this.config.prisma.outputPath=x(this,this.config.prisma.outputPath),this.prisma??={},this.prisma.config=u({config:this.config.prisma,cmd:`generate --sql`});let e=p(p(m(this.config.prisma.schema),this.config.root),this.config.cwd);this.prisma.schema??={schemaRootDir:e,loadedFromPathForLogMessages:h(this.config.root,e),schemaPath:e,schemas:[],schemaFiles:[],generators:[],datasources:[],warnings:[],primaryDatasource:void 0},this.prisma.schema.schemas=await Promise.all((await this.fs.glob(this.config.prisma.schema.map(e=>e.includes(`*`)||this.fs.isFileSync(e)?e:g(e,`**/*.prisma`)))).map(async e=>t(e))),this.prisma.schema=this.prisma.schema.schemas.reduce((e,t)=>(e.datasources.push(...t.datasources),e.generators.push(...t.generators),e.warnings.push(...t.warnings),e.schemaFiles.push([t.path,t.content]),e),this.prisma.schema),this.prisma.schema.primaryDatasource=this.prisma.schema.datasources.at(0),this.prisma.schema.schemaPath=this.prisma.schema.schemas.at(0).path,this.prisma.builder=new n(this)},async prepare(){await this.prisma.builder.write(),this.prisma.previewFeatures=s(this.prisma.schema.generators),this.prisma.dmmf=await c({datamodel:this.prisma.schema.schemaFiles,previewFeatures:this.prisma.previewFeatures});let t=await r(this),n=await l({schemaContext:this.prisma.schema,printDownloadProgress:!0,version:o,typedSql:t,allowNoModels:!0,registry:a.toInternal()});!n||!n.some(e=>[`prisma-client`,`prisma-client-js`,`prisma-client-ts`].includes(e.name||e.getProvider()))?(n??=[],n.push(new e(this))):n=n.map(t=>[`prisma-client`,`prisma-client-js`,`prisma-client-ts`].includes(t.name||t.getProvider())?new e(this):t);for(let e of n)try{await e.generate(),e.stop()}catch(t){e.stop(),this.error(`Error while generating with ${e.name||e.getProvider()}: ${t instanceof Error?t.message:String(t)}`)}},pulumi:{async deploy(){if(this.config.prisma.prismaPostgres){let e=process.env.PRISMA_SERVICE_TOKEN;if(!e)if(e=S.serviceToken,e)this.warn("If possible, please use the `PRISMA_SERVICE_TOKEN` environment variable instead of using the `serviceToken` option directly. The `serviceToken` option will work; however, this is a less secure method of configuration.");else throw Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");await this.pulumi.workspace.installPlugin(`registry.terraform.io/prisma/prisma-postgres`,`v0.2.0`);let t=new d.Project(`project`,{name:`${this.config.prisma.prismaPostgres?.projectId||this.config.name}`}),n=new d.Database(`database`,{projectId:t.id,name:`${this.config.prisma.prismaPostgres?.databaseName||`${v(this.config.name)}.${this.config.mode}.${this.config.prisma.prismaPostgres?.region}`}`,region:`${this.config.prisma.prismaPostgres?.region}`});return{project:t,database:n,connection:new d.Connection(`connection`,{databaseId:n.id,name:`${_(this.config.name)}_API_KEY`})}}return null}}}];export{S as default,S as plugin};
|
package/dist/types/index.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
require(
|
|
2
|
-
require('./plugin.cjs');
|
|
1
|
+
require(`./prisma.cjs`),require(`./plugin.cjs`);
|
package/dist/types/index.mjs
CHANGED
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
package/dist/types/prisma.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-prisma",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.113",
|
|
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.
|
|
177
|
+
"@powerlines/plugin-pulumi": "^0.6.72",
|
|
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.43.
|
|
195
|
+
"powerlines": "^0.43.27",
|
|
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.
|
|
200
|
+
"@powerlines/plugin-plugin": "^0.12.382",
|
|
201
201
|
"@prisma/client-generator-ts": "7.6.0",
|
|
202
202
|
"@pulumi/pulumi": "^3.232.0",
|
|
203
203
|
"@types/node": "^25.6.0"
|
|
204
204
|
},
|
|
205
205
|
"publishConfig": { "access": "public" },
|
|
206
|
-
"gitHead": "
|
|
206
|
+
"gitHead": "ad851a239011b884c15b0444db518d74927fd13f"
|
|
207
207
|
}
|
|
@@ -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.110";
|
|
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,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.110";
|
|
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.111";
|
|
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 };
|