@replit/river 0.215.1 → 0.216.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 +47 -0
- package/dist/{adapter-Dtt4bYL-.d.ts → adapter-BXCk-dmy.d.ts} +3 -21
- package/dist/{adapter-CjgmjtUJ.d.cts → adapter-D5X11kmP.d.cts} +3 -21
- package/dist/{chunk-3DDZCLJM.js → chunk-62BM2WOT.js} +22 -6
- package/dist/{chunk-3DDZCLJM.js.map → chunk-62BM2WOT.js.map} +1 -1
- package/dist/{chunk-NUGV5QWU.js → chunk-C4EPHIKQ.js} +21 -3
- package/dist/chunk-C4EPHIKQ.js.map +1 -0
- package/dist/chunk-SHND2JG6.js +86 -0
- package/dist/chunk-SHND2JG6.js.map +1 -0
- package/dist/{client-BOc8blGj.d.ts → client-BNc5Pj_4.d.ts} +2 -2
- package/dist/{client-B9aKi9Li.d.cts → client-BZUvFL6B.d.cts} +2 -2
- package/dist/codec/index.cjs.map +1 -1
- package/dist/codec/index.d.cts +3 -3
- package/dist/codec/index.d.ts +3 -3
- package/dist/codec/index.js +2 -2
- package/dist/{connection-DnMYvolf.d.ts → connection-ou9w2dSY.d.ts} +3 -3
- package/dist/{connection-1hFoyxuX.d.cts → connection-xxgJHs2o.d.cts} +3 -3
- package/dist/{index-Bf9PGbS4.d.cts → index-BAGGleT3.d.cts} +1 -1
- package/dist/{index-DiAq34gk.d.ts → index-ZWkoesQD.d.ts} +1 -1
- package/dist/logging/index.d.cts +2 -2
- package/dist/logging/index.d.ts +2 -2
- package/dist/{message-DL74OqsX.d.cts → message-CpXWqmJw.d.cts} +1 -1
- package/dist/{message-DL74OqsX.d.ts → message-CpXWqmJw.d.ts} +1 -1
- package/dist/protobuf/codec.cjs +107 -0
- package/dist/protobuf/codec.cjs.map +1 -0
- package/dist/protobuf/codec.d.cts +13 -0
- package/dist/protobuf/codec.d.ts +13 -0
- package/dist/protobuf/codec.js +7 -0
- package/dist/protobuf/codec.js.map +1 -0
- package/dist/protobuf/index.cjs +1877 -0
- package/dist/protobuf/index.cjs.map +1 -0
- package/dist/protobuf/index.d.cts +488 -0
- package/dist/protobuf/index.d.ts +488 -0
- package/dist/protobuf/index.js +1260 -0
- package/dist/protobuf/index.js.map +1 -0
- package/dist/router/index.cjs +10 -2
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +11 -10
- package/dist/router/index.d.ts +11 -10
- package/dist/router/index.js +1 -1
- package/dist/{server-_bfE7LYc.d.ts → server-BPu7Td80.d.ts} +4 -4
- package/dist/{server-BkEzDYIv.d.cts → server-JdnoVO11.d.cts} +4 -4
- package/dist/{services-zaansuuR.d.cts → services-CjigASqe.d.cts} +114 -93
- package/dist/{services-KdKBWdJr.d.ts → services-DpT2yNtt.d.ts} +114 -93
- package/dist/testUtil/index.cjs +21 -5
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +8 -7
- package/dist/testUtil/index.d.ts +8 -7
- package/dist/testUtil/index.js +2 -2
- package/dist/transport/impls/ws/client.cjs +1 -1
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +7 -6
- package/dist/transport/impls/ws/client.d.ts +7 -6
- package/dist/transport/impls/ws/client.js +2 -2
- package/dist/transport/impls/ws/server.cjs +21 -5
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +7 -6
- package/dist/transport/impls/ws/server.d.ts +7 -6
- package/dist/transport/impls/ws/server.js +2 -2
- package/dist/transport/index.cjs +21 -5
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +8 -7
- package/dist/transport/index.d.ts +8 -7
- package/dist/transport/index.js +2 -2
- package/dist/{transport-CCBNESLA.d.cts → transport-B1MUtXL7.d.ts} +5 -4
- package/dist/{transport-kW92H6x-.d.ts → transport-BnU3Zb0Q.d.cts} +5 -4
- package/dist/types-BGGvYIJM.d.cts +20 -0
- package/dist/types-BGGvYIJM.d.ts +20 -0
- package/package.json +12 -1
- package/dist/chunk-NUGV5QWU.js.map +0 -1
package/dist/router/index.d.cts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { P as ProcedureHandlerContext, a as PayloadType, M as MaybeDisposable, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, b as AnyProcedure } from '../services-
|
|
2
|
-
export { B as BaseErrorSchemaType, C as CANCEL_CODE, c as Client, E as Err,
|
|
1
|
+
import { P as ProcedureHandlerContext, a as PayloadType, M as MaybeDisposable, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, b as AnyProcedure } from '../services-CjigASqe.cjs';
|
|
2
|
+
export { B as BaseErrorSchemaType, C as CANCEL_CODE, c as CallOptions, d as Client, e as ClientOptions, E as Err, f as ErrResult, g as INVALID_REQUEST_CODE, O as Ok, h as OkResult, i as ProcErrors, j as ProcHandler, k as ProcInit, l as ProcRequest, m as ProcResponse, n as ProcType, o as Procedure, p as ProcedureErrorSchemaType, q as ProcedureMap, R as RPCProcedure, r as RawReadable, s as Readable, t as ReadableBrokenError, u as ReadableResult, v as ReaderErrorSchema, w as ResponseData, x as Result, y as ResultUnwrapErr, z as ResultUnwrapOk, S as SerializedProcedureSchema, D as SerializedProcedureSchemaProtocolv1, F as SerializedServerSchema, G as SerializedServerSchemaProtocolv1, H as SerializedServiceSchema, J as SerializedServiceSchemaProtocolv1, K as Service, L as ServiceConfiguration, N as StreamProcedure, Q as SubscriptionProcedure, U as UNCAUGHT_ERROR_CODE, T as UNEXPECTED_DISCONNECT_CODE, V as UploadProcedure, W as ValidProcType, X as Writable, Y as createClient, Z as createServiceSchema, _ as flattenErrorType, $ as serializeSchema, a0 as serializeSchemaV1Compat } from '../services-CjigASqe.cjs';
|
|
3
3
|
import { Static, TSchema } from '@sinclair/typebox';
|
|
4
|
-
import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-
|
|
5
|
-
import { C as Connection, q as ServerHandshakeOptions } from '../transport-
|
|
6
|
-
export { r as createClientHandshakeOptions, s as createServerHandshakeOptions } from '../transport-
|
|
7
|
-
import { S as ServerTransport } from '../server-
|
|
4
|
+
import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-CpXWqmJw.cjs';
|
|
5
|
+
import { C as Connection, q as ServerHandshakeOptions } from '../transport-BnU3Zb0Q.cjs';
|
|
6
|
+
export { r as createClientHandshakeOptions, s as createServerHandshakeOptions } from '../transport-BnU3Zb0Q.cjs';
|
|
7
|
+
import { S as ServerTransport } from '../server-JdnoVO11.cjs';
|
|
8
8
|
import '@opentelemetry/api';
|
|
9
|
-
import '../client-
|
|
10
|
-
import '../index-
|
|
11
|
-
import '../
|
|
9
|
+
import '../client-BZUvFL6B.cjs';
|
|
10
|
+
import '../index-BAGGleT3.cjs';
|
|
11
|
+
import '../types-BGGvYIJM.cjs';
|
|
12
|
+
import '../adapter-D5X11kmP.cjs';
|
|
12
13
|
|
|
13
14
|
type StreamId = string;
|
|
14
15
|
/**
|
|
@@ -74,6 +75,6 @@ declare function createServer<MetadataSchema extends TSchema, ParsedMetadata ext
|
|
|
74
75
|
middlewares?: Array<Middleware>;
|
|
75
76
|
}>): Server<Context, ParsedMetadata, Services>;
|
|
76
77
|
|
|
77
|
-
var version = "0.
|
|
78
|
+
var version = "0.216.1";
|
|
78
79
|
|
|
79
80
|
export { MaybeDisposable, type Middleware, type MiddlewareContext, type MiddlewareParam, PayloadType, ProcedureHandlerContext, version as RIVER_VERSION, type Server, createServer };
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { P as ProcedureHandlerContext, a as PayloadType, M as MaybeDisposable, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, b as AnyProcedure } from '../services-
|
|
2
|
-
export { B as BaseErrorSchemaType, C as CANCEL_CODE, c as Client, E as Err,
|
|
1
|
+
import { P as ProcedureHandlerContext, a as PayloadType, M as MaybeDisposable, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, b as AnyProcedure } from '../services-DpT2yNtt.js';
|
|
2
|
+
export { B as BaseErrorSchemaType, C as CANCEL_CODE, c as CallOptions, d as Client, e as ClientOptions, E as Err, f as ErrResult, g as INVALID_REQUEST_CODE, O as Ok, h as OkResult, i as ProcErrors, j as ProcHandler, k as ProcInit, l as ProcRequest, m as ProcResponse, n as ProcType, o as Procedure, p as ProcedureErrorSchemaType, q as ProcedureMap, R as RPCProcedure, r as RawReadable, s as Readable, t as ReadableBrokenError, u as ReadableResult, v as ReaderErrorSchema, w as ResponseData, x as Result, y as ResultUnwrapErr, z as ResultUnwrapOk, S as SerializedProcedureSchema, D as SerializedProcedureSchemaProtocolv1, F as SerializedServerSchema, G as SerializedServerSchemaProtocolv1, H as SerializedServiceSchema, J as SerializedServiceSchemaProtocolv1, K as Service, L as ServiceConfiguration, N as StreamProcedure, Q as SubscriptionProcedure, U as UNCAUGHT_ERROR_CODE, T as UNEXPECTED_DISCONNECT_CODE, V as UploadProcedure, W as ValidProcType, X as Writable, Y as createClient, Z as createServiceSchema, _ as flattenErrorType, $ as serializeSchema, a0 as serializeSchemaV1Compat } from '../services-DpT2yNtt.js';
|
|
3
3
|
import { Static, TSchema } from '@sinclair/typebox';
|
|
4
|
-
import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-
|
|
5
|
-
import { C as Connection, q as ServerHandshakeOptions } from '../transport-
|
|
6
|
-
export { r as createClientHandshakeOptions, s as createServerHandshakeOptions } from '../transport-
|
|
7
|
-
import { S as ServerTransport } from '../server-
|
|
4
|
+
import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-CpXWqmJw.js';
|
|
5
|
+
import { C as Connection, q as ServerHandshakeOptions } from '../transport-B1MUtXL7.js';
|
|
6
|
+
export { r as createClientHandshakeOptions, s as createServerHandshakeOptions } from '../transport-B1MUtXL7.js';
|
|
7
|
+
import { S as ServerTransport } from '../server-BPu7Td80.js';
|
|
8
8
|
import '@opentelemetry/api';
|
|
9
|
-
import '../client-
|
|
10
|
-
import '../index-
|
|
11
|
-
import '../
|
|
9
|
+
import '../client-BNc5Pj_4.js';
|
|
10
|
+
import '../index-ZWkoesQD.js';
|
|
11
|
+
import '../types-BGGvYIJM.js';
|
|
12
|
+
import '../adapter-BXCk-dmy.js';
|
|
12
13
|
|
|
13
14
|
type StreamId = string;
|
|
14
15
|
/**
|
|
@@ -74,6 +75,6 @@ declare function createServer<MetadataSchema extends TSchema, ParsedMetadata ext
|
|
|
74
75
|
middlewares?: Array<Middleware>;
|
|
75
76
|
}>): Server<Context, ParsedMetadata, Services>;
|
|
76
77
|
|
|
77
|
-
var version = "0.
|
|
78
|
+
var version = "0.216.1";
|
|
78
79
|
|
|
79
80
|
export { MaybeDisposable, type Middleware, type MiddlewareContext, type MiddlewareParam, PayloadType, ProcedureHandlerContext, version as RIVER_VERSION, type Server, createServer };
|
package/dist/router/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as Connection, t as CommonSession, j as SessionState, u as CommonSessionProps, T as Transport, v as ServerTransportOptions, q as ServerHandshakeOptions, w as ServerSession, e as ProvidedServerTransportOptions, D as DeleteSessionOptions } from './transport-
|
|
2
|
-
import { O as OpaqueTransportMessage, H as HandshakeErrorResponseCodes, P as ProtocolVersion, b as TransportMessage, T as TransportClientId } from './message-
|
|
1
|
+
import { C as Connection, t as CommonSession, j as SessionState, u as CommonSessionProps, T as Transport, v as ServerTransportOptions, q as ServerHandshakeOptions, w as ServerSession, e as ProvidedServerTransportOptions, D as DeleteSessionOptions } from './transport-B1MUtXL7.js';
|
|
2
|
+
import { O as OpaqueTransportMessage, H as HandshakeErrorResponseCodes, P as ProtocolVersion, b as TransportMessage, T as TransportClientId } from './message-CpXWqmJw.js';
|
|
3
3
|
import { Static, TSchema } from '@sinclair/typebox';
|
|
4
|
-
import { T as Tags } from './index-
|
|
5
|
-
import { S as SendResult } from './adapter-
|
|
4
|
+
import { T as Tags } from './index-ZWkoesQD.js';
|
|
5
|
+
import { S as SendResult } from './adapter-BXCk-dmy.js';
|
|
6
6
|
|
|
7
7
|
interface SessionWaitingForHandshakeListeners {
|
|
8
8
|
onConnectionErrored: (err: unknown) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as Connection, t as CommonSession, j as SessionState, u as CommonSessionProps, T as Transport, v as ServerTransportOptions, q as ServerHandshakeOptions, w as ServerSession, e as ProvidedServerTransportOptions, D as DeleteSessionOptions } from './transport-
|
|
2
|
-
import { O as OpaqueTransportMessage, H as HandshakeErrorResponseCodes, P as ProtocolVersion, b as TransportMessage, T as TransportClientId } from './message-
|
|
1
|
+
import { C as Connection, t as CommonSession, j as SessionState, u as CommonSessionProps, T as Transport, v as ServerTransportOptions, q as ServerHandshakeOptions, w as ServerSession, e as ProvidedServerTransportOptions, D as DeleteSessionOptions } from './transport-BnU3Zb0Q.cjs';
|
|
2
|
+
import { O as OpaqueTransportMessage, H as HandshakeErrorResponseCodes, P as ProtocolVersion, b as TransportMessage, T as TransportClientId } from './message-CpXWqmJw.cjs';
|
|
3
3
|
import { Static, TSchema } from '@sinclair/typebox';
|
|
4
|
-
import { T as Tags } from './index-
|
|
5
|
-
import { S as SendResult } from './adapter-
|
|
4
|
+
import { T as Tags } from './index-BAGGleT3.cjs';
|
|
5
|
+
import { S as SendResult } from './adapter-D5X11kmP.cjs';
|
|
6
6
|
|
|
7
7
|
interface SessionWaitingForHandshakeListeners {
|
|
8
8
|
onConnectionErrored: (err: unknown) => void;
|
|
@@ -1,91 +1,9 @@
|
|
|
1
1
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
2
|
import { TObject, TLiteral, TEnum, TString, TSchema, TNever, TUnion, Static } from '@sinclair/typebox';
|
|
3
3
|
import { Span } from '@opentelemetry/api';
|
|
4
|
-
import { T as TransportClientId } from './message-
|
|
5
|
-
import { C as Connection, n as ClientHandshakeOptions, z as SessionId } from './transport-
|
|
6
|
-
import { C as ClientTransport } from './client-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* {@link UNCAUGHT_ERROR_CODE} is the code that is used when an error is thrown
|
|
10
|
-
* inside a procedure handler that's not required.
|
|
11
|
-
*/
|
|
12
|
-
declare const UNCAUGHT_ERROR_CODE = "UNCAUGHT_ERROR";
|
|
13
|
-
/**
|
|
14
|
-
* {@link UNEXPECTED_DISCONNECT_CODE} is the code used the stream's session
|
|
15
|
-
* disconnect unexpetedly.
|
|
16
|
-
*/
|
|
17
|
-
declare const UNEXPECTED_DISCONNECT_CODE = "UNEXPECTED_DISCONNECT";
|
|
18
|
-
/**
|
|
19
|
-
* {@link INVALID_REQUEST_CODE} is the code used when a client's request is invalid.
|
|
20
|
-
*/
|
|
21
|
-
declare const INVALID_REQUEST_CODE = "INVALID_REQUEST";
|
|
22
|
-
/**
|
|
23
|
-
* {@link CANCEL_CODE} is the code used when either server or client cancels the stream.
|
|
24
|
-
*/
|
|
25
|
-
declare const CANCEL_CODE = "CANCEL";
|
|
26
|
-
type TLiteralString = TLiteral<string>;
|
|
27
|
-
type TEnumString = TEnum<Record<string, string>>;
|
|
28
|
-
type BaseErrorSchemaType = TObject<{
|
|
29
|
-
code: TLiteralString | TEnumString;
|
|
30
|
-
message: TLiteralString | TString;
|
|
31
|
-
}> | TObject<{
|
|
32
|
-
code: TLiteralString | TEnumString;
|
|
33
|
-
message: TLiteralString | TString;
|
|
34
|
-
extras: TSchema;
|
|
35
|
-
}>;
|
|
36
|
-
/**
|
|
37
|
-
* A schema for cancel payloads sent from the client
|
|
38
|
-
*/
|
|
39
|
-
declare const CancelErrorSchema: TObject<{
|
|
40
|
-
code: TLiteral<"CANCEL">;
|
|
41
|
-
message: TString;
|
|
42
|
-
}>;
|
|
43
|
-
/**
|
|
44
|
-
* {@link ReaderErrorSchema} is the schema for all the built-in river errors that
|
|
45
|
-
* can be emitted to a reader (request reader on the server, and response reader
|
|
46
|
-
* on the client).
|
|
47
|
-
*/
|
|
48
|
-
declare const ReaderErrorSchema: TUnion<[TObject<{
|
|
49
|
-
code: TLiteral<"UNCAUGHT_ERROR">;
|
|
50
|
-
message: TString;
|
|
51
|
-
}>, TObject<{
|
|
52
|
-
code: TLiteral<"UNEXPECTED_DISCONNECT">;
|
|
53
|
-
message: TString;
|
|
54
|
-
}>, TObject<{
|
|
55
|
-
code: TLiteral<"INVALID_REQUEST">;
|
|
56
|
-
message: TString;
|
|
57
|
-
extras: _sinclair_typebox.TOptional<TObject<{
|
|
58
|
-
firstValidationErrors: _sinclair_typebox.TArray<TObject<{
|
|
59
|
-
path: TString;
|
|
60
|
-
message: TString;
|
|
61
|
-
}>>;
|
|
62
|
-
totalErrors: _sinclair_typebox.TNumber;
|
|
63
|
-
}>>;
|
|
64
|
-
}>, TObject<{
|
|
65
|
-
code: TLiteral<"CANCEL">;
|
|
66
|
-
message: TString;
|
|
67
|
-
}>]>;
|
|
68
|
-
/**
|
|
69
|
-
* Represents an acceptable schema to pass to a procedure.
|
|
70
|
-
* Just a type of a schema, not an actual schema.
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
73
|
-
type ProcedureErrorSchemaType = TNever | BaseErrorSchemaType | TUnion<Array<BaseErrorSchemaType>>;
|
|
74
|
-
type NestableProcedureErrorSchemaType = BaseErrorSchemaType | TUnion<NestableProcedureErrorSchemaTypeArray>;
|
|
75
|
-
interface NestableProcedureErrorSchemaTypeArray extends Array<NestableProcedureErrorSchemaType> {
|
|
76
|
-
}
|
|
77
|
-
type Flatten<T> = T extends BaseErrorSchemaType ? T : T extends TUnion<Array<infer U extends TSchema>> ? Flatten<U> : unknown;
|
|
78
|
-
/**
|
|
79
|
-
* In the case where API consumers for some god-forsaken reason want to use
|
|
80
|
-
* arbitrarily nested unions, this helper flattens them to a single level.
|
|
81
|
-
*
|
|
82
|
-
* Note that loses some metadata information on the nested unions like
|
|
83
|
-
* nested description fields, etc.
|
|
84
|
-
*
|
|
85
|
-
* @param errType - An arbitrarily union-nested error schema.
|
|
86
|
-
* @returns The flattened error schema.
|
|
87
|
-
*/
|
|
88
|
-
declare function flattenErrorType<T extends NestableProcedureErrorSchemaType>(errType: T): Flatten<T>;
|
|
4
|
+
import { T as TransportClientId } from './message-CpXWqmJw.cjs';
|
|
5
|
+
import { C as Connection, n as ClientHandshakeOptions, z as SessionId } from './transport-BnU3Zb0Q.cjs';
|
|
6
|
+
import { C as ClientTransport } from './client-BZUvFL6B.cjs';
|
|
89
7
|
|
|
90
8
|
declare const ReadableBrokenError: {
|
|
91
9
|
readonly code: "READABLE_BROKEN";
|
|
@@ -94,13 +12,13 @@ declare const ReadableBrokenError: {
|
|
|
94
12
|
/**
|
|
95
13
|
* Similar to {@link Result} but with an extra error to handle cases where {@link Readable.break} is called
|
|
96
14
|
*/
|
|
97
|
-
type ReadableResult<T, E extends
|
|
15
|
+
type ReadableResult<T, E extends ErrorPayload = ErrorPayload> = Result<T, E | typeof ReadableBrokenError>;
|
|
98
16
|
/**
|
|
99
17
|
* A simple {@link AsyncIterator} used in {@link Readable}
|
|
100
18
|
* that doesn't have a the extra "return" and "throw" methods, and
|
|
101
19
|
* the doesn't have a "done value" (TReturn).
|
|
102
20
|
*/
|
|
103
|
-
interface ReadableIterator<T, E extends
|
|
21
|
+
interface ReadableIterator<T, E extends ErrorPayload> extends AsyncIterator<ReadableResult<T, E>> {
|
|
104
22
|
next(): Promise<{
|
|
105
23
|
done: false;
|
|
106
24
|
value: ReadableResult<T, E>;
|
|
@@ -120,7 +38,7 @@ interface ReadableIterator<T, E extends Static<BaseErrorSchemaType>> extends Asy
|
|
|
120
38
|
* A {@link Readable} can only have one consumer (iterator or {@link collect}) for the {@link Readable}'s
|
|
121
39
|
* lifetime, in essense, reading from a {@link Readable} locks it forever.
|
|
122
40
|
*/
|
|
123
|
-
interface Readable<T, E extends
|
|
41
|
+
interface Readable<T, E extends ErrorPayload> {
|
|
124
42
|
/**
|
|
125
43
|
* {@link Readable} implements AsyncIterator API and can be consumed via
|
|
126
44
|
* for-await-of loops. Iteration locks the Readable. Exiting the loop
|
|
@@ -189,7 +107,7 @@ interface Writable<T> {
|
|
|
189
107
|
* to 'tee' a {@link Readable} to create a copy of the stream but
|
|
190
108
|
* this is not the common case.
|
|
191
109
|
*/
|
|
192
|
-
declare class ReadableImpl<T, E extends
|
|
110
|
+
declare class ReadableImpl<T, E extends ErrorPayload> implements Readable<T, E> {
|
|
193
111
|
/**
|
|
194
112
|
* Whether the {@link Readable} is closed.
|
|
195
113
|
*
|
|
@@ -307,6 +225,16 @@ type Client<Services extends AnyServiceSchemaMap<any>, IS extends InstantiatedSe
|
|
|
307
225
|
interface ClientOptions {
|
|
308
226
|
connectOnInvoke: boolean;
|
|
309
227
|
eagerlyConnect: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Default options merged into every leaf call (`rpc`, `stream`,
|
|
230
|
+
* `upload`, `subscribe`). Caller-supplied `options` win field-by-field,
|
|
231
|
+
* so a caller can override `signal` while keeping other defaults.
|
|
232
|
+
*
|
|
233
|
+
* Pass a function form when the default needs to be re-resolved per
|
|
234
|
+
* call (e.g. an ambient signal that changes between invocations of
|
|
235
|
+
* the same client).
|
|
236
|
+
*/
|
|
237
|
+
defaultCallOptions?: CallOptions | (() => CallOptions);
|
|
310
238
|
}
|
|
311
239
|
/**
|
|
312
240
|
* Creates a client for a given server using the provided transport.
|
|
@@ -327,19 +255,112 @@ declare function createClient<ServiceSchemaMap extends AnyServiceSchemaMap<any>>
|
|
|
327
255
|
handshakeOptions: ClientHandshakeOptions;
|
|
328
256
|
}>): Client<ServiceSchemaMap>;
|
|
329
257
|
|
|
258
|
+
/**
|
|
259
|
+
* {@link UNCAUGHT_ERROR_CODE} is the code that is used when an error is thrown
|
|
260
|
+
* inside a procedure handler that's not required.
|
|
261
|
+
*/
|
|
262
|
+
declare const UNCAUGHT_ERROR_CODE = "UNCAUGHT_ERROR";
|
|
263
|
+
/**
|
|
264
|
+
* {@link UNEXPECTED_DISCONNECT_CODE} is the code used the stream's session
|
|
265
|
+
* disconnect unexpetedly.
|
|
266
|
+
*/
|
|
267
|
+
declare const UNEXPECTED_DISCONNECT_CODE = "UNEXPECTED_DISCONNECT";
|
|
268
|
+
/**
|
|
269
|
+
* {@link INVALID_REQUEST_CODE} is the code used when a client's request is invalid.
|
|
270
|
+
*/
|
|
271
|
+
declare const INVALID_REQUEST_CODE = "INVALID_REQUEST";
|
|
272
|
+
/**
|
|
273
|
+
* {@link CANCEL_CODE} is the code used when either server or client cancels the stream.
|
|
274
|
+
*/
|
|
275
|
+
declare const CANCEL_CODE = "CANCEL";
|
|
276
|
+
type TLiteralString = TLiteral<string>;
|
|
277
|
+
type TEnumString = TEnum<Record<string, string>>;
|
|
278
|
+
type BaseErrorSchemaType = TObject<{
|
|
279
|
+
code: TLiteralString | TEnumString;
|
|
280
|
+
message: TLiteralString | TString;
|
|
281
|
+
}> | TObject<{
|
|
282
|
+
code: TLiteralString | TEnumString;
|
|
283
|
+
message: TLiteralString | TString;
|
|
284
|
+
extras: TSchema;
|
|
285
|
+
}>;
|
|
286
|
+
/**
|
|
287
|
+
* A schema for cancel payloads sent from the client
|
|
288
|
+
*/
|
|
289
|
+
declare const CancelErrorSchema: TObject<{
|
|
290
|
+
code: TLiteral<"CANCEL">;
|
|
291
|
+
message: TString;
|
|
292
|
+
}>;
|
|
293
|
+
/**
|
|
294
|
+
* {@link ReaderErrorSchema} is the schema for all the built-in river errors that
|
|
295
|
+
* can be emitted to a reader (request reader on the server, and response reader
|
|
296
|
+
* on the client).
|
|
297
|
+
*/
|
|
298
|
+
declare const ReaderErrorSchema: TUnion<[TObject<{
|
|
299
|
+
code: TLiteral<"UNCAUGHT_ERROR">;
|
|
300
|
+
message: TString;
|
|
301
|
+
}>, TObject<{
|
|
302
|
+
code: TLiteral<"UNEXPECTED_DISCONNECT">;
|
|
303
|
+
message: TString;
|
|
304
|
+
}>, TObject<{
|
|
305
|
+
code: TLiteral<"INVALID_REQUEST">;
|
|
306
|
+
message: TString;
|
|
307
|
+
extras: _sinclair_typebox.TOptional<TObject<{
|
|
308
|
+
firstValidationErrors: _sinclair_typebox.TArray<TObject<{
|
|
309
|
+
path: TString;
|
|
310
|
+
message: TString;
|
|
311
|
+
}>>;
|
|
312
|
+
totalErrors: _sinclair_typebox.TNumber;
|
|
313
|
+
}>>;
|
|
314
|
+
}>, TObject<{
|
|
315
|
+
code: TLiteral<"CANCEL">;
|
|
316
|
+
message: TString;
|
|
317
|
+
}>]>;
|
|
318
|
+
/**
|
|
319
|
+
* Represents an acceptable schema to pass to a procedure.
|
|
320
|
+
* Just a type of a schema, not an actual schema.
|
|
321
|
+
*
|
|
322
|
+
*/
|
|
323
|
+
type ProcedureErrorSchemaType = TNever | BaseErrorSchemaType | TUnion<Array<BaseErrorSchemaType>>;
|
|
324
|
+
type NestableProcedureErrorSchemaType = BaseErrorSchemaType | TUnion<NestableProcedureErrorSchemaTypeArray>;
|
|
325
|
+
interface NestableProcedureErrorSchemaTypeArray extends Array<NestableProcedureErrorSchemaType> {
|
|
326
|
+
}
|
|
327
|
+
type Flatten<T> = T extends BaseErrorSchemaType ? T : T extends TUnion<Array<infer U extends TSchema>> ? Flatten<U> : unknown;
|
|
328
|
+
/**
|
|
329
|
+
* In the case where API consumers for some god-forsaken reason want to use
|
|
330
|
+
* arbitrarily nested unions, this helper flattens them to a single level.
|
|
331
|
+
*
|
|
332
|
+
* Note that loses some metadata information on the nested unions like
|
|
333
|
+
* nested description fields, etc.
|
|
334
|
+
*
|
|
335
|
+
* @param errType - An arbitrarily union-nested error schema.
|
|
336
|
+
* @returns The flattened error schema.
|
|
337
|
+
*/
|
|
338
|
+
declare function flattenErrorType<T extends NestableProcedureErrorSchemaType>(errType: T): Flatten<T>;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* The minimum error shape supported by river's `Result` and stream primitives.
|
|
342
|
+
*
|
|
343
|
+
* The existing TypeBox router uses schema-derived object types for this, while
|
|
344
|
+
* the protobuf router can use a richer structural error type.
|
|
345
|
+
*/
|
|
346
|
+
interface ErrorPayload {
|
|
347
|
+
code: string;
|
|
348
|
+
message: string;
|
|
349
|
+
extras?: unknown;
|
|
350
|
+
}
|
|
330
351
|
interface OkResult<T> {
|
|
331
352
|
ok: true;
|
|
332
353
|
payload: T;
|
|
333
354
|
}
|
|
334
|
-
interface ErrResult<Err extends
|
|
355
|
+
interface ErrResult<Err extends ErrorPayload> {
|
|
335
356
|
ok: false;
|
|
336
357
|
payload: Err;
|
|
337
358
|
}
|
|
338
|
-
type Result<T, Err extends
|
|
359
|
+
type Result<T, Err extends ErrorPayload> = OkResult<T> | ErrResult<Err>;
|
|
339
360
|
declare function Ok<const T extends Array<unknown>>(p: T): OkResult<T>;
|
|
340
361
|
declare function Ok<const T extends ReadonlyArray<unknown>>(p: T): OkResult<T>;
|
|
341
362
|
declare function Ok<const T>(payload: T): OkResult<T>;
|
|
342
|
-
declare function Err<const Err extends
|
|
363
|
+
declare function Err<const Err extends ErrorPayload>(error: Err): ErrResult<Err>;
|
|
343
364
|
/**
|
|
344
365
|
* Refine a {@link Result} type to its returned payload.
|
|
345
366
|
*/
|
|
@@ -1111,4 +1132,4 @@ declare class ServiceScaffold<Context extends MaybeDisposable, State extends obj
|
|
|
1111
1132
|
};
|
|
1112
1133
|
}
|
|
1113
1134
|
|
|
1114
|
-
export {
|
|
1135
|
+
export { serializeSchema as $, type AnyServiceSchemaMap as A, type BaseErrorSchemaType as B, CANCEL_CODE as C, type SerializedProcedureSchemaProtocolv1 as D, Err as E, type SerializedServerSchema as F, type SerializedServerSchemaProtocolv1 as G, type SerializedServiceSchema as H, type InstantiatedServiceSchemaMap as I, type SerializedServiceSchemaProtocolv1 as J, type Service as K, type ServiceConfiguration as L, type MaybeDisposable as M, type StreamProcedure as N, Ok as O, type ProcedureHandlerContext as P, type SubscriptionProcedure as Q, type RpcProcedure as R, type SerializedProcedureSchema as S, UNEXPECTED_DISCONNECT_CODE as T, UNCAUGHT_ERROR_CODE as U, type UploadProcedure as V, type ValidProcType as W, type Writable as X, createClient as Y, createServiceSchema as Z, flattenErrorType as _, type PayloadType as a, serializeSchemaV1Compat as a0, type ReadableIterator as a1, type ErrorPayload as a2, type AnyProcedure as b, type CallOptions as c, type Client as d, type ClientOptions as e, type ErrResult as f, INVALID_REQUEST_CODE as g, type OkResult as h, type ProcErrors as i, type ProcHandler as j, type ProcInit as k, type ProcRequest as l, type ProcResponse as m, type ProcType as n, Procedure as o, type ProcedureErrorSchemaType as p, type ProcedureMap as q, ReadableImpl as r, type Readable as s, ReadableBrokenError as t, type ReadableResult as u, ReaderErrorSchema as v, type ResponseData as w, type Result as x, type ResultUnwrapErr as y, type ResultUnwrapOk as z };
|
|
@@ -1,91 +1,9 @@
|
|
|
1
1
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
2
|
import { TObject, TLiteral, TEnum, TString, TSchema, TNever, TUnion, Static } from '@sinclair/typebox';
|
|
3
3
|
import { Span } from '@opentelemetry/api';
|
|
4
|
-
import { T as TransportClientId } from './message-
|
|
5
|
-
import { C as Connection, n as ClientHandshakeOptions, z as SessionId } from './transport-
|
|
6
|
-
import { C as ClientTransport } from './client-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* {@link UNCAUGHT_ERROR_CODE} is the code that is used when an error is thrown
|
|
10
|
-
* inside a procedure handler that's not required.
|
|
11
|
-
*/
|
|
12
|
-
declare const UNCAUGHT_ERROR_CODE = "UNCAUGHT_ERROR";
|
|
13
|
-
/**
|
|
14
|
-
* {@link UNEXPECTED_DISCONNECT_CODE} is the code used the stream's session
|
|
15
|
-
* disconnect unexpetedly.
|
|
16
|
-
*/
|
|
17
|
-
declare const UNEXPECTED_DISCONNECT_CODE = "UNEXPECTED_DISCONNECT";
|
|
18
|
-
/**
|
|
19
|
-
* {@link INVALID_REQUEST_CODE} is the code used when a client's request is invalid.
|
|
20
|
-
*/
|
|
21
|
-
declare const INVALID_REQUEST_CODE = "INVALID_REQUEST";
|
|
22
|
-
/**
|
|
23
|
-
* {@link CANCEL_CODE} is the code used when either server or client cancels the stream.
|
|
24
|
-
*/
|
|
25
|
-
declare const CANCEL_CODE = "CANCEL";
|
|
26
|
-
type TLiteralString = TLiteral<string>;
|
|
27
|
-
type TEnumString = TEnum<Record<string, string>>;
|
|
28
|
-
type BaseErrorSchemaType = TObject<{
|
|
29
|
-
code: TLiteralString | TEnumString;
|
|
30
|
-
message: TLiteralString | TString;
|
|
31
|
-
}> | TObject<{
|
|
32
|
-
code: TLiteralString | TEnumString;
|
|
33
|
-
message: TLiteralString | TString;
|
|
34
|
-
extras: TSchema;
|
|
35
|
-
}>;
|
|
36
|
-
/**
|
|
37
|
-
* A schema for cancel payloads sent from the client
|
|
38
|
-
*/
|
|
39
|
-
declare const CancelErrorSchema: TObject<{
|
|
40
|
-
code: TLiteral<"CANCEL">;
|
|
41
|
-
message: TString;
|
|
42
|
-
}>;
|
|
43
|
-
/**
|
|
44
|
-
* {@link ReaderErrorSchema} is the schema for all the built-in river errors that
|
|
45
|
-
* can be emitted to a reader (request reader on the server, and response reader
|
|
46
|
-
* on the client).
|
|
47
|
-
*/
|
|
48
|
-
declare const ReaderErrorSchema: TUnion<[TObject<{
|
|
49
|
-
code: TLiteral<"UNCAUGHT_ERROR">;
|
|
50
|
-
message: TString;
|
|
51
|
-
}>, TObject<{
|
|
52
|
-
code: TLiteral<"UNEXPECTED_DISCONNECT">;
|
|
53
|
-
message: TString;
|
|
54
|
-
}>, TObject<{
|
|
55
|
-
code: TLiteral<"INVALID_REQUEST">;
|
|
56
|
-
message: TString;
|
|
57
|
-
extras: _sinclair_typebox.TOptional<TObject<{
|
|
58
|
-
firstValidationErrors: _sinclair_typebox.TArray<TObject<{
|
|
59
|
-
path: TString;
|
|
60
|
-
message: TString;
|
|
61
|
-
}>>;
|
|
62
|
-
totalErrors: _sinclair_typebox.TNumber;
|
|
63
|
-
}>>;
|
|
64
|
-
}>, TObject<{
|
|
65
|
-
code: TLiteral<"CANCEL">;
|
|
66
|
-
message: TString;
|
|
67
|
-
}>]>;
|
|
68
|
-
/**
|
|
69
|
-
* Represents an acceptable schema to pass to a procedure.
|
|
70
|
-
* Just a type of a schema, not an actual schema.
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
73
|
-
type ProcedureErrorSchemaType = TNever | BaseErrorSchemaType | TUnion<Array<BaseErrorSchemaType>>;
|
|
74
|
-
type NestableProcedureErrorSchemaType = BaseErrorSchemaType | TUnion<NestableProcedureErrorSchemaTypeArray>;
|
|
75
|
-
interface NestableProcedureErrorSchemaTypeArray extends Array<NestableProcedureErrorSchemaType> {
|
|
76
|
-
}
|
|
77
|
-
type Flatten<T> = T extends BaseErrorSchemaType ? T : T extends TUnion<Array<infer U extends TSchema>> ? Flatten<U> : unknown;
|
|
78
|
-
/**
|
|
79
|
-
* In the case where API consumers for some god-forsaken reason want to use
|
|
80
|
-
* arbitrarily nested unions, this helper flattens them to a single level.
|
|
81
|
-
*
|
|
82
|
-
* Note that loses some metadata information on the nested unions like
|
|
83
|
-
* nested description fields, etc.
|
|
84
|
-
*
|
|
85
|
-
* @param errType - An arbitrarily union-nested error schema.
|
|
86
|
-
* @returns The flattened error schema.
|
|
87
|
-
*/
|
|
88
|
-
declare function flattenErrorType<T extends NestableProcedureErrorSchemaType>(errType: T): Flatten<T>;
|
|
4
|
+
import { T as TransportClientId } from './message-CpXWqmJw.js';
|
|
5
|
+
import { C as Connection, n as ClientHandshakeOptions, z as SessionId } from './transport-B1MUtXL7.js';
|
|
6
|
+
import { C as ClientTransport } from './client-BNc5Pj_4.js';
|
|
89
7
|
|
|
90
8
|
declare const ReadableBrokenError: {
|
|
91
9
|
readonly code: "READABLE_BROKEN";
|
|
@@ -94,13 +12,13 @@ declare const ReadableBrokenError: {
|
|
|
94
12
|
/**
|
|
95
13
|
* Similar to {@link Result} but with an extra error to handle cases where {@link Readable.break} is called
|
|
96
14
|
*/
|
|
97
|
-
type ReadableResult<T, E extends
|
|
15
|
+
type ReadableResult<T, E extends ErrorPayload = ErrorPayload> = Result<T, E | typeof ReadableBrokenError>;
|
|
98
16
|
/**
|
|
99
17
|
* A simple {@link AsyncIterator} used in {@link Readable}
|
|
100
18
|
* that doesn't have a the extra "return" and "throw" methods, and
|
|
101
19
|
* the doesn't have a "done value" (TReturn).
|
|
102
20
|
*/
|
|
103
|
-
interface ReadableIterator<T, E extends
|
|
21
|
+
interface ReadableIterator<T, E extends ErrorPayload> extends AsyncIterator<ReadableResult<T, E>> {
|
|
104
22
|
next(): Promise<{
|
|
105
23
|
done: false;
|
|
106
24
|
value: ReadableResult<T, E>;
|
|
@@ -120,7 +38,7 @@ interface ReadableIterator<T, E extends Static<BaseErrorSchemaType>> extends Asy
|
|
|
120
38
|
* A {@link Readable} can only have one consumer (iterator or {@link collect}) for the {@link Readable}'s
|
|
121
39
|
* lifetime, in essense, reading from a {@link Readable} locks it forever.
|
|
122
40
|
*/
|
|
123
|
-
interface Readable<T, E extends
|
|
41
|
+
interface Readable<T, E extends ErrorPayload> {
|
|
124
42
|
/**
|
|
125
43
|
* {@link Readable} implements AsyncIterator API and can be consumed via
|
|
126
44
|
* for-await-of loops. Iteration locks the Readable. Exiting the loop
|
|
@@ -189,7 +107,7 @@ interface Writable<T> {
|
|
|
189
107
|
* to 'tee' a {@link Readable} to create a copy of the stream but
|
|
190
108
|
* this is not the common case.
|
|
191
109
|
*/
|
|
192
|
-
declare class ReadableImpl<T, E extends
|
|
110
|
+
declare class ReadableImpl<T, E extends ErrorPayload> implements Readable<T, E> {
|
|
193
111
|
/**
|
|
194
112
|
* Whether the {@link Readable} is closed.
|
|
195
113
|
*
|
|
@@ -307,6 +225,16 @@ type Client<Services extends AnyServiceSchemaMap<any>, IS extends InstantiatedSe
|
|
|
307
225
|
interface ClientOptions {
|
|
308
226
|
connectOnInvoke: boolean;
|
|
309
227
|
eagerlyConnect: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Default options merged into every leaf call (`rpc`, `stream`,
|
|
230
|
+
* `upload`, `subscribe`). Caller-supplied `options` win field-by-field,
|
|
231
|
+
* so a caller can override `signal` while keeping other defaults.
|
|
232
|
+
*
|
|
233
|
+
* Pass a function form when the default needs to be re-resolved per
|
|
234
|
+
* call (e.g. an ambient signal that changes between invocations of
|
|
235
|
+
* the same client).
|
|
236
|
+
*/
|
|
237
|
+
defaultCallOptions?: CallOptions | (() => CallOptions);
|
|
310
238
|
}
|
|
311
239
|
/**
|
|
312
240
|
* Creates a client for a given server using the provided transport.
|
|
@@ -327,19 +255,112 @@ declare function createClient<ServiceSchemaMap extends AnyServiceSchemaMap<any>>
|
|
|
327
255
|
handshakeOptions: ClientHandshakeOptions;
|
|
328
256
|
}>): Client<ServiceSchemaMap>;
|
|
329
257
|
|
|
258
|
+
/**
|
|
259
|
+
* {@link UNCAUGHT_ERROR_CODE} is the code that is used when an error is thrown
|
|
260
|
+
* inside a procedure handler that's not required.
|
|
261
|
+
*/
|
|
262
|
+
declare const UNCAUGHT_ERROR_CODE = "UNCAUGHT_ERROR";
|
|
263
|
+
/**
|
|
264
|
+
* {@link UNEXPECTED_DISCONNECT_CODE} is the code used the stream's session
|
|
265
|
+
* disconnect unexpetedly.
|
|
266
|
+
*/
|
|
267
|
+
declare const UNEXPECTED_DISCONNECT_CODE = "UNEXPECTED_DISCONNECT";
|
|
268
|
+
/**
|
|
269
|
+
* {@link INVALID_REQUEST_CODE} is the code used when a client's request is invalid.
|
|
270
|
+
*/
|
|
271
|
+
declare const INVALID_REQUEST_CODE = "INVALID_REQUEST";
|
|
272
|
+
/**
|
|
273
|
+
* {@link CANCEL_CODE} is the code used when either server or client cancels the stream.
|
|
274
|
+
*/
|
|
275
|
+
declare const CANCEL_CODE = "CANCEL";
|
|
276
|
+
type TLiteralString = TLiteral<string>;
|
|
277
|
+
type TEnumString = TEnum<Record<string, string>>;
|
|
278
|
+
type BaseErrorSchemaType = TObject<{
|
|
279
|
+
code: TLiteralString | TEnumString;
|
|
280
|
+
message: TLiteralString | TString;
|
|
281
|
+
}> | TObject<{
|
|
282
|
+
code: TLiteralString | TEnumString;
|
|
283
|
+
message: TLiteralString | TString;
|
|
284
|
+
extras: TSchema;
|
|
285
|
+
}>;
|
|
286
|
+
/**
|
|
287
|
+
* A schema for cancel payloads sent from the client
|
|
288
|
+
*/
|
|
289
|
+
declare const CancelErrorSchema: TObject<{
|
|
290
|
+
code: TLiteral<"CANCEL">;
|
|
291
|
+
message: TString;
|
|
292
|
+
}>;
|
|
293
|
+
/**
|
|
294
|
+
* {@link ReaderErrorSchema} is the schema for all the built-in river errors that
|
|
295
|
+
* can be emitted to a reader (request reader on the server, and response reader
|
|
296
|
+
* on the client).
|
|
297
|
+
*/
|
|
298
|
+
declare const ReaderErrorSchema: TUnion<[TObject<{
|
|
299
|
+
code: TLiteral<"UNCAUGHT_ERROR">;
|
|
300
|
+
message: TString;
|
|
301
|
+
}>, TObject<{
|
|
302
|
+
code: TLiteral<"UNEXPECTED_DISCONNECT">;
|
|
303
|
+
message: TString;
|
|
304
|
+
}>, TObject<{
|
|
305
|
+
code: TLiteral<"INVALID_REQUEST">;
|
|
306
|
+
message: TString;
|
|
307
|
+
extras: _sinclair_typebox.TOptional<TObject<{
|
|
308
|
+
firstValidationErrors: _sinclair_typebox.TArray<TObject<{
|
|
309
|
+
path: TString;
|
|
310
|
+
message: TString;
|
|
311
|
+
}>>;
|
|
312
|
+
totalErrors: _sinclair_typebox.TNumber;
|
|
313
|
+
}>>;
|
|
314
|
+
}>, TObject<{
|
|
315
|
+
code: TLiteral<"CANCEL">;
|
|
316
|
+
message: TString;
|
|
317
|
+
}>]>;
|
|
318
|
+
/**
|
|
319
|
+
* Represents an acceptable schema to pass to a procedure.
|
|
320
|
+
* Just a type of a schema, not an actual schema.
|
|
321
|
+
*
|
|
322
|
+
*/
|
|
323
|
+
type ProcedureErrorSchemaType = TNever | BaseErrorSchemaType | TUnion<Array<BaseErrorSchemaType>>;
|
|
324
|
+
type NestableProcedureErrorSchemaType = BaseErrorSchemaType | TUnion<NestableProcedureErrorSchemaTypeArray>;
|
|
325
|
+
interface NestableProcedureErrorSchemaTypeArray extends Array<NestableProcedureErrorSchemaType> {
|
|
326
|
+
}
|
|
327
|
+
type Flatten<T> = T extends BaseErrorSchemaType ? T : T extends TUnion<Array<infer U extends TSchema>> ? Flatten<U> : unknown;
|
|
328
|
+
/**
|
|
329
|
+
* In the case where API consumers for some god-forsaken reason want to use
|
|
330
|
+
* arbitrarily nested unions, this helper flattens them to a single level.
|
|
331
|
+
*
|
|
332
|
+
* Note that loses some metadata information on the nested unions like
|
|
333
|
+
* nested description fields, etc.
|
|
334
|
+
*
|
|
335
|
+
* @param errType - An arbitrarily union-nested error schema.
|
|
336
|
+
* @returns The flattened error schema.
|
|
337
|
+
*/
|
|
338
|
+
declare function flattenErrorType<T extends NestableProcedureErrorSchemaType>(errType: T): Flatten<T>;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* The minimum error shape supported by river's `Result` and stream primitives.
|
|
342
|
+
*
|
|
343
|
+
* The existing TypeBox router uses schema-derived object types for this, while
|
|
344
|
+
* the protobuf router can use a richer structural error type.
|
|
345
|
+
*/
|
|
346
|
+
interface ErrorPayload {
|
|
347
|
+
code: string;
|
|
348
|
+
message: string;
|
|
349
|
+
extras?: unknown;
|
|
350
|
+
}
|
|
330
351
|
interface OkResult<T> {
|
|
331
352
|
ok: true;
|
|
332
353
|
payload: T;
|
|
333
354
|
}
|
|
334
|
-
interface ErrResult<Err extends
|
|
355
|
+
interface ErrResult<Err extends ErrorPayload> {
|
|
335
356
|
ok: false;
|
|
336
357
|
payload: Err;
|
|
337
358
|
}
|
|
338
|
-
type Result<T, Err extends
|
|
359
|
+
type Result<T, Err extends ErrorPayload> = OkResult<T> | ErrResult<Err>;
|
|
339
360
|
declare function Ok<const T extends Array<unknown>>(p: T): OkResult<T>;
|
|
340
361
|
declare function Ok<const T extends ReadonlyArray<unknown>>(p: T): OkResult<T>;
|
|
341
362
|
declare function Ok<const T>(payload: T): OkResult<T>;
|
|
342
|
-
declare function Err<const Err extends
|
|
363
|
+
declare function Err<const Err extends ErrorPayload>(error: Err): ErrResult<Err>;
|
|
343
364
|
/**
|
|
344
365
|
* Refine a {@link Result} type to its returned payload.
|
|
345
366
|
*/
|
|
@@ -1111,4 +1132,4 @@ declare class ServiceScaffold<Context extends MaybeDisposable, State extends obj
|
|
|
1111
1132
|
};
|
|
1112
1133
|
}
|
|
1113
1134
|
|
|
1114
|
-
export {
|
|
1135
|
+
export { serializeSchema as $, type AnyServiceSchemaMap as A, type BaseErrorSchemaType as B, CANCEL_CODE as C, type SerializedProcedureSchemaProtocolv1 as D, Err as E, type SerializedServerSchema as F, type SerializedServerSchemaProtocolv1 as G, type SerializedServiceSchema as H, type InstantiatedServiceSchemaMap as I, type SerializedServiceSchemaProtocolv1 as J, type Service as K, type ServiceConfiguration as L, type MaybeDisposable as M, type StreamProcedure as N, Ok as O, type ProcedureHandlerContext as P, type SubscriptionProcedure as Q, type RpcProcedure as R, type SerializedProcedureSchema as S, UNEXPECTED_DISCONNECT_CODE as T, UNCAUGHT_ERROR_CODE as U, type UploadProcedure as V, type ValidProcType as W, type Writable as X, createClient as Y, createServiceSchema as Z, flattenErrorType as _, type PayloadType as a, serializeSchemaV1Compat as a0, type ReadableIterator as a1, type ErrorPayload as a2, type AnyProcedure as b, type CallOptions as c, type Client as d, type ClientOptions as e, type ErrResult as f, INVALID_REQUEST_CODE as g, type OkResult as h, type ProcErrors as i, type ProcHandler as j, type ProcInit as k, type ProcRequest as l, type ProcResponse as m, type ProcType as n, Procedure as o, type ProcedureErrorSchemaType as p, type ProcedureMap as q, ReadableImpl as r, type Readable as s, ReadableBrokenError as t, type ReadableResult as u, ReaderErrorSchema as v, type ResponseData as w, type Result as x, type ResultUnwrapErr as y, type ResultUnwrapOk as z };
|