@powerlines/plugin-prisma 0.4.82 → 0.4.83
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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/helpers/client-generator.cjs +143 -2
- package/dist/helpers/client-generator.d.cts +17 -0
- package/dist/helpers/client-generator.d.cts.map +1 -0
- package/dist/helpers/client-generator.d.mts +17 -0
- package/dist/helpers/client-generator.d.mts.map +1 -0
- package/dist/helpers/client-generator.mjs +143 -2
- package/dist/helpers/client-generator.mjs.map +1 -0
- package/dist/helpers/get-schema.cjs +100 -2
- package/dist/helpers/get-schema.d.cts +13 -0
- package/dist/helpers/get-schema.d.cts.map +1 -0
- package/dist/helpers/get-schema.d.mts +13 -0
- package/dist/helpers/get-schema.d.mts.map +1 -0
- package/dist/helpers/get-schema.mjs +2 -1
- package/dist/helpers/get-schema.mjs.map +1 -0
- package/dist/helpers/index.cjs +4 -4
- package/dist/helpers/index.d.cts +5 -0
- package/dist/helpers/index.d.mts +5 -0
- package/dist/helpers/index.mjs +1 -1
- package/dist/helpers/schema-creator.cjs +1 -1
- package/dist/helpers/schema-creator.d.cts +20 -0
- package/dist/helpers/schema-creator.d.cts.map +1 -0
- package/dist/helpers/schema-creator.d.mts +20 -0
- package/dist/helpers/schema-creator.d.mts.map +1 -0
- package/dist/helpers/schema-creator.mjs +2 -1
- package/dist/helpers/schema-creator.mjs.map +1 -0
- package/dist/helpers/typed-sql.cjs +1 -1
- package/dist/helpers/typed-sql.d.cts +7 -0
- package/dist/helpers/typed-sql.d.cts.map +1 -0
- package/dist/helpers/typed-sql.d.mts +7 -0
- package/dist/helpers/typed-sql.d.mts.map +1 -0
- package/dist/helpers/typed-sql.mjs +2 -1
- package/dist/helpers/typed-sql.mjs.map +1 -0
- package/dist/index.cjs +10 -9
- package/dist/index.d.cts +20 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -0
- package/dist/package.cjs +11 -0
- package/dist/package.mjs +6 -0
- package/dist/package.mjs.map +1 -0
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.mts +3 -0
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.d.cts +111 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +111 -0
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/prisma.d.cts +94 -0
- package/dist/types/prisma.d.cts.map +1 -0
- package/dist/types/prisma.d.mts +94 -0
- package/dist/types/prisma.d.mts.map +1 -0
- package/package.json +5 -5
- package/dist/client-generator-CMCbRxho.cjs +0 -152
- package/dist/client-generator-CxKIlqpl.mjs +0 -146
- package/dist/client-generator-DXEkvyAB.mjs +0 -146
- package/dist/client-generator-pMt54S7D.cjs +0 -152
- package/dist/get-schema-OhMkdmwI.cjs +0 -138
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -1,4 +1,145 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_package = require('../package.cjs');
|
|
4
|
+
let _stryke_path_find = require("@stryke/path/find");
|
|
5
|
+
let _prisma_client_generator_ts = require("@prisma/client-generator-ts");
|
|
6
|
+
let _prisma_engines_version = require("@prisma/engines-version");
|
|
7
|
+
let _stryke_convert_buffer_to_string = require("@stryke/convert/buffer-to-string");
|
|
8
|
+
let _stryke_path_replace = require("@stryke/path/replace");
|
|
9
|
+
let _stryke_type_checks_is_buffer = require("@stryke/type-checks/is-buffer");
|
|
10
|
+
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
3
11
|
|
|
4
|
-
|
|
12
|
+
//#region src/helpers/client-generator.ts
|
|
13
|
+
var PowerlinesClientGenerator = class {
|
|
14
|
+
#options;
|
|
15
|
+
name = "powerlines-client";
|
|
16
|
+
constructor(context) {
|
|
17
|
+
this.context = context;
|
|
18
|
+
this.#options = {
|
|
19
|
+
name: this.name,
|
|
20
|
+
output: null,
|
|
21
|
+
config: {},
|
|
22
|
+
provider: {
|
|
23
|
+
fromEnvVar: "POWERLINES_CLIENT_PROVIDER",
|
|
24
|
+
value: this.name
|
|
25
|
+
},
|
|
26
|
+
binaryTargets: [],
|
|
27
|
+
previewFeatures: this.context.prisma.previewFeatures,
|
|
28
|
+
sourceFilePath: this.context.prisma.schema.schemaRootDir
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async getManifest(_config) {
|
|
32
|
+
return Promise.resolve({
|
|
33
|
+
defaultOutput: "./generated",
|
|
34
|
+
prettyName: "Powerlines Client",
|
|
35
|
+
version: require_package.version,
|
|
36
|
+
requiresEngines: [],
|
|
37
|
+
requiresEngineVersion: _prisma_engines_version.enginesVersion
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async generate() {
|
|
41
|
+
const { prismaClientDmmf, fileMap } = (0, _prisma_client_generator_ts.buildClient)({
|
|
42
|
+
datamodel: this.context.prisma.schema.schemas.map((s) => s.content).join("\n"),
|
|
43
|
+
schemaPath: this.context.prisma.schema.schemaPath,
|
|
44
|
+
binaryPaths: {},
|
|
45
|
+
datasources: this.context.prisma.schema.datasources,
|
|
46
|
+
outputDir: this.context.config.prisma.outputPath,
|
|
47
|
+
runtimeBase: "@prisma/client/runtime",
|
|
48
|
+
dmmf: this.context.prisma.dmmf,
|
|
49
|
+
generator: this.#options,
|
|
50
|
+
engineVersion: _prisma_engines_version.enginesVersion,
|
|
51
|
+
clientVersion: require_package.version,
|
|
52
|
+
activeProvider: this.context.prisma.schema.primaryDatasource?.activeProvider,
|
|
53
|
+
typedSql: this.context.prisma.typedSql,
|
|
54
|
+
target: this.context.config.prisma.runtime,
|
|
55
|
+
generatedFileExtension: "ts",
|
|
56
|
+
importFileExtension: "ts",
|
|
57
|
+
moduleFormat: "esm",
|
|
58
|
+
tsNoCheckPreamble: true,
|
|
59
|
+
compilerBuild: "fast"
|
|
60
|
+
});
|
|
61
|
+
const errorArray = [];
|
|
62
|
+
const denylists = {
|
|
63
|
+
models: [
|
|
64
|
+
"PrismaClient",
|
|
65
|
+
"Prisma",
|
|
66
|
+
"async",
|
|
67
|
+
"await",
|
|
68
|
+
"break",
|
|
69
|
+
"case",
|
|
70
|
+
"catch",
|
|
71
|
+
"class",
|
|
72
|
+
"const",
|
|
73
|
+
"continue",
|
|
74
|
+
"debugger",
|
|
75
|
+
"default",
|
|
76
|
+
"delete",
|
|
77
|
+
"do",
|
|
78
|
+
"else",
|
|
79
|
+
"enum",
|
|
80
|
+
"export",
|
|
81
|
+
"extends",
|
|
82
|
+
"false",
|
|
83
|
+
"finally",
|
|
84
|
+
"for",
|
|
85
|
+
"function",
|
|
86
|
+
"if",
|
|
87
|
+
"implements",
|
|
88
|
+
"import",
|
|
89
|
+
"in",
|
|
90
|
+
"instanceof",
|
|
91
|
+
"interface",
|
|
92
|
+
"let",
|
|
93
|
+
"new",
|
|
94
|
+
"null",
|
|
95
|
+
"package",
|
|
96
|
+
"private",
|
|
97
|
+
"protected",
|
|
98
|
+
"public",
|
|
99
|
+
"return",
|
|
100
|
+
"super",
|
|
101
|
+
"switch",
|
|
102
|
+
"this",
|
|
103
|
+
"throw",
|
|
104
|
+
"true",
|
|
105
|
+
"try",
|
|
106
|
+
"using",
|
|
107
|
+
"typeof",
|
|
108
|
+
"var",
|
|
109
|
+
"void",
|
|
110
|
+
"while",
|
|
111
|
+
"with",
|
|
112
|
+
"yield"
|
|
113
|
+
],
|
|
114
|
+
fields: [
|
|
115
|
+
"AND",
|
|
116
|
+
"OR",
|
|
117
|
+
"NOT"
|
|
118
|
+
],
|
|
119
|
+
dynamic: []
|
|
120
|
+
};
|
|
121
|
+
if (prismaClientDmmf.datamodel.enums) {
|
|
122
|
+
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}"`));
|
|
123
|
+
}
|
|
124
|
+
if (prismaClientDmmf.datamodel.models) {
|
|
125
|
+
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}"`));
|
|
126
|
+
}
|
|
127
|
+
if (errorArray.length > 0) {
|
|
128
|
+
let message = `Error: The schema at "${this.context.prisma.schema.schemaPath}" contains reserved keywords.\n Rename the following items:`;
|
|
129
|
+
for (const error of errorArray) message += `\n - ${error.message}`;
|
|
130
|
+
throw new Error(`${message}\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`);
|
|
131
|
+
}
|
|
132
|
+
await this.writeFileMap(fileMap);
|
|
133
|
+
}
|
|
134
|
+
stop() {}
|
|
135
|
+
async writeFileMap(fileMap) {
|
|
136
|
+
return Promise.all(Object.entries(fileMap).map(async ([fileName, content]) => {
|
|
137
|
+
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" });
|
|
138
|
+
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" });
|
|
139
|
+
else await this.writeFileMap(content);
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
//#endregion
|
|
145
|
+
exports.PowerlinesClientGenerator = PowerlinesClientGenerator;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PrismaPluginContext } from "../types/plugin.cjs";
|
|
2
|
+
import { GeneratorConfig, GeneratorManifest } from "@prisma/generator";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/client-generator.d.ts
|
|
5
|
+
declare class PowerlinesClientGenerator {
|
|
6
|
+
#private;
|
|
7
|
+
protected readonly context: PrismaPluginContext;
|
|
8
|
+
readonly name = "powerlines-client";
|
|
9
|
+
constructor(context: PrismaPluginContext);
|
|
10
|
+
getManifest(_config: GeneratorConfig): Promise<GeneratorManifest>;
|
|
11
|
+
generate(): Promise<void>;
|
|
12
|
+
stop(): void;
|
|
13
|
+
private writeFileMap;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { PowerlinesClientGenerator };
|
|
17
|
+
//# sourceMappingURL=client-generator.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-generator.d.cts","names":[],"sources":["../../src/helpers/client-generator.ts"],"mappings":";;;;cAsCa,yBAAA;EAAA;qBAKoB,OAAA,EAAS,mBAAA;EAAA,SAF/B,IAAA;cAEsB,OAAA,EAAS,mBAAA;EAY3B,WAAA,CACX,OAAA,EAAS,eAAA,GACR,OAAA,CAAQ,iBAAA;EAUE,QAAA,CAAA,GAAY,OAAA;EA8HlB,IAAA,CAAA;EAAA,QAEO,YAAA;AAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PrismaPluginContext } from "../types/plugin.mjs";
|
|
2
|
+
import { GeneratorConfig, GeneratorManifest } from "@prisma/generator";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/client-generator.d.ts
|
|
5
|
+
declare class PowerlinesClientGenerator {
|
|
6
|
+
#private;
|
|
7
|
+
protected readonly context: PrismaPluginContext;
|
|
8
|
+
readonly name = "powerlines-client";
|
|
9
|
+
constructor(context: PrismaPluginContext);
|
|
10
|
+
getManifest(_config: GeneratorConfig): Promise<GeneratorManifest>;
|
|
11
|
+
generate(): Promise<void>;
|
|
12
|
+
stop(): void;
|
|
13
|
+
private writeFileMap;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { PowerlinesClientGenerator };
|
|
17
|
+
//# sourceMappingURL=client-generator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-generator.d.mts","names":[],"sources":["../../src/helpers/client-generator.ts"],"mappings":";;;;cAsCa,yBAAA;EAAA;qBAKoB,OAAA,EAAS,mBAAA;EAAA,SAF/B,IAAA;cAEsB,OAAA,EAAS,mBAAA;EAY3B,WAAA,CACX,OAAA,EAAS,eAAA,GACR,OAAA,CAAQ,iBAAA;EAUE,QAAA,CAAA,GAAY,OAAA;EA8HlB,IAAA,CAAA;EAAA,QAEO,YAAA;AAAA"}
|
|
@@ -1,3 +1,144 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { version } from "../package.mjs";
|
|
2
|
+
import { findFileExtension } from "@stryke/path/find";
|
|
3
|
+
import { buildClient } from "@prisma/client-generator-ts";
|
|
4
|
+
import { enginesVersion } from "@prisma/engines-version";
|
|
5
|
+
import { bufferToString } from "@stryke/convert/buffer-to-string";
|
|
6
|
+
import { replaceExtension } from "@stryke/path/replace";
|
|
7
|
+
import { isBuffer } from "@stryke/type-checks/is-buffer";
|
|
8
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
2
9
|
|
|
3
|
-
|
|
10
|
+
//#region src/helpers/client-generator.ts
|
|
11
|
+
var PowerlinesClientGenerator = class {
|
|
12
|
+
#options;
|
|
13
|
+
name = "powerlines-client";
|
|
14
|
+
constructor(context) {
|
|
15
|
+
this.context = context;
|
|
16
|
+
this.#options = {
|
|
17
|
+
name: this.name,
|
|
18
|
+
output: null,
|
|
19
|
+
config: {},
|
|
20
|
+
provider: {
|
|
21
|
+
fromEnvVar: "POWERLINES_CLIENT_PROVIDER",
|
|
22
|
+
value: this.name
|
|
23
|
+
},
|
|
24
|
+
binaryTargets: [],
|
|
25
|
+
previewFeatures: this.context.prisma.previewFeatures,
|
|
26
|
+
sourceFilePath: this.context.prisma.schema.schemaRootDir
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async getManifest(_config) {
|
|
30
|
+
return Promise.resolve({
|
|
31
|
+
defaultOutput: "./generated",
|
|
32
|
+
prettyName: "Powerlines Client",
|
|
33
|
+
version,
|
|
34
|
+
requiresEngines: [],
|
|
35
|
+
requiresEngineVersion: enginesVersion
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async generate() {
|
|
39
|
+
const { prismaClientDmmf, fileMap } = buildClient({
|
|
40
|
+
datamodel: this.context.prisma.schema.schemas.map((s) => s.content).join("\n"),
|
|
41
|
+
schemaPath: this.context.prisma.schema.schemaPath,
|
|
42
|
+
binaryPaths: {},
|
|
43
|
+
datasources: this.context.prisma.schema.datasources,
|
|
44
|
+
outputDir: this.context.config.prisma.outputPath,
|
|
45
|
+
runtimeBase: "@prisma/client/runtime",
|
|
46
|
+
dmmf: this.context.prisma.dmmf,
|
|
47
|
+
generator: this.#options,
|
|
48
|
+
engineVersion: enginesVersion,
|
|
49
|
+
clientVersion: version,
|
|
50
|
+
activeProvider: this.context.prisma.schema.primaryDatasource?.activeProvider,
|
|
51
|
+
typedSql: this.context.prisma.typedSql,
|
|
52
|
+
target: this.context.config.prisma.runtime,
|
|
53
|
+
generatedFileExtension: "ts",
|
|
54
|
+
importFileExtension: "ts",
|
|
55
|
+
moduleFormat: "esm",
|
|
56
|
+
tsNoCheckPreamble: true,
|
|
57
|
+
compilerBuild: "fast"
|
|
58
|
+
});
|
|
59
|
+
const errorArray = [];
|
|
60
|
+
const denylists = {
|
|
61
|
+
models: [
|
|
62
|
+
"PrismaClient",
|
|
63
|
+
"Prisma",
|
|
64
|
+
"async",
|
|
65
|
+
"await",
|
|
66
|
+
"break",
|
|
67
|
+
"case",
|
|
68
|
+
"catch",
|
|
69
|
+
"class",
|
|
70
|
+
"const",
|
|
71
|
+
"continue",
|
|
72
|
+
"debugger",
|
|
73
|
+
"default",
|
|
74
|
+
"delete",
|
|
75
|
+
"do",
|
|
76
|
+
"else",
|
|
77
|
+
"enum",
|
|
78
|
+
"export",
|
|
79
|
+
"extends",
|
|
80
|
+
"false",
|
|
81
|
+
"finally",
|
|
82
|
+
"for",
|
|
83
|
+
"function",
|
|
84
|
+
"if",
|
|
85
|
+
"implements",
|
|
86
|
+
"import",
|
|
87
|
+
"in",
|
|
88
|
+
"instanceof",
|
|
89
|
+
"interface",
|
|
90
|
+
"let",
|
|
91
|
+
"new",
|
|
92
|
+
"null",
|
|
93
|
+
"package",
|
|
94
|
+
"private",
|
|
95
|
+
"protected",
|
|
96
|
+
"public",
|
|
97
|
+
"return",
|
|
98
|
+
"super",
|
|
99
|
+
"switch",
|
|
100
|
+
"this",
|
|
101
|
+
"throw",
|
|
102
|
+
"true",
|
|
103
|
+
"try",
|
|
104
|
+
"using",
|
|
105
|
+
"typeof",
|
|
106
|
+
"var",
|
|
107
|
+
"void",
|
|
108
|
+
"while",
|
|
109
|
+
"with",
|
|
110
|
+
"yield"
|
|
111
|
+
],
|
|
112
|
+
fields: [
|
|
113
|
+
"AND",
|
|
114
|
+
"OR",
|
|
115
|
+
"NOT"
|
|
116
|
+
],
|
|
117
|
+
dynamic: []
|
|
118
|
+
};
|
|
119
|
+
if (prismaClientDmmf.datamodel.enums) {
|
|
120
|
+
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}"`));
|
|
121
|
+
}
|
|
122
|
+
if (prismaClientDmmf.datamodel.models) {
|
|
123
|
+
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}"`));
|
|
124
|
+
}
|
|
125
|
+
if (errorArray.length > 0) {
|
|
126
|
+
let message = `Error: The schema at "${this.context.prisma.schema.schemaPath}" contains reserved keywords.\n Rename the following items:`;
|
|
127
|
+
for (const error of errorArray) message += `\n - ${error.message}`;
|
|
128
|
+
throw new Error(`${message}\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`);
|
|
129
|
+
}
|
|
130
|
+
await this.writeFileMap(fileMap);
|
|
131
|
+
}
|
|
132
|
+
stop() {}
|
|
133
|
+
async writeFileMap(fileMap) {
|
|
134
|
+
return Promise.all(Object.entries(fileMap).map(async ([fileName, content]) => {
|
|
135
|
+
if (isString(content)) this.context.emitBuiltinSync(content, `prisma/${replaceExtension(fileName)}`, { extension: findFileExtension(fileName) || "ts" });
|
|
136
|
+
else if (isBuffer(content)) this.context.emitBuiltinSync(bufferToString(content), `prisma/${replaceExtension(fileName)}`, { extension: findFileExtension(fileName) || "ts" });
|
|
137
|
+
else await this.writeFileMap(content);
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
export { PowerlinesClientGenerator };
|
|
144
|
+
//# sourceMappingURL=client-generator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-generator.mjs","names":["#options","clientVersion"],"sources":["../../src/helpers/client-generator.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { buildClient } from \"@prisma/client-generator-ts\";\nimport { enginesVersion } from \"@prisma/engines-version\";\nimport {\n ActiveConnectorType,\n GeneratorConfig,\n GeneratorManifest\n} from \"@prisma/generator\";\nimport { bufferToString } from \"@stryke/convert/buffer-to-string\";\nimport { findFileExtension } from \"@stryke/path/find\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { isBuffer } from \"@stryke/type-checks/is-buffer\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { Buffer } from \"node:buffer\";\nimport { version as clientVersion } from \"../../package.json\";\nimport type { PrismaPluginContext } from \"../types/plugin\";\n\ninterface FileMap {\n [key: string]: string | Buffer | FileMap;\n}\n\nexport class PowerlinesClientGenerator {\n #options: GeneratorConfig;\n\n readonly name = \"powerlines-client\";\n\n constructor(protected readonly context: PrismaPluginContext) {\n this.#options = {\n name: this.name,\n output: null,\n config: {},\n provider: { fromEnvVar: \"POWERLINES_CLIENT_PROVIDER\", value: this.name },\n binaryTargets: [],\n previewFeatures: this.context.prisma.previewFeatures,\n sourceFilePath: this.context.prisma.schema.schemaRootDir\n };\n }\n\n public async getManifest(\n _config: GeneratorConfig\n ): Promise<GeneratorManifest> {\n return Promise.resolve({\n defaultOutput: \"./generated\",\n prettyName: \"Powerlines Client\",\n version: clientVersion,\n requiresEngines: [],\n requiresEngineVersion: enginesVersion\n });\n }\n\n public async generate(): Promise<void> {\n const { prismaClientDmmf, fileMap } = buildClient({\n datamodel: this.context.prisma.schema.schemas\n .map(s => s.content)\n .join(\"\\n\"),\n schemaPath: this.context.prisma.schema.schemaPath,\n binaryPaths: {},\n datasources: this.context.prisma.schema.datasources,\n outputDir: this.context.config.prisma.outputPath,\n runtimeBase: \"@prisma/client/runtime\",\n dmmf: this.context.prisma.dmmf,\n generator: this.#options,\n engineVersion: enginesVersion,\n clientVersion,\n activeProvider: this.context.prisma.schema.primaryDatasource\n ?.activeProvider as ActiveConnectorType,\n typedSql: this.context.prisma.typedSql,\n target: this.context.config.prisma.runtime,\n generatedFileExtension: \"ts\",\n importFileExtension: \"ts\",\n moduleFormat: \"esm\",\n tsNoCheckPreamble: true,\n compilerBuild: \"fast\"\n });\n\n const errorArray = [] as Error[];\n\n const denylists = {\n models: [\n // Reserved Prisma keywords\n \"PrismaClient\",\n \"Prisma\",\n // JavaScript keywords\n \"async\",\n \"await\",\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"enum\",\n \"export\",\n \"extends\",\n \"false\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"implements\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"interface\",\n \"let\",\n \"new\",\n \"null\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"return\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"true\",\n \"try\",\n \"using\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\"\n ],\n fields: [\"AND\", \"OR\", \"NOT\"],\n dynamic: []\n };\n\n if (prismaClientDmmf.datamodel.enums) {\n for (const it of prismaClientDmmf.datamodel.enums) {\n if (\n denylists.models.includes(it.name) ||\n denylists.fields.includes(it.name)\n ) {\n errorArray.push(new Error(`\"enum ${it.name}\"`));\n }\n }\n }\n\n if (prismaClientDmmf.datamodel.models) {\n for (const it of prismaClientDmmf.datamodel.models) {\n if (\n denylists.models.includes(it.name) ||\n denylists.fields.includes(it.name)\n ) {\n errorArray.push(new Error(`\"model ${it.name}\"`));\n }\n }\n }\n\n if (errorArray.length > 0) {\n let message = `Error: The schema at \"${\n this.context.prisma.schema.schemaPath\n }\" contains reserved keywords.\\n Rename the following items:`;\n\n for (const error of errorArray) {\n message += `\\n - ${error.message}`;\n }\n\n throw new Error(\n `${\n message\n }\\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`\n );\n }\n\n await this.writeFileMap(fileMap);\n }\n\n public stop() {}\n\n private async writeFileMap(fileMap: FileMap) {\n return Promise.all(\n Object.entries(fileMap).map(async ([fileName, content]) => {\n if (isString(content)) {\n this.context.emitBuiltinSync(\n content,\n `prisma/${replaceExtension(fileName)}`,\n {\n extension: findFileExtension(fileName) || \"ts\"\n }\n );\n } else if (isBuffer(content)) {\n this.context.emitBuiltinSync(\n bufferToString(content),\n `prisma/${replaceExtension(fileName)}`,\n {\n extension: findFileExtension(fileName) || \"ts\"\n }\n );\n } else {\n await this.writeFileMap(content);\n }\n })\n );\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,4 +1,102 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.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_runtime.__toESM(_prisma_prisma_schema_wasm, 1);
|
|
6
|
+
let fp_ts_Either = require("fp-ts/Either");
|
|
7
|
+
fp_ts_Either = require_runtime.__toESM(fp_ts_Either, 1);
|
|
8
|
+
let fp_ts_lib_function = require("fp-ts/lib/function");
|
|
9
|
+
let ts_pattern = require("ts-pattern");
|
|
3
10
|
|
|
4
|
-
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PrismaSchema } from "../types/prisma.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/get-schema.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves the Prisma schema using the provided path.
|
|
6
|
+
*
|
|
7
|
+
* @param path - The path to the Prisma schema file.
|
|
8
|
+
* @returns The Prisma schema.
|
|
9
|
+
*/
|
|
10
|
+
declare function getSchema(path: string): Promise<PrismaSchema>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getSchema };
|
|
13
|
+
//# sourceMappingURL=get-schema.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-schema.d.cts","names":[],"sources":["../../src/helpers/get-schema.ts"],"mappings":";;;;;AA2JA;;;;iBAAsB,SAAA,CAAU,IAAA,WAAe,OAAA,CAAQ,YAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PrismaSchema } from "../types/prisma.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/get-schema.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves the Prisma schema using the provided path.
|
|
6
|
+
*
|
|
7
|
+
* @param path - The path to the Prisma schema file.
|
|
8
|
+
* @returns The Prisma schema.
|
|
9
|
+
*/
|
|
10
|
+
declare function getSchema(path: string): Promise<PrismaSchema>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getSchema };
|
|
13
|
+
//# sourceMappingURL=get-schema.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-schema.d.mts","names":[],"sources":["../../src/helpers/get-schema.ts"],"mappings":";;;;;AA2JA;;;;iBAAsB,SAAA,CAAU,IAAA,WAAe,OAAA,CAAQ,YAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-schema.mjs","names":[],"sources":["../../src/helpers/get-schema.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getBinaryTargetForCurrentPlatform } from \"@prisma/get-platform\";\nimport prismaSchemaWasm from \"@prisma/prisma-schema-wasm\";\nimport * as E from \"fp-ts/Either\";\nimport { pipe } from \"fp-ts/lib/function\";\nimport { match } from \"ts-pattern\";\nimport {\n GeneratorConfig,\n GetSchemaResponse,\n PrismaSchema\n} from \"../types/prisma\";\n\nasync function resolveBinaryTargets(generator: GeneratorConfig) {\n for (const binaryTarget of generator.binaryTargets) {\n // load the binaryTargets from the env var\n if (binaryTarget.fromEnvVar && process.env[binaryTarget.fromEnvVar]) {\n const value = JSON.parse(process.env[binaryTarget.fromEnvVar]!);\n\n if (Array.isArray(value)) {\n generator.binaryTargets = value.map(v => ({\n fromEnvVar: null,\n value: v\n }));\n await resolveBinaryTargets(generator); // resolve again if we have native\n } else {\n binaryTarget.value = value;\n }\n }\n\n // resolve native to the current platform\n if (binaryTarget.value === \"native\") {\n binaryTarget.value = await getBinaryTargetForCurrentPlatform();\n binaryTarget.native = true;\n }\n }\n\n if (generator.binaryTargets.length === 0) {\n generator.binaryTargets = [\n {\n fromEnvVar: null,\n value: await getBinaryTargetForCurrentPlatform(),\n native: true\n }\n ];\n }\n}\n\n/**\n * Retrieves the Prisma schema using the provided options.\n *\n * @param schemaPath - The path to the Prisma schema file.\n * @returns The Prisma schema.\n */\nasync function resolveDataModel(schemaPath: string) {\n const configEither = pipe(\n E.tryCatch(\n () => {\n if (process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG) {\n prismaSchemaWasm.debug_panic();\n }\n\n const params = JSON.stringify({\n prismaSchema: schemaPath,\n datasourceOverrides: {},\n ignoreEnvVarErrors: true,\n env: process.env\n });\n\n const data = prismaSchemaWasm.get_config(params);\n\n return data;\n },\n e => ({\n type: \"wasm-error\" as const,\n reason: \"(get-config wasm)\",\n error: e as Error\n })\n ),\n E.map(result => ({ result })),\n E.chainW(({ result }) =>\n // NOTE: this should never fail, as we expect returned values to be valid JSON-serializable strings\n E.tryCatch(\n () => JSON.parse(result) as GetSchemaResponse,\n e => ({\n type: \"parse-json\" as const,\n reason: \"Unable to parse JSON\",\n error: e as Error\n })\n )\n ),\n E.chainW(response => {\n if (response.errors.length > 0) {\n return E.left({\n type: \"validation-error\" as const,\n reason: \"(get-config wasm)\",\n error: response.errors\n });\n }\n return E.right(response.config);\n })\n );\n\n if (E.isRight(configEither)) {\n const { right: data } = configEither;\n\n for (const generator of data.generators) {\n await resolveBinaryTargets(generator);\n }\n\n return Promise.resolve(data);\n }\n\n throw match(configEither.left)\n .with({ type: \"wasm-error\" }, e => {\n return new Error(\n `Prisma get-config Wasm runtime error: ${e.error.message}`\n );\n })\n .with({ type: \"validation-error\" }, e => {\n return new Error(\n `Prisma get-config validation error: ${e.error\n .map(err => err.message)\n .join(\", \")}`\n );\n })\n .otherwise(e => {\n return new Error(\n `Prisma get-config unknown error: ${e.reason} - ${e.error.message}`\n );\n });\n}\n\n/**\n * Retrieves the Prisma schema using the provided path.\n *\n * @param path - The path to the Prisma schema file.\n * @returns The Prisma schema.\n */\nexport async function getSchema(path: string): Promise<PrismaSchema> {\n const schema = {\n path,\n content: \"\",\n generators: [],\n datasources: [],\n warnings: []\n } as PrismaSchema;\n\n const dataModel = await resolveDataModel(path);\n\n return { ...schema, ...dataModel };\n}\n"],"mappings":";;;;;;;AA6BA,eAAe,qBAAqB,WAA4B;AAC9D,MAAK,MAAM,gBAAgB,UAAU,eAAe;AAElD,MAAI,aAAa,cAAc,QAAQ,IAAI,aAAa,aAAa;GACnE,MAAM,QAAQ,KAAK,MAAM,QAAQ,IAAI,aAAa,YAAa;AAE/D,OAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,cAAU,gBAAgB,MAAM,KAAI,OAAM;KACxC,YAAY;KACZ,OAAO;KACR,EAAE;AACH,UAAM,qBAAqB,UAAU;SAErC,cAAa,QAAQ;;AAKzB,MAAI,aAAa,UAAU,UAAU;AACnC,gBAAa,QAAQ,MAAM,mCAAmC;AAC9D,gBAAa,SAAS;;;AAI1B,KAAI,UAAU,cAAc,WAAW,EACrC,WAAU,gBAAgB,CACxB;EACE,YAAY;EACZ,OAAO,MAAM,mCAAmC;EAChD,QAAQ;EACT,CACF;;;;;;;;AAUL,eAAe,iBAAiB,YAAoB;CAClD,MAAM,eAAe,KACnB,EAAE,eACM;AACJ,MAAI,QAAQ,IAAI,oCACd,kBAAiB,aAAa;EAGhC,MAAM,SAAS,KAAK,UAAU;GAC5B,cAAc;GACd,qBAAqB,EAAE;GACvB,oBAAoB;GACpB,KAAK,QAAQ;GACd,CAAC;AAIF,SAFa,iBAAiB,WAAW,OAAO;KAIlD,OAAM;EACJ,MAAM;EACN,QAAQ;EACR,OAAO;EACR,EACF,EACD,EAAE,KAAI,YAAW,EAAE,QAAQ,EAAE,EAC7B,EAAE,QAAQ,EAAE,aAEV,EAAE,eACM,KAAK,MAAM,OAAO,GACxB,OAAM;EACJ,MAAM;EACN,QAAQ;EACR,OAAO;EACR,EACF,CACF,EACD,EAAE,QAAO,aAAY;AACnB,MAAI,SAAS,OAAO,SAAS,EAC3B,QAAO,EAAE,KAAK;GACZ,MAAM;GACN,QAAQ;GACR,OAAO,SAAS;GACjB,CAAC;AAEJ,SAAO,EAAE,MAAM,SAAS,OAAO;GAC/B,CACH;AAED,KAAI,EAAE,QAAQ,aAAa,EAAE;EAC3B,MAAM,EAAE,OAAO,SAAS;AAExB,OAAK,MAAM,aAAa,KAAK,WAC3B,OAAM,qBAAqB,UAAU;AAGvC,SAAO,QAAQ,QAAQ,KAAK;;AAG9B,OAAM,MAAM,aAAa,KAAK,CAC3B,KAAK,EAAE,MAAM,cAAc,GAAE,MAAK;AACjC,yBAAO,IAAI,MACT,yCAAyC,EAAE,MAAM,UAClD;GACD,CACD,KAAK,EAAE,MAAM,oBAAoB,GAAE,MAAK;AACvC,yBAAO,IAAI,MACT,uCAAuC,EAAE,MACtC,KAAI,QAAO,IAAI,QAAQ,CACvB,KAAK,KAAK,GACd;GACD,CACD,WAAU,MAAK;AACd,yBAAO,IAAI,MACT,oCAAoC,EAAE,OAAO,KAAK,EAAE,MAAM,UAC3D;GACD;;;;;;;;AASN,eAAsB,UAAU,MAAqC;CACnE,MAAM,SAAS;EACb;EACA,SAAS;EACT,YAAY,EAAE;EACd,aAAa,EAAE;EACf,UAAU,EAAE;EACb;CAED,MAAM,YAAY,MAAM,iBAAiB,KAAK;AAE9C,QAAO;EAAE,GAAG;EAAQ,GAAG;EAAW"}
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const require_helpers_client_generator = require('./client-generator.cjs');
|
|
3
|
+
const require_helpers_get_schema = require('./get-schema.cjs');
|
|
4
4
|
const require_helpers_schema_creator = require('./schema-creator.cjs');
|
|
5
5
|
const require_helpers_typed_sql = require('./typed-sql.cjs');
|
|
6
6
|
|
|
7
|
-
exports.PowerlinesClientGenerator =
|
|
7
|
+
exports.PowerlinesClientGenerator = require_helpers_client_generator.PowerlinesClientGenerator;
|
|
8
8
|
exports.PrismaSchemaCreator = require_helpers_schema_creator.PrismaSchemaCreator;
|
|
9
|
-
exports.getSchema =
|
|
9
|
+
exports.getSchema = require_helpers_get_schema.getSchema;
|
|
10
10
|
exports.introspectSql = require_helpers_typed_sql.introspectSql;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PrismaSchemaCreator } from "./schema-creator.cjs";
|
|
2
|
+
import { PowerlinesClientGenerator } from "./client-generator.cjs";
|
|
3
|
+
import { getSchema } from "./get-schema.cjs";
|
|
4
|
+
import { introspectSql } from "./typed-sql.cjs";
|
|
5
|
+
export { PowerlinesClientGenerator, PrismaSchemaCreator, getSchema, introspectSql };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PrismaSchemaCreator } from "./schema-creator.mjs";
|
|
2
|
+
import { PowerlinesClientGenerator } from "./client-generator.mjs";
|
|
3
|
+
import { getSchema } from "./get-schema.mjs";
|
|
4
|
+
import { introspectSql } from "./typed-sql.mjs";
|
|
5
|
+
export { PowerlinesClientGenerator, PrismaSchemaCreator, getSchema, introspectSql };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PowerlinesClientGenerator } from "./client-generator.mjs";
|
|
2
2
|
import { getSchema } from "./get-schema.mjs";
|
|
3
3
|
import { PrismaSchemaCreator } from "./schema-creator.mjs";
|
|
4
4
|
import { introspectSql } from "./typed-sql.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
let prisma_util_schema_creator = require("prisma-util/schema-creator");
|
|
4
4
|
|
|
5
5
|
//#region src/helpers/schema-creator.ts
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GeneratorConfig } from "../types/prisma.cjs";
|
|
2
|
+
import { PrismaPluginContext } from "../types/plugin.cjs";
|
|
3
|
+
import { SchemaCreator } from "prisma-util/schema-creator";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/schema-creator.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Prisma schema creator that allows building a schema via code.
|
|
8
|
+
*/
|
|
9
|
+
declare class PrismaSchemaCreator extends SchemaCreator {
|
|
10
|
+
#private;
|
|
11
|
+
private get generators();
|
|
12
|
+
private set generators(value);
|
|
13
|
+
constructor(context: PrismaPluginContext);
|
|
14
|
+
pushGenerator(generator: GeneratorConfig): this;
|
|
15
|
+
build(): string;
|
|
16
|
+
write(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { PrismaSchemaCreator };
|
|
20
|
+
//# sourceMappingURL=schema-creator.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-creator.d.cts","names":[],"sources":["../../src/helpers/schema-creator.ts"],"mappings":";;;;;;;AAyBA;cAAa,mBAAA,SAA4B,aAAA;EAAA;cAI3B,UAAA,CAAA;EAAA,YAIA,UAAA,CAAU,KAAA;cAIH,OAAA,EAAS,mBAAA;EAgBrB,aAAA,CAAc,SAAA,EAAW,eAAA;EAahB,KAAA,CAAA;EA0DH,KAAA,CAAA,GAAS,OAAA;AAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GeneratorConfig } from "../types/prisma.mjs";
|
|
2
|
+
import { PrismaPluginContext } from "../types/plugin.mjs";
|
|
3
|
+
import { SchemaCreator } from "prisma-util/schema-creator";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/schema-creator.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Prisma schema creator that allows building a schema via code.
|
|
8
|
+
*/
|
|
9
|
+
declare class PrismaSchemaCreator extends SchemaCreator {
|
|
10
|
+
#private;
|
|
11
|
+
private get generators();
|
|
12
|
+
private set generators(value);
|
|
13
|
+
constructor(context: PrismaPluginContext);
|
|
14
|
+
pushGenerator(generator: GeneratorConfig): this;
|
|
15
|
+
build(): string;
|
|
16
|
+
write(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { PrismaSchemaCreator };
|
|
20
|
+
//# sourceMappingURL=schema-creator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-creator.d.mts","names":[],"sources":["../../src/helpers/schema-creator.ts"],"mappings":";;;;;;;AAyBA;cAAa,mBAAA,SAA4B,aAAA;EAAA;cAI3B,UAAA,CAAA;EAAA,YAIA,UAAA,CAAU,KAAA;cAIH,OAAA,EAAS,mBAAA;EAgBrB,aAAA,CAAc,SAAA,EAAW,eAAA;EAahB,KAAA,CAAA;EA0DH,KAAA,CAAA,GAAS,OAAA;AAAA"}
|