@solid-stack/mason 1.0.11

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 (111) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +238 -0
  3. package/dist/bin.cjs +3480 -0
  4. package/dist/bin.cjs.map +1 -0
  5. package/dist/bin.d.ts +3 -0
  6. package/dist/bin.d.ts.map +1 -0
  7. package/dist/bin.js +3451 -0
  8. package/dist/bin.js.map +1 -0
  9. package/dist/cli.d.ts +3 -0
  10. package/dist/cli.d.ts.map +1 -0
  11. package/dist/commands/create.d.ts +2 -0
  12. package/dist/commands/create.d.ts.map +1 -0
  13. package/dist/commands/domain.d.ts +2 -0
  14. package/dist/commands/domain.d.ts.map +1 -0
  15. package/dist/commands/feature.d.ts +2 -0
  16. package/dist/commands/feature.d.ts.map +1 -0
  17. package/dist/commands/httpHandler.d.ts +2 -0
  18. package/dist/commands/httpHandler.d.ts.map +1 -0
  19. package/dist/commands/import.d.ts +10 -0
  20. package/dist/commands/import.d.ts.map +1 -0
  21. package/dist/commands/infrastructure.d.ts +2 -0
  22. package/dist/commands/infrastructure.d.ts.map +1 -0
  23. package/dist/commands/injectable.d.ts +2 -0
  24. package/dist/commands/injectable.d.ts.map +1 -0
  25. package/dist/commands/interface.d.ts +2 -0
  26. package/dist/commands/interface.d.ts.map +1 -0
  27. package/dist/commands/menu.d.ts +2 -0
  28. package/dist/commands/menu.d.ts.map +1 -0
  29. package/dist/commands/usecase.d.ts +2 -0
  30. package/dist/commands/usecase.d.ts.map +1 -0
  31. package/dist/core/domainGenerator.d.ts +4 -0
  32. package/dist/core/domainGenerator.d.ts.map +1 -0
  33. package/dist/core/featureGenerator.d.ts +3 -0
  34. package/dist/core/featureGenerator.d.ts.map +1 -0
  35. package/dist/core/httpHandlerGenerator.d.ts +8 -0
  36. package/dist/core/httpHandlerGenerator.d.ts.map +1 -0
  37. package/dist/core/infraGenerator.d.ts +60 -0
  38. package/dist/core/infraGenerator.d.ts.map +1 -0
  39. package/dist/core/injectableGenerator.d.ts +4 -0
  40. package/dist/core/injectableGenerator.d.ts.map +1 -0
  41. package/dist/core/interfaceGenerator.d.ts +4 -0
  42. package/dist/core/interfaceGenerator.d.ts.map +1 -0
  43. package/dist/core/providerManager.d.ts +16 -0
  44. package/dist/core/providerManager.d.ts.map +1 -0
  45. package/dist/core/useCaseGenerator.d.ts +5 -0
  46. package/dist/core/useCaseGenerator.d.ts.map +1 -0
  47. package/dist/index.cjs +3545 -0
  48. package/dist/index.cjs.map +1 -0
  49. package/dist/index.d.ts +19 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +3444 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/templates/domain/class.hbs +17 -0
  54. package/dist/templates/domain/interface.hbs +5 -0
  55. package/dist/templates/domain/valueObject.hbs +15 -0
  56. package/dist/templates/domain.template.d.ts +4 -0
  57. package/dist/templates/domain.template.d.ts.map +1 -0
  58. package/dist/templates/engine.d.ts +20 -0
  59. package/dist/templates/engine.d.ts.map +1 -0
  60. package/dist/templates/express/index.hbs +1 -0
  61. package/dist/templates/expressIndex.template.d.ts +2 -0
  62. package/dist/templates/expressIndex.template.d.ts.map +1 -0
  63. package/dist/templates/httpHandler/handler.hbs +71 -0
  64. package/dist/templates/httpHandler.template.d.ts +2 -0
  65. package/dist/templates/httpHandler.template.d.ts.map +1 -0
  66. package/dist/templates/index.d.ts +10 -0
  67. package/dist/templates/index.d.ts.map +1 -0
  68. package/dist/templates/infra/concrete.hbs +29 -0
  69. package/dist/templates/infra/stub.hbs +103 -0
  70. package/dist/templates/infra.template.d.ts +3 -0
  71. package/dist/templates/infra.template.d.ts.map +1 -0
  72. package/dist/templates/injectable/injectable.hbs +32 -0
  73. package/dist/templates/injectable/interface.hbs +3 -0
  74. package/dist/templates/injectable.template.d.ts +3 -0
  75. package/dist/templates/injectable.template.d.ts.map +1 -0
  76. package/dist/templates/interface/interface.hbs +19 -0
  77. package/dist/templates/interface.template.d.ts +2 -0
  78. package/dist/templates/interface.template.d.ts.map +1 -0
  79. package/dist/templates/provider/provider.hbs +13 -0
  80. package/dist/templates/provider.template.d.ts +2 -0
  81. package/dist/templates/provider.template.d.ts.map +1 -0
  82. package/dist/templates/useCase/useCase.hbs +57 -0
  83. package/dist/templates/useCase/useCaseTest.hbs +24 -0
  84. package/dist/templates/useCase.template.d.ts +3 -0
  85. package/dist/templates/useCase.template.d.ts.map +1 -0
  86. package/dist/types/index.d.ts +129 -0
  87. package/dist/types/index.d.ts.map +1 -0
  88. package/dist/utils/fileOperations.d.ts +8 -0
  89. package/dist/utils/fileOperations.d.ts.map +1 -0
  90. package/dist/utils/formatting.d.ts +43 -0
  91. package/dist/utils/formatting.d.ts.map +1 -0
  92. package/dist/utils/project.d.ts +37 -0
  93. package/dist/utils/project.d.ts.map +1 -0
  94. package/dist/utils/prompts.d.ts +14 -0
  95. package/dist/utils/prompts.d.ts.map +1 -0
  96. package/dist/utils/registry.d.ts +61 -0
  97. package/dist/utils/registry.d.ts.map +1 -0
  98. package/package.json +84 -0
  99. package/templates/domain/class.hbs +17 -0
  100. package/templates/domain/interface.hbs +5 -0
  101. package/templates/domain/valueObject.hbs +15 -0
  102. package/templates/express/index.hbs +1 -0
  103. package/templates/httpHandler/handler.hbs +71 -0
  104. package/templates/infra/concrete.hbs +29 -0
  105. package/templates/infra/stub.hbs +103 -0
  106. package/templates/injectable/injectable.hbs +32 -0
  107. package/templates/injectable/interface.hbs +3 -0
  108. package/templates/interface/interface.hbs +19 -0
  109. package/templates/provider/provider.hbs +13 -0
  110. package/templates/useCase/useCase.hbs +57 -0
  111. package/templates/useCase/useCaseTest.hbs +24 -0
@@ -0,0 +1,17 @@
1
+ export interface {{name}}Props {
2
+ {{#each properties}}
3
+ {{name}}{{#if optional}}?{{/if}}: {{type}};
4
+ {{/each}}
5
+ }
6
+
7
+ export class {{name}} {
8
+ {{#each properties}}
9
+ public {{name}}{{#if optional}}?{{/if}}: {{type}};
10
+ {{/each}}
11
+
12
+ constructor(props: {{name}}Props) {
13
+ {{#each properties}}
14
+ this.{{name}} = props.{{name}};
15
+ {{/each}}
16
+ }
17
+ }
@@ -0,0 +1,5 @@
1
+ export interface {{name}} {
2
+ {{#each properties}}
3
+ {{name}}{{#if optional}}?{{/if}}: {{type}};
4
+ {{/each}}
5
+ }
@@ -0,0 +1,15 @@
1
+ export class {{name}} {
2
+ private constructor(public readonly {{valueProp.name}}: {{valueProp.type}}) {}
3
+
4
+ public static create({{valueProp.name}}: {{valueProp.type}}): {{name}} {
5
+ if ({{valueProp.name}} === undefined || {{valueProp.name}} === null) {
6
+ throw new Error("Value is required for {{name}}");
7
+ }
8
+ return new {{name}}({{valueProp.name}});
9
+ }
10
+
11
+ public equals(other?: {{name}}): boolean {
12
+ if (!other) return false;
13
+ return this.{{valueProp.name}} === other.{{valueProp.name}};
14
+ }
15
+ }
@@ -0,0 +1,4 @@
1
+ export declare const domainInterfaceTemplate: string;
2
+ export declare const domainClassTemplate: string;
3
+ export declare const domainValueObjectTemplate: string;
4
+ //# sourceMappingURL=domain.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain.template.d.ts","sourceRoot":"","sources":["../../src/templates/domain.template.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,QAAuC,CAAC;AAC5E,eAAO,MAAM,mBAAmB,QAAmC,CAAC;AACpE,eAAO,MAAM,yBAAyB,QAAyC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import Handlebars from "handlebars";
2
+ export declare const hbs: typeof Handlebars;
3
+ /**
4
+ * Resolves the absolute path to the templates directory across development and production builds.
5
+ */
6
+ export declare function getTemplatesDir(): string;
7
+ /**
8
+ * Reads a .hbs template file from the templates directory.
9
+ */
10
+ export declare function loadTemplate(relativePath: string): string;
11
+ /**
12
+ * Compiles and renders a Handlebars .hbs template file from disk with caching and noEscape.
13
+ */
14
+ export declare function renderTemplateFile<T extends object>(relativePath: string, context: T): string;
15
+ /**
16
+ * Compiles and renders a Handlebars template string or .hbs file path with HTML escaping disabled.
17
+ * Caches compiled templates for maximum performance.
18
+ */
19
+ export declare function renderTemplate<T extends object>(sourceOrPath: string, context: T): string;
20
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/templates/engine.ts"],"names":[],"mappings":"AAGA,OAAO,UAAU,MAAM,YAAY,CAAC;AAIpC,eAAO,MAAM,GAAG,mBAAsB,CAAC;AAmBvC;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CA4CxC;AAID;;GAEG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAS7F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAYzF"}
@@ -0,0 +1 @@
1
+ export const path = "{{routePath}}";
@@ -0,0 +1,2 @@
1
+ export declare const expressIndexTemplate: string;
2
+ //# sourceMappingURL=expressIndex.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expressIndex.template.d.ts","sourceRoot":"","sources":["../../src/templates/expressIndex.template.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,QAAoC,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { ExpressRoute } from "@solid-stack/agnos-express";
2
+ import { MakeInjectable, type DepsType } from "@solid-stack/di";
3
+ import type { Request, Response } from "express";
4
+ {{#if includeValidation}}
5
+ import { z } from "zod";
6
+ {{/if}}
7
+ {{#if ucName}}
8
+ import { {{ucName}} } from "../../useCases/{{ucName}}.js";
9
+ {{/if}}
10
+
11
+ export type HttpResponseStatus = "info" | "success" | "redirect" | "fail" | "error";
12
+
13
+ export interface HttpResponse<T = object> {
14
+ status: HttpResponseStatus;
15
+ message: string;
16
+ data?: T;
17
+ }
18
+
19
+ {{#if includeValidation}}
20
+ const {{schemaName}} = z.object({
21
+ {{#if hasValidationFields}}
22
+ {{#each validationFields}}
23
+ {{name}}: {{{zodType}}},
24
+ {{/each}}
25
+ {{else}}
26
+ // TODO: define schema properties
27
+ example: z.string().optional(),
28
+ {{/if}}
29
+ });
30
+
31
+ {{/if}}
32
+ @MakeInjectable
33
+ export default class {{className}} extends ExpressRoute {
34
+ public static deps = {
35
+ {{#if ucName}}
36
+ {{ucDepKey}}: {{ucName}},
37
+ {{/if}}
38
+ };
39
+
40
+ constructor(public deps: DepsType<typeof {{className}}.deps>) {
41
+ super();
42
+ }
43
+
44
+ public method = "{{method}}" as const;
45
+ public path = "{{routeSubPath}}";
46
+ public handler = async (req: Request, res: Response) => {
47
+ {{#if includeValidation}}
48
+ const parsed = {{schemaName}}.safeParse(req.{{validationSource}});
49
+ if (!parsed.success) {
50
+ return res.status(400).json({
51
+ status: "error",
52
+ message: "Validation failed",
53
+ data: parsed.error.format(),
54
+ });
55
+ }
56
+ {{/if}}
57
+ {{#if ucName}}
58
+ const result = await this.deps.{{ucDepKey}}.execute({{callArg}});
59
+ return res.status({{statusCode}}).json({
60
+ status: "success",
61
+ message: "{{successMessage}}",
62
+ data: result,
63
+ });
64
+ {{else}}
65
+ return res.status(200).json({
66
+ status: "success",
67
+ message: "{{successMessage}}",
68
+ });
69
+ {{/if}}
70
+ };
71
+ }
@@ -0,0 +1,2 @@
1
+ export declare const httpHandlerTemplate: string;
2
+ //# sourceMappingURL=httpHandler.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpHandler.template.d.ts","sourceRoot":"","sources":["../../src/templates/httpHandler.template.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,QAA0C,CAAC"}
@@ -0,0 +1,10 @@
1
+ export * from "./engine.js";
2
+ export * from "./domain.template.js";
3
+ export * from "./interface.template.js";
4
+ export * from "./useCase.template.js";
5
+ export * from "./infra.template.js";
6
+ export * from "./httpHandler.template.js";
7
+ export * from "./injectable.template.js";
8
+ export * from "./provider.template.js";
9
+ export * from "./expressIndex.template.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { MakeInjectable, type DepsType } from "@solid-stack/di";
2
+ {{#if ifaceName}}
3
+ import { {{ifaceName}} } from "{{ifaceImportPath}}";
4
+ {{/if}}
5
+ {{#each domainImports}}
6
+ import {{#if isTypeOnly}}type {{/if}}{ {{names}} } from "{{from}}";
7
+ {{/each}}
8
+
9
+ @MakeInjectable
10
+ export class {{className}}{{#if ifaceName}} implements {{ifaceName}}{{/if}} {
11
+ public static deps = {
12
+ {{#each dependencies}}
13
+ {{key}}: {{name}},
14
+ {{/each}}
15
+ };
16
+
17
+ constructor(public deps: DepsType<typeof {{className}}.deps>) {}
18
+ {{#if hasMethods}}
19
+ {{#each methods}}
20
+
21
+ {{#if isAsync}}async {{/if}}{{name}}{{{typeParams}}}({{{params}}}): {{{returnType}}} {
22
+ throw new Error("not implemented");
23
+ }
24
+ {{/each}}
25
+ {{else}}
26
+
27
+ // Implement your infrastructure methods here
28
+ {{/if}}
29
+ }
@@ -0,0 +1,103 @@
1
+ import { MakeInjectable, type DepsType } from "@solid-stack/di";
2
+ import { {{ifaceName}} } from "{{ifaceImportPath}}";
3
+ {{#if baseEntity}}
4
+ import type { {{baseEntity}} } from "{{entityImportPath}}";
5
+ {{/if}}
6
+ {{#each domainImports}}
7
+ import {{#if isTypeOnly}}type {{/if}}{ {{names}} } from "{{from}}";
8
+ {{/each}}
9
+
10
+ @MakeInjectable
11
+ export class {{stubClassName}} implements {{ifaceName}} {
12
+ public static deps = {};
13
+ {{#if baseEntity}}
14
+
15
+ private {{entitiesVar}}: Map<string, {{baseEntity}}> = new Map();
16
+ private errorToThrow: Error | null = null;
17
+
18
+ constructor(public deps: DepsType<typeof {{stubClassName}}.deps>) {}
19
+
20
+ // --- Test Helpers ---
21
+ public clear(): void {
22
+ this.{{entitiesVar}}.clear();
23
+ this.errorToThrow = null;
24
+ }
25
+
26
+ public add{{baseEntity}}({{entityVar}}: {{baseEntity}}): void {
27
+ this.{{entitiesVar}}.set({{entityVar}}.id, { ...{{entityVar}} });
28
+ }
29
+
30
+ public get{{baseEntity}}s(): {{baseEntity}}[] {
31
+ return Array.from(this.{{entitiesVar}}.values()).map((e) => ({ ...e }));
32
+ }
33
+
34
+ public setError(error: Error | null): void {
35
+ this.errorToThrow = error;
36
+ }
37
+
38
+ // --- {{ifaceName}} Methods ---
39
+ async Get{{baseEntity}}ById(input: { {{idKey}}: string }): Promise<{ {{entityVar}}: {{baseEntity}} }> {
40
+ if (this.errorToThrow) throw this.errorToThrow;
41
+ const found = this.{{entitiesVar}}.get(input.{{idKey}});
42
+ if (!found) throw new Error("{{baseEntity}} with ID " + input.{{idKey}} + " not found");
43
+ return { {{entityVar}}: { ...found } };
44
+ }
45
+
46
+ async List{{baseEntity}}s(input?: { page?: number | undefined; limit?: number | undefined }): Promise<{ {{entitiesVar}}: {{baseEntity}}[]; total?: number | undefined; page?: number | undefined; limit?: number | undefined }> {
47
+ if (this.errorToThrow) throw this.errorToThrow;
48
+ let all = this.get{{baseEntity}}s();
49
+ const total = all.length;
50
+ if (input?.page && input?.limit) {
51
+ const start = (input.page - 1) * input.limit;
52
+ all = all.slice(start, start + input.limit);
53
+ return { {{entitiesVar}}: all, total, page: input.page, limit: input.limit };
54
+ }
55
+ return { {{entitiesVar}}: all, total };
56
+ }
57
+
58
+ async Create{{baseEntity}}(input: { {{entityVar}}: {{baseEntity}} }): Promise<{ {{entityVar}}: {{baseEntity}} }> {
59
+ if (this.errorToThrow) throw this.errorToThrow;
60
+ const entity = { ...input.{{entityVar}} };
61
+ this.{{entitiesVar}}.set(entity.id, entity);
62
+ return { {{entityVar}}: { ...entity } };
63
+ }
64
+
65
+ async Update{{baseEntity}}(input: { {{entityVar}}: {{baseEntity}} }): Promise<{ {{entityVar}}: {{baseEntity}} }> {
66
+ if (this.errorToThrow) throw this.errorToThrow;
67
+ if (!this.{{entitiesVar}}.has(input.{{entityVar}}.id)) {
68
+ throw new Error("{{baseEntity}} with ID " + input.{{entityVar}}.id + " not found");
69
+ }
70
+ const entity = { ...input.{{entityVar}} };
71
+ this.{{entitiesVar}}.set(entity.id, entity);
72
+ return { {{entityVar}}: { ...entity } };
73
+ }
74
+
75
+ async Delete{{baseEntity}}(input: { {{idKey}}: string }): Promise<{ success: boolean }> {
76
+ if (this.errorToThrow) throw this.errorToThrow;
77
+ this.{{entitiesVar}}.delete(input.{{idKey}});
78
+ return { success: true };
79
+ }
80
+ {{#each extraMethods}}
81
+
82
+ {{#if isAsync}}async {{/if}}{{name}}{{{typeParams}}}({{{params}}}): {{{returnType}}} {
83
+ throw new Error("not implemented");
84
+ }
85
+ {{/each}}
86
+ {{else}}
87
+
88
+ constructor(public deps: DepsType<typeof {{stubClassName}}.deps>) {}
89
+ {{#if hasMethods}}
90
+ {{#each methods}}
91
+
92
+ {{#if isAsync}}async {{/if}}{{name}}{{{typeParams}}}({{{params}}}): {{{returnType}}} {
93
+ throw new Error("not implemented");
94
+ }
95
+ {{/each}}
96
+ {{else}}
97
+
98
+ async execute(input?: unknown): Promise<unknown> {
99
+ throw new Error("{{stubClassName}}.execute not implemented");
100
+ }
101
+ {{/if}}
102
+ {{/if}}
103
+ }
@@ -0,0 +1,3 @@
1
+ export declare const concreteInfraTemplate: string;
2
+ export declare const stubInfraTemplate: string;
3
+ //# sourceMappingURL=infra.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infra.template.d.ts","sourceRoot":"","sources":["../../src/templates/infra.template.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,QAAqC,CAAC;AACxE,eAAO,MAAM,iBAAiB,QAAiC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { MakeInjectable, type DepsType } from "@solid-stack/di";
2
+ {{#if implementsInterface}}
3
+ import { {{implementsInterface}} } from "./{{implementsInterface}}.js";
4
+ {{/if}}
5
+
6
+ @MakeInjectable
7
+ export class {{className}}{{#if implementsInterface}} implements {{implementsInterface}}{{/if}} {
8
+ public static deps = {
9
+ {{#each dependencies}}
10
+ {{key}}: {{name}},
11
+ {{/each}}
12
+ };
13
+
14
+ {{#if hasDependencies}}
15
+ constructor(public deps: DepsType<typeof {{className}}.deps>) {}
16
+ {{else}}
17
+ constructor() {}
18
+ {{/if}}
19
+
20
+ {{#if hasMethods}}
21
+ {{#each methods}}
22
+ public {{#if isAsync}}async {{/if}}{{name}}({{{params}}}): {{{returnType}}} {
23
+ // TODO: implement method logic
24
+ }
25
+
26
+ {{/each}}
27
+ {{else}}
28
+ public execute(): void {
29
+ // TODO: implement logic
30
+ }
31
+ {{/if}}
32
+ }
@@ -0,0 +1,3 @@
1
+ export abstract class {{ifaceName}} {
2
+ abstract execute(): void;
3
+ }
@@ -0,0 +1,3 @@
1
+ export declare const injectableTemplate: string;
2
+ export declare const injectableInterfaceTemplate: string;
3
+ //# sourceMappingURL=injectable.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectable.template.d.ts","sourceRoot":"","sources":["../../src/templates/injectable.template.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,QAA4C,CAAC;AAC5E,eAAO,MAAM,2BAA2B,QAA2C,CAAC"}
@@ -0,0 +1,19 @@
1
+ {{#if domainImport}}
2
+ import type { {{domainImport}} } from "./{{domainImport}}.js";
3
+
4
+ {{/if}}
5
+ export {{#if isAbstractClass}}abstract class{{else}}interface{{/if}} {{ifaceName}} {
6
+ {{#if isCrud}}
7
+ {{methodPrefix}}Get{{baseEntity}}ById(input: { {{idKey}}: string }): Promise<{ {{entityKey}}: {{baseEntity}} }>;
8
+ {{methodPrefix}}List{{baseEntity}}s(input?: { page?: number | undefined; limit?: number | undefined }): Promise<{ {{listKey}}: {{baseEntity}}[]; total?: number | undefined; page?: number | undefined; limit?: number | undefined }>;
9
+ {{methodPrefix}}Create{{baseEntity}}(input: { {{entityKey}}: {{baseEntity}} }): Promise<{ {{entityKey}}: {{baseEntity}} }>;
10
+ {{methodPrefix}}Update{{baseEntity}}(input: { {{entityKey}}: {{baseEntity}} }): Promise<{ {{entityKey}}: {{baseEntity}} }>;
11
+ {{methodPrefix}}Delete{{baseEntity}}(input: { {{idKey}}: string }): Promise<{ success: boolean }>;
12
+ {{else if isCustom}}
13
+ {{#each customMethods}}
14
+ {{../methodPrefix}}{{name}}({{#if params}}input: { {{params}} }{{/if}}): {{returnType}};
15
+ {{/each}}
16
+ {{else}}
17
+ {{methodPrefix}}execute(input?: unknown): Promise<unknown>;
18
+ {{/if}}
19
+ }
@@ -0,0 +1,2 @@
1
+ export declare const interfaceTemplate: string;
2
+ //# sourceMappingURL=interface.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.template.d.ts","sourceRoot":"","sources":["../../src/templates/interface.template.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAA0C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Container, DIModule } from "@solid-stack/di";
2
+ {{#each bindings}}
3
+ import { {{ifaceName}} } from "{{ifaceImportPath}}";
4
+ import { {{implName}} } from "{{implImportPath}}";
5
+ {{/each}}
6
+
7
+ export const {{providerModuleName}}: DIModule = (c: Container) => {
8
+ {{#each bindings}}
9
+ c.provide({{ifaceName}}, {{implName}});
10
+ {{/each}}
11
+ };
12
+
13
+ export default {{providerModuleName}};
@@ -0,0 +1,2 @@
1
+ export declare const diProviderTemplate: string;
2
+ //# sourceMappingURL=provider.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.template.d.ts","sourceRoot":"","sources":["../../src/templates/provider.template.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,QAAwC,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { MakeInjectable, type DepsType } from "@solid-stack/di";
2
+ {{#each dependencyImports}}
3
+ import { {{name}} } from "{{from}}";
4
+ {{/each}}
5
+ {{#each domainImports}}
6
+ import type { {{this}} } from "../domain/{{this}}.js";
7
+ {{/each}}
8
+
9
+ {{#if hasInputProps}}
10
+ export type {{inputTypeName}} = {
11
+ {{#each inputProperties}}
12
+ {{name}}{{#if optional}}?{{/if}}: {{type}};
13
+ {{/each}}
14
+ };
15
+ {{else}}
16
+ export type {{inputTypeName}} = Record<string, never>;
17
+ {{/if}}
18
+
19
+ {{#if hasOutputProps}}
20
+ export type {{outputTypeName}} = {
21
+ {{#each outputProperties}}
22
+ {{name}}{{#if optional}}?{{/if}}: {{type}};
23
+ {{/each}}
24
+ };
25
+ {{else}}
26
+ export type {{outputTypeName}} = {
27
+ success: boolean;
28
+ };
29
+ {{/if}}
30
+
31
+ @MakeInjectable
32
+ export class {{ucName}} {
33
+ public static deps = {
34
+ {{#each dependencies}}
35
+ {{key}}: {{name}},
36
+ {{/each}}
37
+ };
38
+
39
+ {{#if hasDependencies}}
40
+ constructor(public deps: DepsType<typeof {{ucName}}.deps>) {}
41
+ {{else}}
42
+ constructor() {}
43
+ {{/if}}
44
+
45
+ async execute({{paramStr}}): Promise<{{outputTypeName}}> {
46
+ {{#if callWired}}
47
+ {{{callWired}}}
48
+ {{else}}
49
+ // TODO: Implement use case business logic
50
+ {{#if hasOutputProps}}
51
+ throw new Error("{{ucName}} not implemented");
52
+ {{else}}
53
+ return { success: true };
54
+ {{/if}}
55
+ {{/if}}
56
+ }
57
+ }
@@ -0,0 +1,24 @@
1
+ import { describe, it, expect, beforeEach } from "vitest";
2
+ import { Container } from "@solid-stack/di";
3
+ import { {{ucName}} } from "./{{ucName}}.js";
4
+ {{#each stubBindings}}
5
+ import { {{iface}} } from "../domain/{{iface}}.js";
6
+ import { {{stub}} } from "../infrastructure/{{stub}}.js";
7
+ {{/each}}
8
+
9
+ describe("{{ucName}} Use Case", () => {
10
+ let container: Container;
11
+ let useCase: {{ucName}};
12
+
13
+ beforeEach(() => {
14
+ container = new Container();
15
+ {{#each stubBindings}}
16
+ container.provide({{iface}}, {{stub}});
17
+ {{/each}}
18
+ useCase = container.resolve({{ucName}});
19
+ });
20
+
21
+ it("should be successfully resolved from DI container", () => {
22
+ expect(useCase).toBeDefined();
23
+ });
24
+ });
@@ -0,0 +1,3 @@
1
+ export declare const useCaseTemplate: string;
2
+ export declare const useCaseTestTemplate: string;
3
+ //# sourceMappingURL=useCase.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCase.template.d.ts","sourceRoot":"","sources":["../../src/templates/useCase.template.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,QAAsC,CAAC;AACnE,eAAO,MAAM,mBAAmB,QAA0C,CAAC"}
@@ -0,0 +1,129 @@
1
+ export type ActionType = "created" | "overwritten" | "skipped" | "preview";
2
+ export interface GeneratedFile {
3
+ relativePath: string;
4
+ absolutePath: string;
5
+ content: string;
6
+ action: ActionType;
7
+ existedBefore: boolean;
8
+ }
9
+ export interface CommonGeneratorOptions {
10
+ projectRoot?: string | undefined;
11
+ targetDir?: string | undefined;
12
+ dryRun?: boolean | undefined;
13
+ overwrite?: boolean | undefined;
14
+ yes?: boolean | undefined;
15
+ }
16
+ export interface PropertyDef {
17
+ name: string;
18
+ type: string;
19
+ optional?: boolean | undefined;
20
+ }
21
+ export interface MethodDef {
22
+ name: string;
23
+ params?: PropertyDef[] | undefined;
24
+ returnType?: string | undefined;
25
+ async?: boolean | undefined;
26
+ }
27
+ export type CrudOperation = "create" | "read" | "list" | "update" | "delete";
28
+ export interface CustomUseCaseConfig {
29
+ name: string;
30
+ dependencies?: string[] | undefined;
31
+ inputProperties?: PropertyDef[] | undefined;
32
+ outputProperties?: PropertyDef[] | undefined;
33
+ domainImports?: string[] | undefined;
34
+ includeTest?: boolean | undefined;
35
+ createHttpHandler?: boolean | undefined;
36
+ httpMethod?: ("get" | "post" | "put" | "patch" | "delete") | undefined;
37
+ httpPath?: string | undefined;
38
+ validationSource?: ("body" | "query" | "params") | undefined;
39
+ validationFields?: PropertyDef[] | undefined;
40
+ }
41
+ export interface FeatureOptions extends CommonGeneratorOptions {
42
+ name: string;
43
+ includeExpress?: boolean | undefined;
44
+ routePath?: string | undefined;
45
+ includeDomain?: boolean | undefined;
46
+ entityName?: string | undefined;
47
+ entityNames?: string[] | undefined;
48
+ includeInterface?: boolean | undefined;
49
+ interfaceName?: string | undefined;
50
+ includeInfra?: boolean | undefined;
51
+ stubName?: string | undefined;
52
+ includeUseCase?: boolean | undefined;
53
+ crudOperations?: CrudOperation[] | undefined;
54
+ customUseCases?: CustomUseCaseConfig[] | undefined;
55
+ useCaseName?: string | undefined;
56
+ includeHttpHandler?: boolean | undefined;
57
+ httpHandlerName?: string | undefined;
58
+ includeTests?: boolean | undefined;
59
+ includeDiProvider?: boolean | undefined;
60
+ }
61
+ export interface UseCaseOptions extends CommonGeneratorOptions {
62
+ name: string;
63
+ feature: string;
64
+ dependencies?: string[] | undefined;
65
+ inputProperties?: PropertyDef[] | undefined;
66
+ outputProperties?: PropertyDef[] | undefined;
67
+ domainImports?: string[] | undefined;
68
+ includeTest?: boolean | undefined;
69
+ createHttpHandler?: boolean | undefined;
70
+ httpMethod?: ("get" | "post" | "put" | "patch" | "delete") | undefined;
71
+ httpPath?: string | undefined;
72
+ }
73
+ export interface DomainOptions extends CommonGeneratorOptions {
74
+ name: string;
75
+ feature: string;
76
+ kind?: ("interface" | "class" | "valueObject") | undefined;
77
+ properties?: PropertyDef[] | undefined;
78
+ }
79
+ export interface InterfaceOptions extends CommonGeneratorOptions {
80
+ name: string;
81
+ feature: string;
82
+ kind?: ("abstractClass" | "interface") | undefined;
83
+ entityName?: string | undefined;
84
+ methodsPreset?: ("crud" | "custom" | "empty") | undefined;
85
+ customMethods?: MethodDef[] | undefined;
86
+ generateStub?: boolean | undefined;
87
+ stubName?: string | undefined;
88
+ registerInProvider?: boolean | undefined;
89
+ }
90
+ export interface InfrastructureOptions extends CommonGeneratorOptions {
91
+ name: string;
92
+ feature?: string | undefined;
93
+ scope?: ("feature" | "global") | undefined;
94
+ kind?: ("stub" | "concrete") | undefined;
95
+ implementsInterface?: string | undefined;
96
+ interfacePath?: string | undefined;
97
+ entityName?: string | undefined;
98
+ dependencies?: string[] | undefined;
99
+ registerInProvider?: boolean | undefined;
100
+ }
101
+ export type HttpResponseStatus = "info" | "success" | "redirect" | "fail" | "error";
102
+ export interface HttpResponse<T = object> {
103
+ status: HttpResponseStatus;
104
+ message: string;
105
+ data?: T;
106
+ }
107
+ export interface HttpHandlerOptions extends CommonGeneratorOptions {
108
+ name: string;
109
+ feature: string;
110
+ routePrefix?: string | undefined;
111
+ method?: ("get" | "post" | "put" | "patch" | "delete") | undefined;
112
+ path?: string | undefined;
113
+ useCaseName?: string | undefined;
114
+ useCasePath?: string | undefined;
115
+ includeValidation?: boolean | undefined;
116
+ validationSource?: ("body" | "query" | "params") | undefined;
117
+ validationFields?: PropertyDef[] | undefined;
118
+ successMessage?: string | undefined;
119
+ }
120
+ export interface InjectableOptions extends CommonGeneratorOptions {
121
+ name: string;
122
+ feature?: string | undefined;
123
+ location?: ("feature-service" | "feature-transformer" | "shared" | "module" | "custom") | undefined;
124
+ customPath?: string | undefined;
125
+ dependencies?: string[] | undefined;
126
+ methods?: MethodDef[] | undefined;
127
+ generateInterface?: boolean | undefined;
128
+ }
129
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @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