@fjall/generator 0.88.4 → 0.89.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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/dist/src/ast/astCdnParser.d.ts +15 -0
  3. package/dist/src/ast/astCdnParser.js +114 -0
  4. package/dist/src/ast/astCommonParser.d.ts +90 -0
  5. package/dist/src/ast/astCommonParser.js +351 -0
  6. package/dist/src/ast/astComputeParser.d.ts +14 -2
  7. package/dist/src/ast/astComputeParser.js +55 -9
  8. package/dist/src/ast/astDatabaseParser.d.ts +104 -0
  9. package/dist/src/ast/astDatabaseParser.js +275 -0
  10. package/dist/src/ast/astInfrastructureParser.d.ts +23 -277
  11. package/dist/src/ast/astInfrastructureParser.js +83 -1456
  12. package/dist/src/ast/astMessagingParser.d.ts +25 -0
  13. package/dist/src/ast/astMessagingParser.js +78 -0
  14. package/dist/src/ast/astNetworkParser.d.ts +70 -0
  15. package/dist/src/ast/astNetworkParser.js +219 -0
  16. package/dist/src/ast/astPatternParser.d.ts +80 -0
  17. package/dist/src/ast/astPatternParser.js +155 -0
  18. package/dist/src/ast/astStorageParser.d.ts +18 -0
  19. package/dist/src/ast/astStorageParser.js +164 -0
  20. package/dist/src/ast/index.d.ts +1 -0
  21. package/dist/src/ast/index.js +4 -0
  22. package/dist/src/dns/bindParser.d.ts +13 -0
  23. package/dist/src/dns/bindParser.js +224 -0
  24. package/dist/src/dns/bindWriter.d.ts +2 -0
  25. package/dist/src/dns/bindWriter.js +52 -0
  26. package/dist/src/dns/index.d.ts +4 -0
  27. package/dist/src/dns/index.js +4 -0
  28. package/dist/src/dns/infrastructureWriter.d.ts +2 -0
  29. package/dist/src/dns/infrastructureWriter.js +58 -0
  30. package/dist/src/dns/types.d.ts +82 -0
  31. package/dist/src/dns/types.js +52 -0
  32. package/dist/src/generation/common.d.ts +1 -16
  33. package/dist/src/generation/common.js +2 -28
  34. package/dist/src/generation/compute.js +77 -28
  35. package/dist/src/generation/index.d.ts +2 -1
  36. package/dist/src/generation/index.js +3 -1
  37. package/dist/src/generation/messagingConnections.d.ts +33 -0
  38. package/dist/src/generation/messagingConnections.js +73 -0
  39. package/dist/src/generation/storage.d.ts +5 -1
  40. package/dist/src/generation/storage.js +9 -1
  41. package/dist/src/generation/storageConnections.d.ts +3 -3
  42. package/dist/src/generation/storageConnections.js +8 -4
  43. package/dist/src/index.d.ts +1 -0
  44. package/dist/src/index.js +2 -0
  45. package/dist/src/planning/resourcePlanning.js +0 -2
  46. package/dist/src/presets/tierTypes.d.ts +4 -1
  47. package/dist/src/schemas/applicationSchemas.d.ts +854 -0
  48. package/dist/src/schemas/applicationSchemas.js +80 -0
  49. package/dist/src/schemas/baseSchemas.d.ts +206 -0
  50. package/dist/src/schemas/baseSchemas.js +248 -0
  51. package/dist/src/schemas/cdnSchemas.d.ts +61 -0
  52. package/dist/src/schemas/cdnSchemas.js +62 -0
  53. package/dist/src/schemas/computeSchemas.d.ts +723 -0
  54. package/dist/src/schemas/computeSchemas.js +727 -0
  55. package/dist/src/schemas/constants.d.ts +12 -8
  56. package/dist/src/schemas/constants.js +14 -4
  57. package/dist/src/schemas/databaseSchemas.d.ts +638 -0
  58. package/dist/src/schemas/databaseSchemas.js +366 -0
  59. package/dist/src/schemas/messagingSchemas.d.ts +20 -0
  60. package/dist/src/schemas/messagingSchemas.js +29 -0
  61. package/dist/src/schemas/networkSchemas.d.ts +246 -0
  62. package/dist/src/schemas/networkSchemas.js +125 -0
  63. package/dist/src/schemas/patternSchemas.d.ts +708 -0
  64. package/dist/src/schemas/patternSchemas.js +294 -0
  65. package/dist/src/schemas/resourceSchemas.d.ts +24 -3530
  66. package/dist/src/schemas/resourceSchemas.js +24 -2011
  67. package/dist/src/schemas/storageSchemas.d.ts +93 -0
  68. package/dist/src/schemas/storageSchemas.js +119 -0
  69. package/dist/src/util/errorUtils.d.ts +1 -2
  70. package/dist/src/util/errorUtils.js +1 -15
  71. package/dist/src/validation/patterns.d.ts +9 -0
  72. package/dist/src/validation/patterns.js +9 -0
  73. package/dist/src/version.d.ts +1 -1
  74. package/dist/src/version.js +1 -1
  75. package/package.json +5 -3
@@ -0,0 +1,294 @@
1
+ import { z } from "zod";
2
+ import { VALIDATION_MESSAGES } from "../validation/patterns.js";
3
+ import { BackupRetentionSchema, MonitoringIntervalSchema, DatabasePortSchema, ProxyConfigOrFalseSchema, ReadReplicaConfigOrFalseSchema, AuroraWriterConfigSchema, AuroraReadersConfigOrFalseSchema, DatabaseInsightsConfigOrFalseSchema, CredentialsConfigSchema, EncryptionConfigSchema, } from "./databaseSchemas.js";
4
+ import { LambdaMemorySchema } from "./computeSchemas.js";
5
+ // ─── Pattern Lambda configuration ────────────────────────────────────────────
6
+ /**
7
+ * Pattern Lambda configuration for individual functions.
8
+ */
9
+ export const PatternLambdaConfigSchema = z
10
+ .object({
11
+ /** Memory size in MB. Range: 128-10240. */
12
+ memorySize: LambdaMemorySchema.optional(),
13
+ /** Timeout in seconds. Range: 1-900. */
14
+ timeout: z
15
+ .number()
16
+ .int(VALIDATION_MESSAGES.LAMBDA.TIMEOUT.INTEGER)
17
+ .min(1, VALIDATION_MESSAGES.LAMBDA.TIMEOUT.MIN)
18
+ .max(900, VALIDATION_MESSAGES.LAMBDA.TIMEOUT.MAX)
19
+ .optional(),
20
+ /** Ephemeral storage size in MB. Range: 512-10240. Default: 512. */
21
+ ephemeralStorageSize: z
22
+ .number()
23
+ .int(VALIDATION_MESSAGES.EPHEMERAL_STORAGE.INTEGER)
24
+ .min(512, VALIDATION_MESSAGES.EPHEMERAL_STORAGE.MIN)
25
+ .max(10240, VALIDATION_MESSAGES.EPHEMERAL_STORAGE.MAX)
26
+ .optional(),
27
+ })
28
+ .strict();
29
+ // ─── Payload database configuration ──────────────────────────────────────────
30
+ /**
31
+ * Full Payload database configuration for pattern.
32
+ * Exposes ALL underlying DatabaseFactory props with pattern-specific defaults.
33
+ */
34
+ export const PayloadDatabaseConfigSchema = z
35
+ .object({
36
+ /** Database type: "Instance" (RDS Instance) or "Aurora". Default: "Instance" */
37
+ type: z.enum(["Instance", "Aurora"]).optional(),
38
+ /** Database name. Default: derived from pattern name */
39
+ databaseName: z.string().optional(),
40
+ /** Database engine. Default: "postgresql" */
41
+ databaseEngine: z.enum(["postgresql", "mysql"]).optional(),
42
+ /** Enable deletion protection. Default: true */
43
+ deletionProtection: z.boolean().optional(),
44
+ /** Backup retention in days. Default: 7 */
45
+ backupRetention: BackupRetentionSchema.optional(),
46
+ /** Database port. Default: engine-specific (5432 for PostgreSQL) */
47
+ port: DatabasePortSchema.optional(),
48
+ /** Make database publicly accessible (for local development). Default: false */
49
+ publiclyAccessible: z.boolean().optional(),
50
+ /** IP CIDR to allow when publicly accessible */
51
+ allowedIpCidr: z.string().optional(),
52
+ /** Instance type for RDS Instance databases (e.g., "t4g.small", "t4g.large") */
53
+ instanceType: z.string().optional(),
54
+ /** Allocated storage in GB for RDS Instance. Default: 20 */
55
+ allocatedStorage: z
56
+ .number()
57
+ .int(VALIDATION_MESSAGES.ALLOCATED_STORAGE.INTEGER)
58
+ .min(20, VALIDATION_MESSAGES.ALLOCATED_STORAGE.MIN)
59
+ .max(65536, VALIDATION_MESSAGES.ALLOCATED_STORAGE.MAX)
60
+ .optional(),
61
+ /** Enable Multi-AZ deployment for high availability. */
62
+ multiAz: z.boolean().optional(),
63
+ /** Read replica configuration for RDS Instance. Set to false to explicitly disable. */
64
+ readReplica: ReadReplicaConfigOrFalseSchema.optional(),
65
+ /** Aurora writer instance configuration. */
66
+ writer: AuroraWriterConfigSchema.optional(),
67
+ /** Aurora reader instances configuration. Set to false to explicitly disable. */
68
+ readers: AuroraReadersConfigOrFalseSchema.optional(),
69
+ /** Allow access from VPC CIDR (avoids cross-stack cyclic dependencies). */
70
+ allowVpcAccess: z.boolean().optional(),
71
+ /** Enhanced monitoring interval in seconds. */
72
+ monitoringInterval: MonitoringIntervalSchema.optional(),
73
+ /** Preferred maintenance window (e.g., "sun:05:00-sun:06:00"). */
74
+ preferredMaintenanceWindow: z.string().optional(),
75
+ /** Database Insights configuration. Set to false to explicitly disable. */
76
+ databaseInsights: DatabaseInsightsConfigOrFalseSchema.optional(),
77
+ /** RDS Proxy configuration for connection pooling. Set to false to explicitly disable. */
78
+ proxy: ProxyConfigOrFalseSchema.optional(),
79
+ /** Credentials configuration (username, rotation). */
80
+ credentials: CredentialsConfigSchema.optional(),
81
+ /** Encryption configuration. */
82
+ encryption: EncryptionConfigSchema.optional(),
83
+ /** ARN or identifier of snapshot to restore from */
84
+ snapshotIdentifier: z.string().optional(),
85
+ /** Username from the snapshot (required when restoring) */
86
+ snapshotUsername: z.string().optional(),
87
+ })
88
+ .strict();
89
+ // ─── Payload compute configuration ──────────────────────────────────────────
90
+ /**
91
+ * Full Payload compute configuration for pattern.
92
+ * Allows per-function configuration for each Lambda in the pattern.
93
+ */
94
+ export const PayloadComputeConfigSchema = z
95
+ .object({
96
+ /** Server Lambda configuration (handles main application requests). */
97
+ server: PatternLambdaConfigSchema.optional(),
98
+ /** Image optimisation Lambda configuration (handles Next.js image optimisation). */
99
+ imageOptimisation: PatternLambdaConfigSchema.optional(),
100
+ /** Revalidation Lambda configuration (handles ISR revalidation from SQS queue). */
101
+ revalidation: PatternLambdaConfigSchema.optional(),
102
+ })
103
+ .strict();
104
+ // ─── Payload storage configuration ──────────────────────────────────────────
105
+ /**
106
+ * Pattern storage bucket configuration.
107
+ */
108
+ export const PatternStorageBucketConfigSchema = z
109
+ .object({
110
+ /** Enable versioning. Default: false */
111
+ versioned: z.boolean().optional(),
112
+ })
113
+ .strict();
114
+ /**
115
+ * Full Payload storage configuration for pattern.
116
+ * Allows per-bucket configuration for each S3 bucket in the pattern.
117
+ */
118
+ export const PayloadStorageConfigSchema = z
119
+ .object({
120
+ /** Assets bucket (static files) */
121
+ assets: PatternStorageBucketConfigSchema.optional(),
122
+ /** Cache bucket (ISR cache) */
123
+ cache: PatternStorageBucketConfigSchema.optional(),
124
+ /** Media bucket (uploads) */
125
+ media: PatternStorageBucketConfigSchema.optional(),
126
+ })
127
+ .strict();
128
+ // ─── Payload messaging configuration ─────────────────────────────────────────
129
+ /**
130
+ * Pattern queue configuration for messaging.
131
+ */
132
+ export const PatternQueueConfigSchema = z
133
+ .object({
134
+ /** Visibility timeout in seconds. Default: matches revalidation timeout */
135
+ visibilityTimeout: z
136
+ .number()
137
+ .int(VALIDATION_MESSAGES.SQS.VISIBILITY_TIMEOUT.INTEGER)
138
+ .min(0, VALIDATION_MESSAGES.SQS.VISIBILITY_TIMEOUT.MIN)
139
+ .max(43200, VALIDATION_MESSAGES.SQS.VISIBILITY_TIMEOUT.MAX)
140
+ .optional(),
141
+ /** Message retention period in seconds. Default: 345600 (4 days) */
142
+ messageRetentionPeriod: z
143
+ .number()
144
+ .int(VALIDATION_MESSAGES.SQS.RETENTION_PERIOD.INTEGER)
145
+ .min(60, VALIDATION_MESSAGES.SQS.RETENTION_PERIOD.MIN)
146
+ .max(1209600, VALIDATION_MESSAGES.SQS.RETENTION_PERIOD.MAX)
147
+ .optional(),
148
+ /** Maximum message size in bytes. Default: 262144 (256 KB) */
149
+ maxMessageSize: z
150
+ .number()
151
+ .int(VALIDATION_MESSAGES.MAX_MESSAGE_SIZE.INTEGER)
152
+ .min(1024, VALIDATION_MESSAGES.MAX_MESSAGE_SIZE.MIN)
153
+ .max(262144, VALIDATION_MESSAGES.MAX_MESSAGE_SIZE.MAX)
154
+ .optional(),
155
+ /** Dead letter queue configuration. Set to false to explicitly disable. */
156
+ deadLetterQueue: z
157
+ .union([
158
+ z.literal(false),
159
+ z
160
+ .object({
161
+ enabled: z.boolean().optional(),
162
+ maxReceiveCount: z
163
+ .number()
164
+ .int(VALIDATION_MESSAGES.DLQ.MAX_RECEIVE_COUNT.INTEGER)
165
+ .min(1, VALIDATION_MESSAGES.DLQ.MAX_RECEIVE_COUNT.MIN)
166
+ .max(1000, VALIDATION_MESSAGES.DLQ.MAX_RECEIVE_COUNT.MAX)
167
+ .optional(),
168
+ })
169
+ .strict(),
170
+ ])
171
+ .optional(),
172
+ })
173
+ .strict();
174
+ /**
175
+ * Full Payload messaging configuration for pattern.
176
+ */
177
+ export const PayloadMessagingConfigSchema = z
178
+ .object({
179
+ /** Revalidation queue configuration */
180
+ revalidationQueue: PatternQueueConfigSchema.optional(),
181
+ })
182
+ .strict();
183
+ // ─── Payload CDN configuration ───────────────────────────────────────────────
184
+ /**
185
+ * Payload CDN configuration for pattern.
186
+ */
187
+ export const PayloadCdnConfigSchema = z
188
+ .object({
189
+ /** Custom domain names for CloudFront */
190
+ domainNames: z.array(z.string()).optional(),
191
+ /** ACM certificate ARN for custom domains (must be in us-east-1) */
192
+ certificateArn: z.string().optional(),
193
+ })
194
+ .strict();
195
+ // ─── Pattern config discriminated unions ─────────────────────────────────────
196
+ /**
197
+ * Payload pattern configuration.
198
+ */
199
+ export const PayloadPatternConfigSchema = z
200
+ .object({
201
+ type: z.literal("payload"),
202
+ /** Pattern name (used for resource naming) */
203
+ name: z.string().min(1, VALIDATION_MESSAGES.REQUIRED.PATTERN_NAME),
204
+ /** Custom domain (auto-creates certificate + DNS) */
205
+ domain: z.string().optional(),
206
+ /** Database configuration */
207
+ database: PayloadDatabaseConfigSchema.optional(),
208
+ /** Compute (Lambda) configuration */
209
+ compute: PayloadComputeConfigSchema.optional(),
210
+ /** Storage (S3) configuration */
211
+ storage: PayloadStorageConfigSchema.optional(),
212
+ /** Messaging (SQS) configuration */
213
+ messaging: PayloadMessagingConfigSchema.optional(),
214
+ /** CDN (CloudFront) configuration - advanced use, prefer `domain` for simple setup */
215
+ cdn: PayloadCdnConfigSchema.optional(),
216
+ /** Additional environment variables for server Lambda */
217
+ environment: z.record(z.string(), z.string()).optional(),
218
+ })
219
+ .strict();
220
+ /**
221
+ * Next.js pattern configuration.
222
+ * Shares the same OpenNext infrastructure as Payload but without
223
+ * requiring a database by default (pure Next.js with optional database).
224
+ */
225
+ export const NextJSPatternConfigSchema = z
226
+ .object({
227
+ type: z.literal("nextjs"),
228
+ /** Pattern name (used for resource naming) */
229
+ name: z.string().min(1, VALIDATION_MESSAGES.REQUIRED.PATTERN_NAME),
230
+ /** Custom domain (auto-creates certificate + DNS) */
231
+ domain: z.string().optional(),
232
+ /** Database configuration */
233
+ database: PayloadDatabaseConfigSchema.optional(),
234
+ /** Compute (Lambda) configuration */
235
+ compute: PayloadComputeConfigSchema.optional(),
236
+ /** Storage (S3) configuration */
237
+ storage: PayloadStorageConfigSchema.optional(),
238
+ /** Messaging (SQS) configuration */
239
+ messaging: PayloadMessagingConfigSchema.optional(),
240
+ /** CDN (CloudFront) configuration - advanced use, prefer `domain` for simple setup */
241
+ cdn: PayloadCdnConfigSchema.optional(),
242
+ /** Additional environment variables for server Lambda */
243
+ environment: z.record(z.string(), z.string()).optional(),
244
+ })
245
+ .strict();
246
+ /**
247
+ * Pattern configuration discriminated union.
248
+ * Extensible for future patterns (Remix, etc.)
249
+ */
250
+ export const PatternConfigSchema = z.discriminatedUnion("type", [
251
+ PayloadPatternConfigSchema,
252
+ NextJSPatternConfigSchema,
253
+ ]);
254
+ // ─── Pattern tier / custom pattern schemas ───────────────────────────────────
255
+ /**
256
+ * Pattern tier schema for OpenNext patterns (Payload, Next.js).
257
+ * Defines configuration tiers: lightweight, standard, resilient, custom.
258
+ */
259
+ export const PatternTierSchema = z.enum([
260
+ "lightweight",
261
+ "standard",
262
+ "resilient",
263
+ "custom",
264
+ ]);
265
+ /**
266
+ * Custom database configuration for patterns.
267
+ * Used when patternTier is "custom".
268
+ */
269
+ export const CustomPatternDatabaseSchema = z
270
+ .object({
271
+ type: z.enum(["Instance", "Aurora"]),
272
+ instanceType: z.string().optional(),
273
+ backupRetention: BackupRetentionSchema.optional(),
274
+ deletionProtection: z.boolean().optional(),
275
+ encryption: z
276
+ .union([z.object({ useCMK: z.literal(true) }).strict(), z.literal(false)])
277
+ .optional(),
278
+ })
279
+ .strict();
280
+ /**
281
+ * Custom compute configuration for patterns.
282
+ * Used when patternTier is "custom".
283
+ */
284
+ export const CustomPatternComputeSchema = z
285
+ .object({
286
+ memorySize: LambdaMemorySchema.optional(),
287
+ timeout: z
288
+ .number()
289
+ .int(VALIDATION_MESSAGES.LAMBDA.TIMEOUT.INTEGER)
290
+ .min(1, VALIDATION_MESSAGES.LAMBDA.TIMEOUT.MIN)
291
+ .max(900, VALIDATION_MESSAGES.LAMBDA.TIMEOUT.MAX)
292
+ .optional(),
293
+ })
294
+ .strict();