@prismakit/cli 1.0.0
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/LICENSE +190 -0
- package/README.md +1 -0
- package/dist/bin.cjs +430 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/bin.js +101 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-36ZM4UZV.js +325 -0
- package/dist/chunk-36ZM4UZV.js.map +1 -0
- package/dist/index.cjs +362 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +58 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
assertKebabName: () => assertKebabName,
|
|
34
|
+
renderModuleFiles: () => renderModuleFiles,
|
|
35
|
+
resolveNames: () => resolveNames,
|
|
36
|
+
runCodegen: () => runCodegen,
|
|
37
|
+
runGenerate: () => runGenerate,
|
|
38
|
+
runValidate: () => runValidate
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(src_exports);
|
|
41
|
+
|
|
42
|
+
// src/commands/generate.ts
|
|
43
|
+
var fs = __toESM(require("fs"), 1);
|
|
44
|
+
var path = __toESM(require("path"), 1);
|
|
45
|
+
|
|
46
|
+
// src/naming.ts
|
|
47
|
+
var KEBAB_NAME_RE = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
48
|
+
function assertKebabName(name) {
|
|
49
|
+
if (!KEBAB_NAME_RE.test(name)) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Invalid module name "${name}". Use kebab-case (e.g. product, blog-post).`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function kebabToPascal(kebab) {
|
|
56
|
+
return kebab.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
57
|
+
}
|
|
58
|
+
function kebabToCamel(kebab) {
|
|
59
|
+
const pascal = kebabToPascal(kebab);
|
|
60
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
61
|
+
}
|
|
62
|
+
function resolveNames(kebab, route) {
|
|
63
|
+
assertKebabName(kebab);
|
|
64
|
+
const pascal = kebabToPascal(kebab);
|
|
65
|
+
const camel = kebabToCamel(kebab);
|
|
66
|
+
return {
|
|
67
|
+
kebab,
|
|
68
|
+
camel,
|
|
69
|
+
pascal,
|
|
70
|
+
repoModel: camel,
|
|
71
|
+
route: route ?? kebab
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/templates.ts
|
|
76
|
+
function apply(template, names, extras) {
|
|
77
|
+
const replacements = {
|
|
78
|
+
"{{pascal}}": names.pascal,
|
|
79
|
+
"{{camel}}": names.camel,
|
|
80
|
+
"{{kebab}}": names.kebab,
|
|
81
|
+
"{{route}}": names.route,
|
|
82
|
+
"{{repoModel}}": names.repoModel,
|
|
83
|
+
...extras
|
|
84
|
+
};
|
|
85
|
+
let result = template;
|
|
86
|
+
for (const [key, value] of Object.entries(replacements)) {
|
|
87
|
+
result = result.split(key).join(value);
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
function renderRepository(names, cacheEnabled, prismaImport, base) {
|
|
92
|
+
const cacheBlock = cacheEnabled ? ` cache: {
|
|
93
|
+
ttl: 86400,
|
|
94
|
+
sensitiveFields: ['password'],
|
|
95
|
+
},
|
|
96
|
+
` : "";
|
|
97
|
+
const content = apply(
|
|
98
|
+
`import { Prisma } from '{{prismaImport}}';
|
|
99
|
+
import { createInjectableRepository } from '@prismakit/nestjs';
|
|
100
|
+
|
|
101
|
+
export const {{pascal}}Repository = createInjectableRepository({
|
|
102
|
+
model: '{{repoModel}}',
|
|
103
|
+
scalarFields: Prisma.{{pascal}}ScalarFieldEnum,
|
|
104
|
+
{{cacheBlock}}});
|
|
105
|
+
|
|
106
|
+
export type {{pascal}}Repository = InstanceType<typeof {{pascal}}Repository>;
|
|
107
|
+
`,
|
|
108
|
+
names,
|
|
109
|
+
{
|
|
110
|
+
"{{cacheBlock}}": cacheBlock,
|
|
111
|
+
"{{prismaImport}}": prismaImport
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
return {
|
|
115
|
+
relativePath: `${base}/repositories/${names.kebab}.repository.ts`,
|
|
116
|
+
content
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function renderModuleFiles(options) {
|
|
120
|
+
const { names, cacheEnabled, full = false } = options;
|
|
121
|
+
const prismaImport = options.prismaImport ?? "@prisma/client";
|
|
122
|
+
const base = `src/modules/${names.kebab}`;
|
|
123
|
+
const repository = renderRepository(names, cacheEnabled, prismaImport, base);
|
|
124
|
+
if (!full) {
|
|
125
|
+
return [repository];
|
|
126
|
+
}
|
|
127
|
+
const service = apply(
|
|
128
|
+
`import { Injectable } from '@nestjs/common';
|
|
129
|
+
|
|
130
|
+
import { {{pascal}}Repository } from '../repositories/{{kebab}}.repository';
|
|
131
|
+
import { get{{pascal}}Select } from '../types/select-{{kebab}}.type';
|
|
132
|
+
|
|
133
|
+
@Injectable()
|
|
134
|
+
export class {{pascal}}Service {
|
|
135
|
+
constructor(private readonly {{camel}}Repository: {{pascal}}Repository) {}
|
|
136
|
+
|
|
137
|
+
async handleGetById(id: string) {
|
|
138
|
+
return await this.{{camel}}Repository.getThrowById({
|
|
139
|
+
id,
|
|
140
|
+
select: get{{pascal}}Select('general'),
|
|
141
|
+
setCache: true,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
`,
|
|
146
|
+
names,
|
|
147
|
+
{}
|
|
148
|
+
);
|
|
149
|
+
const controller = apply(
|
|
150
|
+
`import { Controller, Get, Param } from '@nestjs/common';
|
|
151
|
+
|
|
152
|
+
import { {{pascal}}Service } from '../services/{{kebab}}.service';
|
|
153
|
+
|
|
154
|
+
@Controller('{{route}}')
|
|
155
|
+
export class {{pascal}}Controller {
|
|
156
|
+
constructor(private readonly {{camel}}Service: {{pascal}}Service) {}
|
|
157
|
+
|
|
158
|
+
@Get(':id')
|
|
159
|
+
async getById(@Param('id') id: string) {
|
|
160
|
+
return this.{{camel}}Service.handleGetById(id);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`,
|
|
164
|
+
names,
|
|
165
|
+
{}
|
|
166
|
+
);
|
|
167
|
+
const moduleFile = apply(
|
|
168
|
+
`import { Module } from '@nestjs/common';
|
|
169
|
+
|
|
170
|
+
import { {{pascal}}Controller } from './controllers/{{kebab}}.controller';
|
|
171
|
+
import { {{pascal}}Service } from './services/{{kebab}}.service';
|
|
172
|
+
import { {{pascal}}Repository } from './repositories/{{kebab}}.repository';
|
|
173
|
+
|
|
174
|
+
@Module({
|
|
175
|
+
controllers: [{{pascal}}Controller],
|
|
176
|
+
providers: [{{pascal}}Service, {{pascal}}Repository],
|
|
177
|
+
exports: [{{pascal}}Service, {{pascal}}Repository],
|
|
178
|
+
})
|
|
179
|
+
export class {{pascal}}Module {}
|
|
180
|
+
`,
|
|
181
|
+
names,
|
|
182
|
+
{}
|
|
183
|
+
);
|
|
184
|
+
const select = apply(
|
|
185
|
+
`import { Prisma } from '{{prismaImport}}';
|
|
186
|
+
|
|
187
|
+
type {{pascal}}SelectPresetKey = keyof typeof {{camel}}SelectPresets;
|
|
188
|
+
|
|
189
|
+
export function get{{pascal}}Select<K extends {{pascal}}SelectPresetKey>(key: K) {
|
|
190
|
+
return {{camel}}SelectPresets[key];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export const {{camel}}SelectPresets = {
|
|
194
|
+
minimal: {
|
|
195
|
+
id: true,
|
|
196
|
+
} satisfies Prisma.{{pascal}}Select,
|
|
197
|
+
|
|
198
|
+
general: {
|
|
199
|
+
id: true,
|
|
200
|
+
} satisfies Prisma.{{pascal}}Select,
|
|
201
|
+
};
|
|
202
|
+
`,
|
|
203
|
+
names,
|
|
204
|
+
{ "{{prismaImport}}": prismaImport }
|
|
205
|
+
);
|
|
206
|
+
const where = apply(
|
|
207
|
+
`import { Prisma } from '{{prismaImport}}';
|
|
208
|
+
|
|
209
|
+
export function where{{pascal}}GetManyPaginate(_filter: {
|
|
210
|
+
q?: string;
|
|
211
|
+
}): {
|
|
212
|
+
where: Prisma.{{pascal}}WhereInput;
|
|
213
|
+
} {
|
|
214
|
+
return { where: {} };
|
|
215
|
+
}
|
|
216
|
+
`,
|
|
217
|
+
names,
|
|
218
|
+
{ "{{prismaImport}}": prismaImport }
|
|
219
|
+
);
|
|
220
|
+
return [
|
|
221
|
+
{ relativePath: `${base}/${names.kebab}.module.ts`, content: moduleFile },
|
|
222
|
+
{
|
|
223
|
+
relativePath: `${base}/controllers/${names.kebab}.controller.ts`,
|
|
224
|
+
content: controller
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
relativePath: `${base}/services/${names.kebab}.service.ts`,
|
|
228
|
+
content: service
|
|
229
|
+
},
|
|
230
|
+
repository,
|
|
231
|
+
{
|
|
232
|
+
relativePath: `${base}/types/select-${names.kebab}.type.ts`,
|
|
233
|
+
content: select
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
relativePath: `${base}/types/where-${names.kebab}.type.ts`,
|
|
237
|
+
content: where
|
|
238
|
+
}
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// src/commands/generate.ts
|
|
243
|
+
function runGenerate(options) {
|
|
244
|
+
const cwd = options.cwd ?? process.cwd();
|
|
245
|
+
const names = resolveNames(options.name, options.route);
|
|
246
|
+
const full = !!options.full;
|
|
247
|
+
const files = renderModuleFiles({
|
|
248
|
+
names,
|
|
249
|
+
cacheEnabled: !!options.cache,
|
|
250
|
+
full,
|
|
251
|
+
prismaImport: options.prismaImport
|
|
252
|
+
});
|
|
253
|
+
for (const file of files) {
|
|
254
|
+
const fullPath = path.join(cwd, file.relativePath);
|
|
255
|
+
if (options.dryRun) {
|
|
256
|
+
console.log(`[dry-run] would write ${file.relativePath}`);
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (fs.existsSync(fullPath)) {
|
|
260
|
+
console.warn(`skip (exists): ${file.relativePath}`);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
264
|
+
const content = file.content.endsWith("\n") ? file.content : `${file.content}
|
|
265
|
+
`;
|
|
266
|
+
fs.writeFileSync(fullPath, content, "utf-8");
|
|
267
|
+
console.log(`created ${file.relativePath}`);
|
|
268
|
+
}
|
|
269
|
+
if (full) {
|
|
270
|
+
console.log(
|
|
271
|
+
`
|
|
272
|
+
Scaffolded module "${names.kebab}". Register ${names.pascal}Module in app.module.ts.`
|
|
273
|
+
);
|
|
274
|
+
} else {
|
|
275
|
+
console.log(
|
|
276
|
+
`
|
|
277
|
+
Scaffolded repository "${names.pascal}Repository". Register it in your feature module providers.`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// src/commands/codegen.ts
|
|
283
|
+
var fs2 = __toESM(require("fs"), 1);
|
|
284
|
+
var path2 = __toESM(require("path"), 1);
|
|
285
|
+
var import_core = require("@prismakit/core");
|
|
286
|
+
function runCodegen(options = {}) {
|
|
287
|
+
const cwd = options.cwd ?? process.cwd();
|
|
288
|
+
const schemaPath = options.schemaPath ?? path2.join(cwd, "prisma", "schema.prisma");
|
|
289
|
+
if (!fs2.existsSync(schemaPath)) {
|
|
290
|
+
throw new Error(`Prisma schema not found at ${schemaPath}`);
|
|
291
|
+
}
|
|
292
|
+
const models = (0, import_core.getSchemaModels)(schemaPath);
|
|
293
|
+
const aliases = (0, import_core.computeRelationAliasesFromSchema)(models);
|
|
294
|
+
const entries = Object.entries(aliases).sort(
|
|
295
|
+
([a], [b]) => a.localeCompare(b)
|
|
296
|
+
);
|
|
297
|
+
if (entries.length === 0) {
|
|
298
|
+
console.log(
|
|
299
|
+
"No additional relation aliases suggested (suffix rules cover all)."
|
|
300
|
+
);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const lines = [
|
|
304
|
+
"// Suggested RELATION_MODEL_ALIASES entries (merge into your resolver config)",
|
|
305
|
+
"export const SUGGESTED_RELATION_MODEL_ALIASES = {",
|
|
306
|
+
...entries.map(([k, v]) => ` ${k}: '${v}',`),
|
|
307
|
+
"} as const;",
|
|
308
|
+
""
|
|
309
|
+
];
|
|
310
|
+
const output = lines.join("\n");
|
|
311
|
+
if (options.write) {
|
|
312
|
+
const out = options.outFile ?? path2.join(
|
|
313
|
+
cwd,
|
|
314
|
+
"src",
|
|
315
|
+
"infrastructure",
|
|
316
|
+
"prisma",
|
|
317
|
+
"suggested-relation-aliases.ts"
|
|
318
|
+
);
|
|
319
|
+
fs2.mkdirSync(path2.dirname(out), { recursive: true });
|
|
320
|
+
fs2.writeFileSync(out, output, "utf-8");
|
|
321
|
+
console.log(`wrote ${path2.relative(cwd, out)}`);
|
|
322
|
+
} else {
|
|
323
|
+
console.log(output);
|
|
324
|
+
}
|
|
325
|
+
console.log(`
|
|
326
|
+
${entries.length} alias suggestion(s).`);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// src/commands/validate.ts
|
|
330
|
+
var import_core2 = require("@prismakit/core");
|
|
331
|
+
function runValidate(options = {}) {
|
|
332
|
+
const cwd = options.cwd ?? process.cwd();
|
|
333
|
+
if (options.assert !== false) {
|
|
334
|
+
try {
|
|
335
|
+
(0, import_core2.assertSelectComposeValid)(cwd);
|
|
336
|
+
console.log("Select compose validation passed.");
|
|
337
|
+
} catch (err) {
|
|
338
|
+
console.error(err.message);
|
|
339
|
+
process.exitCode = 1;
|
|
340
|
+
}
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const issues = (0, import_core2.validateSelectCompose)(cwd);
|
|
344
|
+
if (issues.length === 0) {
|
|
345
|
+
console.log("Select compose validation passed.");
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
for (const issue of issues) {
|
|
349
|
+
console.error(` - ${issue.file}: ${issue.message}`);
|
|
350
|
+
}
|
|
351
|
+
process.exitCode = 1;
|
|
352
|
+
}
|
|
353
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
354
|
+
0 && (module.exports = {
|
|
355
|
+
assertKebabName,
|
|
356
|
+
renderModuleFiles,
|
|
357
|
+
resolveNames,
|
|
358
|
+
runCodegen,
|
|
359
|
+
runGenerate,
|
|
360
|
+
runValidate
|
|
361
|
+
});
|
|
362
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands/generate.ts","../src/naming.ts","../src/templates.ts","../src/commands/codegen.ts","../src/commands/validate.ts"],"sourcesContent":["export { runGenerate, type GenerateCommandOptions } from './commands/generate';\nexport { runCodegen, type CodegenCommandOptions } from './commands/codegen';\nexport { runValidate, type ValidateCommandOptions } from './commands/validate';\nexport { resolveNames, assertKebabName, type ModuleNames } from './naming';\nexport { renderModuleFiles, type GeneratedFile, type GenerateOptions } from './templates';\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { resolveNames } from '../naming';\nimport { renderModuleFiles } from '../templates';\n\nexport type GenerateCommandOptions = {\n name: string;\n cache?: boolean;\n route?: string;\n cwd?: string;\n dryRun?: boolean;\n /** Emit full Nest module (controller/service/types). Default: repo-only. */\n full?: boolean;\n /** Prisma client import path (default `@prisma/client`). */\n prismaImport?: string;\n};\n\nexport function runGenerate(options: GenerateCommandOptions): void {\n const cwd = options.cwd ?? process.cwd();\n const names = resolveNames(options.name, options.route);\n const full = !!options.full;\n const files = renderModuleFiles({\n names,\n cacheEnabled: !!options.cache,\n full,\n prismaImport: options.prismaImport,\n });\n\n for (const file of files) {\n const fullPath = path.join(cwd, file.relativePath);\n if (options.dryRun) {\n console.log(`[dry-run] would write ${file.relativePath}`);\n continue;\n }\n if (fs.existsSync(fullPath)) {\n console.warn(`skip (exists): ${file.relativePath}`);\n continue;\n }\n fs.mkdirSync(path.dirname(fullPath), { recursive: true });\n const content = file.content.endsWith('\\n')\n ? file.content\n : `${file.content}\\n`;\n fs.writeFileSync(fullPath, content, 'utf-8');\n console.log(`created ${file.relativePath}`);\n }\n\n if (full) {\n console.log(\n `\\nScaffolded module \"${names.kebab}\". Register ${names.pascal}Module in app.module.ts.`,\n );\n } else {\n console.log(\n `\\nScaffolded repository \"${names.pascal}Repository\". Register it in your feature module providers.`,\n );\n }\n}\n","export interface ModuleNames {\n kebab: string;\n camel: string;\n pascal: string;\n repoModel: string;\n route: string;\n}\n\nconst KEBAB_NAME_RE = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;\n\nexport function assertKebabName(name: string): void {\n if (!KEBAB_NAME_RE.test(name)) {\n throw new Error(\n `Invalid module name \"${name}\". Use kebab-case (e.g. product, blog-post).`,\n );\n }\n}\n\nfunction kebabToPascal(kebab: string): string {\n return kebab\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('');\n}\n\nfunction kebabToCamel(kebab: string): string {\n const pascal = kebabToPascal(kebab);\n return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n}\n\nexport function resolveNames(kebab: string, route?: string): ModuleNames {\n assertKebabName(kebab);\n const pascal = kebabToPascal(kebab);\n const camel = kebabToCamel(kebab);\n return {\n kebab,\n camel,\n pascal,\n repoModel: camel,\n route: route ?? kebab,\n };\n}\n","import type { ModuleNames } from './naming';\n\nexport type GenerateOptions = {\n names: ModuleNames;\n cacheEnabled: boolean;\n /** When false (default), only emit the repository file. */\n full?: boolean;\n /** Prisma client import path (default `@prisma/client`). */\n prismaImport?: string;\n};\n\nfunction apply(template: string, names: ModuleNames, extras: Record<string, string>): string {\n const replacements: Record<string, string> = {\n '{{pascal}}': names.pascal,\n '{{camel}}': names.camel,\n '{{kebab}}': names.kebab,\n '{{route}}': names.route,\n '{{repoModel}}': names.repoModel,\n ...extras,\n };\n let result = template;\n for (const [key, value] of Object.entries(replacements)) {\n result = result.split(key).join(value);\n }\n return result;\n}\n\nexport type GeneratedFile = {\n relativePath: string;\n content: string;\n};\n\nfunction renderRepository(\n names: ModuleNames,\n cacheEnabled: boolean,\n prismaImport: string,\n base: string,\n): GeneratedFile {\n const cacheBlock = cacheEnabled\n ? ` cache: {\n ttl: 86400,\n sensitiveFields: ['password'],\n },\n`\n : '';\n\n const content = apply(\n `import { Prisma } from '{{prismaImport}}';\nimport { createInjectableRepository } from '@prismakit/nestjs';\n\nexport const {{pascal}}Repository = createInjectableRepository({\n model: '{{repoModel}}',\n scalarFields: Prisma.{{pascal}}ScalarFieldEnum,\n{{cacheBlock}}});\n\nexport type {{pascal}}Repository = InstanceType<typeof {{pascal}}Repository>;\n`,\n names,\n {\n '{{cacheBlock}}': cacheBlock,\n '{{prismaImport}}': prismaImport,\n },\n );\n\n return {\n relativePath: `${base}/repositories/${names.kebab}.repository.ts`,\n content,\n };\n}\n\nexport function renderModuleFiles(options: GenerateOptions): GeneratedFile[] {\n const { names, cacheEnabled, full = false } = options;\n const prismaImport = options.prismaImport ?? '@prisma/client';\n const base = `src/modules/${names.kebab}`;\n\n const repository = renderRepository(names, cacheEnabled, prismaImport, base);\n\n if (!full) {\n return [repository];\n }\n\n const service = apply(\n `import { Injectable } from '@nestjs/common';\n\nimport { {{pascal}}Repository } from '../repositories/{{kebab}}.repository';\nimport { get{{pascal}}Select } from '../types/select-{{kebab}}.type';\n\n@Injectable()\nexport class {{pascal}}Service {\n constructor(private readonly {{camel}}Repository: {{pascal}}Repository) {}\n\n async handleGetById(id: string) {\n return await this.{{camel}}Repository.getThrowById({\n id,\n select: get{{pascal}}Select('general'),\n setCache: true,\n });\n }\n}\n`,\n names,\n {},\n );\n\n const controller = apply(\n `import { Controller, Get, Param } from '@nestjs/common';\n\nimport { {{pascal}}Service } from '../services/{{kebab}}.service';\n\n@Controller('{{route}}')\nexport class {{pascal}}Controller {\n constructor(private readonly {{camel}}Service: {{pascal}}Service) {}\n\n @Get(':id')\n async getById(@Param('id') id: string) {\n return this.{{camel}}Service.handleGetById(id);\n }\n}\n`,\n names,\n {},\n );\n\n const moduleFile = apply(\n `import { Module } from '@nestjs/common';\n\nimport { {{pascal}}Controller } from './controllers/{{kebab}}.controller';\nimport { {{pascal}}Service } from './services/{{kebab}}.service';\nimport { {{pascal}}Repository } from './repositories/{{kebab}}.repository';\n\n@Module({\n controllers: [{{pascal}}Controller],\n providers: [{{pascal}}Service, {{pascal}}Repository],\n exports: [{{pascal}}Service, {{pascal}}Repository],\n})\nexport class {{pascal}}Module {}\n`,\n names,\n {},\n );\n\n const select = apply(\n `import { Prisma } from '{{prismaImport}}';\n\ntype {{pascal}}SelectPresetKey = keyof typeof {{camel}}SelectPresets;\n\nexport function get{{pascal}}Select<K extends {{pascal}}SelectPresetKey>(key: K) {\n return {{camel}}SelectPresets[key];\n}\n\nexport const {{camel}}SelectPresets = {\n minimal: {\n id: true,\n } satisfies Prisma.{{pascal}}Select,\n\n general: {\n id: true,\n } satisfies Prisma.{{pascal}}Select,\n};\n`,\n names,\n { '{{prismaImport}}': prismaImport },\n );\n\n const where = apply(\n `import { Prisma } from '{{prismaImport}}';\n\nexport function where{{pascal}}GetManyPaginate(_filter: {\n q?: string;\n}): {\n where: Prisma.{{pascal}}WhereInput;\n} {\n return { where: {} };\n}\n`,\n names,\n { '{{prismaImport}}': prismaImport },\n );\n\n return [\n { relativePath: `${base}/${names.kebab}.module.ts`, content: moduleFile },\n {\n relativePath: `${base}/controllers/${names.kebab}.controller.ts`,\n content: controller,\n },\n {\n relativePath: `${base}/services/${names.kebab}.service.ts`,\n content: service,\n },\n repository,\n {\n relativePath: `${base}/types/select-${names.kebab}.type.ts`,\n content: select,\n },\n {\n relativePath: `${base}/types/where-${names.kebab}.type.ts`,\n content: where,\n },\n ];\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport {\n computeRelationAliasesFromSchema,\n getSchemaModels,\n} from '@prismakit/core';\n\nexport type CodegenCommandOptions = {\n cwd?: string;\n schemaPath?: string;\n write?: boolean;\n outFile?: string;\n};\n\n/**\n * Parse prisma/schema.prisma and print (or write) suggested relation aliases.\n */\nexport function runCodegen(options: CodegenCommandOptions = {}): void {\n const cwd = options.cwd ?? process.cwd();\n const schemaPath =\n options.schemaPath ?? path.join(cwd, 'prisma', 'schema.prisma');\n\n if (!fs.existsSync(schemaPath)) {\n throw new Error(`Prisma schema not found at ${schemaPath}`);\n }\n\n const models = getSchemaModels(schemaPath);\n const aliases = computeRelationAliasesFromSchema(models);\n\n const entries = Object.entries(aliases).sort(([a], [b]) =>\n a.localeCompare(b),\n );\n\n if (entries.length === 0) {\n console.log(\n 'No additional relation aliases suggested (suffix rules cover all).',\n );\n return;\n }\n\n const lines = [\n '// Suggested RELATION_MODEL_ALIASES entries (merge into your resolver config)',\n 'export const SUGGESTED_RELATION_MODEL_ALIASES = {',\n ...entries.map(([k, v]) => ` ${k}: '${v}',`),\n '} as const;',\n '',\n ];\n const output = lines.join('\\n');\n\n if (options.write) {\n const out =\n options.outFile ??\n path.join(\n cwd,\n 'src',\n 'infrastructure',\n 'prisma',\n 'suggested-relation-aliases.ts',\n );\n fs.mkdirSync(path.dirname(out), { recursive: true });\n fs.writeFileSync(out, output, 'utf-8');\n console.log(`wrote ${path.relative(cwd, out)}`);\n } else {\n console.log(output);\n }\n\n console.log(`\\n${entries.length} alias suggestion(s).`);\n}\n","import {\n assertSelectComposeValid,\n validateSelectCompose,\n} from '@prismakit/core';\n\nexport type ValidateCommandOptions = {\n cwd?: string;\n assert?: boolean;\n};\n\n/**\n * Run select-compose validation from @prismakit/core.\n */\nexport function runValidate(options: ValidateCommandOptions = {}): void {\n const cwd = options.cwd ?? process.cwd();\n\n if (options.assert !== false) {\n try {\n assertSelectComposeValid(cwd);\n console.log('Select compose validation passed.');\n } catch (err) {\n console.error((err as Error).message);\n process.exitCode = 1;\n }\n return;\n }\n\n const issues = validateSelectCompose(cwd);\n if (issues.length === 0) {\n console.log('Select compose validation passed.');\n return;\n }\n\n for (const issue of issues) {\n console.error(` - ${issue.file}: ${issue.message}`);\n }\n process.exitCode = 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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ACnD,IAAG,kBAAc,KAAK,QAAQ,OAAO;AACrC,YAAQ,IAAI,SAAc,eAAS,KAAK,GAAG,CAAC,EAAE;AAAA,EAChD,OAAO;AACL,YAAQ,IAAI,MAAM;AAAA,EACpB;AAEA,UAAQ,IAAI;AAAA,EAAK,QAAQ,MAAM,uBAAuB;AACxD;;;ACpEA,IAAAC,eAGO;AAUA,SAAS,YAAY,UAAkC,CAAC,GAAS;AACtE,QAAM,MAAM,QAAQ,OAAO,QAAQ,IAAI;AAEvC,MAAI,QAAQ,WAAW,OAAO;AAC5B,QAAI;AACF,iDAAyB,GAAG;AAC5B,cAAQ,IAAI,mCAAmC;AAAA,IACjD,SAAS,KAAK;AACZ,cAAQ,MAAO,IAAc,OAAO;AACpC,cAAQ,WAAW;AAAA,IACrB;AACA;AAAA,EACF;AAEA,QAAM,aAAS,oCAAsB,GAAG;AACxC,MAAI,OAAO,WAAW,GAAG;AACvB,YAAQ,IAAI,mCAAmC;AAC/C;AAAA,EACF;AAEA,aAAW,SAAS,QAAQ;AAC1B,YAAQ,MAAM,OAAO,MAAM,IAAI,KAAK,MAAM,OAAO,EAAE;AAAA,EACrD;AACA,UAAQ,WAAW;AACrB;","names":["fs","path","import_core"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
type GenerateCommandOptions = {
|
|
2
|
+
name: string;
|
|
3
|
+
cache?: boolean;
|
|
4
|
+
route?: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
dryRun?: boolean;
|
|
7
|
+
/** Emit full Nest module (controller/service/types). Default: repo-only. */
|
|
8
|
+
full?: boolean;
|
|
9
|
+
/** Prisma client import path (default `@prisma/client`). */
|
|
10
|
+
prismaImport?: string;
|
|
11
|
+
};
|
|
12
|
+
declare function runGenerate(options: GenerateCommandOptions): void;
|
|
13
|
+
|
|
14
|
+
type CodegenCommandOptions = {
|
|
15
|
+
cwd?: string;
|
|
16
|
+
schemaPath?: string;
|
|
17
|
+
write?: boolean;
|
|
18
|
+
outFile?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Parse prisma/schema.prisma and print (or write) suggested relation aliases.
|
|
22
|
+
*/
|
|
23
|
+
declare function runCodegen(options?: CodegenCommandOptions): void;
|
|
24
|
+
|
|
25
|
+
type ValidateCommandOptions = {
|
|
26
|
+
cwd?: string;
|
|
27
|
+
assert?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Run select-compose validation from @prismakit/core.
|
|
31
|
+
*/
|
|
32
|
+
declare function runValidate(options?: ValidateCommandOptions): void;
|
|
33
|
+
|
|
34
|
+
interface ModuleNames {
|
|
35
|
+
kebab: string;
|
|
36
|
+
camel: string;
|
|
37
|
+
pascal: string;
|
|
38
|
+
repoModel: string;
|
|
39
|
+
route: string;
|
|
40
|
+
}
|
|
41
|
+
declare function assertKebabName(name: string): void;
|
|
42
|
+
declare function resolveNames(kebab: string, route?: string): ModuleNames;
|
|
43
|
+
|
|
44
|
+
type GenerateOptions = {
|
|
45
|
+
names: ModuleNames;
|
|
46
|
+
cacheEnabled: boolean;
|
|
47
|
+
/** When false (default), only emit the repository file. */
|
|
48
|
+
full?: boolean;
|
|
49
|
+
/** Prisma client import path (default `@prisma/client`). */
|
|
50
|
+
prismaImport?: string;
|
|
51
|
+
};
|
|
52
|
+
type GeneratedFile = {
|
|
53
|
+
relativePath: string;
|
|
54
|
+
content: string;
|
|
55
|
+
};
|
|
56
|
+
declare function renderModuleFiles(options: GenerateOptions): GeneratedFile[];
|
|
57
|
+
|
|
58
|
+
export { type CodegenCommandOptions, type GenerateCommandOptions, type GenerateOptions, type GeneratedFile, type ModuleNames, type ValidateCommandOptions, assertKebabName, renderModuleFiles, resolveNames, runCodegen, runGenerate, runValidate };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
type GenerateCommandOptions = {
|
|
2
|
+
name: string;
|
|
3
|
+
cache?: boolean;
|
|
4
|
+
route?: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
dryRun?: boolean;
|
|
7
|
+
/** Emit full Nest module (controller/service/types). Default: repo-only. */
|
|
8
|
+
full?: boolean;
|
|
9
|
+
/** Prisma client import path (default `@prisma/client`). */
|
|
10
|
+
prismaImport?: string;
|
|
11
|
+
};
|
|
12
|
+
declare function runGenerate(options: GenerateCommandOptions): void;
|
|
13
|
+
|
|
14
|
+
type CodegenCommandOptions = {
|
|
15
|
+
cwd?: string;
|
|
16
|
+
schemaPath?: string;
|
|
17
|
+
write?: boolean;
|
|
18
|
+
outFile?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Parse prisma/schema.prisma and print (or write) suggested relation aliases.
|
|
22
|
+
*/
|
|
23
|
+
declare function runCodegen(options?: CodegenCommandOptions): void;
|
|
24
|
+
|
|
25
|
+
type ValidateCommandOptions = {
|
|
26
|
+
cwd?: string;
|
|
27
|
+
assert?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Run select-compose validation from @prismakit/core.
|
|
31
|
+
*/
|
|
32
|
+
declare function runValidate(options?: ValidateCommandOptions): void;
|
|
33
|
+
|
|
34
|
+
interface ModuleNames {
|
|
35
|
+
kebab: string;
|
|
36
|
+
camel: string;
|
|
37
|
+
pascal: string;
|
|
38
|
+
repoModel: string;
|
|
39
|
+
route: string;
|
|
40
|
+
}
|
|
41
|
+
declare function assertKebabName(name: string): void;
|
|
42
|
+
declare function resolveNames(kebab: string, route?: string): ModuleNames;
|
|
43
|
+
|
|
44
|
+
type GenerateOptions = {
|
|
45
|
+
names: ModuleNames;
|
|
46
|
+
cacheEnabled: boolean;
|
|
47
|
+
/** When false (default), only emit the repository file. */
|
|
48
|
+
full?: boolean;
|
|
49
|
+
/** Prisma client import path (default `@prisma/client`). */
|
|
50
|
+
prismaImport?: string;
|
|
51
|
+
};
|
|
52
|
+
type GeneratedFile = {
|
|
53
|
+
relativePath: string;
|
|
54
|
+
content: string;
|
|
55
|
+
};
|
|
56
|
+
declare function renderModuleFiles(options: GenerateOptions): GeneratedFile[];
|
|
57
|
+
|
|
58
|
+
export { type CodegenCommandOptions, type GenerateCommandOptions, type GenerateOptions, type GeneratedFile, type ModuleNames, type ValidateCommandOptions, assertKebabName, renderModuleFiles, resolveNames, runCodegen, runGenerate, runValidate };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertKebabName,
|
|
3
|
+
renderModuleFiles,
|
|
4
|
+
resolveNames,
|
|
5
|
+
runCodegen,
|
|
6
|
+
runGenerate,
|
|
7
|
+
runValidate
|
|
8
|
+
} from "./chunk-36ZM4UZV.js";
|
|
9
|
+
export {
|
|
10
|
+
assertKebabName,
|
|
11
|
+
renderModuleFiles,
|
|
12
|
+
resolveNames,
|
|
13
|
+
runCodegen,
|
|
14
|
+
runGenerate,
|
|
15
|
+
runValidate
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prismakit/cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI for PrismaKit — generate modules, codegen relation aliases, validate compose",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=20"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"bin": {
|
|
11
|
+
"prismakit": "./dist/bin.js"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@prismakit/core": "1.0.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@prismakit/core": "1.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"typescript": "^5.9.2",
|
|
36
|
+
"tsup": "^8.4.0",
|
|
37
|
+
"vitest": "^3.0.8"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsup",
|
|
44
|
+
"test": "vitest run --passWithNoTests",
|
|
45
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
46
|
+
"lint": "tsc -p tsconfig.json --noEmit",
|
|
47
|
+
"clean": "rm -rf dist"
|
|
48
|
+
}
|
|
49
|
+
}
|