@powerlines/plugin-prisma 0.4.287 → 0.4.288

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,147 +0,0 @@
1
- import { findFileExtension } from "@stryke/path/find";
2
- import { buildClient } from "@prisma/client-generator-ts";
3
- import { enginesVersion } from "@prisma/engines-version";
4
- import { bufferToString } from "@stryke/convert/buffer-to-string";
5
- import { replaceExtension } from "@stryke/path/replace";
6
- import { isBuffer } from "@stryke/type-checks/is-buffer";
7
- import { isString } from "@stryke/type-checks/is-string";
8
-
9
- //#region package.json
10
- var version = "0.4.286";
11
-
12
- //#endregion
13
- //#region src/helpers/client-generator.ts
14
- var PowerlinesClientGenerator = class {
15
- context;
16
- #options;
17
- name = "powerlines-client";
18
- constructor(context) {
19
- this.context = context;
20
- this.#options = {
21
- name: this.name,
22
- output: null,
23
- config: {},
24
- provider: {
25
- fromEnvVar: "POWERLINES_CLIENT_PROVIDER",
26
- value: this.name
27
- },
28
- binaryTargets: [],
29
- previewFeatures: this.context.prisma.previewFeatures,
30
- sourceFilePath: this.context.prisma.schema.schemaRootDir
31
- };
32
- }
33
- async getManifest(_config) {
34
- return Promise.resolve({
35
- defaultOutput: "./generated",
36
- prettyName: "Powerlines Client",
37
- version,
38
- requiresEngines: [],
39
- requiresEngineVersion: enginesVersion
40
- });
41
- }
42
- async generate() {
43
- const { prismaClientDmmf, fileMap } = buildClient({
44
- datamodel: this.context.prisma.schema.schemas.map((s) => s.content).join("\n"),
45
- schemaPath: this.context.prisma.schema.schemaPath,
46
- binaryPaths: {},
47
- datasources: this.context.prisma.schema.datasources,
48
- outputDir: this.context.config.prisma.outputPath,
49
- runtimeBase: "@prisma/client/runtime",
50
- dmmf: this.context.prisma.dmmf,
51
- generator: this.#options,
52
- engineVersion: enginesVersion,
53
- clientVersion: version,
54
- activeProvider: this.context.prisma.schema.primaryDatasource?.activeProvider,
55
- typedSql: this.context.prisma.typedSql,
56
- target: this.context.config.prisma.runtime,
57
- generatedFileExtension: "ts",
58
- importFileExtension: "ts",
59
- moduleFormat: "esm",
60
- tsNoCheckPreamble: true,
61
- compilerBuild: "fast"
62
- });
63
- const errorArray = [];
64
- const denylists = {
65
- models: [
66
- "PrismaClient",
67
- "Prisma",
68
- "async",
69
- "await",
70
- "break",
71
- "case",
72
- "catch",
73
- "class",
74
- "const",
75
- "continue",
76
- "debugger",
77
- "default",
78
- "delete",
79
- "do",
80
- "else",
81
- "enum",
82
- "export",
83
- "extends",
84
- "false",
85
- "finally",
86
- "for",
87
- "function",
88
- "if",
89
- "implements",
90
- "import",
91
- "in",
92
- "instanceof",
93
- "interface",
94
- "let",
95
- "new",
96
- "null",
97
- "package",
98
- "private",
99
- "protected",
100
- "public",
101
- "return",
102
- "super",
103
- "switch",
104
- "this",
105
- "throw",
106
- "true",
107
- "try",
108
- "using",
109
- "typeof",
110
- "var",
111
- "void",
112
- "while",
113
- "with",
114
- "yield"
115
- ],
116
- fields: [
117
- "AND",
118
- "OR",
119
- "NOT"
120
- ],
121
- dynamic: []
122
- };
123
- if (prismaClientDmmf.datamodel.enums) {
124
- for (const it of prismaClientDmmf.datamodel.enums) if (denylists.models.includes(it.name) || denylists.fields.includes(it.name)) errorArray.push(/* @__PURE__ */ new Error(`"enum ${it.name}"`));
125
- }
126
- if (prismaClientDmmf.datamodel.models) {
127
- for (const it of prismaClientDmmf.datamodel.models) if (denylists.models.includes(it.name) || denylists.fields.includes(it.name)) errorArray.push(/* @__PURE__ */ new Error(`"model ${it.name}"`));
128
- }
129
- if (errorArray.length > 0) {
130
- let message = `Error: The schema at "${this.context.prisma.schema.schemaPath}" contains reserved keywords.\n Rename the following items:`;
131
- for (const error of errorArray) message += `\n - ${error.message}`;
132
- throw new Error(`${message}\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`);
133
- }
134
- await this.writeFileMap(fileMap);
135
- }
136
- stop() {}
137
- async writeFileMap(fileMap) {
138
- return Promise.all(Object.entries(fileMap).map(async ([fileName, content]) => {
139
- if (isString(content)) this.context.emitBuiltinSync(content, `prisma/${replaceExtension(fileName)}`, { extension: findFileExtension(fileName) || "ts" });
140
- else if (isBuffer(content)) this.context.emitBuiltinSync(bufferToString(content), `prisma/${replaceExtension(fileName)}`, { extension: findFileExtension(fileName) || "ts" });
141
- else await this.writeFileMap(content);
142
- }));
143
- }
144
- };
145
-
146
- //#endregion
147
- export { PowerlinesClientGenerator as t };
@@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_client_generator = require('../client-generator-DzDgrDsT.cjs');
3
-
4
- exports.PowerlinesClientGenerator = require_client_generator.PowerlinesClientGenerator;
@@ -1,3 +0,0 @@
1
- import { t as PowerlinesClientGenerator } from "../client-generator-BXFg7x5g.mjs";
2
-
3
- export { PowerlinesClientGenerator };
@@ -1,102 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_rolldown_runtime = require('../rolldown-runtime-C_NdSu1c.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_rolldown_runtime.__toESM(_prisma_prisma_schema_wasm, 1);
6
- let fp_ts_Either = require("fp-ts/Either");
7
- fp_ts_Either = require_rolldown_runtime.__toESM(fp_ts_Either, 1);
8
- let fp_ts_lib_function = require("fp-ts/lib/function");
9
- let ts_pattern = require("ts-pattern");
10
-
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;
@@ -1,98 +0,0 @@
1
- import { getBinaryTargetForCurrentPlatform } from "@prisma/get-platform";
2
- import prismaSchemaWasm from "@prisma/prisma-schema-wasm";
3
- import * as E from "fp-ts/Either";
4
- import { pipe } from "fp-ts/lib/function";
5
- import { match } from "ts-pattern";
6
-
7
- //#region src/helpers/get-schema.ts
8
- async function resolveBinaryTargets(generator) {
9
- for (const binaryTarget of generator.binaryTargets) {
10
- if (binaryTarget.fromEnvVar && process.env[binaryTarget.fromEnvVar]) {
11
- const value = JSON.parse(process.env[binaryTarget.fromEnvVar]);
12
- if (Array.isArray(value)) {
13
- generator.binaryTargets = value.map((v) => ({
14
- fromEnvVar: null,
15
- value: v
16
- }));
17
- await resolveBinaryTargets(generator);
18
- } else binaryTarget.value = value;
19
- }
20
- if (binaryTarget.value === "native") {
21
- binaryTarget.value = await getBinaryTargetForCurrentPlatform();
22
- binaryTarget.native = true;
23
- }
24
- }
25
- if (generator.binaryTargets.length === 0) generator.binaryTargets = [{
26
- fromEnvVar: null,
27
- value: await getBinaryTargetForCurrentPlatform(),
28
- native: true
29
- }];
30
- }
31
- /**
32
- * Retrieves the Prisma schema using the provided options.
33
- *
34
- * @param schemaPath - The path to the Prisma schema file.
35
- * @returns The Prisma schema.
36
- */
37
- async function resolveDataModel(schemaPath) {
38
- const configEither = pipe(E.tryCatch(() => {
39
- if (process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG) prismaSchemaWasm.debug_panic();
40
- const params = JSON.stringify({
41
- prismaSchema: schemaPath,
42
- datasourceOverrides: {},
43
- ignoreEnvVarErrors: true,
44
- env: process.env
45
- });
46
- return prismaSchemaWasm.get_config(params);
47
- }, (e) => ({
48
- type: "wasm-error",
49
- reason: "(get-config wasm)",
50
- error: e
51
- })), E.map((result) => ({ result })), E.chainW(({ result }) => E.tryCatch(() => JSON.parse(result), (e) => ({
52
- type: "parse-json",
53
- reason: "Unable to parse JSON",
54
- error: e
55
- }))), E.chainW((response) => {
56
- if (response.errors.length > 0) return E.left({
57
- type: "validation-error",
58
- reason: "(get-config wasm)",
59
- error: response.errors
60
- });
61
- return E.right(response.config);
62
- }));
63
- if (E.isRight(configEither)) {
64
- const { right: data } = configEither;
65
- for (const generator of data.generators) await resolveBinaryTargets(generator);
66
- return Promise.resolve(data);
67
- }
68
- throw match(configEither.left).with({ type: "wasm-error" }, (e) => {
69
- return /* @__PURE__ */ new Error(`Prisma get-config Wasm runtime error: ${e.error.message}`);
70
- }).with({ type: "validation-error" }, (e) => {
71
- return /* @__PURE__ */ new Error(`Prisma get-config validation error: ${e.error.map((err) => err.message).join(", ")}`);
72
- }).otherwise((e) => {
73
- return /* @__PURE__ */ new Error(`Prisma get-config unknown error: ${e.reason} - ${e.error.message}`);
74
- });
75
- }
76
- /**
77
- * Retrieves the Prisma schema using the provided path.
78
- *
79
- * @param path - The path to the Prisma schema file.
80
- * @returns The Prisma schema.
81
- */
82
- async function getSchema(path) {
83
- const schema = {
84
- path,
85
- content: "",
86
- generators: [],
87
- datasources: [],
88
- warnings: []
89
- };
90
- const dataModel = await resolveDataModel(path);
91
- return {
92
- ...schema,
93
- ...dataModel
94
- };
95
- }
96
-
97
- //#endregion
98
- export { getSchema };
@@ -1,10 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_client_generator = require('../client-generator-DzDgrDsT.cjs');
3
- const require_helpers_get_schema = require('./get-schema.cjs');
4
- const require_helpers_schema_creator = require('./schema-creator.cjs');
5
- const require_helpers_typed_sql = require('./typed-sql.cjs');
6
-
7
- exports.PowerlinesClientGenerator = require_client_generator.PowerlinesClientGenerator;
8
- exports.PrismaSchemaCreator = require_helpers_schema_creator.PrismaSchemaCreator;
9
- exports.getSchema = require_helpers_get_schema.getSchema;
10
- exports.introspectSql = require_helpers_typed_sql.introspectSql;
@@ -1,6 +0,0 @@
1
- import { t as PowerlinesClientGenerator } from "../client-generator-BXFg7x5g.mjs";
2
- import { getSchema } from "./get-schema.mjs";
3
- import { PrismaSchemaCreator } from "./schema-creator.mjs";
4
- import { introspectSql } from "./typed-sql.mjs";
5
-
6
- export { PowerlinesClientGenerator, PrismaSchemaCreator, getSchema, introspectSql };
@@ -1,61 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- let prisma_util_schema_creator = require("prisma-util/schema-creator");
3
-
4
- //#region src/helpers/schema-creator.ts
5
- /**
6
- * Prisma schema creator that allows building a schema via code.
7
- */
8
- var PrismaSchemaCreator = class extends prisma_util_schema_creator.SchemaCreator {
9
- /** Prisma plugin context */
10
- #context;
11
- get generators() {
12
- return this.#context.prisma.schema.generators;
13
- }
14
- set generators(value) {
15
- this.#context.prisma.schema.generators = value;
16
- }
17
- constructor(context) {
18
- super();
19
- this.#context = context;
20
- this.#context.prisma ??= {};
21
- this.#context.prisma.schema ??= {
22
- generators: [],
23
- datasources: [],
24
- warnings: []
25
- };
26
- this.#context.prisma.schema.generators.forEach((generator) => {
27
- this.pushGenerator(generator);
28
- });
29
- }
30
- pushGenerator(generator) {
31
- if (this.generators.some((gen) => gen.name === generator.name)) this.generators = [...this.generators.filter((gen) => gen.name !== generator.name), generator];
32
- else this.generators.push(generator);
33
- return this;
34
- }
35
- build() {
36
- let schema = super.build();
37
- for (const generator of this.generators) schema = `
38
- generator ${generator.name} {
39
- provider = "${generator.provider.value}"
40
- output = "${generator.output?.value}"${generator.previewFeatures && generator.previewFeatures.length > 0 ? `
41
- previewFeatures = [${generator.previewFeatures.map((feature) => `"${feature}"`).join(", ")}]` : ""}${generator.config && Object.keys(generator.config).length > 0 ? Object.entries(generator.config).map(([key, value]) => {
42
- if (Array.isArray(value)) return `${key} = [${value.map((v) => `"${v}"`).join(", ")}]`;
43
- else return `${key} = "${value}"`;
44
- }).join("\n ") : ""}${generator.binaryTargets && generator.binaryTargets.length > 0 ? `
45
- binaryTargets = [${generator.binaryTargets.map((bt) => `"${bt.value}"`).join(", ")}]` : ""}${generator.envPaths?.rootEnvPath || generator.envPaths?.schemaEnvPath ? `
46
- env = {${generator.envPaths?.rootEnvPath ? `
47
- root = "${generator.envPaths.rootEnvPath}"` : ""}${generator.envPaths?.schemaEnvPath ? `
48
- schema = "${generator.envPaths.schemaEnvPath}"` : ""}
49
- }` : ""}
50
- }
51
-
52
- ${schema}`;
53
- return schema;
54
- }
55
- async write() {
56
- await this.#context.fs.write(this.#context.config.prisma.schema, this.build());
57
- }
58
- };
59
-
60
- //#endregion
61
- exports.PrismaSchemaCreator = PrismaSchemaCreator;
@@ -1,60 +0,0 @@
1
- import { SchemaCreator } from "prisma-util/schema-creator";
2
-
3
- //#region src/helpers/schema-creator.ts
4
- /**
5
- * Prisma schema creator that allows building a schema via code.
6
- */
7
- var PrismaSchemaCreator = class extends SchemaCreator {
8
- /** Prisma plugin context */
9
- #context;
10
- get generators() {
11
- return this.#context.prisma.schema.generators;
12
- }
13
- set generators(value) {
14
- this.#context.prisma.schema.generators = value;
15
- }
16
- constructor(context) {
17
- super();
18
- this.#context = context;
19
- this.#context.prisma ??= {};
20
- this.#context.prisma.schema ??= {
21
- generators: [],
22
- datasources: [],
23
- warnings: []
24
- };
25
- this.#context.prisma.schema.generators.forEach((generator) => {
26
- this.pushGenerator(generator);
27
- });
28
- }
29
- pushGenerator(generator) {
30
- if (this.generators.some((gen) => gen.name === generator.name)) this.generators = [...this.generators.filter((gen) => gen.name !== generator.name), generator];
31
- else this.generators.push(generator);
32
- return this;
33
- }
34
- build() {
35
- let schema = super.build();
36
- for (const generator of this.generators) schema = `
37
- generator ${generator.name} {
38
- provider = "${generator.provider.value}"
39
- output = "${generator.output?.value}"${generator.previewFeatures && generator.previewFeatures.length > 0 ? `
40
- previewFeatures = [${generator.previewFeatures.map((feature) => `"${feature}"`).join(", ")}]` : ""}${generator.config && Object.keys(generator.config).length > 0 ? Object.entries(generator.config).map(([key, value]) => {
41
- if (Array.isArray(value)) return `${key} = [${value.map((v) => `"${v}"`).join(", ")}]`;
42
- else return `${key} = "${value}"`;
43
- }).join("\n ") : ""}${generator.binaryTargets && generator.binaryTargets.length > 0 ? `
44
- binaryTargets = [${generator.binaryTargets.map((bt) => `"${bt.value}"`).join(", ")}]` : ""}${generator.envPaths?.rootEnvPath || generator.envPaths?.schemaEnvPath ? `
45
- env = {${generator.envPaths?.rootEnvPath ? `
46
- root = "${generator.envPaths.rootEnvPath}"` : ""}${generator.envPaths?.schemaEnvPath ? `
47
- schema = "${generator.envPaths.schemaEnvPath}"` : ""}
48
- }` : ""}
49
- }
50
-
51
- ${schema}`;
52
- return schema;
53
- }
54
- async write() {
55
- await this.#context.fs.write(this.#context.config.prisma.schema, this.build());
56
- }
57
- };
58
-
59
- //#endregion
60
- export { PrismaSchemaCreator };
@@ -1,37 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- let _prisma_internals = require("@prisma/internals");
3
- let _prisma_migrate = require("@prisma/migrate");
4
- let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
5
- let _stryke_path_join = require("@stryke/path/join");
6
-
7
- //#region src/helpers/typed-sql.ts
8
- async function readTypedSqlFiles(context, typedSqlDirPath) {
9
- const files = await context.fs.list(typedSqlDirPath);
10
- const results = [];
11
- for (const fileName of files) {
12
- if ((0, _stryke_path_file_path_fns.findFileExtension)(fileName) !== ".sql") continue;
13
- if (!(0, _prisma_internals.isValidJsIdentifier)((0, _stryke_path_file_path_fns.findFileName)(fileName, { withExtension: false }))) throw new Error(`${(0, _stryke_path_join.joinPaths)(typedSqlDirPath, fileName)} can not be used as a typed sql query: name must be a valid JS identifier`);
14
- if ((0, _stryke_path_file_path_fns.findFileName)(fileName).startsWith("$")) throw new Error(`${(0, _stryke_path_join.joinPaths)(typedSqlDirPath, fileName)} can not be used as a typed sql query: name must not start with $`);
15
- results.push({
16
- name: (0, _stryke_path_file_path_fns.findFileName)(fileName, { withExtension: false }),
17
- source: await context.fs.read((0, _stryke_path_join.joinPaths)(typedSqlDirPath, fileName)),
18
- fileName: (0, _stryke_path_join.joinPaths)(typedSqlDirPath, fileName)
19
- });
20
- }
21
- return results;
22
- }
23
- async function introspectSql(context) {
24
- const sqlFiles = await readTypedSqlFiles(context, (0, _prisma_internals.inferDirectoryConfig)(context.prisma.schema, context.prisma.config).typedSqlDirPath);
25
- const introspectionResult = await (0, _prisma_migrate.introspectSql)(context.prisma.schema, context.prisma.config, context.config.root, sqlFiles);
26
- if (introspectionResult.ok) return introspectionResult.queries;
27
- const lines = [`Errors while reading sql files:\n`];
28
- for (const { fileName, message } of introspectionResult.errors) {
29
- lines.push(`In ${(0, _stryke_path_file_path_fns.relativePath)(process.cwd(), fileName)}:`);
30
- lines.push(message);
31
- lines.push("");
32
- }
33
- throw new Error(lines.join("\n"));
34
- }
35
-
36
- //#endregion
37
- exports.introspectSql = introspectSql;
@@ -1,36 +0,0 @@
1
- import { inferDirectoryConfig, isValidJsIdentifier } from "@prisma/internals";
2
- import { introspectSql as introspectSql$1 } from "@prisma/migrate";
3
- import { findFileExtension, findFileName, relativePath } from "@stryke/path/file-path-fns";
4
- import { joinPaths } from "@stryke/path/join";
5
-
6
- //#region src/helpers/typed-sql.ts
7
- async function readTypedSqlFiles(context, typedSqlDirPath) {
8
- const files = await context.fs.list(typedSqlDirPath);
9
- const results = [];
10
- for (const fileName of files) {
11
- if (findFileExtension(fileName) !== ".sql") continue;
12
- if (!isValidJsIdentifier(findFileName(fileName, { withExtension: false }))) throw new Error(`${joinPaths(typedSqlDirPath, fileName)} can not be used as a typed sql query: name must be a valid JS identifier`);
13
- if (findFileName(fileName).startsWith("$")) throw new Error(`${joinPaths(typedSqlDirPath, fileName)} can not be used as a typed sql query: name must not start with $`);
14
- results.push({
15
- name: findFileName(fileName, { withExtension: false }),
16
- source: await context.fs.read(joinPaths(typedSqlDirPath, fileName)),
17
- fileName: joinPaths(typedSqlDirPath, fileName)
18
- });
19
- }
20
- return results;
21
- }
22
- async function introspectSql(context) {
23
- const sqlFiles = await readTypedSqlFiles(context, inferDirectoryConfig(context.prisma.schema, context.prisma.config).typedSqlDirPath);
24
- const introspectionResult = await introspectSql$1(context.prisma.schema, context.prisma.config, context.config.root, sqlFiles);
25
- if (introspectionResult.ok) return introspectionResult.queries;
26
- const lines = [`Errors while reading sql files:\n`];
27
- for (const { fileName, message } of introspectionResult.errors) {
28
- lines.push(`In ${relativePath(process.cwd(), fileName)}:`);
29
- lines.push(message);
30
- lines.push("");
31
- }
32
- throw new Error(lines.join("\n"));
33
- }
34
-
35
- //#endregion
36
- export { introspectSql };
File without changes
@@ -1 +0,0 @@
1
- export { };