@decionis/agent-safe-pipeline 0.3.8 → 0.4.1
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 +50 -0
- package/dist/Index.d.ts +15 -0
- package/dist/Index.d.ts.map +1 -1
- package/dist/Index.js +15 -0
- package/dist/Index.js.map +1 -1
- package/dist/decision/DecionisGate.d.ts.map +1 -1
- package/dist/decision/DecionisGate.js +3 -2
- package/dist/decision/DecionisGate.js.map +1 -1
- package/dist/execution/AuthorizationVerifier.d.ts +33 -4
- package/dist/execution/AuthorizationVerifier.d.ts.map +1 -1
- package/dist/execution/AuthorizationVerifier.js +74 -10
- package/dist/execution/AuthorizationVerifier.js.map +1 -1
- package/dist/execution/EffectAdapter.d.ts +117 -0
- package/dist/execution/EffectAdapter.d.ts.map +1 -0
- package/dist/execution/EffectAdapter.js +22 -0
- package/dist/execution/EffectAdapter.js.map +1 -0
- package/dist/execution/ExecutionDeadline.d.ts +35 -0
- package/dist/execution/ExecutionDeadline.d.ts.map +1 -0
- package/dist/execution/ExecutionDeadline.js +52 -0
- package/dist/execution/ExecutionDeadline.js.map +1 -0
- package/dist/execution/ExecutionJournal.d.ts +148 -0
- package/dist/execution/ExecutionJournal.d.ts.map +1 -0
- package/dist/execution/ExecutionJournal.js +157 -0
- package/dist/execution/ExecutionJournal.js.map +1 -0
- package/dist/execution/ExecutionOutcome.d.ts +186 -0
- package/dist/execution/ExecutionOutcome.d.ts.map +1 -0
- package/dist/execution/ExecutionOutcome.js +2 -0
- package/dist/execution/ExecutionOutcome.js.map +1 -0
- package/dist/execution/ExecutionPosture.d.ts +50 -0
- package/dist/execution/ExecutionPosture.d.ts.map +1 -0
- package/dist/execution/ExecutionPosture.js +20 -0
- package/dist/execution/ExecutionPosture.js.map +1 -0
- package/dist/execution/ExecutorEvidence.d.ts +64 -0
- package/dist/execution/ExecutorEvidence.d.ts.map +1 -0
- package/dist/execution/ExecutorEvidence.js +14 -0
- package/dist/execution/ExecutorEvidence.js.map +1 -0
- package/dist/execution/GovernedExecutionRunner.d.ts +315 -0
- package/dist/execution/GovernedExecutionRunner.d.ts.map +1 -0
- package/dist/execution/GovernedExecutionRunner.js +1358 -0
- package/dist/execution/GovernedExecutionRunner.js.map +1 -0
- package/dist/execution/NativeExecutor.d.ts +226 -0
- package/dist/execution/NativeExecutor.d.ts.map +1 -0
- package/dist/execution/NativeExecutor.js +22 -0
- package/dist/execution/NativeExecutor.js.map +1 -0
- package/dist/execution/NativeExecutorSchema.d.ts +387 -0
- package/dist/execution/NativeExecutorSchema.d.ts.map +1 -0
- package/dist/execution/NativeExecutorSchema.js +261 -0
- package/dist/execution/NativeExecutorSchema.js.map +1 -0
- package/dist/execution/PostgresExecutionJournal.d.ts +54 -0
- package/dist/execution/PostgresExecutionJournal.d.ts.map +1 -0
- package/dist/execution/PostgresExecutionJournal.js +131 -0
- package/dist/execution/PostgresExecutionJournal.js.map +1 -0
- package/dist/execution/RegistryExecutor.d.ts +35 -0
- package/dist/execution/RegistryExecutor.d.ts.map +1 -0
- package/dist/execution/RegistryExecutor.js +84 -0
- package/dist/execution/RegistryExecutor.js.map +1 -0
- package/dist/execution/SafeExecutor.d.ts +22 -193
- package/dist/execution/SafeExecutor.d.ts.map +1 -1
- package/dist/execution/SafeExecutor.js +49 -521
- package/dist/execution/SafeExecutor.js.map +1 -1
- package/dist/http/AuthorityPaths.d.ts +51 -0
- package/dist/http/AuthorityPaths.d.ts.map +1 -0
- package/dist/http/AuthorityPaths.js +84 -0
- package/dist/http/AuthorityPaths.js.map +1 -0
- 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 +44 -4
- package/dist/intent/ExecutionIntent.d.ts.map +1 -1
- package/dist/intent/ExecutionIntent.js +25 -0
- package/dist/intent/ExecutionIntent.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 +3 -0
- package/dist/intent/IntentCapture.js.map +1 -1
- package/dist/profile/ApiProfile.d.ts +154 -0
- package/dist/profile/ApiProfile.d.ts.map +1 -0
- package/dist/profile/ApiProfile.js +369 -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 +296 -0
- package/dist/profile/BuiltInApiProfiles.js.map +1 -0
- package/dist/testing/LocalAuthority.d.ts +14 -0
- package/dist/testing/LocalAuthority.d.ts.map +1 -1
- package/dist/testing/LocalAuthority.js +75 -0
- package/dist/testing/LocalAuthority.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* `agent-safe.profile.api/1`: a platform API described as data, so that every
|
|
4
|
+
* component that turns one of its calls into an intent turns it into the same
|
|
5
|
+
* one. A profile maps method + path (and, where an API overloads a path, an
|
|
6
|
+
* exact query value) to an action type, and names the facts a decision reads
|
|
7
|
+
* by JSON pointer into the call. The gateway reads it to govern an agent's
|
|
8
|
+
* call; a native executor's `prepare` reads it to describe the call it is
|
|
9
|
+
* about to make. One mapping, no code coupling between them.
|
|
10
|
+
*/
|
|
11
|
+
export const API_PROFILE_CONTRACT = "agent-safe.profile.api/1";
|
|
12
|
+
export const API_PROFILE_SCHEMA_ID = "https://github.com/decionis/agent-safe-pipeline/blob/master/spec/profiles/api/v1/schema.json";
|
|
13
|
+
/** The methods a profile governs; a read is never an operation. */
|
|
14
|
+
export const API_PROFILE_METHODS = ["POST", "PUT", "PATCH", "DELETE"];
|
|
15
|
+
/**
|
|
16
|
+
* Fact names a profile may not use. The first group is what the gateway
|
|
17
|
+
* already states in an intent's context; the second is what the Decionis
|
|
18
|
+
* authority states itself, or reads from the request rather than the context,
|
|
19
|
+
* so a fact of that name would be shadowed or refused there.
|
|
20
|
+
*/
|
|
21
|
+
export const RESERVED_FACT_NAMES = [
|
|
22
|
+
"request_sha256",
|
|
23
|
+
"body_sha256",
|
|
24
|
+
"body_bytes",
|
|
25
|
+
"content_type",
|
|
26
|
+
"body_embedded",
|
|
27
|
+
"ingress",
|
|
28
|
+
"claimed_principal",
|
|
29
|
+
"api_profile",
|
|
30
|
+
"agent_safe",
|
|
31
|
+
"action_context",
|
|
32
|
+
"amount",
|
|
33
|
+
"risk_score",
|
|
34
|
+
"channel",
|
|
35
|
+
"objective_profile",
|
|
36
|
+
"mode",
|
|
37
|
+
"decision_band",
|
|
38
|
+
"transaction_type",
|
|
39
|
+
"workflow_key",
|
|
40
|
+
"vertical_pack",
|
|
41
|
+
"policy_version",
|
|
42
|
+
"org_id",
|
|
43
|
+
"decision_type",
|
|
44
|
+
"decision_domain",
|
|
45
|
+
"signals",
|
|
46
|
+
"signal_provenance",
|
|
47
|
+
"history",
|
|
48
|
+
"override",
|
|
49
|
+
"evidence",
|
|
50
|
+
"attachments",
|
|
51
|
+
"attachment_count",
|
|
52
|
+
"policy",
|
|
53
|
+
"context",
|
|
54
|
+
"intake",
|
|
55
|
+
"runtime_attribution",
|
|
56
|
+
];
|
|
57
|
+
/** The most elements one `*` pointer collects; more is not a fact, it is a payload. */
|
|
58
|
+
export const MAX_FACT_ELEMENTS = 100;
|
|
59
|
+
/** The longest string a fact carries; a longer value is not stated. */
|
|
60
|
+
export const MAX_FACT_STRING = 1000;
|
|
61
|
+
const PLACEHOLDER = /\{([A-Z]\w{0,63})\}/gi;
|
|
62
|
+
const TEMPLATE = /^(\/[^/?#%\\\s]+)+$/;
|
|
63
|
+
const POINTER = /^\/(path|query|body)(\/.*)?$/;
|
|
64
|
+
const name = z.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
|
|
65
|
+
const projectionText = z.string().trim().min(1).max(120);
|
|
66
|
+
export const ApiPolicyProjectionSchema = z.strictObject({
|
|
67
|
+
decision_type: projectionText,
|
|
68
|
+
transaction_type: projectionText.nullable(),
|
|
69
|
+
workflow_key: projectionText.nullable(),
|
|
70
|
+
channel: projectionText.nullable(),
|
|
71
|
+
});
|
|
72
|
+
export const ApiOperationSchema = z.strictObject({
|
|
73
|
+
/** The operation's name in the profile, unique, dotted lower camel case. */
|
|
74
|
+
id: z
|
|
75
|
+
.string()
|
|
76
|
+
.regex(/^[a-z][A-Za-z0-9]*(\.[a-z][A-Za-z0-9]*)*$/)
|
|
77
|
+
.max(120),
|
|
78
|
+
method: z.enum(API_PROFILE_METHODS),
|
|
79
|
+
/** A path template: literal text and `{name}` placeholders, each within one segment. */
|
|
80
|
+
path: z.string().max(500).regex(TEMPLATE),
|
|
81
|
+
/** Exact query values the call must carry to be this operation (an API that overloads a path). */
|
|
82
|
+
query: z.record(z.string().regex(/^[a-z][\w.-]{0,63}$/), z.string().max(200)).optional(),
|
|
83
|
+
/** The intent's action type. */
|
|
84
|
+
action: z
|
|
85
|
+
.string()
|
|
86
|
+
.max(120)
|
|
87
|
+
.regex(/^[a-z][a-z0-9._:-]*$/),
|
|
88
|
+
summary: z.string().trim().min(1).max(300),
|
|
89
|
+
/** Fact name → RFC 6901 pointer into `{ path, query, body }`; one `*` segment collects an array. */
|
|
90
|
+
facts: z.record(name, z.string().max(300).regex(POINTER)),
|
|
91
|
+
/** The policy path the authority decides the call under, when the profile states one. */
|
|
92
|
+
policy_projection: ApiPolicyProjectionSchema.nullable(),
|
|
93
|
+
});
|
|
94
|
+
export const ApiProfileDefinitionSchema = z.strictObject({
|
|
95
|
+
profile: z.literal(API_PROFILE_CONTRACT),
|
|
96
|
+
/** `<platform>/<api>/<version>`, the profile's directory under `profiles/`. */
|
|
97
|
+
id: z
|
|
98
|
+
.string()
|
|
99
|
+
.regex(/^[a-z][a-z0-9]*\/[a-z][a-z0-9]*\/v\d+(\.\d+)?$/)
|
|
100
|
+
.max(120),
|
|
101
|
+
platform: z
|
|
102
|
+
.string()
|
|
103
|
+
.regex(/^[a-z][a-z0-9-]*$/)
|
|
104
|
+
.max(80),
|
|
105
|
+
title: z.string().trim().min(1).max(200),
|
|
106
|
+
/** Path templates an operation's path may follow; `""` is the bare path. Tried in order. */
|
|
107
|
+
prefixes: z
|
|
108
|
+
.array(z.union([z.literal(""), z.string().max(300).regex(TEMPLATE)]))
|
|
109
|
+
.min(1)
|
|
110
|
+
.max(8),
|
|
111
|
+
operations: z.array(ApiOperationSchema).min(1).max(200),
|
|
112
|
+
});
|
|
113
|
+
export class ApiProfileError extends Error {
|
|
114
|
+
code;
|
|
115
|
+
detail;
|
|
116
|
+
constructor(code, detail) {
|
|
117
|
+
super(code);
|
|
118
|
+
this.code = code;
|
|
119
|
+
this.detail = detail;
|
|
120
|
+
this.name = "ApiProfileError";
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* One profile, validated and compiled. Matching is deterministic and total:
|
|
125
|
+
* the first operation, in profile order, whose method, path and query match
|
|
126
|
+
* is the call's operation; a call no operation matches is not described by
|
|
127
|
+
* the profile and the caller decides what that means.
|
|
128
|
+
*/
|
|
129
|
+
export class ApiProfile {
|
|
130
|
+
definition;
|
|
131
|
+
compiled;
|
|
132
|
+
constructor(definition) {
|
|
133
|
+
this.definition = definition;
|
|
134
|
+
const ids = new Set();
|
|
135
|
+
const signatures = new Set();
|
|
136
|
+
this.compiled = definition.operations.map((operation) => {
|
|
137
|
+
if (ids.has(operation.id))
|
|
138
|
+
throw new ApiProfileError("API_PROFILE_INVALID", `duplicate operation ${operation.id}`);
|
|
139
|
+
ids.add(operation.id);
|
|
140
|
+
const signature = `${operation.method} ${operation.path.replace(PLACEHOLDER, "{}")} ${JSON.stringify(Object.entries(operation.query ?? {}).sort(([a], [b]) => a.localeCompare(b)))}`;
|
|
141
|
+
if (signatures.has(signature))
|
|
142
|
+
throw new ApiProfileError("API_PROFILE_INVALID", `operation ${operation.id} repeats another operation's method, path and query`);
|
|
143
|
+
signatures.add(signature);
|
|
144
|
+
for (const fact of Object.keys(operation.facts)) {
|
|
145
|
+
if (RESERVED_FACT_NAMES.includes(fact))
|
|
146
|
+
throw new ApiProfileError("API_PROFILE_INVALID", `operation ${operation.id} names the reserved fact ${fact}`);
|
|
147
|
+
}
|
|
148
|
+
for (const pointer of Object.values(operation.facts))
|
|
149
|
+
ApiProfile.pointerSegments(pointer, operation.id);
|
|
150
|
+
const matchers = [];
|
|
151
|
+
const placeholders = [];
|
|
152
|
+
for (const prefix of definition.prefixes) {
|
|
153
|
+
const { pattern, names } = ApiProfile.compile(`${prefix}${operation.path}`, operation.id);
|
|
154
|
+
matchers.push(pattern);
|
|
155
|
+
placeholders.push(names);
|
|
156
|
+
}
|
|
157
|
+
return { definition: operation, matchers, placeholders };
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/** Validates a definition (closed schema, unique operations, pointers, reserved names) and compiles it. */
|
|
161
|
+
static parse(value) {
|
|
162
|
+
const parsed = ApiProfileDefinitionSchema.safeParse(value);
|
|
163
|
+
if (!parsed.success)
|
|
164
|
+
throw new ApiProfileError("API_PROFILE_INVALID", parsed.error.issues
|
|
165
|
+
.slice(0, 3)
|
|
166
|
+
.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`)
|
|
167
|
+
.join("; "));
|
|
168
|
+
return new ApiProfile(parsed.data);
|
|
169
|
+
}
|
|
170
|
+
get id() {
|
|
171
|
+
return this.definition.id;
|
|
172
|
+
}
|
|
173
|
+
get platform() {
|
|
174
|
+
return this.definition.platform;
|
|
175
|
+
}
|
|
176
|
+
/** Every action type the profile can produce, for a registry to be sealed over. */
|
|
177
|
+
actions() {
|
|
178
|
+
return [...new Set(this.definition.operations.map((operation) => operation.action))];
|
|
179
|
+
}
|
|
180
|
+
operation(id) {
|
|
181
|
+
return this.definition.operations.find((operation) => operation.id === id) ?? null;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The operation a method, path and query select, before any body is read:
|
|
185
|
+
* what the gateway needs to decide whether to govern a call.
|
|
186
|
+
*/
|
|
187
|
+
operationFor(method, path, query = {}) {
|
|
188
|
+
return this.select(method, path, query)?.operation.definition ?? null;
|
|
189
|
+
}
|
|
190
|
+
/** The operation, action type, facts and policy projection of one call; null when no operation matches. */
|
|
191
|
+
match(request) {
|
|
192
|
+
const selected = this.select(request.method, request.path, request.query ?? {});
|
|
193
|
+
if (selected === null)
|
|
194
|
+
return null;
|
|
195
|
+
const { operation, parameters } = selected;
|
|
196
|
+
const root = {
|
|
197
|
+
path: parameters,
|
|
198
|
+
query: ApiProfile.queryRoot(request.query ?? {}),
|
|
199
|
+
...(request.body === undefined ? {} : { body: request.body }),
|
|
200
|
+
};
|
|
201
|
+
const facts = {};
|
|
202
|
+
for (const [fact, pointer] of Object.entries(operation.definition.facts)) {
|
|
203
|
+
const value = ApiProfile.read(root, ApiProfile.pointerSegments(pointer, operation.definition.id));
|
|
204
|
+
if (value !== undefined)
|
|
205
|
+
facts[fact] = value;
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
profile: this.definition.id,
|
|
209
|
+
operation: operation.definition.id,
|
|
210
|
+
action: operation.definition.action,
|
|
211
|
+
facts,
|
|
212
|
+
policyProjection: operation.definition.policy_projection,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
select(method, path, query) {
|
|
216
|
+
const upper = method.toUpperCase();
|
|
217
|
+
if (!path.startsWith("/") || /[?#]/.test(path))
|
|
218
|
+
return null;
|
|
219
|
+
for (const operation of this.compiled) {
|
|
220
|
+
if (operation.definition.method !== upper)
|
|
221
|
+
continue;
|
|
222
|
+
if (!ApiProfile.queryMatches(operation.definition.query ?? {}, query))
|
|
223
|
+
continue;
|
|
224
|
+
for (let index = 0; index < operation.matchers.length; index += 1) {
|
|
225
|
+
const found = operation.matchers[index].exec(path);
|
|
226
|
+
if (found === null)
|
|
227
|
+
continue;
|
|
228
|
+
const parameters = {};
|
|
229
|
+
let decodable = true;
|
|
230
|
+
operation.placeholders[index].forEach((placeholder, position) => {
|
|
231
|
+
const decoded = ApiProfile.decode(found[position + 1] ?? "");
|
|
232
|
+
if (decoded === null)
|
|
233
|
+
decodable = false;
|
|
234
|
+
else
|
|
235
|
+
parameters[placeholder] = decoded;
|
|
236
|
+
});
|
|
237
|
+
if (decodable)
|
|
238
|
+
return { operation, parameters };
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
/** A template as an anchored expression: placeholders take one segment's text, never a `/`. */
|
|
244
|
+
static compile(template, operation) {
|
|
245
|
+
const names = [];
|
|
246
|
+
let source = "";
|
|
247
|
+
let last = 0;
|
|
248
|
+
for (const found of template.matchAll(PLACEHOLDER)) {
|
|
249
|
+
const placeholder = found[1];
|
|
250
|
+
if (names.includes(placeholder))
|
|
251
|
+
throw new ApiProfileError("API_PROFILE_INVALID", `operation ${operation} repeats the placeholder ${placeholder}`);
|
|
252
|
+
names.push(placeholder);
|
|
253
|
+
source += ApiProfile.escape(template.slice(last, found.index)) + "([^/()]+)";
|
|
254
|
+
last = (found.index ?? 0) + found[0].length;
|
|
255
|
+
}
|
|
256
|
+
source += ApiProfile.escape(template.slice(last));
|
|
257
|
+
if (/[{}]/.test(template.replace(PLACEHOLDER, "")))
|
|
258
|
+
throw new ApiProfileError("API_PROFILE_INVALID", `operation ${operation} has a malformed placeholder`);
|
|
259
|
+
return { pattern: new RegExp(`^${source}$`), names };
|
|
260
|
+
}
|
|
261
|
+
static escape(text) {
|
|
262
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
263
|
+
}
|
|
264
|
+
/** A placeholder's value: percent-decoded, OData quotes removed; null when it does not decode. */
|
|
265
|
+
static decode(raw) {
|
|
266
|
+
let value;
|
|
267
|
+
try {
|
|
268
|
+
value = decodeURIComponent(raw);
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
if (value.length >= 2 && value.startsWith("'") && value.endsWith("'"))
|
|
274
|
+
value = value.slice(1, -1);
|
|
275
|
+
if (value === "" || value === "." || value === ".." || value.includes("/"))
|
|
276
|
+
return null;
|
|
277
|
+
return value;
|
|
278
|
+
}
|
|
279
|
+
static queryMatches(expected, query) {
|
|
280
|
+
return Object.entries(expected).every(([key, value]) => {
|
|
281
|
+
const actual = query[key];
|
|
282
|
+
return typeof actual === "string" ? actual === value : false;
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
static queryRoot(query) {
|
|
286
|
+
const root = {};
|
|
287
|
+
for (const [key, value] of Object.entries(query)) {
|
|
288
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
289
|
+
continue;
|
|
290
|
+
root[key] = typeof value === "string" ? value : [...value];
|
|
291
|
+
}
|
|
292
|
+
return root;
|
|
293
|
+
}
|
|
294
|
+
/** RFC 6901 reference tokens, unescaped; one `*` token at most. */
|
|
295
|
+
static pointerSegments(pointer, operation) {
|
|
296
|
+
const tokens = pointer
|
|
297
|
+
.slice(1)
|
|
298
|
+
.split("/")
|
|
299
|
+
.map((token) => token.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
300
|
+
if (tokens.filter((token) => token === "*").length > 1 || /~[^01]|~$/.test(pointer))
|
|
301
|
+
throw new ApiProfileError("API_PROFILE_INVALID", `operation ${operation} has an invalid fact pointer ${pointer}`);
|
|
302
|
+
return tokens;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* The value at a pointer, when it is statable: a string (at most 1000
|
|
306
|
+
* characters), a finite number or a boolean; or, through one `*`, an array
|
|
307
|
+
* of up to 100 of them, every element statable. Anything else is absent.
|
|
308
|
+
*/
|
|
309
|
+
static read(root, tokens) {
|
|
310
|
+
const wildcard = tokens.indexOf("*");
|
|
311
|
+
if (wildcard === -1)
|
|
312
|
+
return ApiProfile.statable(ApiProfile.walk(root, tokens));
|
|
313
|
+
const list = ApiProfile.walk(root, tokens.slice(0, wildcard));
|
|
314
|
+
if (!Array.isArray(list) || list.length === 0 || list.length > MAX_FACT_ELEMENTS)
|
|
315
|
+
return undefined;
|
|
316
|
+
const values = [];
|
|
317
|
+
for (const element of list) {
|
|
318
|
+
const value = ApiProfile.statable(ApiProfile.walk(element, tokens.slice(wildcard + 1)));
|
|
319
|
+
if (value === undefined)
|
|
320
|
+
return undefined;
|
|
321
|
+
values.push(value);
|
|
322
|
+
}
|
|
323
|
+
return values;
|
|
324
|
+
}
|
|
325
|
+
static walk(value, tokens) {
|
|
326
|
+
let current = value;
|
|
327
|
+
for (const token of tokens) {
|
|
328
|
+
if (Array.isArray(current)) {
|
|
329
|
+
if (!/^(?:0|[1-9]\d{0,5})$/.test(token))
|
|
330
|
+
return undefined;
|
|
331
|
+
current = current[Number(token)];
|
|
332
|
+
}
|
|
333
|
+
else if (current !== null && typeof current === "object") {
|
|
334
|
+
current = Object.hasOwn(current, token) ? current[token] : undefined;
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
return undefined;
|
|
338
|
+
}
|
|
339
|
+
if (current === undefined)
|
|
340
|
+
return undefined;
|
|
341
|
+
}
|
|
342
|
+
return current;
|
|
343
|
+
}
|
|
344
|
+
static statable(value) {
|
|
345
|
+
if (typeof value === "string")
|
|
346
|
+
return value.length <= MAX_FACT_STRING ? value : undefined;
|
|
347
|
+
if (typeof value === "number")
|
|
348
|
+
return Number.isFinite(value) ? value : undefined;
|
|
349
|
+
if (typeof value === "boolean")
|
|
350
|
+
return value;
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/** The published JSON Schema of a profile definition, generated from the validator above. */
|
|
355
|
+
export function apiProfileJsonSchema() {
|
|
356
|
+
const generated = z.toJSONSchema(ApiProfileDefinitionSchema, {
|
|
357
|
+
target: "draft-2020-12",
|
|
358
|
+
io: "input",
|
|
359
|
+
});
|
|
360
|
+
const schema = { ...generated };
|
|
361
|
+
delete schema["$schema"];
|
|
362
|
+
return {
|
|
363
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
364
|
+
$id: API_PROFILE_SCHEMA_ID,
|
|
365
|
+
title: API_PROFILE_CONTRACT,
|
|
366
|
+
...schema,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
//# sourceMappingURL=ApiProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiProfile.js","sourceRoot":"","sources":["../../src/profile/ApiProfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAE/D,MAAM,CAAC,MAAM,qBAAqB,GAChC,8FAA8F,CAAC;AAEjG,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAG/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACpD,gBAAgB;IAChB,aAAa;IACb,YAAY;IACZ,cAAc;IACd,eAAe;IACf,SAAS;IACT,mBAAmB;IACnB,aAAa;IACb,YAAY;IACZ,gBAAgB;IAChB,QAAQ;IACR,YAAY;IACZ,SAAS;IACT,mBAAmB;IACnB,MAAM;IACN,eAAe;IACf,kBAAkB;IAClB,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,QAAQ;IACR,eAAe;IACf,iBAAiB;IACjB,SAAS;IACT,mBAAmB;IACnB,SAAS;IACT,UAAU;IACV,UAAU;IACV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AAC;QAC9C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,KAA4B;QAClD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1F,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QACjF,IAAI,OAAO,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC7C,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED,6FAA6F;AAC7F,MAAM,UAAU,oBAAoB;IAClC,MAAM,SAAS,GAAG,CAAC,CAAC,YAAY,CAAC,0BAA0B,EAAE;QAC3D,MAAM,EAAE,eAAe;QACvB,EAAE,EAAE,OAAO;KACZ,CAAC,CAAC;IACH,MAAM,MAAM,GAA4B,EAAE,GAAG,SAAS,EAAE,CAAC;IACzD,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC;IACzB,OAAO;QACL,OAAO,EAAE,8CAA8C;QACvD,GAAG,EAAE,qBAAqB;QAC1B,KAAK,EAAE,oBAAoB;QAC3B,GAAG,MAAM;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ApiProfile } from "./ApiProfile.js";
|
|
2
|
+
/**
|
|
3
|
+
* The API intent profiles this build ships (`profiles/<platform>/<api>/<version>`),
|
|
4
|
+
* compiled once. The gateway reads one by the id its configuration names; a
|
|
5
|
+
* native executor reads the one for the API it writes to, so both describe a
|
|
6
|
+
* call the same way.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ApiProfiles {
|
|
9
|
+
private static compiled;
|
|
10
|
+
/** Every shipped profile id, in profile order. */
|
|
11
|
+
static ids(): readonly string[];
|
|
12
|
+
/** The shipped profile with this id, or null when the build has none. */
|
|
13
|
+
static get(id: string): ApiProfile | null;
|
|
14
|
+
private static all;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ApiProfiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiProfiles.d.ts","sourceRoot":"","sources":["../../src/profile/ApiProfiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgD;IAEvE,kDAAkD;WACpC,GAAG,IAAI,SAAS,MAAM,EAAE;IAItC,yEAAyE;WAC3D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAIhD,OAAO,CAAC,MAAM,CAAC,GAAG;CAWnB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ApiProfile } from "./ApiProfile.js";
|
|
2
|
+
import { BUILT_IN_API_PROFILES } from "./BuiltInApiProfiles.js";
|
|
3
|
+
/**
|
|
4
|
+
* The API intent profiles this build ships (`profiles/<platform>/<api>/<version>`),
|
|
5
|
+
* compiled once. The gateway reads one by the id its configuration names; a
|
|
6
|
+
* native executor reads the one for the API it writes to, so both describe a
|
|
7
|
+
* call the same way.
|
|
8
|
+
*/
|
|
9
|
+
export class ApiProfiles {
|
|
10
|
+
static compiled = null;
|
|
11
|
+
/** Every shipped profile id, in profile order. */
|
|
12
|
+
static ids() {
|
|
13
|
+
return [...ApiProfiles.all().keys()];
|
|
14
|
+
}
|
|
15
|
+
/** The shipped profile with this id, or null when the build has none. */
|
|
16
|
+
static get(id) {
|
|
17
|
+
return ApiProfiles.all().get(id) ?? null;
|
|
18
|
+
}
|
|
19
|
+
static all() {
|
|
20
|
+
if (ApiProfiles.compiled === null) {
|
|
21
|
+
ApiProfiles.compiled = new Map(BUILT_IN_API_PROFILES.map((definition) => {
|
|
22
|
+
const profile = ApiProfile.parse(definition);
|
|
23
|
+
return [profile.id, profile];
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
return ApiProfiles.compiled;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ApiProfiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiProfiles.js","sourceRoot":"","sources":["../../src/profile/ApiProfiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAC,QAAQ,GAA2C,IAAI,CAAC;IAEvE,kDAAkD;IAC3C,MAAM,CAAC,GAAG;QACf,OAAO,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,yEAAyE;IAClE,MAAM,CAAC,GAAG,CAAC,EAAU;QAC1B,OAAO,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;IAC3C,CAAC;IAEO,MAAM,CAAC,GAAG;QAChB,IAAI,WAAW,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAClC,WAAW,CAAC,QAAQ,GAAG,IAAI,GAAG,CAC5B,qBAAqB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;gBACvC,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAC7C,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAU,CAAC;YACxC,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QACD,OAAO,WAAW,CAAC,QAAQ,CAAC;IAC9B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ApiProfileDefinition } from "./ApiProfile.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every API intent profile this build ships, exactly as profiles/ states it.
|
|
4
|
+
* The runtime never reads profiles/: the generator mirrors them here, and the
|
|
5
|
+
* pipeline's tests compare this mirror with the files and their manifests on
|
|
6
|
+
* every run, so a drift is a failing test rather than a silent disagreement.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BUILT_IN_API_PROFILES: readonly ApiProfileDefinition[];
|
|
9
|
+
//# sourceMappingURL=BuiltInApiProfiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuiltInApiProfiles.d.ts","sourceRoot":"","sources":["../../src/profile/BuiltInApiProfiles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,oBAAoB,EAiShE,CAAC"}
|