@kensio/yulin 1.21.6 → 1.21.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/service/eventbridge/cfn/bus/sim-cfn-event-bus-creator.js +1 -0
- package/dist/service/eventbridge/cfn/bus/sim-cfn-event-bus-properties.d.ts +4 -0
- package/dist/service/eventbridge/cfn/bus/sim-cfn-event-bus-properties.js +26 -1
- package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-creator.js +3 -1
- package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-properties.d.ts +0 -7
- package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-properties.js +0 -20
- package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-unsimulated-properties.d.ts +13 -0
- package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-unsimulated-properties.js +59 -0
- package/dist/service/eventbridge/cfn/sim-cfn-event-bridge-resource-error.d.ts +1 -1
- package/dist/service/eventbridge/cfn/sim-cfn-event-bridge-resource-error.js +1 -1
- package/dist/service/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-properties.js +1 -1
- package/dist/service/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-property-rules.d.ts +3 -2
- package/dist/service/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-property-rules.js +25 -3
- package/dist/service/sns/cfn/topic/sim-cfn-sns-topic-creator.js +1 -0
- package/dist/service/sns/cfn/topic/sim-cfn-sns-topic-properties.d.ts +9 -4
- package/dist/service/sns/cfn/topic/sim-cfn-sns-topic-properties.js +18 -6
- package/dist/service/sns/cfn/topic/sim-cfn-sns-topic-property-names.d.ts +10 -0
- package/dist/service/sns/cfn/topic/sim-cfn-sns-topic-property-names.js +16 -1
- package/dist/service/ssm/cfn/parameter/sim-cfn-ssm-parameter-creator.js +1 -1
- package/dist/service/ssm/cfn/parameter/sim-cfn-ssm-parameter-properties.d.ts +11 -6
- package/dist/service/ssm/cfn/parameter/sim-cfn-ssm-parameter-properties.js +18 -9
- package/docs/README.md +33 -4
- package/docs/ai-skill/README.md +52 -54
- package/docs/cli/README.md +84 -94
- package/docs/factories/README.md +42 -54
- package/docs/lint/README.md +41 -67
- package/docs/non-aws-dependencies/README.md +72 -168
- package/docs/sdk/README.md +97 -98
- package/docs/serve/README.md +192 -898
- package/docs/services/eventbridge/README.md +10 -2
- package/docs/services/lambda/README.md +7 -1
- package/docs/services/sns/README.md +13 -7
- package/docs/services/ssm/README.md +6 -4
- package/docs/terraform/README.md +108 -126
- package/docs/time/README.md +80 -120
- package/llms.txt +1 -1
- package/package.json +1 -1
package/docs/sdk/README.md
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AWS SDK interception
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
`SimSdk` routes AWS SDK for JavaScript v3 commands to Yulin. Use it to test code that already sends
|
|
4
|
+
commands through AWS SDK clients.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
interaction with `SimAws` remains useful for seeding and inspecting simulated state from within
|
|
8
|
-
tests.
|
|
6
|
+
## Intercept a client
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`SimSdk` replaces the `send` method of an intercepted SDK client. Each sent Command is routed by
|
|
13
|
-
name to the matching operation of a simulated AWS service, and the result comes back to the caller
|
|
14
|
-
as a normal SDK response. Every Command is served in process.
|
|
15
|
-
|
|
16
|
-
Every `SimSdk` owns a simulated AWS environment. You can let it create its own, or give it an
|
|
17
|
-
existing one to share:
|
|
18
|
-
|
|
19
|
-
- `new SimSdk()` creates an isolated `SimAws` internally, available as `simSdk.simAws`.
|
|
20
|
-
- `new SimSdk({ simAws })` wraps a `SimAws` you already have.
|
|
21
|
-
|
|
22
|
-
## Basic usage
|
|
23
|
-
|
|
24
|
-
Intercept an SDK client class, then use the SDK as normal:
|
|
8
|
+
Create a `SimSdk`, intercept a client class, and run the code under test:
|
|
25
9
|
|
|
26
10
|
```typescript sim-sdk-intercept-s3
|
|
27
11
|
/**
|
|
@@ -58,36 +42,33 @@ console.log(await output.Body?.transformToString()); // "Hello, world!"
|
|
|
58
42
|
simSdk.restoreAll();
|
|
59
43
|
```
|
|
60
44
|
|
|
61
|
-
|
|
45
|
+
Intercepting a class affects every instance of that class. This includes clients created after the
|
|
46
|
+
call to `intercept`. Intercepting an object affects that client only.
|
|
47
|
+
|
|
48
|
+
`SimSdk` replaces the intercepted client's `send` method. It routes each command to the matching
|
|
49
|
+
Yulin service and returns an SDK-shaped response. The request stays inside the process.
|
|
50
|
+
|
|
51
|
+
A client can have one active interception. A second interception throws
|
|
52
|
+
`SimSdkAlreadyInterceptedError` and leaves the first one in place.
|
|
62
53
|
|
|
63
|
-
|
|
64
|
-
the code under test constructs later. This is the most common choice.
|
|
65
|
-
- **An instance** (`simSdk.intercept(s3Client)`) intercepts only that instance. Use it when one
|
|
66
|
-
client should hit the simulator and the others are handled some other way.
|
|
54
|
+
## Access simulated state
|
|
67
55
|
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
`new SimSdk()` creates a `SimAws` instance and exposes it as `simSdk.simAws`. Use that instance to
|
|
57
|
+
prepare state before running the application, or to inspect state afterwards.
|
|
70
58
|
|
|
71
|
-
|
|
59
|
+
Pass an existing instance as `new SimSdk({ simAws })` when several parts of a test need to share the
|
|
60
|
+
same simulation.
|
|
72
61
|
|
|
73
|
-
|
|
62
|
+
## Account and region
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
2. The **Account** comes from the ambient `simAws.runAs(...)` caller when one is set, falling back
|
|
78
|
-
to the simulation default Account.
|
|
64
|
+
Yulin resolves the account and region for every `send` call. The client's `region` configuration
|
|
65
|
+
selects the simulated region. Yulin uses its default region when the client has none.
|
|
79
66
|
|
|
80
|
-
The
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
as the simulation's `defaultCaller`, and as the default Account root where the simulation was given
|
|
84
|
-
none. See
|
|
85
|
-
[Name the caller a simulation uses by default](https://yulinsim.dev/services/iam/#name-the-caller-a-simulation-uses-by-default).
|
|
67
|
+
The current `simAws.runAs(...)` caller selects the account. Without a `runAs` caller, Yulin uses the
|
|
68
|
+
simulation's default account and caller. Simulated [IAM](https://yulinsim.dev/services/iam/)
|
|
69
|
+
authorization applies to intercepted commands.
|
|
86
70
|
|
|
87
|
-
`runAs`
|
|
88
|
-
the run are attributed to that caller, with no changes to the client or the code under test. A
|
|
89
|
-
direct sim service call inside the run is attributed to it too, covered in
|
|
90
|
-
[Run a block of calls as one caller](https://yulinsim.dev/services/iam/#run-a-block-of-calls-as-one-caller):
|
|
71
|
+
Use `runAs` to send commands as a role without changing the client or the application code:
|
|
91
72
|
|
|
92
73
|
```typescript sim-sdk-run-as
|
|
93
74
|
/**
|
|
@@ -155,31 +136,31 @@ await simAws.runAs(
|
|
|
155
136
|
simSdk.restoreAll();
|
|
156
137
|
```
|
|
157
138
|
|
|
158
|
-
|
|
159
|
-
|
|
139
|
+
`runAs` applies only to the `SimAws` instance on which it was called. A caller set on another
|
|
140
|
+
simulation does not affect these commands.
|
|
160
141
|
|
|
161
|
-
##
|
|
142
|
+
## Restore the client
|
|
162
143
|
|
|
163
|
-
|
|
144
|
+
Restore an interception before later code needs the client's original `send` method:
|
|
164
145
|
|
|
165
|
-
- `
|
|
166
|
-
- `simSdk.restoreAll()`
|
|
167
|
-
- `SimSdk`
|
|
168
|
-
automatically at the end of the scope.
|
|
146
|
+
- Save the result of `simSdk.intercept(...)` and call its `restore()` method to restore one client.
|
|
147
|
+
- Call `simSdk.restoreAll()` to restore every client intercepted by that `SimSdk`.
|
|
148
|
+
- Declare `SimSdk` or an interception handle with `using` to restore it when the scope ends.
|
|
169
149
|
|
|
170
|
-
##
|
|
150
|
+
## Limit the intercepted commands
|
|
171
151
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
`simSdk.intercept(s3Client, { commands: [GetObjectCommand] })`. Commands outside the allow list
|
|
175
|
-
throw a diagnostic error.
|
|
152
|
+
An interception handles every command by default. Pass an allow list when a test should accept only
|
|
153
|
+
specific commands:
|
|
176
154
|
|
|
177
|
-
|
|
155
|
+
`simSdk.intercept(s3Client, { commands: [GetObjectCommand] })`
|
|
178
156
|
|
|
179
|
-
|
|
180
|
-
`
|
|
181
|
-
|
|
182
|
-
|
|
157
|
+
The list accepts command classes or command names. Sending another command throws
|
|
158
|
+
`SimSdkCommandNotInterceptedError`.
|
|
159
|
+
|
|
160
|
+
## Intercept the DynamoDB document client
|
|
161
|
+
|
|
162
|
+
The DynamoDB document client accepts plain JavaScript values. Intercept the document client object,
|
|
163
|
+
then send `@aws-sdk/lib-dynamodb` commands through it:
|
|
183
164
|
|
|
184
165
|
```typescript sim-sdk-document-client
|
|
185
166
|
/**
|
|
@@ -232,43 +213,61 @@ console.log(read.Item?.["total"]); // 42
|
|
|
232
213
|
console.log(read.Item?.["paid"]); // true
|
|
233
214
|
```
|
|
234
215
|
|
|
235
|
-
`DynamoDBDocumentClient.from(client)`
|
|
236
|
-
base
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
-
|
|
257
|
-
|
|
258
|
-
-
|
|
259
|
-
|
|
216
|
+
`DynamoDBDocumentClient.from(client)` returns a separate client object. Intercept that object, not
|
|
217
|
+
the base `DynamoDBClient`. You may intercept both clients. They use the same simulated tables when
|
|
218
|
+
their account and region match.
|
|
219
|
+
|
|
220
|
+
Yulin converts document values at the interception boundary. It uses the default translation
|
|
221
|
+
options from `@aws-sdk/lib-dynamodb`. The [DynamoDB documentation](https://yulinsim.dev/services/dynamodb/#the-document-client)
|
|
222
|
+
lists the supported value conversions.
|
|
223
|
+
|
|
224
|
+
## Available functionality
|
|
225
|
+
|
|
226
|
+
SDK interception supports these service clients:
|
|
227
|
+
|
|
228
|
+
- ACM
|
|
229
|
+
- API Gateway REST APIs and HTTP APIs
|
|
230
|
+
- Athena
|
|
231
|
+
- AWS Backup
|
|
232
|
+
- Bedrock Runtime
|
|
233
|
+
- CloudFormation
|
|
234
|
+
- CloudFront and CloudFront KeyValueStore
|
|
235
|
+
- CloudWatch metrics and CloudWatch Logs
|
|
236
|
+
- Cognito Identity Provider
|
|
237
|
+
- DynamoDB and DynamoDB Streams
|
|
238
|
+
- ECS and Elastic Load Balancing v2
|
|
239
|
+
- EventBridge and EventBridge Scheduler
|
|
240
|
+
- Glue
|
|
241
|
+
- IAM
|
|
242
|
+
- Kinesis Data Firehose and Kinesis Data Streams
|
|
243
|
+
- KMS
|
|
244
|
+
- Lambda
|
|
245
|
+
- Personalize, Personalize Events, and Personalize Runtime
|
|
246
|
+
- Rekognition
|
|
247
|
+
- Route 53
|
|
248
|
+
- S3
|
|
249
|
+
- Secrets Manager
|
|
250
|
+
- SESv2
|
|
251
|
+
- SNS and SQS
|
|
252
|
+
- SSM
|
|
253
|
+
- Step Functions
|
|
254
|
+
- STS
|
|
255
|
+
- WAFv2
|
|
256
|
+
|
|
257
|
+
Each service page lists the commands that service accepts. An unsupported command throws
|
|
258
|
+
`SimSdkUnsupportedCommandError` and includes the supported command names. A client for an unknown
|
|
259
|
+
service throws `SimSdkUnknownServiceError`.
|
|
260
260
|
|
|
261
261
|
## Limitations
|
|
262
262
|
|
|
263
|
-
-
|
|
264
|
-
`getSignedUrl`,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
- Yulin intercepts `client.send(command)`. SDK utilities that bypass `send`, including
|
|
264
|
+
`getSignedUrl`, bypass interception. Paginators and waiters use `send` and can be intercepted. To
|
|
265
|
+
use a presigned URL with Yulin, point the client at a served endpoint as shown in the
|
|
266
|
+
[S3 documentation](https://yulinsim.dev/services/s3/#presigned-urls).
|
|
267
|
+
- Simulated errors have SDK-shaped `name` and `$metadata` fields. They are separate classes from the
|
|
268
|
+
SDK exceptions, so match them by `error.name` instead of `instanceof`.
|
|
269
269
|
- The callback form of `send(command, callback)` is not supported. Use the promise form.
|
|
270
|
-
-
|
|
271
|
-
`DynamoDBDocumentClient.from(client, { marshallOptions, unmarshallOptions })
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
the attribute and says so.
|
|
270
|
+
- Yulin ignores the translation options in
|
|
271
|
+
`DynamoDBDocumentClient.from(client, { marshallOptions, unmarshallOptions })`. The conversion uses
|
|
272
|
+
the defaults. `removeUndefinedValues: true` has no effect. Yulin refuses an `undefined` attribute
|
|
273
|
+
that the configured document client would otherwise remove.
|