t3-code-android-nightly/.repos/effect-smol/packages/effect/test/cluster/EntityProxy.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

25 lines
889 B
TypeScript

import { assert, describe, it } from "@effect/vitest"
import { PrimaryKey, Schema } from "effect"
import { Entity, EntityProxy } from "effect/cluster"
import { Rpc } from "effect/rpc"
describe("EntityProxy", () => {
it("constructs the original RPC payload", () => {
const Request = Rpc.make("Request", {
payload: { key: Schema.String },
primaryKey: ({ key }) => key
})
const entity = Entity.make("Entity", [Request])
const group = EntityProxy.toRpcGroup(entity)
const rpc = group.requests.get("Entity.Request")!
const payload = rpc.payloadSchema.make({
entityId: "entity-id",
payload: { key: "request-id" }
})
const originalPayload: unknown = payload.payload
const primaryKey = PrimaryKey.isPrimaryKey(originalPayload) ? PrimaryKey.value(originalPayload) : undefined
assert.strictEqual(primaryKey, "request-id")
})
})