Skip to content
Myr

envelope.ts

This file

Path

packages/protocol/src/envelope.ts

34 lines · 802 bytes · TypeScript

Last changed by

Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 1–34why, one step back
1import { Schema } from "effect";
2import type { Array } from "effect";34import { Refusal } from "./refusal.ts";56export const Envelope = <A extends Schema.Top>(data: A) =>7 Schema.Union([8 Schema.Struct({9 command: Schema.NonEmptyString,10 data,11 ok: Schema.Literal(true),12 v: Schema.Literal(1),13 }),14 Schema.Struct({15 command: Schema.NonEmptyString,16 ok: Schema.Literal(false),17 refusals: Schema.NonEmptyArray(Refusal),18 v: Schema.Literal(1),19 }),20 ]);2122export type Envelope<A> =23 | {24 readonly command: string;25 readonly data: A;26 readonly ok: true;27 readonly v: 1;28 }29 | {30 readonly command: string;31 readonly ok: false;32 readonly refusals: Array.NonEmptyReadonlyArray<Refusal>;33 readonly v: 1;34 };