@powerlines/plugin-prisma 0.2.207 → 0.2.209
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/api/client/client.gen.cjs +175 -8
- package/dist/api/client/client.gen.mjs +174 -7
- package/dist/api/client/index.cjs +13 -18
- package/dist/api/client/index.mjs +5 -10
- package/dist/api/client/utils.gen.cjs +186 -13
- package/dist/api/client/utils.gen.mjs +178 -5
- package/dist/api/client.gen.cjs +8 -12
- package/dist/api/client.gen.mjs +7 -11
- package/dist/api/core/auth.gen.cjs +11 -2
- package/dist/api/core/auth.gen.mjs +9 -1
- package/dist/api/core/bodySerializer.gen.cjs +34 -4
- package/dist/api/core/bodySerializer.gen.mjs +30 -1
- package/dist/api/core/params.gen.cjs +64 -2
- package/dist/api/core/params.gen.mjs +62 -1
- package/dist/api/core/pathSerializer.gen.cjs +86 -7
- package/dist/api/core/pathSerializer.gen.mjs +79 -1
- package/dist/api/core/queryKeySerializer.gen.cjs +65 -4
- package/dist/api/core/queryKeySerializer.gen.mjs +61 -1
- package/dist/api/core/serverSentEvents.gen.cjs +94 -2
- package/dist/api/core/serverSentEvents.gen.mjs +92 -1
- package/dist/api/core/utils.gen.cjs +80 -6
- package/dist/api/core/utils.gen.mjs +76 -2
- package/dist/api/sdk.gen.cjs +255 -13
- package/dist/api/sdk.gen.mjs +254 -12
- package/dist/api/types.gen.cjs +0 -1
- package/dist/api/types.gen.mjs +0 -2
- package/dist/helpers/get-schema.cjs +80 -2
- package/dist/helpers/get-schema.mjs +76 -1
- package/dist/helpers/index.cjs +6 -6
- package/dist/helpers/index.mjs +3 -3
- package/dist/helpers/prisma-postgres.cjs +15 -2
- package/dist/helpers/prisma-postgres.mjs +13 -1
- package/dist/helpers/schema-creator.cjs +60 -2
- package/dist/helpers/schema-creator.mjs +58 -1
- package/dist/index.cjs +14 -25
- package/dist/index.mjs +6 -18
- package/dist/types/index.cjs +0 -3
- package/dist/types/index.mjs +0 -4
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.mjs +0 -2
- package/dist/types/prisma.cjs +0 -1
- package/dist/types/prisma.mjs +0 -2
- package/package.json +5 -5
- package/dist/auth.gen-BFteuMTV.cjs +0 -17
- package/dist/auth.gen-C4FxE4_3.mjs +0 -11
- package/dist/bodySerializer.gen-BLtxkFoA.cjs +0 -50
- package/dist/bodySerializer.gen-DBXNewIA.mjs +0 -32
- package/dist/client-BlRUW8mL.mjs +0 -1
- package/dist/client-DBAc9HV1.cjs +0 -0
- package/dist/client.gen-COMS1glH.mjs +0 -8
- package/dist/client.gen-CPQm4WCv.mjs +0 -176
- package/dist/client.gen-DPSMNZNm.cjs +0 -181
- package/dist/client.gen-JhYC1fDf.cjs +0 -13
- package/dist/get-schema-CKw6MiKb.mjs +0 -78
- package/dist/get-schema-CqMBOHOd.cjs +0 -118
- package/dist/params.gen-BM1l95BD.mjs +0 -64
- package/dist/params.gen-BtCSnwiV.cjs +0 -70
- package/dist/pathSerializer.gen-BEbuI0Vn.cjs +0 -117
- package/dist/pathSerializer.gen-m7BRzH23.mjs +0 -81
- package/dist/plugin-DE9fKOLA.cjs +0 -0
- package/dist/plugin-EFmNQLKA.mjs +0 -1
- package/dist/prisma-BzQJneyW.cjs +0 -0
- package/dist/prisma-CB-m5c-j.mjs +0 -1
- package/dist/prisma-postgres-CAOpTtWq.mjs +0 -15
- package/dist/prisma-postgres-dGaLzxF3.cjs +0 -21
- package/dist/queryKeySerializer.gen-4TWHHXn3.cjs +0 -81
- package/dist/queryKeySerializer.gen-BMMZAjVN.mjs +0 -63
- package/dist/schema-creator-Cfian3ih.mjs +0 -60
- package/dist/schema-creator-zmlwh4-l.cjs +0 -66
- package/dist/sdk.gen-B2his2jD.mjs +0 -256
- package/dist/sdk.gen-CAWIQ8BM.cjs +0 -261
- package/dist/serverSentEvents.gen-C4apQvDl.mjs +0 -94
- package/dist/serverSentEvents.gen-CiMMmhyQ.cjs +0 -100
- package/dist/types-CmY9-4ff.cjs +0 -0
- package/dist/types-Dbwx-Khg.mjs +0 -1
- package/dist/types.gen-BN-p9nVT.cjs +0 -0
- package/dist/types.gen-CS2KiRfG.mjs +0 -1
- package/dist/utils.gen-Bk2pTkV1.cjs +0 -101
- package/dist/utils.gen-C-7sZa7Z.mjs +0 -180
- package/dist/utils.gen-DATakax-.cjs +0 -227
- package/dist/utils.gen-RO8GxC4i.mjs +0 -78
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const require_helpers_get_schema = require('./get-schema.cjs');
|
|
2
|
+
const require_helpers_schema_creator = require('./schema-creator.cjs');
|
|
3
|
+
const require_helpers_prisma_postgres = require('./prisma-postgres.cjs');
|
|
4
4
|
|
|
5
|
-
exports.PrismaSchemaCreator =
|
|
6
|
-
exports.findDatabaseByName =
|
|
7
|
-
exports.getSchema =
|
|
5
|
+
exports.PrismaSchemaCreator = require_helpers_schema_creator.PrismaSchemaCreator;
|
|
6
|
+
exports.findDatabaseByName = require_helpers_prisma_postgres.findDatabaseByName;
|
|
7
|
+
exports.getSchema = require_helpers_get_schema.getSchema;
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { getSchema } from "./get-schema.mjs";
|
|
2
|
+
import { PrismaSchemaCreator } from "./schema-creator.mjs";
|
|
3
|
+
import { findDatabaseByName } from "./prisma-postgres.mjs";
|
|
4
4
|
|
|
5
5
|
export { PrismaSchemaCreator, findDatabaseByName, getSchema };
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
const require_prisma_postgres = require('../prisma-postgres-dGaLzxF3.cjs');
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
//#region src/helpers/prisma-postgres.ts
|
|
3
|
+
/**
|
|
4
|
+
* Find a Postgres database by name.
|
|
5
|
+
*
|
|
6
|
+
* @param context - The Prisma plugin context.
|
|
7
|
+
* @param name - The name of the database to find.
|
|
8
|
+
* @returns The database object if found, otherwise undefined.
|
|
9
|
+
*/
|
|
10
|
+
async function findDatabaseByName(context, name) {
|
|
11
|
+
if (!context.config.prisma.prismaPostgres?.projectId) throw new Error(`Prisma Postgres project ID is not configured. Please set "prisma.prismaPostgres.projectId" in your Powerlines configuration.`);
|
|
12
|
+
return (await context.prisma.api.listDatabases({ path: { projectId: context.config.prisma.prismaPostgres.projectId } })).data.data.find((db) => db.name === name);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.findDatabaseByName = findDatabaseByName;
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/helpers/prisma-postgres.ts
|
|
2
|
+
/**
|
|
3
|
+
* Find a Postgres database by name.
|
|
4
|
+
*
|
|
5
|
+
* @param context - The Prisma plugin context.
|
|
6
|
+
* @param name - The name of the database to find.
|
|
7
|
+
* @returns The database object if found, otherwise undefined.
|
|
8
|
+
*/
|
|
9
|
+
async function findDatabaseByName(context, name) {
|
|
10
|
+
if (!context.config.prisma.prismaPostgres?.projectId) throw new Error(`Prisma Postgres project ID is not configured. Please set "prisma.prismaPostgres.projectId" in your Powerlines configuration.`);
|
|
11
|
+
return (await context.prisma.api.listDatabases({ path: { projectId: context.config.prisma.prismaPostgres.projectId } })).data.data.find((db) => db.name === name);
|
|
12
|
+
}
|
|
2
13
|
|
|
14
|
+
//#endregion
|
|
3
15
|
export { findDatabaseByName };
|
|
@@ -1,3 +1,61 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let prisma_util_schema_creator = require("prisma-util/schema-creator");
|
|
2
3
|
|
|
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,3 +1,60 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SchemaCreator } from "prisma-util/schema-creator";
|
|
2
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
|
|
3
60
|
export { PrismaSchemaCreator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const
|
|
3
|
-
require('./
|
|
4
|
-
require('./
|
|
5
|
-
require('./
|
|
6
|
-
require('./
|
|
7
|
-
require('./
|
|
8
|
-
const
|
|
9
|
-
const require_client_gen = require('./client.gen-DPSMNZNm.cjs');
|
|
10
|
-
require('./params.gen-BtCSnwiV.cjs');
|
|
11
|
-
require('./queryKeySerializer.gen-4TWHHXn3.cjs');
|
|
12
|
-
require('./client-DBAc9HV1.cjs');
|
|
13
|
-
const require_client_gen$1 = require('./client.gen-JhYC1fDf.cjs');
|
|
14
|
-
const require_sdk_gen = require('./sdk.gen-CAWIQ8BM.cjs');
|
|
15
|
-
const require_schema_creator = require('./schema-creator-zmlwh4-l.cjs');
|
|
16
|
-
require('./types.gen-BN-p9nVT.cjs');
|
|
17
|
-
require('./plugin-DE9fKOLA.cjs');
|
|
18
|
-
require('./prisma-BzQJneyW.cjs');
|
|
19
|
-
require('./types-CmY9-4ff.cjs');
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_api_client_utils_gen = require('./api/client/utils.gen.cjs');
|
|
4
|
+
const require_api_client_client_gen = require('./api/client/client.gen.cjs');
|
|
5
|
+
const require_api_client_gen = require('./api/client.gen.cjs');
|
|
6
|
+
const require_api_sdk_gen = require('./api/sdk.gen.cjs');
|
|
7
|
+
const require_helpers_get_schema = require('./helpers/get-schema.cjs');
|
|
8
|
+
const require_helpers_schema_creator = require('./helpers/schema-creator.cjs');
|
|
20
9
|
let __stryke_cli_execute = require("@stryke/cli/execute");
|
|
21
10
|
let __stryke_fs_exists = require("@stryke/fs/exists");
|
|
22
11
|
let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
|
|
23
12
|
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
24
13
|
let __stryke_path_replace = require("@stryke/path/replace");
|
|
25
14
|
let defu = require("defu");
|
|
26
|
-
defu =
|
|
15
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
27
16
|
let powerlines_plugin_utils_get_config_path = require("powerlines/plugin-utils/get-config-path");
|
|
28
17
|
let powerlines_plugin_utils_paths = require("powerlines/plugin-utils/paths");
|
|
29
18
|
|
|
@@ -60,7 +49,7 @@ const plugin = (options = {}) => {
|
|
|
60
49
|
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.");
|
|
61
50
|
else throw new Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");
|
|
62
51
|
}
|
|
63
|
-
const client$1 =
|
|
52
|
+
const client$1 = require_api_client_client_gen.createClient(require_api_client_utils_gen.createConfig({
|
|
64
53
|
baseUrl: "https://api.prisma.io",
|
|
65
54
|
throwOnError: true,
|
|
66
55
|
headers: {
|
|
@@ -68,7 +57,7 @@ const plugin = (options = {}) => {
|
|
|
68
57
|
"User-Agent": "powerlines/1.0"
|
|
69
58
|
}
|
|
70
59
|
}));
|
|
71
|
-
this.prisma.api = new
|
|
60
|
+
this.prisma.api = new require_api_sdk_gen.PrismaClient({ client: client$1 });
|
|
72
61
|
await this.prisma.api.createDatabase({
|
|
73
62
|
path: { projectId: this.config.prisma.prismaPostgres.projectId },
|
|
74
63
|
body: {
|
|
@@ -86,7 +75,7 @@ const plugin = (options = {}) => {
|
|
|
86
75
|
datasources: [],
|
|
87
76
|
warnings: []
|
|
88
77
|
};
|
|
89
|
-
else this.prisma.schema = await
|
|
78
|
+
else this.prisma.schema = await require_helpers_get_schema.getSchema({ datamodel: this.config.prisma.schema });
|
|
90
79
|
const generator = this.prisma.schema.generators.find((gen) => gen.provider.value === "prisma-client-js");
|
|
91
80
|
if (!generator) this.prisma.schema.generators.push({
|
|
92
81
|
name: "prisma-client-js",
|
|
@@ -107,7 +96,7 @@ const plugin = (options = {}) => {
|
|
|
107
96
|
value: this.config.prisma.outputPath,
|
|
108
97
|
fromEnvVar: null
|
|
109
98
|
};
|
|
110
|
-
this.prisma.builder = new
|
|
99
|
+
this.prisma.builder = new require_helpers_schema_creator.PrismaSchemaCreator(this);
|
|
111
100
|
},
|
|
112
101
|
async prepare() {
|
|
113
102
|
await this.prisma.builder.write();
|
|
@@ -132,7 +121,7 @@ const plugin = (options = {}) => {
|
|
|
132
121
|
var src_default = plugin;
|
|
133
122
|
|
|
134
123
|
//#endregion
|
|
135
|
-
exports.PrismaClient =
|
|
136
|
-
exports.client =
|
|
124
|
+
exports.PrismaClient = require_api_sdk_gen.PrismaClient;
|
|
125
|
+
exports.client = require_api_client_gen.client;
|
|
137
126
|
exports.default = src_default;
|
|
138
127
|
exports.plugin = plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
5
|
-
import "./
|
|
6
|
-
import {
|
|
7
|
-
import { t as createClient } from "./client.gen-CPQm4WCv.mjs";
|
|
8
|
-
import "./params.gen-BM1l95BD.mjs";
|
|
9
|
-
import "./queryKeySerializer.gen-BMMZAjVN.mjs";
|
|
10
|
-
import "./client-BlRUW8mL.mjs";
|
|
11
|
-
import { t as client } from "./client.gen-COMS1glH.mjs";
|
|
12
|
-
import { t as PrismaClient } from "./sdk.gen-B2his2jD.mjs";
|
|
13
|
-
import { t as getSchema } from "./get-schema-CKw6MiKb.mjs";
|
|
14
|
-
import { t as PrismaSchemaCreator } from "./schema-creator-Cfian3ih.mjs";
|
|
15
|
-
import "./types.gen-CS2KiRfG.mjs";
|
|
16
|
-
import "./plugin-EFmNQLKA.mjs";
|
|
17
|
-
import "./prisma-CB-m5c-j.mjs";
|
|
18
|
-
import "./types-Dbwx-Khg.mjs";
|
|
1
|
+
import { createConfig } from "./api/client/utils.gen.mjs";
|
|
2
|
+
import { createClient } from "./api/client/client.gen.mjs";
|
|
3
|
+
import { client } from "./api/client.gen.mjs";
|
|
4
|
+
import { PrismaClient } from "./api/sdk.gen.mjs";
|
|
5
|
+
import { getSchema } from "./helpers/get-schema.mjs";
|
|
6
|
+
import { PrismaSchemaCreator } from "./helpers/schema-creator.mjs";
|
|
19
7
|
import { execute, executePackage } from "@stryke/cli/execute";
|
|
20
8
|
import { existsSync } from "@stryke/fs/exists";
|
|
21
9
|
import { isPackageListed } from "@stryke/fs/package-fns";
|
package/dist/types/index.cjs
CHANGED
package/dist/types/index.mjs
CHANGED
package/dist/types/plugin.cjs
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('../plugin-DE9fKOLA.cjs');
|
package/dist/types/plugin.mjs
CHANGED
package/dist/types/prisma.cjs
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('../prisma-BzQJneyW.cjs');
|
package/dist/types/prisma.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-prisma",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.209",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin to generate project code and a Prisma client from a Prisma schema (PSL).",
|
|
6
6
|
"repository": {
|
|
@@ -379,15 +379,15 @@
|
|
|
379
379
|
"defu": "^6.1.4",
|
|
380
380
|
"fp-ts": "^2.16.11",
|
|
381
381
|
"jiti": "^2.6.1",
|
|
382
|
-
"powerlines": "^0.38.
|
|
382
|
+
"powerlines": "^0.38.22",
|
|
383
383
|
"prisma-util": "^2.1.1",
|
|
384
384
|
"ts-pattern": "^5.9.0"
|
|
385
385
|
},
|
|
386
386
|
"devDependencies": {
|
|
387
|
-
"@powerlines/plugin-hey-api": "^0.1.
|
|
388
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
387
|
+
"@powerlines/plugin-hey-api": "^0.1.209",
|
|
388
|
+
"@powerlines/plugin-plugin": "^0.12.206",
|
|
389
389
|
"@types/node": "^24.10.9"
|
|
390
390
|
},
|
|
391
391
|
"publishConfig": { "access": "public" },
|
|
392
|
-
"gitHead": "
|
|
392
|
+
"gitHead": "02ca3097aeae5f5bb4838b4263e8cf7cc44fa3bd"
|
|
393
393
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/api/core/auth.gen.ts
|
|
3
|
-
const getAuthToken = async (auth, callback) => {
|
|
4
|
-
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
5
|
-
if (!token) return;
|
|
6
|
-
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
7
|
-
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
8
|
-
return token;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
Object.defineProperty(exports, 'getAuthToken', {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return getAuthToken;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/api/core/auth.gen.ts
|
|
2
|
-
const getAuthToken = async (auth, callback) => {
|
|
3
|
-
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
4
|
-
if (!token) return;
|
|
5
|
-
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
6
|
-
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
7
|
-
return token;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { getAuthToken as t };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/api/core/bodySerializer.gen.ts
|
|
3
|
-
const serializeFormDataPair = (data, key, value) => {
|
|
4
|
-
if (typeof value === "string" || value instanceof Blob) data.append(key, value);
|
|
5
|
-
else if (value instanceof Date) data.append(key, value.toISOString());
|
|
6
|
-
else data.append(key, JSON.stringify(value));
|
|
7
|
-
};
|
|
8
|
-
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
9
|
-
if (typeof value === "string") data.append(key, value);
|
|
10
|
-
else data.append(key, JSON.stringify(value));
|
|
11
|
-
};
|
|
12
|
-
const formDataBodySerializer = { bodySerializer: (body) => {
|
|
13
|
-
const data = new FormData();
|
|
14
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
15
|
-
if (value === void 0 || value === null) return;
|
|
16
|
-
if (Array.isArray(value)) value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
17
|
-
else serializeFormDataPair(data, key, value);
|
|
18
|
-
});
|
|
19
|
-
return data;
|
|
20
|
-
} };
|
|
21
|
-
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
22
|
-
const urlSearchParamsBodySerializer = { bodySerializer: (body) => {
|
|
23
|
-
const data = new URLSearchParams();
|
|
24
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
25
|
-
if (value === void 0 || value === null) return;
|
|
26
|
-
if (Array.isArray(value)) value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
27
|
-
else serializeUrlSearchParamsPair(data, key, value);
|
|
28
|
-
});
|
|
29
|
-
return data.toString();
|
|
30
|
-
} };
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
Object.defineProperty(exports, 'formDataBodySerializer', {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () {
|
|
36
|
-
return formDataBodySerializer;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
Object.defineProperty(exports, 'jsonBodySerializer', {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () {
|
|
42
|
-
return jsonBodySerializer;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
Object.defineProperty(exports, 'urlSearchParamsBodySerializer', {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () {
|
|
48
|
-
return urlSearchParamsBodySerializer;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//#region src/api/core/bodySerializer.gen.ts
|
|
2
|
-
const serializeFormDataPair = (data, key, value) => {
|
|
3
|
-
if (typeof value === "string" || value instanceof Blob) data.append(key, value);
|
|
4
|
-
else if (value instanceof Date) data.append(key, value.toISOString());
|
|
5
|
-
else data.append(key, JSON.stringify(value));
|
|
6
|
-
};
|
|
7
|
-
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
8
|
-
if (typeof value === "string") data.append(key, value);
|
|
9
|
-
else data.append(key, JSON.stringify(value));
|
|
10
|
-
};
|
|
11
|
-
const formDataBodySerializer = { bodySerializer: (body) => {
|
|
12
|
-
const data = new FormData();
|
|
13
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
14
|
-
if (value === void 0 || value === null) return;
|
|
15
|
-
if (Array.isArray(value)) value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
16
|
-
else serializeFormDataPair(data, key, value);
|
|
17
|
-
});
|
|
18
|
-
return data;
|
|
19
|
-
} };
|
|
20
|
-
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
21
|
-
const urlSearchParamsBodySerializer = { bodySerializer: (body) => {
|
|
22
|
-
const data = new URLSearchParams();
|
|
23
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
24
|
-
if (value === void 0 || value === null) return;
|
|
25
|
-
if (Array.isArray(value)) value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
26
|
-
else serializeUrlSearchParamsPair(data, key, value);
|
|
27
|
-
});
|
|
28
|
-
return data.toString();
|
|
29
|
-
} };
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
export { jsonBodySerializer as n, urlSearchParamsBodySerializer as r, formDataBodySerializer as t };
|
package/dist/client-BlRUW8mL.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/client-DBAc9HV1.cjs
DELETED
|
File without changes
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { n as createConfig } from "./utils.gen-C-7sZa7Z.mjs";
|
|
2
|
-
import { t as createClient } from "./client.gen-CPQm4WCv.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/api/client.gen.ts
|
|
5
|
-
const client = createClient(createConfig({ throwOnError: true }));
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
export { client as t };
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { t as createSseClient } from "./serverSentEvents.gen-C4apQvDl.mjs";
|
|
2
|
-
import { i as getValidRequestBody } from "./utils.gen-RO8GxC4i.mjs";
|
|
3
|
-
import { a as getParseAs, c as setAuthParams, n as createConfig, o as mergeConfigs, r as createInterceptors, s as mergeHeaders, t as buildUrl } from "./utils.gen-C-7sZa7Z.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/api/client/client.gen.ts
|
|
6
|
-
const createClient = (config = {}) => {
|
|
7
|
-
let _config = mergeConfigs(createConfig(), config);
|
|
8
|
-
const getConfig = () => ({ ..._config });
|
|
9
|
-
const setConfig = (config$1) => {
|
|
10
|
-
_config = mergeConfigs(_config, config$1);
|
|
11
|
-
return getConfig();
|
|
12
|
-
};
|
|
13
|
-
const interceptors = createInterceptors();
|
|
14
|
-
const beforeRequest = async (options) => {
|
|
15
|
-
const opts = {
|
|
16
|
-
..._config,
|
|
17
|
-
...options,
|
|
18
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
19
|
-
headers: mergeHeaders(_config.headers, options.headers),
|
|
20
|
-
serializedBody: void 0
|
|
21
|
-
};
|
|
22
|
-
if (opts.security) await setAuthParams({
|
|
23
|
-
...opts,
|
|
24
|
-
security: opts.security
|
|
25
|
-
});
|
|
26
|
-
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
27
|
-
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
28
|
-
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
29
|
-
return {
|
|
30
|
-
opts,
|
|
31
|
-
url: buildUrl(opts)
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
const request = async (options) => {
|
|
35
|
-
const { opts, url } = await beforeRequest(options);
|
|
36
|
-
const requestInit = {
|
|
37
|
-
redirect: "follow",
|
|
38
|
-
...opts,
|
|
39
|
-
body: getValidRequestBody(opts)
|
|
40
|
-
};
|
|
41
|
-
let request$1 = new Request(url, requestInit);
|
|
42
|
-
for (const fn of interceptors.request.fns) if (fn) request$1 = await fn(request$1, opts);
|
|
43
|
-
const _fetch = opts.fetch;
|
|
44
|
-
let response;
|
|
45
|
-
try {
|
|
46
|
-
response = await _fetch(request$1);
|
|
47
|
-
} catch (error$1) {
|
|
48
|
-
let finalError$1 = error$1;
|
|
49
|
-
for (const fn of interceptors.error.fns) if (fn) finalError$1 = await fn(error$1, void 0, request$1, opts);
|
|
50
|
-
finalError$1 = finalError$1 || {};
|
|
51
|
-
if (opts.throwOnError) throw finalError$1;
|
|
52
|
-
return opts.responseStyle === "data" ? void 0 : {
|
|
53
|
-
error: finalError$1,
|
|
54
|
-
request: request$1,
|
|
55
|
-
response: void 0
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request$1, opts);
|
|
59
|
-
const result = {
|
|
60
|
-
request: request$1,
|
|
61
|
-
response
|
|
62
|
-
};
|
|
63
|
-
if (response.ok) {
|
|
64
|
-
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
65
|
-
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
66
|
-
let emptyData;
|
|
67
|
-
switch (parseAs) {
|
|
68
|
-
case "arrayBuffer":
|
|
69
|
-
case "blob":
|
|
70
|
-
case "text":
|
|
71
|
-
emptyData = await response[parseAs]();
|
|
72
|
-
break;
|
|
73
|
-
case "formData":
|
|
74
|
-
emptyData = new FormData();
|
|
75
|
-
break;
|
|
76
|
-
case "stream":
|
|
77
|
-
emptyData = response.body;
|
|
78
|
-
break;
|
|
79
|
-
case "json":
|
|
80
|
-
default:
|
|
81
|
-
emptyData = {};
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
return opts.responseStyle === "data" ? emptyData : {
|
|
85
|
-
data: emptyData,
|
|
86
|
-
...result
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
let data;
|
|
90
|
-
switch (parseAs) {
|
|
91
|
-
case "arrayBuffer":
|
|
92
|
-
case "blob":
|
|
93
|
-
case "formData":
|
|
94
|
-
case "json":
|
|
95
|
-
case "text":
|
|
96
|
-
data = await response[parseAs]();
|
|
97
|
-
break;
|
|
98
|
-
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
99
|
-
data: response.body,
|
|
100
|
-
...result
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
if (parseAs === "json") {
|
|
104
|
-
if (opts.responseValidator) await opts.responseValidator(data);
|
|
105
|
-
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
106
|
-
}
|
|
107
|
-
return opts.responseStyle === "data" ? data : {
|
|
108
|
-
data,
|
|
109
|
-
...result
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
const textError = await response.text();
|
|
113
|
-
let jsonError;
|
|
114
|
-
try {
|
|
115
|
-
jsonError = JSON.parse(textError);
|
|
116
|
-
} catch {}
|
|
117
|
-
const error = jsonError ?? textError;
|
|
118
|
-
let finalError = error;
|
|
119
|
-
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(error, response, request$1, opts);
|
|
120
|
-
finalError = finalError || {};
|
|
121
|
-
if (opts.throwOnError) throw finalError;
|
|
122
|
-
return opts.responseStyle === "data" ? void 0 : {
|
|
123
|
-
error: finalError,
|
|
124
|
-
...result
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
const makeMethodFn = (method) => (options) => request({
|
|
128
|
-
...options,
|
|
129
|
-
method
|
|
130
|
-
});
|
|
131
|
-
const makeSseFn = (method) => async (options) => {
|
|
132
|
-
const { opts, url } = await beforeRequest(options);
|
|
133
|
-
return createSseClient({
|
|
134
|
-
...opts,
|
|
135
|
-
body: opts.body,
|
|
136
|
-
headers: opts.headers,
|
|
137
|
-
method,
|
|
138
|
-
onRequest: async (url$1, init) => {
|
|
139
|
-
let request$1 = new Request(url$1, init);
|
|
140
|
-
for (const fn of interceptors.request.fns) if (fn) request$1 = await fn(request$1, opts);
|
|
141
|
-
return request$1;
|
|
142
|
-
},
|
|
143
|
-
url
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
return {
|
|
147
|
-
buildUrl,
|
|
148
|
-
connect: makeMethodFn("CONNECT"),
|
|
149
|
-
delete: makeMethodFn("DELETE"),
|
|
150
|
-
get: makeMethodFn("GET"),
|
|
151
|
-
getConfig,
|
|
152
|
-
head: makeMethodFn("HEAD"),
|
|
153
|
-
interceptors,
|
|
154
|
-
options: makeMethodFn("OPTIONS"),
|
|
155
|
-
patch: makeMethodFn("PATCH"),
|
|
156
|
-
post: makeMethodFn("POST"),
|
|
157
|
-
put: makeMethodFn("PUT"),
|
|
158
|
-
request,
|
|
159
|
-
setConfig,
|
|
160
|
-
sse: {
|
|
161
|
-
connect: makeSseFn("CONNECT"),
|
|
162
|
-
delete: makeSseFn("DELETE"),
|
|
163
|
-
get: makeSseFn("GET"),
|
|
164
|
-
head: makeSseFn("HEAD"),
|
|
165
|
-
options: makeSseFn("OPTIONS"),
|
|
166
|
-
patch: makeSseFn("PATCH"),
|
|
167
|
-
post: makeSseFn("POST"),
|
|
168
|
-
put: makeSseFn("PUT"),
|
|
169
|
-
trace: makeSseFn("TRACE")
|
|
170
|
-
},
|
|
171
|
-
trace: makeMethodFn("TRACE")
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
//#endregion
|
|
176
|
-
export { createClient as t };
|