@apso/cli 0.7.4 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autogen/index.d.ts +2 -0
- package/dist/autogen/index.js +3 -0
- package/dist/commands/server/new.d.ts +4 -1
- package/dist/commands/server/new.js +115 -22
- package/dist/commands/server/scaffold.d.ts +10 -0
- package/dist/commands/server/scaffold.js +200 -10
- package/dist/lib/api/client.d.ts +65 -0
- package/dist/lib/api/client.js +305 -0
- package/dist/lib/api/index.d.ts +8 -0
- package/dist/lib/api/index.js +22 -0
- package/dist/lib/api/services.d.ts +166 -0
- package/dist/lib/api/services.js +202 -0
- package/dist/lib/api/types.d.ts +212 -0
- package/dist/lib/api/types.js +7 -0
- package/dist/lib/apsorc-parser.d.ts +3 -0
- package/dist/lib/apsorc-parser.js +4 -0
- package/dist/lib/config/index.d.ts +8 -0
- package/dist/lib/config/index.js +17 -0
- package/dist/lib/config/manager.d.ts +127 -0
- package/dist/lib/config/manager.js +304 -0
- package/dist/lib/config/paths.d.ts +65 -0
- package/dist/lib/config/paths.js +127 -0
- package/dist/lib/config/types.d.ts +230 -0
- package/dist/lib/config/types.js +30 -0
- package/dist/lib/generators/base.d.ts +93 -0
- package/dist/lib/generators/base.js +90 -0
- package/dist/lib/generators/go.d.ts +37 -0
- package/dist/lib/generators/go.js +340 -0
- package/dist/lib/generators/index.d.ts +21 -0
- package/dist/lib/generators/index.js +51 -0
- package/dist/lib/generators/python.d.ts +21 -0
- package/dist/lib/generators/python.js +253 -0
- package/dist/lib/generators/typescript.d.ts +25 -0
- package/dist/lib/generators/typescript.js +373 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +9 -1
- package/dist/lib/templates/entities/entity-col-timestamp.eta +9 -2
- package/dist/lib/templates/entities/entity-col-timestamptz.eta +9 -2
- package/dist/lib/templates/entities/entity.eta +16 -3
- package/dist/lib/templates/go/dto/dto-col-array.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-boolean.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-date.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-decimal.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-enum.eta +8 -0
- package/dist/lib/templates/go/dto/dto-col-float.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-integer.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-json.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-jsonb.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-numeric.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-string.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-text.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-timestamp.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-timestamptz.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-uuid.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-varchar.eta +7 -0
- package/dist/lib/templates/go/dto/dto.eta +78 -0
- package/dist/lib/templates/go/enums.eta +44 -0
- package/dist/lib/templates/go/handlers/handler.eta +212 -0
- package/dist/lib/templates/go/header.eta +3 -0
- package/dist/lib/templates/go/index-module.eta +53 -0
- package/dist/lib/templates/go/middleware/auth.eta +101 -0
- package/dist/lib/templates/go/models/model-col-array.eta +1 -0
- package/dist/lib/templates/go/models/model-col-boolean.eta +1 -0
- package/dist/lib/templates/go/models/model-col-date.eta +1 -0
- package/dist/lib/templates/go/models/model-col-decimal.eta +1 -0
- package/dist/lib/templates/go/models/model-col-enum.eta +2 -0
- package/dist/lib/templates/go/models/model-col-float.eta +1 -0
- package/dist/lib/templates/go/models/model-col-integer.eta +1 -0
- package/dist/lib/templates/go/models/model-col-json.eta +1 -0
- package/dist/lib/templates/go/models/model-col-jsonb.eta +1 -0
- package/dist/lib/templates/go/models/model-col-numeric.eta +1 -0
- package/dist/lib/templates/go/models/model-col-string.eta +1 -0
- package/dist/lib/templates/go/models/model-col-text.eta +1 -0
- package/dist/lib/templates/go/models/model-col-timestamp.eta +1 -0
- package/dist/lib/templates/go/models/model-col-timestamptz.eta +1 -0
- package/dist/lib/templates/go/models/model-col-uuid.eta +1 -0
- package/dist/lib/templates/go/models/model-col-varchar.eta +1 -0
- package/dist/lib/templates/go/models/model.eta +53 -0
- package/dist/lib/templates/go/services/service.eta +190 -0
- package/dist/lib/templates/python/enums.eta +10 -0
- package/dist/lib/templates/python/header.eta +6 -0
- package/dist/lib/templates/python/index-module.eta +18 -0
- package/dist/lib/templates/python/models/model-col-array.eta +4 -0
- package/dist/lib/templates/python/models/model-col-boolean.eta +5 -0
- package/dist/lib/templates/python/models/model-col-date.eta +4 -0
- package/dist/lib/templates/python/models/model-col-decimal.eta +4 -0
- package/dist/lib/templates/python/models/model-col-enum.eta +16 -0
- package/dist/lib/templates/python/models/model-col-float.eta +5 -0
- package/dist/lib/templates/python/models/model-col-integer.eta +6 -0
- package/dist/lib/templates/python/models/model-col-json.eta +4 -0
- package/dist/lib/templates/python/models/model-col-jsonb.eta +4 -0
- package/dist/lib/templates/python/models/model-col-numeric.eta +4 -0
- package/dist/lib/templates/python/models/model-col-string.eta +6 -0
- package/dist/lib/templates/python/models/model-col-text.eta +6 -0
- package/dist/lib/templates/python/models/model-col-timestamp.eta +11 -0
- package/dist/lib/templates/python/models/model-col-timestamptz.eta +11 -0
- package/dist/lib/templates/python/models/model-col-uuid.eta +5 -0
- package/dist/lib/templates/python/models/model-col-varchar.eta +6 -0
- package/dist/lib/templates/python/models/model.eta +124 -0
- package/dist/lib/templates/python/routers/router.eta +206 -0
- package/dist/lib/templates/python/schemas/schema-col-array.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-boolean.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-date.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-decimal.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-enum.eta +6 -0
- package/dist/lib/templates/python/schemas/schema-col-float.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-integer.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-json.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-jsonb.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-numeric.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-string.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-text.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-timestamp.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-timestamptz.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-uuid.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-varchar.eta +1 -0
- package/dist/lib/templates/python/schemas/schema.eta +87 -0
- package/dist/lib/templates/python/services/service.eta +163 -0
- package/dist/lib/templates/rest/controller-rest.eta +13 -12
- package/dist/lib/templates/rest/dto-rest.eta +173 -59
- package/dist/lib/types/generator.d.ts +241 -0
- package/dist/lib/types/generator.js +2 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/utils/casing.d.ts +1 -0
- package/dist/lib/utils/casing.js +11 -1
- package/oclif.manifest.json +32 -3
- package/package.json +4 -2
- package/dist/lib/utils/relationships/parse.spec.d.ts +0 -1
- package/dist/lib/utils/relationships/parse.spec.js +0 -402
- package/dist/tests/templates/entities/types/array-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/array-template.spec.js +0 -82
- package/dist/tests/templates/entities/types/bigint-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/bigint-template.spec.js +0 -82
- package/dist/tests/templates/entities/types/boolean-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/boolean-template.spec.js +0 -77
- package/dist/tests/templates/entities/types/bytea-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/bytea-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/char-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/char-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/date-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/date-template.spec.js +0 -56
- package/dist/tests/templates/entities/types/decimal-field-validation.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/decimal-field-validation.spec.js +0 -100
- package/dist/tests/templates/entities/types/decimal-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/decimal-template.spec.js +0 -86
- package/dist/tests/templates/entities/types/double-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/double-template.spec.js +0 -70
- package/dist/tests/templates/entities/types/enum-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/enum-template.spec.js +0 -85
- package/dist/tests/templates/entities/types/float-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/float-template.spec.js +0 -70
- package/dist/tests/templates/entities/types/geometry-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/geometry-template.spec.js +0 -58
- package/dist/tests/templates/entities/types/inet-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/inet-template.spec.js +0 -69
- package/dist/tests/templates/entities/types/int4range-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/int4range-template.spec.js +0 -72
- package/dist/tests/templates/entities/types/integer-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/integer-template.spec.js +0 -79
- package/dist/tests/templates/entities/types/interval-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/interval-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/json-plain-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/json-plain-template.spec.js +0 -54
- package/dist/tests/templates/entities/types/json-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/json-template.spec.js +0 -40
- package/dist/tests/templates/entities/types/jsonb-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/jsonb-template.spec.js +0 -40
- package/dist/tests/templates/entities/types/money-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/money-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/numeric-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/numeric-template.spec.js +0 -84
- package/dist/tests/templates/entities/types/point-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/point-template.spec.js +0 -64
- package/dist/tests/templates/entities/types/polygon-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/polygon-template.spec.js +0 -70
- package/dist/tests/templates/entities/types/real-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/real-template.spec.js +0 -67
- package/dist/tests/templates/entities/types/serial-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/serial-template.spec.js +0 -113
- package/dist/tests/templates/entities/types/smallint-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/smallint-template.spec.js +0 -82
- package/dist/tests/templates/entities/types/string-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/string-template.spec.js +0 -111
- package/dist/tests/templates/entities/types/text-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/text-template.spec.js +0 -70
- package/dist/tests/templates/entities/types/time-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/time-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/timestamp-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/timestamp-template.spec.js +0 -74
- package/dist/tests/templates/entities/types/timetz-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/timetz-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/tsvector-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/tsvector-template.spec.js +0 -55
- package/dist/tests/templates/entities/types/uuid-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/uuid-template.spec.js +0 -82
- package/dist/tests/templates/entities/types/varchar-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/varchar-template.spec.js +0 -105
- package/dist/tests/templates/entities/types/xml-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/xml-template.spec.js +0 -55
- package/dist/tests/templates/entities/uuid-entity-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/uuid-entity-template.spec.js +0 -277
- package/dist/tests/utils/relationship-deduplication.spec.d.ts +0 -1
- 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
|
+
}
|