@fjall/generator 2.34.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.minified +1 -1
- package/dist/src/ast/astTestHelpers.js +1 -1
- package/dist/src/ast/domain/astDomainParser.d.ts +15 -7
- package/dist/src/ast/domain/astDomainParser.js +1 -1
- package/dist/src/ast/index.d.ts +1 -1
- package/dist/src/ast/mutation/astCodeInjection.js +4 -4
- package/dist/src/ast/mutation/astExpressionEvaluator.js +1 -1
- package/dist/src/ast/mutation/astSurgicalModification.js +5 -5
- package/dist/src/ast/parsers/common/astCommonParser.js +1 -1
- package/dist/src/ast/parsers/common/astStatementClassifier.js +1 -1
- package/dist/src/ast/parsers/common/astStatementQueries.js +3 -3
- package/dist/src/ast/parsers/orchestrator/astInfrastructureParser.js +1 -1
- package/dist/src/ast/parsers/orchestrator/astPlanConverter.js +2 -2
- package/dist/src/ast/parsers/resources/astCdnParser.js +1 -1
- package/dist/src/ast/parsers/resources/astClickHouseParser.js +1 -1
- package/dist/src/ast/parsers/resources/astComputeConnectionParser.js +1 -1
- package/dist/src/ast/parsers/resources/astComputeParser.js +1 -1
- package/dist/src/ast/parsers/resources/astComputeParserHelpers.js +1 -1
- package/dist/src/ast/parsers/resources/astDatabaseParser.js +1 -1
- package/dist/src/ast/parsers/resources/astDynamoDBParser.js +1 -1
- package/dist/src/ast/parsers/resources/astMessagingParser.js +1 -1
- package/dist/src/ast/parsers/resources/astNetworkParser.js +1 -1
- package/dist/src/ast/parsers/resources/astPatternParser.js +1 -1
- package/dist/src/ast/parsers/resources/astScheduleParser.js +1 -1
- package/dist/src/ast/parsers/resources/astStorageParser.js +1 -1
- package/dist/src/aws/regions.js +1 -1
- package/dist/src/codemod/_internal.js +1 -1
- package/dist/src/codemod/drift/detect.js +1 -1
- package/dist/src/codemod/drift/merge.js +1 -1
- package/dist/src/codemod/drift/snapshot.js +1 -1
- package/dist/src/codemod/edits/addResource/bodyIndex.js +1 -1
- package/dist/src/codemod/edits/addResource/propertyBuilder.js +1 -1
- package/dist/src/codemod/edits/addResource.js +1 -1
- package/dist/src/codemod/edits/appendAccountToStage.js +1 -1
- package/dist/src/codemod/edits/controlFlowPolicy.js +1 -1
- package/dist/src/codemod/edits/crossPlanConnection.js +1 -1
- package/dist/src/codemod/edits/driftPolicy.js +1 -1
- package/dist/src/codemod/edits/ensureImports.js +1 -1
- package/dist/src/codemod/edits/findInsertionPosition.js +1 -1
- package/dist/src/codemod/edits/modifyResource/literalConversion.js +1 -1
- package/dist/src/codemod/edits/modifyResource.js +1 -1
- package/dist/src/codemod/edits/removeResource/commentHeuristic.js +1 -1
- package/dist/src/codemod/edits/removeResource/importPruning.js +1 -1
- package/dist/src/codemod/edits/removeResource.js +1 -1
- package/dist/src/codemod/edits/vpcPeer.js +1 -1
- package/dist/src/codemod/edits/vpcPeerAccepter.js +1 -1
- package/dist/src/codemod/fileRewriter/builders.js +1 -1
- package/dist/src/codemod/fileRewriter/locateByRange.js +1 -1
- package/dist/src/codemod/fileRewriter/parse.js +2 -2
- package/dist/src/codemod/fileRewriter/print.js +2 -2
- package/dist/src/codemod/historyPaths.js +1 -1
- package/dist/src/codemod/listResources.js +1 -1
- package/dist/src/codemod/llmFallback/apply.js +1 -1
- package/dist/src/codemod/llmFallback/claudeTier.js +1 -1
- package/dist/src/codemod/llmFallback/egressGate.js +1 -1
- package/dist/src/codemod/llmFallback/morphTier.js +2 -2
- package/dist/src/codemod/llmFallback/prompt.js +13 -13
- package/dist/src/codemod/llmFallback/runFallback.js +1 -1
- package/dist/src/codemod/llmFallback/shouldTryFallback.js +1 -1
- package/dist/src/codemod/llmFallback/signals.js +1 -1
- package/dist/src/codemod/llmFallback/telemetryEvents.js +1 -1
- package/dist/src/codemod/llmFallback/tierRunner.js +1 -1
- package/dist/src/codemod/registry.js +1 -1
- package/dist/src/codemod/semanticIndex/classifyControlFlow.js +1 -1
- package/dist/src/codemod/semanticIndex/findReferences.js +2 -2
- package/dist/src/codemod/semanticIndex/listImports.js +1 -1
- package/dist/src/codemod/semanticIndex/locateByShape.js +1 -1
- package/dist/src/codemod/semanticIndex/projectCache.js +1 -1
- package/dist/src/codemod/semanticIndex/resolveConstructByLiteralProperty.js +1 -1
- package/dist/src/codemod/validationGate/gates/classify.js +1 -1
- package/dist/src/codemod/validationGate/gates/locate.js +1 -1
- package/dist/src/codemod/validationGate/types.js +1 -1
- package/dist/src/detection/index.js +1 -1
- package/dist/src/dns/bindParser.js +2 -2
- package/dist/src/dns/bindWriter.js +2 -2
- package/dist/src/dns/domainFileGenerator.js +18 -28
- package/dist/src/dns/domainRecords.d.ts +11 -0
- package/dist/src/dns/domainRecords.js +1 -1
- package/dist/src/generation/common.js +7 -7
- package/dist/src/generation/compute/ec2.js +3 -3
- package/dist/src/generation/compute/ecs.js +24 -24
- package/dist/src/generation/compute/lambda.js +8 -8
- package/dist/src/generation/compute/shared.js +4 -4
- package/dist/src/generation/compute.js +5 -5
- package/dist/src/generation/database.js +18 -18
- package/dist/src/generation/generatePatternCode.js +16 -16
- package/dist/src/generation/infrastructure.js +14 -14
- package/dist/src/generation/messagingConnections.js +1 -1
- package/dist/src/generation/storage.js +14 -14
- package/dist/src/generation/storageConnections.js +1 -1
- package/dist/src/planning/generateResourceChange.js +1 -1
- package/dist/src/planning/openNextPlanning.js +1 -1
- package/dist/src/planning/resourceAddition.js +1 -1
- package/dist/src/planning/resourceConnections.js +1 -1
- package/dist/src/planning/resourcePlanning.js +1 -1
- package/dist/src/planning/staticSitePlanning.js +1 -1
- package/dist/src/presets/patternTierPresets.js +1 -1
- package/dist/src/presets/storagePresets.js +1 -1
- package/dist/src/presets/tierPresets.js +1 -1
- package/dist/src/schemas/baseSchemas.js +2 -2
- package/dist/src/schemas/computeSchemas.js +1 -1
- package/dist/src/schemas/constants.js +1 -1
- package/dist/src/schemas/devRolePolicies.js +1 -1
- package/dist/src/schemas/instanceTypeArchitecture.js +1 -1
- package/dist/src/schemas/securityBoundary.js +1 -1
- package/dist/src/types/Result.js +1 -1
- package/dist/src/validation/validationPatterns.js +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
var v=Object.defineProperty;var o=(t,e)=>v(t,"name",{value:e,configurable:!0});import*as h from"typescript";import{STATIC_SITE_ROUTING_VALUES as I}from"@fjall/util";import{asBoolean as g,asNumber as c,asString as s,asStringArray as _,asStringUnion as S,asObjectOrFalse as y,collectFromAst as C,extractSubConfig as d,extractVariableName as F,isFactoryBuildCall as D,isFactoryMethodCall as E,isParsedObject as A,isPlainObject as L,parseObjectLiteral as N,parseOptionalConfig as m,typed as x}from"../common/astCommonParser.js";import{parseDeadLetterQueueConfig as z}from"./astMessagingParser.js";const R=["Instance","Aurora"],T=["postgresql","mysql"];function b(t){if(!A(t))return;const e={...t.memorySize!==void 0&&{memorySize:c(t.memorySize)},...t.timeout!==void 0&&{timeout:c(t.timeout)},...t.ephemeralStorageSize!==void 0&&{ephemeralStorageSize:c(t.ephemeralStorageSize)}};return Object.keys(e).length>0?e:void 0}o(b,"parseLambdaConfig");function k(t){return d(t,"database",e=>({type:S(e.type,R),databaseName:s(e.databaseName),databaseEngine:S(e.databaseEngine,T),deletionProtection:g(e.deletionProtection),backupRetention:c(e.backupRetention),port:c(e.port),publiclyAccessible:g(e.publiclyAccessible),allowedIpCidr:s(e.allowedIpCidr),instanceType:s(e.instanceType),allocatedStorage:c(e.allocatedStorage),multiAz:g(e.multiAz),allowVpcAccess:g(e.allowVpcAccess),monitoringInterval:c(e.monitoringInterval),preferredMaintenanceWindow:s(e.preferredMaintenanceWindow),snapshotIdentifier:s(e.snapshotIdentifier),snapshotUsername:s(e.snapshotUsername),readReplica:y(e.readReplica),writer:m(e.writer,x()),readers:y(e.readers),databaseInsights:y(e.databaseInsights),proxy:y(e.proxy),credentials:m(e.credentials,x()),encryption:m(e.encryption,x())}))}o(k,"extractPatternDatabaseConfig");function j(t){return d(t,"compute",e=>({server:m(e.server,b),imageOptimisation:m(e.imageOptimisation,b),revalidation:m(e.revalidation,b)}))}o(j,"extractPatternComputeConfig");function U(t){const e=o(n=>({versioned:g(n.versioned)}),"parseVersionedConfig");return d(t,"storage",n=>({assets:m(n.assets,e),cache:m(n.cache,e),media:m(n.media,e)}))}o(U,"extractPatternStorageConfig");function V(t){return d(t,"messaging",e=>({revalidationQueue:m(e.revalidationQueue,n=>({visibilityTimeout:c(n.visibilityTimeout),messageRetentionPeriod:c(n.messageRetentionPeriod),maxMessageSize:c(n.maxMessageSize),deadLetterQueue:z(n.deadLetterQueue)}))}))}o(V,"extractPatternMessagingConfig");function M(t){return d(t,"cdn",e=>({domainNames:_(e.domainNames),certificateArn:s(e.certificateArn)}))}o(M,"extractPatternCdnConfig");function B(t){return d(t,"environment",e=>{const n=Object.fromEntries(Object.entries(e).filter(r=>typeof r[1]=="string"));return Object.keys(n).length>0?n:void 0})}o(B,"extractPatternEnvironmentConfig");function Q(t,e){const n=$(t);return{name:e,source:s(t.source),build:d(t,"build",r=>({command:s(r.command),outputDir:s(r.outputDir)})),routing:S(t.routing,I),security:d(t,"security",r=>({headers:g(r.headers),contentSecurityPolicy:s(r.contentSecurityPolicy)})),domain:s(t.domain),forms:d(t,"forms",r=>({to:s(r.to),from:s(r.from),corsOrigin:s(r.corsOrigin),maxConcurrency:c(r.maxConcurrency)})),cdn:d(t,"cdn",r=>({behaviours:Array.isArray(r.behaviours)?r.behaviours:void 0})),...n.length>0&&{unreadableFields:n}}}o(Q,"extractStaticSiteConfig");function P(t){return L(t)&&("__identifier"in t||"__expression"in t||"__call"in t||"__unknown"in t)}o(P,"isUnreadableRef");function $(t){const e=[],n=o((i,a)=>{P(i)&&e.push(a)},"check");n(t.source,"source"),n(t.routing,"routing"),n(t.domain,"domain");const r=[[t.build,"build",["command","outputDir"]],[t.security,"security",["headers","contentSecurityPolicy"]],[t.forms,"forms",["to","from","corsOrigin","maxConcurrency"]],[t.cdn,"cdn",["behaviours"]]];for(const[i,a,u]of r)if(P(i))e.push(a);else if(A(i))for(const l of u)n(i[l],`${a}.${l}`);return e}o($,"collectUnreadableStaticSiteFields");function p(t){return t!==void 0&&t!==""}o(p,"isReadable");function O(t,e){return new Error(`Static-site pattern '${t}' in infrastructure.ts: Fjall could not read ${e.join(", ")} as inline literal(s). Fjall reads these fields out of the file and writes them back, so they must be written inline (source: "./site"), not as a variable or an expression.`)}o(O,"unreadableStaticSiteFields");function w(t,e){const n=e.to;if(!p(n))throw O(t,["forms.to"]);return{to:n,...e.from!==void 0&&{from:e.from},...e.corsOrigin!==void 0&&{corsOrigin:e.corsOrigin},...e.maxConcurrency!==void 0&&{maxConcurrency:e.maxConcurrency}}}o(w,"readStaticSiteForms");function G(t,e){if(t.arguments.length<2)return null;const n=t.arguments[0],r=t.arguments[1];if(!h.isStringLiteral(n)||!h.isObjectLiteralExpression(r))return null;const i=n.text,a=N(r),u=a.type,l=F(e),f=s(a.name);return f?u==="payload"||u==="nextjs"?{variableName:l,constructId:i,type:u,config:{name:f,domain:s(a.domain),database:k(a),compute:j(a),storage:U(a),messaging:V(a),cdn:M(a),environment:B(a)},node:t}:u==="staticsite"?{variableName:l,constructId:i,type:"staticsite",config:Q(a,f),node:t}:null:null}o(G,"extractPatternResource");function J(t){return C(t,e=>{if(!h.isCallExpression(e)||!E(e,"addPattern"))return null;const n=e.arguments[0];return D(n,"PatternFactory")?G(n,e):null})}o(J,"findPatternResources");function X(t,e){if(!e||e.length===0)return;const n=e[0];if(t.pattern=n.type,n.type==="staticsite"){const{config:i}=n,a=i.source,u=i.build?.command,l=i.build?.outputDir;if(i.unreadableFields!==void 0)throw O(i.name,i.unreadableFields);if(!p(a)||!p(u)||!p(l)){const f=[];throw p(a)||f.push("source"),p(u)||f.push("build.command"),p(l)||f.push("build.outputDir"),O(i.name,f)}t.patternConfig={type:"staticsite",name:i.name,source:a,build:{command:u,outputDir:l},routing:i.routing,security:i.security,domain:i.domain,...i.forms!==void 0&&{forms:w(i.name,i.forms)},cdn:i.cdn};return}const{config:r}=n;t.patternConfig={type:n.type,name:r.name,domain:r.domain,database:r.database,compute:r.compute,storage:r.storage,messaging:r.messaging,cdn:r.cdn,environment:r.environment}}o(X,"applyPatternConfig");export{X as applyPatternConfig,J as findPatternResources};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
var c=Object.defineProperty;var a=(i,r)=>c(i,"name",{value:r,configurable:!0});import*as t from"typescript";import{asString as f,collectFromAst as g,isFactoryMethodCall as m,parseObjectLiteral as p}from"../common/astCommonParser.js";function x(i){return g(i,r=>{if(!t.isCallExpression(r)||!m(r,"addSchedule")||r.arguments.length<2)return null;const l=r.arguments[0],n=r.arguments[1];if(!t.isStringLiteral(l)||!t.isObjectLiteralExpression(n))return null;const o=p(n),u=f(o.schedule);if(u===void 0)return null;const e=n.properties.find(s=>t.isPropertyAssignment(s)&&t.isIdentifier(s.name)&&s.name.text==="target");return!e||!t.isPropertyAssignment(e)||!t.isIdentifier(e.initializer)?null:{id:l.text,schedule:u,targetVariableName:e.initializer.text}})}a(x,"findSchedules");export{x as findSchedules};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as i from"typescript";import{S3_STACK_PLACEMENTS as
|
|
1
|
+
var N=Object.defineProperty;var a=(n,e)=>N(n,"name",{value:e,configurable:!0});import*as i from"typescript";import{S3_STACK_PLACEMENTS as f}from"../../../schemas/resourceSchemas.js";import{S3_ENCRYPTION_TYPES as p,BACKUP_VAULT_TIERS as d}from"../../../schemas/constants.js";import{asBoolean as c,asNumber as b,asString as o,asStringUnion as s,captureExtraProperties as k,collectFromAst as y,extractVariableName as h,isFactoryBuildCall as C,isFactoryMethodCall as P,isParsedObject as l,parseObjectLiteral as A}from"../common/astCommonParser.js";const S=new Set(["S3Bucket"]);function T(n,e,r){const t=i.isIdentifier(n.name)?n.name.text:"";if(e.arguments&&e.arguments.length>=2){const u=e.arguments[1],g=i.isStringLiteral(u)?u.text:"",m=e.arguments.length>=3?e.arguments[2]:void 0,x=m&&i.isObjectLiteralExpression(m)?A(m):{};return{variableName:t,resourceName:g,bucketClass:r,config:x,node:n}}return null}a(T,"extractS3Resource");function w(n,e){if(e.arguments.length<2)return null;const r=e.arguments[0],t=e.arguments[1];if(!i.isStringLiteral(r)||!i.isObjectLiteralExpression(t))return null;const u=A(t);return{variableName:h(n)??"",resourceName:r.text,bucketClass:"StorageFactory",config:u,node:n}}a(w,"extractS3FactoryResource");function K(n){return y(n,e=>{if(!i.isVariableDeclaration(e)||!e.initializer||!i.isNewExpression(e.initializer))return null;const r=e.initializer;if(!i.isIdentifier(r.expression))return null;const t=r.expression.text;return S.has(t)?T(e,r,t):null})}a(K,"findS3Resources");function O(n){return y(n,e=>{if(!i.isCallExpression(e)||!P(e,"addStorage"))return null;const r=e.arguments[0];return C(r,"StorageFactory")?w(e,r):null})}a(O,"findS3FactoryResources");function L(n){return n.map(e=>({name:e.resourceName,...o(e.config.bucketName)&&{bucketName:o(e.config.bucketName)},...c(e.config.publicReadAccess)===!0&&{publicReadAccess:!0},...l(e.config.websiteHosting)&&(()=>{const r=e.config.websiteHosting;return{websiteHosting:{indexDocument:o(r.indexDocument)??"index.html",...o(r.errorDocument)&&{errorDocument:o(r.errorDocument)}}}})(),...s(e.config.backupVaultTier,d)&&{backupVaultTier:s(e.config.backupVaultTier,d)},...c(e.config.versioned)!==void 0&&{versioned:c(e.config.versioned)},...s(e.config.encryption,p)&&{encryption:s(e.config.encryption,p)},...o(e.config.kmsKeyArn)&&{kmsKeyArn:o(e.config.kmsKeyArn)},...Array.isArray(e.config.cors)&&e.config.cors.length>0&&{cors:e.config.cors.filter(l).map(r=>({allowedOrigins:Array.isArray(r.allowedOrigins)?r.allowedOrigins.filter(t=>typeof t=="string"):[],allowedMethods:Array.isArray(r.allowedMethods)?r.allowedMethods.filter(t=>typeof t=="string"):[]}))},...l(e.config.deployment)&&(()=>{const r=e.config.deployment;return{deployment:{source:o(r.source)??"",...c(r.prune)!==void 0&&{prune:c(r.prune)},...l(r.cacheControl)&&(()=>{const t=r.cacheControl;return{cacheControl:{...b(t.maxAge)!==void 0&&{maxAge:b(t.maxAge)},...c(t.immutable)!==void 0&&{immutable:c(t.immutable)}}}})()}}})(),...s(e.config.stackPlacement,f)&&{stackPlacement:s(e.config.stackPlacement,f)},...e.variableName&&{variableName:e.variableName},...(()=>{const r=new Set(["bucketName","publicReadAccess","websiteHosting","backupVaultTier","versioned","encryption","kmsKeyArn","cors","deployment","stackPlacement"]),t=k(e.config,r);return t.length>0?{extraProperties:t}:{}})()}))}a(L,"convertS3Resources");export{S as S3_BUCKET_CLASSES,L as convertS3Resources,O as findS3FactoryResources,K as findS3Resources};
|
package/dist/src/aws/regions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AWS_REGIONS_METADATA as
|
|
1
|
+
var p=Object.defineProperty;var n=(t,e)=>p(t,"name",{value:e,configurable:!0});import{AWS_REGIONS_METADATA as u,getRegionInfo as l,regions as c}from"@fjall/util";import{AWS_REGIONS_METADATA as y,DEFAULT_REGION as z,getRegionInfo as G,OPT_IN_REGION_CODES as L,optInRegionWarning as W,regions as j,suggestRegionForTimezone as F}from"@fjall/util";const R=["us-east-2","us-west-2","us-east-1","eu-west-1","eu-central-1","ap-southeast-1"],_=Object.freeze(R.flatMap(t=>{const e=l(t);return e?[e]:[]})),g=Object.freeze(["us-east-2","us-west-2","us-east-1","eu-west-1","ap-southeast-1"]);function a(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}n(a,"parseRegionList");function x(t){return c.includes(t)}n(x,"isValidRegion");function d(t){return/^[a-z]{2}-[a-z]+-[1-9]$/.test(t)}n(d,"isValidRegionFormat");function m(t){if(!t)return g.slice(0,3);const e=t.toLowerCase().split("-"),o=e[0],r=e.length>1?e[1]:"";let i=[];return o&&r&&(i=c.filter(s=>s.startsWith(`${o}-${r}`))),i.length===0&&o&&(i=c.filter(s=>s.startsWith(`${o}-`))),i.length>0?i.slice(0,3):g.slice(0,3)}n(m,"getSuggestions");function O(t){if(x(t))return!0;const e=m(t);return d(t)?`Unknown region. Try: ${e.join(", ")}`:`Invalid format. Try: ${e.join(", ")}`}n(O,"validateRegion");function A(t){if(!t||t.trim()==="")return!0;const e=a(t);for(const o of e){const r=O(o);if(r!==!0)return r}return!0}n(A,"validateRegionList");function E(t,e){return t.filter(o=>o!==e)}n(E,"filterDuplicateRegions");function f(t){return{label:t.city,value:t.code,description:t.optIn?`${t.code} \u2014 opt-in required`:t.code}}n(f,"toRegionOption");function h(){return u.map(f)}n(h,"getRegionOptions");function N(t){return u.filter(e=>e.code!==t).map(f)}n(N,"getRegionOptionsExcluding");function S(t){const e=u.find(o=>o.code===t);return e?e.city:t}n(S,"getRegionName");function $(t){return e=>{const o=a(e);return E(o,t)}}n($,"createRegionFormatter");export{y as AWS_REGIONS_METADATA,z as DEFAULT_REGION,L as OPT_IN_REGION_CODES,g as commonRegions,$ as createRegionFormatter,E as filterDuplicateRegions,G as getRegionInfo,S as getRegionName,h as getRegionOptions,N as getRegionOptionsExcluding,m as getSuggestions,x as isValidRegion,d as isValidRegionFormat,W as optInRegionWarning,a as parseRegionList,j as regions,F as suggestRegionForTimezone,_ as topRegions,O as validateRegion,A as validateRegionList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{detectLineTerminator as
|
|
1
|
+
var u=Object.defineProperty;var n=(r,t)=>u(r,"name",{value:t,configurable:!0});import{detectLineTerminator as c}from"./fileRewriter/index.js";const m="/__codemod__/input.ts";function d(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}n(d,"isRecord");function p(r){if(!d(r))return;const t=r.program;if(!d(t))return;const e=t.body;if(Array.isArray(e)&&e.every(d))return e}n(p,"extractProgramBody");function i(r,t){return r.length===0?0:r.split(t).length}n(i,"countLines");function s(r,t){const e=c(r),o=i(t,e)-i(r,e);return o>=0?{added:o,removed:0}:{added:0,removed:-o}}n(s,"computeLinesDelta");export{m as DEFAULT_FILE_PATH,s as computeLinesDelta,p as extractProgramBody,d as isRecord};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as
|
|
1
|
+
var y=Object.defineProperty;var c=(r,e)=>y(r,"name",{value:e,configurable:!0});import{failure as u,success as d}from"../../types/Result.js";import{listResources as h}from"../listResources.js";import{mergeProperties as b}from"./merge.js";import{snapshotProperties as k}from"./snapshot.js";function P(r,e,n){const t=h(r);if(!t.success)return u(t.error);if(t.data.resources.find(o=>o.type===e.type&&o.name===e.name)===void 0)return e.op==="add"?d({resource:{type:e.type,name:e.name},deltas:[],summary:"clean"}):u({kind:"ResourceNotFoundError",type:e.type,name:e.name,knownNames:t.data.resources.filter(o=>o.type===e.type).map(o=>o.name)});const s=k(r,e.type,e.name);if(!s.success)return u(s.error);const i={...s.data.properties},p={...e.properties},f=n===void 0?void 0:{...n.properties},m=b(f,i,p),l=g(m.deltas,f!==void 0);return d({resource:{type:e.type,name:e.name},deltas:m.deltas,summary:l})}c(P,"detectDrift");function g(r,e){if(r.length===0)return"clean";let n=!1,t=!1,a=!1,s=!1;for(const i of r)switch(i.verdict){case"conflict":n=!0;break;case"compatible":t=!0;break;case"clean":a=!0;break;case"no-op":s=!0;break}return n?"drifted-conflict":t?"drifted-compatible":s&&!a?"no-op":"clean"}c(g,"summariseDeltas");export{P as detectDrift};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isDeepStrictEqual as
|
|
1
|
+
var b=Object.defineProperty;var i=(e,t)=>b(e,"name",{value:t,configurable:!0});import{isDeepStrictEqual as a}from"node:util";function q(e,t,n){const o=[...new Set([...e===void 0?[]:Object.keys(e),...Object.keys(t),...Object.keys(n)])].sort((r,l)=>r.localeCompare(l,"en")),f={},u=[];for(const r of o){const l=e!==void 0&&k(e,r),m=k(t,r),p=k(n,r),j=l?e[r]:void 0,s=m?t[r]:void 0,y=p?n[r]:void 0,v=e===void 0?w(m,s,p,y):P(l,j,m,s,p,y);u.push({property:r,base:j,theirs:s,ours:y,verdict:v.verdict}),v.merged.has&&(f[r]=v.merged.value)}return{merged:f,deltas:u}}i(q,"mergeProperties");function w(e,t,n,c){return!e&&n?d(c):e&&!n||a(t,c)?d(t):g()}i(w,"classifyWithoutBase");function P(e,t,n,c,o,f){if(!e&&!n&&o)return d(f);if(e&&!n&&o)return g();const u=e===n&&a(t,c);return u&&o?d(f):u&&!o?d(t):o?n===o&&a(c,f)?{verdict:"no-op",merged:{has:!0,value:c}}:g():n?{verdict:"compatible",merged:{has:!0,value:c}}:{verdict:"compatible",merged:{has:!1}}}i(P,"classifyWithBase");function d(e){return{verdict:"clean",merged:{has:!0,value:e}}}i(d,"clean");function g(){return{verdict:"conflict",merged:{has:!1}}}i(g,"conflict");function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}i(k,"hasOwn");export{q as mergeProperties};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as
|
|
1
|
+
var h=Object.defineProperty;var u=(r,t)=>h(r,"name",{value:t,configurable:!0});import{failure as d,success as g}from"../../types/Result.js";import{extractProgramBody as k,isRecord as m}from"../_internal.js";import{astToLiteral as b,isNodeShape as y,NON_LITERAL as E,readKeyName as x}from"../edits/modifyResource/literalConversion.js";import{parse as N}from"../fileRewriter/index.js";import{listResources as O}from"../listResources.js";import{STATEMENT_REGISTRY as j}from"../registry.js";function I(r,t,n){const e=O(r);if(!e.success)return d(e.error);const i=e.data.resources.find(o=>o.type===t&&o.name===n);if(i===void 0)return d({kind:"ResourceNotFoundError",type:t,name:n,knownNames:e.data.resources.filter(o=>o.type===t).map(o=>o.name)});const s=N(r,i.filePath);if(!s.success)return d(s.error);const c=k(s.data);if(c===void 0)return d({kind:"SemanticQueryError",reason:"recast File is missing program.body"});const f=S(c,i);if(f===void 0)return d({kind:"SemanticQueryError",reason:"Unable to resolve config ObjectExpression for the located resource."});const a=new Set(Object.keys(j[t].schemaFragment.shape)),l={};for(const o of f.properties){if(o.type!=="Property"&&o.type!=="ObjectProperty"||o.shorthand===!0||o.computed===!0)continue;const p=x(o.key);p===void 0||!a.has(p)||o.value!==void 0&&(l[p]=v(o.value,r))}return g({type:t,name:n,properties:l,schemaVersion:1})}u(I,"snapshotProperties");function S(r,t){const n=t.start+t.length;let e;const i=u(s=>{if(e!==void 0||s.type!=="CallExpression")return;const c=s.arguments;if(!Array.isArray(c)||c.length<2)return;const f=c[0];if(!y(f)||f.type!=="StringLiteral"||f.start!==t.start||f.end!==n)return;const a=c[1];y(a)&&a.type==="ObjectExpression"&&(e=a)},"visitor");for(const s of r)if(P(s,i),e!==void 0)break;return e}u(S,"findConfigObject");function v(r,t){const n=b(r);return n!==E?n:A(r,t)}u(v,"extractPropertyValue");function A(r,t){const n=typeof r.start=="number"?r.start:void 0,e=typeof r.end=="number"?r.end:void 0;return{kind:"expression",text:n!==void 0&&e!==void 0&&n<e?t.slice(n,e):""}}u(A,"toExpressionValue");function P(r,t){const n=[r];for(;n.length>0;){const e=n.pop();if(m(e)){typeof e.type=="string"&&t(e);for(const i of Object.keys(e)){if(i==="loc"||i==="comments"||i==="tokens")continue;const s=e[i];if(Array.isArray(s))for(const c of s)m(c)&&n.push(c);else m(s)&&n.push(s)}}}}u(P,"visit");export{I as snapshotProperties};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isRecord as
|
|
1
|
+
var l=Object.defineProperty;var p=(e,t)=>l(e,"name",{value:t,configurable:!0});import{isRecord as u}from"../../_internal.js";import{findTypeByIdentifier as y}from"../../registry.js";function g(e,t){const n=[],r=[],i=[];let o=t.length;for(let c=0;c<e.length;c+=1){const s=e[c];if(s===void 0)continue;const a=typeof s.start=="number"?s.start:0,d=typeof s.end=="number"?s.end:a;d>o&&(o=d);const f=m(s);n.push({index:c,start:a,end:d,type:f}),f==="import"?r.push({endPos:d}):(f==="app-init"||f==="tags")&&i.push({endPos:d,type:f})}return{anchors:n,importInfos:r,appInitLocations:i,programEnd:o}}p(g,"indexBody");function m(e){if(e.type==="ImportDeclaration")return"import";if(e.type!=="ExpressionStatement")return;const t=e.expression;if(!u(t)||t.type!=="CallExpression")return;const n=t.callee;if(!u(n)||n.type!=="MemberExpression")return;const r=n.object,i=n.property;if(!u(r)||r.type!=="Identifier"||!u(i)||i.type!=="Identifier"||i.name!=="build")return;const o=r.name;if(typeof o=="string")return o==="AppFactory"?"app-init":y(o)}p(m,"classifyStatement");function b(e,t){const n=[];for(const r of t){const i=e.find(o=>o.start<=r.start&&o.end>=r.start+r.length);i!==void 0&&n.push({endPos:i.end,type:r.type})}return n}p(b,"buildResourceLocations");function P(e){return[...e].sort((t,n)=>t.endPos-n.endPos)}p(P,"orderByEndPos");function E(e,t){const n=e.find(r=>r.end===t);return n!==void 0?n.index+1:e.length}p(E,"resolveInsertIndex");export{b as buildResourceLocations,g as indexBody,P as orderByEndPos,E as resolveInsertIndex};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{builders as i}from"ast-types";import{failure as
|
|
1
|
+
var c=Object.defineProperty;var f=(r,e)=>c(r,"name",{value:e,configurable:!0});import{builders as i}from"ast-types";import{failure as u,success as a}from"../../../types/Result.js";import{buildObjectProperty as d}from"../../fileRewriter/index.js";function j(r,e){const n=[];for(const[t,o]of Object.entries(r)){const s=p(o,e);if(s===void 0)return u({kind:"InvalidPropertyError",property:t,reason:`Unsupported property value for "${t}" (accepts string/number/boolean/null/array/object of the same).`});n.push({key:t,value:s})}return a(n)}f(j,"buildPropertyInputs");function p(r,e){if(typeof r=="string")return l(r,e);if(typeof r=="number"&&Number.isFinite(r))return i.numericLiteral(r);if(typeof r=="boolean")return i.booleanLiteral(r);if(r===null)return i.nullLiteral();if(Array.isArray(r)){const n=[];for(const t of r){const o=p(t,e);if(o===void 0)return;n.push(o)}return i.arrayExpression(n)}if(typeof r=="object"&&r!==null){const n=[];for(const[t,o]of Object.entries(r)){const s=p(o,e);if(s===void 0)return;n.push(d(t,s,e))}return i.objectExpression(n)}}f(p,"toAstValue");function l(r,e){const n=e==="single"?"'":'"',t=e==="single"?r.replace(/\\/g,"\\\\").replace(/'/g,"\\'"):r.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),o=`${n}${t}${n}`;return i.stringLiteral.from({value:r,extra:{rawValue:r,raw:o}})}f(l,"makeStringLiteral");export{j as buildPropertyInputs,l as makeStringLiteral,p as toAstValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as o,success as
|
|
1
|
+
var T=Object.defineProperty;var u=(e,r)=>T(e,"name",{value:r,configurable:!0});import{failure as o,success as S}from"../../types/Result.js";import{DEFAULT_FILE_PATH as F,computeLinesDelta as C,extractProgramBody as D,isRecord as b}from"../_internal.js";import{appendSpecifier as x,buildFactoryStatement as w,buildImportDeclaration as Q,detectQuoteStyle as v,parse as A,printFile as _}from"../fileRewriter/index.js";import{STATEMENT_REGISTRY as B}from"../registry.js";import{locateAllShapes as G,locateByShape as N}from"../semanticIndex/index.js";import{checkControlFlowPolicy as O}from"./controlFlowPolicy.js";import{driftGate as U,runPipeline as M,schemaGate as Y}from"../validationGate/index.js";import{buildResourceLocations as j,indexBody as q,orderByEndPos as H,resolveInsertIndex as $}from"./addResource/bodyIndex.js";import{buildPropertyInputs as z}from"./addResource/propertyBuilder.js";import{findInsertionPosition as J}from"./findInsertionPosition.js";const I="@fjall/components-infrastructure";function cr(e,r,d={}){const i=r.filePath??F,a=A(e,i);if(!a.success)return o(a.error);const t=N(e,{type:r.type,name:r.name},i);if(!t.success)return t.error.kind==="TemplateLiteralNameError"?o(t.error):o({kind:"SemanticQueryError",reason:t.error.reason,cause:t.error.cause});if(t.data!==void 0){const E=O({ast:a.data,target:t.data,resource:{type:r.type,name:r.name},op:"add"});if(E.refusal!==void 0)return o(E.refusal);const m=M([Y,U],{content:e,plan:{type:r.type,name:r.name,properties:r.properties,op:"add"},baseline:d.baseline,policy:r.driftPolicy});return m.success?m.data.action==="skip"?S({content:e,linesChanged:{added:0,removed:0},skipped:!0}):o({kind:"DuplicateResourceError",type:r.type,name:r.name}):o(K(m.error))}const p=v(a.data),l=z(r.properties,p);if(!l.success)return o(l.error);const f=B[r.type].factoryIdentifier,h=w({factory:f,name:r.name,properties:l.data,quoteStyle:p}),c=D(a.data);if(c===void 0)return o({kind:"SemanticQueryError",reason:"recast File is missing program.body"});const s=q(c,e),n=G(e,i);if(!n.success)return n.error.kind==="TemplateLiteralNameError"?o(n.error):o({kind:"SemanticQueryError",reason:n.error.reason,cause:n.error.cause});const k=j(s.anchors,n.data),L=H([...s.appInitLocations,...k]),P=J(s.importInfos,L,r.type,s.programEnd),R=$(s.anchors,P);c.splice(R,0,h),V(c,f,p);const y=_(a.data,e),g=C(e,y);return S({content:y,linesChanged:g})}u(cr,"addResource");function K(e){switch(e.kind){case"ParseError":case"TemplateLiteralNameError":case"DuplicateResourceError":case"InvalidPropertyError":case"SemanticQueryError":case"DriftConflictError":case"ControlFlowClassifierError":return e;default:return{kind:"SemanticQueryError",reason:`Unexpected codemod error in validation-gate pipeline: ${e.kind}`}}}u(K,"narrowGateError");function V(e,r,d){for(const a of e){if(a.type!=="ImportDeclaration")continue;const t=a.source;if(!(!b(t)||t.type!=="StringLiteral")&&t.value===I){x(a,r);return}}const i=Q([r],I,d);e.unshift(i)}u(V,"ensureFactoryImport");export{cr as addResource};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as
|
|
1
|
+
var T=Object.defineProperty;var u=(e,r)=>T(e,"name",{value:r,configurable:!0});import{failure as d,success as y}from"../../types/Result.js";import{DEFAULT_FILE_PATH as x,computeLinesDelta as k,extractProgramBody as b}from"../_internal.js";import{buildObjectProperty as h,detectQuoteStyle as D,parse as C,printFile as F}from"../fileRewriter/index.js";import{makeStringLiteral as L,toAstValue as w}from"./addResource/propertyBuilder.js";import{astToLiteral as I,isNodeShape as f,readKeyName as g}from"./modifyResource/literalConversion.js";const K="ACCOUNTS",O="workloads";function J(e,r){const n=r.filePath??x,t=r.constName??K,a=r.nestedKey??O,{stage:i,displayName:o}=r,s=C(e,n);if(!s.success)return d(s.error);const l=b(s.data);if(l===void 0)return d({kind:"InvalidStageTargetError",stage:i,reason:"recast File is missing program.body"});const m=$(l,t);if(m===void 0)return d({kind:"ConstNotFoundError",constName:t});const p=D(s.data),c=V(m,{constName:t,stage:i,nestedKey:a,displayName:o,quoteStyle:p});if(!c.success)return d(c.error);if(c.data.created)return P(s.data,e);const v=c.data.array;return v.elements.some(N=>f(N)&&I(N)===o)?y({content:e,linesChanged:{added:0,removed:0},skipped:!0}):(v.elements.push(L(o,p)),P(s.data,e))}u(J,"appendAccountToStage");function P(e,r){const n=F(e,r);return y({content:n,linesChanged:k(r,n)})}u(P,"printSuccess");function V(e,r){const{constName:n,stage:t,nestedKey:a,displayName:i,quoteStyle:o}=r,s=E(e,t);if(s!==void 0)return A(s.value)?y({created:!1,array:s.value}):d({kind:"InvalidStageTargetError",stage:t,reason:`Top-level "${t}" is not an array literal.`});const l=E(e,a);if(l!==void 0&&S(l.value)){const m=l.value,p=E(m,t);if(p!==void 0)return A(p.value)?y({created:!1,array:p.value}):d({kind:"InvalidStageTargetError",stage:t,reason:`Nested "${a}.${t}" is not an array literal.`});const c=_(m,t,i,o);return c.success?y({created:!0}):d(c.error)}return d({kind:"StageNotFoundError",constName:n,stage:t,knownStages:B(e,a)})}u(V,"resolveStageArray");function _(e,r,n,t){const a=w([n],t);if(a===void 0)return d({kind:"InvalidStageTargetError",stage:r,reason:`Unable to build an array literal for "${r}".`});const i=h(r,a,t);return e.properties[e.properties.length-1]?.extra?.trailingComma===!0&&(i.extra={...i.extra??{},trailingComma:!0}),e.properties.push(i),y(void 0)}u(_,"appendStageProperty");function $(e,r){for(const n of e){const t=U(n);if(t===void 0)continue;const a=t.declarations;if(Array.isArray(a))for(const i of a){if(!f(i)||i.type!=="VariableDeclarator")continue;const o=i.id,s=j(i.init);if(f(o)&&o.type==="Identifier"&&o.name===r&&S(s))return s}}}u($,"findConstObjectExpression");function U(e){if(e.type==="VariableDeclaration")return e;if(e.type==="ExportNamedDeclaration"){const r=e.declaration;if(f(r)&&r.type==="VariableDeclaration")return r}}u(U,"unwrapVariableDeclaration");function j(e){let r=e;for(;f(r)&&(r.type==="TSAsExpression"||r.type==="TSSatisfiesExpression");)r=r.expression;return r}u(j,"unwrapExpression");function E(e,r){return e.properties.find(n=>(n.type==="Property"||n.type==="ObjectProperty")&&n.shorthand!==!0&&n.computed!==!0&&g(n.key)===r)}u(E,"findPropertyByKey");function B(e,r){const n=[];for(const t of e.properties){if(t.type!=="Property"&&t.type!=="ObjectProperty")continue;const a=g(t.key);if(a!==void 0)if(a===r&&S(t.value))for(const i of t.value.properties){const o=g(i.key);o!==void 0&&n.push(`${r}.${o}`)}else A(t.value)&&n.push(a)}return n}u(B,"collectStageKeys");function S(e){return f(e)&&e.type==="ObjectExpression"&&Array.isArray(e.properties)}u(S,"isObjectExpression");function A(e){return f(e)&&e.type==="ArrayExpression"&&Array.isArray(e.elements)}u(A,"isArrayExpression");export{J as appendAccountToStage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isRecord as
|
|
1
|
+
var p=Object.defineProperty;var s=(e,t)=>p(e,"name",{value:t,configurable:!0});import{isRecord as h}from"../_internal.js";const m=new Set(["loc","tokens","comments","original","range"]),g=new Set(["ForStatement","ForInStatement","ForOfStatement","WhileStatement","DoWhileStatement"]),S={"try-catch":"Move the resource declaration outside the try block.","switch-fall-through":"Add a break statement or convert to if/else.","nested-ternary":"Convert nested ternaries to if/else.",loop:"Extract the resource declaration before the loop.","generator-function":"Extract the resource declaration outside the generator.","async-iterator":"Extract the resource declaration outside the async iterator.","anonymous-helper":"Extract the resource to module scope.","decorator-return":"Extract the resource declaration outside the decorated function."};function F(e,t){if(!u(e))return;const n=[{node:e,ancestors:[]}];for(;n.length>0;){const i=n.pop();if(i===void 0)continue;const{node:o,ancestors:c}=i;if(o.type==="StringLiteral"&&typeof o.start=="number"&&o.start===t)return{node:o,ancestors:c};const r=[...c,o];for(const f of Object.keys(o)){if(m.has(f))continue;const d=o[f];if(Array.isArray(d))for(let l=d.length-1;l>=0;l-=1){const y=d[l];u(y)&&n.push({node:y,ancestors:r})}else u(d)&&n.push({node:d,ancestors:r})}}}s(F,"findNodeAtOffset");function u(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}s(u,"isAstNode");function a(e,t,n){return{kind:"ControlFlowClassifierError",reason:e,resource:t,location:E(n),remediation:S[e]}}s(a,"buildRefusal");function E(e){const t=e.loc;if(t?.start!==void 0&&typeof t.start.line=="number"&&typeof t.start.column=="number")return{line:t.start.line,column:t.start.column}}s(E,"resolveLocation");function b(e,t){const n=e.finalizer;return n!==void 0&&n===t}s(b,"cameFromFinaliser");function x(e,t){const n=e.handler;return n!==void 0&&n===t}s(x,"cameFromHandler");function w(e){const t=e.consequent;if(!Array.isArray(t)||t.length===0)return!0;const n=t[t.length-1];return u(n)?n.type!=="BreakStatement"&&n.type!=="ReturnStatement":!0}s(w,"isSwitchFallThrough");function I(e){const t=k(e.ast);if(t===void 0)return{};const n=F(t,e.target.start);if(n===void 0)return{};const{ancestors:i}=n;let o=n.node;for(let c=i.length-1;c>=0;c-=1){const r=i[c];if(r!==void 0){if(g.has(r.type))return{refusal:a("loop",e.resource,r)};if(r.type==="TryStatement"){if(x(r,o)||b(r,o))return{refusal:a("try-catch",e.resource,r)};o=r;continue}if(r.type==="CatchClause")return{refusal:a("try-catch",e.resource,r)};if(r.type==="SwitchCase"&&w(r))return{refusal:a("switch-fall-through",e.resource,r)};if(r.type==="ConditionalExpression"){const f=c-1;if((f>=0?i[f]:void 0)?.type==="ConditionalExpression")return{refusal:a("nested-ternary",e.resource,r)};if(e.op==="modify")return{warning:{message:`Modified property on resource "${e.resource.name}" declared in a ternary expression \u2014 consider converting to if/else.`}};if(e.op==="add"||e.op==="remove")return{refusal:a("nested-ternary",e.resource,r)}}if(r.type==="FunctionDeclaration"||r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression"||r.type==="ObjectMethod"||r.type==="ClassMethod")return r.generator===!0?{refusal:a("generator-function",e.resource,r)}:r.async===!0&&C(r)?{refusal:a("async-iterator",e.resource,r)}:A(r)===void 0?{refusal:a("anonymous-helper",e.resource,r)}:{refusal:a("anonymous-helper",e.resource,r)};o=r}}return{}}s(I,"checkControlFlowPolicy");function A(e){if(e.type==="FunctionDeclaration"){const t=e.id;if(u(t)&&typeof t.name=="string")return t.name}}s(A,"resolveFunctionName");function C(e){if(e.type!=="FunctionDeclaration"&&e.type!=="FunctionExpression")return!1;const t=e.body;if(!u(t)||t.type!=="BlockStatement")return!1;const n=t.body;return Array.isArray(n)?n.some(i=>u(i)&&i.type==="ForOfStatement"&&i.await===!0):!1}s(C,"isIteratorShape");function k(e){if(!h(e))return;const t=e.program;if(h(t)&&typeof t.type=="string")return e}s(k,"extractBody");export{I as checkControlFlowPolicy};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as
|
|
1
|
+
var f=Object.defineProperty;var o=(e,n)=>f(e,"name",{value:n,configurable:!0});import{failure as d,success as u}from"../../types/Result.js";import{addResource as l}from"./addResource.js";import{modifyResource as m}from"./modifyResource.js";import{removeResource as p}from"./removeResource.js";function x(e,n){const{name:t,filePath:c,...a}=n,i={...a},r=l(e,{type:"cross-plan-connection",name:t,properties:i,...c!==void 0?{filePath:c}:{}});if(!r.success)return d(r.error);const s=g(n);return u({content:r.data.content,linesChanged:r.data.linesChanged,...s.length>0?{warnings:s}:{}})}o(x,"addCrossPlanConnection");function $(e,n){const t=p(e,{type:"cross-plan-connection",name:n.name,...n.filePath!==void 0?{filePath:n.filePath}:{},...n.force!==void 0?{force:n.force}:{}});return t.success?u({content:t.data.content,linesChanged:t.data.linesChanged}):d(t.error)}o($,"removeCrossPlanConnection");function b(e,n){const{name:t,filePath:c,...a}=n,i={...a},r=m(e,{type:"cross-plan-connection",name:t,properties:i,...c!==void 0?{filePath:c}:{}});if(!r.success)return d(r.error);const s=h(a);return u({content:r.data.content,linesChanged:r.data.linesChanged,...s.length>0?{warnings:s}:{}})}o(b,"modifyCrossPlanConnection");function g(e){return[`Cross-plan connection to "${e.remoteApp}/${e.remoteResource}" requires an accepter role granting ${e.permission} access on the remote plan.`]}o(g,"buildAddWarnings");function h(e){return e.remoteApp===void 0&&e.remoteResource===void 0&&e.permission===void 0?[]:["Updating remoteApp, remoteResource, or permission may require a corresponding change to the accepter role on the remote plan."]}o(h,"buildModifyWarnings");export{x as addCrossPlanConnection,b as modifyCrossPlanConnection,$ as removeCrossPlanConnection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var t=Object.defineProperty;var i=(e,n)=>t(e,"name",{value:n,configurable:!0});function l(e,n,o){const r=e.summary;return r==="clean"?{action:"proceed",driftState:e}:r==="no-op"?{action:"skip",driftState:e}:o?.force===!0?{action:"proceed",driftState:e}:r==="drifted-compatible"?{action:"proceed",driftState:e}:r==="drifted-conflict"?u(e,o)?{action:"proceed",driftState:e}:{action:"reject",driftState:e}:n==="add"?{action:"proceed",driftState:e}:{action:"reject",driftState:e}}i(l,"resolveDriftPolicy");function u(e,n){const o=n?.resolutionMap;if(o===void 0)return!1;const r=e.deltas.filter(c=>c.verdict==="conflict");return r.length===0?!1:r.every(c=>Object.prototype.hasOwnProperty.call(o,c.property))}i(u,"isResolvedByMap");export{l as resolveDriftPolicy};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as
|
|
1
|
+
var l=Object.defineProperty;var s=(t,r)=>l(t,"name",{value:r,configurable:!0});import{failure as d,success as c}from"../../types/Result.js";import{extractProgramBody as y,isRecord as I}from"../_internal.js";import{appendSpecifier as g,buildImportDeclaration as S,detectQuoteStyle as x}from"../fileRewriter/index.js";function k(t,r){const e=y(t);if(e===void 0)return d({kind:"SemanticQueryError",reason:"recast File is missing program.body"});if(r.length===0)return c({mutated:!1});const n=x(t);let o=!1;for(const i of r){const f=A(e,i.module);if(f!==void 0){for(const a of i.specifiers){const m=u(f);g(f,a),u(f)>m&&(o=!0)}continue}if(i.specifiers.length===0)continue;const p=S(i.specifiers,i.module,n);D(e,p),o=!0}return c({mutated:o})}s(k,"ensureImports");function A(t,r){for(const e of t){if(e.type!=="ImportDeclaration")continue;const n=e.source;if(I(n)&&!(n.type!=="StringLiteral"&&n.type!=="Literal")&&n.value===r)return e}}s(A,"findImportDeclaration");function D(t,r){let e=-1;for(let o=0;o<t.length;o+=1){const i=t[o];i!==void 0&&i.type==="ImportDeclaration"&&(e=o)}const n=e===-1?0:e+1;t.splice(n,0,r)}s(D,"insertAfterLastImport");function u(t){if(!Array.isArray(t.specifiers))return 0;let r=0;for(const e of t.specifiers)e!==null&&typeof e=="object"&&"type"in e&&e.type==="ImportSpecifier"&&(r+=1);return r}s(u,"countImportedNames");export{k as ensureImports};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
var d=Object.defineProperty;var i=(n,e)=>d(n,"name",{value:e,configurable:!0});const r={import:0,"app-init":1,tags:2,organisation:3,database:4,storage:5,messaging:6,compute:7,network:8,"vpc-peer":9,"vpc-peer-accepter":10,"cross-plan-connection":11,cdn:12,pattern:13};function g(n,e,a,c){const s=r[a];let o;const p=r.import;for(const t of n)p<=s&&(o=t.endPos);for(const t of e)r[t.type]<=s&&(o=t.endPos);return o??c}i(g,"findInsertionPosition");export{g as findInsertionPosition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const n=Symbol("non-literal");function
|
|
1
|
+
var l=Object.defineProperty;var u=(e,r)=>l(e,"name",{value:r,configurable:!0});const n=Symbol("non-literal");function L(e,r){const o={};for(const t of e.properties){if(t.type!=="Property"&&t.type!=="ObjectProperty"||t.shorthand===!0||t.computed===!0)continue;const i=c(t.key);if(i===void 0||t.value===void 0)continue;const a=s(t.value);a!==n&&(o[i]=a)}return{...o,...r}}u(L,"buildMergedLiteral");function s(e){const r=e.value;switch(e.type){case"StringLiteral":return typeof r=="string"?r:n;case"NumericLiteral":return typeof r=="number"?r:n;case"BooleanLiteral":return typeof r=="boolean"?r:n;case"NullLiteral":return null;case"ArrayExpression":return y(e);case"ObjectExpression":return d(e);default:return n}}u(s,"astToLiteral");function y(e){const r=e.elements;if(!Array.isArray(r))return n;const o=[];for(const t of r){if(!p(t))return n;const i=s(t);if(i===n)return n;o.push(i)}return o}u(y,"arrayToLiteral");function d(e){const r=e.properties;if(!Array.isArray(r))return n;const o={};for(const t of r){if(!p(t)||t.type!=="Property"&&t.type!=="ObjectProperty")return n;const i=c(t.key),a=t.value;if(i===void 0||a===void 0)return n;const f=s(a);if(f===n)return n;o[i]=f}return o}u(d,"objectToLiteral");function c(e){if(e===void 0)return;const r=e;if(e.type==="Identifier"&&typeof r.name=="string")return r.name;if(e.type==="StringLiteral"&&typeof r.value=="string")return r.value}u(c,"readKeyName");function p(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.type=="string"}u(p,"isNodeShape");export{n as NON_LITERAL,s as astToLiteral,L as buildMergedLiteral,p as isNodeShape,c as readKeyName};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as c,success as
|
|
1
|
+
var S=Object.defineProperty;var d=(r,e)=>S(r,"name",{value:e,configurable:!0});import{failure as c,success as p}from"../../types/Result.js";import{DEFAULT_FILE_PATH as v,computeLinesDelta as w,extractProgramBody as C,isRecord as m}from"../_internal.js";import{buildObjectProperty as N,detectQuoteStyle as x,parse as T,printFile as A}from"../fileRewriter/index.js";import{STATEMENT_REGISTRY as F}from"../registry.js";import{locateAllShapes as R,locateByShape as L}from"../semanticIndex/index.js";import{checkControlFlowPolicy as j}from"./controlFlowPolicy.js";import{driftGate as O,runPipeline as Q,schemaGate as I}from"../validationGate/index.js";import{toAstValue as G}from"./addResource/propertyBuilder.js";import{buildMergedLiteral as U,isNodeShape as E,readKeyName as B}from"./modifyResource/literalConversion.js";function ne(r,e,a={}){const i=e.filePath??v,t=T(r,i);if(!t.success)return c(t.error);const n=L(r,{type:e.type,name:e.name},i);if(!n.success)return n.error.kind==="TemplateLiteralNameError"?c(n.error):c({kind:"SemanticQueryError",reason:n.error.reason,cause:n.error.cause});if(n.data===void 0)return c({kind:"ResourceNotFoundError",type:e.type,name:e.name,knownNames:$(r,e.type,i)});const o=j({ast:t.data,target:n.data,resource:{type:e.type,name:e.name},op:"modify"});if(o.refusal!==void 0)return c(o.refusal);const s=Q([I,O],{content:r,plan:{type:e.type,name:e.name,properties:e.properties,op:"modify"},baseline:a.baseline,policy:e.driftPolicy});if(!s.success)return c(D(s.error));if(s.data.action==="skip")return p({content:r,linesChanged:{added:0,removed:0},skipped:!0});const u=C(t.data);if(u===void 0)return c({kind:"SemanticQueryError",reason:"recast File is missing program.body"});const l=K(u,n.data);if(l===void 0)return c({kind:"SemanticQueryError",reason:"Unable to resolve config ObjectExpression for the located resource."});const k=x(t.data),b=U(l,e.properties),y=F[e.type].schemaFragment.safeParse(b);if(!y.success){const f=y.error.issues[0];return c({kind:"InvalidPropertyError",property:f!==void 0&&f.path.length>0?String(f.path[0]):Object.keys(e.properties)[0]??"<unknown>",reason:f?.message??"Schema validation failed"})}const g=_(l,e.properties,k);if(!g.success)return c(g.error);const h=A(t.data,r),P=o.warning!==void 0?[o.warning.message]:void 0;return p({content:h,linesChanged:w(r,h),warnings:P})}d(ne,"modifyResource");function D(r){switch(r.kind){case"ParseError":case"ResourceNotFoundError":case"InvalidPropertyError":case"TemplateLiteralNameError":case"SemanticQueryError":case"DriftConflictError":case"ControlFlowClassifierError":return r;default:return{kind:"SemanticQueryError",reason:`Unexpected codemod error in validation-gate pipeline: ${r.kind}`}}}d(D,"narrowGateError");function K(r,e){const a=e.start+e.length;let i;const t=d(n=>{if(i!==void 0||n.type!=="CallExpression")return;const o=n.arguments;if(!Array.isArray(o)||o.length<2)return;const s=o[0];if(!E(s)||s.type!=="StringLiteral"||s.start!==e.start||s.end!==a)return;const u=o[1];E(u)&&u.type==="ObjectExpression"&&(i=u)},"visitor");for(const n of r)if(H(n,t),i!==void 0)break;return i}d(K,"findConfigObject");function _(r,e,a){const i=V(r);for(const[t,n]of Object.entries(e)){const o=G(n,a);if(o===void 0)return c({kind:"InvalidPropertyError",property:t,reason:`Unsupported property value for "${t}" (accepts string/number/boolean/null/array/object of the same).`});const s=M(r,t);if(s!==void 0){s.value=o;continue}const u=N(t,o,a);i&&(u.extra={...u.extra??{},trailingComma:!0}),r.properties.push(u)}return p(void 0)}d(_,"applyPropertyEdits");function M(r,e){return r.properties.find(a=>(a.type==="Property"||a.type==="ObjectProperty")&&a.shorthand!==!0&&a.computed!==!0&&B(a.key)===e)}d(M,"findPropertyByKey");function V(r){return r.properties[r.properties.length-1]?.extra?.trailingComma===!0}d(V,"detectTrailingCommaStyle");function $(r,e,a){const i=R(r,a);return i.success?i.data.filter(t=>t.type===e).map(t=>t.symbolName):[]}d($,"collectKnownNames");function H(r,e){const a=[r];for(;a.length>0;){const i=a.pop();if(m(i)){typeof i.type=="string"&&e(i);for(const t of Object.keys(i)){if(t==="loc"||t==="comments"||t==="tokens")continue;const n=i[t];if(Array.isArray(n))for(const o of n)m(o)&&a.push(o);else m(n)&&a.push(n)}}}}d(H,"visit");export{ne as modifyResource};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
var f=Object.defineProperty;var r=(n,e)=>f(n,"name",{value:e,configurable:!0});function y(n,e){const t=[],i=[],s=n.comments;if(!Array.isArray(s)||typeof n.start!="number")return{preserved:t,adjacent:i};for(const o of s){if(!a(o)||o.leading!==!0||typeof o.end!="number")continue;const c=e.slice(o.end,n.start);u(c)>=2?t.push(o):i.push(o)}return{preserved:t,adjacent:i}}r(y,"classifyLeadingComments");function u(n){let e=0;for(let t=0;t<n.length;t+=1)n.charCodeAt(t)===10&&(e+=1);return e}r(u,"countNewlines");function a(n){if(typeof n!="object"||n===null||Array.isArray(n))return!1;const e=n;return typeof e.type=="string"&&typeof e.value=="string"}r(a,"isCommentNode");export{y as classifyLeadingComments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isRecord as f}from"../../_internal.js";function
|
|
1
|
+
var a=Object.defineProperty;var c=(e,n)=>a(e,"name",{value:n,configurable:!0});import{isRecord as f}from"../../_internal.js";function d(e){const n=u(e);for(let i=e.length-1;i>=0;i-=1){const t=e[i];if(t===void 0||t.type!=="ImportDeclaration")continue;const r=t.specifiers;if(!Array.isArray(r))continue;const o=r.filter(s=>{if(!m(s))return!0;const p=l(s);return(n.get(p)??0)>0});if(o.length!==r.length){if(o.length===0){e.splice(i,1);continue}t.specifiers=o}}}c(d,"pruneUnusedImports");function u(e){const n=new Map,i=[...e];for(;i.length>0;){const t=i.pop();if(!(!f(t)||typeof t.type!="string")&&t.type!=="ImportDeclaration"){if(t.type==="Identifier"){const r=t.name;typeof r=="string"&&n.set(r,(n.get(r)??0)+1);continue}for(const r of Object.keys(t)){if(r==="loc"||r==="comments"||r==="tokens")continue;const o=t[r];if(Array.isArray(o))for(const s of o)f(s)&&typeof s.type=="string"&&i.push(s);else f(o)&&typeof o.type=="string"&&i.push(o)}}}return n}c(u,"collectIdentifierUsage");function l(e){const n=e.local;if(f(n)){const t=n.name;if(typeof t=="string")return t}const i=e.imported;if(f(i)){const t=i.name;if(typeof t=="string")return t}return""}c(l,"readLocalName");function m(e){if(!f(e)||e.type!=="ImportSpecifier")return!1;const n=e.imported;return f(n)&&typeof n.name=="string"}c(m,"isNamedImportSpecifier");export{d as pruneUnusedImports};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as f,success as
|
|
1
|
+
var g=Object.defineProperty;var u=(n,r)=>g(n,"name",{value:r,configurable:!0});import{failure as f,success as d}from"../../types/Result.js";import{DEFAULT_FILE_PATH as p,computeLinesDelta as h,extractProgramBody as b,isRecord as l}from"../_internal.js";import{parse as E,printFile as v}from"../fileRewriter/index.js";import{findReferences as k,locateAllShapes as R,locateByShape as S}from"../semanticIndex/index.js";import{checkControlFlowPolicy as N}from"./controlFlowPolicy.js";import{classifyLeadingComments as D}from"./removeResource/commentHeuristic.js";import{pruneUnusedImports as F}from"./removeResource/importPruning.js";function H(n,r){const a=r.filePath??p,t=E(n,a);if(!t.success)return f(t.error);const e=S(n,{type:r.type,name:r.name},a);if(!e.success)return e.error.kind==="TemplateLiteralNameError"?f(e.error):f({kind:"SemanticQueryError",reason:e.error.reason,cause:e.error.cause});if(e.data===void 0)return f({kind:"ResourceNotFoundError",type:r.type,name:r.name,knownNames:Q(n,r.type,a)});const o=N({ast:t.data,target:e.data,resource:{type:r.type,name:r.name},op:"remove"});if(o.refusal!==void 0)return f(o.refusal);const i=b(t.data);if(i===void 0)return f({kind:"SemanticQueryError",reason:"recast File is missing program.body"});const c=P(i,e.data);if(c===void 0)return f({kind:"SemanticQueryError",reason:"Unable to resolve enclosing statement for the located resource."});const s=A(n,c.statement,a);if(!s.success)return f(s.error);if(s.data.locations.length>0&&r.force!==!0)return f({kind:"ReferencesRemainError",variable:s.data.variable??r.name,references:s.data.locations});x(i,c.index,n),F(i);const m=v(t.data,n),y=h(n,m);return d({content:m,linesChanged:y,references:s.data.locations})}u(H,"removeResource");function P(n,r){const a=r.start+r.length;for(let t=0;t<n.length;t+=1){const e=n[t];if(e!==void 0&&!(typeof e.start!="number"||typeof e.end!="number")&&e.start<=r.start&&e.end>=a)return{index:t,statement:e}}}u(P,"findEnclosingStatement");function A(n,r,a){const t=L(r);if(t===void 0)return d({variable:void 0,locations:[]});const e=k(n,t.location,a);return e.success?d({variable:t.name,locations:e.data}):f({kind:"SemanticQueryError",reason:e.error.reason,cause:e.error.cause})}u(A,"resolveReferences");function L(n){let r=n;if(n.type==="ExportNamedDeclaration"){const s=n.declaration;if(!l(s)||s.type!=="VariableDeclaration")return;r=s}if(r.type!=="VariableDeclaration")return;const a=r.declarations;if(!Array.isArray(a)||a.length!==1)return;const t=a[0];if(!l(t))return;const e=t.id;if(!l(e)||e.type!=="Identifier")return;const o=e.name,i=e.start,c=e.end;if(!(typeof o!="string"||typeof i!="number"||typeof c!="number"))return{name:o,location:{filePath:p,start:i,length:c-i,symbolName:o}}}u(L,"extractVariableDeclaration");function x(n,r,a){const t=n[r];if(t===void 0)return;const{preserved:e}=D(t,a);if(e.length>0){const o=n[r+1];if(o!==void 0){const i=e.map(c=>({...c,leading:!0,trailing:!1}));o.comments=[...i,...o.comments??[]]}else{const i=n[r-1];if(i!==void 0){const c=e.map(s=>({...s,leading:!1,trailing:!0}));i.comments=[...i.comments??[],...c]}}}n.splice(r,1)}u(x,"spliceStatement");function Q(n,r,a){const t=R(n,a);if(!t.success)return[];const e=[];for(const o of t.data)o.type===r&&e.push(o.symbolName);return e}u(Q,"collectKnownNames");export{H as removeResource};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as
|
|
1
|
+
var P=Object.defineProperty;var c=(e,n)=>P(e,"name",{value:n,configurable:!0});import{failure as a,success as p}from"../../types/Result.js";import{addResource as A}from"./addResource.js";import{modifyResource as y}from"./modifyResource.js";import{removeResource as $}from"./removeResource.js";const s="vpc-peer";function _(e,n){const t=m(n);if(t!==void 0)return a(t);const{name:r,filePath:i,currentAccount:u,...f}=n,l={...f},d=A(e,{type:s,name:r,properties:l,...i!==void 0?{filePath:i}:{}});if(!d.success)return a(d.error);const o=C(n);return p({content:d.data.content,linesChanged:d.data.linesChanged,...o.length>0?{warnings:o}:{}})}c(_,"addVpcPeer");function E(e,n){const t=$(e,{type:s,name:n.name,...n.filePath!==void 0?{filePath:n.filePath}:{},...n.force!==void 0?{force:n.force}:{}});return t.success?p({content:t.data.content,linesChanged:t.data.linesChanged}):a(t.error)}c(E,"removeVpcPeer");function k(e,n){const t=m(n);if(t!==void 0)return a(t);const{name:r,filePath:i,currentAccount:u,...f}=n,l={...f},d=y(e,{type:s,name:r,properties:l,...i!==void 0?{filePath:i}:{}});if(!d.success)return a(d.error);const o=W(f,u);return p({content:d.data.content,linesChanged:d.data.linesChanged,...o.length>0?{warnings:o}:{}})}c(k,"modifyVpcPeer");function C(e){return g(e.peerAppName,e.peerAccountId,e.currentAccount)}c(C,"buildAddWarnings");function W(e,n){return e.peerAccountId===void 0?[]:g(e.peerAppName,e.peerAccountId,n)}c(W,"buildModifyWarnings");function g(e,n,t){if(t!==void 0&&n===t)return[];const r=e!==void 0?` (peer app ${e})`:"";return[`VPC peer targets AWS account ${n}${r}. Peer requires a VpcPeerAccepter in that account trusting the local account. Deploy the accepter stack first, then the requester.`]}c(g,"buildCrossAccountWarnings");function x(e,n,t){const r=h(n);if(r!==void 0)return{kind:"PermissionError",reason:"wildcard-principal-rejected",details:`Wildcard value detected in ${e} field "${r}". Fjall refuses to emit a ${e} statement that could map to a wildcard principal in the generated trust policy.`,remediation:t}}c(x,"buildWildcardRejection");function m(e){const{name:n,filePath:t,currentAccount:r,...i}=e;return x(s,i,"Replace the wildcard with a concrete 12-digit AWS account id, region, or vpc-id.")}c(m,"rejectWildcardPrincipal");function h(e,n=""){if(typeof e=="string")return e.includes("*")?n:void 0;if(Array.isArray(e)){for(let t=0;t<e.length;t+=1){const r=h(e[t],`${n}[${t}]`);if(r!==void 0)return r}return}if(e!==null&&typeof e=="object")for(const[t,r]of Object.entries(e)){const i=n.length>0?`${n}.${t}`:t,u=h(r,i);if(u!==void 0)return u}}c(h,"findWildcardField");export{_ as addVpcPeer,x as buildWildcardRejection,h as findWildcardField,k as modifyVpcPeer,E as removeVpcPeer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as
|
|
1
|
+
var m=Object.defineProperty;var n=(e,r)=>m(e,"name",{value:r,configurable:!0});import{failure as f,success as s}from"../../types/Result.js";import{addResource as l}from"./addResource.js";import{modifyResource as P}from"./modifyResource.js";import{removeResource as h}from"./removeResource.js";import{buildWildcardRejection as R}from"./vpcPeer.js";const d="vpc-peer-accepter";function u(e){return e.success?s({content:e.data.content,linesChanged:e.data.linesChanged}):f(e.error)}n(u,"unwrapEditResult");function x(e,r){const t=p(r);if(t!==void 0)return f(t);const{name:c,filePath:i,...o}=r,a={...o};return u(l(e,{type:d,name:c,properties:a,...i!==void 0?{filePath:i}:{}}))}n(x,"addVpcPeerAccepter");function C(e,r){return u(h(e,{type:d,name:r.name,...r.filePath!==void 0?{filePath:r.filePath}:{},...r.force!==void 0?{force:r.force}:{}}))}n(C,"removeVpcPeerAccepter");function V(e,r){const t=p(r);if(t!==void 0)return f(t);const{name:c,filePath:i,...o}=r,a={...o};return u(P(e,{type:d,name:c,properties:a,...i!==void 0?{filePath:i}:{}}))}n(V,"modifyVpcPeerAccepter");function p(e){const{name:r,filePath:t,...c}=e;return R(d,c,"Replace the wildcard with a concrete 12-digit AWS account id.")}n(p,"rejectWildcardPrincipal");export{x as addVpcPeerAccepter,V as modifyVpcPeerAccepter,C as removeVpcPeerAccepter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{builders as
|
|
1
|
+
var p=Object.defineProperty;var n=(e,i)=>p(e,"name",{value:i,configurable:!0});import{builders as t}from"ast-types";function x(e){const i=t.memberExpression(t.identifier(e.factory),t.identifier("build"),!1),r=f(e.name,e.quoteStyle),o=t.objectExpression(e.properties.map(s=>u(s.key,s.value,e.quoteStyle))),c=t.callExpression(i,[r,o]);return t.expressionStatement(c)}n(x,"buildFactoryStatement");function u(e,i,r){const o=l(e)?t.identifier(e):f(e,r);return t.property("init",o,i)}n(u,"buildObjectProperty");function y(e,i,r="double"){const o=e.map(s=>t.importSpecifier(t.identifier(s))),c=f(i,r);return t.importDeclaration(o,c)}n(y,"buildImportDeclaration");function S(e,i){return t.memberExpression(t.identifier(e),t.identifier(i),!1)}n(S,"buildMemberExpression");function g(e,i){Array.isArray(e.specifiers)||(e.specifiers=[]);for(const r of e.specifiers)if(d(r)&&r.imported.name===i)return;e.specifiers.push(t.importSpecifier(t.identifier(i)))}n(g,"appendSpecifier");function f(e,i){const r=i==="single"?"'":'"',o=`${r}${a(e,i)}${r}`;return t.stringLiteral.from({value:e,extra:{rawValue:e,raw:o}})}n(f,"makeStringLiteral");function a(e,i){const r=e.replace(/\\/g,"\\\\");return i==="single"?r.replace(/'/g,"\\'"):r.replace(/"/g,'\\"')}n(a,"escapeForQuote");function l(e){return/^[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}]*$/u.test(e)}n(l,"isValidIdentifier");function d(e){return e!==null&&typeof e=="object"&&"type"in e&&e.type==="ImportSpecifier"}n(d,"isNamedImportSpecifier");export{g as appendSpecifier,x as buildFactoryStatement,y as buildImportDeclaration,S as buildMemberExpression,u as buildObjectProperty};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
var m=Object.defineProperty;var f=(i,n)=>m(i,"name",{value:n,configurable:!0});function d(i,n,u){const e=g(i,n);if(e!==void 0)return e;if(u?.line!==void 0)return b(i,{...n,...u})}f(d,"locateByRange");function b(i,n){if(n.line===void 0)return;const u=n.line,e=n.column??0,r=[];if(p(i,t=>{if(t.type!=="StringLiteral"||typeof t.value!="string"||t.value!==n.symbolName||typeof t.start!="number"||typeof t.end!="number")return;const s=t.loc?.start?.line,a=t.loc?.start?.column;typeof s!="number"||typeof a!="number"||Math.abs(s-u)>2||r.push({node:t,line:s,column:a,start:t.start})}),r.length!==0)return r.sort((t,s)=>{const a=Math.abs(t.line-u),c=Math.abs(s.line-u);if(a!==c)return a-c;const l=Math.abs(t.column-e),y=Math.abs(s.column-e);return l!==y?l-y:t.start-s.start}),r[0]?.node}f(b,"locateByLineColumn");function g(i,n){const u=n.start+n.length;let e;return p(i,r=>{e===void 0&&(typeof r.start!="number"||typeof r.end!="number"||r.start===n.start&&r.end===u&&(e=r))}),e}f(g,"findByExactRange");function p(i,n){const u=[i];for(;u.length>0;){const e=u.pop();if(!(!o(e)||typeof e.type!="string")){n(e);for(const r of Object.keys(e)){if(r==="loc"||r==="comments"||r==="tokens")continue;const t=e[r];if(Array.isArray(t))for(const s of t)o(s)&&typeof s.type=="string"&&u.push(s);else o(t)&&typeof t.type=="string"&&u.push(t)}}}}f(p,"visit");function o(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}f(o,"isRecord");export{b as locateByLineColumn,d as locateByRange};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
`)}export{
|
|
1
|
+
var x=Object.defineProperty;var o=(n,t)=>x(n,"name",{value:t,configurable:!0});import*as E from"recast";import y from"recast/parsers/typescript.js";import m from"recast/parsers/babel-ts.js";import{failure as b,success as g}from"../../types/Result.js";const l=1,p=120;function j(n,t){if((t?.endsWith(".tsx")??!1)||S(n))return a(n,m,t);const e=a(n,y,t);if(e.success)return e;const s=a(n,m,t);return s.success?s:e}o(j,"parse");function S(n){return/<[A-Z][A-Za-z0-9]*[\s/>]|<>/.test(n)}o(S,"detectJsx");function a(n,t,r){try{const e=E.parse(n,{parser:t});return g(e)}catch(e){return b(h(e,n,r))}}o(a,"tryParse");function h(n,t,r){const e=n instanceof Error?n.message:String(n),s=L(n),c=s?.line,u=s?.column;return{kind:"ParseError",file:r,line:c,column:u,message:e,sourceSnippet:N(t,c)}}o(h,"toParseError");function L(n){if(typeof n!="object"||n===null)return;const t=n.loc;if(typeof t!="object"||t===null)return;const r=t.line,e=t.column;return{line:typeof r=="number"?r:void 0,column:typeof e=="number"?e:void 0}}o(L,"extractLoc");function N(n,t){const r=n.split(/\r?\n/);if(r.length===0)return"";const e=t!==void 0&&t>=1&&t<=r.length?t-1:0,s=Math.max(0,e-l),c=Math.min(r.length-1,e+l),u=[];for(let i=s;i<=c;i+=1){const f=r[i]??"",d=f.length>p?`${f.slice(0,p)}\u2026`:f;u.push(d)}return u.join(`
|
|
2
|
+
`)}o(N,"buildSourceSnippet");export{j as parse};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
var p=Object.defineProperty;var s=(t,o)=>p(t,"name",{value:o,configurable:!0});import*as a from"recast";const l="\uFEFF",u=65279;function h(t,o){const i=y(o),e=m(t),r=a.print(t,{quote:e,lineTerminator:i,trailingComma:!0}).code,n=o.charCodeAt(0)===u,c=r.charCodeAt(0)===u;return n&&!c?`${l}${r}`:r}s(h,"printFile");function y(t){return t.includes(`\r
|
|
2
2
|
`)?`\r
|
|
3
3
|
`:`
|
|
4
|
-
`}function
|
|
4
|
+
`}s(y,"detectLineTerminator");function m(t){let o=0,i=0;return g(t,e=>{if(e.type!=="StringLiteral"&&e.type!=="Literal")return;const r=e.extra;if(!f(r))return;const n=r.raw;if(typeof n!="string"||n.length===0)return;const c=n.charAt(0);c==="'"?o+=1:c==='"'&&(i+=1)}),o>i?"single":"double"}s(m,"detectQuoteStyle");function g(t,o){const i=[t];for(;i.length>0;){const e=i.pop();if(!(!f(e)||typeof e.type!="string")){o(e);for(const r of Object.keys(e)){if(r==="loc"||r==="comments"||r==="tokens")continue;const n=e[r];if(Array.isArray(n))for(const c of n)f(c)&&typeof c.type=="string"&&i.push(c);else f(n)&&typeof n.type=="string"&&i.push(n)}}}}s(g,"visit");function f(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}s(f,"isRecord");export{y as detectLineTerminator,m as detectQuoteStyle,h as printFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
var a=Object.defineProperty;var n=(t,r)=>a(t,"name",{value:r,configurable:!0});function c(t){return`${t}.bak`}n(c,"backupPath");function p(t,r){const o=r.toISOString().replaceAll(":","");return`${t}/${o}.ts`}n(p,"historyEntryPath");export{c as backupPath,p as historyEntryPath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failure as
|
|
1
|
+
var c=Object.defineProperty;var o=(s,r)=>c(s,"name",{value:r,configurable:!0});import{failure as m,success as l}from"../types/Result.js";import{DEFAULT_FILE_PATH as n}from"./_internal.js";import{locateAllShapes as p}from"./semanticIndex/index.js";function A(s,r=n){const t=p(s,r);if(!t.success)return m(t.error);const a=t.data.map(e=>({type:e.type,name:e.symbolName,filePath:e.filePath,start:e.start,length:e.length}));return l({filePath:r,resources:a})}o(A,"listResources");export{A as listResources};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{success as
|
|
1
|
+
var d=Object.defineProperty;var l=(o,n)=>d(o,"name",{value:n,configurable:!0});import{success as u,failure as f}from"../../types/Result.js";function O(o,n){let e=o,r=0,i=0;for(let s=0;s<n.length;s+=1){const t=n[s];if(t===void 0)continue;const c=e.indexOf(t.old_str);if(c===-1){i+=1;continue}if(e.indexOf(t.old_str,c+1)!==-1)return f({kind:"ambiguous-str-replace",opIndex:s,old_str:t.old_str,matchCount:p(e,t.old_str)});e=e.slice(0,c)+t.new_str+e.slice(c+t.old_str.length),r+=1}return u({content:e,appliedCount:r,skippedCount:i})}l(O,"applyStrReplaceOps");function p(o,n){let e=0,r=0;for(;;){const i=o.indexOf(n,r);if(i===-1)break;e+=1,r=i+1}return e}l(p,"countOccurrences");export{O as applyStrReplaceOps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{gateEgress as
|
|
1
|
+
var k=Object.defineProperty;var p=(t,n)=>k(t,"name",{value:n,configurable:!0});import{gateEgress as d}from"./egressGate.js";import{buildPrompt as E}from"./prompt.js";import{applyStrReplaceOps as b}from"./apply.js";import{withTierTimeout as w}from"./tierRunner.js";import{PARSE_GATE as m}from"./types.js";const O=3e4,o="claude",f={name:"str_replace_based_edit_tool",type:"text_editor_20250728"};async function P(t,n){if(!t.orgAllowsFallback)return{state:"disabled",reason:"org-opt-out"};const s=d(t.content,o);if(s!==void 0)return s;const e=d(JSON.stringify(t.intent.properties),o);if(e!==void 0)return e;const{systemPrompt:i,userPrompt:c}=E({content:t.content,intent:t.intent,tier:o});return w(t.abortSignal,o,O,async({signal:_,started:g})=>{const a=await n.create({model:n.resolveModelId(),max_tokens:4096,system:i,messages:[{role:"user",content:c}],tools:[f],signal:_}),T=Date.now()-g,l=x(a.content);if(l.length===0)return{state:"rejected",tier:o,failedGate:m,diagnostics:"Model produced no str_replace operations"};const r=b(t.content,l);if(!r.success)return{state:"rejected",tier:o,failedGate:m,diagnostics:`Ambiguous str_replace at op ${r.error.opIndex}: "${r.error.old_str.slice(0,40)}\u2026" matched ${r.error.matchCount} times`};const u=d(r.data.content,o);if(u!==void 0)return u;const y={tier:o,elapsedMs:T,inputTokens:a.usage?.input_tokens??0,outputTokens:a.usage?.output_tokens??0,opsApplied:r.data.appliedCount};return{state:"applied",content:r.data.content,telemetry:y}})}p(P,"runClaudeTier");function x(t){const n=[];for(const s of t){if(s.type!=="tool_use"||s.name!==f.name)continue;const e=s.input;if(!("command"in e)||e.command!=="str_replace"||!("old_str"in e)||!("new_str"in e))continue;const i=e.old_str,c=e.new_str;typeof i!="string"||typeof c!="string"||n.push({old_str:i,new_str:c})}return n}p(x,"extractStrReplaceOps");export{f as TEXT_EDITOR_TOOL,P as runClaudeTier};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
var a=Object.defineProperty;var r=(t,n)=>a(t,"name",{value:n,configurable:!0});const h=32,u=4.5,f=8,_=/\barn:aws:[a-z0-9-]+:[a-z0-9-]*:[0-9]*:[^\s"']+/g,H=/(?<![A-Za-z0-9+/=_-])[A-Za-z0-9+/=_-]{32,}(?![A-Za-z0-9+/=_-])/g;function E(t){if(t.length===0)return 0;const n=new Map;for(const o of t)n.set(o,(n.get(o)??0)+1);let e=0;for(const o of n.values()){const s=o/t.length;e-=s*Math.log2(s)}return e}r(E,"shannonEntropy");function c(t){return t.length<=8?t:`${t.slice(0,8)}\u2026`}r(c,"truncateHint");function l(t){const n=[...t.matchAll(_)];if(n.length>0){const o=n[0]?.[0]??"";return{state:"block",reason:"arn-shape",count:n.length,sampleHint:c(o)}}const e=[];for(const o of t.matchAll(H)){const s=o[0]??"";s.length>=32&&E(s)>=4.5&&e.push(s)}return e.length>0?{state:"block",reason:"high-entropy",count:e.length,sampleHint:c(e[0]??"")}:{state:"pass"}}r(l,"scanForEgressRisk");function g(t,n){const e=l(t);if(e.state==="block")return{state:"egress-blocked",tier:n,reason:e.reason,count:e.count}}r(g,"gateEgress");export{g as gateEgress,l as scanForEgressRisk};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{gateEgress as
|
|
1
|
+
var m=Object.defineProperty;var c=(e,o)=>m(e,"name",{value:o,configurable:!0});import{gateEgress as r}from"./egressGate.js";import{buildPrompt as T}from"./prompt.js";import{withTierTimeout as k}from"./tierRunner.js";import{PARSE_GATE as E}from"./types.js";const b=15e3,t="morph";async function _(e,o){if(!e.orgAllowsFallback)return{state:"disabled",reason:"org-opt-out"};if(!o.isAvailable())return{state:"disabled",reason:"env-flag"};const s=r(e.content,t);if(s!==void 0)return s;const i=r(JSON.stringify(e.intent.properties),t);if(i!==void 0)return i;const{systemPrompt:p,userPrompt:u}=T({content:e.content,intent:e.intent,tier:t});return k(e.abortSignal,t,b,async({signal:l,started:d})=>{const n=await o.apply({originalFile:e.content,update:`${p}
|
|
2
2
|
|
|
3
|
-
${
|
|
3
|
+
${u}`,signal:l}),f=Date.now()-d;if(n.content===e.content)return{state:"rejected",tier:t,failedGate:E,diagnostics:"Morph returned unchanged content"};const a=r(n.content,t);if(a!==void 0)return a;const g={tier:t,elapsedMs:f,inputTokens:n.usage?.inputTokens??0,outputTokens:n.usage?.outputTokens??0,opsApplied:1};return{state:"applied",content:n.content,telemetry:g}})}c(_,"runMorphTier");export{_ as runMorphTier};
|