@fjall/generator 2.34.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/.minified +1 -1
  2. package/dist/src/ast/astTestHelpers.js +1 -1
  3. package/dist/src/ast/domain/astDomainParser.d.ts +15 -7
  4. package/dist/src/ast/domain/astDomainParser.js +1 -1
  5. package/dist/src/ast/index.d.ts +1 -1
  6. package/dist/src/ast/mutation/astCodeInjection.js +4 -4
  7. package/dist/src/ast/mutation/astExpressionEvaluator.js +1 -1
  8. package/dist/src/ast/mutation/astSurgicalModification.js +5 -5
  9. package/dist/src/ast/parsers/common/astCommonParser.js +1 -1
  10. package/dist/src/ast/parsers/common/astStatementClassifier.js +1 -1
  11. package/dist/src/ast/parsers/common/astStatementQueries.js +3 -3
  12. package/dist/src/ast/parsers/orchestrator/astInfrastructureParser.js +1 -1
  13. package/dist/src/ast/parsers/orchestrator/astPlanConverter.js +2 -2
  14. package/dist/src/ast/parsers/resources/astCdnParser.js +1 -1
  15. package/dist/src/ast/parsers/resources/astClickHouseParser.js +1 -1
  16. package/dist/src/ast/parsers/resources/astComputeConnectionParser.js +1 -1
  17. package/dist/src/ast/parsers/resources/astComputeParser.js +1 -1
  18. package/dist/src/ast/parsers/resources/astComputeParserHelpers.js +1 -1
  19. package/dist/src/ast/parsers/resources/astDatabaseParser.js +1 -1
  20. package/dist/src/ast/parsers/resources/astDynamoDBParser.js +1 -1
  21. package/dist/src/ast/parsers/resources/astMessagingParser.js +1 -1
  22. package/dist/src/ast/parsers/resources/astNetworkParser.js +1 -1
  23. package/dist/src/ast/parsers/resources/astPatternParser.js +1 -1
  24. package/dist/src/ast/parsers/resources/astScheduleParser.js +1 -1
  25. package/dist/src/ast/parsers/resources/astStorageParser.js +1 -1
  26. package/dist/src/aws/regions.js +1 -1
  27. package/dist/src/codemod/_internal.js +1 -1
  28. package/dist/src/codemod/drift/detect.js +1 -1
  29. package/dist/src/codemod/drift/merge.js +1 -1
  30. package/dist/src/codemod/drift/snapshot.js +1 -1
  31. package/dist/src/codemod/edits/addResource/bodyIndex.js +1 -1
  32. package/dist/src/codemod/edits/addResource/propertyBuilder.js +1 -1
  33. package/dist/src/codemod/edits/addResource.js +1 -1
  34. package/dist/src/codemod/edits/appendAccountToStage.js +1 -1
  35. package/dist/src/codemod/edits/controlFlowPolicy.js +1 -1
  36. package/dist/src/codemod/edits/crossPlanConnection.js +1 -1
  37. package/dist/src/codemod/edits/driftPolicy.js +1 -1
  38. package/dist/src/codemod/edits/ensureImports.js +1 -1
  39. package/dist/src/codemod/edits/findInsertionPosition.js +1 -1
  40. package/dist/src/codemod/edits/modifyResource/literalConversion.js +1 -1
  41. package/dist/src/codemod/edits/modifyResource.js +1 -1
  42. package/dist/src/codemod/edits/removeResource/commentHeuristic.js +1 -1
  43. package/dist/src/codemod/edits/removeResource/importPruning.js +1 -1
  44. package/dist/src/codemod/edits/removeResource.js +1 -1
  45. package/dist/src/codemod/edits/vpcPeer.js +1 -1
  46. package/dist/src/codemod/edits/vpcPeerAccepter.js +1 -1
  47. package/dist/src/codemod/fileRewriter/builders.js +1 -1
  48. package/dist/src/codemod/fileRewriter/locateByRange.js +1 -1
  49. package/dist/src/codemod/fileRewriter/parse.js +2 -2
  50. package/dist/src/codemod/fileRewriter/print.js +2 -2
  51. package/dist/src/codemod/historyPaths.js +1 -1
  52. package/dist/src/codemod/listResources.js +1 -1
  53. package/dist/src/codemod/llmFallback/apply.js +1 -1
  54. package/dist/src/codemod/llmFallback/claudeTier.js +1 -1
  55. package/dist/src/codemod/llmFallback/egressGate.js +1 -1
  56. package/dist/src/codemod/llmFallback/morphTier.js +2 -2
  57. package/dist/src/codemod/llmFallback/prompt.js +13 -13
  58. package/dist/src/codemod/llmFallback/runFallback.js +1 -1
  59. package/dist/src/codemod/llmFallback/shouldTryFallback.js +1 -1
  60. package/dist/src/codemod/llmFallback/signals.js +1 -1
  61. package/dist/src/codemod/llmFallback/telemetryEvents.js +1 -1
  62. package/dist/src/codemod/llmFallback/tierRunner.js +1 -1
  63. package/dist/src/codemod/registry.js +1 -1
  64. package/dist/src/codemod/semanticIndex/classifyControlFlow.js +1 -1
  65. package/dist/src/codemod/semanticIndex/findReferences.js +2 -2
  66. package/dist/src/codemod/semanticIndex/listImports.js +1 -1
  67. package/dist/src/codemod/semanticIndex/locateByShape.js +1 -1
  68. package/dist/src/codemod/semanticIndex/projectCache.js +1 -1
  69. package/dist/src/codemod/semanticIndex/resolveConstructByLiteralProperty.js +1 -1
  70. package/dist/src/codemod/validationGate/gates/classify.js +1 -1
  71. package/dist/src/codemod/validationGate/gates/locate.js +1 -1
  72. package/dist/src/codemod/validationGate/types.js +1 -1
  73. package/dist/src/detection/index.js +1 -1
  74. package/dist/src/dns/bindParser.js +2 -2
  75. package/dist/src/dns/bindWriter.js +2 -2
  76. package/dist/src/dns/domainFileGenerator.js +18 -28
  77. package/dist/src/dns/domainRecords.d.ts +11 -0
  78. package/dist/src/dns/domainRecords.js +1 -1
  79. package/dist/src/generation/common.js +7 -7
  80. package/dist/src/generation/compute/ec2.js +3 -3
  81. package/dist/src/generation/compute/ecs.js +24 -24
  82. package/dist/src/generation/compute/lambda.js +8 -8
  83. package/dist/src/generation/compute/shared.js +4 -4
  84. package/dist/src/generation/compute.js +5 -5
  85. package/dist/src/generation/database.js +18 -18
  86. package/dist/src/generation/generatePatternCode.js +16 -16
  87. package/dist/src/generation/infrastructure.js +14 -14
  88. package/dist/src/generation/messagingConnections.js +1 -1
  89. package/dist/src/generation/storage.js +14 -14
  90. package/dist/src/generation/storageConnections.js +1 -1
  91. package/dist/src/planning/generateResourceChange.js +1 -1
  92. package/dist/src/planning/openNextPlanning.js +1 -1
  93. package/dist/src/planning/resourceAddition.js +1 -1
  94. package/dist/src/planning/resourceConnections.js +1 -1
  95. package/dist/src/planning/resourcePlanning.js +1 -1
  96. package/dist/src/planning/staticSitePlanning.js +1 -1
  97. package/dist/src/presets/patternTierPresets.js +1 -1
  98. package/dist/src/presets/storagePresets.js +1 -1
  99. package/dist/src/presets/tierPresets.js +1 -1
  100. package/dist/src/schemas/baseSchemas.js +2 -2
  101. package/dist/src/schemas/computeSchemas.js +1 -1
  102. package/dist/src/schemas/constants.js +1 -1
  103. package/dist/src/schemas/devRolePolicies.js +1 -1
  104. package/dist/src/schemas/instanceTypeArchitecture.js +1 -1
  105. package/dist/src/schemas/securityBoundary.js +1 -1
  106. package/dist/src/types/Result.js +1 -1
  107. package/dist/src/validation/validationPatterns.js +1 -1
  108. package/dist/src/version.d.ts +1 -1
  109. package/dist/src/version.js +1 -1
  110. package/package.json +3 -3
package/dist/.minified CHANGED
@@ -1 +1 @@
1
- 143 files minified at 2026-07-17T22:47:42.342Z
1
+ 143 files minified at 2026-07-18T01:56:28.544Z
@@ -1 +1 @@
1
- import{parseInfrastructure as e,convertToResourcePlan as o}from"@fjall/generator";function n(t){const r=e(t);return o(r,r.appName??"test-app")}export{n as parseAndConvert,e as parseInfrastructure};
1
+ var p=Object.defineProperty;var t=(e,r)=>p(e,"name",{value:r,configurable:!0});import{parseInfrastructure as o,convertToResourcePlan as n}from"@fjall/generator";function c(e){const r=o(e);return n(r,r.appName??"test-app")}t(c,"parseAndConvert");export{c as parseAndConvert,o as parseInfrastructure};
@@ -63,11 +63,6 @@ export interface ParsedCertificateFromAst {
63
63
  readonly subjectAlternativeNames?: string[];
64
64
  readonly transparencyLogging?: boolean;
65
65
  }
66
- export interface ParsedDelegationFromAst {
67
- readonly subdomain: string;
68
- readonly toAccount: string;
69
- readonly auto?: boolean;
70
- }
71
66
  interface ParsedDomainCommon {
72
67
  readonly zoneName: string;
73
68
  readonly description: string | undefined;
@@ -79,12 +74,18 @@ interface ParsedDomainCommon {
79
74
  export interface ParsedRoute53ApexDomainProps extends ParsedDomainCommon {
80
75
  readonly registrar: "route53";
81
76
  readonly hostedZoneId: string | undefined;
82
- readonly delegations: ParsedDelegationFromAst[];
83
77
  }
84
78
  export interface ParsedExternalDelegatedDomainProps extends ParsedDomainCommon {
85
79
  readonly registrar: "external-delegated";
86
80
  readonly delegatedSubdomain: string;
87
- readonly delegations: ParsedDelegationFromAst[];
81
+ /**
82
+ * D8 child-writes delegation: LITERAL parent DelegationRole ARN, when the
83
+ * source declares one. `undefined` when absent (the CLI injects it at
84
+ * deploy time via ManagedDomainBinding.delegationRoleArn).
85
+ */
86
+ readonly parentDelegationRoleArn: string | undefined;
87
+ /** R2 two-step deploy gate; `undefined` means the default (`"full"`). */
88
+ readonly phase: "zone" | "full" | undefined;
88
89
  }
89
90
  export interface ParsedExternalRecordsDomainProps extends ParsedDomainCommon {
90
91
  readonly registrar: "external-records";
@@ -109,6 +110,9 @@ export declare function findDomainConstructCall(sourceFile: ts.SourceFile): Resu
109
110
  * record fields) is absent
110
111
  * - `invalid_literal` — a field is present but its shape/value is wrong
111
112
  * (array expected, type mismatch, unsupported enum value)
113
+ * - `removed_field` — a field that existed on an older Domain API is
114
+ * present; `cure` names the replacement shape (fail-closed: the parser
115
+ * refuses rather than silently dropping declared state)
112
116
  */
113
117
  export type ParseDomainError = {
114
118
  readonly kind: "registrar_required";
@@ -122,6 +126,10 @@ export type ParseDomainError = {
122
126
  readonly kind: "invalid_literal";
123
127
  readonly field: string;
124
128
  readonly reason: string;
129
+ } | {
130
+ readonly kind: "removed_field";
131
+ readonly field: string;
132
+ readonly cure: string;
125
133
  };
126
134
  /**
127
135
  * Parse the props object literal of a located `new Domain(...)` call into a
@@ -1 +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
+ var D=Object.defineProperty;var a=(e,n)=>D(e,"name",{value:n,configurable:!0});import*as m from"typescript";import{parseObjectLiteral as R,asString as c,asStringUnion as h,asStringArray as k,asBoolean as T,asNumber as $,isCallRef as E,isParsedObject as g}from"../parsers/common/astCommonParser.js";import{success as l,failure as u}from"../../types/Result.js";import{DnsRecordTypeSchema as I}from"../../dns/types.js";import{DomainRegistrarSchema as v,DomainDeployPhaseSchema as L,AliasRecordTypeSchema as j,TYPED_FJALL_TARGET_KINDS as O}from"../../dns/domainRecords.js";const A=v.options,S=L.options,C=I.options,V=j.options;function ne(e){const n=[],t=a(i=>{if(m.isNewExpression(i)&&P(i.expression)){const o=Z(i);o!==void 0&&n.push(o)}m.forEachChild(i,t)},"visit");if(t(e),n.length===0)return l(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?l(r):l(void 0)}a(ne,"findDomainConstructCall");function P(e){return m.isIdentifier(e)&&e.text==="Domain"}a(P,"isDomainIdentifier");function Z(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||!m.isObjectLiteralExpression(i))return;const o=z(e);if(o===void 0)return;const d=M(e),s=m.isStringLiteral(r)?r.text:void 0;return{callExpression:e,containingStatement:o,propsObjectLiteral:i,domainVarId:d,scopeArgumentText:t.getText(),constructIdLiteral:s}}a(Z,"buildMatch");function z(e){let n=e;for(;n!==void 0;){if(m.isExpressionStatement(n)||m.isVariableStatement(n))return n;n=n.parent}}a(z,"findContainingTopLevelStatement");function M(e){let n=e.parent;for(;n!==void 0;){if(m.isVariableDeclaration(n)&&m.isIdentifier(n.name)&&n.initializer===e)return n.name.text;n=n.parent}}a(M,"extractDomainVarId");function q(e){switch(e.kind){case"registrar_required":return"'registrar' property is required";case"registrar_unsupported":return`'registrar' must be one of ${A.join(", ")}, got ${JSON.stringify(e.value)}`;case"missing_field":return`'${e.field}' property is required`;case"invalid_literal":return`'${e.field}' ${e.reason}`;case"removed_field":return`'${e.field}' was removed from the Domain API \u2014 ${e.cure}`}}a(q,"errorMessage");const B="declare the delegated child as its own Domain with registrar: 'external-delegated' and set 'parentDelegationRoleArn' (the CLI injects it via ManagedDomainBinding.delegationRoleArn); the child UPSERTs its NS records into the parent zone";function te(e){const n=R(e),t=h(n.registrar,A);if(t===void 0){const s=n.registrar;if(s===void 0)return u({kind:"registrar_required"});const f=typeof s=="string"?s:_(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=J(n.records);if(!i.success)return i;const o=H(n.certificates);if(!o.success)return o;if(n.delegations!==void 0)return u({kind:"removed_field",field:"delegations",cure:B});const d={zoneName:r,description:c(n.description),costAllocationEnvironment:c(n.costAllocationEnvironment),tags:K(n.tags),records:i.data,certificates:o.data};switch(t){case"route53":return l({...d,registrar:t,hostedZoneId:c(n.hostedZoneId)});case"external-delegated":{const s=c(n.delegatedSubdomain);if(s===void 0)return u({kind:"missing_field",field:"delegatedSubdomain"});const f=c(n.parentDelegationRoleArn);if(n.parentDelegationRoleArn!==void 0&&f===void 0)return u({kind:"invalid_literal",field:"parentDelegationRoleArn",reason:"must be a literal string ARN (VD2-a) \u2014 the CLI injects it via ManagedDomainBinding.delegationRoleArn; dynamic expressions such as Fn.importValue are not supported"});const y=h(n.phase,S);return n.phase!==void 0&&y===void 0?u({kind:"invalid_literal",field:"phase",reason:`must be one of ${S.map(N=>`'${N}'`).join(", ")}`}):l({...d,registrar:t,delegatedSubdomain:s,parentDelegationRoleArn:f,phase:y})}case"external-records":return l({...d,registrar:t})}}a(te,"parseDomainProps");function ie(e){return q(e)}a(ie,"parseDomainErrorMessage");function J(e){if(e===void 0)return l([]);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=F(r,t);if(!i.success)return i;n.push(i.data)}return l(n)}a(J,"parseRecordsArray");function F(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(!V.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=U(e.target);return l({kind:"alias",type:t,name:r,target:s})}if(!C.some(s=>s===t))return u({kind:"invalid_literal",field:`records[${n}]`,reason:`unsupported record type '${t}'`});const i=G(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=$(e.ttl),d={kind:"standard",type:t,name:r,value:i,...o!==void 0?{ttl:o}:{}};return l(d)}a(F,"parseRecord");function G(e){if(e===void 0)return;if(typeof e=="string")return e;const n=k(e);if(n!==void 0)return n}a(G,"parseRecordValue");function U(e){if(E(e))return Y(e);if(g(e)){const n=h(e.kind,O);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:_(e)}}a(U,"parseTarget");function Y(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=b(i);switch(r){case"fjallApp":{const d=p(o,0);return d===void 0?{kind:"dynamic",sourceText:n}:{kind:"ecs",appName:d}}case"fjallCdn":{const d=p(o,0);return d===void 0?{kind:"dynamic",sourceText:n}:{kind:"cdn",appName:d}}case"fjallBucket":{const d=p(o,0);return d===void 0?{kind:"dynamic",sourceText:n}:{kind:"bucket",bucketName:d}}case"aliasTo":{if(o.length>=2){const d=p(o,0),s=p(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=x(d,"dnsName"),f=x(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}}}a(Y,"resolveCallRefTarget");function b(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}a(b,"splitTopLevelArgs");function p(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)}a(p,"extractStringLiteralArg");function x(e,n){const t=e.trim().replace(/^\{|\}$/g,""),r=b(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 p([s],0)}}a(x,"extractObjectFieldString");function H(e){if(e===void 0)return l([]);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=T(r.transparencyLogging);n.push({domainName:i,...o!==void 0?{subjectAlternativeNames:o}:{},...d!==void 0?{transparencyLogging:d}:{}})}return l(n)}a(H,"parseCertificatesArray");function K(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}a(K,"parseStringRecord");function _(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=>_(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)}a(_,"stringifyParsedValue");export{ne as findDomainConstructCall,ie as parseDomainErrorMessage,te as parseDomainProps,b as splitTopLevelArgs};
@@ -2,4 +2,4 @@ export { type IdentifierRef, type ExpressionRef, type CallRef, type ParsedValue,
2
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
3
  export { type SurgicalModificationResult, type InsertionOptions, type UpdateOptions, type DeleteOptions, addResourceSurgically, updateResourceSurgically, removeResourceSurgically, } from "./mutation/astSurgicalModification.js";
4
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";
5
+ export { type DomainCallMatch, type ParsedFjallTarget, type ParsedDnsRecordFromAst, type ParsedCertificateFromAst, type ParsedDomainProps, type ParsedRoute53ApexDomainProps, type ParsedExternalDelegatedDomainProps, type ParsedExternalRecordsDomainProps, type ParseDomainError, findDomainConstructCall, parseDomainProps, parseDomainErrorMessage, splitTopLevelArgs, } from "./domain/astDomainParser.js";
@@ -1,8 +1,8 @@
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=`
1
+ var C=Object.defineProperty;var a=(t,e)=>C(t,"name",{value:e,configurable:!0});import*as d from"typescript";import{classifyStatements as y}from"../parsers/orchestrator/astInfrastructureParser.js";import{parseSourceFile as m,insertAtPosition as l,formatLeadingNewlines as w,getContextBeforePosition as P,formatResourceId as p,createErrorResult as g,findClassification as h,findLastClassification as N}from"./astSurgicalModification.js";import{getErrorMessage as O}from"../../util/errorUtils.js";function j(t,e){try{const n=m(t),o=new Set;for(const i of n.statements)d.isImportDeclaration(i)&&o.add(i.getText(n).trim());const r=[];for(const i of e){const f=i.trim();[...o].some(x=>A(x,f))||r.push(f)}if(r.length===0)return{content:t,success:!0};const s=n.statements.filter(d.isImportDeclaration).at(-1)?.getEnd()??0,c=`
2
2
  `+r.join(`
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)}]
3
+ `);return{content:l(t,s,c),success:!0}}catch(n){return g(n,t)}}a(j,"ensureImports");function R(t){return new Set(t.split(",").map(e=>e.trim()).filter(Boolean))}a(R,"parseNamedImports");function T(t,e){const n=R(t),o=R(e);for(const r of o)if(!n.has(r))return!1;return!0}a(T,"existingImportCoversRequired");function A(t,e){const n=t.match(M),o=e.match(M);if(!n||!o||n[1]!==o[1])return!1;const r=t.match(E),s=e.match(E);return r&&s?T(r[1],s[1]):!!r==!!s}a(A,"importsAreEquivalent");const M=/from\s+["']([^"']+)["']/,E=/\{([^}]+)\}/,I={"before-imports":0,"after-imports":1,"after-app-init":2,"after-tags":3,"after-resource":4,"end-of-file":5};function S(t){return[...t].sort((e,n)=>{const o=I[n.position]-I[e.position];return o!==0?o:(n.originalLine??0)-(e.originalLine??0)})}a(S,"sortCustomBlocksForInsertion");function D(t,e,n,o){if(n!==null){const s=B(t,n,e);return l(t,n,s)}const r=e.afterManagedResource?`// [ORPHANED: was after ${p(e.afterManagedResource.type,e.afterManagedResource.name)}]
4
4
  `:`// [ORPHANED]
5
5
  `;return o.push(`Custom code from line ${e.originalLine} could not be positioned. Added at end of file.`),t+`
6
- `+r+e.sourceText}function U(t,e,n){if(!e||e.length===0)return{content:t,success:!0};try{const o=d(t),r=x(o),s=[],u=T(e);let a=t;for(const i of u){const c=D(o,r,i,n,s);a=A(a,i,c,s)}return{content:a,success:!0,warnings:s.length>0?s:void 0}}catch(o){return p(o,t)}}function S(t,e,n,o){if(!e.afterManagedResource)return null;const r=e.afterManagedResource,s=(r.name&&n?.get(r.name))??r.name,u=t.find(i=>i.type===r.type&&i.resourceName===s);if(u)return u.endPos;const a=t.filter(i=>i.type===r.type&&i.isManaged);return a.length===1?a[0].endPos:(o&&o.push(`Resource ${l(e.afterManagedResource.type,e.afterManagedResource.name)} not found. Custom code may be orphaned.`),null)}function D(t,e,n,o,r){switch(n.position){case"before-imports":return 0;case"after-imports":return w(e,"import")?.endPos??0;case"after-app-init":return g(e,"app-init")?.endPos??null;case"after-tags":return g(e,"tags")?.endPos??null;case"after-resource":return S(e,n,o,r);case"end-of-file":return t.getEnd();default:return null}}function F(t,e,n){const o=y(t,e);let r=n.sourceText;return r=C(o,r)+r,r.endsWith(`
6
+ `+r+e.sourceText}a(D,"insertOrOrphanBlock");function G(t,e,n){if(!e||e.length===0)return{content:t,success:!0};try{const o=m(t),r=y(o),s=[],c=S(e);let u=t;for(const i of c){const f=v(o,r,i,n,s);u=D(u,i,f,s)}return{content:u,success:!0,warnings:s.length>0?s:void 0}}catch(o){return g(o,t)}}a(G,"injectCustomCodeBlocks");function F(t,e,n,o){if(!e.afterManagedResource)return null;const r=e.afterManagedResource,s=(r.name&&n?.get(r.name))??r.name,c=t.find(i=>i.type===r.type&&i.resourceName===s);if(c)return c.endPos;const u=t.filter(i=>i.type===r.type&&i.isManaged);return u.length===1?u[0].endPos:(o&&o.push(`Resource ${p(e.afterManagedResource.type,e.afterManagedResource.name)} not found. Custom code may be orphaned.`),null)}a(F,"findAfterResourcePosition");function v(t,e,n,o,r){switch(n.position){case"before-imports":return 0;case"after-imports":return N(e,"import")?.endPos??0;case"after-app-init":return h(e,"app-init")?.endPos??null;case"after-tags":return h(e,"tags")?.endPos??null;case"after-resource":return F(e,n,o,r);case"end-of-file":return t.getEnd();default:return null}}a(v,"findCustomCodeInsertPosition");function B(t,e,n){const o=P(t,e);let r=n.sourceText;return r=w(o,r)+r,r.endsWith(`
7
7
  `)||(r+=`
8
- `),r}function $(t){try{let o=function(r){r.kind===f.SyntaxKind.Unknown&&n.push("Unknown node found in AST - possible parse error"),f.forEachChild(r,o)};const e=d(t),n=[];return o(e),n.length>0?{valid:!1,errors:n}:{valid:!0}}catch(e){return{valid:!1,errors:[P(e)]}}}export{q as ensureImports,U as injectCustomCodeBlocks,$ as validateModifiedFile};
8
+ `),r}a(B,"formatCustomCodeForInsertion");function H(t){try{let o=function(r){r.kind===d.SyntaxKind.Unknown&&n.push("Unknown node found in AST - possible parse error"),d.forEachChild(r,o)};a(o,"visit");const e=m(t),n=[];return o(e),n.length>0?{valid:!1,errors:n}:{valid:!0}}catch(e){return{valid:!1,errors:[O(e)]}}}a(H,"validateModifiedFile");export{j as ensureImports,G as injectCustomCodeBlocks,H as validateModifiedFile};
@@ -1 +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
+ var o=Object.defineProperty;var a=(e,n)=>o(e,"name",{value:n,configurable:!0});import*as t from"typescript";import{findFirstInAst as u}from"../parsers/common/astCommonParser.js";function l(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]=f(i.initializer))}return n}a(l,"parseObjectLiteral");function f(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=>f(n));if(t.isObjectLiteralExpression(e))return l(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=f(e.left),i=f(e.right);return typeof i=="string"?i:n}else if(t.isConditionalExpression(e)){const n=f(e.whenTrue),i=f(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()}}a(f,"evaluateExpression");function p(e,n){return u(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=l(r.initializer);return JSON.stringify(s)}}}})}a(p,"findVariableValue");function x(e,n){return u(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 l(r.initializer)}})}a(x,"findObjectDeclaration");function c(e,n){if(!t.isIdentifier(n.expression))return;const i=x(e,n.expression.text),r=n.name.text;if(i&&i[r]!==void 0)return String(i[r])}a(c,"evaluatePropertyAccess");function d(e,n){let i=n.head.text;for(const r of n.templateSpans){if(t.isIdentifier(r.expression)){const s=p(e,r.expression.text);if(s)i+=s;else return n.getText(e).replace(/^`|`$/g,"")}else if(t.isPropertyAccessExpression(r.expression)){const s=c(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}a(d,"resolveTemplateLiteral");export{f as evaluateExpression,c as evaluatePropertyAccess,x as findObjectDeclaration,p as findVariableValue,l as parseObjectLiteral,d as resolveTemplateLiteral};
@@ -1,12 +1,12 @@
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(`
1
+ var E=Object.defineProperty;var c=(e,r)=>E(e,"name",{value:r,configurable:!0});import*as w from"typescript";import{parseInfrastructure as O,classifyStatements as T,findManagedResourcePosition as C}from"../parsers/orchestrator/astInfrastructureParser.js";import{getErrorMessage as I}from"../../util/errorUtils.js";function P(e,r,t){return e.slice(0,r)+t+e.slice(r)}c(P,"insertAtPosition");function H(e,r){return e.find(t=>t.type===r)}c(H,"findClassification");function b(e,r){return e.filter(t=>t.type===r).pop()}c(b,"findLastClassification");function y(e){return w.createSourceFile("infrastructure.ts",e,w.ScriptTarget.Latest,!0,w.ScriptKind.TS)}c(y,"parseSourceFile");function M(e,r){return e.endsWith(`
2
2
 
3
3
  `)||r.startsWith(`
4
4
  `)?"":e.endsWith(`
5
5
  `)?`
6
6
  `:`
7
7
 
8
- `}function I(e,r){return e.slice(Math.max(0,r-2),r)}function p(e,r){return r?`${e}:${r}`:e}function f(e,r){return{content:r,success:!1,error:O(e)}}function P(e,r,t,i){const n=y(e,t,i);return n||f(new Error(`Resource not found: ${p(t,i)}`),r)}function R(e){return"success"in e&&!e.success}function B(e,r){const{resourceType:t,code:i,afterResource:n}=r;try{const s=w(e);let o;if(n){const u=y(s,n.type,n.name);if(!u)return f(new Error(`Insertion target not found: ${p(n.type,n.name)}`),e);o=u.endPos}else o=M(s,t);const c=v(e,o,i);return{content:C(e,o,c),success:!0}}catch(s){return f(s,e)}}function M(e,r){const t=E(e),i=["import","app-init","tags","database","storage","messaging","compute","network","vpc-peer","vpc-peer-accepter","cross-plan-connection","cdn","pattern"],n=i.indexOf(r);let s=null;for(const o of t)if(o.isManaged){const c=i.indexOf(o.type);c!==-1&&c<=n&&(s=o)}return s?s.endPos:e.getEnd()}function v(e,r,t){const i=I(e,r),n=e.slice(r,Math.min(e.length,r+2)),s=T(i,t),o=n.startsWith(`
8
+ `}c(M,"formatLeadingNewlines");function v(e,r){return e.slice(Math.max(0,r-2),r)}c(v,"getContextBeforePosition");function g(e,r){return r?`${e}:${r}`:e}c(g,"formatResourceId");function l(e,r){return{content:r,success:!1,error:I(e)}}c(l,"createErrorResult");function R(e,r,t,i){const n=C(e,t,i);return n||l(new Error(`Resource not found: ${g(t,i)}`),r)}c(R,"findResourceOrFail");function S(e){return"success"in e&&!e.success}c(S,"isFailureResult");function D(e,r){const{resourceType:t,code:i,afterResource:n}=r;try{const s=y(e);let o;if(n){const f=C(s,n.type,n.name);if(!f)return l(new Error(`Insertion target not found: ${g(n.type,n.name)}`),e);o=f.endPos}else o=$(s,t);const a=N(e,o,i);return{content:P(e,o,a),success:!0}}catch(s){return l(s,e)}}c(D,"addResourceSurgically");function $(e,r){const t=T(e),i=["import","app-init","tags","database","storage","messaging","compute","network","vpc-peer","vpc-peer-accepter","cross-plan-connection","cdn","pattern"],n=i.indexOf(r);let s=null;for(const o of t)if(o.isManaged){const a=i.indexOf(o.type);a!==-1&&a<=n&&(s=o)}return s?s.endPos:e.getEnd()}c($,"findInsertionPositionByType");function N(e,r,t){const i=v(e,r),n=e.slice(r,Math.min(e.length,r+2)),s=M(i,t),o=n.startsWith(`
9
9
  `)?"":`
10
- `;return s+t+o}function H(e,r){const{resourceType:t,resourceName:i,newCode:n}=r;try{const s=w(e),o=P(s,e,t,i);if(R(o))return o;const c=o,a=c.node.getFullStart(),u=c.endPos,l=e.slice(a,c.node.getStart()),g=$(l);return{content:e.slice(0,a)+g+n+e.slice(u),success:!0}}catch(s){return f(s,e)}}function $(e){const r=e.match(/^[\s]*[\n\r]+[\s]*/);return r?r[0]:""}function N(e,r,t,i){let n=e,s=0;for(const o of r){const c=`// [ORPHANED: was after ${p(t,i)}]
11
- `,a=o.sourceText.trim(),u=n.indexOf(a,s);u!==-1&&(n=C(n,u,c),s=u+c.length+a.length)}return n}function b(e,r){const{resourceType:t,resourceName:i,orphanHandling:n}=r,s=[];try{const o=w(e),c=P(o,e,t,i);if(R(c))return c;const a=c,l=(F(e,{extractCustomCode:!0}).customCodeBlocks??[]).filter(h=>h.position==="after-resource"&&h.afterManagedResource?.type===t&&h.afterManagedResource?.name===i);if(l.length>0)if(n==="preserve-with-warning")s.push(`Custom code after ${p(t,i)} will be orphaned. Added // [ORPHANED] marker comment.`);else return f(new Error(`Orphan handling "${n}" is not yet implemented`),e);const g=a.node.getFullStart(),d=a.endPos,S=e[d]===`
12
- `?d+1:d;let m=e.slice(0,g)+e.slice(S);return l.length>0&&n==="preserve-with-warning"&&(m=N(m,l,t,i)),{content:m,success:!0,warnings:s.length>0?s:void 0}}catch(o){return f(o,e)}}export{B as addResourceSurgically,f as createErrorResult,L as findClassification,A as findLastClassification,T as formatLeadingNewlines,p as formatResourceId,I as getContextBeforePosition,C as insertAtPosition,w as parseSourceFile,b as removeResourceSurgically,H as updateResourceSurgically};
10
+ `;return s+t+o}c(N,"formatCodeForInsertion");function K(e,r){const{resourceType:t,resourceName:i,newCode:n}=r;try{const s=y(e),o=R(s,e,t,i);if(S(o))return o;const a=o,u=a.node.getFullStart(),f=a.endPos,d=e.slice(u,a.node.getStart()),m=W(d);return{content:e.slice(0,u)+m+n+e.slice(f),success:!0}}catch(s){return l(s,e)}}c(K,"updateResourceSurgically");function W(e){const r=e.match(/^[\s]*[\n\r]+[\s]*/);return r?r[0]:""}c(W,"extractLeadingWhitespace");function k(e,r,t,i){let n=e,s=0;for(const o of r){const a=`// [ORPHANED: was after ${g(t,i)}]
11
+ `,u=o.sourceText.trim(),f=n.indexOf(u,s);f!==-1&&(n=P(n,f,a),s=f+a.length+u.length)}return n}c(k,"insertOrphanMarkers");function j(e,r){const{resourceType:t,resourceName:i,orphanHandling:n}=r,s=[];try{const o=y(e),a=R(o,e,t,i);if(S(a))return a;const u=a,d=(O(e,{extractCustomCode:!0}).customCodeBlocks??[]).filter(x=>x.position==="after-resource"&&x.afterManagedResource?.type===t&&x.afterManagedResource?.name===i);if(d.length>0)if(n==="preserve-with-warning")s.push(`Custom code after ${g(t,i)} will be orphaned. Added // [ORPHANED] marker comment.`);else return l(new Error(`Orphan handling "${n}" is not yet implemented`),e);const m=u.node.getFullStart(),p=u.endPos,F=e[p]===`
12
+ `?p+1:p;let h=e.slice(0,m)+e.slice(F);return d.length>0&&n==="preserve-with-warning"&&(h=k(h,d,t,i)),{content:h,success:!0,warnings:s.length>0?s:void 0}}catch(o){return l(o,e)}}c(j,"removeResourceSurgically");export{D as addResourceSurgically,l as createErrorResult,H as findClassification,b as findLastClassification,M as formatLeadingNewlines,g as formatResourceId,v as getContextBeforePosition,P as insertAtPosition,y as parseSourceFile,j as removeResourceSurgically,K as updateResourceSurgically};
@@ -1 +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};
1
+ var x=Object.defineProperty;var r=(n,e)=>x(n,"name",{value:e,configurable:!0});import*as s from"typescript";import{constIncludes as d}from"../../../schemas/constants.js";function f(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}r(f,"isPlainObject");function a(n){return f(n)&&"__identifier"in n}r(a,"isIdentifierRef");function y(n){return f(n)&&"__expression"in n}r(y,"isExpressionRef");function l(n){return f(n)&&"__call"in n}r(l,"isCallRef");function p(n){return f(n)&&!("__identifier"in n)&&!("__expression"in n)&&!("__call"in n)&&!("__unknown"in n)}r(p,"isParsedObject");function m(n){return typeof n=="string"?n:void 0}r(m,"asString");function A(n){return typeof n=="number"?n:void 0}r(A,"asNumber");function g(n){return typeof n=="boolean"?n:void 0}r(g,"asBoolean");function h(n){if(!Array.isArray(n))return;const e=[];for(const t of n)typeof t=="string"&&e.push(t);return e.length>0?e:void 0}r(h,"asStringArray");function j(n,e){const t=m(n);if(t!==void 0)return d(e,t)?t:void 0}r(j,"asStringUnion");function O(n){const e={};for(const[t,i]of Object.entries(n))i!==void 0&&(e[t]=i);return e}r(O,"omitUndefined");function u(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(u).join(", ")}]`;if(!f(n))return String(n);if(a(n))return n.__identifier;if(y(n))return n.__expression;if(l(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(([i,o])=>`${i}: ${u(o)}`).join(", ")} }`}r(u,"parsedValueToSourceText");function C(n,e){const t=[];for(const[i,o]of Object.entries(n))e.has(i)||o===void 0||t.push({key:i,sourceText:u(o)});return t}r(C,"captureExtraProperties");function E(n,e){return s.isPropertyAssignment(n)&&s.isIdentifier(n.name)&&n.name.text===e}r(E,"isNamedProperty");function P(n){return s.isCallExpression(n)&&s.isPropertyAccessExpression(n.expression)&&n.expression.name.text==="getApp"&&s.isIdentifier(n.expression.expression)&&n.expression.expression.text==="App"}r(P,"isAppGetAppCall");function S(n,e){const{expression:t}=n;return s.isPropertyAccessExpression(t)&&t.name.text===e&&n.arguments.length>0}r(S,"isFactoryMethodCall");function I(n,e){let t;const i=r(o=>{t===void 0&&(t=e(o),t===void 0&&s.forEachChild(o,i))},"visit");return i(n),t}r(I,"findFirstInAst");function k(n,e){const t=[],i=r(o=>{const c=e(o);c!==null&&t.push(c),s.forEachChild(o,i)},"visit");return i(n),t}r(k,"collectFromAst");function F(n,e){return s.isCallExpression(n)&&s.isPropertyAccessExpression(n.expression)&&n.expression.name.text==="build"&&s.isIdentifier(n.expression.expression)&&n.expression.expression.text===e}r(F,"isFactoryBuildCall");function V(n){const e=n.parent;if(s.isVariableDeclaration(e)&&s.isIdentifier(e.name))return e.name.text}r(V,"extractVariableName");const w=r(()=>n=>n,"typed");function N(n){if(n!=null){if(n===!1)return!1;if(typeof n=="object"&&!Array.isArray(n))return n}}r(N,"asObjectOrFalse");function T(n,e){return n===!1?!1:p(n)?e(n):void 0}r(T,"parseBooleanOrConfig");function $(n,e){return p(n)?e(n):void 0}r($,"parseOptionalConfig");function B(n,e,t){const i=n[e];return p(i)?t(i):void 0}r(B,"extractSubConfig");import{parseObjectLiteral as L,evaluateExpression as U,findVariableValue as G,findObjectDeclaration as J,evaluatePropertyAccess as M,resolveTemplateLiteral as q}from"../../mutation/astExpressionEvaluator.js";export{g as asBoolean,A as asNumber,N as asObjectOrFalse,m as asString,h as asStringArray,j as asStringUnion,C as captureExtraProperties,k as collectFromAst,U as evaluateExpression,M as evaluatePropertyAccess,B as extractSubConfig,V as extractVariableName,I as findFirstInAst,J as findObjectDeclaration,G as findVariableValue,P as isAppGetAppCall,l as isCallRef,y as isExpressionRef,F as isFactoryBuildCall,S as isFactoryMethodCall,a as isIdentifierRef,E as isNamedProperty,p as isParsedObject,f as isPlainObject,O as omitUndefined,T as parseBooleanOrConfig,L as parseObjectLiteral,$ as parseOptionalConfig,u as parsedValueToSourceText,q as resolveTemplateLiteral,w as typed};
@@ -1 +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};
1
+ var d=Object.defineProperty;var o=(e,i)=>d(e,"name",{value:i,configurable:!0});import*as a from"typescript";import{isAppGetAppCall as y}from"./astCommonParser.js";import{S3_BUCKET_CLASSES as l}from"../resources/astStorageParser.js";const g=new Set(["App","Architecture","DatabaseFactory","StorageFactory","ComputeFactory","getConfig","MessagingFactory","CdnFactory","Code","Runtime","FunctionUrlAuthType","NetworkFactory","PatternFactory","VpcPeerFactory","VpcPeerAccepterFactory","CrossPlanConnectionFactory"]);function m(e){return!!(e.startsWith("@fjall/")||e==="aws-cdk-lib"||e.startsWith("aws-cdk-lib/")||e==="constructs")}o(m,"isManagedModuleSpecifier");function E(e){const i=[];for(const t of e.statements){const r=t.getFullStart(),n=t.getEnd();if(a.isImportDeclaration(t)){i.push({type:"import",node:t,startPos:r,endPos:n,isManaged:x(t)});continue}if(a.isVariableStatement(t)){i.push(F(t,r,n));continue}if(a.isExpressionStatement(t)){i.push(S(t,r,n));continue}i.push({type:"custom",node:t,startPos:r,endPos:n,isManaged:!1})}return i}o(E,"classifyStatements");function x(e){return a.isStringLiteral(e.moduleSpecifier)?m(e.moduleSpecifier.text):!1}o(x,"isManagedImport");function F(e,i,t){for(const r of e.declarationList.declarations)if(r.initializer){if(y(r.initializer))return{type:"app-init",node:e,resourceName:a.isIdentifier(r.name)?r.name.text:void 0,startPos:i,endPos:t,isManaged:!0};if(a.isIdentifier(r.name)&&r.name.text==="appName"&&a.isStringLiteral(r.initializer))return{type:"app-init",node:e,startPos:i,endPos:t,isManaged:!0};if(a.isNewExpression(r.initializer)){const n=r.initializer;if(a.isIdentifier(n.expression)){const s=n.expression.text;if(l.has(s)){const p=n.arguments&&n.arguments.length>=2&&a.isStringLiteral(n.arguments[1])?n.arguments[1].text:void 0;return{type:"storage",node:e,resourceName:p,startPos:i,endPos:t,isManaged:!0}}}}if(a.isCallExpression(r.initializer)){const n=u(r.initializer,e,i,t);if(n.type!=="custom")return n}}return{type:"custom",node:e,startPos:i,endPos:t,isManaged:!1}}o(F,"classifyVariableStatement");function S(e,i,t){const r=e.expression;return a.isCallExpression(r)?u(r,e,i,t):{type:"custom",node:e,startPos:i,endPos:t,isManaged:!1}}o(S,"classifyExpressionStatement");function u(e,i,t,r){const n=e.expression;if(a.isPropertyAccessExpression(n)&&a.isIdentifier(n.expression)){const s=n.name.text;if(s==="addTags")return{type:"tags",node:i,startPos:t,endPos:r,isManaged:!0};const c={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"}}[s];if(c){const f=M(e,c.factory);return{type:c.type,node:i,resourceName:f,startPos:t,endPos:r,isManaged:!0}}}return{type:"custom",node:i,startPos:t,endPos:r,isManaged:!1}}o(u,"classifyCallExpression");function M(e,i){if(e.arguments.length===0)return;const t=e.arguments[0];if(!a.isCallExpression(t))return;const r=t.expression;if(!a.isPropertyAccessExpression(r)||r.name.text!=="build"||!a.isIdentifier(r.expression)||r.expression.text!==i||t.arguments.length===0)return;const n=t.arguments[0];if(a.isStringLiteral(n))return n.text}o(M,"extractResourceNameFromFactoryCall");export{g as KNOWN_FJALL_IMPORTS,E as classifyStatements,m as isManagedModuleSpecifier};
@@ -1,3 +1,3 @@
1
- import*as l from"typescript";import{classifyStatements as r}from"./astStatementClassifier.js";const d={import:"after-imports","app-init":"after-app-init",tags:"after-tags"};function g(t){if(!t)return{position:"before-imports"};const n=d[t.type];return n?{position:n}:{position:"after-resource",afterManagedResource:{type:t.type,name:t.resourceName}}}function C(t,n){const i=n??r(t),o=[],s=t.getFullText();let e=null;for(const c of i)if(c.type==="custom"&&!c.isManaged){const{position:a,afterManagedResource:p}=g(e),u=x(s,c.node),f=y(s,c.node),m=t.getLineAndCharacterOfPosition(c.node.getStart());o.push({sourceText:u,position:a,afterManagedResource:p,originalLine:m.line+1,leadingComments:f.length>0?f:void 0})}else c.isManaged&&(e=c);return o}function x(t,n){const i=n.getFullStart(),o=n.getEnd(),e=t.slice(i,o).split(`
2
- `),c=e.findIndex(a=>a.trim()!=="");return e.slice(c===-1?0:c).join(`
3
- `)}function y(t,n){const i=[],o=l.getLeadingCommentRanges(t,n.getFullStart());if(o)for(const s of o){const e=t.slice(s.pos,s.end);i.push(e)}return i}function P(t,n,i,o){const s=o??r(t);for(const e of s)if(e.type===n&&e.resourceName===i)return{startPos:e.startPos,endPos:e.endPos,node:e.node};return null}function S(t,n,i){const o=i??r(t);let s=null;for(const e of o)e.type===n&&e.isManaged&&(s=e);return s}function h(t,n){const i=n??r(t),o={import:[],"app-init":[],tags:[],database:[],compute:[],storage:[],network:[],messaging:[],cdn:[],pattern:[],"vpc-peer":[],"vpc-peer-accepter":[],"cross-plan-connection":[],custom:[]};for(const s of i)o[s.type].push(s);return o}export{C as extractCustomCodeBlocks,P as findManagedResourcePosition,S as getLastManagedStatementOfType,h as getManagedResourcesByType};
1
+ var d=Object.defineProperty;var r=(t,e)=>d(t,"name",{value:e,configurable:!0});import*as g from"typescript";import{classifyStatements as a}from"./astStatementClassifier.js";const x={import:"after-imports","app-init":"after-app-init",tags:"after-tags"};function y(t){if(!t)return{position:"before-imports"};const e=x[t.type];return e?{position:e}:{position:"after-resource",afterManagedResource:{type:t.type,name:t.resourceName}}}r(y,"determineCustomBlockPosition");function h(t,e){const i=e??a(t),o=[],s=t.getFullText();let n=null;for(const c of i)if(c.type==="custom"&&!c.isManaged){const{position:f,afterManagedResource:u}=y(n),m=T(s,c.node),p=C(s,c.node),l=t.getLineAndCharacterOfPosition(c.node.getStart());o.push({sourceText:m,position:f,afterManagedResource:u,originalLine:l.line+1,leadingComments:p.length>0?p:void 0})}else c.isManaged&&(n=c);return o}r(h,"extractCustomCodeBlocks");function T(t,e){const i=e.getFullStart(),o=e.getEnd(),n=t.slice(i,o).split(`
2
+ `),c=n.findIndex(f=>f.trim()!=="");return n.slice(c===-1?0:c).join(`
3
+ `)}r(T,"getStatementTextWithComments");function C(t,e){const i=[],o=g.getLeadingCommentRanges(t,e.getFullStart());if(o)for(const s of o){const n=t.slice(s.pos,s.end);i.push(n)}return i}r(C,"extractLeadingComments");function M(t,e,i,o){const s=o??a(t);for(const n of s)if(n.type===e&&n.resourceName===i)return{startPos:n.startPos,endPos:n.endPos,node:n.node};return null}r(M,"findManagedResourcePosition");function R(t,e,i){const o=i??a(t);let s=null;for(const n of o)n.type===e&&n.isManaged&&(s=n);return s}r(R,"getLastManagedStatementOfType");function k(t,e){const i=e??a(t),o={import:[],"app-init":[],tags:[],database:[],compute:[],storage:[],network:[],messaging:[],cdn:[],pattern:[],"vpc-peer":[],"vpc-peer-accepter":[],"cross-plan-connection":[],custom:[]};for(const s of i)o[s.type].push(s);return o}r(k,"getManagedResourcesByType");export{h as extractCustomCodeBlocks,M as findManagedResourcePosition,R as getLastManagedStatementOfType,k as getManagedResourcesByType};
@@ -1 +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};
1
+ var k=Object.defineProperty;var n=(r,t)=>k(r,"name",{value:t,configurable:!0});import*as s from"typescript";import{isPlainObject as le,isIdentifierRef as de,isExpressionRef as xe,isCallRef as Re,isParsedObject as ge,asString as Ce,asNumber as Se,asBoolean as be,asStringArray as Ie,asStringUnion as ye,captureExtraProperties as Ne}from"../common/astCommonParser.js";import{findComputeResources as ke}from"../resources/astComputeParser.js";import{findSchedules as Be}from"../resources/astScheduleParser.js";import{classifyStatements as Pe}from"../common/astStatementClassifier.js";import{extractCustomCodeBlocks as ve,findManagedResourcePosition as Ve,getLastManagedStatementOfType as Le,getManagedResourcesByType as Oe}from"../common/astStatementQueries.js";import{convertToResourcePlan as De}from"./astPlanConverter.js";import{isAppGetAppCall as A,isExpressionRef as B,findFirstInAst as E,parseObjectLiteral as P,findVariableValue as T,evaluatePropertyAccess as v}from"../common/astCommonParser.js";import{findDatabaseResources as V,splitDatabaseResources as L}from"../resources/astDatabaseParser.js";import{findS3Resources as O,findS3FactoryResources as j}from"../resources/astStorageParser.js";import{findComputeResources as D}from"../resources/astComputeParser.js";import{findSchedules as w}from"../resources/astScheduleParser.js";import{findSQSResources as z}from"../resources/astMessagingParser.js";import{findCDNResource as F}from"../resources/astCdnParser.js";import{findVpcId as M,findNetworkConfig as q,findBackupConfig as G,findTunnelConfig as K,findNetworkResources as Q}from"../resources/astNetworkParser.js";import{findPatternResources as U}from"../resources/astPatternParser.js";import{classifyStatements as H}from"../common/astStatementClassifier.js";import{extractCustomCodeBlocks as J}from"../common/astStatementQueries.js";function fe(r,t){const e=s.createSourceFile("infrastructure.ts",r,s.ScriptTarget.Latest,!0,s.ScriptKind.TS),i=W(e),{appVariableName:o,appName:a}=Y(e),p=M(e),c=q(e),m=G(e),u=K(e),l=Q(e),d=V(e),{databases:x,dynamodb:R,clickhouse:g}=L(d),C=z(e),S=F(e),b=[...O(e),...j(e)],I=D(e),y=w(e),N=U(e),h=Z(e),f={sourceFile:e,imports:i,appVariableName:o,appName:a,vpcId:p,network:c,backup:m,tunnel:u,networkResources:l,databaseResources:x,dynamodbResources:R,clickhouseResources:g,sqsResources:C,cdnResource:S,s3Resources:b,computeResources:I,schedules:y,patternResources:N,tags:h};return t?.extractCustomCode&&(f.customCodeBlocks=J(e),f.classifiedStatements=H(e)),f}n(fe,"parseInfrastructure");function W(r){const t=[];return s.forEachChild(r,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(a=>a.name.text))),t.push(o)}}),t}n(W,"extractImports");function X(r,t){return s.isStringLiteral(t)?t.text:s.isIdentifier(t)?T(r,t.text)??"":s.isPropertyAccessExpression(t)?v(r,t)??"":""}n(X,"resolveAppName");function Y(r){return E(r,t=>{if(s.isVariableStatement(t))for(const e of t.declarationList.declarations){if(!e.initializer||!A(e.initializer))continue;const i=s.isIdentifier(e.name)?e.name.text:"",o=e.initializer.arguments.length>0?X(r,e.initializer.arguments[0]):"";return{appVariableName:i,appName:o}}})??{appVariableName:"",appName:""}}n(Y,"findAppVariable");function Z(r){const t={};function e(i){if(s.isCallExpression(i)&&s.isPropertyAccessExpression(i.expression)&&i.expression.name.text==="addTags"&&s.isIdentifier(i.expression.expression)&&i.arguments.length>0){const o=i.arguments[0];if(s.isObjectLiteralExpression(o)){const a=P(o);for(const[p,c]of Object.entries(a))typeof c=="string"?t[p]=c:B(c)&&(t[p]="default-value")}}s.forEachChild(i,e)}return n(e,"visit"),e(r),t}n(Z,"extractTags");export{be as asBoolean,Se as asNumber,Ce as asString,Ie as asStringArray,ye as asStringUnion,Ne as captureExtraProperties,Pe as classifyStatements,De as convertToResourcePlan,ve as extractCustomCodeBlocks,ke as findComputeResources,Ve as findManagedResourcePosition,Be as findSchedules,Le as getLastManagedStatementOfType,Oe as getManagedResourcesByType,Re as isCallRef,xe as isExpressionRef,de as isIdentifierRef,ge as isParsedObject,le as isPlainObject,fe as parseInfrastructure};
@@ -1,2 +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};
1
+ var u=Object.defineProperty;var c=(e,t)=>u(e,"name",{value:t,configurable:!0});import{ApplicationResourcePlanSchema as a,getZodErrorMessage as m}from"../../../schemas/resourceSchemas.js";import{z as f}from"zod";import{COST_ALLOCATION_TAG as i}from"../../../generation/infrastructure.js";import{convertDatabaseResources as l,convertDynamoDBResources as p,convertClickHouseResources as d}from"../resources/astDatabaseParser.js";import{convertS3Resources as R}from"../resources/astStorageParser.js";import{convertComputeResources as h}from"../resources/astComputeParser.js";import{convertSQSResources as v}from"../resources/astMessagingParser.js";import{convertCDNResource as g}from"../resources/astCdnParser.js";import{convertNetworkConfig as k,convertBackupConfig as I,convertTunnelConfig as b,convertAdditionalNetworks as S}from"../resources/astNetworkParser.js";import{applyPatternConfig as w}from"../resources/astPatternParser.js";import{KNOWN_FJALL_IMPORTS as y,isManagedModuleSpecifier as N}from"../common/astStatementClassifier.js";function C(e,t){for(const r of t){const o=e.compute.find(n=>n.variableName===r.targetVariableName);o!==void 0&&o.type==="lambda"&&(o.scheduleExpression=r.schedule)}}c(C,"applyScheduleBackfill");function A(e,t){Object.keys(t).length>0&&(e.tags={...t}),t[i]&&(e.owner=t[i])}c(A,"applyTagsAndOwner");function M(e){const t=[];for(const r of e)if(N(r.moduleSpecifier))if(r.moduleSpecifier==="@fjall/components-infrastructure"||r.moduleSpecifier==="@fjall/infrastructure"){const o=r.namedImports.filter(n=>!y.has(n));o.length>0&&t.push({moduleSpecifier:r.moduleSpecifier,namedImports:o,defaultImport:r.defaultImport})}else(r.namedImports.length>0||r.defaultImport)&&t.push(r);return t.length>0?t:void 0}c(M,"computeAdditionalManagedImports");function Z(e,t,r){const o={appName:t,type:"standard",database:[],s3:[],compute:[]};if(w(o,e.patternResources),e.vpcId&&(o.vpcId=e.vpcId),o.network=k(e.network),o.backup=I(e.backup),o.tunnel=b(e.tunnel),o.additionalNetworks=S(e.networkResources),A(o,e.tags),o.database=l(e.databaseResources),o.dynamodb=p(e.dynamodbResources),o.clickhouse=d(e.clickhouseResources),o.sqs=v(e.sqsResources),o.cdn=g(e.cdnResource,e.s3Resources,e.computeResources),o.s3=R(e.s3Resources),o.compute=h(e.computeResources,e.databaseResources,e.s3Resources,o),C(o,e.schedules),o.additionalManagedImports=M(e.imports),r?.skipValidation)return o;try{return a.parse(o)}catch(n){if(n instanceof f.ZodError){const s=m(n);throw new Error(`Invalid infrastructure configuration:
2
+ ${s}`)}throw n}}c(Z,"convertToResourcePlan");export{Z as convertToResourcePlan};
@@ -1 +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};
1
+ var y=Object.defineProperty;var u=(e,n)=>y(e,"name",{value:n,configurable:!0});import*as m from"typescript";import{asString as c,asStringArray as I,asStringUnion as p,captureExtraProperties as O,findFirstInAst as P,isFactoryBuildCall as _,isFactoryMethodCall as x,isIdentifierRef as E,isParsedObject as A,parseObjectLiteral as G}from"../common/astCommonParser.js";function S(e){if(e.arguments.length<2)return null;const n=e.arguments[0],s=e.arguments[1];return!m.isStringLiteral(n)||!m.isObjectLiteralExpression(s)?null:{resourceName:n.text,config:G(s),node:e}}u(S,"extractCDNResource");function v(e,n,s){const f=n.find(i=>i.variableName===e);if(f)return f.resourceName;const r=s.find(i=>i.variableName===e||i.resourceName.charAt(0).toLowerCase()+i.resourceName.slice(1)===e);return r?r.resourceName:e}u(v,"resolveOriginIdentifier");const C=["CACHING_OPTIMIZED","CACHING_DISABLED"];function w(e){return P(e,n=>{if(!m.isCallExpression(n)||!x(n,"addCdn"))return;const s=n.arguments[0];if(_(s,"CdnFactory"))return S(s)??void 0})}u(w,"findCDNResource");function F(e,n,s){if(!e)return;const f=e,r=f.config,i=u(t=>E(t)?v(t.__identifier,n,s):c(t)??"","resolveOrigin"),D=i(r.origin),a={name:f.resourceName,defaultOriginRef:D};if(Array.isArray(r.behaviours)){const t=r.behaviours.filter(A).map(o=>({pathPattern:c(o.pathPattern)??"",originRef:i(o.origin),...p(o.cachePolicy,C)!==void 0&&{cachePolicy:p(o.cachePolicy,C)}}));t.length>0&&(a.behaviours=t)}const g=c(r.customDomain);if(g)a.customDomain=g;else{const t=I(r.domainNames);t&&t.length>0&&(a.customDomain=t[0])}const d=c(r.certificateArn);if(d&&(a.certificateArn=d),r.accessGate!==void 0){if(r.accessGate===!1)a.accessGate=!1;else if(A(r.accessGate)){const t=r.accessGate,o=c(t.type),l=c(t.username),h=c(t.password);o==="basic-auth"&&l&&h&&(a.accessGate={type:"basic-auth",username:l,password:h})}}const N=O(r,new Set(["originType","origin","behaviours","customDomain","domainNames","certificateArn","accessGate"]));return N.length>0&&(a.extraProperties=N),a}u(F,"convertCDNResource");export{F as convertCDNResource,w as findCDNResource};
@@ -1 +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};
1
+ var S=Object.defineProperty;var r=(a,e)=>S(a,"name",{value:e,configurable:!0});import*as c from"typescript";import{asNumber as N,asString as s,captureExtraProperties as k,isParsedObject as y,omitUndefined as g,parseObjectLiteral as T}from"../common/astCommonParser.js";const x=new Set(["type","databaseName","instanceType","coldTier","optimiseSchedule","backupSchedule","backupRetentionDays"]);function v(a){const e=a.node;if(!c.isCallExpression(e))return null;const o=e.arguments[0];if(!c.isCallExpression(o)||o.arguments.length<2)return null;const u=o.arguments[1];if(!c.isObjectLiteralExpression(u))return null;const i=T(u),t={resourceName:a.resourceName,databaseName:a.databaseName,node:a.node};a.variableName&&(t.variableName=a.variableName);const d=s(i.instanceType);d&&(t.instanceType=d);const l=i.coldTier;l===!1?t.coldTier=!1:y(l)&&s(l.mode)==="s3"&&(t.coldTier={mode:"s3"});const p=i.optimiseSchedule;if(p===!1)t.optimiseSchedule=!1;else{const n=s(p);n&&(t.optimiseSchedule=n)}const m=i.backupSchedule;if(m===!1)t.backupSchedule=!1;else{const n=s(m);n&&(t.backupSchedule=n)}const f=N(i.backupRetentionDays);f!==void 0&&(t.backupRetentionDays=f);const b=k(i,x);return b.length>0&&(t.extraProperties=b),t}r(v,"extractClickHouseFields");function D(a){if(a.length!==0)return a.map(e=>({name:e.resourceName,type:"ClickHouse",databaseName:e.databaseName,...g({instanceType:e.instanceType,coldTier:e.coldTier,optimiseSchedule:e.optimiseSchedule,backupSchedule:e.backupSchedule,backupRetentionDays:e.backupRetentionDays,variableName:e.variableName,extraProperties:e.extraProperties})}))}r(D,"convertClickHouseResources");export{D as convertClickHouseResources,v as extractClickHouseFields};
@@ -1 +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};
1
+ var u=Object.defineProperty;var s=(n,r)=>u(n,"name",{value:r,configurable:!0});import{isIdentifierRef as c,isParsedObject as f}from"../common/astCommonParser.js";const d=10;function S(n,r){return Array.isArray(n)?n.filter(c).map(e=>r.find(t=>t.variableName===e.__identifier)).filter(e=>e!==void 0).map(e=>e.resourceName):[]}s(S,"resolveConnectedDatabaseNames");function E(n,r){return Array.isArray(n)?n.filter(c).map(e=>r.find(t=>t.variableName===e.__identifier)).filter(e=>e!==void 0).map(e=>e.resourceName):[]}s(E,"resolveConnectedStorageNames");function N(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<=d;A++)(a[`DATABASE_HOST_${A}`]||a[`DATABASE_PORT_${A}`]||a[`DATABASE_NAME_${A}`])&&(n.needsConnection=!0)}s(N,"inferDatabaseConnectionsFromEnv");function T(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])}s(T,"inferStorageConnectionsFromEnv");export{N as inferDatabaseConnectionsFromEnv,T as inferStorageConnectionsFromEnv,S as resolveConnectedDatabaseNames,E as resolveConnectedStorageNames};
@@ -1 +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};
1
+ var v=Object.defineProperty;var a=(e,n)=>v(e,"name",{value:n,configurable:!0});import*as E from"typescript";import{asString as f,asNumber as y,asBoolean as m,asStringArray as C,asStringUnion as d,captureExtraProperties as T,collectFromAst as _,extractVariableName as b,isFactoryBuildCall as A,isFactoryMethodCall as x,isParsedObject as S,parseObjectLiteral as O}from"../common/astCommonParser.js";import{COMPUTE_ARCHITECTURES as D,COMPUTE_TYPES as R,DEPLOYMENT_TYPES as Y,EC2_INSTANCE_TYPES as K,FUNCTION_URL_AUTH_TYPES as U}from"../../../schemas/constants.js";import{assignIfDefined as c,extractCallStringArg as F,extractClusterConfig as L,extractEnumString as N,isEnvironmentRecord as h,parseEcsService as k}from"./astComputeParserHelpers.js";import{inferDatabaseConnectionsFromEnv as H,inferStorageConnectionsFromEnv as V,resolveConnectedDatabaseNames as M,resolveConnectedStorageNames as W}from"./astComputeConnectionParser.js";function z(e){if(e.arguments.length<2)return null;const n=e.arguments[0],i=e.arguments[1];if(!E.isStringLiteral(n)||!E.isObjectLiteralExpression(i))return null;const t=n.text,r=O(i);return{resourceName:t,type:f(r.type)??"ecs",config:r,node:e}}a(z,"extractComputeResource");function Z(e){return _(e,n=>{if(!E.isCallExpression(n)||!x(n,"addCompute"))return null;const i=n.arguments[0];if(!A(i,"ComputeFactory"))return null;const t=z(i);if(t){const r=b(n);r&&(t.variableName=r)}return t})}a(Z,"findComputeResources");function u(e,n,i){const t=T(e.config,i);t.length>0&&(n.extraProperties=t)}a(u,"applyExtras");function I(e,n){const i=e.config.docker;if(S(i)){const o=f(i.path),g=f(i.context),l=f(i.target);(o!==void 0||g!==void 0||l!==void 0)&&(n.docker={...o!==void 0&&{path:o},...g!==void 0&&{context:g},...l!==void 0&&{target:l}})}const t=e.config.cluster;t!==void 0&&(n.cluster=L(t));const r=e.config.services;r!==void 0&&Array.isArray(r)&&(n.services=r.filter(o=>S(o)).map(k)),u(e,n,new Set(["type","ecrRepository","docker","cluster","services","connections"]))}a(I,"convertEcsCompute");function B(e,n){if(c(n,"deployment",d(e.config.deployment,Y)),c(n,"timeout",y(e.config.timeout)),c(n,"memory",y(e.config.memorySize)??y(e.config.memory)),c(n,"handler",f(e.config.handler)),c(n,"runtime",N(e.config.runtime,"Runtime")),h(e.config.environment)&&(n.environment=e.config.environment),h(e.config.secrets))n.secrets=e.config.secrets;else{const s=C(e.config.secrets);s&&(n.ssmSecrets=s)}const i=e.config.functionUrl;if(S(i)){const s=d(N(i.authType,"FunctionUrlAuthType"),U);s!==void 0&&(n.functionUrl={authType:s})}const t=e.config.code;if(t!==void 0){const s=F(t);s&&(n.codePath=s)}c(n,"description",f(e.config.lambdaDescription)),c(n,"architecture",d(N(e.config.architecture,"Architecture"),D)),c(n,"ephemeralStorageSize",y(e.config.ephemeralStorageSize)),c(n,"functionName",f(e.config.functionName)),c(n,"ssmSecretsPath",f(e.config.ssmSecretsPath)),u(e,n,new Set(["type","deployment","timeout","memorySize","memory","handler","runtime","environment","secrets","functionUrl","code","connections","ecrRepository","containerSecretsImport","lambdaDescription","architecture","ephemeralStorageSize","functionName","ssmSecretsPath"]))}a(B,"convertLambdaCompute");function G(e,n){c(n,"instanceType",d(e.config.instanceType,K));const i=e.config.ssh;i===!1?n.enableSSH=!1:i!==void 0&&S(i)?n.enableSSH=!0:c(n,"enableSSH",m(e.config.enableSSH)),c(n,"keyName",f(e.config.keyName)),c(n,"userData",f(e.config.userData)),e.config.securityGroups!==void 0&&(n.securityGroups=C(e.config.securityGroups)),u(e,n,new Set(["type","instanceType","ssh","enableSSH","keyName","userData","securityGroups","connections"]))}a(G,"convertEc2Compute");function j(e,n,i,t){let r=n.config.connections;if(!r&&Array.isArray(n.config.services)){const g=n.config.services[0];S(g)&&(r=g.connections)}if(!r)return;const s=M(r,i);s.length>0&&(e.needsConnection=!0,e.connectedDatabase=s);const o=W(r,t);o.length>0&&(e.connectedStorage=o)}a(j,"applyConnectionConfig");function w(e,n){({ecs:I,lambda:B,ec2:G})[e.type]?.(n,e)}a(w,"applyTypeSpecificConfig");function $(e,n,i,t){return e.map(r=>{const s=d(r.config.type,R)??"ecs",o={name:r.resourceName,type:s,needsConnection:!1,connectedDatabase:[],...r.variableName&&{variableName:r.variableName}};return j(o,r,n,i),w(o,r),H(o,r.config.services,t.database),V(o,r.config.services,t.s3),o})}a($,"convertComputeResources");export{$ as convertComputeResources,Z as findComputeResources};
@@ -1 +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};
1
+ var S=Object.defineProperty;var a=(e,n)=>S(e,"name",{value:n,configurable:!0});import{isPlainObject as y,isParsedObject as s,isExpressionRef as C,isCallRef as h,asString as r,asNumber as i,asBoolean as f,asStringArray as m,asStringUnion as d,captureExtraProperties as p}from"../common/astCommonParser.js";import{ECS_CAPACITY_PROVIDERS as E,LOAD_BALANCER_TYPES as P,SCALING_TYPES as _,AMI_HARDWARE_TYPES as x}from"../../../schemas/constants.js";function A(e){return e!==void 0&&y(e)}a(A,"isEnvironmentRecord");function N(e){if(!s(e))return;const n={};for(const[t,o]of Object.entries(e))if(s(o)){const c=r(o.id),u=r(o.name);c&&u&&(n[t]={id:c,name:u,field:r(o.field)})}return Object.keys(n).length>0?n:void 0}a(N,"parseContainerSecretsImport");function g(e){if(!s(e))return;const n=m(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)}}a(g,"parseContainerHealthCheck");function O(e){const t=p(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:A(e.environment)?e.environment:void 0,essential:f(e.essential),command:m(e.command),entryPoint:m(e.entryPoint),secretsImport:N(e.secretsImport),ssmSecrets:m(e.secrets),healthCheck:g(e.healthCheck),extraProperties:t.length>0?t:void 0}}a(O,"parseServiceContainer");function T(e){if(Array.isArray(e))return e.filter(s).map(n=>({path:r(n.path),host:r(n.host),priority:i(n.priority),healthCheckPath:r(n.healthCheckPath)}));if(s(e))return{path:r(e.path),host:r(e.host),priority:i(e.priority),healthCheckPath:r(e.healthCheckPath)}}a(T,"parseServiceRouting");function I(e){if(e===!1)return!1;if(s(e))return{minCapacity:i(e.minCapacity),maxCapacity:i(e.maxCapacity),desiredCount:i(e.desiredCount),scalingType:d(e.scalingType,_)}}a(I,"parseServiceScaling");const R=new Set(["instanceType","amiHardwareType","minCapacity","maxCapacity","memoryLimitMiB","warmPool"]);function l(e){if(!s(e))return;const n=e.warmPool,t=s(n)?{minSize:i(n.minSize),reuseOnScaleIn:f(n.reuseOnScaleIn)}:void 0,o=p(e,R);return{instanceType:r(e.instanceType),amiHardwareType:d(e.amiHardwareType,x),minCapacity:i(e.minCapacity),maxCapacity:i(e.maxCapacity),memoryLimitMiB:i(e.memoryLimitMiB),warmPool:t,extraProperties:o.length>0?o:void 0}}a(l,"parseServiceEc2Config");const B=new Set(["domain","loadBalancer","directAccess"]);function k(e){if(!s(e))return;const n=e.loadBalancer,t=p(e,B);return{domain:r(e.domain),loadBalancer:n===!1?!1:d(n,P),directAccess:f(e.directAccess),...t.length>0&&{extraProperties:t}}}a(k,"extractClusterConfig");function W(e){const n=e.containers,t=Array.isArray(n)?n.filter(s).map(O):void 0,c=p(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:K(e.docker),ssmSecretsPath:r(e.ssmSecretsPath),containers:t,routing:T(e.routing),cpu:i(e.cpu),memoryLimitMiB:i(e.memoryLimitMiB),desiredCount:i(e.desiredCount),scaling:I(e.scaling),capacityProvider:d(e.capacityProvider,E)??"FARGATE",ec2Config:l(e.ec2Config),...c.length>0&&{extraProperties:c}}}a(W,"parseEcsService");function K(e){if(!s(e))return;const n=r(e.path);if(n===void 0)return;const t=r(e.context),o=r(e.target);return{path:n,...t!==void 0&&{context:t},...o!==void 0&&{target:o}}}a(K,"parseServiceDocker");function M(e,n){const t=r(e);if(t)return t;if(C(e)&&e.__expression.startsWith(n+"."))return e.__expression.slice(n.length+1)}a(M,"extractEnumString");function b(e){return h(e)?e.__call.match(/\(\s*"([^"]+)"\s*\)/)?.[1]:void 0}a(b,"extractCallStringArg");function D(e,n,t){t!==void 0&&(e[n]=t)}a(D,"assignIfDefined");export{D as assignIfDefined,b as extractCallStringArg,k as extractClusterConfig,M as extractEnumString,A as isEnvironmentRecord,W as parseEcsService};
@@ -1 +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};
1
+ var A=Object.defineProperty;var l=(r,e)=>A(r,"name",{value:e,configurable:!0});import*as p from"typescript";import{constIncludes as R,DATABASE_ENGINES as I}from"../../../schemas/constants.js";import{asBoolean as u,asNumber as g,asString as o,asStringArray as E,captureExtraProperties as S,collectFromAst as h,extractVariableName as D,isCallRef as x,isFactoryBuildCall as N,isFactoryMethodCall as w,omitUndefined as v,parseObjectLiteral as C,parseOptionalConfig as f,parseBooleanOrConfig as m,resolveTemplateLiteral as P,typed as c}from"../common/astCommonParser.js";import{extractDynamoDBFields as T}from"./astDynamoDBParser.js";import{extractClickHouseFields as W}from"./astClickHouseParser.js";import{convertDynamoDBResources as Y}from"./astDynamoDBParser.js";import{convertClickHouseResources as Q}from"./astClickHouseParser.js";function B(r){const e=o(r.databaseEngine);if(e!==void 0&&R(I,e))return e;const i=r.engine;if(x(i)){const t=String(i.__call);if(t.includes("postgres")||t.includes("auroraPostgres"))return"postgresql";if(t.includes("mysql")||t.includes("auroraMysql"))return"mysql"}}l(B,"extractDatabaseEngine");function F(r){const e=r.engine;if(x(e))return String(e.__call)}l(F,"extractEngineExpression");const k=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 _(r,e,i){if(i.arguments.length<2)return null;const t=i.arguments[0],a=i.arguments[1];if(!p.isStringLiteral(t)&&!p.isTemplateExpression(t))return null;const s=p.isStringLiteral(t)?t.text:P(r,t);if(!p.isObjectLiteralExpression(a))return null;const n=C(a),d={resourceName:s,type:o(n.type)??"",databaseName:o(n.databaseName)??"",databaseEngine:B(n),engineExpression:F(n),port:g(n.port),deletionProtection:u(n.deletionProtection),instanceType:o(n.instanceType),multiAz:u(n.multiAz),publiclyAccessible:u(n.publiclyAccessible),enableSecretRotation:u(n.enableSecretRotation),encryption:f(n.encryption,c()),databaseInsights:m(n.databaseInsights,c()),proxy:m(n.proxy,c()),readReplica:m(n.readReplica,c()),credentials:f(n.credentials,c()),writer:f(n.writer,c()),readers:m(n.readers,c()),backupRetention:g(n.backupRetention),preferredMaintenanceWindow:o(n.preferredMaintenanceWindow),primaryRegion:o(n.primaryRegion),secondaryRegions:E(n.secondaryRegions),globalClusterIdentifier:o(n.globalClusterIdentifier),enableGlobalWriteForwarding:u(n.enableGlobalWriteForwarding),allocatedStorage:g(n.allocatedStorage),monitoringInterval:g(n.monitoringInterval),snapshotIdentifier:o(n.snapshotIdentifier),snapshotUsername:o(n.snapshotUsername),node:e},y=D(e);y&&(d.variableName=y);const b=S(n,k);return b.length>0&&(d.extraProperties=b),d}l(_,"extractDatabaseResource");function U(r){return h(r,e=>{if(!p.isCallExpression(e)||!w(e,"addDatabase"))return null;const i=e.arguments[0];return N(i,"DatabaseFactory")?_(r,e,i):null})}l(U,"findDatabaseResources");function H(r){const e=[],i=[],t=[];for(const a of r)if(a.type==="DynamoDB"){const s=T(a);s&&i.push(s)}else if(a.type==="ClickHouse"){const s=W(a);s&&t.push(s)}else e.push(a);return{databases:e,dynamodb:i,clickhouse:t}}l(H,"splitDatabaseResources");const G=["Instance","Aurora","GlobalAurora"];function j(r){return r.filter(e=>e.type!=="DynamoDB").map(e=>({name:e.resourceName,type:R(G,e.type)?e.type:"Instance",databaseName:e.databaseName,...v({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})}))}l(j,"convertDatabaseResources");export{Q as convertClickHouseResources,j as convertDatabaseResources,Y as convertDynamoDBResources,U as findDatabaseResources,H as splitDatabaseResources};
@@ -1 +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};
1
+ var S=Object.defineProperty;var a=(t,e)=>S(t,"name",{value:e,configurable:!0});import*as l from"typescript";import{asBoolean as D,asString as u,asStringUnion as B,captureExtraProperties as E,isParsedObject as A,omitUndefined as O,parseObjectLiteral as Y}from"../common/astCommonParser.js";const I=["S","N","B"];function s(t){if(!A(t))return;const e=u(t.name),i=B(t.type,I);if(!(!e||!i))return{name:e,type:i}}a(s,"parseDynamoDBKey");function v(t){const e=t.node;if(!l.isCallExpression(e))return null;const i=e.arguments[0];if(!l.isCallExpression(i)||i.arguments.length<2)return null;const c=i.arguments[1];if(!l.isObjectLiteralExpression(c))return null;const r=Y(c),m=s(r.partitionKey);if(!m)return null;const n={resourceName:t.resourceName,partitionKey:m,node:t.node};t.variableName&&(n.variableName=t.variableName);const f=s(r.sortKey);if(f&&(n.sortKey=f),Array.isArray(r.globalSecondaryIndexes)){const K=r.globalSecondaryIndexes.filter(A).map(o=>{const x=s(o.partitionKey);if(!x)return null;const N=u(o.indexName);if(!N)return null;const g={indexName:N,partitionKey:x},b=s(o.sortKey);return b&&(g.sortKey=b),g}).filter(o=>o!==null);K.length>0&&(n.globalSecondaryIndexes=K)}const d=u(r.ttlAttribute);d&&(n.ttlAttribute=d);const y=D(r.stream);y!==void 0&&(n.stream=y);const p=E(r,new Set(["type","databaseName","partitionKey","sortKey","globalSecondaryIndexes","ttlAttribute","stream"]));return p.length>0&&(n.extraProperties=p),n}a(v,"extractDynamoDBFields");function j(t){if(t.length!==0)return t.map(e=>({name:e.resourceName,partitionKey:e.partitionKey,...O({sortKey:e.sortKey,globalSecondaryIndexes:e.globalSecondaryIndexes,ttlAttribute:e.ttlAttribute,stream:e.stream,variableName:e.variableName,extraProperties:e.extraProperties})}))}a(j,"convertDynamoDBResources");export{j as convertDynamoDBResources,v as extractDynamoDBFields};
@@ -1 +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};
1
+ var p=Object.defineProperty;var i=(e,t)=>p(e,"name",{value:t,configurable:!0});import*as a from"typescript";import{SqsRemovalPolicySchema as S}from"../../../schemas/messagingSchemas.js";import{asBoolean as m,asNumber as s,asString as d,captureExtraProperties as y,collectFromAst as g,extractVariableName as P,isFactoryBuildCall as x,isFactoryMethodCall as b,isParsedObject as v,omitUndefined as f,parseObjectLiteral as N}from"../common/astCommonParser.js";function R(e,t){if(t.arguments.length<2)return null;const r=t.arguments[0],c=t.arguments[1];if(!a.isStringLiteral(r)||!a.isObjectLiteralExpression(c))return null;const n=N(c),o={resourceName:r.text,queueType:d(n.queueType)??"standard",visibilityTimeout:s(n.visibilityTimeout),retentionPeriod:s(n.messageRetentionPeriod),contentBasedDeduplication:m(n.contentBasedDeduplication),removalPolicy:d(n.removalPolicy),node:e},l=P(e);l&&(o.variableName=l);const u=y(n,new Set(["type","queueType","visibilityTimeout","messageRetentionPeriod","contentBasedDeduplication","removalPolicy"]));return u.length>0&&(o.extraProperties=u),o}i(R,"extractSQSResource");function L(e){if(e!=null){if(e===!1)return!1;if(v(e))return f({enabled:m(e.enabled),maxReceiveCount:s(e.maxReceiveCount)})}}i(L,"parseDeadLetterQueueConfig");function _(e){return g(e,t=>{if(!a.isCallExpression(t)||!b(t,"addMessaging"))return null;const r=t.arguments[0];return x(r,"MessagingFactory")?R(t,r):null})}i(_,"findSQSResources");function A(e){if(e.length!==0)return e.map(t=>({name:t.resourceName,queueType:t.queueType==="fifo"?"fifo":"standard",...f({visibilityTimeout:t.visibilityTimeout,retentionPeriod:t.retentionPeriod,contentBasedDeduplication:t.contentBasedDeduplication,removalPolicy:E(t.removalPolicy),variableName:t.variableName,extraProperties:t.extraProperties})}))}i(A,"convertSQSResources");const T=new Set(S.options);function B(e){return T.has(e)}i(B,"isSqsRemovalPolicy");function E(e){return e!==void 0&&B(e)?e:void 0}i(E,"toSqsRemovalPolicy");export{A as convertSQSResources,_ as findSQSResources,L as parseDeadLetterQueueConfig};
@@ -1 +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};
1
+ var z=Object.defineProperty;var s=(n,e)=>z(n,"name",{value:e,configurable:!0});import*as r from"typescript";import{constIncludes as A,BACKUP_VAULT_TIERS as N}from"../../../schemas/constants.js";import{FlowLogDestinationSchema as O}from"../../../schemas/networkSchemas.js";import{asNumber as p,asString as l,collectFromAst as k,extractVariableName as F,findFirstInAst as u,isAppGetAppCall as c,isFactoryBuildCall as b,isFactoryMethodCall as S,isNamedProperty as f,isParsedObject as T,omitUndefined as g,parseObjectLiteral as d,parseBooleanOrConfig as w}from"../common/astCommonParser.js";const h=new Set(O.options);function j(n){if(n!==void 0)return h.has(n)?n:void 0}s(j,"asFlowLogDestination");function y(n){return{maxAzs:p(n.maxAzs),natGateways:w(n.natGateways,e=>({count:p(e.count)})),flowLogs:w(n.flowLogs,e=>({destination:l(e.destination),retentionDays:p(e.retentionDays)})),vpcEndpoints:T(n.vpcEndpoints)?n.vpcEndpoints:void 0}}s(y,"parseNetworkConfigFields");function C(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 a=t.text,o=r.isObjectLiteralExpression(i)?d(i):{},E=y(o),m={name:a,config:g({...E}),node:n},x=F(n);return x&&(m.variableName=x),m}s(C,"extractNetworkResource");function I(n){return u(n,e=>{if(!c(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(f(i,"network")&&r.isObjectLiteralExpression(i.initializer)){for(const a of i.initializer.properties)if(f(a,"useExisting")&&r.isStringLiteral(a.initializer))return a.initializer.text}}})}s(I,"findVpcId");function B(n){return u(n,e=>{if(!c(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(f(i,"network")){if(i.initializer.kind===r.SyntaxKind.FalseKeyword)return;if(r.isObjectLiteralExpression(i.initializer)&&!i.initializer.properties.some(o=>f(o,"useExisting"))){const o=d(i.initializer);return y(o)}}}})}s(B,"findNetworkConfig");function U(n){return u(n,e=>{if(!c(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(f(i,"backup")){if(i.initializer.kind===r.SyntaxKind.FalseKeyword)return!1;if(r.isObjectLiteralExpression(i.initializer)){const a=d(i.initializer),o=l(a.tier);if(o)return{tier:o}}}}})}s(U,"findBackupConfig");function P(n){return u(n,e=>{if(!c(e)||e.arguments.length<=1)return;const t=e.arguments[1];if(r.isObjectLiteralExpression(t)){for(const i of t.properties)if(f(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 a=d(i.initializer),o=l(a.instanceType);return o?{instanceType:o}:{}}}}})}s(P,"findTunnelConfig");function _(n){return k(n,e=>{if(!r.isCallExpression(e)||!S(e,"addNetwork"))return null;const t=e.arguments[0];return b(t,"NetworkFactory")?C(e,t):null})}s(_,"findNetworkResources");function L(n){const e=n.flowLogs;return{...g({maxAzs:n.maxAzs,natGateways:n.natGateways,vpcEndpoints:n.vpcEndpoints}),...e!==void 0&&{flowLogs:e===!1?!1:g({destination:j(e.destination),retentionDays:e.retentionDays})}}}s(L,"buildNetworkFields");function V(n){if(n)return L(n)}s(V,"convertNetworkConfig");function M(n){if(n===void 0)return;if(n===!1)return!1;const e=n.tier;if(A(N,e))return{tier:e}}s(M,"convertBackupConfig");function R(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}s(R,"convertTunnelConfig");function W(n){if(!(!n||n.length===0))return n.map(e=>({name:e.name,...L(e.config)}))}s(W,"convertAdditionalNetworks");export{L as buildNetworkFields,W as convertAdditionalNetworks,M as convertBackupConfig,V as convertNetworkConfig,R as convertTunnelConfig,U as findBackupConfig,B as findNetworkConfig,_ as findNetworkResources,P as findTunnelConfig,I as findVpcId};