@decionis/agent-safe-pipeline 0.4.0 → 0.5.0
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 +29 -0
- package/dist/Index.d.ts +9 -0
- package/dist/Index.d.ts.map +1 -1
- package/dist/Index.js +9 -0
- package/dist/Index.js.map +1 -1
- package/dist/execution/ActionRegistry.d.ts +12 -0
- package/dist/execution/ActionRegistry.d.ts.map +1 -1
- package/dist/execution/ActionRegistry.js +14 -0
- package/dist/execution/ActionRegistry.js.map +1 -1
- package/dist/execution/GovernedExecutionRunner.d.ts +14 -0
- package/dist/execution/GovernedExecutionRunner.d.ts.map +1 -1
- package/dist/execution/GovernedExecutionRunner.js +46 -1
- package/dist/execution/GovernedExecutionRunner.js.map +1 -1
- package/dist/execution/NativeExecutor.d.ts +20 -1
- package/dist/execution/NativeExecutor.d.ts.map +1 -1
- package/dist/execution/NativeExecutor.js.map +1 -1
- package/dist/intent/CanonicalIntentHasher.d.ts.map +1 -1
- package/dist/intent/CanonicalIntentHasher.js +11 -0
- package/dist/intent/CanonicalIntentHasher.js.map +1 -1
- package/dist/intent/ExecutionIntent.d.ts +55 -4
- package/dist/intent/ExecutionIntent.d.ts.map +1 -1
- package/dist/intent/ExecutionIntent.js +40 -0
- package/dist/intent/ExecutionIntent.js.map +1 -1
- package/dist/intent/ExecutionSignals.d.ts +9 -1
- package/dist/intent/ExecutionSignals.d.ts.map +1 -1
- package/dist/intent/ExecutionSignals.js +9 -0
- package/dist/intent/ExecutionSignals.js.map +1 -1
- package/dist/intent/IntentBindingSchema.d.ts +6 -0
- package/dist/intent/IntentBindingSchema.d.ts.map +1 -1
- package/dist/intent/IntentBindingSchema.js +10 -0
- package/dist/intent/IntentBindingSchema.js.map +1 -1
- package/dist/intent/IntentCapture.d.ts.map +1 -1
- package/dist/intent/IntentCapture.js +18 -4
- package/dist/intent/IntentCapture.js.map +1 -1
- package/dist/intent/TargetPrecondition.d.ts +36 -0
- package/dist/intent/TargetPrecondition.d.ts.map +1 -0
- package/dist/intent/TargetPrecondition.js +57 -0
- package/dist/intent/TargetPrecondition.js.map +1 -0
- package/dist/manifest/ActionManifest.d.ts +112 -0
- package/dist/manifest/ActionManifest.d.ts.map +1 -0
- package/dist/manifest/ActionManifest.js +182 -0
- package/dist/manifest/ActionManifest.js.map +1 -0
- package/dist/plan/GovernedPlan.d.ts +109 -0
- package/dist/plan/GovernedPlan.d.ts.map +1 -0
- package/dist/plan/GovernedPlan.js +187 -0
- package/dist/plan/GovernedPlan.js.map +1 -0
- package/dist/plan/PlanState.d.ts +94 -0
- package/dist/plan/PlanState.d.ts.map +1 -0
- package/dist/plan/PlanState.js +240 -0
- package/dist/plan/PlanState.js.map +1 -0
- package/dist/plan/PlanStepReference.d.ts +16 -0
- package/dist/plan/PlanStepReference.d.ts.map +1 -0
- package/dist/plan/PlanStepReference.js +25 -0
- package/dist/plan/PlanStepReference.js.map +1 -0
- package/dist/profile/ApiProfile.d.ts +354 -0
- package/dist/profile/ApiProfile.d.ts.map +1 -0
- package/dist/profile/ApiProfile.js +755 -0
- package/dist/profile/ApiProfile.js.map +1 -0
- package/dist/profile/ApiProfiles.d.ts +16 -0
- package/dist/profile/ApiProfiles.d.ts.map +1 -0
- package/dist/profile/ApiProfiles.js +29 -0
- package/dist/profile/ApiProfiles.js.map +1 -0
- package/dist/profile/BuiltInApiProfiles.d.ts +9 -0
- package/dist/profile/BuiltInApiProfiles.d.ts.map +1 -0
- package/dist/profile/BuiltInApiProfiles.js +494 -0
- package/dist/profile/BuiltInApiProfiles.js.map +1 -0
- package/dist/profile/McpToolProfile.d.ts +129 -0
- package/dist/profile/McpToolProfile.d.ts.map +1 -0
- package/dist/profile/McpToolProfile.js +270 -0
- package/dist/profile/McpToolProfile.js.map +1 -0
- package/dist/testing/Index.d.ts +3 -1
- package/dist/testing/Index.d.ts.map +1 -1
- package/dist/testing/Index.js +2 -0
- package/dist/testing/Index.js.map +1 -1
- package/dist/testing/LocalAssumptionBreaches.d.ts +96 -0
- package/dist/testing/LocalAssumptionBreaches.d.ts.map +1 -0
- package/dist/testing/LocalAssumptionBreaches.js +109 -0
- package/dist/testing/LocalAssumptionBreaches.js.map +1 -0
- package/dist/testing/LocalAuthority.d.ts +158 -5
- package/dist/testing/LocalAuthority.d.ts.map +1 -1
- package/dist/testing/LocalAuthority.js +302 -18
- package/dist/testing/LocalAuthority.js.map +1 -1
- package/dist/testing/LocalPlans.d.ts +43 -0
- package/dist/testing/LocalPlans.d.ts.map +1 -0
- package/dist/testing/LocalPlans.js +124 -0
- package/dist/testing/LocalPlans.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { JsonObject, JsonValue } from "../intent/JsonValue.js";
|
|
3
|
+
import { type TargetPrecondition } from "../intent/TargetPrecondition.js";
|
|
4
|
+
/**
|
|
5
|
+
* `agent-safe.profile.api/1`: a platform API described as data, so that every
|
|
6
|
+
* component that turns one of its calls into an intent turns it into the same
|
|
7
|
+
* one. A profile maps method + path (and, where an API overloads a path, an
|
|
8
|
+
* exact query value) to an action type, and names the facts a decision reads
|
|
9
|
+
* by JSON pointer into the call. The gateway reads it to govern an agent's
|
|
10
|
+
* call; a native executor's `prepare` reads it to describe the call it is
|
|
11
|
+
* about to make. One mapping, no code coupling between them.
|
|
12
|
+
*
|
|
13
|
+
* An operation may also say where the subject sits (the customer a call is
|
|
14
|
+
* for): in the call, and, for a read, in each item of its answer. A component
|
|
15
|
+
* that pins a session to one subject checks a read against it, and states the
|
|
16
|
+
* subject to the authority for a write. A read is an operation only for that:
|
|
17
|
+
* it is checked, never decided.
|
|
18
|
+
*
|
|
19
|
+
* A write may also name the read that states its target's version (an ETag,
|
|
20
|
+
* a row version), and where that read's answer states it: a component that
|
|
21
|
+
* binds the target's state reads it once before the authority is asked, and
|
|
22
|
+
* the version rides into the intent as its precondition.
|
|
23
|
+
*/
|
|
24
|
+
export declare const API_PROFILE_CONTRACT = "agent-safe.profile.api/1";
|
|
25
|
+
export declare const API_PROFILE_SCHEMA_ID = "https://github.com/decionis/agent-safe-pipeline/blob/master/spec/profiles/api/v1/schema.json";
|
|
26
|
+
/** The methods a profile governs: each operation of one is decided by the authority. */
|
|
27
|
+
export declare const API_PROFILE_METHODS: readonly ["POST", "PUT", "PATCH", "DELETE"];
|
|
28
|
+
export type ApiProfileMethod = (typeof API_PROFILE_METHODS)[number];
|
|
29
|
+
/** The one read method an operation may name: checked for its subject, never decided. */
|
|
30
|
+
export declare const API_PROFILE_READ_METHOD = "GET";
|
|
31
|
+
/**
|
|
32
|
+
* Fact names a profile may not use. The first group is what the gateway
|
|
33
|
+
* already states in an intent's context; the second is what the Decionis
|
|
34
|
+
* authority states itself, or reads from the request rather than the context,
|
|
35
|
+
* so a fact of that name would be shadowed or refused there.
|
|
36
|
+
*/
|
|
37
|
+
export declare const RESERVED_FACT_NAMES: readonly string[];
|
|
38
|
+
/** The most elements one `*` pointer collects; more is not a fact, it is a payload. */
|
|
39
|
+
export declare const MAX_FACT_ELEMENTS = 100;
|
|
40
|
+
/** The longest string a fact carries; a longer value is not stated. */
|
|
41
|
+
export declare const MAX_FACT_STRING = 1000;
|
|
42
|
+
/** The longest subject: an identifier, never a payload. */
|
|
43
|
+
export declare const MAX_SUBJECT_LENGTH = 200;
|
|
44
|
+
export declare const ApiPolicyProjectionSchema: z.ZodObject<{
|
|
45
|
+
decision_type: z.ZodString;
|
|
46
|
+
transaction_type: z.ZodNullable<z.ZodString>;
|
|
47
|
+
workflow_key: z.ZodNullable<z.ZodString>;
|
|
48
|
+
channel: z.ZodNullable<z.ZodString>;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
/**
|
|
51
|
+
* Where an operation's subject sits, and what else a call or an answer may
|
|
52
|
+
* carry around it:
|
|
53
|
+
*
|
|
54
|
+
* - `request`, a pointer into the call like a fact's, with no `*`;
|
|
55
|
+
* - `response`, a pointer into a successful answer's JSON body, where one `*`
|
|
56
|
+
* reaches every item of a list;
|
|
57
|
+
* - `query`, for a read, the one query parameter that must state the subject,
|
|
58
|
+
* exactly as `template` writes it with `{subject}` in place of the
|
|
59
|
+
* session's subject (`customerNumber eq '{subject}'`);
|
|
60
|
+
* - `parameters`, for a read, every other query parameter it may carry;
|
|
61
|
+
* - `envelope`, beside a `response` pointer through `*`, the keys the object
|
|
62
|
+
* holding the list may carry besides the list.
|
|
63
|
+
*/
|
|
64
|
+
export declare const ApiSubjectSchema: z.ZodObject<{
|
|
65
|
+
request: z.ZodOptional<z.ZodString>;
|
|
66
|
+
response: z.ZodOptional<z.ZodString>;
|
|
67
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
name: z.ZodString;
|
|
69
|
+
template: z.ZodString;
|
|
70
|
+
}, z.core.$strict>>;
|
|
71
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
72
|
+
envelope: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
/**
|
|
75
|
+
* Where a write's target states its version: `read`, a read in the same
|
|
76
|
+
* profile whose path placeholders the write's path also has, so the read can
|
|
77
|
+
* be made from the write's own call; `version`, a pointer into the read's
|
|
78
|
+
* answer, `{ body, headers }`, with no `*`; and `state`, where the same answer
|
|
79
|
+
* states the target's state, when a transition rule reads one.
|
|
80
|
+
*/
|
|
81
|
+
export declare const ApiPreconditionSchema: z.ZodObject<{
|
|
82
|
+
read: z.ZodString;
|
|
83
|
+
version: z.ZodString;
|
|
84
|
+
state: z.ZodOptional<z.ZodString>;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
export declare const ApiOperationSchema: z.ZodObject<{
|
|
87
|
+
id: z.ZodString;
|
|
88
|
+
method: z.ZodEnum<{
|
|
89
|
+
POST: "POST";
|
|
90
|
+
GET: "GET";
|
|
91
|
+
PUT: "PUT";
|
|
92
|
+
PATCH: "PATCH";
|
|
93
|
+
DELETE: "DELETE";
|
|
94
|
+
}>;
|
|
95
|
+
path: z.ZodString;
|
|
96
|
+
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
97
|
+
action: z.ZodString;
|
|
98
|
+
summary: z.ZodString;
|
|
99
|
+
facts: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
100
|
+
policy_projection: z.ZodNullable<z.ZodObject<{
|
|
101
|
+
decision_type: z.ZodString;
|
|
102
|
+
transaction_type: z.ZodNullable<z.ZodString>;
|
|
103
|
+
workflow_key: z.ZodNullable<z.ZodString>;
|
|
104
|
+
channel: z.ZodNullable<z.ZodString>;
|
|
105
|
+
}, z.core.$strict>>;
|
|
106
|
+
subject: z.ZodOptional<z.ZodObject<{
|
|
107
|
+
request: z.ZodOptional<z.ZodString>;
|
|
108
|
+
response: z.ZodOptional<z.ZodString>;
|
|
109
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
110
|
+
name: z.ZodString;
|
|
111
|
+
template: z.ZodString;
|
|
112
|
+
}, z.core.$strict>>;
|
|
113
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
114
|
+
envelope: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
115
|
+
}, z.core.$strict>>;
|
|
116
|
+
precondition: z.ZodOptional<z.ZodObject<{
|
|
117
|
+
read: z.ZodString;
|
|
118
|
+
version: z.ZodString;
|
|
119
|
+
state: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, z.core.$strict>>;
|
|
121
|
+
}, z.core.$strict>;
|
|
122
|
+
export declare const ApiProfileDefinitionSchema: z.ZodObject<{
|
|
123
|
+
profile: z.ZodLiteral<"agent-safe.profile.api/1">;
|
|
124
|
+
id: z.ZodString;
|
|
125
|
+
platform: z.ZodString;
|
|
126
|
+
title: z.ZodString;
|
|
127
|
+
prefixes: z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
|
|
128
|
+
operations: z.ZodArray<z.ZodObject<{
|
|
129
|
+
id: z.ZodString;
|
|
130
|
+
method: z.ZodEnum<{
|
|
131
|
+
POST: "POST";
|
|
132
|
+
GET: "GET";
|
|
133
|
+
PUT: "PUT";
|
|
134
|
+
PATCH: "PATCH";
|
|
135
|
+
DELETE: "DELETE";
|
|
136
|
+
}>;
|
|
137
|
+
path: z.ZodString;
|
|
138
|
+
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
139
|
+
action: z.ZodString;
|
|
140
|
+
summary: z.ZodString;
|
|
141
|
+
facts: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
142
|
+
policy_projection: z.ZodNullable<z.ZodObject<{
|
|
143
|
+
decision_type: z.ZodString;
|
|
144
|
+
transaction_type: z.ZodNullable<z.ZodString>;
|
|
145
|
+
workflow_key: z.ZodNullable<z.ZodString>;
|
|
146
|
+
channel: z.ZodNullable<z.ZodString>;
|
|
147
|
+
}, z.core.$strict>>;
|
|
148
|
+
subject: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
request: z.ZodOptional<z.ZodString>;
|
|
150
|
+
response: z.ZodOptional<z.ZodString>;
|
|
151
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
152
|
+
name: z.ZodString;
|
|
153
|
+
template: z.ZodString;
|
|
154
|
+
}, z.core.$strict>>;
|
|
155
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
156
|
+
envelope: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
157
|
+
}, z.core.$strict>>;
|
|
158
|
+
precondition: z.ZodOptional<z.ZodObject<{
|
|
159
|
+
read: z.ZodString;
|
|
160
|
+
version: z.ZodString;
|
|
161
|
+
state: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, z.core.$strict>>;
|
|
163
|
+
}, z.core.$strict>>;
|
|
164
|
+
}, z.core.$strict>;
|
|
165
|
+
export type ApiPolicyProjection = z.infer<typeof ApiPolicyProjectionSchema>;
|
|
166
|
+
export type ApiSubject = z.infer<typeof ApiSubjectSchema>;
|
|
167
|
+
export type ApiPrecondition = z.infer<typeof ApiPreconditionSchema>;
|
|
168
|
+
export type ApiOperationDefinition = z.infer<typeof ApiOperationSchema>;
|
|
169
|
+
export type ApiProfileDefinition = z.infer<typeof ApiProfileDefinitionSchema>;
|
|
170
|
+
/** One call as a component is about to make it, or as the gateway received it. */
|
|
171
|
+
export interface ApiRequest {
|
|
172
|
+
readonly method: string;
|
|
173
|
+
/** The URL path, as sent (percent-encoded); without query or fragment. */
|
|
174
|
+
readonly path: string;
|
|
175
|
+
readonly query?: {
|
|
176
|
+
readonly [key: string]: string | readonly string[];
|
|
177
|
+
};
|
|
178
|
+
/** The parsed JSON body, when there is one. */
|
|
179
|
+
readonly body?: JsonValue;
|
|
180
|
+
}
|
|
181
|
+
/** A read's answer, as a component that binds a precondition received it. */
|
|
182
|
+
export interface ApiAnswer {
|
|
183
|
+
/** Header names in lower case. */
|
|
184
|
+
readonly headers: {
|
|
185
|
+
readonly [name: string]: string;
|
|
186
|
+
};
|
|
187
|
+
/** The parsed JSON body, when there is one. */
|
|
188
|
+
readonly body?: JsonValue;
|
|
189
|
+
}
|
|
190
|
+
/** What a profile says about one call. */
|
|
191
|
+
export interface ApiProfileMatch {
|
|
192
|
+
readonly profile: string;
|
|
193
|
+
readonly operation: string;
|
|
194
|
+
readonly action: string;
|
|
195
|
+
/** Every fact whose pointer resolved to a statable value; the others are absent. */
|
|
196
|
+
readonly facts: JsonObject;
|
|
197
|
+
readonly policyProjection: ApiPolicyProjection | null;
|
|
198
|
+
/**
|
|
199
|
+
* The call's subject, when the operation names where it sits in the call:
|
|
200
|
+
* a string or a finite number, as a string; null when the pointer found
|
|
201
|
+
* neither. Absent when the operation names no request subject.
|
|
202
|
+
*/
|
|
203
|
+
readonly subject?: string | null;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* A subject check's answer. `MATCH` is the only one that lets a call or an
|
|
207
|
+
* answer through; every other is a refusal, and each says why without saying
|
|
208
|
+
* whose record it was.
|
|
209
|
+
*/
|
|
210
|
+
export type ApiSubjectCheck = "MATCH" | "SUBJECT_ABSENT" | "SUBJECT_MISMATCH" | "QUERY_PARAMETER_REFUSED" | "RESPONSE_UNREADABLE" | "RESPONSE_KEY_REFUSED" | "RESPONSE_SUBJECT_ABSENT" | "RESPONSE_SUBJECT_MISMATCH";
|
|
211
|
+
export declare class ApiProfileError extends Error {
|
|
212
|
+
readonly code: "API_PROFILE_INVALID";
|
|
213
|
+
readonly detail: string;
|
|
214
|
+
constructor(code: "API_PROFILE_INVALID", detail: string);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* One profile, validated and compiled. Matching is deterministic and total:
|
|
218
|
+
* the first operation, in profile order, whose method, path and query match
|
|
219
|
+
* is the call's operation; a call no operation matches is not described by
|
|
220
|
+
* the profile and the caller decides what that means.
|
|
221
|
+
*/
|
|
222
|
+
export declare class ApiProfile {
|
|
223
|
+
readonly definition: ApiProfileDefinition;
|
|
224
|
+
private readonly compiled;
|
|
225
|
+
private constructor();
|
|
226
|
+
/** Validates a definition (closed schema, unique operations, pointers, reserved names) and compiles it. */
|
|
227
|
+
static parse(value: unknown): ApiProfile;
|
|
228
|
+
get id(): string;
|
|
229
|
+
get platform(): string;
|
|
230
|
+
/**
|
|
231
|
+
* Every action type the profile's writes can produce, for a registry to be
|
|
232
|
+
* sealed over. A read's action names it in reports; it is never an intent.
|
|
233
|
+
*/
|
|
234
|
+
actions(): readonly string[];
|
|
235
|
+
/** Whether an operation is a read: checked for its subject, never decided. */
|
|
236
|
+
static isRead(operation: ApiOperationDefinition): boolean;
|
|
237
|
+
/**
|
|
238
|
+
* A call against the session's subject, before it is sent: `MATCH`, or why
|
|
239
|
+
* not. A read that names the query parameters it may carry carries no
|
|
240
|
+
* other (`QUERY_PARAMETER_REFUSED`); a read that names its subject query
|
|
241
|
+
* states the session's subject there and nothing else, so a list can be
|
|
242
|
+
* asked only for the session's own records; and the subject at the
|
|
243
|
+
* operation's request pointer is the session's.
|
|
244
|
+
*/
|
|
245
|
+
checkRequest(match: ApiProfileMatch, query: NonNullable<ApiRequest["query"]>, subject: string): ApiSubjectCheck;
|
|
246
|
+
/**
|
|
247
|
+
* A subject query parameter against its template: absent is
|
|
248
|
+
* `SUBJECT_ABSENT`; given twice, or anything but the template with one
|
|
249
|
+
* literal in place of `{subject}`, is `QUERY_PARAMETER_REFUSED`, which is
|
|
250
|
+
* what a second predicate beside the subject's is; a literal naming
|
|
251
|
+
* another subject is `SUBJECT_MISMATCH`. A `'` inside the literal is
|
|
252
|
+
* written doubled, as an OData string literal writes it; a single one ends
|
|
253
|
+
* the literal, so it refuses the call.
|
|
254
|
+
*/
|
|
255
|
+
private static checkQuery;
|
|
256
|
+
/**
|
|
257
|
+
* A successful answer, to a read or a write, against the session's
|
|
258
|
+
* subject, before any of it is relayed: every item the operation's response
|
|
259
|
+
* pointer reaches must name the subject. One item naming another is
|
|
260
|
+
* `RESPONSE_SUBJECT_MISMATCH`, one naming none `RESPONSE_SUBJECT_ABSENT`,
|
|
261
|
+
* and an answer the pointer cannot be walked into (not JSON, or no list
|
|
262
|
+
* where the `*` stands) `RESPONSE_UNREADABLE`. Beside a list, the object
|
|
263
|
+
* that holds it may carry only the keys the operation's `envelope` names,
|
|
264
|
+
* so a count or a summary about other subjects is `RESPONSE_KEY_REFUSED`.
|
|
265
|
+
* Nothing is filtered: a partial answer would look complete. An empty list
|
|
266
|
+
* names no one and matches. Null when the operation names no response
|
|
267
|
+
* subject, so there is nothing to check.
|
|
268
|
+
*/
|
|
269
|
+
checkResponse(operationId: string, body: JsonValue | undefined, subject: string): ApiSubjectCheck | null;
|
|
270
|
+
operation(id: string): ApiOperationDefinition | null;
|
|
271
|
+
/**
|
|
272
|
+
* The operation a method, path and query select, before any body is read:
|
|
273
|
+
* what the gateway needs to decide whether to govern a call.
|
|
274
|
+
*/
|
|
275
|
+
operationFor(method: string, path: string, query?: ApiRequest["query"]): ApiOperationDefinition | null;
|
|
276
|
+
/**
|
|
277
|
+
* Whether a call reads like one of this method's operations without
|
|
278
|
+
* matching it exactly: its path in another letter case, or with a literal
|
|
279
|
+
* percent-encoded. An upstream that folds case or decodes before it routes
|
|
280
|
+
* would serve it as that operation, so a component that checks reads
|
|
281
|
+
* refuses it rather than let it through unchecked. A path that does not
|
|
282
|
+
* decode resembles everything.
|
|
283
|
+
*/
|
|
284
|
+
resembles(method: string, path: string): boolean;
|
|
285
|
+
/**
|
|
286
|
+
* Whether a call's path goes on below one of this method's operations
|
|
287
|
+
* without being an operation itself, in any letter case: a count
|
|
288
|
+
* (`/customers/$count`), a navigation or a media stream beneath a record.
|
|
289
|
+
* What it answers is not what the operation's subject rule checks, so a
|
|
290
|
+
* component that checks reads refuses it.
|
|
291
|
+
*/
|
|
292
|
+
beneath(method: string, path: string): boolean;
|
|
293
|
+
/** The operation, action type, facts and policy projection of one call; null when no operation matches. */
|
|
294
|
+
match(request: ApiRequest): ApiProfileMatch | null;
|
|
295
|
+
/**
|
|
296
|
+
* The read a write's precondition names, as the call to make: `GET`, the
|
|
297
|
+
* read's path under the prefix the write matched, each placeholder filled
|
|
298
|
+
* with the write's own text for it, exactly as the write's call wrote it.
|
|
299
|
+
* Null when the call matches no write, or its operation names no
|
|
300
|
+
* precondition. The component makes the read; the profile makes no call.
|
|
301
|
+
*/
|
|
302
|
+
stateRead(request: ApiRequest): ApiRequest | null;
|
|
303
|
+
/**
|
|
304
|
+
* The precondition a write's read answered: the version at the operation's
|
|
305
|
+
* pointer, a string or a finite number as a string, within the
|
|
306
|
+
* precondition's bounds; the state beside it when the operation names
|
|
307
|
+
* where; which read said so, as `<profile>#<read>`; and when. Null when the
|
|
308
|
+
* operation names no precondition, or the answer states no usable version:
|
|
309
|
+
* a component that binds the target's state refuses then, rather than bind
|
|
310
|
+
* none. A state the answer does not state is left out.
|
|
311
|
+
*/
|
|
312
|
+
precondition(operationId: string, answer: ApiAnswer, readAt: Date): TargetPrecondition | null;
|
|
313
|
+
private select;
|
|
314
|
+
/** A template as an anchored expression: placeholders take one segment's text, never a `/`. */
|
|
315
|
+
private static compile;
|
|
316
|
+
private static escape;
|
|
317
|
+
/** A placeholder's value: percent-decoded, OData quotes removed; null when it does not decode. */
|
|
318
|
+
private static decode;
|
|
319
|
+
private static queryMatches;
|
|
320
|
+
private static queryRoot;
|
|
321
|
+
/**
|
|
322
|
+
* What a definition must also be about subjects: a subject names where it
|
|
323
|
+
* sits, in the call, its query or its answer; a read names one and states
|
|
324
|
+
* no fact or policy path, since it is never decided; only a read names a
|
|
325
|
+
* subject query or the parameters it may carry; a request subject is one
|
|
326
|
+
* value, so its pointer has no `*`; a subject query's template states the
|
|
327
|
+
* subject once; an envelope stands beside a list.
|
|
328
|
+
*/
|
|
329
|
+
private static subjectRules;
|
|
330
|
+
/**
|
|
331
|
+
* What a precondition must be: a write's, naming a read in the same
|
|
332
|
+
* profile, whose path placeholders the write's path all has, so the read
|
|
333
|
+
* is made from the write's own call; and pointers through no `*`, since a
|
|
334
|
+
* version is one value.
|
|
335
|
+
*/
|
|
336
|
+
private static preconditionRules;
|
|
337
|
+
/** A subject as stated: a string or a finite number, as a string, within the bound; else null. */
|
|
338
|
+
private static subjectOf;
|
|
339
|
+
/** Each element's value through a `*`; null when there is no list where the `*` stands. */
|
|
340
|
+
private static walkList;
|
|
341
|
+
/** RFC 6901 reference tokens, unescaped; one `*` token at most. */
|
|
342
|
+
private static pointerSegments;
|
|
343
|
+
/**
|
|
344
|
+
* The value at a pointer, when it is statable: a string (at most 1000
|
|
345
|
+
* characters), a finite number or a boolean; or, through one `*`, an array
|
|
346
|
+
* of up to 100 of them, every element statable. Anything else is absent.
|
|
347
|
+
*/
|
|
348
|
+
private static read;
|
|
349
|
+
private static walk;
|
|
350
|
+
private static statable;
|
|
351
|
+
}
|
|
352
|
+
/** The published JSON Schema of a profile definition, generated from the validator above. */
|
|
353
|
+
export declare function apiProfileJsonSchema(): Record<string, unknown>;
|
|
354
|
+
//# sourceMappingURL=ApiProfile.d.ts.map
|
|
@@ -0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