@lssm/app.cli-database 0.0.0-canary-20251207012602 → 0.0.0-canary-20251207043720
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/commands/schema-compose.mjs +1 -1
- package/dist/commands/schema-generate.mjs +1 -1
- package/dist/index.mjs +1 -2
- package/package.json +9 -4
- package/dist/cli.d.mts +0 -1
- package/dist/index.d.mts +0 -5
- package/dist/lib/client.d.mts +0 -7
- package/dist/lib/client.mjs +0 -17
- package/dist/lib/config.d.mts +0 -7
- package/dist/lib/schema-config.d.mts +0 -31
- package/dist/lib/types.d.mts +0 -13
- package/dist/libs/schema/dist/EnumType.mjs +0 -4
- package/dist/libs/schema/dist/FieldType.mjs +0 -4
- package/dist/libs/schema/dist/ScalarTypeEnum.mjs +0 -5
- package/dist/libs/schema/dist/SchemaModel.mjs +0 -5
- package/dist/libs/schema/dist/entity/defineEntity.mjs +0 -3
- package/dist/libs/schema/dist/entity/generator.mjs +0 -90
- package/dist/libs/schema/dist/entity/index.mjs +0 -5
- package/dist/libs/schema/dist/entity/types.mjs +0 -3
- package/dist/libs/schema/dist/index.mjs +0 -9
|
@@ -46,7 +46,7 @@ async function runSchemaCompose(argv) {
|
|
|
46
46
|
console.log(`📋 Enums discovered: ${Array.from(allEnums).join(", ")}`);
|
|
47
47
|
console.log("");
|
|
48
48
|
}
|
|
49
|
-
const { composeModuleSchemas } = await import("
|
|
49
|
+
const { composeModuleSchemas } = await import("@lssm/lib.schema");
|
|
50
50
|
const prismaSchema = composeModuleSchemas(modules, {
|
|
51
51
|
provider: config.provider ?? "postgresql",
|
|
52
52
|
clientOutput: config.clientOutput,
|
|
@@ -28,7 +28,7 @@ async function runSchemaGenerate(argv) {
|
|
|
28
28
|
console.log(` - ${m.moduleId} (${m.entities.length} entities)`);
|
|
29
29
|
});
|
|
30
30
|
console.log("");
|
|
31
|
-
const { composeModuleSchemas } = await import("
|
|
31
|
+
const { composeModuleSchemas } = await import("@lssm/lib.schema");
|
|
32
32
|
const prismaSchema = composeModuleSchemas(modules, {
|
|
33
33
|
provider: config.provider ?? "postgresql",
|
|
34
34
|
clientOutput: config.clientOutput,
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineSchemaConfig, loadSchemaConfig } from "./lib/schema-config.mjs";
|
|
2
|
-
import { createPrismaClientFromEnv, getSingletonClient } from "./lib/client.mjs";
|
|
3
2
|
import { defineMergedPrismaConfig } from "./lib/config.mjs";
|
|
4
3
|
|
|
5
|
-
export {
|
|
4
|
+
export { defineMergedPrismaConfig, defineSchemaConfig, loadSchemaConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/app.cli-database",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251207043720",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"database": "dist/cli.js"
|
|
@@ -44,11 +44,16 @@
|
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
46
|
"exports": {
|
|
47
|
-
".": "./
|
|
48
|
-
"./cli": "./
|
|
47
|
+
".": "./src/index.ts",
|
|
48
|
+
"./cli": "./src/cli.ts",
|
|
49
49
|
"./*": "./*"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
|
-
"access": "public"
|
|
52
|
+
"access": "public",
|
|
53
|
+
"exports": {
|
|
54
|
+
".": "./dist/index.mjs",
|
|
55
|
+
"./cli": "./dist/cli.mjs",
|
|
56
|
+
"./*": "./*"
|
|
57
|
+
}
|
|
53
58
|
}
|
|
54
59
|
}
|
package/dist/cli.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/index.d.mts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createPrismaClientFromEnv, getSingletonClient } from "./lib/client.mjs";
|
|
2
|
-
import { ImportLock, ImportLockEntry } from "./lib/types.mjs";
|
|
3
|
-
import { MergedPrismaConfig, defineMergedPrismaConfig } from "./lib/config.mjs";
|
|
4
|
-
import { ModuleSchemaContribution, SchemaConfig, defineSchemaConfig, loadSchemaConfig } from "./lib/schema-config.mjs";
|
|
5
|
-
export { ImportLock, ImportLockEntry, MergedPrismaConfig, ModuleSchemaContribution, SchemaConfig, createPrismaClientFromEnv, defineMergedPrismaConfig, defineSchemaConfig, getSingletonClient, loadSchemaConfig };
|
package/dist/lib/client.d.mts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { PrismaClient } from "@prisma/client";
|
|
2
|
-
|
|
3
|
-
//#region src/lib/client.d.ts
|
|
4
|
-
declare function createPrismaClientFromEnv(envVar: string, fallback?: string): PrismaClient;
|
|
5
|
-
declare function getSingletonClient(envVar?: string): PrismaClient;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { createPrismaClientFromEnv, getSingletonClient };
|
package/dist/lib/client.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PrismaClient } from "@prisma/client";
|
|
2
|
-
import { PrismaPg } from "@prisma/adapter-pg";
|
|
3
|
-
|
|
4
|
-
//#region src/lib/client.ts
|
|
5
|
-
const g = global;
|
|
6
|
-
function createPrismaClientFromEnv(envVar, fallback) {
|
|
7
|
-
const raw = process.env[envVar] || (fallback ? process.env[fallback] : void 0);
|
|
8
|
-
if (!raw) throw new Error(`Missing database URL env: ${envVar}${fallback ? ` (or ${fallback})` : ""}`);
|
|
9
|
-
return new PrismaClient({ adapter: new PrismaPg({ connectionString: `${raw}`.replaceAll("sslmode=require", "sslmode=disable") }) });
|
|
10
|
-
}
|
|
11
|
-
function getSingletonClient(envVar = "DATABASE_URL") {
|
|
12
|
-
if (!g.__lssm_db) g.__lssm_db = createPrismaClientFromEnv(envVar);
|
|
13
|
-
return g.__lssm_db;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { createPrismaClientFromEnv, getSingletonClient };
|
package/dist/lib/config.d.mts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ModuleSchemaContribution } from "@lssm/lib.schema";
|
|
2
|
-
|
|
3
|
-
//#region src/lib/schema-config.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Configuration for schema generation and composition.
|
|
7
|
-
*/
|
|
8
|
-
interface SchemaConfig {
|
|
9
|
-
/** Module schema contributions to include */
|
|
10
|
-
modules: ModuleSchemaContribution[];
|
|
11
|
-
/** Prisma datasource provider (default: 'postgresql') */
|
|
12
|
-
provider?: 'postgresql' | 'mysql' | 'sqlite' | 'mongodb' | 'sqlserver';
|
|
13
|
-
/** Output path for generated Prisma schema */
|
|
14
|
-
outputPath?: string;
|
|
15
|
-
/** Prisma client output directory */
|
|
16
|
-
clientOutput?: string;
|
|
17
|
-
/** Include Pothos generator (default: true) */
|
|
18
|
-
includePothos?: boolean;
|
|
19
|
-
/** Pothos output path */
|
|
20
|
-
pothosOutput?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Define a schema configuration.
|
|
24
|
-
*/
|
|
25
|
-
declare function defineSchemaConfig(config: SchemaConfig): SchemaConfig;
|
|
26
|
-
/**
|
|
27
|
-
* Load schema configuration from a file.
|
|
28
|
-
*/
|
|
29
|
-
declare function loadSchemaConfig(configPath: string): Promise<SchemaConfig | null>;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { type ModuleSchemaContribution, SchemaConfig, defineSchemaConfig, loadSchemaConfig };
|
package/dist/lib/types.d.mts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/lib/types.d.ts
|
|
2
|
-
interface ImportLockEntry {
|
|
3
|
-
moduleName: string;
|
|
4
|
-
version: string;
|
|
5
|
-
sourcePath: string;
|
|
6
|
-
sha256: string;
|
|
7
|
-
}
|
|
8
|
-
interface ImportLock {
|
|
9
|
-
updatedAt: string;
|
|
10
|
-
entries: ImportLockEntry[];
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { ImportLock, ImportLockEntry };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
//#region ../../libs/schema/dist/entity/generator.js
|
|
2
|
-
function e(e$1, r$1 = {}) {
|
|
3
|
-
let { provider: i$1 = `postgresql`, clientOutput: a$1 = `../../src/generated/prisma`, includePothos: o$1 = !0, pothosOutput: s$1 = `../../src/generated/pothos-types.ts` } = r$1, c$1 = [], l = /* @__PURE__ */ new Set();
|
|
4
|
-
e$1.forEach((e$2) => {
|
|
5
|
-
e$2.schema && l.add(e$2.schema);
|
|
6
|
-
});
|
|
7
|
-
let u = l.size > 0 ? Array.from(l) : [`public`];
|
|
8
|
-
c$1.push(`datasource db {`), c$1.push(` provider = "${i$1}"`), l.size > 0 && c$1.push(` schemas = [${u.map((e$2) => `"${e$2}"`).join(`, `)}]`), c$1.push(`}`), c$1.push(``), c$1.push(`generator client {`), c$1.push(` provider = "prisma-client"`), c$1.push(` output = "${a$1}"`), c$1.push(``), c$1.push(` engineType = "client"`), c$1.push(` runtime = "bun"`), c$1.push(` moduleFormat = "esm"`), c$1.push(` generatedFileExtension = "ts"`), c$1.push(` importFileExtension = "ts"`), c$1.push(`}`), c$1.push(``), o$1 && (c$1.push(`generator pothos {`), c$1.push(` provider = "prisma-pothos-types"`), c$1.push(` clientOutput = "./prisma"`), c$1.push(` output = "${s$1}"`), c$1.push(` generateDatamodel = true`), c$1.push(` documentation = false`), c$1.push(`}`), c$1.push(``));
|
|
9
|
-
let d = /* @__PURE__ */ new Map();
|
|
10
|
-
return e$1.forEach((e$2) => {
|
|
11
|
-
e$2.enums?.forEach((e$3) => {
|
|
12
|
-
d.has(e$3.name) || d.set(e$3.name, e$3);
|
|
13
|
-
}), Object.values(e$2.fields).forEach((t$1) => {
|
|
14
|
-
t$1.kind === `enum` && t$1.values && !d.has(t$1.enumName) && d.set(t$1.enumName, {
|
|
15
|
-
name: t$1.enumName,
|
|
16
|
-
values: t$1.values,
|
|
17
|
-
schema: e$2.schema
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}), d.forEach((e$2) => {
|
|
21
|
-
c$1.push(...t(e$2)), c$1.push(``);
|
|
22
|
-
}), e$1.forEach((e$2) => {
|
|
23
|
-
c$1.push(...n(e$2)), c$1.push(``);
|
|
24
|
-
}), c$1.join(`
|
|
25
|
-
`);
|
|
26
|
-
}
|
|
27
|
-
function t(e$1) {
|
|
28
|
-
let t$1 = [];
|
|
29
|
-
return e$1.description && t$1.push(`/// ${e$1.description}`), t$1.push(`enum ${e$1.name} {`), e$1.values.forEach((e$2) => {
|
|
30
|
-
t$1.push(` ${e$2}`);
|
|
31
|
-
}), t$1.push(``), e$1.schema && t$1.push(` @@schema("${e$1.schema}")`), t$1.push(`}`), t$1;
|
|
32
|
-
}
|
|
33
|
-
function n(e$1) {
|
|
34
|
-
let t$1 = [];
|
|
35
|
-
return e$1.description && t$1.push(`/// ${e$1.description}`), t$1.push(`model ${e$1.name} {`), Object.entries(e$1.fields).forEach(([e$2, n$1]) => {
|
|
36
|
-
let i$1 = r(e$2, n$1);
|
|
37
|
-
n$1.description && t$1.push(` /// ${n$1.description}`), t$1.push(` ${i$1}`);
|
|
38
|
-
}), e$1.indexes && e$1.indexes.length > 0 && (t$1.push(``), e$1.indexes.forEach((e$2) => {
|
|
39
|
-
t$1.push(` ${s(e$2)}`);
|
|
40
|
-
})), e$1.map && t$1.push(` @@map("${e$1.map}")`), e$1.schema && t$1.push(` @@schema("${e$1.schema}")`), t$1.push(`}`), t$1;
|
|
41
|
-
}
|
|
42
|
-
function r(e$1, t$1) {
|
|
43
|
-
if (t$1.kind === `scalar`) return i(e$1, t$1);
|
|
44
|
-
if (t$1.kind === `enum`) return a(e$1, t$1);
|
|
45
|
-
if (t$1.kind === `relation`) return o(e$1, t$1);
|
|
46
|
-
throw Error(`Unknown field kind: ${t$1.kind}`);
|
|
47
|
-
}
|
|
48
|
-
function i(e$1, t$1) {
|
|
49
|
-
let n$1 = [e$1], r$1 = t$1.type;
|
|
50
|
-
t$1.isArray && (r$1 += `[]`), t$1.isOptional && (r$1 += `?`), n$1.push(r$1);
|
|
51
|
-
let i$1 = [];
|
|
52
|
-
return t$1.isId && i$1.push(`@id`), t$1.default !== void 0 && (typeof t$1.default == `string` && t$1.default.includes(`(`) || typeof t$1.default == `boolean` || typeof t$1.default == `number` ? i$1.push(`@default(${t$1.default})`) : i$1.push(`@default("${t$1.default}")`)), t$1.updatedAt && i$1.push(`@updatedAt`), t$1.isUnique && i$1.push(`@unique`), t$1.map && i$1.push(`@map("${t$1.map}")`), t$1.dbType && i$1.push(`@db.${t$1.dbType}`), i$1.length > 0 && n$1.push(i$1.join(` `)), n$1.join(` `);
|
|
53
|
-
}
|
|
54
|
-
function a(e$1, t$1) {
|
|
55
|
-
let n$1 = [e$1], r$1 = t$1.enumName;
|
|
56
|
-
t$1.isArray && (r$1 += `[]`), t$1.isOptional && (r$1 += `?`), n$1.push(r$1);
|
|
57
|
-
let i$1 = [];
|
|
58
|
-
return t$1.default !== void 0 && i$1.push(`@default(${t$1.default})`), t$1.isUnique && i$1.push(`@unique`), t$1.map && i$1.push(`@map("${t$1.map}")`), i$1.length > 0 && n$1.push(i$1.join(` `)), n$1.join(` `);
|
|
59
|
-
}
|
|
60
|
-
function o(e$1, t$1) {
|
|
61
|
-
let n$1 = [e$1], r$1 = t$1.target;
|
|
62
|
-
t$1.type === `hasMany` && (r$1 += `[]`), t$1.type === `hasOne` && (r$1 += `?`), n$1.push(r$1);
|
|
63
|
-
let i$1 = [];
|
|
64
|
-
return t$1.name && i$1.push(`name: "${t$1.name}"`), t$1.fields && t$1.fields.length > 0 && i$1.push(`fields: [${t$1.fields.join(`, `)}]`), t$1.references && t$1.references.length > 0 && i$1.push(`references: [${t$1.references.join(`, `)}]`), t$1.onDelete && i$1.push(`onDelete: ${t$1.onDelete}`), t$1.onUpdate && i$1.push(`onUpdate: ${t$1.onUpdate}`), i$1.length > 0 && n$1.push(`@relation(${i$1.join(`, `)})`), n$1.join(` `);
|
|
65
|
-
}
|
|
66
|
-
function s(e$1) {
|
|
67
|
-
let t$1 = e$1.fields.join(`, `), n$1 = [];
|
|
68
|
-
e$1.unique ? n$1.push(`@@unique([${t$1}]`) : n$1.push(`@@index([${t$1}]`);
|
|
69
|
-
let r$1 = [];
|
|
70
|
-
return e$1.name && r$1.push(`name: "${e$1.name}"`), e$1.type && r$1.push(`type: ${e$1.type}`), r$1.length > 0 && (n$1[0] += `, ${r$1.join(`, `)}`), n$1[0] += `)`, n$1.join(``);
|
|
71
|
-
}
|
|
72
|
-
function c(t$1, n$1 = {}) {
|
|
73
|
-
let r$1 = [], i$1 = /* @__PURE__ */ new Map();
|
|
74
|
-
return t$1.forEach((e$1) => {
|
|
75
|
-
e$1.entities.forEach((t$2) => {
|
|
76
|
-
r$1.push({
|
|
77
|
-
...t$2,
|
|
78
|
-
module: e$1.moduleId
|
|
79
|
-
});
|
|
80
|
-
}), e$1.enums?.forEach((e$2) => {
|
|
81
|
-
i$1.has(e$2.name) || i$1.set(e$2.name, e$2);
|
|
82
|
-
});
|
|
83
|
-
}), r$1.length > 0 && i$1.size > 0 && (r$1[0] = {
|
|
84
|
-
...r$1[0],
|
|
85
|
-
enums: [...r$1[0].enums ?? [], ...i$1.values()]
|
|
86
|
-
}), e(r$1, n$1);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
//#endregion
|
|
90
|
-
export { c, e };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import "./EnumType.mjs";
|
|
2
|
-
import "./FieldType.mjs";
|
|
3
|
-
import "./ScalarTypeEnum.mjs";
|
|
4
|
-
import "./SchemaModel.mjs";
|
|
5
|
-
import "./entity/defineEntity.mjs";
|
|
6
|
-
import { c, e } from "./entity/generator.mjs";
|
|
7
|
-
import "./entity/index.mjs";
|
|
8
|
-
|
|
9
|
-
export { c as composeModuleSchemas };
|