@fjall/generator 0.88.4

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 (57) hide show
  1. package/dist/src/ast/astComputeParser.d.ts +4 -0
  2. package/dist/src/ast/astComputeParser.js +427 -0
  3. package/dist/src/ast/astInfrastructureParser.d.ts +357 -0
  4. package/dist/src/ast/astInfrastructureParser.js +1925 -0
  5. package/dist/src/ast/astSurgicalModification.d.ts +47 -0
  6. package/dist/src/ast/astSurgicalModification.js +400 -0
  7. package/dist/src/ast/index.d.ts +2 -0
  8. package/dist/src/ast/index.js +2 -0
  9. package/dist/src/aws/regions.d.ts +30 -0
  10. package/dist/src/aws/regions.js +254 -0
  11. package/dist/src/generation/common.d.ts +86 -0
  12. package/dist/src/generation/common.js +187 -0
  13. package/dist/src/generation/compute.d.ts +6 -0
  14. package/dist/src/generation/compute.js +547 -0
  15. package/dist/src/generation/database.d.ts +54 -0
  16. package/dist/src/generation/database.js +201 -0
  17. package/dist/src/generation/index.d.ts +12 -0
  18. package/dist/src/generation/index.js +18 -0
  19. package/dist/src/generation/infrastructure.d.ts +44 -0
  20. package/dist/src/generation/infrastructure.js +389 -0
  21. package/dist/src/generation/storage.d.ts +23 -0
  22. package/dist/src/generation/storage.js +174 -0
  23. package/dist/src/generation/storageConnections.d.ts +37 -0
  24. package/dist/src/generation/storageConnections.js +71 -0
  25. package/dist/src/index.d.ts +10 -0
  26. package/dist/src/index.js +19 -0
  27. package/dist/src/planning/index.d.ts +1 -0
  28. package/dist/src/planning/index.js +1 -0
  29. package/dist/src/planning/resourcePlanning.d.ts +58 -0
  30. package/dist/src/planning/resourcePlanning.js +216 -0
  31. package/dist/src/presets/index.d.ts +3 -0
  32. package/dist/src/presets/index.js +3 -0
  33. package/dist/src/presets/patternTierPresets.d.ts +93 -0
  34. package/dist/src/presets/patternTierPresets.js +131 -0
  35. package/dist/src/presets/storagePresets.d.ts +11 -0
  36. package/dist/src/presets/storagePresets.js +36 -0
  37. package/dist/src/presets/tierPresets.d.ts +59 -0
  38. package/dist/src/presets/tierPresets.js +384 -0
  39. package/dist/src/presets/tierTypes.d.ts +301 -0
  40. package/dist/src/presets/tierTypes.js +7 -0
  41. package/dist/src/schemas/constants.d.ts +74 -0
  42. package/dist/src/schemas/constants.js +208 -0
  43. package/dist/src/schemas/index.d.ts +3 -0
  44. package/dist/src/schemas/index.js +3 -0
  45. package/dist/src/schemas/instanceTypeArchitecture.d.ts +35 -0
  46. package/dist/src/schemas/instanceTypeArchitecture.js +75 -0
  47. package/dist/src/schemas/resourceSchemas.d.ts +3534 -0
  48. package/dist/src/schemas/resourceSchemas.js +2015 -0
  49. package/dist/src/types/Result.d.ts +19 -0
  50. package/dist/src/types/Result.js +31 -0
  51. package/dist/src/util/errorUtils.d.ts +2 -0
  52. package/dist/src/util/errorUtils.js +15 -0
  53. package/dist/src/validation/patterns.d.ts +300 -0
  54. package/dist/src/validation/patterns.js +360 -0
  55. package/dist/src/version.d.ts +1 -0
  56. package/dist/src/version.js +1 -0
  57. package/package.json +32 -0
@@ -0,0 +1,360 @@
1
+ export const VALIDATION_PATTERNS = Object.freeze({
2
+ // User-facing identifiers: app names, org names, service names, cluster names
3
+ IDENTIFIER: /^[a-zA-Z][a-zA-Z0-9-]*$/,
4
+ // CDK construct names: database, storage, network resource labels
5
+ RESOURCE_NAME: /^[a-zA-Z][a-zA-Z0-9]*$/,
6
+ // ECS service names: allow hyphens for kebab-case service identifiers
7
+ ECS_SERVICE_NAME: /^[a-zA-Z][a-zA-Z0-9-]*$/,
8
+ // AWS-native patterns
9
+ BUCKET_NAME: /^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z][a-z0-9]*$/,
10
+ DATABASE_NAME: /^[a-zA-Z][a-zA-Z0-9_]*$/,
11
+ // Resource type patterns
12
+ RESOURCE_TYPE: /^[a-z]+(:[a-z]+)?$/,
13
+ // Path patterns
14
+ SSM_PATH: /^\/[a-zA-Z][a-zA-Z0-9-]*(\/[a-zA-Z][a-zA-Z0-9-]*)*$/,
15
+ // Secrets patterns (matches SSM Parameter Store allowed characters)
16
+ SECRET_NAME: /^[a-zA-Z_][a-zA-Z0-9._-]*$/,
17
+ // SSM namespace component pattern (more permissive for CDK-generated names)
18
+ SSM_COMPONENT: /^[a-zA-Z][a-zA-Z0-9._-]*$/,
19
+ // Email pattern (basic validation)
20
+ EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
21
+ // Docker image pattern
22
+ DOCKER_IMAGE: /^[a-z0-9][a-z0-9._-]*[a-z0-9](:[a-z0-9._-]+)?$/,
23
+ // Domain pattern (e.g., cms.example.com)
24
+ DOMAIN: /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/i,
25
+ });
26
+ export const VALIDATION_MESSAGES = Object.freeze({
27
+ // User-facing identifier (app, org, service, cluster names)
28
+ IDENTIFIER: "Must start with a letter, contain only letters, numbers, and hyphens",
29
+ IDENTIFIER_MIN_LENGTH: "Must be at least 2 characters",
30
+ IDENTIFIER_NO_TRAILING_HYPHEN: "Must not end with a hyphen",
31
+ IDENTIFIER_NO_CONSECUTIVE_HYPHENS: "Must not contain consecutive hyphens",
32
+ // CDK construct names
33
+ RESOURCE_NAME: "Must start with a letter and contain only letters and numbers (PascalCase recommended)",
34
+ // ECS service names
35
+ ECS_SERVICE_NAME: "Service name must start with a letter and contain only letters, numbers, and hyphens",
36
+ // AWS-native
37
+ BUCKET_NAME: "Bucket name must start with a lowercase letter and contain only lowercase letters, numbers, and hyphens",
38
+ DATABASE_NAME: "Database name must start with a letter and contain only letters, numbers, and underscores",
39
+ // Resource type messages
40
+ RESOURCE_TYPE: "Resource type must be in format 'category' or 'category:type'",
41
+ // Path messages
42
+ SSM_PATH: "SSM path must start with / and contain valid namespace segments (e.g., /myapp/ApiCluster/service)",
43
+ // Secrets messages
44
+ SECRET_NAME: "Secret name must start with a letter or underscore and contain only letters, numbers, underscores, hyphens, or periods",
45
+ // SSM component messages
46
+ SSM_COMPONENT: "Must start with a letter and contain only letters, numbers, periods, hyphens, or underscores",
47
+ // Email messages
48
+ EMAIL: "Please enter a valid email address",
49
+ // Domain messages
50
+ DOMAIN: "Please enter a valid domain (e.g., cms.example.com)",
51
+ // Docker messages
52
+ DOCKER_IMAGE: "Invalid Docker image name format",
53
+ // Required field messages
54
+ REQUIRED: {
55
+ APP_NAME: "Application name is required",
56
+ RESOURCE_NAME: "Resource name is required",
57
+ BUCKET_NAME: "Bucket name is required",
58
+ SERVICE_NAME: "Service name is required",
59
+ NETWORK_NAME: "Network name is required",
60
+ DATABASE_NAME: "Database name is required",
61
+ ORGANISATION_NAME: "Organisation name is required",
62
+ EMAIL: "Email is required",
63
+ NAME: "Name is required",
64
+ USERNAME: "Username is required",
65
+ CONTAINER_NAME: "Container name is required",
66
+ FIRST_NAME: "First name is required",
67
+ LAST_NAME: "Last name is required",
68
+ GROUP: "Group is required",
69
+ PATTERN_NAME: "Pattern name is required",
70
+ ROUTING_PATH: "Routing path is required",
71
+ RESOURCE_TYPE: "Resource type is required",
72
+ VARIANT: "Variant is required",
73
+ SUBTYPE: "Subtype is required",
74
+ DEPLOY_TARGET: "Deploy target is required",
75
+ DESTROY_TARGET: "Destroy target is required",
76
+ },
77
+ // Length constraint messages
78
+ MAX_LENGTH: {
79
+ APP_NAME: "Application name must be 50 characters or less",
80
+ RESOURCE_NAME: "Resource name must be 63 characters or less",
81
+ BUCKET_NAME: "Bucket name must be 63 characters or less",
82
+ SERVICE_NAME: "Service name must be 255 characters or less",
83
+ NETWORK_NAME: "Network name must be 50 characters or less",
84
+ DATABASE_NAME: "Database name must be 63 characters or less",
85
+ ORGANISATION_NAME: "Organisation name must be 50 characters or less",
86
+ },
87
+ // Port validation messages
88
+ PORT: {
89
+ INTEGER: "Port must be an integer",
90
+ MIN: "Port must be at least 1",
91
+ MAX: "Port cannot exceed 65535",
92
+ },
93
+ // Username validation messages
94
+ USERNAME: {
95
+ MAX_LENGTH: "Username cannot exceed 63 characters",
96
+ },
97
+ // Lambda validation messages
98
+ LAMBDA: {
99
+ MEMORY: {
100
+ INTEGER: "Lambda memory must be an integer",
101
+ MIN: "Memory must be at least 128 MB",
102
+ MAX: "Memory cannot exceed 10240 MB",
103
+ MULTIPLE: "Memory must be 128 MB or a multiple of 64 MB",
104
+ },
105
+ TIMEOUT: {
106
+ INTEGER: "Timeout must be an integer",
107
+ MIN: "Timeout must be at least 1 second",
108
+ MAX: "Timeout cannot exceed 900 seconds",
109
+ },
110
+ },
111
+ // Priority validation messages (ALB routing rules)
112
+ PRIORITY: {
113
+ INTEGER: "Priority must be an integer",
114
+ MIN: "Priority must be at least 1",
115
+ MAX: "Priority cannot exceed 50000",
116
+ },
117
+ // Capacity validation messages (ECS scaling)
118
+ CAPACITY: {
119
+ MIN: {
120
+ INTEGER: "Minimum capacity must be an integer",
121
+ MIN_0: "Minimum capacity must be at least 0",
122
+ MIN_1: "Minimum capacity must be at least 1",
123
+ MAX: "Minimum capacity cannot exceed 100",
124
+ },
125
+ MAX: {
126
+ INTEGER: "Maximum capacity must be an integer",
127
+ MIN_0: "Maximum capacity must be at least 0",
128
+ MIN_1: "Maximum capacity must be at least 1",
129
+ MAX: "Maximum capacity cannot exceed 100",
130
+ },
131
+ DESIRED: {
132
+ INTEGER: "Desired count must be an integer",
133
+ MIN: "Desired count must be at least 0",
134
+ MAX: "Desired count cannot exceed 100",
135
+ },
136
+ },
137
+ // Memory limit validation messages (ECS)
138
+ MEMORY_LIMIT: {
139
+ INTEGER: "Memory limit must be an integer",
140
+ MIN_512: "Memory limit must be at least 512 MiB",
141
+ MIN_128: "Memory limit must be at least 128 MiB",
142
+ MAX: "Memory limit cannot exceed 30720 MiB",
143
+ },
144
+ // Database validation messages
145
+ DATABASE: {
146
+ PORT: {
147
+ INTEGER: "Database port must be an integer",
148
+ MIN: "Database port must be at least 1024",
149
+ MAX: "Database port cannot exceed 65535",
150
+ },
151
+ NAME: {
152
+ REQUIRED: "Database name is required",
153
+ MAX_LENGTH: "Database name cannot exceed 64 characters",
154
+ },
155
+ },
156
+ // Backup retention validation messages
157
+ BACKUP_RETENTION: {
158
+ INTEGER: "Backup retention must be an integer",
159
+ MIN: "Backup retention must be at least 1 day",
160
+ MAX: "Backup retention cannot exceed 35 days",
161
+ },
162
+ // SQS validation messages
163
+ SQS: {
164
+ VISIBILITY_TIMEOUT: {
165
+ INTEGER: "Visibility timeout must be an integer",
166
+ MIN: "Visibility timeout must be at least 0 seconds",
167
+ MAX: "Visibility timeout cannot exceed 43200 seconds (12 hours)",
168
+ },
169
+ RETENTION_PERIOD: {
170
+ INTEGER: "Retention period must be an integer",
171
+ MIN: "Retention period must be at least 60 seconds",
172
+ MAX: "Retention period cannot exceed 1209600 seconds (14 days)",
173
+ },
174
+ },
175
+ // Reader validation messages (Aurora)
176
+ READER: {
177
+ COUNT: {
178
+ INTEGER: "Reader count must be an integer",
179
+ MIN: "Reader count must be at least 0",
180
+ MAX: "Reader count cannot exceed 15",
181
+ },
182
+ },
183
+ // Identifier suffix validation messages
184
+ IDENTIFIER_SUFFIX: {
185
+ REQUIRED: "Identifier suffix is required when specified",
186
+ MAX_LENGTH: "Identifier suffix cannot exceed 50 characters",
187
+ },
188
+ // Rotation validation messages
189
+ ROTATION: {
190
+ INTEGER: "Rotation days must be an integer",
191
+ MIN: "Rotation interval must be at least 1 day",
192
+ MAX: "Rotation interval cannot exceed 365 days",
193
+ },
194
+ // Max connections validation messages
195
+ MAX_CONNECTIONS: {
196
+ INTEGER: "Max connections must be an integer",
197
+ MIN: "Max connections must be at least 1",
198
+ MAX: "Max connections cannot exceed 100",
199
+ },
200
+ // Monitoring interval validation messages
201
+ MONITORING_INTERVAL: {
202
+ INTEGER: "Monitoring interval must be an integer",
203
+ MIN: "Monitoring interval must be at least 0",
204
+ MAX: "Monitoring interval cannot exceed 60 seconds",
205
+ VALUES: "Monitoring interval must be 0, 1, 5, 10, 15, 30, or 60 seconds",
206
+ },
207
+ // Retention days validation messages (Performance Insights)
208
+ RETENTION_DAYS: {
209
+ INTEGER: "Retention days must be an integer",
210
+ MIN: "Retention days must be at least 1",
211
+ MAX: "Retention days cannot exceed 365",
212
+ },
213
+ // Batch size validation messages
214
+ BATCH_SIZE: {
215
+ INTEGER: "Batch size must be an integer",
216
+ MIN: "Batch size must be at least 1",
217
+ MAX: "Batch size cannot exceed 10000",
218
+ },
219
+ // Service validation messages
220
+ SERVICE: {
221
+ UNIQUE_WITHIN_CLUSTER: "Service names must be unique within a cluster",
222
+ MIN_REQUIRED: "At least one service is required",
223
+ ROUTING_REQUIRED: "Multiple services with ports require routing config (path or host)",
224
+ },
225
+ // RDS Proxy configuration messages
226
+ PROXY_CONFIG: {
227
+ MAX_IDLE_CONNECTIONS: {
228
+ INTEGER: "Max idle connections must be an integer",
229
+ MIN: "Max idle connections must be at least 0",
230
+ MAX: "Max idle connections cannot exceed 100",
231
+ },
232
+ BORROW_TIMEOUT: {
233
+ INTEGER: "Connection borrow timeout must be an integer",
234
+ MIN: "Connection borrow timeout must be at least 1 second",
235
+ MAX: "Connection borrow timeout cannot exceed 3600 seconds",
236
+ },
237
+ },
238
+ // Network availability zone messages
239
+ MAX_AZS: {
240
+ INTEGER: "Max AZs must be an integer",
241
+ MIN: "Max AZs must be at least 1",
242
+ MAX: "Max AZs cannot exceed 3",
243
+ },
244
+ // SQS batching window messages
245
+ BATCHING_WINDOW: {
246
+ INTEGER: "Max batching window must be an integer",
247
+ MIN: "Max batching window must be at least 0",
248
+ MAX: "Max batching window cannot exceed 300 seconds",
249
+ },
250
+ // Health check validation messages
251
+ HEALTH_CHECK: {
252
+ INTERVAL: {
253
+ INTEGER: "Health check interval must be an integer",
254
+ MIN: "Health check interval must be at least 5 seconds",
255
+ MAX: "Health check interval cannot exceed 300 seconds",
256
+ },
257
+ TIMEOUT: {
258
+ INTEGER: "Health check timeout must be an integer",
259
+ MIN: "Health check timeout must be at least 2 seconds",
260
+ MAX: "Health check timeout cannot exceed 60 seconds",
261
+ },
262
+ RETRIES: {
263
+ INTEGER: "Health check retries must be an integer",
264
+ MIN: "Health check retries must be at least 1",
265
+ MAX: "Health check retries cannot exceed 10",
266
+ },
267
+ START_PERIOD: {
268
+ INTEGER: "Health check start period must be an integer",
269
+ MIN: "Health check start period must be at least 0 seconds",
270
+ MAX: "Health check start period cannot exceed 300 seconds",
271
+ },
272
+ },
273
+ // Ephemeral storage messages
274
+ EPHEMERAL_STORAGE: {
275
+ INTEGER: "Ephemeral storage size must be an integer",
276
+ MIN: "Ephemeral storage size must be at least 512 MB",
277
+ MAX: "Ephemeral storage size cannot exceed 10240 MB",
278
+ },
279
+ // SQS max message size messages
280
+ MAX_MESSAGE_SIZE: {
281
+ INTEGER: "Max message size must be an integer",
282
+ MIN: "Max message size must be at least 1024 bytes",
283
+ MAX: "Max message size cannot exceed 262144 bytes (256 KB)",
284
+ },
285
+ // Capacity constraint messages
286
+ CAPACITY_CONSTRAINT: {
287
+ MIN_LTE_MAX: "minCapacity must be less than or equal to maxCapacity",
288
+ },
289
+ // Direct access constraint messages
290
+ DIRECT_ACCESS: {
291
+ NO_DOMAIN: "directAccess cannot be used with domain (no ALB for HTTPS)",
292
+ NO_LOAD_BALANCER: "directAccess cannot be used with loadBalancer (mutually exclusive)",
293
+ },
294
+ // Global Aurora messages
295
+ GLOBAL_AURORA: {
296
+ PRIMARY_REGION_REQUIRED: "primaryRegion is required for GlobalAurora databases",
297
+ },
298
+ // NAT gateway messages
299
+ NAT_GATEWAY: {
300
+ INTEGER: "NAT gateway count must be an integer",
301
+ MIN: "NAT gateway count must be at least 0",
302
+ MAX: "NAT gateway count cannot exceed 3",
303
+ },
304
+ // CIDR mask messages
305
+ CIDR_MASK: {
306
+ INTEGER: "CIDR mask must be an integer",
307
+ MIN: "CIDR mask must be at least 16",
308
+ MAX: "CIDR mask cannot exceed 28",
309
+ },
310
+ // CPU units messages
311
+ CPU: {
312
+ INTEGER: "CPU must be an integer",
313
+ MIN: "CPU must be at least 256 units",
314
+ MAX: "CPU cannot exceed 4096 units",
315
+ },
316
+ // KMS encryption messages
317
+ KMS: {
318
+ KEY_REQUIRED: "KMS key ARN is required when using KMS encryption",
319
+ },
320
+ // Website bucket messages
321
+ WEBSITE_BUCKET: {
322
+ DOCUMENTS_REQUIRED: "Website index and error documents are required for website buckets",
323
+ },
324
+ // Aurora reader instances messages
325
+ READER_INSTANCES: {
326
+ MAX: "Cannot have more than 15 reader instances",
327
+ COUNT_OR_INSTANCES: "Cannot specify both 'count' and 'instances' - use one or the other",
328
+ },
329
+ // Generator capacity messages (1-1000 range for ECS/EC2 generators)
330
+ GENERATOR_CAPACITY: {
331
+ MIN: {
332
+ MIN: "Minimum capacity must be at least 1",
333
+ MAX: "Minimum capacity cannot exceed 1000",
334
+ },
335
+ MAX: {
336
+ MIN: "Maximum capacity must be at least 1",
337
+ MAX: "Maximum capacity cannot exceed 1000",
338
+ },
339
+ },
340
+ // Instance type messages
341
+ INSTANCE_TYPE: "Unknown instance type. Common types include: t4g.micro, t4g.small, m5.large",
342
+ // Architecture mismatch messages
343
+ ARCHITECTURE_MISMATCH: "Architecture mismatch between instance type and AMI",
344
+ // Allocated storage messages (RDS Instance)
345
+ ALLOCATED_STORAGE: {
346
+ INTEGER: "Allocated storage must be an integer",
347
+ MIN: "Allocated storage must be at least 20 GB",
348
+ MAX: "Allocated storage cannot exceed 65536 GB",
349
+ },
350
+ // DLQ (dead-letter queue) messages
351
+ DLQ: {
352
+ MAX_RECEIVE_COUNT: {
353
+ INTEGER: "Max receive count must be an integer",
354
+ MIN: "Max receive count must be at least 1",
355
+ MAX: "Max receive count cannot exceed 1000",
356
+ },
357
+ },
358
+ // Region messages
359
+ REGION: "Invalid AWS region",
360
+ });
@@ -0,0 +1 @@
1
+ export declare const GENERATOR_VERSION = "0.88.3";
@@ -0,0 +1 @@
1
+ export const GENERATOR_VERSION = "0.88.3";
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@fjall/generator",
3
+ "version": "0.88.4",
4
+ "description": "Pure infrastructure generation logic for Fjall",
5
+ "type": "module",
6
+ "main": "dist/src/index.js",
7
+ "types": "dist/src/index.d.ts",
8
+ "files": [
9
+ "dist/"
10
+ ],
11
+ "scripts": {
12
+ "clean": "rm -rf ./dist",
13
+ "build": "npm run clean && tsc",
14
+ "typecheck": "tsc --noEmit",
15
+ "test": "vitest run",
16
+ "test:watch": "vitest",
17
+ "format": "prettier --write \"src/**/*.ts\"",
18
+ "format:check": "prettier --check \"src/**/*.ts\""
19
+ },
20
+ "engines": {
21
+ "node": ">=18.0.0"
22
+ },
23
+ "license": "ISC",
24
+ "dependencies": {
25
+ "typescript": "^5.8.2",
26
+ "zod": "^4.0.14"
27
+ },
28
+ "devDependencies": {
29
+ "vitest": "^3.2.3"
30
+ },
31
+ "gitHead": "bae02efe8e447ef008c7bc3eef3398ded4872f42"
32
+ }