@warlock.js/core 4.0.131 → 4.0.133

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.
Files changed (86) hide show
  1. package/esm/cli/commands/create-database.command.d.ts +2 -0
  2. package/esm/cli/commands/create-database.command.d.ts.map +1 -0
  3. package/esm/cli/commands/create-database.command.js +18 -0
  4. package/esm/cli/commands/create-database.command.js.map +1 -0
  5. package/esm/cli/commands/generate/generate.command.d.ts +10 -0
  6. package/esm/cli/commands/generate/generate.command.d.ts.map +1 -0
  7. package/esm/cli/commands/generate/generate.command.js +167 -0
  8. package/esm/cli/commands/generate/generate.command.js.map +1 -0
  9. package/esm/cli/commands/generate/generators/controller.generator.d.ts +3 -0
  10. package/esm/cli/commands/generate/generators/controller.generator.d.ts.map +1 -0
  11. package/esm/cli/commands/generate/generators/controller.generator.js +51 -0
  12. package/esm/cli/commands/generate/generators/controller.generator.js.map +1 -0
  13. package/esm/cli/commands/generate/generators/migration.generator.d.ts +13 -0
  14. package/esm/cli/commands/generate/generators/migration.generator.d.ts.map +1 -0
  15. package/esm/cli/commands/generate/generators/migration.generator.js +42 -0
  16. package/esm/cli/commands/generate/generators/migration.generator.js.map +1 -0
  17. package/esm/cli/commands/generate/generators/model.generator.d.ts +3 -0
  18. package/esm/cli/commands/generate/generators/model.generator.d.ts.map +1 -0
  19. package/esm/cli/commands/generate/generators/model.generator.js +56 -0
  20. package/esm/cli/commands/generate/generators/model.generator.js.map +1 -0
  21. package/esm/cli/commands/generate/generators/module.generator.d.ts +3 -0
  22. package/esm/cli/commands/generate/generators/module.generator.d.ts.map +1 -0
  23. package/esm/cli/commands/generate/generators/module.generator.js +156 -0
  24. package/esm/cli/commands/generate/generators/module.generator.js.map +1 -0
  25. package/esm/cli/commands/generate/generators/repository.generator.d.ts +3 -0
  26. package/esm/cli/commands/generate/generators/repository.generator.d.ts.map +1 -0
  27. package/esm/cli/commands/generate/generators/repository.generator.js +37 -0
  28. package/esm/cli/commands/generate/generators/repository.generator.js.map +1 -0
  29. package/esm/cli/commands/generate/generators/resource.generator.d.ts +3 -0
  30. package/esm/cli/commands/generate/generators/resource.generator.d.ts.map +1 -0
  31. package/esm/cli/commands/generate/generators/resource.generator.js +37 -0
  32. package/esm/cli/commands/generate/generators/resource.generator.js.map +1 -0
  33. package/esm/cli/commands/generate/generators/service.generator.d.ts +3 -0
  34. package/esm/cli/commands/generate/generators/service.generator.d.ts.map +1 -0
  35. package/esm/cli/commands/generate/generators/service.generator.js +37 -0
  36. package/esm/cli/commands/generate/generators/service.generator.js.map +1 -0
  37. package/esm/cli/commands/generate/generators/validation.generator.d.ts +3 -0
  38. package/esm/cli/commands/generate/generators/validation.generator.d.ts.map +1 -0
  39. package/esm/cli/commands/generate/generators/validation.generator.js +46 -0
  40. package/esm/cli/commands/generate/generators/validation.generator.js.map +1 -0
  41. package/esm/cli/commands/generate/templates/stubs.d.ts +111 -0
  42. package/esm/cli/commands/generate/templates/stubs.d.ts.map +1 -0
  43. package/esm/cli/commands/generate/templates/stubs.js +569 -0
  44. package/esm/cli/commands/generate/templates/stubs.js.map +1 -0
  45. package/esm/cli/commands/generate/types.d.ts +53 -0
  46. package/esm/cli/commands/generate/types.d.ts.map +1 -0
  47. package/esm/cli/commands/generate/utils/name-parser.d.ts +45 -0
  48. package/esm/cli/commands/generate/utils/name-parser.d.ts.map +1 -0
  49. package/esm/cli/commands/generate/utils/name-parser.js +76 -0
  50. package/esm/cli/commands/generate/utils/name-parser.js.map +1 -0
  51. package/esm/cli/commands/generate/utils/path-resolver.d.ts +30 -0
  52. package/esm/cli/commands/generate/utils/path-resolver.d.ts.map +1 -0
  53. package/esm/cli/commands/generate/utils/path-resolver.js +42 -0
  54. package/esm/cli/commands/generate/utils/path-resolver.js.map +1 -0
  55. package/esm/cli/commands/generate/utils/prompt.d.ts +13 -0
  56. package/esm/cli/commands/generate/utils/prompt.d.ts.map +1 -0
  57. package/esm/cli/framework-cli-commands.d.ts.map +1 -1
  58. package/esm/cli/framework-cli-commands.js +12 -1
  59. package/esm/cli/framework-cli-commands.js.map +1 -1
  60. package/esm/database/create-database-action.d.ts +3 -0
  61. package/esm/database/create-database-action.d.ts.map +1 -0
  62. package/esm/database/create-database-action.js +28 -0
  63. package/esm/database/create-database-action.js.map +1 -0
  64. package/esm/index.js +1 -1
  65. package/esm/resource/define-resource.d.ts.map +1 -1
  66. package/esm/resource/define-resource.js +6 -2
  67. package/esm/resource/define-resource.js.map +1 -1
  68. package/esm/resource/index.d.ts +1 -0
  69. package/esm/resource/index.d.ts.map +1 -1
  70. package/esm/resource/register-resource.d.ts +21 -0
  71. package/esm/resource/register-resource.d.ts.map +1 -0
  72. package/esm/resource/register-resource.js +23 -0
  73. package/esm/resource/register-resource.js.map +1 -0
  74. package/esm/resource/resource-field-builder.d.ts +22 -1
  75. package/esm/resource/resource-field-builder.d.ts.map +1 -1
  76. package/esm/resource/resource-field-builder.js +71 -14
  77. package/esm/resource/resource-field-builder.js.map +1 -1
  78. package/esm/resource/resource.d.ts +19 -8
  79. package/esm/resource/resource.d.ts.map +1 -1
  80. package/esm/resource/resource.js +59 -40
  81. package/esm/resource/resource.js.map +1 -1
  82. package/esm/resource/types.d.ts +25 -1
  83. package/esm/resource/types.d.ts.map +1 -1
  84. package/esm/router/types.d.ts +6 -0
  85. package/esm/router/types.d.ts.map +1 -1
  86. package/package.json +7 -7
@@ -0,0 +1,569 @@
1
+ import {parseName}from'../utils/name-parser.js';/**
2
+ * Controller template stub
3
+ */
4
+ function controllerStub(name, options = {}) {
5
+ const { withValidation } = options;
6
+ return `import type { RequestHandler, Response } from "@warlock.js/core";
7
+ ${withValidation
8
+ ? `import { type ${name.pascal}Request } from "../requests/${name.kebab}.request";
9
+ import { ${name.camel}Schema } from "../validation/${name.kebab}.schema";`
10
+ : ""}
11
+
12
+ export const ${name.camel}Controller: RequestHandler = async (
13
+ request${withValidation ? `: ${name.pascal}Request` : ""},
14
+ response: Response,
15
+ ) => {
16
+ // TODO: Implement controller logic
17
+ return response.success({});
18
+ };
19
+ ${withValidation
20
+ ? `
21
+ ${name.camel}Controller.validation = {
22
+ schema: ${name.camel}Schema,
23
+ };`
24
+ : ""}
25
+ `;
26
+ }
27
+ /**
28
+ * CRUD Create Controller template
29
+ * Note: moduleName is the module (plural), we need singular entity name
30
+ */
31
+ function crudCreateControllerStub(moduleName) {
32
+ // Get singular entity name (e.g., "products" -> "product")
33
+ const entityKebab = moduleName.kebab.endsWith("s")
34
+ ? moduleName.kebab.slice(0, -1)
35
+ : moduleName.kebab;
36
+ const entity = parseName(entityKebab);
37
+ return `import { type RequestHandler } from "@warlock.js/core";
38
+ import { type Create${entity.pascal}Request } from "../requests/create-${entity.kebab}.request";
39
+ import { create${entity.pascal}Schema } from "../validation/create-${entity.kebab}.schema";
40
+ import { create${entity.pascal}Service } from "../services/create-${entity.kebab}.service";
41
+
42
+ export const create${entity.pascal}Controller: RequestHandler = async (
43
+ request: Create${entity.pascal}Request,
44
+ response,
45
+ ) => {
46
+ const ${entity.camel} = await create${entity.pascal}Service(request.validated());
47
+
48
+ return response.success({
49
+ ${entity.camel},
50
+ });
51
+ };
52
+
53
+ create${entity.pascal}Controller.validation = {
54
+ schema: create${entity.pascal}Schema,
55
+ };
56
+ `;
57
+ }
58
+ /**
59
+ * CRUD Update Controller template
60
+ */
61
+ function crudUpdateControllerStub(moduleName) {
62
+ // Get singular entity name
63
+ const entityKebab = moduleName.kebab.endsWith("s")
64
+ ? moduleName.kebab.slice(0, -1)
65
+ : moduleName.kebab;
66
+ const entity = parseName(entityKebab);
67
+ return `import { type RequestHandler } from "@warlock.js/core";
68
+ import { type Update${entity.pascal}Request } from "../requests/update-${entity.kebab}.request";
69
+ import { update${entity.pascal}Schema } from "../validation/update-${entity.kebab}.schema";
70
+ import { update${entity.pascal}Service } from "../services/update-${entity.kebab}.service";
71
+
72
+ export const update${entity.pascal}Controller: RequestHandler = async (
73
+ request: Update${entity.pascal}Request,
74
+ response,
75
+ ) => {
76
+ const ${entity.camel} = await update${entity.pascal}Service(request.int("id"), request.validated());
77
+
78
+ if (!${entity.camel}) {
79
+ return response.notFound();
80
+ }
81
+
82
+ return response.success({
83
+ ${entity.camel},
84
+ });
85
+ };
86
+
87
+ update${entity.pascal}Controller.validation = {
88
+ schema: update${entity.pascal}Schema,
89
+ };
90
+ `;
91
+ }
92
+ /**
93
+ * CRUD List Controller template
94
+ */
95
+ function crudListControllerStub(moduleName) {
96
+ const entityKebab = moduleName.kebab.endsWith("s")
97
+ ? moduleName.kebab.slice(0, -1)
98
+ : moduleName.kebab;
99
+ const entity = parseName(entityKebab);
100
+ return `import { type RequestHandler } from "@warlock.js/core";
101
+ import { list${entity.pascal}sService } from "../services/list-${moduleName.kebab}.service";
102
+
103
+ export const list${entity.pascal}sController: RequestHandler = async (
104
+ request,
105
+ response,
106
+ ) => {
107
+ const { records, paginationInfo } = await list${entity.pascal}sService(request.all());
108
+
109
+ return response.success({
110
+ records,
111
+ paginationInfo,
112
+ });
113
+ };
114
+ `;
115
+ }
116
+ /**
117
+ * CRUD Show/Get Controller template
118
+ */
119
+ function crudShowControllerStub(moduleName) {
120
+ const entityKebab = moduleName.kebab.endsWith("s")
121
+ ? moduleName.kebab.slice(0, -1)
122
+ : moduleName.kebab;
123
+ const entity = parseName(entityKebab);
124
+ return `import { type RequestHandler } from "@warlock.js/core";
125
+ import { get${entity.pascal}Service } from "../services/get-${entity.kebab}.service";
126
+
127
+ export const get${entity.pascal}Controller: RequestHandler = async (
128
+ request,
129
+ response,
130
+ ) => {
131
+ const ${entity.camel} = await get${entity.pascal}Service(request.int("id"));
132
+
133
+ if (!${entity.camel}) {
134
+ return response.notFound();
135
+ }
136
+
137
+ return response.success({
138
+ ${entity.camel},
139
+ });
140
+ };
141
+ `;
142
+ }
143
+ /**
144
+ * CRUD Delete Controller template
145
+ */
146
+ function crudDeleteControllerStub(moduleName) {
147
+ const entityKebab = moduleName.kebab.endsWith("s")
148
+ ? moduleName.kebab.slice(0, -1)
149
+ : moduleName.kebab;
150
+ const entity = parseName(entityKebab);
151
+ return `import { type RequestHandler } from "@warlock.js/core";
152
+ import { delete${entity.pascal}Service } from "../services/delete-${entity.kebab}.service";
153
+
154
+ export const delete${entity.pascal}Controller: RequestHandler = async (
155
+ request,
156
+ response,
157
+ ) => {
158
+ await delete${entity.pascal}Service(request.int("id"));
159
+
160
+ return response.success({
161
+ message: "${entity.pascal} deleted successfully",
162
+ });
163
+ };
164
+ `;
165
+ }
166
+ /**
167
+ * CRUD Routes template
168
+ */
169
+ function crudRoutesStub(moduleName) {
170
+ const entityKebab = moduleName.kebab.endsWith("s")
171
+ ? moduleName.kebab.slice(0, -1)
172
+ : moduleName.kebab;
173
+ const entity = parseName(entityKebab);
174
+ return `import { router } from "@warlock.js/core";
175
+ import { guarded } from "app/shared/utils/router";
176
+ import { create${entity.pascal}Controller } from "./controllers/create-${entity.kebab}.controller";
177
+ import { delete${entity.pascal}Controller } from "./controllers/delete-${entity.kebab}.controller";
178
+ import { get${entity.pascal}Controller } from "./controllers/get-${entity.kebab}.controller";
179
+ import { list${entity.pascal}sController } from "./controllers/list-${moduleName.kebab}.controller";
180
+ import { update${entity.pascal}Controller } from "./controllers/update-${entity.kebab}.controller";
181
+
182
+ guarded(() => {
183
+ router
184
+ .route("/${moduleName.kebab}")
185
+ .list(list${entity.pascal}sController)
186
+ .show(get${entity.pascal}Controller)
187
+ .create(create${entity.pascal}Controller)
188
+ .update(update${entity.pascal}Controller)
189
+ .destroy(delete${entity.pascal}Controller);
190
+ });
191
+ `;
192
+ }
193
+ /**
194
+ * CRUD Model template
195
+ */
196
+ function crudModelStub(moduleName) {
197
+ // Get singular entity name
198
+ const entityKebab = moduleName.kebab.endsWith("s")
199
+ ? moduleName.kebab.slice(0, -1)
200
+ : moduleName.kebab;
201
+ const entity = parseName(entityKebab);
202
+ return `import { Model, RegisterModel } from "@warlock.js/cascade";
203
+ import { type Infer, v } from "@warlock.js/core";
204
+ import { ${entity.pascal}Resource } from "app/${moduleName.kebab}/resources/${entity.kebab}.resource";
205
+ import { globalColumnsSchema } from "app/shared/utils/global-columns-schema";
206
+
207
+ export const ${entity.camel}Schema = globalColumnsSchema.extend({
208
+ name: v.string().required(),
209
+ // TODO: Add more fields
210
+ });
211
+
212
+ type ${entity.pascal}Schema = Infer<typeof ${entity.camel}Schema>;
213
+
214
+ @RegisterModel()
215
+ export class ${entity.pascal} extends Model<${entity.pascal}Schema> {
216
+ public static table = "${moduleName.snake}";
217
+
218
+ public static schema = ${entity.camel}Schema;
219
+
220
+ public static relations = {};
221
+
222
+ public static resource = ${entity.pascal}Resource;
223
+ }
224
+ `;
225
+ }
226
+ /**
227
+ * CRUD Resource template
228
+ */
229
+ function crudResourceStub(moduleName) {
230
+ // Get singular entity name
231
+ const entityKebab = moduleName.kebab.endsWith("s")
232
+ ? moduleName.kebab.slice(0, -1)
233
+ : moduleName.kebab;
234
+ const entity = parseName(entityKebab);
235
+ return `import { defineResource } from "@warlock.js/core";
236
+
237
+ export const ${entity.pascal}Resource = defineResource({
238
+ schema: {
239
+ id: "number",
240
+ name: "string",
241
+ // TODO: Add more fields
242
+ createdBy: "object",
243
+ updatedBy: "object",
244
+ isActive: "boolean",
245
+ },
246
+ });
247
+ `;
248
+ }
249
+ /**
250
+ * CRUD Repository template
251
+ */
252
+ function crudRepositoryStub(moduleName) {
253
+ const entityKebab = moduleName.kebab.endsWith("s")
254
+ ? moduleName.kebab.slice(0, -1)
255
+ : moduleName.kebab;
256
+ const entity = parseName(entityKebab);
257
+ return `import type { FilterRules, RepositoryOptions } from "@warlock.js/core";
258
+ import { RepositoryManager } from "@warlock.js/core";
259
+ import { ${entity.pascal} } from "../models/${entity.kebab}";
260
+
261
+ class ${entity.pascal}Repository extends RepositoryManager<${entity.pascal}> {
262
+ public source = ${entity.pascal};
263
+
264
+ public simpleSelectColumns: string[] = ["id", "name", "createdAt"];
265
+
266
+ public filterBy: FilterRules = {
267
+ id: "int",
268
+ name: "like",
269
+ };
270
+
271
+ public defaultOptions: RepositoryOptions = {
272
+ orderBy: {
273
+ createdAt: "desc",
274
+ },
275
+ };
276
+ }
277
+
278
+ export const ${moduleName.camel}Repository = new ${entity.pascal}Repository();
279
+ `;
280
+ }
281
+ /**
282
+ * CRUD Create Service template
283
+ */
284
+ function crudCreateServiceStub(moduleName) {
285
+ const entityKebab = moduleName.kebab.endsWith("s")
286
+ ? moduleName.kebab.slice(0, -1)
287
+ : moduleName.kebab;
288
+ const entity = parseName(entityKebab);
289
+ return `import { ${entity.pascal} } from "../models/${entity.kebab}";
290
+ import type { Create${entity.pascal}Schema } from "../validation/create-${entity.kebab}.schema";
291
+
292
+ export async function create${entity.pascal}Service(data: Create${entity.pascal}Schema) {
293
+ const ${entity.camel} = await ${entity.pascal}.create(data);
294
+ return ${entity.camel};
295
+ }
296
+ `;
297
+ }
298
+ /**
299
+ * CRUD Update Service template
300
+ */
301
+ function crudUpdateServiceStub(moduleName) {
302
+ const entityKebab = moduleName.kebab.endsWith("s")
303
+ ? moduleName.kebab.slice(0, -1)
304
+ : moduleName.kebab;
305
+ const entity = parseName(entityKebab);
306
+ return `import { ResourceNotFoundError } from "@warlock.js/core";
307
+ import { ${entity.pascal} } from "../models/${entity.kebab}";
308
+ import type { Update${entity.pascal}Schema } from "../validation/update-${entity.kebab}.schema";
309
+
310
+ export async function update${entity.pascal}Service(id: number, data: Update${entity.pascal}Schema) {
311
+ const ${entity.camel} = await ${entity.pascal}.find(id);
312
+ if (!${entity.camel}) {
313
+ throw new ResourceNotFoundError("${entity.pascal} not found");
314
+ }
315
+ await ${entity.camel}.save({ merge: data });
316
+ return ${entity.camel};
317
+ }
318
+ `;
319
+ }
320
+ /**
321
+ * CRUD List Service template
322
+ */
323
+ function crudListServiceStub(moduleName) {
324
+ const entityKebab = moduleName.kebab.endsWith("s")
325
+ ? moduleName.kebab.slice(0, -1)
326
+ : moduleName.kebab;
327
+ const entity = parseName(entityKebab);
328
+ return `import { ${moduleName.camel}Repository } from "../repositories/${moduleName.kebab}.repository";
329
+
330
+ export async function list${entity.pascal}sService(filters: any) {
331
+ return ${moduleName.camel}Repository.listCached(filters);
332
+ }
333
+ `;
334
+ }
335
+ /**
336
+ * CRUD Get Service template
337
+ */
338
+ function crudGetServiceStub(moduleName) {
339
+ const entityKebab = moduleName.kebab.endsWith("s")
340
+ ? moduleName.kebab.slice(0, -1)
341
+ : moduleName.kebab;
342
+ const entity = parseName(entityKebab);
343
+ return `import { ${moduleName.camel}Repository } from "../repositories/${moduleName.kebab}.repository";
344
+
345
+ export async function get${entity.pascal}Service(id: number) {
346
+ return ${moduleName.camel}Repository.getCached(id);
347
+ }
348
+ `;
349
+ }
350
+ /**
351
+ * CRUD Delete Service template
352
+ */
353
+ function crudDeleteServiceStub(moduleName) {
354
+ const entityKebab = moduleName.kebab.endsWith("s")
355
+ ? moduleName.kebab.slice(0, -1)
356
+ : moduleName.kebab;
357
+ const entity = parseName(entityKebab);
358
+ return `import { ResourceNotFoundError } from "@warlock.js/core";
359
+ import { ${entity.pascal} } from "../models/${entity.kebab}";
360
+
361
+ export async function delete${entity.pascal}Service(id: number) {
362
+ const ${entity.camel} = await ${entity.pascal}.find(id);
363
+ if (!${entity.camel}) {
364
+ throw new ResourceNotFoundError("${entity.pascal} not found");
365
+ }
366
+ await ${entity.camel}.destroy();
367
+ }
368
+ `;
369
+ }
370
+ /**
371
+ * CRUD Seed template
372
+ */
373
+ function crudSeedStub(moduleName) {
374
+ const entityKebab = moduleName.kebab.endsWith("s")
375
+ ? moduleName.kebab.slice(0, -1)
376
+ : moduleName.kebab;
377
+ const entity = parseName(entityKebab);
378
+ return `import { Random } from "@mongez/reinforcements";
379
+ import { seeder } from "@warlock.js/core";
380
+ import { ${entity.pascal} } from "../models/${entity.kebab}";
381
+
382
+ export default seeder({
383
+ name: "Seed ${entity.pascal}s",
384
+ once: true,
385
+ run: async () => {
386
+ for (let i = 0; i < 10; i++) {
387
+ await ${entity.pascal}.create({
388
+ name: \`${entity.pascal} \${Random.int()}\`,
389
+ // TODO: Add more fields
390
+ });
391
+ }
392
+
393
+ return {
394
+ recordsCreated: 10,
395
+ };
396
+ },
397
+ });
398
+ `;
399
+ }
400
+ /**
401
+ * Migration template
402
+ */
403
+ function migrationStub(entityName) {
404
+ return `import { Migration } from "@warlock.js/cascade";
405
+ import { ${entityName.pascal} } from "../${entityName.kebab}.model";
406
+
407
+ export default class ${entityName.pascal}Migration extends Migration.for(${entityName.pascal}) {
408
+ public up() {
409
+ // Create table
410
+ this.createTableIfNotExists();
411
+
412
+ // Primary key
413
+ this.id();
414
+
415
+ // Add your schema fields here
416
+ this.string("name", 255).notNullable();
417
+
418
+ // Status
419
+ this.boolean("isActive").default(true);
420
+
421
+ // Timestamps
422
+ this.timestamps();
423
+ this.timestamp("deletedAt").nullable();
424
+ }
425
+
426
+ public down() {
427
+ this.dropTableIfExists();
428
+ }
429
+ }
430
+ `;
431
+ }
432
+ /**
433
+ * CRUD Create Validation template
434
+ */
435
+ function crudCreateValidationStub(moduleName) {
436
+ // Get singular entity name
437
+ const entityKebab = moduleName.kebab.endsWith("s")
438
+ ? moduleName.kebab.slice(0, -1)
439
+ : moduleName.kebab;
440
+ const entity = parseName(entityKebab);
441
+ return `import { v, type Infer } from "@warlock.js/core";
442
+
443
+ export const create${entity.pascal}Schema = v.object({
444
+ name: v.string().required(),
445
+ // TODO: Add validation rules
446
+ });
447
+
448
+ export type Create${entity.pascal}Schema = Infer<typeof create${entity.pascal}Schema>;
449
+ `;
450
+ }
451
+ /**
452
+ * CRUD Update Validation template
453
+ */
454
+ function crudUpdateValidationStub(moduleName) {
455
+ // Get singular entity name
456
+ const entityKebab = moduleName.kebab.endsWith("s")
457
+ ? moduleName.kebab.slice(0, -1)
458
+ : moduleName.kebab;
459
+ const entity = parseName(entityKebab);
460
+ return `import { v, type Infer } from "@warlock.js/core";
461
+
462
+ export const update${entity.pascal}Schema = v.object({
463
+ name: v.string(),
464
+ // TODO: Add validation rules
465
+ });
466
+
467
+ export type Update${entity.pascal}Schema = Infer<typeof update${entity.pascal}Schema>;
468
+ `;
469
+ }
470
+ /**
471
+ * Service template stub
472
+ */
473
+ function serviceStub(name) {
474
+ return `export async function ${name.camel}Service(data: any): Promise<any> {
475
+ // TODO: Implement service logic
476
+ throw new Error("${name.camel}Service not implemented");
477
+ }
478
+ `;
479
+ }
480
+ /**
481
+ * Validation schema template stub
482
+ */
483
+ function validationStub(name) {
484
+ return `import { v, type Infer } from "@warlock.js/core";
485
+
486
+ export const ${name.camel}Schema = v.object({
487
+ // TODO: Define validation schema
488
+ });
489
+
490
+ export type ${name.pascal}Schema = Infer<typeof ${name.camel}Schema>;
491
+ `;
492
+ }
493
+ /**
494
+ * Request type template stub
495
+ */
496
+ function requestStub(name) {
497
+ return `import type { Request } from "@warlock.js/core";
498
+ import { type ${name.pascal}Schema } from "../validation/${name.kebab}.schema";
499
+
500
+ export type ${name.pascal}Request = Request<${name.pascal}Schema>;
501
+ `;
502
+ }
503
+ /**
504
+ * Model template stub
505
+ */
506
+ function modelStub(name, options = {}) {
507
+ const { tableName = `${name.snake}s`, withResource } = options;
508
+ return `import { Model } from "@warlock.js/core";
509
+ import type { StrictMode } from "@warlock.js/cascade";
510
+ import { v, type Infer } from "@warlock.js/core";
511
+ ${withResource ? `import { ${name.pascal}Resource } from "../../resources/${name.kebab}.resource";` : ""}
512
+
513
+ const ${name.camel}Schema = v.object({
514
+ // TODO: Define model schema
515
+ name: v.string().required(),
516
+ });
517
+
518
+ type ${name.pascal}Type = Infer<typeof ${name.camel}Schema>;
519
+
520
+ export class ${name.pascal} extends Model<${name.pascal}Type> {
521
+ public static table = "${tableName}";
522
+ public static strictMode: StrictMode = "fail";
523
+ ${withResource ? ` public static resource = ${name.pascal}Resource;` : ""}
524
+
525
+ public static schema = ${name.camel}Schema;
526
+
527
+ public embed = ["id", "name"];
528
+ }
529
+ `;
530
+ }
531
+ /**
532
+ * Repository template stub
533
+ */
534
+ function repositoryStub(name) {
535
+ return `import type { FilterByOptions, RepositoryOptions } from "@warlock.js/core";
536
+ import { RepositoryManager } from "@warlock.js/core";
537
+ import { ${name.pascal} } from "../models/${name.kebab}";
538
+
539
+ export class ${name.pascal}Repository extends RepositoryManager<${name.pascal}> {
540
+ public source = ${name.pascal};
541
+
542
+ protected defaultOptions: RepositoryOptions = this.withDefaultOptions({});
543
+
544
+ protected filterBy: FilterByOptions = this.withDefaultFilters({
545
+ name: "like",
546
+ });
547
+ }
548
+
549
+ export const ${name.camel}Repository = new ${name.pascal}Repository();
550
+ `;
551
+ }
552
+ /**
553
+ * Resource template stub
554
+ */
555
+ function resourceStub(name) {
556
+ return `import { Resource } from "@warlock.js/core";
557
+
558
+ export class ${name.pascal}Resource extends Resource {
559
+ public schema = {
560
+ id: "int",
561
+ name: "string",
562
+ // TODO: Define resource schema
563
+ };
564
+ }
565
+ `;
566
+ }
567
+ /**
568
+ * Migration template stub
569
+ */export{controllerStub,crudCreateControllerStub,crudCreateServiceStub,crudCreateValidationStub,crudDeleteControllerStub,crudDeleteServiceStub,crudGetServiceStub,crudListControllerStub,crudListServiceStub,crudModelStub,crudRepositoryStub,crudResourceStub,crudRoutesStub,crudSeedStub,crudShowControllerStub,crudUpdateControllerStub,crudUpdateServiceStub,crudUpdateValidationStub,migrationStub,modelStub,repositoryStub,requestStub,resourceStub,serviceStub,validationStub};//# sourceMappingURL=stubs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubs.js","sources":["../../../../../src/cli/commands/generate/templates/stubs.ts"],"sourcesContent":[null],"names":[],"mappings":"gDAGA;;AAEG;SACa,cAAc,CAC5B,IAAgB,EAChB,UAAwC,EAAE,EAAA;AAE1C,IAAA,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAEnC,OAAO,CAAA;EAEP,cAAc;UACV,iBAAiB,IAAI,CAAC,MAAM,CAA+B,4BAAA,EAAA,IAAI,CAAC,KAAK,CAAA;AAChE,SAAA,EAAA,IAAI,CAAC,KAAK,CAAA,6BAAA,EAA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,CAAA;;AAEM,aAAA,EAAA,IAAI,CAAC,MAAM,CAAA;;;;;;;CAOzB,CAAC;AACF,CAAC;AAED;;AAEG"}
@@ -0,0 +1,53 @@
1
+ export interface Generator {
2
+ name: string;
3
+ description: string;
4
+ generate(options: GeneratorOptions): Promise<void>;
5
+ }
6
+ export interface GeneratorOptions {
7
+ /**
8
+ * The name of the component to generate
9
+ * For module: "users"
10
+ * For controller: "create-user"
11
+ */
12
+ name: string;
13
+ /**
14
+ * The module name (for non-module generators)
15
+ * Example: "users", "posts"
16
+ */
17
+ module?: string;
18
+ /**
19
+ * Flags passed from CLI
20
+ */
21
+ flags: Record<string, boolean>;
22
+ /**
23
+ * Raw arguments from CLI
24
+ */
25
+ args: string[];
26
+ }
27
+ export interface ParsedName {
28
+ /**
29
+ * Original input
30
+ */
31
+ raw: string;
32
+ /**
33
+ * PascalCase: CreateUser
34
+ */
35
+ pascal: string;
36
+ /**
37
+ * camelCase: createUser
38
+ */
39
+ camel: string;
40
+ /**
41
+ * kebab-case: create-user
42
+ */
43
+ kebab: string;
44
+ /**
45
+ * snake_case: create_user
46
+ */
47
+ snake: string;
48
+ /**
49
+ * Module name (if applicable)
50
+ */
51
+ module?: string;
52
+ }
53
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/generate/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,45 @@
1
+ import type { ParsedName } from "../types";
2
+ /**
3
+ * Parse module path from input
4
+ * Examples:
5
+ * - "users/create-user" → { module: "users", name: "create-user" }
6
+ * - "create-user" → { module: undefined, name: "create-user" }
7
+ */
8
+ export declare function parseModulePath(input: string): {
9
+ module?: string;
10
+ name: string;
11
+ };
12
+ /**
13
+ * Convert string to PascalCase
14
+ * Examples:
15
+ * - "create-user" → "CreateUser"
16
+ * - "create_user" → "CreateUser"
17
+ * - "createUser" → "CreateUser"
18
+ */
19
+ export declare function toPascalCase(str: string): string;
20
+ /**
21
+ * Convert string to camelCase
22
+ * Examples:
23
+ * - "create-user" → "createUser"
24
+ * - "CreateUser" → "createUser"
25
+ */
26
+ export declare function toCamelCase(str: string): string;
27
+ /**
28
+ * Convert string to kebab-case
29
+ * Examples:
30
+ * - "CreateUser" → "create-user"
31
+ * - "createUser" → "create-user"
32
+ */
33
+ export declare function toKebabCase(str: string): string;
34
+ /**
35
+ * Convert string to snake_case
36
+ * Examples:
37
+ * - "CreateUser" → "create_user"
38
+ * - "create-user" → "create_user"
39
+ */
40
+ export declare function toSnakeCase(str: string): string;
41
+ /**
42
+ * Parse name into all case variants
43
+ */
44
+ export declare function parseName(input: string, module?: string): ParsedName;
45
+ //# sourceMappingURL=name-parser.d.ts.map