@fjall/generator 0.89.5 → 0.89.6

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 (168) hide show
  1. package/LICENSE +50 -21
  2. package/README.md +28 -0
  3. package/dist/.minified +1 -0
  4. package/dist/src/ast/astCdnParser.d.ts +5 -0
  5. package/dist/src/ast/astCdnParser.js +1 -114
  6. package/dist/src/ast/astCommonParser.d.ts +6 -17
  7. package/dist/src/ast/astCommonParser.js +1 -351
  8. package/dist/src/ast/astComputeConnectionParser.d.ts +18 -0
  9. package/dist/src/ast/astComputeConnectionParser.js +1 -0
  10. package/dist/src/ast/astComputeParser.d.ts +6 -0
  11. package/dist/src/ast/astComputeParser.js +1 -473
  12. package/dist/src/ast/astComputeParserHelpers.d.ts +21 -0
  13. package/dist/src/ast/astComputeParserHelpers.js +1 -0
  14. package/dist/src/ast/astDatabaseParser.d.ts +9 -24
  15. package/dist/src/ast/astDatabaseParser.js +1 -275
  16. package/dist/src/ast/astDomainParser.d.ts +139 -0
  17. package/dist/src/ast/astDomainParser.js +1 -0
  18. package/dist/src/ast/astDynamoDBParser.d.ts +35 -0
  19. package/dist/src/ast/astDynamoDBParser.js +1 -0
  20. package/dist/src/ast/astExpressionEvaluator.d.ts +23 -0
  21. package/dist/src/ast/astExpressionEvaluator.js +1 -0
  22. package/dist/src/ast/astInfrastructureParser.d.ts +12 -49
  23. package/dist/src/ast/astInfrastructureParser.js +1 -552
  24. package/dist/src/ast/astMessagingParser.d.ts +5 -0
  25. package/dist/src/ast/astMessagingParser.js +1 -78
  26. package/dist/src/ast/astNetworkParser.d.ts +6 -0
  27. package/dist/src/ast/astNetworkParser.js +1 -219
  28. package/dist/src/ast/astPatternParser.d.ts +6 -0
  29. package/dist/src/ast/astPatternParser.js +1 -155
  30. package/dist/src/ast/astPlanConverter.d.ts +11 -0
  31. package/dist/src/ast/astPlanConverter.js +2 -0
  32. package/dist/src/ast/astStatementClassifier.d.ts +24 -0
  33. package/dist/src/ast/astStatementClassifier.js +1 -0
  34. package/dist/src/ast/astStatementQueries.d.ts +21 -0
  35. package/dist/src/ast/astStatementQueries.js +3 -0
  36. package/dist/src/ast/astStorageParser.d.ts +5 -0
  37. package/dist/src/ast/astStorageParser.js +1 -164
  38. package/dist/src/ast/astSurgicalModification.js +19 -400
  39. package/dist/src/ast/astTestHelpers.d.ts +635 -0
  40. package/dist/src/ast/astTestHelpers.js +1 -0
  41. package/dist/src/ast/index.d.ts +1 -0
  42. package/dist/src/ast/index.js +1 -6
  43. package/dist/src/aws/regions.js +1 -254
  44. package/dist/src/codemod/_internal.d.ts +12 -0
  45. package/dist/src/codemod/_internal.js +1 -0
  46. package/dist/src/codemod/edits/addResource/bodyIndex.d.ts +34 -0
  47. package/dist/src/codemod/edits/addResource/bodyIndex.js +1 -0
  48. package/dist/src/codemod/edits/addResource/propertyBuilder.d.ts +7 -0
  49. package/dist/src/codemod/edits/addResource/propertyBuilder.js +1 -0
  50. package/dist/src/codemod/edits/addResource.d.ts +9 -0
  51. package/dist/src/codemod/edits/addResource.js +1 -0
  52. package/dist/src/codemod/edits/ensureImports.d.ts +26 -0
  53. package/dist/src/codemod/edits/ensureImports.js +1 -0
  54. package/dist/src/codemod/edits/findInsertionPosition.d.ts +39 -0
  55. package/dist/src/codemod/edits/findInsertionPosition.js +1 -0
  56. package/dist/src/codemod/edits/index.d.ts +6 -0
  57. package/dist/src/codemod/edits/index.js +1 -0
  58. package/dist/src/codemod/edits/modifyResource/literalConversion.d.ts +37 -0
  59. package/dist/src/codemod/edits/modifyResource/literalConversion.js +1 -0
  60. package/dist/src/codemod/edits/modifyResource.d.ts +9 -0
  61. package/dist/src/codemod/edits/modifyResource.js +1 -0
  62. package/dist/src/codemod/edits/removeResource/commentHeuristic.d.ts +31 -0
  63. package/dist/src/codemod/edits/removeResource/commentHeuristic.js +1 -0
  64. package/dist/src/codemod/edits/removeResource/importPruning.d.ts +8 -0
  65. package/dist/src/codemod/edits/removeResource/importPruning.js +1 -0
  66. package/dist/src/codemod/edits/removeResource.d.ts +10 -0
  67. package/dist/src/codemod/edits/removeResource.js +1 -0
  68. package/dist/src/codemod/edits/schemaFragments.d.ts +9 -0
  69. package/dist/src/codemod/edits/schemaFragments.js +1 -0
  70. package/dist/src/codemod/fileRewriter/builders.d.ts +57 -0
  71. package/dist/src/codemod/fileRewriter/builders.js +1 -0
  72. package/dist/src/codemod/fileRewriter/index.d.ts +4 -0
  73. package/dist/src/codemod/fileRewriter/index.js +1 -0
  74. package/dist/src/codemod/fileRewriter/locateByRange.d.ts +65 -0
  75. package/dist/src/codemod/fileRewriter/locateByRange.js +1 -0
  76. package/dist/src/codemod/fileRewriter/parse.d.ts +18 -0
  77. package/dist/src/codemod/fileRewriter/parse.js +2 -0
  78. package/dist/src/codemod/fileRewriter/print.d.ts +46 -0
  79. package/dist/src/codemod/fileRewriter/print.js +4 -0
  80. package/dist/src/codemod/historyPaths.d.ts +2 -0
  81. package/dist/src/codemod/historyPaths.js +1 -0
  82. package/dist/src/codemod/index.d.ts +7 -0
  83. package/dist/src/codemod/index.js +1 -0
  84. package/dist/src/codemod/listResources.d.ts +4 -0
  85. package/dist/src/codemod/listResources.js +1 -0
  86. package/dist/src/codemod/semanticIndex/findReferences.d.ts +15 -0
  87. package/dist/src/codemod/semanticIndex/findReferences.js +2 -0
  88. package/dist/src/codemod/semanticIndex/index.d.ts +4 -0
  89. package/dist/src/codemod/semanticIndex/index.js +1 -0
  90. package/dist/src/codemod/semanticIndex/listImports.d.ts +24 -0
  91. package/dist/src/codemod/semanticIndex/listImports.js +1 -0
  92. package/dist/src/codemod/semanticIndex/locateByShape.d.ts +28 -0
  93. package/dist/src/codemod/semanticIndex/locateByShape.js +1 -0
  94. package/dist/src/codemod/semanticIndex/projectCache.d.ts +14 -0
  95. package/dist/src/codemod/semanticIndex/projectCache.js +1 -0
  96. package/dist/src/codemod/types.d.ts +172 -0
  97. package/dist/src/codemod/types.js +1 -0
  98. package/dist/src/dns/bindParser.js +2 -224
  99. package/dist/src/dns/bindWriter.js +3 -52
  100. package/dist/src/dns/domainFileGenerator.d.ts +20 -0
  101. package/dist/src/dns/domainFileGenerator.js +207 -0
  102. package/dist/src/dns/domainRecords.d.ts +164 -0
  103. package/dist/src/dns/domainRecords.js +1 -0
  104. package/dist/src/dns/index.d.ts +2 -1
  105. package/dist/src/dns/index.js +1 -4
  106. package/dist/src/dns/types.js +1 -52
  107. package/dist/src/generation/common.js +6 -161
  108. package/dist/src/generation/compute.js +82 -590
  109. package/dist/src/generation/database.js +12 -198
  110. package/dist/src/generation/generatePatternCode.d.ts +58 -0
  111. package/dist/src/generation/generatePatternCode.js +33 -0
  112. package/dist/src/generation/index.js +1 -20
  113. package/dist/src/generation/infrastructure.d.ts +1 -5
  114. package/dist/src/generation/infrastructure.js +35 -377
  115. package/dist/src/generation/messagingConnections.js +1 -73
  116. package/dist/src/generation/storage.d.ts +0 -15
  117. package/dist/src/generation/storage.js +35 -168
  118. package/dist/src/generation/storageConnections.js +1 -75
  119. package/dist/src/planning/generateResourceChange.d.ts +21 -0
  120. package/dist/src/planning/generateResourceChange.js +1 -0
  121. package/dist/src/planning/index.d.ts +3 -0
  122. package/dist/src/planning/index.js +1 -1
  123. package/dist/src/planning/resourceAddition.d.ts +154 -0
  124. package/dist/src/planning/resourceAddition.js +1 -0
  125. package/dist/src/planning/resourceConnections.d.ts +19 -0
  126. package/dist/src/planning/resourceConnections.js +1 -0
  127. package/dist/src/planning/resourcePlanning.js +1 -214
  128. package/dist/src/presets/index.js +1 -3
  129. package/dist/src/presets/patternTierPresets.js +1 -131
  130. package/dist/src/presets/storagePresets.js +1 -36
  131. package/dist/src/presets/tierPresets.d.ts +5 -8
  132. package/dist/src/presets/tierPresets.js +1 -384
  133. package/dist/src/presets/tierTypes.d.ts +1 -1
  134. package/dist/src/presets/tierTypes.js +0 -7
  135. package/dist/src/schemas/alarmSchemas.d.ts +19 -0
  136. package/dist/src/schemas/alarmSchemas.js +1 -0
  137. package/dist/src/schemas/applicationSchemas.d.ts +22 -6
  138. package/dist/src/schemas/applicationSchemas.js +1 -80
  139. package/dist/src/schemas/baseSchemas.d.ts +8 -3
  140. package/dist/src/schemas/baseSchemas.js +2 -248
  141. package/dist/src/schemas/cdnSchemas.js +1 -62
  142. package/dist/src/schemas/computeSchemas.d.ts +25 -3
  143. package/dist/src/schemas/computeSchemas.js +1 -727
  144. package/dist/src/schemas/constants.d.ts +5 -7
  145. package/dist/src/schemas/constants.js +1 -218
  146. package/dist/src/schemas/databaseSchemas.d.ts +6 -1
  147. package/dist/src/schemas/databaseSchemas.js +1 -366
  148. package/dist/src/schemas/index.js +1 -3
  149. package/dist/src/schemas/instanceTypeArchitecture.js +1 -75
  150. package/dist/src/schemas/messagingSchemas.js +1 -29
  151. package/dist/src/schemas/networkSchemas.js +1 -125
  152. package/dist/src/schemas/patternSchemas.d.ts +1 -1
  153. package/dist/src/schemas/patternSchemas.js +1 -294
  154. package/dist/src/schemas/resourceSchemas.d.ts +1 -0
  155. package/dist/src/schemas/resourceSchemas.js +1 -28
  156. package/dist/src/schemas/sharedTypes.d.ts +18 -0
  157. package/dist/src/schemas/sharedTypes.js +1 -0
  158. package/dist/src/schemas/storageSchemas.d.ts +1 -0
  159. package/dist/src/schemas/storageSchemas.js +1 -119
  160. package/dist/src/types/Result.js +1 -31
  161. package/dist/src/util/errorUtils.js +1 -1
  162. package/dist/src/validation/patterns.d.ts +9 -0
  163. package/dist/src/validation/patterns.js +1 -369
  164. package/dist/src/version.d.ts +1 -1
  165. package/dist/src/version.js +1 -1
  166. package/package.json +29 -9
  167. package/dist/src/dns/infrastructureWriter.d.ts +0 -2
  168. package/dist/src/dns/infrastructureWriter.js +0 -58
@@ -1,214 +1 @@
1
- import { TIER_PRESETS, getDefaultDatabaseTypeForTier, getNetworkPreset, applyTierDefaultsToServices, } from "../presets/tierPresets.js";
2
- import { getPatternTierPreset, isPatternTierName, } from "../presets/patternTierPresets.js";
3
- import { COMPUTE_TYPE } from "../schemas/constants.js";
4
- import { success, failure } from "../types/Result.js";
5
- import { PatternConfigSchema } from "../schemas/resourceSchemas.js";
6
- import { injectCustomCodeBlocks } from "../ast/astSurgicalModification.js";
7
- import { toVariableName, toValidDatabaseName, generateImports, generateAppInit, generateTags, generateNetworkCode, generateDatabaseCode, generateS3Code, generateDynamoDBCode, generateSQSCode, generateComputeCode, generateCDNCode, collectCdnReferencedResources, usesPatternApproach, generatePatternCodeWithComments, } from "../generation/index.js";
8
- const DEFAULT_NETWORK = getNetworkPreset("standard");
9
- /** Type guard that narrows a pattern string to a supported PatternConfig type via Zod schema. */
10
- function isPatternConfigType(value) {
11
- return PatternConfigSchema.options.some((schema) => schema.shape?.type?.value === value);
12
- }
13
- export function planApplicationResources(appName, appType, includeDatabase = true, services, snapshotOptions) {
14
- const basePlan = {
15
- appName,
16
- type: appType,
17
- database: [],
18
- s3: [],
19
- compute: [],
20
- };
21
- if (appType === "custom") {
22
- return basePlan;
23
- }
24
- const tier = appType;
25
- const tierPreset = TIER_PRESETS[tier];
26
- return {
27
- ...basePlan,
28
- database: buildDatabasePlan(appName, tierPreset, tier, includeDatabase, snapshotOptions),
29
- compute: buildComputePlan(appName, tierPreset, tier, includeDatabase, services),
30
- network: tierPreset.network,
31
- backup: tierPreset.backup,
32
- };
33
- }
34
- function buildDatabasePlan(appName, tierPreset, tier, includeDatabase, snapshotOptions) {
35
- const databaseType = getDefaultDatabaseTypeForTier(tier);
36
- const databasePreset = tierPreset.database[databaseType];
37
- if (!includeDatabase || databasePreset === null)
38
- return [];
39
- return [
40
- {
41
- name: appName,
42
- type: databaseType,
43
- databaseName: toValidDatabaseName(appName),
44
- variableName: `${toVariableName(appName)}Database`,
45
- ...databasePreset,
46
- ...(snapshotOptions?.snapshotIdentifier !== undefined && {
47
- snapshotIdentifier: snapshotOptions.snapshotIdentifier,
48
- }),
49
- ...(snapshotOptions?.snapshotUsername !== undefined && {
50
- snapshotUsername: snapshotOptions.snapshotUsername,
51
- }),
52
- },
53
- ];
54
- }
55
- function buildScalingConfig(minCapacity, maxCapacity) {
56
- if (minCapacity === undefined && maxCapacity === undefined)
57
- return undefined;
58
- return {
59
- scaling: {
60
- ...(minCapacity !== undefined && { minCapacity }),
61
- ...(maxCapacity !== undefined && { maxCapacity }),
62
- },
63
- };
64
- }
65
- function buildServiceEntry(tierService, userService) {
66
- const { minCapacity, maxCapacity, ...rest } = tierService;
67
- const containerPort = userService?.containerPort ?? 3000;
68
- return {
69
- ...rest,
70
- dockerfilePath: userService?.dockerfilePath,
71
- needsDatabaseConnection: userService?.needsDatabaseConnection,
72
- containers: [{ port: containerPort }],
73
- ...buildScalingConfig(minCapacity, maxCapacity),
74
- };
75
- }
76
- function buildComputePlan(appName, tierPreset, tier, includeDatabase, services) {
77
- const ecsPreset = tierPreset.compute.ecs;
78
- const tierServices = services && services.length > 0
79
- ? applyTierDefaultsToServices(tier, services)
80
- : ecsPreset.services.map((s, i) => ({
81
- ...s,
82
- name: i === 0 ? "api" : `service-${i + 1}`,
83
- }));
84
- return [
85
- {
86
- name: appName,
87
- type: COMPUTE_TYPE.ECS,
88
- needsConnection: includeDatabase,
89
- connectedDatabase: includeDatabase ? [appName] : undefined,
90
- variableName: `${toVariableName(appName)}Compute`,
91
- cluster: ecsPreset.cluster,
92
- services: tierServices.map((tierService, index) => buildServiceEntry(tierService, services?.[index])),
93
- },
94
- ];
95
- }
96
- /**
97
- * Plan resources for OpenNext patterns (Next.js/Payload).
98
- *
99
- * All OpenNext patterns use the PatternFactory approach, generating a single
100
- * `PatternFactory.build()` call. The pattern class internally handles all
101
- * infrastructure (database, S3, DynamoDB, SQS, Lambdas, CDN).
102
- *
103
- * @example
104
- * const plan = planOpenNextResources("my-cms", "payload", { tier: "standard" });
105
- */
106
- export function planOpenNextResources(appName, pattern, options) {
107
- const { tier = "standard", domain, database, compute, cdn, environment, tags, } = options ?? {};
108
- const validTier = isPatternTierName(tier);
109
- if (!validTier && tier !== "custom") {
110
- return failure(new Error(`Invalid pattern tier: "${tier}". Valid tiers are: lightweight, standard, resilient, custom`));
111
- }
112
- if (!isPatternConfigType(pattern)) {
113
- return failure(new Error(`Unsupported pattern type: ${pattern}`));
114
- }
115
- const tierPreset = validTier ? getPatternTierPreset(tier) : null;
116
- const patternConfig = buildPatternConfig(pattern, appName, {
117
- domain,
118
- database,
119
- compute,
120
- cdn,
121
- environment,
122
- tierPreset,
123
- });
124
- if (patternConfig instanceof Error) {
125
- return failure(patternConfig);
126
- }
127
- return success({
128
- appName,
129
- type: "standard",
130
- pattern,
131
- network: tierPreset ? tierPreset.network : DEFAULT_NETWORK,
132
- backup: tierPreset ? tierPreset.backup : false,
133
- patternConfig,
134
- database: [],
135
- s3: [],
136
- compute: [],
137
- tags: tags ?? {},
138
- });
139
- }
140
- function mergeDatabaseConfig(database, tierPreset) {
141
- return {
142
- type: database?.type ?? tierPreset.database.type,
143
- instanceType: database?.instanceType ?? tierPreset.database.instanceType,
144
- databaseName: database?.databaseName,
145
- publiclyAccessible: database?.publiclyAccessible,
146
- allowedIpCidr: database?.allowedIpCidr,
147
- backupRetention: database?.backupRetention ?? tierPreset.database.backupRetention,
148
- deletionProtection: database?.deletionProtection ?? tierPreset.database.deletionProtection,
149
- encryption: database?.encryption,
150
- };
151
- }
152
- function mergeComputeConfig(compute, tierPreset) {
153
- return {
154
- memorySize: compute?.memorySize ?? tierPreset.compute.memorySize,
155
- timeout: compute?.timeout ?? tierPreset.compute.timeout,
156
- };
157
- }
158
- function toPatternDatabaseConfig(db) {
159
- const { encryption, ...rest } = db;
160
- return {
161
- ...rest,
162
- ...(encryption && { encryption: { storageKey: encryption } }),
163
- };
164
- }
165
- function buildPatternConfig(type, appName, opts) {
166
- const { domain, database, compute, cdn, environment, tierPreset } = opts;
167
- const mergedDatabase = tierPreset
168
- ? mergeDatabaseConfig(database, tierPreset)
169
- : database;
170
- const mergedCompute = tierPreset
171
- ? mergeComputeConfig(compute, tierPreset)
172
- : compute;
173
- const config = {
174
- type,
175
- name: appName,
176
- domain,
177
- database: mergedDatabase
178
- ? toPatternDatabaseConfig(mergedDatabase)
179
- : undefined,
180
- compute: mergedCompute ? { server: mergedCompute } : undefined,
181
- cdn: cdn
182
- ? { domainNames: cdn.domainNames, certificateArn: cdn.certificateArn }
183
- : undefined,
184
- environment,
185
- };
186
- const result = PatternConfigSchema.safeParse(config);
187
- if (!result.success) {
188
- return new Error(`Invalid pattern config: ${result.error.message}`);
189
- }
190
- return result.data;
191
- }
192
- export function generateInfrastructureFromPlan(plan, options) {
193
- const parts = [
194
- generateImports(plan),
195
- generateAppInit(plan),
196
- generateTags(plan),
197
- ];
198
- if (usesPatternApproach(plan)) {
199
- parts.push(generatePatternCodeWithComments(plan), generateNetworkCode(plan));
200
- }
201
- else {
202
- const cdnReferencedResources = collectCdnReferencedResources(plan);
203
- parts.push(generateNetworkCode(plan), generateDatabaseCode(plan), generateS3Code(plan), generateDynamoDBCode(plan), generateSQSCode(plan), generateComputeCode(plan, cdnReferencedResources), generateCDNCode(plan));
204
- }
205
- const code = parts.join("");
206
- if (plan.customCodeBlocks && plan.customCodeBlocks.length > 0) {
207
- const injectionResult = injectCustomCodeBlocks(code, plan.customCodeBlocks, options?.resourceMapping);
208
- if (!injectionResult.success) {
209
- return failure(new Error(`Custom code injection failed: ${injectionResult.error ?? "unknown error"}`));
210
- }
211
- return success(injectionResult.content);
212
- }
213
- return success(code);
214
- }
1
+ import{TIER_PRESETS as P,getDefaultDatabaseTypeForTier as y,getNetworkPreset as k,applyTierDefaultsToServices as T}from"../presets/tierPresets.js";import{getPatternTierPreset as h,isPatternTierName as D}from"../presets/patternTierPresets.js";import{COMPUTE_TYPE as w}from"../schemas/constants.js";import{success as g,failure as l}from"../types/Result.js";import{PatternConfigSchema as p}from"../schemas/resourceSchemas.js";import{injectCustomCodeBlocks as E}from"../ast/astSurgicalModification.js";import{toVariableName as b,toValidDatabaseName as R,generateImports as S,generateAppInit as I,generateTags as v,generateNetworkCode as C,generateDatabaseCode as A,generateS3Code as N,generateDynamoDBCode as $,generateSQSCode as U,generateComputeCode as B,generateCDNCode as j,collectCdnReferencedResources as x,usesPatternApproach as z,generatePatternCodeWithComments as F}from"../generation/index.js";const V=k("standard");function _(e){return p.options.some(t=>t.shape?.type?.value===e)}function ne(e,t,r=!0,o,n){const i={appName:e,type:t,database:[],s3:[],compute:[]};if(t==="custom")return i;const a=t,s=P[a];return{...i,database:K(e,s,a,r,n),compute:L(e,s,a,r,o),network:s.network,backup:s.backup}}function K(e,t,r,o,n){const i=y(r),a=t.database[i];return!o||a===null?[]:[{name:e,type:i,databaseName:R(e),variableName:`${b(e)}Database`,...a,...n?.snapshotIdentifier!==void 0&&{snapshotIdentifier:n.snapshotIdentifier},...n?.snapshotUsername!==void 0&&{snapshotUsername:n.snapshotUsername}}]}function M(e,t){if(!(e===void 0&&t===void 0))return{scaling:{...e!==void 0&&{minCapacity:e},...t!==void 0&&{maxCapacity:t}}}}function W(e,t){const{minCapacity:r,maxCapacity:o,...n}=e,i=t?.containerPort??3e3;return{...n,dockerfilePath:t?.dockerfilePath,needsDatabaseConnection:t?.needsDatabaseConnection,containers:[{port:i}],...M(r,o)}}function L(e,t,r,o,n){const i=t.compute.ecs,a=n&&n.length>0?T(r,n):i.services.map((s,c)=>({...s,name:c===0?"api":`service-${c+1}`}));return[{name:e,type:w.ECS,needsConnection:o,connectedDatabase:o?[e]:void 0,variableName:`${b(e)}Compute`,cluster:i.cluster,services:a.map((s,c)=>W(s,n?.[c]))}]}function re(e,t,r){const{tier:o="standard",domain:n,database:i,compute:a,cdn:s,environment:c,tags:f}=r??{},m=D(o);if(!m&&o!=="custom")return l(new Error(`Invalid pattern tier: "${o}". Valid tiers are: lightweight, standard, resilient, custom`));if(!_(t))return l(new Error(`Unsupported pattern type: ${t}`));const u=m?h(o):null,d=G(t,e,{domain:n,database:i,compute:a,cdn:s,environment:c,tierPreset:u});return d instanceof Error?l(d):g({appName:e,type:"standard",pattern:t,network:u?u.network:V,backup:u?u.backup:!1,patternConfig:d,database:[],s3:[],compute:[],tags:f??{}})}function Q(e,t){return{type:e?.type??t.database.type,instanceType:e?.instanceType??t.database.instanceType,databaseName:e?.databaseName,publiclyAccessible:e?.publiclyAccessible,allowedIpCidr:e?.allowedIpCidr,backupRetention:e?.backupRetention??t.database.backupRetention,deletionProtection:e?.deletionProtection??t.database.deletionProtection,encryption:e?.encryption}}function Y(e,t){return{memorySize:e?.memorySize??t.compute.memorySize,timeout:e?.timeout??t.compute.timeout}}function q(e){const{encryption:t,...r}=e;return{...r,...t&&{encryption:{storageKey:t}}}}function G(e,t,r){const{domain:o,database:n,compute:i,cdn:a,environment:s,tierPreset:c}=r,f=c?Q(n,c):n,m=c?Y(i,c):i,u={type:e,name:t,domain:o,database:f?q(f):void 0,compute:m?{server:m}:void 0,cdn:a?{domainNames:a.domainNames,certificateArn:a.certificateArn}:void 0,environment:s},d=p.safeParse(u);return d.success?d.data:new Error(`Invalid pattern config: ${d.error.message}`)}function oe(e,t){const r=[S(e),I(e),v(e)];if(z(e))r.push(F(e),C(e));else{const n=x(e);r.push(C(e),A(e),N(e),$(e),U(e),B(e,n),j(e))}const o=r.join("");if(e.customCodeBlocks&&e.customCodeBlocks.length>0){const n=E(o,e.customCodeBlocks,t?.resourceMapping);return n.success?g(n.content):l(new Error(`Custom code injection failed: ${n.error??"unknown error"}`))}return g(o)}export{oe as generateInfrastructureFromPlan,ne as planApplicationResources,re as planOpenNextResources};
@@ -1,3 +1 @@
1
- export * from "./tierPresets.js";
2
- export { PATTERN_TIER_NAMES, PATTERN_TYPES_WITH_CUSTOM, PATTERN_TIER_PRESETS, getPatternTierPreset, getPatternTierOptions, isPatternTierName, } from "./patternTierPresets.js";
3
- export { STORAGE_PRESETS, getStoragePreset, getStoragePresetOptions, } from "./storagePresets.js";
1
+ export*from"./tierPresets.js";import{PATTERN_TIER_NAMES as T,PATTERN_TYPES_WITH_CUSTOM as E,PATTERN_TIER_PRESETS as P,getPatternTierPreset as o,getPatternTierOptions as S,isPatternTierName as R}from"./patternTierPresets.js";import{STORAGE_PRESETS as a,getStoragePreset as g,getStoragePresetOptions as i}from"./storagePresets.js";export{T as PATTERN_TIER_NAMES,P as PATTERN_TIER_PRESETS,E as PATTERN_TYPES_WITH_CUSTOM,a as STORAGE_PRESETS,S as getPatternTierOptions,o as getPatternTierPreset,g as getStoragePreset,i as getStoragePresetOptions,R as isPatternTierName};
@@ -1,131 +1 @@
1
- /**
2
- * Pattern Tier Presets
3
- *
4
- * Defines configuration presets for OpenNext patterns (Payload, Next.js).
5
- * Mirrors the application TIER_PRESETS structure for consistency.
6
- *
7
- * Architecture:
8
- * - PATTERN_TIER_PRESETS defines what each tier means for patterns
9
- * - planOpenNextResources() uses these during `fjall create`
10
- * - CreateScreen uses these for pattern tier selection
11
- * - Custom mode bypasses presets and prompts for each parameter
12
- */
13
- /**
14
- * Pattern tier names - ordered from least to most capable/expensive
15
- * Tinkerer and Enterprise are deferred for future implementation.
16
- */
17
- export const PATTERN_TIER_NAMES = [
18
- "lightweight",
19
- "standard",
20
- "resilient",
21
- ];
22
- export const PATTERN_TYPES_WITH_CUSTOM = [
23
- ...PATTERN_TIER_NAMES,
24
- "custom",
25
- ];
26
- /**
27
- * Master configuration for all pattern tiers.
28
- *
29
- * | Tier | Database | Lambda Memory | Lambda Timeout | Network |
30
- * |-------------|----------------------|---------------|----------------|------------------|
31
- * | Lightweight | Instance (t4g.small) | 512 MB | 30s | 2 AZ, 1 NAT |
32
- * | Standard | Instance (t4g.large) | 1536 MB | 60s | 3 AZ, 1 NAT |
33
- * | Resilient | Aurora V2 + KMS | 2048 MB | 120s | 3 AZ, 3 NAT |
34
- */
35
- export const PATTERN_TIER_PRESETS = Object.freeze({
36
- lightweight: {
37
- displayName: "Lightweight",
38
- description: "Cost-effective · Instance DB, minimal Lambda",
39
- database: {
40
- type: "Instance",
41
- instanceType: "t4g.small",
42
- backupRetention: 7,
43
- deletionProtection: false,
44
- },
45
- compute: {
46
- memorySize: 512,
47
- timeout: 30,
48
- },
49
- network: { maxAzs: 2, natGateways: { count: 1 }, flowLogs: false },
50
- backup: false,
51
- },
52
- standard: {
53
- displayName: "Standard",
54
- description: "Production-ready · Instance DB, balanced Lambda",
55
- database: {
56
- type: "Instance",
57
- instanceType: "t4g.large",
58
- backupRetention: 14,
59
- deletionProtection: true,
60
- },
61
- compute: {
62
- memorySize: 1536,
63
- timeout: 60,
64
- },
65
- network: { maxAzs: 3, natGateways: { count: 1 }, flowLogs: {} },
66
- backup: { tier: "standard" },
67
- },
68
- resilient: {
69
- displayName: "Resilient",
70
- description: "High-availability · Aurora V2, KMS encryption",
71
- database: {
72
- type: "Aurora",
73
- backupRetention: 30,
74
- deletionProtection: true,
75
- encryption: { useCMK: true },
76
- },
77
- compute: {
78
- memorySize: 2048,
79
- timeout: 120,
80
- },
81
- network: {
82
- maxAzs: 3,
83
- natGateways: { count: 3 },
84
- flowLogs: { retentionDays: 90 },
85
- },
86
- backup: { tier: "resilient" },
87
- },
88
- });
89
- /**
90
- * Get pattern tier preset by name.
91
- */
92
- export function getPatternTierPreset(tier) {
93
- return PATTERN_TIER_PRESETS[tier];
94
- }
95
- /**
96
- * Get tier options formatted for UI Select component.
97
- */
98
- export function getPatternTierOptions() {
99
- return [
100
- {
101
- label: PATTERN_TIER_PRESETS.standard.displayName,
102
- value: "standard",
103
- description: PATTERN_TIER_PRESETS.standard.description,
104
- },
105
- {
106
- label: PATTERN_TIER_PRESETS.lightweight.displayName,
107
- value: "lightweight",
108
- description: PATTERN_TIER_PRESETS.lightweight.description,
109
- },
110
- {
111
- label: PATTERN_TIER_PRESETS.resilient.displayName,
112
- value: "resilient",
113
- description: PATTERN_TIER_PRESETS.resilient.description,
114
- },
115
- {
116
- label: "Custom",
117
- value: "custom",
118
- description: "Full control · Configure everything",
119
- },
120
- ];
121
- }
122
- /**
123
- * Set of pattern tier names for O(1) lookup.
124
- */
125
- const PATTERN_TIER_NAMES_SET = new Set(PATTERN_TIER_NAMES);
126
- /**
127
- * Check if a tier name is a valid pattern tier.
128
- */
129
- export function isPatternTierName(tier) {
130
- return PATTERN_TIER_NAMES_SET.has(tier);
131
- }
1
+ const i=["lightweight","standard","resilient"],n=[...i,"custom"],e=Object.freeze({lightweight:{displayName:"Lightweight",description:"Cost-effective \xB7 Instance DB, minimal Lambda",database:{type:"Instance",instanceType:"t4g.small",backupRetention:7,deletionProtection:!1},compute:{memorySize:512,timeout:30},network:{maxAzs:2,natGateways:{count:1},flowLogs:!1},backup:!1},standard:{displayName:"Standard",description:"Production-ready \xB7 Instance DB, balanced Lambda",database:{type:"Instance",instanceType:"t4g.large",backupRetention:14,deletionProtection:!0},compute:{memorySize:1536,timeout:60},network:{maxAzs:3,natGateways:{count:1},flowLogs:{}},backup:{tier:"standard"}},resilient:{displayName:"Resilient",description:"High-availability \xB7 Aurora V2, KMS encryption",database:{type:"Aurora",backupRetention:30,deletionProtection:!0,encryption:{useCMK:!0}},compute:{memorySize:2048,timeout:120},network:{maxAzs:3,natGateways:{count:3},flowLogs:{retentionDays:90}},backup:{tier:"resilient"}}});function o(t){return e[t]}function r(){return[{label:e.standard.displayName,value:"standard",description:e.standard.description},{label:e.lightweight.displayName,value:"lightweight",description:e.lightweight.description},{label:e.resilient.displayName,value:"resilient",description:e.resilient.description},{label:"Custom",value:"custom",description:"Full control \xB7 Configure everything"}]}const a=new Set(i);function s(t){return a.has(t)}export{i as PATTERN_TIER_NAMES,e as PATTERN_TIER_PRESETS,n as PATTERN_TYPES_WITH_CUSTOM,r as getPatternTierOptions,o as getPatternTierPreset,s as isPatternTierName};
@@ -1,36 +1 @@
1
- export const STORAGE_PRESETS = Object.freeze({
2
- standard: {},
3
- assets: {
4
- versioned: true,
5
- deployment: {
6
- source: "./assets",
7
- },
8
- },
9
- upload: {
10
- versioned: true,
11
- cors: [
12
- {
13
- allowedOrigins: ["*"],
14
- allowedMethods: ["GET", "PUT", "POST"],
15
- },
16
- ],
17
- },
18
- website: {
19
- publicReadAccess: true,
20
- websiteHosting: {
21
- indexDocument: "index.html",
22
- errorDocument: "error.html",
23
- },
24
- },
25
- });
26
- export function getStoragePreset(preset) {
27
- return { ...STORAGE_PRESETS[preset] };
28
- }
29
- export function getStoragePresetOptions() {
30
- return [
31
- { label: "Standard", value: "standard" },
32
- { label: "Assets", value: "assets" },
33
- { label: "Upload", value: "upload" },
34
- { label: "Website Hosting", value: "website" },
35
- ];
36
- }
1
+ const t=Object.freeze({standard:{},assets:{versioned:!0,deployment:{source:"./assets"}},upload:{versioned:!0,cors:[{allowedOrigins:["*"],allowedMethods:["GET","PUT","POST"]}]},website:{publicReadAccess:!0,websiteHosting:{indexDocument:"index.html",errorDocument:"error.html"}}});function s(e){return{...t[e]}}function r(){return[{label:"Standard",value:"standard"},{label:"Assets",value:"assets"},{label:"Upload",value:"upload"},{label:"Website Hosting",value:"website"}]}export{t as STORAGE_PRESETS,s as getStoragePreset,r as getStoragePresetOptions};
@@ -13,18 +13,15 @@
13
13
  *
14
14
  * Type definitions live in ./tierTypes.ts and are re-exported here.
15
15
  */
16
- import type { DatabaseType } from "../schemas/constants.js";
16
+ import { type TierName, type DatabaseType } from "../schemas/sharedTypes.js";
17
17
  import type { TierProxyConfig, TierReadReplicaConfig, TierCredentialsConfig, TierAuroraReadersConfig, TierDatabaseInsightsConfig, TierEncryptionConfig, DatabaseTierPreset, TierEc2CapacityConfig, TierClusterConfig, TierEcsServiceConfig, EcsTierPreset, LambdaTierPreset, TierNatConfig, TierFlowLogConfig, TierGatewayEndpointsConfig, TierInterfaceEndpointsConfig, TierVpcEndpointsConfig, NetworkTierPreset, TierPreset, UserServiceConfig } from "./tierTypes.js";
18
18
  export type { TierProxyConfig, TierReadReplicaConfig, TierCredentialsConfig, TierAuroraReadersConfig, TierDatabaseInsightsConfig, TierEncryptionConfig, DatabaseTierPreset, TierEc2CapacityConfig, TierClusterConfig, TierEcsServiceConfig, EcsTierPreset, LambdaTierPreset, TierNatConfig, TierFlowLogConfig, TierGatewayEndpointsConfig, TierInterfaceEndpointsConfig, TierVpcEndpointsConfig, NetworkTierPreset, TierPreset, UserServiceConfig, };
19
19
  /**
20
- * Tier names - ordered from least to most capable/expensive
21
- * This is the single source of truth for all tier-based configuration.
20
+ * Tier names - ordered from least to most capable/expensive.
21
+ * Defined in sharedTypes.ts to avoid circular dependency with schemas/constants.ts.
22
+ * Re-exported here for backwards compatibility.
22
23
  */
23
- export declare const TIER_NAMES: readonly ["tinkerer", "lightweight", "standard", "resilient", "enterprise"];
24
- export type TierName = (typeof TIER_NAMES)[number];
25
- export declare const CUSTOM_TIER: "custom";
26
- export declare const APP_TYPES: readonly ["tinkerer", "lightweight", "standard", "resilient", "enterprise", "custom"];
27
- export type AppType = (typeof APP_TYPES)[number];
24
+ export { TIER_NAMES, type TierName, CUSTOM_TIER, APP_TYPES, type AppType, } from "../schemas/sharedTypes.js";
28
25
  /**
29
26
  * Master configuration for all tiers
30
27
  */