@fjall/generator 2.34.0 → 3.1.0

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 (110) hide show
  1. package/dist/.minified +1 -1
  2. package/dist/src/ast/astTestHelpers.js +1 -1
  3. package/dist/src/ast/domain/astDomainParser.d.ts +15 -7
  4. package/dist/src/ast/domain/astDomainParser.js +1 -1
  5. package/dist/src/ast/index.d.ts +1 -1
  6. package/dist/src/ast/mutation/astCodeInjection.js +4 -4
  7. package/dist/src/ast/mutation/astExpressionEvaluator.js +1 -1
  8. package/dist/src/ast/mutation/astSurgicalModification.js +5 -5
  9. package/dist/src/ast/parsers/common/astCommonParser.js +1 -1
  10. package/dist/src/ast/parsers/common/astStatementClassifier.js +1 -1
  11. package/dist/src/ast/parsers/common/astStatementQueries.js +3 -3
  12. package/dist/src/ast/parsers/orchestrator/astInfrastructureParser.js +1 -1
  13. package/dist/src/ast/parsers/orchestrator/astPlanConverter.js +2 -2
  14. package/dist/src/ast/parsers/resources/astCdnParser.js +1 -1
  15. package/dist/src/ast/parsers/resources/astClickHouseParser.js +1 -1
  16. package/dist/src/ast/parsers/resources/astComputeConnectionParser.js +1 -1
  17. package/dist/src/ast/parsers/resources/astComputeParser.js +1 -1
  18. package/dist/src/ast/parsers/resources/astComputeParserHelpers.js +1 -1
  19. package/dist/src/ast/parsers/resources/astDatabaseParser.js +1 -1
  20. package/dist/src/ast/parsers/resources/astDynamoDBParser.js +1 -1
  21. package/dist/src/ast/parsers/resources/astMessagingParser.js +1 -1
  22. package/dist/src/ast/parsers/resources/astNetworkParser.js +1 -1
  23. package/dist/src/ast/parsers/resources/astPatternParser.js +1 -1
  24. package/dist/src/ast/parsers/resources/astScheduleParser.js +1 -1
  25. package/dist/src/ast/parsers/resources/astStorageParser.js +1 -1
  26. package/dist/src/aws/regions.js +1 -1
  27. package/dist/src/codemod/_internal.js +1 -1
  28. package/dist/src/codemod/drift/detect.js +1 -1
  29. package/dist/src/codemod/drift/merge.js +1 -1
  30. package/dist/src/codemod/drift/snapshot.js +1 -1
  31. package/dist/src/codemod/edits/addResource/bodyIndex.js +1 -1
  32. package/dist/src/codemod/edits/addResource/propertyBuilder.js +1 -1
  33. package/dist/src/codemod/edits/addResource.js +1 -1
  34. package/dist/src/codemod/edits/appendAccountToStage.js +1 -1
  35. package/dist/src/codemod/edits/controlFlowPolicy.js +1 -1
  36. package/dist/src/codemod/edits/crossPlanConnection.js +1 -1
  37. package/dist/src/codemod/edits/driftPolicy.js +1 -1
  38. package/dist/src/codemod/edits/ensureImports.js +1 -1
  39. package/dist/src/codemod/edits/findInsertionPosition.js +1 -1
  40. package/dist/src/codemod/edits/modifyResource/literalConversion.js +1 -1
  41. package/dist/src/codemod/edits/modifyResource.js +1 -1
  42. package/dist/src/codemod/edits/removeResource/commentHeuristic.js +1 -1
  43. package/dist/src/codemod/edits/removeResource/importPruning.js +1 -1
  44. package/dist/src/codemod/edits/removeResource.js +1 -1
  45. package/dist/src/codemod/edits/vpcPeer.js +1 -1
  46. package/dist/src/codemod/edits/vpcPeerAccepter.js +1 -1
  47. package/dist/src/codemod/fileRewriter/builders.js +1 -1
  48. package/dist/src/codemod/fileRewriter/locateByRange.js +1 -1
  49. package/dist/src/codemod/fileRewriter/parse.js +2 -2
  50. package/dist/src/codemod/fileRewriter/print.js +2 -2
  51. package/dist/src/codemod/historyPaths.js +1 -1
  52. package/dist/src/codemod/listResources.js +1 -1
  53. package/dist/src/codemod/llmFallback/apply.js +1 -1
  54. package/dist/src/codemod/llmFallback/claudeTier.js +1 -1
  55. package/dist/src/codemod/llmFallback/egressGate.js +1 -1
  56. package/dist/src/codemod/llmFallback/morphTier.js +2 -2
  57. package/dist/src/codemod/llmFallback/prompt.js +13 -13
  58. package/dist/src/codemod/llmFallback/runFallback.js +1 -1
  59. package/dist/src/codemod/llmFallback/shouldTryFallback.js +1 -1
  60. package/dist/src/codemod/llmFallback/signals.js +1 -1
  61. package/dist/src/codemod/llmFallback/telemetryEvents.js +1 -1
  62. package/dist/src/codemod/llmFallback/tierRunner.js +1 -1
  63. package/dist/src/codemod/registry.js +1 -1
  64. package/dist/src/codemod/semanticIndex/classifyControlFlow.js +1 -1
  65. package/dist/src/codemod/semanticIndex/findReferences.js +2 -2
  66. package/dist/src/codemod/semanticIndex/listImports.js +1 -1
  67. package/dist/src/codemod/semanticIndex/locateByShape.js +1 -1
  68. package/dist/src/codemod/semanticIndex/projectCache.js +1 -1
  69. package/dist/src/codemod/semanticIndex/resolveConstructByLiteralProperty.js +1 -1
  70. package/dist/src/codemod/validationGate/gates/classify.js +1 -1
  71. package/dist/src/codemod/validationGate/gates/locate.js +1 -1
  72. package/dist/src/codemod/validationGate/types.js +1 -1
  73. package/dist/src/detection/index.js +1 -1
  74. package/dist/src/dns/bindParser.js +2 -2
  75. package/dist/src/dns/bindWriter.js +2 -2
  76. package/dist/src/dns/domainFileGenerator.js +18 -28
  77. package/dist/src/dns/domainRecords.d.ts +11 -0
  78. package/dist/src/dns/domainRecords.js +1 -1
  79. package/dist/src/generation/common.js +7 -7
  80. package/dist/src/generation/compute/ec2.js +3 -3
  81. package/dist/src/generation/compute/ecs.js +24 -24
  82. package/dist/src/generation/compute/lambda.js +8 -8
  83. package/dist/src/generation/compute/shared.js +4 -4
  84. package/dist/src/generation/compute.js +5 -5
  85. package/dist/src/generation/database.js +18 -18
  86. package/dist/src/generation/generatePatternCode.js +16 -16
  87. package/dist/src/generation/infrastructure.js +14 -14
  88. package/dist/src/generation/messagingConnections.js +1 -1
  89. package/dist/src/generation/storage.js +14 -14
  90. package/dist/src/generation/storageConnections.js +1 -1
  91. package/dist/src/planning/generateResourceChange.js +1 -1
  92. package/dist/src/planning/openNextPlanning.js +1 -1
  93. package/dist/src/planning/resourceAddition.js +1 -1
  94. package/dist/src/planning/resourceConnections.js +1 -1
  95. package/dist/src/planning/resourcePlanning.js +1 -1
  96. package/dist/src/planning/staticSitePlanning.js +1 -1
  97. package/dist/src/presets/patternTierPresets.js +1 -1
  98. package/dist/src/presets/storagePresets.js +1 -1
  99. package/dist/src/presets/tierPresets.js +1 -1
  100. package/dist/src/schemas/baseSchemas.js +2 -2
  101. package/dist/src/schemas/computeSchemas.js +1 -1
  102. package/dist/src/schemas/constants.js +1 -1
  103. package/dist/src/schemas/devRolePolicies.js +1 -1
  104. package/dist/src/schemas/instanceTypeArchitecture.js +1 -1
  105. package/dist/src/schemas/securityBoundary.js +1 -1
  106. package/dist/src/types/Result.js +1 -1
  107. package/dist/src/validation/validationPatterns.js +1 -1
  108. package/dist/src/version.d.ts +1 -1
  109. package/dist/src/version.js +1 -1
  110. package/package.json +3 -3
@@ -1,9 +1,9 @@
1
- import{z as u}from"zod";import{STATEMENT_REGISTRY as s}from"../registry.js";const p=[...new Set(Object.values(s).map(e=>e.factoryIdentifier))].join(", "),a=`You are a Fjall infrastructure code editor. You modify TypeScript infrastructure files that use the Fjall CDK factory pattern.
1
+ var p=Object.defineProperty;var n=(e,r)=>p(e,"name",{value:r,configurable:!0});import{z as d}from"zod";import{STATEMENT_REGISTRY as i}from"../registry.js";const m=[...new Set(Object.values(i).map(e=>e.factoryIdentifier))].join(", "),l=`You are a Fjall infrastructure code editor. You modify TypeScript infrastructure files that use the Fjall CDK factory pattern.
2
2
 
3
3
  Each resource is declared as a factory call:
4
4
  \`XFactory.build("ResourceName", { ...properties })\`
5
5
 
6
- where X is one of: ${p}.
6
+ where X is one of: ${m}.
7
7
 
8
8
  ## Rules
9
9
 
@@ -13,24 +13,24 @@ where X is one of: ${p}.
13
13
  4. Preserve the quote style used in the file (single or double quotes).
14
14
  5. Do not move resource declarations into conditional blocks, loops, or function bodies. All factory calls must remain at module top level.
15
15
  6. If you cannot produce a valid edit, respond with an empty tool_use \u2014 do not guess.
16
- 7. Properties must conform to the schema provided below. Do not invent property names.`;function d(e){return e==="morph"?`${a}
16
+ 7. Properties must conform to the schema provided below. Do not invent property names.`;function h(e){return e==="morph"?`${l}
17
17
 
18
- You are operating as a fast-apply tier. Produce minimal, precise edits only.`:a}function m(e){const t=s[e.type].factoryIdentifier;switch(e.op){case"add":return`Add a new ${e.type} resource named "${e.name}" using ${t}.build("${e.name}", { ... }) with the properties specified below.`;case"remove":return`Remove the ${e.type} resource named "${e.name}" (the ${t}.build("${e.name}", ...) call and any directly related code). Preserve all other resources.`;case"modify":return`Modify the ${e.type} resource named "${e.name}" by updating its properties to match the values specified below. Keep properties not mentioned in the update unchanged.`;case"resolve-drift-merge":return`Resolve a drift conflict on the ${e.type} resource named "${e.name}". The resource has been edited manually since Fjall last wrote it, and the requested properties conflict with the manual edits. Merge the two sets of changes: apply the requested properties below while preserving any manual edits to OTHER properties not listed in the update. Use ${t}.build("${e.name}", { ... }) with the merged property set.`}}function h(e){const o=s[e.type],t=u.toJSONSchema(o.schemaFragment,{io:"input"}),r=JSON.stringify(t,null,2),n=i(r);return`## Property Schema for ${e.type}
18
+ You are operating as a fast-apply tier. Produce minimal, precise edits only.`:l}n(h,"buildSystemPrompt");function f(e){const t=i[e.type].factoryIdentifier;switch(e.op){case"add":return`Add a new ${e.type} resource named "${e.name}" using ${t}.build("${e.name}", { ... }) with the properties specified below.`;case"remove":return`Remove the ${e.type} resource named "${e.name}" (the ${t}.build("${e.name}", ...) call and any directly related code). Preserve all other resources.`;case"modify":return`Modify the ${e.type} resource named "${e.name}" by updating its properties to match the values specified below. Keep properties not mentioned in the update unchanged.`;case"resolve-drift-merge":return`Resolve a drift conflict on the ${e.type} resource named "${e.name}". The resource has been edited manually since Fjall last wrote it, and the requested properties conflict with the manual edits. Merge the two sets of changes: apply the requested properties below while preserving any manual edits to OTHER properties not listed in the update. Use ${t}.build("${e.name}", { ... }) with the merged property set.`}}n(f,"describeOp");function y(e){const r=i[e.type],t=d.toJSONSchema(r.schemaFragment,{io:"input"}),o=JSON.stringify(t,null,2),s=c(o);return`## Property Schema for ${e.type}
19
19
 
20
- ${n}json
21
- ${r}
22
- ${n}`}function f(e){if(e.op==="remove")return"";const o=Object.fromEntries(Object.entries(e.properties).filter(([,n])=>n!==void 0));if(Object.keys(o).length===0)return"";const t=JSON.stringify(o,null,2),r=i(t);return`## Target Properties
20
+ ${s}json
21
+ ${o}
22
+ ${s}`}n(y,"buildSchemaSection");function $(e){if(e.op==="remove")return"";const r=Object.fromEntries(Object.entries(e.properties).filter(([,s])=>s!==void 0));if(Object.keys(r).length===0)return"";const t=JSON.stringify(r,null,2),o=c(t);return`## Target Properties
23
23
 
24
- ${r}json
24
+ ${o}json
25
25
  ${t}
26
- ${r}`}function i(e){const o=e.match(/`+/g)??[];let t=0;for(const r of o)r.length>t&&(t=r.length);return"`".repeat(Math.max(3,t+1))}function b(e){const o=d(e.tier),t=m(e.intent),r=h(e.intent),n=f(e.intent),c=i(e.content),l=`## Task
26
+ ${o}`}n($,"buildPropertiesSection");function c(e){const r=e.match(/`+/g)??[];let t=0;for(const o of r)o.length>t&&(t=o.length);return"`".repeat(Math.max(3,t+1))}n(c,"pickFence");function v(e){const r=h(e.tier),t=f(e.intent),o=y(e.intent),s=$(e.intent),a=c(e.content),u=`## Task
27
27
 
28
28
  ${t}
29
29
 
30
- ${r}
31
- ${n}
30
+ ${o}
31
+ ${s}
32
32
  ## Current File
33
33
 
34
- ${c}typescript
34
+ ${a}typescript
35
35
  ${e.content}
36
- ${c}`.trim();return{systemPrompt:o,userPrompt:l}}export{b as buildPrompt};
36
+ ${a}`.trim();return{systemPrompt:r,userPrompt:u}}n(v,"buildPrompt");export{v as buildPrompt};
@@ -1 +1 @@
1
- import{runClaudeTier as n}from"./claudeTier.js";import{runMorphTier as a}from"./morphTier.js";function o(r,e){return{content:r.content,intent:r.intent,tier:e,orgAllowsFallback:r.orgAllowsFallback,abortSignal:r.abortSignal}}async function u(r,e){const t=await n(o(r,"claude"),e.claude);return!(t.state==="rejected"||t.state==="timeout")||!r.morphTierEnabled||e.morph===void 0?t:a(o(r,"morph"),e.morph)}export{u as runFallback};
1
+ var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});import{runClaudeTier as l}from"./claudeTier.js";import{runMorphTier as i}from"./morphTier.js";function n(r,e){return{content:r.content,intent:r.intent,tier:e,orgAllowsFallback:r.orgAllowsFallback,abortSignal:r.abortSignal}}o(n,"buildTierInput");async function d(r,e){const t=await l(n(r,"claude"),e.claude);return!(t.state==="rejected"||t.state==="timeout")||!r.morphTierEnabled||e.morph===void 0?t:i(n(r,"morph"),e.morph)}o(d,"runFallback");export{d as runFallback};
@@ -1 +1 @@
1
- const e={shouldTry:!1};function o(r,n){if(!n.envEnabled||!n.orgAllowsFallback)return e;const t=l(r);return t===void 0?e:{shouldTry:!0,trigger:t}}function l(r){switch(r.kind){case"TemplateLiteralNameError":return"template-literal-name";case"ResourceNotFoundError":return"resource-not-found";case"ControlFlowClassifierError":return r.reason==="anonymous-helper"?"control-flow-unclassifiable":void 0;case"DriftUnmergeableError":return"drift-unmergeable";default:return}}export{o as shouldTryFallback};
1
+ var o=Object.defineProperty;var n=(r,e)=>o(r,"name",{value:e,configurable:!0});const t={shouldTry:!1};function i(r,e){if(!e.envEnabled||!e.orgAllowsFallback)return t;const l=u(r);return l===void 0?t:{shouldTry:!0,trigger:l}}n(i,"shouldTryFallback");function u(r){switch(r.kind){case"TemplateLiteralNameError":return"template-literal-name";case"ResourceNotFoundError":return"resource-not-found";case"ControlFlowClassifierError":return r.reason==="anonymous-helper"?"control-flow-unclassifiable":void 0;case"DriftUnmergeableError":return"drift-unmergeable";default:return}}n(u,"matchTrigger");export{i as shouldTryFallback};
@@ -1 +1 @@
1
- function e(a,n){if(a===void 0)return{signal:n.signal,cleanup:()=>{}};if(a.aborted)return n.abort(),{signal:n.signal,cleanup:()=>{}};const i=()=>n.abort();return a.addEventListener("abort",i,{once:!0}),{signal:n.signal,cleanup:()=>a.removeEventListener("abort",i)}}export{e as linkAbortSignals};
1
+ var t=Object.defineProperty;var i=(a,n)=>t(a,"name",{value:n,configurable:!0});function b(a,n){if(a===void 0)return{signal:n.signal,cleanup:i(()=>{},"cleanup")};if(a.aborted)return n.abort(),{signal:n.signal,cleanup:i(()=>{},"cleanup")};const e=i(()=>n.abort(),"onAbort");return a.addEventListener("abort",e,{once:!0}),{signal:n.signal,cleanup:i(()=>a.removeEventListener("abort",e),"cleanup")}}i(b,"linkAbortSignals");export{b as linkAbortSignals};
@@ -1 +1 @@
1
- const t={FIRED:"codemod.llm_fallback.fired",SUCCEEDED:"codemod.llm_fallback.succeeded",REJECTED:"codemod.llm_fallback.rejected",TIMEOUT:"codemod.llm_fallback.timeout",EGRESS_BLOCKED:"codemod.llm_fallback.egress_blocked"},o={PASSED:"codemod.gate.passed",FAILED:"codemod.gate.failed"},E=3/1e6,d=15/1e6;function i(e){if(e.tier!=="claude")return 0;const n=e.inputTokens*E,r=e.outputTokens*d;return Math.round((n+r)*1e6)/1e6}function u(e){return{event:t.FIRED,properties:e}}function c(e){return{event:t.SUCCEEDED,properties:{source:e.source,operation:e.operation,tier:e.telemetry.tier,durationMs:e.telemetry.elapsedMs,estimatedCostUsd:i(e.telemetry),organisationId:e.organisationId}}}function l(e){return{event:t.REJECTED,properties:e}}function s(e){return{event:t.TIMEOUT,properties:e}}function p(e){return{event:t.EGRESS_BLOCKED,properties:e}}function _(e){return{event:o.PASSED,properties:e}}function a(e){return{event:o.FAILED,properties:e}}export{t as FALLBACK_EVENTS,o as GATE_EVENTS,p as buildEgressBlockedEvent,u as buildFiredEvent,a as buildGateFailedEvent,_ as buildGatePassedEvent,l as buildRejectedEvent,c as buildSucceededEvent,s as buildTimeoutEvent,i as estimateCostUsd};
1
+ var d=Object.defineProperty;var t=(e,n)=>d(e,"name",{value:n,configurable:!0});const o={FIRED:"codemod.llm_fallback.fired",SUCCEEDED:"codemod.llm_fallback.succeeded",REJECTED:"codemod.llm_fallback.rejected",TIMEOUT:"codemod.llm_fallback.timeout",EGRESS_BLOCKED:"codemod.llm_fallback.egress_blocked"},r={PASSED:"codemod.gate.passed",FAILED:"codemod.gate.failed"},i=3/1e6,u=15/1e6;function c(e){if(e.tier!=="claude")return 0;const n=e.inputTokens*i,E=e.outputTokens*u;return Math.round((n+E)*1e6)/1e6}t(c,"estimateCostUsd");function s(e){return{event:o.FIRED,properties:e}}t(s,"buildFiredEvent");function p(e){return{event:o.SUCCEEDED,properties:{source:e.source,operation:e.operation,tier:e.telemetry.tier,durationMs:e.telemetry.elapsedMs,estimatedCostUsd:c(e.telemetry),organisationId:e.organisationId}}}t(p,"buildSucceededEvent");function _(e){return{event:o.REJECTED,properties:e}}t(_,"buildRejectedEvent");function a(e){return{event:o.TIMEOUT,properties:e}}t(a,"buildTimeoutEvent");function T(e){return{event:o.EGRESS_BLOCKED,properties:e}}t(T,"buildEgressBlockedEvent");function f(e){return{event:r.PASSED,properties:e}}t(f,"buildGatePassedEvent");function D(e){return{event:r.FAILED,properties:e}}t(D,"buildGateFailedEvent");export{o as FALLBACK_EVENTS,r as GATE_EVENTS,T as buildEgressBlockedEvent,s as buildFiredEvent,D as buildGateFailedEvent,f as buildGatePassedEvent,_ as buildRejectedEvent,p as buildSucceededEvent,a as buildTimeoutEvent,c as estimateCostUsd};
@@ -1 +1 @@
1
- import{maskSensitiveOutput as m}from"@fjall/util";import{linkAbortSignals as d}from"./signals.js";import{RUNTIME_GATE as f}from"./types.js";async function w(r,n,l,s){const i=new AbortController,{signal:u,cleanup:c}=d(r,i);let t,a=!1;const o=Date.now();try{return t=setTimeout(()=>{a=!0,i.abort()},l),await s({signal:u,started:o})}catch(e){return r?.aborted?{state:"cancelled"}:a?{state:"timeout",tier:n,elapsedMs:Date.now()-o}:{state:"rejected",tier:n,failedGate:f,diagnostics:m(e instanceof Error?e.message:String(e))}}finally{t!==void 0&&clearTimeout(t),c()}}export{w as withTierTimeout};
1
+ var d=Object.defineProperty;var l=(t,e)=>d(t,"name",{value:e,configurable:!0});import{maskSensitiveOutput as f}from"@fjall/util";import{linkAbortSignals as p}from"./signals.js";import{RUNTIME_GATE as g}from"./types.js";async function k(t,e,s,u){const i=new AbortController,{signal:c,cleanup:m}=p(t,i);let r,a=!1;const o=Date.now();try{return r=setTimeout(()=>{a=!0,i.abort()},s),await u({signal:c,started:o})}catch(n){return t?.aborted?{state:"cancelled"}:a?{state:"timeout",tier:e,elapsedMs:Date.now()-o}:{state:"rejected",tier:e,failedGate:g,diagnostics:f(n instanceof Error?n.message:String(n))}}finally{r!==void 0&&clearTimeout(r),m()}}l(k,"withTierTimeout");export{k as withTierTimeout};
@@ -1 +1 @@
1
- import{z as c}from"zod";import{CDNResourcePlanSchema as l,ComputeResourcePlanSchema as d,CrossPlanConnectionResourcePlanSchema as S,DatabaseResourcePlanSchema as h,NetworkResourcePlanSchema as y,NextJSPatternConfigSchema as P,OrganisationResourcePlanSchema as F,PayloadPatternConfigSchema as f,S3ResourcePlanSchema as C,SQSResourcePlanSchema as E,StaticSitePatternConfigSchema as R,VpcPeerAccepterResourcePlanSchema as b,VpcPeerResourcePlanSchema as _}from"../schemas/index.js";import{failure as T}from"../types/Result.js";const n={database:"DatabaseFactory",storage:"StorageFactory",compute:"ComputeFactory",messaging:"MessagingFactory",cdn:"CdnFactory",network:"NetworkFactory",pattern:"PatternFactory","vpc-peer":"VpcPeerFactory","vpc-peer-accepter":"VpcPeerAccepterFactory","cross-plan-connection":"CrossPlanConnectionFactory",organisation:"OrganisationFactory"};function r(e){const{name:t,...o}=e.shape;return c.object(o).partial().strict()}const v=r(h),k=r(C),w=(()=>{const{name:e,...t}=d.shape;return c.object(t).partial().strict()})(),x=r(E),N=r(l),j=r(y),A=(()=>{const{name:e,type:t,cdn:o,...i}=f.shape,{name:M,type:Y,cdn:Q,...m}=P.shape,{name:$,type:z,domain:J,cdn:g,...u}=R.shape;return c.object({...i,...m,...u,cdn:c.union([o,g])}).partial().strict()})(),O=r(_),D=r(b),V=r(S),B=r(F);function s(e,t){return T({kind:"SemanticQueryError",reason:`StatementTypeEntry.${e} for ${t} is not wired; existing types dispatch through the shared locator/generator.`})}function G(e){return{factoryIdentifier:e,findByShape:()=>s("locator.findByShape",e),validateContext:()=>s("locator.validateContext",e)}}function I(e){return{build:()=>{const t=s("generator.build",e);throw new Error(t.success?"unreachable":t.error.reason)}}}function a(e,t){return{factoryIdentifier:e,locator:G(e),generator:I(e),schemaFragment:t}}const p={database:a(n.database,v),storage:a(n.storage,k),compute:a(n.compute,w),messaging:a(n.messaging,x),cdn:a(n.cdn,N),network:a(n.network,j),pattern:a(n.pattern,A),"vpc-peer":a(n["vpc-peer"],O),"vpc-peer-accepter":a(n["vpc-peer-accepter"],D),"cross-plan-connection":a(n["cross-plan-connection"],V),organisation:a(n.organisation,B)},H=Object.keys(p);function K(e){const t=Object.keys(p);for(const o of t)if(p[o].factoryIdentifier===e)return o}export{H as REGISTERED_STATEMENT_TYPES,p as STATEMENT_REGISTRY,K as findTypeByIdentifier};
1
+ var d=Object.defineProperty;var r=(e,t)=>d(e,"name",{value:t,configurable:!0});import{z as s}from"zod";import{CDNResourcePlanSchema as S,ComputeResourcePlanSchema as h,CrossPlanConnectionResourcePlanSchema as y,DatabaseResourcePlanSchema as P,NetworkResourcePlanSchema as F,NextJSPatternConfigSchema as f,OrganisationResourcePlanSchema as C,PayloadPatternConfigSchema as E,S3ResourcePlanSchema as R,SQSResourcePlanSchema as b,StaticSitePatternConfigSchema as _,VpcPeerAccepterResourcePlanSchema as T,VpcPeerResourcePlanSchema as v}from"../schemas/index.js";import{failure as k}from"../types/Result.js";const n={database:"DatabaseFactory",storage:"StorageFactory",compute:"ComputeFactory",messaging:"MessagingFactory",cdn:"CdnFactory",network:"NetworkFactory",pattern:"PatternFactory","vpc-peer":"VpcPeerFactory","vpc-peer-accepter":"VpcPeerAccepterFactory","cross-plan-connection":"CrossPlanConnectionFactory",organisation:"OrganisationFactory"};function o(e){const{name:t,...c}=e.shape;return s.object(c).partial().strict()}r(o,"fragmentOf");const w=o(P),x=o(R),N=(()=>{const{name:e,...t}=h.shape;return s.object(t).partial().strict()})(),j=o(b),A=o(S),O=o(F),D=(()=>{const{name:e,type:t,cdn:c,...m}=E.shape,{name:Q,type:$,cdn:z,...g}=f.shape,{name:J,type:L,domain:W,cdn:u,...l}=_.shape;return s.object({...m,...g,...l,cdn:s.union([c,u])}).partial().strict()})(),V=o(v),B=o(T),G=o(y),I=o(C);function p(e,t){return k({kind:"SemanticQueryError",reason:`StatementTypeEntry.${e} for ${t} is not wired; existing types dispatch through the shared locator/generator.`})}r(p,"notWiredError");function M(e){return{factoryIdentifier:e,findByShape:r(()=>p("locator.findByShape",e),"findByShape"),validateContext:r(()=>p("locator.validateContext",e),"validateContext")}}r(M,"createLocator");function Y(e){return{build:r(()=>{const t=p("generator.build",e);throw new Error(t.success?"unreachable":t.error.reason)},"build")}}r(Y,"createGenerator");function a(e,t){return{factoryIdentifier:e,locator:M(e),generator:Y(e),schemaFragment:t}}r(a,"createEntry");const i={database:a(n.database,w),storage:a(n.storage,x),compute:a(n.compute,N),messaging:a(n.messaging,j),cdn:a(n.cdn,A),network:a(n.network,O),pattern:a(n.pattern,D),"vpc-peer":a(n["vpc-peer"],V),"vpc-peer-accepter":a(n["vpc-peer-accepter"],B),"cross-plan-connection":a(n["cross-plan-connection"],G),organisation:a(n.organisation,I)},X=Object.keys(i);function Z(e){const t=Object.keys(i);for(const c of t)if(i[c].factoryIdentifier===e)return c}r(Z,"findTypeByIdentifier");export{X as REGISTERED_STATEMENT_TYPES,i as STATEMENT_REGISTRY,Z as findTypeByIdentifier};
@@ -1 +1 @@
1
- const u=new Set(["IfStatement","ConditionalExpression","SwitchStatement","SwitchCase","CatchClause"]),c=new Set(["ForStatement","ForInStatement","ForOfStatement","WhileStatement","DoWhileStatement"]),a=new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ObjectMethod","ClassMethod"]);function p(n,t){if(t.length===0)return S(n);let e=n;for(let r=t.length-1;r>=0;r-=1){const o=t[r],i=f(o);if(i===void 0){e=o;continue}if(i==="TryStatement"){if(s(o,e))return"conditional";e=o;continue}if(u.has(i))return"conditional";if(c.has(i))return"loop";if(a.has(i))return"function-body";e=o}const l=f(t[0]);return l==="Program"||l==="File"?"top-level":"unknown"}function f(n){if(typeof n!="object"||n===null)return;const t=n.type;return typeof t=="string"?t:void 0}function s(n,t){if(typeof n!="object"||n===null)return!1;const e=n.finalizer;return e!==void 0&&e===t}function S(n){const t=f(n);return t==="Program"||t==="File"?"top-level":"unknown"}export{p as classifyControlFlow};
1
+ var c=Object.defineProperty;var r=(n,t)=>c(n,"name",{value:t,configurable:!0});const a=new Set(["IfStatement","ConditionalExpression","SwitchStatement","SwitchCase","CatchClause"]),s=new Set(["ForStatement","ForInStatement","ForOfStatement","WhileStatement","DoWhileStatement"]),S=new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ObjectMethod","ClassMethod"]);function m(n,t){if(t.length===0)return d(n);let e=n;for(let f=t.length-1;f>=0;f-=1){const o=t[f],i=l(o);if(i===void 0){e=o;continue}if(i==="TryStatement"){if(p(o,e))return"conditional";e=o;continue}if(a.has(i))return"conditional";if(s.has(i))return"loop";if(S.has(i))return"function-body";e=o}const u=l(t[0]);return u==="Program"||u==="File"?"top-level":"unknown"}r(m,"classifyControlFlow");function l(n){if(typeof n!="object"||n===null)return;const t=n.type;return typeof t=="string"?t:void 0}r(l,"typeOf");function p(n,t){if(typeof n!="object"||n===null)return!1;const e=n.finalizer;return e!==void 0&&e===t}r(p,"cameFromFinalizer");function d(n){const t=l(n);return t==="Program"||t==="File"?"top-level":"unknown"}r(d,"classifySolo");export{m as classifyControlFlow};
@@ -1,2 +1,2 @@
1
- import{Node as m,SyntaxKind as y}from"ts-morph";import{failure as a,success as u}from"../../types/Result.js";import{DEFAULT_FILE_PATH as S}from"../_internal.js";import{getProject as p}from"./projectCache.js";const f=120;function D(r,n,e=S){let o;try{o=p().createSourceFile(e,r,{overwrite:!0})}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to create source file",cause:t})}let c;try{c=g(o,n.start)}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to resolve declaration at the supplied offset",cause:t})}if(c===void 0)return u([]);let i;try{i=c.getSymbol()}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to resolve symbol for declaration",cause:t})}if(i===void 0)return u([]);let s;try{s=c.findReferencesAsNodes()}catch(t){return a({kind:"SemanticQueryError",reason:"findReferencesAsNodes failed",cause:t})}const d=o.getFullText().split(`
2
- `),l=[];try{for(const t of s)F(t,i)&&(b(t,c)||l.push(A(t,d)))}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to map references to plain-data locations",cause:t})}return u(l)}function g(r,n){const e=r.getDescendantAtPos(n);return e===void 0?void 0:m.isVariableDeclaration(e)?e:e.getFirstAncestorByKind(y.VariableDeclaration)}function F(r,n){const e=r.getSymbol();return e===void 0?!1:e===n?!0:e.compilerSymbol===n.compilerSymbol}function b(r,n){const e=n.getNameNode();return r===e||r.getStart()===e.getStart()}function A(r,n){const e=r.getStart(),{line:o,column:c}=r.getSourceFile().getLineAndColumnAtPos(e),i=n[o-1]??"",s=i.length>f?i.slice(0,f):i;return{line:o,column:c,context:s}}export{D as findReferences};
1
+ var y=Object.defineProperty;var a=(r,n)=>y(r,"name",{value:n,configurable:!0});import{Node as S,SyntaxKind as p}from"ts-morph";import{failure as s,success as l}from"../../types/Result.js";import{DEFAULT_FILE_PATH as g}from"../_internal.js";import{getProject as F}from"./projectCache.js";const d=120;function P(r,n,e=g){let o;try{o=F().createSourceFile(e,r,{overwrite:!0})}catch(t){return s({kind:"SemanticQueryError",reason:"Failed to create source file",cause:t})}let c;try{c=b(o,n.start)}catch(t){return s({kind:"SemanticQueryError",reason:"Failed to resolve declaration at the supplied offset",cause:t})}if(c===void 0)return l([]);let i;try{i=c.getSymbol()}catch(t){return s({kind:"SemanticQueryError",reason:"Failed to resolve symbol for declaration",cause:t})}if(i===void 0)return l([]);let u;try{u=c.findReferencesAsNodes()}catch(t){return s({kind:"SemanticQueryError",reason:"findReferencesAsNodes failed",cause:t})}const m=o.getFullText().split(`
2
+ `),f=[];try{for(const t of u)A(t,i)&&(E(t,c)||f.push(N(t,m)))}catch(t){return s({kind:"SemanticQueryError",reason:"Failed to map references to plain-data locations",cause:t})}return l(f)}a(P,"findReferences");function b(r,n){const e=r.getDescendantAtPos(n);return e===void 0?void 0:S.isVariableDeclaration(e)?e:e.getFirstAncestorByKind(p.VariableDeclaration)}a(b,"resolveDeclaration");function A(r,n){const e=r.getSymbol();return e===void 0?!1:e===n?!0:e.compilerSymbol===n.compilerSymbol}a(A,"isSameSymbol");function E(r,n){const e=n.getNameNode();return r===e||r.getStart()===e.getStart()}a(E,"isDeclarationNode");function N(r,n){const e=r.getStart(),{line:o,column:c}=r.getSourceFile().getLineAndColumnAtPos(e),i=n[o-1]??"",u=i.length>d?i.slice(0,d):i;return{line:o,column:c,context:u}}a(N,"toReferenceLocation");export{P as findReferences};
@@ -1 +1 @@
1
- import{Node as s}from"ts-morph";import{failure as c,success as a}from"../../types/Result.js";import{DEFAULT_FILE_PATH as u}from"../_internal.js";import{getProject as m}from"./projectCache.js";function S(t,i=u){let r;try{r=m().createSourceFile(i,t,{overwrite:!0})}catch(e){return c({kind:"SemanticQueryError",reason:"Failed to create source file",cause:e})}const o=[];try{for(const e of r.getImportDeclarations()){const n=f(e,i);n!==void 0&&o.push(n)}}catch(e){return c({kind:"SemanticQueryError",reason:"Failed to enumerate import declarations",cause:e})}return a(o)}function f(t,i){const r=t.getModuleSpecifier();if(!s.isStringLiteral(r))return;const o=r.getLiteralValue(),e=t.getNamedImports().map(n=>n.getNameNode().getText());return{module:o,specifiers:e,location:{filePath:i,start:t.getStart(),length:t.getWidth(),symbolName:o}}}export{S as listImports};
1
+ var a=Object.defineProperty;var c=(e,r)=>a(e,"name",{value:r,configurable:!0});import{Node as u}from"ts-morph";import{failure as s,success as m}from"../../types/Result.js";import{DEFAULT_FILE_PATH as f}from"../_internal.js";import{getProject as p}from"./projectCache.js";function N(e,r=f){let o;try{o=p().createSourceFile(r,e,{overwrite:!0})}catch(t){return s({kind:"SemanticQueryError",reason:"Failed to create source file",cause:t})}const i=[];try{for(const t of o.getImportDeclarations()){const n=l(t,r);n!==void 0&&i.push(n)}}catch(t){return s({kind:"SemanticQueryError",reason:"Failed to enumerate import declarations",cause:t})}return m(i)}c(N,"listImports");function l(e,r){const o=e.getModuleSpecifier();if(!u.isStringLiteral(o))return;const i=o.getLiteralValue(),t=e.getNamedImports().map(n=>n.getNameNode().getText());return{module:i,specifiers:t,location:{filePath:r,start:e.getStart(),length:e.getWidth(),symbolName:i}}}c(l,"toImportInfo");export{N as listImports};
@@ -1 +1 @@
1
- import{Node as s,SyntaxKind as i}from"ts-morph";import{failure as c,success as l}from"../../types/Result.js";import{DEFAULT_FILE_PATH as u}from"../_internal.js";import{findTypeByIdentifier as d}from"../registry.js";import{getProject as m}from"./projectCache.js";function b(n,r,t=u){const a=g(n,t);if(!a.success)return a;const e=a.data.find(o=>o.type===r.type&&o.symbolName===r.name);return l(e)}function g(n,r=u){const t=[],a=y(n,r,e=>{t.push({filePath:r,start:e.nameStart,length:e.nameLength,symbolName:e.name,type:e.type})});return a.success?l(t):a}function y(n,r,t){let a;try{a=m().createSourceFile(r,n,{overwrite:!0})}catch(e){return c({kind:"SemanticQueryError",reason:"Failed to create source file",cause:e})}try{a.forEachDescendant(e=>{if(!s.isCallExpression(e))return;const o=h(e);if(o!=="not-factory-call"&&o.kind!=="binding-pattern-declared"){if(o.kind==="template-literal-name")throw new f(e,o.type);t({type:o.type,name:o.name,nameStart:o.nameStart,nameLength:o.nameLength},e)}})}catch(e){return e instanceof f?c(e.toError(r)):c({kind:"SemanticQueryError",reason:"forEachDescendant traversal failed",cause:e})}return l(void 0)}function h(n){const r=n.getExpression();if(!s.isPropertyAccessExpression(r))return"not-factory-call";const t=S(r);if(t===void 0||E(n))return"not-factory-call";if(T(n))return{kind:"binding-pattern-declared"};const e=n.getArguments()[0];return e===void 0?"not-factory-call":s.isTemplateExpression(e)||s.isNoSubstitutionTemplateLiteral(e)?{kind:"template-literal-name",type:t}:s.isStringLiteral(e)?{kind:"match",type:t,name:e.getLiteralValue(),nameStart:e.getStart(),nameLength:e.getWidth()}:"not-factory-call"}function S(n){const r=n.getExpression();if(s.isIdentifier(r)&&n.getName()==="build")return d(r.getText())}function E(n){let r=n.getParent();for(;r!==void 0;){const t=r.getKind();if(t===i.TypeReference||t===i.TypeQuery||t===i.TypeLiteral||t===i.TypeAliasDeclaration||t===i.InterfaceDeclaration||t===i.TypeParameter||t===i.PropertySignature||t===i.MethodSignature||t===i.JsxOpeningElement||t===i.JsxClosingElement||t===i.JsxSelfClosingElement||t===i.JsxAttribute)return!0;r=r.getParent()}return!1}function T(n){const r=n.getFirstAncestorByKind(i.VariableDeclaration);if(r===void 0)return!1;const a=r.getNameNode().getKind();return a===i.ObjectBindingPattern||a===i.ArrayBindingPattern}class f extends Error{call;type;constructor(r,t){super("Template-literal factory name detected"),this.call=r,this.type=t,this.name="TemplateLiteralMarker"}toError(r){const a=this.call.getArguments()[0]?.getStart()??this.call.getStart(),e=this.call.getSourceFile(),{line:o,column:p}=e.getLineAndColumnAtPos(a);return{kind:"TemplateLiteralNameError",file:r,line:o,column:p,suggestion:"Replace the template literal with a plain string literal so the resource name can be resolved statically."}}}export{y as forEachFactoryMatch,g as locateAllShapes,b as locateByShape};
1
+ var m=Object.defineProperty;var s=(n,e)=>m(n,"name",{value:e,configurable:!0});import{Node as c,SyntaxKind as i}from"ts-morph";import{failure as l,success as u}from"../../types/Result.js";import{DEFAULT_FILE_PATH as f}from"../_internal.js";import{findTypeByIdentifier as g}from"../registry.js";import{getProject as y}from"./projectCache.js";function w(n,e,r=f){const a=h(n,r);if(!a.success)return a;const t=a.data.find(o=>o.type===e.type&&o.symbolName===e.name);return u(t)}s(w,"locateByShape");function h(n,e=f){const r=[],a=S(n,e,t=>{r.push({filePath:e,start:t.nameStart,length:t.nameLength,symbolName:t.name,type:t.type})});return a.success?u(r):a}s(h,"locateAllShapes");function S(n,e,r){let a;try{a=y().createSourceFile(e,n,{overwrite:!0})}catch(t){return l({kind:"SemanticQueryError",reason:"Failed to create source file",cause:t})}try{a.forEachDescendant(t=>{if(!c.isCallExpression(t))return;const o=E(t);if(o!=="not-factory-call"&&o.kind!=="binding-pattern-declared"){if(o.kind==="template-literal-name")throw new p(t,o.type);r({type:o.type,name:o.name,nameStart:o.nameStart,nameLength:o.nameLength},t)}})}catch(t){return t instanceof p?l(t.toError(e)):l({kind:"SemanticQueryError",reason:"forEachDescendant traversal failed",cause:t})}return u(void 0)}s(S,"forEachFactoryMatch");function E(n){const e=n.getExpression();if(!c.isPropertyAccessExpression(e))return"not-factory-call";const r=T(e);if(r===void 0||x(n))return"not-factory-call";if(A(n))return{kind:"binding-pattern-declared"};const t=n.getArguments()[0];return t===void 0?"not-factory-call":c.isTemplateExpression(t)||c.isNoSubstitutionTemplateLiteral(t)?{kind:"template-literal-name",type:r}:c.isStringLiteral(t)?{kind:"match",type:r,name:t.getLiteralValue(),nameStart:t.getStart(),nameLength:t.getWidth()}:"not-factory-call"}s(E,"classifyFactoryCall");function T(n){const e=n.getExpression();if(c.isIdentifier(e)&&n.getName()==="build")return g(e.getText())}s(T,"factoryTypeFromPropertyAccess");function x(n){let e=n.getParent();for(;e!==void 0;){const r=e.getKind();if(r===i.TypeReference||r===i.TypeQuery||r===i.TypeLiteral||r===i.TypeAliasDeclaration||r===i.InterfaceDeclaration||r===i.TypeParameter||r===i.PropertySignature||r===i.MethodSignature||r===i.JsxOpeningElement||r===i.JsxClosingElement||r===i.JsxSelfClosingElement||r===i.JsxAttribute)return!0;e=e.getParent()}return!1}s(x,"isInsideTypeSpace");function A(n){const e=n.getFirstAncestorByKind(i.VariableDeclaration);if(e===void 0)return!1;const a=e.getNameNode().getKind();return a===i.ObjectBindingPattern||a===i.ArrayBindingPattern}s(A,"isInsideBindingPattern");class p extends Error{static{s(this,"TemplateLiteralMarker")}call;type;constructor(e,r){super("Template-literal factory name detected"),this.call=e,this.type=r,this.name="TemplateLiteralMarker"}toError(e){const a=this.call.getArguments()[0]?.getStart()??this.call.getStart(),t=this.call.getSourceFile(),{line:o,column:d}=t.getLineAndColumnAtPos(a);return{kind:"TemplateLiteralNameError",file:e,line:o,column:d,suggestion:"Replace the template literal with a plain string literal so the resource name can be resolved statically."}}}export{S as forEachFactoryMatch,h as locateAllShapes,w as locateByShape};
@@ -1 +1 @@
1
- import{Project as t,ScriptTarget as r}from"ts-morph";let e;function i(){return e===void 0&&(e=new t({useInMemoryFileSystem:!0,skipAddingFilesFromTsConfig:!0,compilerOptions:{target:r.ES2022}})),e}function n(){e=void 0}export{i as getProject,n as resetProjectForTest};
1
+ var i=Object.defineProperty;var t=(r,o)=>i(r,"name",{value:o,configurable:!0});import{Project as n,ScriptTarget as c}from"ts-morph";let e;function d(){return e===void 0&&(e=new n({useInMemoryFileSystem:!0,skipAddingFilesFromTsConfig:!0,compilerOptions:{target:c.ES2022}})),e}t(d,"getProject");function f(){e=void 0}t(f,"resetProjectForTest");export{d as getProject,f as resetProjectForTest};
@@ -1 +1 @@
1
- import{Node as s}from"ts-morph";import{success as u}from"../../types/Result.js";import{DEFAULT_FILE_PATH as p}from"../_internal.js";import{forEachFactoryMatch as g}from"./locateByShape.js";function A(i,n,t=p){const r=[],e=[],c=g(i,t,(o,l)=>{if(o.type!==n.type)return;const a={type:o.type,constructId:o.name,filePath:t};r.push(a);const f=m(l,n.property);f!==void 0&&f===n.value&&e.push(a)});if(!c.success)return c;const[d]=e;return e.length===1&&d!==void 0?u({resolved:!0,construct:d}):e.length===0?u({resolved:!1,reason:"no-literal-match",candidates:r}):u({resolved:!1,reason:"ambiguous",candidates:e})}function m(i,n){const t=i.getArguments()[1];if(t===void 0||!s.isObjectLiteralExpression(t))return;const r=t.getProperty(n);if(r===void 0||!s.isPropertyAssignment(r))return;const e=r.getInitializer();if(!(e===void 0||!s.isStringLiteral(e)))return e.getLiteralValue()}export{A as resolveConstructByLiteralProperty};
1
+ var g=Object.defineProperty;var s=(i,t)=>g(i,"name",{value:t,configurable:!0});import{Node as u}from"ts-morph";import{success as c}from"../../types/Result.js";import{DEFAULT_FILE_PATH as m}from"../_internal.js";import{forEachFactoryMatch as y}from"./locateByShape.js";function F(i,t,r=m){const n=[],e=[],d=y(i,r,(o,p)=>{if(o.type!==t.type)return;const f={type:o.type,constructId:o.name,filePath:r};n.push(f);const l=L(p,t.property);l!==void 0&&l===t.value&&e.push(f)});if(!d.success)return d;const[a]=e;return e.length===1&&a!==void 0?c({resolved:!0,construct:a}):e.length===0?c({resolved:!1,reason:"no-literal-match",candidates:n}):c({resolved:!1,reason:"ambiguous",candidates:e})}s(F,"resolveConstructByLiteralProperty");function L(i,t){const r=i.getArguments()[1];if(r===void 0||!u.isObjectLiteralExpression(r))return;const n=r.getProperty(t);if(n===void 0||!u.isPropertyAssignment(n))return;const e=n.getInitializer();if(!(e===void 0||!u.isStringLiteral(e)))return e.getLiteralValue()}s(L,"readLiteralStringProperty");export{F as resolveConstructByLiteralProperty};
@@ -1 +1 @@
1
- import{success as p,failure as y}from"../../../types/Result.js";import{parse as m}from"../../fileRewriter/parse.js";import{classifyControlFlow as h}from"../../semanticIndex/classifyControlFlow.js";import{locateAllShapes as A}from"../../semanticIndex/locateByShape.js";const C=new Set(["loc","tokens","comments","original","range"]);function f(o){return typeof o=="object"&&o!==null&&typeof o.type=="string"}function S(o,i){if(!f(o))return;const e=[{node:o,ancestors:[]}];for(;e.length>0;){const t=e.pop();if(t===void 0)continue;const{node:n,ancestors:s}=t;if(n.type==="StringLiteral"&&typeof n.start=="number"&&n.start===i)return{node:n,ancestors:s};const c=[...s,n];for(const u of Object.keys(n)){if(C.has(u))continue;const r=n[u];if(Array.isArray(r))for(let a=r.length-1;a>=0;a-=1){const l=r[a];f(l)&&e.push({node:l,ancestors:c})}else f(r)&&e.push({node:r,ancestors:c})}}}const g={conditional:"try-catch",loop:"loop","function-body":"anonymous-helper",unknown:"anonymous-helper"};function d(o){const i=A(o);if(!i.success)return[];const e=m(o);if(!e.success)return[];const t=[];for(const n of i.data){const s=S(e.data,n.start);if(s===void 0)continue;const c=h(s.node,s.ancestors);t.push({name:n.symbolName,type:n.type,classification:c})}return t}const O={id:"classify",run(o){if(o.inputContent===void 0)return p({action:"proceed"});const i=d(o.inputContent),e=d(o.content);for(const t of e){const n=i.find(s=>s.name===t.name&&s.type===t.type);if(n!==void 0&&n.classification==="top-level"&&t.classification!=="top-level")return y({kind:"ControlFlowClassifierError",reason:g[t.classification],resource:{type:t.type,name:t.name},location:void 0,remediation:"The LLM output moved a resource into a conditional or loop scope."})}return p({action:"proceed"})}};export{O as classifyGate};
1
+ var m=Object.defineProperty;var a=(n,i)=>m(n,"name",{value:i,configurable:!0});import{success as d,failure as h}from"../../../types/Result.js";import{parse as A}from"../../fileRewriter/parse.js";import{classifyControlFlow as C}from"../../semanticIndex/classifyControlFlow.js";import{locateAllShapes as S}from"../../semanticIndex/locateByShape.js";const g=new Set(["loc","tokens","comments","original","range"]);function u(n){return typeof n=="object"&&n!==null&&typeof n.type=="string"}a(u,"isAstNode");function k(n,i){if(!u(n))return;const e=[{node:n,ancestors:[]}];for(;e.length>0;){const t=e.pop();if(t===void 0)continue;const{node:o,ancestors:s}=t;if(o.type==="StringLiteral"&&typeof o.start=="number"&&o.start===i)return{node:o,ancestors:s};const c=[...s,o];for(const l of Object.keys(o)){if(g.has(l))continue;const r=o[l];if(Array.isArray(r))for(let f=r.length-1;f>=0;f-=1){const p=r[f];u(p)&&e.push({node:p,ancestors:c})}else u(r)&&e.push({node:r,ancestors:c})}}}a(k,"findNodeAtOffset");const b={conditional:"try-catch",loop:"loop","function-body":"anonymous-helper",unknown:"anonymous-helper"};function y(n){const i=S(n);if(!i.success)return[];const e=A(n);if(!e.success)return[];const t=[];for(const o of i.data){const s=k(e.data,o.start);if(s===void 0)continue;const c=C(s.node,s.ancestors);t.push({name:o.symbolName,type:o.type,classification:c})}return t}a(y,"classifyAllResources");const E={id:"classify",run(n){if(n.inputContent===void 0)return d({action:"proceed"});const i=y(n.inputContent),e=y(n.content);for(const t of e){const o=i.find(s=>s.name===t.name&&s.type===t.type);if(o!==void 0&&o.classification==="top-level"&&t.classification!=="top-level")return h({kind:"ControlFlowClassifierError",reason:b[t.classification],resource:{type:t.type,name:t.name},location:void 0,remediation:"The LLM output moved a resource into a conditional or loop scope."})}return d({action:"proceed"})}};export{E as classifyGate};
@@ -1 +1 @@
1
- import{success as o,failure as r}from"../../../types/Result.js";import{locateByShape as p}from"../../semanticIndex/locateByShape.js";function u(t){return{id:"locate",run(e){const n=p(e.content,{type:e.plan.type,name:e.plan.name});if(!n.success)return r(n.error);const a=n.data!==void 0;return t.mode==="present"&&!a?r({kind:"ResourceNotFoundError",type:e.plan.type,name:e.plan.name,knownNames:[]}):t.mode==="absent"&&a?r({kind:"DuplicateResourceError",type:e.plan.type,name:e.plan.name}):o({action:"proceed"})}}}const c=u({mode:"present"});export{u as createLocateGate,c as locateGate};
1
+ var p=Object.defineProperty;var o=(n,e)=>p(n,"name",{value:e,configurable:!0});import{success as u,failure as t}from"../../../types/Result.js";import{locateByShape as s}from"../../semanticIndex/locateByShape.js";function m(n){return{id:"locate",run(e){const r=s(e.content,{type:e.plan.type,name:e.plan.name});if(!r.success)return t(r.error);const a=r.data!==void 0;return n.mode==="present"&&!a?t({kind:"ResourceNotFoundError",type:e.plan.type,name:e.plan.name,knownNames:[]}):n.mode==="absent"&&a?t({kind:"DuplicateResourceError",type:e.plan.type,name:e.plan.name}):u({action:"proceed"})}}}o(m,"createLocateGate");const l=m({mode:"present"});export{m as createLocateGate,l as locateGate};
@@ -1 +1 @@
1
- import{success as o}from"../../types/Result.js";function i(n,r){for(const t of n){const e=t.run(r);if(!e.success||e.data.action!=="proceed")return e}return o({action:"proceed"})}async function a(n,r){for(const t of n){if(r.signal?.aborted===!0)return o({action:"reject",failedGate:t.id,diagnostics:"aborted"});const e=await t.run(r);if(!e.success||e.data.action!=="proceed")return e}return o({action:"proceed"})}export{i as runPipeline,a as runPipelineAsync};
1
+ var i=Object.defineProperty;var o=(t,r)=>i(t,"name",{value:r,configurable:!0});import{success as c}from"../../types/Result.js";function u(t,r){for(const n of t){const e=n.run(r);if(!e.success||e.data.action!=="proceed")return e}return c({action:"proceed"})}o(u,"runPipeline");async function f(t,r){for(const n of t){if(r.signal?.aborted===!0)return c({action:"reject",failedGate:n.id,diagnostics:"aborted"});const e=await n.run(r);if(!e.success||e.data.action!=="proceed")return e}return c({action:"proceed"})}o(f,"runPipelineAsync");export{u as runPipeline,f as runPipelineAsync};
@@ -1 +1 @@
1
- import{buildAppConfigPath as i}from"@fjall/util";import{z as o}from"zod";const p=["nextjs","payload","nextjs+payload","express","remix","astro","unknown"],c=o.enum(p),l=["npm-workspaces","pnpm","lerna","turbo","nx"],f=o.enum(l),u=o.object({relativePath:o.string().describe("Path relative to repo root. '.' for flat repo, e.g. 'apps/website' for monorepo workspace."),framework:c,packageName:o.string().nullable(),hasDockerfile:o.boolean(),docker:o.object({path:o.string().describe("Path to chosen Dockerfile, relative to relativePath.")}).strict().nullable().describe("Docker build descriptor. Null if no Dockerfile present."),inferredPort:o.number().int().min(1).max(65535),suggestedAppName:o.string().describe("kebab-case app name suggestion derived from packageName or relativePath."),suggestedConfigPath:o.string().describe("Suggested fjall config path relative to repo root, e.g. 'fjall/website' or 'apps/website/fjall/website'.")}).strict(),g=o.object({isMonorepo:o.boolean(),monorepoTool:f.nullable(),rootPackageName:o.string().nullable(),apps:o.array(u).describe("Detected apps. Empty if nothing scaffoldable was found. Single-element for flat repos, multi-element for monorepos."),warnings:o.array(o.string()).describe("Non-fatal observations (e.g. 'apps/legacy has no package.json \u2014 skipped').")}).strict();function k(e,r){return r.turboJson?"turbo":r.nxJson?"nx":r.pnpmWorkspaceYaml?"pnpm":r.lernaJson?"lerna":e?.workspaces?"npm-workspaces":null}function w(e){return e?.workspaces?Array.isArray(e.workspaces)?e.workspaces:e.workspaces.packages??[]:[]}const d=[{framework:"nextjs+payload",required:["next","payload"]},{framework:"nextjs",required:["next"]},{framework:"payload",required:["payload"]},{framework:"remix",required:["@remix-run/node"]},{framework:"astro",required:["astro"]},{framework:"express",required:["express"]}];function D(e){if(!e)return"unknown";const r={...e.dependencies??{},...e.devDependencies??{}};for(const t of d)if(t.required.every(n=>n in r))return t.framework;return"unknown"}const m={nextjs:3e3,"nextjs+payload":3e3,payload:3e3,remix:3e3,astro:4321,express:3e3,unknown:3e3};function h(e){return m[e]}function y(e){if(e.length===0)return null;const r=e.find(s=>s==="Dockerfile");if(r)return{name:r,isDev:!1};const t=e.find(s=>s.startsWith("Dockerfile")&&!/\.(dev|local|test)$/i.test(s));if(t)return{name:t,isDev:!1};const n=e.find(s=>/\.dev$/i.test(s));if(n)return{name:n,isDev:!0};const a=e[0];return a===void 0?null:{name:a,isDev:!1}}function j(e,r){if(e){const n=e.replace(/^@[^/]+\//,"");if(n.length>0)return n}return r==="."||r===""?"app":r.split("/").pop()??"app"}function v(e,r){return r==="."||r===""?i(e):i(e,r)}export{u as AppDetectionSchema,p as FRAMEWORK_VALUES,c as FrameworkSchema,l as MONOREPO_TOOL_VALUES,f as MonorepoToolSchema,g as RepositoryDetectionSchema,w as extractWorkspaceGlobs,D as inferFrameworkFromDeps,k as inferMonorepoTool,h as inferPortForFramework,y as pickPreferredDockerfile,j as suggestAppName,v as suggestConfigPath};
1
+ var c=Object.defineProperty;var n=(e,r)=>c(e,"name",{value:r,configurable:!0});import{buildAppConfigPath as p}from"@fjall/util";import{z as o}from"zod";const l=["nextjs","payload","nextjs+payload","express","remix","astro","unknown"],f=o.enum(l),u=["npm-workspaces","pnpm","lerna","turbo","nx"],d=o.enum(u),m=o.object({relativePath:o.string().describe("Path relative to repo root. '.' for flat repo, e.g. 'apps/website' for monorepo workspace."),framework:f,packageName:o.string().nullable(),hasDockerfile:o.boolean(),docker:o.object({path:o.string().describe("Path to chosen Dockerfile, relative to relativePath.")}).strict().nullable().describe("Docker build descriptor. Null if no Dockerfile present."),inferredPort:o.number().int().min(1).max(65535),suggestedAppName:o.string().describe("kebab-case app name suggestion derived from packageName or relativePath."),suggestedConfigPath:o.string().describe("Suggested fjall config path relative to repo root, e.g. 'fjall/website' or 'apps/website/fjall/website'.")}).strict(),D=o.object({isMonorepo:o.boolean(),monorepoTool:d.nullable(),rootPackageName:o.string().nullable(),apps:o.array(m).describe("Detected apps. Empty if nothing scaffoldable was found. Single-element for flat repos, multi-element for monorepos."),warnings:o.array(o.string()).describe("Non-fatal observations (e.g. 'apps/legacy has no package.json \u2014 skipped').")}).strict();function h(e,r){return r.turboJson?"turbo":r.nxJson?"nx":r.pnpmWorkspaceYaml?"pnpm":r.lernaJson?"lerna":e?.workspaces?"npm-workspaces":null}n(h,"inferMonorepoTool");function y(e){return e?.workspaces?Array.isArray(e.workspaces)?e.workspaces:e.workspaces.packages??[]:[]}n(y,"extractWorkspaceGlobs");const x=[{framework:"nextjs+payload",required:["next","payload"]},{framework:"nextjs",required:["next"]},{framework:"payload",required:["payload"]},{framework:"remix",required:["@remix-run/node"]},{framework:"astro",required:["astro"]},{framework:"express",required:["express"]}];function j(e){if(!e)return"unknown";const r={...e.dependencies??{},...e.devDependencies??{}};for(const s of x)if(s.required.every(t=>t in r))return s.framework;return"unknown"}n(j,"inferFrameworkFromDeps");const b={nextjs:3e3,"nextjs+payload":3e3,payload:3e3,remix:3e3,astro:4321,express:3e3,unknown:3e3};function v(e){return b[e]}n(v,"inferPortForFramework");function A(e){if(e.length===0)return null;const r=e.find(a=>a==="Dockerfile");if(r)return{name:r,isDev:!1};const s=e.find(a=>a.startsWith("Dockerfile")&&!/\.(dev|local|test)$/i.test(a));if(s)return{name:s,isDev:!1};const t=e.find(a=>/\.dev$/i.test(a));if(t)return{name:t,isDev:!0};const i=e[0];return i===void 0?null:{name:i,isDev:!1}}n(A,"pickPreferredDockerfile");function E(e,r){if(e){const t=e.replace(/^@[^/]+\//,"");if(t.length>0)return t}return r==="."||r===""?"app":r.split("/").pop()??"app"}n(E,"suggestAppName");function P(e,r){return r==="."||r===""?p(e):p(e,r)}n(P,"suggestConfigPath");export{m as AppDetectionSchema,l as FRAMEWORK_VALUES,f as FrameworkSchema,u as MONOREPO_TOOL_VALUES,d as MonorepoToolSchema,D as RepositoryDetectionSchema,y as extractWorkspaceGlobs,j as inferFrameworkFromDeps,h as inferMonorepoTool,v as inferPortForFramework,A as pickPreferredDockerfile,E as suggestAppName,P as suggestConfigPath};
@@ -1,2 +1,2 @@
1
- import{success as g,failure as m}from"../types/Result.js";import{DnsRecordTypeSchema as I,BIND_DIRECTIVES as p,ALIAS_PREFIX as T}from"./types.js";const A=new Set(I.options);function E(e){return A.has(e.toUpperCase())}function v(e){return e.endsWith(".")?e.slice(0,-1):e}function L(e){let n=!1;for(let t=0;t<e.length;t++)if(e[t]==='"')n=!n;else if(e[t]===";"&&!n)return e.slice(0,t).trimEnd();return e}function C(e,n){const t=e.slice(n).join(" "),s=[];let i="",r=!1;for(const o of t)o==='"'?(r&&(s.push(i),i=""),r=!r):r&&(i+=o);return s.join(" ")}function R(e){const n=/;\s*auto\s*$/.test(e),s=e.replace(/;\s*auto\s*$/,"").trim().match(/^\$FJALL-DELEGATE\s+(\S+)\s+TO\s+(\S+)$/i);if(s)return{subdomain:s[1],targetAccount:s[2],auto:n}}function D(e){if(e.length<2)return;const n=e[1],t=e.slice(2);return{domainName:n,subjectAlternativeNames:t}}function $(e){const n=[];let t="",s=!1;for(const i of e)i==='"'?(s=!s,t+=i):/\s/.test(i)&&!s?t.length>0&&(n.push(t),t=""):t+=i;return t.length>0&&n.push(t),n}function S(e){if(e.length<2)return;let n=0;const t=e[n++];let s,i;for(;n<e.length&&i===void 0;){const o=e[n].toUpperCase();if(o==="IN")n++;else if(E(o))i=o,n++;else if(/^\d+$/.test(e[n]))s=parseInt(e[n],10),n++;else return}if(!i)return;const r=e.slice(n);switch(i){case"MX":{if(r.length<2)return;const o=parseInt(r[0],10),u=r.slice(1).join(" ");return{name:t,type:i,ttl:s,value:u,priority:o}}case"SRV":{if(r.length<4)return;const o=parseInt(r[0],10),u=parseInt(r[1],10),f=parseInt(r[2],10),a=r[3];return{name:t,type:i,ttl:s,value:a,priority:o,weight:u,port:f}}case"TXT":{const o=C(e,n);return{name:t,type:i,ttl:s,value:o}}case"CAA":{const o=r.join(" ");return{name:t,type:i,ttl:s,value:o}}case"A":{if(r.length===0)return;if(r[0].toUpperCase()==="ALIAS"){if(r.length<2)return;const u=r.slice(1).join(" ");return{name:t,type:i,ttl:s,value:`${T}${u}`}}return{name:t,type:i,ttl:s,value:r[0]}}default:return r.length===0?void 0:{name:t,type:i,ttl:s,value:r[0]}}}function y(e){const n=e.split(`
2
- `);let t,s=300;const i=[],r=[],o=[];for(const u of n){const f=u.trim();if(f===""||f.startsWith(";"))continue;if(f.toUpperCase().startsWith(p.FJALL_DELEGATE)){const l=R(f);l&&r.push(l);continue}const a=L(f);if(a==="")continue;const c=$(a);if(c.length===0)continue;const d=c[0].toUpperCase();if(d===p.ORIGIN){if(c.length<2)continue;t=v(c[1]);continue}if(d===p.TTL){if(c.length<2)continue;s=parseInt(c[1],10);continue}if(d===p.FJALL_CERT){const l=D(c);l&&o.push(l);continue}const h=S(c);h&&i.push(h)}return t?g({origin:t,ttl:s,records:i,delegations:r,certificates:o}):m(new Error("Missing $ORIGIN directive"))}function N(e,n){if(!e.startsWith("fjall:"))return;const t=e.split(":");if(t.length<3)return;const s=t[1],i=t[2],r=`${s}:${i}`;return n.get(r)??n.get(e)}export{y as parseZoneFile,N as resolveAlias};
1
+ var m=Object.defineProperty;var c=(e,n)=>m(e,"name",{value:n,configurable:!0});import{success as I,failure as T}from"../types/Result.js";import{DnsRecordTypeSchema as A,BIND_DIRECTIVES as d,ALIAS_PREFIX as E}from"./types.js";const v=new Set(A.options);function L(e){return v.has(e.toUpperCase())}c(L,"isRecordType");function C(e){return e.endsWith(".")?e.slice(0,-1):e}c(C,"stripTrailingDot");function R(e){let n=!1;for(let t=0;t<e.length;t++)if(e[t]==='"')n=!n;else if(e[t]===";"&&!n)return e.slice(0,t).trimEnd();return e}c(R,"stripInlineComment");function D(e,n){const t=e.slice(n).join(" "),s=[];let i="",r=!1;for(const o of t)o==='"'?(r&&(s.push(i),i=""),r=!r):r&&(i+=o);return s.join(" ")}c(D,"parseTxtValue");function $(e){const n=/;\s*auto\s*$/.test(e),s=e.replace(/;\s*auto\s*$/,"").trim().match(/^\$FJALL-DELEGATE\s+(\S+)\s+TO\s+(\S+)$/i);if(s)return{subdomain:s[1],targetAccount:s[2],auto:n}}c($,"parseDelegateDirective");function S(e){if(e.length<2)return;const n=e[1],t=e.slice(2);return{domainName:n,subjectAlternativeNames:t}}c(S,"parseCertDirective");function j(e){const n=[];let t="",s=!1;for(const i of e)i==='"'?(s=!s,t+=i):/\s/.test(i)&&!s?t.length>0&&(n.push(t),t=""):t+=i;return t.length>0&&n.push(t),n}c(j,"tokenise");function w(e){if(e.length<2)return;let n=0;const t=e[n++];let s,i;for(;n<e.length&&i===void 0;){const o=e[n].toUpperCase();if(o==="IN")n++;else if(L(o))i=o,n++;else if(/^\d+$/.test(e[n]))s=parseInt(e[n],10),n++;else return}if(!i)return;const r=e.slice(n);switch(i){case"MX":{if(r.length<2)return;const o=parseInt(r[0],10),f=r.slice(1).join(" ");return{name:t,type:i,ttl:s,value:f,priority:o}}case"SRV":{if(r.length<4)return;const o=parseInt(r[0],10),f=parseInt(r[1],10),l=parseInt(r[2],10),p=r[3];return{name:t,type:i,ttl:s,value:p,priority:o,weight:f,port:l}}case"TXT":{const o=D(e,n);return{name:t,type:i,ttl:s,value:o}}case"CAA":{const o=r.join(" ");return{name:t,type:i,ttl:s,value:o}}case"A":{if(r.length===0)return;if(r[0].toUpperCase()==="ALIAS"){if(r.length<2)return;const f=r.slice(1).join(" ");return{name:t,type:i,ttl:s,value:`${E}${f}`}}return{name:t,type:i,ttl:s,value:r[0]}}default:return r.length===0?void 0:{name:t,type:i,ttl:s,value:r[0]}}}c(w,"parseRecord");function U(e){const n=e.split(`
2
+ `);let t,s=300;const i=[],r=[],o=[];for(const f of n){const l=f.trim();if(l===""||l.startsWith(";"))continue;if(l.toUpperCase().startsWith(d.FJALL_DELEGATE)){const a=$(l);a&&r.push(a);continue}const p=R(l);if(p==="")continue;const u=j(p);if(u.length===0)continue;const h=u[0].toUpperCase();if(h===d.ORIGIN){if(u.length<2)continue;t=C(u[1]);continue}if(h===d.TTL){if(u.length<2)continue;s=parseInt(u[1],10);continue}if(h===d.FJALL_CERT){const a=S(u);a&&o.push(a);continue}const g=w(u);g&&i.push(g)}return t?I({origin:t,ttl:s,records:i,delegations:r,certificates:o}):T(new Error("Missing $ORIGIN directive"))}c(U,"parseZoneFile");function _(e,n){if(!e.startsWith("fjall:"))return;const t=e.split(":");if(t.length<3)return;const s=t[1],i=t[2],r=`${s}:${i}`;return n.get(r)??n.get(e)}c(_,"resolveAlias");export{U as parseZoneFile,_ as resolveAlias};
@@ -1,3 +1,3 @@
1
- import{BIND_DIRECTIVES as $,ALIAS_PREFIX as i}from"./types.js";function u(t,n){return t.length>=n?t:t+" ".repeat(n-t.length)}function l(t,n){const s=u(t.name,24),e=t.ttl!==void 0&&t.ttl!==n?`${t.ttl} `:"";switch(t.type){case"MX":return`${s} ${e}IN MX ${t.priority??10} ${t.value}`;case"SRV":return`${s} ${e}IN SRV ${t.priority??0} ${t.weight??0} ${t.port??0} ${t.value}`;case"TXT":return`${s} ${e}IN TXT "${t.value}"`;case"CAA":return`${s} ${e}IN CAA ${t.value}`;default:return t.type==="A"&&t.value.startsWith(i)?`${s} ${e}IN A ${t.value}`:`${s} ${e}IN ${t.type} ${t.value}`}}function p(t){const n=[];if(n.push("; zone.bind \u2014 managed by fjall"),n.push(`${$.ORIGIN} ${t.origin}.`),n.push(`${$.TTL} ${t.ttl}`),n.push(""),t.certificates.length>0){for(const s of t.certificates){const a=[s.domainName,...s.subjectAlternativeNames];n.push(`${$.FJALL_CERT} ${a.join(" ")}`)}n.push("")}if(t.delegations.length>0){for(const s of t.delegations){const a=s.auto?" ; auto":"";n.push(`${$.FJALL_DELEGATE} ${s.subdomain} TO ${s.targetAccount}${a}`)}n.push("")}for(const s of t.records)n.push(l(s,t.ttl));return n.join(`
1
+ var u=Object.defineProperty;var $=(t,n)=>u(t,"name",{value:n,configurable:!0});import{BIND_DIRECTIVES as i,ALIAS_PREFIX as l}from"./types.js";function f(t,n){return t.length>=n?t:t+" ".repeat(n-t.length)}$(f,"padRight");function p(t,n){const s=f(t.name,24),e=t.ttl!==void 0&&t.ttl!==n?`${t.ttl} `:"";switch(t.type){case"MX":return`${s} ${e}IN MX ${t.priority??10} ${t.value}`;case"SRV":return`${s} ${e}IN SRV ${t.priority??0} ${t.weight??0} ${t.port??0} ${t.value}`;case"TXT":return`${s} ${e}IN TXT "${t.value}"`;case"CAA":return`${s} ${e}IN CAA ${t.value}`;default:return t.type==="A"&&t.value.startsWith(l)?`${s} ${e}IN A ${t.value}`:`${s} ${e}IN ${t.type} ${t.value}`}}$(p,"formatRecord");function g(t){const n=[];if(n.push("; zone.bind \u2014 managed by fjall"),n.push(`${i.ORIGIN} ${t.origin}.`),n.push(`${i.TTL} ${t.ttl}`),n.push(""),t.certificates.length>0){for(const s of t.certificates){const a=[s.domainName,...s.subjectAlternativeNames];n.push(`${i.FJALL_CERT} ${a.join(" ")}`)}n.push("")}if(t.delegations.length>0){for(const s of t.delegations){const a=s.auto?" ; auto":"";n.push(`${i.FJALL_DELEGATE} ${s.subdomain} TO ${s.targetAccount}${a}`)}n.push("")}for(const s of t.records)n.push(p(s,t.ttl));return n.join(`
2
2
  `)+`
3
- `}export{p as generateZoneFile};
3
+ `}$(g,"generateZoneFile");export{g as generateZoneFile};
@@ -1,46 +1,36 @@
1
- import{generateZoneFile as d}from"./bindWriter.js";import{toPascalCase as p}from"../generation/common.js";import{GENERATOR_VERSION as c}from"../version.js";function $(e){const{domainName:t,hostedZoneId:o,records:a=[]}=e,s=`fjall/domains/${t}`,n={origin:t,ttl:300,records:a,delegations:[],certificates:[{domainName:t,subjectAlternativeNames:[]}]};return[{path:`${s}/zone.bind`,content:a.length>0?d(n):w(t)},{path:`${s}/infrastructure.ts`,content:m({domainName:t,records:a,hostedZoneId:o})},{path:`${s}/package.json`,content:f(t)},{path:`${s}/tsconfig.json`,content:k},{path:`${s}/cdk.json`,content:y},{path:`${s}/.gitignore`,content:g}]}function m(e){const{domainName:t,records:o,hostedZoneId:a}=e,s=p(t.split(".").join("")),n=o.map(r=>{const l=r.ttl!==void 0?`, ttl: ${r.ttl}`:"";return` { type: ${JSON.stringify(r.type)}, name: ${JSON.stringify(r.name)}, value: ${JSON.stringify(r.value)}${l} },`}),i=n.length>0?`[
2
- ${n.join(`
1
+ var m=Object.defineProperty;var r=(a,e)=>m(a,"name",{value:e,configurable:!0});import{toPascalCase as p}from"../generation/common.js";import{GENERATOR_VERSION as i}from"../version.js";function D(a){const{domainName:e,hostedZoneId:o,records:n=[]}=a,t=`fjall/domains/${e}`;return[{path:`${t}/infrastructure.ts`,content:w({domainName:e,records:n,hostedZoneId:o})},{path:`${t}/package.json`,content:f(e)},{path:`${t}/tsconfig.json`,content:g},{path:`${t}/cdk.json`,content:y},{path:`${t}/.gitignore`,content:k}]}r(D,"generateDomainFiles");function w(a){const{domainName:e,records:o,hostedZoneId:n}=a,t=p(e.split(".").join("")),c=o.map(s=>{const l=s.ttl!==void 0?`, ttl: ${s.ttl}`:"";return` { type: ${JSON.stringify(s.type)}, name: ${JSON.stringify(s.name)}, value: ${JSON.stringify(s.value)}${l} },`}),u=c.length>0?`[
2
+ ${c.join(`
3
3
  `)}
4
- ]`:"[]",u=a?` hostedZoneId: ${JSON.stringify(a)},
4
+ ]`:"[]",d=n?` hostedZoneId: ${JSON.stringify(n)},
5
5
  `:"";return`import {
6
6
  App,
7
7
  Domain,
8
8
  } from "@fjall/components-infrastructure";
9
9
 
10
10
  // Fjall-managed domain \u2014 edit this file to add or change records.
11
- // See docs/domains.md for the Domain construct API.
11
+ // See https://docs.fjall.io/resources/networking/domain for the Domain construct API.
12
12
 
13
- const app = App.getApp(${JSON.stringify(`${s}Domain`)});
13
+ const app = App.getApp(${JSON.stringify(`${t}Domain`)});
14
14
 
15
- new Domain(app, ${JSON.stringify(s)}, {
15
+ // Stack name must equal getDomainStackName(${JSON.stringify(e)}) \u2014 the CLI's
16
+ // deploy record and ManagedDomainBinding resolution both DescribeStacks by it.
17
+ const stack = app.getStack(${JSON.stringify(`${t}Domain`)}).getStack();
18
+
19
+ new Domain(stack, ${JSON.stringify(t)}, {
16
20
  registrar: "route53",
17
- zoneName: ${JSON.stringify(t)},
18
- ${u} certificates: [
19
- { domainName: ${JSON.stringify(t)} },
21
+ zoneName: ${JSON.stringify(e)},
22
+ ${d} certificates: [
23
+ { domainName: ${JSON.stringify(e)} },
20
24
  ],
21
- records: ${i},
25
+ records: ${u},
22
26
  });
23
- `}function w(e){return`; zone.bind \u2014 advisory copy only (Fjall reads infrastructure.ts)
24
- ; This file is written at import time with --preserve-bind; edit infrastructure.ts to change records
25
- $ORIGIN ${e}.
26
- $TTL 300
27
-
28
- ; Certificate for this domain
29
- $FJALL-CERT ${e}
30
-
31
- ; Add your DNS records below
32
- ; Examples:
33
- ; @ IN A ALIAS fjall:ecs:my-app
34
- ; www IN CNAME ${e}.
35
- ; api IN A ALIAS fjall:ecs:my-api
36
- ; @ IN MX 10 mail.${e}.
37
- `}function f(e){return JSON.stringify({name:`domain-${e}`,version:c,scripts:{},devDependencies:{"@types/node":"20.4.9","ts-node":"^10.9.1",typescript:"~5.1.6"},dependencies:{"@fjall/components-infrastructure":`^${c}`,"aws-cdk-lib":"^2.260.0",constructs:"^10.6.0"}},null,2)+`
38
- `}const g=`node_modules/
27
+ `}r(w,"generateDefaultInfrastructureTs");function f(a){return JSON.stringify({name:`domain-${a}`,version:i,scripts:{},devDependencies:{"@types/node":"20.4.9","ts-node":"^10.9.1",typescript:"~5.1.6"},dependencies:{"@fjall/components-infrastructure":`^${i}`,"aws-cdk-lib":"^2.260.0",constructs:"^10.6.0"}},null,2)+`
28
+ `}r(f,"generateDomainPackageJson");const k=`node_modules/
39
29
  cdk.out/
40
30
  *.d.ts
41
31
  *.js
42
32
  .deploy-state.json
43
33
  .deploy-state.json.tmp
44
- `,k=JSON.stringify({compilerOptions:{target:"ES2020",module:"commonjs",lib:["es2020","dom"],declaration:!0,strict:!0,noImplicitAny:!0,strictNullChecks:!0,noImplicitThis:!0,alwaysStrict:!0,noUnusedLocals:!1,noUnusedParameters:!1,noImplicitReturns:!0,noFallthroughCasesInSwitch:!1,inlineSourceMap:!0,inlineSources:!0,experimentalDecorators:!0,strictPropertyInitialization:!1,typeRoots:["./node_modules/@types"]},exclude:["node_modules","cdk.out"]},null,2)+`
34
+ `,g=JSON.stringify({compilerOptions:{target:"ES2020",module:"commonjs",lib:["es2020","dom"],declaration:!0,strict:!0,noImplicitAny:!0,strictNullChecks:!0,noImplicitThis:!0,alwaysStrict:!0,noUnusedLocals:!1,noUnusedParameters:!1,noImplicitReturns:!0,noFallthroughCasesInSwitch:!1,inlineSourceMap:!0,inlineSources:!0,experimentalDecorators:!0,strictPropertyInitialization:!1,typeRoots:["./node_modules/@types"]},exclude:["node_modules","cdk.out"]},null,2)+`
45
35
  `,y=JSON.stringify({app:"npx ts-node --prefer-ts-exts --transpile-only infrastructure.ts",assetMetadata:!1,pathMetadata:!1,versionReporting:!1,watch:{include:["**"],exclude:["README.md","cdk*.json","**/*.d.ts","**/*.js","tsconfig.json","package*.json","yarn.lock","node_modules","test"]},context:{"@aws-cdk/aws-lambda:recognizeLayerVersion":!0,"@aws-cdk/core:checkSecretUsage":!0,"@aws-cdk/core:target-partitions":["aws","aws-cn"],"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver":!0,"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName":!0,"@aws-cdk/aws-ecs:arnFormatIncludesClusterName":!0,"@aws-cdk/aws-iam:minimizePolicies":!0,"@aws-cdk/core:validateSnapshotRemovalPolicy":!0,"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName":!0,"@aws-cdk/aws-s3:createDefaultLoggingPolicy":!0,"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption":!0,"@aws-cdk/aws-apigateway:disableCloudWatchRole":!0,"@aws-cdk/core:enablePartitionLiterals":!0,"@aws-cdk/aws-events:eventsTargetQueueSameAccount":!0,"@aws-cdk/aws-iam:standardizedServicePrincipals":!0,"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker":!0,"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName":!0,"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy":!0,"@aws-cdk/aws-route53-patters:useCertificate":!0,"@aws-cdk/customresources:installLatestAwsSdkDefault":!1,"@aws-cdk/aws-rds:databaseProxyUniqueResourceName":!0,"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup":!0,"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId":!0,"@aws-cdk/aws-ec2:launchTemplateDefaultUserData":!0,"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments":!0,"@aws-cdk/aws-redshift:columnId":!0,"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2":!0,"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup":!0,"@aws-cdk/aws-apigateway:requestValidatorUniqueId":!0,"@aws-cdk/aws-kms:aliasNameRef":!0,"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig":!0,"@aws-cdk/core:includePrefixInUniqueNameGeneration":!0,"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby":!0}},null,2)+`
46
- `;export{$ as generateDomainFiles};
36
+ `;export{D as generateDomainFiles};
@@ -25,6 +25,17 @@ export declare const DomainRegistrarSchema: z.ZodEnum<{
25
25
  "external-records": "external-records";
26
26
  }>;
27
27
  export type DomainRegistrar = z.infer<typeof DomainRegistrarSchema>;
28
+ /**
29
+ * R2 two-step deploy gate on the delegated-child Domain topology (D8):
30
+ * `"zone"` synthesises the child zone + delegation record + records only;
31
+ * `"full"` (the construct default) additionally issues certificates.
32
+ * Mirrors `DomainDeployPhase` in @fjall/components-infrastructure.
33
+ */
34
+ export declare const DomainDeployPhaseSchema: z.ZodEnum<{
35
+ zone: "zone";
36
+ full: "full";
37
+ }>;
38
+ export type DomainDeployPhase = z.infer<typeof DomainDeployPhaseSchema>;
28
39
  export declare const ParsedStandardRecordSchema: z.ZodObject<{
29
40
  kind: z.ZodLiteral<"standard">;
30
41
  type: z.ZodEnum<{
@@ -1 +1 @@
1
- import{z as e}from"zod";const r=e.discriminatedUnion("kind",[e.object({kind:e.literal("ecs"),appName:e.string()}).strict(),e.object({kind:e.literal("cdn"),appName:e.string()}).strict(),e.object({kind:e.literal("bucket"),bucketName:e.string()}).strict(),e.object({kind:e.literal("custom"),dnsName:e.string(),hostedZoneId:e.string()}).strict()]),g=r.options.map(t=>t.shape.kind.value),a=e.enum(["A","AAAA"]),n=e.enum(["route53","external-delegated","external-records"]),i=e.object({kind:e.literal("standard"),type:e.enum(["A","AAAA","CNAME","MX","TXT","NS","SRV","CAA"]),name:e.string(),value:e.union([e.string(),e.array(e.string())]),ttl:e.number().int().positive().optional()}).strict(),o=e.object({kind:e.literal("alias"),type:a,name:e.string(),target:r}).strict(),s=e.discriminatedUnion("kind",[i,o]),d=e.object({domainName:e.string(),subjectAlternativeNames:e.array(e.string()).optional(),transparencyLogging:e.boolean().optional()}).strict(),c=e.object({subdomain:e.string(),toAccount:e.string(),auto:e.boolean().optional()}).strict(),m=e.object({zoneName:e.string(),registrar:n,hostedZoneId:e.string().optional(),delegatedSubdomain:e.string().optional(),records:e.array(s),certificates:e.array(d),delegations:e.array(c)}).strict().refine(t=>t.registrar!=="external-delegated"||t.delegatedSubdomain!==void 0,{message:"external-delegated requires delegatedSubdomain"}).refine(t=>t.registrar!=="external-records"||t.delegations.length===0,{message:"external-records forbids delegations"});export{a as AliasRecordTypeSchema,n as DomainRegistrarSchema,o as ParsedAliasRecordSchema,d as ParsedCertificateSchema,s as ParsedDnsRecordSchema,m as ParsedDomainRecordsSchema,i as ParsedStandardRecordSchema,c as ParsedSubdomainDelegationSchema,g as TYPED_FJALL_TARGET_KINDS,r as TypedFjallTargetSchema};
1
+ import{z as e}from"zod";const r=e.discriminatedUnion("kind",[e.object({kind:e.literal("ecs"),appName:e.string()}).strict(),e.object({kind:e.literal("cdn"),appName:e.string()}).strict(),e.object({kind:e.literal("bucket"),bucketName:e.string()}).strict(),e.object({kind:e.literal("custom"),dnsName:e.string(),hostedZoneId:e.string()}).strict()]),m=r.options.map(t=>t.shape.kind.value),a=e.enum(["A","AAAA"]),n=e.enum(["route53","external-delegated","external-records"]),g=e.enum(["zone","full"]),i=e.object({kind:e.literal("standard"),type:e.enum(["A","AAAA","CNAME","MX","TXT","NS","SRV","CAA"]),name:e.string(),value:e.union([e.string(),e.array(e.string())]),ttl:e.number().int().positive().optional()}).strict(),o=e.object({kind:e.literal("alias"),type:a,name:e.string(),target:r}).strict(),s=e.discriminatedUnion("kind",[i,o]),c=e.object({domainName:e.string(),subjectAlternativeNames:e.array(e.string()).optional(),transparencyLogging:e.boolean().optional()}).strict(),d=e.object({subdomain:e.string(),toAccount:e.string(),auto:e.boolean().optional()}).strict(),p=e.object({zoneName:e.string(),registrar:n,hostedZoneId:e.string().optional(),delegatedSubdomain:e.string().optional(),records:e.array(s),certificates:e.array(c),delegations:e.array(d)}).strict().refine(t=>t.registrar!=="external-delegated"||t.delegatedSubdomain!==void 0,{message:"external-delegated requires delegatedSubdomain"}).refine(t=>t.registrar!=="external-records"||t.delegations.length===0,{message:"external-records forbids delegations"});export{a as AliasRecordTypeSchema,g as DomainDeployPhaseSchema,n as DomainRegistrarSchema,o as ParsedAliasRecordSchema,c as ParsedCertificateSchema,s as ParsedDnsRecordSchema,p as ParsedDomainRecordsSchema,i as ParsedStandardRecordSchema,d as ParsedSubdomainDelegationSchema,m as TYPED_FJALL_TARGET_KINDS,r as TypedFjallTargetSchema};
@@ -1,7 +1,7 @@
1
- import{toPascalCase as N,toKebab as S,toValidDatabaseName as A}from"@fjall/util";function s(r){return JSON.stringify(r)}function l(r){return r.map(s).join(", ")}const m="import:SharedAlarmTopicArn";function d(r=" "){return`
2
- ${r}...(getConfig().environment === "production" ? { alertsTopic: ${s(m)} } : {}),`}function b(r){if(typeof r!="object"||r===null)return!1;const e=r;return typeof e.__identifier=="string"||typeof e.__expression=="string"||typeof e.__call=="string"}function c(r){return r.replace(/[^a-zA-Z0-9]/g," ").split(" ").map((e,t)=>t===0?e.charAt(0).toLowerCase()+e.slice(1):e.charAt(0).toUpperCase()+e.slice(1)).join("")}function g(r){return r.variableName??c(r.name)}function y(r,e){for(const t of r.database)if(t.name===e&&t.variableName)return t.variableName;for(const t of r.s3)if(t.name===e&&t.variableName)return t.variableName;for(const t of r.compute)if(t.name===e&&t.variableName)return t.variableName;for(const t of r.dynamodb??[])if(t.name===e&&t.variableName)return t.variableName;for(const t of r.sqs??[])if(t.name===e&&t.variableName)return t.variableName;return c(e)}function u(r){const e=Object.entries(r);return e.length===0?!0:e.length>1?!1:e.every(([,t])=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null)}function o(r,e=" "){if(r==null)return"undefined";if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean")return String(r);if(b(r)){if("__identifier"in r)return r.__identifier;if("__expression"in r)return r.__expression;if("__call"in r)return r.__call}if(Array.isArray(r))return`[${r.map(t=>o(t,e)).join(", ")}]`;if(typeof r=="object"){const t=Object.entries(r).filter(([,i])=>i!==void 0);if(u(r)){const i=t.map(([a,p])=>`${a}: ${o(p,e)}`).join(", ");return i?`{ ${i} }`:"{}"}const f=e+" ",n=t.map(([i,a])=>`${f}${i}: ${o(a,f)}`).join(`,
3
- `);return n?`{
4
- ${n}
5
- ${e}}`:"{}"}return JSON.stringify(r)}function _(r,e,t,f="raw"){if(!r)return"";let n;switch(f){case"string":n=s(String(t));break;case"object":n=o(t);break;case"boolean-or-object":n=t===!1?"false":o(t);break;default:n=String(t)}return`
6
- ${e}: ${n},`}function x(r,e=" "){return r?.length?r.map(t=>`
7
- ${e}${t.key}: ${t.sourceText},`).join(""):""}export{m as PRODUCTION_ALERTS_TOPIC_IMPORT,_ as buildProperty,x as emitExtraProperties,d as emitProductionAlertsTopicSpread,s as escapeStringLiteral,l as formatStringArray,o as formatValue,g as getVariableName,b as isSpecialValue,y as resolveResourceVariable,S as toKebab,N as toPascalCase,A as toValidDatabaseName,c as toVariableName};
1
+ var b=Object.defineProperty;var n=(r,e)=>b(r,"name",{value:e,configurable:!0});import{toPascalCase as O,toKebab as T,toValidDatabaseName as h}from"@fjall/util";function c(r){return JSON.stringify(r)}n(c,"escapeStringLiteral");function y(r){return r.map(c).join(", ")}n(y,"formatStringArray");const u="import:SharedAlarmTopicArn";function _(r=" "){return`
2
+ ${r}...(getConfig().environment === "production" ? { alertsTopic: ${c(u)} } : {}),`}n(_,"emitProductionAlertsTopicSpread");function l(r){if(typeof r!="object"||r===null)return!1;const e=r;return typeof e.__identifier=="string"||typeof e.__expression=="string"||typeof e.__call=="string"}n(l,"isSpecialValue");function p(r){return r.replace(/[^a-zA-Z0-9]/g," ").split(" ").map((e,t)=>t===0?e.charAt(0).toLowerCase()+e.slice(1):e.charAt(0).toUpperCase()+e.slice(1)).join("")}n(p,"toVariableName");function x(r){return r.variableName??p(r.name)}n(x,"getVariableName");function $(r,e){for(const t of r.database)if(t.name===e&&t.variableName)return t.variableName;for(const t of r.s3)if(t.name===e&&t.variableName)return t.variableName;for(const t of r.compute)if(t.name===e&&t.variableName)return t.variableName;for(const t of r.dynamodb??[])if(t.name===e&&t.variableName)return t.variableName;for(const t of r.sqs??[])if(t.name===e&&t.variableName)return t.variableName;return p(e)}n($,"resolveResourceVariable");function d(r){const e=Object.entries(r);return e.length===0?!0:e.length>1?!1:e.every(([,t])=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null)}n(d,"isSimpleObject");function f(r,e=" "){if(r==null)return"undefined";if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean")return String(r);if(l(r)){if("__identifier"in r)return r.__identifier;if("__expression"in r)return r.__expression;if("__call"in r)return r.__call}if(Array.isArray(r))return`[${r.map(t=>f(t,e)).join(", ")}]`;if(typeof r=="object"){const t=Object.entries(r).filter(([,o])=>o!==void 0);if(d(r)){const o=t.map(([s,m])=>`${s}: ${f(m,e)}`).join(", ");return o?`{ ${o} }`:"{}"}const a=e+" ",i=t.map(([o,s])=>`${a}${o}: ${f(s,a)}`).join(`,
3
+ `);return i?`{
4
+ ${i}
5
+ ${e}}`:"{}"}return JSON.stringify(r)}n(f,"formatValue");function j(r,e,t,a="raw"){if(!r)return"";let i;switch(a){case"string":i=c(String(t));break;case"object":i=f(t);break;case"boolean-or-object":i=t===!1?"false":f(t);break;default:i=String(t)}return`
6
+ ${e}: ${i},`}n(j,"buildProperty");function N(r,e=" "){return r?.length?r.map(t=>`
7
+ ${e}${t.key}: ${t.sourceText},`).join(""):""}n(N,"emitExtraProperties");export{u as PRODUCTION_ALERTS_TOPIC_IMPORT,j as buildProperty,N as emitExtraProperties,_ as emitProductionAlertsTopicSpread,c as escapeStringLiteral,y as formatStringArray,f as formatValue,x as getVariableName,l as isSpecialValue,$ as resolveResourceVariable,T as toKebab,O as toPascalCase,h as toValidDatabaseName,p as toVariableName};
@@ -1,4 +1,4 @@
1
- import{emitExtraProperties as r,escapeStringLiteral as i}from"../common.js";function a(e){let n="";return e.instanceType&&(n+=`
2
- instanceType: ${i(e.instanceType)},`),e.enableSSH!==void 0&&(n+=e.enableSSH?`
1
+ var i=Object.defineProperty;var r=(e,n)=>i(e,"name",{value:n,configurable:!0});import{emitExtraProperties as t,escapeStringLiteral as a}from"../common.js";function l(e){let n="";return e.instanceType&&(n+=`
2
+ instanceType: ${a(e.instanceType)},`),e.enableSSH!==void 0&&(n+=e.enableSSH?`
3
3
  ssh: {},`:`
4
- ssh: false,`),n+=r(e.extraProperties),n}export{a as generateEc2Code};
4
+ ssh: false,`),n+=t(e.extraProperties),n}r(l,"generateEc2Code");export{l as generateEc2Code};
@@ -1,42 +1,42 @@
1
- import{formatValue as S,emitExtraProperties as v,escapeStringLiteral as o,formatStringArray as T,emitProductionAlertsTopicSpread as O}from"../common.js";import{DATABASE_ENV_VARS as g,getConnectedDatabases as k,buildDatabaseEnvVars as R}from"../database.js";import{STORAGE_ENV_VARS as D,getConnectedStorage as N,buildStorageEnvVars as B,formatAllConnectionsCode as j}from"../storageConnections.js";import{MESSAGING_ENV_VARS as b,getConnectedMessaging as L,buildMessagingEnvVars as _}from"../messagingConnections.js";import{BASE_ENVIRONMENT_VARS as H,computeHasConnections as w,computeHasDatabaseConnections as C,computeHasMessagingConnections as P,computeHasStorageConnections as M,formatCompactOrExpandedObject as $,formatEnvBlock as V}from"./shared.js";function I(e){const n=[];if(e.instanceType!==void 0&&n.push(`instanceType: ${o(e.instanceType)}`),e.amiHardwareType!==void 0&&n.push(`amiHardwareType: ${o(e.amiHardwareType)}`),e.minCapacity!==void 0&&n.push(`minCapacity: ${e.minCapacity}`),e.maxCapacity!==void 0&&n.push(`maxCapacity: ${e.maxCapacity}`),e.memoryLimitMiB!==void 0&&n.push(`memoryLimitMiB: ${e.memoryLimitMiB}`),e.warmPool!==void 0&&n.push(`warmPool: ${S(e.warmPool," ")}`),e.extraProperties?.length)for(const t of e.extraProperties)n.push(`${t.key}: ${t.sourceText}`);return`
2
- ec2Config: ${$(n," "," ")},`}function G(e){if(!e.cluster)return"";const n=[];if(e.cluster.directAccess&&n.push("directAccess: true"),e.cluster.domain&&n.push(`domain: ${o(e.cluster.domain)}`),e.cluster.loadBalancer!==void 0&&n.push(e.cluster.loadBalancer===!1?"loadBalancer: false":`loadBalancer: ${o(e.cluster.loadBalancer)}`),e.cluster.extraProperties?.length)for(const t of e.cluster.extraProperties)n.push(`${t.key}: ${t.sourceText}`);return`
3
- cluster: ${$(n," "," ")},`}function J(e,n,t,m,l,h){let i="";e.name&&(i+=`
1
+ var O=Object.defineProperty;var u=(e,n)=>O(e,"name",{value:n,configurable:!0});import{formatValue as $,emitExtraProperties as E,escapeStringLiteral as o,formatStringArray as k,emitProductionAlertsTopicSpread as R}from"../common.js";import{DATABASE_ENV_VARS as y,getConnectedDatabases as D,buildDatabaseEnvVars as N}from"../database.js";import{STORAGE_ENV_VARS as B,getConnectedStorage as j,buildStorageEnvVars as L,formatAllConnectionsCode as _}from"../storageConnections.js";import{MESSAGING_ENV_VARS as C,getConnectedMessaging as H,buildMessagingEnvVars as w}from"../messagingConnections.js";import{BASE_ENVIRONMENT_VARS as I,computeHasConnections as G,computeHasDatabaseConnections as P,computeHasMessagingConnections as M,computeHasStorageConnections as V,formatCompactOrExpandedObject as v,formatEnvBlock as x}from"./shared.js";function J(e){const n=[];if(e.instanceType!==void 0&&n.push(`instanceType: ${o(e.instanceType)}`),e.amiHardwareType!==void 0&&n.push(`amiHardwareType: ${o(e.amiHardwareType)}`),e.minCapacity!==void 0&&n.push(`minCapacity: ${e.minCapacity}`),e.maxCapacity!==void 0&&n.push(`maxCapacity: ${e.maxCapacity}`),e.memoryLimitMiB!==void 0&&n.push(`memoryLimitMiB: ${e.memoryLimitMiB}`),e.warmPool!==void 0&&n.push(`warmPool: ${$(e.warmPool," ")}`),e.extraProperties?.length)for(const t of e.extraProperties)n.push(`${t.key}: ${t.sourceText}`);return`
2
+ ec2Config: ${v(n," "," ")},`}u(J,"generateEcsServiceEc2ConfigCode");function K(e){if(!e.cluster)return"";const n=[];if(e.cluster.directAccess&&n.push("directAccess: true"),e.cluster.domain&&n.push(`domain: ${o(e.cluster.domain)}`),e.cluster.loadBalancer!==void 0&&n.push(e.cluster.loadBalancer===!1?"loadBalancer: false":`loadBalancer: ${o(e.cluster.loadBalancer)}`),e.cluster.extraProperties?.length)for(const t of e.cluster.extraProperties)n.push(`${t.key}: ${t.sourceText}`);return`
3
+ cluster: ${v(n," "," ")},`}u(K,"generateEcsClusterCode");function U(e,n,t,l,h,p){let i="";e.name&&(i+=`
4
4
  name: ${o(e.name)},`),e.image&&(i+=`
5
5
  image: ${o(e.image)},`),e.port!==void 0&&(i+=`
6
6
  port: ${e.port},`),e.essential!==void 0&&(i+=`
7
7
  essential: ${e.essential},`),e.command?.length&&(i+=`
8
8
  command: ${JSON.stringify(e.command)},`),e.entryPoint?.length&&(i+=`
9
- entryPoint: ${JSON.stringify(e.entryPoint)},`);const c=[g.HOST,g.PORT,g.NAME,g.SSL,g.USERNAME,g.PASSWORD,D.NAME,b.URL,b.ARN],r=a=>{if(!a)return a;const d={};for(const[u,p]of Object.entries(a))c.some(y=>u===y||u.startsWith(`${y}_`))||(d[u]=p);return Object.keys(d).length>0?d:void 0},f=n?{...h,...t.env,...m.env,...l.env,...e.environment}:{...h,...r(e.environment)},s=n?{...t.secrets,...e.secretsImport}:r(e.secretsImport);return f&&Object.keys(f).length>0&&(i+=`
9
+ entryPoint: ${JSON.stringify(e.entryPoint)},`);const c=[y.HOST,y.PORT,y.NAME,y.SSL,y.USERNAME,y.PASSWORD,B.NAME,C.URL,C.ARN],r=u(a=>{if(!a)return a;const d={};for(const[m,g]of Object.entries(a))c.some(S=>m===S||m.startsWith(`${S}_`))||(d[m]=g);return Object.keys(d).length>0?d:void 0},"stripConnectionEnv"),f=n?{...p,...t.env,...l.env,...h.env,...e.environment}:{...p,...r(e.environment)},s=n?{...t.secrets,...e.secretsImport}:r(e.secretsImport);return f&&Object.keys(f).length>0&&(i+=`
10
10
  environment: {
11
- ${V(f," ")}
11
+ ${x(f," ")}
12
12
  },`),s&&Object.keys(s).length>0&&(i+=`
13
13
  secretsImport: {
14
- ${V(s," ")}
14
+ ${x(s," ")}
15
15
  },`),e.ssmSecrets&&e.ssmSecrets.length>0&&(i+=`
16
- secrets: [${T(e.ssmSecrets)}],`),e.healthCheck&&(i+=`
17
- healthCheck: ${S(e.healthCheck," ")},`),i+=v(e.extraProperties," "),i}function x(e,n){const t=[];return e.path&&t.push(`path: ${o(e.path)}`),e.host&&t.push(`host: ${o(e.host)}`),e.priority!==void 0&&t.push(`priority: ${e.priority}`),e.healthCheckPath&&t.push(`healthCheckPath: ${o(e.healthCheckPath)}`),$(t,n,`${n} `)}function K(e){const n=Array.isArray(e)?e:[e];return n.length===1?`
18
- routing: ${x(n[0]," ")},`:`
16
+ secrets: [${k(e.ssmSecrets)}],`),e.healthCheck&&(i+=`
17
+ healthCheck: ${$(e.healthCheck," ")},`),i+=E(e.extraProperties," "),i}u(U,"generateEcsContainerCode");function A(e,n){const t=[];return e.path&&t.push(`path: ${o(e.path)}`),e.host&&t.push(`host: ${o(e.host)}`),e.priority!==void 0&&t.push(`priority: ${e.priority}`),e.healthCheckPath&&t.push(`healthCheckPath: ${o(e.healthCheckPath)}`),v(t,n,`${n} `)}u(A,"formatRoutingRule");function W(e){const n=Array.isArray(e)?e:[e];return n.length===1?`
18
+ routing: ${A(n[0]," ")},`:`
19
19
  routing: [
20
- ${n.map(m=>x(m," ")).join(`,
20
+ ${n.map(l=>A(l," ")).join(`,
21
21
  `)},
22
- ],`}function U(e){if(e===!1)return`
22
+ ],`}u(W,"generateEcsServiceRoutingCode");function q(e){if(e===!1)return`
23
23
  scaling: false,`;if(typeof e!="object"||!(e.minCapacity!==void 0||e.maxCapacity!==void 0||e.desiredCount!==void 0||e.scalingType!==void 0))return"";const t=[];return e.minCapacity!==void 0&&t.push(`minCapacity: ${e.minCapacity}`),e.maxCapacity!==void 0&&t.push(`maxCapacity: ${e.maxCapacity}`),e.desiredCount!==void 0&&t.push(`desiredCount: ${e.desiredCount}`),e.scalingType&&t.push(`scalingType: ${o(e.scalingType)}`),`
24
- scaling: ${$(t," "," ")},`}function W(e,n,t){return{needsDb:e.needsDatabaseConnection!==void 0?e.needsDatabaseConnection:n&&C(t),needsStorage:e.needsStorageConnection!==void 0?e.needsStorageConnection:n&&M(t),needsMessaging:e.needsMessagingConnection!==void 0?e.needsMessagingConnection:n&&P(t)}}function q(e){const{service:n,isFirstService:t,hasConnections:m,dbEnvVars:l,storageEnvVars:h,messagingEnvVars:i,baseEnvVars:c,plan:r,compute:f}=e;let s=`
24
+ scaling: ${v(t," "," ")},`}u(q,"generateEcsServiceScalingCode");function z(e,n,t){return{needsDb:e.needsDatabaseConnection!==void 0?e.needsDatabaseConnection:n&&P(t),needsStorage:e.needsStorageConnection!==void 0?e.needsStorageConnection:n&&V(t),needsMessaging:e.needsMessagingConnection!==void 0?e.needsMessagingConnection:n&&M(t)}}u(z,"deriveServiceConnectionNeeds");function F(e){const{service:n,isFirstService:t,hasConnections:l,dbEnvVars:h,storageEnvVars:p,messagingEnvVars:i,baseEnvVars:c,plan:r,compute:f}=e;let s=`
25
25
  name: ${o(n.name)},`;s+=`
26
- capacityProvider: ${o(n.capacityProvider)},`,n.ec2Config&&(s+=I(n.ec2Config)),n.docker&&(s+=`
27
- docker: ${S(n.docker," ")},`),n.image&&(s+=`
26
+ capacityProvider: ${o(n.capacityProvider)},`,n.ec2Config&&(s+=J(n.ec2Config)),n.docker&&(s+=`
27
+ docker: ${$(n.docker," ")},`),n.image&&(s+=`
28
28
  image: ${o(n.image)},`),n.ssmSecretsPath&&(s+=`
29
- ssmSecretsPath: ${o(n.ssmSecretsPath)},`);const a=W(n,t,f);if(n.containers?.length){s+=`
30
- containers: [{`;for(let d=0;d<n.containers.length;d++){const u=n.containers[d];if(!u)continue;const p=d===0&&(a.needsDb||a.needsStorage||a.needsMessaging)&&m,E=a.needsDb?l:{env:{},secrets:{}},y=a.needsStorage?h:{env:{},secrets:{}},A=a.needsMessaging?i:{env:{},secrets:{}};d>0&&(s+=`
31
- }, {`),s+=J(u,p,E,y,A,c)}s+=`
32
- }],`}if(n.routing&&(s+=K(n.routing)),n.cpu!==void 0&&(s+=`
29
+ ssmSecretsPath: ${o(n.ssmSecretsPath)},`);const a=z(n,t,f);if(n.containers?.length){s+=`
30
+ containers: [{`;for(let d=0;d<n.containers.length;d++){const m=n.containers[d];if(!m)continue;const g=d===0&&(a.needsDb||a.needsStorage||a.needsMessaging)&&l,b=a.needsDb?h:{env:{},secrets:{}},S=a.needsStorage?p:{env:{},secrets:{}},T=a.needsMessaging?i:{env:{},secrets:{}};d>0&&(s+=`
31
+ }, {`),s+=U(m,g,b,S,T,c)}s+=`
32
+ }],`}if(n.routing&&(s+=W(n.routing)),n.cpu!==void 0&&(s+=`
33
33
  cpu: ${n.cpu},`),n.memoryLimitMiB!==void 0&&(s+=`
34
34
  memoryLimitMiB: ${n.memoryLimitMiB},`),n.desiredCount!==void 0&&(s+=`
35
- desiredCount: ${n.desiredCount},`),n.scaling!==void 0&&(s+=U(n.scaling)),n.alarms===!1?s+=`
35
+ desiredCount: ${n.desiredCount},`),n.scaling!==void 0&&(s+=q(n.scaling)),n.alarms===!1?s+=`
36
36
  alarms: false,`:typeof n.alarms=="object"&&(s+=`
37
- alarms: ${S(n.alarms," ")},`),s+=v(n.extraProperties," "),a.needsDb||a.needsStorage||a.needsMessaging){const d=a.needsDb?k(r,f):[],u=a.needsStorage?N(r,f):[],p=a.needsMessaging?L(r,f):[];(d.length>0||u.length>0||p.length>0)&&(s+=`
38
- ${j(d,u,p)}`)}return s}function Z(e,n){const t=w(e),m={...H},l={env:{},secrets:{}};if(C(e)){const r=R(n,e);Object.assign(l.env,r.env),Object.assign(l.secrets,r.secrets)}const h={env:{},secrets:{}};if(M(e)){const r=B(n,e);Object.assign(h.env,r.env)}const i={env:{},secrets:{}};if(P(e)){const r=_(n,e);Object.assign(i.env,r.env)}let c=`
39
- ecrRepository: app.getDefaultContainerRegistry(),`;if(c+=G(e),e.services?.length){c+=`
37
+ alarms: ${$(n.alarms," ")},`),s+=E(n.extraProperties," "),a.needsDb||a.needsStorage||a.needsMessaging){const d=a.needsDb?D(r,f):[],m=a.needsStorage?j(r,f):[],g=a.needsMessaging?H(r,f):[];(d.length>0||m.length>0||g.length>0)&&(s+=`
38
+ ${_(d,m,g)}`)}return s}u(F,"generateEcsServiceCode");function te(e,n){const t=G(e),l={...I},h={env:{},secrets:{}};if(P(e)){const r=N(n,e);Object.assign(h.env,r.env),Object.assign(h.secrets,r.secrets)}const p={env:{},secrets:{}};if(V(e)){const r=L(n,e);Object.assign(p.env,r.env)}const i={env:{},secrets:{}};if(M(e)){const r=w(n,e);Object.assign(i.env,r.env)}let c=`
39
+ ecrRepository: app.getDefaultContainerRegistry(),`;if(c+=K(e),e.services?.length){c+=`
40
40
  services: [{`;for(let r=0;r<e.services.length;r++){const f=e.services[r];f&&(r>0&&(c+=`
41
- }, {`),c+=q({service:f,isFirstService:r===0,hasConnections:t,dbEnvVars:l,storageEnvVars:h,messagingEnvVars:i,baseEnvVars:m,plan:n,compute:e}))}c+=`
42
- }],`}return c+=v(e.extraProperties),c+=O(),c}export{Z as generateEcsCode};
41
+ }, {`),c+=F({service:f,isFirstService:r===0,hasConnections:t,dbEnvVars:h,storageEnvVars:p,messagingEnvVars:i,baseEnvVars:l,plan:n,compute:e}))}c+=`
42
+ }],`}return c+=E(e.extraProperties),c+=R(),c}u(te,"generateEcsCode");export{te as generateEcsCode};
@@ -1,4 +1,4 @@
1
- import{formatValue as m,emitExtraProperties as S,escapeStringLiteral as a,formatStringArray as $}from"../common.js";import{getConnectedDatabases as v,generateDatabaseEnvVarEntries as b,toDatabaseEnvVarValue as D}from"../database.js";import{getConnectedStorage as O,generateStorageEnvVarEntries as T,formatAllConnectionsCode as A}from"../storageConnections.js";import{getConnectedMessaging as N,generateMessagingEnvVarEntries as _}from"../messagingConnections.js";import{DEPLOYMENT_TYPE as l,DEFAULT_COMPUTE_ARCHITECTURE as k}from"../../schemas/constants.js";import{BASE_ENVIRONMENT_VARS as C,computeHasConnections as x,computeHasDatabaseConnections as P,computeHasMessagingConnections as V,computeHasStorageConnections as R,formatEnvBlock as M}from"./shared.js";function z(e){let n="";if(e.deployment===l.CODE&&e.codePath?(n+=`
1
+ var $=Object.defineProperty;var h=(e,n)=>$(e,"name",{value:n,configurable:!0});import{formatValue as C,emitExtraProperties as v,escapeStringLiteral as a,formatStringArray as b}from"../common.js";import{getConnectedDatabases as D,generateDatabaseEnvVarEntries as O,toDatabaseEnvVarValue as T}from"../database.js";import{getConnectedStorage as A,generateStorageEnvVarEntries as N,formatAllConnectionsCode as _}from"../storageConnections.js";import{getConnectedMessaging as k,generateMessagingEnvVarEntries as x}from"../messagingConnections.js";import{DEPLOYMENT_TYPE as l,DEFAULT_COMPUTE_ARCHITECTURE as P}from"../../schemas/constants.js";import{BASE_ENVIRONMENT_VARS as E,computeHasConnections as V,computeHasDatabaseConnections as R,computeHasMessagingConnections as M,computeHasStorageConnections as U,formatEnvBlock as j}from"./shared.js";function Y(e){let n="";if(e.deployment===l.CODE&&e.codePath?(n+=`
2
2
  deployment: "${l.CODE}",
3
3
  code: Code.fromAsset(${a(e.codePath)}),`,e.handler&&(n+=`
4
4
  handler: ${a(e.handler)},`),e.runtime&&(n+=`
@@ -8,19 +8,19 @@ import{formatValue as m,emitExtraProperties as S,escapeStringLiteral as a,format
8
8
  timeout: ${e.timeout},`),e.memory!==void 0&&(n+=`
9
9
  memorySize: ${e.memory},`),e.functionUrl&&(n+=`
10
10
  functionUrl: { authType: FunctionUrlAuthType.${e.functionUrl.authType} },`),e.description&&(n+=`
11
- lambdaDescription: ${a(e.description)},`),e.architecture||e.deployment===l.CONTAINER){const i=e.architecture??k;n+=`
11
+ lambdaDescription: ${a(e.description)},`),e.architecture||e.deployment===l.CONTAINER){const i=e.architecture??P;n+=`
12
12
  architecture: Architecture.${i},`}if(e.ephemeralStorageSize!==void 0&&(n+=`
13
13
  ephemeralStorageSize: ${e.ephemeralStorageSize},`),e.functionName&&(n+=`
14
14
  functionName: ${a(e.functionName)},`),e.ssmSecretsPath&&(n+=`
15
15
  ssmSecretsPath: ${a(e.ssmSecretsPath)},`),e.ssmSecrets&&e.ssmSecrets.length>0&&(n+=`
16
- secrets: [${$(e.ssmSecrets)}],`),!x(e)){const i={...C,...e.environment};n+=`
16
+ secrets: [${b(e.ssmSecrets)}],`),!V(e)){const i={...E,...e.environment};n+=`
17
17
  environment: {
18
- ${M(i," ")}
19
- },`}return n+=S(e.extraProperties),n}function B(e,n){const i=P(e),h=R(e),y=V(e);if(!i&&!h&&!y)return"";const f=i?v(n,e):[],c=h?O(n,e):[],g=y?N(n,e):[];if(f.length===0&&c.length===0&&g.length===0)return"";const o={...C},d={};if(f.length>0){const r=b(f);for(const t of r){const E=D(t);t.isSecret?d[t.key]={__expression:t.expression}:o[t.key]=E}}if(c.length>0){const r=T(c);for(const t of r)o[t.key]={__expression:t.expression}}if(g.length>0){const r=_(g);for(const t of r)o[t.key]={__expression:t.expression}}if(e.environment)for(const[r,t]of Object.entries(e.environment))o[r]=t;let s="";if(Object.keys(d).length>0){s+=`
18
+ ${j(i," ")}
19
+ },`}return n+=v(e.extraProperties),n}h(Y,"generateLambdaCode");function p(e,n){const i=R(e),y=U(e),m=M(e);if(!i&&!y&&!m)return"";const f=i?D(n,e):[],c=y?A(n,e):[],g=m?k(n,e):[];if(f.length===0&&c.length===0&&g.length===0)return"";const o={...E},d={};if(f.length>0){const r=O(f);for(const t of r){const S=T(t);t.isSecret?d[t.key]={__expression:t.expression}:o[t.key]=S}}if(c.length>0){const r=N(c);for(const t of r)o[t.key]={__expression:t.expression}}if(g.length>0){const r=x(g);for(const t of r)o[t.key]={__expression:t.expression}}if(e.environment)for(const[r,t]of Object.entries(e.environment))o[r]=t;let s="";if(Object.keys(d).length>0){s+=`
20
20
  containerSecretsImport: {`;for(const[r,t]of Object.entries(d))s+=`
21
- ${r}: ${m(t)},`;s+=`
21
+ ${r}: ${C(t)},`;s+=`
22
22
  },`}if(Object.keys(o).length>0){s+=`
23
23
  environment: {`;for(const[r,t]of Object.entries(o))s+=`
24
- ${r}: ${m(t)},`;s+=`
24
+ ${r}: ${C(t)},`;s+=`
25
25
  },`}return s+=`
26
- ${A(f,c,g)}`,s}export{z as generateLambdaCode,B as generateLambdaConnectionsCode};
26
+ ${_(f,c,g)}`,s}h(p,"generateLambdaConnectionsCode");export{Y as generateLambdaCode,p as generateLambdaConnectionsCode};