@voltro/protocol 0.84.0 → 0.85.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/CHANGELOG.md +549 -0
- package/THIRD-PARTY-NOTICES.md +1 -57
- package/dist/apikey.d.ts +32 -34
- package/dist/index.d.ts +1273 -1349
- package/dist/index.js +1022 -733
- package/dist/inspect.d.ts +88 -88
- package/dist/inspect.js +103 -53
- package/dist/jwt.d.ts +32 -34
- package/dist/rest.d.ts +72 -57
- package/dist/rest.js +287 -208
- package/dist/{restFormat-EZ8k9ZcQ.js → restFormat-BlgTLxm1.js} +108 -114
- package/dist/{scopes-Di756ENh.js → scopes-ClywBij8.js} +167 -137
- package/dist/session.d.ts +90 -96
- package/dist/session.js +1 -1
- package/package.json +4 -8
package/dist/rest.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as AST from 'effect/SchemaAST';
|
|
|
2
2
|
import { DataStore } from '@voltro/database';
|
|
3
3
|
import { Schema } from 'effect';
|
|
4
4
|
|
|
5
|
-
declare interface ActionProcedureDescriptor<Name extends string, Input extends Schema.
|
|
5
|
+
declare interface ActionProcedureDescriptor<Name extends string, Input extends Schema.Top, Output extends Schema.Top, Error extends Schema.Top> {
|
|
6
6
|
readonly kind: 'action';
|
|
7
7
|
readonly name: Name;
|
|
8
8
|
readonly input: Input;
|
|
@@ -113,7 +113,7 @@ export declare const bytes: (stream: ReadableStream<Uint8Array> | (() => Readabl
|
|
|
113
113
|
* Field by field for a struct; the object is returned unchanged for any other
|
|
114
114
|
* shape (the schema then decides). Unknown keys pass through untouched.
|
|
115
115
|
*/
|
|
116
|
-
export declare const coerceQueryObject: (query: unknown, input: Schema.
|
|
116
|
+
export declare const coerceQueryObject: (query: unknown, input: Schema.Top) => unknown;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Coerce ONE query-string value toward what `ast` (an ENCODED shape) expects.
|
|
@@ -144,7 +144,7 @@ export declare const collectPublicApiRoutes: (entries: ReadonlyArray<PublicApiEn
|
|
|
144
144
|
declare type DeclaredAccess<Input = unknown> = ReadonlyArray<AnyGuardSpec<Input> | OpenAccessSpec | ServiceAccessSpec>;
|
|
145
145
|
|
|
146
146
|
/** The `_tag` literals a descriptor's `error:` union declares (empty for none). */
|
|
147
|
-
export declare const declaredErrorTags: (error: Schema.
|
|
147
|
+
export declare const declaredErrorTags: (error: Schema.Top | undefined) => ReadonlySet<string>;
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* Identity helper that fixes the descriptor's types (like `defineAction` /
|
|
@@ -210,7 +210,7 @@ export declare const encodeRestSuccess: (format: RestFormat, value: unknown, ctx
|
|
|
210
210
|
|
|
211
211
|
/** The member of an error union that declares `tag`, as a schema of its own —
|
|
212
212
|
* for the spec's per-status responses. */
|
|
213
|
-
export declare const errorMemberSchema: (error: Schema.
|
|
213
|
+
export declare const errorMemberSchema: (error: Schema.Top | undefined, tag: string) => Schema.Top | undefined;
|
|
214
214
|
|
|
215
215
|
/** Normalize the `exposeAsTool` shorthand. `true` is only valid when the
|
|
216
216
|
* descriptor carries a top-level `description`; callers pass that in. */
|
|
@@ -359,7 +359,7 @@ export declare const matchPathParams: (pattern: string, path: string) => Record<
|
|
|
359
359
|
* (for example joining a room) must execute once for EACH native connection. */
|
|
360
360
|
declare type MutationIdempotencyScope = 'subject' | 'connection';
|
|
361
361
|
|
|
362
|
-
declare interface MutationProcedureDescriptor<Name extends string, Input extends Schema.
|
|
362
|
+
declare interface MutationProcedureDescriptor<Name extends string, Input extends Schema.Top, Output extends Schema.Top, Error extends Schema.Top> {
|
|
363
363
|
readonly kind: 'mutation';
|
|
364
364
|
readonly name: Name;
|
|
365
365
|
readonly input: Input;
|
|
@@ -498,7 +498,7 @@ export declare const pathParamNames: (path: string) => ReadonlyArray<string>;
|
|
|
498
498
|
* Requires the plugin to ship the schema as a NAMED export from `module`.
|
|
499
499
|
*/
|
|
500
500
|
declare interface PluginErrorSchema {
|
|
501
|
-
readonly schema: Schema.
|
|
501
|
+
readonly schema: Schema.Top;
|
|
502
502
|
readonly import: {
|
|
503
503
|
readonly module: string;
|
|
504
504
|
readonly name: string;
|
|
@@ -827,7 +827,7 @@ export declare interface PublicApiClientConfig {
|
|
|
827
827
|
}
|
|
828
828
|
|
|
829
829
|
/** A descriptor kind that can be projected to REST (streams are not, in v1). */
|
|
830
|
-
export declare type PublicApiDescriptor = QueryProcedureDescriptor<string, Schema.
|
|
830
|
+
export declare type PublicApiDescriptor = QueryProcedureDescriptor<string, Schema.Top, Schema.Top, Schema.Top> | MutationProcedureDescriptor<string, Schema.Top, Schema.Top, Schema.Top> | ActionProcedureDescriptor<string, Schema.Top, Schema.Top, Schema.Top>;
|
|
831
831
|
|
|
832
832
|
/** A descriptor paired with its bound executor, for batch projection at boot. */
|
|
833
833
|
export declare interface PublicApiEntry {
|
|
@@ -1061,7 +1061,7 @@ declare interface QueryCacheConfig {
|
|
|
1061
1061
|
readonly scope: 'subject' | 'tenant' | 'global';
|
|
1062
1062
|
}
|
|
1063
1063
|
|
|
1064
|
-
declare interface QueryProcedureDescriptor<Name extends string, Input extends Schema.
|
|
1064
|
+
declare interface QueryProcedureDescriptor<Name extends string, Input extends Schema.Top, Output extends Schema.Top, Error extends Schema.Top> {
|
|
1065
1065
|
readonly kind: 'query';
|
|
1066
1066
|
readonly name: Name;
|
|
1067
1067
|
readonly input: Input;
|
|
@@ -1196,7 +1196,18 @@ export declare interface RestByteResponse {
|
|
|
1196
1196
|
* headers CDNs purge by. A request that carries a credential (`Authorization`
|
|
1197
1197
|
* or a cookie) gets `private, no-cache` and no tags, whatever is declared:
|
|
1198
1198
|
* what a key or a session may see must never land in a shared cache. Every
|
|
1199
|
-
* such answer says `Vary: Authorization, Cookie`.
|
|
1199
|
+
* such answer says `Vary: Authorization, Cookie`.
|
|
1200
|
+
*
|
|
1201
|
+
* With `audience`, the ANSWER decides instead of the request's cookies: an
|
|
1202
|
+
* answer that is the same for every reader (`'public'`) is shared even when
|
|
1203
|
+
* the request carries cookies (a consent choice, a signed-in reader on a
|
|
1204
|
+
* public page) — the cache serves it to everyone, so it says only
|
|
1205
|
+
* `Vary: Authorization`; an answer for this reader alone (`'private'`: a
|
|
1206
|
+
* members page, a running experiment) is `private, no-store`. A request with
|
|
1207
|
+
* `Authorization` is private either way.
|
|
1208
|
+
*
|
|
1209
|
+
* Any other answer than a 200 (a 404, a 410, a 401) of a route with `cache`
|
|
1210
|
+
* is `private, no-store`: one reader's "not found" can be another's page.
|
|
1200
1211
|
*/
|
|
1201
1212
|
export declare interface RestCache {
|
|
1202
1213
|
/** Seconds a cache may serve the answer without asking again. */
|
|
@@ -1206,6 +1217,12 @@ export declare interface RestCache {
|
|
|
1206
1217
|
/** Purge tags from the answer as it goes on the wire, and the input.
|
|
1207
1218
|
* A tag with whitespace or a comma is dropped (no header can carry it). */
|
|
1208
1219
|
readonly tags?: (output: unknown, input: unknown) => ReadonlyArray<string>;
|
|
1220
|
+
/** Who may share the answer, decided by the answer and the reader it was
|
|
1221
|
+
* made for: `'public'` — every reader gets the same, cookies are ignored;
|
|
1222
|
+
* `'private'` — this reader's alone, never shared. Answer `'private'` for
|
|
1223
|
+
* a signed-in `subject` whenever anything in the answer depends on who
|
|
1224
|
+
* reads it. Without it, any cookie makes the answer private. */
|
|
1225
|
+
readonly audience?: (output: unknown, input: unknown, subject: Subject) => 'public' | 'private';
|
|
1209
1226
|
}
|
|
1210
1227
|
|
|
1211
1228
|
export declare type RestDates = 'iso' | 'epoch-ms';
|
|
@@ -1363,10 +1380,10 @@ export declare interface RestRouteDescriptor<I, O> {
|
|
|
1363
1380
|
* before decoding. Omit for routes that take no input. The schema's
|
|
1364
1381
|
* decoded `Type` flows to the handler's `input`; its `Encoded` is left
|
|
1365
1382
|
* open (`any`) so any `Schema.Struct(...)` is accepted. */
|
|
1366
|
-
readonly input?: Schema.
|
|
1383
|
+
readonly input?: Schema.Codec<I, any, never, never>;
|
|
1367
1384
|
/** Output schema. The handler returns the decoded `Type`; the desugar
|
|
1368
1385
|
* encodes it to JSON for the `200` response. */
|
|
1369
|
-
readonly output: Schema.
|
|
1386
|
+
readonly output: Schema.Codec<O, any, never, never>;
|
|
1370
1387
|
readonly handler: (input: I, ctx: RestRouteContext) => Promise<RestHandlerResult<O>> | RestHandlerResult<O>;
|
|
1371
1388
|
readonly summary?: string;
|
|
1372
1389
|
readonly description?: string;
|
|
@@ -1462,10 +1479,10 @@ export declare interface RestRouteProjection {
|
|
|
1462
1479
|
/** `publicApi.idempotent` — the route honours `Idempotency-Key` (under the
|
|
1463
1480
|
* app's idempotency binding); a client sends one per attempt. */
|
|
1464
1481
|
readonly idempotent: boolean;
|
|
1465
|
-
readonly input: Schema.
|
|
1482
|
+
readonly input: Schema.Top;
|
|
1466
1483
|
/** The wire names of the input fields bound from the path. */
|
|
1467
1484
|
readonly pathParams: ReadonlyArray<string>;
|
|
1468
|
-
readonly output: Schema.
|
|
1485
|
+
readonly output: Schema.Top;
|
|
1469
1486
|
/** The first `source` table, when the procedure declares one. */
|
|
1470
1487
|
readonly source: string | undefined;
|
|
1471
1488
|
/** Every failure the operation answers with a typed body, and its status:
|
|
@@ -1474,7 +1491,7 @@ export declare interface RestRouteProjection {
|
|
|
1474
1491
|
readonly errorResponses: ReadonlyArray<{
|
|
1475
1492
|
readonly status: number;
|
|
1476
1493
|
readonly tag: string;
|
|
1477
|
-
readonly schema: Schema.
|
|
1494
|
+
readonly schema: Schema.Top;
|
|
1478
1495
|
}>;
|
|
1479
1496
|
readonly format: RestFormat;
|
|
1480
1497
|
}
|
|
@@ -1528,15 +1545,15 @@ export declare interface RestStreamResponse {
|
|
|
1528
1545
|
|
|
1529
1546
|
/**
|
|
1530
1547
|
* Rewrite a descriptor's schema into the shape the profile puts on the wire:
|
|
1531
|
-
* `timestampMs`
|
|
1532
|
-
*
|
|
1533
|
-
*
|
|
1534
|
-
*
|
|
1535
|
-
*
|
|
1536
|
-
* `format: date-time` string, the snake keys). Classes and other opaque
|
|
1537
|
-
*
|
|
1548
|
+
* `timestampMs` becomes an RFC 3339 string under `dates: 'iso'`, and every
|
|
1549
|
+
* struct's property names become `snake_case` under `naming: 'snake_case'` —
|
|
1550
|
+
* as an encoding, so decoding a wire value yields the descriptor's own typed
|
|
1551
|
+
* value and encoding the typed value yields the wire form.
|
|
1552
|
+
* `Schema.toJsonSchemaDocument` of the result documents the wire (a
|
|
1553
|
+
* `format: date-time` string, the snake keys). Classes and other opaque codecs
|
|
1554
|
+
* pass through unchanged; a struct inside one keeps its keys.
|
|
1538
1555
|
*/
|
|
1539
|
-
export declare const restViewSchema: (schema: Schema.
|
|
1556
|
+
export declare const restViewSchema: (schema: Schema.Top, format: RestFormat) => Schema.Top;
|
|
1540
1557
|
|
|
1541
1558
|
/**
|
|
1542
1559
|
* Whether `path` is one the route declared. The underlying router folds case
|
|
@@ -1602,33 +1619,31 @@ export declare const sse: (subscribe: (emit: (chunk: string) => void) => () => v
|
|
|
1602
1619
|
* the protocol requires — a raw `\n` inside one would truncate the event. */
|
|
1603
1620
|
export declare const sseFrame: (event: string, data: unknown) => string;
|
|
1604
1621
|
|
|
1605
|
-
declare const Subject: Schema.Union<[Schema.Struct<{
|
|
1606
|
-
type: Schema.Literal<
|
|
1607
|
-
id:
|
|
1608
|
-
tenantId:
|
|
1609
|
-
scopes: Schema.optional<Schema
|
|
1610
|
-
metadata: Schema.optional<Schema
|
|
1622
|
+
declare const Subject: Schema.Union<readonly [Schema.Struct<{
|
|
1623
|
+
readonly type: Schema.Literal<"user">;
|
|
1624
|
+
readonly id: Schema.String;
|
|
1625
|
+
readonly tenantId: Schema.String;
|
|
1626
|
+
readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
|
|
1627
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
1611
1628
|
}>, Schema.Struct<{
|
|
1612
|
-
type: Schema.Literal<
|
|
1613
|
-
id:
|
|
1614
|
-
tenantId:
|
|
1615
|
-
scopes: Schema.optional<Schema
|
|
1616
|
-
metadata: Schema.optional<Schema
|
|
1629
|
+
readonly type: Schema.Literal<"apiKey">;
|
|
1630
|
+
readonly id: Schema.String;
|
|
1631
|
+
readonly tenantId: Schema.String;
|
|
1632
|
+
readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
|
|
1633
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
1617
1634
|
}>, Schema.Struct<{
|
|
1618
|
-
type: Schema.Literal<
|
|
1619
|
-
id:
|
|
1620
|
-
tenantId:
|
|
1635
|
+
readonly type: Schema.Literal<"serviceAccount">;
|
|
1636
|
+
readonly id: Schema.String;
|
|
1637
|
+
readonly tenantId: Schema.String;
|
|
1621
1638
|
/** Application actor used for audit columns; null means machine work with
|
|
1622
1639
|
* no application actor. Identity only, never a permission grant. */
|
|
1623
|
-
auditActorId: Schema.
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
scopes: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
1627
|
-
metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
|
|
1640
|
+
readonly auditActorId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
1641
|
+
readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
|
|
1642
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
1628
1643
|
}>, Schema.Struct<{
|
|
1629
|
-
type: Schema.Literal<
|
|
1630
|
-
id:
|
|
1631
|
-
tenantId: Schema.NullOr<
|
|
1644
|
+
readonly type: Schema.Literal<"anonymous">;
|
|
1645
|
+
readonly id: Schema.Null;
|
|
1646
|
+
readonly tenantId: Schema.NullOr<Schema.String>;
|
|
1632
1647
|
/**
|
|
1633
1648
|
* Set when this caller PRESENTED a credential and it was rejected — an
|
|
1634
1649
|
* expired token above all. Absent when they presented none.
|
|
@@ -1645,21 +1660,21 @@ declare const Subject: Schema.Union<[Schema.Struct<{
|
|
|
1645
1660
|
* must not break an `openAccess` procedure that needs no session at all. The
|
|
1646
1661
|
* fact travels, and only a guard that actually refuses spends it.
|
|
1647
1662
|
*/
|
|
1648
|
-
credentialRejected: Schema.optional<
|
|
1663
|
+
readonly credentialRejected: Schema.optional<Schema.String>;
|
|
1649
1664
|
}>, Schema.Struct<{
|
|
1650
|
-
type: Schema.Literal<
|
|
1651
|
-
id:
|
|
1652
|
-
tenantId:
|
|
1653
|
-
scopes: Schema.optional<Schema
|
|
1654
|
-
metadata: Schema.optional<Schema
|
|
1665
|
+
readonly type: Schema.Literal<"system">;
|
|
1666
|
+
readonly id: Schema.String;
|
|
1667
|
+
readonly tenantId: Schema.Null;
|
|
1668
|
+
readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
|
|
1669
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
1655
1670
|
}>, Schema.Struct<{
|
|
1656
|
-
type: Schema.Literal<
|
|
1657
|
-
id:
|
|
1671
|
+
readonly type: Schema.Literal<"service">;
|
|
1672
|
+
readonly id: Schema.String;
|
|
1658
1673
|
/** The calling app's name, as the callee lists it in `serviceCallers`. */
|
|
1659
|
-
service:
|
|
1660
|
-
tenantId:
|
|
1661
|
-
scopes: Schema.optional<Schema
|
|
1662
|
-
metadata: Schema.optional<Schema
|
|
1674
|
+
readonly service: Schema.String;
|
|
1675
|
+
readonly tenantId: Schema.Null;
|
|
1676
|
+
readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
|
|
1677
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
1663
1678
|
}>]>;
|
|
1664
1679
|
|
|
1665
1680
|
declare type Subject = typeof Subject.Type;
|
|
@@ -1737,7 +1752,7 @@ declare interface UpdateTarget<Input = unknown, Row = unknown, Item = Record<str
|
|
|
1737
1752
|
export declare const wireExample: (example: {
|
|
1738
1753
|
readonly request?: unknown;
|
|
1739
1754
|
readonly response?: unknown;
|
|
1740
|
-
}, wireInput: Schema.
|
|
1755
|
+
}, wireInput: Schema.Top, wireOutput: Schema.Top) => {
|
|
1741
1756
|
readonly request?: unknown;
|
|
1742
1757
|
readonly response?: unknown;
|
|
1743
1758
|
};
|