@replit/river 0.200.0-rc.13 → 0.200.0-rc.15

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.
Files changed (36) hide show
  1. package/dist/{chunk-MQ6ANR3H.js → chunk-A2MGUPER.js} +1 -1
  2. package/dist/chunk-A2MGUPER.js.map +1 -0
  3. package/dist/{chunk-2PUERXLT.js → chunk-GRDOQL3Q.js} +4 -4
  4. package/dist/{chunk-MTCAW5XM.js → chunk-H2NIGO66.js} +2 -2
  5. package/dist/{chunk-JEAAPPOD.js → chunk-R5KEFZGW.js} +4 -4
  6. package/dist/{chunk-TTIA2KT2.js → chunk-RIN5PMQD.js} +2 -2
  7. package/dist/{chunk-4CRFHK3A.js → chunk-TBBQ5MGX.js} +2 -2
  8. package/dist/{chunk-4CRFHK3A.js.map → chunk-TBBQ5MGX.js.map} +1 -1
  9. package/dist/{chunk-K34VQODM.js → chunk-Z553YSPV.js} +3 -3
  10. package/dist/router/index.cjs +1 -1
  11. package/dist/router/index.cjs.map +1 -1
  12. package/dist/router/index.d.cts +3 -3
  13. package/dist/router/index.d.ts +3 -3
  14. package/dist/router/index.js +2 -2
  15. package/dist/{services-5f5157e0.d.ts → services-437a8142.d.ts} +4 -1
  16. package/dist/transport/impls/ws/client.cjs +1 -1
  17. package/dist/transport/impls/ws/client.cjs.map +1 -1
  18. package/dist/transport/impls/ws/client.js +5 -5
  19. package/dist/transport/impls/ws/server.cjs +1 -1
  20. package/dist/transport/impls/ws/server.cjs.map +1 -1
  21. package/dist/transport/impls/ws/server.js +5 -5
  22. package/dist/transport/index.cjs +1 -1
  23. package/dist/transport/index.cjs.map +1 -1
  24. package/dist/transport/index.js +5 -5
  25. package/dist/util/testHelpers.cjs +1 -1
  26. package/dist/util/testHelpers.cjs.map +1 -1
  27. package/dist/util/testHelpers.d.cts +1 -1
  28. package/dist/util/testHelpers.d.ts +1 -1
  29. package/dist/util/testHelpers.js +3 -3
  30. package/package.json +1 -1
  31. package/dist/chunk-MQ6ANR3H.js.map +0 -1
  32. /package/dist/{chunk-2PUERXLT.js.map → chunk-GRDOQL3Q.js.map} +0 -0
  33. /package/dist/{chunk-MTCAW5XM.js.map → chunk-H2NIGO66.js.map} +0 -0
  34. /package/dist/{chunk-JEAAPPOD.js.map → chunk-R5KEFZGW.js.map} +0 -0
  35. /package/dist/{chunk-TTIA2KT2.js.map → chunk-RIN5PMQD.js.map} +0 -0
  36. /package/dist/{chunk-K34VQODM.js.map → chunk-Z553YSPV.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { T as Transport, C as Connection, m as SessionOptions, n as ClientTransportOptions, e as SessionNoConnection, o as ServiceContext, S as Session } from '../context-b3f0eb0e.js';
2
2
  import { Static } from '@sinclair/typebox';
3
3
  import { P as PartialTransportMessage, b as OpaqueTransportMessage } from '../message-34667c7a.js';
4
- import { B as BaseErrorSchemaType, R as ReadStream, S as SimpleIterator, O as OkResult, E as ErrResult, P as PayloadType, a as ProcedureErrorSchemaType, b as Procedure, c as Result, d as ResponseReaderErrorSchema, W as WriteStream } from '../services-5f5157e0.js';
4
+ import { B as BaseErrorSchemaType, R as ReadStream, S as SimpleIterator, O as OkResult, E as ErrResult, P as PayloadType, a as ProcedureErrorSchemaType, b as Procedure, c as Result, d as ResponseReaderErrorSchema, W as WriteStream } from '../services-437a8142.js';
5
5
  import NodeWs from 'ws';
6
6
  import http from 'node:http';
7
7
  import { W as WsLike } from '../wslike-e0b32dd5.js';
@@ -1,7 +1,7 @@
1
1
  import { T as Transport, C as Connection, m as SessionOptions, n as ClientTransportOptions, e as SessionNoConnection, o as ServiceContext, S as Session } from '../context-b3f0eb0e.js';
2
2
  import { Static } from '@sinclair/typebox';
3
3
  import { P as PartialTransportMessage, b as OpaqueTransportMessage } from '../message-34667c7a.js';
4
- import { B as BaseErrorSchemaType, R as ReadStream, S as SimpleIterator, O as OkResult, E as ErrResult, P as PayloadType, a as ProcedureErrorSchemaType, b as Procedure, c as Result, d as ResponseReaderErrorSchema, W as WriteStream } from '../services-5f5157e0.js';
4
+ import { B as BaseErrorSchemaType, R as ReadStream, S as SimpleIterator, O as OkResult, E as ErrResult, P as PayloadType, a as ProcedureErrorSchemaType, b as Procedure, c as Result, d as ResponseReaderErrorSchema, W as WriteStream } from '../services-437a8142.js';
5
5
  import NodeWs from 'ws';
6
6
  import http from 'node:http';
7
7
  import { W as WsLike } from '../wslike-e0b32dd5.js';
@@ -4,16 +4,16 @@ import {
4
4
  ReadStreamImpl,
5
5
  UNCAUGHT_ERROR_CODE,
6
6
  WriteStreamImpl
7
- } from "../chunk-MQ6ANR3H.js";
7
+ } from "../chunk-A2MGUPER.js";
8
8
  import {
9
9
  SessionStateGraph,
10
10
  defaultClientTransportOptions,
11
11
  defaultTransportOptions
12
- } from "../chunk-TTIA2KT2.js";
12
+ } from "../chunk-RIN5PMQD.js";
13
13
  import {
14
14
  coerceErrorString,
15
15
  currentProtocolVersion
16
- } from "../chunk-4CRFHK3A.js";
16
+ } from "../chunk-TBBQ5MGX.js";
17
17
  import "../chunk-4PVU7J25.js";
18
18
 
19
19
  // util/testHelpers.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@replit/river",
3
3
  "description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
4
- "version": "0.200.0-rc.13",
4
+ "version": "0.200.0-rc.15",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../router/procedures.ts","../router/result.ts","../router/streams.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\nimport { Static, TNever, TSchema, TUnion, Type } from '@sinclair/typebox';\nimport { ProcedureHandlerContext } from './context';\nimport { BaseErrorSchemaType, Result } from './result';\nimport { ReadStream, WriteStream } from './streams';\n\n/**\n * Brands a type to prevent it from being directly constructed.\n */\nexport type Branded<T> = T & { readonly __BRAND_DO_NOT_USE: unique symbol };\n\n/**\n * Unbrands a {@link Branded} type.\n */\nexport type Unbranded<T> = T extends Branded<infer U> ? U : never;\n\n/**\n * The valid {@link Procedure} types. The `stream` and `upload` types can optionally have a\n * different type for the very first initialization message. The suffixless types correspond to\n * gRPC's four combinations of stream / non-stream in each direction.\n */\nexport type ValidProcType =\n // Single message in both directions (1:1).\n | 'rpc'\n // Client-stream single message from server (n:1).\n | 'upload'\n // Single message from client, stream from server (1:n).\n | 'subscription'\n // Bidirectional stream (n:n).\n | 'stream';\n\n/**\n * Represents the payload type for {@link Procedure}s.\n */\nexport type PayloadType = TSchema;\n\n/**\n * INTERNAL_RIVER_ERROR_CODE is the code that is used when an internal error occurs,\n * this means that some invariants expected by the river server implementation have\n * been violated. When encountering this error please report this to river maintainers.\n */\nexport const INTERNAL_RIVER_ERROR_CODE = 'INTERNAL_RIVER_ERROR' as const;\n/**\n * UNCAUGHT_ERROR_CODE is the code that is used when an error is thrown\n * inside a procedure handler that's not required.\n */\nexport const UNCAUGHT_ERROR_CODE = 'UNCAUGHT_ERROR' as const;\n/**\n * UNEXPECTED_DISCONNECT_CODE is the code used the stream's session\n * disconnect unexpetedly.\n */\nexport const UNEXPECTED_DISCONNECT_CODE = 'UNEXPECTED_DISCONNECT' as const;\n/**\n * INVALID_REQUEST_CODE is the code used when a client's request is invalid.\n */\nexport const INVALID_REQUEST_CODE = 'INVALID_REQUEST' as const;\n/**\n * ABORT_CODE is the code used when either server or client aborts the stream.\n */\nexport const ABORT_CODE = 'ABORT' as const;\n\n/**\n * ResponseReaderErrorSchema is the schema for all the errors that can be\n * emitted in the ResponseData ReadStream on the client.\n */\nexport const ResponseReaderErrorSchema = Type.Object({\n code: Type.Union([\n Type.Literal(INTERNAL_RIVER_ERROR_CODE),\n Type.Literal(UNCAUGHT_ERROR_CODE),\n Type.Literal(UNEXPECTED_DISCONNECT_CODE),\n Type.Literal(INVALID_REQUEST_CODE),\n Type.Literal(ABORT_CODE),\n ]),\n message: Type.String(),\n});\n\n/**\n * RequestReaderErrorSchema is the schema for all the errors that can be\n * emitted in the RequestData ReadStream on the server.\n */\nexport const RequestReaderErrorSchema = Type.Object({\n code: Type.Union([\n Type.Literal(UNCAUGHT_ERROR_CODE),\n Type.Literal(UNEXPECTED_DISCONNECT_CODE),\n Type.Literal(INVALID_REQUEST_CODE),\n Type.Literal(ABORT_CODE),\n ]),\n message: Type.String(),\n});\n\n/**\n * Represents an acceptable schema to pass to a procedure.\n * Just a type of a schema, not an actual schema.\n */\nexport type ProcedureErrorSchemaType =\n | TUnion<Array<BaseErrorSchemaType>>\n | BaseErrorSchemaType\n | TNever;\n\n/**\n * Procedure for a single message in both directions (1:1).\n *\n * @template State - The context state object.\n * @template RequestInit - The TypeBox schema of the initialization object.\n * @template ResponseData - The TypeBox schema of the output object.\n * @template ResponseErr - The TypeBox schema of the error object.\n */\nexport interface RpcProcedure<\n State,\n RequestInit extends PayloadType,\n ResponseData extends PayloadType,\n ResponseErr extends ProcedureErrorSchemaType,\n> {\n type: 'rpc';\n requestInit: RequestInit;\n responseData: ResponseData;\n responseError: ResponseErr;\n description?: string;\n handler({\n ctx,\n reqInit,\n }: {\n ctx: ProcedureHandlerContext<State>;\n reqInit: Static<RequestInit>;\n }): Promise<Result<Static<ResponseData>, Static<ResponseErr>>>;\n}\n\n/**\n * Procedure for a client-stream (potentially preceded by an initialization message),\n * single message from server (n:1).\n *\n * @template State - The context state object.\n * @template RequestInit - The TypeBox schema of the initialization object.\n * @template RequestData - The TypeBox schema of the input object.\n * @template ResponseData - The TypeBox schema of the output object.\n * @template ResponseErr - The TypeBox schema of the error object.\n */\nexport interface UploadProcedure<\n State,\n RequestInit extends PayloadType,\n RequestData extends PayloadType,\n ResponseData extends PayloadType,\n ResponseErr extends ProcedureErrorSchemaType,\n> {\n type: 'upload';\n requestInit: RequestInit;\n requestData: RequestData;\n responseData: ResponseData;\n responseError: ResponseErr;\n description?: string;\n handler({\n ctx,\n reqInit,\n reqReader,\n }: {\n ctx: ProcedureHandlerContext<State>;\n reqInit: Static<RequestInit>;\n reqReader: ReadStream<\n Static<RequestData>,\n Static<typeof RequestReaderErrorSchema>\n >;\n }): Promise<Result<Static<ResponseData>, Static<ResponseErr>>>;\n}\n\n/**\n * Procedure for a single message from client, stream from server (1:n).\n *\n * @template State - The context state object.\n * @template RequestInit - The TypeBox schema of the initialization object.\n * @template ResponseData - The TypeBox schema of the output object.\n * @template ResponseErr - The TypeBox schema of the error object.\n */\nexport interface SubscriptionProcedure<\n State,\n RequestInit extends PayloadType,\n ResponseData extends PayloadType,\n ResponseErr extends ProcedureErrorSchemaType,\n> {\n type: 'subscription';\n requestInit: RequestInit;\n responseData: ResponseData;\n responseError: ResponseErr;\n description?: string;\n handler({\n ctx,\n reqInit,\n resWriter,\n }: {\n ctx: ProcedureHandlerContext<State>;\n reqInit: Static<RequestInit>;\n resWriter: WriteStream<Result<Static<ResponseData>, Static<ResponseErr>>>;\n }): Promise<void | undefined>;\n}\n\n/**\n * Procedure for a bidirectional stream (potentially preceded by an initialization message),\n * (n:n).\n *\n * @template State - The context state object.\n * @template RequestInit - The TypeBox schema of the initialization object.\n * @template RequestData - The TypeBox schema of the input object.\n * @template ResponseData - The TypeBox schema of the output object.\n * @template ResponseErr - The TypeBox schema of the error object.\n */\nexport interface StreamProcedure<\n State,\n RequestInit extends PayloadType,\n RequestData extends PayloadType,\n ResponseData extends PayloadType,\n ResponseErr extends ProcedureErrorSchemaType,\n> {\n type: 'stream';\n requestInit: RequestInit;\n requestData: RequestData;\n responseData: ResponseData;\n responseError: ResponseErr;\n description?: string;\n handler({\n ctx,\n reqInit,\n reqReader,\n resWriter,\n }: {\n ctx: ProcedureHandlerContext<State>;\n reqInit: Static<RequestInit>;\n reqReader: ReadStream<\n Static<RequestData>,\n Static<typeof RequestReaderErrorSchema>\n >;\n resWriter: WriteStream<Result<Static<ResponseData>, Static<ResponseErr>>>;\n }): Promise<void | undefined>;\n}\n\n/**\n * Defines a Procedure type that can be a:\n * - {@link RpcProcedure} for a single message in both directions (1:1)\n * - {@link UploadProcedure} for a client-stream (potentially preceded by an\n * initialization message)\n * - {@link SubscriptionProcedure} for a single message from client, stream from server (1:n)\n * - {@link StreamProcedure} for a bidirectional stream (potentially preceded by an\n * initialization message)\n *\n * @template State - The TypeBox schema of the state object.\n * @template Ty - The type of the procedure.\n * @template RequestData - The TypeBox schema of the input object.\n * @template RequestInit - The TypeBox schema of the input initialization object, if any.\n * @template ResponseData - The TypeBox schema of the output object.\n */\nexport type Procedure<\n State,\n Ty extends ValidProcType,\n RequestInit extends PayloadType,\n RequestData extends PayloadType | null,\n ResponseData extends PayloadType,\n ResponseErr extends ProcedureErrorSchemaType,\n> = { type: Ty } & (RequestData extends PayloadType\n ? Ty extends 'upload'\n ? UploadProcedure<\n State,\n RequestInit,\n RequestData,\n ResponseData,\n ResponseErr\n >\n : Ty extends 'stream'\n ? StreamProcedure<\n State,\n RequestInit,\n RequestData,\n ResponseData,\n ResponseErr\n >\n : never\n : Ty extends 'rpc'\n ? RpcProcedure<State, RequestInit, ResponseData, ResponseErr>\n : Ty extends 'subscription'\n ? SubscriptionProcedure<State, RequestInit, ResponseData, ResponseErr>\n : never);\n\n/**\n * Represents any {@link Procedure} type.\n *\n * @template State - The context state object. You can provide this to constrain\n * the type of procedures.\n */\nexport type AnyProcedure<State = object> = Procedure<\n State,\n ValidProcType,\n PayloadType,\n PayloadType | null,\n PayloadType,\n ProcedureErrorSchemaType\n>;\n\n/**\n * Represents a map of {@link Procedure}s.\n *\n * @template State - The context state object. You can provide this to constrain\n * the type of procedures.\n */\nexport type ProcedureMap<State = object> = Record<string, AnyProcedure<State>>;\n\n// typescript is funky so with these upcoming procedure constructors, the overloads\n// which handle the `init` case _must_ come first, otherwise the `init` property\n// is not recognized as optional, for some reason\n\n/**\n * Creates an {@link RpcProcedure}.\n */\n// signature: default errors\nfunction rpc<\n State,\n RequestInit extends PayloadType,\n ResponseData extends PayloadType,\n>(def: {\n requestInit: RequestInit;\n responseData: ResponseData;\n responseError?: never;\n description?: string;\n handler: RpcProcedure<State, RequestInit, ResponseData, TNever>['handler'];\n}): Branded<RpcProcedure<State, RequestInit, ResponseData, TNever>>;\n\n// signature: explicit errors\nfunction rpc<\n State,\n RequestInit extends PayloadType,\n ResponseData extends PayloadType,\n ResponseErr extends ProcedureErrorSchemaType,\n>(def: {\n requestInit: RequestInit;\n responseData: ResponseData;\n responseError: ResponseErr;\n description?: string;\n handler: RpcProcedure<\n State,\n RequestInit,\n ResponseData,\n ResponseErr\n >['handler'];\n}): Branded<RpcProcedure<State, RequestInit, ResponseData, ResponseErr>>;\n\n// implementation\nfunction rpc({\n requestInit,\n responseData,\n responseError = Type.Never(),\n description,\n handler,\n}: {\n requestInit: PayloadType;\n responseData: PayloadType;\n responseError?: ProcedureErrorSchemaType;\n description?: string;\n handler: RpcProcedure<\n object,\n PayloadType,\n PayloadType,\n ProcedureErrorSchemaType\n >['handler'];\n}) {\n return {\n ...(description ? { description } : {}),\n type: 'rpc',\n requestInit,\n responseData,\n responseError,\n handler,\n };\n}\n\n/**\n * Creates an {@link UploadProcedure}, optionally with an initialization message.\n */\n// signature: init with default errors\nfunction upload<\n State,\n RequestInit extends PayloadType,\n RequestData extends PayloadType,\n ResponseData extends PayloadType,\n>(def: {\n requestInit: RequestInit;\n requestData: RequestData;\n responseData: ResponseData;\n responseError?: never;\n description?: string;\n handler: UploadProcedure<\n State,\n RequestInit,\n RequestData,\n ResponseData,\n TNever\n >['handler'];\n}): Branded<\n UploadProcedure<State, RequestInit, RequestData, ResponseData, TNever>\n>;\n\n// signature: init with explicit errors\nfunction upload<\n State,\n RequestInit extends PayloadType,\n RequestData extends PayloadType,\n ResponseData extends PayloadType,\n ResponseErr extends ProcedureErrorSchemaType,\n>(def: {\n requestInit: RequestInit;\n requestData: RequestData;\n responseData: ResponseData;\n responseError: ResponseErr;\n description?: string;\n handler: UploadProcedure<\n State,\n RequestInit,\n RequestData,\n ResponseData,\n ResponseErr\n >['handler'];\n}): Branded<\n UploadProcedure<State, RequestInit, RequestData, ResponseData, ResponseErr>\n>;\n\n// implementation\nfunction upload({\n requestInit,\n requestData,\n responseData,\n responseError = Type.Never(),\n description,\n handler,\n}: {\n requestInit: PayloadType;\n requestData: PayloadType;\n responseData: PayloadType;\n responseError?: ProcedureErrorSchemaType;\n description?: string;\n handler: UploadProcedure<\n object,\n PayloadType,\n PayloadType,\n PayloadType,\n ProcedureErrorSchemaType\n >['handler'];\n}) {\n return {\n type: 'upload',\n ...(description ? { description } : {}),\n requestInit,\n requestData,\n responseData,\n responseError,\n handler,\n };\n}\n\n/**\n * Creates a {@link SubscriptionProcedure}.\n */\n// signature: default errors\nfunction subscription<\n State,\n RequestInit extends PayloadType,\n ResponseData extends PayloadType,\n>(def: {\n requestInit: RequestInit;\n responseData: ResponseData;\n responseError?: never;\n description?: string;\n handler: SubscriptionProcedure<\n State,\n RequestInit,\n ResponseData,\n TNever\n >['handler'];\n}): Branded<SubscriptionProcedure<State, RequestInit, ResponseData, TNever>>;\n\n// signature: explicit errors\nfunction subscription<\n State,\n RequestInit extends PayloadType,\n ResponseData extends PayloadType,\n ResponseErr extends ProcedureErrorSchemaType,\n>(def: {\n requestInit: RequestInit;\n responseData: ResponseData;\n responseError: ResponseErr;\n description?: string;\n handler: SubscriptionProcedure<\n State,\n RequestInit,\n ResponseData,\n ResponseErr\n >['handler'];\n}): Branded<\n SubscriptionProcedure<State, RequestInit, ResponseData, ResponseErr>\n>;\n\n// implementation\nfunction subscription({\n requestInit,\n responseData,\n responseError = Type.Never(),\n description,\n handler,\n}: {\n requestInit: PayloadType;\n responseData: PayloadType;\n responseError?: ProcedureErrorSchemaType;\n description?: string;\n handler: SubscriptionProcedure<\n object,\n PayloadType,\n PayloadType,\n ProcedureErrorSchemaType\n >['handler'];\n}) {\n return {\n type: 'subscription',\n ...(description ? { description } : {}),\n requestInit,\n responseData,\n responseError,\n handler,\n };\n}\n\n/**\n * Creates a {@link StreamProcedure}, optionally with an initialization message.\n */\n// signature: with default errors\nfunction stream<\n State,\n RequestInit extends PayloadType,\n RequestData extends PayloadType,\n ResponseData extends PayloadType,\n>(def: {\n requestInit: RequestInit;\n requestData: RequestData;\n responseData: ResponseData;\n responseError?: never;\n description?: string;\n handler: StreamProcedure<\n State,\n RequestInit,\n RequestData,\n ResponseData,\n TNever\n >['handler'];\n}): Branded<\n StreamProcedure<State, RequestInit, RequestData, ResponseData, TNever>\n>;\n\n// signature: explicit errors\nfunction stream<\n State,\n RequestInit extends PayloadType,\n RequestData extends PayloadType,\n ResponseData extends PayloadType,\n ResponseErr extends ProcedureErrorSchemaType,\n>(def: {\n requestInit: RequestInit;\n requestData: RequestData;\n responseData: ResponseData;\n responseError: ResponseErr;\n description?: string;\n handler: StreamProcedure<\n State,\n RequestInit,\n RequestData,\n ResponseData,\n ResponseErr\n >['handler'];\n}): Branded<\n StreamProcedure<State, RequestInit, RequestData, ResponseData, ResponseErr>\n>;\n\n// implementation\nfunction stream({\n requestInit,\n requestData,\n responseData,\n responseError = Type.Never(),\n description,\n handler,\n}: {\n requestInit: PayloadType;\n requestData: PayloadType;\n responseData: PayloadType;\n responseError?: ProcedureErrorSchemaType;\n description?: string;\n handler: StreamProcedure<\n object,\n PayloadType,\n PayloadType,\n PayloadType,\n ProcedureErrorSchemaType\n >['handler'];\n}) {\n return {\n type: 'stream',\n ...(description ? { description } : {}),\n requestInit,\n requestData,\n responseData,\n responseError,\n handler,\n };\n}\n\n/**\n * Holds the {@link Procedure} creation functions. Use these to create\n * procedures for services. You aren't allowed to create procedures directly.\n */\nexport const Procedure = {\n rpc,\n upload,\n subscription,\n stream,\n};\n","import {\n Static,\n TLiteral,\n TObject,\n TSchema,\n TString,\n TUnion,\n Type,\n} from '@sinclair/typebox';\nimport { Client } from './client';\nimport { ReadStream } from './streams';\n\ntype TLiteralString = TLiteral<string>;\n\nexport type BaseErrorSchemaType =\n | TObject<{\n code: TLiteralString | TUnion<Array<TLiteralString>>;\n message: TLiteralString | TString;\n }>\n | TObject<{\n code: TLiteralString | TUnion<Array<TLiteralString>>;\n message: TLiteralString | TString;\n extras: TSchema;\n }>;\n\n/**\n * Takes in a specific error schema and returns a result schema the error\n */\nexport const ErrResultSchema = <T extends BaseErrorSchemaType>(t: T) =>\n Type.Object({\n ok: Type.Literal(false),\n payload: t,\n });\n\n/**\n * AnyResultSchema is a schema to validate any result.\n */\nexport const AnyResultSchema = Type.Union([\n Type.Object({\n ok: Type.Literal(false),\n payload: Type.Object({\n code: Type.String(),\n message: Type.String(),\n extras: Type.Optional(Type.Unknown()),\n }),\n }),\n\n Type.Object({\n ok: Type.Literal(true),\n payload: Type.Unknown(),\n }),\n]);\n\nexport interface OkResult<T> {\n ok: true;\n payload: T;\n}\nexport interface ErrResult<Err extends Static<BaseErrorSchemaType>> {\n ok: false;\n payload: Err;\n}\nexport type Result<T, Err extends Static<BaseErrorSchemaType>> =\n | OkResult<T>\n | ErrResult<Err>;\n\nexport function Ok<const T extends Array<unknown>>(p: T): OkResult<T>;\nexport function Ok<const T extends ReadonlyArray<unknown>>(p: T): OkResult<T>;\nexport function Ok<const T>(payload: T): OkResult<T>;\nexport function Ok<const T>(payload: T): OkResult<T> {\n return {\n ok: true,\n payload,\n };\n}\n\nexport function Err<const Err extends Static<BaseErrorSchemaType>>(\n error: Err,\n): ErrResult<Err> {\n return {\n ok: false,\n payload: error,\n };\n}\n\n/**\n * Refine a {@link Result} type to its returned payload.\n */\nexport type ResultUnwrapOk<R> = R extends Result<infer T, infer __E>\n ? T\n : never;\n\n/**\n * Unwrap a {@link Result} type and return the payload if successful,\n * otherwise throws an error.\n * @param result - The result to unwrap.\n * @throws Will throw an error if the result is not ok.\n */\nexport function unwrap<T, Err extends Static<BaseErrorSchemaType>>(\n result: Result<T, Err>,\n): T {\n if (result.ok) {\n return result.payload;\n }\n\n throw new Error(\n `Cannot non-ok result, got: ${result.payload.code} - ${result.payload.message}`,\n );\n}\n\n/**\n * Refine a {@link Result} type to its error payload.\n */\nexport type ResultUnwrapErr<R> = R extends Result<infer __T, infer Err>\n ? Err\n : never;\n\n/**\n * Retrieve the output type for a procedure, represented as a {@link Result}\n * type.\n * Example:\n * ```\n * type Message = Output<typeof client, 'serviceName', 'procedureName'>\n * ```\n */\nexport type Output<\n RiverClient,\n ServiceName extends keyof RiverClient,\n ProcedureName extends keyof RiverClient[ServiceName],\n Procedure = RiverClient[ServiceName][ProcedureName],\n Fn extends (...args: never) => unknown = (...args: never) => unknown,\n> = RiverClient extends Client<infer __ServiceSchemaMap>\n ? Procedure extends object\n ? Procedure extends object & { rpc: infer RpcFn extends Fn }\n ? Awaited<ReturnType<RpcFn>>\n : Procedure extends object & { upload: infer UploadFn extends Fn }\n ? ReturnType<UploadFn> extends {\n finalize: (...args: never) => Promise<infer UploadOutputMessage>;\n }\n ? UploadOutputMessage\n : never\n : Procedure extends object & { stream: infer StreamFn extends Fn }\n ? ReturnType<StreamFn> extends {\n resReader: ReadStream<\n infer StreamOutputMessage,\n Static<BaseErrorSchemaType>\n >;\n }\n ? StreamOutputMessage\n : never\n : Procedure extends object & {\n subscribe: infer SubscriptionFn extends Fn;\n }\n ? Awaited<ReturnType<SubscriptionFn>> extends {\n resReader: ReadStream<\n infer SubscriptionOutputMessage,\n Static<BaseErrorSchemaType>\n >;\n }\n ? SubscriptionOutputMessage\n : never\n : never\n : never\n : never;\n","import { Static } from '@sinclair/typebox';\nimport { BaseErrorSchemaType, Err, Result } from './result';\n\nexport const StreamDrainedError = {\n code: 'STREAM_DRAINED',\n message: 'Stream was drained',\n} as const;\n\ntype ReadStreamResult<T, E extends Static<BaseErrorSchemaType>> = Result<\n T,\n E | typeof StreamDrainedError\n>;\n\n/**\n * Using simple iterator here to lock down the iteration and disallow\n * `return` and `throw` to be called from the outside.\n */\nexport interface SimpleIterator<T> {\n next(): Promise<\n | {\n done: false;\n value: T;\n }\n | {\n done: true;\n value: undefined;\n }\n >;\n}\n\n/**\n * A `ReadStream` represents a stream of data.\n *\n * This stream is not closable by the reader, the reader must wait for\n * the writer to close it.\n *\n * The stream can only be locked (aka consumed) once and will remain\n * locked, trying to lock the stream again will throw an TypeError.\n */\nexport interface ReadStream<T, E extends Static<BaseErrorSchemaType>> {\n /**\n * Stream implements AsyncIterator API and can be consumed via\n * for-await-of loops. Iteration locks the stream\n *\n */\n [Symbol.asyncIterator](): SimpleIterator<ReadStreamResult<T, E>>;\n /**\n * `unwrappedIter` returns an AsyncIterator that will unwrap the results coming\n * into the stream, yielding the payload if successful, otherwise throwing.\n * We generally recommend using the normal iterator instead of this method,\n * and handling errors explicitly.\n */\n unwrappedIter(): {\n [Symbol.asyncIterator](): SimpleIterator<T>;\n };\n /**\n * `asArray` locks the stream and returns a promise that resolves\n * with an array of the stream's content when the stream is closed.\n *\n */\n asArray(): Promise<Array<ReadStreamResult<T, E>>>;\n /**\n * `drain` locks the stream and discards any existing or future data.\n *\n * If there is an existing Promise waiting for the next value,\n * `drain` causes it to resolve with a {@link StreamDrainedError} error.\n */\n drain(): undefined;\n /**\n * `isLocked` returns true if the stream is locked.\n */\n isLocked(): boolean;\n /**\n * `onClose` registers a callback that will be called when the stream\n * is closed. Returns a function that can be used to unregister the\n * listener.\n */\n onClose(cb: () => void): () => void;\n /**\n * `isClosed` returns true if the stream was closed by the writer.\n *\n * Note that the stream can still have queued data and can still be\n * consumed.\n */\n isClosed(): boolean;\n /**\n * `requestClose` sends a request to the writer to close the stream,\n * and resolves the writer closes its end of the stream..\n *\n * The stream can still receive more data after the request is sent. If you\n * no longer wish to use the stream, make sure to call `drain`.\n */\n requestClose(): Promise<undefined>;\n /**\n * `isCloseRequested` checks if the reader has requested to close the stream.\n */\n isCloseRequested(): boolean;\n}\n\n/**\n * A `WriteStream` is a streams that can be written to.\n */\nexport interface WriteStream<T> {\n /**\n * `write` writes a value to the stream. An error is thrown if writing to a closed stream.\n */\n write(value: T): undefined;\n /**\n * `close` signals the closure of the write stream, informing the reader that the stream is complete.\n * Calling close multiple times has no effect.\n */\n close(): undefined;\n /**\n * `isCloseRequested` checks if the reader has requested to close the stream.\n */\n isCloseRequested(): boolean;\n /**\n * `onCloseRequest` registers a callback that will be called when the stream's\n * reader requests a close. Returns a function that can be used to unregister the\n * listener.\n */\n onCloseRequest(cb: () => void): () => void;\n /**\n * `isClosed` returns true if the stream was closed by the writer.\n */\n isClosed(): boolean;\n /**\n * `onClose` registers a callback that will be called when the stream\n * is closed. Returns a function that can be used to unregister the\n * listener.\n */\n onClose(cb: () => void): () => void;\n}\n\n/**\n * Internal implementation of a `ReadStream`.\n * This won't be exposed as an interface to river\n * consumers directly, it has internal river methods\n * to pushed data to the stream and close it.\n */\nexport class ReadStreamImpl<T, E extends Static<BaseErrorSchemaType>>\n implements ReadStream<T, E>\n{\n /**\n * Whether the stream is closed.\n */\n private closed = false;\n /**\n * A list of listeners that will be called when the stream is closed.\n */\n private onCloseListeners: Set<() => void>;\n /**\n * Whether the user has requested to close the stream.\n */\n private closeRequested = false;\n /**\n * Used to signal to the outside world that the user has requested to close the stream.\n */\n private closeRequestCallback: () => void;\n /**\n * Whether the stream is locked.\n */\n private locked = false;\n /**\n * Whether drain was called.\n */\n private drained = false;\n /**\n * This flag allows us to avoid cases where drain was called,\n * but the stream is fully consumed and closed. We don't need\n * to signal that drain was called.\n */\n private didDrainDisposeValues = false;\n /**\n * A list of values that have been pushed to the stream but not yet emitted to the user.\n */\n private queue: Array<ReadStreamResult<T, E>> = [];\n /**\n * Used by methods in the class to signal to the iterator that it\n * should check for the next value.\n */\n private nextPromise: Promise<void> | null = null;\n /**\n * Resolves nextPromise\n */\n private resolveNextPromise: null | (() => void) = null;\n\n constructor(closeRequestCallback: () => void) {\n this.closeRequestCallback = closeRequestCallback;\n this.onCloseListeners = new Set();\n }\n\n public [Symbol.asyncIterator]() {\n if (this.isLocked()) {\n throw new TypeError('ReadStream is already locked');\n }\n\n // first iteration with drain signals an error, the following one signals end of iteration.\n let didSignalDrain = false;\n this.locked = true;\n\n return {\n next: async () => {\n if (this.drained && didSignalDrain) {\n return {\n done: true,\n value: undefined,\n } as const;\n }\n\n // Wait until we have something in the queue\n while (this.queue.length === 0) {\n if (this.isClosed() && !this.didDrainDisposeValues) {\n return {\n done: true,\n value: undefined,\n } as const;\n }\n\n if (this.drained) {\n didSignalDrain = true;\n\n return {\n done: false,\n value: Err(StreamDrainedError),\n } as const;\n }\n\n if (!this.nextPromise) {\n this.nextPromise = new Promise<void>((resolve) => {\n this.resolveNextPromise = resolve;\n });\n }\n\n await this.nextPromise;\n this.nextPromise = null;\n this.resolveNextPromise = null;\n }\n\n // Unfortunately we have to use non-null assertion here, because T can be undefined\n // we already check for array length above anyway\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const value = this.queue.shift()!;\n\n return { done: false, value } as const;\n },\n return: () => {\n this.drain();\n return { done: true, value: undefined } as const;\n },\n };\n }\n\n public unwrappedIter() {\n const iterator = this[Symbol.asyncIterator]();\n\n let unwrappedLock = false;\n return {\n [Symbol.asyncIterator]() {\n if (unwrappedLock) {\n throw new TypeError('ReadStream is already locked');\n }\n\n unwrappedLock = true;\n\n return {\n next: async (): ReturnType<SimpleIterator<T>['next']> => {\n const next = await iterator.next();\n\n if (next.done) {\n return next;\n }\n\n if (next.value.ok) {\n return { done: false, value: next.value.payload };\n }\n\n iterator.return();\n\n throw new Error(\n `Got err result in unwrappedIter: ${next.value.payload.code} - ${next.value.payload.message}`,\n );\n },\n return: () => iterator.return(),\n };\n },\n };\n }\n\n public async asArray(): Promise<Array<ReadStreamResult<T, E>>> {\n const array: Array<ReadStreamResult<T, E>> = [];\n for await (const value of this) {\n array.push(value);\n }\n\n return array;\n }\n\n public drain(): undefined {\n if (this.drained) {\n return;\n }\n\n this.locked = true;\n this.drained = true;\n this.didDrainDisposeValues = this.queue.length > 0;\n this.queue.length = 0;\n\n this.resolveNextPromise?.();\n }\n\n public isClosed(): boolean {\n return this.closed;\n }\n\n public isLocked(): boolean {\n return this.locked;\n }\n\n public onClose(cb: () => void): () => void {\n if (this.isClosed()) {\n throw new Error('Stream is already closed');\n }\n\n this.onCloseListeners.add(cb);\n\n return () => {\n this.onCloseListeners.delete(cb);\n };\n }\n\n public requestClose(): Promise<undefined> {\n if (this.isClosed()) {\n throw new Error('Cannot request close after stream already closed');\n }\n\n if (!this.closeRequested) {\n this.closeRequested = true;\n this.closeRequestCallback();\n }\n\n return new Promise<undefined>((resolve) => {\n this.onClose(() => {\n resolve(undefined);\n });\n });\n }\n\n public isCloseRequested(): boolean {\n return this.closeRequested;\n }\n\n /**\n * @internal meant for use within river, not exposed as a public API\n *\n * Pushes a value to the stream.\n */\n public pushValue(value: Result<T, E>): undefined {\n if (this.drained) {\n return;\n }\n\n if (this.closed) {\n throw new Error('Cannot push to closed stream');\n }\n\n this.queue.push(value);\n this.resolveNextPromise?.();\n }\n\n /**\n * @internal meant for use within river, not exposed as a public API\n *\n * Triggers the close of the stream. Make sure to push all remaining\n * values before calling this method.\n */\n public triggerClose(): undefined {\n if (this.isClosed()) {\n throw new Error('Unexpected closing multiple times');\n }\n\n this.closed = true;\n this.resolveNextPromise?.();\n this.onCloseListeners.forEach((cb) => cb());\n this.onCloseListeners.clear();\n\n // TODO maybe log a warn if after a certain amount of time\n // the queue was not fully consumed\n }\n\n /**\n * @internal meant for use within river, not exposed as a public API\n */\n public hasValuesInQueue(): boolean {\n return this.queue.length > 0;\n }\n}\n\n/**\n * Internal implementation of a `WriteStream`.\n * This won't be exposed as an interface to river\n * consumers directly, it has internal river methods\n * to trigger a close request, a way to pass on close\n * signals, and a way to push data to the stream.\n */\nexport class WriteStreamImpl<T> implements WriteStream<T> {\n /**\n * Passed via constructor to pass on write requests\n */\n private writeCb: (value: T) => void;\n /**\n * Whether the stream is closed.\n */\n private closed = false;\n /**\n * A list of listeners that will be called when the stream is closed.\n */\n private onCloseListeners: Set<() => void>;\n /**\n * Whether the reader has requested to close the stream.\n */\n private closeRequested = false;\n /**\n * A list of listeners that will be called when a close request is triggered.\n */\n private onCloseRequestListeners: Set<() => void>;\n\n constructor(writeCb: (value: T) => void) {\n this.writeCb = writeCb;\n this.onCloseListeners = new Set();\n this.onCloseRequestListeners = new Set();\n }\n\n public write(value: T): undefined {\n if (this.isClosed()) {\n throw new Error('Cannot write to closed stream');\n }\n\n this.writeCb(value);\n }\n\n public isClosed(): boolean {\n return this.closed;\n }\n\n onClose(cb: () => void): () => void {\n if (this.isClosed()) {\n cb();\n\n return () => undefined;\n }\n\n this.onCloseListeners.add(cb);\n\n return () => this.onCloseListeners.delete(cb);\n }\n\n public close(): undefined {\n if (this.isClosed()) {\n return;\n }\n\n this.closed = true;\n this.onCloseListeners.forEach((cb) => cb());\n\n // cleanup\n this.onCloseListeners.clear();\n this.onCloseRequestListeners.clear();\n this.writeCb = () => undefined;\n }\n\n public isCloseRequested(): boolean {\n return this.closeRequested;\n }\n\n public onCloseRequest(cb: () => void): () => void {\n if (this.isClosed()) {\n throw new Error('Stream is already closed');\n }\n\n if (this.isCloseRequested()) {\n cb();\n\n return () => undefined;\n }\n\n this.onCloseRequestListeners.add(cb);\n\n return () => this.onCloseRequestListeners.delete(cb);\n }\n\n /**\n * @internal meant for use within river, not exposed as a public API\n *\n * Triggers a close request.\n */\n public triggerCloseRequest(): undefined {\n if (this.isCloseRequested()) {\n throw new Error('Cannot trigger close request multiple times');\n }\n\n if (this.isClosed()) {\n throw new Error('Cannot trigger close request on closed stream');\n }\n\n this.closeRequested = true;\n this.onCloseRequestListeners.forEach((cb) => cb());\n this.onCloseRequestListeners.clear();\n }\n}\n"],"mappings":";AACA,SAA0C,YAAY;AAwC/C,IAAM,4BAA4B;AAKlC,IAAM,sBAAsB;AAK5B,IAAM,6BAA6B;AAInC,IAAM,uBAAuB;AAI7B,IAAM,aAAa;AAMnB,IAAM,4BAA4B,KAAK,OAAO;AAAA,EACnD,MAAM,KAAK,MAAM;AAAA,IACf,KAAK,QAAQ,yBAAyB;AAAA,IACtC,KAAK,QAAQ,mBAAmB;AAAA,IAChC,KAAK,QAAQ,0BAA0B;AAAA,IACvC,KAAK,QA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