@kensio/yulin 1.21.7 → 1.21.9
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/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-properties.js +2 -0
- package/dist/service/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-property-rules.js +1 -1
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-input.d.ts +2 -0
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-input.js +4 -0
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-refusals.js +0 -5
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping.handler.d.ts +2 -0
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping.handler.js +2 -0
- package/dist/service/lambda/command/event-source-mapping/sim-lambda-event-source-mapping-commands.d.ts +2 -0
- package/dist/service/lambda/destination/sim-lambda-destination-targets.d.ts +2 -1
- package/dist/service/lambda/event-source/poll/kinesis/sim-lambda-kinesis-shard-poller.d.ts +0 -4
- package/dist/service/lambda/event-source/poll/kinesis/sim-lambda-kinesis-shard-poller.js +10 -15
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-event-source-poller.d.ts +1 -6
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-event-source-poller.js +9 -27
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-polling.d.ts +19 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-polling.js +27 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-event-source-function.d.ts +1 -1
- package/dist/service/lambda/event-source/poll/sim-lambda-event-source-function.js +3 -1
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-age.d.ts +13 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-age.js +27 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-info.d.ts +15 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-info.js +26 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-outcome.d.ts +1 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-outcome.js +7 -1
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-processing.d.ts +17 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-processing.js +12 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-cursor.d.ts +15 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-cursor.js +28 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-expiry.d.ts +19 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-expiry.js +23 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-context.d.ts +3 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-context.js +19 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-destination.d.ts +15 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-destination.js +38 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-record.d.ts +41 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-record.js +17 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress-state.d.ts +21 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress-state.js +39 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress.d.ts +7 -37
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress.js +22 -62
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-retry.d.ts +4 -39
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-retry.js +12 -64
- package/dist/service/lambda/event-source/sim-lambda-event-source-mapping.d.ts +10 -3
- package/dist/service/lambda/event-source/sim-lambda-event-source-mapping.js +12 -3
- package/dist/service/lambda/event-source/sim-lambda-stream-destination-config.d.ts +7 -0
- package/dist/service/lambda/event-source/sim-lambda-stream-destination-config.js +38 -0
- package/dist/service/lambda/event-source/stream/kinesis/sim-kinesis-event-source-streams.js +1 -0
- package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-reader.js +1 -0
- package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-shard.d.ts +1 -0
- package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-shard.js +7 -0
- package/dist/service/lambda/event-source/stream/sim-lambda-event-source-streams.d.ts +1 -0
- package/dist/service/lambda/index.d.ts +1 -0
- package/dist/service/lambda/sim-lambda-commands.js +1 -0
- 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/docs/README.md +7 -0
- package/docs/ai-skill/README.md +6 -1
- package/docs/sdk/README.md +15 -0
- 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 +14 -18
- 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 +112 -85
- 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 +18 -26
- package/docs/services/sqs/README.md +14 -14
- package/docs/services/ssm/README.md +13 -17
- 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/testing/README.md +228 -0
- package/docs/time/README.md +10 -0
- package/llms.txt +1 -0
- package/package.json +1 -1
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
# Simulated Athena
|
|
2
2
|
|
|
3
|
-
Yulin
|
|
4
|
-
|
|
3
|
+
Yulin simulates Amazon Athena workgroups, named queries and query execution for tests and local
|
|
4
|
+
development. Tests can supply a result for a particular SQL statement, or enable the optional
|
|
5
|
+
[query engine](#running-a-query-for-real) to run SQL against objects in simulated S3.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
project.
|
|
7
|
+
Both paths use the same query lifecycle. Athena checks tables in the simulated
|
|
8
|
+
[Glue Data Catalog](https://yulinsim.dev/services/glue/ "Simulated Glue usage docs"), applies the
|
|
9
|
+
workgroup's bytes-scanned limit and writes results to the configured S3 location. This lets client
|
|
10
|
+
code start a query, poll its status and read its results through the AWS SDK.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
refuses a query, that results land where the workgroup says, and that a client polls the lifecycle
|
|
14
|
-
correctly. The tables a query names are looked for in the simulated
|
|
15
|
-
[Glue Data Catalog](https://yulinsim.dev/services/glue/ "Simulated Glue usage docs"), and a query
|
|
16
|
-
naming one that is absent fails the way real Athena fails it. The
|
|
17
|
-
[Limitations](#limitations) at the end say what this leaves out.
|
|
18
|
-
|
|
19
|
-
Athena-specific types are imported from the `@kensio/yulin/athena` subpath.
|
|
12
|
+
Import Athena-specific types from `@kensio/yulin/athena`.
|
|
20
13
|
|
|
21
14
|
## Workgroups from a template
|
|
22
15
|
|
|
@@ -177,23 +170,21 @@ const results = await simAws.athena().getQueryResults({
|
|
|
177
170
|
console.log(results.ResultSet?.Rows?.[1]?.Data?.[1]?.VarCharValue);
|
|
178
171
|
```
|
|
179
172
|
|
|
180
|
-
A
|
|
181
|
-
|
|
182
|
-
|
|
173
|
+
A result declared for an exact query takes precedence over a workgroup result, which takes
|
|
174
|
+
precedence over the default result. Use `onWorkGroup` to cover every query in one workgroup and
|
|
175
|
+
`byDefault` as the fallback. Exact matching includes whitespace.
|
|
183
176
|
|
|
184
177
|
The query engine sits between the two tiers. A rule for an exact query is ahead of it and the
|
|
185
178
|
workgroup rule and the default are behind it.
|
|
186
179
|
|
|
187
|
-
`failsWith`
|
|
188
|
-
|
|
189
|
-
reachable.
|
|
180
|
+
Use `failsWith` to declare a failed query and test the client's error handling. Declared results do
|
|
181
|
+
not parse the SQL, so failures must be configured explicitly.
|
|
190
182
|
|
|
191
183
|
## Running a query for real
|
|
192
184
|
|
|
193
|
-
The query engine
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
nineteen queries in twenty of the shapes a test writes run this way.
|
|
185
|
+
The query engine runs a `SELECT` against objects seeded into simulated S3. It reads the table schema
|
|
186
|
+
from the Glue Data Catalog, decodes each object with the table's SerDe, loads the rows into an
|
|
187
|
+
in-memory SQLite database and executes the statement.
|
|
197
188
|
|
|
198
189
|
The engine is off until a test turns it on, and it needs `node-sql-parser` in the project. The
|
|
199
190
|
parser is an optional peer dependency, so a project that never runs a query never installs it. A
|
|
@@ -965,7 +956,7 @@ Every command is authorized against the workgroup ARN,
|
|
|
965
956
|
own and authorizes work on one against the workgroup it belongs to. This asks the same question.
|
|
966
957
|
`ListWorkGroups` names no workgroup, so IAM evaluates it against `*`.
|
|
967
958
|
|
|
968
|
-
##
|
|
959
|
+
## Supported operations
|
|
969
960
|
|
|
970
961
|
- Query executions, moving through `QUEUED` and `RUNNING` to `SUCCEEDED`, `FAILED` or `CANCELLED`
|
|
971
962
|
- `StartQueryExecution`, `GetQueryExecution`, `GetQueryResults` and `StopQueryExecution`
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Simulated AWS Backup
|
|
2
2
|
|
|
3
|
-
Yulin
|
|
4
|
-
|
|
3
|
+
Yulin simulates AWS Backup vaults, plans, selections, jobs and recovery points. Import Backup types
|
|
4
|
+
from `@kensio/yulin/backup`.
|
|
5
5
|
|
|
6
6
|
## Creating a vault, plan and selection
|
|
7
7
|
|
|
8
|
-
`simAws.backup()`
|
|
9
|
-
|
|
8
|
+
Use `simAws.backup()` for the default account and Region. Each plan rule names an existing vault. A
|
|
9
|
+
selection assigns resource ARNs to a plan.
|
|
10
10
|
|
|
11
11
|
```typescript sim-backup-create-plan-selection
|
|
12
12
|
/**
|
|
@@ -78,19 +78,17 @@ console.log(selection.BackupSelection?.Resources);
|
|
|
78
78
|
// ["arn:aws:dynamodb:us-east-1:888888888888:table/orders"]
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
A plan needs at least one
|
|
82
|
-
`cron(0 5 ? * * *)
|
|
83
|
-
|
|
81
|
+
A plan needs at least one named rule and target vault. The default schedule is
|
|
82
|
+
`cron(0 5 ? * * *)`. Yulin accepts six-field AWS cron expressions and rate expressions. It rejects
|
|
83
|
+
`at(...)` expressions.
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
`InvalidParameterValueException`. Set both values to `-1` to retain recovery points indefinitely.
|
|
85
|
+
When both lifecycle values are set, `DeleteAfterDays` must be at least 90 days after
|
|
86
|
+
`MoveToColdStorageAfterDays`. Use `-1` for both values to keep recovery points indefinitely.
|
|
88
87
|
|
|
89
88
|
## Running scheduled backups
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
resource ARN in
|
|
93
|
-
and creation time. The simulation completes backup jobs at the scheduled instant.
|
|
90
|
+
Plan rules run on the simulated clock. A due rule creates one completed job and recovery point for
|
|
91
|
+
each distinct resource ARN in its selections.
|
|
94
92
|
|
|
95
93
|
```typescript sim-backup-run-schedule
|
|
96
94
|
/**
|
|
@@ -161,19 +159,16 @@ console.log(points.RecoveryPoints?.[0]?.ResourceArn);
|
|
|
161
159
|
console.log(jobs.BackupJobs?.[0]?.State); // "COMPLETED"
|
|
162
160
|
```
|
|
163
161
|
|
|
164
|
-
`DeleteAfterDays` removes a recovery point when
|
|
165
|
-
|
|
166
|
-
Repeated schedules keep every unexpired recovery point.
|
|
162
|
+
`DeleteAfterDays` removes a recovery point when simulated time reaches its expiry. Recovery point
|
|
163
|
+
reads apply expiry before returning.
|
|
167
164
|
|
|
168
|
-
Vault Lock bounds
|
|
169
|
-
|
|
170
|
-
vault receives no recovery point for that job. Use `ListBackupJobs` or `DescribeBackupJob` to read
|
|
171
|
-
the failure and its `StatusMessage`.
|
|
165
|
+
Vault Lock bounds are checked when a backup starts. An invalid lifecycle produces a `FAILED` job and
|
|
166
|
+
no recovery point. Read the reason from the job's `StatusMessage`.
|
|
172
167
|
|
|
173
168
|
## Starting an on-demand backup
|
|
174
169
|
|
|
175
|
-
`StartBackupJob` completes
|
|
176
|
-
|
|
170
|
+
`StartBackupJob` completes at the current simulated time. It applies the same lifecycle and Vault
|
|
171
|
+
Lock checks as a scheduled job.
|
|
177
172
|
|
|
178
173
|
```typescript sim-backup-start-job
|
|
179
174
|
/**
|
|
@@ -219,9 +214,8 @@ console.log(point.CreationDate?.toISOString());
|
|
|
219
214
|
|
|
220
215
|
## Vault Lock
|
|
221
216
|
|
|
222
|
-
`PutBackupVaultLockConfiguration`
|
|
223
|
-
|
|
224
|
-
period ends, then becomes immutable.
|
|
217
|
+
`PutBackupVaultLockConfiguration` sets minimum and maximum retention. `ChangeableForDays` adds a
|
|
218
|
+
grace period. The configuration becomes immutable when that period ends.
|
|
225
219
|
|
|
226
220
|
```typescript sim-backup-vault-lock
|
|
227
221
|
/**
|
|
@@ -284,8 +278,7 @@ exceed the maximum, and the maximum cannot exceed 36,500 days. A lock without
|
|
|
284
278
|
## Deploying from CloudFormation
|
|
285
279
|
|
|
286
280
|
Simulated CloudFormation deploys `AWS::Backup::BackupVault`, `AWS::Backup::BackupPlan` and
|
|
287
|
-
`AWS::Backup::BackupSelection`.
|
|
288
|
-
them.
|
|
281
|
+
`AWS::Backup::BackupSelection`.
|
|
289
282
|
|
|
290
283
|
```typescript sim-backup-cloudformation
|
|
291
284
|
/**
|
|
@@ -376,10 +369,9 @@ Stack teardown removes all three resource types from the simulation.
|
|
|
376
369
|
|
|
377
370
|
## Permissions
|
|
378
371
|
|
|
379
|
-
Every supported operation
|
|
380
|
-
and selection operations use the plan ARN. `
|
|
381
|
-
|
|
382
|
-
`DescribeRecoveryPoint` uses the recovery point ARN. Backup job reads use `*`.
|
|
372
|
+
Every supported operation uses simulated IAM. Vault operations authorize against the vault ARN.
|
|
373
|
+
Plan and selection operations use the plan ARN. `DescribeRecoveryPoint` uses the recovery point ARN.
|
|
374
|
+
List and backup job read operations that name no resource use `*`.
|
|
383
375
|
|
|
384
376
|
```typescript sim-backup-iam-policy
|
|
385
377
|
/**
|
|
@@ -432,13 +424,12 @@ const created = await simAws.backup().createBackupVault(
|
|
|
432
424
|
console.log(created.BackupVaultName); // "application-backups"
|
|
433
425
|
```
|
|
434
426
|
|
|
435
|
-
Authorization runs before resource lookup. An unauthorized request for a missing
|
|
436
|
-
|
|
427
|
+
Authorization runs before resource lookup. An unauthorized request for a missing resource raises
|
|
428
|
+
`AccessDeniedException`.
|
|
437
429
|
|
|
438
430
|
## SDK interception
|
|
439
431
|
|
|
440
|
-
`
|
|
441
|
-
when a test owns it, or intercept the class when application code creates the client.
|
|
432
|
+
Intercept a `BackupClient` instance or the client class to route SDK commands to Yulin.
|
|
442
433
|
|
|
443
434
|
```typescript sim-backup-sdk-interception
|
|
444
435
|
/**
|
|
@@ -466,13 +457,12 @@ console.log(listed.BackupVaultList?.[0]?.BackupVaultName);
|
|
|
466
457
|
// "application-backups"
|
|
467
458
|
```
|
|
468
459
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
for class interception and credential handling.
|
|
460
|
+
Client Region and credentials select the simulated scope and caller. See
|
|
461
|
+
[SDK interception](https://yulinsim.dev/sdk/) for details.
|
|
472
462
|
|
|
473
463
|
## Account and Region scoping
|
|
474
464
|
|
|
475
|
-
|
|
465
|
+
Backup state is scoped by account and Region. The same vault name can exist in another scope.
|
|
476
466
|
|
|
477
467
|
```typescript sim-backup-account-region-scoping
|
|
478
468
|
/**
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# Simulated Bedrock
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Yulin answers Bedrock Runtime requests from response rules declared by the test. Model responses
|
|
4
|
+
come entirely from those rules.
|
|
5
5
|
|
|
6
6
|
Bedrock-specific types are imported from the `@kensio/yulin/bedrock` subpath.
|
|
7
7
|
|
|
8
8
|
## Answering a conversation
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
Declare a response with `onPrompt`, then call `converse`. The prompt is the text of the last user
|
|
11
|
+
message.
|
|
12
12
|
|
|
13
13
|
```typescript sim-bedrock-converse
|
|
14
14
|
/**
|
|
@@ -37,13 +37,12 @@ console.log(answered.output.message.content.at(0)?.text);
|
|
|
37
37
|
console.log(answered.stopReason); // "end_turn"
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
A conversation
|
|
41
|
-
conversation grows.
|
|
40
|
+
A multi-turn conversation also matches its last user message.
|
|
42
41
|
|
|
43
42
|
## Answering every call to one model
|
|
44
43
|
|
|
45
|
-
`onModel`
|
|
46
|
-
|
|
44
|
+
Use `onModel` when every call to one model should receive the same response. Prompt rules take
|
|
45
|
+
precedence over model rules.
|
|
47
46
|
|
|
48
47
|
```typescript sim-bedrock-model-rule
|
|
49
48
|
/**
|
|
@@ -71,13 +70,13 @@ const answered = await simAws.bedrock().converse(
|
|
|
71
70
|
console.log(answered.output.message.content.at(0)?.text); // "A short summary."
|
|
72
71
|
```
|
|
73
72
|
|
|
74
|
-
`byDefault`
|
|
75
|
-
built-in
|
|
73
|
+
`byDefault` handles calls that match no prompt or model rule. With no matching declaration, Yulin
|
|
74
|
+
returns a built-in simulated response for `Converse`.
|
|
76
75
|
|
|
77
76
|
## Answering with a tool call
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
Declare a `toolUse` content block to test code that handles model tool calls. The default stop reason
|
|
79
|
+
for this response is `tool_use`.
|
|
81
80
|
|
|
82
81
|
```typescript sim-bedrock-tool-use
|
|
83
82
|
/**
|
|
@@ -119,8 +118,8 @@ console.log(answered.output.message.content.at(0)?.toolUse?.name);
|
|
|
119
118
|
|
|
120
119
|
## Streaming a conversation
|
|
121
120
|
|
|
122
|
-
`ConverseStream`
|
|
123
|
-
|
|
121
|
+
`ConverseStream` uses the same rules as `Converse`. Declare `chunks` to control the text in each
|
|
122
|
+
stream event.
|
|
124
123
|
|
|
125
124
|
```typescript sim-bedrock-converse-stream
|
|
126
125
|
/**
|
|
@@ -156,14 +155,11 @@ for await (const event of answered.stream) {
|
|
|
156
155
|
console.log(accumulated); // "Entry 1042 covers the tone sandhi rules."
|
|
157
156
|
```
|
|
158
157
|
|
|
159
|
-
The
|
|
160
|
-
|
|
161
|
-
`metadata` carrying the token counts. A tool call adds a `contentBlockStart` before its delta,
|
|
162
|
-
carrying the tool use id and name.
|
|
158
|
+
The stream contains `messageStart`, content block events, `messageStop` and `metadata`. Tool calls
|
|
159
|
+
also include `contentBlockStart` with the tool use ID and name.
|
|
163
160
|
|
|
164
|
-
The same declaration serves both APIs. `Converse`
|
|
165
|
-
|
|
166
|
-
raises.
|
|
161
|
+
The same declaration serves both APIs. `Converse` joins declared chunks. Plain `text` becomes one
|
|
162
|
+
stream delta. A stream can be read once.
|
|
167
163
|
|
|
168
164
|
`InvokeModelWithResponseStream` streams the declared body as a single `chunk`:
|
|
169
165
|
|
|
@@ -175,8 +171,8 @@ for await (const event of answered.body) {
|
|
|
175
171
|
|
|
176
172
|
## Invoking a model directly
|
|
177
173
|
|
|
178
|
-
`InvokeModel`
|
|
179
|
-
|
|
174
|
+
`InvokeModel` returns the declared `body` as JSON. The response shape depends on the model, so this
|
|
175
|
+
operation has no built-in body.
|
|
180
176
|
|
|
181
177
|
```typescript sim-bedrock-invoke-model
|
|
182
178
|
/**
|
|
@@ -207,12 +203,11 @@ console.log(JSON.parse(new TextDecoder().decode(answered.body)));
|
|
|
207
203
|
// { results: [ { outputText: "Entry 1042 covers tone sandhi." } ] }
|
|
208
204
|
```
|
|
209
205
|
|
|
210
|
-
|
|
211
|
-
usually the one to reach for.
|
|
206
|
+
Prompt rules match the UTF-8 request body. Model rules are usually simpler for this API.
|
|
212
207
|
|
|
213
208
|
## Reporting token counts
|
|
214
209
|
|
|
215
|
-
`usage`
|
|
210
|
+
Set `usage` on a response rule to control token counts. Yulin uses fixed counts when it is omitted.
|
|
216
211
|
|
|
217
212
|
```typescript sim-bedrock-usage
|
|
218
213
|
/**
|
|
@@ -245,14 +240,13 @@ console.log(answered.usage.totalTokens); // 1620
|
|
|
245
240
|
|
|
246
241
|
## Authorizing an invocation
|
|
247
242
|
|
|
248
|
-
|
|
249
|
-
foundation model ARN
|
|
250
|
-
provisioned model ARN is authorized against as it was written.
|
|
243
|
+
Every invocation authorizes `bedrock:InvokeModel` against the requested model. A base model ID is
|
|
244
|
+
converted to a foundation model ARN in the request Region. Model ARNs are used unchanged.
|
|
251
245
|
|
|
252
246
|
## SDK interception
|
|
253
247
|
|
|
254
|
-
|
|
255
|
-
|
|
248
|
+
Intercept a `BedrockRuntimeClient` when application code constructs the client itself. Client
|
|
249
|
+
credentials and Region select the simulated scope.
|
|
256
250
|
|
|
257
251
|
```typescript sim-bedrock-sdk-interception
|
|
258
252
|
/**
|
|
@@ -296,32 +290,26 @@ simSdk.restoreAll();
|
|
|
296
290
|
|
|
297
291
|
- `Converse`, `ConverseStream`, `InvokeModel` and `InvokeModelWithResponseStream`, through
|
|
298
292
|
`simAws.bedrock()` and through an intercepted `BedrockRuntimeClient`.
|
|
299
|
-
- Responses declared with `onPrompt`, `onModel` and `byDefault
|
|
300
|
-
rule, then the default.
|
|
293
|
+
- Responses declared with `onPrompt`, `onModel` and `byDefault`, in that precedence order.
|
|
301
294
|
- A declared response carries `text`, `chunks` or `content` blocks for `Converse`, a `body` for
|
|
302
295
|
`InvokeModel`, and optionally a `stopReason` and a `usage`.
|
|
303
|
-
- Streamed responses
|
|
304
|
-
streaming and non-streaming APIs alike.
|
|
296
|
+
- Streamed responses with caller-controlled chunks.
|
|
305
297
|
- Tool calls, as a declared `toolUse` content block.
|
|
306
298
|
- IAM authorization of `bedrock:InvokeModel` against the foundation model, inference profile or
|
|
307
299
|
provisioned model ARN the request names.
|
|
308
|
-
- Rules
|
|
300
|
+
- Rules scoped by account and Region.
|
|
309
301
|
|
|
310
302
|
## Limitations
|
|
311
303
|
|
|
312
|
-
- No model runs.
|
|
313
|
-
a key to match on.
|
|
304
|
+
- No model runs. Yulin returns the matching declared response.
|
|
314
305
|
- Every event of a stream is ready as soon as the call returns. Real Bedrock sends them as the model
|
|
315
306
|
generates them. No simulated clock advance separates them here.
|
|
316
|
-
- A response is split
|
|
317
|
-
arrives in one delta. The split a real model streams comes from its own tokenizer.
|
|
307
|
+
- A response is split only at declared chunk boundaries. Other text arrives in one delta.
|
|
318
308
|
- A streamed tool call sends its arguments in one delta. Real `ConverseStream` sends them as
|
|
319
309
|
fragments of JSON to be concatenated. A tool call with no declared arguments sends `{}`.
|
|
320
310
|
- `InvokeModelWithResponseStream` sends the declared body as a single chunk. Real Bedrock sends a
|
|
321
311
|
chunk per generated fragment, in the shape the model behind the id uses.
|
|
322
|
-
-
|
|
323
|
-
the AWS JSON protocol services. A function bundling its own SDK reaches Bedrock through module
|
|
324
|
-
interception. S3 and every other non-JSON-protocol service are reached the same way.
|
|
312
|
+
- Serialized Bedrock requests are unsupported. Use SDK interception.
|
|
325
313
|
- The Bedrock control plane is unsimulated. `ListFoundationModels`, guardrail management, inference
|
|
326
314
|
profile management and provisioned throughput all belong to `BedrockClient`.
|
|
327
315
|
- Bedrock Agents and knowledge bases are unsimulated. `InvokeAgent`, `Retrieve` and
|
|
@@ -329,22 +317,20 @@ simSdk.restoreAll();
|
|
|
329
317
|
- `ApplyGuardrail` is unsimulated, and a `guardrailConfig` or a `guardrailIdentifier` on an
|
|
330
318
|
invocation is refused outright. Answering without the guardrail would make one look applied here
|
|
331
319
|
and be applied in production.
|
|
332
|
-
- `system`, `inferenceConfig`, `toolConfig` and `additionalModelRequestFields` are accepted and
|
|
333
|
-
|
|
320
|
+
- `system`, `inferenceConfig`, `toolConfig` and `additionalModelRequestFields` are accepted and have
|
|
321
|
+
no effect. `maxTokens` truncates no declared response, and a `toolConfig` naming no tools
|
|
334
322
|
still gets a declared tool call.
|
|
335
323
|
- Token counts are fixed unless the declaration carries them. Counting them needs the tokenizer of
|
|
336
324
|
the model the request names. Declare a `usage` where the code under test meters spend.
|
|
337
325
|
- `metrics.latencyMs` is always zero. No time passes during an invocation.
|
|
338
326
|
- A `Converse` with no messages is refused. Real Bedrock accepts one where the `modelId` names a
|
|
339
327
|
prompt version from Prompt management, which is unsimulated.
|
|
340
|
-
-
|
|
341
|
-
be failing closed against Yulin's own gaps.
|
|
328
|
+
- Any model ID is accepted.
|
|
342
329
|
- `InvokeModel` has no built-in default response body, and an invocation matching a rule that
|
|
343
330
|
declares none is refused. A response body is model-specific, and one family's shape served for
|
|
344
331
|
every other one would parse into something the caller cannot read.
|
|
345
|
-
- An `InvokeModel` body
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
does not fall back to the default.
|
|
332
|
+
- An `InvokeModel` body supplied as a stream or `Blob` cannot match a prompt rule. It may still match
|
|
333
|
+
a model or default rule.
|
|
334
|
+
- A `Converse` call matching a response declared only as a body is refused for the same reason. The
|
|
335
|
+
matching rule prevents the default rule from being selected.
|
|
350
336
|
- There are no CloudFormation resource types for Bedrock, and Bedrock is absent from `serveSimAws`.
|