@fjall/generator 2.19.3 → 2.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/.minified +1 -1
  2. package/dist/src/ast/{astDomainParser.d.ts → domain/astDomainParser.d.ts} +2 -2
  3. package/dist/src/ast/domain/astDomainParser.js +1 -0
  4. package/dist/src/ast/index.d.ts +5 -5
  5. package/dist/src/ast/index.js +1 -1
  6. package/dist/src/ast/{astCodeInjection.d.ts → mutation/astCodeInjection.d.ts} +1 -1
  7. package/dist/src/ast/{astCodeInjection.js → mutation/astCodeInjection.js} +1 -1
  8. package/dist/src/ast/{astExpressionEvaluator.d.ts → mutation/astExpressionEvaluator.d.ts} +1 -1
  9. package/dist/src/ast/mutation/astExpressionEvaluator.js +1 -0
  10. package/dist/src/ast/{astSurgicalModification.d.ts → mutation/astSurgicalModification.d.ts} +1 -1
  11. package/dist/src/ast/{astSurgicalModification.js → mutation/astSurgicalModification.js} +1 -1
  12. package/dist/src/ast/{astCommonParser.d.ts → parsers/common/astCommonParser.d.ts} +2 -2
  13. package/dist/src/ast/parsers/common/astCommonParser.js +1 -0
  14. package/dist/src/ast/{astStatementClassifier.d.ts → parsers/common/astStatementClassifier.d.ts} +1 -1
  15. package/dist/src/ast/parsers/common/astStatementClassifier.js +1 -0
  16. package/dist/src/ast/{astStatementQueries.d.ts → parsers/common/astStatementQueries.d.ts} +1 -1
  17. package/dist/src/ast/{astInfrastructureParser.d.ts → parsers/orchestrator/astInfrastructureParser.d.ts} +28 -28
  18. package/dist/src/ast/parsers/orchestrator/astInfrastructureParser.js +1 -0
  19. package/dist/src/ast/{astPlanConverter.d.ts → parsers/orchestrator/astPlanConverter.d.ts} +1 -1
  20. package/dist/src/ast/parsers/orchestrator/astPlanConverter.js +2 -0
  21. package/dist/src/ast/{astCdnParser.d.ts → parsers/resources/astCdnParser.d.ts} +2 -2
  22. package/dist/src/ast/parsers/resources/astCdnParser.js +1 -0
  23. package/dist/src/ast/{astClickHouseParser.d.ts → parsers/resources/astClickHouseParser.d.ts} +1 -1
  24. package/dist/src/ast/parsers/resources/astClickHouseParser.js +1 -0
  25. package/dist/src/ast/{astComputeConnectionParser.d.ts → parsers/resources/astComputeConnectionParser.d.ts} +2 -2
  26. package/dist/src/ast/parsers/resources/astComputeConnectionParser.js +1 -0
  27. package/dist/src/ast/{astComputeParser.d.ts → parsers/resources/astComputeParser.d.ts} +2 -2
  28. package/dist/src/ast/parsers/resources/astComputeParser.js +1 -0
  29. package/dist/src/ast/{astComputeParserHelpers.d.ts → parsers/resources/astComputeParserHelpers.d.ts} +2 -2
  30. package/dist/src/ast/parsers/resources/astComputeParserHelpers.js +1 -0
  31. package/dist/src/ast/{astDatabaseParser.d.ts → parsers/resources/astDatabaseParser.d.ts} +1 -1
  32. package/dist/src/ast/parsers/resources/astDatabaseParser.js +1 -0
  33. package/dist/src/ast/{astDynamoDBParser.d.ts → parsers/resources/astDynamoDBParser.d.ts} +1 -1
  34. package/dist/src/ast/parsers/resources/astDynamoDBParser.js +1 -0
  35. package/dist/src/ast/{astMessagingParser.d.ts → parsers/resources/astMessagingParser.d.ts} +2 -2
  36. package/dist/src/ast/parsers/resources/astMessagingParser.js +1 -0
  37. package/dist/src/ast/{astNetworkParser.d.ts → parsers/resources/astNetworkParser.d.ts} +2 -2
  38. package/dist/src/ast/parsers/resources/astNetworkParser.js +1 -0
  39. package/dist/src/ast/{astPatternParser.d.ts → parsers/resources/astPatternParser.d.ts} +1 -1
  40. package/dist/src/ast/parsers/resources/astPatternParser.js +1 -0
  41. package/dist/src/ast/parsers/resources/astScheduleParser.js +1 -0
  42. package/dist/src/ast/{astStorageParser.d.ts → parsers/resources/astStorageParser.d.ts} +2 -2
  43. package/dist/src/ast/parsers/resources/astStorageParser.js +1 -0
  44. package/dist/src/planning/resourcePlanning.js +1 -1
  45. package/dist/src/version.d.ts +1 -1
  46. package/dist/src/version.js +1 -1
  47. package/package.json +3 -3
  48. package/dist/src/ast/astCdnParser.js +0 -1
  49. package/dist/src/ast/astClickHouseParser.js +0 -1
  50. package/dist/src/ast/astCommonParser.js +0 -1
  51. package/dist/src/ast/astComputeConnectionParser.js +0 -1
  52. package/dist/src/ast/astComputeParser.js +0 -1
  53. package/dist/src/ast/astComputeParserHelpers.js +0 -1
  54. package/dist/src/ast/astDatabaseParser.js +0 -1
  55. package/dist/src/ast/astDomainParser.js +0 -1
  56. package/dist/src/ast/astDynamoDBParser.js +0 -1
  57. package/dist/src/ast/astExpressionEvaluator.js +0 -1
  58. package/dist/src/ast/astInfrastructureParser.js +0 -1
  59. package/dist/src/ast/astMessagingParser.js +0 -1
  60. package/dist/src/ast/astNetworkParser.js +0 -1
  61. package/dist/src/ast/astPatternParser.js +0 -1
  62. package/dist/src/ast/astPlanConverter.js +0 -2
  63. package/dist/src/ast/astScheduleParser.js +0 -1
  64. package/dist/src/ast/astStatementClassifier.js +0 -1
  65. package/dist/src/ast/astStorageParser.js +0 -1
  66. /package/dist/src/ast/{astStatementQueries.js → parsers/common/astStatementQueries.js} +0 -0
  67. /package/dist/src/ast/{astScheduleParser.d.ts → parsers/resources/astScheduleParser.d.ts} +0 -0
package/dist/.minified CHANGED
@@ -1 +1 @@
1
- 139 files minified at 2026-06-20T10:10:35.456Z
1
+ 139 files minified at 2026-06-22T21:30:27.962Z
@@ -1,6 +1,6 @@
1
1
  import * as ts from "typescript";
2
- import { type Result } from "../types/Result.js";
3
- import { type DnsRecordType } from "../dns/types.js";
2
+ import { type Result } from "../../types/Result.js";
3
+ import { type DnsRecordType } from "../../dns/types.js";
4
4
  /** One-of match for a single `new Domain(...)` call in an infrastructure file. */
5
5
  export interface DomainCallMatch {
6
6
  readonly callExpression: ts.NewExpression;
@@ -0,0 +1 @@
1
+ import*as l from"typescript";import{parseObjectLiteral as x,asString as c,asStringUnion as y,asStringArray as k,asBoolean as h,asNumber as N,isCallRef as T,isParsedObject as g}from"../parsers/common/astCommonParser.js";import{success as a,failure as u}from"../../types/Result.js";import{DnsRecordTypeSchema as $}from"../../dns/types.js";import{DomainRegistrarSchema as I,AliasRecordTypeSchema as D,TYPED_FJALL_TARGET_KINDS as R}from"../../dns/domainRecords.js";const _=I.options,E=$.options,L=D.options;function U(e){const n=[],t=i=>{if(l.isNewExpression(i)&&j(i.expression)){const o=v(i);o!==void 0&&n.push(o)}l.forEachChild(i,t)};if(t(e),n.length===0)return a(void 0);if(n.length>1)return u(new Error(`Expected exactly one 'new Domain(...)' call per infrastructure file, found ${n.length}`));const r=n[0];return r?a(r):a(void 0)}function j(e){return l.isIdentifier(e)&&e.text==="Domain"}function v(e){const n=e.arguments;if(!n||n.length<3)return;const t=n[0],r=n[1],i=n[2];if(!t||!r||!i||!l.isObjectLiteralExpression(i))return;const o=O(e);if(o===void 0)return;const d=C(e),s=l.isStringLiteral(r)?r.text:void 0;return{callExpression:e,containingStatement:o,propsObjectLiteral:i,domainVarId:d,scopeArgumentText:t.getText(),constructIdLiteral:s}}function O(e){let n=e;for(;n!==void 0;){if(l.isExpressionStatement(n)||l.isVariableStatement(n))return n;n=n.parent}}function C(e){let n=e.parent;for(;n!==void 0;){if(l.isVariableDeclaration(n)&&l.isIdentifier(n.name)&&n.initializer===e)return n.name.text;n=n.parent}}function Z(e){switch(e.kind){case"registrar_required":return"'registrar' property is required";case"registrar_unsupported":return`'registrar' must be one of ${_.join(", ")}, got ${JSON.stringify(e.value)}`;case"missing_field":return`'${e.field}' property is required`;case"invalid_literal":return`'${e.field}' ${e.reason}`}}function H(e){const n=x(e),t=y(n.registrar,_);if(t===void 0){const s=n.registrar;if(s===void 0)return u({kind:"registrar_required"});const f=typeof s=="string"?s:p(s);return u({kind:"registrar_unsupported",value:f})}const r=c(n.zoneName);if(r===void 0)return u({kind:"missing_field",field:"zoneName"});const i=V(n.records);if(!i.success)return i;const o=M(n.certificates);if(!o.success)return o;const d={zoneName:r,description:c(n.description),costAllocationEnvironment:c(n.costAllocationEnvironment),tags:Y(n.tags),records:i.data,certificates:o.data};switch(t){case"route53":{const s=S(n.delegations);return s.success?a({...d,registrar:t,hostedZoneId:c(n.hostedZoneId),delegations:s.data}):s}case"external-delegated":{const s=c(n.delegatedSubdomain);if(s===void 0)return u({kind:"missing_field",field:"delegatedSubdomain"});const f=S(n.delegations);return f.success?a({...d,registrar:t,delegatedSubdomain:s,delegations:f.data}):f}case"external-records":return a({...d,registrar:t})}}function Q(e){return Z(e)}function V(e){if(e===void 0)return a([]);if(!Array.isArray(e))return u({kind:"invalid_literal",field:"records",reason:"must be an array"});const n=[];for(let t=0;t<e.length;t++){const r=e[t];if(!g(r))return u({kind:"invalid_literal",field:`records[${t}]`,reason:"must be an object literal"});const i=P(r,t);if(!i.success)return i;n.push(i.data)}return a(n)}function P(e,n){const t=c(e.type),r=c(e.name);if(t===void 0)return u({kind:"missing_field",field:`records[${n}].type`});if(r===void 0)return u({kind:"missing_field",field:`records[${n}].name`});if(e.target!==void 0){if(!L.some(f=>f===t))return u({kind:"invalid_literal",field:`records[${n}]`,reason:`alias records must have type 'A' or 'AAAA', got '${t}'`});const s=q(e.target);return a({kind:"alias",type:t,name:r,target:s})}if(!E.some(s=>s===t))return u({kind:"invalid_literal",field:`records[${n}]`,reason:`unsupported record type '${t}'`});const i=z(e.value);if(i===void 0)return u({kind:"invalid_literal",field:`records[${n}].value`,reason:`must be a string or array of strings (got ${JSON.stringify(e.value)})`});const o=N(e.ttl),d={kind:"standard",type:t,name:r,value:i,...o!==void 0?{ttl:o}:{}};return a(d)}function z(e){if(e===void 0)return;if(typeof e=="string")return e;const n=k(e);if(n!==void 0)return n}function q(e){if(T(e))return J(e);if(g(e)){const n=y(e.kind,R);if(n==="ecs"||n==="cdn"){const t=c(e.appName);if(t!==void 0)return{kind:n,appName:t}}if(n==="bucket"){const t=c(e.bucketName);if(t!==void 0)return{kind:n,bucketName:t}}if(n==="custom"){const t=c(e.dnsName),r=c(e.hostedZoneId);if(t!==void 0&&r!==void 0)return{kind:n,dnsName:t,hostedZoneId:r}}}return{kind:"unresolved",sourceText:p(e)}}function J(e){const n=e.__call.trim(),t=n.match(/^([A-Za-z_][\w$]*)\s*\(([\s\S]*)\)\s*$/);if(!t)return{kind:"unresolved",sourceText:n};const r=t[1],i=t[2]??"",o=A(i);switch(r){case"fjallApp":{const d=m(o,0);return d===void 0?{kind:"dynamic",sourceText:n}:{kind:"ecs",appName:d}}case"fjallCdn":{const d=m(o,0);return d===void 0?{kind:"dynamic",sourceText:n}:{kind:"cdn",appName:d}}case"fjallBucket":{const d=m(o,0);return d===void 0?{kind:"dynamic",sourceText:n}:{kind:"bucket",bucketName:d}}case"aliasTo":{if(o.length>=2){const d=m(o,0),s=m(o,1);return d!==void 0&&s!==void 0?{kind:"custom",dnsName:d,hostedZoneId:s}:{kind:"dynamic",sourceText:n}}if(o.length===1){const d=o[0]?.trim()??"",s=b(d,"dnsName"),f=b(d,"hostedZoneId");return s!==void 0&&f!==void 0?{kind:"custom",dnsName:s,hostedZoneId:f}:{kind:"dynamic",sourceText:n}}return{kind:"unresolved",sourceText:n}}default:return{kind:"unresolved",sourceText:n}}}function A(e){const n=[];let t=0,r=null,i="";for(let d=0;d<e.length;d++){const s=e[d];if(r!==null){if(i+=s,s==="\\"&&d+1<e.length){const f=e[d+1];f!==void 0&&(i+=f,d+=1);continue}s===r&&(r=null);continue}if(s==='"'||s==="'"||s==="`"){r=s,i+=s;continue}if(s==="("||s==="{"||s==="["){t+=1,i+=s;continue}if(s===")"||s==="}"||s==="]"){t-=1,i+=s;continue}if(s===","&&t===0){n.push(i.trim()),i="";continue}i+=s}const o=i.trim();return o.length>0&&n.push(o),n}function m(e,n){const t=e[n];if(t===void 0)return;const r=t.trim();if(r.length<2)return;const i=r[0],o=r[r.length-1];if(i===o&&!(i!=='"'&&i!=="'"&&i!=="`"))return r.slice(1,-1)}function b(e,n){const t=e.trim().replace(/^\{|\}$/g,""),r=A(t);for(const i of r){const o=i.indexOf(":");if(o<0||i.slice(0,o).trim().replace(/["'`]/g,"")!==n)continue;const s=i.slice(o+1).trim();return m([s],0)}}function M(e){if(e===void 0)return a([]);if(!Array.isArray(e))return u({kind:"invalid_literal",field:"certificates",reason:"must be an array"});const n=[];for(let t=0;t<e.length;t++){const r=e[t];if(typeof r=="string"){n.push({domainName:r});continue}if(!g(r))return u({kind:"invalid_literal",field:`certificates[${t}]`,reason:"must be a string or object literal"});const i=c(r.domainName);if(i===void 0)return u({kind:"missing_field",field:`certificates[${t}].domainName`});const o=k(r.subjectAlternativeNames),d=h(r.transparencyLogging);n.push({domainName:i,...o!==void 0?{subjectAlternativeNames:o}:{},...d!==void 0?{transparencyLogging:d}:{}})}return a(n)}function S(e){if(e===void 0)return a([]);if(!Array.isArray(e))return u({kind:"invalid_literal",field:"delegations",reason:"must be an array"});const n=[];for(let t=0;t<e.length;t++){const r=e[t];if(!g(r))return u({kind:"invalid_literal",field:`delegations[${t}]`,reason:"must be an object literal"});const i=c(r.subdomain),o=c(r.toAccount);if(i===void 0)return u({kind:"missing_field",field:`delegations[${t}].subdomain`});if(o===void 0)return u({kind:"missing_field",field:`delegations[${t}].toAccount`});const d=h(r.auto);n.push({subdomain:i,toAccount:o,...d!==void 0?{auto:d}:{}})}return a(n)}function Y(e){if(e===void 0||!g(e))return;const n={};for(const[t,r]of Object.entries(e)){const i=c(r);i!==void 0&&(n[t]=i)}return Object.keys(n).length===0?void 0:n}function p(e){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`[${e.map(n=>p(n)).join(", ")}]`;if(typeof e=="object"){if("__call"in e)return String(e.__call);if("__identifier"in e)return String(e.__identifier);if("__expression"in e)return String(e.__expression);if("__unknown"in e)return String(e.__unknown)}return String(e)}export{U as findDomainConstructCall,Q as parseDomainErrorMessage,H as parseDomainProps,A as splitTopLevelArgs};
@@ -1,5 +1,5 @@
1
- export { type IdentifierRef, type ExpressionRef, type CallRef, type ParsedValue, type ParsedObject, isPlainObject, isIdentifierRef, isExpressionRef, isCallRef, isParsedObject, asString, asNumber, asBoolean, asStringArray, asStringUnion, captureExtraProperties, } from "./astCommonParser.js";
2
- export { type ParsedInfrastructure, type ParsedDatabaseResource, type ParsedS3Resource, type ParsedComputeResource, type ParsedSQSResource, type ParsedCDNResource, type ParsedNetworkResource, type ParsedDynamoDBResource, type ParsedLambdaConfig, type ParsedPatternResource, type ImportInfo, type AstStatementType, type ClassifiedStatement, type CustomCodeBlock, parseInfrastructure, convertToResourcePlan, classifyStatements, extractCustomCodeBlocks, findManagedResourcePosition, getLastManagedStatementOfType, getManagedResourcesByType, } from "./astInfrastructureParser.js";
3
- export { type SurgicalModificationResult, type InsertionOptions, type UpdateOptions, type DeleteOptions, addResourceSurgically, updateResourceSurgically, removeResourceSurgically, } from "./astSurgicalModification.js";
4
- export { type FileValidationResult, ensureImports, injectCustomCodeBlocks, validateModifiedFile, } from "./astCodeInjection.js";
5
- export { type DomainCallMatch, type ParsedFjallTarget, type ParsedDnsRecordFromAst, type ParsedCertificateFromAst, type ParsedDelegationFromAst, type ParsedDomainProps, type ParsedRoute53ApexDomainProps, type ParsedExternalDelegatedDomainProps, type ParsedExternalRecordsDomainProps, type ParseDomainError, findDomainConstructCall, parseDomainProps, parseDomainErrorMessage, splitTopLevelArgs, } from "./astDomainParser.js";
1
+ export { type IdentifierRef, type ExpressionRef, type CallRef, type ParsedValue, type ParsedObject, isPlainObject, isIdentifierRef, isExpressionRef, isCallRef, isParsedObject, asString, asNumber, asBoolean, asStringArray, asStringUnion, captureExtraProperties, } from "./parsers/common/astCommonParser.js";
2
+ export { type ParsedInfrastructure, type ParsedDatabaseResource, type ParsedS3Resource, type ParsedComputeResource, type ParsedSQSResource, type ParsedCDNResource, type ParsedNetworkResource, type ParsedDynamoDBResource, type ParsedLambdaConfig, type ParsedPatternResource, type ImportInfo, type AstStatementType, type ClassifiedStatement, type CustomCodeBlock, parseInfrastructure, convertToResourcePlan, classifyStatements, extractCustomCodeBlocks, findManagedResourcePosition, getLastManagedStatementOfType, getManagedResourcesByType, } from "./parsers/orchestrator/astInfrastructureParser.js";
3
+ export { type SurgicalModificationResult, type InsertionOptions, type UpdateOptions, type DeleteOptions, addResourceSurgically, updateResourceSurgically, removeResourceSurgically, } from "./mutation/astSurgicalModification.js";
4
+ export { type FileValidationResult, ensureImports, injectCustomCodeBlocks, validateModifiedFile, } from "./mutation/astCodeInjection.js";
5
+ export { type DomainCallMatch, type ParsedFjallTarget, type ParsedDnsRecordFromAst, type ParsedCertificateFromAst, type ParsedDelegationFromAst, type ParsedDomainProps, type ParsedRoute53ApexDomainProps, type ParsedExternalDelegatedDomainProps, type ParsedExternalRecordsDomainProps, type ParseDomainError, findDomainConstructCall, parseDomainProps, parseDomainErrorMessage, splitTopLevelArgs, } from "./domain/astDomainParser.js";
@@ -1 +1 @@
1
- import{isPlainObject as s,isIdentifierRef as o,isExpressionRef as a,isCallRef as t,isParsedObject as i,asString as n,asNumber as c,asBoolean as l,asStringArray as p,asStringUnion as u,captureExtraProperties as d}from"./astCommonParser.js";import{parseInfrastructure as m,convertToResourcePlan as g,classifyStatements as R,extractCustomCodeBlocks as x,findManagedResourcePosition as y,getLastManagedStatementOfType as S,getManagedResourcesByType as C}from"./astInfrastructureParser.js";import{addResourceSurgically as M,updateResourceSurgically as v,removeResourceSurgically as B}from"./astSurgicalModification.js";import{ensureImports as b,injectCustomCodeBlocks as j,validateModifiedFile as D}from"./astCodeInjection.js";import{findDomainConstructCall as I,parseDomainProps as O,parseDomainErrorMessage as k,splitTopLevelArgs as A}from"./astDomainParser.js";export{M as addResourceSurgically,l as asBoolean,c as asNumber,n as asString,p as asStringArray,u as asStringUnion,d as captureExtraProperties,R as classifyStatements,g as convertToResourcePlan,b as ensureImports,x as extractCustomCodeBlocks,I as findDomainConstructCall,y as findManagedResourcePosition,S as getLastManagedStatementOfType,C as getManagedResourcesByType,j as injectCustomCodeBlocks,t as isCallRef,a as isExpressionRef,o as isIdentifierRef,i as isParsedObject,s as isPlainObject,k as parseDomainErrorMessage,O as parseDomainProps,m as parseInfrastructure,B as removeResourceSurgically,A as splitTopLevelArgs,v as updateResourceSurgically,D as validateModifiedFile};
1
+ import{isPlainObject as s,isIdentifierRef as o,isExpressionRef as a,isCallRef as t,isParsedObject as i,asString as n,asNumber as c,asBoolean as l,asStringArray as p,asStringUnion as u,captureExtraProperties as d}from"./parsers/common/astCommonParser.js";import{parseInfrastructure as m,convertToResourcePlan as g,classifyStatements as R,extractCustomCodeBlocks as x,findManagedResourcePosition as y,getLastManagedStatementOfType as S,getManagedResourcesByType as C}from"./parsers/orchestrator/astInfrastructureParser.js";import{addResourceSurgically as M,updateResourceSurgically as v,removeResourceSurgically as B}from"./mutation/astSurgicalModification.js";import{ensureImports as b,injectCustomCodeBlocks as j,validateModifiedFile as D}from"./mutation/astCodeInjection.js";import{findDomainConstructCall as I,parseDomainProps as O,parseDomainErrorMessage as k,splitTopLevelArgs as A}from"./domain/astDomainParser.js";export{M as addResourceSurgically,l as asBoolean,c as asNumber,n as asString,p as asStringArray,u as asStringUnion,d as captureExtraProperties,R as classifyStatements,g as convertToResourcePlan,b as ensureImports,x as extractCustomCodeBlocks,I as findDomainConstructCall,y as findManagedResourcePosition,S as getLastManagedStatementOfType,C as getManagedResourcesByType,j as injectCustomCodeBlocks,t as isCallRef,a as isExpressionRef,o as isIdentifierRef,i as isParsedObject,s as isPlainObject,k as parseDomainErrorMessage,O as parseDomainProps,m as parseInfrastructure,B as removeResourceSurgically,A as splitTopLevelArgs,v as updateResourceSurgically,D as validateModifiedFile};
@@ -1,4 +1,4 @@
1
- import { type CustomCodeBlock } from "./astInfrastructureParser.js";
1
+ import { type CustomCodeBlock } from "../parsers/orchestrator/astInfrastructureParser.js";
2
2
  import { type SurgicalModificationResult } from "./astSurgicalModification.js";
3
3
  export declare function ensureImports(content: string, requiredImports: string[]): SurgicalModificationResult;
4
4
  export declare function injectCustomCodeBlocks(generatedCode: string, customBlocks: CustomCodeBlock[], resourceMapping?: Map<string, string>): SurgicalModificationResult;
@@ -1,4 +1,4 @@
1
- import*as f from"typescript";import{classifyStatements as x}from"./astInfrastructureParser.js";import{parseSourceFile as d,insertAtPosition as m,formatLeadingNewlines as C,getContextBeforePosition as y,formatResourceId as l,createErrorResult as p,findClassification as g,findLastClassification as w}from"./astSurgicalModification.js";import{getErrorMessage as P}from"../util/errorUtils.js";function q(t,e){try{const n=d(t),o=new Set;for(const i of n.statements)f.isImportDeclaration(i)&&o.add(i.getText(n).trim());const r=[];for(const i of e){const c=i.trim();[...o].some(I=>O(I,c))||r.push(c)}if(r.length===0)return{content:t,success:!0};const s=n.statements.filter(f.isImportDeclaration).at(-1)?.getEnd()??0,u=`
1
+ import*as f from"typescript";import{classifyStatements as x}from"../parsers/orchestrator/astInfrastructureParser.js";import{parseSourceFile as d,insertAtPosition as m,formatLeadingNewlines as C,getContextBeforePosition as y,formatResourceId as l,createErrorResult as p,findClassification as g,findLastClassification as w}from"./astSurgicalModification.js";import{getErrorMessage as P}from"../../util/errorUtils.js";function q(t,e){try{const n=d(t),o=new Set;for(const i of n.statements)f.isImportDeclaration(i)&&o.add(i.getText(n).trim());const r=[];for(const i of e){const c=i.trim();[...o].some(I=>O(I,c))||r.push(c)}if(r.length===0)return{content:t,success:!0};const s=n.statements.filter(f.isImportDeclaration).at(-1)?.getEnd()??0,u=`
2
2
  `+r.join(`
3
3
  `);return{content:m(t,s,u),success:!0}}catch(n){return p(n,t)}}function h(t){return new Set(t.split(",").map(e=>e.trim()).filter(Boolean))}function N(t,e){const n=h(t),o=h(e);for(const r of o)if(!n.has(r))return!1;return!0}function O(t,e){const n=t.match(R),o=e.match(R);if(!n||!o||n[1]!==o[1])return!1;const r=t.match(M),s=e.match(M);return r&&s?N(r[1],s[1]):!!r==!!s}const R=/from\s+["']([^"']+)["']/,M=/\{([^}]+)\}/,E={"before-imports":0,"after-imports":1,"after-app-init":2,"after-tags":3,"after-resource":4,"end-of-file":5};function T(t){return[...t].sort((e,n)=>{const o=E[n.position]-E[e.position];return o!==0?o:(n.originalLine??0)-(e.originalLine??0)})}function A(t,e,n,o){if(n!==null){const s=F(t,n,e);return m(t,n,s)}const r=e.afterManagedResource?`// [ORPHANED: was after ${l(e.afterManagedResource.type,e.afterManagedResource.name)}]
4
4
  `:`// [ORPHANED]
@@ -4,7 +4,7 @@
4
4
  * paths live in src/codemod/. Do not add mutation helpers here.
5
5
  */
6
6
  import * as ts from "typescript";
7
- import { type ParsedObject, type ParsedValue } from "./astCommonParser.js";
7
+ import { type ParsedObject, type ParsedValue } from "../parsers/common/astCommonParser.js";
8
8
  /** Parse an object literal expression into a ParsedObject */
9
9
  export declare function parseObjectLiteral(node: ts.ObjectLiteralExpression): ParsedObject;
10
10
  /** Evaluate a TypeScript AST expression to a ParsedValue */
@@ -0,0 +1 @@
1
+ import*as t from"typescript";import{findFirstInAst as l}from"../parsers/common/astCommonParser.js";function f(e){const n={};for(const i of e.properties){if(!t.isPropertyAssignment(i))continue;const r=t.isIdentifier(i.name)||t.isStringLiteral(i.name)?i.name.text:void 0;r!==void 0&&(n[r]=a(i.initializer))}return n}function a(e){if(t.isStringLiteral(e))return e.text;if(t.isNumericLiteral(e))return Number(e.text);if(e.kind===t.SyntaxKind.TrueKeyword)return!0;if(e.kind===t.SyntaxKind.FalseKeyword)return!1;if(t.isArrayLiteralExpression(e))return e.elements.map(n=>a(n));if(t.isObjectLiteralExpression(e))return f(e);if(t.isIdentifier(e))return{__identifier:e.text};if(t.isPropertyAccessExpression(e))return{__expression:e.getText()};if(t.isCallExpression(e))return{__call:e.getText()};if(t.isBinaryExpression(e)&&e.operatorToken.kind===t.SyntaxKind.BarBarToken){const n=a(e.left),i=a(e.right);return typeof i=="string"?i:n}else if(t.isConditionalExpression(e)){const n=a(e.whenTrue),i=a(e.whenFalse);return typeof i=="string"||typeof i=="number"?i:n}else if(t.isTemplateExpression(e)||t.isNoSubstitutionTemplateLiteral(e))return{__expression:e.getText()};return{__unknown:e.getText()}}function u(e,n){return l(e,i=>{if(t.isVariableStatement(i)){for(const r of i.declarationList.declarations)if(t.isIdentifier(r.name)&&r.name.text===n&&r.initializer){if(t.isStringLiteral(r.initializer))return r.initializer.text;if(t.isObjectLiteralExpression(r.initializer)){const s=f(r.initializer);return JSON.stringify(s)}}}})}function o(e,n){return l(e,i=>{if(t.isVariableStatement(i)){for(const r of i.declarationList.declarations)if(t.isIdentifier(r.name)&&r.name.text===n&&r.initializer&&t.isObjectLiteralExpression(r.initializer))return f(r.initializer)}})}function p(e,n){if(!t.isIdentifier(n.expression))return;const i=o(e,n.expression.text),r=n.name.text;if(i&&i[r]!==void 0)return String(i[r])}function c(e,n){let i=n.head.text;for(const r of n.templateSpans){if(t.isIdentifier(r.expression)){const s=u(e,r.expression.text);if(s)i+=s;else return n.getText(e).replace(/^`|`$/g,"")}else if(t.isPropertyAccessExpression(r.expression)){const s=p(e,r.expression);if(s)i+=s;else return n.getText(e).replace(/^`|`$/g,"")}else return n.getText(e).replace(/^`|`$/g,"");i+=r.literal.text}return i}export{a as evaluateExpression,p as evaluatePropertyAccess,o as findObjectDeclaration,u as findVariableValue,f as parseObjectLiteral,c as resolveTemplateLiteral};
@@ -1,5 +1,5 @@
1
1
  import * as ts from "typescript";
2
- import { type AstStatementType, type ClassifiedStatement } from "./astInfrastructureParser.js";
2
+ import { type AstStatementType, type ClassifiedStatement } from "../parsers/orchestrator/astInfrastructureParser.js";
3
3
  export declare function insertAtPosition(content: string, position: number, text: string): string;
4
4
  export declare function findClassification(classifications: ClassifiedStatement[], type: AstStatementType): ClassifiedStatement | undefined;
5
5
  export declare function findLastClassification(classifications: ClassifiedStatement[], type: AstStatementType): ClassifiedStatement | undefined;
@@ -1,4 +1,4 @@
1
- import*as x from"typescript";import{parseInfrastructure as F,classifyStatements as E,findManagedResourcePosition as y}from"./astInfrastructureParser.js";import{getErrorMessage as O}from"../util/errorUtils.js";function C(e,r,t){return e.slice(0,r)+t+e.slice(r)}function L(e,r){return e.find(t=>t.type===r)}function A(e,r){return e.filter(t=>t.type===r).pop()}function w(e){return x.createSourceFile("infrastructure.ts",e,x.ScriptTarget.Latest,!0,x.ScriptKind.TS)}function T(e,r){return e.endsWith(`
1
+ import*as x from"typescript";import{parseInfrastructure as F,classifyStatements as E,findManagedResourcePosition as y}from"../parsers/orchestrator/astInfrastructureParser.js";import{getErrorMessage as O}from"../../util/errorUtils.js";function C(e,r,t){return e.slice(0,r)+t+e.slice(r)}function L(e,r){return e.find(t=>t.type===r)}function A(e,r){return e.filter(t=>t.type===r).pop()}function w(e){return x.createSourceFile("infrastructure.ts",e,x.ScriptTarget.Latest,!0,x.ScriptKind.TS)}function T(e,r){return e.endsWith(`
2
2
 
3
3
  `)||r.startsWith(`
4
4
  `)?"":e.endsWith(`
@@ -4,7 +4,7 @@
4
4
  * paths live in src/codemod/. Do not add mutation helpers here.
5
5
  */
6
6
  import * as ts from "typescript";
7
- import type { ExtraProperty } from "../schemas/resourceSchemas.js";
7
+ import type { ExtraProperty } from "../../../schemas/resourceSchemas.js";
8
8
  /** Special marker for identifier references in parsed AST */
9
9
  export interface IdentifierRef {
10
10
  __identifier: string;
@@ -76,4 +76,4 @@ export declare function parseBooleanOrConfig<T>(value: ParsedValue | undefined,
76
76
  export declare function parseOptionalConfig<T>(value: ParsedValue | undefined, parser: (obj: ParsedObject) => T): T | undefined;
77
77
  /** Extract a named sub-object from a config, returning undefined if not a plain object */
78
78
  export declare function extractSubConfig<T>(rawConfig: ParsedObject, field: string, transform: (obj: ParsedObject) => T): T | undefined;
79
- export { parseObjectLiteral, evaluateExpression, findVariableValue, findObjectDeclaration, evaluatePropertyAccess, resolveTemplateLiteral, } from "./astExpressionEvaluator.js";
79
+ export { parseObjectLiteral, evaluateExpression, findVariableValue, findObjectDeclaration, evaluatePropertyAccess, resolveTemplateLiteral, } from "../../mutation/astExpressionEvaluator.js";
@@ -0,0 +1 @@
1
+ import*as i from"typescript";import{constIncludes as c}from"../../../schemas/constants.js";function o(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function x(n){return o(n)&&"__identifier"in n}function d(n){return o(n)&&"__expression"in n}function a(n){return o(n)&&"__call"in n}function f(n){return o(n)&&!("__identifier"in n)&&!("__expression"in n)&&!("__call"in n)&&!("__unknown"in n)}function y(n){return typeof n=="string"?n:void 0}function m(n){return typeof n=="number"?n:void 0}function _(n){return typeof n=="boolean"?n:void 0}function b(n){if(!Array.isArray(n))return;const e=[];for(const r of n)typeof r=="string"&&e.push(r);return e.length>0?e:void 0}function A(n,e){const r=y(n);if(r!==void 0)return c(e,r)?r:void 0}function g(n){const e={};for(const[r,t]of Object.entries(n))t!==void 0&&(e[r]=t);return e}function p(n){if(n===null)return"null";if(n===void 0)return"undefined";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return String(n);if(Array.isArray(n))return`[${n.map(p).join(", ")}]`;if(!o(n))return String(n);if(x(n))return n.__identifier;if(d(n))return n.__expression;if(a(n))return n.__call;if("__unknown"in n&&typeof n.__unknown=="string")return n.__unknown;const e=Object.entries(n);return e.length===0?"{}":`{ ${e.map(([t,s])=>`${t}: ${p(s)}`).join(", ")} }`}function h(n,e){const r=[];for(const[t,s]of Object.entries(n))e.has(t)||s===void 0||r.push({key:t,sourceText:p(s)});return r}function j(n,e){return i.isPropertyAssignment(n)&&i.isIdentifier(n.name)&&n.name.text===e}function O(n){return i.isCallExpression(n)&&i.isPropertyAccessExpression(n.expression)&&n.expression.name.text==="getApp"&&i.isIdentifier(n.expression.expression)&&n.expression.expression.text==="App"}function C(n,e){const{expression:r}=n;return i.isPropertyAccessExpression(r)&&r.name.text===e&&n.arguments.length>0}function E(n,e){let r;const t=s=>{r===void 0&&(r=e(s),r===void 0&&i.forEachChild(s,t))};return t(n),r}function P(n,e){const r=[],t=s=>{const u=e(s);u!==null&&r.push(u),i.forEachChild(s,t)};return t(n),r}function S(n,e){return i.isCallExpression(n)&&i.isPropertyAccessExpression(n.expression)&&n.expression.name.text==="build"&&i.isIdentifier(n.expression.expression)&&n.expression.expression.text===e}function I(n){const e=n.parent;if(i.isVariableDeclaration(e)&&i.isIdentifier(e.name))return e.name.text}const k=()=>n=>n;function F(n){if(n!=null){if(n===!1)return!1;if(typeof n=="object"&&!Array.isArray(n))return n}}function V(n,e){return n===!1?!1:f(n)?e(n):void 0}function w(n,e){return f(n)?e(n):void 0}function N(n,e,r){const t=n[e];return f(t)?r(t):void 0}import{parseObjectLiteral as B,evaluateExpression as R,findVariableValue as D,findObjectDeclaration as L,evaluatePropertyAccess as U,resolveTemplateLiteral as G}from"../../mutation/astExpressionEvaluator.js";export{_ as asBoolean,m as asNumber,F as asObjectOrFalse,y as asString,b as asStringArray,A as asStringUnion,h as captureExtraProperties,P as collectFromAst,R as evaluateExpression,U as evaluatePropertyAccess,N as extractSubConfig,I as extractVariableName,E as findFirstInAst,L as findObjectDeclaration,D as findVariableValue,O as isAppGetAppCall,a as isCallRef,d as isExpressionRef,S as isFactoryBuildCall,C as isFactoryMethodCall,x as isIdentifierRef,j as isNamedProperty,f as isParsedObject,o as isPlainObject,g as omitUndefined,V as parseBooleanOrConfig,B as parseObjectLiteral,w as parseOptionalConfig,p as parsedValueToSourceText,G as resolveTemplateLiteral,k as typed};
@@ -6,7 +6,7 @@
6
6
  * src/codemod/. Do not add mutation helpers here.
7
7
  */
8
8
  import * as ts from "typescript";
9
- import type { AstStatementType } from "../schemas/resourceSchemas.js";
9
+ import type { AstStatementType } from "../../../schemas/resourceSchemas.js";
10
10
  /** Imports that the generator always handles -- don't preserve as "additional" */
11
11
  declare const KNOWN_FJALL_IMPORTS: Set<string>;
12
12
  export { KNOWN_FJALL_IMPORTS };
@@ -0,0 +1 @@
1
+ import*as a from"typescript";import{isAppGetAppCall as f}from"./astCommonParser.js";import{S3_BUCKET_CLASSES as d}from"../resources/astStorageParser.js";const y=new Set(["App","Architecture","DatabaseFactory","StorageFactory","ComputeFactory","getConfig","MessagingFactory","CdnFactory","Code","Runtime","FunctionUrlAuthType","NetworkFactory","PatternFactory","VpcPeerFactory","VpcPeerAccepterFactory","CrossPlanConnectionFactory"]);function l(r){return!!(r.startsWith("@fjall/")||r==="aws-cdk-lib"||r.startsWith("aws-cdk-lib/")||r==="constructs")}function C(r){const n=[];for(const e of r.statements){const t=e.getFullStart(),i=e.getEnd();if(a.isImportDeclaration(e)){n.push({type:"import",node:e,startPos:t,endPos:i,isManaged:g(e)});continue}if(a.isVariableStatement(e)){n.push(m(e,t,i));continue}if(a.isExpressionStatement(e)){n.push(x(e,t,i));continue}n.push({type:"custom",node:e,startPos:t,endPos:i,isManaged:!1})}return n}function g(r){return a.isStringLiteral(r.moduleSpecifier)?l(r.moduleSpecifier.text):!1}function m(r,n,e){for(const t of r.declarationList.declarations)if(t.initializer){if(f(t.initializer))return{type:"app-init",node:r,resourceName:a.isIdentifier(t.name)?t.name.text:void 0,startPos:n,endPos:e,isManaged:!0};if(a.isIdentifier(t.name)&&t.name.text==="appName"&&a.isStringLiteral(t.initializer))return{type:"app-init",node:r,startPos:n,endPos:e,isManaged:!0};if(a.isNewExpression(t.initializer)){const i=t.initializer;if(a.isIdentifier(i.expression)){const o=i.expression.text;if(d.has(o)){const c=i.arguments&&i.arguments.length>=2&&a.isStringLiteral(i.arguments[1])?i.arguments[1].text:void 0;return{type:"storage",node:r,resourceName:c,startPos:n,endPos:e,isManaged:!0}}}}if(a.isCallExpression(t.initializer)){const i=p(t.initializer,r,n,e);if(i.type!=="custom")return i}}return{type:"custom",node:r,startPos:n,endPos:e,isManaged:!1}}function x(r,n,e){const t=r.expression;return a.isCallExpression(t)?p(t,r,n,e):{type:"custom",node:r,startPos:n,endPos:e,isManaged:!1}}function p(r,n,e,t){const i=r.expression;if(a.isPropertyAccessExpression(i)&&a.isIdentifier(i.expression)){const o=i.name.text;if(o==="addTags")return{type:"tags",node:n,startPos:e,endPos:t,isManaged:!0};const s={addDatabase:{type:"database",factory:"DatabaseFactory"},addCompute:{type:"compute",factory:"ComputeFactory"},addNetwork:{type:"network",factory:"NetworkFactory"},addMessaging:{type:"messaging",factory:"MessagingFactory"},addCdn:{type:"cdn",factory:"CdnFactory"},addPattern:{type:"pattern",factory:"PatternFactory"},addStorage:{type:"storage",factory:"StorageFactory"},addVpcPeer:{type:"vpc-peer",factory:"VpcPeerFactory"},addVpcPeerAccepter:{type:"vpc-peer-accepter",factory:"VpcPeerAccepterFactory"}}[o];if(s){const u=F(r,s.factory);return{type:s.type,node:n,resourceName:u,startPos:e,endPos:t,isManaged:!0}}}return{type:"custom",node:n,startPos:e,endPos:t,isManaged:!1}}function F(r,n){if(r.arguments.length===0)return;const e=r.arguments[0];if(!a.isCallExpression(e))return;const t=e.expression;if(!a.isPropertyAccessExpression(t)||t.name.text!=="build"||!a.isIdentifier(t.expression)||t.expression.text!==n||e.arguments.length===0)return;const i=e.arguments[0];if(a.isStringLiteral(i))return i.text}export{y as KNOWN_FJALL_IMPORTS,C as classifyStatements,l as isManagedModuleSpecifier};
@@ -5,7 +5,7 @@
5
5
  * add mutation helpers here.
6
6
  */
7
7
  import * as ts from "typescript";
8
- import type { AstStatementType, CustomCodeBlock } from "../schemas/resourceSchemas.js";
8
+ import type { AstStatementType, CustomCodeBlock } from "../../../schemas/resourceSchemas.js";
9
9
  import { type ClassifiedStatement } from "./astStatementClassifier.js";
10
10
  /** Extract custom code blocks from an infrastructure file. */
11
11
  export declare function extractCustomCodeBlocks(sourceFile: ts.SourceFile, precomputedClassifications?: ClassifiedStatement[]): CustomCodeBlock[];
@@ -4,35 +4,35 @@
4
4
  * Do not add mutation helpers here.
5
5
  */
6
6
  import * as ts from "typescript";
7
- import type { CustomCodeBlock } from "../schemas/resourceSchemas.js";
8
- export { type IdentifierRef, type ExpressionRef, type CallRef, type ParsedValue, type ParsedObject, isPlainObject, isIdentifierRef, isExpressionRef, isCallRef, isParsedObject, asString, asNumber, asBoolean, asStringArray, asStringUnion, captureExtraProperties, } from "./astCommonParser.js";
9
- export { type ParsedDatabaseResource } from "./astDatabaseParser.js";
10
- export { type ParsedDynamoDBResource } from "./astDatabaseParser.js";
11
- export { type ParsedClickHouseResource } from "./astDatabaseParser.js";
12
- export { type ParsedS3Resource } from "./astStorageParser.js";
13
- export { type ParsedComputeResource, findComputeResources, } from "./astComputeParser.js";
14
- export { type ParsedScheduleCall, findSchedules } from "./astScheduleParser.js";
15
- export { type ParsedSQSResource } from "./astMessagingParser.js";
16
- export { type ParsedCDNResource } from "./astCdnParser.js";
17
- export { type ParsedNetworkResource } from "./astNetworkParser.js";
18
- export { type ParsedLambdaConfig, type ParsedPatternResource, } from "./astPatternParser.js";
19
- export { type AstStatementType } from "../schemas/resourceSchemas.js";
20
- export { type CustomCodeBlock } from "../schemas/resourceSchemas.js";
21
- export { type ClassifiedStatement, classifyStatements, } from "./astStatementClassifier.js";
22
- export { extractCustomCodeBlocks, findManagedResourcePosition, getLastManagedStatementOfType, getManagedResourcesByType, } from "./astStatementQueries.js";
7
+ import type { CustomCodeBlock } from "../../../schemas/resourceSchemas.js";
8
+ export { type IdentifierRef, type ExpressionRef, type CallRef, type ParsedValue, type ParsedObject, isPlainObject, isIdentifierRef, isExpressionRef, isCallRef, isParsedObject, asString, asNumber, asBoolean, asStringArray, asStringUnion, captureExtraProperties, } from "../common/astCommonParser.js";
9
+ export { type ParsedDatabaseResource } from "../resources/astDatabaseParser.js";
10
+ export { type ParsedDynamoDBResource } from "../resources/astDatabaseParser.js";
11
+ export { type ParsedClickHouseResource } from "../resources/astDatabaseParser.js";
12
+ export { type ParsedS3Resource } from "../resources/astStorageParser.js";
13
+ export { type ParsedComputeResource, findComputeResources, } from "../resources/astComputeParser.js";
14
+ export { type ParsedScheduleCall, findSchedules, } from "../resources/astScheduleParser.js";
15
+ export { type ParsedSQSResource } from "../resources/astMessagingParser.js";
16
+ export { type ParsedCDNResource } from "../resources/astCdnParser.js";
17
+ export { type ParsedNetworkResource } from "../resources/astNetworkParser.js";
18
+ export { type ParsedLambdaConfig, type ParsedPatternResource, } from "../resources/astPatternParser.js";
19
+ export { type AstStatementType } from "../../../schemas/resourceSchemas.js";
20
+ export { type CustomCodeBlock } from "../../../schemas/resourceSchemas.js";
21
+ export { type ClassifiedStatement, classifyStatements, } from "../common/astStatementClassifier.js";
22
+ export { extractCustomCodeBlocks, findManagedResourcePosition, getLastManagedStatementOfType, getManagedResourcesByType, } from "../common/astStatementQueries.js";
23
23
  export { convertToResourcePlan } from "./astPlanConverter.js";
24
- import { type ParsedScheduleCall } from "./astScheduleParser.js";
25
- import { type ParsedNetworkConfig } from "./astNetworkParser.js";
26
- import { type ClassifiedStatement } from "./astStatementClassifier.js";
27
- import type { ParsedDatabaseResource } from "./astDatabaseParser.js";
28
- import type { ParsedDynamoDBResource } from "./astDatabaseParser.js";
29
- import type { ParsedClickHouseResource } from "./astDatabaseParser.js";
30
- import type { ParsedS3Resource } from "./astStorageParser.js";
31
- import type { ParsedComputeResource } from "./astComputeParser.js";
32
- import type { ParsedSQSResource } from "./astMessagingParser.js";
33
- import type { ParsedCDNResource } from "./astCdnParser.js";
34
- import type { ParsedNetworkResource } from "./astNetworkParser.js";
35
- import type { ParsedPatternResource } from "./astPatternParser.js";
24
+ import { type ParsedScheduleCall } from "../resources/astScheduleParser.js";
25
+ import { type ParsedNetworkConfig } from "../resources/astNetworkParser.js";
26
+ import { type ClassifiedStatement } from "../common/astStatementClassifier.js";
27
+ import type { ParsedDatabaseResource } from "../resources/astDatabaseParser.js";
28
+ import type { ParsedDynamoDBResource } from "../resources/astDatabaseParser.js";
29
+ import type { ParsedClickHouseResource } from "../resources/astDatabaseParser.js";
30
+ import type { ParsedS3Resource } from "../resources/astStorageParser.js";
31
+ import type { ParsedComputeResource } from "../resources/astComputeParser.js";
32
+ import type { ParsedSQSResource } from "../resources/astMessagingParser.js";
33
+ import type { ParsedCDNResource } from "../resources/astCdnParser.js";
34
+ import type { ParsedNetworkResource } from "../resources/astNetworkParser.js";
35
+ import type { ParsedPatternResource } from "../resources/astPatternParser.js";
36
36
  export interface ImportInfo {
37
37
  moduleSpecifier: string;
38
38
  namedImports: string[];
@@ -0,0 +1 @@
1
+ import*as s from"typescript";import{isPlainObject as fe,isIdentifierRef as me,isExpressionRef as ue,isCallRef as le,isParsedObject as de,asString as xe,asNumber as Re,asBoolean as ge,asStringArray as Ce,asStringUnion as Se,captureExtraProperties as be}from"../common/astCommonParser.js";import{findComputeResources as ye}from"../resources/astComputeParser.js";import{findSchedules as he}from"../resources/astScheduleParser.js";import{classifyStatements as Ae}from"../common/astStatementClassifier.js";import{extractCustomCodeBlocks as Ee,findManagedResourcePosition as Pe,getLastManagedStatementOfType as Te,getManagedResourcesByType as ve}from"../common/astStatementQueries.js";import{convertToResourcePlan as Le}from"./astPlanConverter.js";import{isAppGetAppCall as h,isExpressionRef as k,findFirstInAst as A,parseObjectLiteral as B,findVariableValue as E,evaluatePropertyAccess as P}from"../common/astCommonParser.js";import{findDatabaseResources as T,splitDatabaseResources as v}from"../resources/astDatabaseParser.js";import{findS3Resources as V,findS3FactoryResources as L}from"../resources/astStorageParser.js";import{findComputeResources as O}from"../resources/astComputeParser.js";import{findSchedules as j}from"../resources/astScheduleParser.js";import{findSQSResources as D}from"../resources/astMessagingParser.js";import{findCDNResource as w}from"../resources/astCdnParser.js";import{findVpcId as z,findNetworkConfig as F,findBackupConfig as M,findTunnelConfig as q,findNetworkResources as G}from"../resources/astNetworkParser.js";import{findPatternResources as K}from"../resources/astPatternParser.js";import{classifyStatements as Q}from"../common/astStatementClassifier.js";import{extractCustomCodeBlocks as U}from"../common/astStatementQueries.js";function ae(i,t){const e=s.createSourceFile("infrastructure.ts",i,s.ScriptTarget.Latest,!0,s.ScriptKind.TS),r=H(e),{appVariableName:o,appName:n}=W(e),c=z(e),a=F(e),f=M(e),m=q(e),u=G(e),l=T(e),{databases:d,dynamodb:x,clickhouse:R}=v(l),g=D(e),C=w(e),S=[...V(e),...L(e)],b=O(e),I=j(e),y=K(e),N=X(e),p={sourceFile:e,imports:r,appVariableName:o,appName:n,vpcId:c,network:a,backup:f,tunnel:m,networkResources:u,databaseResources:d,dynamodbResources:x,clickhouseResources:R,sqsResources:g,cdnResource:C,s3Resources:S,computeResources:b,schedules:I,patternResources:y,tags:N};return t?.extractCustomCode&&(p.customCodeBlocks=U(e),p.classifiedStatements=Q(e)),p}function H(i){const t=[];return s.forEachChild(i,e=>{if(s.isImportDeclaration(e)){if(!s.isStringLiteral(e.moduleSpecifier))return;const o={moduleSpecifier:e.moduleSpecifier.text,namedImports:[]};e.importClause&&(e.importClause.name&&(o.defaultImport=e.importClause.name.text),e.importClause.namedBindings&&s.isNamedImports(e.importClause.namedBindings)&&(o.namedImports=e.importClause.namedBindings.elements.map(n=>n.name.text))),t.push(o)}}),t}function J(i,t){return s.isStringLiteral(t)?t.text:s.isIdentifier(t)?E(i,t.text)??"":s.isPropertyAccessExpression(t)?P(i,t)??"":""}function W(i){return A(i,t=>{if(s.isVariableStatement(t))for(const e of t.declarationList.declarations){if(!e.initializer||!h(e.initializer))continue;const r=s.isIdentifier(e.name)?e.name.text:"",o=e.initializer.arguments.length>0?J(i,e.initializer.arguments[0]):"";return{appVariableName:r,appName:o}}})??{appVariableName:"",appName:""}}function X(i){const t={};function e(r){if(s.isCallExpression(r)&&s.isPropertyAccessExpression(r.expression)&&r.expression.name.text==="addTags"&&s.isIdentifier(r.expression.expression)&&r.arguments.length>0){const o=r.arguments[0];if(s.isObjectLiteralExpression(o)){const n=B(o);for(const[c,a]of Object.entries(n))typeof a=="string"?t[c]=a:k(a)&&(t[c]="default-value")}}s.forEachChild(r,e)}return e(i),t}export{ge as asBoolean,Re as asNumber,xe as asString,Ce as asStringArray,Se as asStringUnion,be as captureExtraProperties,Ae as classifyStatements,Le as convertToResourcePlan,Ee as extractCustomCodeBlocks,ye as findComputeResources,Pe as findManagedResourcePosition,he as findSchedules,Te as getLastManagedStatementOfType,ve as getManagedResourcesByType,le as isCallRef,ue as isExpressionRef,me as isIdentifierRef,de as isParsedObject,fe as isPlainObject,ae as parseInfrastructure};
@@ -4,7 +4,7 @@
4
4
  * 400-line budget. Used by fjall list and by the deploy-worker. Write paths
5
5
  * live in src/codemod/. Do not add mutation helpers here.
6
6
  */
7
- import { type ApplicationResourcePlan } from "../schemas/resourceSchemas.js";
7
+ import { type ApplicationResourcePlan } from "../../../schemas/resourceSchemas.js";
8
8
  import type { ParsedInfrastructure } from "./astInfrastructureParser.js";
9
9
  export declare function convertToResourcePlan(parsed: ParsedInfrastructure, appName: string, options?: {
10
10
  skipValidation?: boolean;
@@ -0,0 +1,2 @@
1
+ import{ApplicationResourcePlanSchema as s,getZodErrorMessage as u}from"../../../schemas/resourceSchemas.js";import{z as a}from"zod";import{COST_ALLOCATION_TAG as c}from"../../../generation/infrastructure.js";import{convertDatabaseResources as m,convertDynamoDBResources as f,convertClickHouseResources as l}from"../resources/astDatabaseParser.js";import{convertS3Resources as p}from"../resources/astStorageParser.js";import{convertComputeResources as d}from"../resources/astComputeParser.js";import{convertSQSResources as R}from"../resources/astMessagingParser.js";import{convertCDNResource as h}from"../resources/astCdnParser.js";import{convertNetworkConfig as v,convertBackupConfig as g,convertTunnelConfig as k,convertAdditionalNetworks as I}from"../resources/astNetworkParser.js";import{applyPatternConfig as b}from"../resources/astPatternParser.js";import{KNOWN_FJALL_IMPORTS as S,isManagedModuleSpecifier as w}from"../common/astStatementClassifier.js";function y(e,r){for(const t of r){const o=e.compute.find(n=>n.variableName===t.targetVariableName);o!==void 0&&o.type==="lambda"&&(o.scheduleExpression=t.schedule)}}function N(e,r){Object.keys(r).length>0&&(e.tags={...r}),r[c]&&(e.owner=r[c])}function C(e){const r=[];for(const t of e)if(w(t.moduleSpecifier))if(t.moduleSpecifier==="@fjall/components-infrastructure"||t.moduleSpecifier==="@fjall/infrastructure"){const o=t.namedImports.filter(n=>!S.has(n));o.length>0&&r.push({moduleSpecifier:t.moduleSpecifier,namedImports:o,defaultImport:t.defaultImport})}else(t.namedImports.length>0||t.defaultImport)&&r.push(t);return r.length>0?r:void 0}function B(e,r,t){const o={appName:r,type:"standard",database:[],s3:[],compute:[]};if(b(o,e.patternResources),e.vpcId&&(o.vpcId=e.vpcId),o.network=v(e.network),o.backup=g(e.backup),o.tunnel=k(e.tunnel),o.additionalNetworks=I(e.networkResources),N(o,e.tags),o.database=m(e.databaseResources),o.dynamodb=f(e.dynamodbResources),o.clickhouse=l(e.clickhouseResources),o.sqs=R(e.sqsResources),o.cdn=h(e.cdnResource,e.s3Resources,e.computeResources),o.s3=p(e.s3Resources),o.compute=d(e.computeResources,e.databaseResources,e.s3Resources,o),y(o,e.schedules),o.additionalManagedImports=C(e.imports),t?.skipValidation)return o;try{return s.parse(o)}catch(n){if(n instanceof a.ZodError){const i=u(n);throw new Error(`Invalid infrastructure configuration:
2
+ ${i}`)}throw n}}export{B as convertToResourcePlan};
@@ -4,8 +4,8 @@
4
4
  * live in src/codemod/. Do not add mutation helpers here.
5
5
  */
6
6
  import * as ts from "typescript";
7
- import type { ApplicationResourcePlan } from "../schemas/resourceSchemas.js";
8
- import { type ParsedObject } from "./astCommonParser.js";
7
+ import type { ApplicationResourcePlan } from "../../../schemas/resourceSchemas.js";
8
+ import { type ParsedObject } from "../common/astCommonParser.js";
9
9
  import type { ParsedS3Resource } from "./astStorageParser.js";
10
10
  import type { ParsedComputeResource } from "./astComputeParser.js";
11
11
  /** Parsed CDN resource from app.addCdn(CdnFactory.build(...)) */
@@ -0,0 +1 @@
1
+ import*as f from"typescript";import{asString as c,asStringArray as D,asStringUnion as h,captureExtraProperties as y,findFirstInAst as I,isFactoryBuildCall as O,isFactoryMethodCall as P,isIdentifierRef as _,isParsedObject as p,parseObjectLiteral as x}from"../common/astCommonParser.js";function E(e){if(e.arguments.length<2)return null;const n=e.arguments[0],s=e.arguments[1];return!f.isStringLiteral(n)||!f.isObjectLiteralExpression(s)?null:{resourceName:n.text,config:x(s),node:e}}function G(e,n,s){const u=n.find(i=>i.variableName===e);if(u)return u.resourceName;const r=s.find(i=>i.variableName===e||i.resourceName.charAt(0).toLowerCase()+i.resourceName.slice(1)===e);return r?r.resourceName:e}const A=["CACHING_OPTIMIZED","CACHING_DISABLED"];function b(e){return I(e,n=>{if(!f.isCallExpression(n)||!P(n,"addCdn"))return;const s=n.arguments[0];if(O(s,"CdnFactory"))return E(s)??void 0})}function L(e,n,s){if(!e)return;const u=e,r=u.config,i=t=>_(t)?G(t.__identifier,n,s):c(t)??"",C=i(r.origin),a={name:u.resourceName,defaultOriginRef:C};if(Array.isArray(r.behaviours)){const t=r.behaviours.filter(p).map(o=>({pathPattern:c(o.pathPattern)??"",originRef:i(o.origin),...h(o.cachePolicy,A)!==void 0&&{cachePolicy:h(o.cachePolicy,A)}}));t.length>0&&(a.behaviours=t)}const m=c(r.customDomain);if(m)a.customDomain=m;else{const t=D(r.domainNames);t&&t.length>0&&(a.customDomain=t[0])}const g=c(r.certificateArn);if(g&&(a.certificateArn=g),r.accessGate!==void 0){if(r.accessGate===!1)a.accessGate=!1;else if(p(r.accessGate)){const t=r.accessGate,o=c(t.type),N=c(t.username),l=c(t.password);o==="basic-auth"&&N&&l&&(a.accessGate={type:"basic-auth",username:N,password:l})}}const d=y(r,new Set(["originType","origin","behaviours","customDomain","domainNames","certificateArn","accessGate"]));return d.length>0&&(a.extraProperties=d),a}export{L as convertCDNResource,b as findCDNResource};
@@ -5,7 +5,7 @@
5
5
  * src/codemod/. Do not add mutation helpers here.
6
6
  */
7
7
  import * as ts from "typescript";
8
- import type { ApplicationResourcePlan, ExtraProperty } from "../schemas/resourceSchemas.js";
8
+ import type { ApplicationResourcePlan, ExtraProperty } from "../../../schemas/resourceSchemas.js";
9
9
  import type { ParsedDatabaseResource } from "./astDatabaseParser.js";
10
10
  export interface ParsedClickHouseResource {
11
11
  variableName?: string;
@@ -0,0 +1 @@
1
+ import*as r from"typescript";import{asNumber as b,asString as s,captureExtraProperties as S,isParsedObject as N,omitUndefined as k,parseObjectLiteral as y}from"../common/astCommonParser.js";const g=new Set(["type","databaseName","instanceType","coldTier","optimiseSchedule","backupSchedule","backupRetentionDays"]);function x(t){const e=t.node;if(!r.isCallExpression(e))return null;const o=e.arguments[0];if(!r.isCallExpression(o)||o.arguments.length<2)return null;const c=o.arguments[1];if(!r.isObjectLiteralExpression(c))return null;const i=y(c),a={resourceName:t.resourceName,databaseName:t.databaseName,node:t.node};t.variableName&&(a.variableName=t.variableName);const u=s(i.instanceType);u&&(a.instanceType=u);const l=i.coldTier;l===!1?a.coldTier=!1:N(l)&&s(l.mode)==="s3"&&(a.coldTier={mode:"s3"});const d=i.optimiseSchedule;if(d===!1)a.optimiseSchedule=!1;else{const n=s(d);n&&(a.optimiseSchedule=n)}const p=i.backupSchedule;if(p===!1)a.backupSchedule=!1;else{const n=s(p);n&&(a.backupSchedule=n)}const m=b(i.backupRetentionDays);m!==void 0&&(a.backupRetentionDays=m);const f=S(i,g);return f.length>0&&(a.extraProperties=f),a}function h(t){if(t.length!==0)return t.map(e=>({name:e.resourceName,type:"ClickHouse",databaseName:e.databaseName,...k({instanceType:e.instanceType,coldTier:e.coldTier,optimiseSchedule:e.optimiseSchedule,backupSchedule:e.backupSchedule,backupRetentionDays:e.backupRetentionDays,variableName:e.variableName,extraProperties:e.extraProperties})}))}export{h as convertClickHouseResources,x as extractClickHouseFields};
@@ -4,8 +4,8 @@
4
4
  * astComputeParserHelpers.ts to keep both files within the 400-line budget.
5
5
  * Write paths live in src/codemod/. Do not add mutation helpers here.
6
6
  */
7
- import { type ParsedValue } from "./astCommonParser.js";
8
- import type { ComputeResourcePlan, ApplicationResourcePlan } from "../schemas/resourceSchemas.js";
7
+ import { type ParsedValue } from "../common/astCommonParser.js";
8
+ import type { ComputeResourcePlan, ApplicationResourcePlan } from "../../../schemas/resourceSchemas.js";
9
9
  import type { ParsedDatabaseResource } from "./astDatabaseParser.js";
10
10
  import type { ParsedS3Resource } from "./astStorageParser.js";
11
11
  /** Resolve connected database names from AST connection references */
@@ -0,0 +1 @@
1
+ import{isIdentifierRef as s,isParsedObject as f}from"../common/astCommonParser.js";const c=10;function d(n,r){return Array.isArray(n)?n.filter(s).map(e=>r.find(t=>t.variableName===e.__identifier)).filter(e=>e!==void 0).map(e=>e.resourceName):[]}function _(n,r){return Array.isArray(n)?n.filter(s).map(e=>r.find(t=>t.variableName===e.__identifier)).filter(e=>e!==void 0).map(e=>e.resourceName):[]}function m(n,r,e){if(!Array.isArray(r)||r.length===0)return;const t=r[0];if(!f(t))return;const i=t.containers;if(!Array.isArray(i)||i.length===0)return;const o=i[0];if(!f(o)||!f(o.environment))return;const a=o.environment;(a.DATABASE_HOST||a.DATABASE_PORT||a.DATABASE_NAME)&&(n.needsConnection=!0,e.length>0&&(n.connectedDatabase??[]).length===0&&(n.connectedDatabase=[e[0].name]));for(let A=1;A<=c;A++)(a[`DATABASE_HOST_${A}`]||a[`DATABASE_PORT_${A}`]||a[`DATABASE_NAME_${A}`])&&(n.needsConnection=!0)}function S(n,r,e){if(!Array.isArray(r)||r.length===0)return;const t=r[0];if(!f(t))return;const i=t.containers;if(!Array.isArray(i)||i.length===0)return;const o=i[0];if(!f(o)||!f(o.environment))return;o.environment.BUCKET_NAME&&e.length>0&&(n.connectedStorage??[]).length===0&&(n.connectedStorage=[e[0].name])}export{m as inferDatabaseConnectionsFromEnv,S as inferStorageConnectionsFromEnv,d as resolveConnectedDatabaseNames,_ as resolveConnectedStorageNames};
@@ -5,8 +5,8 @@
5
5
  * mutation helpers here.
6
6
  */
7
7
  import * as ts from "typescript";
8
- import { type ParsedObject } from "./astCommonParser.js";
9
- import { type ApplicationResourcePlan } from "../schemas/resourceSchemas.js";
8
+ import { type ParsedObject } from "../common/astCommonParser.js";
9
+ import { type ApplicationResourcePlan } from "../../../schemas/resourceSchemas.js";
10
10
  import type { ParsedDatabaseResource } from "./astDatabaseParser.js";
11
11
  import type { ParsedS3Resource } from "./astStorageParser.js";
12
12
  export interface ParsedComputeResource {
@@ -0,0 +1 @@
1
+ import*as l from"typescript";import{asString as a,asNumber as S,asBoolean as h,asStringArray as u,asStringUnion as g,captureExtraProperties as v,collectFromAst as m,extractVariableName as T,isFactoryBuildCall as _,isFactoryMethodCall as b,isParsedObject as d,parseObjectLiteral as A}from"../common/astCommonParser.js";import{COMPUTE_ARCHITECTURES as x,COMPUTE_TYPES as O,DEPLOYMENT_TYPES as D,EC2_INSTANCE_TYPES as R,FUNCTION_URL_AUTH_TYPES as Y}from"../../../schemas/constants.js";import{assignIfDefined as c,extractCallStringArg as K,extractClusterConfig as U,extractEnumString as E,isEnvironmentRecord as C,parseEcsService as F}from"./astComputeParserHelpers.js";import{inferDatabaseConnectionsFromEnv as L,inferStorageConnectionsFromEnv as k,resolveConnectedDatabaseNames as H,resolveConnectedStorageNames as V}from"./astComputeConnectionParser.js";function M(e){if(e.arguments.length<2)return null;const n=e.arguments[0],i=e.arguments[1];if(!l.isStringLiteral(n)||!l.isObjectLiteralExpression(i))return null;const t=n.text,r=A(i);return{resourceName:t,type:a(r.type)??"ecs",config:r,node:e}}function J(e){return m(e,n=>{if(!l.isCallExpression(n)||!b(n,"addCompute"))return null;const i=n.arguments[0];if(!_(i,"ComputeFactory"))return null;const t=M(i);if(t){const r=T(n);r&&(t.variableName=r)}return t})}function N(e,n,i){const t=v(e.config,i);t.length>0&&(n.extraProperties=t)}function W(e,n){const i=e.config.docker;if(d(i)){const o=a(i.path),f=a(i.context),y=a(i.target);(o!==void 0||f!==void 0||y!==void 0)&&(n.docker={...o!==void 0&&{path:o},...f!==void 0&&{context:f},...y!==void 0&&{target:y}})}const t=e.config.cluster;t!==void 0&&(n.cluster=U(t));const r=e.config.services;r!==void 0&&Array.isArray(r)&&(n.services=r.filter(o=>d(o)).map(F)),N(e,n,new Set(["type","ecrRepository","docker","cluster","services","connections"]))}function z(e,n){if(c(n,"deployment",g(e.config.deployment,D)),c(n,"timeout",S(e.config.timeout)),c(n,"memory",S(e.config.memorySize)??S(e.config.memory)),c(n,"handler",a(e.config.handler)),c(n,"runtime",E(e.config.runtime,"Runtime")),C(e.config.environment)&&(n.environment=e.config.environment),C(e.config.secrets))n.secrets=e.config.secrets;else{const s=u(e.config.secrets);s&&(n.ssmSecrets=s)}const i=e.config.functionUrl;if(d(i)){const s=g(E(i.authType,"FunctionUrlAuthType"),Y);s!==void 0&&(n.functionUrl={authType:s})}const t=e.config.code;if(t!==void 0){const s=K(t);s&&(n.codePath=s)}c(n,"description",a(e.config.lambdaDescription)),c(n,"architecture",g(E(e.config.architecture,"Architecture"),x)),c(n,"ephemeralStorageSize",S(e.config.ephemeralStorageSize)),c(n,"functionName",a(e.config.functionName)),c(n,"ssmSecretsPath",a(e.config.ssmSecretsPath)),N(e,n,new Set(["type","deployment","timeout","memorySize","memory","handler","runtime","environment","secrets","functionUrl","code","connections","ecrRepository","containerSecretsImport","lambdaDescription","architecture","ephemeralStorageSize","functionName","ssmSecretsPath"]))}function I(e,n){c(n,"instanceType",g(e.config.instanceType,R));const i=e.config.ssh;i===!1?n.enableSSH=!1:i!==void 0&&d(i)?n.enableSSH=!0:c(n,"enableSSH",h(e.config.enableSSH)),c(n,"keyName",a(e.config.keyName)),c(n,"userData",a(e.config.userData)),e.config.securityGroups!==void 0&&(n.securityGroups=u(e.config.securityGroups)),N(e,n,new Set(["type","instanceType","ssh","enableSSH","keyName","userData","securityGroups","connections"]))}function B(e,n,i,t){let r=n.config.connections;if(!r&&Array.isArray(n.config.services)){const f=n.config.services[0];d(f)&&(r=f.connections)}if(!r)return;const s=H(r,i);s.length>0&&(e.needsConnection=!0,e.connectedDatabase=s);const o=V(r,t);o.length>0&&(e.connectedStorage=o)}function G(e,n){({ecs:W,lambda:z,ec2:I})[e.type]?.(n,e)}function Q(e,n,i,t){return e.map(r=>{const s=g(r.config.type,O)??"ecs",o={name:r.resourceName,type:s,needsConnection:!1,connectedDatabase:[],...r.variableName&&{variableName:r.variableName}};return B(o,r,n,i),G(o,r),L(o,r.config.services,t.database),k(o,r.config.services,t.s3),o})}export{Q as convertComputeResources,J as findComputeResources};
@@ -4,8 +4,8 @@
4
4
  * only by astComputeParser.ts. Write paths live in src/codemod/. Do not add
5
5
  * mutation helpers here.
6
6
  */
7
- import { type ParsedValue, type ParsedObject, type IdentifierRef } from "./astCommonParser.js";
8
- import { type ComputeResourcePlan } from "../schemas/resourceSchemas.js";
7
+ import { type ParsedValue, type ParsedObject, type IdentifierRef } from "../common/astCommonParser.js";
8
+ import { type ComputeResourcePlan } from "../../../schemas/resourceSchemas.js";
9
9
  export type EnvironmentRecord = Record<string, string | number | boolean | IdentifierRef | {
10
10
  __expression: string;
11
11
  } | {
@@ -0,0 +1 @@
1
+ import{isPlainObject as u,isParsedObject as o,isExpressionRef as S,isCallRef as y,asString as r,asNumber as i,asBoolean as p,asStringArray as c,asStringUnion as m,captureExtraProperties as d}from"../common/astCommonParser.js";import{ECS_CAPACITY_PROVIDERS as C,LOAD_BALANCER_TYPES as h,SCALING_TYPES as E,AMI_HARDWARE_TYPES as P}from"../../../schemas/constants.js";function _(e){return e!==void 0&&u(e)}function x(e){if(!o(e))return;const n={};for(const[t,a]of Object.entries(e))if(o(a)){const s=r(a.id),f=r(a.name);s&&f&&(n[t]={id:s,name:f,field:r(a.field)})}return Object.keys(n).length>0?n:void 0}function A(e){if(!o(e))return;const n=c(e.command);if(!(!n||n.length===0))return{command:n,interval:i(e.interval),timeout:i(e.timeout),retries:i(e.retries),startPeriod:i(e.startPeriod)}}function N(e){const t=d(e,new Set(["name","image","port","environment","essential","command","entryPoint","secretsImport","secrets","healthCheck"]));return{name:r(e.name),image:r(e.image),port:i(e.port),environment:_(e.environment)?e.environment:void 0,essential:p(e.essential),command:c(e.command),entryPoint:c(e.entryPoint),secretsImport:x(e.secretsImport),ssmSecrets:c(e.secrets),healthCheck:A(e.healthCheck),extraProperties:t.length>0?t:void 0}}function g(e){if(Array.isArray(e))return e.filter(o).map(n=>({path:r(n.path),host:r(n.host),priority:i(n.priority),healthCheckPath:r(n.healthCheckPath)}));if(o(e))return{path:r(e.path),host:r(e.host),priority:i(e.priority),healthCheckPath:r(e.healthCheckPath)}}function O(e){if(e===!1)return!1;if(o(e))return{minCapacity:i(e.minCapacity),maxCapacity:i(e.maxCapacity),desiredCount:i(e.desiredCount),scalingType:m(e.scalingType,E)}}const T=new Set(["instanceType","amiHardwareType","minCapacity","maxCapacity","memoryLimitMiB","warmPool"]);function I(e){if(!o(e))return;const n=e.warmPool,t=o(n)?{minSize:i(n.minSize),reuseOnScaleIn:p(n.reuseOnScaleIn)}:void 0,a=d(e,T);return{instanceType:r(e.instanceType),amiHardwareType:m(e.amiHardwareType,P),minCapacity:i(e.minCapacity),maxCapacity:i(e.maxCapacity),memoryLimitMiB:i(e.memoryLimitMiB),warmPool:t,extraProperties:a.length>0?a:void 0}}const R=new Set(["domain","loadBalancer","directAccess"]);function w(e){if(!o(e))return;const n=e.loadBalancer,t=d(e,R);return{domain:r(e.domain),loadBalancer:n===!1?!1:m(n,h),directAccess:p(e.directAccess),...t.length>0&&{extraProperties:t}}}function L(e){const n=e.containers,t=Array.isArray(n)?n.filter(o).map(N):void 0,s=d(e,new Set(["name","image","docker","ssmSecretsPath","containers","routing","connections","cpu","memoryLimitMiB","desiredCount","scaling","capacityProvider","ec2Config"]));return{name:r(e.name)??"",image:r(e.image),docker:l(e.docker),ssmSecretsPath:r(e.ssmSecretsPath),containers:t,routing:g(e.routing),cpu:i(e.cpu),memoryLimitMiB:i(e.memoryLimitMiB),desiredCount:i(e.desiredCount),scaling:O(e.scaling),capacityProvider:m(e.capacityProvider,C)??"FARGATE",ec2Config:I(e.ec2Config),...s.length>0&&{extraProperties:s}}}function l(e){if(!o(e))return;const n=r(e.path);if(n===void 0)return;const t=r(e.context),a=r(e.target);return{path:n,...t!==void 0&&{context:t},...a!==void 0&&{target:a}}}function Y(e,n){const t=r(e);if(t)return t;if(S(e)&&e.__expression.startsWith(n+"."))return e.__expression.slice(n.length+1)}function k(e){return y(e)?e.__call.match(/\(\s*"([^"]+)"\s*\)/)?.[1]:void 0}function W(e,n,t){t!==void 0&&(e[n]=t)}export{W as assignIfDefined,k as extractCallStringArg,w as extractClusterConfig,Y as extractEnumString,_ as isEnvironmentRecord,L as parseEcsService};
@@ -6,7 +6,7 @@
6
6
  * mutation helpers here.
7
7
  */
8
8
  import * as ts from "typescript";
9
- import type { ApplicationResourcePlan, ExtraProperty } from "../schemas/resourceSchemas.js";
9
+ import type { ApplicationResourcePlan, ExtraProperty } from "../../../schemas/resourceSchemas.js";
10
10
  import { type ParsedDynamoDBResource } from "./astDynamoDBParser.js";
11
11
  import { type ParsedClickHouseResource } from "./astClickHouseParser.js";
12
12
  export { type ParsedDynamoDBResource, convertDynamoDBResources, } from "./astDynamoDBParser.js";
@@ -0,0 +1 @@
1
+ import*as c from"typescript";import{constIncludes as b,DATABASE_ENGINES as x}from"../../../schemas/constants.js";import{asBoolean as p,asNumber as u,asString as o,asStringArray as A,captureExtraProperties as I,collectFromAst as E,extractVariableName as S,isCallRef as R,isFactoryBuildCall as h,isFactoryMethodCall as D,omitUndefined as N,parseObjectLiteral as w,parseOptionalConfig as d,parseBooleanOrConfig as g,resolveTemplateLiteral as v,typed as l}from"../common/astCommonParser.js";import{extractDynamoDBFields as C}from"./astDynamoDBParser.js";import{extractClickHouseFields as P}from"./astClickHouseParser.js";import{convertDynamoDBResources as j}from"./astDynamoDBParser.js";import{convertClickHouseResources as V}from"./astClickHouseParser.js";function T(r){const e=o(r.databaseEngine);if(e!==void 0&&b(x,e))return e;const i=r.engine;if(R(i)){const t=String(i.__call);if(t.includes("postgres")||t.includes("auroraPostgres"))return"postgresql";if(t.includes("mysql")||t.includes("auroraMysql"))return"mysql"}}function W(r){const e=r.engine;if(R(e))return String(e.__call)}const B=new Set(["type","databaseName","databaseEngine","engine","vpc","port","deletionProtection","instanceType","multiAz","publiclyAccessible","enableSecretRotation","encryption","databaseInsights","proxy","readReplica","credentials","writer","readers","backupRetention","preferredMaintenanceWindow","primaryRegion","secondaryRegions","globalClusterIdentifier","enableGlobalWriteForwarding","snapshotIdentifier","allocatedStorage","monitoringInterval","snapshotUsername"]);function F(r,e,i){if(i.arguments.length<2)return null;const t=i.arguments[0],a=i.arguments[1];if(!c.isStringLiteral(t)&&!c.isTemplateExpression(t))return null;const s=c.isStringLiteral(t)?t.text:v(r,t);if(!c.isObjectLiteralExpression(a))return null;const n=w(a),m={resourceName:s,type:o(n.type)??"",databaseName:o(n.databaseName)??"",databaseEngine:T(n),engineExpression:W(n),port:u(n.port),deletionProtection:p(n.deletionProtection),instanceType:o(n.instanceType),multiAz:p(n.multiAz),publiclyAccessible:p(n.publiclyAccessible),enableSecretRotation:p(n.enableSecretRotation),encryption:d(n.encryption,l()),databaseInsights:g(n.databaseInsights,l()),proxy:g(n.proxy,l()),readReplica:g(n.readReplica,l()),credentials:d(n.credentials,l()),writer:d(n.writer,l()),readers:g(n.readers,l()),backupRetention:u(n.backupRetention),preferredMaintenanceWindow:o(n.preferredMaintenanceWindow),primaryRegion:o(n.primaryRegion),secondaryRegions:A(n.secondaryRegions),globalClusterIdentifier:o(n.globalClusterIdentifier),enableGlobalWriteForwarding:p(n.enableGlobalWriteForwarding),allocatedStorage:u(n.allocatedStorage),monitoringInterval:u(n.monitoringInterval),snapshotIdentifier:o(n.snapshotIdentifier),snapshotUsername:o(n.snapshotUsername),node:e},f=S(e);f&&(m.variableName=f);const y=I(n,B);return y.length>0&&(m.extraProperties=y),m}function z(r){return E(r,e=>{if(!c.isCallExpression(e)||!D(e,"addDatabase"))return null;const i=e.arguments[0];return h(i,"DatabaseFactory")?F(r,e,i):null})}function O(r){const e=[],i=[],t=[];for(const a of r)if(a.type==="DynamoDB"){const s=C(a);s&&i.push(s)}else if(a.type==="ClickHouse"){const s=P(a);s&&t.push(s)}else e.push(a);return{databases:e,dynamodb:i,clickhouse:t}}const k=["Instance","Aurora","GlobalAurora"];function q(r){return r.filter(e=>e.type!=="DynamoDB").map(e=>({name:e.resourceName,type:b(k,e.type)?e.type:"Instance",databaseName:e.databaseName,...N({port:e.port,deletionProtection:e.deletionProtection,instanceType:e.instanceType,multiAz:e.multiAz,publiclyAccessible:e.publiclyAccessible,enableSecretRotation:e.enableSecretRotation,encryption:e.encryption,databaseInsights:e.databaseInsights,proxy:e.proxy,readReplica:e.readReplica,credentials:e.credentials,writer:e.writer,readers:e.readers,backupRetention:e.backupRetention,preferredMaintenanceWindow:e.preferredMaintenanceWindow,primaryRegion:e.primaryRegion,secondaryRegions:e.secondaryRegions,globalClusterIdentifier:e.globalClusterIdentifier,enableGlobalWriteForwarding:e.enableGlobalWriteForwarding,allocatedStorage:e.allocatedStorage,monitoringInterval:e.monitoringInterval,variableName:e.variableName,databaseEngine:e.databaseEngine,engineExpression:e.engineExpression,extraProperties:e.extraProperties})}))}export{V as convertClickHouseResources,q as convertDatabaseResources,j as convertDynamoDBResources,z as findDatabaseResources,O as splitDatabaseResources};
@@ -5,7 +5,7 @@
5
5
  * mutation helpers here.
6
6
  */
7
7
  import * as ts from "typescript";
8
- import type { ApplicationResourcePlan, ExtraProperty } from "../schemas/resourceSchemas.js";
8
+ import type { ApplicationResourcePlan, ExtraProperty } from "../../../schemas/resourceSchemas.js";
9
9
  import type { ParsedDatabaseResource } from "./astDatabaseParser.js";
10
10
  declare const DYNAMODB_KEY_TYPES: readonly ["S", "N", "B"];
11
11
  type DynamoDBKeyType = (typeof DYNAMODB_KEY_TYPES)[number];
@@ -0,0 +1 @@
1
+ import*as s from"typescript";import{asBoolean as A,asString as l,asStringUnion as S,captureExtraProperties as D,isParsedObject as b,omitUndefined as B,parseObjectLiteral as E}from"../common/astCommonParser.js";const O=["S","N","B"];function a(t){if(!b(t))return;const e=l(t.name),i=S(t.type,O);if(!(!e||!i))return{name:e,type:i}}function P(t){const e=t.node;if(!s.isCallExpression(e))return null;const i=e.arguments[0];if(!s.isCallExpression(i)||i.arguments.length<2)return null;const u=i.arguments[1];if(!s.isObjectLiteralExpression(u))return null;const r=E(u),c=a(r.partitionKey);if(!c)return null;const n={resourceName:t.resourceName,partitionKey:c,node:t.node};t.variableName&&(n.variableName=t.variableName);const m=a(r.sortKey);if(m&&(n.sortKey=m),Array.isArray(r.globalSecondaryIndexes)){const p=r.globalSecondaryIndexes.filter(b).map(o=>{const K=a(o.partitionKey);if(!K)return null;const x=l(o.indexName);if(!x)return null;const N={indexName:x,partitionKey:K},g=a(o.sortKey);return g&&(N.sortKey=g),N}).filter(o=>o!==null);p.length>0&&(n.globalSecondaryIndexes=p)}const f=l(r.ttlAttribute);f&&(n.ttlAttribute=f);const d=A(r.stream);d!==void 0&&(n.stream=d);const y=D(r,new Set(["type","databaseName","partitionKey","sortKey","globalSecondaryIndexes","ttlAttribute","stream"]));return y.length>0&&(n.extraProperties=y),n}function _(t){if(t.length!==0)return t.map(e=>({name:e.resourceName,partitionKey:e.partitionKey,...B({sortKey:e.sortKey,globalSecondaryIndexes:e.globalSecondaryIndexes,ttlAttribute:e.ttlAttribute,stream:e.stream,variableName:e.variableName,extraProperties:e.extraProperties})}))}export{_ as convertDynamoDBResources,P as extractDynamoDBFields};
@@ -4,8 +4,8 @@
4
4
  * paths live in src/codemod/. Do not add mutation helpers here.
5
5
  */
6
6
  import * as ts from "typescript";
7
- import type { ApplicationResourcePlan } from "../schemas/resourceSchemas.js";
8
- import { type ParsedValue } from "./astCommonParser.js";
7
+ import type { ApplicationResourcePlan } from "../../../schemas/resourceSchemas.js";
8
+ import { type ParsedValue } from "../common/astCommonParser.js";
9
9
  /** Parsed SQS queue resource from app.addMessaging(MessagingFactory.build(...)) */
10
10
  export interface ParsedSQSResource {
11
11
  variableName?: string;
@@ -0,0 +1 @@
1
+ import*as o from"typescript";import{SqsRemovalPolicySchema as f}from"../../../schemas/messagingSchemas.js";import{asBoolean as u,asNumber as a,asString as m,captureExtraProperties as p,collectFromAst as S,extractVariableName as y,isFactoryBuildCall as g,isFactoryMethodCall as P,isParsedObject as x,omitUndefined as d,parseObjectLiteral as b}from"../common/astCommonParser.js";function v(e,t){if(t.arguments.length<2)return null;const n=t.arguments[0],s=t.arguments[1];if(!o.isStringLiteral(n)||!o.isObjectLiteralExpression(s))return null;const i=b(s),r={resourceName:n.text,queueType:m(i.queueType)??"standard",visibilityTimeout:a(i.visibilityTimeout),retentionPeriod:a(i.messageRetentionPeriod),contentBasedDeduplication:u(i.contentBasedDeduplication),removalPolicy:m(i.removalPolicy),node:e},c=y(e);c&&(r.variableName=c);const l=p(i,new Set(["type","queueType","visibilityTimeout","messageRetentionPeriod","contentBasedDeduplication","removalPolicy"]));return l.length>0&&(r.extraProperties=l),r}function Q(e){if(e!=null){if(e===!1)return!1;if(x(e))return d({enabled:u(e.enabled),maxReceiveCount:a(e.maxReceiveCount)})}}function h(e){return S(e,t=>{if(!o.isCallExpression(t)||!P(t,"addMessaging"))return null;const n=t.arguments[0];return g(n,"MessagingFactory")?v(t,n):null})}function D(e){if(e.length!==0)return e.map(t=>({name:t.resourceName,queueType:t.queueType==="fifo"?"fifo":"standard",...d({visibilityTimeout:t.visibilityTimeout,retentionPeriod:t.retentionPeriod,contentBasedDeduplication:t.contentBasedDeduplication,removalPolicy:T(t.removalPolicy),variableName:t.variableName,extraProperties:t.extraProperties})}))}const N=new Set(f.options);function R(e){return N.has(e)}function T(e){return e!==void 0&&R(e)?e:void 0}export{D as convertSQSResources,h as findSQSResources,Q as parseDeadLetterQueueConfig};
@@ -5,8 +5,8 @@
5
5
  * not add mutation helpers here.
6
6
  */
7
7
  import * as ts from "typescript";
8
- import type { ApplicationResourcePlan, NetworkResourcePlan } from "../schemas/resourceSchemas.js";
9
- import { type ParsedObject } from "./astCommonParser.js";
8
+ import type { ApplicationResourcePlan, NetworkResourcePlan } from "../../../schemas/resourceSchemas.js";
9
+ import { type ParsedObject } from "../common/astCommonParser.js";
10
10
  /** Parsed network configuration from App.getApp() options */
11
11
  export interface ParsedNetworkConfig {
12
12
  maxAzs?: number;
@@ -0,0 +1 @@
1
+ import*as r from"typescript";import{constIncludes as E,BACKUP_VAULT_TIERS as z}from"../../../schemas/constants.js";import{FlowLogDestinationSchema as A}from"../../../schemas/networkSchemas.js";import{asNumber as d,asString as p,collectFromAst as N,extractVariableName as O,findFirstInAst as f,isAppGetAppCall as u,isFactoryBuildCall as k,isFactoryMethodCall as F,isNamedProperty as a,isParsedObject as b,omitUndefined as l,parseObjectLiteral as c,parseBooleanOrConfig as x}from"../common/astCommonParser.js";const S=new Set(A.options);function T(n){if(n!==void 0)return S.has(n)?n:void 0}function w(n){return{maxAzs:d(n.maxAzs),natGateways:x(n.natGateways,e=>({count:d(e.count)})),flowLogs:x(n.flowLogs,e=>({destination:p(e.destination),retentionDays:d(e.retentionDays)})),vpcEndpoints:b(n.vpcEndpoints)?n.vpcEndpoints:void 0}}function h(n,e){if(e.arguments.length<2)return null;const t=e.arguments[0],i=e.arguments[1];if(!r.isStringLiteral(t))return null;const o=t.text,s=r.isObjectLiteralExpression(i)?c(i):{},L=w(s),g={name:o,config:l({...L}),node:n},m=O(n);return m&&(g.variableName=m),g}function v(n){return f(n,e=>{if(!u(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(a(i,"network")&&r.isObjectLiteralExpression(i.initializer)){for(const o of i.initializer.properties)if(a(o,"useExisting")&&r.isStringLiteral(o.initializer))return o.initializer.text}}})}function D(n){return f(n,e=>{if(!u(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(a(i,"network")){if(i.initializer.kind===r.SyntaxKind.FalseKeyword)return;if(r.isObjectLiteralExpression(i.initializer)&&!i.initializer.properties.some(s=>a(s,"useExisting"))){const s=c(i.initializer);return w(s)}}}})}function G(n){return f(n,e=>{if(!u(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(a(i,"backup")){if(i.initializer.kind===r.SyntaxKind.FalseKeyword)return!1;if(r.isObjectLiteralExpression(i.initializer)){const o=c(i.initializer),s=p(o.tier);if(s)return{tier:s}}}}})}function I(n){return f(n,e=>{if(!u(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(a(i,"tunnel")){if(i.initializer.kind===r.SyntaxKind.FalseKeyword)return!1;if(i.initializer.kind===r.SyntaxKind.TrueKeyword)return!0;if(r.isObjectLiteralExpression(i.initializer)){const o=c(i.initializer),s=p(o.instanceType);return s?{instanceType:s}:{}}}}})}function B(n){return N(n,e=>{if(!r.isCallExpression(e)||!F(e,"addNetwork"))return null;const t=e.arguments[0];return k(t,"NetworkFactory")?h(e,t):null})}function y(n){const e=n.flowLogs;return{...l({maxAzs:n.maxAzs,natGateways:n.natGateways,vpcEndpoints:n.vpcEndpoints}),...e!==void 0&&{flowLogs:e===!1?!1:l({destination:T(e.destination),retentionDays:e.retentionDays})}}}function U(n){if(n)return y(n)}function P(n){if(n===void 0)return;if(n===!1)return!1;const e=n.tier;if(E(z,e))return{tier:e}}function _(n){if(n===void 0)return;if(n===!1)return!1;if(n===!0)return{};const e={};return n.instanceType&&(e.instanceType=n.instanceType),e}function V(n){if(!(!n||n.length===0))return n.map(e=>({name:e.name,...y(e.config)}))}export{y as buildNetworkFields,V as convertAdditionalNetworks,P as convertBackupConfig,U as convertNetworkConfig,_ as convertTunnelConfig,G as findBackupConfig,D as findNetworkConfig,B as findNetworkResources,I as findTunnelConfig,v as findVpcId};
@@ -5,7 +5,7 @@
5
5
  * helpers here.
6
6
  */
7
7
  import * as ts from "typescript";
8
- import type { ApplicationResourcePlan } from "../schemas/resourceSchemas.js";
8
+ import type { ApplicationResourcePlan } from "../../../schemas/resourceSchemas.js";
9
9
  /** Parsed Lambda function configuration */
10
10
  export interface ParsedLambdaConfig {
11
11
  memorySize?: number;
@@ -0,0 +1 @@
1
+ import*as l from"typescript";import{asBoolean as c,asNumber as r,asString as o,asStringArray as v,asStringUnion as y,asObjectOrFalse as g,collectFromAst as C,extractSubConfig as s,extractVariableName as A,isFactoryBuildCall as P,isFactoryMethodCall as h,isParsedObject as I,parseObjectLiteral as O,parseOptionalConfig as a,typed as p}from"../common/astCommonParser.js";import{parseDeadLetterQueueConfig as L}from"./astMessagingParser.js";const N=["Instance","Aurora"],z=["postgresql","mysql"];function f(n){if(!I(n))return;const e={...n.memorySize!==void 0&&{memorySize:r(n.memorySize)},...n.timeout!==void 0&&{timeout:r(n.timeout)},...n.ephemeralStorageSize!==void 0&&{ephemeralStorageSize:r(n.ephemeralStorageSize)}};return Object.keys(e).length>0?e:void 0}function w(n){return s(n,"database",e=>({type:y(e.type,N),databaseName:o(e.databaseName),databaseEngine:y(e.databaseEngine,z),deletionProtection:c(e.deletionProtection),backupRetention:r(e.backupRetention),port:r(e.port),publiclyAccessible:c(e.publiclyAccessible),allowedIpCidr:o(e.allowedIpCidr),instanceType:o(e.instanceType),allocatedStorage:r(e.allocatedStorage),multiAz:c(e.multiAz),allowVpcAccess:c(e.allowVpcAccess),monitoringInterval:r(e.monitoringInterval),preferredMaintenanceWindow:o(e.preferredMaintenanceWindow),snapshotIdentifier:o(e.snapshotIdentifier),snapshotUsername:o(e.snapshotUsername),readReplica:g(e.readReplica),writer:a(e.writer,p()),readers:g(e.readers),databaseInsights:g(e.databaseInsights),proxy:g(e.proxy),credentials:a(e.credentials,p()),encryption:a(e.encryption,p())}))}function E(n){return s(n,"compute",e=>({server:a(e.server,f),imageOptimisation:a(e.imageOptimisation,f),revalidation:a(e.revalidation,f)}))}function R(n){const e=t=>({versioned:c(t.versioned)});return s(n,"storage",t=>({assets:a(t.assets,e),cache:a(t.cache,e),media:a(t.media,e)}))}function D(n){return s(n,"messaging",e=>({revalidationQueue:a(e.revalidationQueue,t=>({visibilityTimeout:r(t.visibilityTimeout),messageRetentionPeriod:r(t.messageRetentionPeriod),maxMessageSize:r(t.maxMessageSize),deadLetterQueue:L(t.deadLetterQueue)}))}))}function M(n){return s(n,"cdn",e=>({domainNames:v(e.domainNames),certificateArn:o(e.certificateArn)}))}function T(n){return s(n,"environment",e=>{const t=Object.fromEntries(Object.entries(e).filter(m=>typeof m[1]=="string"));return Object.keys(t).length>0?t:void 0})}function V(n,e){if(n.arguments.length<2)return null;const t=n.arguments[0],m=n.arguments[1];if(!l.isStringLiteral(t)||!l.isObjectLiteralExpression(m))return null;const S=t.text,i=O(m),u=i.type;if(u!=="payload"&&u!=="nextjs")return null;const x=A(e),d=o(i.name);return d?{variableName:x,constructId:S,type:u,config:{name:d,domain:o(i.domain),database:w(i),compute:E(i),storage:R(i),messaging:D(i),cdn:M(i),environment:T(i)},node:n}:null}function F(n){return C(n,e=>{if(!l.isCallExpression(e)||!h(e,"addPattern"))return null;const t=e.arguments[0];return P(t,"PatternFactory")?V(t,e):null})}function Q(n,e){if(!e||e.length===0)return;const t=e[0];t.type!=="payload"&&t.type!=="nextjs"||(n.pattern=t.type,n.patternConfig={type:t.type,name:t.config.name,domain:t.config.domain,database:t.config.database,compute:t.config.compute,storage:t.config.storage,messaging:t.config.messaging,cdn:t.config.cdn,environment:t.config.environment})}export{Q as applyPatternConfig,F as findPatternResources};
@@ -0,0 +1 @@
1
+ import*as r from"typescript";import{asString as o,collectFromAst as c,isFactoryMethodCall as f,parseObjectLiteral as g}from"../common/astCommonParser.js";function p(u){return c(u,t=>{if(!r.isCallExpression(t)||!f(t,"addSchedule")||t.arguments.length<2)return null;const s=t.arguments[0],i=t.arguments[1];if(!r.isStringLiteral(s)||!r.isObjectLiteralExpression(i))return null;const a=g(i),l=o(a.schedule);if(l===void 0)return null;const e=i.properties.find(n=>r.isPropertyAssignment(n)&&r.isIdentifier(n.name)&&n.name.text==="target");return!e||!r.isPropertyAssignment(e)||!r.isIdentifier(e.initializer)?null:{id:s.text,schedule:l,targetVariableName:e.initializer.text}})}export{p as findSchedules};
@@ -4,8 +4,8 @@
4
4
  * paths live in src/codemod/. Do not add mutation helpers here.
5
5
  */
6
6
  import * as ts from "typescript";
7
- import { type ApplicationResourcePlan } from "../schemas/resourceSchemas.js";
8
- import { type ParsedObject } from "./astCommonParser.js";
7
+ import { type ApplicationResourcePlan } from "../../../schemas/resourceSchemas.js";
8
+ import { type ParsedObject } from "../common/astCommonParser.js";
9
9
  declare const S3_BUCKET_CLASSES: Set<string>;
10
10
  export { S3_BUCKET_CLASSES };
11
11
  export interface ParsedS3Resource {
@@ -0,0 +1 @@
1
+ import*as i from"typescript";import{S3_STACK_PLACEMENTS as g}from"../../../schemas/resourceSchemas.js";import{S3_ENCRYPTION_TYPES as f,BACKUP_VAULT_TIERS as p}from"../../../schemas/constants.js";import{asBoolean as c,asNumber as d,asString as o,asStringUnion as a,captureExtraProperties as x,collectFromAst as b,extractVariableName as N,isFactoryBuildCall as k,isFactoryMethodCall as h,isParsedObject as u,parseObjectLiteral as y}from"../common/astCommonParser.js";const A=new Set(["S3Bucket"]);function C(n,e,r){const t=i.isIdentifier(n.name)?n.name.text:"";if(e.arguments&&e.arguments.length>=2){const s=e.arguments[1],m=i.isStringLiteral(s)?s.text:"",l=e.arguments.length>=3?e.arguments[2]:void 0,S=l&&i.isObjectLiteralExpression(l)?y(l):{};return{variableName:t,resourceName:m,bucketClass:r,config:S,node:n}}return null}function P(n,e){if(e.arguments.length<2)return null;const r=e.arguments[0],t=e.arguments[1];if(!i.isStringLiteral(r)||!i.isObjectLiteralExpression(t))return null;const s=y(t);return{variableName:N(n)??"",resourceName:r.text,bucketClass:"StorageFactory",config:s,node:n}}function R(n){return b(n,e=>{if(!i.isVariableDeclaration(e)||!e.initializer||!i.isNewExpression(e.initializer))return null;const r=e.initializer;if(!i.isIdentifier(r.expression))return null;const t=r.expression.text;return A.has(t)?C(e,r,t):null})}function _(n){return b(n,e=>{if(!i.isCallExpression(e)||!h(e,"addStorage"))return null;const r=e.arguments[0];return k(r,"StorageFactory")?P(e,r):null})}function v(n){return n.map(e=>({name:e.resourceName,...o(e.config.bucketName)&&{bucketName:o(e.config.bucketName)},...c(e.config.publicReadAccess)===!0&&{publicReadAccess:!0},...u(e.config.websiteHosting)&&(()=>{const r=e.config.websiteHosting;return{websiteHosting:{indexDocument:o(r.indexDocument)??"index.html",...o(r.errorDocument)&&{errorDocument:o(r.errorDocument)}}}})(),...a(e.config.backupVaultTier,p)&&{backupVaultTier:a(e.config.backupVaultTier,p)},...c(e.config.versioned)!==void 0&&{versioned:c(e.config.versioned)},...a(e.config.encryption,f)&&{encryption:a(e.config.encryption,f)},...o(e.config.kmsKeyArn)&&{kmsKeyArn:o(e.config.kmsKeyArn)},...Array.isArray(e.config.cors)&&e.config.cors.length>0&&{cors:e.config.cors.filter(u).map(r=>({allowedOrigins:Array.isArray(r.allowedOrigins)?r.allowedOrigins.filter(t=>typeof t=="string"):[],allowedMethods:Array.isArray(r.allowedMethods)?r.allowedMethods.filter(t=>typeof t=="string"):[]}))},...u(e.config.deployment)&&(()=>{const r=e.config.deployment;return{deployment:{source:o(r.source)??"",...c(r.prune)!==void 0&&{prune:c(r.prune)},...u(r.cacheControl)&&(()=>{const t=r.cacheControl;return{cacheControl:{...d(t.maxAge)!==void 0&&{maxAge:d(t.maxAge)},...c(t.immutable)!==void 0&&{immutable:c(t.immutable)}}}})()}}})(),...a(e.config.stackPlacement,g)&&{stackPlacement:a(e.config.stackPlacement,g)},...e.variableName&&{variableName:e.variableName},...(()=>{const r=new Set(["bucketName","publicReadAccess","websiteHosting","backupVaultTier","versioned","encryption","kmsKeyArn","cors","deployment","stackPlacement"]),t=x(e.config,r);return t.length>0?{extraProperties:t}:{}})()}))}export{A as S3_BUCKET_CLASSES,v as convertS3Resources,_ as findS3FactoryResources,R as findS3Resources};
@@ -1 +1 @@
1
- import{TIER_PRESETS as m,getDefaultDatabaseTypeForTier as C,applyTierDefaultsToServices as g}from"../presets/tierPresets.js";import{COMPUTE_TYPE as b,DEFAULT_CONTAINER_PORT as l}from"../schemas/constants.js";import{success as u,failure as P}from"../types/Result.js";import{injectCustomCodeBlocks as k}from"../ast/astCodeInjection.js";import{toVariableName as d,toValidDatabaseName as D,generateImports as h,generateAppInit as T,generateTags as E,generateNetworkCode as f,generateDatabaseCode as R,generateClickHouseCode as I,generateS3Code as S,generateDynamoDBCode as p,generateSQSCode as w,generateComputeCode as A,generateCDNCode as B,collectCdnReferencedResources as U,usesPatternApproach as j,generatePatternCodeWithComments as x}from"../generation/index.js";function L(e,n,r=!0,s,t){const a={appName:e,type:n,database:[],s3:[],compute:[]};if(n==="custom")return a;const o=n,c=m[o];return{...a,database:y(e,c,o,r,t),compute:F(e,c,o,r,s),network:c.network,backup:c.backup}}function y(e,n,r,s,t){const a=C(r),o=n.database[a];return!s||o===null?[]:[{name:e,type:a,databaseName:D(e),variableName:`${d(e)}Database`,...o,...t?.snapshotIdentifier!==void 0&&{snapshotIdentifier:t.snapshotIdentifier},...t?.snapshotUsername!==void 0&&{snapshotUsername:t.snapshotUsername}}]}function _(e,n){if(!(e===void 0&&n===void 0))return{scaling:{...e!==void 0&&{minCapacity:e},...n!==void 0&&{maxCapacity:n}}}}function $(e,n){const{minCapacity:r,maxCapacity:s,...t}=e,a=n?.containerPort??l,o=n?.docker;return{...t,...o?.path!==void 0&&{docker:{path:o.path,...o.context!==void 0&&{context:o.context},...o.target!==void 0&&{target:o.target}}},...n?.needsDatabaseConnection!==void 0&&{needsDatabaseConnection:n.needsDatabaseConnection},containers:[{port:a}],..._(r,s)}}function F(e,n,r,s,t){const a=n.compute.ecs,o=t&&t.length>0?g(r,t):a.services.map((c,i)=>({...c,name:i===0?"api":`service-${i+1}`}));return[{name:e,type:b.ECS,needsConnection:s,connectedDatabase:s?[e]:void 0,variableName:`${d(e)}Compute`,cluster:a.cluster,services:o.map((c,i)=>$(c,t?.[i]))}]}function Q(e,n){const r=[h(e),T(e),E(e)];if(j(e))r.push(x(e),f(e));else{const t=U(e);r.push(f(e),R(e),I(e),S(e),p(e),w(e),A(e,t),B(e))}const s=r.join("");if(e.customCodeBlocks&&e.customCodeBlocks.length>0){const t=k(s,e.customCodeBlocks,n?.resourceMapping);return t.success?u(t.content):P(new Error(`Custom code injection failed: ${t.error??"unknown error"}`))}return u(s)}export{Q as generateInfrastructureFromPlan,L as planApplicationResources};
1
+ import{TIER_PRESETS as m,getDefaultDatabaseTypeForTier as C,applyTierDefaultsToServices as g}from"../presets/tierPresets.js";import{COMPUTE_TYPE as b,DEFAULT_CONTAINER_PORT as l}from"../schemas/constants.js";import{success as u,failure as P}from"../types/Result.js";import{injectCustomCodeBlocks as k}from"../ast/mutation/astCodeInjection.js";import{toVariableName as d,toValidDatabaseName as D,generateImports as h,generateAppInit as T,generateTags as E,generateNetworkCode as f,generateDatabaseCode as R,generateClickHouseCode as I,generateS3Code as S,generateDynamoDBCode as p,generateSQSCode as w,generateComputeCode as A,generateCDNCode as B,collectCdnReferencedResources as U,usesPatternApproach as j,generatePatternCodeWithComments as x}from"../generation/index.js";function L(e,n,r=!0,s,t){const a={appName:e,type:n,database:[],s3:[],compute:[]};if(n==="custom")return a;const o=n,c=m[o];return{...a,database:y(e,c,o,r,t),compute:F(e,c,o,r,s),network:c.network,backup:c.backup}}function y(e,n,r,s,t){const a=C(r),o=n.database[a];return!s||o===null?[]:[{name:e,type:a,databaseName:D(e),variableName:`${d(e)}Database`,...o,...t?.snapshotIdentifier!==void 0&&{snapshotIdentifier:t.snapshotIdentifier},...t?.snapshotUsername!==void 0&&{snapshotUsername:t.snapshotUsername}}]}function _(e,n){if(!(e===void 0&&n===void 0))return{scaling:{...e!==void 0&&{minCapacity:e},...n!==void 0&&{maxCapacity:n}}}}function $(e,n){const{minCapacity:r,maxCapacity:s,...t}=e,a=n?.containerPort??l,o=n?.docker;return{...t,...o?.path!==void 0&&{docker:{path:o.path,...o.context!==void 0&&{context:o.context},...o.target!==void 0&&{target:o.target}}},...n?.needsDatabaseConnection!==void 0&&{needsDatabaseConnection:n.needsDatabaseConnection},containers:[{port:a}],..._(r,s)}}function F(e,n,r,s,t){const a=n.compute.ecs,o=t&&t.length>0?g(r,t):a.services.map((c,i)=>({...c,name:i===0?"api":`service-${i+1}`}));return[{name:e,type:b.ECS,needsConnection:s,connectedDatabase:s?[e]:void 0,variableName:`${d(e)}Compute`,cluster:a.cluster,services:o.map((c,i)=>$(c,t?.[i]))}]}function Q(e,n){const r=[h(e),T(e),E(e)];if(j(e))r.push(x(e),f(e));else{const t=U(e);r.push(f(e),R(e),I(e),S(e),p(e),w(e),A(e,t),B(e))}const s=r.join("");if(e.customCodeBlocks&&e.customCodeBlocks.length>0){const t=k(s,e.customCodeBlocks,n?.resourceMapping);return t.success?u(t.content):P(new Error(`Custom code injection failed: ${t.error??"unknown error"}`))}return u(s)}export{Q as generateInfrastructureFromPlan,L as planApplicationResources};
@@ -1 +1 @@
1
- export declare const GENERATOR_VERSION = "2.19.2";
1
+ export declare const GENERATOR_VERSION = "2.19.3";
@@ -1 +1 @@
1
- const E="2.19.2";export{E as GENERATOR_VERSION};
1
+ const E="2.19.3";export{E as GENERATOR_VERSION};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjall/generator",
3
- "version": "2.19.3",
3
+ "version": "2.19.4",
4
4
  "description": "Pure infrastructure generation logic for Fjall",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "license": "SEE LICENSE IN LICENSE",
45
45
  "dependencies": {
46
- "@fjall/util": "^2.19.3",
46
+ "@fjall/util": "^2.19.4",
47
47
  "ast-types": "^0.16.1",
48
48
  "recast": "^0.23.11",
49
49
  "ts-morph": "^28.0.0",
@@ -59,5 +59,5 @@
59
59
  "typescript-eslint": "^8.59.1",
60
60
  "vitest": "^4.1.5"
61
61
  },
62
- "gitHead": "622bf104895ff3f51147de46d5b70c5928aaaa86"
62
+ "gitHead": "269cdbb75bb3b35c5f2b393bd2a883f5ebbd4155"
63
63
  }
@@ -1 +0,0 @@
1
- import*as f from"typescript";import{asString as c,asStringArray as D,asStringUnion as h,captureExtraProperties as y,findFirstInAst as I,isFactoryBuildCall as O,isFactoryMethodCall as P,isIdentifierRef as _,isParsedObject as p,parseObjectLiteral as x}from"./astCommonParser.js";function E(e){if(e.arguments.length<2)return null;const n=e.arguments[0],s=e.arguments[1];return!f.isStringLiteral(n)||!f.isObjectLiteralExpression(s)?null:{resourceName:n.text,config:x(s),node:e}}function G(e,n,s){const u=n.find(i=>i.variableName===e);if(u)return u.resourceName;const r=s.find(i=>i.variableName===e||i.resourceName.charAt(0).toLowerCase()+i.resourceName.slice(1)===e);return r?r.resourceName:e}const A=["CACHING_OPTIMIZED","CACHING_DISABLED"];function b(e){return I(e,n=>{if(!f.isCallExpression(n)||!P(n,"addCdn"))return;const s=n.arguments[0];if(O(s,"CdnFactory"))return E(s)??void 0})}function L(e,n,s){if(!e)return;const u=e,r=u.config,i=t=>_(t)?G(t.__identifier,n,s):c(t)??"",C=i(r.origin),a={name:u.resourceName,defaultOriginRef:C};if(Array.isArray(r.behaviours)){const t=r.behaviours.filter(p).map(o=>({pathPattern:c(o.pathPattern)??"",originRef:i(o.origin),...h(o.cachePolicy,A)!==void 0&&{cachePolicy:h(o.cachePolicy,A)}}));t.length>0&&(a.behaviours=t)}const m=c(r.customDomain);if(m)a.customDomain=m;else{const t=D(r.domainNames);t&&t.length>0&&(a.customDomain=t[0])}const g=c(r.certificateArn);if(g&&(a.certificateArn=g),r.accessGate!==void 0){if(r.accessGate===!1)a.accessGate=!1;else if(p(r.accessGate)){const t=r.accessGate,o=c(t.type),N=c(t.username),l=c(t.password);o==="basic-auth"&&N&&l&&(a.accessGate={type:"basic-auth",username:N,password:l})}}const d=y(r,new Set(["originType","origin","behaviours","customDomain","domainNames","certificateArn","accessGate"]));return d.length>0&&(a.extraProperties=d),a}export{L as convertCDNResource,b as findCDNResource};
@@ -1 +0,0 @@
1
- import*as r from"typescript";import{asNumber as b,asString as s,captureExtraProperties as S,isParsedObject as N,omitUndefined as k,parseObjectLiteral as y}from"./astCommonParser.js";const g=new Set(["type","databaseName","instanceType","coldTier","optimiseSchedule","backupSchedule","backupRetentionDays"]);function x(t){const e=t.node;if(!r.isCallExpression(e))return null;const o=e.arguments[0];if(!r.isCallExpression(o)||o.arguments.length<2)return null;const c=o.arguments[1];if(!r.isObjectLiteralExpression(c))return null;const i=y(c),a={resourceName:t.resourceName,databaseName:t.databaseName,node:t.node};t.variableName&&(a.variableName=t.variableName);const u=s(i.instanceType);u&&(a.instanceType=u);const l=i.coldTier;l===!1?a.coldTier=!1:N(l)&&s(l.mode)==="s3"&&(a.coldTier={mode:"s3"});const d=i.optimiseSchedule;if(d===!1)a.optimiseSchedule=!1;else{const n=s(d);n&&(a.optimiseSchedule=n)}const p=i.backupSchedule;if(p===!1)a.backupSchedule=!1;else{const n=s(p);n&&(a.backupSchedule=n)}const m=b(i.backupRetentionDays);m!==void 0&&(a.backupRetentionDays=m);const f=S(i,g);return f.length>0&&(a.extraProperties=f),a}function h(t){if(t.length!==0)return t.map(e=>({name:e.resourceName,type:"ClickHouse",databaseName:e.databaseName,...k({instanceType:e.instanceType,coldTier:e.coldTier,optimiseSchedule:e.optimiseSchedule,backupSchedule:e.backupSchedule,backupRetentionDays:e.backupRetentionDays,variableName:e.variableName,extraProperties:e.extraProperties})}))}export{h as convertClickHouseResources,x as extractClickHouseFields};
@@ -1 +0,0 @@
1
- import*as i from"typescript";import{constIncludes as c}from"../schemas/constants.js";function o(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function x(n){return o(n)&&"__identifier"in n}function d(n){return o(n)&&"__expression"in n}function a(n){return o(n)&&"__call"in n}function f(n){return o(n)&&!("__identifier"in n)&&!("__expression"in n)&&!("__call"in n)&&!("__unknown"in n)}function y(n){return typeof n=="string"?n:void 0}function m(n){return typeof n=="number"?n:void 0}function _(n){return typeof n=="boolean"?n:void 0}function b(n){if(!Array.isArray(n))return;const e=[];for(const r of n)typeof r=="string"&&e.push(r);return e.length>0?e:void 0}function A(n,e){const r=y(n);if(r!==void 0)return c(e,r)?r:void 0}function g(n){const e={};for(const[r,t]of Object.entries(n))t!==void 0&&(e[r]=t);return e}function p(n){if(n===null)return"null";if(n===void 0)return"undefined";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return String(n);if(Array.isArray(n))return`[${n.map(p).join(", ")}]`;if(!o(n))return String(n);if(x(n))return n.__identifier;if(d(n))return n.__expression;if(a(n))return n.__call;if("__unknown"in n&&typeof n.__unknown=="string")return n.__unknown;const e=Object.entries(n);return e.length===0?"{}":`{ ${e.map(([t,s])=>`${t}: ${p(s)}`).join(", ")} }`}function h(n,e){const r=[];for(const[t,s]of Object.entries(n))e.has(t)||s===void 0||r.push({key:t,sourceText:p(s)});return r}function j(n,e){return i.isPropertyAssignment(n)&&i.isIdentifier(n.name)&&n.name.text===e}function O(n){return i.isCallExpression(n)&&i.isPropertyAccessExpression(n.expression)&&n.expression.name.text==="getApp"&&i.isIdentifier(n.expression.expression)&&n.expression.expression.text==="App"}function C(n,e){const{expression:r}=n;return i.isPropertyAccessExpression(r)&&r.name.text===e&&n.arguments.length>0}function E(n,e){let r;const t=s=>{r===void 0&&(r=e(s),r===void 0&&i.forEachChild(s,t))};return t(n),r}function P(n,e){const r=[],t=s=>{const u=e(s);u!==null&&r.push(u),i.forEachChild(s,t)};return t(n),r}function S(n,e){return i.isCallExpression(n)&&i.isPropertyAccessExpression(n.expression)&&n.expression.name.text==="build"&&i.isIdentifier(n.expression.expression)&&n.expression.expression.text===e}function I(n){const e=n.parent;if(i.isVariableDeclaration(e)&&i.isIdentifier(e.name))return e.name.text}const k=()=>n=>n;function F(n){if(n!=null){if(n===!1)return!1;if(typeof n=="object"&&!Array.isArray(n))return n}}function V(n,e){return n===!1?!1:f(n)?e(n):void 0}function w(n,e){return f(n)?e(n):void 0}function N(n,e,r){const t=n[e];return f(t)?r(t):void 0}import{parseObjectLiteral as B,evaluateExpression as R,findVariableValue as D,findObjectDeclaration as L,evaluatePropertyAccess as U,resolveTemplateLiteral as G}from"./astExpressionEvaluator.js";export{_ as asBoolean,m as asNumber,F as asObjectOrFalse,y as asString,b as asStringArray,A as asStringUnion,h as captureExtraProperties,P as collectFromAst,R as evaluateExpression,U as evaluatePropertyAccess,N as extractSubConfig,I as extractVariableName,E as findFirstInAst,L as findObjectDeclaration,D as findVariableValue,O as isAppGetAppCall,a as isCallRef,d as isExpressionRef,S as isFactoryBuildCall,C as isFactoryMethodCall,x as isIdentifierRef,j as isNamedProperty,f as isParsedObject,o as isPlainObject,g as omitUndefined,V as parseBooleanOrConfig,B as parseObjectLiteral,w as parseOptionalConfig,p as parsedValueToSourceText,G as resolveTemplateLiteral,k as typed};
@@ -1 +0,0 @@
1
- import{isIdentifierRef as s,isParsedObject as f}from"./astCommonParser.js";const c=10;function d(n,r){return Array.isArray(n)?n.filter(s).map(e=>r.find(t=>t.variableName===e.__identifier)).filter(e=>e!==void 0).map(e=>e.resourceName):[]}function _(n,r){return Array.isArray(n)?n.filter(s).map(e=>r.find(t=>t.variableName===e.__identifier)).filter(e=>e!==void 0).map(e=>e.resourceName):[]}function m(n,r,e){if(!Array.isArray(r)||r.length===0)return;const t=r[0];if(!f(t))return;const i=t.containers;if(!Array.isArray(i)||i.length===0)return;const o=i[0];if(!f(o)||!f(o.environment))return;const a=o.environment;(a.DATABASE_HOST||a.DATABASE_PORT||a.DATABASE_NAME)&&(n.needsConnection=!0,e.length>0&&(n.connectedDatabase??[]).length===0&&(n.connectedDatabase=[e[0].name]));for(let A=1;A<=c;A++)(a[`DATABASE_HOST_${A}`]||a[`DATABASE_PORT_${A}`]||a[`DATABASE_NAME_${A}`])&&(n.needsConnection=!0)}function S(n,r,e){if(!Array.isArray(r)||r.length===0)return;const t=r[0];if(!f(t))return;const i=t.containers;if(!Array.isArray(i)||i.length===0)return;const o=i[0];if(!f(o)||!f(o.environment))return;o.environment.BUCKET_NAME&&e.length>0&&(n.connectedStorage??[]).length===0&&(n.connectedStorage=[e[0].name])}export{m as inferDatabaseConnectionsFromEnv,S as inferStorageConnectionsFromEnv,d as resolveConnectedDatabaseNames,_ as resolveConnectedStorageNames};
@@ -1 +0,0 @@
1
- import*as l from"typescript";import{asString as a,asNumber as S,asBoolean as h,asStringArray as u,asStringUnion as g,captureExtraProperties as v,collectFromAst as m,extractVariableName as T,isFactoryBuildCall as _,isFactoryMethodCall as b,isParsedObject as d,parseObjectLiteral as A}from"./astCommonParser.js";import{COMPUTE_ARCHITECTURES as x,COMPUTE_TYPES as O,DEPLOYMENT_TYPES as D,EC2_INSTANCE_TYPES as R,FUNCTION_URL_AUTH_TYPES as Y}from"../schemas/constants.js";import{assignIfDefined as c,extractCallStringArg as K,extractClusterConfig as U,extractEnumString as E,isEnvironmentRecord as C,parseEcsService as F}from"./astComputeParserHelpers.js";import{inferDatabaseConnectionsFromEnv as L,inferStorageConnectionsFromEnv as k,resolveConnectedDatabaseNames as H,resolveConnectedStorageNames as V}from"./astComputeConnectionParser.js";function M(e){if(e.arguments.length<2)return null;const n=e.arguments[0],i=e.arguments[1];if(!l.isStringLiteral(n)||!l.isObjectLiteralExpression(i))return null;const t=n.text,r=A(i);return{resourceName:t,type:a(r.type)??"ecs",config:r,node:e}}function J(e){return m(e,n=>{if(!l.isCallExpression(n)||!b(n,"addCompute"))return null;const i=n.arguments[0];if(!_(i,"ComputeFactory"))return null;const t=M(i);if(t){const r=T(n);r&&(t.variableName=r)}return t})}function N(e,n,i){const t=v(e.config,i);t.length>0&&(n.extraProperties=t)}function W(e,n){const i=e.config.docker;if(d(i)){const o=a(i.path),f=a(i.context),y=a(i.target);(o!==void 0||f!==void 0||y!==void 0)&&(n.docker={...o!==void 0&&{path:o},...f!==void 0&&{context:f},...y!==void 0&&{target:y}})}const t=e.config.cluster;t!==void 0&&(n.cluster=U(t));const r=e.config.services;r!==void 0&&Array.isArray(r)&&(n.services=r.filter(o=>d(o)).map(F)),N(e,n,new Set(["type","ecrRepository","docker","cluster","services","connections"]))}function z(e,n){if(c(n,"deployment",g(e.config.deployment,D)),c(n,"timeout",S(e.config.timeout)),c(n,"memory",S(e.config.memorySize)??S(e.config.memory)),c(n,"handler",a(e.config.handler)),c(n,"runtime",E(e.config.runtime,"Runtime")),C(e.config.environment)&&(n.environment=e.config.environment),C(e.config.secrets))n.secrets=e.config.secrets;else{const s=u(e.config.secrets);s&&(n.ssmSecrets=s)}const i=e.config.functionUrl;if(d(i)){const s=g(E(i.authType,"FunctionUrlAuthType"),Y);s!==void 0&&(n.functionUrl={authType:s})}const t=e.config.code;if(t!==void 0){const s=K(t);s&&(n.codePath=s)}c(n,"description",a(e.config.lambdaDescription)),c(n,"architecture",g(E(e.config.architecture,"Architecture"),x)),c(n,"ephemeralStorageSize",S(e.config.ephemeralStorageSize)),c(n,"functionName",a(e.config.functionName)),c(n,"ssmSecretsPath",a(e.config.ssmSecretsPath)),N(e,n,new Set(["type","deployment","timeout","memorySize","memory","handler","runtime","environment","secrets","functionUrl","code","connections","ecrRepository","containerSecretsImport","lambdaDescription","architecture","ephemeralStorageSize","functionName","ssmSecretsPath"]))}function I(e,n){c(n,"instanceType",g(e.config.instanceType,R));const i=e.config.ssh;i===!1?n.enableSSH=!1:i!==void 0&&d(i)?n.enableSSH=!0:c(n,"enableSSH",h(e.config.enableSSH)),c(n,"keyName",a(e.config.keyName)),c(n,"userData",a(e.config.userData)),e.config.securityGroups!==void 0&&(n.securityGroups=u(e.config.securityGroups)),N(e,n,new Set(["type","instanceType","ssh","enableSSH","keyName","userData","securityGroups","connections"]))}function B(e,n,i,t){let r=n.config.connections;if(!r&&Array.isArray(n.config.services)){const f=n.config.services[0];d(f)&&(r=f.connections)}if(!r)return;const s=H(r,i);s.length>0&&(e.needsConnection=!0,e.connectedDatabase=s);const o=V(r,t);o.length>0&&(e.connectedStorage=o)}function G(e,n){({ecs:W,lambda:z,ec2:I})[e.type]?.(n,e)}function Q(e,n,i,t){return e.map(r=>{const s=g(r.config.type,O)??"ecs",o={name:r.resourceName,type:s,needsConnection:!1,connectedDatabase:[],...r.variableName&&{variableName:r.variableName}};return B(o,r,n,i),G(o,r),L(o,r.config.services,t.database),k(o,r.config.services,t.s3),o})}export{Q as convertComputeResources,J as findComputeResources};
@@ -1 +0,0 @@
1
- import{isPlainObject as u,isParsedObject as o,isExpressionRef as S,isCallRef as y,asString as r,asNumber as i,asBoolean as p,asStringArray as c,asStringUnion as m,captureExtraProperties as d}from"./astCommonParser.js";import{ECS_CAPACITY_PROVIDERS as C,LOAD_BALANCER_TYPES as h,SCALING_TYPES as E,AMI_HARDWARE_TYPES as P}from"../schemas/constants.js";function _(e){return e!==void 0&&u(e)}function x(e){if(!o(e))return;const n={};for(const[t,a]of Object.entries(e))if(o(a)){const s=r(a.id),f=r(a.name);s&&f&&(n[t]={id:s,name:f,field:r(a.field)})}return Object.keys(n).length>0?n:void 0}function A(e){if(!o(e))return;const n=c(e.command);if(!(!n||n.length===0))return{command:n,interval:i(e.interval),timeout:i(e.timeout),retries:i(e.retries),startPeriod:i(e.startPeriod)}}function N(e){const t=d(e,new Set(["name","image","port","environment","essential","command","entryPoint","secretsImport","secrets","healthCheck"]));return{name:r(e.name),image:r(e.image),port:i(e.port),environment:_(e.environment)?e.environment:void 0,essential:p(e.essential),command:c(e.command),entryPoint:c(e.entryPoint),secretsImport:x(e.secretsImport),ssmSecrets:c(e.secrets),healthCheck:A(e.healthCheck),extraProperties:t.length>0?t:void 0}}function g(e){if(Array.isArray(e))return e.filter(o).map(n=>({path:r(n.path),host:r(n.host),priority:i(n.priority),healthCheckPath:r(n.healthCheckPath)}));if(o(e))return{path:r(e.path),host:r(e.host),priority:i(e.priority),healthCheckPath:r(e.healthCheckPath)}}function O(e){if(e===!1)return!1;if(o(e))return{minCapacity:i(e.minCapacity),maxCapacity:i(e.maxCapacity),desiredCount:i(e.desiredCount),scalingType:m(e.scalingType,E)}}const T=new Set(["instanceType","amiHardwareType","minCapacity","maxCapacity","memoryLimitMiB","warmPool"]);function I(e){if(!o(e))return;const n=e.warmPool,t=o(n)?{minSize:i(n.minSize),reuseOnScaleIn:p(n.reuseOnScaleIn)}:void 0,a=d(e,T);return{instanceType:r(e.instanceType),amiHardwareType:m(e.amiHardwareType,P),minCapacity:i(e.minCapacity),maxCapacity:i(e.maxCapacity),memoryLimitMiB:i(e.memoryLimitMiB),warmPool:t,extraProperties:a.length>0?a:void 0}}const R=new Set(["domain","loadBalancer","directAccess"]);function w(e){if(!o(e))return;const n=e.loadBalancer,t=d(e,R);return{domain:r(e.domain),loadBalancer:n===!1?!1:m(n,h),directAccess:p(e.directAccess),...t.length>0&&{extraProperties:t}}}function L(e){const n=e.containers,t=Array.isArray(n)?n.filter(o).map(N):void 0,s=d(e,new Set(["name","image","docker","ssmSecretsPath","containers","routing","connections","cpu","memoryLimitMiB","desiredCount","scaling","capacityProvider","ec2Config"]));return{name:r(e.name)??"",image:r(e.image),docker:l(e.docker),ssmSecretsPath:r(e.ssmSecretsPath),containers:t,routing:g(e.routing),cpu:i(e.cpu),memoryLimitMiB:i(e.memoryLimitMiB),desiredCount:i(e.desiredCount),scaling:O(e.scaling),capacityProvider:m(e.capacityProvider,C)??"FARGATE",ec2Config:I(e.ec2Config),...s.length>0&&{extraProperties:s}}}function l(e){if(!o(e))return;const n=r(e.path);if(n===void 0)return;const t=r(e.context),a=r(e.target);return{path:n,...t!==void 0&&{context:t},...a!==void 0&&{target:a}}}function Y(e,n){const t=r(e);if(t)return t;if(S(e)&&e.__expression.startsWith(n+"."))return e.__expression.slice(n.length+1)}function k(e){return y(e)?e.__call.match(/\(\s*"([^"]+)"\s*\)/)?.[1]:void 0}function W(e,n,t){t!==void 0&&(e[n]=t)}export{W as assignIfDefined,k as extractCallStringArg,w as extractClusterConfig,Y as extractEnumString,_ as isEnvironmentRecord,L as parseEcsService};
@@ -1 +0,0 @@
1
- import*as c from"typescript";import{constIncludes as b,DATABASE_ENGINES as x}from"../schemas/constants.js";import{asBoolean as p,asNumber as u,asString as o,asStringArray as A,captureExtraProperties as I,collectFromAst as E,extractVariableName as S,isCallRef as R,isFactoryBuildCall as h,isFactoryMethodCall as D,omitUndefined as N,parseObjectLiteral as w,parseOptionalConfig as d,parseBooleanOrConfig as g,resolveTemplateLiteral as v,typed as l}from"./astCommonParser.js";import{extractDynamoDBFields as C}from"./astDynamoDBParser.js";import{extractClickHouseFields as P}from"./astClickHouseParser.js";import{convertDynamoDBResources as j}from"./astDynamoDBParser.js";import{convertClickHouseResources as V}from"./astClickHouseParser.js";function T(r){const e=o(r.databaseEngine);if(e!==void 0&&b(x,e))return e;const i=r.engine;if(R(i)){const t=String(i.__call);if(t.includes("postgres")||t.includes("auroraPostgres"))return"postgresql";if(t.includes("mysql")||t.includes("auroraMysql"))return"mysql"}}function W(r){const e=r.engine;if(R(e))return String(e.__call)}const B=new Set(["type","databaseName","databaseEngine","engine","vpc","port","deletionProtection","instanceType","multiAz","publiclyAccessible","enableSecretRotation","encryption","databaseInsights","proxy","readReplica","credentials","writer","readers","backupRetention","preferredMaintenanceWindow","primaryRegion","secondaryRegions","globalClusterIdentifier","enableGlobalWriteForwarding","snapshotIdentifier","allocatedStorage","monitoringInterval","snapshotUsername"]);function F(r,e,i){if(i.arguments.length<2)return null;const t=i.arguments[0],a=i.arguments[1];if(!c.isStringLiteral(t)&&!c.isTemplateExpression(t))return null;const s=c.isStringLiteral(t)?t.text:v(r,t);if(!c.isObjectLiteralExpression(a))return null;const n=w(a),m={resourceName:s,type:o(n.type)??"",databaseName:o(n.databaseName)??"",databaseEngine:T(n),engineExpression:W(n),port:u(n.port),deletionProtection:p(n.deletionProtection),instanceType:o(n.instanceType),multiAz:p(n.multiAz),publiclyAccessible:p(n.publiclyAccessible),enableSecretRotation:p(n.enableSecretRotation),encryption:d(n.encryption,l()),databaseInsights:g(n.databaseInsights,l()),proxy:g(n.proxy,l()),readReplica:g(n.readReplica,l()),credentials:d(n.credentials,l()),writer:d(n.writer,l()),readers:g(n.readers,l()),backupRetention:u(n.backupRetention),preferredMaintenanceWindow:o(n.preferredMaintenanceWindow),primaryRegion:o(n.primaryRegion),secondaryRegions:A(n.secondaryRegions),globalClusterIdentifier:o(n.globalClusterIdentifier),enableGlobalWriteForwarding:p(n.enableGlobalWriteForwarding),allocatedStorage:u(n.allocatedStorage),monitoringInterval:u(n.monitoringInterval),snapshotIdentifier:o(n.snapshotIdentifier),snapshotUsername:o(n.snapshotUsername),node:e},f=S(e);f&&(m.variableName=f);const y=I(n,B);return y.length>0&&(m.extraProperties=y),m}function z(r){return E(r,e=>{if(!c.isCallExpression(e)||!D(e,"addDatabase"))return null;const i=e.arguments[0];return h(i,"DatabaseFactory")?F(r,e,i):null})}function O(r){const e=[],i=[],t=[];for(const a of r)if(a.type==="DynamoDB"){const s=C(a);s&&i.push(s)}else if(a.type==="ClickHouse"){const s=P(a);s&&t.push(s)}else e.push(a);return{databases:e,dynamodb:i,clickhouse:t}}const k=["Instance","Aurora","GlobalAurora"];function q(r){return r.filter(e=>e.type!=="DynamoDB").map(e=>({name:e.resourceName,type:b(k,e.type)?e.type:"Instance",databaseName:e.databaseName,...N({port:e.port,deletionProtection:e.deletionProtection,instanceType:e.instanceType,multiAz:e.multiAz,publiclyAccessible:e.publiclyAccessible,enableSecretRotation:e.enableSecretRotation,encryption:e.encryption,databaseInsights:e.databaseInsights,proxy:e.proxy,readReplica:e.readReplica,credentials:e.credentials,writer:e.writer,readers:e.readers,backupRetention:e.backupRetention,preferredMaintenanceWindow:e.preferredMaintenanceWindow,primaryRegion:e.primaryRegion,secondaryRegions:e.secondaryRegions,globalClusterIdentifier:e.globalClusterIdentifier,enableGlobalWriteForwarding:e.enableGlobalWriteForwarding,allocatedStorage:e.allocatedStorage,monitoringInterval:e.monitoringInterval,variableName:e.variableName,databaseEngine:e.databaseEngine,engineExpression:e.engineExpression,extraProperties:e.extraProperties})}))}export{V as convertClickHouseResources,q as convertDatabaseResources,j as convertDynamoDBResources,z as findDatabaseResources,O as splitDatabaseResources};
@@ -1 +0,0 @@
1
- import*as l from"typescript";import{parseObjectLiteral as x,asString as c,asStringUnion as y,asStringArray as k,asBoolean as h,asNumber as N,isCallRef as T,isParsedObject as g}from"./astCommonParser.js";import{success as a,failure as u}from"../types/Result.js";import{DnsRecordTypeSchema as $}from"../dns/types.js";import{DomainRegistrarSchema as I,AliasRecordTypeSchema as D,TYPED_FJALL_TARGET_KINDS as R}from"../dns/domainRecords.js";const _=I.options,E=$.options,L=D.options;function U(e){const n=[],t=i=>{if(l.isNewExpression(i)&&j(i.expression)){const o=v(i);o!==void 0&&n.push(o)}l.forEachChild(i,t)};if(t(e),n.length===0)return a(void 0);if(n.length>1)return u(new Error(`Expected exactly one 'new Domain(...)' call per infrastructure file, found ${n.length}`));const r=n[0];return r?a(r):a(void 0)}function j(e){return l.isIdentifier(e)&&e.text==="Domain"}function v(e){const n=e.arguments;if(!n||n.length<3)return;const t=n[0],r=n[1],i=n[2];if(!t||!r||!i||!l.isObjectLiteralExpression(i))return;const o=O(e);if(o===void 0)return;const d=C(e),s=l.isStringLiteral(r)?r.text:void 0;return{callExpression:e,containingStatement:o,propsObjectLiteral:i,domainVarId:d,scopeArgumentText:t.getText(),constructIdLiteral:s}}function O(e){let n=e;for(;n!==void 0;){if(l.isExpressionStatement(n)||l.isVariableStatement(n))return n;n=n.parent}}function C(e){let n=e.parent;for(;n!==void 0;){if(l.isVariableDeclaration(n)&&l.isIdentifier(n.name)&&n.initializer===e)return n.name.text;n=n.parent}}function Z(e){switch(e.kind){case"registrar_required":return"'registrar' property is required";case"registrar_unsupported":return`'registrar' must be one of ${_.join(", ")}, got ${JSON.stringify(e.value)}`;case"missing_field":return`'${e.field}' property is required`;case"invalid_literal":return`'${e.field}' ${e.reason}`}}function H(e){const n=x(e),t=y(n.registrar,_);if(t===void 0){const s=n.registrar;if(s===void 0)return u({kind:"registrar_required"});const f=typeof s=="string"?s:p(s);return u({kind:"registrar_unsupported",value:f})}const r=c(n.zoneName);if(r===void 0)return u({kind:"missing_field",field:"zoneName"});const i=V(n.records);if(!i.success)return i;const o=M(n.certificates);if(!o.success)return o;const d={zoneName:r,description:c(n.description),costAllocationEnvironment:c(n.costAllocationEnvironment),tags:Y(n.tags),records:i.data,certificates:o.data};switch(t){case"route53":{const s=S(n.delegations);return s.success?a({...d,registrar:t,hostedZoneId:c(n.hostedZoneId),delegations:s.data}):s}case"external-delegated":{const s=c(n.delegatedSubdomain);if(s===void 0)return u({kind:"missing_field",field:"delegatedSubdomain"});const f=S(n.delegations);return f.success?a({...d,registrar:t,delegatedSubdomain:s,delegations:f.data}):f}case"external-records":return a({...d,registrar:t})}}function Q(e){return Z(e)}function V(e){if(e===void 0)return a([]);if(!Array.isArray(e))return u({kind:"invalid_literal",field:"records",reason:"must be an array"});const n=[];for(let t=0;t<e.length;t++){const r=e[t];if(!g(r))return u({kind:"invalid_literal",field:`records[${t}]`,reason:"must be an object literal"});const i=P(r,t);if(!i.success)return i;n.push(i.data)}return a(n)}function P(e,n){const t=c(e.type),r=c(e.name);if(t===void 0)return u({kind:"missing_field",field:`records[${n}].type`});if(r===void 0)return u({kind:"missing_field",field:`records[${n}].name`});if(e.target!==void 0){if(!L.some(f=>f===t))return u({kind:"invalid_literal",field:`records[${n}]`,reason:`alias records must have type 'A' or 'AAAA', got '${t}'`});const s=q(e.target);return a({kind:"alias",type:t,name:r,target:s})}if(!E.some(s=>s===t))return u({kind:"invalid_literal",field:`records[${n}]`,reason:`unsupported record type '${t}'`});const i=z(e.value);if(i===void 0)return u({kind:"invalid_literal",field:`records[${n}].value`,reason:`must be a string or array of strings (got ${JSON.stringify(e.value)})`});const o=N(e.ttl),d={kind:"standard",type:t,name:r,value:i,...o!==void 0?{ttl:o}:{}};return a(d)}function z(e){if(e===void 0)return;if(typeof e=="string")return e;const n=k(e);if(n!==void 0)return n}function q(e){if(T(e))return J(e);if(g(e)){const n=y(e.kind,R);if(n==="ecs"||n==="cdn"){const t=c(e.appName);if(t!==void 0)return{kind:n,appName:t}}if(n==="bucket"){const t=c(e.bucketName);if(t!==void 0)return{kind:n,bucketName:t}}if(n==="custom"){const t=c(e.dnsName),r=c(e.hostedZoneId);if(t!==void 0&&r!==void 0)return{kind:n,dnsName:t,hostedZoneId:r}}}return{kind:"unresolved",sourceText:p(e)}}function J(e){const n=e.__call.trim(),t=n.match(/^([A-Za-z_][\w$]*)\s*\(([\s\S]*)\)\s*$/);if(!t)return{kind:"unresolved",sourceText:n};const r=t[1],i=t[2]??"",o=A(i);switch(r){case"fjallApp":{const d=m(o,0);return d===void 0?{kind:"dynamic",sourceText:n}:{kind:"ecs",appName:d}}case"fjallCdn":{const d=m(o,0);return d===void 0?{kind:"dynamic",sourceText:n}:{kind:"cdn",appName:d}}case"fjallBucket":{const d=m(o,0);return d===void 0?{kind:"dynamic",sourceText:n}:{kind:"bucket",bucketName:d}}case"aliasTo":{if(o.length>=2){const d=m(o,0),s=m(o,1);return d!==void 0&&s!==void 0?{kind:"custom",dnsName:d,hostedZoneId:s}:{kind:"dynamic",sourceText:n}}if(o.length===1){const d=o[0]?.trim()??"",s=b(d,"dnsName"),f=b(d,"hostedZoneId");return s!==void 0&&f!==void 0?{kind:"custom",dnsName:s,hostedZoneId:f}:{kind:"dynamic",sourceText:n}}return{kind:"unresolved",sourceText:n}}default:return{kind:"unresolved",sourceText:n}}}function A(e){const n=[];let t=0,r=null,i="";for(let d=0;d<e.length;d++){const s=e[d];if(r!==null){if(i+=s,s==="\\"&&d+1<e.length){const f=e[d+1];f!==void 0&&(i+=f,d+=1);continue}s===r&&(r=null);continue}if(s==='"'||s==="'"||s==="`"){r=s,i+=s;continue}if(s==="("||s==="{"||s==="["){t+=1,i+=s;continue}if(s===")"||s==="}"||s==="]"){t-=1,i+=s;continue}if(s===","&&t===0){n.push(i.trim()),i="";continue}i+=s}const o=i.trim();return o.length>0&&n.push(o),n}function m(e,n){const t=e[n];if(t===void 0)return;const r=t.trim();if(r.length<2)return;const i=r[0],o=r[r.length-1];if(i===o&&!(i!=='"'&&i!=="'"&&i!=="`"))return r.slice(1,-1)}function b(e,n){const t=e.trim().replace(/^\{|\}$/g,""),r=A(t);for(const i of r){const o=i.indexOf(":");if(o<0||i.slice(0,o).trim().replace(/["'`]/g,"")!==n)continue;const s=i.slice(o+1).trim();return m([s],0)}}function M(e){if(e===void 0)return a([]);if(!Array.isArray(e))return u({kind:"invalid_literal",field:"certificates",reason:"must be an array"});const n=[];for(let t=0;t<e.length;t++){const r=e[t];if(typeof r=="string"){n.push({domainName:r});continue}if(!g(r))return u({kind:"invalid_literal",field:`certificates[${t}]`,reason:"must be a string or object literal"});const i=c(r.domainName);if(i===void 0)return u({kind:"missing_field",field:`certificates[${t}].domainName`});const o=k(r.subjectAlternativeNames),d=h(r.transparencyLogging);n.push({domainName:i,...o!==void 0?{subjectAlternativeNames:o}:{},...d!==void 0?{transparencyLogging:d}:{}})}return a(n)}function S(e){if(e===void 0)return a([]);if(!Array.isArray(e))return u({kind:"invalid_literal",field:"delegations",reason:"must be an array"});const n=[];for(let t=0;t<e.length;t++){const r=e[t];if(!g(r))return u({kind:"invalid_literal",field:`delegations[${t}]`,reason:"must be an object literal"});const i=c(r.subdomain),o=c(r.toAccount);if(i===void 0)return u({kind:"missing_field",field:`delegations[${t}].subdomain`});if(o===void 0)return u({kind:"missing_field",field:`delegations[${t}].toAccount`});const d=h(r.auto);n.push({subdomain:i,toAccount:o,...d!==void 0?{auto:d}:{}})}return a(n)}function Y(e){if(e===void 0||!g(e))return;const n={};for(const[t,r]of Object.entries(e)){const i=c(r);i!==void 0&&(n[t]=i)}return Object.keys(n).length===0?void 0:n}function p(e){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`[${e.map(n=>p(n)).join(", ")}]`;if(typeof e=="object"){if("__call"in e)return String(e.__call);if("__identifier"in e)return String(e.__identifier);if("__expression"in e)return String(e.__expression);if("__unknown"in e)return String(e.__unknown)}return String(e)}export{U as findDomainConstructCall,Q as parseDomainErrorMessage,H as parseDomainProps,A as splitTopLevelArgs};
@@ -1 +0,0 @@
1
- import*as s from"typescript";import{asBoolean as A,asString as l,asStringUnion as S,captureExtraProperties as D,isParsedObject as b,omitUndefined as B,parseObjectLiteral as E}from"./astCommonParser.js";const O=["S","N","B"];function a(t){if(!b(t))return;const e=l(t.name),i=S(t.type,O);if(!(!e||!i))return{name:e,type:i}}function P(t){const e=t.node;if(!s.isCallExpression(e))return null;const i=e.arguments[0];if(!s.isCallExpression(i)||i.arguments.length<2)return null;const u=i.arguments[1];if(!s.isObjectLiteralExpression(u))return null;const r=E(u),c=a(r.partitionKey);if(!c)return null;const n={resourceName:t.resourceName,partitionKey:c,node:t.node};t.variableName&&(n.variableName=t.variableName);const m=a(r.sortKey);if(m&&(n.sortKey=m),Array.isArray(r.globalSecondaryIndexes)){const p=r.globalSecondaryIndexes.filter(b).map(o=>{const K=a(o.partitionKey);if(!K)return null;const x=l(o.indexName);if(!x)return null;const N={indexName:x,partitionKey:K},g=a(o.sortKey);return g&&(N.sortKey=g),N}).filter(o=>o!==null);p.length>0&&(n.globalSecondaryIndexes=p)}const f=l(r.ttlAttribute);f&&(n.ttlAttribute=f);const d=A(r.stream);d!==void 0&&(n.stream=d);const y=D(r,new Set(["type","databaseName","partitionKey","sortKey","globalSecondaryIndexes","ttlAttribute","stream"]));return y.length>0&&(n.extraProperties=y),n}function _(t){if(t.length!==0)return t.map(e=>({name:e.resourceName,partitionKey:e.partitionKey,...B({sortKey:e.sortKey,globalSecondaryIndexes:e.globalSecondaryIndexes,ttlAttribute:e.ttlAttribute,stream:e.stream,variableName:e.variableName,extraProperties:e.extraProperties})}))}export{_ as convertDynamoDBResources,P as extractDynamoDBFields};
@@ -1 +0,0 @@
1
- import*as t from"typescript";import{findFirstInAst as l}from"./astCommonParser.js";function f(e){const n={};for(const i of e.properties){if(!t.isPropertyAssignment(i))continue;const r=t.isIdentifier(i.name)||t.isStringLiteral(i.name)?i.name.text:void 0;r!==void 0&&(n[r]=a(i.initializer))}return n}function a(e){if(t.isStringLiteral(e))return e.text;if(t.isNumericLiteral(e))return Number(e.text);if(e.kind===t.SyntaxKind.TrueKeyword)return!0;if(e.kind===t.SyntaxKind.FalseKeyword)return!1;if(t.isArrayLiteralExpression(e))return e.elements.map(n=>a(n));if(t.isObjectLiteralExpression(e))return f(e);if(t.isIdentifier(e))return{__identifier:e.text};if(t.isPropertyAccessExpression(e))return{__expression:e.getText()};if(t.isCallExpression(e))return{__call:e.getText()};if(t.isBinaryExpression(e)&&e.operatorToken.kind===t.SyntaxKind.BarBarToken){const n=a(e.left),i=a(e.right);return typeof i=="string"?i:n}else if(t.isConditionalExpression(e)){const n=a(e.whenTrue),i=a(e.whenFalse);return typeof i=="string"||typeof i=="number"?i:n}else if(t.isTemplateExpression(e)||t.isNoSubstitutionTemplateLiteral(e))return{__expression:e.getText()};return{__unknown:e.getText()}}function u(e,n){return l(e,i=>{if(t.isVariableStatement(i)){for(const r of i.declarationList.declarations)if(t.isIdentifier(r.name)&&r.name.text===n&&r.initializer){if(t.isStringLiteral(r.initializer))return r.initializer.text;if(t.isObjectLiteralExpression(r.initializer)){const s=f(r.initializer);return JSON.stringify(s)}}}})}function o(e,n){return l(e,i=>{if(t.isVariableStatement(i)){for(const r of i.declarationList.declarations)if(t.isIdentifier(r.name)&&r.name.text===n&&r.initializer&&t.isObjectLiteralExpression(r.initializer))return f(r.initializer)}})}function p(e,n){if(!t.isIdentifier(n.expression))return;const i=o(e,n.expression.text),r=n.name.text;if(i&&i[r]!==void 0)return String(i[r])}function c(e,n){let i=n.head.text;for(const r of n.templateSpans){if(t.isIdentifier(r.expression)){const s=u(e,r.expression.text);if(s)i+=s;else return n.getText(e).replace(/^`|`$/g,"")}else if(t.isPropertyAccessExpression(r.expression)){const s=p(e,r.expression);if(s)i+=s;else return n.getText(e).replace(/^`|`$/g,"")}else return n.getText(e).replace(/^`|`$/g,"");i+=r.literal.text}return i}export{a as evaluateExpression,p as evaluatePropertyAccess,o as findObjectDeclaration,u as findVariableValue,f as parseObjectLiteral,c as resolveTemplateLiteral};
@@ -1 +0,0 @@
1
- import*as s from"typescript";import{isPlainObject as fe,isIdentifierRef as me,isExpressionRef as ue,isCallRef as le,isParsedObject as de,asString as xe,asNumber as Re,asBoolean as ge,asStringArray as Ce,asStringUnion as Se,captureExtraProperties as be}from"./astCommonParser.js";import{findComputeResources as ye}from"./astComputeParser.js";import{findSchedules as he}from"./astScheduleParser.js";import{classifyStatements as Ae}from"./astStatementClassifier.js";import{extractCustomCodeBlocks as Ee,findManagedResourcePosition as Pe,getLastManagedStatementOfType as Te,getManagedResourcesByType as ve}from"./astStatementQueries.js";import{convertToResourcePlan as Le}from"./astPlanConverter.js";import{isAppGetAppCall as h,isExpressionRef as k,findFirstInAst as A,parseObjectLiteral as B,findVariableValue as E,evaluatePropertyAccess as P}from"./astCommonParser.js";import{findDatabaseResources as T,splitDatabaseResources as v}from"./astDatabaseParser.js";import{findS3Resources as V,findS3FactoryResources as L}from"./astStorageParser.js";import{findComputeResources as O}from"./astComputeParser.js";import{findSchedules as j}from"./astScheduleParser.js";import{findSQSResources as D}from"./astMessagingParser.js";import{findCDNResource as w}from"./astCdnParser.js";import{findVpcId as z,findNetworkConfig as F,findBackupConfig as M,findTunnelConfig as q,findNetworkResources as G}from"./astNetworkParser.js";import{findPatternResources as K}from"./astPatternParser.js";import{classifyStatements as Q}from"./astStatementClassifier.js";import{extractCustomCodeBlocks as U}from"./astStatementQueries.js";function ae(i,t){const e=s.createSourceFile("infrastructure.ts",i,s.ScriptTarget.Latest,!0,s.ScriptKind.TS),r=H(e),{appVariableName:o,appName:n}=W(e),c=z(e),a=F(e),f=M(e),m=q(e),u=G(e),l=T(e),{databases:d,dynamodb:x,clickhouse:R}=v(l),g=D(e),C=w(e),S=[...V(e),...L(e)],b=O(e),I=j(e),y=K(e),N=X(e),p={sourceFile:e,imports:r,appVariableName:o,appName:n,vpcId:c,network:a,backup:f,tunnel:m,networkResources:u,databaseResources:d,dynamodbResources:x,clickhouseResources:R,sqsResources:g,cdnResource:C,s3Resources:S,computeResources:b,schedules:I,patternResources:y,tags:N};return t?.extractCustomCode&&(p.customCodeBlocks=U(e),p.classifiedStatements=Q(e)),p}function H(i){const t=[];return s.forEachChild(i,e=>{if(s.isImportDeclaration(e)){if(!s.isStringLiteral(e.moduleSpecifier))return;const o={moduleSpecifier:e.moduleSpecifier.text,namedImports:[]};e.importClause&&(e.importClause.name&&(o.defaultImport=e.importClause.name.text),e.importClause.namedBindings&&s.isNamedImports(e.importClause.namedBindings)&&(o.namedImports=e.importClause.namedBindings.elements.map(n=>n.name.text))),t.push(o)}}),t}function J(i,t){return s.isStringLiteral(t)?t.text:s.isIdentifier(t)?E(i,t.text)??"":s.isPropertyAccessExpression(t)?P(i,t)??"":""}function W(i){return A(i,t=>{if(s.isVariableStatement(t))for(const e of t.declarationList.declarations){if(!e.initializer||!h(e.initializer))continue;const r=s.isIdentifier(e.name)?e.name.text:"",o=e.initializer.arguments.length>0?J(i,e.initializer.arguments[0]):"";return{appVariableName:r,appName:o}}})??{appVariableName:"",appName:""}}function X(i){const t={};function e(r){if(s.isCallExpression(r)&&s.isPropertyAccessExpression(r.expression)&&r.expression.name.text==="addTags"&&s.isIdentifier(r.expression.expression)&&r.arguments.length>0){const o=r.arguments[0];if(s.isObjectLiteralExpression(o)){const n=B(o);for(const[c,a]of Object.entries(n))typeof a=="string"?t[c]=a:k(a)&&(t[c]="default-value")}}s.forEachChild(r,e)}return e(i),t}export{ge as asBoolean,Re as asNumber,xe as asString,Ce as asStringArray,Se as asStringUnion,be as captureExtraProperties,Ae as classifyStatements,Le as convertToResourcePlan,Ee as extractCustomCodeBlocks,ye as findComputeResources,Pe as findManagedResourcePosition,he as findSchedules,Te as getLastManagedStatementOfType,ve as getManagedResourcesByType,le as isCallRef,ue as isExpressionRef,me as isIdentifierRef,de as isParsedObject,fe as isPlainObject,ae as parseInfrastructure};
@@ -1 +0,0 @@
1
- import*as o from"typescript";import{SqsRemovalPolicySchema as f}from"../schemas/messagingSchemas.js";import{asBoolean as u,asNumber as a,asString as m,captureExtraProperties as p,collectFromAst as S,extractVariableName as y,isFactoryBuildCall as g,isFactoryMethodCall as P,isParsedObject as x,omitUndefined as d,parseObjectLiteral as b}from"./astCommonParser.js";function v(e,t){if(t.arguments.length<2)return null;const n=t.arguments[0],s=t.arguments[1];if(!o.isStringLiteral(n)||!o.isObjectLiteralExpression(s))return null;const i=b(s),r={resourceName:n.text,queueType:m(i.queueType)??"standard",visibilityTimeout:a(i.visibilityTimeout),retentionPeriod:a(i.messageRetentionPeriod),contentBasedDeduplication:u(i.contentBasedDeduplication),removalPolicy:m(i.removalPolicy),node:e},c=y(e);c&&(r.variableName=c);const l=p(i,new Set(["type","queueType","visibilityTimeout","messageRetentionPeriod","contentBasedDeduplication","removalPolicy"]));return l.length>0&&(r.extraProperties=l),r}function Q(e){if(e!=null){if(e===!1)return!1;if(x(e))return d({enabled:u(e.enabled),maxReceiveCount:a(e.maxReceiveCount)})}}function h(e){return S(e,t=>{if(!o.isCallExpression(t)||!P(t,"addMessaging"))return null;const n=t.arguments[0];return g(n,"MessagingFactory")?v(t,n):null})}function D(e){if(e.length!==0)return e.map(t=>({name:t.resourceName,queueType:t.queueType==="fifo"?"fifo":"standard",...d({visibilityTimeout:t.visibilityTimeout,retentionPeriod:t.retentionPeriod,contentBasedDeduplication:t.contentBasedDeduplication,removalPolicy:T(t.removalPolicy),variableName:t.variableName,extraProperties:t.extraProperties})}))}const N=new Set(f.options);function R(e){return N.has(e)}function T(e){return e!==void 0&&R(e)?e:void 0}export{D as convertSQSResources,h as findSQSResources,Q as parseDeadLetterQueueConfig};
@@ -1 +0,0 @@
1
- import*as r from"typescript";import{constIncludes as E,BACKUP_VAULT_TIERS as z}from"../schemas/constants.js";import{FlowLogDestinationSchema as A}from"../schemas/networkSchemas.js";import{asNumber as d,asString as p,collectFromAst as N,extractVariableName as O,findFirstInAst as f,isAppGetAppCall as u,isFactoryBuildCall as k,isFactoryMethodCall as F,isNamedProperty as a,isParsedObject as b,omitUndefined as l,parseObjectLiteral as c,parseBooleanOrConfig as x}from"./astCommonParser.js";const S=new Set(A.options);function T(n){if(n!==void 0)return S.has(n)?n:void 0}function w(n){return{maxAzs:d(n.maxAzs),natGateways:x(n.natGateways,e=>({count:d(e.count)})),flowLogs:x(n.flowLogs,e=>({destination:p(e.destination),retentionDays:d(e.retentionDays)})),vpcEndpoints:b(n.vpcEndpoints)?n.vpcEndpoints:void 0}}function h(n,e){if(e.arguments.length<2)return null;const t=e.arguments[0],i=e.arguments[1];if(!r.isStringLiteral(t))return null;const o=t.text,s=r.isObjectLiteralExpression(i)?c(i):{},L=w(s),g={name:o,config:l({...L}),node:n},m=O(n);return m&&(g.variableName=m),g}function v(n){return f(n,e=>{if(!u(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(a(i,"network")&&r.isObjectLiteralExpression(i.initializer)){for(const o of i.initializer.properties)if(a(o,"useExisting")&&r.isStringLiteral(o.initializer))return o.initializer.text}}})}function D(n){return f(n,e=>{if(!u(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(a(i,"network")){if(i.initializer.kind===r.SyntaxKind.FalseKeyword)return;if(r.isObjectLiteralExpression(i.initializer)&&!i.initializer.properties.some(s=>a(s,"useExisting"))){const s=c(i.initializer);return w(s)}}}})}function G(n){return f(n,e=>{if(!u(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(a(i,"backup")){if(i.initializer.kind===r.SyntaxKind.FalseKeyword)return!1;if(r.isObjectLiteralExpression(i.initializer)){const o=c(i.initializer),s=p(o.tier);if(s)return{tier:s}}}}})}function I(n){return f(n,e=>{if(!u(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(a(i,"tunnel")){if(i.initializer.kind===r.SyntaxKind.FalseKeyword)return!1;if(i.initializer.kind===r.SyntaxKind.TrueKeyword)return!0;if(r.isObjectLiteralExpression(i.initializer)){const o=c(i.initializer),s=p(o.instanceType);return s?{instanceType:s}:{}}}}})}function B(n){return N(n,e=>{if(!r.isCallExpression(e)||!F(e,"addNetwork"))return null;const t=e.arguments[0];return k(t,"NetworkFactory")?h(e,t):null})}function y(n){const e=n.flowLogs;return{...l({maxAzs:n.maxAzs,natGateways:n.natGateways,vpcEndpoints:n.vpcEndpoints}),...e!==void 0&&{flowLogs:e===!1?!1:l({destination:T(e.destination),retentionDays:e.retentionDays})}}}function U(n){if(n)return y(n)}function P(n){if(n===void 0)return;if(n===!1)return!1;const e=n.tier;if(E(z,e))return{tier:e}}function _(n){if(n===void 0)return;if(n===!1)return!1;if(n===!0)return{};const e={};return n.instanceType&&(e.instanceType=n.instanceType),e}function V(n){if(!(!n||n.length===0))return n.map(e=>({name:e.name,...y(e.config)}))}export{y as buildNetworkFields,V as convertAdditionalNetworks,P as convertBackupConfig,U as convertNetworkConfig,_ as convertTunnelConfig,G as findBackupConfig,D as findNetworkConfig,B as findNetworkResources,I as findTunnelConfig,v as findVpcId};
@@ -1 +0,0 @@
1
- import*as l from"typescript";import{asBoolean as c,asNumber as r,asString as o,asStringArray as v,asStringUnion as y,asObjectOrFalse as g,collectFromAst as C,extractSubConfig as s,extractVariableName as A,isFactoryBuildCall as P,isFactoryMethodCall as h,isParsedObject as I,parseObjectLiteral as O,parseOptionalConfig as a,typed as p}from"./astCommonParser.js";import{parseDeadLetterQueueConfig as L}from"./astMessagingParser.js";const N=["Instance","Aurora"],z=["postgresql","mysql"];function f(n){if(!I(n))return;const e={...n.memorySize!==void 0&&{memorySize:r(n.memorySize)},...n.timeout!==void 0&&{timeout:r(n.timeout)},...n.ephemeralStorageSize!==void 0&&{ephemeralStorageSize:r(n.ephemeralStorageSize)}};return Object.keys(e).length>0?e:void 0}function w(n){return s(n,"database",e=>({type:y(e.type,N),databaseName:o(e.databaseName),databaseEngine:y(e.databaseEngine,z),deletionProtection:c(e.deletionProtection),backupRetention:r(e.backupRetention),port:r(e.port),publiclyAccessible:c(e.publiclyAccessible),allowedIpCidr:o(e.allowedIpCidr),instanceType:o(e.instanceType),allocatedStorage:r(e.allocatedStorage),multiAz:c(e.multiAz),allowVpcAccess:c(e.allowVpcAccess),monitoringInterval:r(e.monitoringInterval),preferredMaintenanceWindow:o(e.preferredMaintenanceWindow),snapshotIdentifier:o(e.snapshotIdentifier),snapshotUsername:o(e.snapshotUsername),readReplica:g(e.readReplica),writer:a(e.writer,p()),readers:g(e.readers),databaseInsights:g(e.databaseInsights),proxy:g(e.proxy),credentials:a(e.credentials,p()),encryption:a(e.encryption,p())}))}function E(n){return s(n,"compute",e=>({server:a(e.server,f),imageOptimisation:a(e.imageOptimisation,f),revalidation:a(e.revalidation,f)}))}function R(n){const e=t=>({versioned:c(t.versioned)});return s(n,"storage",t=>({assets:a(t.assets,e),cache:a(t.cache,e),media:a(t.media,e)}))}function D(n){return s(n,"messaging",e=>({revalidationQueue:a(e.revalidationQueue,t=>({visibilityTimeout:r(t.visibilityTimeout),messageRetentionPeriod:r(t.messageRetentionPeriod),maxMessageSize:r(t.maxMessageSize),deadLetterQueue:L(t.deadLetterQueue)}))}))}function M(n){return s(n,"cdn",e=>({domainNames:v(e.domainNames),certificateArn:o(e.certificateArn)}))}function T(n){return s(n,"environment",e=>{const t=Object.fromEntries(Object.entries(e).filter(m=>typeof m[1]=="string"));return Object.keys(t).length>0?t:void 0})}function V(n,e){if(n.arguments.length<2)return null;const t=n.arguments[0],m=n.arguments[1];if(!l.isStringLiteral(t)||!l.isObjectLiteralExpression(m))return null;const S=t.text,i=O(m),u=i.type;if(u!=="payload"&&u!=="nextjs")return null;const x=A(e),d=o(i.name);return d?{variableName:x,constructId:S,type:u,config:{name:d,domain:o(i.domain),database:w(i),compute:E(i),storage:R(i),messaging:D(i),cdn:M(i),environment:T(i)},node:n}:null}function F(n){return C(n,e=>{if(!l.isCallExpression(e)||!h(e,"addPattern"))return null;const t=e.arguments[0];return P(t,"PatternFactory")?V(t,e):null})}function Q(n,e){if(!e||e.length===0)return;const t=e[0];t.type!=="payload"&&t.type!=="nextjs"||(n.pattern=t.type,n.patternConfig={type:t.type,name:t.config.name,domain:t.config.domain,database:t.config.database,compute:t.config.compute,storage:t.config.storage,messaging:t.config.messaging,cdn:t.config.cdn,environment:t.config.environment})}export{Q as applyPatternConfig,F as findPatternResources};
@@ -1,2 +0,0 @@
1
- import{ApplicationResourcePlanSchema as s,getZodErrorMessage as u}from"../schemas/resourceSchemas.js";import{z as a}from"zod";import{COST_ALLOCATION_TAG as c}from"../generation/infrastructure.js";import{convertDatabaseResources as m,convertDynamoDBResources as f,convertClickHouseResources as l}from"./astDatabaseParser.js";import{convertS3Resources as p}from"./astStorageParser.js";import{convertComputeResources as d}from"./astComputeParser.js";import{convertSQSResources as R}from"./astMessagingParser.js";import{convertCDNResource as h}from"./astCdnParser.js";import{convertNetworkConfig as v,convertBackupConfig as g,convertTunnelConfig as k,convertAdditionalNetworks as I}from"./astNetworkParser.js";import{applyPatternConfig as b}from"./astPatternParser.js";import{KNOWN_FJALL_IMPORTS as S,isManagedModuleSpecifier as w}from"./astStatementClassifier.js";function y(e,r){for(const t of r){const o=e.compute.find(n=>n.variableName===t.targetVariableName);o!==void 0&&o.type==="lambda"&&(o.scheduleExpression=t.schedule)}}function N(e,r){Object.keys(r).length>0&&(e.tags={...r}),r[c]&&(e.owner=r[c])}function C(e){const r=[];for(const t of e)if(w(t.moduleSpecifier))if(t.moduleSpecifier==="@fjall/components-infrastructure"||t.moduleSpecifier==="@fjall/infrastructure"){const o=t.namedImports.filter(n=>!S.has(n));o.length>0&&r.push({moduleSpecifier:t.moduleSpecifier,namedImports:o,defaultImport:t.defaultImport})}else(t.namedImports.length>0||t.defaultImport)&&r.push(t);return r.length>0?r:void 0}function B(e,r,t){const o={appName:r,type:"standard",database:[],s3:[],compute:[]};if(b(o,e.patternResources),e.vpcId&&(o.vpcId=e.vpcId),o.network=v(e.network),o.backup=g(e.backup),o.tunnel=k(e.tunnel),o.additionalNetworks=I(e.networkResources),N(o,e.tags),o.database=m(e.databaseResources),o.dynamodb=f(e.dynamodbResources),o.clickhouse=l(e.clickhouseResources),o.sqs=R(e.sqsResources),o.cdn=h(e.cdnResource,e.s3Resources,e.computeResources),o.s3=p(e.s3Resources),o.compute=d(e.computeResources,e.databaseResources,e.s3Resources,o),y(o,e.schedules),o.additionalManagedImports=C(e.imports),t?.skipValidation)return o;try{return s.parse(o)}catch(n){if(n instanceof a.ZodError){const i=u(n);throw new Error(`Invalid infrastructure configuration:
2
- ${i}`)}throw n}}export{B as convertToResourcePlan};
@@ -1 +0,0 @@
1
- import*as r from"typescript";import{asString as o,collectFromAst as c,isFactoryMethodCall as f,parseObjectLiteral as g}from"./astCommonParser.js";function p(u){return c(u,t=>{if(!r.isCallExpression(t)||!f(t,"addSchedule")||t.arguments.length<2)return null;const s=t.arguments[0],i=t.arguments[1];if(!r.isStringLiteral(s)||!r.isObjectLiteralExpression(i))return null;const a=g(i),l=o(a.schedule);if(l===void 0)return null;const e=i.properties.find(n=>r.isPropertyAssignment(n)&&r.isIdentifier(n.name)&&n.name.text==="target");return!e||!r.isPropertyAssignment(e)||!r.isIdentifier(e.initializer)?null:{id:s.text,schedule:l,targetVariableName:e.initializer.text}})}export{p as findSchedules};
@@ -1 +0,0 @@
1
- import*as a from"typescript";import{isAppGetAppCall as f}from"./astCommonParser.js";import{S3_BUCKET_CLASSES as d}from"./astStorageParser.js";const y=new Set(["App","Architecture","DatabaseFactory","StorageFactory","ComputeFactory","getConfig","MessagingFactory","CdnFactory","Code","Runtime","FunctionUrlAuthType","NetworkFactory","PatternFactory","VpcPeerFactory","VpcPeerAccepterFactory","CrossPlanConnectionFactory"]);function l(r){return!!(r.startsWith("@fjall/")||r==="aws-cdk-lib"||r.startsWith("aws-cdk-lib/")||r==="constructs")}function C(r){const n=[];for(const e of r.statements){const t=e.getFullStart(),i=e.getEnd();if(a.isImportDeclaration(e)){n.push({type:"import",node:e,startPos:t,endPos:i,isManaged:g(e)});continue}if(a.isVariableStatement(e)){n.push(m(e,t,i));continue}if(a.isExpressionStatement(e)){n.push(x(e,t,i));continue}n.push({type:"custom",node:e,startPos:t,endPos:i,isManaged:!1})}return n}function g(r){return a.isStringLiteral(r.moduleSpecifier)?l(r.moduleSpecifier.text):!1}function m(r,n,e){for(const t of r.declarationList.declarations)if(t.initializer){if(f(t.initializer))return{type:"app-init",node:r,resourceName:a.isIdentifier(t.name)?t.name.text:void 0,startPos:n,endPos:e,isManaged:!0};if(a.isIdentifier(t.name)&&t.name.text==="appName"&&a.isStringLiteral(t.initializer))return{type:"app-init",node:r,startPos:n,endPos:e,isManaged:!0};if(a.isNewExpression(t.initializer)){const i=t.initializer;if(a.isIdentifier(i.expression)){const o=i.expression.text;if(d.has(o)){const c=i.arguments&&i.arguments.length>=2&&a.isStringLiteral(i.arguments[1])?i.arguments[1].text:void 0;return{type:"storage",node:r,resourceName:c,startPos:n,endPos:e,isManaged:!0}}}}if(a.isCallExpression(t.initializer)){const i=p(t.initializer,r,n,e);if(i.type!=="custom")return i}}return{type:"custom",node:r,startPos:n,endPos:e,isManaged:!1}}function x(r,n,e){const t=r.expression;return a.isCallExpression(t)?p(t,r,n,e):{type:"custom",node:r,startPos:n,endPos:e,isManaged:!1}}function p(r,n,e,t){const i=r.expression;if(a.isPropertyAccessExpression(i)&&a.isIdentifier(i.expression)){const o=i.name.text;if(o==="addTags")return{type:"tags",node:n,startPos:e,endPos:t,isManaged:!0};const s={addDatabase:{type:"database",factory:"DatabaseFactory"},addCompute:{type:"compute",factory:"ComputeFactory"},addNetwork:{type:"network",factory:"NetworkFactory"},addMessaging:{type:"messaging",factory:"MessagingFactory"},addCdn:{type:"cdn",factory:"CdnFactory"},addPattern:{type:"pattern",factory:"PatternFactory"},addStorage:{type:"storage",factory:"StorageFactory"},addVpcPeer:{type:"vpc-peer",factory:"VpcPeerFactory"},addVpcPeerAccepter:{type:"vpc-peer-accepter",factory:"VpcPeerAccepterFactory"}}[o];if(s){const u=F(r,s.factory);return{type:s.type,node:n,resourceName:u,startPos:e,endPos:t,isManaged:!0}}}return{type:"custom",node:n,startPos:e,endPos:t,isManaged:!1}}function F(r,n){if(r.arguments.length===0)return;const e=r.arguments[0];if(!a.isCallExpression(e))return;const t=e.expression;if(!a.isPropertyAccessExpression(t)||t.name.text!=="build"||!a.isIdentifier(t.expression)||t.expression.text!==n||e.arguments.length===0)return;const i=e.arguments[0];if(a.isStringLiteral(i))return i.text}export{y as KNOWN_FJALL_IMPORTS,C as classifyStatements,l as isManagedModuleSpecifier};
@@ -1 +0,0 @@
1
- import*as i from"typescript";import{S3_STACK_PLACEMENTS as g}from"../schemas/resourceSchemas.js";import{S3_ENCRYPTION_TYPES as f,BACKUP_VAULT_TIERS as p}from"../schemas/constants.js";import{asBoolean as c,asNumber as d,asString as o,asStringUnion as a,captureExtraProperties as x,collectFromAst as b,extractVariableName as N,isFactoryBuildCall as k,isFactoryMethodCall as h,isParsedObject as u,parseObjectLiteral as y}from"./astCommonParser.js";const A=new Set(["S3Bucket"]);function C(n,e,r){const t=i.isIdentifier(n.name)?n.name.text:"";if(e.arguments&&e.arguments.length>=2){const s=e.arguments[1],m=i.isStringLiteral(s)?s.text:"",l=e.arguments.length>=3?e.arguments[2]:void 0,S=l&&i.isObjectLiteralExpression(l)?y(l):{};return{variableName:t,resourceName:m,bucketClass:r,config:S,node:n}}return null}function P(n,e){if(e.arguments.length<2)return null;const r=e.arguments[0],t=e.arguments[1];if(!i.isStringLiteral(r)||!i.isObjectLiteralExpression(t))return null;const s=y(t);return{variableName:N(n)??"",resourceName:r.text,bucketClass:"StorageFactory",config:s,node:n}}function R(n){return b(n,e=>{if(!i.isVariableDeclaration(e)||!e.initializer||!i.isNewExpression(e.initializer))return null;const r=e.initializer;if(!i.isIdentifier(r.expression))return null;const t=r.expression.text;return A.has(t)?C(e,r,t):null})}function _(n){return b(n,e=>{if(!i.isCallExpression(e)||!h(e,"addStorage"))return null;const r=e.arguments[0];return k(r,"StorageFactory")?P(e,r):null})}function v(n){return n.map(e=>({name:e.resourceName,...o(e.config.bucketName)&&{bucketName:o(e.config.bucketName)},...c(e.config.publicReadAccess)===!0&&{publicReadAccess:!0},...u(e.config.websiteHosting)&&(()=>{const r=e.config.websiteHosting;return{websiteHosting:{indexDocument:o(r.indexDocument)??"index.html",...o(r.errorDocument)&&{errorDocument:o(r.errorDocument)}}}})(),...a(e.config.backupVaultTier,p)&&{backupVaultTier:a(e.config.backupVaultTier,p)},...c(e.config.versioned)!==void 0&&{versioned:c(e.config.versioned)},...a(e.config.encryption,f)&&{encryption:a(e.config.encryption,f)},...o(e.config.kmsKeyArn)&&{kmsKeyArn:o(e.config.kmsKeyArn)},...Array.isArray(e.config.cors)&&e.config.cors.length>0&&{cors:e.config.cors.filter(u).map(r=>({allowedOrigins:Array.isArray(r.allowedOrigins)?r.allowedOrigins.filter(t=>typeof t=="string"):[],allowedMethods:Array.isArray(r.allowedMethods)?r.allowedMethods.filter(t=>typeof t=="string"):[]}))},...u(e.config.deployment)&&(()=>{const r=e.config.deployment;return{deployment:{source:o(r.source)??"",...c(r.prune)!==void 0&&{prune:c(r.prune)},...u(r.cacheControl)&&(()=>{const t=r.cacheControl;return{cacheControl:{...d(t.maxAge)!==void 0&&{maxAge:d(t.maxAge)},...c(t.immutable)!==void 0&&{immutable:c(t.immutable)}}}})()}}})(),...a(e.config.stackPlacement,g)&&{stackPlacement:a(e.config.stackPlacement,g)},...e.variableName&&{variableName:e.variableName},...(()=>{const r=new Set(["bucketName","publicReadAccess","websiteHosting","backupVaultTier","versioned","encryption","kmsKeyArn","cors","deployment","stackPlacement"]),t=x(e.config,r);return t.length>0?{extraProperties:t}:{}})()}))}export{A as S3_BUCKET_CLASSES,v as convertS3Resources,_ as findS3FactoryResources,R as findS3Resources};