MCPcopy Create free account
hub / github.com/Effect-TS/effect / decodeJsonRpcRaw

Function decodeJsonRpcRaw

packages/effect/src/unstable/rpc/RpcSerialization.ts:247–271  ·  view source on GitHub ↗
(
  decoded: JsonRpcMessage | Array<JsonRpcMessage>,
  batches: Map<string | number, {
    readonly size: number
    readonly responses: Map<string | number, RpcMessage.FromServerEncoded>
  }>
)

Source from the content-addressed store, hash-verified

245 })
246
247function decodeJsonRpcRaw(
248 decoded: JsonRpcMessage | Array<JsonRpcMessage>,
249 batches: Map<string | number, {
250 readonly size: number
251 readonly responses: Map<string | number, RpcMessage.FromServerEncoded>
252 }>
253) {
254 if (Array.isArray(decoded)) {
255 const batch = {
256 size: 0,
257 responses: new Map<string, RpcMessage.FromServerEncoded>()
258 }
259 const messages: Array<RpcMessage.FromClientEncoded | RpcMessage.FromServerEncoded> = []
260 for (let i = 0; i < decoded.length; i++) {
261 const message = decodeJsonRpcMessage(decoded[i])
262 messages.push(message)
263 if (message._tag === "Request" && !message.isNotification) {
264 batch.size++
265 batches.set(message.id, batch)
266 }
267 }
268 return messages
269 }
270 return [decodeJsonRpcMessage(decoded)]
271}
272
273function decodeJsonRpcMessage(decoded: JsonRpcMessage): RpcMessage.FromClientEncoded | RpcMessage.FromServerEncoded {
274 if (Object.hasOwn(decoded, "method")) {

Callers 2

jsonRpcFunction · 0.85
ndJsonRpcFunction · 0.85

Calls 3

decodeJsonRpcMessageFunction · 0.85
pushMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected