proposal.ts
This file
Path
packages/protocol/src/domain/proposal.ts
65 lines · 1.5 KiB · TypeScript
Last changed by
Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import { Schema } from "effect";
import { AskId, CommitSha, Handle, LaneName, ProjectName, ProposalId, RepoName, RepoPath,} from "../ids.ts";import { AtLeastOne } from "./common.ts";
export const ProposalState = Schema.Literals([ "open", "accepted", "declined", "expired",]);
export type ProposalState = typeof ProposalState.Type;
export const DraftNote = Schema.String.check(Schema.isMaxLength(2000));
export const DraftState = Schema.TaggedUnion({ Drafting: { note: Schema.optionalKey(DraftNote), round: AtLeastOne, startedAt: Schema.DateTimeUtcFromString, }, Failed: { attempts: AtLeastOne, model: Schema.NonEmptyString, refusal: Schema.NonEmptyString, round: AtLeastOne, }, Ready: { attempts: AtLeastOne, model: Schema.NonEmptyString, red: Schema.Struct({ lane: LaneName, signature: Schema.NonEmptyString }), round: AtLeastOne, },});
export type DraftState = typeof DraftState.Type;
export const Proposal = Schema.Struct({ draft: Schema.optionalKey(DraftState), expiresAt: Schema.DateTimeUtcFromString, files: Schema.Array(RepoPath), flags: Schema.optionalKey(AskId), id: ProposalId, openedAt: Schema.DateTimeUtcFromString, project: ProjectName, proposer: Handle, sealed: Schema.optionalKey( Schema.Struct({ fork: RepoName, head: CommitSha }) ), state: ProposalState, territory: Schema.optionalKey(Schema.NonEmptyString), want: Schema.NonEmptyString,});
export type Proposal = typeof Proposal.Type;