@chipschat/conformance 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +34 -2
- package/dist/checks.d.ts +29 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +133 -0
- package/dist/checks.js.map +1 -0
- package/dist/exchange.d.ts +30 -0
- package/dist/exchange.d.ts.map +1 -0
- package/dist/exchange.js +102 -0
- package/dist/exchange.js.map +1 -0
- package/dist/fake-chips.d.ts +130 -0
- package/dist/fake-chips.d.ts.map +1 -0
- package/dist/fake-chips.js +1642 -0
- package/dist/fake-chips.js.map +1 -0
- package/dist/fake-join.d.ts +56 -0
- package/dist/fake-join.d.ts.map +1 -0
- package/dist/fake-join.js +181 -0
- package/dist/fake-join.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/project.d.ts +39 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +254 -0
- package/dist/project.js.map +1 -0
- package/dist/report.d.ts +65 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +142 -0
- package/dist/report.js.map +1 -0
- package/dist/room-files.d.ts +54 -0
- package/dist/room-files.d.ts.map +1 -0
- package/dist/room-files.js +144 -0
- package/dist/room-files.js.map +1 -0
- package/dist/scenario.d.ts +41 -0
- package/dist/scenario.d.ts.map +1 -0
- package/dist/scenario.js +414 -0
- package/dist/scenario.js.map +1 -0
- package/dist/settings.d.ts +60 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +142 -0
- package/dist/settings.js.map +1 -0
- package/dist/spend.d.ts +20 -0
- package/dist/spend.d.ts.map +1 -0
- package/dist/spend.js +50 -0
- package/dist/spend.js.map +1 -0
- package/dist/subject.d.ts +55 -0
- package/dist/subject.d.ts.map +1 -0
- package/dist/subject.js +22 -0
- package/dist/subject.js.map +1 -0
- package/dist/waiting.d.ts +12 -0
- package/dist/waiting.d.ts.map +1 -0
- package/dist/waiting.js +30 -0
- package/dist/waiting.js.map +1 -0
- package/dist/workspace.d.ts +893 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +3160 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +38 -3
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A fake Chips: the wire an adapter speaks, on a real port, with the log and the rules of
|
|
3
|
+
* `workspace.ts` behind it. HTTP for what a harness says — `POST /v1/harnesses/:id/events`,
|
|
4
|
+
* `POST /v1/runs/:id/events`, the space door, uploads, the approval long poll — and `/v1/ws`
|
|
5
|
+
* for what it hears, with the handshake, the subscription, the replay and the acks the real
|
|
6
|
+
* server gives. The person's side has no port: the kit plays it by calling `say`, `decide`,
|
|
7
|
+
* `answer` and `askForSpace` directly, and reads the log the same way.
|
|
8
|
+
*
|
|
9
|
+
* The shapes here are the real routes' shapes, field for field, because an adapter passing
|
|
10
|
+
* against a stand-in that is looser than the server would learn nothing. Where the real server
|
|
11
|
+
* would do something this one cannot — sniff an upload's bytes, sign an attachment URL — the
|
|
12
|
+
* answer is honest about it: the mime type comes from the filename, the signature is a word.
|
|
13
|
+
*/
|
|
14
|
+
import { type IdGenerator, type JobRun } from "@chipschat/protocol";
|
|
15
|
+
import { type FakeJoinView } from "./fake-join.js";
|
|
16
|
+
import { FakeSettings, type SettingKind } from "./settings.js";
|
|
17
|
+
import type { ChipsAddress } from "./subject.js";
|
|
18
|
+
import { type StoredEvent, Workspace } from "./workspace.js";
|
|
19
|
+
export interface FakeChipsOptions {
|
|
20
|
+
/** Where to listen. `0`, the default, takes any free port. */
|
|
21
|
+
readonly port?: number | undefined;
|
|
22
|
+
readonly host?: string | undefined;
|
|
23
|
+
readonly harnessName?: string | undefined;
|
|
24
|
+
readonly ownerName?: string | undefined;
|
|
25
|
+
readonly now?: (() => Date) | undefined;
|
|
26
|
+
readonly ids?: IdGenerator | undefined;
|
|
27
|
+
readonly version?: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* What the harness declares, as its registration would (ADR 0046). `new_spaces` lets the person
|
|
30
|
+
* ask it for a room; nothing is declared otherwise.
|
|
31
|
+
*/
|
|
32
|
+
readonly capabilities?: readonly string[] | undefined;
|
|
33
|
+
}
|
|
34
|
+
export interface DecideOptions {
|
|
35
|
+
readonly reason?: string | undefined;
|
|
36
|
+
readonly scope?: "once" | "session" | "always" | undefined;
|
|
37
|
+
readonly updatedInput?: unknown;
|
|
38
|
+
}
|
|
39
|
+
/** The harness saying how it is (ADR 0083): fine, or in trouble and why. */
|
|
40
|
+
export interface HarnessStatus {
|
|
41
|
+
readonly state: "ok" | "trouble";
|
|
42
|
+
readonly reason?: string | undefined;
|
|
43
|
+
readonly at: string;
|
|
44
|
+
}
|
|
45
|
+
export interface FakeChips {
|
|
46
|
+
readonly address: ChipsAddress;
|
|
47
|
+
readonly workspace: Workspace;
|
|
48
|
+
/**
|
|
49
|
+
* The owner says something. In the direct space unless another is named, and as a reply to the
|
|
50
|
+
* message `replyTo` names when one is given (ADR 0219).
|
|
51
|
+
*/
|
|
52
|
+
readonly say: (text: string, spaceId?: string, options?: {
|
|
53
|
+
readonly replyTo?: string;
|
|
54
|
+
}) => Promise<StoredEvent>;
|
|
55
|
+
/** The owner answers a card. */
|
|
56
|
+
readonly decide: (approvalId: string, decision: "approved" | "edited" | "denied", options?: DecideOptions) => Promise<StoredEvent>;
|
|
57
|
+
/** The owner answers a question: the choices given, or each question's default or first option. */
|
|
58
|
+
readonly answer: (askId: string, choices?: Readonly<Record<string, readonly string[]>>) => Promise<StoredEvent>;
|
|
59
|
+
/**
|
|
60
|
+
* The owner asks the harness for a new room, as the phone does on the first send: the room,
|
|
61
|
+
* asked of the harness, the harness added to it, and the words. For a harness that declares
|
|
62
|
+
* `new_spaces`; the door refuses it for any other, and so does this.
|
|
63
|
+
*/
|
|
64
|
+
readonly askForSpace: (text: string) => Promise<{
|
|
65
|
+
spaceId: string;
|
|
66
|
+
message: StoredEvent;
|
|
67
|
+
}>;
|
|
68
|
+
/** A group room of the owner's, with nobody else in it yet. */
|
|
69
|
+
readonly openRoom: (title: string) => Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* The owner asks for a copy of one of the harness's agents in a room (ADR 0087, Fork), as
|
|
72
|
+
* `POST /v1/agents/:id/fork` does. For a harness that declares `forks`; refused for any other.
|
|
73
|
+
*/
|
|
74
|
+
readonly askForFork: (agentId: string, spaceId: string) => Promise<{
|
|
75
|
+
forkId: string;
|
|
76
|
+
asked: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* The owner asks the harness for a new agent in a room (ADR 0108), as
|
|
80
|
+
* `POST /v1/spaces/:id/agents` does. For a harness that declares `new_agents`; refused for any
|
|
81
|
+
* other.
|
|
82
|
+
*/
|
|
83
|
+
readonly askForAgent: (spaceId: string, name?: string) => Promise<{
|
|
84
|
+
askId: string;
|
|
85
|
+
name: string;
|
|
86
|
+
}>;
|
|
87
|
+
/** Any event, as the owner. A refusal throws, because the person's side is the kit's own. */
|
|
88
|
+
readonly asOwner: (event: Record<string, unknown>) => Promise<StoredEvent>;
|
|
89
|
+
/**
|
|
90
|
+
* Join requests (ADR 0122), the owner's side: a link made, allowed already with what it may do;
|
|
91
|
+
* the oldest request waiting allowed, with what is granted of what it asked, or refused; and
|
|
92
|
+
* every request so far. Whatever joins is handed this fake's harness.
|
|
93
|
+
*/
|
|
94
|
+
readonly makeJoinLink: (capabilities?: readonly string[]) => string;
|
|
95
|
+
readonly allowJoin: (capabilities?: readonly string[]) => FakeJoinView;
|
|
96
|
+
readonly denyJoin: () => FakeJoinView;
|
|
97
|
+
readonly joinRequests: () => FakeJoinView[];
|
|
98
|
+
/** The first event that matches, in the log already or arriving within the time. */
|
|
99
|
+
readonly waitFor: <T>(match: (event: StoredEvent) => T | undefined, timeoutMs: number) => Promise<T>;
|
|
100
|
+
/** How many sockets are subscribed right now. */
|
|
101
|
+
readonly connections: () => number;
|
|
102
|
+
/** How many `hello`s the harness's sockets have said, so a reconnect is seen. */
|
|
103
|
+
readonly hellos: () => number;
|
|
104
|
+
/** The harness's settings copies and the answers they carried (ADRs 0134, 0140, 0143, 0146). */
|
|
105
|
+
readonly settings: FakeSettings;
|
|
106
|
+
/** The runs of its own jobs the harness posted, a run posted again in place (ADR 0252). */
|
|
107
|
+
readonly jobRuns: () => readonly JobRun[];
|
|
108
|
+
/**
|
|
109
|
+
* The owner changes a setting of an agent's (or, for `harness-context`, of the harness's) to what
|
|
110
|
+
* its copy says now, as the agent's page would: the frame, sent to every socket that said the
|
|
111
|
+
* kind's word in its `hello`, and how many heard it. Nothing when there is no copy, or nothing in
|
|
112
|
+
* it to change.
|
|
113
|
+
*/
|
|
114
|
+
readonly askToChange: (kind: SettingKind, id: string) => {
|
|
115
|
+
readonly frame: Record<string, unknown>;
|
|
116
|
+
readonly heard: number;
|
|
117
|
+
} | undefined;
|
|
118
|
+
/** The owner asks the harness to restart (ADR 0094): how many sockets that said `restart` heard. */
|
|
119
|
+
readonly askToRestart: () => number;
|
|
120
|
+
/** What the harness has said of how it is (`PUT /v1/harnesses/:id/status`), oldest first. */
|
|
121
|
+
readonly statuses: () => readonly HarnessStatus[];
|
|
122
|
+
/**
|
|
123
|
+
* Has the harness shown up at all: a socket subscribed, or any call made with its token. A
|
|
124
|
+
* read counts, because a harness in hooks mode polls before it has anything to say.
|
|
125
|
+
*/
|
|
126
|
+
readonly heard: () => boolean;
|
|
127
|
+
readonly close: () => Promise<void>;
|
|
128
|
+
}
|
|
129
|
+
export declare function startFakeChips(options?: FakeChipsOptions): Promise<FakeChips>;
|
|
130
|
+
//# sourceMappingURL=fake-chips.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-chips.d.ts","sourceRoot":"","sources":["../src/fake-chips.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EAUL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