agent-claw: automated task changes

This commit is contained in:
daniel
2026-05-06 18:55:16 -05:00
parent 38905bb1e9
commit 732b00fb66
8494 changed files with 2018127 additions and 4 deletions

13
cdk/node_modules/aws-cdk-lib/assertions/.jsiirc.json generated vendored Normal file
View File

@@ -0,0 +1,13 @@
{
"targets": {
"java": {
"package": "software.amazon.awscdk.assertions"
},
"dotnet": {
"namespace": "Amazon.CDK.Assertions"
},
"python": {
"module": "aws_cdk.assertions"
}
}
}

123
cdk/node_modules/aws-cdk-lib/assertions/MIGRATING.md generated vendored Normal file
View File

@@ -0,0 +1,123 @@
# Migrating to Assertions
Most of the APIs in the old `assert` module has a corresponding API in `assertions`.
Make the following modifications to your CDK test files to migrate to the
`@aws-cdk/assertions` module.
For a migration script that handles most common use cases for you, see
[Migration Script](migration-script).
## Translation Guide
- Rewrite module imports that use `@aws-cdk/aws-assert` to `@aws-cdk/aws-assertions`.
For example:
```ts
import '@aws-cdk/assert/jest';
import { ABSENT, SynthUtils, ResourcePart } from '@aws-cdk/assert';
```
...becomes...
```ts
import { Template } from '@aws-cdk/assertions';
import { Match, Template } from '@aws-cdk/assertions';
```
- Replace instances of `toHaveResource()` with `hasResourceProperties()` or `hasResource()`.
For example:
```ts
expect(stack).toHaveResource('FOO::BAR', {/*...*/});
expect(stack).toHaveResource('FOO::BAR', {/*...*/}, ResourcePart.CompleteDefinition);
```
...becomes...
```ts
Template.fromStack(stack).hasResourceProperties('FOO::BAR', {/*...*/});
Template.fromStack(stacK).hasResource('FOO::BAR', {/*...*/});
```
- Replace instances of `toCountResources()` with `resourceCountIs`. For example:
```ts
expect(stack).toCountResources('FOO::BAR', 1);
```
...becomes...
```ts
Template.fromStack(stack).resourceCountIs('FOO::BAR', 1);
```
- Replace instances of `toMatchTemplate()` with `templateMatches()`. For example:
```ts
expect(stack).toMatchTemplate({/*...*/});
```
...becomes...
```ts
Template.fromStack(stack).templateMatches({/*...*/});
```
- Replace `arrayWith()` with `Match.arrayWith()`, `objectLike()` with `Match.objectLike()`, and
`ABSENT` with `Match.absent()`.
- `not` can be replaced with `Match.not()` _or_ `resourceCountIs()` depending on the use case.
```ts
// asserting that the stack does not have a particular resource.
expect(stack).not.toHaveResource('FOO::BAR');
```
...becomes...
```ts
Template.fromStack(stack).resourceCountIs('FOO::BAR', 0);
```
```ts
// asserting that the stack does not have a resource with these properties
expect(stack).not.toHaveResource('FOO::BAR', {
prop: 'does not exist',
});
```
...becomes...
```ts
Template.fromStack(stack).hasResourceProperties('FOO::BAR', Match.not({
prop: 'does not exist',
}));
```
- `SynthUtils.synthesize(stack)` can be replaced as well. For example:
```ts
expect(SynthUtils.synthesize(stack).template).toEqual(/*...*/);
SynthUtils.syntesize(stack);
```
...becomes...
```ts
expect(Template.fromStack(stack).toJSON()).toEqual(/*...*/);
App.of(stack).synth();
```
## Migration Script
> NOTE: We have some code rewrite rules that will make it easier to migrate from one library
> to the other. This tool will not do a complete rewrite and is not guaranteed to produce
> compilable code! It will just save you the effort of performing a lot of code substitutions
> you would otherwise have to do by hand.
Comby is a tool used to do structured code rewriting. You can install it
[here](https://comby.dev/). Download the [rewrite.toml](rewrite.toml) file from our GitHub
repository, and run the following command in the root directory of your project:
```bash
comby -config ~/rewrite.toml -f .ts -d test -in-place -timeout 10
```

681
cdk/node_modules/aws-cdk-lib/assertions/README.md generated vendored Normal file
View File

@@ -0,0 +1,681 @@
# Assertions
If you're migrating from the old `@aws-cdk/assert` library, first use this migration guide to migrate from `@aws-cdk/assert` to `@aws-cdk/assertions` found in
[our GitHub repository](https://github.com/aws/aws-cdk/blob/v1-main/packages/@aws-cdk/assertions/MIGRATING.md). Then, you can migrate your application to AWS CDK v2 in order to use this library using [this guide](https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html).
Functions for writing test asserting against CDK applications, with focus on CloudFormation templates.
The `Template` class includes a set of methods for writing assertions against CloudFormation templates. Use one of the `Template.fromXxx()` static methods to create an instance of this class.
To create `Template` from CDK stack, start off with:
```ts nofixture
import { Stack } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
const stack = new Stack(/* ... */);
// ...
const template = Template.fromStack(stack);
```
Alternatively, assertions can be run on an existing CloudFormation template -
```ts fixture=init
const templateJson = '{ "Resources": ... }'; /* The CloudFormation template as JSON serialized string. */
const template = Template.fromString(templateJson);
```
**Cyclical Resources Note**
If allowing cyclical references is desired, for example in the case of unprocessed Transform templates, supply TemplateParsingOptions and
set skipCyclicalDependenciesCheck to true. In all other cases, will fail on detecting cyclical dependencies.
## Full Template Match
The simplest assertion would be to assert that the template matches a given
template.
```ts
template.templateMatches({
Resources: {
BarLogicalId: {
Type: 'Foo::Bar',
Properties: {
Baz: 'Qux',
},
},
},
});
```
By default, the `templateMatches()` API will use the an 'object-like' comparison,
which means that it will allow for the actual template to be a superset of the
given expectation. See [Special Matchers](#special-matchers) for details on how
to change this.
Snapshot testing is a common technique to store a snapshot of the output and
compare it during future changes. Since CloudFormation templates are human readable,
they are a good target for snapshot testing.
The `toJSON()` method on the `Template` can be used to produce a well formatted JSON
of the CloudFormation template that can be used as a snapshot.
See [Snapshot Testing in Jest](https://jestjs.io/docs/snapshot-testing) and [Snapshot
Testing in Java](https://json-snapshot.github.io/).
## Counting Resources
This module allows asserting the number of resources of a specific type found
in a template.
```ts
template.resourceCountIs('Foo::Bar', 2);
```
You can also count the number of resources of a specific type whose `Properties`
section contains the specified properties:
```ts
template.resourcePropertiesCountIs('Foo::Bar', {
Foo: 'Bar',
Baz: 5,
Qux: [ 'Waldo', 'Fred' ],
}, 1);
```
## Resource Matching & Retrieval
Beyond resource counting, the module also allows asserting that a resource with
specific properties are present.
The following code asserts that the `Properties` section of a resource of type
`Foo::Bar` contains the specified properties -
```ts
template.hasResourceProperties('Foo::Bar', {
Lorem: 'Ipsum',
Baz: 5,
Qux: [ 'Waldo', 'Fred' ],
});
```
You can also assert that the `Properties` section of all resources of type
`Foo::Bar` contains the specified properties -
```ts
template.allResourcesProperties('Foo::Bar', {
Lorem: 'Ipsum',
Baz: 5,
Qux: [ 'Waldo', 'Fred' ],
});
```
Alternatively, if you would like to assert the entire resource definition, you
can use the `hasResource()` API.
```ts
template.hasResource('Foo::Bar', {
Properties: { Lorem: 'Ipsum' },
DependsOn: [ 'Waldo', 'Fred' ],
});
```
You can also assert the definitions of all resources of a type using the
`allResources()` API.
```ts
template.allResources('Foo::Bar', {
Properties: { Lorem: 'Ipsum' },
DependsOn: [ 'Waldo', 'Fred' ],
});
```
Beyond assertions, the module provides APIs to retrieve matching resources.
The `findResources()` API is complementary to the `hasResource()` API, except,
instead of asserting its presence, it returns the set of matching resources.
Similarly, the `getResourceId()` API is complementary to the `findResources()` API,
except it expects only one matching resource, and returns the matched resource's resource id.
Useful for asserting that certain cloudformation resources correlate expectedly.
```ts
// Assert that a certain bucket denies unsecure communication
const bucket = template.getResourceId('AWS::S3::Bucket', {
Properties: {
BucketName: 'my-bucket',
}
})
template.hasResourceProperties('AWS::S3::BucketPolicy', {
Bucket: {
Ref: bucket,
},
PolicyDocument: {
Statement: [
{
Effect: 'Deny',
Action: 's3:*',
Principal: { AWS: '*' },
Condition: { Bool: { 'aws:SecureTransport': 'false' } },
},
],
}
})
```
By default, the `hasResource()` and `hasResourceProperties()` APIs perform deep
partial object matching. This behavior can be configured using matchers.
See subsequent section on [special matchers](#special-matchers).
## Output and Mapping sections
The module allows you to assert that the CloudFormation template contains an Output
that matches specific properties. The following code asserts that a template contains
an Output with a `logicalId` of `Foo` and the specified properties -
```ts
const expected = {
Value: 'Bar',
Export: { Name: 'ExportBaz' },
};
template.hasOutput('Foo', expected);
```
If you want to match against all Outputs in the template, use `*` as the `logicalId`.
```ts
template.hasOutput('*', {
Value: 'Bar',
Export: { Name: 'ExportBaz' },
});
```
`findOutputs()` will return a set of outputs that match the `logicalId` and `props`,
and you can use the `'*'` special case as well.
```ts
const result = template.findOutputs('*', { Value: 'Fred' });
expect(result.Foo).toEqual({ Value: 'Fred', Description: 'FooFred' });
expect(result.Bar).toEqual({ Value: 'Fred', Description: 'BarFred' });
```
The APIs `hasMapping()`, `findMappings()`, `hasCondition()`, and `hasCondtions()` provide similar functionalities.
## Special Matchers
The expectation provided to the `hasXxx()`, `findXxx()` and `templateMatches()`
APIs, besides carrying literal values, as seen in the above examples, also accept
special matchers.
They are available as part of the `Match` class.
### Object Matchers
The `Match.objectLike()` API can be used to assert that the target is a superset
object of the provided pattern.
This API will perform a deep partial match on the target.
Deep partial matching is where objects are matched partially recursively. At each
level, the list of keys in the target is a subset of the provided pattern.
```ts
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": {
// "Wobble": "Flob",
// "Bob": "Cat"
// }
// }
// }
// }
// }
// The following will NOT throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Wobble: 'Flob',
}),
});
// The following will throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Brew: 'Coffee',
}),
});
```
The `Match.objectEquals()` API can be used to assert a target as a deep exact
match.
### Presence and Absence
The `Match.absent()` matcher can be used to specify that a specific
value should not exist on the target. This can be used within `Match.objectLike()`
or outside of any matchers.
```ts
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": {
// "Wobble": "Flob",
// }
// }
// }
// }
// }
// The following will NOT throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Bob: Match.absent(),
}),
});
// The following will throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Fred: Match.objectLike({
Wobble: Match.absent(),
}),
});
```
The `Match.anyValue()` matcher can be used to specify that a specific value should be found
at the location. This matcher will fail if when the target location has null-ish values
(i.e., `null` or `undefined`).
This matcher can be combined with any of the other matchers.
```ts
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": {
// "Wobble": ["Flob", "Flib"],
// }
// }
// }
// }
// }
// The following will NOT throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Fred: {
Wobble: [ Match.anyValue(), Match.anyValue() ],
},
});
// The following will throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Fred: {
Wimble: Match.anyValue(),
},
});
```
### Array Matchers
The `Match.arrayWith()` API can be used to assert that the target is equal to or a subset
of the provided pattern array.
This API will perform subset match on the target.
```ts
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": ["Flob", "Cat"]
// }
// }
// }
// }
// The following will NOT throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Fred: Match.arrayWith(['Flob']),
});
// The following will throw an assertion error
template.hasResourceProperties('Foo::Bar', Match.objectLike({
Fred: Match.arrayWith(['Wobble']),
}));
```
*Note:* The list of items in the pattern array should be in order as they appear in the
target array. Out of order will be recorded as a match failure.
Alternatively, the `Match.arrayEquals()` API can be used to assert that the target is
exactly equal to the pattern array.
### String Matchers
The `Match.stringLikeRegexp()` API can be used to assert that the target matches the
provided regular expression.
```ts
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Template": "const includeHeaders = true;"
// }
// }
// }
// }
// The following will NOT throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Template: Match.stringLikeRegexp('includeHeaders = (true|false)'),
});
// The following will throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Template: Match.stringLikeRegexp('includeHeaders = null'),
});
```
### Not Matcher
The not matcher inverts the search pattern and matches all patterns in the path that does
not match the pattern specified.
```ts
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": ["Flob", "Cat"]
// }
// }
// }
// }
// The following will NOT throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Fred: Match.not(['Flob']),
});
// The following will throw an assertion error
template.hasResourceProperties('Foo::Bar', Match.objectLike({
Fred: Match.not(['Flob', 'Cat']),
}));
```
### Serialized JSON
Often, we find that some CloudFormation Resource types declare properties as a string,
but actually expect JSON serialized as a string.
For example, the [`BuildSpec` property of `AWS::CodeBuild::Project`][Pipeline BuildSpec],
the [`Definition` property of `AWS::StepFunctions::StateMachine`][StateMachine Definition],
to name a couple.
The `Match.serializedJson()` matcher allows deep matching within a stringified JSON.
```ts
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Baz": "{ \"Fred\": [\"Waldo\", \"Willow\"] }"
// }
// }
// }
// }
// The following will NOT throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Baz: Match.serializedJson({
Fred: Match.arrayWith(["Waldo"]),
}),
});
// The following will throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Baz: Match.serializedJson({
Fred: ["Waldo", "Johnny"],
}),
});
```
[Pipeline BuildSpec]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-source.html#cfn-codebuild-project-source-buildspec
[StateMachine Definition]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-definition
## Capturing Values
The matcher APIs documented above allow capturing values in the matching entry
(Resource, Output, Mapping, etc.). The following code captures a string from a
matching resource.
```ts
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": ["Flob", "Cat"],
// "Waldo": ["Qix", "Qux"],
// }
// }
// }
// }
const fredCapture = new Capture();
const waldoCapture = new Capture();
template.hasResourceProperties('Foo::Bar', {
Fred: fredCapture,
Waldo: ["Qix", waldoCapture] as any[],
});
fredCapture.asArray(); // returns ["Flob", "Cat"]
waldoCapture.asString(); // returns "Qux"
```
With captures, a nested pattern can also be specified, so that only targets
that match the nested pattern will be captured. This pattern can be literals or
further Matchers.
```ts
// Given a template -
// {
// "Resources": {
// "MyBar1": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": ["Flob", "Cat"],
// }
// }
// "MyBar2": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": ["Qix", "Qux"],
// }
// }
// }
// }
const capture = new Capture(Match.arrayWith(['Cat']));
template.hasResourceProperties('Foo::Bar', {
Fred: capture,
});
capture.asArray(); // returns ['Flob', 'Cat']
```
When multiple resources match the given condition, each `Capture` defined in
the condition will capture all matching values. They can be paged through using
the `next()` API. The following example illustrates this -
```ts
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": "Flob",
// }
// },
// "MyBaz": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": "Quib",
// }
// }
// }
// }
const fredCapture = new Capture();
template.hasResourceProperties('Foo::Bar', {
Fred: fredCapture,
});
fredCapture.asString(); // returns "Flob"
fredCapture.next(); // returns true
fredCapture.asString(); // returns "Quib"
```
## Asserting Annotations
In addition to template matching, we provide an API for annotation matching.
[Annotations](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Annotations.html)
can be added via the [Aspects](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Aspects.html)
API. You can learn more about Aspects [here](https://docs.aws.amazon.com/cdk/v2/guide/aspects.html).
Say you have a `MyAspect` and a `MyStack` that uses `MyAspect`:
```ts nofixture
import * as cdk from 'aws-cdk-lib';
import { Construct, IConstruct } from 'constructs';
class MyAspect implements cdk.IAspect {
public visit(node: IConstruct): void {
if (node instanceof cdk.CfnResource && node.cfnResourceType === 'Foo::Bar') {
this.error(node, 'we do not want a Foo::Bar resource');
}
}
protected error(node: IConstruct, message: string): void {
cdk.Annotations.of(node).addError(message);
}
}
class MyStack extends cdk.Stack {
constructor(scope: Construct, id: string) {
super(scope, id);
const stack = new cdk.Stack();
new cdk.CfnResource(stack, 'Foo', {
type: 'Foo::Bar',
properties: {
Fred: 'Thud',
},
});
cdk.Aspects.of(stack).add(new MyAspect());
}
}
```
We can then assert that the stack contains the expected Error:
```ts
// import { Annotations } from '@aws-cdk/assertions';
Annotations.fromStack(stack).hasError(
'/Default/Foo',
'we do not want a Foo::Bar resource',
);
```
Here are the available APIs for `Annotations`:
- `hasError()`, `hasNoError()`, and `findError()`
- `hasWarning()`, `hasNoWarning()`, and `findWarning()`
- `hasInfo()`, `hasNoInfo()`, and `findInfo()`
The corresponding `findXxx()` API is complementary to the `hasXxx()` API, except instead
of asserting its presence, it returns the set of matching messages.
In addition, this suite of APIs is compatible with `Matchers` for more fine-grained control.
For example, the following assertion works as well:
```ts
Annotations.fromStack(stack).hasError(
'/Default/Foo',
Match.stringLikeRegexp('.*Foo::Bar.*'),
);
```
## Asserting Stack tags
Tags applied to a `Stack` are not part of the rendered template: instead, they
are included as properties in the Cloud Assembly Manifest. To test that stacks
are tagged as expected, simple assertions can be written.
Given the following setup:
```ts nofixture
import { App, Stack } from 'aws-cdk-lib';
import { Tags } from 'aws-cdk-lib/assertions';
const app = new App();
const stack = new Stack(app, 'MyStack', {
tags: {
'tag-name': 'tag-value',
},
});
```
It is possible to test against these values:
```ts
const tags = Tags.fromStack(stack);
// using a default 'objectLike' Matcher
tags.hasValues({
'tag-name': 'tag-value',
});
// ... with Matchers embedded
tags.hasValues({
'tag-name': Match.stringLikeRegexp('value'),
});
// or another object Matcher at the top level
tags.hasValues(Match.objectEquals({
'tag-name': Match.anyValue(),
}));
```
When tags are not defined on the stack, it is represented as an empty object
rather than `undefined`. To make this more obvious, there is a `hasNone()`
method that can be used in place of `Match.exactly({})`. If `Match.absent()` is
passed, an error will result.
```ts
// no tags present
Tags.fromStack(stack).hasNone();
// don't use absent() at the top level, it won't work
expect(() => { Tags.fromStack(stack).hasValues(Match.absent()); }).toThrow(/will never match/i);
```

1
cdk/node_modules/aws-cdk-lib/assertions/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './lib';

1
cdk/node_modules/aws-cdk-lib/assertions/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});var _noFold;exports.Capture=void 0,Object.defineProperty(exports,_noFold="Capture",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").Capture;return Object.defineProperty(exports,_noFold="Capture",{enumerable:!0,configurable:!0,value}),value}}),exports.Template=void 0,Object.defineProperty(exports,_noFold="Template",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").Template;return Object.defineProperty(exports,_noFold="Template",{enumerable:!0,configurable:!0,value}),value}}),exports.Match=void 0,Object.defineProperty(exports,_noFold="Match",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").Match;return Object.defineProperty(exports,_noFold="Match",{enumerable:!0,configurable:!0,value}),value}}),exports.Matcher=void 0,Object.defineProperty(exports,_noFold="Matcher",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").Matcher;return Object.defineProperty(exports,_noFold="Matcher",{enumerable:!0,configurable:!0,value}),value}}),exports.MatchResult=void 0,Object.defineProperty(exports,_noFold="MatchResult",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").MatchResult;return Object.defineProperty(exports,_noFold="MatchResult",{enumerable:!0,configurable:!0,value}),value}}),exports.Annotations=void 0,Object.defineProperty(exports,_noFold="Annotations",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").Annotations;return Object.defineProperty(exports,_noFold="Annotations",{enumerable:!0,configurable:!0,value}),value}}),exports.Tags=void 0,Object.defineProperty(exports,_noFold="Tags",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").Tags;return Object.defineProperty(exports,_noFold="Tags",{enumerable:!0,configurable:!0,value}),value}});

View File

@@ -0,0 +1,78 @@
import type { Stack } from '../../core';
import type { SynthesisMessage } from '../../cx-api';
/**
* Suite of assertions that can be run on a CDK Stack.
* Focused on asserting annotations.
*/
export declare class Annotations {
/**
* Base your assertions on the messages returned by a synthesized CDK `Stack`.
* @param stack the CDK Stack to run assertions on
*/
static fromStack(stack: Stack): Annotations;
private readonly _messages;
private constructor();
/**
* Assert that an error with the given message exists in the synthesized CDK `Stack`.
*
* @param constructPath the construct path to the error, provide `'*'` to match all errors in the template.
* @param message the error message as should be expected. This should be a string or Matcher object.
*/
hasError(constructPath: string, message: any): void;
/**
* Assert that an error with the given message does not exist in the synthesized CDK `Stack`.
*
* @param constructPath the construct path to the error, provide `'*'` to match all errors in the template.
* @param message the error message as should be expected. This should be a string or Matcher object.
*/
hasNoError(constructPath: string, message: any): void;
/**
* Get the set of matching errors of a given construct path and message.
*
* @param constructPath the construct path to the error, provide `'*'` to match all errors in the template.
* @param message the error message as should be expected. This should be a string or Matcher object.
*/
findError(constructPath: string, message: any): SynthesisMessage[];
/**
* Assert that an warning with the given message exists in the synthesized CDK `Stack`.
*
* @param constructPath the construct path to the warning, provide `'*'` to match all warnings in the template.
* @param message the warning message as should be expected. This should be a string or Matcher object.
*/
hasWarning(constructPath: string, message: any): void;
/**
* Assert that an warning with the given message does not exist in the synthesized CDK `Stack`.
*
* @param constructPath the construct path to the warning, provide `'*'` to match all warnings in the template.
* @param message the warning message as should be expected. This should be a string or Matcher object.
*/
hasNoWarning(constructPath: string, message: any): void;
/**
* Get the set of matching warning of a given construct path and message.
*
* @param constructPath the construct path to the warning, provide `'*'` to match all warnings in the template.
* @param message the warning message as should be expected. This should be a string or Matcher object.
*/
findWarning(constructPath: string, message: any): SynthesisMessage[];
/**
* Assert that an info with the given message exists in the synthesized CDK `Stack`.
*
* @param constructPath the construct path to the info, provide `'*'` to match all info in the template.
* @param message the info message as should be expected. This should be a string or Matcher object.
*/
hasInfo(constructPath: string, message: any): void;
/**
* Assert that an info with the given message does not exist in the synthesized CDK `Stack`.
*
* @param constructPath the construct path to the info, provide `'*'` to match all info in the template.
* @param message the info message as should be expected. This should be a string or Matcher object.
*/
hasNoInfo(constructPath: string, message: any): void;
/**
* Get the set of matching infos of a given construct path and message.
*
* @param constructPath the construct path to the info, provide `'*'` to match all infos in the template.
* @param message the info message as should be expected. This should be a string or Matcher object.
*/
findInfo(constructPath: string, message: any): SynthesisMessage[];
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Annotations=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var messages_1=()=>{var tmp=require("./private/messages");return messages_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},error_1=()=>{var tmp=require("./private/error");return error_1=()=>tmp,tmp};class Annotations{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.assertions.Annotations",version:"2.252.0"};static fromStack(stack){try{jsiiDeprecationWarnings().aws_cdk_lib_Stack(stack)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromStack),error}return new Annotations(toMessages(stack))}_messages;constructor(messages){this._messages=convertArrayToMessagesType(messages)}hasError(constructPath,message){const matchError=(0,messages_1().hasMessage)(this._messages,constructPath,constructMessage("error",message));if(matchError)throw new(error_1()).AssertionError(matchError)}hasNoError(constructPath,message){const matchError=(0,messages_1().hasNoMessage)(this._messages,constructPath,constructMessage("error",message));if(matchError)throw new(error_1()).AssertionError(matchError)}findError(constructPath,message){return convertMessagesTypeToArray((0,messages_1().findMessage)(this._messages,constructPath,constructMessage("error",message)))}hasWarning(constructPath,message){const matchError=(0,messages_1().hasMessage)(this._messages,constructPath,constructMessage("warning",message));if(matchError)throw new(error_1()).AssertionError(matchError)}hasNoWarning(constructPath,message){const matchError=(0,messages_1().hasNoMessage)(this._messages,constructPath,constructMessage("warning",message));if(matchError)throw new(error_1()).AssertionError(matchError)}findWarning(constructPath,message){return convertMessagesTypeToArray((0,messages_1().findMessage)(this._messages,constructPath,constructMessage("warning",message)))}hasInfo(constructPath,message){const matchError=(0,messages_1().hasMessage)(this._messages,constructPath,constructMessage("info",message));if(matchError)throw new(error_1()).AssertionError(matchError)}hasNoInfo(constructPath,message){const matchError=(0,messages_1().hasNoMessage)(this._messages,constructPath,constructMessage("info",message));if(matchError)throw new(error_1()).AssertionError(matchError)}findInfo(constructPath,message){return convertMessagesTypeToArray((0,messages_1().findMessage)(this._messages,constructPath,constructMessage("info",message)))}}exports.Annotations=Annotations;function constructMessage(type,message){return{level:type,entry:{data:message}}}function convertArrayToMessagesType(messages){return messages.reduce((obj,item,index)=>({...obj,[index]:item}),{})}function convertMessagesTypeToArray(messages){return Object.values(messages)}function toMessages(stack){const root=stack.node.root;if(!core_1().Stage.isStage(root))throw new(error_1()).AssertionError("unexpected: all stacks must be part of a Stage or an App");return root.synth({force:!0}).getStackArtifact(stack.artifactId).messages}

View File

@@ -0,0 +1,54 @@
import { Matcher, MatchResult } from './matcher';
/**
* Capture values while matching templates.
* Using an instance of this class within a Matcher will capture the matching value.
* The `as*()` APIs on the instance can be used to get the captured value.
*/
export declare class Capture extends Matcher {
private readonly pattern?;
readonly name: string;
/** @internal */
_captured: any[];
private idx;
/**
* Initialize a new capture
* @param pattern a nested pattern or Matcher.
* If a nested pattern is provided `objectLike()` matching is applied.
*/
constructor(pattern?: any | undefined);
test(actual: any): MatchResult;
/**
* When multiple results are captured, move the iterator to the next result.
* @returns true if another capture is present, false otherwise
*/
next(): boolean;
/**
* Retrieve the captured value as a string.
* An error is generated if no value is captured or if the value is not a string.
*/
asString(): string;
/**
* Retrieve the captured value as a number.
* An error is generated if no value is captured or if the value is not a number.
*/
asNumber(): number;
/**
* Retrieve the captured value as a boolean.
* An error is generated if no value is captured or if the value is not a boolean.
*/
asBoolean(): boolean;
/**
* Retrieve the captured value as an array.
* An error is generated if no value is captured or if the value is not an array.
*/
asArray(): any[];
/**
* Retrieve the captured value as a JSON object.
* An error is generated if no value is captured or if the value is not an object.
*/
asObject(): {
[key: string]: any;
};
private validate;
private reportIncorrectType;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Capture=void 0;const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var _1=()=>{var tmp=require(".");return _1=()=>tmp,tmp},matcher_1=()=>{var tmp=require("./matcher");return matcher_1=()=>tmp,tmp},error_1=()=>{var tmp=require("./private/error");return error_1=()=>tmp,tmp},type_1=()=>{var tmp=require("./private/type");return type_1=()=>tmp,tmp};class Capture extends matcher_1().Matcher{pattern;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.assertions.Capture",version:"2.252.0"};name;_captured=[];idx=0;constructor(pattern){super(),this.pattern=pattern,this.name="Capture"}test(actual){const result=new(matcher_1()).MatchResult(actual);if(actual==null)return result.recordFailure({matcher:this,path:[],message:`Can only capture non-nullish values. Found ${actual}`});if(this.pattern!==void 0){const innerResult=(matcher_1().Matcher.isMatcher(this.pattern)?this.pattern:_1().Match.objectLike(this.pattern)).test(actual);if(innerResult.hasFailed())return innerResult}return result.recordCapture({capture:this,value:actual}),result}next(){return this.idx<this._captured.length-1?(this.idx++,!0):!1}asString(){this.validate();const val=this._captured[this.idx];if((0,type_1().getType)(val)==="string")return val;this.reportIncorrectType("string")}asNumber(){this.validate();const val=this._captured[this.idx];if((0,type_1().getType)(val)==="number")return val;this.reportIncorrectType("number")}asBoolean(){this.validate();const val=this._captured[this.idx];if((0,type_1().getType)(val)==="boolean")return val;this.reportIncorrectType("boolean")}asArray(){this.validate();const val=this._captured[this.idx];if((0,type_1().getType)(val)==="array")return val;this.reportIncorrectType("array")}asObject(){this.validate();const val=this._captured[this.idx];if((0,type_1().getType)(val)==="object")return val;this.reportIncorrectType("object")}validate(){if(this._captured.length===0)throw new(error_1()).AssertionError("No value captured")}reportIncorrectType(expected){throw new(error_1()).AssertionError(`Captured value is expected to be ${expected} but found ${(0,type_1().getType)(this._captured[this.idx])}. Value is ${JSON.stringify(this._captured[this.idx],void 0,2)}`)}}exports.Capture=Capture;

View File

@@ -0,0 +1,2 @@
export * from '../match';
export * from '../matcher';

View File

@@ -0,0 +1 @@
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});var _noFold;exports.Match=void 0,Object.defineProperty(exports,_noFold="Match",{enumerable:!0,configurable:!0,get:()=>{var value=require("../match").Match;return Object.defineProperty(exports,_noFold="Match",{enumerable:!0,configurable:!0,value}),value}}),exports.Matcher=void 0,Object.defineProperty(exports,_noFold="Matcher",{enumerable:!0,configurable:!0,get:()=>{var value=require("../matcher").Matcher;return Object.defineProperty(exports,_noFold="Matcher",{enumerable:!0,configurable:!0,value}),value}}),exports.MatchResult=void 0,Object.defineProperty(exports,_noFold="MatchResult",{enumerable:!0,configurable:!0,get:()=>{var value=require("../matcher").MatchResult;return Object.defineProperty(exports,_noFold="MatchResult",{enumerable:!0,configurable:!0,value}),value}});

View File

@@ -0,0 +1,6 @@
export * from './capture';
export * from './template';
export * from './match';
export * from './matcher';
export * from './annotations';
export * from './tags';

1
cdk/node_modules/aws-cdk-lib/assertions/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});var _noFold;exports.Capture=void 0,Object.defineProperty(exports,_noFold="Capture",{enumerable:!0,configurable:!0,get:()=>{var value=require("./capture").Capture;return Object.defineProperty(exports,_noFold="Capture",{enumerable:!0,configurable:!0,value}),value}}),exports.Template=void 0,Object.defineProperty(exports,_noFold="Template",{enumerable:!0,configurable:!0,get:()=>{var value=require("./template").Template;return Object.defineProperty(exports,_noFold="Template",{enumerable:!0,configurable:!0,value}),value}}),exports.Match=void 0,Object.defineProperty(exports,_noFold="Match",{enumerable:!0,configurable:!0,get:()=>{var value=require("./match").Match;return Object.defineProperty(exports,_noFold="Match",{enumerable:!0,configurable:!0,value}),value}}),exports.Matcher=void 0,Object.defineProperty(exports,_noFold="Matcher",{enumerable:!0,configurable:!0,get:()=>{var value=require("./matcher").Matcher;return Object.defineProperty(exports,_noFold="Matcher",{enumerable:!0,configurable:!0,value}),value}}),exports.MatchResult=void 0,Object.defineProperty(exports,_noFold="MatchResult",{enumerable:!0,configurable:!0,get:()=>{var value=require("./matcher").MatchResult;return Object.defineProperty(exports,_noFold="MatchResult",{enumerable:!0,configurable:!0,value}),value}}),exports.Annotations=void 0,Object.defineProperty(exports,_noFold="Annotations",{enumerable:!0,configurable:!0,get:()=>{var value=require("./annotations").Annotations;return Object.defineProperty(exports,_noFold="Annotations",{enumerable:!0,configurable:!0,value}),value}}),exports.Tags=void 0,Object.defineProperty(exports,_noFold="Tags",{enumerable:!0,configurable:!0,get:()=>{var value=require("./tags").Tags;return Object.defineProperty(exports,_noFold="Tags",{enumerable:!0,configurable:!0,value}),value}});

61
cdk/node_modules/aws-cdk-lib/assertions/lib/match.d.ts generated vendored Normal file
View File

@@ -0,0 +1,61 @@
import { Matcher } from './matcher';
/**
* Partial and special matching during template assertions.
*/
export declare abstract class Match {
/**
* Use this matcher in the place of a field's value, if the field must not be present.
*/
static absent(): Matcher;
/**
* Matches the specified pattern with the array found in the same relative path of the target.
* The set of elements (or matchers) must be in the same order as would be found.
* @param pattern the pattern to match
*/
static arrayWith(pattern: any[]): Matcher;
/**
* Matches the specified pattern with the array found in the same relative path of the target.
* The set of elements (or matchers) must match exactly and in order.
* @param pattern the pattern to match
*/
static arrayEquals(pattern: any[]): Matcher;
/**
* Deep exact matching of the specified pattern to the target.
* @param pattern the pattern to match
*/
static exact(pattern: any): Matcher;
/**
* Matches the specified pattern to an object found in the same relative path of the target.
* The keys and their values (or matchers) must be present in the target but the target can be a superset.
* @param pattern the pattern to match
*/
static objectLike(pattern: {
[key: string]: any;
}): Matcher;
/**
* Matches the specified pattern to an object found in the same relative path of the target.
* The keys and their values (or matchers) must match exactly with the target.
* @param pattern the pattern to match
*/
static objectEquals(pattern: {
[key: string]: any;
}): Matcher;
/**
* Matches any target which does NOT follow the specified pattern.
* @param pattern the pattern to NOT match
*/
static not(pattern: any): Matcher;
/**
* Matches any string-encoded JSON and applies the specified pattern after parsing it.
* @param pattern the pattern to match after parsing the encoded JSON.
*/
static serializedJson(pattern: any): Matcher;
/**
* Matches any non-null value at the target.
*/
static anyValue(): Matcher;
/**
* Matches targets according to a regular expression
*/
static stringLikeRegexp(pattern: string): Matcher;
}

1
cdk/node_modules/aws-cdk-lib/assertions/lib/match.js generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,122 @@
import type { Capture } from './capture';
/**
* Represents a matcher that can perform special data matching
* capabilities between a given pattern and a target.
*/
export declare abstract class Matcher {
/**
* Check whether the provided object is a subtype of the `IMatcher`.
*/
static isMatcher(x: any): x is Matcher;
/**
* A name for the matcher. This is collected as part of the result and may be presented to the user.
*/
abstract readonly name: string;
/**
* Test whether a target matches the provided pattern.
* Every Matcher must implement this method.
* This method will be invoked by the assertions framework. Do not call this method directly.
* @param actual the target to match
* @return the list of match failures. An empty array denotes a successful match.
*/
abstract test(actual: any): MatchResult;
}
/**
* Match failure details
*/
export interface MatchFailure {
/**
* The matcher that had the failure
*/
readonly matcher: Matcher;
/**
* The relative path in the target where the failure occurred.
* If the failure occurred at root of the match tree, set the path to an empty list.
* If it occurs in the 5th index of an array nested within the 'foo' key of an object,
* set the path as `['/foo', '[5]']`.
*/
readonly path: string[];
/**
* Failure message
*/
readonly message: string;
/**
* The cost of this particular mismatch
*
* @default 1
*/
readonly cost?: number;
}
/**
* Information about a value captured during match
*/
export interface MatchCapture {
/**
* The instance of Capture class to which this capture is associated with.
*/
readonly capture: Capture;
/**
* The value that was captured
*/
readonly value: any;
}
/**
* The result of `Match.test()`.
*/
export declare class MatchResult {
/**
* The target for which this result was generated.
*/
readonly target: any;
private readonly failuresHere;
private readonly captures;
private finalized;
private readonly innerMatchFailures;
private _hasFailed;
private _failCount;
private _cost;
constructor(target: any);
/**
* DEPRECATED
* @deprecated use recordFailure()
*/
push(matcher: Matcher, path: string[], message: string): this;
/**
* Record a new failure into this result at a specific path.
*/
recordFailure(failure: MatchFailure): this;
/** Whether the match is a success */
get isSuccess(): boolean;
/** Does the result contain any failures. If not, the result is a success */
hasFailed(): boolean;
/** The number of failures */
get failCount(): number;
/** The cost of the failures so far */
get failCost(): number;
/**
* Compose the results of a previous match as a subtree.
* @param id the id of the parent tree.
*/
compose(id: string, inner: MatchResult): this;
/**
* Prepare the result to be analyzed.
* This API *must* be called prior to analyzing these results.
*/
finished(): this;
/**
* Render the failed match in a presentable way
*
* Prefer using `renderMismatch` over this method. It is left for backwards
* compatibility for test suites that expect it, but `renderMismatch()` will
* produce better output.
*/
toHumanStrings(): string[];
/**
* Do a deep render of the match result, showing the structure mismatches in context
*/
renderMismatch(): string;
/**
* Record a capture against in this match result.
*/
recordCapture(options: MatchCapture): void;
}

10
cdk/node_modules/aws-cdk-lib/assertions/lib/matcher.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MatchResult=exports.Matcher=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");class Matcher{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.assertions.Matcher",version:"2.252.0"};static isMatcher(x){return x&&x instanceof Matcher}}exports.Matcher=Matcher;class MatchResult{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.assertions.MatchResult",version:"2.252.0"};target;failuresHere=new Map;captures=new Map;finalized=!1;innerMatchFailures=new Map;_hasFailed=!1;_failCount=0;_cost=0;constructor(target){this.target=target}push(matcher,path,message){try{jsiiDeprecationWarnings().print("aws-cdk-lib.assertions.MatchResult#push","use recordFailure()"),jsiiDeprecationWarnings().aws_cdk_lib_assertions_Matcher(matcher)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.push),error}return this.recordFailure({matcher,path,message})}recordFailure(failure){try{jsiiDeprecationWarnings().aws_cdk_lib_assertions_MatchFailure(failure)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.recordFailure),error}const failKey=failure.path.join(".");let list=this.failuresHere.get(failKey);return list||(list=[],this.failuresHere.set(failKey,list)),this._failCount+=1,this._cost+=failure.cost??1,list.push(failure),this._hasFailed=!0,this}get isSuccess(){return!this._hasFailed}hasFailed(){return this._hasFailed}get failCount(){return this._failCount}get failCost(){return this._cost}compose(id,inner){try{jsiiDeprecationWarnings().aws_cdk_lib_assertions_MatchResult(inner)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.compose),error}return inner.hasFailed()&&(this._hasFailed=!0,this._failCount+=inner.failCount,this._cost+=inner._cost,this.innerMatchFailures.set(id,inner)),inner.captures.forEach((vals,capture)=>{vals.forEach(value=>this.recordCapture({capture,value}))}),this}finished(){return this.finalized?this:(this.failCount===0&&this.captures.forEach((vals,cap)=>cap._captured.push(...vals)),this.finalized=!0,this)}toHumanStrings(){const failures=new Array;return recurse(this,[]),failures.map(r=>{const loc=r.path.length===0?"":` at /${r.path.join("/")}`;return""+r.message+loc+` (using ${r.matcher.name} matcher)`});function recurse(x,prefix){for(const fail of Array.from(x.failuresHere.values()).flat())failures.push({matcher:fail.matcher,message:fail.message,path:[...prefix,...fail.path]});for(const[key,inner]of x.innerMatchFailures.entries())recurse(inner,[...prefix,key])}}renderMismatch(){if(!this.hasFailed())return"<match>";const parts=new Array,indents=new Array;return emitFailures(this,""),recurse(this),moveMarkersToFront(parts.join("").trimEnd());function emit(x){if(x===void 0)debugger;parts.push(x.replace(/\n/g,`
${indents.join("")}`))}function emitFailures(r,path,scrapSet){for(const fail of r.failuresHere.get(path)??[])emit(`!! ${fail.message}
`);scrapSet?.delete(path)}function recurse(r){const remainingFailures=new Set(Array.from(r.failuresHere.keys()).filter(x=>x!==""));if(Array.isArray(r.target)){indents.push(" "),emit(`[
`);for(const[first,i]of enumFirst(range(r.target.length))){first||emit(`,
`),emitFailures(r,`${i}`,remainingFailures);const innerMatcher=r.innerMatchFailures.get(`${i}`);innerMatcher?(emitFailures(innerMatcher,""),recurseComparingValues(innerMatcher,r.target[i])):emit(renderAbridged(r.target[i]))}emitRemaining(),indents.pop(),emit(`
]`);return}if(r.target&&typeof r.target=="object"){indents.push(" "),emit(`{
`);const keys=Array.from(new Set([...Object.keys(r.target),...Array.from(remainingFailures)])).sort();for(const[first,key]of enumFirst(keys)){first||emit(`,
`),emitFailures(r,key,remainingFailures);const innerMatcher=r.innerMatchFailures.get(key);innerMatcher?(emitFailures(innerMatcher,""),emit(`${jsonify(key)}: `),recurseComparingValues(innerMatcher,r.target[key])):(emit(`${jsonify(key)}: `),emit(renderAbridged(r.target[key])))}emitRemaining(),indents.pop(),emit(`
}`);return}emitRemaining(),emit(jsonify(r.target));function emitRemaining(){remainingFailures.size>0&&emit(`
`);for(const key of remainingFailures)emitFailures(r,key)}}function recurseComparingValues(inner,actualValue){if(inner.target===actualValue)return recurse(inner);emit(renderAbridged(actualValue)),emit(" <*> "),recurse(inner)}function renderAbridged(x){if(Array.isArray(x))switch(x.length){case 0:return"[]";case 1:return`[ ${renderAbridged(x[0])} ]`;case 2:return x.every(e=>["number","boolean","string"].includes(typeof e))?`[ ${x.map(renderAbridged).join(", ")} ]`:"[ ... ]";default:return"[ ... ]"}if(x&&typeof x=="object"){const keys=Object.keys(x);switch(keys.length){case 0:return"{}";case 1:return`{ ${JSON.stringify(keys[0])}: ${renderAbridged(x[keys[0]])} }`;default:return"{ ... }"}}return jsonify(x)}function jsonify(x){return JSON.stringify(x)??"undefined"}function moveMarkersToFront(x){const re=/^(\s+)!!/gm;return x.replace(re,(_,spaces)=>`!!${spaces.substring(0,spaces.length-2)}`)}}recordCapture(options){try{jsiiDeprecationWarnings().aws_cdk_lib_assertions_MatchCapture(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.recordCapture),error}let values=this.captures.get(options.capture);values===void 0&&(values=[]),values.push(options.value),this.captures.set(options.capture,values)}}exports.MatchResult=MatchResult;function*range(n){for(let i=0;i<n;i++)yield i}function*enumFirst(xs){let first=!0;for(const x of xs)yield[first,x],first=!1}

View File

@@ -0,0 +1,7 @@
import type { Template } from './template';
export declare function findConditions(template: Template, logicalId: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
export declare function hasCondition(template: Template, logicalId: string, props: any): string | void;

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findConditions=findConditions,exports.hasCondition=hasCondition;var section_1=()=>{var tmp=require("./section");return section_1=()=>tmp,tmp};function findConditions(template,logicalId,props={}){const section=template.Conditions??{},result=(0,section_1().matchSection)((0,section_1().filterLogicalId)(section,logicalId),props);return result.match?result.matches:{}}function hasCondition(template,logicalId,props){const section=template.Conditions??{},result=(0,section_1().matchSection)((0,section_1().filterLogicalId)(section,logicalId),props);if(!result.match)return(0,section_1().formatSectionMatchFailure)(`conditions with logicalId ${logicalId}`,result)}

View File

@@ -0,0 +1,8 @@
import type { Template } from './template';
/**
* Check a template for cyclic dependencies
*
* This will make sure that we don't happily validate templates
* in unit tests that wouldn't deploy to CloudFormation anyway.
*/
export declare function checkTemplateForCyclicDependencies(template: Template): void;

View File

@@ -0,0 +1,3 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkTemplateForCyclicDependencies=checkTemplateForCyclicDependencies;var error_1=()=>{var tmp=require("./error");return error_1=()=>tmp,tmp};function checkTemplateForCyclicDependencies(template){const logicalIds=new Set(Object.keys(template.Resources??{})),dependencies=new Map;for(const[logicalId,resource]of Object.entries(template.Resources??{}))dependencies.set(logicalId,intersect(findResourceDependencies(resource),logicalIds));for(;dependencies.size>0;){const free=Array.from(dependencies.entries()).filter(([_,deps])=>deps.size===0);if(free.length===0){const cycle=findCycle(dependencies),cycleResources={};for(const logicalId of cycle)cycleResources[logicalId]=template.Resources?.[logicalId];throw new(error_1()).AssertionError(`Template is undeployable, these resources have a dependency cycle: ${cycle.join(" -> ")}:
${JSON.stringify(cycleResources,void 0,2)}`)}for(const[logicalId,_]of free){for(const deps of dependencies.values())deps.delete(logicalId);dependencies.delete(logicalId)}}}function findResourceDependencies(res){return new Set([...toArray(res.DependsOn??[]),...findExpressionDependencies(res.Properties)])}function toArray(x){return Array.isArray(x)?x:[x]}function findExpressionDependencies(obj){const ret=new Set;return recurse(obj),ret;function recurse(x){if(x&&(Array.isArray(x)&&x.forEach(recurse),typeof x=="object")){const keys=Object.keys(x);if(keys.length===1&&keys[0]==="Ref")ret.add(x[keys[0]]);else if(keys.length===1&&keys[0]==="Fn::GetAtt")ret.add(x[keys[0]][0]);else if(keys.length===1&&keys[0]==="Fn::Sub"){const argument=x[keys[0]],pattern=Array.isArray(argument)?argument[0]:argument;if(typeof pattern=="string")for(const logId of logicalIdsInSubString(pattern))ret.add(logId);const contextDict=Array.isArray(argument)?argument[1]:void 0;contextDict&&typeof contextDict=="object"&&Object.values(contextDict).forEach(recurse)}else Object.values(x).forEach(recurse)}}}function logicalIdsInSubString(x){return analyzeSubPattern(x).flatMap(fragment=>{switch(fragment.type){case"getatt":case"ref":return[fragment.logicalId];case"literal":return[]}})}function analyzeSubPattern(pattern){const ret=[];let start=0,ph0=pattern.indexOf("${",start);for(;ph0>-1;){if(pattern[ph0+2]==="!"){start=ph0+3,ph0=pattern.indexOf("${",start);continue}const ph1=pattern.indexOf("}",ph0+2);if(ph1===-1)break;const placeholder=pattern.substring(ph0+2,ph1);if(ph0>start&&ret.push({type:"literal",content:pattern.substring(start,ph0)}),placeholder.includes(".")){const[logicalId,attr]=placeholder.split(".");ret.push({type:"getatt",logicalId,attr})}else ret.push({type:"ref",logicalId:placeholder});start=ph1+1,ph0=pattern.indexOf("${",start)}return start<pattern.length-1&&ret.push({type:"literal",content:pattern.slice(start)}),ret}function intersect(xs,ys){return new Set(Array.from(xs).filter(x=>ys.has(x)))}function findCycle(deps){for(const node of deps.keys()){const cycle=recurse(node,[node]);if(cycle)return cycle}throw new(error_1()).AssertionError("No cycle found. Assertion failure!");function recurse(node,path){for(const dep of deps.get(node)??[]){if(path.includes(dep))return[...path,dep];const cycle=recurse(dep,[...path,dep]);if(cycle)return cycle}}}

View File

@@ -0,0 +1,19 @@
/**
* An AssertionError is thrown from the assertions module when an assertion fails.
* Assertion errors are directly connected to an assertion a user wrote.
*
* Not all errors from the assertions module are automatically AssertionErrors.
* When a pre-condition is incorrect (e.g. disallowed use of a matcher),
* throwing an UnscopedValidationError is more appropriate.
*
* @internal
*/
export declare class AssertionError extends Error {
#private;
/**
* The time the error was thrown.
*/
get time(): string;
get type(): 'assertion';
constructor(msg: string);
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AssertionError=void 0;const ASSERTION_ERROR_SYMBOL=Symbol.for("@aws-cdk/assertions.AssertionError");class AssertionError extends Error{#time;get time(){return this.#time}get type(){return"assertion"}constructor(msg){super(msg),Object.setPrototypeOf(this,AssertionError.prototype),Object.defineProperty(this,ASSERTION_ERROR_SYMBOL,{value:!0}),this.name=new.target.name,this.#time=new Date().toISOString()}}exports.AssertionError=AssertionError;

View File

@@ -0,0 +1,7 @@
import type { Template } from './template';
export declare function findMappings(template: Template, logicalId: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
export declare function hasMapping(template: Template, logicalId: string, props: any): string | void;

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findMappings=findMappings,exports.hasMapping=hasMapping;var section_1=()=>{var tmp=require("./section");return section_1=()=>tmp,tmp};function findMappings(template,logicalId,props={}){const section=template.Mappings??{},result=(0,section_1().matchSection)((0,section_1().filterLogicalId)(section,logicalId),props);return result.match?result.matches:{}}function hasMapping(template,logicalId,props){const section=template.Mappings??{},result=(0,section_1().matchSection)((0,section_1().filterLogicalId)(section,logicalId),props);if(!result.match)return(0,section_1().formatSectionMatchFailure)(`mappings with logicalId ${logicalId}`,result)}

View File

@@ -0,0 +1,6 @@
import { Matcher, MatchResult } from '../../matcher';
export declare class AbsentMatch extends Matcher {
readonly name: string;
constructor(name: string);
test(actual: any): MatchResult;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AbsentMatch=void 0;var matcher_1=()=>{var tmp=require("../../matcher");return matcher_1=()=>tmp,tmp};class AbsentMatch extends matcher_1().Matcher{name;constructor(name){super(),this.name=name}test(actual){const result=new(matcher_1()).MatchResult(actual);return actual!==void 0&&result.recordFailure({matcher:this,path:[],message:`Received ${actual}, but key should be absent`}),result}}exports.AbsentMatch=AbsentMatch;

View File

@@ -0,0 +1,4 @@
import type { SynthesisMessage } from '../../../cx-api';
export type Messages = {
[key: string]: SynthesisMessage;
};

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});

View File

@@ -0,0 +1,8 @@
import type { Messages } from './message';
export declare function findMessage(messages: Messages, constructPath: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
export declare function hasMessage(messages: Messages, constructPath: string, props: any): string | void;
export declare function hasNoMessage(messages: Messages, constructPath: string, props: any): string | void;

View File

@@ -0,0 +1,2 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findMessage=findMessage,exports.hasMessage=hasMessage,exports.hasNoMessage=hasNoMessage;var section_1=()=>{var tmp=require("./section");return section_1=()=>tmp,tmp};function findMessage(messages,constructPath,props={}){const section=messages,result=(0,section_1().matchSection)(filterPath(section,constructPath),props);return result.match?result.matches:{}}function hasMessage(messages,constructPath,props){const section=messages,result=(0,section_1().matchSection)(filterPath(section,constructPath),props);if(!result.match){for(const mr of Object.values(result.closestResults))redactTraces(mr.target);return(0,section_1().formatSectionMatchFailure)(`messages at path ${constructPath}`,result,"Stack")}}function hasNoMessage(messages,constructPath,props){const section=messages,result=(0,section_1().matchSection)(filterPath(section,constructPath),props);if(result.match)return[`Expected no matches, but stack has ${Object.keys(result.matches).length} messages as follows:`,(0,section_1().formatAllMatches)(result.matches)].join(`
`)}function redactTraces(match,redact=!0){redact&&match.entry?.trace!==void 0&&(match.entry.trace="redacted")}function filterPath(section,path){return path==="*"?section:Object.entries(section??{}).filter(([_,v])=>v.id===path).reduce((agg,[k,v])=>({...agg,[k]:v}),{})}

View File

@@ -0,0 +1,7 @@
import type { Template } from './template';
export declare function findOutputs(template: Template, logicalId: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
export declare function hasOutput(template: Template, logicalId: string, props: any): string | void;

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findOutputs=findOutputs,exports.hasOutput=hasOutput;var section_1=()=>{var tmp=require("./section");return section_1=()=>tmp,tmp};function findOutputs(template,logicalId,props={}){const section=template.Outputs??{},result=(0,section_1().matchSection)((0,section_1().filterLogicalId)(section,logicalId),props);return result.match?result.matches:{}}function hasOutput(template,logicalId,props){const section=template.Outputs??{},result=(0,section_1().matchSection)((0,section_1().filterLogicalId)(section,logicalId),props);if(!result.match)return(0,section_1().formatSectionMatchFailure)(`outputs named ${logicalId}`,result)}

View File

@@ -0,0 +1,7 @@
import type { Template } from './template';
export declare function findParameters(template: Template, logicalId: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
export declare function hasParameter(template: Template, logicalId: string, props: any): string | void;

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findParameters=findParameters,exports.hasParameter=hasParameter;var section_1=()=>{var tmp=require("./section");return section_1=()=>tmp,tmp};function findParameters(template,logicalId,props={}){const section=template.Parameters??{},result=(0,section_1().matchSection)((0,section_1().filterLogicalId)(section,logicalId),props);return result.match?result.matches:{}}function hasParameter(template,logicalId,props){const section=template.Parameters??{},result=(0,section_1().matchSection)((0,section_1().filterLogicalId)(section,logicalId),props);if(!result.match)return(0,section_1().formatSectionMatchFailure)(`parameters with logicalId '${logicalId}'`,result)}

View File

@@ -0,0 +1,16 @@
import type { Template } from './template';
export declare function findResources(template: Template, type: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
export declare function getResourceId(template: Template, type: string, props?: any): {
resourceId?: string;
matchError?: string;
};
export declare function allResources(template: Template, type: string, props: any): string | void;
export declare function allResourcesProperties(template: Template, type: string, props: any): string | void;
export declare function hasResource(template: Template, type: string, props: any): string | void;
export declare function hasResourceProperties(template: Template, type: string, props: any): string | void;
export declare function countResources(template: Template, type: string): number;
export declare function countResourcesProperties(template: Template, type: string, props: any): number;

View File

@@ -0,0 +1,4 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findResources=findResources,exports.getResourceId=getResourceId,exports.allResources=allResources,exports.allResourcesProperties=allResourcesProperties,exports.hasResource=hasResource,exports.hasResourceProperties=hasResourceProperties,exports.countResources=countResources,exports.countResourcesProperties=countResourcesProperties;var __1=()=>{var tmp=require("..");return __1=()=>tmp,tmp},absent_1=()=>{var tmp=require("./matchers/absent");return absent_1=()=>tmp,tmp},section_1=()=>{var tmp=require("./section");return section_1=()=>tmp,tmp};function findResources(template,type,props={}){const section=template.Resources??{},result=(0,section_1().matchSection)(filterType(section,type),props);return result.match?result.matches:{}}function getResourceId(template,type,props={}){const section=template.Resources??{},result=(0,section_1().matchSection)(filterType(section,type),props);if(!result.match)return{matchError:(0,section_1().formatSectionMatchFailure)(`resources with type ${type}`,result)};const resourceIds=Object.keys(result.matches);return resourceIds.length!==1?{matchError:[`Template has ${resourceIds.length} matches, expected only one.`,(0,section_1().formatAllMatches)(result.matches)].join(`
`)}:{resourceId:resourceIds[0]}}function allResources(template,type,props){const section=template.Resources??{},result=(0,section_1().matchSection)(filterType(section,type),props);if(result.match){const matchCount=Object.keys(result.matches).length;if(result.analyzedCount>matchCount)return[`Template has ${result.analyzedCount} resource(s) with type ${type}, but only ${matchCount} match as expected.`,(0,section_1().formatAllMismatches)(result.analyzed,result.matches)].join(`
`)}else return[`Template has ${result.analyzedCount} resource(s) with type ${type}, but none match as expected.`,(0,section_1().formatAllMismatches)(result.analyzed)].join(`
`)}function allResourcesProperties(template,type,props){let amended=template;return(!__1().Matcher.isMatcher(props)||!(props instanceof absent_1().AbsentMatch))&&(amended=JSON.parse(JSON.stringify(template)),amended=addEmptyProperties(amended)),allResources(amended,type,__1().Match.objectLike({Properties:props}))}function hasResource(template,type,props){const section=template.Resources??{},result=(0,section_1().matchSection)(filterType(section,type),props);if(!result.match)return(0,section_1().formatSectionMatchFailure)(`resources with type ${type}`,result)}function hasResourceProperties(template,type,props){let amended=template;return(!__1().Matcher.isMatcher(props)||!(props instanceof absent_1().AbsentMatch))&&(amended=JSON.parse(JSON.stringify(template)),amended=addEmptyProperties(amended)),hasResource(amended,type,__1().Match.objectLike({Properties:props}))}function countResources(template,type){const section=template.Resources??{},types=filterType(section,type);return Object.entries(types).length}function countResourcesProperties(template,type,props){let amended=template;(!__1().Matcher.isMatcher(props)||!(props instanceof absent_1().AbsentMatch))&&(amended=JSON.parse(JSON.stringify(template)),amended=addEmptyProperties(amended));const section=amended.Resources??{},result=(0,section_1().matchSection)(filterType(section,type),__1().Match.objectLike({Properties:props}));return result.match?Object.keys(result.matches).length:0}function addEmptyProperties(template){let section=template.Resources??{};return Object.keys(section).map(key=>{section[key].hasOwnProperty("Properties")||(section[key].Properties={})}),template}function filterType(section,type){return Object.entries(section??{}).filter(([_,v])=>v.Type===type).reduce((agg,[k,v])=>({...agg,[k]:v}),{})}

View File

@@ -0,0 +1,35 @@
import type { MatchResult } from '../matcher';
export type MatchSuccess = {
match: true;
matches: {
[key: string]: any;
};
analyzed: {
[key: string]: any;
};
analyzedCount: number;
};
export type MatchFailure = {
match: false;
closestResults: Record<string, MatchResult>;
analyzed: {
[key: string]: any;
};
analyzedCount: number;
};
export declare function matchSection(section: any, props: any): MatchSuccess | MatchFailure;
export declare function formatAllMatches(matches: {
[key: string]: any;
}): string;
export declare function formatAllMismatches(analyzed: {
[key: string]: any;
}, matches?: {
[key: string]: any;
}): string;
export declare function formatSectionMatchFailure(qualifier: string, result: MatchFailure, what?: string): string;
export declare function formatFailure(closestResults: Record<string, MatchResult>): string;
export declare function filterLogicalId(section: {
[key: string]: {};
}, logicalId: string): {
[key: string]: {};
};

View File

@@ -0,0 +1,7 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.matchSection=matchSection,exports.formatAllMatches=formatAllMatches,exports.formatAllMismatches=formatAllMismatches,exports.formatSectionMatchFailure=formatSectionMatchFailure,exports.formatFailure=formatFailure,exports.filterLogicalId=filterLogicalId;var sorting_1=()=>{var tmp=require("./sorting");return sorting_1=()=>tmp,tmp},match_1=()=>{var tmp=require("../match");return match_1=()=>tmp,tmp},matcher_1=()=>{var tmp=require("../matcher");return matcher_1=()=>tmp,tmp};function matchSection(section,props){const matcher=matcher_1().Matcher.isMatcher(props)?props:match_1().Match.objectLike(props),matching={},analyzed={},failures=new Array;return eachEntryInSection(section,(logicalId,entry)=>{analyzed[logicalId]=entry;const result=matcher.test(entry);result.finished(),result.hasFailed()?failures.push([logicalId,result]):matching[logicalId]=entry}),Object.keys(matching).length>0?{match:!0,matches:matching,analyzedCount:Object.keys(analyzed).length,analyzed}:(failures.sort((0,sorting_1().sortKeyComparator)(([logicalId,result])=>[result.failCost,logicalId])),{match:!1,closestResults:Object.fromEntries(failures.slice(0,3)),analyzedCount:Object.keys(analyzed).length,analyzed})}function eachEntryInSection(section,cb){for(const logicalId of Object.keys(section??{})){const resource=section[logicalId];cb(logicalId,resource)}}function formatAllMatches(matches){return[leftPad(JSON.stringify(matches,void 0,2))].join(`
`)}function formatAllMismatches(analyzed,matches={}){return["The following resources do not match the given definition:",...Object.keys(analyzed).filter(id=>!(id in matches)).map(id=>` ${id}`)].join(`
`)}function formatSectionMatchFailure(qualifier,result,what="Template"){return[`${what} has ${result.analyzedCount} ${qualifier}`,result.analyzedCount>0?", but none match as expected":"",`.
`,formatFailure(result.closestResults)].join("")}function formatFailure(closestResults){const keys=Object.keys(closestResults);return keys.length===0?"No matches found":[`The ${keys.length} closest matches:`,...keys.map(key=>`${key} :: ${closestResults[key].renderMismatch()}`)].join(`
`)}function leftPad(x,indent=2){const pad=" ".repeat(indent);return pad+x.split(`
`).join(`
${pad}`)}function filterLogicalId(section,logicalId){return logicalId==="*"?section:Object.entries(section??{}).filter(([k,_])=>k===logicalId).reduce((agg,[k,v])=>({...agg,[k]:v}),{})}

View File

@@ -0,0 +1,4 @@
/**
* Make a sorting comparator that will sort by a given sort key
*/
export declare function sortKeyComparator<A>(keyFn: (x: A) => Array<string | number>): (a: A, b: A) => number;

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.sortKeyComparator=sortKeyComparator;function sortKeyComparator(keyFn){return(a,b)=>{const ak=keyFn(a),bk=keyFn(b);for(let i=0;i<ak.length&&i<bk.length;i++){const av=ak[i],bv=bk[i];let diff=0;if(typeof av=="number"&&typeof bv=="number"?diff=av-bv:typeof av=="string"&&typeof bv=="string"&&(diff=av.localeCompare(bv)),diff!==0)return diff}return bk.length-ak.length}}

View File

@@ -0,0 +1,6 @@
export declare class SparseMatrix<A> {
private readonly matrix;
get(row: number, col: number): A | undefined;
row(row: number): Array<[number, A]>;
set(row: number, col: number, value: A): void;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SparseMatrix=void 0;class SparseMatrix{matrix=new Map;get(row,col){return this.matrix.get(row)?.get(col)}row(row){return Array.from(this.matrix.get(row)?.entries()??[])}set(row,col,value){let r=this.matrix.get(row);r||(r=new Map,this.matrix.set(row,r)),r.set(col,value)}}exports.SparseMatrix=SparseMatrix;

View File

@@ -0,0 +1,38 @@
export type Template = {
Resources?: {
[logicalId: string]: Resource;
};
Outputs?: {
[logicalId: string]: Output;
};
Mappings?: {
[logicalId: string]: Mapping;
};
Parameters?: {
[logicalId: string]: Parameter;
};
Conditions?: {
[logicalId: string]: Condition;
};
};
export type Resource = {
Type: string;
DependsOn?: string | string[];
Properties?: {
[key: string]: any;
};
[key: string]: any;
};
export type Output = {
[key: string]: any;
};
export type Mapping = {
[key: string]: any;
};
export type Parameter = {
Type: string;
[key: string]: any;
};
export type Condition = {
[key: string]: any;
};

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});

View File

@@ -0,0 +1,2 @@
export type Type = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'array';
export declare function getType(obj: any): Type;

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getType=getType;function getType(obj){return Array.isArray(obj)?"array":typeof obj}

45
cdk/node_modules/aws-cdk-lib/assertions/lib/tags.d.ts generated vendored Normal file
View File

@@ -0,0 +1,45 @@
import type { Stack } from '../../core';
type ManifestTags = {
[key: string]: string;
};
/**
* Allows assertions on the tags associated with a synthesized CDK stack's
* manifest. Stack tags are not part of the synthesized template, so can only be
* checked from the manifest in this manner.
*/
export declare class Tags {
/**
* Find tags associated with a synthesized CDK `Stack`.
*
* @param stack the CDK Stack to find tags on.
*/
static fromStack(stack: Stack): Tags;
private readonly _tags;
private constructor();
/**
* Assert that the given Matcher or object matches the tags associated with
* the synthesized CDK Stack's manifest.
*
* @param tags the expected set of tags. This should be a
* string or Matcher object.
*/
hasValues(tags: any): void;
/**
* Assert that the there are no tags associated with the synthesized CDK
* Stack's manifest.
*
* This is a convenience method over `hasValues(Match.exact({}))`, and is
* present because the more obvious method of detecting no tags
* (`Match.absent()`) will not work. Manifests default the tag set to an empty
* object.
*/
hasNone(): void;
/**
* Get the tags associated with the manifest. This will be an empty object if
* no tags were supplied.
*
* @returns The tags associated with the stack's synthesized manifest.
*/
all(): ManifestTags;
}
export {};

2
cdk/node_modules/aws-cdk-lib/assertions/lib/tags.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Tags=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var match_1=()=>{var tmp=require("./match");return match_1=()=>tmp,tmp},matcher_1=()=>{var tmp=require("./matcher");return matcher_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},error_1=()=>{var tmp=require("./private/error");return error_1=()=>tmp,tmp};class Tags{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.assertions.Tags",version:"2.252.0"};static fromStack(stack){try{jsiiDeprecationWarnings().aws_cdk_lib_Stack(stack)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromStack),error}return new Tags(getManifestTags(stack))}_tags;constructor(tags){this._tags=tags}hasValues(tags){if(matcher_1().Matcher.isMatcher(tags)&&tags.name==="absent")throw new(error_1()).AssertionError('Match.absent() will never match Tags because "{}" is the default value. Use Tags.hasNone() instead.');const result=(matcher_1().Matcher.isMatcher(tags)?tags:match_1().Match.objectLike(tags)).test(this.all());if(result.hasFailed())throw new(error_1()).AssertionError(`Stack tags did not match as expected:
`+result.renderMismatch())}hasNone(){this.hasValues(match_1().Match.exact({}))}all(){return this._tags}}exports.Tags=Tags;function getManifestTags(stack){const root=stack.node.root;if(!core_1().Stage.isStage(root))throw new(error_1()).AssertionError("unexpected: all stacks must be part of a Stage or an App");return root.synth().getStackArtifact(stack.artifactId).tags}

View File

@@ -0,0 +1,211 @@
import type { Stack } from '../../core';
/**
* Suite of assertions that can be run on a CDK stack.
* Typically used, as part of unit tests, to validate that the rendered
* CloudFormation template has expected resources and properties.
*/
export declare class Template {
/**
* Base your assertions on the CloudFormation template synthesized by a CDK `Stack`.
* @param stack the CDK Stack to run assertions on
* @param templateParsingOptions Optional param to configure template parsing behavior, such as disregarding circular
* dependencies.
*/
static fromStack(stack: Stack, templateParsingOptions?: TemplateParsingOptions): Template;
/**
* Base your assertions from an existing CloudFormation template formatted as an in-memory
* JSON object.
* @param template the CloudFormation template formatted as a nested set of records
* @param templateParsingOptions Optional param to configure template parsing behavior, such as disregarding circular
* dependencies.
*/
static fromJSON(template: {
[key: string]: any;
}, templateParsingOptions?: TemplateParsingOptions): Template;
/**
* Base your assertions from an existing CloudFormation template formatted as a
* JSON string.
* @param template the CloudFormation template in
* @param templateParsingOptions Optional param to configure template parsing behavior, such as disregarding circular
* dependencies.
*/
static fromString(template: string, templateParsingOptions?: TemplateParsingOptions): Template;
private readonly template;
private constructor();
/**
* The CloudFormation template deserialized into an object.
*/
toJSON(): {
[key: string]: any;
};
/**
* Assert that the given number of resources of the given type exist in the
* template.
* @param type the resource type; ex: `AWS::S3::Bucket`
* @param count number of expected instances
*/
resourceCountIs(type: string, count: number): void;
/**
* Assert that the given number of resources of the given type and properties exists in the
* CloudFormation template.
* @param type the resource type; ex: `AWS::S3::Bucket`
* @param props the 'Properties' section of the resource as should be expected in the template.
* @param count number of expected instances
*/
resourcePropertiesCountIs(type: string, props: any, count: number): void;
/**
* Assert that a resource of the given type and properties exists in the
* CloudFormation template.
* By default, performs partial matching on the `Properties` key of the resource, via the
* `Match.objectLike()`. To configure different behavior, use other matchers in the `Match` class.
* @param type the resource type; ex: `AWS::S3::Bucket`
* @param props the 'Properties' section of the resource as should be expected in the template.
*/
hasResourceProperties(type: string, props: any): void;
/**
* Assert that a resource of the given type and given definition exists in the
* CloudFormation template.
* By default, performs partial matching on the resource, via the `Match.objectLike()`.
* To configure different behavior, use other matchers in the `Match` class.
* @param type the resource type; ex: `AWS::S3::Bucket`
* @param props the entire definition of the resource as should be expected in the template.
*/
hasResource(type: string, props: any): void;
/**
* Get the set of matching resources of a given type and properties in the CloudFormation template.
* @param type the type to match in the CloudFormation template
* @param props by default, matches all resources with the given type.
* When a literal is provided, performs a partial match via `Match.objectLike()`.
* Use the `Match` APIs to configure a different behaviour.
*/
findResources(type: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
/**
* Get the Resource ID of a matching resource, expects only to find one match.
* Throws AssertionError if none or multiple resources were found.
* @param type the resource type; ex: `AWS::S3::Bucket`
* @param props by default, matches all resources with the given type.
* @returns The resource id of the matched resource.
* Performs a partial match via `Match.objectLike()`.
*/
getResourceId(type: string, props?: any): string;
/**
* Assert that all resources of the given type contain the given definition in the
* CloudFormation template.
* By default, performs partial matching on the resource, via the `Match.objectLike()`.
* To configure different behavior, use other matchers in the `Match` class.
* @param type the resource type; ex: `AWS::S3::Bucket`
* @param props the entire definition of the resources as they should be expected in the template.
*/
allResources(type: string, props: any): void;
/**
* Assert that all resources of the given type contain the given properties
* CloudFormation template.
* By default, performs partial matching on the `Properties` key of the resource, via the
* `Match.objectLike()`. To configure different behavior, use other matchers in the `Match` class.
* @param type the resource type; ex: `AWS::S3::Bucket`
* @param props the 'Properties' section of the resource as should be expected in the template.
*/
allResourcesProperties(type: string, props: any): void;
/**
* Assert that a Parameter with the given properties exists in the CloudFormation template.
* By default, performs partial matching on the parameter, via the `Match.objectLike()`.
* To configure different behavior, use other matchers in the `Match` class.
* @param logicalId the name of the parameter, provide `'*'` to match all parameters in the template.
* @param props the parameter as should be expected in the template.
*/
hasParameter(logicalId: string, props: any): void;
/**
* Get the set of matching Parameters that match the given properties in the CloudFormation template.
* @param logicalId the name of the parameter, provide `'*'` to match all parameters in the template.
* @param props by default, matches all Parameters in the template.
* When a literal object is provided, performs a partial match via `Match.objectLike()`.
* Use the `Match` APIs to configure a different behaviour.
*/
findParameters(logicalId: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
/**
* Assert that an Output with the given properties exists in the CloudFormation template.
* By default, performs partial matching on the resource, via the `Match.objectLike()`.
* To configure different behavior, use other matchers in the `Match` class.
* @param logicalId the name of the output, provide `'*'` to match all outputs in the template.
* @param props the output as should be expected in the template.
*/
hasOutput(logicalId: string, props: any): void;
/**
* Get the set of matching Outputs that match the given properties in the CloudFormation template.
* @param logicalId the name of the output, provide `'*'` to match all outputs in the template.
* @param props by default, matches all Outputs in the template.
* When a literal object is provided, performs a partial match via `Match.objectLike()`.
* Use the `Match` APIs to configure a different behaviour.
*/
findOutputs(logicalId: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
/**
* Assert that a Mapping with the given properties exists in the CloudFormation template.
* By default, performs partial matching on the resource, via the `Match.objectLike()`.
* To configure different behavior, use other matchers in the `Match` class.
* @param logicalId the name of the mapping, provide `'*'` to match all mappings in the template.
* @param props the output as should be expected in the template.
*/
hasMapping(logicalId: string, props: any): void;
/**
* Get the set of matching Mappings that match the given properties in the CloudFormation template.
* @param logicalId the name of the mapping, provide `'*'` to match all mappings in the template.
* @param props by default, matches all Mappings in the template.
* When a literal object is provided, performs a partial match via `Match.objectLike()`.
* Use the `Match` APIs to configure a different behaviour.
*/
findMappings(logicalId: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
/**
* Assert that a Condition with the given properties exists in the CloudFormation template.
* By default, performs partial matching on the resource, via the `Match.objectLike()`.
* To configure different behavior, use other matchers in the `Match` class.
* @param logicalId the name of the mapping, provide `'*'` to match all conditions in the template.
* @param props the output as should be expected in the template.
*/
hasCondition(logicalId: string, props: any): void;
/**
* Get the set of matching Conditions that match the given properties in the CloudFormation template.
* @param logicalId the name of the condition, provide `'*'` to match all conditions in the template.
* @param props by default, matches all Conditions in the template.
* When a literal object is provided, performs a partial match via `Match.objectLike()`.
* Use the `Match` APIs to configure a different behaviour.
*/
findConditions(logicalId: string, props?: any): {
[key: string]: {
[key: string]: any;
};
};
/**
* Assert that the CloudFormation template matches the given value
* @param expected the expected CloudFormation template as key-value pairs.
*/
templateMatches(expected: any): void;
}
/**
* Options to configure template parsing behavior, such as disregarding circular
* dependencies.
*/
export interface TemplateParsingOptions {
/**
* If set to true, will skip checking for cyclical / circular dependencies. Should be set to false other than for
* templates that are valid despite containing cycles, such as unprocessed transform stacks.
*
* @default false
*/
readonly skipCyclicalDependenciesCheck?: boolean;
}

File diff suppressed because one or more lines are too long

115
cdk/node_modules/aws-cdk-lib/assertions/rewrite.toml generated vendored Normal file
View File

@@ -0,0 +1,115 @@
# comby -config ~/rewrite.toml -f .ts -d test -in-place -timeout 10
[000_import]
match="import '@aws-cdk/assert-internal/jest'"
rewrite="import { Template } from '@aws-cdk/assertions'"
[000_import2]
match="import :[_] from '@aws-cdk/assert-internal'"
rewrite="import { Template } from '@aws-cdk/assertions'"
[100_jest_toHaveResourceLike_CompleteDefinition]
match="expect(:[stack]).toHaveResourceLike(:[args], ResourcePart.CompleteDefinition)"
rewrite="Template.fromStack(:[stack]).hasResource(:[args])"
[100_assert_toHaveResourceLike_CompleteDefinition]
match=":[[expect]](:[stack]).to(haveResourceLike(:[args], ResourcePart.CompleteDefinition))"
rewrite="Template.fromStack(:[stack]).hasResource(:[args])"
rule='''where match :[expect] {
| "expect" -> true
| "cdkExpect" -> true
| ":[_]" -> false
}'''
[100_jest_toHaveResource_CompleteDefinition]
match="expect(:[stack]).toHaveResource(:[args], ResourcePart.CompleteDefinition)"
rewrite="Template.fromStack(:[stack]).hasResource(:[args])"
[100_assert_toHaveResource_CompleteDefinition]
match=":[[expect]](:[stack]).to(haveResource(:[args], ResourcePart.CompleteDefinition))"
rewrite="Template.fromStack(:[stack]).hasResource(:[args])"
rule='''where match :[expect] {
| "expect" -> true
| "cdkExpect" -> true
| ":[_]" -> false
}'''
[200_jest_toHaveResourceLike]
match="expect(:[stack]).toHaveResourceLike(:[args])"
rewrite="Template.fromStack(:[stack]).hasResourceProperties(:[args])"
[200_assert_toHaveResourceLike]
match=":[[expect]](:[stack]).to(haveResourceLike(:[args]))"
rewrite="Template.fromStack(:[stack]).hasResourceProperties(:[args])"
rule='''where match :[expect] {
| "expect" -> true
| "cdkExpect" -> true
| ":[_]" -> false
}'''
[200_jest_toHaveResource]
match="expect(:[stack]).toHaveResource(:[args])"
rewrite="Template.fromStack(:[stack]).hasResourceProperties(:[args])"
[200_assert_toHaveResource]
match=":[[expect]](:[stack]).to(haveResource(:[args]))"
rewrite="Template.fromStack(:[stack]).hasResourceProperties(:[args])"
rule='''where match :[expect] {
| "expect" -> true
| "cdkExpect" -> true
| ":[_]" -> false
}'''
[200_jest_toCountResources]
match="expect(:[stack]).toCountResources"
rewrite="Template.fromStack(:[stack]).resourceCountIs"
[200_assert_toCountResources2]
match=":[[expect]](:[stack]).to(countResources(:[args]))"
rewrite="Template.fromStack(:[stack]).resourceCountIs(:[args])"
rule='''where match :[expect] {
| "expect" -> true
| "cdkExpect" -> true
| ":[_]" -> false
}'''
[200_jest_toMatchTemplate]
match="expect(:[stack]).toMatchTemplate"
rewrite="Template.fromStack(:[stack]).templateMatches"
[200_assert_toMatchTemplate]
match=":[[expect]](:[stack]).toMatchTemplate"
rewrite="Template.fromStack(:[stack]).templateMatches"
rule='''where match :[expect] {
| "expect" -> true
| "cdkExpect" -> true
| ":[_]" -> false
}'''
[300_notToHaveResourceLike]
match="expect(:[stack]).not.toHaveResourceLike(:[args])"
rewrite="Template.fromStack(:[stack]).resourceCountIs(:[args], 0)"
[300_notToHaveResource]
match="expect(:[stack]).not.toHaveResource(:[args])"
rewrite="Template.fromStack(:[stack]).resourceCountIs(:[args], 0)"
[arrayWith]
match="arrayWith(:[args])"
rewrite="Match.arrayWith([:[args]])"
[objectLike]
match="objectLike"
rewrite="Match.objectLike"
[absent]
match="ABSENT"
rewrite="Match.absent()"
[400_synthutils_template]
match="SynthUtils.synthesize(:[stack]).template"
rewrite="Template.fromStack(:[stack]).toJSON()"
[401_synthutils_assembly]
match="SynthUtils.synthesize(:[stack])"
rewrite="App.of(:[stack]).synth()"