MCPcopy Create free account
hub / github.com/effect-app/libs / rpcSchemas

Function rpcSchemas

repos/effect/packages/effect/src/unstable/rpc/RpcClient.ts:782–798  ·  view source on GitHub ↗
(rpc: Rpc.AnyWithProps)

Source from the content-addressed store, hash-verified

780 (chunk: ReadonlyArray<unknown>) => Effect.Effect<NonEmptyReadonlyArray<any>, Schema.SchemaError, unknown>
781 >
782 readonly encodePayload: (payload: any) => Effect.Effect<any, Schema.SchemaError, unknown>
783 readonly decodeExit: (encoded: unknown) => Effect.Effect<Exit.Exit<any, any>, Schema.SchemaError, unknown>
784}
785const rpcSchemasCache = new WeakMap<Rpc.AnyWithProps, RpcSchemas>()
786const rpcSchemas = (rpc: Rpc.AnyWithProps) => {
787 let entry = rpcSchemasCache.get(rpc)
788 if (entry !== undefined) {
789 return entry
790 }
791 const streamSchemas = RpcSchema.getStreamSchemas(rpc.successSchema)
792 entry = {
793 decodeChunk: Option.map(
794 streamSchemas,
795 (streamSchemas) => Schema.decodeUnknownEffect(Schema.toCodecJson(Schema.NonEmptyArray(streamSchemas.success)))
796 ),
797 encodePayload: Schema.encodeEffect(Schema.toCodecJson(rpc.payloadSchema)),
798 decodeExit: Schema.decodeUnknownEffect(Schema.toCodecJson(Rpc.exitSchema(rpc as any)))
799 }
800 rpcSchemasCache.set(rpc, entry)
801 return entry

Callers 1

onFromClientFunction · 0.85

Calls 4

getMethod · 0.65
mapMethod · 0.65
setMethod · 0.65
toCodecJsonMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…