Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@replit/river

Package Overview
Dependencies
Maintainers
0
Versions
162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@replit/river - npm Package Compare versions

Comparing version 0.200.5 to 0.201.0

dist/chunk-52DVJUVZ.js

2

dist/logging/index.d.ts

@@ -1,4 +0,4 @@

export { h as LogFn, L as Logger, M as MessageMetadata, l as coloredStringLogger, m as jsonLogger, s as stringLogger } from '../message-45658364.js';
export { h as LogFn, L as Logger, M as MessageMetadata, l as coloredStringLogger, m as jsonLogger, s as stringLogger } from '../message-3def9ded.js';
import '@sinclair/typebox/value';
import '@sinclair/typebox';
import '@opentelemetry/api';

@@ -1,9 +0,9 @@

import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, g as AnyProcedure } from '../services-94e0afc3.js';
export { B as BaseErrorSchemaType, H as CANCEL_CODE, K as Client, L as Err, N as ErrResult, G as INVALID_REQUEST_CODE, O as Ok, Q as OkResult, P as PayloadType, m as ProcErrors, i as ProcHandler, j as ProcInit, k as ProcRequest, l as ProcResponse, n as ProcType, d as Procedure, c as ProcedureErrorSchemaType, x as ProcedureMap, y as RPCProcedure, R as Readable, f as ReaderErrorSchema, Y as ResponseData, e as Result, X as ResultUnwrapErr, T as ResultUnwrapOk, r as SerializedProcedureSchema, w as SerializedProcedureSchemaProtocolv1, p as SerializedServerSchema, u as SerializedServerSchemaProtocolv1, q as SerializedServiceSchema, v as SerializedServiceSchemaProtocolv1, S as Service, h as ServiceConfiguration, o as ServiceSchema, C as StreamProcedure, z as SubscriptionProcedure, E as UNCAUGHT_ERROR_CODE, F as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, J as createClient, D as flattenErrorType, s as serializeSchema, t as serializeSchemaV1Compat, M as unwrapOrThrow } from '../services-94e0afc3.js';
import { c as TransportClientId, b as OpaqueTransportMessage } from '../message-45658364.js';
import { t as ParsedMetadata, C as Connection, u as ServerHandshakeOptions, p as ServiceContext } from '../context-8d1ed9a1.js';
export { v as ProcedureHandlerContext, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../context-8d1ed9a1.js';
import { S as ServerTransport } from '../server-eb7d2cfd.js';
import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, a as AnyProcedure } from '../services-e71ea921.js';
export { E as BaseErrorSchemaType, C as CANCEL_CODE, G as Client, H as Err, L as ErrResult, B as INVALID_REQUEST_CODE, O as Ok, M as OkResult, p as PayloadType, f as ProcErrors, P as ProcHandler, c as ProcInit, d as ProcRequest, e as ProcResponse, g as ProcType, v as Procedure, w as ProcedureErrorSchemaType, q as ProcedureMap, R as RPCProcedure, u as Readable, D as ReaderErrorSchema, T as ResponseData, K as Result, Q as ResultUnwrapErr, N as ResultUnwrapOk, k as SerializedProcedureSchema, o as SerializedProcedureSchemaProtocolv1, i as SerializedServerSchema, m as SerializedServerSchemaProtocolv1, j as SerializedServiceSchema, n as SerializedServiceSchemaProtocolv1, S as Service, b as ServiceConfiguration, h as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, y as UNCAUGHT_ERROR_CODE, z as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, F as createClient, x as flattenErrorType, s as serializeSchema, l as serializeSchemaV1Compat, J as unwrapOrThrow } from '../services-e71ea921.js';
import { c as TransportClientId, b as OpaqueTransportMessage } from '../message-3def9ded.js';
import { q as ParsedMetadata, C as Connection, r as ServerHandshakeOptions, s as ServiceContext } from '../context-8d263a7f.js';
export { t as ProcedureHandlerContext, u as createClientHandshakeOptions, v as createServerHandshakeOptions } from '../context-8d263a7f.js';
import { S as ServerTransport } from '../server-48d90a77.js';
import '@sinclair/typebox';
import '../client-ba6815ae.js';
import '../client-a32692b0.js';
import '@sinclair/typebox/value';

@@ -58,4 +58,4 @@ import '@opentelemetry/api';

var version = "0.200.5";
var version = "0.201.0";
export { ParsedMetadata, version as RIVER_VERSION, Server, ServiceContext, createServer };
import {
AnyResultSchema,
CANCEL_CODE,
Err,
ErrResultSchema,
INVALID_REQUEST_CODE,
Ok,
ReadableImpl,
ReaderErrorSchema,
UNCAUGHT_ERROR_CODE,
UNEXPECTED_DISCONNECT_CODE,
WritableImpl,
flattenErrorType,
unwrapOrThrow
} from "../chunk-ZVWJN6V2.js";
import {
ControlMessageCloseSchema,

@@ -30,6 +15,60 @@ ControlMessagePayloadSchema,

version
} from "../chunk-64J442AK.js";
} from "../chunk-7IUEEQP7.js";
// router/services.ts
import { Type, Kind } from "@sinclair/typebox";
import { Type as Type2, Kind as Kind2 } from "@sinclair/typebox";
// router/errors.ts
import {
Kind,
Type
} from "@sinclair/typebox";
var UNCAUGHT_ERROR_CODE = "UNCAUGHT_ERROR";
var UNEXPECTED_DISCONNECT_CODE = "UNEXPECTED_DISCONNECT";
var INVALID_REQUEST_CODE = "INVALID_REQUEST";
var CANCEL_CODE = "CANCEL";
var ErrResultSchema = (t) => Type.Object({
ok: Type.Literal(false),
payload: t
});
var ReaderErrorSchema = Type.Union([
Type.Object({
code: Type.Literal(UNCAUGHT_ERROR_CODE),
message: Type.String()
}),
Type.Object({
code: Type.Literal(UNEXPECTED_DISCONNECT_CODE),
message: Type.String()
}),
Type.Object({
code: Type.Literal(INVALID_REQUEST_CODE),
message: Type.String()
}),
Type.Object({
code: Type.Literal(CANCEL_CODE),
message: Type.String()
})
]);
function isUnion(schema) {
return schema[Kind] === "Union";
}
function flattenErrorType(errType) {
if (!isUnion(errType)) {
return errType;
}
const flattenedTypes = [];
function flatten(type) {
if (isUnion(type)) {
for (const t of type.anyOf) {
flatten(t);
}
} else {
flattenedTypes.push(type);
}
}
flatten(errType);
return Type.Union(flattenedTypes);
}
// router/services.ts
function serializeSchemaV1Compat(services, handshakeSchema) {

@@ -44,3 +83,3 @@ const serializedServiceObject = Object.entries(services).reduce((acc, [name, value]) => {

if (handshakeSchema) {
schema.handshakeSchema = Type.Strict(handshakeSchema);
schema.handshakeSchema = Type2.Strict(handshakeSchema);
}

@@ -58,3 +97,3 @@ return schema;

if (handshakeSchema) {
schema.handshakeSchema = Type.Strict(handshakeSchema);
schema.handshakeSchema = Type2.Strict(handshakeSchema);
}

@@ -162,4 +201,4 @@ return schema;

{
init: Type.Strict(procDef.requestInit),
output: Type.Strict(procDef.responseData),
init: Type2.Strict(procDef.requestInit),
output: Type2.Strict(procDef.responseData),
errors: getSerializedProcErrors(procDef),

@@ -171,3 +210,3 @@ // Only add `description` field if the type declares it.

..."requestData" in procDef ? {
input: Type.Strict(procDef.requestData)
input: Type2.Strict(procDef.requestData)
} : {}

@@ -196,4 +235,4 @@ }

// this is the only change needed to make it compatible.
input: Type.Strict(procDef.requestInit),
output: Type.Strict(procDef.responseData),
input: Type2.Strict(procDef.requestInit),
output: Type2.Strict(procDef.responseData),
errors: getSerializedProcErrors(procDef),

@@ -209,4 +248,4 @@ // Only add `description` field if the type declares it.

{
init: Type.Strict(procDef.requestInit),
output: Type.Strict(procDef.responseData),
init: Type2.Strict(procDef.requestInit),
output: Type2.Strict(procDef.responseData),
errors: getSerializedProcErrors(procDef),

@@ -216,3 +255,3 @@ // Only add `description` field if the type declares it.

type: procDef.type,
input: Type.Strict(procDef.requestData)
input: Type2.Strict(procDef.requestData)
}

@@ -239,9 +278,9 @@ ];

function getSerializedProcErrors(procDef) {
if (!("responseError" in procDef) || procDef.responseError[Kind] === "Never") {
return Type.Strict(ReaderErrorSchema);
if (!("responseError" in procDef) || procDef.responseError[Kind2] === "Never") {
return Type2.Strict(ReaderErrorSchema);
}
const withProtocolErrors = flattenErrorType(
Type.Union([procDef.responseError, ReaderErrorSchema])
Type2.Union([procDef.responseError, ReaderErrorSchema])
);
return Type.Strict(withProtocolErrors);
return Type2.Strict(withProtocolErrors);
}

@@ -306,7 +345,7 @@ var ServiceScaffold = class {

// router/procedures.ts
import { Type as Type2 } from "@sinclair/typebox";
import { Type as Type3 } from "@sinclair/typebox";
function rpc({
requestInit,
responseData,
responseError = Type2.Never(),
responseError = Type3.Never(),
description,

@@ -328,3 +367,3 @@ handler

responseData,
responseError = Type2.Never(),
responseError = Type3.Never(),
description,

@@ -346,3 +385,3 @@ handler

responseData,
responseError = Type2.Never(),
responseError = Type3.Never(),
description,

@@ -364,3 +403,3 @@ handler

responseData,
responseError = Type2.Never(),
responseError = Type3.Never(),
description,

@@ -386,2 +425,241 @@ handler

// router/result.ts
import { Type as Type4 } from "@sinclair/typebox";
var AnyResultSchema = Type4.Union([
Type4.Object({
ok: Type4.Literal(false),
payload: Type4.Object({
code: Type4.String(),
message: Type4.String(),
extras: Type4.Optional(Type4.Unknown())
})
}),
Type4.Object({
ok: Type4.Literal(true),
payload: Type4.Unknown()
})
]);
function Ok(payload) {
return {
ok: true,
payload
};
}
function Err(error) {
return {
ok: false,
payload: error
};
}
function unwrapOrThrow(result) {
if (result.ok) {
return result.payload;
}
throw new Error(
`Cannot non-ok result, got: ${result.payload.code} - ${result.payload.message}`
);
}
// router/streams.ts
var ReadableBrokenError = {
code: "READABLE_BROKEN",
message: "Readable was broken before it is fully consumed"
};
function createPromiseWithResolvers() {
let resolve;
let reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
return {
promise,
// @ts-expect-error promise callbacks are sync
resolve,
// @ts-expect-error promise callbacks are sync
reject
};
}
var ReadableImpl = class {
/**
* Whether the {@link Readable} is closed.
*
* Closed {@link Readable}s are done receiving values, but that doesn't affect
* any other aspect of the {@link Readable} such as it's consumability.
*/
closed = false;
/**
* Whether the {@link Readable} is locked.
*
* @see {@link Readable}'s typedoc to understand locking
*/
locked = false;
/**
* Whether {@link break} was called.
*
* @see {@link break} for more information
*/
broken = false;
/**
* This flag allows us to avoid emitting a {@link ReadableBrokenError} after {@link break} was called
* in cases where the {@link queue} is fully consumed and {@link ReadableImpl} is {@link closed}. This is just an
* ergonomic feature to avoid emitting an error in our iteration when we don't have to.
*/
brokenWithValuesLeftToRead = false;
/**
* A list of values that have been pushed to the {@link ReadableImpl} but not yet emitted to the user.
*/
queue = [];
/**
* Used by methods in the class to signal to the iterator that it
* should check for the next value.
*/
next = null;
[Symbol.asyncIterator]() {
if (this.locked) {
throw new TypeError("Readable is already locked");
}
this.locked = true;
let didSignalBreak = false;
return {
next: async () => {
if (didSignalBreak) {
return {
done: true,
value: void 0
};
}
while (this.queue.length === 0) {
if (this.closed && !this.brokenWithValuesLeftToRead) {
return {
done: true,
value: void 0
};
}
if (this.broken) {
didSignalBreak = true;
return {
done: false,
value: Err(ReadableBrokenError)
};
}
if (!this.next) {
this.next = createPromiseWithResolvers();
}
await this.next.promise;
this.next = null;
}
const value = this.queue.shift();
return { done: false, value };
},
return: () => {
this.break();
return { done: true, value: void 0 };
}
};
}
async collect() {
const array = [];
for await (const value of this) {
array.push(value);
}
return array;
}
break() {
if (this.broken) {
return;
}
this.locked = true;
this.broken = true;
this.brokenWithValuesLeftToRead = this.queue.length > 0;
this.queue.length = 0;
this.next?.resolve();
}
isReadable() {
return !this.locked && !this.broken;
}
/**
* @internal meant for use within river, not exposed as a public API
*
* Pushes a value to be read.
*/
_pushValue(value) {
if (this.broken) {
return;
}
if (this.closed) {
throw new Error("Cannot push to closed Readable");
}
this.queue.push(value);
this.next?.resolve();
}
/**
* @internal meant for use within river, not exposed as a public API
*
* Triggers the close of the {@link Readable}. Make sure to push all remaining
* values before calling this method.
*/
_triggerClose() {
if (this.closed) {
throw new Error("Unexpected closing multiple times");
}
this.closed = true;
this.next?.resolve();
}
/**
* @internal meant for use within river, not exposed as a public API
*/
_hasValuesInQueue() {
return this.queue.length > 0;
}
/**
* @internal meant for use within river, not exposed as a public API
*/
isClosed() {
return this.closed;
}
};
var WritableImpl = class {
/**
* Passed via constructor to pass on calls to {@link write}
*/
writeCb;
/**
* Passed via constructor to pass on calls to {@link close}
*/
closeCb;
/**
* Whether {@link close} was called, and {@link Writable} is not writable anymore.
*/
closed = false;
constructor(callbacks) {
this.writeCb = callbacks.writeCb;
this.closeCb = callbacks.closeCb;
}
write(value) {
if (this.closed) {
throw new Error("Cannot write to closed Writable");
}
this.writeCb(value);
}
isWritable() {
return !this.closed;
}
close() {
if (this.closed) {
return;
}
this.closed = true;
this.writeCb = () => void 0;
this.closeCb();
this.closeCb = () => void 0;
}
/**
* @internal meant for use within river, not exposed as a public API
*/
isClosed() {
return this.closed;
}
};
// router/client.ts

@@ -664,9 +942,9 @@ import { Value } from "@sinclair/typebox/value";

// router/server.ts
import { Type as Type3 } from "@sinclair/typebox";
import { Type as Type5 } from "@sinclair/typebox";
import { Value as Value2 } from "@sinclair/typebox/value";
import { SpanStatusCode } from "@opentelemetry/api";
var CancelResultSchema = ErrResultSchema(
Type3.Object({
code: Type3.Literal(CANCEL_CODE),
message: Type3.String()
Type5.Object({
code: Type5.Literal(CANCEL_CODE),
message: Type5.String()
})

@@ -673,0 +951,0 @@ );

@@ -1,5 +0,5 @@

import { C as ClientTransport } from '../../../client-ba6815ae.js';
import { c as TransportClientId } from '../../../message-45658364.js';
import { b as ProvidedClientTransportOptions } from '../../../context-8d1ed9a1.js';
import { W as WebSocketConnection } from '../../../connection-d217c989.js';
import { C as ClientTransport } from '../../../client-a32692b0.js';
import { c as TransportClientId } from '../../../message-3def9ded.js';
import { b as ProvidedClientTransportOptions } from '../../../context-8d263a7f.js';
import { W as WebSocketConnection } from '../../../connection-48d021ca.js';
import { W as WsLike } from '../../../wslike-e0b32dd5.js';

@@ -6,0 +6,0 @@ import '@sinclair/typebox/value';

import {
ClientTransport
} from "../../../chunk-WN7GEBMX.js";
} from "../../../chunk-OZ3ITXW5.js";
import {
WebSocketConnection
} from "../../../chunk-Z7Q5CDXD.js";
import "../../../chunk-7Z5MSOKL.js";
} from "../../../chunk-52DVJUVZ.js";
import "../../../chunk-PJ4GJ5CU.js";
import "../../../chunk-7IUEEQP7.js";
import "../../../chunk-LHH5LQ7C.js";
import "../../../chunk-3FMY7VTM.js";
import "../../../chunk-64J442AK.js";
import "../../../chunk-AJGIY2UB.js";

@@ -12,0 +11,0 @@

@@ -1,7 +0,7 @@

import { c as TransportClientId } from '../../../message-45658364.js';
import { c as TransportClientId } from '../../../message-3def9ded.js';
import { WebSocketServer } from 'ws';
import { W as WebSocketConnection } from '../../../connection-d217c989.js';
import { W as WebSocketConnection } from '../../../connection-48d021ca.js';
import { W as WsLike } from '../../../wslike-e0b32dd5.js';
import { S as ServerTransport } from '../../../server-eb7d2cfd.js';
import { c as ProvidedServerTransportOptions } from '../../../context-8d1ed9a1.js';
import { S as ServerTransport } from '../../../server-48d90a77.js';
import { c as ProvidedServerTransportOptions } from '../../../context-8d263a7f.js';
import { IncomingMessage } from 'http';

@@ -8,0 +8,0 @@ import '@sinclair/typebox/value';

import {
ServerTransport
} from "../../../chunk-MSJGPQRT.js";
} from "../../../chunk-UBUD2LMZ.js";
import {
WebSocketConnection
} from "../../../chunk-Z7Q5CDXD.js";
import "../../../chunk-7Z5MSOKL.js";
} from "../../../chunk-52DVJUVZ.js";
import "../../../chunk-PJ4GJ5CU.js";
import "../../../chunk-7IUEEQP7.js";
import "../../../chunk-LHH5LQ7C.js";
import "../../../chunk-3FMY7VTM.js";
import "../../../chunk-64J442AK.js";
import "../../../chunk-AJGIY2UB.js";

@@ -12,0 +11,0 @@

@@ -1,5 +0,5 @@

export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../context-8d1ed9a1.js';
export { C as ClientTransport } from '../client-ba6815ae.js';
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-eb7d2cfd.js';
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-45658364.js';
export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../context-8d263a7f.js';
export { C as ClientTransport } from '../client-a32692b0.js';
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-48d90a77.js';
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-3def9ded.js';
import '@sinclair/typebox';

@@ -6,0 +6,0 @@ import '@sinclair/typebox/errors';

import {
ClientTransport
} from "../chunk-WN7GEBMX.js";
} from "../chunk-OZ3ITXW5.js";
import {
ServerTransport
} from "../chunk-MSJGPQRT.js";
} from "../chunk-UBUD2LMZ.js";
import {
Connection,
ProtocolError,
SessionState,
Transport
} from "../chunk-7Z5MSOKL.js";
import "../chunk-LHH5LQ7C.js";
} from "../chunk-PJ4GJ5CU.js";
import {
SessionState
} from "../chunk-3FMY7VTM.js";
import {
OpaqueTransportMessageSchema,
TransportMessageSchema
} from "../chunk-64J442AK.js";
} from "../chunk-7IUEEQP7.js";
import "../chunk-LHH5LQ7C.js";
import "../chunk-AJGIY2UB.js";

@@ -21,0 +19,0 @@ export {

{
"name": "@replit/river",
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
"version": "0.200.5",
"version": "0.201.0",
"type": "module",

@@ -40,4 +40,4 @@ "exports": {

"./test-util": {
"import": "./dist/util/testHelpers.js",
"require": "./dist/util/testHelpers.cjs"
"import": "./dist/testUtil/index.js",
"require": "./dist/testUtil/index.cjs"
}

@@ -44,0 +44,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc