@fjall/generator 14.0.0 → 14.2.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 +42 -37
- package/dist/.minified +1 -1
- package/dist/src/ast/astTestHelpers.d.ts +2 -0
- package/dist/src/ast/domain/astDomainParser.d.ts +12 -0
- package/dist/src/ast/domain/astDomainParser.js +1 -1
- package/dist/src/ast/index.d.ts +1 -1
- package/dist/src/ast/index.js +1 -1
- package/dist/src/ast/parsers/resources/astCdnParser.js +1 -1
- package/dist/src/ast/parsers/resources/astComputeParser.js +1 -1
- package/dist/src/codemod/edits/addResource/propertyBuilder.d.ts +8 -0
- package/dist/src/codemod/edits/addResource/propertyBuilder.js +1 -1
- package/dist/src/codemod/edits/addResource/siblingEmission.d.ts +61 -0
- package/dist/src/codemod/edits/addResource/siblingEmission.js +1 -0
- package/dist/src/codemod/edits/addResource.js +1 -1
- package/dist/src/codemod/edits/connectResourceToCompute.js +1 -1
- package/dist/src/codemod/edits/ensureImports.d.ts +18 -0
- package/dist/src/codemod/edits/ensureImports.js +1 -1
- package/dist/src/codemod/edits/modifyResource.js +1 -1
- package/dist/src/codemod/edits/resourceStatementLocator.d.ts +3 -0
- package/dist/src/codemod/edits/resourceStatementLocator.js +1 -1
- package/dist/src/codemod/edits/siblingBindingResolution.d.ts +54 -1
- package/dist/src/codemod/edits/siblingBindingResolution.js +1 -1
- package/dist/src/codemod/emitGuard.d.ts +2 -30
- package/dist/src/codemod/emitGuard.js +1 -1
- package/dist/src/codemod/emitProjection.d.ts +31 -2
- package/dist/src/codemod/emitProjection.js +1 -1
- package/dist/src/codemod/fileRewriter/builders.d.ts +18 -0
- package/dist/src/codemod/fileRewriter/builders.js +1 -1
- package/dist/src/codemod/fileRewriter/index.d.ts +1 -1
- package/dist/src/codemod/fileRewriter/index.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 +26 -27
- package/dist/src/codemod/registry.js +1 -1
- package/dist/src/codemod/validationGate/gates/projection.js +1 -1
- package/dist/src/generation/common.js +8 -8
- package/dist/src/generation/connectionWiring.d.ts +83 -0
- package/dist/src/generation/connectionWiring.js +1 -0
- package/dist/src/generation/database.d.ts +3 -34
- package/dist/src/generation/database.js +20 -20
- package/dist/src/generation/index.d.ts +1 -0
- package/dist/src/generation/index.js +1 -1
- package/dist/src/generation/infrastructure.d.ts +11 -0
- package/dist/src/generation/infrastructure.js +38 -28
- package/dist/src/generation/messagingConnections.d.ts +1 -4
- package/dist/src/generation/messagingConnections.js +1 -1
- package/dist/src/generation/storageConnections.d.ts +1 -12
- package/dist/src/generation/storageConnections.js +1 -1
- package/dist/src/planning/resourceAddition.d.ts +3 -0
- package/dist/src/planning/resourceAddition.js +1 -1
- package/dist/src/projection/compute.d.ts +31 -0
- package/dist/src/projection/compute.js +1 -0
- package/dist/src/projection/index.d.ts +3 -2
- package/dist/src/projection/index.js +1 -1
- package/dist/src/projection/project.d.ts +16 -1
- package/dist/src/projection/project.js +1 -1
- package/dist/src/projection/roundTripKeys.d.ts +12 -0
- package/dist/src/projection/roundTripKeys.js +1 -0
- package/dist/src/projection/tables.d.ts +13 -9
- package/dist/src/projection/tables.js +1 -1
- package/dist/src/projection/types.d.ts +204 -4
- package/dist/src/projection/unresolved.d.ts +17 -0
- package/dist/src/projection/unresolved.js +1 -0
- package/dist/src/schemas/applicationSchemas.d.ts +2 -0
- package/dist/src/schemas/cdnSchemas.d.ts +4 -0
- package/dist/src/schemas/cdnSchemas.js +1 -1
- package/dist/src/schemas/computeSchemas.js +1 -1
- package/dist/src/validation/validationMessages.d.ts +1 -0
- package/dist/src/validation/validationMessages.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,11 +9,11 @@
|
|
|
9
9
|
"package.json",
|
|
10
10
|
"tsconfig.json"
|
|
11
11
|
],
|
|
12
|
-
"hash": "
|
|
12
|
+
"hash": "6d028a961afb031d8a02daeffe0311505bf6f29a03a51de748a739742361e8bc",
|
|
13
13
|
"files": {
|
|
14
14
|
"src/ast/astTestHelpers.ts": "026cac849eb88bdb",
|
|
15
|
-
"src/ast/domain/astDomainParser.ts": "
|
|
16
|
-
"src/ast/index.ts": "
|
|
15
|
+
"src/ast/domain/astDomainParser.ts": "a1f49028bcf3508a",
|
|
16
|
+
"src/ast/index.ts": "48c73220502e5201",
|
|
17
17
|
"src/ast/mutation/astCodeInjection.ts": "c1ebf483fb1e2332",
|
|
18
18
|
"src/ast/mutation/astExpressionEvaluator.ts": "6082789268b91212",
|
|
19
19
|
"src/ast/mutation/astSurgicalModification.ts": "9c512e11e8239c4d",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"src/ast/parsers/common/astStatementQueries.ts": "e40e31e0fcdc15e3",
|
|
23
23
|
"src/ast/parsers/orchestrator/astInfrastructureParser.ts": "07fd7a94796ebf5f",
|
|
24
24
|
"src/ast/parsers/orchestrator/astPlanConverter.ts": "eb9b1f0ab90f6999",
|
|
25
|
-
"src/ast/parsers/resources/astCdnParser.ts": "
|
|
25
|
+
"src/ast/parsers/resources/astCdnParser.ts": "726b298b0b580d68",
|
|
26
26
|
"src/ast/parsers/resources/astClickHouseParser.ts": "cf49943b3d2bbd48",
|
|
27
27
|
"src/ast/parsers/resources/astComputeConnectionParser.ts": "e0f1533845f3ce8a",
|
|
28
|
-
"src/ast/parsers/resources/astComputeParser.ts": "
|
|
28
|
+
"src/ast/parsers/resources/astComputeParser.ts": "8caa5cc22af1913a",
|
|
29
29
|
"src/ast/parsers/resources/astComputeParserHelpers.ts": "b824f221f8c7e3d9",
|
|
30
30
|
"src/ast/parsers/resources/astDatabaseParser.ts": "e18f5483f5e23297",
|
|
31
31
|
"src/ast/parsers/resources/astDynamoDBParser.ts": "809c2c633447b388",
|
|
@@ -41,42 +41,43 @@
|
|
|
41
41
|
"src/codemod/drift/merge.ts": "29093929befa9abd",
|
|
42
42
|
"src/codemod/drift/snapshot.ts": "e389b8dbc41f6dc3",
|
|
43
43
|
"src/codemod/drift/types.ts": "7f1d7899e420e4d7",
|
|
44
|
-
"src/codemod/edits/addResource.ts": "
|
|
44
|
+
"src/codemod/edits/addResource.ts": "bdc90708af588ff4",
|
|
45
45
|
"src/codemod/edits/addResource/appBinding.ts": "3553fdb30fe06335",
|
|
46
46
|
"src/codemod/edits/addResource/bodyIndex.ts": "3e179eac10d7bcf4",
|
|
47
|
-
"src/codemod/edits/addResource/propertyBuilder.ts": "
|
|
47
|
+
"src/codemod/edits/addResource/propertyBuilder.ts": "04d04e8207041381",
|
|
48
|
+
"src/codemod/edits/addResource/siblingEmission.ts": "a305b45583272eca",
|
|
48
49
|
"src/codemod/edits/appendAccountToStage.ts": "1796d909fa3ef79d",
|
|
49
50
|
"src/codemod/edits/computeServiceLocator.ts": "7f86483d9a35e053",
|
|
50
|
-
"src/codemod/edits/connectResourceToCompute.ts": "
|
|
51
|
+
"src/codemod/edits/connectResourceToCompute.ts": "6c1c2ea2f761760f",
|
|
51
52
|
"src/codemod/edits/controlFlowPolicy.ts": "e32bbe2894f76c65",
|
|
52
53
|
"src/codemod/edits/crossPlanConnection.ts": "54a4ecb7b3368160",
|
|
53
54
|
"src/codemod/edits/driftPolicy.ts": "5d9b7bb3505f987d",
|
|
54
|
-
"src/codemod/edits/ensureImports.ts": "
|
|
55
|
+
"src/codemod/edits/ensureImports.ts": "f1ac65fd7b4b826e",
|
|
55
56
|
"src/codemod/edits/findInsertionPosition.ts": "20cd34fdcf781017",
|
|
56
57
|
"src/codemod/edits/index.ts": "bea5ed7c3983342b",
|
|
57
|
-
"src/codemod/edits/modifyResource.ts": "
|
|
58
|
+
"src/codemod/edits/modifyResource.ts": "987e14d973caa83e",
|
|
58
59
|
"src/codemod/edits/modifyResource/literalConversion.ts": "31295cccd59131b7",
|
|
59
60
|
"src/codemod/edits/moduleConstResolver.ts": "85a8597427849a80",
|
|
60
61
|
"src/codemod/edits/objectGraph.ts": "5efc4181547237f8",
|
|
61
62
|
"src/codemod/edits/removeResource.ts": "6af70ee482fabc06",
|
|
62
63
|
"src/codemod/edits/removeResource/commentHeuristic.ts": "90b6ce7ba5aa2a48",
|
|
63
64
|
"src/codemod/edits/removeResource/importPruning.ts": "f22783108b40f6cb",
|
|
64
|
-
"src/codemod/edits/resourceStatementLocator.ts": "
|
|
65
|
+
"src/codemod/edits/resourceStatementLocator.ts": "47ce6a99fe5858c9",
|
|
65
66
|
"src/codemod/edits/secretsProvability.ts": "d723283918e31efd",
|
|
66
67
|
"src/codemod/edits/setContainerSecrets.ts": "24478c4205e79cbd",
|
|
67
|
-
"src/codemod/edits/siblingBindingResolution.ts": "
|
|
68
|
+
"src/codemod/edits/siblingBindingResolution.ts": "7f313b04b5f53633",
|
|
68
69
|
"src/codemod/edits/unmanagedShapeErrors.ts": "47a2644913c8e619",
|
|
69
70
|
"src/codemod/edits/vpcPeer.ts": "0bcf90c2e6d16ca4",
|
|
70
71
|
"src/codemod/edits/vpcPeerAccepter.ts": "c9eace933e9e2345",
|
|
71
|
-
"src/codemod/emitGuard.ts": "
|
|
72
|
-
"src/codemod/emitProjection.ts": "
|
|
73
|
-
"src/codemod/fileRewriter/builders.ts": "
|
|
74
|
-
"src/codemod/fileRewriter/index.ts": "
|
|
72
|
+
"src/codemod/emitGuard.ts": "d199ccbf91166618",
|
|
73
|
+
"src/codemod/emitProjection.ts": "bdc862dedf8d649a",
|
|
74
|
+
"src/codemod/fileRewriter/builders.ts": "9b7ab0f797c9ab56",
|
|
75
|
+
"src/codemod/fileRewriter/index.ts": "222aa7493cedbb01",
|
|
75
76
|
"src/codemod/fileRewriter/locateByRange.ts": "889ee6256201c1fe",
|
|
76
77
|
"src/codemod/fileRewriter/parse.ts": "b12026c31562a13c",
|
|
77
78
|
"src/codemod/fileRewriter/print.ts": "f5ff7afb5b7786bf",
|
|
78
79
|
"src/codemod/historyPaths.ts": "ef8084013146db57",
|
|
79
|
-
"src/codemod/index.ts": "
|
|
80
|
+
"src/codemod/index.ts": "230dbe39a65348ae",
|
|
80
81
|
"src/codemod/listResources.ts": "97f206a50edbea20",
|
|
81
82
|
"src/codemod/llmFallback/apply.ts": "2e656a6e55b3b4e3",
|
|
82
83
|
"src/codemod/llmFallback/claudeTier.ts": "ace3e3baa51383c9",
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
"src/codemod/llmFallback/telemetryEvents.ts": "827282cb185eea6c",
|
|
93
94
|
"src/codemod/llmFallback/tierRunner.ts": "a26094accd78cf15",
|
|
94
95
|
"src/codemod/llmFallback/types.ts": "0b528ccbab7d48b8",
|
|
95
|
-
"src/codemod/registry.ts": "
|
|
96
|
+
"src/codemod/registry.ts": "cb04890990f06ec0",
|
|
96
97
|
"src/codemod/semanticIndex/classifyControlFlow.ts": "ed96215d91a3cae3",
|
|
97
98
|
"src/codemod/semanticIndex/findReferences.ts": "96aea37418d1e91a",
|
|
98
99
|
"src/codemod/semanticIndex/index.ts": "cfcd212d34ab20fb",
|
|
@@ -106,7 +107,7 @@
|
|
|
106
107
|
"src/codemod/validationGate/gates/drift.ts": "bd603a216fbb91a9",
|
|
107
108
|
"src/codemod/validationGate/gates/locate.ts": "2c186c32edbb97ce",
|
|
108
109
|
"src/codemod/validationGate/gates/parse.ts": "5433c5c8ffa35324",
|
|
109
|
-
"src/codemod/validationGate/gates/projection.ts": "
|
|
110
|
+
"src/codemod/validationGate/gates/projection.ts": "461051f3dc6bf6b2",
|
|
110
111
|
"src/codemod/validationGate/gates/schema.ts": "7ed5acaec0620a46",
|
|
111
112
|
"src/codemod/validationGate/index.ts": "bbe1f460330a11cf",
|
|
112
113
|
"src/codemod/validationGate/types.ts": "4a1cfa054e3383d5",
|
|
@@ -118,25 +119,26 @@
|
|
|
118
119
|
"src/dns/index.ts": "266288ae3b851e3d",
|
|
119
120
|
"src/dns/tsEmitter.ts": "2f2f13061d1850db",
|
|
120
121
|
"src/dns/types.ts": "82d6db9d7d26dbc2",
|
|
121
|
-
"src/generation/common.ts": "
|
|
122
|
+
"src/generation/common.ts": "20075ada839797fb",
|
|
122
123
|
"src/generation/compute.ts": "4029a0d8e3197686",
|
|
123
124
|
"src/generation/compute/ec2.ts": "4d8187d293a57fb1",
|
|
124
125
|
"src/generation/compute/ecs.ts": "38a345cbd45c40d4",
|
|
125
126
|
"src/generation/compute/lambda.ts": "4f5e31080941b83a",
|
|
126
127
|
"src/generation/compute/shared.ts": "3724d4bfe92cfcb7",
|
|
127
|
-
"src/generation/
|
|
128
|
+
"src/generation/connectionWiring.ts": "9afb0227f2584ab2",
|
|
129
|
+
"src/generation/database.ts": "07c09dd692c8c4be",
|
|
128
130
|
"src/generation/generatePatternCode.ts": "ab752292dd72b676",
|
|
129
|
-
"src/generation/index.ts": "
|
|
130
|
-
"src/generation/infrastructure.ts": "
|
|
131
|
-
"src/generation/messagingConnections.ts": "
|
|
131
|
+
"src/generation/index.ts": "5745098c57819b3a",
|
|
132
|
+
"src/generation/infrastructure.ts": "0e0c70437195bb0e",
|
|
133
|
+
"src/generation/messagingConnections.ts": "09e70af97e055712",
|
|
132
134
|
"src/generation/storage.ts": "2c0171aeeec3d79e",
|
|
133
|
-
"src/generation/storageConnections.ts": "
|
|
135
|
+
"src/generation/storageConnections.ts": "c0dc86aebf7158ae",
|
|
134
136
|
"src/index.ts": "fc8f27b8ffade9ef",
|
|
135
137
|
"src/planning/generateResourceChange.ts": "1c6411f9a12e7acb",
|
|
136
138
|
"src/planning/index.ts": "8ef807b31c43310c",
|
|
137
139
|
"src/planning/openNextPlanning.ts": "4af9cb9061f7d21e",
|
|
138
140
|
"src/planning/planBuilders.ts": "bea93d0c05caef21",
|
|
139
|
-
"src/planning/resourceAddition.ts": "
|
|
141
|
+
"src/planning/resourceAddition.ts": "7d0320620a74fdcd",
|
|
140
142
|
"src/planning/resourceConnections.ts": "a6b7db8f733e560f",
|
|
141
143
|
"src/planning/resourcePlanning.ts": "1fefdbc93e12ba7f",
|
|
142
144
|
"src/planning/staticSitePlanning.ts": "242af1e9618821ab",
|
|
@@ -146,16 +148,19 @@
|
|
|
146
148
|
"src/presets/storagePresets.ts": "5df2d4d7d21a66d8",
|
|
147
149
|
"src/presets/tierPresets.ts": "c0148771bffbef9b",
|
|
148
150
|
"src/presets/tierTypes.ts": "6526373876daacf0",
|
|
149
|
-
"src/projection/
|
|
150
|
-
"src/projection/
|
|
151
|
-
"src/projection/
|
|
152
|
-
"src/projection/
|
|
151
|
+
"src/projection/compute.ts": "b26369999600a11f",
|
|
152
|
+
"src/projection/index.ts": "3ddb1d53f5781805",
|
|
153
|
+
"src/projection/project.ts": "06e6a3b872d10243",
|
|
154
|
+
"src/projection/roundTripKeys.ts": "a6996fc1ae067d27",
|
|
155
|
+
"src/projection/tables.ts": "5ed946e03b08f705",
|
|
156
|
+
"src/projection/types.ts": "68045bc02a36cee9",
|
|
157
|
+
"src/projection/unresolved.ts": "885c8d3c1624b328",
|
|
153
158
|
"src/schemas/alarmSchemas.ts": "a6f6ac07b2a102de",
|
|
154
159
|
"src/schemas/applicationSchemas.ts": "d85771a4607cf2da",
|
|
155
160
|
"src/schemas/baseSchemas.ts": "93d9bd1c0adfcaa0",
|
|
156
161
|
"src/schemas/buildkiteSchemas.ts": "a28ec3b40f7851ec",
|
|
157
|
-
"src/schemas/cdnSchemas.ts": "
|
|
158
|
-
"src/schemas/computeSchemas.ts": "
|
|
162
|
+
"src/schemas/cdnSchemas.ts": "16784f15894c62ba",
|
|
163
|
+
"src/schemas/computeSchemas.ts": "e06dee92ede421d3",
|
|
159
164
|
"src/schemas/constants.ts": "732a290de68e4ff8",
|
|
160
165
|
"src/schemas/databaseSchemas.ts": "3c05f176e1aadb46",
|
|
161
166
|
"src/schemas/devRolePolicies.ts": "6ca70fb20f5fbebc",
|
|
@@ -172,13 +177,13 @@
|
|
|
172
177
|
"src/types/Result.ts": "6a078a91fc3072e3",
|
|
173
178
|
"src/util/errorUtils.ts": "c021c57804424a5d",
|
|
174
179
|
"src/validation/patterns.ts": "f9629eafdad7ac3e",
|
|
175
|
-
"src/validation/validationMessages.ts": "
|
|
180
|
+
"src/validation/validationMessages.ts": "772ae6e5a897a301",
|
|
176
181
|
"src/validation/validationPatterns.ts": "865f3d688975b7c8",
|
|
177
|
-
"src/version.ts": "
|
|
182
|
+
"src/version.ts": "cbdfef5ce52036bb",
|
|
178
183
|
"../scripts/minify-dist.mjs": "6b2e4b0df8aec601",
|
|
179
|
-
"package.json": "
|
|
184
|
+
"package.json": "82ab778ab479909c",
|
|
180
185
|
"tsconfig.json": "1929cf3f99fe9b1e"
|
|
181
186
|
},
|
|
182
|
-
"outputHash": "
|
|
183
|
-
"outputFileCount":
|
|
187
|
+
"outputHash": "7e48f63d787d3a26a089767f43bc64628be0c727974a63da7119a9fe6be5bb28",
|
|
188
|
+
"outputFileCount": 339
|
|
184
189
|
}
|
package/dist/.minified
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
169 files minified at 2026-08-18T14:33:02.288Z
|
|
@@ -711,6 +711,8 @@ export declare function parseAndConvert(code: string): {
|
|
|
711
711
|
}[] | undefined;
|
|
712
712
|
customDomain?: string | undefined;
|
|
713
713
|
certificateArn?: string | undefined;
|
|
714
|
+
domain?: string | undefined;
|
|
715
|
+
originHostname?: string | undefined;
|
|
714
716
|
accessGate?: false | {
|
|
715
717
|
type: "basic-auth";
|
|
716
718
|
username: string;
|
|
@@ -159,6 +159,18 @@ export type ParseDomainError = {
|
|
|
159
159
|
export declare function parseDomainProps(propsObjectLiteral: ts.ObjectLiteralExpression): Result<ParsedDomainProps, ParseDomainError>;
|
|
160
160
|
/** Human-readable single-line message for a `ParseDomainError`. */
|
|
161
161
|
export declare function parseDomainErrorMessage(err: ParseDomainError): string;
|
|
162
|
+
/**
|
|
163
|
+
* Parse a domain component's infrastructure.ts SOURCE TEXT into the typed
|
|
164
|
+
* Domain props (single-Domain convention). Pure on its inputs — no
|
|
165
|
+
* filesystem — so both the CLI (cwd-resolved paths, ambient masking) and
|
|
166
|
+
* deploy-core's worker provider (job-checkout paths, explicit params) share
|
|
167
|
+
* ONE parse composition instead of each re-assembling
|
|
168
|
+
* createSourceFile + findDomainConstructCall + parseDomainProps.
|
|
169
|
+
*
|
|
170
|
+
* Error messages are unmasked here; callers with sensitive-output masking
|
|
171
|
+
* apply it at their boundary.
|
|
172
|
+
*/
|
|
173
|
+
export declare function parseDomainInfrastructureSource(sourceText: string, infraPath: string, domainName: string): Result<ParsedDomainProps, Error>;
|
|
162
174
|
/**
|
|
163
175
|
* Split a comma-separated argument list into top-level args, respecting
|
|
164
176
|
* nested parens/braces/brackets and string literals. Does NOT attempt to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var R=Object.defineProperty;var u=(n,e)=>R(n,"name",{value:e,configurable:!0});import*as m from"typescript";import{parseObjectLiteral as T,asString as c,asStringUnion as k,asStringArray as y,asBoolean as b,asNumber as $,isCallRef as E,isParsedObject as g}from"../parsers/common/astCommonParser.js";import{success as l,failure as a}from"../../types/Result.js";import{DnsRecordTypeSchema as L}from"../../dns/types.js";import{DomainRegistrarSchema as j,DomainDeployPhaseSchema as Z,AliasRecordTypeSchema as O,TYPED_FJALL_TARGET_KINDS as C}from"../../dns/domainRecords.js";const N=j.options,x=Z.options,P=L.options,V=O.options;function ie(n){const e=[],t=u(r=>{if(m.isNewExpression(r)&&z(r.expression)){const d=F(r);d!==void 0&&e.push(d)}m.forEachChild(r,t)},"visit");if(t(n),e.length===0)return l(void 0);if(e.length>1)return a(new Error(`Expected exactly one 'new Domain(...)' call per infrastructure file, found ${e.length}`));const s=e[0];return s?l(s):l(void 0)}u(ie,"findDomainConstructCall");function z(n){return m.isIdentifier(n)&&n.text==="Domain"}u(z,"isDomainIdentifier");function F(n){const e=n.arguments;if(!e||e.length<3)return;const t=e[0],s=e[1],r=e[2];if(!t||!s||!r||!m.isObjectLiteralExpression(r))return;const d=M(n);if(d===void 0)return;const o=q(n),i=m.isStringLiteral(s)?s.text:void 0;return{callExpression:n,containingStatement:d,propsObjectLiteral:r,domainVarId:o,scopeArgumentText:t.getText(),constructIdLiteral:i}}u(F,"buildMatch");function M(n){let e=n;for(;e!==void 0;){if(m.isExpressionStatement(e)||m.isVariableStatement(e))return e;e=e.parent}}u(M,"findContainingTopLevelStatement");function q(n){let e=n.parent;for(;e!==void 0;){if(m.isVariableDeclaration(e)&&m.isIdentifier(e.name)&&e.initializer===n)return e.name.text;e=e.parent}}u(q,"extractDomainVarId");function B(n){switch(n.kind){case"registrar_required":return"'registrar' property is required";case"registrar_unsupported":return`'registrar' must be one of ${N.join(", ")}, got ${JSON.stringify(n.value)}`;case"missing_field":return`'${n.field}' property is required`;case"invalid_literal":return`'${n.field}' ${n.reason}`;case"removed_field":return`'${n.field}' was removed from the Domain API \u2014 ${n.cure}`}}u(B,"errorMessage");const J="declare the delegated child as its own Domain with registrar: 'external-delegated' and set 'parentDelegationRoleArn' (the CLI injects it via ManagedDomainBinding.delegationRoleArn); the child UPSERTs its NS records into the parent zone";function re(n){const e=T(n),t=k(e.registrar,N);if(t===void 0){const i=e.registrar;if(i===void 0)return a({kind:"registrar_required"});const f=typeof i=="string"?i:_(i);return a({kind:"registrar_unsupported",value:f})}const s=c(e.zoneName);if(s===void 0)return a({kind:"missing_field",field:"zoneName"});const r=U(e.records);if(!r.success)return r;const d=Q(e.certificates);if(!d.success)return d;if(e.delegations!==void 0)return a({kind:"removed_field",field:"delegations",cure:J});const o={zoneName:s,description:c(e.description),costAllocationEnvironment:c(e.costAllocationEnvironment),tags:W(e.tags),records:r.data,certificates:d.data};switch(t){case"route53":return l({...o,registrar:t,hostedZoneId:c(e.hostedZoneId)});case"external-delegated":{const i=c(e.delegatedSubdomain);if(i===void 0)return a({kind:"missing_field",field:"delegatedSubdomain"});const f=c(e.hostedZoneId);if(e.hostedZoneId!==void 0&&f===void 0)return a({kind:"invalid_literal",field:"hostedZoneId",reason:"must be a literal string zone id on external-delegated \u2014 dynamic expressions cannot be round-tripped"});const h=y(e.adoptedNameServers);if(e.adoptedNameServers!==void 0&&h===void 0)return a({kind:"invalid_literal",field:"adoptedNameServers",reason:"must be an array of literal NS hostname strings \u2014 the parent NS UPSERT writes them verbatim"});if(f===void 0!=(h===void 0))return a({kind:"invalid_literal",field:f===void 0?"hostedZoneId":"adoptedNameServers",reason:"adopting an existing child zone requires hostedZoneId and adoptedNameServers together (both-or-neither) \u2014 an imported zone exposes no name-server attribute at synth"});const S=c(e.parentDelegationRoleArn);if(e.parentDelegationRoleArn!==void 0&&S===void 0)return a({kind:"invalid_literal",field:"parentDelegationRoleArn",reason:"must be a literal string ARN (VD2-a) \u2014 the CLI injects it via ManagedDomainBinding.delegationRoleArn; dynamic expressions such as Fn.importValue are not supported"});const A=k(e.phase,x);return e.phase!==void 0&&A===void 0?a({kind:"invalid_literal",field:"phase",reason:`must be one of ${x.map(I=>`'${I}'`).join(", ")}`}):l({...o,registrar:t,delegatedSubdomain:i,hostedZoneId:f,adoptedNameServers:h,parentDelegationRoleArn:S,phase:A})}case"external-records":return l({...o,registrar:t})}}u(re,"parseDomainProps");function se(n){return B(n)}u(se,"parseDomainErrorMessage");function U(n){if(n===void 0)return l([]);if(!Array.isArray(n))return a({kind:"invalid_literal",field:"records",reason:"must be an array"});const e=[];for(let t=0;t<n.length;t++){const s=n[t];if(!g(s))return a({kind:"invalid_literal",field:`records[${t}]`,reason:"must be an object literal"});const r=G(s,t);if(!r.success)return r;e.push(r.data)}return l(e)}u(U,"parseRecordsArray");function G(n,e){const t=c(n.type),s=c(n.name);if(t===void 0)return a({kind:"missing_field",field:`records[${e}].type`});if(s===void 0)return a({kind:"missing_field",field:`records[${e}].name`});if(n.target!==void 0){if(!V.some(f=>f===t))return a({kind:"invalid_literal",field:`records[${e}]`,reason:`alias records must have type 'A' or 'AAAA', got '${t}'`});const i=H(n.target);return l({kind:"alias",type:t,name:s,target:i})}if(!P.some(i=>i===t))return a({kind:"invalid_literal",field:`records[${e}]`,reason:`unsupported record type '${t}'`});const r=Y(n.value);if(r===void 0)return a({kind:"invalid_literal",field:`records[${e}].value`,reason:`must be a string or array of strings (got ${JSON.stringify(n.value)})`});const d=$(n.ttl),o={kind:"standard",type:t,name:s,value:r,...d!==void 0?{ttl:d}:{}};return l(o)}u(G,"parseRecord");function Y(n){if(n===void 0)return;if(typeof n=="string")return n;const e=y(n);if(e!==void 0)return e}u(Y,"parseRecordValue");function H(n){if(E(n))return K(n);if(g(n)){const e=k(n.kind,C);if(e==="ecs"||e==="cdn"){const t=c(n.appName);if(t!==void 0)return{kind:e,appName:t}}if(e==="bucket"){const t=c(n.bucketName);if(t!==void 0)return{kind:e,bucketName:t}}if(e==="custom"){const t=c(n.dnsName),s=c(n.hostedZoneId);if(t!==void 0&&s!==void 0)return{kind:e,dnsName:t,hostedZoneId:s}}}return{kind:"unresolved",sourceText:_(n)}}u(H,"parseTarget");function K(n){const e=n.__call.trim(),t=e.match(/^([A-Za-z_][\w$]*)\s*\(([\s\S]*)\)\s*$/);if(!t)return{kind:"unresolved",sourceText:e};const s=t[1],r=t[2]??"",d=v(r);switch(s){case"fjallApp":{const o=p(d,0);if(o===void 0)return{kind:"dynamic",sourceText:e};if(d.length<2)return{kind:"ecs",appName:o};const i=p(d,1);return i===void 0?{kind:"dynamic",sourceText:e}:{kind:"ecs",appName:o,computeName:i}}case"fjallCdn":{const o=p(d,0);return o===void 0?{kind:"dynamic",sourceText:e}:{kind:"cdn",appName:o}}case"fjallBucket":{const o=p(d,0);return o===void 0?{kind:"dynamic",sourceText:e}:{kind:"bucket",bucketName:o}}case"aliasTo":{if(d.length>=2){const o=p(d,0),i=p(d,1);return o!==void 0&&i!==void 0?{kind:"custom",dnsName:o,hostedZoneId:i}:{kind:"dynamic",sourceText:e}}if(d.length===1){const o=d[0]?.trim()??"",i=D(o,"dnsName"),f=D(o,"hostedZoneId");return i!==void 0&&f!==void 0?{kind:"custom",dnsName:i,hostedZoneId:f}:{kind:"dynamic",sourceText:e}}return{kind:"unresolved",sourceText:e}}default:return{kind:"unresolved",sourceText:e}}}u(K,"resolveCallRefTarget");function v(n){const e=[];let t=0,s=null,r="";for(let o=0;o<n.length;o++){const i=n[o];if(s!==null){if(r+=i,i==="\\"&&o+1<n.length){const f=n[o+1];f!==void 0&&(r+=f,o+=1);continue}i===s&&(s=null);continue}if(i==='"'||i==="'"||i==="`"){s=i,r+=i;continue}if(i==="("||i==="{"||i==="["){t+=1,r+=i;continue}if(i===")"||i==="}"||i==="]"){t-=1,r+=i;continue}if(i===","&&t===0){e.push(r.trim()),r="";continue}r+=i}const d=r.trim();return d.length>0&&e.push(d),e}u(v,"splitTopLevelArgs");function p(n,e){const t=n[e];if(t===void 0)return;const s=t.trim();if(s.length<2)return;const r=s[0],d=s[s.length-1];if(r===d&&!(r!=='"'&&r!=="'"&&r!=="`"))return s.slice(1,-1)}u(p,"extractStringLiteralArg");function D(n,e){const t=n.trim().replace(/^\{|\}$/g,""),s=v(t);for(const r of s){const d=r.indexOf(":");if(d<0||r.slice(0,d).trim().replace(/["'`]/g,"")!==e)continue;const i=r.slice(d+1).trim();return p([i],0)}}u(D,"extractObjectFieldString");function Q(n){if(n===void 0)return l([]);if(!Array.isArray(n))return a({kind:"invalid_literal",field:"certificates",reason:"must be an array"});const e=[];for(let t=0;t<n.length;t++){const s=n[t];if(typeof s=="string"){e.push({domainName:s});continue}if(!g(s))return a({kind:"invalid_literal",field:`certificates[${t}]`,reason:"must be a string or object literal"});const r=c(s.domainName);if(r===void 0)return a({kind:"missing_field",field:`certificates[${t}].domainName`});const d=y(s.subjectAlternativeNames),o=b(s.transparencyLogging),i=b(s.cloudFront);if(s.cloudFront!==void 0&&i===void 0)return a({kind:"invalid_literal",field:`certificates[${t}].cloudFront`,reason:"must be a boolean literal \u2014 the CloudFront designation drives the zone-level us-east-1 export contract and cannot be round-tripped from a dynamic expression"});e.push({domainName:r,...d!==void 0?{subjectAlternativeNames:d}:{},...o!==void 0?{transparencyLogging:o}:{},...i!==void 0?{cloudFront:i}:{}})}return l(e)}u(Q,"parseCertificatesArray");function W(n){if(n===void 0||!g(n))return;const e={};for(const[t,s]of Object.entries(n)){const r=c(s);r!==void 0&&(e[t]=r)}return Object.keys(e).length===0?void 0:e}u(W,"parseStringRecord");function _(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return String(n);if(Array.isArray(n))return`[${n.map(e=>_(e)).join(", ")}]`;if(typeof n=="object"){if("__call"in n)return String(n.__call);if("__identifier"in n)return String(n.__identifier);if("__expression"in n)return String(n.__expression);if("__unknown"in n)return String(n.__unknown)}return String(n)}u(_,"stringifyParsedValue");export{ie as findDomainConstructCall,se as parseDomainErrorMessage,re as parseDomainProps,v as splitTopLevelArgs};
|
|
1
|
+
var T=Object.defineProperty;var u=(n,e)=>T(n,"name",{value:e,configurable:!0});import*as m from"typescript";import{parseObjectLiteral as $,asString as c,asStringUnion as k,asStringArray as S,asBoolean as b,asNumber as I,isCallRef as E,isParsedObject as g}from"../parsers/common/astCommonParser.js";import{success as l,failure as a}from"../../types/Result.js";import{DnsRecordTypeSchema as L}from"../../dns/types.js";import{DomainRegistrarSchema as j,DomainDeployPhaseSchema as O,AliasRecordTypeSchema as Z,TYPED_FJALL_TARGET_KINDS as C}from"../../dns/domainRecords.js";const x=j.options,N=O.options,F=L.options,V=Z.options;function z(n){const e=[],t=u(r=>{if(m.isNewExpression(r)&&P(r.expression)){const o=M(r);o!==void 0&&e.push(o)}m.forEachChild(r,t)},"visit");if(t(n),e.length===0)return l(void 0);if(e.length>1)return a(new Error(`Expected exactly one 'new Domain(...)' call per infrastructure file, found ${e.length}`));const i=e[0];return i?l(i):l(void 0)}u(z,"findDomainConstructCall");function P(n){return m.isIdentifier(n)&&n.text==="Domain"}u(P,"isDomainIdentifier");function M(n){const e=n.arguments;if(!e||e.length<3)return;const t=e[0],i=e[1],r=e[2];if(!t||!i||!r||!m.isObjectLiteralExpression(r))return;const o=q(n);if(o===void 0)return;const d=B(n),s=m.isStringLiteral(i)?i.text:void 0;return{callExpression:n,containingStatement:o,propsObjectLiteral:r,domainVarId:d,scopeArgumentText:t.getText(),constructIdLiteral:s}}u(M,"buildMatch");function q(n){let e=n;for(;e!==void 0;){if(m.isExpressionStatement(e)||m.isVariableStatement(e))return e;e=e.parent}}u(q,"findContainingTopLevelStatement");function B(n){let e=n.parent;for(;e!==void 0;){if(m.isVariableDeclaration(e)&&m.isIdentifier(e.name)&&e.initializer===n)return e.name.text;e=e.parent}}u(B,"extractDomainVarId");function J(n){switch(n.kind){case"registrar_required":return"'registrar' property is required";case"registrar_unsupported":return`'registrar' must be one of ${x.join(", ")}, got ${JSON.stringify(n.value)}`;case"missing_field":return`'${n.field}' property is required`;case"invalid_literal":return`'${n.field}' ${n.reason}`;case"removed_field":return`'${n.field}' was removed from the Domain API \u2014 ${n.cure}`}}u(J,"errorMessage");const U="declare the delegated child as its own Domain with registrar: 'external-delegated' and set 'parentDelegationRoleArn' (the CLI injects it via ManagedDomainBinding.delegationRoleArn); the child UPSERTs its NS records into the parent zone";function G(n){const e=$(n),t=k(e.registrar,x);if(t===void 0){const s=e.registrar;if(s===void 0)return a({kind:"registrar_required"});const f=typeof s=="string"?s:y(s);return a({kind:"registrar_unsupported",value:f})}const i=c(e.zoneName);if(i===void 0)return a({kind:"missing_field",field:"zoneName"});const r=Y(e.records);if(!r.success)return r;const o=W(e.certificates);if(!o.success)return o;if(e.delegations!==void 0)return a({kind:"removed_field",field:"delegations",cure:U});const d={zoneName:i,description:c(e.description),costAllocationEnvironment:c(e.costAllocationEnvironment),tags:X(e.tags),records:r.data,certificates:o.data};switch(t){case"route53":return l({...d,registrar:t,hostedZoneId:c(e.hostedZoneId)});case"external-delegated":{const s=c(e.delegatedSubdomain);if(s===void 0)return a({kind:"missing_field",field:"delegatedSubdomain"});const f=c(e.hostedZoneId);if(e.hostedZoneId!==void 0&&f===void 0)return a({kind:"invalid_literal",field:"hostedZoneId",reason:"must be a literal string zone id on external-delegated \u2014 dynamic expressions cannot be round-tripped"});const h=S(e.adoptedNameServers);if(e.adoptedNameServers!==void 0&&h===void 0)return a({kind:"invalid_literal",field:"adoptedNameServers",reason:"must be an array of literal NS hostname strings \u2014 the parent NS UPSERT writes them verbatim"});if(f===void 0!=(h===void 0))return a({kind:"invalid_literal",field:f===void 0?"hostedZoneId":"adoptedNameServers",reason:"adopting an existing child zone requires hostedZoneId and adoptedNameServers together (both-or-neither) \u2014 an imported zone exposes no name-server attribute at synth"});const _=c(e.parentDelegationRoleArn);if(e.parentDelegationRoleArn!==void 0&&_===void 0)return a({kind:"invalid_literal",field:"parentDelegationRoleArn",reason:"must be a literal string ARN (VD2-a) \u2014 the CLI injects it via ManagedDomainBinding.delegationRoleArn; dynamic expressions such as Fn.importValue are not supported"});const A=k(e.phase,N);return e.phase!==void 0&&A===void 0?a({kind:"invalid_literal",field:"phase",reason:`must be one of ${N.map(R=>`'${R}'`).join(", ")}`}):l({...d,registrar:t,delegatedSubdomain:s,hostedZoneId:f,adoptedNameServers:h,parentDelegationRoleArn:_,phase:A})}case"external-records":return l({...d,registrar:t})}}u(G,"parseDomainProps");function se(n){return J(n)}u(se,"parseDomainErrorMessage");function oe(n,e,t){const i=m.createSourceFile(e,n,m.ScriptTarget.Latest,!0,m.ScriptKind.TS),r=z(i);if(!r.success)return a(new Error(r.error.message));if(r.data===void 0)return a(new Error(`Domain '${t}': no 'new Domain(...)' call found in ${e} \u2014 the file is not a Fjall domain component.`));const o=G(r.data.propsObjectLiteral);return o.success?l(o.data):a(new Error(`Domain '${t}': infrastructure.ts could not be parsed (${o.error.kind}).`))}u(oe,"parseDomainInfrastructureSource");function Y(n){if(n===void 0)return l([]);if(!Array.isArray(n))return a({kind:"invalid_literal",field:"records",reason:"must be an array"});const e=[];for(let t=0;t<n.length;t++){const i=n[t];if(!g(i))return a({kind:"invalid_literal",field:`records[${t}]`,reason:"must be an object literal"});const r=w(i,t);if(!r.success)return r;e.push(r.data)}return l(e)}u(Y,"parseRecordsArray");function w(n,e){const t=c(n.type),i=c(n.name);if(t===void 0)return a({kind:"missing_field",field:`records[${e}].type`});if(i===void 0)return a({kind:"missing_field",field:`records[${e}].name`});if(n.target!==void 0){if(!V.some(f=>f===t))return a({kind:"invalid_literal",field:`records[${e}]`,reason:`alias records must have type 'A' or 'AAAA', got '${t}'`});const s=H(n.target);return l({kind:"alias",type:t,name:i,target:s})}if(!F.some(s=>s===t))return a({kind:"invalid_literal",field:`records[${e}]`,reason:`unsupported record type '${t}'`});const r=K(n.value);if(r===void 0)return a({kind:"invalid_literal",field:`records[${e}].value`,reason:`must be a string or array of strings (got ${JSON.stringify(n.value)})`});const o=I(n.ttl),d={kind:"standard",type:t,name:i,value:r,...o!==void 0?{ttl:o}:{}};return l(d)}u(w,"parseRecord");function K(n){if(n===void 0)return;if(typeof n=="string")return n;const e=S(n);if(e!==void 0)return e}u(K,"parseRecordValue");function H(n){if(E(n))return Q(n);if(g(n)){const e=k(n.kind,C);if(e==="ecs"||e==="cdn"){const t=c(n.appName);if(t!==void 0)return{kind:e,appName:t}}if(e==="bucket"){const t=c(n.bucketName);if(t!==void 0)return{kind:e,bucketName:t}}if(e==="custom"){const t=c(n.dnsName),i=c(n.hostedZoneId);if(t!==void 0&&i!==void 0)return{kind:e,dnsName:t,hostedZoneId:i}}}return{kind:"unresolved",sourceText:y(n)}}u(H,"parseTarget");function Q(n){const e=n.__call.trim(),t=e.match(/^([A-Za-z_][\w$]*)\s*\(([\s\S]*)\)\s*$/);if(!t)return{kind:"unresolved",sourceText:e};const i=t[1],r=t[2]??"",o=D(r);switch(i){case"fjallApp":{const d=p(o,0);if(d===void 0)return{kind:"dynamic",sourceText:e};if(o.length<2)return{kind:"ecs",appName:d};const s=p(o,1);return s===void 0?{kind:"dynamic",sourceText:e}:{kind:"ecs",appName:d,computeName:s}}case"fjallCdn":{const d=p(o,0);return d===void 0?{kind:"dynamic",sourceText:e}:{kind:"cdn",appName:d}}case"fjallBucket":{const d=p(o,0);return d===void 0?{kind:"dynamic",sourceText:e}:{kind:"bucket",bucketName:d}}case"aliasTo":{if(o.length>=2){const d=p(o,0),s=p(o,1);return d!==void 0&&s!==void 0?{kind:"custom",dnsName:d,hostedZoneId:s}:{kind:"dynamic",sourceText:e}}if(o.length===1){const d=o[0]?.trim()??"",s=v(d,"dnsName"),f=v(d,"hostedZoneId");return s!==void 0&&f!==void 0?{kind:"custom",dnsName:s,hostedZoneId:f}:{kind:"dynamic",sourceText:e}}return{kind:"unresolved",sourceText:e}}default:return{kind:"unresolved",sourceText:e}}}u(Q,"resolveCallRefTarget");function D(n){const e=[];let t=0,i=null,r="";for(let d=0;d<n.length;d++){const s=n[d];if(i!==null){if(r+=s,s==="\\"&&d+1<n.length){const f=n[d+1];f!==void 0&&(r+=f,d+=1);continue}s===i&&(i=null);continue}if(s==='"'||s==="'"||s==="`"){i=s,r+=s;continue}if(s==="("||s==="{"||s==="["){t+=1,r+=s;continue}if(s===")"||s==="}"||s==="]"){t-=1,r+=s;continue}if(s===","&&t===0){e.push(r.trim()),r="";continue}r+=s}const o=r.trim();return o.length>0&&e.push(o),e}u(D,"splitTopLevelArgs");function p(n,e){const t=n[e];if(t===void 0)return;const i=t.trim();if(i.length<2)return;const r=i[0],o=i[i.length-1];if(r===o&&!(r!=='"'&&r!=="'"&&r!=="`"))return i.slice(1,-1)}u(p,"extractStringLiteralArg");function v(n,e){const t=n.trim().replace(/^\{|\}$/g,""),i=D(t);for(const r of i){const o=r.indexOf(":");if(o<0||r.slice(0,o).trim().replace(/["'`]/g,"")!==e)continue;const s=r.slice(o+1).trim();return p([s],0)}}u(v,"extractObjectFieldString");function W(n){if(n===void 0)return l([]);if(!Array.isArray(n))return a({kind:"invalid_literal",field:"certificates",reason:"must be an array"});const e=[];for(let t=0;t<n.length;t++){const i=n[t];if(typeof i=="string"){e.push({domainName:i});continue}if(!g(i))return a({kind:"invalid_literal",field:`certificates[${t}]`,reason:"must be a string or object literal"});const r=c(i.domainName);if(r===void 0)return a({kind:"missing_field",field:`certificates[${t}].domainName`});const o=S(i.subjectAlternativeNames),d=b(i.transparencyLogging),s=b(i.cloudFront);if(i.cloudFront!==void 0&&s===void 0)return a({kind:"invalid_literal",field:`certificates[${t}].cloudFront`,reason:"must be a boolean literal \u2014 the CloudFront designation drives the zone-level us-east-1 export contract and cannot be round-tripped from a dynamic expression"});e.push({domainName:r,...o!==void 0?{subjectAlternativeNames:o}:{},...d!==void 0?{transparencyLogging:d}:{},...s!==void 0?{cloudFront:s}:{}})}return l(e)}u(W,"parseCertificatesArray");function X(n){if(n===void 0||!g(n))return;const e={};for(const[t,i]of Object.entries(n)){const r=c(i);r!==void 0&&(e[t]=r)}return Object.keys(e).length===0?void 0:e}u(X,"parseStringRecord");function y(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return String(n);if(Array.isArray(n))return`[${n.map(e=>y(e)).join(", ")}]`;if(typeof n=="object"){if("__call"in n)return String(n.__call);if("__identifier"in n)return String(n.__identifier);if("__expression"in n)return String(n.__expression);if("__unknown"in n)return String(n.__unknown)}return String(n)}u(y,"stringifyParsedValue");export{z as findDomainConstructCall,se as parseDomainErrorMessage,oe as parseDomainInfrastructureSource,G as parseDomainProps,D as splitTopLevelArgs};
|
package/dist/src/ast/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { type IdentifierRef, type ExpressionRef, type CallRef, type ParsedValue,
|
|
|
2
2
|
export { type ParsedInfrastructure, type ParsedDatabaseResource, type ParsedS3Resource, type ParsedComputeResource, type ParsedSQSResource, type ParsedCDNResource, type ParsedNetworkResource, type ParsedDynamoDBResource, type ParsedLambdaConfig, type ParsedPatternResource, type ImportInfo, type AstStatementType, type ClassifiedStatement, type CustomCodeBlock, parseInfrastructure, convertToResourcePlan, classifyStatements, extractCustomCodeBlocks, findManagedResourcePosition, getLastManagedStatementOfType, getManagedResourcesByType, } from "./parsers/orchestrator/astInfrastructureParser.js";
|
|
3
3
|
export { type SurgicalModificationResult, type InsertionOptions, type UpdateOptions, type DeleteOptions, addResourceSurgically, updateResourceSurgically, removeResourceSurgically, } from "./mutation/astSurgicalModification.js";
|
|
4
4
|
export { type FileValidationResult, ensureImports, injectCustomCodeBlocks, validateModifiedFile, } from "./mutation/astCodeInjection.js";
|
|
5
|
-
export { type DomainCallMatch, type ParsedFjallTarget, type ParsedDnsRecordFromAst, type ParsedCertificateFromAst, type ParsedDomainProps, type ParsedRoute53ApexDomainProps, type ParsedExternalDelegatedDomainProps, type ParsedExternalRecordsDomainProps, type ParseDomainError, findDomainConstructCall, parseDomainProps, parseDomainErrorMessage, splitTopLevelArgs, } from "./domain/astDomainParser.js";
|
|
5
|
+
export { type DomainCallMatch, type ParsedFjallTarget, type ParsedDnsRecordFromAst, type ParsedCertificateFromAst, type ParsedDomainProps, type ParsedRoute53ApexDomainProps, type ParsedExternalDelegatedDomainProps, type ParsedExternalRecordsDomainProps, type ParseDomainError, findDomainConstructCall, parseDomainProps, parseDomainErrorMessage, parseDomainInfrastructureSource, splitTopLevelArgs, } from "./domain/astDomainParser.js";
|
package/dist/src/ast/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isPlainObject as s,isIdentifierRef as
|
|
1
|
+
import{isPlainObject as s,isIdentifierRef as a,isExpressionRef as o,isCallRef as t,isParsedObject as i,asString as n,asNumber as c,asBoolean as u,asStringArray as l,asStringUnion as p,captureExtraProperties as f}from"./parsers/common/astCommonParser.js";import{parseInfrastructure as d,convertToResourcePlan as g,classifyStatements as R,extractCustomCodeBlocks as S,findManagedResourcePosition as x,getLastManagedStatementOfType as y,getManagedResourcesByType as C}from"./parsers/orchestrator/astInfrastructureParser.js";import{addResourceSurgically as M,updateResourceSurgically as v,removeResourceSurgically as B}from"./mutation/astSurgicalModification.js";import{ensureImports as I,injectCustomCodeBlocks as T,validateModifiedFile as b}from"./mutation/astCodeInjection.js";import{findDomainConstructCall as E,parseDomainProps as O,parseDomainErrorMessage as k,parseDomainInfrastructureSource as A,splitTopLevelArgs as L}from"./domain/astDomainParser.js";export{M as addResourceSurgically,u as asBoolean,c as asNumber,n as asString,l as asStringArray,p as asStringUnion,f as captureExtraProperties,R as classifyStatements,g as convertToResourcePlan,I as ensureImports,S as extractCustomCodeBlocks,E as findDomainConstructCall,x as findManagedResourcePosition,y as getLastManagedStatementOfType,C as getManagedResourcesByType,T as injectCustomCodeBlocks,t as isCallRef,o as isExpressionRef,a as isIdentifierRef,i as isParsedObject,s as isPlainObject,k as parseDomainErrorMessage,A as parseDomainInfrastructureSource,O as parseDomainProps,d as parseInfrastructure,B as removeResourceSurgically,L as splitTopLevelArgs,v as updateResourceSurgically,b as validateModifiedFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var I=Object.defineProperty;var u=(r,a)=>I(r,"name",{value:a,configurable:!0});import*as h from"typescript";import{asString as t,asStringArray as S,asStringUnion as b,captureExtraProperties as _,findFirstInAst as v,isFactoryBuildCall as x,isFactoryMethodCall as E,isIdentifierRef as G,isParsedObject as N,parseObjectLiteral as H}from"../common/astCommonParser.js";function L(r){if(r.arguments.length<2)return null;const a=r.arguments[0],i=r.arguments[1];return!h.isStringLiteral(a)||!h.isObjectLiteralExpression(i)?null:{resourceName:a.text,config:H(i),node:r}}u(L,"extractCDNResource");function T(r,a,i){const m=a.find(c=>c.variableName===r);if(m)return m.resourceName;const n=i.find(c=>c.variableName===r||c.resourceName.charAt(0).toLowerCase()+c.resourceName.slice(1)===r);return n?n.resourceName:r}u(T,"resolveOriginIdentifier");const O=["CACHING_OPTIMIZED","CACHING_DISABLED"];function R(r){return v(r,a=>{if(!h.isCallExpression(a)||!E(a,"addCdn"))return;const i=a.arguments[0];if(x(i,"CdnFactory"))return L(i)??void 0})}u(R,"findCDNResource");function j(r,a,i){if(!r)return;const m=r,n=m.config,c=u(e=>G(e)?T(e.__identifier,a,i):t(e)??"","resolveOrigin"),C=t(n.originType)==="alb";let g;if(C){const e=c(n.loadBalancer),o=i.some(f=>f.resourceName===e),l=t(n.protocolPolicy);if(!o||l!=="HTTP_ONLY")throw new Error(`CDN '${m.resourceName}': only the generated alb lane is plan-mappable \u2014 originType "alb" with loadBalancer referencing a compute declared in this app and protocolPolicy "HTTP_ONLY". Reshape the statement to that form, or manage this CDN outside the generator lane.`);g=e}else g=c(n.origin);const s={name:m.resourceName,defaultOriginRef:g};if(Array.isArray(n.behaviours)){const e=n.behaviours.filter(N).map(o=>({pathPattern:t(o.pathPattern)??"",originRef:c(o.origin),...b(o.cachePolicy,O)!==void 0&&{cachePolicy:b(o.cachePolicy,O)}}));e.length>0&&(s.behaviours=e)}const y=t(n.customDomain);if(y)s.customDomain=y;else{const e=S(n.domainNames);e&&e.length>0&&(s.customDomain=e[0])}const A=t(n.certificateArn);A&&(s.certificateArn=A);const p=t(n.originHostname);p&&(s.originHostname=p);let D=!1;if(N(n.domainConfig)){const e=n.domainConfig,o=t(e.domainName);o!==void 0&&Object.keys(e).every(f=>f==="domainName"||f==="record")&&(e.record===void 0||t(e.record)==="alias")&&(s.domain=o,D=!0)}if(n.accessGate!==void 0){if(n.accessGate===!1)s.accessGate=!1;else if(N(n.accessGate)){const e=n.accessGate,o=t(e.type),l=t(e.username),f=t(e.password);o==="basic-auth"&&l&&f&&(s.accessGate={type:"basic-auth",username:l,password:f})}}const d=new Set(["originType","origin","behaviours","customDomain","domainNames","certificateArn","accessGate"]);D&&d.add("domainConfig"),C&&(d.add("loadBalancer"),d.add("protocolPolicy")),p&&d.add("originHostname");const P=_(n,d);return P.length>0&&(s.extraProperties=P),s}u(j,"convertCDNResource");export{j as convertCDNResource,R as findCDNResource};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var v=Object.defineProperty;var
|
|
1
|
+
var v=Object.defineProperty;var f=(e,n)=>v(e,"name",{value:n,configurable:!0});import*as E from"typescript";import{asString as a,asNumber as y,asBoolean as m,asStringArray as u,asStringUnion as d,captureExtraProperties as T,collectFromAst as _,extractVariableName as b,isFactoryBuildCall as A,isFactoryMethodCall as x,isParsedObject as S,parseObjectLiteral as O}from"../common/astCommonParser.js";import{COMPUTE_ARCHITECTURES as D,COMPUTE_TYPES as R,DEPLOYMENT_TYPES as Y,EC2_INSTANCE_TYPES as K,FUNCTION_URL_AUTH_TYPES as U}from"../../../schemas/constants.js";import{assignIfDefined as c,extractCallStringArg as F,extractClusterConfig as L,extractEnumString as N,isEnvironmentRecord as h,parseEcsService as k}from"./astComputeParserHelpers.js";import{inferDatabaseConnectionsFromEnv as H,inferStorageConnectionsFromEnv as V,resolveConnectedDatabaseNames as I,resolveConnectedStorageNames as M}from"./astComputeConnectionParser.js";function W(e){if(e.arguments.length<2)return null;const n=e.arguments[0],i=e.arguments[1];if(!E.isStringLiteral(n)||!E.isObjectLiteralExpression(i))return null;const t=n.text,r=O(i);return{resourceName:t,type:a(r.type)??"ecs",config:r,node:e}}f(W,"extractComputeResource");function Z(e){return _(e,n=>{if(!E.isCallExpression(n)||!x(n,"addCompute"))return null;const i=n.arguments[0];if(!A(i,"ComputeFactory"))return null;const t=W(i);if(t){const r=b(n);r&&(t.variableName=r)}return t})}f(Z,"findComputeResources");function C(e,n,i){const t=T(e.config,i);t.length>0&&(n.extraProperties=t)}f(C,"applyExtras");function z(e,n){const i=e.config.docker;if(S(i)){const o=a(i.path),g=a(i.context),l=a(i.target);(o!==void 0||g!==void 0||l!==void 0)&&(n.docker={...o!==void 0&&{path:o},...g!==void 0&&{context:g},...l!==void 0&&{target:l}})}const t=e.config.cluster;t!==void 0&&(n.cluster=L(t));const r=e.config.services;r!==void 0&&Array.isArray(r)&&(n.services=r.filter(o=>S(o)).map(k)),C(e,n,new Set(["type","ecrRepository","docker","cluster","services","connections"]))}f(z,"convertEcsCompute");function p(e,n){if(c(n,"deployment",d(e.config.deployment,Y)),c(n,"timeout",y(e.config.timeout)),c(n,"memory",y(e.config.memorySize)??y(e.config.memory)),c(n,"handler",a(e.config.handler)),c(n,"runtime",N(e.config.runtime,"Runtime")),h(e.config.environment)&&(n.environment=e.config.environment),h(e.config.secrets))n.secrets=e.config.secrets;else{const s=u(e.config.secrets);s&&(n.ssmSecrets=s)}const i=e.config.functionUrl;if(S(i)){const s=d(N(i.authType,"FunctionUrlAuthType"),U);s!==void 0&&(n.functionUrl={authType:s})}const t=e.config.code;if(t!==void 0){const s=F(t);s&&(n.codePath=s)}c(n,"description",a(e.config.description)??a(e.config.lambdaDescription)),c(n,"architecture",d(N(e.config.architecture,"Architecture"),D)),c(n,"ephemeralStorageSize",y(e.config.ephemeralStorageSize)),c(n,"functionName",a(e.config.functionName)),c(n,"ssmSecretsPath",a(e.config.ssmSecretsPath)),C(e,n,new Set(["type","deployment","timeout","memorySize","memory","handler","runtime","environment","secrets","functionUrl","code","connections","ecrRepository","containerSecretsImport","secretsImport","lambdaDescription","description","architecture","ephemeralStorageSize","functionName","ssmSecretsPath"]))}f(p,"convertLambdaCompute");function B(e,n){c(n,"instanceType",d(e.config.instanceType,K));const i=e.config.ssh;i===!1?n.enableSSH=!1:i!==void 0&&S(i)?n.enableSSH=!0:c(n,"enableSSH",m(e.config.enableSSH)),c(n,"keyName",a(e.config.keyName)),c(n,"userData",a(e.config.userData)),e.config.securityGroups!==void 0&&(n.securityGroups=u(e.config.securityGroups)),C(e,n,new Set(["type","instanceType","ssh","enableSSH","keyName","userData","securityGroups","connections"]))}f(B,"convertEc2Compute");function G(e,n,i,t){let r=n.config.connections;if(!r&&Array.isArray(n.config.services)){const g=n.config.services[0];S(g)&&(r=g.connections)}if(!r)return;const s=I(r,i);s.length>0&&(e.needsConnection=!0,e.connectedDatabase=s);const o=M(r,t);o.length>0&&(e.connectedStorage=o)}f(G,"applyConnectionConfig");function j(e,n){({ecs:z,lambda:p,ec2:B})[e.type]?.(n,e)}f(j,"applyTypeSpecificConfig");function $(e,n,i,t){return e.map(r=>{const s=d(r.config.type,R)??"ecs",o={name:r.resourceName,type:s,needsConnection:!1,connectedDatabase:[],...r.variableName&&{variableName:r.variableName}};return G(o,r,n,i),j(o,r),H(o,r.config.services,t.database),V(o,r.config.services,t.s3),o})}f($,"convertComputeResources");export{$ as convertComputeResources,Z as findComputeResources};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type namedTypes as n } from "ast-types";
|
|
2
|
+
import type { StructuredValue } from "../../../projection/index.js";
|
|
2
3
|
import { type Result } from "../../../types/Result.js";
|
|
3
4
|
import { type ObjectPropertyInput, type QuoteStyle } from "../../fileRewriter/index.js";
|
|
4
5
|
import type { EmittedProp } from "../../emitProjection.js";
|
|
@@ -40,5 +41,12 @@ export declare const RESERVED_IDENTIFIER_NAMES: ReadonlySet<string>;
|
|
|
40
41
|
* they land in does not parse.
|
|
41
42
|
*/
|
|
42
43
|
export declare function buildEmittedValue(prop: EmittedProp, quoteStyle: QuoteStyle): Result<n.Property["value"], InvalidPropertyError>;
|
|
44
|
+
/**
|
|
45
|
+
* Serialise a {@link StructuredValue} to its AST node — the ONE place
|
|
46
|
+
* structured expressions become source. Every identifier segment is
|
|
47
|
+
* validated; literals go through {@link toAstValue}; object entries reuse
|
|
48
|
+
* `buildObjectProperty`, which quotes keys that are not valid identifiers.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildStructuredValue(key: string, value: StructuredValue, quoteStyle: QuoteStyle): Result<n.Property["value"], InvalidPropertyError>;
|
|
43
51
|
export declare function toAstValue(value: unknown, quoteStyle: QuoteStyle): n.Property["value"] | undefined;
|
|
44
52
|
export declare function makeStringLiteral(value: string, quote: QuoteStyle): n.StringLiteral;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var E=Object.defineProperty;var u=(e,r)=>E(e,"name",{value:r,configurable:!0});import{builders as o}from"ast-types";import{failure as a,success as c}from"../../../types/Result.js";import{buildObjectProperty as b}from"../../fileRewriter/index.js";function P(e,r){const i=[];for(const n of e){const t=w(n,r);if(!t.success)return a(t.error);i.push({key:n.key,value:t.data})}return c(i)}u(P,"buildPropertyInputs");const h=/^[A-Za-z_$][A-Za-z0-9_$]*$/,g=new Set(["await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","implements","interface","package","private","protected","public","let","static","eval","arguments"]);function w(e,r){if(e.kind==="expression")return h.test(e.source)?g.has(e.source)?a({kind:"InvalidPropertyError",property:e.key,reason:`\`${e.key}\` resolved to \`${e.source}\`, which is a JavaScript reserved word \u2014 no binding can carry that name, so splicing it would write a file that does not parse.`}):c(o.identifier(e.source)):a({kind:"InvalidPropertyError",property:e.key,reason:`\`${e.key}\` resolved to the expression \`${e.source}\`, which is not a bare identifier; this emitter only splices the name of a live binding.`});if(e.kind==="structured")return d(e.key,e.expression,r);const i=f(e.value,r);return i===void 0?a({kind:"InvalidPropertyError",property:e.key,reason:`Unsupported property value for "${e.key}" (accepts string/number/boolean/null/array/object of the same).`}):c(i)}u(w,"buildEmittedValue");function p(e,r){if(!h.test(r))return{kind:"InvalidPropertyError",property:e,reason:`\`${e}\` produced the expression segment \`${r}\`, which is not a bare identifier; structured expressions emit validated identifier segments only.`};if(g.has(r))return{kind:"InvalidPropertyError",property:e,reason:`\`${e}\` produced the expression segment \`${r}\`, which is a JavaScript reserved word \u2014 emitting it would write a file that does not parse.`}}u(p,"identifierSegmentRefusal");function y(e){return{kind:"InvalidPropertyError",property:e,reason:`Unsupported property value for "${e}" (accepts string/number/boolean/null/array/object of the same).`}}u(y,"unsupportedLiteralRefusal");function d(e,r,i){switch(r.kind){case"primary-binding":return a({kind:"InvalidPropertyError",property:e,reason:`\`${e}\` carries an unsubstituted primary-binding marker \u2014 only a sibling statement's props may reference the primary construct, and the sibling engine substitutes the marker before anything is built.`});case"literal":{const n=f(r.value,i);return n===void 0?a(y(e)):c(n)}case"identifier":{const n=p(e,r.name);return n!==void 0?a(n):c(o.identifier(r.name))}case"member":{const n=p(e,r.property);if(n!==void 0)return a(n);const t=d(e,r.object,i);return t.success?c(o.memberExpression(t.data,o.identifier(r.property),!1)):t}case"call":{const n=d(e,r.callee,i);if(!n.success)return n;const t=[];for(const s of r.args){if(s.kind==="identifier"){const m=p(e,s.name);if(m!==void 0)return a(m);t.push(o.identifier(s.name));continue}const l=f(s.value,i);if(l===void 0)return a(y(e));t.push(l)}return c(o.callExpression(n.data,t))}case"object":{const n=[];for(const t of r.entries){const s=d(e,t.value,i);if(!s.success)return s;n.push(b(t.key,s.data,i))}return c(o.objectExpression(n))}case"array":{const n=[];for(const t of r.elements){const s=d(e,t,i);if(!s.success)return s;n.push(s.data)}return c(o.arrayExpression(n))}}}u(d,"buildStructuredValue");function f(e,r){if(typeof e=="string")return x(e,r);if(typeof e=="number"&&Number.isFinite(e))return o.numericLiteral(e);if(typeof e=="boolean")return o.booleanLiteral(e);if(e===null)return o.nullLiteral();if(Array.isArray(e)){const i=[];for(const n of e){const t=f(n,r);if(t===void 0)return;i.push(t)}return o.arrayExpression(i)}if(typeof e=="object"&&e!==null){const i=[];for(const[n,t]of Object.entries(e)){const s=f(t,r);if(s===void 0)return;i.push(b(n,s,r))}return o.objectExpression(i)}}u(f,"toAstValue");function x(e,r){const i=r==="single"?"'":'"',n=r==="single"?e.replace(/\\/g,"\\\\").replace(/'/g,"\\'"):e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),t=`${i}${n}${i}`;return o.stringLiteral.from({value:e,extra:{rawValue:e,raw:t}})}u(x,"makeStringLiteral");export{g as RESERVED_IDENTIFIER_NAMES,w as buildEmittedValue,P as buildPropertyInputs,d as buildStructuredValue,x as makeStringLiteral,f as toAstValue};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type namedTypes as n } from "ast-types";
|
|
2
|
+
import { type Result } from "../../../types/Result.js";
|
|
3
|
+
import type { EmittedSibling } from "../../emitProjection.js";
|
|
4
|
+
import { type QuoteStyle } from "../../fileRewriter/index.js";
|
|
5
|
+
import type { InvalidPropertyError } from "../../types.js";
|
|
6
|
+
import { type NodeShapeLike, type ObjectExpressionNodeLike } from "../modifyResource/literalConversion.js";
|
|
7
|
+
import type { PendingDeclaration } from "../siblingBindingResolution.js";
|
|
8
|
+
export interface SiblingEmissionPlan {
|
|
9
|
+
/** Sibling statements in derivation order, ready to splice after the
|
|
10
|
+
* primary statement. */
|
|
11
|
+
statements: n.ExpressionStatement[];
|
|
12
|
+
/**
|
|
13
|
+
* Set when a sibling prop references the primary construct: the caller must
|
|
14
|
+
* bind the primary statement under this name (`const <name> = app.<m>(…)`)
|
|
15
|
+
* — the substituted identifiers below point at it.
|
|
16
|
+
*/
|
|
17
|
+
primaryBindingName?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface PlanSiblingEmissionParams {
|
|
20
|
+
siblings: ReadonlyArray<EmittedSibling>;
|
|
21
|
+
body: NodeShapeLike[];
|
|
22
|
+
appIdentifier: string;
|
|
23
|
+
resourceName: string;
|
|
24
|
+
quoteStyle: QuoteStyle;
|
|
25
|
+
/**
|
|
26
|
+
* The `const` names this edit's pending wrap plans will declare. The body
|
|
27
|
+
* check below sees only PRE-mutation declarations, so a primary binding
|
|
28
|
+
* whose name a pending wrap already claims (`"Uploads"` and a connected
|
|
29
|
+
* `"uploads"` both derive `uploads`) must be refused here — applied
|
|
30
|
+
* together they write a file that does not parse.
|
|
31
|
+
*/
|
|
32
|
+
pendingDeclarations?: ReadonlyArray<PendingDeclaration>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the emitted siblings to AST statements, or the refusal that stops
|
|
36
|
+
* the add. Every refusal is attributed to the PLAN key that asked for the
|
|
37
|
+
* sibling, so the operator sees the flag they typed, never a derived
|
|
38
|
+
* construct id they did not.
|
|
39
|
+
*/
|
|
40
|
+
export declare function planSiblingEmission(params: PlanSiblingEmissionParams): Result<SiblingEmissionPlan, InvalidPropertyError>;
|
|
41
|
+
/**
|
|
42
|
+
* True when any statement already carries `<recv>.<appMethod>("<id>", …)` for
|
|
43
|
+
* this sibling — wherever it sits (bare, `const`-bound, export-wrapped): the
|
|
44
|
+
* construct id is what collides at synth, not the statement shape.
|
|
45
|
+
*
|
|
46
|
+
* The scan matches only string-literal first arguments, so a same-id
|
|
47
|
+
* construct written as a template literal is invisible to it.
|
|
48
|
+
*
|
|
49
|
+
* Exported for the projection gate, which asserts the PRESENCE of derived
|
|
50
|
+
* sibling statements in fallback output through the same matcher the add
|
|
51
|
+
* path uses to refuse duplicates — two matchers would disagree on exactly
|
|
52
|
+
* the shapes that matter.
|
|
53
|
+
*/
|
|
54
|
+
export declare function bodyCarriesSibling(body: NodeShapeLike[], sibling: Pick<EmittedSibling, "appMethod" | "constructId">): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The props object (second argument) of the sibling's emitted call, when the
|
|
57
|
+
* body carries the sibling and that argument is a plain object literal.
|
|
58
|
+
* Exported for the projection gate, which verifies the emitted statement
|
|
59
|
+
* carries every derived prop key — through the same matcher as above.
|
|
60
|
+
*/
|
|
61
|
+
export declare function siblingCallPropsObject(body: NodeShapeLike[], sibling: Pick<EmittedSibling, "appMethod" | "constructId">): ObjectExpressionNodeLike | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=Object.defineProperty;var s=(e,t)=>m(e,"name",{value:t,configurable:!0});import{toVariableName as y}from"../../../generation/common.js";import{failure as u,success as b}from"../../../types/Result.js";import{buildAppMethodStatement as h}from"../../fileRewriter/index.js";import{isNodeShape as f}from"../modifyResource/literalConversion.js";import{visit as g}from"../objectGraph.js";import{appMethodNameOf as k,moduleScopeDeclares as w}from"../resourceStatementLocator.js";import{buildPropertyInputs as E,RESERVED_IDENTIFIER_NAMES as I}from"./propertyBuilder.js";function A(e){for(const r of e.siblings)if($(e.body,r))return u({kind:"InvalidPropertyError",property:r.planKey,reason:`\`${r.planKey}\` expands into the statement \`app.${r.appMethod}("${r.constructId}", \u2026)\`, and this file already carries one \u2014 the two would collide at synth. Remove or rename the existing statement, or drop the key.`});const t=e.siblings.find(r=>r.props.some(i=>i.kind==="structured"&&c(i.expression)));let n;if(t!==void 0){const r=y(e.resourceName);if(I.has(r))return u({kind:"InvalidPropertyError",property:t.planKey,reason:`\`${t.planKey}\` references the primary construct, which must be bound as \`const ${r}\` \u2014 but \`${r}\` is a JavaScript reserved word, so the binding would write a file that does not parse. Rename the resource.`});if(w(e.body,r))return u({kind:"InvalidPropertyError",property:t.planKey,reason:`\`${t.planKey}\` references the primary construct, which must be bound as \`const ${r}\` \u2014 but this file already declares \`${r}\`. Rename the resource or the existing binding.`});const i=e.pendingDeclarations?.find(o=>o.variableName===r);if(i!==void 0)return u({kind:"InvalidPropertyError",property:t.planKey,reason:`\`${t.planKey}\` references the primary construct, which must be bound as \`const ${r}\` \u2014 but this add already binds the connected resource "${i.resourceName}" under that name ("${e.resourceName}" and "${i.resourceName}" derive the same variable), and declaring it twice would write a file that does not parse. Rename one of the two resources.`});n=r}const a=[];for(const r of e.siblings){const i=n===void 0?r.props:S(r.props,n),o=E(i,e.quoteStyle);if(!o.success)return u(o.error);a.push(h({appIdentifier:e.appIdentifier,appMethod:r.appMethod,name:r.constructId,properties:o.data,quoteStyle:e.quoteStyle}))}return b({statements:a,...n!==void 0&&{primaryBindingName:n}})}s(A,"planSiblingEmission");function $(e,t){return p(e,t)!==void 0}s($,"bodyCarriesSibling");function C(e,t){const n=p(e,t);if(n===void 0)return;const a=n.arguments;if(!Array.isArray(a))return;const r=a[1];if(!(!f(r)||r.type!=="ObjectExpression"))return r}s(C,"siblingCallPropsObject");function p(e,t){let n;for(const a of e)if(g(a,r=>{if(n!==void 0||r.type!=="CallExpression"||k(r)!==t.appMethod)return;const i=r.arguments;if(!Array.isArray(i))return;const o=i[0];f(o)&&(o.type!=="StringLiteral"&&o.type!=="Literal"||o.value===t.constructId&&(n=r))}),n!==void 0)return n}s(p,"findSiblingCall");function c(e){switch(e.kind){case"primary-binding":return!0;case"member":return c(e.object);case"call":return c(e.callee);case"object":return e.entries.some(t=>c(t.value));case"array":return e.elements.some(c);case"literal":case"identifier":return!1}}s(c,"valueReferencesPrimary");function S(e,t){return e.map(n=>n.kind==="structured"?{...n,expression:d(n.expression,t)}:n)}s(S,"substitutePrimaryInProps");function d(e,t){switch(e.kind){case"literal":return e;case"object":return{kind:"object",entries:e.entries.map(n=>({key:n.key,value:d(n.value,t)}))};case"array":return{kind:"array",elements:e.elements.map(n=>d(n,t))};default:return l(e,t)}}s(d,"substituteValue");function l(e,t){switch(e.kind){case"primary-binding":return{kind:"identifier",name:t};case"member":return{...e,object:l(e.object,t)};case"call":return{...e,callee:l(e.callee,t)};case"identifier":return e}}s(l,"substituteExpression");export{$ as bodyCarriesSibling,A as planSiblingEmission,C as siblingCallPropsObject};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Q=Object.defineProperty;var S=(t,e)=>Q(t,"name",{value:e,configurable:!0});import{builders as P}from"ast-types";import{failure as a,success as M}from"../../types/Result.js";import{DEFAULT_FILE_PATH as W,computeLinesDelta as U,extractProgramBody as R}from"../_internal.js";import{evaluateEmitGuard as _}from"../emitGuard.js";import{collectImportSpecifiers as j,projectEmittedProperties as q}from"../emitProjection.js";import{buildAppMethodWrappedStatement as O,buildFactoryStatement as H,detectQuoteStyle as Y,parse as z,printFile as J}from"../fileRewriter/index.js";import{STATEMENT_REGISTRY as V,constructIdFor as X}from"../registry.js";import{locateAllShapes as Z,locateByShape as ee}from"../semanticIndex/index.js";import{checkControlFlowPolicy as re}from"./controlFlowPolicy.js";import{driftGate as ae,runPipeline as te,schemaGate as ne}from"../validationGate/index.js";import{resolveAppBindingName as ie}from"./addResource/appBinding.js";import{buildUnmanagedDuplicateError as oe}from"./unmanagedShapeErrors.js";import{buildResourceLocations as se,indexBody as de,orderByEndPos as pe,resolveInsertIndex as ce}from"./addResource/bodyIndex.js";import{buildPropertyInputs as le}from"./addResource/propertyBuilder.js";import{planSiblingEmission as me}from"./addResource/siblingEmission.js";import{ensureBarrelSpecifiers as ue}from"./ensureImports.js";import{findInsertionPosition as fe}from"./findInsertionPosition.js";import{applyBinding as ye}from"./resourceStatementLocator.js";import{createSiblingBindingResolution as ge,findPendingWrapCollision as Ee}from"./siblingBindingResolution.js";function $e(t,e,A={}){const h=e.filePath??W,s=z(t,h);if(!s.success)return a(s.error);const i=ee(t,{type:e.type,name:e.name},h);if(!i.success)return i.error.kind==="TemplateLiteralNameError"?a(i.error):a({kind:"SemanticQueryError",reason:i.error.reason,cause:i.error.cause});if(i.data!==void 0){if(i.data.managed===!1)return a(oe(e.type,i.data.symbolName));const r=re({ast:s.data,target:i.data,resource:{type:e.type,name:e.name},op:"add"});if(r.refusal!==void 0)return a(r.refusal);const n=te([ae],{content:t,plan:{type:e.type,name:e.name,properties:e.properties,op:"add"},baseline:A.baseline,policy:e.driftPolicy});return n.success?n.data.action==="skip"?M({content:t,linesChanged:{added:0,removed:0},skipped:!0}):a({kind:"DuplicateResourceError",type:e.type,name:e.name}):a(L(n.error))}const f=Y(s.data),l=ge(e.type,()=>R(s.data)),m=q(e.type,e.properties,{resourceName:e.name,resolveBinding:l.resolveBinding,resolveBindings:l.resolveBindings});if("refusal"in m)return a(m.refusal);const I=Ee(l.pendingDeclarations());if(I!==void 0){const{first:r,second:n}=I,$=r.planKey!==void 0?`\`${r.planKey}\``:"another property",G=n.planKey!==void 0?`\`${n.planKey}\``:"this add";return a({kind:"InvalidPropertyError",property:n.planKey??r.planKey??e.name,reason:`${G} binds "${n.resourceName}" as \`const ${n.variableName}\` \u2014 but ${$} already binds "${r.resourceName}" under that name in this add (both names derive the same variable), and declaring it twice would write a file that does not parse. Rename one of the two resources.`})}const b=le(m.props,f);if(!b.success)return a(b.error);const o=R(s.data);if(o===void 0)return a({kind:"SemanticQueryError",reason:"recast File is missing program.body"});const d=V[e.type],v=_(d.emitGuard,e.properties);if(v!==void 0)return a(v);const k=ne.run({content:t,plan:{type:e.type,name:e.name,properties:e.properties,op:"add"}});if(!k.success)return a(L(k.error));const B={factory:d.factoryIdentifier,name:X(e.type,e.name,e.properties),properties:b.data,quoteStyle:f},y=m.siblings??[],N=d.emitWrapper?.appMethod??y[0]?.appMethod;let p;if(N!==void 0&&(p=ie(o),p===void 0))return a({kind:"MissingAppInitError",type:e.type,appMethod:N});let g;d.emitWrapper!==void 0&&p!==void 0?g=O({...B,appIdentifier:p,appMethod:d.emitWrapper.appMethod}):g=H(B);let E={statements:[]};if(y.length>0&&p!==void 0){const r=me({siblings:y,body:o,appIdentifier:p,resourceName:e.name,quoteStyle:f,pendingDeclarations:l.pendingDeclarations()});if(!r.success)return a(r.error);E=r.data}const u=de(o,t),c=Z(t,h);if(!c.success)return c.error.kind==="TemplateLiteralNameError"?a(c.error):a({kind:"SemanticQueryError",reason:c.error.reason,cause:c.error.cause});const T=se(u.anchors,c.data),x=pe([...u.appInitLocations,...T]),C=fe(u.importInfos,x,e.type,u.programEnd),w=ce(u.anchors,C);for(const r of l.takePendingWraps())ye(o,r);const F=E.primaryBindingName===void 0?g:P.variableDeclaration("const",[P.variableDeclarator(P.identifier(E.primaryBindingName),g.expression)]);o.splice(w,0,F),E.statements.forEach((r,n)=>{o.splice(w+1+n,0,r)}),ue(o,[d.factoryIdentifier,...j([...m.props,...y.flatMap(r=>r.props)])],f);const D=J(s.data,t),K=U(t,D);return M({content:D,linesChanged:K})}S($e,"addResource");function L(t){switch(t.kind){case"ParseError":case"TemplateLiteralNameError":case"DuplicateResourceError":case"InvalidPropertyError":case"SemanticQueryError":case"MissingAppInitError":case"DriftConflictError":case"ControlFlowClassifierError":return t;default:return{kind:"SemanticQueryError",reason:`Unexpected codemod error in validation-gate pipeline: ${t.kind}`}}}S(L,"narrowGateError");export{$e as addResource};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var B=Object.defineProperty;var p=(n,e)=>B(n,"name",{value:e,configurable:!0});import{builders as y}from"ast-types";import{CREDENTIAL_KEYS as T,DATABASE_ACCESSORS as v,DATABASE_ENV_VARS as E,DATABASE_SSL_VALUE as V}from"../../generation/database.js";import{MESSAGING_ENV_VARS as F}from"../../generation/messagingConnections.js";import{STORAGE_ACCESSORS as K,STORAGE_ENV_VARS as A}from"../../generation/storageConnections.js";import{connectionEnvSuffix as W,connectionKeyOrdinal as w}from"../../generation/common.js";import{failure as d,success as S}from"../../types/Result.js";import{DEFAULT_FILE_PATH as G,computeLinesDelta as H,extractProgramBody as z}from"../_internal.js";import{buildObjectProperty as U,detectQuoteStyle as Y,parse as J,printFile as Q}from"../fileRewriter/index.js";import{FACTORY_IDENTIFIERS as I,STATEMENT_REGISTRY as X}from"../registry.js";import{makeStringLiteral as P}from"./addResource/propertyBuilder.js";import{findLastPlainPropertyIndex as _,isArrayExpression as Z,locateContainer as q,locateServiceByName as ee}from"./computeServiceLocator.js";import{isNodeShape as g,readKeyName as x}from"./modifyResource/literalConversion.js";import{objectAbsenceIsProvable as $,pushPropertyPreservingComma as ne}from"./objectGraph.js";import{applyBinding as te,appMethodNameOf as re,planBinding as oe,unwrapExportDeclaration as ie}from"./resourceStatementLocator.js";const j=Object.freeze({database:I.database,storage:I.storage});function O(n){const e=X[n].emitWrapper?.appMethod;if(e===void 0)throw new Error(`No app method registered for statement type "${n}"`);return e}p(O,"requireAppMethod");const k=Object.freeze({database:O("database"),storage:O("storage")}),M=new Map([[k.database,0],[k.storage,1],[O("messaging"),2]]);function Pe(n,e){const t=e.filePath??G,{resourceType:o,resourceName:r}=e,i=[...new Set(e.serviceNames)];if(i.length===0)return d({kind:"UnsupportedConnectionShapeError",reason:"No target services were supplied."});const a=J(n,t);if(!a.success)return d(a.error);const s=z(a.data);if(s===void 0)return d({kind:"UnsupportedConnectionShapeError",reason:"recast File is missing program.body"});const c=oe(s,{factory:j[o],appMethod:k[o]},r);if(!c.success)return d(ae(c.error,o,r));const{variableName:u}=c.data,l=[],h=[];for(const m of i){const C=se(s,m,u,o);if(!C.success)return d(C.error);if(C.data==="already-connected"){l.push(m);continue}h.push(C.data)}const f=l.map(m=>`Service "${m}" already lists "${u}" in its \`connections\` array \u2014 left untouched.`);for(const m of h)m.container===void 0&&f.push(`Service "${m.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(h.length===0)return S({content:n,linesChanged:{added:0,removed:0},variableName:u,wiredServices:[],skipped:!0,warnings:f});const b=Y(a.data),L=le(s);te(s,c.data);for(const m of h)ue(m,u,o,b,L);const R=Q(a.data,n);return S({content:R,linesChanged:H(n,R),variableName:u,wiredServices:h.map(m=>m.serviceName),skipped:!1,warnings:f})}p(Pe,"connectResourceToCompute");function ae(n,e,t){switch(n.kind){case"statement-not-found":return{kind:"ResourceStatementNotFoundError",resourceType:e,resourceName:t};case"ambiguous":return{kind:"AmbiguousResourceStatementError",resourceType:e,resourceName:t,count:n.count};case"multiple-declarators":return{kind:"UnsupportedConnectionShapeError",reason:`The statement declaring "${t}" carries multiple declarators \u2014 the binding cannot be identified.`};case"pattern-binding":return{kind:"UnsupportedConnectionShapeError",reason:`The statement declaring "${t}" binds a pattern, not an identifier.`};case"unreadable-name":return{kind:"UnsupportedConnectionShapeError",reason:`The binding for "${t}" has no readable name.`};case"init-not-app-method-wrap":return{kind:"UnsupportedConnectionShapeError",reason:`The binding for "${t}" is not a direct \`app.${k[e]}(${j[e]}.build(...))\` call \u2014 the bound value is not the construct \`connections\` needs.`};case"unbindable-statement":return{kind:"UnsupportedConnectionShapeError",reason:`The statement containing "${t}" is a ${n.statementType}, which cannot be bound to a const.`};case"not-app-method-call":return{kind:"UnsupportedConnectionShapeError",reason:`The statement containing "${t}" is not an app-method call \u2014 there is no construct value to bind.`};case"bare-factory-call":return{kind:"UnsupportedConnectionShapeError",reason:`"${t}" is a bare factory call not wrapped in an app method \u2014 there is no construct value to bind.`};case"foreign-wrapper":return{kind:"UnsupportedConnectionShapeError",reason:`The statement containing "${t}" is not a direct \`app.${k[e]}(...)\` call \u2014 binding it would wire a value \`connections\` cannot use.`};case"name-conflict":return{kind:"VariableNameConflictError",variableName:n.variableName};case"reserved-word":return{kind:"UnsupportedConnectionShapeError",reason:`Binding "${t}" would derive the variable name "${n.variableName}", a JavaScript reserved word no \`const\` can carry \u2014 bind the statement to a const of your own naming, or rename the resource.`}}}p(ae,"mapLocatorFailure");function se(n,e,t,o){const r=ee(n,e);if(!r.success){const f=r.error;return f.kind==="AmbiguousService"?d({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:`${String(f.count)} services share the name "${e}" across ComputeFactory.build calls \u2014 the edit cannot be proven to target the right one.`}):d({kind:"ConnectServiceNotFoundError",serviceName:e,knownServices:f.knownServices})}const i=r.data,a=q(i,0);let s;if(a.success)s=a.data;else switch(a.error.kind){case"ContainerNotObjectLiteral":return d({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:"The first container is not an object literal."});case"ContainersNotStaticArray":return d({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 d({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 c=ce(i,e,t);if(!c.success)return d(c.error);if(c.data.alreadyConnected)return S("already-connected");let u,l,h="";if(s!==void 0){const f=N(s,"environment",e);if(!f.success)return d(f.error);const b=N(s,"secretsImport",e);if(!b.success)return d(b.error);u=f.data,l=b.data,h=de(o,[...f.data.keys,...b.data.keys])}return S({serviceName:e,service:i,container:s,environment:u,secretsImport:l,suffix:h,connectionsArray:c.data.array})}p(se,"planService");function ce(n,e,t){const o=_(n,"connections");if(o===-1)return $(n,"connections")?S({array:void 0,alreadyConnected:!1}):d({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=n.properties[o]?.value;if(!Z(r))return d({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:"`connections` is not an array literal."});for(const i of r.elements)if(g(i)){if(i.type==="Identifier"){if(i.name===t)return S({array:r,alreadyConnected:!0});continue}return d({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:`\`connections\` contains a ${i.type}, so "${t}" cannot be proven absent from it.`})}return S({array:r,alreadyConnected:!1})}p(ce,"inspectConnections");function N(n,e,t){const o=_(n,e);if(o===-1)return $(n,e)?S({obj:void 0,keys:[]}):d({kind:"UnsupportedConnectionShapeError",serviceName:t,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=n.properties[o]?.value;if(!g(r)||r.type!=="ObjectExpression")return d({kind:"UnsupportedConnectionShapeError",serviceName:t,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 d({kind:"UnsupportedConnectionShapeError",serviceName:t,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 d({kind:"UnsupportedConnectionShapeError",serviceName:t,reason:`\`${e}\` contains a computed key.`});const c=x(s.key);c!==void 0&&a.push(c)}return S({obj:i,keys:a})}p(N,"collectWiringTarget");function de(n,e){const t=Object.values(n==="database"?E:A),o=new Set;for(const r of e)for(const i of t){const a=w(r,i);a!==void 0&&o.add(a)}return W(o.size===0?0:Math.max(...o))}p(de,"nextConnectionSuffix");function pe(n,e,t,o){const r=p((s,c,u=[])=>y.callExpression(y.memberExpression(s,y.identifier(c),!1),u),"call"),i=p(()=>y.identifier(e),"variable");if(n==="storage")return[{key:`${A.NAME}${t}`,value:r(i(),K.BUCKET_NAME),target:"environment"}];const a=p(s=>r(r(i(),v.CREDENTIALS),v.IMPORT,[P(s,o)]),"credential");return[{key:`${E.HOST}${t}`,value:r(i(),v.HOST),target:"environment"},{key:`${E.PORT}${t}`,value:r(i(),v.PORT),target:"environment"},{key:`${E.NAME}${t}`,value:r(i(),v.NAME),target:"environment"},{key:`${E.SSL}${t}`,value:P(V,o),target:"environment"},{key:`${E.USERNAME}${t}`,value:a(T.USERNAME),target:"secretsImport"},{key:`${E.PASSWORD}${t}`,value:a(T.PASSWORD),target:"secretsImport"}]}p(pe,"buildWiringEntries");function ue(n,e,t,o,r){if(n.connectionsArray!==void 0){const c=fe(n.connectionsArray,t,r);n.connectionsArray.elements.splice(c,0,y.identifier(e))}else D(n.service,"connections",y.arrayExpression([y.identifier(e)]),o);const i=n.container;if(i===void 0)return;const a=pe(t,e,n.suffix,o),s=[{key:"environment",state:n.environment},{key:"secretsImport",state:n.secretsImport}];for(const{key:c,state:u}of s){const l=a.filter(h=>h.target===c);l.length!==0&&Se(i,c,u,l,o)}}p(ue,"applyServiceWiring");function fe(n,e,t){const o=M.get(k[e])??0;for(let r=0;r<n.elements.length;r++){const i=n.elements[r];if(!g(i)||i.type!=="Identifier")continue;const a=i.name;if(typeof a!="string")continue;const s=t.get(a);if(s!==void 0&&s>o)return r}return n.elements.length}p(fe,"connectionInsertIndex");function le(n){const e=new Map;for(const t of n){const o=ie(t);if(o===void 0||o.type!=="VariableDeclaration")continue;const r=o.declarations;if(Array.isArray(r))for(const i of r){if(!g(i))continue;const a=i.id,s=i.init;if(!g(a)||a.type!=="Identifier"||!g(s))continue;const c=a.name;if(typeof c!="string")continue;const u=re(s);if(u===void 0)continue;const l=M.get(u);l!==void 0&&e.set(c,l)}}return e}p(le,"collectConnectionRanks");const me=Object.freeze([...Object.values(E),...Object.values(A),...Object.values(F)]);function he(n){let e=-1;for(let t=0;t<n.properties.length;t++){const o=n.properties[t];if(o===void 0||o.type!=="Property"&&o.type!=="ObjectProperty"||o.computed===!0)continue;const r=x(o.key);if(r===void 0)continue;me.some(a=>w(r,a)!==void 0)&&(e=t)}return e===-1?n.properties.length:e+1}p(he,"connectionEntryInsertIndex");function Se(n,e,t,o,r){const i=o.map(c=>U(c.key,c.value,r)),a=t?.obj;if(a===void 0){D(n,e,y.objectExpression(i),r);return}const s=he(a);a.properties.splice(s,0,...i)}p(Se,"insertObjectEntries");function D(n,e,t,o){const r=U(e,t,o);ne(n,r)}p(D,"appendProperty");export{Pe as connectResourceToCompute};
|
|
1
|
+
var L=Object.defineProperty;var p=(n,e)=>L(n,"name",{value:e,configurable:!0});import{builders as b}from"ast-types";import{CONNECTION_TYPE_ORDER as V,DATABASE_ACCESSORS as O,DATABASE_ENV_VARS as w,MESSAGING_ENV_VARS as B,STORAGE_ENV_VARS as T,buildConnectionWiringEntries as F}from"../../generation/connectionWiring.js";import{connectionEnvSuffix as K,connectionKeyOrdinal as R}from"../../generation/common.js";import{failure as d,success as y}from"../../types/Result.js";import{DEFAULT_FILE_PATH as W,computeLinesDelta as z,extractProgramBody as G}from"../_internal.js";import{buildObjectProperty as x,detectQuoteStyle as H,parse as Y,printFile as J}from"../fileRewriter/index.js";import{FACTORY_IDENTIFIERS as I,STATEMENT_REGISTRY as Q}from"../registry.js";import{makeStringLiteral as $}from"./addResource/propertyBuilder.js";import{findLastPlainPropertyIndex as U,isArrayExpression as X,locateContainer as Z,locateServiceByName as q}from"./computeServiceLocator.js";import{isNodeShape as S,readKeyName as P}from"./modifyResource/literalConversion.js";import{objectAbsenceIsProvable as k,pushPropertyPreservingComma as ee}from"./objectGraph.js";import{applyBinding as ne,appMethodNameOf as te,planBinding as re,unwrapExportDeclaration as oe}from"./resourceStatementLocator.js";const _=Object.freeze({database:I.database,storage:I.storage});function v(n){const e=Q[n].emitWrapper?.appMethod;if(e===void 0)throw new Error(`No app method registered for statement type "${n}"`);return e}p(v,"requireAppMethod");const C=Object.freeze({database:v("database"),storage:v("storage")}),j=new Map(V.map((n,e)=>[v(n),e]));function Ie(n,e){const t=e.filePath??W,{resourceType:r,resourceName:o}=e,i=[...new Set(e.serviceNames)];if(i.length===0)return d({kind:"UnsupportedConnectionShapeError",reason:"No target services were supplied."});const a=Y(n,t);if(!a.success)return d(a.error);const s=G(a.data);if(s===void 0)return d({kind:"UnsupportedConnectionShapeError",reason:"recast File is missing program.body"});const c=re(s,{factory:_[r],appMethod:C[r]},o);if(!c.success)return d(ie(c.error,r,o));const{variableName:u}=c.data,l=[],m=[];for(const h of i){const g=ae(s,h,u,r);if(!g.success)return d(g.error);if(g.data==="already-connected"){l.push(h);continue}m.push(g.data)}const f=l.map(h=>`Service "${h}" already lists "${u}" in its \`connections\` array \u2014 left untouched.`);for(const h of m)h.container===void 0&&f.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(m.length===0)return y({content:n,linesChanged:{added:0,removed:0},variableName:u,wiredServices:[],skipped:!0,warnings:f});const E=H(a.data),D=le(s);ne(s,c.data);for(const h of m)ue(h,u,r,E,D);const A=J(a.data,n);return y({content:A,linesChanged:z(n,A),variableName:u,wiredServices:m.map(h=>h.serviceName),skipped:!1,warnings:f})}p(Ie,"connectResourceToCompute");function ie(n,e,t){switch(n.kind){case"statement-not-found":return{kind:"ResourceStatementNotFoundError",resourceType:e,resourceName:t};case"ambiguous":return{kind:"AmbiguousResourceStatementError",resourceType:e,resourceName:t,count:n.count};case"multiple-declarators":return{kind:"UnsupportedConnectionShapeError",reason:`The statement declaring "${t}" carries multiple declarators \u2014 the binding cannot be identified.`};case"pattern-binding":return{kind:"UnsupportedConnectionShapeError",reason:`The statement declaring "${t}" binds a pattern, not an identifier.`};case"unreadable-name":return{kind:"UnsupportedConnectionShapeError",reason:`The binding for "${t}" has no readable name.`};case"init-not-app-method-wrap":return{kind:"UnsupportedConnectionShapeError",reason:`The binding for "${t}" is not a direct \`app.${C[e]}(${_[e]}.build(...))\` call \u2014 the bound value is not the construct \`connections\` needs.`};case"unbindable-statement":return{kind:"UnsupportedConnectionShapeError",reason:`The statement containing "${t}" is a ${n.statementType}, which cannot be bound to a const.`};case"not-app-method-call":return{kind:"UnsupportedConnectionShapeError",reason:`The statement containing "${t}" is not an app-method call \u2014 there is no construct value to bind.`};case"bare-factory-call":return{kind:"UnsupportedConnectionShapeError",reason:`"${t}" is a bare factory call not wrapped in an app method \u2014 there is no construct value to bind.`};case"foreign-wrapper":return{kind:"UnsupportedConnectionShapeError",reason:`The statement containing "${t}" is not a direct \`app.${C[e]}(...)\` call \u2014 binding it would wire a value \`connections\` cannot use.`};case"name-conflict":return{kind:"VariableNameConflictError",variableName:n.variableName};case"reserved-word":return{kind:"UnsupportedConnectionShapeError",reason:`Binding "${t}" would derive the variable name "${n.variableName}", a JavaScript reserved word no \`const\` can carry \u2014 bind the statement to a const of your own naming, or rename the resource.`}}}p(ie,"mapLocatorFailure");function ae(n,e,t,r){const o=q(n,e);if(!o.success){const f=o.error;return f.kind==="AmbiguousService"?d({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:`${String(f.count)} services share the name "${e}" across ComputeFactory.build calls \u2014 the edit cannot be proven to target the right one.`}):d({kind:"ConnectServiceNotFoundError",serviceName:e,knownServices:f.knownServices})}const i=o.data,a=Z(i,0);let s;if(a.success)s=a.data;else switch(a.error.kind){case"ContainerNotObjectLiteral":return d({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:"The first container is not an object literal."});case"ContainersNotStaticArray":return d({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:"`containers` is not a static array literal, so the container to wire cannot be located."});case"NoContainersArray":if(!k(i,"containers"))return d({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 c=se(i,e,t);if(!c.success)return d(c.error);if(c.data.alreadyConnected)return y("already-connected");let u,l,m="";if(s!==void 0){const f=M(s,"environment",e);if(!f.success)return d(f.error);const E=M(s,"secretsImport",e);if(!E.success)return d(E.error);u=f.data,l=E.data,m=ce(r,[...f.data.keys,...E.data.keys])}return y({serviceName:e,service:i,container:s,environment:u,secretsImport:l,suffix:m,connectionsArray:c.data.array})}p(ae,"planService");function se(n,e,t){const r=U(n,"connections");if(r===-1)return k(n,"connections")?y({array:void 0,alreadyConnected:!1}):d({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 o=n.properties[r]?.value;if(!X(o))return d({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:"`connections` is not an array literal."});for(const i of o.elements)if(S(i)){if(i.type==="Identifier"){if(i.name===t)return y({array:o,alreadyConnected:!0});continue}return d({kind:"UnsupportedConnectionShapeError",serviceName:e,reason:`\`connections\` contains a ${i.type}, so "${t}" cannot be proven absent from it.`})}return y({array:o,alreadyConnected:!1})}p(se,"inspectConnections");function M(n,e,t){const r=U(n,e);if(r===-1)return k(n,e)?y({obj:void 0,keys:[]}):d({kind:"UnsupportedConnectionShapeError",serviceName:t,reason:`The first container carries a spread, shorthand or computed key that could supply \`${e}\` invisibly, so an absent property cannot be proven.`});const o=n.properties[r]?.value;if(!S(o)||o.type!=="ObjectExpression")return d({kind:"UnsupportedConnectionShapeError",serviceName:t,reason:`\`${e}\` is not an object literal.`});const i=o,a=[];for(const s of i.properties){if(s.type==="SpreadElement"||s.type==="SpreadProperty")return d({kind:"UnsupportedConnectionShapeError",serviceName:t,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 d({kind:"UnsupportedConnectionShapeError",serviceName:t,reason:`\`${e}\` contains a computed key.`});const c=P(s.key);c!==void 0&&a.push(c)}return y({obj:i,keys:a})}p(M,"collectWiringTarget");function ce(n,e){const t=Object.values(n==="database"?w:T),r=new Set;for(const o of e)for(const i of t){const a=R(o,i);a!==void 0&&r.add(a)}return K(r.size===0?0:Math.max(...r))}p(ce,"nextConnectionSuffix");function de(n,e,t,r){return F(n,t).map(o=>({key:o.key,value:pe(o.value,e,r),target:o.target}))}p(de,"buildWiringEntries");function pe(n,e,t){const r=p((o,i,a=[])=>b.callExpression(b.memberExpression(o,b.identifier(i),!1),a),"call");switch(n.kind){case"accessor":return r(b.identifier(e),n.method);case"credential":return r(r(b.identifier(e),O.CREDENTIALS),O.IMPORT,[$(n.credentialKey,t)]);case"literal":return $(n.value,t)}}p(pe,"wiringValueNode");function ue(n,e,t,r,o){if(n.connectionsArray!==void 0){const c=fe(n.connectionsArray,t,o);n.connectionsArray.elements.splice(c,0,b.identifier(e))}else N(n.service,"connections",b.arrayExpression([b.identifier(e)]),r);const i=n.container;if(i===void 0)return;const a=de(t,e,n.suffix,r),s=[{key:"environment",state:n.environment},{key:"secretsImport",state:n.secretsImport}];for(const{key:c,state:u}of s){const l=a.filter(m=>m.target===c);l.length!==0&&be(i,c,u,l,r)}}p(ue,"applyServiceWiring");function fe(n,e,t){const r=j.get(C[e])??0;for(let o=0;o<n.elements.length;o++){const i=n.elements[o];if(!S(i)||i.type!=="Identifier")continue;const a=i.name;if(typeof a!="string")continue;const s=t.get(a);if(s!==void 0&&s>r)return o}return n.elements.length}p(fe,"connectionInsertIndex");function le(n){const e=new Map;for(const t of n){const r=oe(t);if(r===void 0||r.type!=="VariableDeclaration")continue;const o=r.declarations;if(Array.isArray(o))for(const i of o){if(!S(i))continue;const a=i.id,s=i.init;if(!S(a)||a.type!=="Identifier"||!S(s))continue;const c=a.name;if(typeof c!="string")continue;const u=te(s);if(u===void 0)continue;const l=j.get(u);l!==void 0&&e.set(c,l)}}return e}p(le,"collectConnectionRanks");const he=Object.freeze([...Object.values(w),...Object.values(T),...Object.values(B)]);function me(n){let e=-1;for(let t=0;t<n.properties.length;t++){const r=n.properties[t];if(r===void 0||r.type!=="Property"&&r.type!=="ObjectProperty"||r.computed===!0)continue;const o=P(r.key);if(o===void 0)continue;he.some(a=>R(o,a)!==void 0)&&(e=t)}return e===-1?n.properties.length:e+1}p(me,"connectionEntryInsertIndex");function be(n,e,t,r,o){const i=r.map(c=>x(c.key,c.value,o)),a=t?.obj;if(a===void 0){N(n,e,b.objectExpression(i),o);return}const s=me(a);a.properties.splice(s,0,...i)}p(be,"insertObjectEntries");function N(n,e,t,r){const o=x(e,t,r);ee(n,o)}p(N,"appendProperty");export{Ie as connectResourceToCompute};
|