@powerlines/plugin-prisma 0.2.192 → 0.2.193
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/api/client/client.gen.cjs +8 -175
- package/dist/api/client/client.gen.mjs +7 -174
- package/dist/api/client/index.cjs +18 -13
- package/dist/api/client/index.mjs +10 -5
- package/dist/api/client/utils.gen.cjs +13 -186
- package/dist/api/client/utils.gen.mjs +5 -178
- package/dist/api/client.gen.cjs +12 -8
- package/dist/api/client.gen.mjs +11 -7
- package/dist/api/core/auth.gen.cjs +2 -11
- package/dist/api/core/auth.gen.mjs +1 -9
- package/dist/api/core/bodySerializer.gen.cjs +4 -34
- package/dist/api/core/bodySerializer.gen.mjs +1 -30
- package/dist/api/core/params.gen.cjs +2 -64
- package/dist/api/core/params.gen.mjs +1 -62
- package/dist/api/core/pathSerializer.gen.cjs +7 -86
- package/dist/api/core/pathSerializer.gen.mjs +1 -79
- package/dist/api/core/queryKeySerializer.gen.cjs +4 -65
- package/dist/api/core/queryKeySerializer.gen.mjs +1 -61
- package/dist/api/core/serverSentEvents.gen.cjs +2 -94
- package/dist/api/core/serverSentEvents.gen.mjs +1 -92
- package/dist/api/core/utils.gen.cjs +6 -80
- package/dist/api/core/utils.gen.mjs +2 -76
- package/dist/api/sdk.gen.cjs +13 -255
- package/dist/api/sdk.gen.mjs +12 -254
- package/dist/api/types.gen.cjs +1 -0
- package/dist/api/types.gen.mjs +2 -0
- package/dist/auth.gen-BFteuMTV.cjs +17 -0
- package/dist/auth.gen-C4FxE4_3.mjs +11 -0
- package/dist/bodySerializer.gen-BLtxkFoA.cjs +50 -0
- package/dist/bodySerializer.gen-DBXNewIA.mjs +32 -0
- package/dist/client-BlRUW8mL.mjs +1 -0
- package/dist/client-DBAc9HV1.cjs +0 -0
- package/dist/client.gen-COMS1glH.mjs +8 -0
- package/dist/client.gen-CPQm4WCv.mjs +176 -0
- package/dist/client.gen-DPSMNZNm.cjs +181 -0
- package/dist/client.gen-JhYC1fDf.cjs +13 -0
- package/dist/get-schema-CKw6MiKb.mjs +78 -0
- package/dist/get-schema-CqMBOHOd.cjs +118 -0
- package/dist/helpers/get-schema.cjs +2 -80
- package/dist/helpers/get-schema.mjs +1 -76
- package/dist/helpers/index.cjs +6 -6
- package/dist/helpers/index.mjs +3 -3
- package/dist/helpers/prisma-postgres.cjs +2 -15
- package/dist/helpers/prisma-postgres.mjs +1 -13
- package/dist/helpers/schema-creator.cjs +2 -60
- package/dist/helpers/schema-creator.mjs +1 -58
- package/dist/index.cjs +25 -14
- package/dist/index.mjs +18 -6
- package/dist/params.gen-BM1l95BD.mjs +64 -0
- package/dist/params.gen-BtCSnwiV.cjs +70 -0
- package/dist/pathSerializer.gen-BEbuI0Vn.cjs +117 -0
- package/dist/pathSerializer.gen-m7BRzH23.mjs +81 -0
- package/dist/plugin-DE9fKOLA.cjs +0 -0
- package/dist/plugin-EFmNQLKA.mjs +1 -0
- package/dist/prisma-BzQJneyW.cjs +0 -0
- package/dist/prisma-CB-m5c-j.mjs +1 -0
- package/dist/prisma-postgres-CAOpTtWq.mjs +15 -0
- package/dist/prisma-postgres-dGaLzxF3.cjs +21 -0
- package/dist/queryKeySerializer.gen-4TWHHXn3.cjs +81 -0
- package/dist/queryKeySerializer.gen-BMMZAjVN.mjs +63 -0
- package/dist/schema-creator-Cfian3ih.mjs +60 -0
- package/dist/schema-creator-zmlwh4-l.cjs +66 -0
- package/dist/sdk.gen-B2his2jD.mjs +256 -0
- package/dist/sdk.gen-CAWIQ8BM.cjs +261 -0
- package/dist/serverSentEvents.gen-C4apQvDl.mjs +94 -0
- package/dist/serverSentEvents.gen-CiMMmhyQ.cjs +100 -0
- package/dist/types/index.cjs +3 -0
- package/dist/types/index.mjs +4 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.mjs +2 -0
- package/dist/types/prisma.cjs +1 -0
- package/dist/types/prisma.mjs +2 -0
- package/dist/types-CmY9-4ff.cjs +0 -0
- package/dist/types-Dbwx-Khg.mjs +1 -0
- package/dist/types.gen-BN-p9nVT.cjs +0 -0
- package/dist/types.gen-CS2KiRfG.mjs +1 -0
- package/dist/utils.gen-Bk2pTkV1.cjs +101 -0
- package/dist/utils.gen-C-7sZa7Z.mjs +180 -0
- package/dist/utils.gen-DATakax-.cjs +227 -0
- package/dist/utils.gen-RO8GxC4i.mjs +78 -0
- package/package.json +5 -5
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
|
@@ -1,78 +1,3 @@
|
|
|
1
|
-
import {
|
|
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";
|
|
1
|
+
import { t as getSchema } from "../get-schema-CKw6MiKb.mjs";
|
|
6
2
|
|
|
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 options - The options to customize the schema retrieval.
|
|
35
|
-
* @returns The Prisma schema.
|
|
36
|
-
*/
|
|
37
|
-
async function getSchema(options) {
|
|
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: options.datamodel,
|
|
42
|
-
datasourceOverrides: {},
|
|
43
|
-
ignoreEnvVarErrors: options.ignoreEnvVarErrors ?? false,
|
|
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
|
-
//#endregion
|
|
78
3
|
export { getSchema };
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const require_get_schema = require('../get-schema-CqMBOHOd.cjs');
|
|
2
|
+
const require_schema_creator = require('../schema-creator-zmlwh4-l.cjs');
|
|
3
|
+
const require_prisma_postgres = require('../prisma-postgres-dGaLzxF3.cjs');
|
|
4
4
|
|
|
5
|
-
exports.PrismaSchemaCreator =
|
|
6
|
-
exports.findDatabaseByName =
|
|
7
|
-
exports.getSchema =
|
|
5
|
+
exports.PrismaSchemaCreator = require_schema_creator.PrismaSchemaCreator;
|
|
6
|
+
exports.findDatabaseByName = require_prisma_postgres.findDatabaseByName;
|
|
7
|
+
exports.getSchema = require_get_schema.getSchema;
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getSchema } from "
|
|
2
|
-
import { PrismaSchemaCreator } from "
|
|
3
|
-
import { findDatabaseByName } from "
|
|
1
|
+
import { t as getSchema } from "../get-schema-CKw6MiKb.mjs";
|
|
2
|
+
import { t as PrismaSchemaCreator } from "../schema-creator-Cfian3ih.mjs";
|
|
3
|
+
import { t as findDatabaseByName } from "../prisma-postgres-CAOpTtWq.mjs";
|
|
4
4
|
|
|
5
5
|
export { PrismaSchemaCreator, findDatabaseByName, getSchema };
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
+
const require_prisma_postgres = require('../prisma-postgres-dGaLzxF3.cjs');
|
|
1
2
|
|
|
2
|
-
|
|
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;
|
|
3
|
+
exports.findDatabaseByName = require_prisma_postgres.findDatabaseByName;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
1
|
+
import { t as findDatabaseByName } from "../prisma-postgres-CAOpTtWq.mjs";
|
|
13
2
|
|
|
14
|
-
//#endregion
|
|
15
3
|
export { findDatabaseByName };
|
|
@@ -1,61 +1,3 @@
|
|
|
1
|
-
const
|
|
2
|
-
let prisma_util_schema_creator = require("prisma-util/schema-creator");
|
|
1
|
+
const require_schema_creator = require('../schema-creator-zmlwh4-l.cjs');
|
|
3
2
|
|
|
4
|
-
|
|
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;
|
|
3
|
+
exports.PrismaSchemaCreator = require_schema_creator.PrismaSchemaCreator;
|
|
@@ -1,60 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as PrismaSchemaCreator } from "../schema-creator-Cfian3ih.mjs";
|
|
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
|
|
60
3
|
export { PrismaSchemaCreator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
2
|
+
const require_get_schema = require('./get-schema-CqMBOHOd.cjs');
|
|
3
|
+
require('./serverSentEvents.gen-CiMMmhyQ.cjs');
|
|
4
|
+
require('./pathSerializer.gen-BEbuI0Vn.cjs');
|
|
5
|
+
require('./utils.gen-Bk2pTkV1.cjs');
|
|
6
|
+
require('./auth.gen-BFteuMTV.cjs');
|
|
7
|
+
require('./bodySerializer.gen-BLtxkFoA.cjs');
|
|
8
|
+
const require_utils_gen$1 = require('./utils.gen-DATakax-.cjs');
|
|
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');
|
|
9
20
|
let __stryke_cli_execute = require("@stryke/cli/execute");
|
|
10
21
|
let __stryke_fs_exists = require("@stryke/fs/exists");
|
|
11
22
|
let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
|
|
12
23
|
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
13
24
|
let __stryke_path_replace = require("@stryke/path/replace");
|
|
14
25
|
let defu = require("defu");
|
|
15
|
-
defu =
|
|
26
|
+
defu = require_get_schema.__toESM(defu);
|
|
16
27
|
let powerlines_plugin_utils_get_config_path = require("powerlines/plugin-utils/get-config-path");
|
|
17
28
|
let powerlines_plugin_utils_paths = require("powerlines/plugin-utils/paths");
|
|
18
29
|
|
|
@@ -49,7 +60,7 @@ const plugin = (options = {}) => {
|
|
|
49
60
|
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.");
|
|
50
61
|
else throw new Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");
|
|
51
62
|
}
|
|
52
|
-
const client$1 =
|
|
63
|
+
const client$1 = require_client_gen.createClient(require_utils_gen$1.createConfig({
|
|
53
64
|
baseUrl: "https://api.prisma.io",
|
|
54
65
|
throwOnError: true,
|
|
55
66
|
headers: {
|
|
@@ -57,7 +68,7 @@ const plugin = (options = {}) => {
|
|
|
57
68
|
"User-Agent": "powerlines/1.0"
|
|
58
69
|
}
|
|
59
70
|
}));
|
|
60
|
-
this.prisma.api = new
|
|
71
|
+
this.prisma.api = new require_sdk_gen.PrismaClient({ client: client$1 });
|
|
61
72
|
await this.prisma.api.createDatabase({
|
|
62
73
|
path: { projectId: this.config.prisma.prismaPostgres.projectId },
|
|
63
74
|
body: {
|
|
@@ -75,7 +86,7 @@ const plugin = (options = {}) => {
|
|
|
75
86
|
datasources: [],
|
|
76
87
|
warnings: []
|
|
77
88
|
};
|
|
78
|
-
else this.prisma.schema = await
|
|
89
|
+
else this.prisma.schema = await require_get_schema.getSchema({ datamodel: this.config.prisma.schema });
|
|
79
90
|
const generator = this.prisma.schema.generators.find((gen) => gen.provider.value === "prisma-client-js");
|
|
80
91
|
if (!generator) this.prisma.schema.generators.push({
|
|
81
92
|
name: "prisma-client-js",
|
|
@@ -96,7 +107,7 @@ const plugin = (options = {}) => {
|
|
|
96
107
|
value: this.config.prisma.outputPath,
|
|
97
108
|
fromEnvVar: null
|
|
98
109
|
};
|
|
99
|
-
this.prisma.builder = new
|
|
110
|
+
this.prisma.builder = new require_schema_creator.PrismaSchemaCreator(this);
|
|
100
111
|
},
|
|
101
112
|
async prepare() {
|
|
102
113
|
await this.prisma.builder.write();
|
|
@@ -121,7 +132,7 @@ const plugin = (options = {}) => {
|
|
|
121
132
|
var src_default = plugin;
|
|
122
133
|
|
|
123
134
|
//#endregion
|
|
124
|
-
exports.PrismaClient =
|
|
125
|
-
exports.client =
|
|
135
|
+
exports.PrismaClient = require_sdk_gen.PrismaClient;
|
|
136
|
+
exports.client = require_client_gen$1.client;
|
|
126
137
|
exports.default = src_default;
|
|
127
138
|
exports.plugin = plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
1
|
+
import "./serverSentEvents.gen-C4apQvDl.mjs";
|
|
2
|
+
import "./pathSerializer.gen-m7BRzH23.mjs";
|
|
3
|
+
import "./utils.gen-RO8GxC4i.mjs";
|
|
4
|
+
import "./auth.gen-C4FxE4_3.mjs";
|
|
5
|
+
import "./bodySerializer.gen-DBXNewIA.mjs";
|
|
6
|
+
import { n as createConfig } from "./utils.gen-C-7sZa7Z.mjs";
|
|
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";
|
|
7
19
|
import { execute, executePackage } from "@stryke/cli/execute";
|
|
8
20
|
import { existsSync } from "@stryke/fs/exists";
|
|
9
21
|
import { isPackageListed } from "@stryke/fs/package-fns";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//#region src/api/core/params.gen.ts
|
|
2
|
+
const extraPrefixes = Object.entries({
|
|
3
|
+
$body_: "body",
|
|
4
|
+
$headers_: "headers",
|
|
5
|
+
$path_: "path",
|
|
6
|
+
$query_: "query"
|
|
7
|
+
});
|
|
8
|
+
const buildKeyMap = (fields, map) => {
|
|
9
|
+
if (!map) map = /* @__PURE__ */ new Map();
|
|
10
|
+
for (const config of fields) if ("in" in config) {
|
|
11
|
+
if (config.key) map.set(config.key, {
|
|
12
|
+
in: config.in,
|
|
13
|
+
map: config.map
|
|
14
|
+
});
|
|
15
|
+
} else if ("key" in config) map.set(config.key, { map: config.map });
|
|
16
|
+
else if (config.args) buildKeyMap(config.args, map);
|
|
17
|
+
return map;
|
|
18
|
+
};
|
|
19
|
+
const stripEmptySlots = (params) => {
|
|
20
|
+
for (const [slot, value] of Object.entries(params)) if (value && typeof value === "object" && !Object.keys(value).length) delete params[slot];
|
|
21
|
+
};
|
|
22
|
+
const buildClientParams = (args, fields) => {
|
|
23
|
+
const params = {
|
|
24
|
+
body: {},
|
|
25
|
+
headers: {},
|
|
26
|
+
path: {},
|
|
27
|
+
query: {}
|
|
28
|
+
};
|
|
29
|
+
const map = buildKeyMap(fields);
|
|
30
|
+
let config;
|
|
31
|
+
for (const [index, arg] of args.entries()) {
|
|
32
|
+
if (fields[index]) config = fields[index];
|
|
33
|
+
if (!config) continue;
|
|
34
|
+
if ("in" in config) if (config.key) {
|
|
35
|
+
const field = map.get(config.key);
|
|
36
|
+
const name = field.map || config.key;
|
|
37
|
+
if (field.in) params[field.in][name] = arg;
|
|
38
|
+
} else params.body = arg;
|
|
39
|
+
else for (const [key, value] of Object.entries(arg ?? {})) {
|
|
40
|
+
const field = map.get(key);
|
|
41
|
+
if (field) if (field.in) {
|
|
42
|
+
const name = field.map || key;
|
|
43
|
+
params[field.in][name] = value;
|
|
44
|
+
} else params[field.map] = value;
|
|
45
|
+
else {
|
|
46
|
+
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
47
|
+
if (extra) {
|
|
48
|
+
const [prefix, slot] = extra;
|
|
49
|
+
params[slot][key.slice(prefix.length)] = value;
|
|
50
|
+
} else if ("allowExtra" in config && config.allowExtra) {
|
|
51
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) if (allowed) {
|
|
52
|
+
params[slot][key] = value;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
stripEmptySlots(params);
|
|
60
|
+
return params;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { buildClientParams as t };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/api/core/params.gen.ts
|
|
3
|
+
const extraPrefixes = Object.entries({
|
|
4
|
+
$body_: "body",
|
|
5
|
+
$headers_: "headers",
|
|
6
|
+
$path_: "path",
|
|
7
|
+
$query_: "query"
|
|
8
|
+
});
|
|
9
|
+
const buildKeyMap = (fields, map) => {
|
|
10
|
+
if (!map) map = /* @__PURE__ */ new Map();
|
|
11
|
+
for (const config of fields) if ("in" in config) {
|
|
12
|
+
if (config.key) map.set(config.key, {
|
|
13
|
+
in: config.in,
|
|
14
|
+
map: config.map
|
|
15
|
+
});
|
|
16
|
+
} else if ("key" in config) map.set(config.key, { map: config.map });
|
|
17
|
+
else if (config.args) buildKeyMap(config.args, map);
|
|
18
|
+
return map;
|
|
19
|
+
};
|
|
20
|
+
const stripEmptySlots = (params) => {
|
|
21
|
+
for (const [slot, value] of Object.entries(params)) if (value && typeof value === "object" && !Object.keys(value).length) delete params[slot];
|
|
22
|
+
};
|
|
23
|
+
const buildClientParams = (args, fields) => {
|
|
24
|
+
const params = {
|
|
25
|
+
body: {},
|
|
26
|
+
headers: {},
|
|
27
|
+
path: {},
|
|
28
|
+
query: {}
|
|
29
|
+
};
|
|
30
|
+
const map = buildKeyMap(fields);
|
|
31
|
+
let config;
|
|
32
|
+
for (const [index, arg] of args.entries()) {
|
|
33
|
+
if (fields[index]) config = fields[index];
|
|
34
|
+
if (!config) continue;
|
|
35
|
+
if ("in" in config) if (config.key) {
|
|
36
|
+
const field = map.get(config.key);
|
|
37
|
+
const name = field.map || config.key;
|
|
38
|
+
if (field.in) params[field.in][name] = arg;
|
|
39
|
+
} else params.body = arg;
|
|
40
|
+
else for (const [key, value] of Object.entries(arg ?? {})) {
|
|
41
|
+
const field = map.get(key);
|
|
42
|
+
if (field) if (field.in) {
|
|
43
|
+
const name = field.map || key;
|
|
44
|
+
params[field.in][name] = value;
|
|
45
|
+
} else params[field.map] = value;
|
|
46
|
+
else {
|
|
47
|
+
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
48
|
+
if (extra) {
|
|
49
|
+
const [prefix, slot] = extra;
|
|
50
|
+
params[slot][key.slice(prefix.length)] = value;
|
|
51
|
+
} else if ("allowExtra" in config && config.allowExtra) {
|
|
52
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) if (allowed) {
|
|
53
|
+
params[slot][key] = value;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
stripEmptySlots(params);
|
|
61
|
+
return params;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
Object.defineProperty(exports, 'buildClientParams', {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return buildClientParams;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/api/core/pathSerializer.gen.ts
|
|
3
|
+
const separatorArrayExplode = (style) => {
|
|
4
|
+
switch (style) {
|
|
5
|
+
case "label": return ".";
|
|
6
|
+
case "matrix": return ";";
|
|
7
|
+
case "simple": return ",";
|
|
8
|
+
default: return "&";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const separatorArrayNoExplode = (style) => {
|
|
12
|
+
switch (style) {
|
|
13
|
+
case "form": return ",";
|
|
14
|
+
case "pipeDelimited": return "|";
|
|
15
|
+
case "spaceDelimited": return "%20";
|
|
16
|
+
default: return ",";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const separatorObjectExplode = (style) => {
|
|
20
|
+
switch (style) {
|
|
21
|
+
case "label": return ".";
|
|
22
|
+
case "matrix": return ";";
|
|
23
|
+
case "simple": return ",";
|
|
24
|
+
default: return "&";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
28
|
+
if (!explode) {
|
|
29
|
+
const joinedValues$1 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
30
|
+
switch (style) {
|
|
31
|
+
case "label": return `.${joinedValues$1}`;
|
|
32
|
+
case "matrix": return `;${name}=${joinedValues$1}`;
|
|
33
|
+
case "simple": return joinedValues$1;
|
|
34
|
+
default: return `${name}=${joinedValues$1}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const separator = separatorArrayExplode(style);
|
|
38
|
+
const joinedValues = value.map((v) => {
|
|
39
|
+
if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
|
|
40
|
+
return serializePrimitiveParam({
|
|
41
|
+
allowReserved,
|
|
42
|
+
name,
|
|
43
|
+
value: v
|
|
44
|
+
});
|
|
45
|
+
}).join(separator);
|
|
46
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
47
|
+
};
|
|
48
|
+
const serializePrimitiveParam = ({ allowReserved, name, value }) => {
|
|
49
|
+
if (value === void 0 || value === null) return "";
|
|
50
|
+
if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
51
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
52
|
+
};
|
|
53
|
+
const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
54
|
+
if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
55
|
+
if (style !== "deepObject" && !explode) {
|
|
56
|
+
let values = [];
|
|
57
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
58
|
+
values = [
|
|
59
|
+
...values,
|
|
60
|
+
key,
|
|
61
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
62
|
+
];
|
|
63
|
+
});
|
|
64
|
+
const joinedValues$1 = values.join(",");
|
|
65
|
+
switch (style) {
|
|
66
|
+
case "form": return `${name}=${joinedValues$1}`;
|
|
67
|
+
case "label": return `.${joinedValues$1}`;
|
|
68
|
+
case "matrix": return `;${name}=${joinedValues$1}`;
|
|
69
|
+
default: return joinedValues$1;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const separator = separatorObjectExplode(style);
|
|
73
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
|
|
74
|
+
allowReserved,
|
|
75
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
76
|
+
value: v
|
|
77
|
+
})).join(separator);
|
|
78
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
Object.defineProperty(exports, 'separatorArrayExplode', {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () {
|
|
85
|
+
return separatorArrayExplode;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, 'separatorArrayNoExplode', {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () {
|
|
91
|
+
return separatorArrayNoExplode;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(exports, 'separatorObjectExplode', {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () {
|
|
97
|
+
return separatorObjectExplode;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, 'serializeArrayParam', {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function () {
|
|
103
|
+
return serializeArrayParam;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(exports, 'serializeObjectParam', {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function () {
|
|
109
|
+
return serializeObjectParam;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, 'serializePrimitiveParam', {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () {
|
|
115
|
+
return serializePrimitiveParam;
|
|
116
|
+
}
|
|
117
|
+
});
|