@suss/manifest-aws 0.33.0 → 0.34.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/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, and the Lambda pack pairs a handler in code against the route or queue the template gives it. Both used to parse the template themselves, and they disagreed about what it said.
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/behavioral-ir` and a YAML parser, and it produces data rather than summaries. Nothing here decides what a resource means; a reader does.
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
- * templateLoader.ts parses a CloudFormation or SAM template file into a
6
- * plain object, resolving the shorthand YAML tags CFN uses for intrinsics.
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
- * This is the one place that turns a template on disk into data. The
9
- * summary-generation paths and the code-side handler pairing both read
10
- * through it, so the YAML and JSON parsing, along with the handling of
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
- * appsyncResolvers.ts works out which GraphQL field each Lambda serves.
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 covered, the raw AWS::AppSync::* resources and the SAM
60
- * AWS::Serverless::GraphQLApi shorthand whose DataSources, Functions, and
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, this reports only what the template says.
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 for a reader above to decide.
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
- * arn.ts resolves the references AWS manifests use to point at a queue, a
88
- * topic, or a bucket, down to the channel string suss keys the boundary on.
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 when the reference is dynamic (a parameter, an import,
104
- * or an Fn::Join that points at nothing this template declares); those
105
- * need cross-stack resolution that's out of scope for v0.
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
- * eventPattern.ts reads what an EventBridge rule says about the events it
126
- * matches, and which bus those events arrive on.
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. v0 handles only a literal `detail-type` array; anything else
147
- * (absent detail-type, content-filter objects, empty array) is
148
- * unresolvable, surfaced by the checker, never silently dropped.
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
- * globals.ts folds the SAM `Globals` section into the resources that
161
- * inherit from it, so every reader sees one set of properties per resource
162
- * and none of them has to know that `Globals` exists.
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. Merging keys is what makes a function that sets
171
- * one environment variable of its own still get the section's others.
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 its own contract
184
- * needs the difference, because a variable every function in the
185
- * document receives tells you about the document, not about one
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
- * nestedStacks.ts reads a template and every child template it embeds, as a
192
- * list of documents.
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 nothing, like any reference we can't resolve.
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 ROOT throws, matching
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
- * serverlessFunctions.ts reads AWS::Serverless::Function resources into a
275
- * code-facing view: which module and export each function points at, and
276
- * which route and non-route Events it declares.
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 summary-generation paths expand SAM Events into API Gateway route
279
- * summaries. This reader covers the other question the code-side pairing
280
- * needs: given the template, where is each handler's implementation, and
281
- * what routes is it bound to? The manifest semantics (how a Handler string
282
- * is laid out, how CodeUri is inherited from Globals, Api versus HttpApi
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
- * templateLoader.ts parses a CloudFormation or SAM template file into a
6
- * plain object, resolving the shorthand YAML tags CFN uses for intrinsics.
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
- * This is the one place that turns a template on disk into data. The
9
- * summary-generation paths and the code-side handler pairing both read
10
- * through it, so the YAML and JSON parsing, along with the handling of
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
- * appsyncResolvers.ts works out which GraphQL field each Lambda serves.
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 covered, the raw AWS::AppSync::* resources and the SAM
60
- * AWS::Serverless::GraphQLApi shorthand whose DataSources, Functions, and
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, this reports only what the template says.
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 for a reader above to decide.
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
- * arn.ts resolves the references AWS manifests use to point at a queue, a
88
- * topic, or a bucket, down to the channel string suss keys the boundary on.
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 when the reference is dynamic (a parameter, an import,
104
- * or an Fn::Join that points at nothing this template declares); those
105
- * need cross-stack resolution that's out of scope for v0.
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
- * eventPattern.ts reads what an EventBridge rule says about the events it
126
- * matches, and which bus those events arrive on.
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. v0 handles only a literal `detail-type` array; anything else
147
- * (absent detail-type, content-filter objects, empty array) is
148
- * unresolvable, surfaced by the checker, never silently dropped.
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
- * globals.ts folds the SAM `Globals` section into the resources that
161
- * inherit from it, so every reader sees one set of properties per resource
162
- * and none of them has to know that `Globals` exists.
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. Merging keys is what makes a function that sets
171
- * one environment variable of its own still get the section's others.
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 its own contract
184
- * needs the difference, because a variable every function in the
185
- * document receives tells you about the document, not about one
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
- * nestedStacks.ts reads a template and every child template it embeds, as a
192
- * list of documents.
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 nothing, like any reference we can't resolve.
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 ROOT throws, matching
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
- * serverlessFunctions.ts reads AWS::Serverless::Function resources into a
275
- * code-facing view: which module and export each function points at, and
276
- * which route and non-route Events it declares.
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 summary-generation paths expand SAM Events into API Gateway route
279
- * summaries. This reader covers the other question the code-side pairing
280
- * needs: given the template, where is each handler's implementation, and
281
- * what routes is it bound to? The manifest semantics (how a Handler string
282
- * is laid out, how CodeUri is inherited from Globals, Api versus HttpApi
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.33.0",
3
+ "version": "0.34.0",
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://github.com/nimbuscloud-ai/suss/tree/main/packages/manifest/aws#readme",
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.33.0",
49
+ "@suss/ir-core": "0.34.0",
50
50
  "yaml": "^2.4.0"
51
51
  },
52
52
  "devDependencies": {