@kensio/yulin 1.21.6 → 1.21.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -2
- 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/ses/command/authorize/sim-ses-authorizer.d.ts +9 -0
- package/dist/service/ses/command/authorize/sim-ses-authorizer.js +18 -2
- package/dist/service/ses/command/send/sim-ses-send-email.js +2 -1
- 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 +40 -4
- package/docs/ai-skill/README.md +57 -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 +109 -95
- package/docs/serve/README.md +192 -898
- package/docs/services/acm/README.md +24 -40
- package/docs/services/apigateway/README.md +52 -71
- package/docs/services/apigatewayv2/README.md +55 -74
- package/docs/services/athena/README.md +17 -26
- package/docs/services/backup/README.md +29 -39
- package/docs/services/bedrock/README.md +38 -52
- package/docs/services/cloudformation/README.md +43 -55
- package/docs/services/cloudfront/README.md +69 -95
- package/docs/services/cloudwatch/README.md +40 -54
- package/docs/services/cognito/README.md +30 -45
- package/docs/services/dynamodb/README.md +34 -51
- package/docs/services/ecr/README.md +36 -77
- package/docs/services/ecs/README.md +26 -46
- package/docs/services/elbv2/README.md +19 -29
- package/docs/services/eventbridge/README.md +24 -20
- package/docs/services/firehose/README.md +24 -32
- package/docs/services/glue/README.md +41 -78
- package/docs/services/iam/README.md +13 -15
- package/docs/services/kinesis/README.md +53 -93
- package/docs/services/kms/README.md +22 -32
- package/docs/services/lambda/README.md +60 -80
- package/docs/services/logs/README.md +41 -50
- package/docs/services/organizations/README.md +50 -85
- package/docs/services/personalize/README.md +28 -44
- package/docs/services/rekognition/README.md +26 -38
- package/docs/services/route53/README.md +17 -17
- package/docs/services/s3/README.md +47 -51
- package/docs/services/scheduler/README.md +41 -52
- package/docs/services/secretsmanager/README.md +27 -42
- package/docs/services/ses/README.md +24 -34
- package/docs/services/sns/README.md +31 -33
- package/docs/services/sqs/README.md +14 -14
- package/docs/services/ssm/README.md +19 -21
- package/docs/services/stepfunctions/README.md +18 -20
- package/docs/services/sts/README.md +32 -45
- package/docs/services/wafv2/README.md +12 -17
- package/docs/terraform/README.md +108 -126
- package/docs/testing/README.md +228 -0
- package/docs/time/README.md +87 -117
- package/llms.txt +2 -1
- package/package.json +1 -1
package/docs/sdk/README.md
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
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
|
+
## Install interception in suite setup
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
Application tests should normally create one `SimSdk` in Vitest suite setup and keep its class
|
|
9
|
+
interceptions installed for the whole suite. Every SDK client then reaches the same simulated state,
|
|
10
|
+
including clients created in different test files.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
The [test suite setup guide](https://yulinsim.dev/testing/) shows how to share one in-process
|
|
13
|
+
environment across Vitest files. It also covers the worker and isolation settings this requires.
|
|
14
|
+
A separate `SimSdk` for each test or file remains supported when a case needs an empty environment.
|
|
15
|
+
Tests that control the simulation's clock should use a separate `SimSdk` so their time changes cannot
|
|
16
|
+
affect the shared suite.
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
existing one to share:
|
|
18
|
+
## Intercept a client
|
|
18
19
|
|
|
19
|
-
|
|
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:
|
|
20
|
+
Create a `SimSdk`, intercept a client class, and run the code under test:
|
|
25
21
|
|
|
26
22
|
```typescript sim-sdk-intercept-s3
|
|
27
23
|
/**
|
|
@@ -58,36 +54,33 @@ console.log(await output.Body?.transformToString()); // "Hello, world!"
|
|
|
58
54
|
simSdk.restoreAll();
|
|
59
55
|
```
|
|
60
56
|
|
|
61
|
-
|
|
57
|
+
Intercepting a class affects every instance of that class. This includes clients created after the
|
|
58
|
+
call to `intercept`. Intercepting an object affects that client only.
|
|
59
|
+
|
|
60
|
+
`SimSdk` replaces the intercepted client's `send` method. It routes each command to the matching
|
|
61
|
+
Yulin service and returns an SDK-shaped response. The request stays inside the process.
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
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.
|
|
63
|
+
A client can have one active interception. A second interception throws
|
|
64
|
+
`SimSdkAlreadyInterceptedError` and leaves the first one in place.
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
throws a diagnostic error, and the existing interception stays in place.
|
|
66
|
+
## Access simulated state
|
|
70
67
|
|
|
71
|
-
|
|
68
|
+
`new SimSdk()` creates a `SimAws` instance and exposes it as `simSdk.simAws`. Use that instance to
|
|
69
|
+
prepare state before running the application, or to inspect state afterwards.
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
Pass an existing instance as `new SimSdk({ simAws })` when several parts of a test need to share the
|
|
72
|
+
same simulation.
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
`new S3Client({ region: "eu-west-2" })`, falling back to the simulation default.
|
|
77
|
-
2. The **Account** comes from the ambient `simAws.runAs(...)` caller when one is set, falling back
|
|
78
|
-
to the simulation default Account.
|
|
74
|
+
## Account and region
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
permission for a Command is denied, as on real AWS. Where no caller can be identified, Commands run
|
|
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).
|
|
76
|
+
Yulin resolves the account and region for every `send` call. The client's `region` configuration
|
|
77
|
+
selects the simulated region. Yulin uses its default region when the client has none.
|
|
86
78
|
|
|
87
|
-
`runAs`
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
The current `simAws.runAs(...)` caller selects the account. Without a `runAs` caller, Yulin uses the
|
|
80
|
+
simulation's default account and caller. Simulated [IAM](https://yulinsim.dev/services/iam/)
|
|
81
|
+
authorization applies to intercepted commands.
|
|
82
|
+
|
|
83
|
+
Use `runAs` to send commands as a role without changing the client or the application code:
|
|
91
84
|
|
|
92
85
|
```typescript sim-sdk-run-as
|
|
93
86
|
/**
|
|
@@ -155,31 +148,34 @@ await simAws.runAs(
|
|
|
155
148
|
simSdk.restoreAll();
|
|
156
149
|
```
|
|
157
150
|
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
`runAs` applies only to the `SimAws` instance on which it was called. A caller set on another
|
|
152
|
+
simulation does not affect these commands.
|
|
153
|
+
|
|
154
|
+
## Restore the client
|
|
155
|
+
|
|
156
|
+
Restore an interception before later code needs the client's original `send` method:
|
|
160
157
|
|
|
161
|
-
|
|
158
|
+
- Save the result of `simSdk.intercept(...)` and call its `restore()` method to restore one client.
|
|
159
|
+
- Call `simSdk.restoreAll()` to restore every client intercepted by that `SimSdk`.
|
|
160
|
+
- Declare `SimSdk` or an interception handle with `using` to restore it when the scope ends.
|
|
162
161
|
|
|
163
|
-
|
|
162
|
+
A suite-wide interception stays installed until the test worker exits. Do not restore it in a
|
|
163
|
+
per-file `afterAll`, since later files use the same interception and simulated state.
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
- `simSdk.restoreAll()` restores everything intercepted through that `SimSdk`.
|
|
167
|
-
- `SimSdk` and interception handles are disposable. `using simSdk = new SimSdk();` restores
|
|
168
|
-
automatically at the end of the scope.
|
|
165
|
+
## Limit the intercepted commands
|
|
169
166
|
|
|
170
|
-
|
|
167
|
+
An interception handles every command by default. Pass an allow list when a test should accept only
|
|
168
|
+
specific commands:
|
|
171
169
|
|
|
172
|
-
|
|
173
|
-
intercept only specific Commands, pass an allow list of Command classes or names:
|
|
174
|
-
`simSdk.intercept(s3Client, { commands: [GetObjectCommand] })`. Commands outside the allow list
|
|
175
|
-
throw a diagnostic error.
|
|
170
|
+
`simSdk.intercept(s3Client, { commands: [GetObjectCommand] })`
|
|
176
171
|
|
|
177
|
-
|
|
172
|
+
The list accepts command classes or command names. Sending another command throws
|
|
173
|
+
`SimSdkCommandNotInterceptedError`.
|
|
178
174
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
## Intercept the DynamoDB document client
|
|
176
|
+
|
|
177
|
+
The DynamoDB document client accepts plain JavaScript values. Intercept the document client object,
|
|
178
|
+
then send `@aws-sdk/lib-dynamodb` commands through it:
|
|
183
179
|
|
|
184
180
|
```typescript sim-sdk-document-client
|
|
185
181
|
/**
|
|
@@ -232,43 +228,61 @@ console.log(read.Item?.["total"]); // 42
|
|
|
232
228
|
console.log(read.Item?.["paid"]); // true
|
|
233
229
|
```
|
|
234
230
|
|
|
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
|
-
|
|
231
|
+
`DynamoDBDocumentClient.from(client)` returns a separate client object. Intercept that object, not
|
|
232
|
+
the base `DynamoDBClient`. You may intercept both clients. They use the same simulated tables when
|
|
233
|
+
their account and region match.
|
|
234
|
+
|
|
235
|
+
Yulin converts document values at the interception boundary. It uses the default translation
|
|
236
|
+
options from `@aws-sdk/lib-dynamodb`. The [DynamoDB documentation](https://yulinsim.dev/services/dynamodb/#the-document-client)
|
|
237
|
+
lists the supported value conversions.
|
|
238
|
+
|
|
239
|
+
## Available functionality
|
|
240
|
+
|
|
241
|
+
SDK interception supports these service clients:
|
|
242
|
+
|
|
243
|
+
- ACM
|
|
244
|
+
- API Gateway REST APIs and HTTP APIs
|
|
245
|
+
- Athena
|
|
246
|
+
- AWS Backup
|
|
247
|
+
- Bedrock Runtime
|
|
248
|
+
- CloudFormation
|
|
249
|
+
- CloudFront and CloudFront KeyValueStore
|
|
250
|
+
- CloudWatch metrics and CloudWatch Logs
|
|
251
|
+
- Cognito Identity Provider
|
|
252
|
+
- DynamoDB and DynamoDB Streams
|
|
253
|
+
- ECS and Elastic Load Balancing v2
|
|
254
|
+
- EventBridge and EventBridge Scheduler
|
|
255
|
+
- Glue
|
|
256
|
+
- IAM
|
|
257
|
+
- Kinesis Data Firehose and Kinesis Data Streams
|
|
258
|
+
- KMS
|
|
259
|
+
- Lambda
|
|
260
|
+
- Personalize, Personalize Events, and Personalize Runtime
|
|
261
|
+
- Rekognition
|
|
262
|
+
- Route 53
|
|
263
|
+
- S3
|
|
264
|
+
- Secrets Manager
|
|
265
|
+
- SESv2
|
|
266
|
+
- SNS and SQS
|
|
267
|
+
- SSM
|
|
268
|
+
- Step Functions
|
|
269
|
+
- STS
|
|
270
|
+
- WAFv2
|
|
271
|
+
|
|
272
|
+
Each service page lists the commands that service accepts. An unsupported command throws
|
|
273
|
+
`SimSdkUnsupportedCommandError` and includes the supported command names. A client for an unknown
|
|
274
|
+
service throws `SimSdkUnknownServiceError`.
|
|
260
275
|
|
|
261
276
|
## Limitations
|
|
262
277
|
|
|
263
|
-
-
|
|
264
|
-
`getSignedUrl`,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
278
|
+
- Yulin intercepts `client.send(command)`. SDK utilities that bypass `send`, including
|
|
279
|
+
`getSignedUrl`, bypass interception. Paginators and waiters use `send` and can be intercepted. To
|
|
280
|
+
use a presigned URL with Yulin, point the client at a served endpoint as shown in the
|
|
281
|
+
[S3 documentation](https://yulinsim.dev/services/s3/#presigned-urls).
|
|
282
|
+
- Simulated errors have SDK-shaped `name` and `$metadata` fields. They are separate classes from the
|
|
283
|
+
SDK exceptions, so match them by `error.name` instead of `instanceof`.
|
|
269
284
|
- 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.
|
|
285
|
+
- Yulin ignores the translation options in
|
|
286
|
+
`DynamoDBDocumentClient.from(client, { marshallOptions, unmarshallOptions })`. The conversion uses
|
|
287
|
+
the defaults. `removeUndefinedValues: true` has no effect. Yulin refuses an `undefined` attribute
|
|
288
|
+
that the configured document client would otherwise remove.
|