Fork Horse repository, listed by its owner. Publisher snapshot.

packages/forkhorse-stable/test/core-shapes.ts

Snapshot at 34e3175

Containing directory

3,067 bytes · typescriptView raw
1// Compiled against declarations freshly read from core by contracts.test.ts.
2// These aliases are test-only paths; the shipping package imports no core code.
3import type * as Core from "core-workflow";
4import type { Project, Activity } from "core-records";
5import type { CoreOperation } from "core-operations";
6import type * as Stable from "../src/index.ts";
7
8type Assert<T extends true> = T;
9type Same<A, B> = [A] extends [B] ? [B] extends [A] ? true : false : false;
10type ExpectedReview = Omit<Core.Review, "receiptGeneration" | "receipt" | "usageAtReview"> & {
11  receipt: Core.ReceiptSummary | null;
12  usageAtReview: Core.UsageSources;
13};
14type ExpectedState = Omit<Core.StateSnapshot, "reviews"> & { reviews: ExpectedReview[] };
15type RequestFor<K extends CoreOperation["kind"]> = Omit<Extract<CoreOperation, { kind: K }>, "kind">;
16
17export type CoreCompatibility = [
18  Assert<Same<Stable.Project, Project>>,
19  Assert<Same<Stable.Activity, Activity>>,
20  Assert<Same<Stable.Packet, Core.Packet>>,
21  Assert<Same<Stable.Claim, Core.Claim>>,
22  Assert<Same<Stable.RaceEntrant, Core.RaceEntrant>>,
23  Assert<Same<Stable.RaceState, Core.RaceState>>,
24  Assert<Same<Stable.ReceiptSummary, Core.ReceiptSummary>>,
25  Assert<Same<Stable.WorkItem, Core.WorkItem>>,
26  Assert<Same<Stable.Blocker, Core.Blocker>>,
27  Assert<Same<Stable.LedgerEntry, Core.LedgerEntry>>,
28  Assert<Same<Stable.StateSnapshot, ExpectedState>>,
29  Assert<Same<Stable.Review, ExpectedReview>>,
30  Assert<Same<keyof Stable.Review, keyof ExpectedReview>>,
31  Assert<Same<Stable.ContextResponse["myWork"], Core.WorkItem[]>>,
32  Assert<Same<Stable.ClaimResponse["claim"], (Core.Claim | Core.RaceEntrant) & { usage: Core.UsageSources }>>,
33  Assert<Same<Stable.RequestReviewResponse["review"], ExpectedReview>>,
34  Assert<Same<Stable.ReadReviewResponse["review"], ExpectedReview>>,
35  Assert<Same<Stable.ReadReviewResponse["packet"], Pick<Core.Packet, "id" | "title" | "goal" | "paths" | "acceptance">>>,
36  Assert<Same<Stable.ReadReviewResponse["promotion"], Pick<Core.LedgerEntry, "before" | "after" | "recordedAt" | "receiptDigest" | "requireReceipt"> | null>>,
37  Assert<Same<Stable.ReadReceiptsResponse["receipt"], Core.ReceiptSummary | null>>,
38  Assert<Same<Stable.ContextRequest, RequestFor<"state">>>,
39  Assert<Same<Stable.JoinRequest, RequestFor<"join">>>,
40  Assert<Same<Stable.ClaimRequest, RequestFor<"claim">>>,
41  Assert<Same<Stable.RequestReviewRequest, RequestFor<"review">>>,
42  Assert<Same<Exclude<Stable.ContributionVerb, Stable.V1Verb>, keyof Stable.ContributionContract>>,
43  Assert<Same<Extract<keyof Stable.JoinResponse, "token" | "apiToken" | "agentCredential">, never>>,
44];
45
46// v1 cannot accidentally enter a typed v0 adapter.
47// @ts-expect-error v1 shapes are deliberately undefined.
48export type NoV1Shape = Stable.ContributionRequest<"start_work">;
49// @ts-expect-error execution generation stays private to core.
50export type NoGeneration = Stable.Review["receiptGeneration"];
51// @ts-expect-error the join grant is never a public response field.
52export type NoJoinKey = Stable.JoinResponse["token"];
53