@apso/cli 0.7.4 → 0.8.2

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 (203) hide show
  1. package/dist/autogen/index.d.ts +2 -0
  2. package/dist/autogen/index.js +3 -0
  3. package/dist/commands/server/new.d.ts +4 -1
  4. package/dist/commands/server/new.js +115 -22
  5. package/dist/commands/server/scaffold.d.ts +10 -0
  6. package/dist/commands/server/scaffold.js +200 -10
  7. package/dist/lib/api/client.d.ts +65 -0
  8. package/dist/lib/api/client.js +305 -0
  9. package/dist/lib/api/index.d.ts +8 -0
  10. package/dist/lib/api/index.js +22 -0
  11. package/dist/lib/api/services.d.ts +166 -0
  12. package/dist/lib/api/services.js +202 -0
  13. package/dist/lib/api/types.d.ts +212 -0
  14. package/dist/lib/api/types.js +7 -0
  15. package/dist/lib/apsorc-parser.d.ts +3 -0
  16. package/dist/lib/apsorc-parser.js +4 -0
  17. package/dist/lib/config/index.d.ts +8 -0
  18. package/dist/lib/config/index.js +17 -0
  19. package/dist/lib/config/manager.d.ts +127 -0
  20. package/dist/lib/config/manager.js +304 -0
  21. package/dist/lib/config/paths.d.ts +65 -0
  22. package/dist/lib/config/paths.js +127 -0
  23. package/dist/lib/config/types.d.ts +230 -0
  24. package/dist/lib/config/types.js +30 -0
  25. package/dist/lib/generators/base.d.ts +93 -0
  26. package/dist/lib/generators/base.js +90 -0
  27. package/dist/lib/generators/go.d.ts +37 -0
  28. package/dist/lib/generators/go.js +340 -0
  29. package/dist/lib/generators/index.d.ts +21 -0
  30. package/dist/lib/generators/index.js +51 -0
  31. package/dist/lib/generators/python.d.ts +21 -0
  32. package/dist/lib/generators/python.js +253 -0
  33. package/dist/lib/generators/typescript.d.ts +25 -0
  34. package/dist/lib/generators/typescript.js +373 -0
  35. package/dist/lib/index.d.ts +2 -0
  36. package/dist/lib/index.js +9 -1
  37. package/dist/lib/templates/entities/entity-col-timestamp.eta +9 -2
  38. package/dist/lib/templates/entities/entity-col-timestamptz.eta +9 -2
  39. package/dist/lib/templates/entities/entity.eta +18 -5
  40. package/dist/lib/templates/go/dto/dto-col-array.eta +7 -0
  41. package/dist/lib/templates/go/dto/dto-col-boolean.eta +7 -0
  42. package/dist/lib/templates/go/dto/dto-col-date.eta +7 -0
  43. package/dist/lib/templates/go/dto/dto-col-decimal.eta +7 -0
  44. package/dist/lib/templates/go/dto/dto-col-enum.eta +8 -0
  45. package/dist/lib/templates/go/dto/dto-col-float.eta +7 -0
  46. package/dist/lib/templates/go/dto/dto-col-integer.eta +7 -0
  47. package/dist/lib/templates/go/dto/dto-col-json.eta +7 -0
  48. package/dist/lib/templates/go/dto/dto-col-jsonb.eta +7 -0
  49. package/dist/lib/templates/go/dto/dto-col-numeric.eta +7 -0
  50. package/dist/lib/templates/go/dto/dto-col-string.eta +7 -0
  51. package/dist/lib/templates/go/dto/dto-col-text.eta +7 -0
  52. package/dist/lib/templates/go/dto/dto-col-timestamp.eta +7 -0
  53. package/dist/lib/templates/go/dto/dto-col-timestamptz.eta +7 -0
  54. package/dist/lib/templates/go/dto/dto-col-uuid.eta +7 -0
  55. package/dist/lib/templates/go/dto/dto-col-varchar.eta +7 -0
  56. package/dist/lib/templates/go/dto/dto.eta +78 -0
  57. package/dist/lib/templates/go/enums.eta +44 -0
  58. package/dist/lib/templates/go/handlers/handler.eta +212 -0
  59. package/dist/lib/templates/go/header.eta +3 -0
  60. package/dist/lib/templates/go/index-module.eta +53 -0
  61. package/dist/lib/templates/go/middleware/auth.eta +101 -0
  62. package/dist/lib/templates/go/models/model-col-array.eta +1 -0
  63. package/dist/lib/templates/go/models/model-col-boolean.eta +1 -0
  64. package/dist/lib/templates/go/models/model-col-date.eta +1 -0
  65. package/dist/lib/templates/go/models/model-col-decimal.eta +1 -0
  66. package/dist/lib/templates/go/models/model-col-enum.eta +2 -0
  67. package/dist/lib/templates/go/models/model-col-float.eta +1 -0
  68. package/dist/lib/templates/go/models/model-col-integer.eta +1 -0
  69. package/dist/lib/templates/go/models/model-col-json.eta +1 -0
  70. package/dist/lib/templates/go/models/model-col-jsonb.eta +1 -0
  71. package/dist/lib/templates/go/models/model-col-numeric.eta +1 -0
  72. package/dist/lib/templates/go/models/model-col-string.eta +1 -0
  73. package/dist/lib/templates/go/models/model-col-text.eta +1 -0
  74. package/dist/lib/templates/go/models/model-col-timestamp.eta +1 -0
  75. package/dist/lib/templates/go/models/model-col-timestamptz.eta +1 -0
  76. package/dist/lib/templates/go/models/model-col-uuid.eta +1 -0
  77. package/dist/lib/templates/go/models/model-col-varchar.eta +1 -0
  78. package/dist/lib/templates/go/models/model.eta +53 -0
  79. package/dist/lib/templates/go/services/service.eta +190 -0
  80. package/dist/lib/templates/python/enums.eta +10 -0
  81. package/dist/lib/templates/python/header.eta +6 -0
  82. package/dist/lib/templates/python/index-module.eta +18 -0
  83. package/dist/lib/templates/python/models/model-col-array.eta +4 -0
  84. package/dist/lib/templates/python/models/model-col-boolean.eta +5 -0
  85. package/dist/lib/templates/python/models/model-col-date.eta +4 -0
  86. package/dist/lib/templates/python/models/model-col-decimal.eta +4 -0
  87. package/dist/lib/templates/python/models/model-col-enum.eta +16 -0
  88. package/dist/lib/templates/python/models/model-col-float.eta +5 -0
  89. package/dist/lib/templates/python/models/model-col-integer.eta +6 -0
  90. package/dist/lib/templates/python/models/model-col-json.eta +4 -0
  91. package/dist/lib/templates/python/models/model-col-jsonb.eta +4 -0
  92. package/dist/lib/templates/python/models/model-col-numeric.eta +4 -0
  93. package/dist/lib/templates/python/models/model-col-string.eta +6 -0
  94. package/dist/lib/templates/python/models/model-col-text.eta +6 -0
  95. package/dist/lib/templates/python/models/model-col-timestamp.eta +11 -0
  96. package/dist/lib/templates/python/models/model-col-timestamptz.eta +11 -0
  97. package/dist/lib/templates/python/models/model-col-uuid.eta +5 -0
  98. package/dist/lib/templates/python/models/model-col-varchar.eta +6 -0
  99. package/dist/lib/templates/python/models/model.eta +124 -0
  100. package/dist/lib/templates/python/routers/router.eta +206 -0
  101. package/dist/lib/templates/python/schemas/schema-col-array.eta +1 -0
  102. package/dist/lib/templates/python/schemas/schema-col-boolean.eta +1 -0
  103. package/dist/lib/templates/python/schemas/schema-col-date.eta +1 -0
  104. package/dist/lib/templates/python/schemas/schema-col-decimal.eta +1 -0
  105. package/dist/lib/templates/python/schemas/schema-col-enum.eta +6 -0
  106. package/dist/lib/templates/python/schemas/schema-col-float.eta +1 -0
  107. package/dist/lib/templates/python/schemas/schema-col-integer.eta +1 -0
  108. package/dist/lib/templates/python/schemas/schema-col-json.eta +1 -0
  109. package/dist/lib/templates/python/schemas/schema-col-jsonb.eta +1 -0
  110. package/dist/lib/templates/python/schemas/schema-col-numeric.eta +1 -0
  111. package/dist/lib/templates/python/schemas/schema-col-string.eta +1 -0
  112. package/dist/lib/templates/python/schemas/schema-col-text.eta +1 -0
  113. package/dist/lib/templates/python/schemas/schema-col-timestamp.eta +1 -0
  114. package/dist/lib/templates/python/schemas/schema-col-timestamptz.eta +1 -0
  115. package/dist/lib/templates/python/schemas/schema-col-uuid.eta +1 -0
  116. package/dist/lib/templates/python/schemas/schema-col-varchar.eta +1 -0
  117. package/dist/lib/templates/python/schemas/schema.eta +87 -0
  118. package/dist/lib/templates/python/services/service.eta +163 -0
  119. package/dist/lib/templates/rest/controller-rest.eta +13 -12
  120. package/dist/lib/templates/rest/dto-rest.eta +173 -59
  121. package/dist/lib/types/generator.d.ts +241 -0
  122. package/dist/lib/types/generator.js +2 -0
  123. package/dist/lib/types/index.d.ts +1 -0
  124. package/dist/lib/utils/casing.d.ts +1 -0
  125. package/dist/lib/utils/casing.js +11 -1
  126. package/oclif.manifest.json +32 -3
  127. package/package.json +4 -2
  128. package/dist/lib/utils/relationships/parse.spec.d.ts +0 -1
  129. package/dist/lib/utils/relationships/parse.spec.js +0 -402
  130. package/dist/tests/templates/entities/types/array-template.spec.d.ts +0 -1
  131. package/dist/tests/templates/entities/types/array-template.spec.js +0 -82
  132. package/dist/tests/templates/entities/types/bigint-template.spec.d.ts +0 -1
  133. package/dist/tests/templates/entities/types/bigint-template.spec.js +0 -82
  134. package/dist/tests/templates/entities/types/boolean-template.spec.d.ts +0 -1
  135. package/dist/tests/templates/entities/types/boolean-template.spec.js +0 -77
  136. package/dist/tests/templates/entities/types/bytea-template.spec.d.ts +0 -1
  137. package/dist/tests/templates/entities/types/bytea-template.spec.js +0 -68
  138. package/dist/tests/templates/entities/types/char-template.spec.d.ts +0 -1
  139. package/dist/tests/templates/entities/types/char-template.spec.js +0 -68
  140. package/dist/tests/templates/entities/types/date-template.spec.d.ts +0 -1
  141. package/dist/tests/templates/entities/types/date-template.spec.js +0 -56
  142. package/dist/tests/templates/entities/types/decimal-field-validation.spec.d.ts +0 -1
  143. package/dist/tests/templates/entities/types/decimal-field-validation.spec.js +0 -100
  144. package/dist/tests/templates/entities/types/decimal-template.spec.d.ts +0 -1
  145. package/dist/tests/templates/entities/types/decimal-template.spec.js +0 -86
  146. package/dist/tests/templates/entities/types/double-template.spec.d.ts +0 -1
  147. package/dist/tests/templates/entities/types/double-template.spec.js +0 -70
  148. package/dist/tests/templates/entities/types/enum-template.spec.d.ts +0 -1
  149. package/dist/tests/templates/entities/types/enum-template.spec.js +0 -85
  150. package/dist/tests/templates/entities/types/float-template.spec.d.ts +0 -1
  151. package/dist/tests/templates/entities/types/float-template.spec.js +0 -70
  152. package/dist/tests/templates/entities/types/geometry-template.spec.d.ts +0 -1
  153. package/dist/tests/templates/entities/types/geometry-template.spec.js +0 -58
  154. package/dist/tests/templates/entities/types/inet-template.spec.d.ts +0 -1
  155. package/dist/tests/templates/entities/types/inet-template.spec.js +0 -69
  156. package/dist/tests/templates/entities/types/int4range-template.spec.d.ts +0 -1
  157. package/dist/tests/templates/entities/types/int4range-template.spec.js +0 -72
  158. package/dist/tests/templates/entities/types/integer-template.spec.d.ts +0 -1
  159. package/dist/tests/templates/entities/types/integer-template.spec.js +0 -79
  160. package/dist/tests/templates/entities/types/interval-template.spec.d.ts +0 -1
  161. package/dist/tests/templates/entities/types/interval-template.spec.js +0 -68
  162. package/dist/tests/templates/entities/types/json-plain-template.spec.d.ts +0 -1
  163. package/dist/tests/templates/entities/types/json-plain-template.spec.js +0 -54
  164. package/dist/tests/templates/entities/types/json-template.spec.d.ts +0 -1
  165. package/dist/tests/templates/entities/types/json-template.spec.js +0 -40
  166. package/dist/tests/templates/entities/types/jsonb-template.spec.d.ts +0 -1
  167. package/dist/tests/templates/entities/types/jsonb-template.spec.js +0 -40
  168. package/dist/tests/templates/entities/types/money-template.spec.d.ts +0 -1
  169. package/dist/tests/templates/entities/types/money-template.spec.js +0 -68
  170. package/dist/tests/templates/entities/types/numeric-template.spec.d.ts +0 -1
  171. package/dist/tests/templates/entities/types/numeric-template.spec.js +0 -84
  172. package/dist/tests/templates/entities/types/point-template.spec.d.ts +0 -1
  173. package/dist/tests/templates/entities/types/point-template.spec.js +0 -64
  174. package/dist/tests/templates/entities/types/polygon-template.spec.d.ts +0 -1
  175. package/dist/tests/templates/entities/types/polygon-template.spec.js +0 -70
  176. package/dist/tests/templates/entities/types/real-template.spec.d.ts +0 -1
  177. package/dist/tests/templates/entities/types/real-template.spec.js +0 -67
  178. package/dist/tests/templates/entities/types/serial-template.spec.d.ts +0 -1
  179. package/dist/tests/templates/entities/types/serial-template.spec.js +0 -113
  180. package/dist/tests/templates/entities/types/smallint-template.spec.d.ts +0 -1
  181. package/dist/tests/templates/entities/types/smallint-template.spec.js +0 -82
  182. package/dist/tests/templates/entities/types/string-template.spec.d.ts +0 -1
  183. package/dist/tests/templates/entities/types/string-template.spec.js +0 -111
  184. package/dist/tests/templates/entities/types/text-template.spec.d.ts +0 -1
  185. package/dist/tests/templates/entities/types/text-template.spec.js +0 -70
  186. package/dist/tests/templates/entities/types/time-template.spec.d.ts +0 -1
  187. package/dist/tests/templates/entities/types/time-template.spec.js +0 -68
  188. package/dist/tests/templates/entities/types/timestamp-template.spec.d.ts +0 -1
  189. package/dist/tests/templates/entities/types/timestamp-template.spec.js +0 -74
  190. package/dist/tests/templates/entities/types/timetz-template.spec.d.ts +0 -1
  191. package/dist/tests/templates/entities/types/timetz-template.spec.js +0 -68
  192. package/dist/tests/templates/entities/types/tsvector-template.spec.d.ts +0 -1
  193. package/dist/tests/templates/entities/types/tsvector-template.spec.js +0 -55
  194. package/dist/tests/templates/entities/types/uuid-template.spec.d.ts +0 -1
  195. package/dist/tests/templates/entities/types/uuid-template.spec.js +0 -82
  196. package/dist/tests/templates/entities/types/varchar-template.spec.d.ts +0 -1
  197. package/dist/tests/templates/entities/types/varchar-template.spec.js +0 -105
  198. package/dist/tests/templates/entities/types/xml-template.spec.d.ts +0 -1
  199. package/dist/tests/templates/entities/types/xml-template.spec.js +0 -55
  200. package/dist/tests/templates/entities/uuid-entity-template.spec.d.ts +0 -1
  201. package/dist/tests/templates/entities/uuid-entity-template.spec.js +0 -277
  202. package/dist/tests/utils/relationship-deduplication.spec.d.ts +0 -1
  203. package/dist/tests/utils/relationship-deduplication.spec.js +0 -98
@@ -0,0 +1,25 @@
1
+ import { BaseGenerator } from "./base";
2
+ import { TargetLanguage, GeneratedFile, ValidationResult, GeneratorConfig, EntityGenerationOptions, ControllerGenerationOptions, ServiceGenerationOptions, DtoGenerationOptions, MigrationGenerationOptions, Entity, AuthConfig } from "../types";
3
+ /**
4
+ * TypeScript/NestJS generator that wraps the existing generation functions.
5
+ * This generator produces TypeORM entities, NestJS controllers, services, and DTOs.
6
+ */
7
+ export declare class TypeScriptGenerator extends BaseGenerator {
8
+ constructor(config: GeneratorConfig);
9
+ getLanguage(): TargetLanguage;
10
+ getFileExtension(): string;
11
+ validateConfig(config: GeneratorConfig): ValidationResult;
12
+ generateEntity(options: EntityGenerationOptions): Promise<GeneratedFile[]>;
13
+ generateController(options: ControllerGenerationOptions): Promise<GeneratedFile[]>;
14
+ generateService(options: ServiceGenerationOptions): Promise<GeneratedFile[]>;
15
+ generateDto(options: DtoGenerationOptions): Promise<GeneratedFile[]>;
16
+ generateModule(options: EntityGenerationOptions): Promise<GeneratedFile[]>;
17
+ generateMigration(_options: MigrationGenerationOptions): Promise<GeneratedFile[]>;
18
+ generateEnums(entities: Entity[], apiType: string): Promise<GeneratedFile[]>;
19
+ generateIndexModule(entities: Entity[], apiType: string): Promise<GeneratedFile[]>;
20
+ generateGuards(entities: Entity[], auth?: AuthConfig): Promise<GeneratedFile[]>;
21
+ /**
22
+ * Normalizes auth config by applying defaults for DB session providers
23
+ */
24
+ private normalizeAuthConfig;
25
+ }
@@ -0,0 +1,373 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeScriptGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path = tslib_1.__importStar(require("path"));
6
+ const Eta = tslib_1.__importStar(require("eta"));
7
+ const base_1 = require("./base");
8
+ // Utilities available for future use: createFile, withGeneratedMeta from "../utils/file-system"
9
+ const field_1 = require("../utils/field");
10
+ const relationships_1 = require("../utils/relationships");
11
+ const parse_1 = require("../utils/relationships/parse");
12
+ const casing_1 = require("../utils/casing");
13
+ const pluralize_1 = tslib_1.__importDefault(require("pluralize"));
14
+ const fs = tslib_1.__importStar(require("fs"));
15
+ const os = tslib_1.__importStar(require("os"));
16
+ const util_1 = require("util");
17
+ const guards_1 = require("../guards");
18
+ const auth_1 = require("../types/auth");
19
+ const unlinkAsync = (0, util_1.promisify)(fs.unlink);
20
+ /**
21
+ * TypeScript/NestJS generator that wraps the existing generation functions.
22
+ * This generator produces TypeORM entities, NestJS controllers, services, and DTOs.
23
+ */
24
+ class TypeScriptGenerator extends base_1.BaseGenerator {
25
+ constructor(config) {
26
+ super(config);
27
+ // Override template path for TypeScript - use root templates directory
28
+ // since TypeScript templates are the existing ones in entities/, rest/, graphql/
29
+ this.templateBasePath = path.join(__dirname, "../templates");
30
+ Eta.configure({
31
+ views: this.templateBasePath,
32
+ cache: false,
33
+ });
34
+ }
35
+ getLanguage() {
36
+ return "typescript";
37
+ }
38
+ getFileExtension() {
39
+ return ".ts";
40
+ }
41
+ validateConfig(config) {
42
+ var _a;
43
+ const errors = [];
44
+ const warnings = [];
45
+ // Validate that entities are provided
46
+ if (!config.entities || config.entities.length === 0) {
47
+ errors.push("No entities defined in configuration");
48
+ }
49
+ // Validate each entity
50
+ for (const entity of config.entities) {
51
+ if (!entity.name) {
52
+ errors.push("Entity missing required 'name' property");
53
+ }
54
+ // Validate field types
55
+ for (const field of (_a = entity.fields) !== null && _a !== void 0 ? _a : []) {
56
+ if (!field.name) {
57
+ errors.push(`Entity '${entity.name}' has a field without a name`);
58
+ }
59
+ if (!field.type) {
60
+ errors.push(`Entity '${entity.name}' field '${field.name}' missing type`);
61
+ }
62
+ }
63
+ }
64
+ // Validate API type
65
+ if (config.apiType && !["rest", "graphql"].includes(config.apiType)) {
66
+ errors.push(`Invalid API type: '${config.apiType}'. Must be 'rest' or 'graphql'`);
67
+ }
68
+ return this.createValidationResult(errors, warnings);
69
+ }
70
+ async generateEntity(options) {
71
+ const { entity, relationships, allEntities, apiType } = options;
72
+ const { name, fields = [], indexes, uniques } = entity;
73
+ const columns = (0, field_1.getFieldForTemplate)(fields, name);
74
+ const createPrimaryKey = columns.filter((column) => column.primary === true).length === 0;
75
+ const createdAt = entity.created_at;
76
+ const updatedAt = entity.updated_at;
77
+ const primaryKeyType = entity.primaryKeyType || "serial";
78
+ const relationshipsForTemplate = (0, relationships_1.getRelationshipForTemplate)(name, relationships, allEntities);
79
+ const entitiesToImport = (0, relationships_1.getRelationshipsForImport)(name, relationshipsForTemplate);
80
+ const data = {
81
+ name,
82
+ indexes: indexes || [],
83
+ uniques: uniques || [],
84
+ createPrimaryKey,
85
+ primaryKeyType,
86
+ snakeCasedName: (0, casing_1.snakeCase)(name),
87
+ createdAt,
88
+ updatedAt,
89
+ pluralizedName: (0, casing_1.camelCase)((0, pluralize_1.default)(name)),
90
+ columns,
91
+ associations: [...new Set(relationshipsForTemplate)],
92
+ entitiesToImport,
93
+ importEnums: (0, field_1.typeExistsInEntity)(entity, "enum") !== -1,
94
+ apiType,
95
+ };
96
+ const templatePath = apiType === "graphql"
97
+ ? "./graphql/gql-entity-graphql"
98
+ : "./entities/entity";
99
+ const content = await this.renderTemplate(templatePath, data);
100
+ return [
101
+ {
102
+ path: `${name}/${name}.entity.ts`,
103
+ content,
104
+ },
105
+ ];
106
+ }
107
+ async generateController(options) {
108
+ const { entity, relationships, relationshipMap } = options;
109
+ const { name: entityName } = entity;
110
+ const relationshipsForTemplate = (0, relationships_1.getRelationshipForTemplate)(entityName, relationships);
111
+ // Handle nested relationships for joins
112
+ const tmpDir = os.tmpdir();
113
+ const nestedJoinsFile = path.join(tmpDir, `apso-nested-joins-${entityName}-${Date.now()}.eta`);
114
+ const nestedJoinsStream = fs.createWriteStream(nestedJoinsFile, {
115
+ encoding: "utf8",
116
+ });
117
+ await (0, parse_1.streamNestedRelationships)(entityName, relationshipMap, nestedJoinsStream);
118
+ nestedJoinsStream.end();
119
+ await new Promise((resolve) => {
120
+ nestedJoinsStream.on("finish", resolve);
121
+ });
122
+ const svcName = `${entityName}Service`;
123
+ const ctrlName = `${entityName}Controller`;
124
+ const pluralEntityName = (0, pluralize_1.default)(entityName);
125
+ const primaryKeyType = entity.primaryKeyType || "serial";
126
+ const data = {
127
+ svcName,
128
+ ctrlName,
129
+ entityName,
130
+ pluralEntityName,
131
+ primaryKeyType,
132
+ associations: [...new Set(relationshipsForTemplate)],
133
+ nestedJoinsFile,
134
+ };
135
+ const controllerContent = await this.renderTemplate("./rest/controller-rest", data);
136
+ const specContent = await this.renderTemplate("./rest/controller-rest-spec", data);
137
+ // Clean up temp file
138
+ try {
139
+ await unlinkAsync(nestedJoinsFile);
140
+ }
141
+ catch {
142
+ // Ignore cleanup errors
143
+ }
144
+ return [
145
+ {
146
+ path: `${entityName}/${entityName}.controller.ts`,
147
+ content: controllerContent,
148
+ },
149
+ {
150
+ path: `${entityName}/${entityName}.controller.spec.ts`,
151
+ content: specContent,
152
+ },
153
+ ];
154
+ }
155
+ async generateService(options) {
156
+ const { entity, relationshipMap } = options;
157
+ const { name: entityName } = entity;
158
+ const svcName = `${entityName}Service`;
159
+ const repoName = `${entityName}Repository`;
160
+ // Collect all related entities for the test file
161
+ let allRelatedEntities = [entityName];
162
+ if (relationshipMap && relationshipMap[entityName]) {
163
+ const visited = new Set();
164
+ const collect = (entName) => {
165
+ if (visited.has(entName))
166
+ return;
167
+ visited.add(entName);
168
+ allRelatedEntities.push(entName);
169
+ const rels = relationshipMap[entName] || [];
170
+ for (const rel of rels) {
171
+ if (!visited.has(rel.name)) {
172
+ collect(rel.name);
173
+ }
174
+ }
175
+ };
176
+ allRelatedEntities = [];
177
+ collect(entityName);
178
+ allRelatedEntities = [...new Set(allRelatedEntities)];
179
+ }
180
+ const data = {
181
+ svcName,
182
+ repoName,
183
+ entityName,
184
+ allRelatedEntities,
185
+ };
186
+ const serviceContent = await this.renderTemplate("./rest/service-rest", data);
187
+ const specContent = await this.renderTemplate("./rest/service-rest-spec", data);
188
+ return [
189
+ {
190
+ path: `${entityName}/${entityName}.service.ts`,
191
+ content: serviceContent,
192
+ },
193
+ {
194
+ path: `${entityName}/${entityName}.service.spec.ts`,
195
+ content: specContent,
196
+ },
197
+ ];
198
+ }
199
+ async generateDto(options) {
200
+ const { entity, relationships, allEntities, apiType } = options;
201
+ const { name: entityName, fields = [] } = entity;
202
+ const columns = (0, field_1.getFieldForTemplate)(fields, entityName);
203
+ const relationshipsTemplate = (0, relationships_1.getRelationshipForTemplate)(entityName, relationships);
204
+ // Add foreign key columns for ManyToOne relationships
205
+ relationshipsTemplate.forEach((rel) => {
206
+ if (rel.type === "ManyToOne") {
207
+ const fkName = (0, casing_1.camelCase)(rel.referenceName || rel.name) + "Id";
208
+ const referencedEntity = allEntities === null || allEntities === void 0 ? void 0 : allEntities.find((e) => e.name === rel.name);
209
+ const referencedPrimaryKeyType = (referencedEntity === null || referencedEntity === void 0 ? void 0 : referencedEntity.primaryKeyType) || "serial";
210
+ const fkDataType = referencedPrimaryKeyType === "uuid" ? "string" : "number";
211
+ const fkType = referencedPrimaryKeyType === "uuid" ? "text" : "integer";
212
+ if (!columns.some((col) => col.name === fkName)) {
213
+ columns.push({
214
+ name: fkName,
215
+ dataType: fkDataType,
216
+ type: fkType,
217
+ });
218
+ }
219
+ }
220
+ });
221
+ const primaryKeyColumns = columns.filter((column) => column.primary === true);
222
+ const addDefaultPKProperty = primaryKeyColumns.length === 0;
223
+ const createdAt = entity.created_at;
224
+ const updatedAt = entity.updated_at;
225
+ const primaryKeyType = entity.primaryKeyType || "serial";
226
+ const dtoColumns = columns.filter((col) => !["id", "createdAt", "updatedAt"].includes(col.name));
227
+ const createDtoName = `Create${(0, casing_1.pascalCase)(entityName)}Dto`;
228
+ const updateDtoName = `Update${(0, casing_1.pascalCase)(entityName)}Dto`;
229
+ const data = {
230
+ entityName,
231
+ addDefaultPKProperty,
232
+ primaryKeyType,
233
+ createdAt,
234
+ updatedAt,
235
+ columns: dtoColumns,
236
+ associations: relationshipsTemplate,
237
+ createDtoName,
238
+ updateDtoName,
239
+ apiType: apiType !== null && apiType !== void 0 ? apiType : "rest",
240
+ importEnums: (0, field_1.typeExistsInEntity)(entity, "enum") !== -1,
241
+ };
242
+ const dtoContent = await this.renderTemplate("./rest/dto-rest", data);
243
+ return [
244
+ {
245
+ path: `${entityName}/dtos/${entityName}.dto.ts`,
246
+ content: dtoContent,
247
+ },
248
+ ];
249
+ }
250
+ async generateModule(options) {
251
+ const { entity, apiType } = options;
252
+ const { name: entityName } = entity;
253
+ const moduleName = `${entityName}Module`;
254
+ const svcName = `${entityName}Service`;
255
+ const ctrlName = `${entityName}Controller`;
256
+ const resolverName = `${entityName}Resolver`;
257
+ const data = {
258
+ moduleName,
259
+ svcName,
260
+ ctrlName,
261
+ resolverName,
262
+ entityName,
263
+ };
264
+ const templatePath = apiType === "graphql"
265
+ ? "./graphql/gql-module-graphql"
266
+ : "./rest/module-rest";
267
+ const content = await this.renderTemplate(templatePath, data);
268
+ return [
269
+ {
270
+ path: `${entityName}/${entityName}.module.ts`,
271
+ content,
272
+ },
273
+ ];
274
+ }
275
+ async generateMigration(_options) {
276
+ // TypeORM handles migrations differently - typically via CLI
277
+ // This is a placeholder for future migration template generation
278
+ return [];
279
+ }
280
+ async generateEnums(entities, apiType) {
281
+ if (entities.length === 0) {
282
+ return [];
283
+ }
284
+ const allEnumsFields = entities
285
+ .flatMap((entity) => (entity.fields || []).map((field) => {
286
+ if (field.type === "enum") {
287
+ return { ...field, name: (0, field_1.fieldToEnumType)(field.name, entity.name) };
288
+ }
289
+ return null;
290
+ }))
291
+ .filter(Boolean);
292
+ if (allEnumsFields.length === 0) {
293
+ return [];
294
+ }
295
+ const content = await this.renderTemplate(`./${apiType}/enums-${apiType}`, {
296
+ allEnumsFields,
297
+ });
298
+ return [
299
+ {
300
+ path: "enums.ts",
301
+ content,
302
+ },
303
+ ];
304
+ }
305
+ async generateIndexModule(entities, apiType) {
306
+ const content = await this.renderTemplate(`./${apiType}/index-module-${apiType}`, { entities });
307
+ return [
308
+ {
309
+ path: "index.ts",
310
+ content,
311
+ },
312
+ ];
313
+ }
314
+ async generateGuards(entities, auth) {
315
+ const hasScopes = (0, guards_1.hasScopedEntities)(entities);
316
+ const normalizedAuth = this.normalizeAuthConfig(auth);
317
+ if (!hasScopes && !normalizedAuth) {
318
+ return [];
319
+ }
320
+ const scopedEntities = (0, guards_1.getScopedEntities)(entities);
321
+ const files = [];
322
+ const templateData = {
323
+ scopedEntities,
324
+ authConfig: normalizedAuth,
325
+ generatedAt: new Date().toISOString(),
326
+ generatedBy: "Apso CLI",
327
+ };
328
+ // Generate auth.guard.ts if auth is configured
329
+ if (normalizedAuth) {
330
+ const authGuardContent = await this.renderTemplate("./guards/auth.guard.eta", templateData);
331
+ files.push({
332
+ path: "guards/auth.guard.ts",
333
+ content: authGuardContent,
334
+ });
335
+ }
336
+ // Generate scope.guard.ts if there are scoped entities
337
+ if (hasScopes) {
338
+ const scopeGuardContent = await this.renderTemplate("./guards/scope.guard.eta", templateData);
339
+ files.push({
340
+ path: "guards/scope.guard.ts",
341
+ content: scopeGuardContent,
342
+ });
343
+ }
344
+ // Generate guards.module.ts
345
+ const guardsModuleContent = await this.renderTemplate("./guards/guards.module.eta", templateData);
346
+ files.push({
347
+ path: "guards/guards.module.ts",
348
+ content: guardsModuleContent,
349
+ });
350
+ // Generate index.ts
351
+ const indexContent = await this.renderTemplate("./guards/index.eta", templateData);
352
+ files.push({
353
+ path: "guards/index.ts",
354
+ content: indexContent,
355
+ });
356
+ return files;
357
+ }
358
+ /**
359
+ * Normalizes auth config by applying defaults for DB session providers
360
+ */
361
+ normalizeAuthConfig(auth) {
362
+ if (!auth)
363
+ return undefined;
364
+ if ((0, auth_1.isDbSessionAuth)(auth)) {
365
+ return {
366
+ ...auth_1.DB_SESSION_AUTH_DEFAULTS,
367
+ ...auth,
368
+ };
369
+ }
370
+ return undefined;
371
+ }
372
+ }
373
+ exports.TypeScriptGenerator = TypeScriptGenerator;
@@ -9,3 +9,5 @@ export { createDto } from "./dto";
9
9
  export { createEnums } from "./enums";
10
10
  export { createGqlDTO } from "./gql-dto";
11
11
  export { createGuards, hasScopedEntities, getScopedEntities } from "./guards";
12
+ export { BaseGenerator, TypeScriptGenerator, createGenerator, isLanguageSupported, getSupportedLanguages, getImplementedLanguages, } from "./generators";
13
+ export type { TargetLanguage, GeneratedFile, ValidationResult, GeneratorConfig, LanguageGenerator, } from "./types";
package/dist/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getScopedEntities = exports.hasScopedEntities = exports.createGuards = exports.createGqlDTO = exports.createEnums = exports.createDto = exports.createIndexAppModule = exports.createModule = exports.createService = exports.createController = exports.createEntity = exports.parseApsorc = void 0;
3
+ exports.getImplementedLanguages = exports.getSupportedLanguages = exports.isLanguageSupported = exports.createGenerator = exports.TypeScriptGenerator = exports.BaseGenerator = exports.getScopedEntities = exports.hasScopedEntities = exports.createGuards = exports.createGqlDTO = exports.createEnums = exports.createDto = exports.createIndexAppModule = exports.createModule = exports.createService = exports.createController = exports.createEntity = exports.parseApsorc = void 0;
4
4
  var apsorc_parser_1 = require("./apsorc-parser");
5
5
  Object.defineProperty(exports, "parseApsorc", { enumerable: true, get: function () { return apsorc_parser_1.parseApsorc; } });
6
6
  var entity_1 = require("./entity");
@@ -23,3 +23,11 @@ var guards_1 = require("./guards");
23
23
  Object.defineProperty(exports, "createGuards", { enumerable: true, get: function () { return guards_1.createGuards; } });
24
24
  Object.defineProperty(exports, "hasScopedEntities", { enumerable: true, get: function () { return guards_1.hasScopedEntities; } });
25
25
  Object.defineProperty(exports, "getScopedEntities", { enumerable: true, get: function () { return guards_1.getScopedEntities; } });
26
+ // Generator exports
27
+ var generators_1 = require("./generators");
28
+ Object.defineProperty(exports, "BaseGenerator", { enumerable: true, get: function () { return generators_1.BaseGenerator; } });
29
+ Object.defineProperty(exports, "TypeScriptGenerator", { enumerable: true, get: function () { return generators_1.TypeScriptGenerator; } });
30
+ Object.defineProperty(exports, "createGenerator", { enumerable: true, get: function () { return generators_1.createGenerator; } });
31
+ Object.defineProperty(exports, "isLanguageSupported", { enumerable: true, get: function () { return generators_1.isLanguageSupported; } });
32
+ Object.defineProperty(exports, "getSupportedLanguages", { enumerable: true, get: function () { return generators_1.getSupportedLanguages; } });
33
+ Object.defineProperty(exports, "getImplementedLanguages", { enumerable: true, get: function () { return generators_1.getImplementedLanguages; } });
@@ -1,4 +1,11 @@
1
1
  <% const {field} = it; %>
2
-
2
+ <% if (field.name === 'createdAt') { %>
3
+ @CreateDateColumn()
4
+ createdAt: Date;
5
+ <% } else if (field.name === 'updatedAt') { %>
6
+ @UpdateDateColumn()
7
+ updatedAt: Date;
8
+ <% } else { %>
3
9
  @Column({ type: 'timestamp', nullable: <%= Boolean(field.nullable) %> })
4
- <%= field.name %>: Date;
10
+ <%= field.name %>: Date;
11
+ <% } %>
@@ -1,4 +1,11 @@
1
1
  <% const {field} = it; %>
2
-
2
+ <% if (field.name === 'createdAt') { %>
3
+ @CreateDateColumn()
4
+ createdAt: Date;
5
+ <% } else if (field.name === 'updatedAt') { %>
6
+ @UpdateDateColumn()
7
+ updatedAt: Date;
8
+ <% } else { %>
3
9
  @Column({ type: 'timestamptz', nullable: <%= Boolean(field.nullable) %> })
4
- <%= field.name %>: Date;
10
+ <%= field.name %>: Date;
11
+ <% } %>
@@ -1,14 +1,19 @@
1
1
  <%~ includeFile('./header.eta') %>
2
2
  /* eslint @typescript-eslint/no-unused-vars: "off" */
3
3
 
4
+ <%
5
+ // Check if any columns are named createdAt or updatedAt
6
+ const hasCreatedAt = it.createdAt || it.columns.some(c => c.name === 'createdAt');
7
+ const hasUpdatedAt = it.updatedAt || it.columns.some(c => c.name === 'updatedAt');
8
+ %>
4
9
  import {
5
10
  Column,
6
11
  Entity,
7
12
  <%~ it.associations.map((assoc) => `${assoc.type},`).filter((v, i, s) => s.indexOf(v) === i).join("\r\n") %>
8
- <% if (it.createdAt) { %>
13
+ <% if (hasCreatedAt) { %>
9
14
  CreateDateColumn,
10
15
  <% } %>
11
- <% if (it.updatedAt) { %>
16
+ <% if (hasUpdatedAt) { %>
12
17
  UpdateDateColumn,
13
18
  <% } %>
14
19
  PrimaryGeneratedColumn,
@@ -68,15 +73,23 @@ export class <%= it.name %> {
68
73
 
69
74
  <% if (it.createdAt) { %>
70
75
  @CreateDateColumn()
71
- created_at: Date;
76
+ createdAt: Date;
72
77
  <% } %>
73
78
 
74
79
  <% if (it.updatedAt) { %>
75
80
  @UpdateDateColumn()
76
- updated_at: Date;
81
+ updatedAt: Date;
77
82
  <% } %>
78
83
 
79
- <% it.columns.forEach((field) => { %>
84
+ <%
85
+ // Filter out id (if createPrimaryKey), createdAt, and updatedAt since they're handled separately
86
+ const columnsToProcess = it.columns.filter(c => {
87
+ if (it.createPrimaryKey && c.name === 'id') return false;
88
+ if (it.createdAt && c.name === 'createdAt') return false;
89
+ if (it.updatedAt && c.name === 'updatedAt') return false;
90
+ return true;
91
+ });
92
+ columnsToProcess.forEach((field) => { %>
80
93
 
81
94
  <%~ includeFile(`./entities/entity-col-${field.type}`, { field }) %>
82
95
 
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> []<%= it.column.arrayItemGoType || 'string' %> `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> []<%= it.column.arrayItemGoType || 'string' %> `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> []<%= it.column.arrayItemGoType || 'string' %> `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>bool `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>bool `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *bool `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>time.Time `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>time.Time `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *time.Time `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>float64 `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>float64 `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *float64 `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,8 @@
1
+ <% const enumTypeName = it.column.enumType || (it.column.pascalName + 'Enum'); %>
2
+ <% if (it.mode === 'response') { %>
3
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>enums.<%= enumTypeName %> `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
4
+ <% } else if (it.mode === 'create') { %>
5
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>enums.<%= enumTypeName %> `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required"<% } %>`
6
+ <% } else { %>
7
+ <%= it.column.pascalName %> *enums.<%= enumTypeName %> `json:"<%= it.column.name %>,omitempty"`
8
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>float64 `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>float64 `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *float64 `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>int `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>int `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *int `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> map[string]interface{} `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> map[string]interface{} `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> map[string]interface{} `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> map[string]interface{} `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> map[string]interface{} `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> map[string]interface{} `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>float64 `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>float64 `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *float64 `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required<% if (it.column.length) { %>,max=<%= it.column.length %><% } %>"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *string `json:"<%= it.column.name %>,omitempty"<% if (it.column.length) { %> validate:"omitempty,max=<%= it.column.length %>"<% } %>`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *string `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>time.Time `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>time.Time `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *time.Time `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>time.Time `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>time.Time `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *time.Time `json:"<%= it.column.name %>,omitempty"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required,uuid"<% } else { %> validate:"omitempty,uuid"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *string `json:"<%= it.column.name %>,omitempty" validate:"omitempty,uuid"`
7
+ <% } %>
@@ -0,0 +1,7 @@
1
+ <% if (it.mode === 'response') { %>
2
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"`
3
+ <% } else if (it.mode === 'create') { %>
4
+ <%= it.column.pascalName %> <% if (!it.column.required) { %>*<% } %>string `json:"<%= it.column.name %><% if (!it.column.required) { %>,omitempty<% } %>"<% if (it.column.required) { %> validate:"required<% if (it.column.length) { %>,max=<%= it.column.length %><% } %>"<% } %>`
5
+ <% } else { %>
6
+ <%= it.column.pascalName %> *string `json:"<%= it.column.name %>,omitempty"<% if (it.column.length) { %> validate:"omitempty,max=<%= it.column.length %>"<% } %>`
7
+ <% } %>