Commit 6804c7c
authored
fix(events): restore
### Issue # (if applicable)
Closes #36902.
### Reason for this change
PR #36602 introduced a regression where `Match.anyOf()` no longer accepts raw strings as arguments. The change assumed all arguments are arrays (results from other Match methods), causing the method to call `.map()` on strings, which fails. Users who previously used `Match.anyOf("string1", "string2")` now get a TypeError.
### Description of changes
Modified the `anyOf()` method in `event-pattern.ts` to handle both raw values (strings, numbers) and arrays (results from other Match methods):
- Added `Array.isArray()` check to detect input type
- Arrays from Match methods are processed with `match.map(Token.asString)`
- Raw values are wrapped as single-element arrays with `[Token.asString(match)]`
- Added unit tests for raw string inputs and mixed inputs
This restores backward compatibility while maintaining the fix from PR #36602 for array inputs.
### Describe any new or updated permissions being added
N/A - No IAM permission changes. This is a CDK API fix that does not affect CloudFormation template generation or resource permissions.
### Description of how you validated changes
- **Unit tests**: Added 2 new test cases in `matchers.test.ts`:
- `anyOf with raw strings` - Tests `Match.anyOf('string1', 'string2')` and single string inputs
- `anyOf with mixed inputs` - Tests combinations of raw strings and Match method results
- **Existing tests**: All 39 existing tests continue to pass
- **Build verification**: Module compiles successfully with no linting errors
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
[comment]: <> (cdk-contribution-power preview)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*Match.anyOf support for raw strings (#36908)1 parent 9ccb548 commit 6804c7c
2 files changed
Lines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
230 | 237 | | |
231 | 238 | | |
232 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
116 | 150 | | |
117 | 151 | | |
118 | 152 | | |
| |||
0 commit comments