mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 09:21:16 +00:00
fix(environment)!: report recorded reads and target uncertainty (#7834)
* fix(environment)!: report recorded reads and target uncertainty BREAKING CHANGE: Environment state and coverage can report method-replay for non-GET safe reads; exhaustive reason consumers must handle it. * docs(environment): include safe-method replay reason
This commit is contained in:
1 parent
cc5a4062ff
commit
1e088c19ad
14 files changed
+205
-37
No files matched your search
@@ -2,6 +2,7 @@ import {
|
||||
ownMember,
|
||||
isObject,
|
||||
isQueryPost,
|
||||
isSafeHttpMethod,
|
||||
listItems,
|
||||
locateList,
|
||||
pointerTokens,
|
||||
@@ -64,27 +65,14 @@ export interface EnvironmentToolDefinition {
|
||||
readonly tool: EnvironmentManifestTool;
|
||||
}
|
||||
|
||||
/** RFC 9110 safe methods: a preflight `OPTIONS` reads, as `GET` does. */
|
||||
const SAFE_METHODS: ReadonlySet<string> = new Set([
|
||||
"GET",
|
||||
"HEAD",
|
||||
"OPTIONS",
|
||||
"TRACE",
|
||||
]);
|
||||
|
||||
const IDEMPOTENT_METHODS: ReadonlySet<string> = new Set([
|
||||
...SAFE_METHODS,
|
||||
"PUT",
|
||||
"DELETE",
|
||||
]);
|
||||
|
||||
const environmentToolAnnotations = ({
|
||||
method,
|
||||
path_template: path,
|
||||
}: EnvironmentManifestTool): EnvironmentToolAnnotations => ({
|
||||
readOnlyHint: SAFE_METHODS.has(method) || isQueryPost(method, path),
|
||||
readOnlyHint: isSafeHttpMethod(method) || isQueryPost(method, path),
|
||||
...(method === "DELETE" ? { destructiveHint: true as const } : {}),
|
||||
idempotentHint: IDEMPOTENT_METHODS.has(method),
|
||||
idempotentHint:
|
||||
isSafeHttpMethod(method) || method === "PUT" || method === "DELETE",
|
||||
openWorldHint: false,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user