@arbol-ai/maximus 8.1.0 → 8.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/dist/analytics/analytics.d.ts +16 -16
- package/dist/analytics/analytics.js +3 -3
- package/dist/body.d.ts +2 -2
- package/dist/body.js +2 -1
- package/dist/capture/index.d.ts +1 -1
- package/dist/capture/index.js +3 -4
- package/dist/chunks/{define-app-BxGZdNmS.js → define-app-CQpWqqqE.js} +33 -14
- package/dist/chunks/destination-5xTX0b7E.js +65 -0
- package/dist/chunks/{digest-C7UGt760.js → digest-C51F1bhA.js} +1 -2
- package/dist/chunks/{errors-CWgE9uvM.js → errors-BoutSmiy.js} +2 -3
- package/dist/chunks/{execution-BTiAWA4n.js → execution-Bpq6s4nA.js} +9 -8
- package/dist/chunks/{generate-C-9FKW0o.js → generate-Dg88LzLU.js} +1 -1
- package/dist/chunks/{handler-iebR-urt.js → handler-DSpyrWc-.js} +6 -2
- package/dist/chunks/{http-layout-BvlbD__1.js → http-layout-BcYH4I2w.js} +1 -1
- package/dist/chunks/{http-paths-DMBxwpp6.js → http-paths-D043DkJv.js} +50 -81
- package/dist/chunks/http-routes-B6tCsnxB.js +29 -0
- package/dist/chunks/{openapi-BF3eCpux.js → openapi-D2rds7vy.js} +27 -116
- package/dist/chunks/{openapi-file-RcXoq0AF.js → openapi-file-BK8zET5U.js} +24 -6
- package/dist/chunks/{pages-BCksUeRf.js → pages-B7ysoFAM.js} +1 -1
- package/dist/chunks/result-CF4OzG9O.js +29 -0
- package/dist/chunks/{runtime-D5eR9-Es.js → runtime-8OpxAvsI.js} +132 -7
- package/dist/chunks/schemas-_UJcx_uY.js +813 -0
- package/dist/chunks/{server-B9C8KPwa.js → server-CVhTLNj2.js} +37 -101
- package/dist/chunks/{src-C-4z443M.js → src-B_LthUVU.js} +39 -18
- package/dist/chunks/tasks-C873C3le.js +100 -0
- package/dist/chunks/tasks-DYdY-dBI.js +267 -0
- package/dist/chunks/{types-Dqo3oGig.d.ts → types-BfGa2aJT.d.ts} +346 -138
- package/dist/chunks/validation-CpzAxj2_.js +201 -0
- package/dist/chunks/{workers-types-BgjyDtGd.d.ts → workers-types-Cxf-5cH7.d.ts} +6 -1
- package/dist/client.d.ts +92 -0
- package/dist/client.js +300 -0
- package/dist/diagnostics.d.ts +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/http-paths.d.ts +1 -1
- package/dist/http-paths.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -9
- package/dist/internals.d.ts +1 -1
- package/dist/internals.js +4 -4
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/tasks.d.ts +33 -0
- package/dist/mcp/tasks.js +3 -0
- package/dist/project/config.d.ts +2 -2
- package/dist/project/config.js +3 -2
- package/dist/project/index.d.ts +2 -2
- package/dist/project/index.js +3 -3
- package/dist/schemas.d.ts +2 -2
- package/dist/schemas.js +3 -3
- package/dist/standard-failures.d.ts +1 -1
- package/dist/tooling/cli.js +2 -2
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +6 -5
- package/dist/webhooks.d.ts +13 -2
- package/dist/webhooks.js +38 -1
- package/dist/workers/runtime.d.ts +1 -1
- package/dist/workers/runtime.js +1 -1
- package/package.json +15 -3
- package/skills/maximus/SKILL.md +7 -4
- package/skills/maximus/references/routes-and-tools.md +9 -1
- package/dist/chunks/result-CKgZHrnj.js +0 -56
- package/dist/chunks/schemas-BOFxZP1c.js +0 -227
- package/dist/chunks/validation-DMu0rkMQ.js +0 -670
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Static, Static as Static$1, Static as Static$2, StaticDecode, TArray, TCodec, TLiteral, TObject, TOptional, TProperties, TSchema, TSchema as TSchema$1, TSchema as TSchema$2, TString, TUnion, TUnsafe, Type, Type as Type$1, Type as Type$2, Type as t, Type as t$1 } from "typebox";
|
|
2
|
+
import "typebox/error";
|
|
2
3
|
/**
|
|
3
4
|
* Request correlation: request ids (a UUID, or a ray id from a trusted Cloudflare edge), W3C `traceparent`
|
|
4
5
|
* parsing, and the correlation that durable work persists.
|
|
@@ -84,9 +85,9 @@ interface ErrorDefinition {
|
|
|
84
85
|
* share. The OpenAPI document names each code's own failure, `NoteNotFoundFailure`, which fixes its code.
|
|
85
86
|
*/
|
|
86
87
|
declare const FailureSchema: TObject<{
|
|
87
|
-
code:
|
|
88
|
-
message:
|
|
89
|
-
retryable:
|
|
88
|
+
code: Type.TString;
|
|
89
|
+
message: Type.TString;
|
|
90
|
+
retryable: Type.TBoolean;
|
|
90
91
|
data: TObject<{}>;
|
|
91
92
|
}>;
|
|
92
93
|
/** The standard failures as a catalog defines them; INVALID_INPUT carries its field issues. */
|
|
@@ -155,9 +156,9 @@ declare const STANDARD: {
|
|
|
155
156
|
readonly status: 400;
|
|
156
157
|
readonly message: 'The request does not match the published schema.';
|
|
157
158
|
readonly dataSchema: TObject<{
|
|
158
|
-
issues:
|
|
159
|
-
path:
|
|
160
|
-
message:
|
|
159
|
+
issues: Type.TOptional<Type.TArray<TObject<{
|
|
160
|
+
path: Type.TString;
|
|
161
|
+
message: Type.TString;
|
|
161
162
|
}>>>;
|
|
162
163
|
}>;
|
|
163
164
|
};
|
|
@@ -207,8 +208,11 @@ interface ErrorCatalog {
|
|
|
207
208
|
/** The value as one of the catalog's failures; throws a TypeError when it is none of them. */
|
|
208
209
|
validate: (error: unknown) => Failure;
|
|
209
210
|
}
|
|
210
|
-
/**
|
|
211
|
-
|
|
211
|
+
/**
|
|
212
|
+
* The union schema of a set of definitions: one strict failure schema per definition. TypeBox reads a union's
|
|
213
|
+
* members as a tuple; one member that is the union of every failure schema types the same values.
|
|
214
|
+
*/
|
|
215
|
+
type CatalogSchema<Definitions extends Record<string, ErrorDefinition>> = TUnion<[{ [K in keyof Definitions]: FailureSchemaOf<Definitions[K]>; }[keyof Definitions]]>;
|
|
212
216
|
/** A catalog over a set of definitions: a factory per name, and the members of `ErrorCatalog`. */
|
|
213
217
|
type Catalog<Definitions extends Record<string, ErrorDefinition>> = Factories<Definitions> & {
|
|
214
218
|
/** The union of the catalog's failure schemas. */
|
|
@@ -272,7 +276,7 @@ interface Attachment {
|
|
|
272
276
|
byteLength: number;
|
|
273
277
|
}
|
|
274
278
|
/** The output of an operation that answers with a file (`http.response: 'attachment'`). */
|
|
275
|
-
declare const AttachmentOutputSchema:
|
|
279
|
+
declare const AttachmentOutputSchema: Type.TUnsafe<Attachment>;
|
|
276
280
|
/** A successful outcome and its value. Each transport presents it in its own envelope. */
|
|
277
281
|
interface Success<T> {
|
|
278
282
|
/** Always `true`, which marks a success. */
|
|
@@ -321,45 +325,45 @@ interface BinaryBody {
|
|
|
321
325
|
* `secret: true`. A refusal before the operation ran has `stage: 'admission'` and null wherever admission had
|
|
322
326
|
* not learned the value: a token is never read before it is verified.
|
|
323
327
|
*/
|
|
324
|
-
declare const CaptureRecordSchema:
|
|
325
|
-
id:
|
|
326
|
-
service:
|
|
327
|
-
operation:
|
|
328
|
-
organizationId:
|
|
329
|
-
actorId:
|
|
330
|
-
actorKind:
|
|
331
|
-
requestId:
|
|
332
|
-
traceId:
|
|
333
|
-
surface:
|
|
334
|
-
occurredAt:
|
|
335
|
-
durationMicros:
|
|
336
|
-
outcome:
|
|
337
|
-
errorCode:
|
|
338
|
-
stage:
|
|
339
|
-
version:
|
|
340
|
-
effect:
|
|
341
|
-
scopes:
|
|
342
|
-
visibility:
|
|
343
|
-
httpMethod:
|
|
344
|
-
httpPath:
|
|
345
|
-
mcpTool:
|
|
346
|
-
rpcCaller:
|
|
347
|
-
clientId:
|
|
348
|
-
clientClass:
|
|
349
|
-
grantedScopes:
|
|
350
|
-
userAgent:
|
|
351
|
-
tokenSha256:
|
|
352
|
-
dimensions:
|
|
353
|
-
startedAt:
|
|
354
|
-
admissionMicros:
|
|
355
|
-
input:
|
|
356
|
-
output:
|
|
357
|
-
failureData:
|
|
358
|
-
payloadRef:
|
|
359
|
-
$ref:
|
|
360
|
-
bytes:
|
|
361
|
-
sha256:
|
|
362
|
-
}>,
|
|
328
|
+
declare const CaptureRecordSchema: Type.TObject<{
|
|
329
|
+
id: Type.TString;
|
|
330
|
+
service: Type.TString;
|
|
331
|
+
operation: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
332
|
+
organizationId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
333
|
+
actorId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
334
|
+
actorKind: Type.TUnion<[Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"service">]>, Type.TNull]>;
|
|
335
|
+
requestId: Type.TString;
|
|
336
|
+
traceId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
337
|
+
surface: Type.TUnion<[Type.TLiteral<"http">, Type.TLiteral<"mcp">, Type.TLiteral<"rpc">]>;
|
|
338
|
+
occurredAt: Type.TInteger;
|
|
339
|
+
durationMicros: Type.TInteger;
|
|
340
|
+
outcome: Type.TUnion<[Type.TLiteral<"success">, Type.TLiteral<"failure">]>;
|
|
341
|
+
errorCode: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
342
|
+
stage: Type.TUnion<[Type.TLiteral<"execution">, Type.TLiteral<"admission">]>;
|
|
343
|
+
version: Type.TString;
|
|
344
|
+
effect: Type.TUnion<[Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"delete">]>, Type.TNull]>;
|
|
345
|
+
scopes: Type.TArray<Type.TString>;
|
|
346
|
+
visibility: Type.TUnion<[Type.TUnion<[Type.TLiteral<"public">, Type.TLiteral<"internal">]>, Type.TNull]>;
|
|
347
|
+
httpMethod: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
348
|
+
httpPath: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
349
|
+
mcpTool: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
350
|
+
rpcCaller: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
351
|
+
clientId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
352
|
+
clientClass: Type.TUnion<[Type.TUnion<[Type.TLiteral<"human">, Type.TLiteral<"machine">, Type.TLiteral<"dcr">]>, Type.TNull]>;
|
|
353
|
+
grantedScopes: Type.TUnion<[Type.TArray<Type.TString>, Type.TNull]>;
|
|
354
|
+
userAgent: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
355
|
+
tokenSha256: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
356
|
+
dimensions: Type.TRecord<"^.*$", Type.TString>;
|
|
357
|
+
startedAt: Type.TInteger;
|
|
358
|
+
admissionMicros: Type.TInteger;
|
|
359
|
+
input: Type.TUnknown;
|
|
360
|
+
output: Type.TUnknown;
|
|
361
|
+
failureData: Type.TUnknown;
|
|
362
|
+
payloadRef: Type.TUnion<[Type.TObject<{
|
|
363
|
+
$ref: Type.TString;
|
|
364
|
+
bytes: Type.TInteger;
|
|
365
|
+
sha256: Type.TString;
|
|
366
|
+
}>, Type.TNull]>;
|
|
363
367
|
}>;
|
|
364
368
|
/** One capture record. */
|
|
365
369
|
type CaptureRecord = Static<typeof CaptureRecordSchema>;
|
|
@@ -401,11 +405,11 @@ declare function protectedResourceMetadata<E>(resource: OAuthResource<E>, env: E
|
|
|
401
405
|
* Who calls, as every operation receives it: the actor, its kind, its verified organization and the request
|
|
402
406
|
* id.
|
|
403
407
|
*/
|
|
404
|
-
declare const PrincipalSchema:
|
|
405
|
-
actorId:
|
|
406
|
-
actorKind:
|
|
407
|
-
organizationId:
|
|
408
|
-
requestId:
|
|
408
|
+
declare const PrincipalSchema: Type.TObject<{
|
|
409
|
+
actorId: Type.TString;
|
|
410
|
+
actorKind: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"service">]>;
|
|
411
|
+
organizationId: Type.TString;
|
|
412
|
+
requestId: Type.TString;
|
|
409
413
|
}>;
|
|
410
414
|
/** Who calls: the actor, its kind, its organization and the request id. */
|
|
411
415
|
type Principal = Static<typeof PrincipalSchema>;
|
|
@@ -413,9 +417,9 @@ type Principal = Static<typeof PrincipalSchema>;
|
|
|
413
417
|
* The OAuth client a token was issued to: its id and its class, `human`, `machine` or `dcr` (a dynamically
|
|
414
418
|
* registered client).
|
|
415
419
|
*/
|
|
416
|
-
declare const TokenClientSchema:
|
|
417
|
-
id:
|
|
418
|
-
class:
|
|
420
|
+
declare const TokenClientSchema: Type.TObject<{
|
|
421
|
+
id: Type.TString;
|
|
422
|
+
class: Type.TUnion<[Type.TLiteral<"human">, Type.TLiteral<"machine">, Type.TLiteral<"dcr">]>;
|
|
419
423
|
}>;
|
|
420
424
|
/** The OAuth client a token was issued to. */
|
|
421
425
|
type TokenClient = Static<typeof TokenClientSchema>;
|
|
@@ -423,15 +427,15 @@ type TokenClient = Static<typeof TokenClientSchema>;
|
|
|
423
427
|
* What a verified token grants: the principal without a request id, its scopes and, for an OAuth token, its
|
|
424
428
|
* client. A custom `tokens.resolve` returns this shape.
|
|
425
429
|
*/
|
|
426
|
-
declare const TokenPrincipalSchema:
|
|
427
|
-
actorId:
|
|
428
|
-
actorKind:
|
|
429
|
-
organizationId:
|
|
430
|
-
scopes:
|
|
430
|
+
declare const TokenPrincipalSchema: Type.TObject<{
|
|
431
|
+
actorId: Type.TString;
|
|
432
|
+
actorKind: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"service">]>;
|
|
433
|
+
organizationId: Type.TString;
|
|
434
|
+
scopes: Type.TArray<Type.TString>;
|
|
431
435
|
/** Custom resolvers must classify DCR from verified application policy, never request headers. */
|
|
432
|
-
client:
|
|
433
|
-
id:
|
|
434
|
-
class:
|
|
436
|
+
client: Type.TOptional<Type.TObject<{
|
|
437
|
+
id: Type.TString;
|
|
438
|
+
class: Type.TUnion<[Type.TLiteral<"human">, Type.TLiteral<"machine">, Type.TLiteral<"dcr">]>;
|
|
435
439
|
}>>;
|
|
436
440
|
}>;
|
|
437
441
|
/** What a verified token grants. */
|
|
@@ -847,6 +851,8 @@ interface ExecutionCall {
|
|
|
847
851
|
readonly rpcCaller?: string;
|
|
848
852
|
/** On HTTP and MCP, the request's user agent: `Invocation.userAgent`. */
|
|
849
853
|
readonly userAgent?: string;
|
|
854
|
+
/** The task the call runs as, which only the task store sets: `Invocation.taskId`. */
|
|
855
|
+
readonly taskId?: string;
|
|
850
856
|
/** Set once the input is admitted: what its schema checked, and the decoded value the handler receives. */
|
|
851
857
|
admitted?: {
|
|
852
858
|
readonly checked: unknown;
|
|
@@ -976,13 +982,33 @@ interface CapturedCall {
|
|
|
976
982
|
* or while capture is off, whether telemetry is on or not.
|
|
977
983
|
*/
|
|
978
984
|
declare function recordCapture<E>(application: CaptureApplication<E>, env: E, background: BackgroundContext | undefined, captured: CapturedCall): void;
|
|
979
|
-
/** Opaque owner codecs already carry their decoded static type; only native transforms need traversal. */
|
|
980
|
-
type HasNativeTransform<S extends TSchema> = typeof TransformKind extends keyof S ? true : string extends S[typeof Kind] ? false : S extends TObject<infer P> ? true extends { [K in keyof P]: HasNativeTransform<P[K]>; }[keyof P] ? true : false : S extends TArray<infer I> ? HasNativeTransform<I> : S extends TUnion<infer U> | TTuple<infer U> ? HasNativeTransform<U[number]> : S extends TRecord<TSchema, infer V> ? HasNativeTransform<V> : false;
|
|
981
985
|
/**
|
|
982
|
-
* A schema's
|
|
983
|
-
*
|
|
986
|
+
* A schema's JSON Schema keywords, as Maximus reads them to publish, route and check a contract. TypeBox 1.x
|
|
987
|
+
* types a schema without its options, so a service reads one through this view:
|
|
988
|
+
* `(schema as SchemaKeywords).pattern`.
|
|
984
989
|
*/
|
|
985
|
-
|
|
990
|
+
interface SchemaKeywords extends TSchema {
|
|
991
|
+
$id?: string;
|
|
992
|
+
type?: string | string[];
|
|
993
|
+
description?: string;
|
|
994
|
+
default?: unknown;
|
|
995
|
+
properties?: Record<string, SchemaKeywords>;
|
|
996
|
+
required?: string[];
|
|
997
|
+
additionalProperties?: boolean | SchemaKeywords;
|
|
998
|
+
patternProperties?: Record<string, SchemaKeywords>;
|
|
999
|
+
items?: SchemaKeywords | SchemaKeywords[];
|
|
1000
|
+
anyOf?: SchemaKeywords[];
|
|
1001
|
+
allOf?: SchemaKeywords[];
|
|
1002
|
+
oneOf?: SchemaKeywords[];
|
|
1003
|
+
minProperties?: number;
|
|
1004
|
+
maxProperties?: number;
|
|
1005
|
+
$ref?: string;
|
|
1006
|
+
$defs?: Record<string, SchemaKeywords>;
|
|
1007
|
+
pattern?: string;
|
|
1008
|
+
format?: string;
|
|
1009
|
+
minLength?: number;
|
|
1010
|
+
maxLength?: number;
|
|
1011
|
+
}
|
|
986
1012
|
/**
|
|
987
1013
|
* What the transport verified about a call's token, kept apart from the principal: the surface, the granted
|
|
988
1014
|
* scopes, the OAuth client and the token itself. Context preparation and handlers receive a frozen copy.
|
|
@@ -1036,6 +1062,11 @@ interface Invocation<Env> {
|
|
|
1036
1062
|
readonly input?: unknown;
|
|
1037
1063
|
/** The name of the operation being called, which the builder sets; never taken from caller input. */
|
|
1038
1064
|
readonly operation?: string;
|
|
1065
|
+
/**
|
|
1066
|
+
* The id of the task the call runs as, when it runs as one: the task store sets it, never caller input.
|
|
1067
|
+
* Absent on a call that answers its own result.
|
|
1068
|
+
*/
|
|
1069
|
+
readonly taskId?: string;
|
|
1039
1070
|
/**
|
|
1040
1071
|
* Where the call keeps best-effort work running after its answer, the runtime's `waitUntil`; absent when
|
|
1041
1072
|
* the runtime gives none.
|
|
@@ -1119,6 +1150,16 @@ interface Exposure {
|
|
|
1119
1150
|
rpc?: true | {
|
|
1120
1151
|
callers: readonly string[];
|
|
1121
1152
|
};
|
|
1153
|
+
/**
|
|
1154
|
+
* Whether a call that outlasts a short wait may answer a task instead of its result: over MCP when the client
|
|
1155
|
+
* declares the Tasks extension, over HTTP when it sends `Prefer: respond-async`. The work then goes on in the
|
|
1156
|
+
* `MAXIMUS_TASKS` task store, at most once; without that binding the operation always answers its result.
|
|
1157
|
+
* `{ ttlMs }` keeps the task and its result for that long after the call, instead of an hour.
|
|
1158
|
+
*/
|
|
1159
|
+
task?: true | {
|
|
1160
|
+
/** How long the task and its result are kept after the call, in milliseconds, at most a day. */
|
|
1161
|
+
ttlMs: number;
|
|
1162
|
+
};
|
|
1122
1163
|
}
|
|
1123
1164
|
/**
|
|
1124
1165
|
* An operation as an application holds it: its scope, words, effect, schemas, limits, exposure and handler.
|
|
@@ -1214,7 +1255,7 @@ type OperationContext<C, X> = C & (X extends {
|
|
|
1214
1255
|
body: BinaryBody;
|
|
1215
1256
|
} : object);
|
|
1216
1257
|
/** An operation's handler: the prepared context and the decoded input in, a Result of its output out. */
|
|
1217
|
-
type OperationHandler<C, I extends TSchema, O extends TSchema, X> = (context: OperationContext<C, X>, input: StaticDecode
|
|
1258
|
+
type OperationHandler<C, I extends TSchema, O extends TSchema, X> = (context: OperationContext<C, X>, input: StaticDecode<I>) => Promise<Result<Static<O>, Failure>>;
|
|
1218
1259
|
/**
|
|
1219
1260
|
* Declares one operation on its own, keeping its literal types. The builder's `.operation()` is the usual way
|
|
1220
1261
|
* to declare one. As there, `execute` receives the decoded input, `StaticDecode<typeof input>`.
|
|
@@ -1367,6 +1408,128 @@ interface AppManifest<Env, C, Ops extends Record<string, OperationShape>> {
|
|
|
1367
1408
|
/** The MCP server's instructions, guides and skills; setting it requires the MCP transport. */
|
|
1368
1409
|
mcp?: McpConfiguration;
|
|
1369
1410
|
}
|
|
1411
|
+
/** A task as the store keeps it: the call it runs, as whom, and how it ended; never its input. */
|
|
1412
|
+
interface TaskRecord {
|
|
1413
|
+
/** The application's namespace, a dot, and a random UUID, so a gateway can tell whose task it is. */
|
|
1414
|
+
taskId: string;
|
|
1415
|
+
operation: string;
|
|
1416
|
+
principal: Principal;
|
|
1417
|
+
/** The verified authority of the call, without its bearer token, which is never stored. */
|
|
1418
|
+
authority?: Omit<InvocationAuthority, 'token'>;
|
|
1419
|
+
status: 'working' | 'completed' | 'failed' | 'cancelled';
|
|
1420
|
+
/** Set before the work runs, so a task found started but still working is never run again. */
|
|
1421
|
+
started: boolean;
|
|
1422
|
+
result?: Result<unknown, Failure>;
|
|
1423
|
+
createdAt: number;
|
|
1424
|
+
lastUpdatedAt: number;
|
|
1425
|
+
/** How long after `createdAt` the task and its result are kept. */
|
|
1426
|
+
ttlMs: number;
|
|
1427
|
+
}
|
|
1428
|
+
/** The task store's methods, as the Worker calls the Durable Object that keeps one task. */
|
|
1429
|
+
interface TaskStore {
|
|
1430
|
+
/** Keeps the task, runs it with `input`, which stays in memory, and answers it once settled or after `waitMs`. */
|
|
1431
|
+
run: (task: TaskRecord, input: unknown, waitMs: number) => Promise<TaskRecord>;
|
|
1432
|
+
get: (taskId: string, principal: Principal) => Promise<TaskRecord | undefined>;
|
|
1433
|
+
cancel: (taskId: string, principal: Principal) => Promise<TaskRecord | undefined>;
|
|
1434
|
+
}
|
|
1435
|
+
/** One caller's tasks: start one of the application's operations as a task, read one, or cancel one. */
|
|
1436
|
+
interface TaskAccess {
|
|
1437
|
+
start: (operation: string, input: unknown) => Promise<TaskRecord>;
|
|
1438
|
+
get: (taskId: string) => Promise<TaskRecord | undefined>;
|
|
1439
|
+
cancel: (taskId: string) => Promise<TaskRecord | undefined>;
|
|
1440
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* `getOperationTask`, `GET /v1/operation-tasks/{taskId}`, which reads a task the caller started, and
|
|
1443
|
+
* `cancelOperationTask`, `POST /v1/operation-tasks/{taskId}/cancel`, which cancels one that has not started
|
|
1444
|
+
* running: names and paths no resource of a service uses. Either admits any scope of the task operations;
|
|
1445
|
+
* someone else's task, or an unknown or expired one, is `INVALID_INPUT` at `/taskId`, their only failure
|
|
1446
|
+
* besides admission's.
|
|
1447
|
+
*/
|
|
1448
|
+
declare function taskOperations(scope: readonly [string, ...string[]], application: {
|
|
1449
|
+
namespace: string;
|
|
1450
|
+
operations: Record<string, OperationShape>;
|
|
1451
|
+
}): {
|
|
1452
|
+
getOperationTask: {
|
|
1453
|
+
scope: readonly [string, ...string[]];
|
|
1454
|
+
group: string;
|
|
1455
|
+
failures: never[];
|
|
1456
|
+
input: Type.TObject<{
|
|
1457
|
+
taskId: Type.TString;
|
|
1458
|
+
}>;
|
|
1459
|
+
output: Type.TObject<{
|
|
1460
|
+
taskId: Type.TString;
|
|
1461
|
+
status: Type.TUnion<[Type.TLiteral<"working">, Type.TLiteral<"completed">, Type.TLiteral<"failed">, Type.TLiteral<"cancelled">]>;
|
|
1462
|
+
createdAt: Type.TString;
|
|
1463
|
+
lastUpdatedAt: Type.TString;
|
|
1464
|
+
ttlMs: Type.TInteger;
|
|
1465
|
+
pollIntervalMs: Type.TInteger;
|
|
1466
|
+
result: Type.TOptional<Type.TUnknown>;
|
|
1467
|
+
error: Type.TOptional<Type.TWith<Type.TObject<{
|
|
1468
|
+
code: Type.TString;
|
|
1469
|
+
message: Type.TString;
|
|
1470
|
+
retryable: Type.TBoolean;
|
|
1471
|
+
data: Type.TObject<{}>;
|
|
1472
|
+
}>, {
|
|
1473
|
+
readonly description: "The operation's failure, once failed.";
|
|
1474
|
+
}>>;
|
|
1475
|
+
}>;
|
|
1476
|
+
pipeline: {
|
|
1477
|
+
context: (invocation: never) => Promise<Success<never>>;
|
|
1478
|
+
middleware: never[];
|
|
1479
|
+
};
|
|
1480
|
+
title: string;
|
|
1481
|
+
description: string;
|
|
1482
|
+
effect: 'read';
|
|
1483
|
+
http: {
|
|
1484
|
+
method: 'GET';
|
|
1485
|
+
path: string;
|
|
1486
|
+
};
|
|
1487
|
+
execute: OperationShape['execute'];
|
|
1488
|
+
};
|
|
1489
|
+
cancelOperationTask: {
|
|
1490
|
+
scope: readonly [string, ...string[]];
|
|
1491
|
+
group: string;
|
|
1492
|
+
failures: never[];
|
|
1493
|
+
input: Type.TObject<{
|
|
1494
|
+
taskId: Type.TString;
|
|
1495
|
+
}>;
|
|
1496
|
+
output: Type.TObject<{
|
|
1497
|
+
taskId: Type.TString;
|
|
1498
|
+
status: Type.TUnion<[Type.TLiteral<"working">, Type.TLiteral<"completed">, Type.TLiteral<"failed">, Type.TLiteral<"cancelled">]>;
|
|
1499
|
+
createdAt: Type.TString;
|
|
1500
|
+
lastUpdatedAt: Type.TString;
|
|
1501
|
+
ttlMs: Type.TInteger;
|
|
1502
|
+
pollIntervalMs: Type.TInteger;
|
|
1503
|
+
result: Type.TOptional<Type.TUnknown>;
|
|
1504
|
+
error: Type.TOptional<Type.TWith<Type.TObject<{
|
|
1505
|
+
code: Type.TString;
|
|
1506
|
+
message: Type.TString;
|
|
1507
|
+
retryable: Type.TBoolean;
|
|
1508
|
+
data: Type.TObject<{}>;
|
|
1509
|
+
}>, {
|
|
1510
|
+
readonly description: "The operation's failure, once failed.";
|
|
1511
|
+
}>>;
|
|
1512
|
+
}>;
|
|
1513
|
+
pipeline: {
|
|
1514
|
+
context: (invocation: never) => Promise<Success<never>>;
|
|
1515
|
+
middleware: never[];
|
|
1516
|
+
};
|
|
1517
|
+
title: string;
|
|
1518
|
+
description: string;
|
|
1519
|
+
effect: 'write';
|
|
1520
|
+
http: {
|
|
1521
|
+
method: 'POST';
|
|
1522
|
+
path: string;
|
|
1523
|
+
};
|
|
1524
|
+
execute: OperationShape['execute'];
|
|
1525
|
+
};
|
|
1526
|
+
};
|
|
1527
|
+
/** The operations `.build()` adds once an operation declares `task`: `getOperationTask` and `cancelOperationTask`. */
|
|
1528
|
+
type TaskOperations = ReturnType<typeof taskOperations>;
|
|
1529
|
+
/** An application's operations, with the task operations when one of them declares `task`. */
|
|
1530
|
+
type WithTaskOperations<Ops> = true extends { [K in keyof Ops]: Ops[K] extends {
|
|
1531
|
+
task: NonNullable<OperationShape['task']>;
|
|
1532
|
+
} ? true : false; }[keyof Ops] ? Ops & TaskOperations : Ops;
|
|
1370
1533
|
/**
|
|
1371
1534
|
* What `maximus()` takes: the application without its operations, context and middleware, which the builder
|
|
1372
1535
|
* adds.
|
|
@@ -1427,7 +1590,7 @@ declare class ApplicationBuilder<E, C, Ops extends Record<string, OperationShape
|
|
|
1427
1590
|
* Checks every rule the application must keep and returns it. A refusal is a TypeError whose message names
|
|
1428
1591
|
* the rule; most of the rules about one operation also name that operation.
|
|
1429
1592
|
*/
|
|
1430
|
-
build(): AppManifest<E, C, Ops
|
|
1593
|
+
build(): AppManifest<E, C, WithTaskOperations<Ops>>;
|
|
1431
1594
|
}
|
|
1432
1595
|
/**
|
|
1433
1596
|
* Starts an application: its name, scope namespace, title, version, origin, token policy, error catalog and
|
|
@@ -1594,10 +1757,19 @@ declare class Failed<Code extends string = string> {
|
|
|
1594
1757
|
}
|
|
1595
1758
|
/** Answers a failure of the catalog by its code, with the data the code declares. */
|
|
1596
1759
|
type Fail<Codes extends string> = <const Code extends Codes>(code: Code, ...data: FailureArguments<Code>) => Failed<Code>;
|
|
1760
|
+
/**
|
|
1761
|
+
* A TypeBox type rather than a record of fields: TypeBox marks every type it builds with a hidden kind, and
|
|
1762
|
+
* `Type.Unsafe` its own. Every object is a `TSchema`, so the marks are what tell the two apart.
|
|
1763
|
+
*/
|
|
1764
|
+
type TypeBoxType = {
|
|
1765
|
+
readonly '~kind': string;
|
|
1766
|
+
} | {
|
|
1767
|
+
readonly '~unsafe': unknown;
|
|
1768
|
+
};
|
|
1597
1769
|
/** A schema, or the fields of a strict object schema. */
|
|
1598
1770
|
type SchemaOrFields = TSchema | TProperties;
|
|
1599
1771
|
/** The schema `input` or `output` stands for: itself, or the strict object of its fields. */
|
|
1600
|
-
type SchemaOf<S> = S extends
|
|
1772
|
+
type SchemaOf<S> = S extends TypeBoxType ? S : S extends TProperties ? TObject<S> : never;
|
|
1601
1773
|
/** A field a declaration names, or none when it leaves the field out (its type parameter stays `never`). */
|
|
1602
1774
|
type Field<K extends string, T> = [T] extends [never] ? unknown : Record<K, T>;
|
|
1603
1775
|
/**
|
|
@@ -1619,7 +1791,7 @@ interface RouteBody {
|
|
|
1619
1791
|
/** What a handler receives: the prepared context, its decoded input, `fail` and, for a byte body, its reader. */
|
|
1620
1792
|
type HandlerArguments<C, I extends TSchema, X> = Omit<C, 'input' | 'body'> & {
|
|
1621
1793
|
/** The input, decoded against its schema. */
|
|
1622
|
-
readonly input: StaticDecode
|
|
1794
|
+
readonly input: StaticDecode<I>;
|
|
1623
1795
|
/** Answers a failure of the catalog: `return fail('TASK_NOT_FOUND')`. */
|
|
1624
1796
|
readonly fail: Fail<AllowedCode<X>>;
|
|
1625
1797
|
} & (X extends {
|
|
@@ -1716,6 +1888,8 @@ interface HandlerOptions {
|
|
|
1716
1888
|
mcp?: HandlerMcp;
|
|
1717
1889
|
/** Also serve it as a native RPC method, to every allowed caller or to the listed ones. */
|
|
1718
1890
|
rpc?: Exposure['rpc'];
|
|
1891
|
+
/** `true`, or `{ ttlMs }`: a call that outlasts one second may answer a task instead of its result. */
|
|
1892
|
+
task?: Exposure['task'];
|
|
1719
1893
|
/**
|
|
1720
1894
|
* The largest request body it accepts, in bytes: its JSON body, or its byte body. By default, the
|
|
1721
1895
|
* application's limit.
|
|
@@ -1853,9 +2027,7 @@ declare function defineTelemetry(telemetry: TelemetryConfig<RegisteredEnv>): Tel
|
|
|
1853
2027
|
*/
|
|
1854
2028
|
declare function parseInput<Schema extends TSchema>(schema: Schema, input: unknown): {
|
|
1855
2029
|
ok: true;
|
|
1856
|
-
value:
|
|
1857
|
-
params: [];
|
|
1858
|
-
})["static"];
|
|
2030
|
+
value: Static<Schema>;
|
|
1859
2031
|
error?: undefined;
|
|
1860
2032
|
} | {
|
|
1861
2033
|
value?: undefined;
|
|
@@ -1871,11 +2043,11 @@ declare function parseInput<Schema extends TSchema>(schema: Schema, input: unkno
|
|
|
1871
2043
|
declare function parseSchema<Schema extends TSchema>(schema: Schema, input: unknown): Static<Schema>;
|
|
1872
2044
|
/**
|
|
1873
2045
|
* Decodes input against its schema: admits only a bounded plain JSON tree, applies the declared defaults to a
|
|
1874
|
-
* copy, checks it and runs its codecs. Throws a `SchemaValidationError` (or TypeBox's
|
|
1875
|
-
* input is refused, and whatever an owner codec throws otherwise. Output is checked,
|
|
1876
|
-
* handler returns must already be canonical.
|
|
2046
|
+
* copy, checks it, refinements included, and runs its codecs. Throws a `SchemaValidationError` (or TypeBox's
|
|
2047
|
+
* assertion error) when the input is refused, and whatever an owner codec throws otherwise. Output is checked,
|
|
2048
|
+
* never decoded: what a handler returns must already be canonical.
|
|
1877
2049
|
*/
|
|
1878
|
-
declare function decodeSchema<Schema extends TSchema>(schema: Schema, input: unknown): StaticDecode
|
|
2050
|
+
declare function decodeSchema<Schema extends TSchema>(schema: Schema, input: unknown): StaticDecode<Schema>;
|
|
1879
2051
|
/** Field issues a refusal carries: enough to correct the input, never an input value. */
|
|
1880
2052
|
interface InputIssue {
|
|
1881
2053
|
/** RFC 6901 JSON Pointer to the refused field; empty for the whole input. */
|
|
@@ -1890,7 +2062,7 @@ interface InputIssue {
|
|
|
1890
2062
|
*/
|
|
1891
2063
|
declare function decodeInput<Schema extends TSchema>(schema: Schema, input: unknown): {
|
|
1892
2064
|
ok: true;
|
|
1893
|
-
value: StaticDecode
|
|
2065
|
+
value: StaticDecode<Schema>;
|
|
1894
2066
|
} | {
|
|
1895
2067
|
value?: undefined;
|
|
1896
2068
|
ok: false;
|
|
@@ -1904,6 +2076,24 @@ declare function decodeInput<Schema extends TSchema>(schema: Schema, input: unkn
|
|
|
1904
2076
|
};
|
|
1905
2077
|
checked?: undefined;
|
|
1906
2078
|
};
|
|
2079
|
+
/**
|
|
2080
|
+
* One refused field: a code, a message that names the expectation and never the value, and the path to the
|
|
2081
|
+
* field.
|
|
2082
|
+
*/
|
|
2083
|
+
interface SchemaIssue {
|
|
2084
|
+
/** The kind of issue, such as `invalid_input` for a schema mismatch or `custom` for a refinement. */
|
|
2085
|
+
code: string;
|
|
2086
|
+
/** Why the field was refused, for people; it names the expectation, never the value. */
|
|
2087
|
+
message: string;
|
|
2088
|
+
/** The keys and array indexes that lead to the refused field; empty when the whole value is refused. */
|
|
2089
|
+
path: (string | number)[];
|
|
2090
|
+
}
|
|
2091
|
+
/** Every issue of a refused value, as `readSchema` throws it and `checkSchema` returns it. */
|
|
2092
|
+
declare class SchemaValidationError extends TypeError {
|
|
2093
|
+
/** Every issue of the refused value; the error's message is the first one's. */
|
|
2094
|
+
readonly issues: SchemaIssue[];
|
|
2095
|
+
constructor(issues: SchemaIssue[]);
|
|
2096
|
+
}
|
|
1907
2097
|
/** Type-only: the key under which a codec's schema type carries its wire type. No schema object has it. */
|
|
1908
2098
|
declare const WIRE: unique symbol;
|
|
1909
2099
|
/**
|
|
@@ -1927,25 +2117,12 @@ type InputKeys<P extends TProperties> = { [K in keyof P]: P[K] extends {
|
|
|
1927
2117
|
*/
|
|
1928
2118
|
type SchemaInput<S extends TSchema, Depth extends unknown[] = []> = Depth['length'] extends 6 ? Static<S> : typeof WIRE extends keyof S ? S extends WireType<infer W> ? W : never : S extends TObject<infer P> ? { [K in Exclude<keyof P, InputKeys<P>>]: SchemaInput<P[K], [...Depth, unknown]>; } & { [K in InputKeys<P>]?: SchemaInput<P[K], [...Depth, unknown]>; } : S extends TArray<infer I> ? SchemaInput<I, [...Depth, unknown]>[] : S extends TUnion<infer U> ? SchemaInput<U[number], [...Depth, unknown]> : Static<S>;
|
|
1929
2119
|
/**
|
|
1930
|
-
*
|
|
1931
|
-
*
|
|
2120
|
+
* The literals of a union, as TypeBox types its members: one per value of a tuple, or for an array of unknown
|
|
2121
|
+
* length one literal of every value it may hold, since TypeBox reads a union's members as a tuple.
|
|
1932
2122
|
*/
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
/** Why the field was refused, for people; it names the expectation, never the value. */
|
|
1937
|
-
message: string;
|
|
1938
|
-
/** The keys and array indexes that lead to the refused field; empty when the whole value is refused. */
|
|
1939
|
-
path: (string | number)[];
|
|
1940
|
-
}
|
|
1941
|
-
/** Every issue of a refused value, as `readSchema` throws it and `checkSchema` returns it. */
|
|
1942
|
-
declare class SchemaValidationError extends TypeError {
|
|
1943
|
-
/** Every issue of the refused value; the error's message is the first one's. */
|
|
1944
|
-
readonly issues: SchemaIssue[];
|
|
1945
|
-
constructor(issues: SchemaIssue[]);
|
|
1946
|
-
}
|
|
1947
|
-
/** A union of literals: `literalUnion(['open', 'done'])`. */
|
|
1948
|
-
declare const literalUnion: <const V extends readonly (string | number | boolean)[]>(values: V) => TUnion<{ -readonly [K in keyof V]: TLiteral<V[K]>; }>;
|
|
2123
|
+
type LiteralMembers<V extends readonly (string | number | boolean)[]> = number extends V['length'] ? [TLiteral<V[number]>] : { -readonly [K in keyof V]: TLiteral<V[K]>; };
|
|
2124
|
+
/** A union of literals: `literalUnion(['open', 'done'])`, or the values of a list, `literalUnion(ids)`. */
|
|
2125
|
+
declare const literalUnion: <const V extends readonly (string | number | boolean)[]>(values: V) => TUnion<LiteralMembers<V>>;
|
|
1949
2126
|
/**
|
|
1950
2127
|
* The schema with a default that decoding applies when the field is absent, so the field is optional on the
|
|
1951
2128
|
* wire.
|
|
@@ -1971,7 +2148,7 @@ declare const extendObject: <P extends TProperties, Q extends TProperties>(schem
|
|
|
1971
2148
|
* `inputSchema()`.
|
|
1972
2149
|
*/
|
|
1973
2150
|
declare const normalizeSchema: <S extends TSchema, O>(schema: S, normalize: (value: Static<S>) => O) => TUnsafe<O> & WireType<SchemaInput<S>> & (S extends TOptional<TSchema> ? {
|
|
1974
|
-
|
|
2151
|
+
'~optional': true;
|
|
1975
2152
|
} : Record<never, never>) & (S extends {
|
|
1976
2153
|
default: infer D;
|
|
1977
2154
|
} ? {
|
|
@@ -1982,7 +2159,7 @@ declare const normalizeSchema: <S extends TSchema, O>(schema: S, normalize: (val
|
|
|
1982
2159
|
* the handler receives what `transform` returns. Runs inside `inputSchema()`.
|
|
1983
2160
|
*/
|
|
1984
2161
|
declare const transformSchema: <S extends TSchema, O>(schema: S, transform: (value: Static<S>) => O) => TUnsafe<O> & WireType<SchemaInput<S>> & (S extends TOptional<TSchema> ? {
|
|
1985
|
-
|
|
2162
|
+
'~optional': true;
|
|
1986
2163
|
} : Record<never, never>) & (S extends {
|
|
1987
2164
|
default: infer D;
|
|
1988
2165
|
} ? {
|
|
@@ -2018,7 +2195,7 @@ declare const urlSchema: (options: {
|
|
|
2018
2195
|
protocol: RegExp;
|
|
2019
2196
|
hostname?: RegExp;
|
|
2020
2197
|
maxLength?: number;
|
|
2021
|
-
}) =>
|
|
2198
|
+
}) => Type.TString;
|
|
2022
2199
|
/**
|
|
2023
2200
|
* Compiles a schema's codecs (defaults, normalizers, transforms, inspections, refinements, pipes and
|
|
2024
2201
|
* stripping) into one input schema: the wire accepts `SchemaInput<S>`, and the handler receives the
|
|
@@ -2027,16 +2204,16 @@ declare const urlSchema: (options: {
|
|
|
2027
2204
|
*/
|
|
2028
2205
|
declare function inputSchema<S extends TSchema>(schema: S, options?: {
|
|
2029
2206
|
stripUnknown?: boolean;
|
|
2030
|
-
}):
|
|
2207
|
+
}): TCodec<TUnsafe<SchemaInput<S>>, StaticDecode<S>>;
|
|
2031
2208
|
/** The same, reading another wire shape `wire` and decoding it into `schema`'s canonical type. */
|
|
2032
|
-
declare function inputSchema<S extends TSchema, W extends TSchema>(schema: S, wire: W):
|
|
2209
|
+
declare function inputSchema<S extends TSchema, W extends TSchema>(schema: S, wire: W): TCodec<W, StaticDecode<S>>;
|
|
2033
2210
|
/**
|
|
2034
2211
|
* What `checkSchema` answers: the decoded data, `StaticDecode<S>` (which is `Static<S>` unless `S` holds a
|
|
2035
|
-
* TypeBox
|
|
2212
|
+
* TypeBox codec), or the error that lists every issue.
|
|
2036
2213
|
*/
|
|
2037
2214
|
type Checked<S extends TSchema> = {
|
|
2038
2215
|
success: true;
|
|
2039
|
-
data: StaticDecode
|
|
2216
|
+
data: StaticDecode<S>;
|
|
2040
2217
|
error?: never;
|
|
2041
2218
|
} | {
|
|
2042
2219
|
success: false;
|
|
@@ -2051,7 +2228,7 @@ type Checked<S extends TSchema> = {
|
|
|
2051
2228
|
*/
|
|
2052
2229
|
declare function checkSchema<S extends TSchema>(schema: S, input: unknown): Checked<S>;
|
|
2053
2230
|
/** `checkSchema`, throwing its SchemaValidationError on refusal. */
|
|
2054
|
-
declare function readSchema<S extends TSchema>(schema: S, input: unknown): StaticDecode
|
|
2231
|
+
declare function readSchema<S extends TSchema>(schema: S, input: unknown): StaticDecode<S>;
|
|
2055
2232
|
/**
|
|
2056
2233
|
* A copy of a value without every field its schema marks with `secret: true`, at any depth: through objects,
|
|
2057
2234
|
* records, arrays, tuples, unions, intersections, optional fields and references. The input is never changed.
|
|
@@ -2068,10 +2245,10 @@ declare function withoutSecrets(schema: TSchema, value: unknown): unknown;
|
|
|
2068
2245
|
* How to reach a list's neighboring pages: whether they exist and their opaque cursors, named `PageInfo`.
|
|
2069
2246
|
*/
|
|
2070
2247
|
declare const PageInfoSchema: TObject<{
|
|
2071
|
-
hasNextPage:
|
|
2072
|
-
hasPreviousPage:
|
|
2073
|
-
nextCursor:
|
|
2074
|
-
previousCursor:
|
|
2248
|
+
hasNextPage: Type.TBoolean;
|
|
2249
|
+
hasPreviousPage: Type.TBoolean;
|
|
2250
|
+
nextCursor: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
2251
|
+
previousCursor: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
2075
2252
|
}>;
|
|
2076
2253
|
/** How to reach a list's neighboring pages. */
|
|
2077
2254
|
type PageInfo = Static<typeof PageInfoSchema>;
|
|
@@ -2084,7 +2261,7 @@ type PageInfo = Static<typeof PageInfoSchema>;
|
|
|
2084
2261
|
declare function pageLimit(options?: {
|
|
2085
2262
|
maximum?: number;
|
|
2086
2263
|
default?: number;
|
|
2087
|
-
}):
|
|
2264
|
+
}): Type.TInteger & {
|
|
2088
2265
|
default: number;
|
|
2089
2266
|
};
|
|
2090
2267
|
/**
|
|
@@ -2092,11 +2269,11 @@ declare function pageLimit(options?: {
|
|
|
2092
2269
|
* `direction` (`forward` by default, or `backward`) and a `limit` (`pageLimit()`).
|
|
2093
2270
|
*/
|
|
2094
2271
|
declare const PageQueryFields: {
|
|
2095
|
-
cursor:
|
|
2096
|
-
direction:
|
|
2272
|
+
cursor: Type.TOptional<Type.TString>;
|
|
2273
|
+
direction: Type.TUnion<[TLiteral<"forward">, TLiteral<"backward">]> & {
|
|
2097
2274
|
default: "forward";
|
|
2098
2275
|
};
|
|
2099
|
-
limit:
|
|
2276
|
+
limit: Type.TInteger & {
|
|
2100
2277
|
default: number;
|
|
2101
2278
|
};
|
|
2102
2279
|
};
|
|
@@ -2125,6 +2302,28 @@ interface Page<Item> {
|
|
|
2125
2302
|
declare function Page<Item extends TSchema>(item: Item, options: {
|
|
2126
2303
|
$id: string;
|
|
2127
2304
|
}): TPage<Item>;
|
|
2305
|
+
/** How a list a service holds whole is ordered: by each item's key, compared part by part as text. */
|
|
2306
|
+
interface PageOrder<Item> {
|
|
2307
|
+
/** The values an item sorts by, which together tell it from every other item, such as `[createdAt, id]`. */
|
|
2308
|
+
key: (item: Item) => readonly string[];
|
|
2309
|
+
/** `desc` lists the greatest key first, such as the newest; `asc`, the default, the least. */
|
|
2310
|
+
order?: 'asc' | 'desc';
|
|
2311
|
+
}
|
|
2312
|
+
/**
|
|
2313
|
+
* The key of the item a cursor of `cutPage` sits beside, or undefined for text that is not such a cursor: a
|
|
2314
|
+
* service checks with it that a cursor belongs to the list it is asked for before it reads that list.
|
|
2315
|
+
*/
|
|
2316
|
+
declare function cursorKey(cursor: string): readonly string[] | undefined;
|
|
2317
|
+
/**
|
|
2318
|
+
* One page of a list a service holds whole, such as one a provider answers complete. A cursor is a
|
|
2319
|
+
* place between two items, right after one page's last item (`nextCursor`) or right before its first
|
|
2320
|
+
* (`previousCursor`), never an offset: it keeps its meaning while items come and go, the one it names
|
|
2321
|
+
* included. `forward` takes the items after the place and `backward` the ones before it, and both answer in
|
|
2322
|
+
* the list's `ordering`; without a cursor, `forward` starts at the first item and `backward` at the last. A cursor
|
|
2323
|
+
* is null exactly when there is no such page. Undefined when the query's cursor is not one this list made,
|
|
2324
|
+
* including a key of another length, for the service to refuse as it does.
|
|
2325
|
+
*/
|
|
2326
|
+
declare function cutPage<Item>(items: readonly Item[], ordering: PageOrder<Item>, query: PageQuery): Page<Item> | undefined;
|
|
2128
2327
|
/** An email address of at most 254 characters, named `EmailAddress`. */
|
|
2129
2328
|
declare const EmailAddressSchema: TString;
|
|
2130
2329
|
/** A phone number in E.164 format, named `PhoneNumber`. */
|
|
@@ -2134,9 +2333,9 @@ declare const HttpsUrlSchema: TString;
|
|
|
2134
2333
|
/** A `#rrggbb` color, named `HexColor`. */
|
|
2135
2334
|
declare const HexColorSchema: TString;
|
|
2136
2335
|
/** What a delete answers: the deleted resource's id and `deleted: true`, named `DeletedObject`. */
|
|
2137
|
-
declare const DeletedObjectSchema:
|
|
2336
|
+
declare const DeletedObjectSchema: Type.TObject<{
|
|
2138
2337
|
id: TString;
|
|
2139
|
-
deleted:
|
|
2338
|
+
deleted: Type.TLiteral<true>;
|
|
2140
2339
|
}>;
|
|
2141
2340
|
/** What a `delete` answers: the id and `deleted: true`. */
|
|
2142
2341
|
type DeletedObject = Static<typeof DeletedObjectSchema>;
|
|
@@ -2144,14 +2343,14 @@ type DeletedObject = Static<typeof DeletedObjectSchema>;
|
|
|
2144
2343
|
* A link that grants access by itself until it expires, such as a file download: its HTTPS `url` and its
|
|
2145
2344
|
* `expiresAt` date-time, named `SignedUrl`.
|
|
2146
2345
|
*/
|
|
2147
|
-
declare const SignedUrlSchema:
|
|
2346
|
+
declare const SignedUrlSchema: Type.TObject<{
|
|
2148
2347
|
url: TString;
|
|
2149
2348
|
expiresAt: TString;
|
|
2150
2349
|
}>;
|
|
2151
2350
|
/** A URL that grants access by itself, and when it expires. */
|
|
2152
2351
|
type SignedUrl = Static<typeof SignedUrlSchema>;
|
|
2153
2352
|
/** Another resource, by its id and the name people know it by, named `NamedReference`. */
|
|
2154
|
-
declare const NamedReferenceSchema:
|
|
2353
|
+
declare const NamedReferenceSchema: Type.TObject<{
|
|
2155
2354
|
id: TString;
|
|
2156
2355
|
name: TString;
|
|
2157
2356
|
}>;
|
|
@@ -2161,26 +2360,26 @@ type NamedReference = Static<typeof NamedReferenceSchema>;
|
|
|
2161
2360
|
* A postal address, shaped as FHIR `Address` (its lines, city, state, postal code, ISO 3166-1 alpha-2 country
|
|
2162
2361
|
* code and use), every field optional, named `PostalAddress`.
|
|
2163
2362
|
*/
|
|
2164
|
-
declare const PostalAddressSchema:
|
|
2165
|
-
city:
|
|
2166
|
-
countryCode:
|
|
2167
|
-
line:
|
|
2168
|
-
postalCode:
|
|
2169
|
-
state:
|
|
2170
|
-
use:
|
|
2363
|
+
declare const PostalAddressSchema: Type.TObject<{
|
|
2364
|
+
city: Type.TOptional<TString>;
|
|
2365
|
+
countryCode: Type.TOptional<TString>;
|
|
2366
|
+
line: Type.TOptional<Type.TArray<TString>>;
|
|
2367
|
+
postalCode: Type.TOptional<TString>;
|
|
2368
|
+
state: Type.TOptional<TString>;
|
|
2369
|
+
use: Type.TOptional<Type.TUnion<[Type.TLiteral<"home">, Type.TLiteral<"work">]>>;
|
|
2171
2370
|
}>;
|
|
2172
2371
|
/** A postal address, shaped as FHIR `Address`. */
|
|
2173
2372
|
type PostalAddress = Static<typeof PostalAddressSchema>;
|
|
2174
2373
|
/** The input of an operation that takes none: an empty strict object. */
|
|
2175
|
-
declare const EmptyInputSchema:
|
|
2374
|
+
declare const EmptyInputSchema: Type.TObject<{}>;
|
|
2176
2375
|
/**
|
|
2177
2376
|
* An organization id as identity providers issue them (`org_…`, a UUID, a slug): 1 to 128 letters, digits,
|
|
2178
2377
|
* `_` and `-`, starting with a letter or digit, named `OrganizationId`. Nothing in it can change the meaning
|
|
2179
2378
|
* of a storage key, a path or a log line.
|
|
2180
2379
|
*/
|
|
2181
|
-
declare const OrganizationIdSchema:
|
|
2380
|
+
declare const OrganizationIdSchema: Type.TString;
|
|
2182
2381
|
/** A lowercase RFC 9562 UUID of version 1 to 8, named `Uuid`. */
|
|
2183
|
-
declare const UuidSchema:
|
|
2382
|
+
declare const UuidSchema: Type.TString;
|
|
2184
2383
|
/**
|
|
2185
2384
|
* The principal a verified Access application token grants under `policy.access`. A person, whose token
|
|
2186
2385
|
* names them in `sub` and carries no `common_name`, acts as `sub` (never as their email) through a `human`
|
|
@@ -2256,6 +2455,8 @@ interface TransportContext {
|
|
|
2256
2455
|
body: string;
|
|
2257
2456
|
/** The body limit HTTP applies to an operation; a transport holds each invocation to it. */
|
|
2258
2457
|
bodyLimit: (operation: OperationShape) => number;
|
|
2458
|
+
/** The caller's tasks, which an operation that declares `task` may answer; absent without a task store. */
|
|
2459
|
+
tasks?: TaskAccess;
|
|
2259
2460
|
}
|
|
2260
2461
|
/**
|
|
2261
2462
|
* A protocol served at one path beside the operations, such as MCP: the scope a caller needs, the body it
|
|
@@ -2402,10 +2603,6 @@ interface HttpOptions<E = unknown> {
|
|
|
2402
2603
|
* path two of them would claim, and for an option, token scheme or token source it cannot serve.
|
|
2403
2604
|
*/
|
|
2404
2605
|
declare function createHttpHandler<E, C, O extends Record<string, OperationShape>>(manifest: AppManifest<E, C, O>, hooks?: HttpOptions<E>): (request: Request, env: E, background?: BackgroundContext) => Promise<Response>;
|
|
2405
|
-
/**
|
|
2406
|
-
* `@arbol-ai/maximus/http-paths`: versioned route templates, path parameter decoding, and the router that
|
|
2407
|
-
* matches a request to exactly one operation.
|
|
2408
|
-
*/
|
|
2409
2606
|
/** Whether a byte operation may read one of its input fields from this header. */
|
|
2410
2607
|
declare function isInputHeaderName(header: string): boolean;
|
|
2411
2608
|
/**
|
|
@@ -2449,8 +2646,8 @@ interface HttpRouteMatch<D> {
|
|
|
2449
2646
|
* The router for a set of definitions: `match(method, path)` finds the one route a request reaches, with its
|
|
2450
2647
|
* decoded parameters, and `ownsPath(path)` says whether any route answers a path. A definition without `http`
|
|
2451
2648
|
* is skipped. Construction throws a TypeError for an unsupported method, a malformed template, a duplicate
|
|
2452
|
-
* route, or two templates that could match the same path
|
|
2453
|
-
*
|
|
2649
|
+
* route, or two templates that could match the same path; a fixed route may share its path with a template,
|
|
2650
|
+
* and wins it. Matching is rou3's route tree, fixed segments before parameters.
|
|
2454
2651
|
*/
|
|
2455
2652
|
declare function createHttpRouteResolver<D extends HttpRouteDefinition>(definitions: readonly D[]): {
|
|
2456
2653
|
match: (method: string, path: string) => HttpRouteMatch<D> | null;
|
|
@@ -2498,6 +2695,17 @@ declare function readBodyBytes(source: BodySource, options: BodyReadOptions): Pr
|
|
|
2498
2695
|
declare function readBodyText(source: BodySource, options: BodyReadOptions & {
|
|
2499
2696
|
fatalUtf8?: boolean;
|
|
2500
2697
|
}): Promise<Result<string, HttpBodyFailure>>;
|
|
2698
|
+
/**
|
|
2699
|
+
* Where a Worker may send a request for someone it does not control, such as a server an organization
|
|
2700
|
+
* registered. A Worker cannot resolve a name before it fetches it, so the rules hold on the URL itself.
|
|
2701
|
+
*/
|
|
2702
|
+
/**
|
|
2703
|
+
* The URL, when a Worker may send a request there for someone it does not control: https on its default port,
|
|
2704
|
+
* with no credentials or fragment, to a public DNS name; never an IP literal, a special-use or private-network
|
|
2705
|
+
* name, nor Cloudflare's or Arbol's own hosts. Undefined for anything else. Send the request with
|
|
2706
|
+
* `redirect: 'manual'` and refuse a `3xx`, so no redirect takes it elsewhere.
|
|
2707
|
+
*/
|
|
2708
|
+
declare function publicDestination(value: string | URL): URL | undefined;
|
|
2501
2709
|
/**
|
|
2502
2710
|
* Whether a Content-Type value is `application/json` or a structured `+json` type such as
|
|
2503
2711
|
* `application/problem+json`, whatever its parameters and case.
|
|
@@ -2536,7 +2744,7 @@ declare function retryAfterSeconds(value: string | null, nowMs: number, maximum?
|
|
|
2536
2744
|
* effect, limits in force, MCP tool hints and native RPC as `x-*` extensions.
|
|
2537
2745
|
*
|
|
2538
2746
|
* Every schema reference in it is a local `#/components/schemas/<name>` pointer: the `$id`-named
|
|
2539
|
-
* schemas of its paths and components (TypeBox
|
|
2747
|
+
* schemas of its paths and components (TypeBox Cyclic/Ref) become components, as `bundleSchemas`
|
|
2540
2748
|
* describes. A schema `$id` that takes the name of a component the document writes itself, and a component
|
|
2541
2749
|
* named as a generator names an operation's own types, such as `CreateNoteResponse`, throw a TypeError.
|
|
2542
2750
|
*/
|
|
@@ -2563,4 +2771,4 @@ declare function createRpcOpenApi<E, C, O extends Record<string, OperationShape>
|
|
|
2563
2771
|
* the argument.
|
|
2564
2772
|
*/
|
|
2565
2773
|
declare function defineApp<Env, C>(): <const Ops extends Record<string, OperationShape>>(manifest: AppManifest<Env, C, Ops>) => AppManifest<Env, C, Ops>;
|
|
2566
|
-
export {
|
|
2774
|
+
export { PageInfo as $, TokenPolicy as $n, defineContext as $t, TransportContext as A, CaptureConfig as An, ErrorFactory as Ar, decodeSchema as At, DeletedObject as B, BackgroundContext as Bn, durableCorrelation as Br, HandlerArguments as Bt, isPathParameterValue as C, isPublicOperation as Cn, ok as Cr, stripObject as Ct, HttpRoute as D, SchemaKeywords as Dn, DefinedErrors as Dr, SchemaValidationError as Dt, HttpOptions as E, operationScopes as En, CreateArguments as Er, SchemaIssue as Et, Static$2 as F, VerifiedCaller as Fn, resultSchema as Fr, ContextDeclaration as Ft, NamedReference as G, recordExecution as Gn, PreparedContext as Gt, EmailAddressSchema as H, Observer as Hn, parseTraceParent as Hr, HandlerHttp as Ht, TSchema$2 as I, recordCapture as In, standardErrors as Ir, DomainCode as It, PostalAddress as J, withDiagnostics as Jn, SchemaOf as Jt, NamedReferenceSchema as K, reportUnexpected as Kn, RegisteredEnv as Kt, Type$2 as L, ExecutionCall as Ln, DurableCorrelation as Lr, Fail as Lt, projectAccessToken as M, CaptureInvocation as Mn, FailureData as Mr, parseSchema as Mt, EmptyInputSchema as N, CaptureSink as Nn, FailureSchema as Nr, AuthOptions as Nt, HttpTransport as O, StaticDecode as On, ErrorCatalog as Or, InputIssue as Ot, OrganizationIdSchema as P, CapturedCall as Pn, defineErrors as Pr, ContextArguments as Pt, Page as Q, TokenDevelopment as Qn, defineAuth as Qt, UuidSchema as R, executeOperation as Rn, TraceParent as Rr, Failed as Rt, isInputHeaderName as S, composeOperations as Sn, isResult as Sr, strictObject as St, HttpMiddleware as T, operationMatchesScopes as Tn, AttachmentOutputSchema as Tr, urlSchema as Tt, HexColorSchema as U, TelemetryConfig as Un, HandlerMcp as Ut, DeletedObjectSchema as V, ExecutionObservation as Vn, isRequestId as Vr, HandlerDeclaration as Vt, HttpsUrlSchema as W, diagnosticsEnabled as Wn, HandlerOptions as Wt, SignedUrl as X, TokenAlgorithm as Xn, ToolDeclaration as Xt, PostalAddressSchema as Y, TokenAccess as Yn, SchemaOrFields as Yt, SignedUrlSchema as Z, TokenClaims as Zn, ToolOptions as Zt, readBodyText as _, McpSkill as _n, BodyFailure as _r, literalUnion as _t, t as a, ApplicationBuilder as an, projectToken as ar, cursorKey as at, createHttpRouteResolver as b, OperationScope as bn, Success as br, pipeSchema as bt, isJsonMediaType as c, TaskAccess as cn, Principal as cr, withoutSecrets as ct, retryAfterSeconds as d, AppManifest as dn, TokenPrincipal as dr, readSchema as dt, defineHandler as en, TokenResolutionContext as er, PageInfoSchema as et, publicDestination as f, Exposure as fn, OAuthResource as fr, SchemaInput as ft, readBodyBytes as g, McpGuide as gn, BinaryBody as gr, inspectSchema as gt, HttpBodyFailureReason as h, McpConfiguration as hn, CaptureRecordSchema as hr, inputSchema as ht, Type$1 as i, StandardFailure as in, createTokenVerifier as ir, TPage as it, createHttpHandler as j, CaptureDimensions as jn, Failure as jr, parseInput as jt, RouteContext as k, AnyContext as kn, ErrorDefinition as kr, decodeInput as kt, readJsonBody as l, TaskRecord as ln, PrincipalSchema as lr, Checked as lt, HttpBodyFailure as m, InvocationAuthority as mn, CaptureRecord as mr, extendObject as mt, Static$1 as n, defineTool as nn, TokenSource as nr, PageQuery as nt, createOpenApi as o, ApplicationConfiguration as on, ScopeMatch as or, cutPage as ot, BodyReadOptions as p, Invocation as pn, protectedResourceMetadata as pr, defaultSchema as pt, PhoneNumberSchema as q, telemetryEnabled as qn, RouteBody as qt, TSchema$1 as r, STANDARD_FAILURES as rn, createTokenAuthorization as rr, PageQueryFields as rt, createRpcOpenApi as s, maximus as sn, matchesScopes as sr, pageLimit as st, defineApp as t, defineTelemetry as tn, TokenScheme as tr, PageOrder as tt, readJsonResponse as u, TaskStore as un, TokenClient as ur, checkSchema as ut, HttpRouteDefinition as v, OperationHandler as vn, FailureResult as vr, looseObject as vt, operationPathParameters as w, operation as wn, Attachment as wr, transformSchema as wt, decodePathParameter as x, OperationShape as xn, err as xr, refineSchema as xt, HttpRouteMatch as y, OperationMiddleware as yn, Result as yr, normalizeSchema as yt, t$1 as z, AdmissionObservation as zn, createRequestId as zr, HandlerAnswer as zt };
|