@suss/manifest-aws 0.33.1 → 0.34.1
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/README.md +2 -2
- package/dist/index.d.cts +40 -43
- package/dist/index.d.ts +40 -43
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,11 +4,11 @@ Part of [suss](https://github.com/nimbuscloud-ai/suss), which reads both sides o
|
|
|
4
4
|
|
|
5
5
|
Reads a CloudFormation or SAM template into plain data: the resources, what each one declares, the globals every function inherits, the nested stacks, and the ARNs and event patterns written across them.
|
|
6
6
|
|
|
7
|
-
Two kinds of reader work from that data. `@suss/contract-cloudformation` and `@suss/contract-serverless` turn a template into summaries
|
|
7
|
+
Two kinds of reader work from that data. `@suss/contract-cloudformation` and `@suss/contract-serverless` turn a template into summaries. The Lambda pack pairs a handler in code with the route or queue the template assigns to it. Both used to parse the template themselves, and they disagreed about its contents.
|
|
8
8
|
|
|
9
9
|
## Where it fits
|
|
10
10
|
|
|
11
|
-
It depends on `@suss/
|
|
11
|
+
It depends on `@suss/ir-core` and a YAML parser. It produces plain data, and the readers build summaries from it. The readers also decide what each resource means, and this package leaves that to them.
|
|
12
12
|
|
|
13
13
|
## More
|
|
14
14
|
|
package/dist/index.d.cts
CHANGED
|
@@ -2,13 +2,12 @@ import YAML from 'yaml';
|
|
|
2
2
|
export { ParsedHandler, parseHandler } from '@suss/ir-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Parses a CloudFormation or SAM template file into a plain object,
|
|
6
|
+
* resolving the shorthand YAML tags CFN uses for intrinsics.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* intrinsic tags, lives here instead of being repeated per consumer.
|
|
8
|
+
* The contract readers and the code-side handler pairing both load
|
|
9
|
+
* templates through this module, so YAML and JSON parsing and intrinsic
|
|
10
|
+
* tag handling are written once.
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
interface CloudFormationResource {
|
|
@@ -51,18 +50,18 @@ declare function loadCloudFormationTemplate(templatePath: string): CloudFormatio
|
|
|
51
50
|
declare function refTarget(value: unknown): string | null;
|
|
52
51
|
|
|
53
52
|
/**
|
|
54
|
-
*
|
|
53
|
+
* Works out which GraphQL field each Lambda serves.
|
|
55
54
|
*
|
|
56
55
|
* AppSync does not wire a field to a handler in code. The template does it,
|
|
57
56
|
* over three hops: a resolver points at a pipeline function, the function
|
|
58
57
|
* points at a data source, and the data source points at a Lambda. Both ways
|
|
59
|
-
* of writing that are
|
|
60
|
-
* AWS::Serverless::GraphQLApi shorthand whose DataSources, Functions
|
|
58
|
+
* of writing that are read here: the raw AWS::AppSync::* resources, and the
|
|
59
|
+
* SAM AWS::Serverless::GraphQLApi shorthand whose DataSources, Functions and
|
|
61
60
|
* Resolvers blocks the transform expands into those same resources.
|
|
62
61
|
*
|
|
63
|
-
* Like the rest of this package,
|
|
62
|
+
* Like the rest of this package, it reports only what the template says.
|
|
64
63
|
* Whether a field has an implementation, and whether that implementation
|
|
65
|
-
* matches the schema, is
|
|
64
|
+
* matches the schema, is left to the reader that consumes these bindings.
|
|
66
65
|
*/
|
|
67
66
|
|
|
68
67
|
/** One GraphQL field and the Lambdas behind it. */
|
|
@@ -84,8 +83,8 @@ interface AppSyncResolverBinding {
|
|
|
84
83
|
declare function readAppSyncResolvers(template: CloudFormationTemplate): AppSyncResolverBinding[];
|
|
85
84
|
|
|
86
85
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
86
|
+
* Resolves the references AWS manifests use to point at a queue, a topic,
|
|
87
|
+
* or a bucket, down to the channel string suss keys the boundary on.
|
|
89
88
|
*
|
|
90
89
|
* Every manifest language that targets AWS writes a reference one of three
|
|
91
90
|
* ways: as a CFN intrinsic (`!Ref X`, `!GetAtt X.Arn`), as a plain ARN
|
|
@@ -100,9 +99,9 @@ declare function readAppSyncResolvers(template: CloudFormationTemplate): AppSync
|
|
|
100
99
|
* so a queue ARN, a topic ARN, and a bucket ARN all resolve through the
|
|
101
100
|
* same code.
|
|
102
101
|
*
|
|
103
|
-
* Returns null
|
|
104
|
-
*
|
|
105
|
-
*
|
|
102
|
+
* Returns null for any other intrinsic, such as `Fn::ImportValue` or
|
|
103
|
+
* `Fn::Join`, since resolving those needs a stack this package does not
|
|
104
|
+
* read. A `Ref` to a parameter comes back as the parameter's name.
|
|
106
105
|
*/
|
|
107
106
|
declare function resolveResourceChannel(value: unknown, service: string): string | null;
|
|
108
107
|
/**
|
|
@@ -122,8 +121,8 @@ declare function resolveTopicChannel(value: unknown): string | null;
|
|
|
122
121
|
declare function resolveBucketChannel(value: unknown): string | null;
|
|
123
122
|
|
|
124
123
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
124
|
+
* Reads what an EventBridge rule says about the events it matches, and
|
|
125
|
+
* which bus those events arrive on.
|
|
127
126
|
*
|
|
128
127
|
* A rule's EventPattern and its EventBusName are written the same way in a
|
|
129
128
|
* CloudFormation template and in a serverless.yml eventBridge event, so
|
|
@@ -143,9 +142,9 @@ type PatternReduction = {
|
|
|
143
142
|
};
|
|
144
143
|
/**
|
|
145
144
|
* Reduce a rule's EventPattern to the exact set of DetailTypes it
|
|
146
|
-
* matches.
|
|
147
|
-
*
|
|
148
|
-
* unresolvable,
|
|
145
|
+
* matches. Only a literal `detail-type` array reduces. Anything else,
|
|
146
|
+
* such as a missing detail-type, a content filter or an empty array,
|
|
147
|
+
* comes back unresolvable with a reason, and the checker reports it.
|
|
149
148
|
*/
|
|
150
149
|
declare function reduceEventPattern(pattern: unknown): PatternReduction;
|
|
151
150
|
/**
|
|
@@ -157,9 +156,9 @@ declare function reduceEventPattern(pattern: unknown): PatternReduction;
|
|
|
157
156
|
declare function resolveEventBusToken(value: unknown): string;
|
|
158
157
|
|
|
159
158
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
159
|
+
* Folds the SAM `Globals` section into the resources that inherit from it,
|
|
160
|
+
* so every reader sees one set of properties per resource and none of them
|
|
161
|
+
* has to know that `Globals` exists.
|
|
163
162
|
*
|
|
164
163
|
* SAM applies a section's properties to each resource of the matching type,
|
|
165
164
|
* and the resource's own value wins where both declare one, per
|
|
@@ -167,8 +166,8 @@ declare function resolveEventBusToken(value: unknown): string;
|
|
|
167
166
|
*
|
|
168
167
|
* That page has the combining rules too. A map is merged key by key, a list
|
|
169
168
|
* becomes the section's entries followed by the resource's, and anything
|
|
170
|
-
* else is replaced outright.
|
|
171
|
-
* one environment variable of its own still
|
|
169
|
+
* else is replaced outright. Because maps merge by key, a function that sets
|
|
170
|
+
* one environment variable of its own still gets the section's others.
|
|
172
171
|
*/
|
|
173
172
|
|
|
174
173
|
/**
|
|
@@ -180,16 +179,15 @@ declare function resourcesWithGlobals(template: CloudFormationTemplate): Record<
|
|
|
180
179
|
/**
|
|
181
180
|
* Per function logical id, the environment variables the `Function`
|
|
182
181
|
* section supplies that the function does not declare for itself. A
|
|
183
|
-
* consumer that treats a function's environment as
|
|
184
|
-
* needs the difference, because
|
|
185
|
-
*
|
|
186
|
-
* function.
|
|
182
|
+
* consumer that treats a function's environment as that function's
|
|
183
|
+
* contract needs the difference, because every function in the document
|
|
184
|
+
* receives these variables.
|
|
187
185
|
*/
|
|
188
186
|
declare function inheritedEnvVars(template: CloudFormationTemplate): Record<string, string[]>;
|
|
189
187
|
|
|
190
188
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
189
|
+
* Reads a template and every child template it embeds, as a list of
|
|
190
|
+
* documents.
|
|
193
191
|
*
|
|
194
192
|
* A stack resource points at another template, and CloudFormation deploys that
|
|
195
193
|
* template's resources alongside the parent's. Each document keeps its own
|
|
@@ -199,7 +197,7 @@ declare function inheritedEnvVars(template: CloudFormationTemplate): Record<stri
|
|
|
199
197
|
*
|
|
200
198
|
* A child's reference to one of its own parameters is not followed to what the
|
|
201
199
|
* parent bound, and a `Fn::GetAtt` on a stack resource is not followed to the
|
|
202
|
-
* child's output. Both point at
|
|
200
|
+
* child's output. Both point at no resource, like any other unresolved reference.
|
|
203
201
|
*/
|
|
204
202
|
|
|
205
203
|
/**
|
|
@@ -254,7 +252,7 @@ interface TemplateTree {
|
|
|
254
252
|
* The root template plus every template it embeds, directly or through
|
|
255
253
|
* another child.
|
|
256
254
|
*
|
|
257
|
-
* A missing or malformed
|
|
255
|
+
* A missing or malformed root template throws, matching
|
|
258
256
|
* `loadCloudFormationTemplate`: the caller asked for that file by name.
|
|
259
257
|
* A child that cannot be read never throws; it lands in `unfollowed` so
|
|
260
258
|
* the caller can report which one and why.
|
|
@@ -271,16 +269,15 @@ declare function qualifiedLogicalId(stackPath: string[], logicalId: string): str
|
|
|
271
269
|
declare function unfollowedStackMessage(stack: UnfollowedStack): string;
|
|
272
270
|
|
|
273
271
|
/**
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
272
|
+
* Reads AWS::Serverless::Function resources into a code-facing view:
|
|
273
|
+
* which module and export each function points at, and which route and
|
|
274
|
+
* non-route Events it declares.
|
|
277
275
|
*
|
|
278
|
-
* The
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* Events) stay here rather than being reconstructed in a framework pack.
|
|
276
|
+
* The contract readers expand SAM Events into API Gateway route summaries.
|
|
277
|
+
* The code-side pairing needs something else from the template: where each
|
|
278
|
+
* handler's implementation is, and which routes it is bound to. CodeUri
|
|
279
|
+
* inheritance from Globals and the difference between Api and HttpApi
|
|
280
|
+
* Events are handled here, so a framework pack does not work them out again.
|
|
284
281
|
*/
|
|
285
282
|
|
|
286
283
|
/** A route-bearing SAM Event (`Type: Api` or `Type: HttpApi`). */
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,12 @@ import YAML from 'yaml';
|
|
|
2
2
|
export { ParsedHandler, parseHandler } from '@suss/ir-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Parses a CloudFormation or SAM template file into a plain object,
|
|
6
|
+
* resolving the shorthand YAML tags CFN uses for intrinsics.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* intrinsic tags, lives here instead of being repeated per consumer.
|
|
8
|
+
* The contract readers and the code-side handler pairing both load
|
|
9
|
+
* templates through this module, so YAML and JSON parsing and intrinsic
|
|
10
|
+
* tag handling are written once.
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
interface CloudFormationResource {
|
|
@@ -51,18 +50,18 @@ declare function loadCloudFormationTemplate(templatePath: string): CloudFormatio
|
|
|
51
50
|
declare function refTarget(value: unknown): string | null;
|
|
52
51
|
|
|
53
52
|
/**
|
|
54
|
-
*
|
|
53
|
+
* Works out which GraphQL field each Lambda serves.
|
|
55
54
|
*
|
|
56
55
|
* AppSync does not wire a field to a handler in code. The template does it,
|
|
57
56
|
* over three hops: a resolver points at a pipeline function, the function
|
|
58
57
|
* points at a data source, and the data source points at a Lambda. Both ways
|
|
59
|
-
* of writing that are
|
|
60
|
-
* AWS::Serverless::GraphQLApi shorthand whose DataSources, Functions
|
|
58
|
+
* of writing that are read here: the raw AWS::AppSync::* resources, and the
|
|
59
|
+
* SAM AWS::Serverless::GraphQLApi shorthand whose DataSources, Functions and
|
|
61
60
|
* Resolvers blocks the transform expands into those same resources.
|
|
62
61
|
*
|
|
63
|
-
* Like the rest of this package,
|
|
62
|
+
* Like the rest of this package, it reports only what the template says.
|
|
64
63
|
* Whether a field has an implementation, and whether that implementation
|
|
65
|
-
* matches the schema, is
|
|
64
|
+
* matches the schema, is left to the reader that consumes these bindings.
|
|
66
65
|
*/
|
|
67
66
|
|
|
68
67
|
/** One GraphQL field and the Lambdas behind it. */
|
|
@@ -84,8 +83,8 @@ interface AppSyncResolverBinding {
|
|
|
84
83
|
declare function readAppSyncResolvers(template: CloudFormationTemplate): AppSyncResolverBinding[];
|
|
85
84
|
|
|
86
85
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
86
|
+
* Resolves the references AWS manifests use to point at a queue, a topic,
|
|
87
|
+
* or a bucket, down to the channel string suss keys the boundary on.
|
|
89
88
|
*
|
|
90
89
|
* Every manifest language that targets AWS writes a reference one of three
|
|
91
90
|
* ways: as a CFN intrinsic (`!Ref X`, `!GetAtt X.Arn`), as a plain ARN
|
|
@@ -100,9 +99,9 @@ declare function readAppSyncResolvers(template: CloudFormationTemplate): AppSync
|
|
|
100
99
|
* so a queue ARN, a topic ARN, and a bucket ARN all resolve through the
|
|
101
100
|
* same code.
|
|
102
101
|
*
|
|
103
|
-
* Returns null
|
|
104
|
-
*
|
|
105
|
-
*
|
|
102
|
+
* Returns null for any other intrinsic, such as `Fn::ImportValue` or
|
|
103
|
+
* `Fn::Join`, since resolving those needs a stack this package does not
|
|
104
|
+
* read. A `Ref` to a parameter comes back as the parameter's name.
|
|
106
105
|
*/
|
|
107
106
|
declare function resolveResourceChannel(value: unknown, service: string): string | null;
|
|
108
107
|
/**
|
|
@@ -122,8 +121,8 @@ declare function resolveTopicChannel(value: unknown): string | null;
|
|
|
122
121
|
declare function resolveBucketChannel(value: unknown): string | null;
|
|
123
122
|
|
|
124
123
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
124
|
+
* Reads what an EventBridge rule says about the events it matches, and
|
|
125
|
+
* which bus those events arrive on.
|
|
127
126
|
*
|
|
128
127
|
* A rule's EventPattern and its EventBusName are written the same way in a
|
|
129
128
|
* CloudFormation template and in a serverless.yml eventBridge event, so
|
|
@@ -143,9 +142,9 @@ type PatternReduction = {
|
|
|
143
142
|
};
|
|
144
143
|
/**
|
|
145
144
|
* Reduce a rule's EventPattern to the exact set of DetailTypes it
|
|
146
|
-
* matches.
|
|
147
|
-
*
|
|
148
|
-
* unresolvable,
|
|
145
|
+
* matches. Only a literal `detail-type` array reduces. Anything else,
|
|
146
|
+
* such as a missing detail-type, a content filter or an empty array,
|
|
147
|
+
* comes back unresolvable with a reason, and the checker reports it.
|
|
149
148
|
*/
|
|
150
149
|
declare function reduceEventPattern(pattern: unknown): PatternReduction;
|
|
151
150
|
/**
|
|
@@ -157,9 +156,9 @@ declare function reduceEventPattern(pattern: unknown): PatternReduction;
|
|
|
157
156
|
declare function resolveEventBusToken(value: unknown): string;
|
|
158
157
|
|
|
159
158
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
159
|
+
* Folds the SAM `Globals` section into the resources that inherit from it,
|
|
160
|
+
* so every reader sees one set of properties per resource and none of them
|
|
161
|
+
* has to know that `Globals` exists.
|
|
163
162
|
*
|
|
164
163
|
* SAM applies a section's properties to each resource of the matching type,
|
|
165
164
|
* and the resource's own value wins where both declare one, per
|
|
@@ -167,8 +166,8 @@ declare function resolveEventBusToken(value: unknown): string;
|
|
|
167
166
|
*
|
|
168
167
|
* That page has the combining rules too. A map is merged key by key, a list
|
|
169
168
|
* becomes the section's entries followed by the resource's, and anything
|
|
170
|
-
* else is replaced outright.
|
|
171
|
-
* one environment variable of its own still
|
|
169
|
+
* else is replaced outright. Because maps merge by key, a function that sets
|
|
170
|
+
* one environment variable of its own still gets the section's others.
|
|
172
171
|
*/
|
|
173
172
|
|
|
174
173
|
/**
|
|
@@ -180,16 +179,15 @@ declare function resourcesWithGlobals(template: CloudFormationTemplate): Record<
|
|
|
180
179
|
/**
|
|
181
180
|
* Per function logical id, the environment variables the `Function`
|
|
182
181
|
* section supplies that the function does not declare for itself. A
|
|
183
|
-
* consumer that treats a function's environment as
|
|
184
|
-
* needs the difference, because
|
|
185
|
-
*
|
|
186
|
-
* function.
|
|
182
|
+
* consumer that treats a function's environment as that function's
|
|
183
|
+
* contract needs the difference, because every function in the document
|
|
184
|
+
* receives these variables.
|
|
187
185
|
*/
|
|
188
186
|
declare function inheritedEnvVars(template: CloudFormationTemplate): Record<string, string[]>;
|
|
189
187
|
|
|
190
188
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
189
|
+
* Reads a template and every child template it embeds, as a list of
|
|
190
|
+
* documents.
|
|
193
191
|
*
|
|
194
192
|
* A stack resource points at another template, and CloudFormation deploys that
|
|
195
193
|
* template's resources alongside the parent's. Each document keeps its own
|
|
@@ -199,7 +197,7 @@ declare function inheritedEnvVars(template: CloudFormationTemplate): Record<stri
|
|
|
199
197
|
*
|
|
200
198
|
* A child's reference to one of its own parameters is not followed to what the
|
|
201
199
|
* parent bound, and a `Fn::GetAtt` on a stack resource is not followed to the
|
|
202
|
-
* child's output. Both point at
|
|
200
|
+
* child's output. Both point at no resource, like any other unresolved reference.
|
|
203
201
|
*/
|
|
204
202
|
|
|
205
203
|
/**
|
|
@@ -254,7 +252,7 @@ interface TemplateTree {
|
|
|
254
252
|
* The root template plus every template it embeds, directly or through
|
|
255
253
|
* another child.
|
|
256
254
|
*
|
|
257
|
-
* A missing or malformed
|
|
255
|
+
* A missing or malformed root template throws, matching
|
|
258
256
|
* `loadCloudFormationTemplate`: the caller asked for that file by name.
|
|
259
257
|
* A child that cannot be read never throws; it lands in `unfollowed` so
|
|
260
258
|
* the caller can report which one and why.
|
|
@@ -271,16 +269,15 @@ declare function qualifiedLogicalId(stackPath: string[], logicalId: string): str
|
|
|
271
269
|
declare function unfollowedStackMessage(stack: UnfollowedStack): string;
|
|
272
270
|
|
|
273
271
|
/**
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
272
|
+
* Reads AWS::Serverless::Function resources into a code-facing view:
|
|
273
|
+
* which module and export each function points at, and which route and
|
|
274
|
+
* non-route Events it declares.
|
|
277
275
|
*
|
|
278
|
-
* The
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* Events) stay here rather than being reconstructed in a framework pack.
|
|
276
|
+
* The contract readers expand SAM Events into API Gateway route summaries.
|
|
277
|
+
* The code-side pairing needs something else from the template: where each
|
|
278
|
+
* handler's implementation is, and which routes it is bound to. CodeUri
|
|
279
|
+
* inheritance from Globals and the difference between Api and HttpApi
|
|
280
|
+
* Events are handled here, so a framework pack does not work them out again.
|
|
284
281
|
*/
|
|
285
282
|
|
|
286
283
|
/** A route-bearing SAM Event (`Type: Api` or `Type: HttpApi`). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suss/manifest-aws",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Parse a CloudFormation or SAM template into plain data, the facts every suss reader of an AWS template works from.",
|
|
6
6
|
"keywords": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"license": "Apache-2.0",
|
|
15
15
|
"author": "Nimbus Cloud AI LLC",
|
|
16
|
-
"homepage": "https://
|
|
16
|
+
"homepage": "https://suss.sh",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git+https://github.com/nimbuscloud-ai/suss.git",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typecheck": "tsc --noEmit"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@suss/ir-core": "0.
|
|
49
|
+
"@suss/ir-core": "0.34.1",
|
|
50
50
|
"yaml": "^2.4.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|