@fjall/generator 8.0.0 → 9.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.
- package/dist/.build-source-hash +21 -18
- package/dist/.minified +1 -1
- package/dist/src/codemod/edits/appendAccountToStage.js +1 -1
- package/dist/src/codemod/edits/computeServiceLocator.d.ts +65 -0
- package/dist/src/codemod/edits/computeServiceLocator.js +1 -0
- package/dist/src/codemod/edits/connectResourceToCompute.d.ts +65 -0
- package/dist/src/codemod/edits/connectResourceToCompute.js +1 -0
- package/dist/src/codemod/edits/moduleConstResolver.d.ts +1 -0
- package/dist/src/codemod/edits/moduleConstResolver.js +1 -1
- package/dist/src/codemod/edits/objectGraph.d.ts +6 -0
- package/dist/src/codemod/edits/objectGraph.js +1 -1
- package/dist/src/codemod/edits/setContainerSecrets.js +1 -1
- package/dist/src/codemod/index.d.ts +1 -0
- package/dist/src/codemod/index.js +1 -1
- package/dist/src/codemod/registry.d.ts +1 -2
- package/dist/src/codemod/registry.js +1 -1
- package/dist/src/codemod/types.d.ts +9 -1
- package/dist/src/codemod/types.js +1 -1
- package/dist/src/generation/common.d.ts +15 -0
- package/dist/src/generation/common.js +6 -6
- package/dist/src/generation/database.d.ts +20 -0
- package/dist/src/generation/database.js +18 -18
- package/dist/src/generation/messagingConnections.js +1 -1
- package/dist/src/generation/storageConnections.d.ts +9 -0
- package/dist/src/generation/storageConnections.js +1 -1
- package/dist/src/planning/index.d.ts +2 -1
- package/dist/src/planning/index.js +1 -1
- package/dist/src/planning/planBuilders.d.ts +48 -0
- package/dist/src/planning/planBuilders.js +1 -0
- package/dist/src/planning/resourceAddition.d.ts +3 -0
- package/dist/src/planning/resourceAddition.js +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +2 -2
package/dist/.build-source-hash
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"package.json",
|
|
10
10
|
"tsconfig.json"
|
|
11
11
|
],
|
|
12
|
-
"hash": "
|
|
12
|
+
"hash": "ad0983e8acdd6ab00f35788c1a68734a2a72ae29e370dc810e7d1c4491996315",
|
|
13
13
|
"files": {
|
|
14
14
|
"src/ast/astTestHelpers.ts": "026cac849eb88bdb",
|
|
15
15
|
"src/ast/domain/astDomainParser.ts": "940ce5742507477d",
|
|
@@ -45,7 +45,9 @@
|
|
|
45
45
|
"src/codemod/edits/addResource/appBinding.ts": "3553fdb30fe06335",
|
|
46
46
|
"src/codemod/edits/addResource/bodyIndex.ts": "3e179eac10d7bcf4",
|
|
47
47
|
"src/codemod/edits/addResource/propertyBuilder.ts": "9102dff7e9fab376",
|
|
48
|
-
"src/codemod/edits/appendAccountToStage.ts": "
|
|
48
|
+
"src/codemod/edits/appendAccountToStage.ts": "1796d909fa3ef79d",
|
|
49
|
+
"src/codemod/edits/computeServiceLocator.ts": "7f86483d9a35e053",
|
|
50
|
+
"src/codemod/edits/connectResourceToCompute.ts": "7e90a6fbfb07c630",
|
|
49
51
|
"src/codemod/edits/controlFlowPolicy.ts": "e32bbe2894f76c65",
|
|
50
52
|
"src/codemod/edits/crossPlanConnection.ts": "54a4ecb7b3368160",
|
|
51
53
|
"src/codemod/edits/driftPolicy.ts": "5d9b7bb3505f987d",
|
|
@@ -54,13 +56,13 @@
|
|
|
54
56
|
"src/codemod/edits/index.ts": "bea5ed7c3983342b",
|
|
55
57
|
"src/codemod/edits/modifyResource.ts": "c27380cf9dae5dfc",
|
|
56
58
|
"src/codemod/edits/modifyResource/literalConversion.ts": "31295cccd59131b7",
|
|
57
|
-
"src/codemod/edits/moduleConstResolver.ts": "
|
|
58
|
-
"src/codemod/edits/objectGraph.ts": "
|
|
59
|
+
"src/codemod/edits/moduleConstResolver.ts": "85a8597427849a80",
|
|
60
|
+
"src/codemod/edits/objectGraph.ts": "5efc4181547237f8",
|
|
59
61
|
"src/codemod/edits/removeResource.ts": "2c7c8fe67bc3a866",
|
|
60
62
|
"src/codemod/edits/removeResource/commentHeuristic.ts": "90b6ce7ba5aa2a48",
|
|
61
63
|
"src/codemod/edits/removeResource/importPruning.ts": "f22783108b40f6cb",
|
|
62
64
|
"src/codemod/edits/secretsProvability.ts": "d723283918e31efd",
|
|
63
|
-
"src/codemod/edits/setContainerSecrets.ts": "
|
|
65
|
+
"src/codemod/edits/setContainerSecrets.ts": "24478c4205e79cbd",
|
|
64
66
|
"src/codemod/edits/unmanagedShapeErrors.ts": "47a2644913c8e619",
|
|
65
67
|
"src/codemod/edits/vpcPeer.ts": "0bcf90c2e6d16ca4",
|
|
66
68
|
"src/codemod/edits/vpcPeerAccepter.ts": "c9eace933e9e2345",
|
|
@@ -72,7 +74,7 @@
|
|
|
72
74
|
"src/codemod/fileRewriter/parse.ts": "b12026c31562a13c",
|
|
73
75
|
"src/codemod/fileRewriter/print.ts": "f5ff7afb5b7786bf",
|
|
74
76
|
"src/codemod/historyPaths.ts": "ef8084013146db57",
|
|
75
|
-
"src/codemod/index.ts": "
|
|
77
|
+
"src/codemod/index.ts": "db90315eab333aab",
|
|
76
78
|
"src/codemod/listResources.ts": "97f206a50edbea20",
|
|
77
79
|
"src/codemod/llmFallback/apply.ts": "2e656a6e55b3b4e3",
|
|
78
80
|
"src/codemod/llmFallback/claudeTier.ts": "0a37fe782c85f75b",
|
|
@@ -87,7 +89,7 @@
|
|
|
87
89
|
"src/codemod/llmFallback/telemetryEvents.ts": "33a85939739693ab",
|
|
88
90
|
"src/codemod/llmFallback/tierRunner.ts": "a26094accd78cf15",
|
|
89
91
|
"src/codemod/llmFallback/types.ts": "14af8d2bd9afae12",
|
|
90
|
-
"src/codemod/registry.ts": "
|
|
92
|
+
"src/codemod/registry.ts": "e4c9ae5ccc782b7f",
|
|
91
93
|
"src/codemod/semanticIndex/classifyControlFlow.ts": "ed96215d91a3cae3",
|
|
92
94
|
"src/codemod/semanticIndex/findReferences.ts": "96aea37418d1e91a",
|
|
93
95
|
"src/codemod/semanticIndex/index.ts": "cfcd212d34ab20fb",
|
|
@@ -96,7 +98,7 @@
|
|
|
96
98
|
"src/codemod/semanticIndex/projectCache.ts": "dfd9b265c9d233c9",
|
|
97
99
|
"src/codemod/semanticIndex/resolveConstructByLiteralProperty.ts": "2d013a330af15c5c",
|
|
98
100
|
"src/codemod/telemetry/errorKinds.ts": "66c736abfa8b3a67",
|
|
99
|
-
"src/codemod/types.ts": "
|
|
101
|
+
"src/codemod/types.ts": "0cd929df5bb46696",
|
|
100
102
|
"src/codemod/validationGate/gates/classify.ts": "edb92a1f7a2d9aeb",
|
|
101
103
|
"src/codemod/validationGate/gates/drift.ts": "bd603a216fbb91a9",
|
|
102
104
|
"src/codemod/validationGate/gates/locate.ts": "2c186c32edbb97ce",
|
|
@@ -111,24 +113,25 @@
|
|
|
111
113
|
"src/dns/domainRecords.ts": "ab917006b92ae916",
|
|
112
114
|
"src/dns/index.ts": "b476ef3d7b381dc8",
|
|
113
115
|
"src/dns/types.ts": "82d6db9d7d26dbc2",
|
|
114
|
-
"src/generation/common.ts": "
|
|
116
|
+
"src/generation/common.ts": "ab66eac580bc227f",
|
|
115
117
|
"src/generation/compute.ts": "4029a0d8e3197686",
|
|
116
118
|
"src/generation/compute/ec2.ts": "4d8187d293a57fb1",
|
|
117
119
|
"src/generation/compute/ecs.ts": "72190132fdaa1847",
|
|
118
120
|
"src/generation/compute/lambda.ts": "4f5e31080941b83a",
|
|
119
121
|
"src/generation/compute/shared.ts": "3724d4bfe92cfcb7",
|
|
120
|
-
"src/generation/database.ts": "
|
|
122
|
+
"src/generation/database.ts": "dd4a1540986ad350",
|
|
121
123
|
"src/generation/generatePatternCode.ts": "de16f42105a45358",
|
|
122
124
|
"src/generation/index.ts": "fd58a833e13bcf07",
|
|
123
125
|
"src/generation/infrastructure.ts": "6381d502f4733926",
|
|
124
|
-
"src/generation/messagingConnections.ts": "
|
|
126
|
+
"src/generation/messagingConnections.ts": "fef976a8261c6751",
|
|
125
127
|
"src/generation/storage.ts": "2c0171aeeec3d79e",
|
|
126
|
-
"src/generation/storageConnections.ts": "
|
|
128
|
+
"src/generation/storageConnections.ts": "a4020c9d6c36dc3f",
|
|
127
129
|
"src/index.ts": "fc8f27b8ffade9ef",
|
|
128
130
|
"src/planning/generateResourceChange.ts": "1c6411f9a12e7acb",
|
|
129
|
-
"src/planning/index.ts": "
|
|
131
|
+
"src/planning/index.ts": "8ef807b31c43310c",
|
|
130
132
|
"src/planning/openNextPlanning.ts": "4af9cb9061f7d21e",
|
|
131
|
-
"src/planning/
|
|
133
|
+
"src/planning/planBuilders.ts": "bea93d0c05caef21",
|
|
134
|
+
"src/planning/resourceAddition.ts": "ba27203af283d840",
|
|
132
135
|
"src/planning/resourceConnections.ts": "a6b7db8f733e560f",
|
|
133
136
|
"src/planning/resourcePlanning.ts": "6c966fe586fff080",
|
|
134
137
|
"src/planning/staticSitePlanning.ts": "242af1e9618821ab",
|
|
@@ -166,11 +169,11 @@
|
|
|
166
169
|
"src/validation/patterns.ts": "f9629eafdad7ac3e",
|
|
167
170
|
"src/validation/validationMessages.ts": "c727ade4690274f4",
|
|
168
171
|
"src/validation/validationPatterns.ts": "865f3d688975b7c8",
|
|
169
|
-
"src/version.ts": "
|
|
172
|
+
"src/version.ts": "27d242fcf04ce64a",
|
|
170
173
|
"../scripts/minify-dist.mjs": "6b2e4b0df8aec601",
|
|
171
|
-
"package.json": "
|
|
174
|
+
"package.json": "8ff7f2a2605bff3a",
|
|
172
175
|
"tsconfig.json": "1929cf3f99fe9b1e"
|
|
173
176
|
},
|
|
174
|
-
"outputHash": "
|
|
175
|
-
"outputFileCount":
|
|
177
|
+
"outputHash": "764ac0887b73972f66e833ef1670b1225c82080d76940e2dc6781c0a873419f0",
|
|
178
|
+
"outputFileCount": 319
|
|
176
179
|
}
|
package/dist/.minified
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
159 files minified at 2026-08-09T10:17:00.891Z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var T=Object.defineProperty;var d=(e,r)=>T(e,"name",{value:r,configurable:!0});import{failure as c,success as y}from"../../types/Result.js";import{DEFAULT_FILE_PATH as b,computeLinesDelta as k,extractProgramBody as x}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 O}from"./addResource/propertyBuilder.js";import{astToLiteral as w,isNodeShape as f,readKeyName as N}from"./modifyResource/literalConversion.js";import{findPropertyByKey as E,pushPropertyPreservingComma as I}from"./objectGraph.js";const K="ACCOUNTS",V="workloads";function W(e,r){const a=r.filePath??b,t=r.constName??K,n=r.nestedKey??V,{stage:o,displayName:s}=r,i=C(e,a);if(!i.success)return c(i.error);const l=x(i.data);if(l===void 0)return c({kind:"InvalidStageTargetError",stage:o,reason:"recast File is missing program.body"});const m=j(l,t);if(m===void 0)return c({kind:"ConstNotFoundError",constName:t});const p=D(i.data),u=_(m,{constName:t,stage:o,nestedKey:n,displayName:s,quoteStyle:p});if(!u.success)return c(u.error);if(u.data.created)return P(i.data,e);const v=u.data.array;return v.elements.some(A=>f(A)&&w(A)===s)?y({content:e,linesChanged:{added:0,removed:0},skipped:!0}):(v.elements.push(L(s,p)),P(i.data,e))}d(W,"appendAccountToStage");function P(e,r){const a=F(e,r);return y({content:a,linesChanged:k(r,a)})}d(P,"printSuccess");function _(e,r){const{constName:a,stage:t,nestedKey:n,displayName:o,quoteStyle:s}=r,i=E(e,t);if(i!==void 0)return S(i.value)?y({created:!1,array:i.value}):c({kind:"InvalidStageTargetError",stage:t,reason:`Top-level "${t}" is not an array literal.`});const l=E(e,n);if(l!==void 0&&g(l.value)){const m=l.value,p=E(m,t);if(p!==void 0)return S(p.value)?y({created:!1,array:p.value}):c({kind:"InvalidStageTargetError",stage:t,reason:`Nested "${n}.${t}" is not an array literal.`});const u=$(m,t,o,s);return u.success?y({created:!0}):c(u.error)}return c({kind:"StageNotFoundError",constName:a,stage:t,knownStages:q(e,n)})}d(_,"resolveStageArray");function $(e,r,a,t){const n=O([a],t);if(n===void 0)return c({kind:"InvalidStageTargetError",stage:r,reason:`Unable to build an array literal for "${r}".`});const o=h(r,n,t);return I(e,o),y(void 0)}d($,"appendStageProperty");function j(e,r){for(const a of e){const t=U(a);if(t===void 0)continue;const n=t.declarations;if(Array.isArray(n))for(const o of n){if(!f(o)||o.type!=="VariableDeclarator")continue;const s=o.id,i=B(o.init);if(f(s)&&s.type==="Identifier"&&s.name===r&&g(i))return i}}}d(j,"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}}d(U,"unwrapVariableDeclaration");function B(e){let r=e;for(;f(r)&&(r.type==="TSAsExpression"||r.type==="TSSatisfiesExpression");)r=r.expression;return r}d(B,"unwrapExpression");function q(e,r){const a=[];for(const t of e.properties){if(t.type!=="Property"&&t.type!=="ObjectProperty")continue;const n=N(t.key);if(n!==void 0)if(n===r&&g(t.value))for(const o of t.value.properties){const s=N(o.key);s!==void 0&&a.push(`${r}.${s}`)}else S(t.value)&&a.push(n)}return a}d(q,"collectStageKeys");function g(e){return f(e)&&e.type==="ObjectExpression"&&Array.isArray(e.properties)}d(g,"isObjectExpression");function S(e){return f(e)&&e.type==="ArrayExpression"&&Array.isArray(e.elements)}d(S,"isArrayExpression");export{W as appendAccountToStage};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type Result } from "../../types/Result.js";
|
|
2
|
+
import { type NodeShapeLike, type ObjectExpressionNodeLike } from "./modifyResource/literalConversion.js";
|
|
3
|
+
export interface ArrayExpressionNodeLike extends NodeShapeLike {
|
|
4
|
+
type: "ArrayExpression";
|
|
5
|
+
elements: unknown[];
|
|
6
|
+
}
|
|
7
|
+
export type ServiceLocateFailure = {
|
|
8
|
+
kind: "ServiceNotFound";
|
|
9
|
+
serviceName: string;
|
|
10
|
+
knownServices: string[];
|
|
11
|
+
} | {
|
|
12
|
+
kind: "AmbiguousService";
|
|
13
|
+
serviceName: string;
|
|
14
|
+
count: number;
|
|
15
|
+
};
|
|
16
|
+
export type ContainerLocateFailure =
|
|
17
|
+
/** No plain `containers` property. Absence is NOT yet proven — callers that
|
|
18
|
+
* act on absence must gate on `objectAbsenceIsProvable(service, "containers")`. */
|
|
19
|
+
{
|
|
20
|
+
kind: "NoContainersArray";
|
|
21
|
+
}
|
|
22
|
+
/** A plain `containers` property exists but its value is not a static array
|
|
23
|
+
* literal (`containers: SHARED`, `containers: buildContainers()`) — the
|
|
24
|
+
* service HAS containers the edit cannot see. */
|
|
25
|
+
| {
|
|
26
|
+
kind: "ContainersNotStaticArray";
|
|
27
|
+
} | {
|
|
28
|
+
kind: "ContainerIndexOutOfRange";
|
|
29
|
+
containerCount: number;
|
|
30
|
+
} | {
|
|
31
|
+
kind: "ContainerNotObjectLiteral";
|
|
32
|
+
containerIndex: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Every `ComputeFactory.build(<name>, { … })` config object in the file.
|
|
36
|
+
*
|
|
37
|
+
* Walks the whole tree rather than scanning top-level statements: the call is
|
|
38
|
+
* normally nested inside `app.addCompute(...)`, and may sit in a declarator,
|
|
39
|
+
* a bare expression statement, or a conditional.
|
|
40
|
+
*/
|
|
41
|
+
export declare function collectComputeConfigs(body: NodeShapeLike[]): ObjectExpressionNodeLike[];
|
|
42
|
+
/**
|
|
43
|
+
* Locate the single service object literal named `serviceName` across every
|
|
44
|
+
* compute config in the file. Ambiguity (two services sharing the name, even
|
|
45
|
+
* across separate `ComputeFactory.build` calls) is a failure — an edit cannot
|
|
46
|
+
* be proven to target the right one.
|
|
47
|
+
*/
|
|
48
|
+
export declare function locateServiceByName(body: NodeShapeLike[], serviceName: string): Result<ObjectExpressionNodeLike, ServiceLocateFailure>;
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the container object literal at `containerIndex` within a located
|
|
51
|
+
* service.
|
|
52
|
+
*/
|
|
53
|
+
export declare function locateContainer(service: ObjectExpressionNodeLike, containerIndex: number): Result<ObjectExpressionNodeLike, ContainerLocateFailure>;
|
|
54
|
+
/**
|
|
55
|
+
* Read a plain string-literal property from an object literal. `undefined`
|
|
56
|
+
* covers both "no plain property" and "value is not a string literal".
|
|
57
|
+
*/
|
|
58
|
+
export declare function readStringProperty(obj: ObjectExpressionNodeLike, key: string): string | undefined;
|
|
59
|
+
export declare function isArrayExpression(value: unknown): value is ArrayExpressionNodeLike;
|
|
60
|
+
/**
|
|
61
|
+
* Index of the LAST plain (non-shorthand, non-computed) property named `key`:
|
|
62
|
+
* with a duplicate key the later one wins at runtime, so the earlier is a
|
|
63
|
+
* dead literal.
|
|
64
|
+
*/
|
|
65
|
+
export declare function findLastPlainPropertyIndex(obj: ObjectExpressionNodeLike, key: string): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.defineProperty;var i=(r,t)=>g(r,"name",{value:t,configurable:!0});import{failure as c,success as y}from"../../types/Result.js";import{FACTORY_IDENTIFIERS as x}from"../registry.js";import{astToLiteral as C,isNodeShape as s,NON_LITERAL as A,readKeyName as E}from"./modifyResource/literalConversion.js";import{findPropertyByKey as d,visit as O}from"./objectGraph.js";const h=x.compute,b="build";function v(r){const t=[];for(const n of r)O(n,e=>{if(e.type!=="CallExpression"||!P(e))return;const o=e.arguments;if(!Array.isArray(o))return;const u=o[1];s(u)&&u.type==="ObjectExpression"&&t.push(u)});return t}i(v,"collectComputeConfigs");function P(r){const t=r.callee;if(!s(t)||t.type!=="MemberExpression"||t.computed===!0)return!1;const n=t.object,e=t.property;return s(n)&&n.type==="Identifier"&&n.name===h&&s(e)&&e.type==="Identifier"&&e.name===b}i(P,"isComputeFactoryBuild");function L(r,t){const n=[],e=[];for(const u of v(r)){const f=d(u,"services");if(!(f===void 0||!m(f.value)))for(const p of f.value.elements){if(!s(p)||p.type!=="ObjectExpression")continue;const l=p,a=k(l,"name");a!==void 0&&(a===t?e.push(l):n.push(a))}}if(e.length>1)return c({kind:"AmbiguousService",serviceName:t,count:e.length});const[o]=e;return o!==void 0?y(o):c({kind:"ServiceNotFound",serviceName:t,knownServices:n})}i(L,"locateServiceByName");function F(r,t){const n=d(r,"containers");if(n===void 0)return c({kind:"NoContainersArray"});if(!m(n.value))return c({kind:"ContainersNotStaticArray"});const e=n.value.elements,o=e[t];return o===void 0?c({kind:"ContainerIndexOutOfRange",containerCount:e.length}):!s(o)||o.type!=="ObjectExpression"?c({kind:"ContainerNotObjectLiteral",containerIndex:t}):y(o)}i(F,"locateContainer");function k(r,t){const n=d(r,t);if(n===void 0||!s(n.value))return;const e=C(n.value);return e===A||typeof e!="string"?void 0:e}i(k,"readStringProperty");function m(r){return s(r)&&r.type==="ArrayExpression"&&Array.isArray(r.elements)}i(m,"isArrayExpression");function R(r,t){for(let n=r.properties.length-1;n>=0;n--){const e=r.properties[n];if(e!==void 0&&(e.type==="Property"||e.type==="ObjectProperty")&&e.shorthand!==!0&&e.computed!==!0&&E(e.key)===t)return n}return-1}i(R,"findLastPlainPropertyIndex");export{v as collectComputeConfigs,R as findLastPlainPropertyIndex,m as isArrayExpression,F as locateContainer,L as locateServiceByName,k as readStringProperty};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type Result } from "../../types/Result.js";
|
|
2
|
+
import type { LinesChanged, ParseError } from "../types.js";
|
|
3
|
+
declare const RESOURCE_FACTORIES: Readonly<{
|
|
4
|
+
readonly database: "DatabaseFactory";
|
|
5
|
+
readonly storage: "StorageFactory";
|
|
6
|
+
}>;
|
|
7
|
+
export type ConnectableResourceType = keyof typeof RESOURCE_FACTORIES;
|
|
8
|
+
export interface ConnectResourceOptions {
|
|
9
|
+
resourceType: ConnectableResourceType;
|
|
10
|
+
/** Factory name — the first argument of `XFactory.build("<name>", …)`. */
|
|
11
|
+
resourceName: string;
|
|
12
|
+
/**
|
|
13
|
+
* ECS service `name`s to wire. Resolved by the caller (compute-level
|
|
14
|
+
* wiring means every service of that compute) — the edit never expands
|
|
15
|
+
* compute names itself.
|
|
16
|
+
*/
|
|
17
|
+
serviceNames: readonly string[];
|
|
18
|
+
filePath?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ConnectResourceSuccess {
|
|
21
|
+
/** Byte-identical to the input when `skipped` is true. */
|
|
22
|
+
content: string;
|
|
23
|
+
linesChanged: LinesChanged;
|
|
24
|
+
/** Binding the wiring references (existing or newly introduced). */
|
|
25
|
+
variableName: string;
|
|
26
|
+
/** Services actually wired this run (already-wired ones are skipped). */
|
|
27
|
+
wiredServices: string[];
|
|
28
|
+
skipped: boolean;
|
|
29
|
+
warnings: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface ResourceStatementNotFoundError {
|
|
32
|
+
kind: "ResourceStatementNotFoundError";
|
|
33
|
+
resourceType: ConnectableResourceType;
|
|
34
|
+
resourceName: string;
|
|
35
|
+
}
|
|
36
|
+
export interface AmbiguousResourceStatementError {
|
|
37
|
+
kind: "AmbiguousResourceStatementError";
|
|
38
|
+
resourceType: ConnectableResourceType;
|
|
39
|
+
resourceName: string;
|
|
40
|
+
count: number;
|
|
41
|
+
}
|
|
42
|
+
export interface VariableNameConflictError {
|
|
43
|
+
kind: "VariableNameConflictError";
|
|
44
|
+
variableName: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ConnectServiceNotFoundError {
|
|
47
|
+
kind: "ConnectServiceNotFoundError";
|
|
48
|
+
serviceName: string;
|
|
49
|
+
knownServices: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `reason` is author-written text that may embed identifiers, property keys
|
|
53
|
+
* and resource/service NAMES read from the parsed source or CLI input —
|
|
54
|
+
* identifier-class data, never expression values (see security-standards §
|
|
55
|
+
* "Values, not identifiers"). It is never error-derived. The CLI boundary
|
|
56
|
+
* masks defensively regardless.
|
|
57
|
+
*/
|
|
58
|
+
export interface UnsupportedConnectionShapeError {
|
|
59
|
+
kind: "UnsupportedConnectionShapeError";
|
|
60
|
+
reason: string;
|
|
61
|
+
serviceName?: string;
|
|
62
|
+
}
|
|
63
|
+
export type ConnectResourceError = ParseError | ResourceStatementNotFoundError | AmbiguousResourceStatementError | VariableNameConflictError | ConnectServiceNotFoundError | UnsupportedConnectionShapeError;
|
|
64
|
+
export declare function connectResourceToCompute(content: string, options: ConnectResourceOptions): Result<ConnectResourceSuccess, ConnectResourceError>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var H=Object.defineProperty;var u=(t,e)=>H(t,"name",{value:e,configurable:!0});import{builders as E}from"ast-types";import{CREDENTIAL_KEYS as U,DATABASE_ACCESSORS as C,DATABASE_ENV_VARS as b,DATABASE_SSL_VALUE as z}from"../../generation/database.js";import{MESSAGING_ENV_VARS as Y}from"../../generation/messagingConnections.js";import{STORAGE_ACCESSORS as Q,STORAGE_ENV_VARS as O}from"../../generation/storageConnections.js";import{connectionEnvSuffix as J,connectionKeyOrdinal as T,toVariableName as X}from"../../generation/common.js";import{failure as c,success as S}from"../../types/Result.js";import{DEFAULT_FILE_PATH as Z,computeLinesDelta as q,extractProgramBody as ee}from"../_internal.js";import{buildObjectProperty as D,detectQuoteStyle as ne,parse as te,printFile as re}from"../fileRewriter/index.js";import{FACTORY_IDENTIFIERS as P,STATEMENT_REGISTRY as oe}from"../registry.js";import{makeStringLiteral as _}from"./addResource/propertyBuilder.js";import{findLastPlainPropertyIndex as j,isArrayExpression as ie,locateContainer as ae,locateServiceByName as se}from"./computeServiceLocator.js";import{isNodeShape as f,readKeyName as M}from"./modifyResource/literalConversion.js";import{unwrapTsWrappers as I}from"./moduleConstResolver.js";import{objectAbsenceIsProvable as $,pushPropertyPreservingComma as ce,visit as L}from"./objectGraph.js";const v=Object.freeze({database:P.database,storage:P.storage});function x(t){const e=oe[t].emitWrapper?.appMethod;if(e===void 0)throw new Error(`No app method registered for statement type "${t}"`);return e}u(x,"requireAppMethod");const A=Object.freeze({database:x("database"),storage:x("storage")}),F=new Map([[A.database,0],[A.storage,1],[x("messaging"),2]]);function Me(t,e){const n=e.filePath??Z,{resourceType:o,resourceName:r}=e,i=[...new Set(e.serviceNames)];if(i.length===0)return c({kind:"UnsupportedConnectionShapeError",reason:"No target services were supplied."});const a=te(t,n);if(!a.success)return c(a.error);const s=ee(a.data);if(s===void 0)return c({kind:"UnsupportedConnectionShapeError",reason:"recast File is missing program.body"});const d=de(s,o,r);if(!d.success)return c(d.error);const{variableName:p}=d.data,l=[],y=[];for(const h of i){const k=fe(s,h,p,o);if(!k.success)return c(k.error);if(k.data==="already-connected"){l.push(h);continue}y.push(k.data)}const m=l.map(h=>`Service "${h}" already lists "${p}" in its \`connections\` array \u2014 left untouched.`);for(const h of y)h.container===void 0&&m.push(`Service "${h.serviceName}" has no \`containers\` array \u2014 wired \`connections\` only, without env/secret entries (the generator lane emits the same shape for container-less services).`);if(y.length===0)return S({content:t,linesChanged:{added:0,removed:0},variableName:p,wiredServices:[],skipped:!0,warnings:m});const g=ne(a.data),G=Se(s);pe(s,d.data);for(const h of y)he(h,p,o,g,G);const w=re(a.data,t);return S({content:w,linesChanged:q(t,w),variableName:p,wiredServices:y.map(h=>h.serviceName),skipped:!1,warnings:m})}u(Me,"connectResourceToCompute");function de(t,e,n){const o=v[e],r=[];for(let p=0;p<t.length;p++){const l=t[p];if(l===void 0)continue;let y=!1;L(l,m=>{m.type==="CallExpression"&&R(m,o,n)&&(y=!0)}),y&&r.push({statementIndex:p})}if(r.length===0)return c({kind:"ResourceStatementNotFoundError",resourceType:e,resourceName:n});if(r.length>1)return c({kind:"AmbiguousResourceStatementError",resourceType:e,resourceName:n,count:r.length});const i=r[0];if(i===void 0)return c({kind:"ResourceStatementNotFoundError",resourceType:e,resourceName:n});const a=t[i.statementIndex];if(a===void 0)return c({kind:"ResourceStatementNotFoundError",resourceType:e,resourceName:n});if(a.type==="VariableDeclaration"){const p=a.declarations;if(!Array.isArray(p)||p.length!==1)return c({kind:"UnsupportedConnectionShapeError",reason:`The statement declaring "${n}" carries multiple declarators \u2014 the binding cannot be identified.`});const l=p[0].id;if(!f(l)||l.type!=="Identifier")return c({kind:"UnsupportedConnectionShapeError",reason:`The statement declaring "${n}" binds a pattern, not an identifier.`});const y=l.name;if(typeof y!="string")return c({kind:"UnsupportedConnectionShapeError",reason:`The binding for "${n}" has no readable name.`});const m=p[0].init;return!f(m)||!B(m,e,n)?c({kind:"UnsupportedConnectionShapeError",reason:`The binding for "${n}" is not a direct \`app.${A[e]}(${v[e]}.build(...))\` call \u2014 the bound value is not the construct \`connections\` needs.`}):S({variableName:y})}if(a.type!=="ExpressionStatement")return c({kind:"UnsupportedConnectionShapeError",reason:`The statement containing "${n}" is a ${a.type}, which cannot be bound to a const.`});const s=a.expression;if(!f(s)||s.type!=="CallExpression")return c({kind:"UnsupportedConnectionShapeError",reason:`The statement containing "${n}" is not an app-method call \u2014 there is no construct value to bind.`});if(R(s,v[e],n))return c({kind:"UnsupportedConnectionShapeError",reason:`"${n}" is a bare factory call not wrapped in an app method \u2014 there is no construct value to bind.`});if(!B(s,e,n))return c({kind:"UnsupportedConnectionShapeError",reason:`The statement containing "${n}" is not a direct \`app.${A[e]}(...)\` call \u2014 binding it would wire a value \`connections\` cannot use.`});const d=X(n);return ue(t,d)?c({kind:"VariableNameConflictError",variableName:d}):S({variableName:d,wrap:{statementIndex:i.statementIndex,expression:s}})}u(de,"planBinding");function pe(t,e){if(e.wrap===void 0)return;const{statementIndex:n,expression:o}=e.wrap,r=t[n],i=E.variableDeclaration("const",[E.variableDeclarator(E.identifier(e.variableName),o)]),a=r?.comments;a!==void 0&&(i.comments=a),t[n]=i}u(pe,"applyBinding");function R(t,e,n){const o=t.callee;if(!f(o)||o.type!=="MemberExpression"||o.computed===!0)return!1;const r=o.object,i=o.property;if(!f(r)||r.type!=="Identifier"||r.name!==e||!f(i)||i.type!=="Identifier"||i.name!=="build")return!1;const a=t.arguments;if(!Array.isArray(a))return!1;const s=a[0];return!f(s)||s.type!=="StringLiteral"&&s.type!=="Literal"?!1:s.value===n}u(R,"isFactoryBuildOf");function N(t){if(t.type!=="ExportNamedDeclaration"&&t.type!=="ExportDefaultDeclaration")return t;const e=t.declaration;return f(e)?e:void 0}u(N,"unwrapExportDeclaration");function V(t){const e=I(t);if(e.type!=="CallExpression")return;const n=e.callee;if(!f(n)||n.type!=="MemberExpression"||n.computed===!0)return;const o=n.property;if(!f(o)||o.type!=="Identifier")return;const r=o.name;return typeof r=="string"?r:void 0}u(V,"appMethodNameOf");function B(t,e,n){const o=I(t);if(V(o)!==A[e])return!1;const r=o.arguments;if(!Array.isArray(r))return!1;const i=r[0];return f(i)?R(I(i),v[e],n):!1}u(B,"isAppMethodWrap");function ue(t,e){for(const n of t){const o=N(n);if(o!==void 0){if(o.type==="ImportDeclaration"){const r=o.specifiers;if(!Array.isArray(r))continue;for(const i of r){const a=i.local;if(f(a)&&a.name===e)return!0}continue}if(o.type==="VariableDeclaration"){const r=o.declarations;if(!Array.isArray(r))continue;for(const i of r){if(!f(i))continue;const a=i.id;if(!f(a))continue;let s=!1;if(L(a,d=>{d.type==="Identifier"&&d.name===e&&(s=!0)}),s)return!0}continue}if(o.type==="FunctionDeclaration"||o.type==="ClassDeclaration"){const r=o.id;if(f(r)&&r.name===e)return!0}}}return!1}u(ue,"moduleScopeDeclares");function fe(t,e,n,o){const r=se(t,e);if(!r.success){const m=r.error;return m.kind==="AmbiguousService"?c({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:`${String(m.count)} services share the name "${e}" across ComputeFactory.build calls \u2014 the edit cannot be proven to target the right one.`}):c({kind:"ConnectServiceNotFoundError",serviceName:e,knownServices:m.knownServices})}const i=r.data,a=ae(i,0);let s;if(a.success)s=a.data;else switch(a.error.kind){case"ContainerNotObjectLiteral":return c({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:"The first container is not an object literal."});case"ContainersNotStaticArray":return c({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:"`containers` is not a static array literal, so the container to wire cannot be located."});case"NoContainersArray":if(!$(i,"containers"))return c({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:"Service carries a spread, shorthand or computed key that could supply `containers` invisibly, so an absent property cannot be proven."});break;case"ContainerIndexOutOfRange":break}const d=le(i,e,n);if(!d.success)return c(d.error);if(d.data.alreadyConnected)return S("already-connected");let p,l,y="";if(s!==void 0){const m=W(s,"environment",e);if(!m.success)return c(m.error);const g=W(s,"secretsImport",e);if(!g.success)return c(g.error);p=m.data,l=g.data,y=me(o,[...m.data.keys,...g.data.keys])}return S({serviceName:e,service:i,container:s,environment:p,secretsImport:l,suffix:y,connectionsArray:d.data.array})}u(fe,"planService");function le(t,e,n){const o=j(t,"connections");if(o===-1)return $(t,"connections")?S({array:void 0,alreadyConnected:!1}):c({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:"Service carries a spread, shorthand or computed key that could supply `connections` invisibly, so an absent property cannot be proven."});const r=t.properties[o]?.value;if(!ie(r))return c({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:"`connections` is not an array literal."});for(const i of r.elements)if(f(i)){if(i.type==="Identifier"){if(i.name===n)return S({array:r,alreadyConnected:!0});continue}return c({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:`\`connections\` contains a ${i.type}, so "${n}" cannot be proven absent from it.`})}return S({array:r,alreadyConnected:!1})}u(le,"inspectConnections");function W(t,e,n){const o=j(t,e);if(o===-1)return $(t,e)?S({obj:void 0,keys:[]}):c({kind:"UnsupportedConnectionShapeError",serviceName:n,reason:`The first container carries a spread, shorthand or computed key that could supply \`${e}\` invisibly, so an absent property cannot be proven.`});const r=t.properties[o]?.value;if(!f(r)||r.type!=="ObjectExpression")return c({kind:"UnsupportedConnectionShapeError",serviceName:n,reason:`\`${e}\` is not an object literal.`});const i=r,a=[];for(const s of i.properties){if(s.type==="SpreadElement"||s.type==="SpreadProperty")return c({kind:"UnsupportedConnectionShapeError",serviceName:n,reason:`\`${e}\` contains a spread, so existing connection keys cannot be enumerated to derive the next suffix.`});if(s.type!=="Property"&&s.type!=="ObjectProperty")continue;if(s.computed===!0)return c({kind:"UnsupportedConnectionShapeError",serviceName:n,reason:`\`${e}\` contains a computed key.`});const d=M(s.key);d!==void 0&&a.push(d)}return S({obj:i,keys:a})}u(W,"collectWiringTarget");function me(t,e){const n=Object.values(t==="database"?b:O),o=new Set;for(const r of e)for(const i of n){const a=T(r,i);a!==void 0&&o.add(a)}return J(o.size===0?0:Math.max(...o))}u(me,"nextConnectionSuffix");function ye(t,e,n,o){const r=u((s,d,p=[])=>E.callExpression(E.memberExpression(s,E.identifier(d),!1),p),"call"),i=u(()=>E.identifier(e),"variable");if(t==="storage")return[{key:`${O.NAME}${n}`,value:r(i(),Q.BUCKET_NAME),target:"environment"}];const a=u(s=>r(r(i(),C.CREDENTIALS),C.IMPORT,[_(s,o)]),"credential");return[{key:`${b.HOST}${n}`,value:r(i(),C.HOST),target:"environment"},{key:`${b.PORT}${n}`,value:r(i(),C.PORT),target:"environment"},{key:`${b.NAME}${n}`,value:r(i(),C.NAME),target:"environment"},{key:`${b.SSL}${n}`,value:_(z,o),target:"environment"},{key:`${b.USERNAME}${n}`,value:a(U.USERNAME),target:"secretsImport"},{key:`${b.PASSWORD}${n}`,value:a(U.PASSWORD),target:"secretsImport"}]}u(ye,"buildWiringEntries");function he(t,e,n,o,r){if(t.connectionsArray!==void 0){const d=Ee(t.connectionsArray,n,r);t.connectionsArray.elements.splice(d,0,E.identifier(e))}else K(t.service,"connections",E.arrayExpression([E.identifier(e)]),o);const i=t.container;if(i===void 0)return;const a=ye(n,e,t.suffix,o),s=[{key:"environment",state:t.environment},{key:"secretsImport",state:t.secretsImport}];for(const{key:d,state:p}of s){const l=a.filter(y=>y.target===d);l.length!==0&&Ae(i,d,p,l,o)}}u(he,"applyServiceWiring");function Ee(t,e,n){const o=F.get(A[e])??0;for(let r=0;r<t.elements.length;r++){const i=t.elements[r];if(!f(i)||i.type!=="Identifier")continue;const a=i.name;if(typeof a!="string")continue;const s=n.get(a);if(s!==void 0&&s>o)return r}return t.elements.length}u(Ee,"connectionInsertIndex");function Se(t){const e=new Map;for(const n of t){const o=N(n);if(o===void 0||o.type!=="VariableDeclaration")continue;const r=o.declarations;if(Array.isArray(r))for(const i of r){if(!f(i))continue;const a=i.id,s=i.init;if(!f(a)||a.type!=="Identifier"||!f(s))continue;const d=a.name;if(typeof d!="string")continue;const p=V(s);if(p===void 0)continue;const l=F.get(p);l!==void 0&&e.set(d,l)}}return e}u(Se,"collectConnectionRanks");const be=Object.freeze([...Object.values(b),...Object.values(O),...Object.values(Y)]);function ge(t){let e=-1;for(let n=0;n<t.properties.length;n++){const o=t.properties[n];if(o===void 0||o.type!=="Property"&&o.type!=="ObjectProperty"||o.computed===!0)continue;const r=M(o.key);if(r===void 0)continue;be.some(a=>T(r,a)!==void 0)&&(e=n)}return e===-1?t.properties.length:e+1}u(ge,"connectionEntryInsertIndex");function Ae(t,e,n,o,r){const i=o.map(d=>D(d.key,d.value,r)),a=n?.obj;if(a===void 0){K(t,e,E.objectExpression(i),r);return}const s=ge(a);a.properties.splice(s,0,...i)}u(Ae,"insertObjectEntries");function K(t,e,n,o){const r=D(e,n,o);ce(t,r)}u(K,"appendProperty");export{Me as connectResourceToCompute};
|
|
@@ -22,3 +22,4 @@ export declare function buildModuleConstResolver(body: NodeShapeLike[]): ModuleC
|
|
|
22
22
|
* expressionless template literal. `undefined` for anything else.
|
|
23
23
|
*/
|
|
24
24
|
export declare function readStaticString(node: NodeShapeLike): string | undefined;
|
|
25
|
+
export declare function unwrapTsWrappers(node: NodeShapeLike): NodeShapeLike;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var b=Object.defineProperty;var f=(a,r)=>b(a,"name",{value:r,configurable:!0});import{isRecord as l}from"../_internal.js";import{isNodeShape as d,readKeyName as S}from"./modifyResource/literalConversion.js";function w(a){const r=k(a),s=x(a),t=f(n=>r.get(n)===1?s.get(n):void 0,"initFor");return{resolveString(n){const e=t(n);return e===void 0?void 0:g(e)},resolveStringArray(n){const e=t(n);if(e===void 0)return;const i=y(e);if(i.type!=="ArrayExpression")return;const o=i.elements;if(!Array.isArray(o))return;const u=[];for(const p of o){if(!d(p))return;const A=g(p);if(A===void 0)return;u.push(A)}return u},objectKeysOf:f(n=>m(n,t,new Set),"objectKeysOf")}}f(w,"buildModuleConstResolver");function g(a){const r=y(a);if(r.type==="StringLiteral"){const s=r.value;return typeof s=="string"?s:void 0}if(r.type==="TemplateLiteral"){const s=r.expressions,t=r.quasis;if(!Array.isArray(s)||s.length!==0||!Array.isArray(t)||t.length!==1)return;const[c]=t;return!l(c)||!l(c.value)?void 0:typeof c.value.cooked=="string"?c.value.cooked:void 0}}f(g,"readStaticString");const h=new Set(["TSAsExpression","TSSatisfiesExpression","TSTypeAssertion","TSNonNullExpression","ParenthesizedExpression"]);function y(a){let r=a;for(;h.has(r.type);){const s=r.expression;if(!d(s))return r;r=s}return r}f(y,"unwrapTsWrappers");function m(a,r,s){const t=y(a);if(t.type==="Identifier"){const e=t.name;if(typeof e!="string"||s.has(e))return;s.add(e);const i=r(e);return i===void 0?void 0:m(i,r,s)}if(t.type!=="ObjectExpression")return;const c=t.properties;if(!Array.isArray(c))return;const n=[];for(const e of c){if(!d(e))return;if(e.type==="SpreadElement"||e.type==="SpreadProperty"){const u=e.argument;if(!d(u))return;const p=m(u,r,s);if(p===void 0)return;n.push(...p);continue}if(e.type!=="Property"&&e.type!=="ObjectProperty"&&e.type!=="ObjectMethod"||e.computed===!0)return;const i=e.key;if(!d(i))return;const o=S(i);if(o===void 0)return;n.push(o)}return n}f(m,"objectKeysOfNode");function k(a){const r=new Map,s=f(n=>{r.set(n,(r.get(n)??0)+1)},"bump"),t=f(n=>{if(d(n))switch(n.type){case"Identifier":{const e=n.name;typeof e=="string"&&s(e);return}case"ObjectPattern":{const e=n.properties;if(!Array.isArray(e))return;for(const i of e)d(i)&&(i.type==="RestElement"||i.type==="RestProperty"?t(i.argument):t(i.value));return}case"ArrayPattern":{const e=n.elements;if(!Array.isArray(e))return;for(const i of e)t(i);return}case"AssignmentPattern":t(n.left);return;case"RestElement":t(n.argument);return;case"TSParameterProperty":t(n.parameter);return;default:return}},"bumpPattern"),c=f(n=>{const e=[n];for(;e.length>0;){const i=e.pop();if(l(i)){if(typeof i.type=="string"){const o=i;switch(o.type){case"VariableDeclarator":t(o.id);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":{t(o.id);const u=o.params;if(Array.isArray(u))for(const p of u)t(p);break}case"ClassDeclaration":case"ClassExpression":t(o.id);break;case"ImportSpecifier":case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":t(o.local);break;case"CatchClause":t(o.param);break;default:break}}for(const o of Object.keys(i)){if(o==="loc"||o==="comments"||o==="tokens")continue;const u=i[o];if(Array.isArray(u))for(const p of u)l(p)&&e.push(p);else l(u)&&e.push(u)}}}},"visitForBindings");for(const n of a)c(n);return r}f(k,"countBindings");function x(a){const r=new Map;for(const s of a){const t=s.type==="ExportNamedDeclaration"?s.declaration:s;if(!d(t)||t.type!=="VariableDeclaration"||t.kind!=="const")continue;const c=t.declarations;if(Array.isArray(c))for(const n of c){if(!d(n)||n.type!=="VariableDeclarator")continue;const e=n.id,i=n.init;if(!d(e)||e.type!=="Identifier"||!d(i))continue;const o=e.name;typeof o=="string"&&r.set(o,i)}}return r}f(x,"collectTopLevelConstInits");export{w as buildModuleConstResolver,g as readStaticString};
|
|
1
|
+
var b=Object.defineProperty;var f=(a,r)=>b(a,"name",{value:r,configurable:!0});import{isRecord as l}from"../_internal.js";import{isNodeShape as d,readKeyName as S}from"./modifyResource/literalConversion.js";function w(a){const r=k(a),s=x(a),t=f(n=>r.get(n)===1?s.get(n):void 0,"initFor");return{resolveString(n){const e=t(n);return e===void 0?void 0:g(e)},resolveStringArray(n){const e=t(n);if(e===void 0)return;const i=y(e);if(i.type!=="ArrayExpression")return;const o=i.elements;if(!Array.isArray(o))return;const u=[];for(const p of o){if(!d(p))return;const A=g(p);if(A===void 0)return;u.push(A)}return u},objectKeysOf:f(n=>m(n,t,new Set),"objectKeysOf")}}f(w,"buildModuleConstResolver");function g(a){const r=y(a);if(r.type==="StringLiteral"){const s=r.value;return typeof s=="string"?s:void 0}if(r.type==="TemplateLiteral"){const s=r.expressions,t=r.quasis;if(!Array.isArray(s)||s.length!==0||!Array.isArray(t)||t.length!==1)return;const[c]=t;return!l(c)||!l(c.value)?void 0:typeof c.value.cooked=="string"?c.value.cooked:void 0}}f(g,"readStaticString");const h=new Set(["TSAsExpression","TSSatisfiesExpression","TSTypeAssertion","TSNonNullExpression","ParenthesizedExpression"]);function y(a){let r=a;for(;h.has(r.type);){const s=r.expression;if(!d(s))return r;r=s}return r}f(y,"unwrapTsWrappers");function m(a,r,s){const t=y(a);if(t.type==="Identifier"){const e=t.name;if(typeof e!="string"||s.has(e))return;s.add(e);const i=r(e);return i===void 0?void 0:m(i,r,s)}if(t.type!=="ObjectExpression")return;const c=t.properties;if(!Array.isArray(c))return;const n=[];for(const e of c){if(!d(e))return;if(e.type==="SpreadElement"||e.type==="SpreadProperty"){const u=e.argument;if(!d(u))return;const p=m(u,r,s);if(p===void 0)return;n.push(...p);continue}if(e.type!=="Property"&&e.type!=="ObjectProperty"&&e.type!=="ObjectMethod"||e.computed===!0)return;const i=e.key;if(!d(i))return;const o=S(i);if(o===void 0)return;n.push(o)}return n}f(m,"objectKeysOfNode");function k(a){const r=new Map,s=f(n=>{r.set(n,(r.get(n)??0)+1)},"bump"),t=f(n=>{if(d(n))switch(n.type){case"Identifier":{const e=n.name;typeof e=="string"&&s(e);return}case"ObjectPattern":{const e=n.properties;if(!Array.isArray(e))return;for(const i of e)d(i)&&(i.type==="RestElement"||i.type==="RestProperty"?t(i.argument):t(i.value));return}case"ArrayPattern":{const e=n.elements;if(!Array.isArray(e))return;for(const i of e)t(i);return}case"AssignmentPattern":t(n.left);return;case"RestElement":t(n.argument);return;case"TSParameterProperty":t(n.parameter);return;default:return}},"bumpPattern"),c=f(n=>{const e=[n];for(;e.length>0;){const i=e.pop();if(l(i)){if(typeof i.type=="string"){const o=i;switch(o.type){case"VariableDeclarator":t(o.id);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":{t(o.id);const u=o.params;if(Array.isArray(u))for(const p of u)t(p);break}case"ClassDeclaration":case"ClassExpression":t(o.id);break;case"ImportSpecifier":case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":t(o.local);break;case"CatchClause":t(o.param);break;default:break}}for(const o of Object.keys(i)){if(o==="loc"||o==="comments"||o==="tokens")continue;const u=i[o];if(Array.isArray(u))for(const p of u)l(p)&&e.push(p);else l(u)&&e.push(u)}}}},"visitForBindings");for(const n of a)c(n);return r}f(k,"countBindings");function x(a){const r=new Map;for(const s of a){const t=s.type==="ExportNamedDeclaration"?s.declaration:s;if(!d(t)||t.type!=="VariableDeclaration"||t.kind!=="const")continue;const c=t.declarations;if(Array.isArray(c))for(const n of c){if(!d(n)||n.type!=="VariableDeclarator")continue;const e=n.id,i=n.init;if(!d(e)||e.type!=="Identifier"||!d(i))continue;const o=e.name;typeof o=="string"&&r.set(o,i)}}return r}f(x,"collectTopLevelConstInits");export{w as buildModuleConstResolver,g as readStaticString,y as unwrapTsWrappers};
|
|
@@ -19,6 +19,12 @@ export declare function findPropertyByKey(obj: ObjectExpressionNodeLike, key: st
|
|
|
19
19
|
* one depending on source order.
|
|
20
20
|
*/
|
|
21
21
|
export declare function objectAbsenceIsProvable(obj: ObjectExpressionNodeLike, key: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Append a property to an object literal, copying the previous last
|
|
24
|
+
* property's trailing-comma marker so recast keeps multiline formatting.
|
|
25
|
+
* Shared by every edit that appends into an existing object literal.
|
|
26
|
+
*/
|
|
27
|
+
export declare function pushPropertyPreservingComma(obj: ObjectExpressionNodeLike, property: ObjectExpressionNodeLike["properties"][number]): void;
|
|
22
28
|
/**
|
|
23
29
|
* Non-recursive depth-first walk over every typed node reachable from `root`.
|
|
24
30
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var a=Object.defineProperty;var o=(t,r)=>a(t,"name",{value:r,configurable:!0});import{isRecord as u}from"../_internal.js";import{readKeyName as f}from"./modifyResource/literalConversion.js";function l(t,r){return t.properties.find(e=>(e.type==="Property"||e.type==="ObjectProperty")&&e.shorthand!==!0&&e.computed!==!0&&f(e.key)===r)}o(l,"findPropertyByKey");function h(t,r){return!t.properties.some(e=>e.type==="SpreadElement"||e.type==="SpreadProperty"?!0:e.type!=="Property"&&e.type!=="ObjectProperty"?!1:e.computed===!0?!0:e.shorthand===!0&&f(e.key)===r)}o(h,"objectAbsenceIsProvable");function d(t,r){t.properties[t.properties.length-1]?.extra?.trailingComma===!0&&(r.extra={...r.extra??{},trailingComma:!0}),t.properties.push(r)}o(d,"pushPropertyPreservingComma");function P(t,r){const e=[t];for(;e.length>0;){const n=e.pop();if(u(n)){typeof n.type=="string"&&r(n);for(const i of Object.keys(n)){if(i==="loc"||i==="comments"||i==="tokens")continue;const s=n[i];if(Array.isArray(s))for(const c of s)u(c)&&e.push(c);else u(s)&&e.push(s)}}}}o(P,"visit");export{l as findPropertyByKey,h as objectAbsenceIsProvable,d as pushPropertyPreservingComma,P as visit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var x=Object.defineProperty;var d=(r,e)=>x(r,"name",{value:e,configurable:!0});import{failure as o,success as l}from"../../types/Result.js";import{DEFAULT_FILE_PATH as L,computeLinesDelta as O,extractProgramBody as I}from"../_internal.js";import{buildObjectProperty as R,detectQuoteStyle as T,parse as D,printFile as _}from"../fileRewriter/index.js";import{makeStringLiteral as q,toAstValue as B}from"./addResource/propertyBuilder.js";import{findLastPlainPropertyIndex as J,isArrayExpression as M,locateContainer as W,locateServiceByName as z,readStringProperty as H}from"./computeServiceLocator.js";import{buildModuleConstResolver as K}from"./moduleConstResolver.js";import{pushPropertyPreservingComma as Q}from"./objectGraph.js";import{checkSecretsImportConflicts as A,checkShadowingSpread as V,classifySecretsElement as Y,describeElements as U,keyProvablyAbsent as G}from"./secretsProvability.js";const P="secrets";function fe(r,e){const t=e.filePath??L,{serviceName:n}=e,i=e.containerIndex??0,g=e.add??[],b=e.remove??[],a=D(r,t);if(!a.success)return o(a.error);const y=I(a.data);if(y===void 0)return o({kind:"UnsupportedSecretsShapeError",serviceName:n,reason:"recast File is missing program.body"});const p=Z(y,n);if(!p.success)return o(p.error);const{service:f}=p.data,u=N(f,n,i);if(!u.success)return o(u.error);const h=ee(f,n,e.expectedSsmSecretsPath),k=K(y),m=re(u.data,n,k,{add:g,remove:b,quoteStyle:T(a.data)});if(!m.success)return o(m.error);const{added:C,removed:w}=m.data,E=[...h,...m.data.warnings];return C.length===0&&w.length===0?l({content:r,linesChanged:{added:0,removed:0},added:[],removed:[],skipped:!0,warnings:E}):l({...X(a.data,r),added:C,removed:w,skipped:!1,warnings:E})}d(fe,"setContainerSecrets");function X(r,e){const t=_(r,e);return{content:t,linesChanged:O(e,t)}}d(X,"printResult");function Z(r,e){const t=z(r,e);if(t.success)return l({service:t.data});const n=t.error;return n.kind==="AmbiguousService"?o(S(e,`${String(n.count)} services share the name "${e}" across ComputeFactory.build calls \u2014 the edit cannot be proven to target the right one. Edit the file by hand.`)):o({kind:"ServiceNotFoundError",serviceName:e,knownServices:n.knownServices})}d(Z,"locateService");function N(r,e,t){const n=W(r,t);if(n.success)return l(n.data);const i=n.error;switch(i.kind){case"NoContainersArray":return o({kind:"UnsupportedSecretsShapeError",serviceName:e,reason:"Service has no `containers` array literal."});case"ContainersNotStaticArray":return o({kind:"UnsupportedSecretsShapeError",serviceName:e,reason:"Service's `containers` is not a static array literal."});case"ContainerIndexOutOfRange":return o({kind:"ContainerNotFoundError",serviceName:e,containerIndex:t,containerCount:i.containerCount});case"ContainerNotObjectLiteral":return o({kind:"UnsupportedSecretsShapeError",serviceName:e,reason:`Container ${String(t)} is not an object literal.`})}}d(N,"resolveContainer");function ee(r,e,t){if(t===void 0)return[];const n=H(r,"ssmSecretsPath");return n===void 0||n===t?[]:[`Service "${e}" declares ssmSecretsPath "${n}", but the secrets were written under "${t}". The task will read the declared path.`]}d(ee,"collectPathWarnings");function S(r,e){return{kind:"UnsupportedSecretsShapeError",serviceName:r,reason:e}}d(S,"unsupported");function re(r,e,t,n){const{add:i,remove:g,quoteStyle:b}=n,a=J(r,P);if(a===-1){if(!G(r,P,t))return o(S(e,"Container carries a spread, shorthand or computed key that could supply `secrets` invisibly, so an absent property cannot be proven. Declare `secrets` explicitly first."));if(g.length>0&&i.length===0)return l({added:[],removed:[],warnings:[]});const u=$(i),h=A(r,u,t);if(!h.ok)return o(S(e,h.reason));const k=te(r,e,u,b);return k.success?l({...k.data,warnings:h.warnings}):k}const p=r.properties[a]?.value;if(!M(p))return o(S(e,"`secrets` is not an array literal."));const f=V(r,a,t);return f.ok?ne(p,r,e,t,n):o(S(e,f.reason))}d(re,"applySecrets");function te(r,e,t,n){const i=$(t);if(i.length===0)return l({added:[],removed:[]});const g=B(i,n);if(g===void 0)return o({kind:"UnsupportedSecretsShapeError",serviceName:e,reason:"Unable to build a `secrets` array literal."});const b=R(P,g,n);return Q(r,b),l({added:i,removed:[]})}d(te,"createSecretsArray");function ne(r,e,t,n,i){const{add:g,remove:b,quoteStyle:a}=i,y=r.elements.map(s=>Y(s,n)),p=y.filter(s=>s.kind==="unresolvable"),f=new Set(b);if(f.size>0){if(p.length>0)return o(S(t,`\`secrets\` contains ${U(p)}, which cannot be resolved to string literals in this file, so a removed name cannot be proven gone. Edit the array by hand.`));for(const s of y){if(s.kind!=="spread")continue;const v=s.names.filter(c=>f.has(c));if(v.length>0){const c=v.map(j=>JSON.stringify(j)).join(", "),F=v.length===1?"is":"are";return o(S(t,`${c} ${F} supplied by \`${s.description}\`, so this edit cannot undeclare it \u2014 the shared array may feed other services. Edit \`${s.description.slice(3)}\` by hand.`))}}}const u=[],h=[];r.elements=r.elements.filter((s,v)=>{const c=y[v];return c!==void 0&&(c.kind==="literal"||c.kind==="identifier")&&f.has(c.name)?(u.push(c.name),!1):(c!==void 0&&h.push(c),!0)});const k=new Set(h.flatMap(s=>s.kind==="unresolvable"?[]:s.kind==="spread"?[...s.names]:[s.name])),m=$(g).filter(s=>!k.has(s));if(m.length===0)return l({added:[],removed:u,warnings:[]});const C=h.filter(s=>s.kind==="unresolvable");if(C.length>0){const s=m.map(v=>JSON.stringify(v)).join(", ");return o(S(t,`\`secrets\` contains ${U(C)}, which cannot be resolved in this file, so ${s} cannot be proven absent \u2014 a duplicate name breaks \`fjall deploy\` at synth. Add it by hand.`))}const w=A(e,m,n);if(!w.ok)return o(S(t,w.reason));const E=[];for(const s of m)r.elements.push(q(s,a)),E.push(s);return l({added:E,removed:u,warnings:w.warnings})}d(ne,"mutateSecretsArray");function $(r){return[...new Set(r)]}d($,"dedupe");export{fe as setContainerSecrets};
|
|
@@ -3,6 +3,7 @@ export { removeResource, type RemoveResourceError, type RemoveResourceSuccess, }
|
|
|
3
3
|
export { modifyResource, type ModifyResourceCallContext, type ModifyResourceError, type ModifyResourceSuccess, } from "./edits/modifyResource.js";
|
|
4
4
|
export { appendAccountToStage, type AppendAccountToStageError, type AppendAccountToStageOptions, type AppendAccountToStageSuccess, } from "./edits/appendAccountToStage.js";
|
|
5
5
|
export { setContainerSecrets, type SetContainerSecretsError, type SetContainerSecretsOptions, type SetContainerSecretsSuccess, } from "./edits/setContainerSecrets.js";
|
|
6
|
+
export { connectResourceToCompute, type ConnectableResourceType, type ConnectResourceError, type ConnectResourceOptions, type ConnectResourceSuccess, } from "./edits/connectResourceToCompute.js";
|
|
6
7
|
export { addVpcPeer, modifyVpcPeer, removeVpcPeer, type VpcPeerAddOptions, type VpcPeerModifyOptions, type VpcPeerOrchestratorSuccess, type VpcPeerRemoveOptions, } from "./edits/vpcPeer.js";
|
|
7
8
|
export { addVpcPeerAccepter, modifyVpcPeerAccepter, removeVpcPeerAccepter, type VpcPeerAccepterAddOptions, type VpcPeerAccepterModifyOptions, type VpcPeerAccepterOrchestratorSuccess, type VpcPeerAccepterRemoveOptions, } from "./edits/vpcPeerAccepter.js";
|
|
8
9
|
export { addCrossPlanConnection, modifyCrossPlanConnection, removeCrossPlanConnection, type CrossPlanConnectionAddOptions, type CrossPlanConnectionModifyOptions, type CrossPlanConnectionOrchestratorSuccess, type CrossPlanConnectionRemoveOptions, } from "./edits/crossPlanConnection.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{addResource as o}from"./edits/addResource.js";import{removeResource as c}from"./edits/removeResource.js";import{modifyResource as m}from"./edits/modifyResource.js";import{appendAccountToStage as
|
|
1
|
+
import{addResource as o}from"./edits/addResource.js";import{removeResource as c}from"./edits/removeResource.js";import{modifyResource as m}from"./edits/modifyResource.js";import{appendAccountToStage as a}from"./edits/appendAccountToStage.js";import{setContainerSecrets as d}from"./edits/setContainerSecrets.js";import{connectResourceToCompute as i}from"./edits/connectResourceToCompute.js";import{addVpcPeer as f,modifyVpcPeer as u,removeVpcPeer as P}from"./edits/vpcPeer.js";import{addVpcPeerAccepter as R,modifyVpcPeerAccepter as T,removeVpcPeerAccepter as S}from"./edits/vpcPeerAccepter.js";import{addCrossPlanConnection as C,modifyCrossPlanConnection as A,removeCrossPlanConnection as V}from"./edits/crossPlanConnection.js";import{resolveDriftPolicy as y}from"./edits/driftPolicy.js";import{listResources as D}from"./listResources.js";import{resolveConstructByLiteralProperty as N}from"./semanticIndex/index.js";import{parse as F}from"./fileRewriter/parse.js";import{CrossPlanConnectionResourcePlanSchema as I,VpcPeerAccepterResourcePlanSchema as M,VpcPeerResourcePlanSchema as O}from"../schemas/index.js";import{detectDrift as k,mergeProperties as B,snapshotProperties as U}from"./drift/index.js";import{computeLinesDelta as Y}from"./_internal.js";import{ResourceNameSchema as q,StatementTypeSchema as w}from"./types.js";import{REGISTERED_STATEMENT_TYPES as H,STATEMENT_REGISTRY as J}from"./registry.js";import{evaluateEmitGuard as W,UNRESOLVED as X}from"./emitGuard.js";import{CODEMOD_ERROR_KINDS as $}from"./telemetry/errorKinds.js";import{buildEgressBlockedEvent as re,buildFiredEvent as oe,buildGateFailedEvent as te,buildGatePassedEvent as ce,buildRejectedEvent as pe,buildSucceededEvent as me,buildTimeoutEvent as se,estimateCostUsd as ae,FALLBACK_EVENTS as ne,GATE_EVENTS as de,PARSE_GATE as Ee,RUNTIME_GATE as ie,runFallback as le,shouldTryFallback as fe}from"./llmFallback/index.js";export{$ as CODEMOD_ERROR_KINDS,I as CrossPlanConnectionResourcePlanSchema,ne as FALLBACK_EVENTS,de as GATE_EVENTS,Ee as PARSE_GATE,H as REGISTERED_STATEMENT_TYPES,ie as RUNTIME_GATE,q as ResourceNameSchema,J as STATEMENT_REGISTRY,w as StatementTypeSchema,X as UNRESOLVED,M as VpcPeerAccepterResourcePlanSchema,O as VpcPeerResourcePlanSchema,C as addCrossPlanConnection,o as addResource,f as addVpcPeer,R as addVpcPeerAccepter,a as appendAccountToStage,re as buildEgressBlockedEvent,oe as buildFiredEvent,te as buildGateFailedEvent,ce as buildGatePassedEvent,pe as buildRejectedEvent,me as buildSucceededEvent,se as buildTimeoutEvent,Y as computeLinesDelta,i as connectResourceToCompute,k as detectDrift,ae as estimateCostUsd,W as evaluateEmitGuard,D as listResources,B as mergeProperties,A as modifyCrossPlanConnection,m as modifyResource,u as modifyVpcPeer,T as modifyVpcPeerAccepter,F as parse,V as removeCrossPlanConnection,c as removeResource,P as removeVpcPeer,S as removeVpcPeerAccepter,N as resolveConstructByLiteralProperty,y as resolveDriftPolicy,le as runFallback,d as setContainerSecrets,fe as shouldTryFallback,U as snapshotProperties};
|
|
@@ -99,7 +99,7 @@ export interface StatementTypeEntry {
|
|
|
99
99
|
*/
|
|
100
100
|
emitGuard?: ReadonlyArray<EmitGuardRule>;
|
|
101
101
|
}
|
|
102
|
-
declare const FACTORY_IDENTIFIERS: {
|
|
102
|
+
export declare const FACTORY_IDENTIFIERS: {
|
|
103
103
|
readonly database: "DatabaseFactory";
|
|
104
104
|
readonly storage: "StorageFactory";
|
|
105
105
|
readonly compute: "ComputeFactory";
|
|
@@ -125,4 +125,3 @@ export declare const STATEMENT_REGISTRY: Record<StatementType, StatementTypeEntr
|
|
|
125
125
|
*/
|
|
126
126
|
export declare const REGISTERED_STATEMENT_TYPES: ReadonlyArray<StatementType>;
|
|
127
127
|
export declare function findTypeByIdentifier(identifier: string): StatementType | undefined;
|
|
128
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var C=Object.defineProperty;var n=(e,t)=>C(e,"name",{value:t,configurable:!0});import{z as d}from"zod";import{BuildkitePropsObjectSchema as v,CDNResourcePlanSchema as R,ComputeResourcePlanSchema as k,CrossPlanConnectionResourcePlanSchema as T,DatabaseResourcePlanSchema as A,NetworkResourcePlanSchema as E,NextJSPatternConfigSchema as w,OrganisationResourcePlanSchema as F,PayloadPatternConfigSchema as N,S3ResourcePlanSchema as M,SQSResourcePlanSchema as D,StaticSitePatternConfigSchema as _,VpcPeerAccepterResourcePlanSchema as
|
|
1
|
+
var C=Object.defineProperty;var n=(e,t)=>C(e,"name",{value:t,configurable:!0});import{z as d}from"zod";import{BuildkitePropsObjectSchema as v,CDNResourcePlanSchema as R,ComputeResourcePlanSchema as k,CrossPlanConnectionResourcePlanSchema as T,DatabaseResourcePlanSchema as A,NetworkResourcePlanSchema as E,NextJSPatternConfigSchema as w,OrganisationResourcePlanSchema as F,PayloadPatternConfigSchema as N,S3ResourcePlanSchema as M,SQSResourcePlanSchema as D,StaticSitePatternConfigSchema as _,VpcPeerAccepterResourcePlanSchema as x,VpcPeerResourcePlanSchema as O}from"../schemas/index.js";import{failure as W}from"../types/Result.js";import{isRecord as G}from"./_internal.js";import{AUTHOR_BY_HAND as c,requiresLiveValue as g,silentlyDropped as a,UNRESOLVED as m,whenAbsent as p}from"./emitGuard.js";const r={database:"DatabaseFactory",storage:"StorageFactory",compute:"ComputeFactory",messaging:"MessagingFactory",cdn:"CdnFactory",network:"NetworkFactory",pattern:"PatternFactory","vpc-peer":"VpcPeerFactory","vpc-peer-accepter":"VpcPeerAccepterFactory","cross-plan-connection":"CrossPlanConnectionFactory",organisation:"OrganisationFactory",buildkite:"BuildkiteFactory"};function s(e){const{name:t,...i}=e.shape;return d.object(i).partial().strict()}n(s,"fragmentOf");const I=s(A),B=s(M),j=(()=>{const{name:e,...t}=k.shape;return d.object(t).partial().strict()})(),L=s(D),V=s(R),Y=s(E),q=(()=>{const{name:e,type:t,cdn:i,...f}=N.shape,{name:ae,type:re,cdn:oe,...b}=w.shape,{name:se,type:ie,domain:ce,cdn:S,...P}=_.shape;return d.object({...f,...b,...P,cdn:d.union([i,S])}).partial().strict()})(),K=s(O),U=s(x),z=s(T),H=s(F),Q=s(v);function l(e,t){return W({kind:"SemanticQueryError",reason:`StatementTypeEntry.${e} for ${t} is not wired; existing types dispatch through the shared locator/generator.`})}n(l,"notWiredError");function $(e){return{factoryIdentifier:e,findByShape:n(()=>l("locator.findByShape",e),"findByShape"),validateContext:n(()=>l("locator.validateContext",e),"validateContext")}}n($,"createLocator");function J(e){return{build:n(()=>{const t=l("generator.build",e);throw new Error(t.success?"unreachable":t.error.reason)},"build")}}n(J,"createGenerator");const X=a("variableName","`variableName` is a plan-only round-trip key naming the `const <var> =` binding the scaffold emits; no construct reads it."),y=a("extraProperties","`extraProperties` is a plan-only round-trip key: the scaffold flattens each `{ key, sourceText }` entry into a sibling property, and no construct reads the array."),u="the connection keys are scaffold inputs, not construct props: the scaffold expands them into environment variables and a `connections: [...]` array, and the compute constructs read none of them.",Z=[{property:"deployment",refuseWhen:n(e=>(e.type==="lambda"||e.deployment!==void 0)&&e.deployment!=="container"&&e.code!==m,"refuseWhen"),reason:"a code-deployed Lambda requires `code: Code`, a CDK object built by `Code.fromAsset(...)` that no flag value can carry, so the statement takes the whole app's synth down with `Cannot read properties of undefined (reading 'bind')` \u2014 naming no resource. Use `--deployment container`, which is fully expressible, or write this compute in infrastructure.ts by hand."},a("codePath","`codePath` is the scaffold's input to `Code.fromAsset(...)`; no compute construct reads it, and a container Lambda takes its code from the image."),g("runtime","the construct expects a CDK `Runtime`, not a version string, and a container Lambda takes its runtime from the image (`Runtime.FROM_IMAGE`) regardless."),g("architecture","the construct expects a CDK `Architecture`, not a string: `--architecture ARM_64` emits an EMPTY `Architectures` list, whereas omitting the flag emits the correct default."),a("memory","the Lambda construct reads `memorySize`, so `--memory 1024` deploys a function at the 128 MB default."),a("ssmSecrets","the Lambda construct reads `secrets`, so `--ssmSecrets` deploys a function with no SSM wiring and no secrets environment at all."),a("scheduleExpression","`scheduleExpression` is not a compute prop: the scaffold turns it into a SEPARATE `app.addSchedule(...)` statement, which this command cannot emit."),a("needsConnection",u),a("connectedDatabase",u),a("connectedStorage",u),a("connectedMessaging",u),X,y],ee=[{property:"originType",refuseWhen:p("originType"),reason:"`Cdn` selects its origin implementation from an `originType` discriminator that the CDN vocabulary does not carry, so a distribution built from CDN properties throws `Unsupported CDN origin type: undefined` the moment `app.addCdn` materialises it. "+c},{property:"originType",refuseWhen:n(e=>e.originType==="s3"&&e.bucket!==m,"refuseWhen"),reason:"an s3 origin needs `bucket` to be an `IBucket` or a Fjall `Storage` \u2014 a live construct, not a name, and not a string; omitting it throws `Cannot read properties of undefined (reading 'bucketRegionalDomainName')` at synth. "+c},{property:"originType",refuseWhen:n(e=>e.originType==="alb"&&e.loadBalancer!==m,"refuseWhen"),reason:'an alb origin needs `loadBalancer` to be an `IApplicationLoadBalancer` or an ECS compute \u2014 a live construct, not a name, and not a string; a string reaches CloudFormation as `Supplied properties not correct for "OriginProperty"`. '+c},{property:"behaviours",refuseWhen:n(e=>Array.isArray(e.behaviours)&&e.behaviours.some(t=>G(t)&&t.originRef!==void 0),"refuseWhen"),reason:"the plan's `behaviours[].originRef` names another planned resource, while the construct's behaviour takes a live origin object; the plan shape throws `Cannot read properties of undefined (reading 'computeType')` at synth. "+c},a("customDomain","the distribution reads `domainNames`, so `--customDomain` deploys a distribution with no alias."),a("defaultOriginRef","`defaultOriginRef` names another planned resource for the scaffold to resolve into a live origin; no CDN construct reads it."),y],te=[{property:"name",refuseWhen:p("name"),reason:"every pattern construct requires a `name` PROPERTY in addition to its construct id, and `fjall add --name` binds the construct id, so no invocation can deliver it \u2014 `toPascalCase(props.name)` throws at synth and takes the whole app down. "+c},{property:"type",refuseWhen:p("type"),reason:"`PatternFactory.build` reads `PATTERN_REGISTRY[props.type]` before it even returns the thunk, and the pattern vocabulary carries no `type` discriminator. "+c}],ne=[{property:"peerAppName",refuseWhen:p("peerAppName"),reason:"`peerAppName` is required: it is the SSM prefix every remote lookup is built from, and omitting it does NOT fail \u2014 synth succeeds and the app deploys a peering connection pointed at `/fjall/default/undefined/vpc-id`. Pass `--peerAppName <remote app>`."},{property:"peerAccountId",refuseWhen:p("peerAccountId"),reason:"`peerAccountId` is required: omitting it does NOT fail, it deploys a VPC peering connection with no `PeerOwnerId`. Pass `--peerAccountId <12-digit account>`."}];function o(e,t,i={}){return{factoryIdentifier:e,locator:$(e),generator:J(e),schemaFragment:t,...i}}n(o,"createEntry");const h={database:o(r.database,I,{emitWrapper:{appMethod:"addDatabase"}}),storage:o(r.storage,B,{emitWrapper:{appMethod:"addStorage"}}),compute:o(r.compute,j,{emitWrapper:{appMethod:"addCompute"},emitGuard:Z}),messaging:o(r.messaging,L,{emitWrapper:{appMethod:"addMessaging"}}),cdn:o(r.cdn,V,{emitWrapper:{appMethod:"addCdn"},emitGuard:ee}),network:o(r.network,Y,{emitWrapper:{appMethod:"addNetwork"}}),pattern:o(r.pattern,q,{emitWrapper:{appMethod:"addPattern"},emitGuard:te}),"vpc-peer":o(r["vpc-peer"],K,{emitWrapper:{appMethod:"addVpcPeer"},emitGuard:ne}),"vpc-peer-accepter":o(r["vpc-peer-accepter"],U,{emitWrapper:{appMethod:"addVpcPeerAccepter"}}),"cross-plan-connection":o(r["cross-plan-connection"],z),organisation:o(r.organisation,H),buildkite:o(r.buildkite,Q,{emitWrapper:{appMethod:"addBuildkite",propsOverloadConstructId:"Buildkite"}})},ge=Object.keys(h);function ye(e){const t=Object.keys(h);for(const i of t)if(h[i].factoryIdentifier===e)return i}n(ye,"findTypeByIdentifier");export{r as FACTORY_IDENTIFIERS,ge as REGISTERED_STATEMENT_TYPES,h as STATEMENT_REGISTRY,ye as findTypeByIdentifier};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { ResourceNameSchema } from "../schemas/baseSchemas.js";
|
|
2
3
|
import type { GateId } from "./validationGate/types.js";
|
|
3
4
|
import type { EgressRiskReason } from "./llmFallback/egressGate.types.js";
|
|
4
5
|
export declare const DriftPolicySchema: z.ZodObject<{
|
|
@@ -26,7 +27,14 @@ export declare const StatementTypeSchema: z.ZodEnum<{
|
|
|
26
27
|
buildkite: "buildkite";
|
|
27
28
|
}>;
|
|
28
29
|
export type StatementType = z.infer<typeof StatementTypeSchema>;
|
|
29
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The scaffold's shared resource-name vocabulary (lowercase-leading factory
|
|
32
|
+
* names included: interactive adds use `resourceName = databaseName`, the
|
|
33
|
+
* default is `${appName}Database`). Re-exported from the canonical schema so
|
|
34
|
+
* the codemod's add/modify/remove gates cannot drift from the generator's
|
|
35
|
+
* validation.
|
|
36
|
+
*/
|
|
37
|
+
export { ResourceNameSchema };
|
|
30
38
|
export type ResourceName = z.infer<typeof ResourceNameSchema>;
|
|
31
39
|
export declare const AddOptionsSchema: z.ZodObject<{
|
|
32
40
|
type: z.ZodEnum<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as t}from"zod";import{
|
|
1
|
+
import{z as t}from"zod";import{ResourceNameSchema as e}from"../schemas/baseSchemas.js";const o=t.object({force:t.boolean().optional(),resolutionMap:t.record(t.string(),t.unknown()).optional()}).strict(),n=t.enum(["database","storage","compute","messaging","cdn","network","pattern","vpc-peer","vpc-peer-accepter","cross-plan-connection","organisation","buildkite"]),r=t.record(t.string(),t.unknown()),l=t.object({type:n,name:e,properties:r,filePath:t.string().optional(),driftPolicy:o.optional(),branch:t.string().optional()}).strict(),m=t.object({type:n,name:e,filePath:t.string().optional(),force:t.boolean().optional(),branch:t.string().optional()}).strict(),g=t.object({type:n,name:e,properties:r,filePath:t.string().optional(),driftPolicy:o.optional(),branch:t.string().optional()}).strict(),i=t.object({line:t.number().int().positive(),column:t.number().int().positive(),context:t.string()}).strict(),c=t.object({added:t.number().int().nonnegative(),removed:t.number().int().nonnegative()}).strict(),a=t.object({type:n,name:t.string(),filePath:t.string(),start:t.number().int().nonnegative(),length:t.number().int().nonnegative(),managed:t.literal(!1).optional()}).strict(),b=t.object({filePath:t.string(),resources:t.array(a)}).strict(),h=t.object({content:t.string(),linesChanged:c,references:t.array(i).optional(),warnings:t.array(t.string()).optional()}).strict(),u=t.object({property:t.string(),base:t.unknown().optional(),theirs:t.unknown(),ours:t.unknown(),verdict:t.enum(["clean","no-op","compatible","conflict"])}).strict();export{l as AddOptionsSchema,h as CodemodSuccessSchema,o as DriftPolicySchema,c as LinesChangedSchema,g as ModifyOptionsSchema,u as PropertyDeltaSchema,i as ReferenceLocationSchema,m as RemoveOptionsSchema,a as ResourceListingEntrySchema,b as ResourceListingSchema,e as ResourceNameSchema,n as StatementTypeSchema};
|
|
@@ -29,6 +29,21 @@ export declare function formatStringArray(values: readonly string[]): string;
|
|
|
29
29
|
*/
|
|
30
30
|
export declare const PRODUCTION_ALERTS_TOPIC_IMPORT = "import:SharedAlarmTopicArn";
|
|
31
31
|
export declare function emitProductionAlertsTopicSpread(indent?: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* The `_N` connection env-key suffix scheme, shared by every connection
|
|
34
|
+
* emitter (database, storage, messaging) AND the codemod connection edit
|
|
35
|
+
* (`codemod/edits/connectResourceToCompute.ts`): the first connection of a
|
|
36
|
+
* type gets no suffix, the Nth gets `_N`. `index` is zero-based position.
|
|
37
|
+
* Drift between the two lanes silently desynchronises surgically-wired env
|
|
38
|
+
* keys from regenerated ones.
|
|
39
|
+
*/
|
|
40
|
+
export declare function connectionEnvSuffix(index: number): string;
|
|
41
|
+
/**
|
|
42
|
+
* Inverse of {@link connectionEnvSuffix}: the 1-based ordinal a key encodes
|
|
43
|
+
* for `base` (`DATABASE_HOST` → 1, `DATABASE_HOST_2` → 2), or `undefined`
|
|
44
|
+
* when the key does not belong to that base's suffix scheme.
|
|
45
|
+
*/
|
|
46
|
+
export declare function connectionKeyOrdinal(key: string, base: string): number | undefined;
|
|
32
47
|
/**
|
|
33
48
|
* Type guard to check if a value is a special code generation value
|
|
34
49
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
${e}...(getConfig().environment === "production" ? { alertsTopic: ${c(
|
|
1
|
+
var m=Object.defineProperty;var n=(e,r)=>m(e,"name",{value:r,configurable:!0});import{toPascalCase as T,toKebab as V,toValidDatabaseName as C}from"@fjall/util";function c(e){return JSON.stringify(e)}n(c,"escapeStringLiteral");function _(e){return e.map(c).join(", ")}n(_,"formatStringArray");const l="import:SharedAlarmTopicArn";function $(e=" "){return`
|
|
2
|
+
${e}...(getConfig().environment === "production" ? { alertsTopic: ${c(l)} } : {}),`}n($,"emitProductionAlertsTopicSpread");function y(e){return e===0?"":`_${String(e+1)}`}n(y,"connectionEnvSuffix");function x(e,r){if(e===r)return 1;if(!e.startsWith(`${r}_`))return;const t=e.slice(r.length+1);return/^\d+$/.test(t)?parseInt(t,10):void 0}n(x,"connectionKeyOrdinal");function b(e){if(typeof e!="object"||e===null)return!1;const r=e;return typeof r.__identifier=="string"||typeof r.__expression=="string"||typeof r.__call=="string"}n(b,"isSpecialValue");function u(e){return e.replace(/[^a-zA-Z0-9]/g," ").split(" ").map((r,t)=>t===0?r.charAt(0).toLowerCase()+r.slice(1):r.charAt(0).toUpperCase()+r.slice(1)).join("")}n(u,"toVariableName");function j(e){return e.variableName??u(e.name)}n(j,"getVariableName");function S(e,r){for(const t of e.database)if(t.name===r&&t.variableName)return t.variableName;for(const t of e.s3)if(t.name===r&&t.variableName)return t.variableName;for(const t of e.compute)if(t.name===r&&t.variableName)return t.variableName;for(const t of e.dynamodb??[])if(t.name===r&&t.variableName)return t.variableName;for(const t of e.sqs??[])if(t.name===r&&t.variableName)return t.variableName;return u(r)}n(S,"resolveResourceVariable");function d(e){const r=Object.entries(e);return r.length===0?!0:r.length>1?!1:r.every(([,t])=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null)}n(d,"isSimpleObject");function a(e,r=" "){if(e==null)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return String(e);if(b(e)){if("__identifier"in e)return e.__identifier;if("__expression"in e)return e.__expression;if("__call"in e)return e.__call}if(Array.isArray(e))return`[${e.map(t=>a(t,r)).join(", ")}]`;if(typeof e=="object"){const t=Object.entries(e).filter(([,f])=>f!==void 0);if(d(e)){const f=t.map(([s,p])=>`${s}: ${a(p,r)}`).join(", ");return f?`{ ${f} }`:"{}"}const o=r+" ",i=t.map(([f,s])=>`${o}${f}: ${a(s,o)}`).join(`,
|
|
3
3
|
`);return i?`{
|
|
4
4
|
${i}
|
|
5
|
-
${
|
|
6
|
-
${
|
|
7
|
-
${
|
|
8
|
-
${
|
|
5
|
+
${r}}`:"{}"}return JSON.stringify(e)}n(a,"formatValue");function N(e,r=" "){return e.map(t=>{const o=t.value.kind==="expression"?t.value.source:a(t.value.value,r);return`
|
|
6
|
+
${r}${t.key}: ${o}`}).join(",")}n(N,"emitProjectedProps");function O(e,r,t,o="raw"){if(!e)return"";let i;switch(o){case"string":i=c(String(t));break;case"object":i=a(t);break;case"boolean-or-object":i=t===!1?"false":a(t);break;default:i=String(t)}return`
|
|
7
|
+
${r}: ${i},`}n(O,"buildProperty");function A(e,r=" "){return e?.length?e.map(t=>`
|
|
8
|
+
${r}${t.key}: ${t.sourceText},`).join(""):""}n(A,"emitExtraProperties");export{l as PRODUCTION_ALERTS_TOPIC_IMPORT,O as buildProperty,y as connectionEnvSuffix,x as connectionKeyOrdinal,A as emitExtraProperties,$ as emitProductionAlertsTopicSpread,N as emitProjectedProps,c as escapeStringLiteral,_ as formatStringArray,a as formatValue,j as getVariableName,b as isSpecialValue,S as resolveResourceVariable,V as toKebab,T as toPascalCase,C as toValidDatabaseName,u as toVariableName};
|
|
@@ -17,6 +17,26 @@ export declare const CREDENTIAL_KEYS: Readonly<{
|
|
|
17
17
|
readonly USERNAME: "username";
|
|
18
18
|
readonly PASSWORD: "password";
|
|
19
19
|
}>;
|
|
20
|
+
/**
|
|
21
|
+
* The literal value emitted for `DATABASE_SSL`. Shared with the codemod
|
|
22
|
+
* connection edit (`codemod/edits/connectResourceToCompute.ts`) — the two
|
|
23
|
+
* emitters must write the same byte or surgically-wired apps diverge from
|
|
24
|
+
* regenerated ones.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DATABASE_SSL_VALUE = "true";
|
|
27
|
+
/**
|
|
28
|
+
* Construct accessor methods the emitted connection wiring calls on a bound
|
|
29
|
+
* database variable. Shared with the codemod connection edit
|
|
30
|
+
* (`codemod/edits/connectResourceToCompute.ts`) — the two emitters must call
|
|
31
|
+
* identical methods or surgically-wired apps fail at synth.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DATABASE_ACCESSORS: Readonly<{
|
|
34
|
+
readonly HOST: "getHostEndpoint";
|
|
35
|
+
readonly PORT: "getHostPort";
|
|
36
|
+
readonly NAME: "getDatabaseName";
|
|
37
|
+
readonly CREDENTIALS: "getCredentials";
|
|
38
|
+
readonly IMPORT: "getImport";
|
|
39
|
+
}>;
|
|
20
40
|
export type DatabaseEnvVarEntry = {
|
|
21
41
|
key: string;
|
|
22
42
|
expression: string;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
2
|
-
secondaryRegions: [${
|
|
3
|
-
`:""}${
|
|
4
|
-
DatabaseFactory.build(${
|
|
1
|
+
var $=Object.defineProperty;var c=(e,n)=>$(e,"name",{value:n,configurable:!0});import{buildProperty as o,connectionEnvSuffix as y,formatValue as S,getVariableName as p,emitExtraProperties as b,escapeStringLiteral as a,formatStringArray as R,emitProductionAlertsTopicSpread as m}from"./common.js";const l=Object.freeze({HOST:"DATABASE_HOST",PORT:"DATABASE_PORT",NAME:"DATABASE_NAME",SSL:"DATABASE_SSL",USERNAME:"DATABASE_USERNAME",PASSWORD:"DATABASE_PASSWORD"}),A=Object.freeze({USERNAME:"username",PASSWORD:"password"}),g="true",u=Object.freeze({HOST:"getHostEndpoint",PORT:"getHostPort",NAME:"getDatabaseName",CREDENTIALS:"getCredentials",IMPORT:"getImport"});function D(e,n){const r=n.connectedDatabase;return r?.length?e.database.filter(t=>r.includes(t.name)):[]}c(D,"getConnectedDatabases");function E(e,n){return`${e}.${u.CREDENTIALS}().${u.IMPORT}(${a(n)})`}c(E,"getCredentialExpression");function T(e){const n=[],r=c((t,d,s)=>{n.push({key:t,expression:d,isSecret:s})},"addEntry");if(e.length===1){const t=p(e[0]);r(l.HOST,`${t}.${u.HOST}()`,!1),r(l.PORT,`${t}.${u.PORT}()`,!1),r(l.NAME,`${t}.${u.NAME}()`,!1),r(l.SSL,a(g),!1),r(l.USERNAME,E(t,A.USERNAME),!0),r(l.PASSWORD,E(t,A.PASSWORD),!0)}else for(const[t,d]of e.entries()){const s=p(d),i=y(t);r(`${l.HOST}${i}`,`${s}.${u.HOST}()`,!1),r(`${l.PORT}${i}`,`${s}.${u.PORT}()`,!1),r(`${l.NAME}${i}`,`${s}.${u.NAME}()`,!1),r(`${l.SSL}${i}`,a(g),!1),r(`${l.USERNAME}${i}`,E(s,A.USERNAME),!0),r(`${l.PASSWORD}${i}`,E(s,A.PASSWORD),!0)}return n}c(T,"generateDatabaseEnvVarEntries");function j(e){return`connections: [${e.map(r=>p(r)).join(", ")}],`}c(j,"formatConnectionsCode");function h(e){return e.expression===a(g)?g:{__expression:e.expression}}c(h,"toDatabaseEnvVarValue");function _(e,n){const r={},t={};if(!n.needsConnection||!n.connectedDatabase?.length)return{env:r,secrets:t};const d=D(e,n),s=T(d);for(const i of s){const f=h(i);i.isSecret?t[i.key]={__expression:i.expression}:r[i.key]=f}return{env:r,secrets:t}}c(_,"buildDatabaseEnvVars");function x(e){let n="";return n+=o(e.port!==void 0,"port",e.port),n+=o(e.deletionProtection!==void 0,"deletionProtection",e.deletionProtection),n+=o(e.snapshotIdentifier!==void 0,"snapshotIdentifier",e.snapshotIdentifier,"string"),n+=o(e.snapshotUsername!==void 0,"snapshotUsername",e.snapshotUsername,"string"),n+=o(e.monitoringInterval!==void 0,"monitoringInterval",e.monitoringInterval),n}c(x,"generateDatabaseSharedProps");function N(e){if(e.type!=="Instance")return"";let n="";return n+=o(e.instanceType!==void 0,"instanceType",e.instanceType,"string"),n+=o(e.allocatedStorage!==void 0,"allocatedStorage",e.allocatedStorage),n+=o(e.multiAz!==void 0,"multiAz",e.multiAz),n+=o(e.publiclyAccessible!==void 0,"publiclyAccessible",e.publiclyAccessible),n+=o(e.encryption!==void 0,"encryption",e.encryption,"object"),n+=o(e.databaseInsights!==void 0,"databaseInsights",e.databaseInsights,"boolean-or-object"),n+=o(e.proxy!==void 0,"proxy",e.proxy,"boolean-or-object"),n+=o(e.readReplica!==void 0,"readReplica",e.readReplica,"boolean-or-object"),n+=o(e.credentials!==void 0,"credentials",e.credentials,"object"),n+=o(e.backupRetention!==void 0,"backupRetention",e.backupRetention),n}c(N,"generateDatabaseInstanceProps");function P(e){if(e.type!=="Aurora"&&e.type!=="GlobalAurora")return"";let n="";return n+=o(e.encryption!==void 0,"encryption",e.encryption,"object"),n+=o(e.databaseInsights!==void 0,"databaseInsights",e.databaseInsights,"boolean-or-object"),n+=o(e.proxy!==void 0,"proxy",e.proxy,"boolean-or-object"),n+=o(e.credentials!==void 0,"credentials",e.credentials,"object"),n+=o(e.writer!==void 0,"writer",e.writer,"object"),n+=o(e.readers!==void 0,"readers",e.readers,"boolean-or-object"),n+=o(e.backupRetention!==void 0,"backupRetention",e.backupRetention),n+=o(e.preferredMaintenanceWindow!==void 0,"preferredMaintenanceWindow",e.preferredMaintenanceWindow,"string"),n}c(P,"generateDatabaseAuroraProps");function O(e){if(e.type!=="GlobalAurora")return"";let n="";return n+=o(e.primaryRegion!==void 0,"primaryRegion",e.primaryRegion,"string"),e.secondaryRegions!==void 0&&e.secondaryRegions.length>0&&(n+=`
|
|
2
|
+
secondaryRegions: [${R(e.secondaryRegions)}],`),n+=o(e.globalClusterIdentifier!==void 0,"globalClusterIdentifier",e.globalClusterIdentifier,"string"),n+=o(e.enableGlobalWriteForwarding!==void 0,"enableGlobalWriteForwarding",e.enableGlobalWriteForwarding),n}c(O,"generateDatabaseGlobalAuroraProps");function I(e,n){return n.compute.some(r=>r.needsConnection&&r.connectedDatabase?.includes(e.name))}c(I,"databaseNeedsVariable");function w(e){if(e.database.length===0)return"";let n="";for(let r=0;r<e.database.length;r++){const t=e.database[r],d=p(t),s=I(t,e),i=r>0,f=s?`const ${d} = `:"";n+=`${i?`
|
|
3
|
+
`:""}${f}app.addDatabase(
|
|
4
|
+
DatabaseFactory.build(${a(t.name)}, {
|
|
5
5
|
vpc: app.getVpc(),
|
|
6
|
-
type: ${
|
|
7
|
-
databaseName: ${
|
|
6
|
+
type: ${a(t.type)},
|
|
7
|
+
databaseName: ${a(t.databaseName)},`,t.engineExpression?n+=`
|
|
8
8
|
engine: ${t.engineExpression},`:t.databaseEngine&&(n+=`
|
|
9
|
-
databaseEngine: ${
|
|
9
|
+
databaseEngine: ${a(t.databaseEngine)},`),n+=x(t),n+=N(t),n+=P(t),n+=O(t),n+=b(t.extraProperties),t.alarms===!1?n+=`
|
|
10
10
|
alarms: false,`:typeof t.alarms=="object"&&(n+=`
|
|
11
|
-
alarms: ${
|
|
11
|
+
alarms: ${S(t.alarms," ")},`),t.type!=="GlobalAurora"&&(n+=m()),n+=`
|
|
12
12
|
})
|
|
13
13
|
);
|
|
14
|
-
`}return n}
|
|
15
|
-
`:"",
|
|
16
|
-
DatabaseFactory.build(${
|
|
14
|
+
`}return n}c(w,"generateDatabaseCode");function W(e){if(!e.clickhouse||e.clickhouse.length===0)return"";let n="";for(let r=0;r<e.clickhouse.length;r++){const t=e.clickhouse[r],d=p(t),s=k(t,e),i=r>0?`
|
|
15
|
+
`:"",f=s?`const ${d} = `:"";n+=`${i}${f}app.addDatabase(
|
|
16
|
+
DatabaseFactory.build(${a(t.name)}, {
|
|
17
17
|
type: "ClickHouse",
|
|
18
|
-
databaseName: ${
|
|
19
|
-
instanceType: ${
|
|
20
|
-
coldTier: ${
|
|
21
|
-
optimiseSchedule: ${
|
|
22
|
-
backupSchedule: ${
|
|
23
|
-
backupRetentionDays: ${t.backupRetentionDays},`),n+=
|
|
18
|
+
databaseName: ${a(t.databaseName)},`,t.instanceType!==void 0&&(n+=`
|
|
19
|
+
instanceType: ${a(t.instanceType)},`),t.coldTier!==void 0&&(n+=`
|
|
20
|
+
coldTier: ${S(t.coldTier," ")},`),t.optimiseSchedule!==void 0&&(n+=`
|
|
21
|
+
optimiseSchedule: ${S(t.optimiseSchedule," ")},`),t.backupSchedule!==void 0&&(n+=`
|
|
22
|
+
backupSchedule: ${S(t.backupSchedule," ")},`),t.backupRetentionDays!==void 0&&(n+=`
|
|
23
|
+
backupRetentionDays: ${t.backupRetentionDays},`),n+=b(t.extraProperties),n+=`
|
|
24
24
|
})
|
|
25
25
|
);
|
|
26
|
-
`}return n}
|
|
26
|
+
`}return n}c(W,"generateClickHouseCode");function k(e,n){return n.compute.some(r=>r.connectedDatabase?.includes(e.name))}c(k,"clickhouseNeedsVariable");export{A as CREDENTIAL_KEYS,u as DATABASE_ACCESSORS,l as DATABASE_ENV_VARS,g as DATABASE_SSL_VALUE,_ as buildDatabaseEnvVars,I as databaseNeedsVariable,j as formatConnectionsCode,W as generateClickHouseCode,w as generateDatabaseCode,T as generateDatabaseEnvVarEntries,D as getConnectedDatabases,h as toDatabaseEnvVarValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var g=Object.defineProperty;var u=(s,e)=>g(s,"name",{value:e,configurable:!0});import{connectionEnvSuffix as p,getVariableName as f}from"./common.js";const i=Object.freeze({URL:"QUEUE_URL",ARN:"QUEUE_ARN"});function a(s,e){const{connectedMessaging:n}=e;return n?.length?(s.sqs??[]).filter(t=>n.includes(t.name)):[]}u(a,"getConnectedMessaging");function x(s){const e=[];if(s.length===1){const n=s[0];if(!n)return e;const t=f(n);e.push({key:i.URL,expression:`${t}.getQueueUrl()`}),e.push({key:i.ARN,expression:`${t}.getQueueArn()`})}else for(const[n,t]of s.entries()){const r=f(t),o=p(n);e.push({key:`${i.URL}${o}`,expression:`${r}.getQueueUrl()`}),e.push({key:`${i.ARN}${o}`,expression:`${r}.getQueueArn()`})}return e}u(x,"generateMessagingEnvVarEntries");function U(s,e){const n={},t={};if(!e.connectedMessaging?.length)return{env:n,secrets:t};const r=a(s,e),o=x(r);for(const c of o)n[c.key]={__expression:c.expression};return{env:n,secrets:t}}u(U,"buildMessagingEnvVars");export{i as MESSAGING_ENV_VARS,U as buildMessagingEnvVars,x as generateMessagingEnvVarEntries,a as getConnectedMessaging};
|
|
@@ -8,6 +8,15 @@ import type { S3ResourcePlan, SQSResourcePlan, ApplicationResourcePlan, ComputeR
|
|
|
8
8
|
export declare const STORAGE_ENV_VARS: Readonly<{
|
|
9
9
|
readonly NAME: "BUCKET_NAME";
|
|
10
10
|
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Construct accessor methods the emitted connection wiring calls on a bound
|
|
13
|
+
* bucket variable. Shared with the codemod connection edit
|
|
14
|
+
* (`codemod/edits/connectResourceToCompute.ts`) — the two emitters must call
|
|
15
|
+
* identical methods or surgically-wired apps fail at synth.
|
|
16
|
+
*/
|
|
17
|
+
export declare const STORAGE_ACCESSORS: Readonly<{
|
|
18
|
+
readonly BUCKET_NAME: "getBucketName";
|
|
19
|
+
}>;
|
|
11
20
|
export type StorageEnvVarEntry = {
|
|
12
21
|
key: string;
|
|
13
22
|
expression: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p=Object.defineProperty;var i=(t,e)=>p(t,"name",{value:e,configurable:!0});import{connectionEnvSuffix as g,getVariableName as a}from"./common.js";const u=Object.freeze({NAME:"BUCKET_NAME"}),E=Object.freeze({BUCKET_NAME:"getBucketName"});function l(t,e){const{connectedStorage:n}=e;return n?.length?t.s3.filter(r=>n.includes(r.name)):[]}i(l,"getConnectedStorage");function x(t){const e=[];if(t.length===1){const n=t[0];if(!n)return e;const r=a(n);e.push({key:u.NAME,expression:`${r}.${E.BUCKET_NAME}()`})}else for(const[n,r]of t.entries()){const o=a(r),s=g(n);e.push({key:`${u.NAME}${s}`,expression:`${o}.${E.BUCKET_NAME}()`})}return e}i(x,"generateStorageEnvVarEntries");function S(t,e){const n={},r={};if(!e.connectedStorage?.length)return{env:n,secrets:r};const o=l(t,e),s=x(o);for(const f of s)n[f.key]={__expression:f.expression};return{env:n,secrets:r}}i(S,"buildStorageEnvVars");function N(t,e,n=[]){const r=t.map(c=>a(c)),o=e.map(c=>a(c)),s=n.map(c=>a(c));return`connections: [${[...r,...o,...s].join(", ")}],`}i(N,"formatAllConnectionsCode");export{E as STORAGE_ACCESSORS,u as STORAGE_ENV_VARS,S as buildStorageEnvVars,N as formatAllConnectionsCode,x as generateStorageEnvVarEntries,l as getConnectedStorage};
|
|
@@ -2,5 +2,6 @@ export { planApplicationResources, planServiceFromTierPreset, toUserServiceConfi
|
|
|
2
2
|
export { type OpenNextResourceOptions, planOpenNextResources, } from "./openNextPlanning.js";
|
|
3
3
|
export { type StaticSiteResourceOptions, planStaticSiteResources, } from "./staticSitePlanning.js";
|
|
4
4
|
export { type ConnectionType, applyComputeConnections, applyServiceConnections, } from "./resourceConnections.js";
|
|
5
|
-
export { type AddableResourceType, type AddResourceOptions, type DatabaseAddOptions, type ProxyAddOptions, type S3AddOptions, type NetworkAddOptions, type EcsComputeAddOptions, type LambdaComputeAddOptions, type CdnAddOptions, type TunnelAddOptions, addResourceToPlan, validateResourceAddition, listAvailableResources, } from "./resourceAddition.js";
|
|
5
|
+
export { type AddableResourceType, type AddResourceOptions, type DatabaseAddOptions, type ProxyAddOptions, type S3AddOptions, type NetworkAddOptions, type EcsComputeAddOptions, type LambdaComputeAddOptions, type CdnAddOptions, type TunnelAddOptions, addResourceToPlan, validateResourceAddition, listAvailableResources, isResourceNameTaken, resourceNameTakenMessage, } from "./resourceAddition.js";
|
|
6
6
|
export { type ResourceChangeResult, generateResourceChange, } from "./generateResourceChange.js";
|
|
7
|
+
export { type RelationalDatabaseBuildOptions, type ClickHouseDatabaseBuildOptions, type S3BucketBuildOptions, type ProxyAdditionResolution, type ProxyPlanValue, buildRelationalResourcePlan, buildClickHouseResourcePlan, buildS3ResourcePlan, defaultRelationalDatabaseName, duplicateDatabaseNameMessage, resolveProxyAddition, pickDefined, } from "./planBuilders.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{planApplicationResources as
|
|
1
|
+
import{planApplicationResources as a,planServiceFromTierPreset as r,toUserServiceConfigs as s,generateInfrastructureFromPlan as t}from"./resourcePlanning.js";import{planOpenNextResources as i}from"./openNextPlanning.js";import{planStaticSiteResources as c}from"./staticSitePlanning.js";import{applyComputeConnections as u,applyServiceConnections as m}from"./resourceConnections.js";import{addResourceToPlan as R,validateResourceAddition as f,listAvailableResources as x,isResourceNameTaken as P,resourceNameTakenMessage as b}from"./resourceAddition.js";import{generateResourceChange as v}from"./generateResourceChange.js";import{buildRelationalResourcePlan as S,buildClickHouseResourcePlan as N,buildS3ResourcePlan as k,defaultRelationalDatabaseName as A,duplicateDatabaseNameMessage as T,resolveProxyAddition as y,pickDefined as D}from"./planBuilders.js";export{R as addResourceToPlan,u as applyComputeConnections,m as applyServiceConnections,N as buildClickHouseResourcePlan,S as buildRelationalResourcePlan,k as buildS3ResourcePlan,A as defaultRelationalDatabaseName,T as duplicateDatabaseNameMessage,t as generateInfrastructureFromPlan,v as generateResourceChange,P as isResourceNameTaken,x as listAvailableResources,D as pickDefined,a as planApplicationResources,i as planOpenNextResources,r as planServiceFromTierPreset,c as planStaticSiteResources,y as resolveProxyAddition,b as resourceNameTakenMessage,s as toUserServiceConfigs,f as validateResourceAddition};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure resource-plan builders shared by the CLI generator lane (full
|
|
3
|
+
* regeneration) and the surgical codemod lane. Both lanes MUST derive a new
|
|
4
|
+
* resource's plan shape from these builders — a second derivation would let
|
|
5
|
+
* preset expansion and option picking drift silently between the two paths.
|
|
6
|
+
*/
|
|
7
|
+
import type { z } from "zod";
|
|
8
|
+
import type { AddProxyGeneratorOptions, DatabaseGeneratorSchema } from "../schemas/databaseSchemas.js";
|
|
9
|
+
import type { S3GeneratorOptions } from "../schemas/storageSchemas.js";
|
|
10
|
+
import type { ClickHouseResourcePlan, DatabaseResourcePlan, S3ResourcePlan } from "../schemas/resourceSchemas.js";
|
|
11
|
+
export declare function pickDefined<T extends Record<string, unknown>>(source: T, ...keys: Array<keyof T>): Partial<Pick<T, (typeof keys)[number]>>;
|
|
12
|
+
type ValidatedDatabaseOptions = z.infer<typeof DatabaseGeneratorSchema>;
|
|
13
|
+
export type RelationalDatabaseBuildOptions = Extract<ValidatedDatabaseOptions, {
|
|
14
|
+
databaseType: "Instance" | "Aurora" | "GlobalAurora";
|
|
15
|
+
}>;
|
|
16
|
+
export type ClickHouseDatabaseBuildOptions = Extract<ValidatedDatabaseOptions, {
|
|
17
|
+
databaseType: "ClickHouse";
|
|
18
|
+
}>;
|
|
19
|
+
export type S3BucketBuildOptions = S3GeneratorOptions;
|
|
20
|
+
export declare function buildRelationalResourcePlan(resourceName: string, options: RelationalDatabaseBuildOptions): DatabaseResourcePlan;
|
|
21
|
+
/** Default construct name both lanes use for a relational database add. */
|
|
22
|
+
export declare function defaultRelationalDatabaseName(appName: string): string;
|
|
23
|
+
/** Duplicate-`databaseName` refusal both lanes surface verbatim. */
|
|
24
|
+
export declare function duplicateDatabaseNameMessage(databaseName: string, appName: string): string;
|
|
25
|
+
export type ProxyPlanValue = Partial<Pick<AddProxyGeneratorOptions, "maxConnections" | "maxIdleConnections" | "connectionBorrowTimeout" | "requireTLS">>;
|
|
26
|
+
export type ProxyAdditionResolution = {
|
|
27
|
+
ok: true;
|
|
28
|
+
database: DatabaseResourcePlan;
|
|
29
|
+
proxyValue: ProxyPlanValue;
|
|
30
|
+
} | {
|
|
31
|
+
ok: false;
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Shared proxy-addition core for both lanes: target lookup by construct or
|
|
36
|
+
* database name, the two refusal messages, and the proxy config value.
|
|
37
|
+
* Drift here would let the two `fjall add proxy` paths disagree on which
|
|
38
|
+
* databases are eligible or which options survive.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveProxyAddition(databases: DatabaseResourcePlan[], validated: AddProxyGeneratorOptions): ProxyAdditionResolution;
|
|
41
|
+
export declare function buildClickHouseResourcePlan(resourceName: string, options: ClickHouseDatabaseBuildOptions): ClickHouseResourcePlan;
|
|
42
|
+
/**
|
|
43
|
+
* `existingBucketCount` feeds the scaffold's `bucket`/`bucket2`/… variable
|
|
44
|
+
* naming; the surgical lane strips `variableName` before emission (plan-only
|
|
45
|
+
* round-trip key) but passes the real count so both lanes stay one source.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildS3ResourcePlan(constructName: string, options: S3BucketBuildOptions, existingBucketCount: number): S3ResourcePlan;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var t=(a,e)=>c(a,"name",{value:e,configurable:!0});import{STORAGE_PRESETS as u}from"../presets/storagePresets.js";function s(a,...e){const n={};for(const r of e)a[r]!==void 0&&(n[r]=a[r]);return n}t(s,"pickDefined");function b(a,e){const n={name:a,type:e.databaseType,databaseName:e.databaseName,...s(e,"databaseInsights","port","proxy","credentials","encryption","deletionProtection")};switch(e.databaseType){case"Instance":return{...n,...s(e,"instanceType","multiAz","readReplica","publiclyAccessible","backupRetention","allocatedStorage","snapshotIdentifier","snapshotUsername")};case"Aurora":return{...n,...s(e,"writer","readers","backupRetention","preferredMaintenanceWindow","monitoringInterval","snapshotIdentifier","snapshotUsername")};case"GlobalAurora":return{...n,primaryRegion:e.primaryRegion,...e.secondaryRegions&&e.secondaryRegions.length>0&&{secondaryRegions:e.secondaryRegions},...s(e,"globalClusterIdentifier","enableGlobalWriteForwarding","writer","readers","backupRetention","preferredMaintenanceWindow","monitoringInterval","snapshotIdentifier","snapshotUsername")};default:return e}}t(b,"buildRelationalResourcePlan");function m(a){return`${a}Database`}t(m,"defaultRelationalDatabaseName");function f(a,e){return`Database name '${a}' already exists in ${e}. Please choose a different database name.`}t(f,"duplicateDatabaseNameMessage");function p(a,e){const n=a.find(o=>o.name===e.databaseName||o.databaseName===e.databaseName);if(!n)return{ok:!1,message:`Database '${e.databaseName}' not found. Available databases: ${a.map(o=>o.name).join(", ")||"none"}`};if(n.proxy!==void 0&&n.proxy!==!1)return{ok:!1,message:`Database '${n.name}' already has RDS Proxy enabled.`};const r=s(e,"maxConnections","maxIdleConnections","connectionBorrowTimeout","requireTLS");return{ok:!0,database:n,proxyValue:Object.keys(r).length>0?r:{}}}t(p,"resolveProxyAddition");function y(a,e){return{name:a,type:"ClickHouse",databaseName:e.databaseName,...s(e,"instanceType","coldTier","optimiseSchedule","backupSchedule","backupRetentionDays")}}t(y,"buildClickHouseResourcePlan");function R(a,e,n){const r=e.storagePreset??"standard",o=u[r],i=n===0?"":`${n+1}`;return{name:a,bucketName:e.bucketName,variableName:`bucket${i}`,...o,...s(e,"publicReadAccess","websiteHosting","backupVaultTier","versioned","encryption","kmsKeyArn","cors")}}t(R,"buildS3ResourcePlan");export{y as buildClickHouseResourcePlan,b as buildRelationalResourcePlan,R as buildS3ResourcePlan,m as defaultRelationalDatabaseName,f as duplicateDatabaseNameMessage,s as pickDefined,p as resolveProxyAddition};
|
|
@@ -155,4 +155,7 @@ export declare function validateResourceAddition(plan: ApplicationResourcePlan,
|
|
|
155
155
|
* fields wire the new resource to existing compute resources in the plan.
|
|
156
156
|
*/
|
|
157
157
|
export declare function addResourceToPlan(plan: ApplicationResourcePlan, options: AddResourceOptions): Result<ApplicationResourcePlan, Error>;
|
|
158
|
+
export declare function isResourceNameTaken(plan: ApplicationResourcePlan, name: string): boolean;
|
|
159
|
+
/** Refusal message every lane surfaces verbatim when the gate fires. */
|
|
160
|
+
export declare function resourceNameTakenMessage(name: string): string;
|
|
158
161
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var b=Object.defineProperty;var d=(a,e)=>b(a,"name",{value:e,configurable:!0});import{success as c,failure as u}from"../types/Result.js";import{toPascalCase as l}from"../generation/common.js";import{applyComputeConnections as y,applyServiceConnections as w}from"./resourceConnections.js";function
|
|
1
|
+
var b=Object.defineProperty;var d=(a,e)=>b(a,"name",{value:e,configurable:!0});import{success as c,failure as u}from"../types/Result.js";import{toPascalCase as l}from"../generation/common.js";import{applyComputeConnections as y,applyServiceConnections as w}from"./resourceConnections.js";function z(a){const e=a.database.length>0,n=a.cdn!==void 0;return[{type:"database",label:"Database (RDS)",available:!0},{type:"database:proxy",label:"RDS Proxy",available:e,reason:e?void 0:"Requires at least one database"},{type:"storage:s3",label:"S3 Bucket",available:!0},{type:"network",label:"Network (VPC)",available:!0},{type:"compute:ecs",label:"Compute (ECS)",available:!0},{type:"compute:lambda",label:"Compute (Lambda)",available:!0},{type:"cdn",label:"CDN (CloudFront)",available:!n,reason:n?"A CDN is already configured. Remove existing CDN first.":void 0},{type:"tunnel",label:"Database Tunnel",available:e&&!a.tunnel,reason:e?a.tunnel?"Tunnel is already enabled":void 0:"Requires at least one database"}]}d(z,"listAvailableResources");function g(a,e){if(S(a,e.resourceName))return u(new Error($(e.resourceName)));switch(e.type){case"database":return v(a,e);case"database:proxy":return h(a,e);case"storage:s3":return c(void 0);case"network":return c(void 0);case"compute:ecs":return!e.services||e.services.length===0?u(new Error("ECS compute requires at least one service.")):c(void 0);case"compute:lambda":return c(void 0);case"cdn":return C(a,e);case"tunnel":return R(a);default:{const n=e;return u(new Error(`Unknown resource type: ${String(n)}`))}}}d(g,"validateResourceAddition");function v(a,e){const n=e.databaseName??e.resourceName.toLowerCase();return a.database.some(t=>t.databaseName===n)?u(new Error(`Database name '${n}' already exists. Choose a different database name.`)):e.databaseType==="GlobalAurora"&&!e.primaryRegion?u(new Error("GlobalAurora databases require a primaryRegion.")):c(void 0)}d(v,"validateDatabaseAddition");function h(a,e){const n=a.database.find(r=>r.name===e.targetDatabase||r.databaseName===e.targetDatabase);if(!n){const r=a.database.map(t=>t.name).join(", ")||"none";return u(new Error(`Database '${e.targetDatabase}' not found. Available databases: ${r}`))}return n.proxy!==void 0&&n.proxy!==!1?u(new Error(`Database '${n.name}' already has RDS Proxy enabled.`)):c(void 0)}d(h,"validateProxyAddition");function C(a,e){if(a.cdn)return u(new Error("A CDN is already configured for this application. Remove the existing CDN first."));if(!f(a,e.defaultOriginRef))return u(new Error(`Origin '${e.defaultOriginRef}' not found in plan. CDN origin must reference an existing resource.`));if(e.behaviours){for(const n of e.behaviours)if(!f(a,n.originRef))return u(new Error(`Behaviour origin '${n.originRef}' not found in plan.`))}return c(void 0)}d(C,"validateCdnAddition");function R(a){return a.tunnel&&typeof a.tunnel=="object"?u(new Error("Tunnel is already enabled for this application.")):a.database.length===0?u(new Error("No databases found \u2014 tunnel requires at least one relational database.")):c(void 0)}d(R,"validateTunnelAddition");function O(a,e){const n=g(a,e);if(!n.success)return n;switch(e.type){case"database":return k(a,e);case"database:proxy":return x(a,e);case"storage:s3":return N(a,e);case"network":return D(a,e);case"compute:ecs":return A(a,e);case"compute:lambda":return T(a,e);case"cdn":return E(a,e);case"tunnel":return P(a,e);default:{const r=e;return u(new Error(`Unknown resource type: ${String(r)}`))}}}d(O,"addResourceToPlan");function k(a,e){const n=e.databaseName??e.resourceName.toLowerCase(),r={name:e.resourceName,type:e.databaseType,databaseName:n};let t;switch(e.databaseType){case"Instance":t={...r,...e.instanceType!==void 0?{instanceType:e.instanceType}:{},...e.multiAz!==void 0?{multiAz:e.multiAz}:{},...e.readReplica!==void 0?{readReplica:e.readReplica}:{},...e.publiclyAccessible!==void 0?{publiclyAccessible:e.publiclyAccessible}:{},...e.backupRetention!==void 0?{backupRetention:e.backupRetention}:{}};break;case"Aurora":t={...r,...e.writer!==void 0?{writer:e.writer}:{},...e.readers!==void 0?{readers:e.readers}:{},...e.backupRetention!==void 0?{backupRetention:e.backupRetention}:{},...e.preferredMaintenanceWindow!==void 0?{preferredMaintenanceWindow:e.preferredMaintenanceWindow}:{}};break;case"GlobalAurora":t={...r,primaryRegion:e.primaryRegion,...e.secondaryRegions!==void 0?{secondaryRegions:e.secondaryRegions}:{}};break;default:{const s=e.databaseType;return u(new Error(`Unknown database type: ${String(s)}`))}}const i={...a,database:[...a.database,t]};return o(i,e.resourceName,"database",e),c(i)}d(k,"addDatabase");function x(a,e){const n=a.database.map(i=>({...i})),r=n.find(i=>i.name===e.targetDatabase||i.databaseName===e.targetDatabase);if(!r)return u(new Error(`Database '${e.targetDatabase}' not found.`));const t={};return e.maxConnections!==void 0&&(t.maxConnections=e.maxConnections),e.maxIdleConnections!==void 0&&(t.maxIdleConnections=e.maxIdleConnections),e.connectionBorrowTimeout!==void 0&&(t.connectionBorrowTimeout=e.connectionBorrowTimeout),e.requireTLS!==void 0&&(t.requireTLS=e.requireTLS),r.proxy=Object.keys(t).length>0?t:{},c({...a,database:n})}d(x,"addProxy");function N(a,e){const n=e.bucketName??e.resourceName.toLowerCase(),r=l(n),t=a.s3.length,i=t===0?"":`${t+1}`,s={name:r,bucketName:n,variableName:`bucket${i}`,...e.publicReadAccess!==void 0?{publicReadAccess:e.publicReadAccess}:{},...e.versioned!==void 0?{versioned:e.versioned}:{},...e.encryption!==void 0?{encryption:e.encryption}:{},...e.websiteHosting?{websiteHosting:{indexDocument:"index.html"}}:{}},m={...a,s3:[...a.s3,s]};return o(m,r,"storage",e),c(m)}d(N,"addS3");function D(a,e){const n={};if(e.maxAzs!==void 0&&(n.maxAzs=e.maxAzs),e.natGateways!==void 0&&(n.natGateways=e.natGateways),e.flowLogs!==void 0&&(n.flowLogs=e.flowLogs),e.vpcEndpoints!==void 0&&(n.vpcEndpoints=e.vpcEndpoints),e.networkName){const r={name:e.networkName,...n};return c({...a,additionalNetworks:[...a.additionalNetworks??[],r]})}return c({...a,network:{...a.network??{},...n}})}d(D,"addNetwork");function A(a,e){const n=e.connectedDatabase??[],r={name:e.resourceName,type:"ecs",needsConnection:n.length>0,connectedDatabase:n,...e.loadBalancer!==void 0?{cluster:{loadBalancer:e.loadBalancer}}:{},services:e.services.map(t=>({name:t.name,capacityProvider:t.capacityProvider??"FARGATE",...t.port!==void 0?{containers:[{port:t.port}]}:{},...t.cpu!==void 0?{cpu:t.cpu}:{},...t.memory!==void 0?{memoryLimitMiB:t.memory}:{}})),...e.docker!==void 0&&{docker:e.docker}};return c({...a,compute:[...a.compute,r]})}d(A,"addEcsCompute");function T(a,e){const n=e.connectedDatabase??[],r={name:e.resourceName,type:"lambda",needsConnection:n.length>0,connectedDatabase:n,...e.timeout!==void 0?{timeout:e.timeout}:{},...e.memory!==void 0?{memory:e.memory}:{},...e.handler!==void 0?{handler:e.handler}:{},...e.runtime!==void 0?{runtime:e.runtime}:{}};return c({...a,compute:[...a.compute,r]})}d(T,"addLambdaCompute");function E(a,e){const n={name:e.resourceName,defaultOriginRef:e.defaultOriginRef,...e.customDomain!==void 0?{customDomain:e.customDomain}:{},...e.certificateArn!==void 0?{certificateArn:e.certificateArn}:{},...e.behaviours&&e.behaviours.length>0?{behaviours:[...e.behaviours].map(r=>({pathPattern:r.pathPattern,originRef:r.originRef,...r.cachePolicy!==void 0?{cachePolicy:r.cachePolicy}:{}}))}:{}};return c({...a,cdn:n})}d(E,"addCdn");function P(a,e){const n=e.instanceType?{instanceType:e.instanceType}:{};return c({...a,tunnel:n})}d(P,"addTunnel");function S(a,e){const n=[...a.database.map(r=>r.name),...(a.clickhouse??[]).map(r=>r.name),...a.s3.map(r=>r.name),...a.compute.map(r=>r.name),...(a.dynamodb??[]).map(r=>r.name),...(a.sqs??[]).map(r=>r.name),...(a.additionalNetworks??[]).map(r=>r.name)];return a.cdn&&n.push(a.cdn.name),n.includes(e)}d(S,"isResourceNameTaken");function $(a){return`Resource name '${a}' is already used in this application.`}d($,"resourceNameTakenMessage");function f(a,e){return a.database.some(n=>n.name===e)||a.s3.some(n=>n.name===e)||a.compute.some(n=>n.name===e)||(a.dynamodb??[]).some(n=>n.name===e)||(a.sqs??[]).some(n=>n.name===e)}d(f,"resourceExistsInPlan");function o(a,e,n,r){r.connectToCompute&&r.connectToCompute.length>0&&y(a,[...r.connectToCompute],e,n),r.connectToServices&&r.connectToServices.length>0&&w(a,[...r.connectToServices],e,n)}d(o,"applyConnections");export{O as addResourceToPlan,S as isResourceNameTaken,z as listAvailableResources,$ as resourceNameTakenMessage,g as validateResourceAddition};
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const GENERATOR_VERSION = "
|
|
1
|
+
export declare const GENERATOR_VERSION = "9.0.0";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const E="
|
|
1
|
+
const E="9.0.0";export{E as GENERATOR_VERSION};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjall/generator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/fjall-tech/fjall.git",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"license": "SEE LICENSE IN LICENSE",
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@fjall/util": "^
|
|
56
|
+
"@fjall/util": "^9.0.0",
|
|
57
57
|
"ast-types": "^0.16.1",
|
|
58
58
|
"recast": "^0.23.12",
|
|
59
59
|
"ts-morph": "^28.0.0",
|