@replit/river
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -30,2 +30,3 @@ export declare const EchoRequest: import("@sinclair/typebox").TObject<{ | ||
}; | ||
} & { | ||
echo: { | ||
@@ -32,0 +33,0 @@ input: import("@sinclair/typebox").TObject<{ |
@@ -6,3 +6,3 @@ import { TObject, Static } from '@sinclair/typebox'; | ||
export type ProcListing = Record<string, Procedure<object, ValidProcType, TObject, TObject>>; | ||
export interface Service<Name extends string = string, State extends object = object, Procs extends ProcListing = Record<string, any>> { | ||
export interface Service<Name extends string, State extends object, Procs extends ProcListing> { | ||
name: Name; | ||
@@ -12,7 +12,8 @@ state: State; | ||
} | ||
export declare function serializeService(s: Service): object; | ||
export type ProcHandler<S extends Service, ProcName extends keyof S['procedures']> = S['procedures'][ProcName]['handler']; | ||
export type ProcInput<S extends Service, ProcName extends keyof S['procedures']> = S['procedures'][ProcName]['input']; | ||
export type ProcOutput<S extends Service, ProcName extends keyof S['procedures']> = S['procedures'][ProcName]['output']; | ||
export type ProcType<S extends Service, ProcName extends keyof S['procedures']> = S['procedures'][ProcName]['type']; | ||
export type AnyService = Service<string, object, any>; | ||
export declare function serializeService(s: AnyService): object; | ||
export type ProcHandler<S extends AnyService, ProcName extends keyof S['procedures']> = S['procedures'][ProcName]['handler']; | ||
export type ProcInput<S extends AnyService, ProcName extends keyof S['procedures']> = S['procedures'][ProcName]['input']; | ||
export type ProcOutput<S extends AnyService, ProcName extends keyof S['procedures']> = S['procedures'][ProcName]['output']; | ||
export type ProcType<S extends AnyService, ProcName extends keyof S['procedures']> = S['procedures'][ProcName]['type']; | ||
export type Procedure<State extends object | unknown, Ty extends ValidProcType, I extends TObject, O extends TObject> = Ty extends 'rpc' ? { | ||
@@ -38,9 +39,7 @@ input: I; | ||
}>; | ||
defineProcedure<ProcName extends string, Ty extends ValidProcType, I extends TObject, O extends TObject, ProcEntry = { | ||
[k in ProcName]: Procedure<T['state'], Ty, I, O>; | ||
}>(procName: ProcName, procDef: Procedure<T['state'], Ty, I, O>): ServiceBuilder<{ | ||
defineProcedure<ProcName extends string, Ty extends ValidProcType, I extends TObject, O extends TObject>(procName: ProcName, procDef: Procedure<T['state'], Ty, I, O>): ServiceBuilder<{ | ||
name: T['name']; | ||
state: T['state']; | ||
procedures: { | ||
[Key in keyof (T['procedures'] & ProcEntry)]: (T['procedures'] & ProcEntry)[Key]; | ||
procedures: T['procedures'] & { | ||
[k in ProcName]: Procedure<T['state'], Ty, I, O>; | ||
}; | ||
@@ -47,0 +46,0 @@ }>; |
import { Transport } from '../transport/types'; | ||
import { ProcInput, ProcOutput, ProcType, Service } from './builder'; | ||
import { AnyService, ProcInput, ProcOutput, ProcType } from './builder'; | ||
import type { Pushable } from 'it-pushable'; | ||
import { Server } from './server'; | ||
import { Static } from '@sinclair/typebox'; | ||
type ServiceClient<Router extends Service> = { | ||
type ServiceClient<Router extends AnyService> = { | ||
[ProcName in keyof Router['procedures']]: ProcType<Router, ProcName> extends 'rpc' ? (input: Static<ProcInput<Router, ProcName>>) => Promise<Static<ProcOutput<Router, ProcName>>> : () => Promise<[ | ||
@@ -13,6 +13,6 @@ Pushable<Static<ProcInput<Router, ProcName>>>, | ||
}; | ||
export type ServerClient<Srv extends Server<Record<string, Service>>> = { | ||
export type ServerClient<Srv extends Server<Record<string, AnyService>>> = { | ||
[SvcName in keyof Srv['services']]: ServiceClient<Srv['services'][SvcName]>; | ||
}; | ||
export declare const createClient: <Srv extends Server<Record<string, Service<string, object, Record<string, any>>>>>(transport: Transport) => ServerClient<Srv>; | ||
export declare const createClient: <Srv extends Server<Record<string, AnyService>>>(transport: Transport) => ServerClient<Srv>; | ||
export {}; |
import { Transport } from '../transport/types'; | ||
import { Service } from './builder'; | ||
import { AnyService } from './builder'; | ||
export interface Server<Services> { | ||
@@ -7,2 +7,2 @@ services: Services; | ||
} | ||
export declare function createServer<Services extends Record<string, Service>>(transport: Transport, services: Services): Promise<Server<Services>>; | ||
export declare function createServer<Services extends Record<string, AnyService>>(transport: Transport, services: Services): Promise<Server<Services>>; |
{ | ||
"name": "@replit/river", | ||
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44316
43
1109