@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.
Files changed (99) hide show
  1. package/README.md +22 -2
  2. package/dist/service/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-properties.js +2 -0
  3. package/dist/service/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-property-rules.js +1 -1
  4. package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-input.d.ts +2 -0
  5. package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-input.js +4 -0
  6. package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-refusals.js +0 -5
  7. package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping.handler.d.ts +2 -0
  8. package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping.handler.js +2 -0
  9. package/dist/service/lambda/command/event-source-mapping/sim-lambda-event-source-mapping-commands.d.ts +2 -0
  10. package/dist/service/lambda/destination/sim-lambda-destination-targets.d.ts +2 -1
  11. package/dist/service/lambda/event-source/poll/kinesis/sim-lambda-kinesis-shard-poller.d.ts +0 -4
  12. package/dist/service/lambda/event-source/poll/kinesis/sim-lambda-kinesis-shard-poller.js +10 -15
  13. package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-event-source-poller.d.ts +1 -6
  14. package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-event-source-poller.js +9 -27
  15. package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-polling.d.ts +19 -0
  16. package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-polling.js +27 -0
  17. package/dist/service/lambda/event-source/poll/sim-lambda-event-source-function.d.ts +1 -1
  18. package/dist/service/lambda/event-source/poll/sim-lambda-event-source-function.js +3 -1
  19. package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-age.d.ts +13 -0
  20. package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-age.js +27 -0
  21. package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-info.d.ts +15 -0
  22. package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-info.js +26 -0
  23. package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-outcome.d.ts +1 -0
  24. package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-outcome.js +7 -1
  25. package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-processing.d.ts +17 -0
  26. package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-processing.js +12 -0
  27. package/dist/service/lambda/event-source/poll/sim-lambda-stream-cursor.d.ts +15 -0
  28. package/dist/service/lambda/event-source/poll/sim-lambda-stream-cursor.js +28 -0
  29. package/dist/service/lambda/event-source/poll/sim-lambda-stream-expiry.d.ts +19 -0
  30. package/dist/service/lambda/event-source/poll/sim-lambda-stream-expiry.js +23 -0
  31. package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-context.d.ts +3 -0
  32. package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-context.js +19 -0
  33. package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-destination.d.ts +15 -0
  34. package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-destination.js +38 -0
  35. package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-record.d.ts +41 -0
  36. package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-record.js +17 -0
  37. package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress-state.d.ts +21 -0
  38. package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress-state.js +39 -0
  39. package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress.d.ts +7 -37
  40. package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress.js +22 -62
  41. package/dist/service/lambda/event-source/poll/sim-lambda-stream-retry.d.ts +4 -39
  42. package/dist/service/lambda/event-source/poll/sim-lambda-stream-retry.js +12 -64
  43. package/dist/service/lambda/event-source/sim-lambda-event-source-mapping.d.ts +10 -3
  44. package/dist/service/lambda/event-source/sim-lambda-event-source-mapping.js +12 -3
  45. package/dist/service/lambda/event-source/sim-lambda-stream-destination-config.d.ts +7 -0
  46. package/dist/service/lambda/event-source/sim-lambda-stream-destination-config.js +38 -0
  47. package/dist/service/lambda/event-source/stream/kinesis/sim-kinesis-event-source-streams.js +1 -0
  48. package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-reader.js +1 -0
  49. package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-shard.d.ts +1 -0
  50. package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-shard.js +7 -0
  51. package/dist/service/lambda/event-source/stream/sim-lambda-event-source-streams.d.ts +1 -0
  52. package/dist/service/lambda/index.d.ts +1 -0
  53. package/dist/service/lambda/sim-lambda-commands.js +1 -0
  54. package/dist/service/ses/command/authorize/sim-ses-authorizer.d.ts +9 -0
  55. package/dist/service/ses/command/authorize/sim-ses-authorizer.js +18 -2
  56. package/dist/service/ses/command/send/sim-ses-send-email.js +2 -1
  57. package/docs/README.md +7 -0
  58. package/docs/ai-skill/README.md +6 -1
  59. package/docs/sdk/README.md +15 -0
  60. package/docs/services/acm/README.md +24 -40
  61. package/docs/services/apigateway/README.md +52 -71
  62. package/docs/services/apigatewayv2/README.md +55 -74
  63. package/docs/services/athena/README.md +17 -26
  64. package/docs/services/backup/README.md +29 -39
  65. package/docs/services/bedrock/README.md +38 -52
  66. package/docs/services/cloudformation/README.md +43 -55
  67. package/docs/services/cloudfront/README.md +69 -95
  68. package/docs/services/cloudwatch/README.md +40 -54
  69. package/docs/services/cognito/README.md +30 -45
  70. package/docs/services/dynamodb/README.md +34 -51
  71. package/docs/services/ecr/README.md +36 -77
  72. package/docs/services/ecs/README.md +26 -46
  73. package/docs/services/elbv2/README.md +19 -29
  74. package/docs/services/eventbridge/README.md +14 -18
  75. package/docs/services/firehose/README.md +24 -32
  76. package/docs/services/glue/README.md +41 -78
  77. package/docs/services/iam/README.md +13 -15
  78. package/docs/services/kinesis/README.md +53 -93
  79. package/docs/services/kms/README.md +22 -32
  80. package/docs/services/lambda/README.md +112 -85
  81. package/docs/services/logs/README.md +41 -50
  82. package/docs/services/organizations/README.md +50 -85
  83. package/docs/services/personalize/README.md +28 -44
  84. package/docs/services/rekognition/README.md +26 -38
  85. package/docs/services/route53/README.md +17 -17
  86. package/docs/services/s3/README.md +47 -51
  87. package/docs/services/scheduler/README.md +41 -52
  88. package/docs/services/secretsmanager/README.md +27 -42
  89. package/docs/services/ses/README.md +24 -34
  90. package/docs/services/sns/README.md +18 -26
  91. package/docs/services/sqs/README.md +14 -14
  92. package/docs/services/ssm/README.md +13 -17
  93. package/docs/services/stepfunctions/README.md +18 -20
  94. package/docs/services/sts/README.md +32 -45
  95. package/docs/services/wafv2/README.md +12 -17
  96. package/docs/testing/README.md +228 -0
  97. package/docs/time/README.md +10 -0
  98. package/llms.txt +1 -0
  99. package/package.json +1 -1
@@ -1,22 +1,15 @@
1
1
  # Simulated Athena
2
2
 
3
- Yulin includes a simulated Amazon Athena for tests and local development. It holds workgroups and
4
- named queries, and hands both back through the SDK.
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
- A query is answered one of two ways. A test declares what it answers with, and the simulation
7
- matches that declaration on the query text. Or the
8
- [query engine](#running-a-query-for-real) runs the SQL for real over the objects a test seeded into
9
- simulated S3. The engine is off until a test turns it on, and it needs one package added to the
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
- Either way the lifecycle around the query is real. A test can prove its bytes-scanned cutoff
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 rule for an exact query wins, then a rule for a workgroup, then the default. `onWorkGroup` covers
181
- every query a stack's rollups run, and `byDefault` covers everything else. Matching is exact, on the
182
- query text as it was sent, so two queries differing only in whitespace are two different keys.
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` fails a query instead of answering it. Nothing here reads SQL, so a query that should
188
- fail cannot be discovered on its own. Saying so is what makes a client's failure handling
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 answers a `SELECT` from the objects a test seeded into simulated S3. It reads the
194
- table's schema out of the Glue Data Catalog, decodes each object with the SerDe the table declares,
195
- loads the rows into an in-memory SQLite database, and answers the statement from them. Roughly
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
- ## Available functionality
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 includes simulated AWS Backup vaults, plans, selections, backup jobs and recovery points for
4
- tests and local development. AWS Backup types are imported from the `@kensio/yulin/backup` subpath.
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()` gives the AWS Backup service for the default account and Region. A plan rule names
9
- an existing vault. A selection belongs to one plan and records the resource ARNs assigned to it.
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 rule. Every rule needs a name and a target vault. An omitted schedule uses
82
- `cron(0 5 ? * * *)`, the AWS Backup default. Six-field AWS cron expressions and rate expressions
83
- are validated when the plan is created. A one-time `at(...)` expression is refused.
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
- `MoveToColdStorageAfterDays` can be combined with `DeleteAfterDays`. The deletion must be at least
86
- 90 days after the move to cold storage. A shorter lifecycle raises
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
- Each plan rule runs on the simulated clock. A due rule creates one recovery point for each distinct
92
- resource ARN in the plan's selections. The recovery point records the rule, resource ARN, lifecycle
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 the clock reaches its deletion time. Vault reads,
165
- `ListRecoveryPointsByBackupVault` and `DescribeRecoveryPoint` apply the expiry before returning.
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 apply when a backup starts. A lifecycle shorter than `MinRetentionDays`, longer
169
- than `MaxRetentionDays` or indefinite under a finite maximum produces a `FAILED` backup job. The
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 an on-demand job at the current simulated time. It applies the same
176
- lifecycle validation and Vault Lock bounds as a scheduled rule.
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` records minimum and maximum retention periods on a vault. Adding
223
- `ChangeableForDays` creates a compliance lock. The configuration stays changeable until the grace
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`. References between the resources resolve before AWS Backup creates
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 is authorized by simulated IAM. Vault operations use the vault ARN. Plan
380
- and selection operations use the plan ARN. `ListBackupVaults` has no resource in its request and is
381
- authorized against `*`. `StartBackupJob` and `ListRecoveryPointsByBackupVault` use the vault ARN.
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 vault or plan
436
- raises `AccessDeniedException`, without revealing whether the resource exists.
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
- `SimSdk` routes commands from an AWS `BackupClient` to the simulation. Intercept the client instance
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
- The client's configured Region selects the simulated Region. Credentials select the account and
470
- caller when the intercepted client has them. See the [SDK interception docs](https://yulinsim.dev/sdk/)
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
- AWS Backup state belongs to one account and Region. The same vault name can exist in another scope.
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
- Simulated Bedrock answers model invocations from responses declared against a prompt or a model. A
4
- test says what the model says, and no model runs.
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
- `Converse` answers with the response declared for the prompt it carries. The prompt is the text of
11
- the last user message.
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 with several turns matches on its last user message, so a rule keeps matching as the
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` covers every invocation of a model that no prompt rule matched first. This is the rule for
46
- a test that cares about the code around the call rather than about one exchange.
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` covers everything else again. An invocation matching no rule at all answers with a
75
- built-in line of text that says it is simulated.
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
- A declared response carries content blocks as they were written, so a tool call reaches the code
80
- that handles one. The response stops for `tool_use` unless the declaration names another reason.
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` answers from the same rules, and sends the response as the events real Bedrock
123
- sends. Declaring `chunks` says where the deltas fall.
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 events arrive in the order real Bedrock sends them. `messageStart`, then one
160
- `contentBlockDelta` per chunk, then `contentBlockStop`, `messageStop` carrying the stop reason, and
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` answers with the chunks joined, and a response
165
- declared as `text` streams as a single delta. A stream is readable once, and reading it again
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` answers with the body declared for the request, serialized as JSON. The body is the
179
- shape the model behind the id uses, which is why there is no built-in default for it.
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
- An `InvokeModel` request matches a prompt rule on its request body decoded as UTF-8. A model rule is
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` comes from the declaration, and a response that declares none reports fixed counts.
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
- An invocation authorizes `bedrock:InvokeModel` against the model it names. A base model id becomes a
249
- foundation model ARN for the Region the call was made in, and an inference profile ARN or a
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
- An intercepted `BedrockRuntimeClient` reaches the simulated Bedrock of the Account and Region the
255
- client is configured for.
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`. A prompt rule wins, then a model
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, with `chunks` deciding where the deltas fall and one declaration serving the
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 held per Account and Region, so two Regions answer the same prompt differently.
300
+ - Rules scoped by account and Region.
309
301
 
310
302
  ## Limitations
311
303
 
312
- - No model runs. A response is whatever the matching rule declared, and the prompt is read only as
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 into deltas only where the declaration says so. Text declared any other way
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
- - A serialized Bedrock request is refused. Bedrock speaks REST-JSON, and the wire path answers only
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
- decide nothing. `maxTokens` truncates no declared response, and a `toolConfig` naming no tools
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
- - The model id goes unchecked. AWS publishes no enumerable table of model ids, so refusing one would
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 that arrives as a stream or a Blob matches no prompt rule. Reading it would
346
- consume the caller's own request body, so such a request falls through to a model rule or to the
347
- default.
348
- - A `Converse` call matching a response declared only as a body is refused for the same reason. It
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`.