@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
|
@@ -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.111";
|
|
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,138 +0,0 @@
|
|
|
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
|
-
let _prisma_get_platform = require("@prisma/get-platform");
|
|
29
|
-
let _prisma_prisma_schema_wasm = require("@prisma/prisma-schema-wasm");
|
|
30
|
-
_prisma_prisma_schema_wasm = __toESM(_prisma_prisma_schema_wasm, 1);
|
|
31
|
-
let fp_ts_Either = require("fp-ts/Either");
|
|
32
|
-
fp_ts_Either = __toESM(fp_ts_Either, 1);
|
|
33
|
-
let fp_ts_lib_function = require("fp-ts/lib/function");
|
|
34
|
-
let ts_pattern = require("ts-pattern");
|
|
35
|
-
|
|
36
|
-
//#region src/helpers/get-schema.ts
|
|
37
|
-
async function resolveBinaryTargets(generator) {
|
|
38
|
-
for (const binaryTarget of generator.binaryTargets) {
|
|
39
|
-
if (binaryTarget.fromEnvVar && process.env[binaryTarget.fromEnvVar]) {
|
|
40
|
-
const value = JSON.parse(process.env[binaryTarget.fromEnvVar]);
|
|
41
|
-
if (Array.isArray(value)) {
|
|
42
|
-
generator.binaryTargets = value.map((v) => ({
|
|
43
|
-
fromEnvVar: null,
|
|
44
|
-
value: v
|
|
45
|
-
}));
|
|
46
|
-
await resolveBinaryTargets(generator);
|
|
47
|
-
} else binaryTarget.value = value;
|
|
48
|
-
}
|
|
49
|
-
if (binaryTarget.value === "native") {
|
|
50
|
-
binaryTarget.value = await (0, _prisma_get_platform.getBinaryTargetForCurrentPlatform)();
|
|
51
|
-
binaryTarget.native = true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (generator.binaryTargets.length === 0) generator.binaryTargets = [{
|
|
55
|
-
fromEnvVar: null,
|
|
56
|
-
value: await (0, _prisma_get_platform.getBinaryTargetForCurrentPlatform)(),
|
|
57
|
-
native: true
|
|
58
|
-
}];
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Retrieves the Prisma schema using the provided options.
|
|
62
|
-
*
|
|
63
|
-
* @param schemaPath - The path to the Prisma schema file.
|
|
64
|
-
* @returns The Prisma schema.
|
|
65
|
-
*/
|
|
66
|
-
async function resolveDataModel(schemaPath) {
|
|
67
|
-
const configEither = (0, fp_ts_lib_function.pipe)(fp_ts_Either.tryCatch(() => {
|
|
68
|
-
if (process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG) _prisma_prisma_schema_wasm.default.debug_panic();
|
|
69
|
-
const params = JSON.stringify({
|
|
70
|
-
prismaSchema: schemaPath,
|
|
71
|
-
datasourceOverrides: {},
|
|
72
|
-
ignoreEnvVarErrors: true,
|
|
73
|
-
env: process.env
|
|
74
|
-
});
|
|
75
|
-
return _prisma_prisma_schema_wasm.default.get_config(params);
|
|
76
|
-
}, (e) => ({
|
|
77
|
-
type: "wasm-error",
|
|
78
|
-
reason: "(get-config wasm)",
|
|
79
|
-
error: e
|
|
80
|
-
})), fp_ts_Either.map((result) => ({ result })), fp_ts_Either.chainW(({ result }) => fp_ts_Either.tryCatch(() => JSON.parse(result), (e) => ({
|
|
81
|
-
type: "parse-json",
|
|
82
|
-
reason: "Unable to parse JSON",
|
|
83
|
-
error: e
|
|
84
|
-
}))), fp_ts_Either.chainW((response) => {
|
|
85
|
-
if (response.errors.length > 0) return fp_ts_Either.left({
|
|
86
|
-
type: "validation-error",
|
|
87
|
-
reason: "(get-config wasm)",
|
|
88
|
-
error: response.errors
|
|
89
|
-
});
|
|
90
|
-
return fp_ts_Either.right(response.config);
|
|
91
|
-
}));
|
|
92
|
-
if (fp_ts_Either.isRight(configEither)) {
|
|
93
|
-
const { right: data } = configEither;
|
|
94
|
-
for (const generator of data.generators) await resolveBinaryTargets(generator);
|
|
95
|
-
return Promise.resolve(data);
|
|
96
|
-
}
|
|
97
|
-
throw (0, ts_pattern.match)(configEither.left).with({ type: "wasm-error" }, (e) => {
|
|
98
|
-
return /* @__PURE__ */ new Error(`Prisma get-config Wasm runtime error: ${e.error.message}`);
|
|
99
|
-
}).with({ type: "validation-error" }, (e) => {
|
|
100
|
-
return /* @__PURE__ */ new Error(`Prisma get-config validation error: ${e.error.map((err) => err.message).join(", ")}`);
|
|
101
|
-
}).otherwise((e) => {
|
|
102
|
-
return /* @__PURE__ */ new Error(`Prisma get-config unknown error: ${e.reason} - ${e.error.message}`);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Retrieves the Prisma schema using the provided path.
|
|
107
|
-
*
|
|
108
|
-
* @param path - The path to the Prisma schema file.
|
|
109
|
-
* @returns The Prisma schema.
|
|
110
|
-
*/
|
|
111
|
-
async function getSchema(path) {
|
|
112
|
-
const schema = {
|
|
113
|
-
path,
|
|
114
|
-
content: "",
|
|
115
|
-
generators: [],
|
|
116
|
-
datasources: [],
|
|
117
|
-
warnings: []
|
|
118
|
-
};
|
|
119
|
-
const dataModel = await resolveDataModel(path);
|
|
120
|
-
return {
|
|
121
|
-
...schema,
|
|
122
|
-
...dataModel
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
//#endregion
|
|
127
|
-
Object.defineProperty(exports, '__toESM', {
|
|
128
|
-
enumerable: true,
|
|
129
|
-
get: function () {
|
|
130
|
-
return __toESM;
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(exports, 'getSchema', {
|
|
134
|
-
enumerable: true,
|
|
135
|
-
get: function () {
|
|
136
|
-
return getSchema;
|
|
137
|
-
}
|
|
138
|
-
});
|