@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,230 @@
1
+ /**
2
+ * Platform CLI Configuration Types
3
+ *
4
+ * These types define the structure of configuration and credentials
5
+ * stored in ~/.apso/ for platform connectivity.
6
+ */
7
+ /**
8
+ * OAuth tokens received from the platform
9
+ */
10
+ export interface PlatformTokens {
11
+ /**
12
+ * JWT access token for API calls
13
+ */
14
+ accessToken: string;
15
+ /**
16
+ * Refresh token for obtaining new access tokens
17
+ */
18
+ refreshToken: string;
19
+ /**
20
+ * When the access token expires (ISO timestamp)
21
+ */
22
+ expiresAt: string;
23
+ /**
24
+ * Token type, typically "Bearer"
25
+ */
26
+ tokenType: string;
27
+ }
28
+ /**
29
+ * User information from the platform
30
+ */
31
+ export interface PlatformUser {
32
+ /**
33
+ * Unique user ID
34
+ */
35
+ id: string;
36
+ /**
37
+ * User's email address
38
+ */
39
+ email: string;
40
+ /**
41
+ * User's display name
42
+ */
43
+ name?: string;
44
+ /**
45
+ * URL to user's avatar image
46
+ */
47
+ avatarUrl?: string;
48
+ }
49
+ /**
50
+ * Workspace information from the platform
51
+ */
52
+ export interface PlatformWorkspace {
53
+ /**
54
+ * Unique workspace ID
55
+ */
56
+ id: string;
57
+ /**
58
+ * URL-friendly slug
59
+ */
60
+ slug: string;
61
+ /**
62
+ * Display name
63
+ */
64
+ name: string;
65
+ /**
66
+ * Workspace type
67
+ */
68
+ type: "personal" | "company";
69
+ }
70
+ /**
71
+ * Credentials stored in ~/.apso/credentials.json
72
+ */
73
+ export interface CredentialsFile {
74
+ /**
75
+ * OAuth tokens
76
+ */
77
+ tokens: PlatformTokens;
78
+ /**
79
+ * Authenticated user information
80
+ */
81
+ user: PlatformUser;
82
+ /**
83
+ * When credentials were last updated (ISO timestamp)
84
+ */
85
+ updatedAt: string;
86
+ /**
87
+ * CLI version that wrote these credentials
88
+ */
89
+ cliVersion: string;
90
+ }
91
+ /**
92
+ * Global CLI configuration stored in ~/.apso/config.json
93
+ */
94
+ export interface GlobalConfigFile {
95
+ /**
96
+ * Default workspace slug to use
97
+ */
98
+ defaultWorkspace?: string;
99
+ /**
100
+ * Platform API base URL
101
+ */
102
+ apiUrl: string;
103
+ /**
104
+ * Platform web app URL (for OAuth)
105
+ */
106
+ webUrl: string;
107
+ /**
108
+ * Enable verbose logging
109
+ */
110
+ verbose: boolean;
111
+ /**
112
+ * Disable colored output
113
+ */
114
+ noColor: boolean;
115
+ /**
116
+ * Disable telemetry
117
+ */
118
+ telemetryDisabled: boolean;
119
+ }
120
+ /**
121
+ * Project link stored in .apso/link.json
122
+ */
123
+ export interface ProjectLinkFile {
124
+ /**
125
+ * Linked workspace ID
126
+ */
127
+ workspaceId: string;
128
+ /**
129
+ * Linked workspace slug
130
+ */
131
+ workspaceSlug: string;
132
+ /**
133
+ * Linked service ID
134
+ */
135
+ serviceId: string;
136
+ /**
137
+ * Linked service slug
138
+ */
139
+ serviceSlug: string;
140
+ /**
141
+ * GitHub repository (if connected)
142
+ */
143
+ githubRepo?: string;
144
+ /**
145
+ * GitHub branch
146
+ */
147
+ githubBranch?: string;
148
+ /**
149
+ * When the link was created (ISO timestamp)
150
+ */
151
+ linkedAt: string;
152
+ /**
153
+ * Last successful sync (ISO timestamp)
154
+ */
155
+ lastSyncedAt?: string;
156
+ /**
157
+ * Hash of local schema at last sync
158
+ */
159
+ localSchemaHash?: string;
160
+ /**
161
+ * Hash of remote schema at last sync
162
+ */
163
+ remoteSchemaHash?: string;
164
+ }
165
+ /**
166
+ * Sync queue item for offline operations
167
+ */
168
+ export interface SyncQueueItem {
169
+ /**
170
+ * Unique operation ID
171
+ */
172
+ id: string;
173
+ /**
174
+ * Type of operation
175
+ */
176
+ type: "push" | "pull" | "sync";
177
+ /**
178
+ * When the operation was queued (ISO timestamp)
179
+ */
180
+ queuedAt: string;
181
+ /**
182
+ * Operation payload
183
+ */
184
+ payload: {
185
+ /**
186
+ * Schema snapshot at queue time
187
+ */
188
+ schemaSnapshot?: unknown;
189
+ /**
190
+ * Additional metadata
191
+ */
192
+ metadata?: Record<string, unknown>;
193
+ };
194
+ /**
195
+ * Number of retry attempts
196
+ */
197
+ retryCount: number;
198
+ /**
199
+ * Last error message if retried
200
+ */
201
+ lastError?: string;
202
+ }
203
+ /**
204
+ * Sync queue file stored in .apso/sync-queue.json
205
+ */
206
+ export interface SyncQueueFile {
207
+ /**
208
+ * Schema version for migrations
209
+ */
210
+ version: number;
211
+ /**
212
+ * Queued operations
213
+ */
214
+ operations: SyncQueueItem[];
215
+ }
216
+ /**
217
+ * Default values for global configuration
218
+ */
219
+ export declare const DEFAULT_GLOBAL_CONFIG: GlobalConfigFile;
220
+ /**
221
+ * Environment variables that can override configuration
222
+ */
223
+ export declare const CONFIG_ENV_VARS: {
224
+ readonly APSO_API_URL: "apiUrl";
225
+ readonly APSO_WEB_URL: "webUrl";
226
+ readonly APSO_DEBUG: "verbose";
227
+ readonly APSO_NO_COLOR: "noColor";
228
+ readonly APSO_PROFILE: "profile";
229
+ readonly APSO_CONFIG_DIR: "configDir";
230
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * Platform CLI Configuration Types
4
+ *
5
+ * These types define the structure of configuration and credentials
6
+ * stored in ~/.apso/ for platform connectivity.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CONFIG_ENV_VARS = exports.DEFAULT_GLOBAL_CONFIG = void 0;
10
+ /**
11
+ * Default values for global configuration
12
+ */
13
+ exports.DEFAULT_GLOBAL_CONFIG = {
14
+ apiUrl: "https://api.apso.ai",
15
+ webUrl: "https://app.apso.ai",
16
+ verbose: false,
17
+ noColor: false,
18
+ telemetryDisabled: false,
19
+ };
20
+ /**
21
+ * Environment variables that can override configuration
22
+ */
23
+ exports.CONFIG_ENV_VARS = {
24
+ APSO_API_URL: "apiUrl",
25
+ APSO_WEB_URL: "webUrl",
26
+ APSO_DEBUG: "verbose",
27
+ APSO_NO_COLOR: "noColor",
28
+ APSO_PROFILE: "profile",
29
+ APSO_CONFIG_DIR: "configDir",
30
+ };
@@ -0,0 +1,93 @@
1
+ import * as Eta from "eta";
2
+ import { TargetLanguage, GeneratedFile, ValidationResult, GeneratorConfig, EntityGenerationOptions, ControllerGenerationOptions, ServiceGenerationOptions, DtoGenerationOptions, MigrationGenerationOptions, LanguageGenerator, Entity, AuthConfig } from "../types";
3
+ /**
4
+ * Abstract base class for language-specific generators.
5
+ * Provides common functionality and enforces the LanguageGenerator interface.
6
+ */
7
+ export declare abstract class BaseGenerator implements LanguageGenerator {
8
+ protected config: GeneratorConfig;
9
+ protected templateEngine: typeof Eta;
10
+ protected templateBasePath: string;
11
+ constructor(config: GeneratorConfig);
12
+ /**
13
+ * Get the target language this generator supports
14
+ */
15
+ abstract getLanguage(): TargetLanguage;
16
+ /**
17
+ * Get the file extension for generated files (e.g., ".ts", ".py", ".go")
18
+ */
19
+ abstract getFileExtension(): string;
20
+ /**
21
+ * Validate the configuration for this language
22
+ */
23
+ abstract validateConfig(config: GeneratorConfig): ValidationResult;
24
+ /**
25
+ * Generate entity/model files
26
+ */
27
+ abstract generateEntity(options: EntityGenerationOptions): Promise<GeneratedFile[]>;
28
+ /**
29
+ * Generate controller/router files
30
+ */
31
+ abstract generateController(options: ControllerGenerationOptions): Promise<GeneratedFile[]>;
32
+ /**
33
+ * Generate service files
34
+ */
35
+ abstract generateService(options: ServiceGenerationOptions): Promise<GeneratedFile[]>;
36
+ /**
37
+ * Generate DTO/schema files
38
+ */
39
+ abstract generateDto(options: DtoGenerationOptions): Promise<GeneratedFile[]>;
40
+ /**
41
+ * Generate module/router registration files
42
+ */
43
+ abstract generateModule(options: EntityGenerationOptions): Promise<GeneratedFile[]>;
44
+ /**
45
+ * Generate migration files
46
+ */
47
+ abstract generateMigration(options: MigrationGenerationOptions): Promise<GeneratedFile[]>;
48
+ /**
49
+ * Generate enum files for all entities
50
+ */
51
+ abstract generateEnums(entities: Entity[], apiType: string): Promise<GeneratedFile[]>;
52
+ /**
53
+ * Generate the index/main module file
54
+ */
55
+ abstract generateIndexModule(entities: Entity[], apiType: string): Promise<GeneratedFile[]>;
56
+ /**
57
+ * Generate guard files (auth, scope, etc.)
58
+ */
59
+ abstract generateGuards(entities: Entity[], auth?: AuthConfig): Promise<GeneratedFile[]>;
60
+ /**
61
+ * Render a template file with the given data
62
+ */
63
+ protected renderTemplate(templatePath: string, data: Record<string, unknown>): Promise<string>;
64
+ /**
65
+ * Write generated files to disk
66
+ * Note: Sequential writes are intentional to avoid race conditions
67
+ */
68
+ protected writeFiles(baseDir: string, files: GeneratedFile[]): Promise<void>;
69
+ /**
70
+ * Get the configuration for this generator
71
+ */
72
+ getConfig(): GeneratorConfig;
73
+ /**
74
+ * Get the template base path for this generator
75
+ */
76
+ getTemplateBasePath(): string;
77
+ /**
78
+ * Helper to create a validation result
79
+ */
80
+ protected createValidationResult(errors?: string[], warnings?: string[]): ValidationResult;
81
+ /**
82
+ * Helper to check if an entity has a specific field type
83
+ */
84
+ protected entityHasFieldType(entity: Entity, fieldType: string): boolean;
85
+ /**
86
+ * Helper to get all unique field types from entities
87
+ */
88
+ protected getUniqueFieldTypes(entities: Entity[]): string[];
89
+ /**
90
+ * Helper to check if any entity has enum fields
91
+ */
92
+ protected hasEnumFields(entities: Entity[]): boolean;
93
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseGenerator = 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 file_system_1 = require("../utils/file-system");
8
+ /**
9
+ * Abstract base class for language-specific generators.
10
+ * Provides common functionality and enforces the LanguageGenerator interface.
11
+ */
12
+ class BaseGenerator {
13
+ constructor(config) {
14
+ this.config = config;
15
+ this.templateEngine = Eta;
16
+ this.templateBasePath = path.join(__dirname, `../templates/${this.getLanguage()}`);
17
+ // Configure Eta for this generator's templates
18
+ Eta.configure({
19
+ views: this.templateBasePath,
20
+ cache: false,
21
+ });
22
+ }
23
+ /**
24
+ * Render a template file with the given data
25
+ */
26
+ async renderTemplate(templatePath, data) {
27
+ const content = await this.templateEngine.renderFileAsync(templatePath, (0, file_system_1.withGeneratedMeta)(data));
28
+ return content;
29
+ }
30
+ /**
31
+ * Write generated files to disk
32
+ * Note: Sequential writes are intentional to avoid race conditions
33
+ */
34
+ async writeFiles(baseDir, files) {
35
+ for (const file of files) {
36
+ const fullPath = path.join(baseDir, file.path);
37
+ // eslint-disable-next-line no-await-in-loop
38
+ await (0, file_system_1.createFile)(fullPath, file.content);
39
+ }
40
+ }
41
+ /**
42
+ * Get the configuration for this generator
43
+ */
44
+ getConfig() {
45
+ return this.config;
46
+ }
47
+ /**
48
+ * Get the template base path for this generator
49
+ */
50
+ getTemplateBasePath() {
51
+ return this.templateBasePath;
52
+ }
53
+ /**
54
+ * Helper to create a validation result
55
+ */
56
+ createValidationResult(errors = [], warnings = []) {
57
+ return {
58
+ valid: errors.length === 0,
59
+ errors,
60
+ warnings,
61
+ };
62
+ }
63
+ /**
64
+ * Helper to check if an entity has a specific field type
65
+ */
66
+ entityHasFieldType(entity, fieldType) {
67
+ var _a, _b;
68
+ return ((_b = (_a = entity.fields) === null || _a === void 0 ? void 0 : _a.some((field) => field.type === fieldType)) !== null && _b !== void 0 ? _b : false);
69
+ }
70
+ /**
71
+ * Helper to get all unique field types from entities
72
+ */
73
+ getUniqueFieldTypes(entities) {
74
+ var _a;
75
+ const types = new Set();
76
+ for (const entity of entities) {
77
+ for (const field of (_a = entity.fields) !== null && _a !== void 0 ? _a : []) {
78
+ types.add(field.type);
79
+ }
80
+ }
81
+ return [...types];
82
+ }
83
+ /**
84
+ * Helper to check if any entity has enum fields
85
+ */
86
+ hasEnumFields(entities) {
87
+ return entities.some((entity) => this.entityHasFieldType(entity, "enum"));
88
+ }
89
+ }
90
+ exports.BaseGenerator = BaseGenerator;
@@ -0,0 +1,37 @@
1
+ import { BaseGenerator } from "./base";
2
+ import { TargetLanguage, GeneratedFile, ValidationResult, GeneratorConfig, EntityGenerationOptions, ControllerGenerationOptions, ServiceGenerationOptions, DtoGenerationOptions, MigrationGenerationOptions, Entity, AuthConfig } from "../types";
3
+ /**
4
+ * Go/Gin generator that produces GORM models, DTOs, Gin handlers,
5
+ * and service layer code.
6
+ */
7
+ export declare class GoGenerator extends BaseGenerator {
8
+ constructor(config: GeneratorConfig);
9
+ getLanguage(): TargetLanguage;
10
+ getFileExtension(): string;
11
+ validateConfig(config: GeneratorConfig): ValidationResult;
12
+ /**
13
+ * Maps .apsorc field types to Go types
14
+ */
15
+ private mapFieldToGoType;
16
+ /**
17
+ * Gets the Go type for primary keys
18
+ */
19
+ private getPrimaryKeyGoType;
20
+ /**
21
+ * Gets the Swagger type for primary keys
22
+ */
23
+ private getPrimaryKeySwaggerType;
24
+ /**
25
+ * Transforms fields for Go templates with additional Go-specific properties
26
+ */
27
+ private getGoFieldsForTemplate;
28
+ generateEntity(options: EntityGenerationOptions): Promise<GeneratedFile[]>;
29
+ generateController(options: ControllerGenerationOptions): Promise<GeneratedFile[]>;
30
+ generateService(options: ServiceGenerationOptions): Promise<GeneratedFile[]>;
31
+ generateDto(options: DtoGenerationOptions): Promise<GeneratedFile[]>;
32
+ generateModule(_options: EntityGenerationOptions): Promise<GeneratedFile[]>;
33
+ generateMigration(_options: MigrationGenerationOptions): Promise<GeneratedFile[]>;
34
+ generateEnums(entities: Entity[], _apiType: string): Promise<GeneratedFile[]>;
35
+ generateIndexModule(entities: Entity[], _apiType: string): Promise<GeneratedFile[]>;
36
+ generateGuards(_entities: Entity[], auth?: AuthConfig): Promise<GeneratedFile[]>;
37
+ }