@boxxy/server 0.1.3 → 0.1.4
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { WatchReport } from '@boxxy/dispatch';
|
|
1
2
|
import type { FakeForge } from '@boxxy/dispatch/test-utils/create-fake-forge';
|
|
2
3
|
import type { TestDispatch } from '@boxxy/dispatch/test-utils/create-test-dispatch';
|
|
3
|
-
import type {
|
|
4
|
+
import type { ClosableClaimStore } from '@boxxy/dispatch/test-utils/types';
|
|
5
|
+
import type { AttemptRow, CallerProof, Clock, PepysReader, PhaseName } from '@boxxy/model';
|
|
4
6
|
import type { FakeNotifier } from '@boxxy/model/test-utils/create-fake-notifier';
|
|
5
7
|
import type { FakePepysReader } from '@boxxy/model/test-utils/create-fake-pepys-reader';
|
|
6
8
|
import type { TickReport } from '../tick/run-tick.ts';
|
|
@@ -9,6 +11,8 @@ import type { FakeCallerProof } from './create-fake-caller-proof.ts';
|
|
|
9
11
|
export interface TestServerOptions {
|
|
10
12
|
readonly hasPepys?: boolean;
|
|
11
13
|
readonly makeCallerProof?: (clock: Clock) => Promise<CallerProof>;
|
|
14
|
+
readonly pepys?: PepysReader;
|
|
15
|
+
readonly store?: ClosableClaimStore;
|
|
12
16
|
}
|
|
13
17
|
export interface TestServer {
|
|
14
18
|
readonly dispatch: TestDispatch;
|
|
@@ -25,6 +29,7 @@ export interface TestServer {
|
|
|
25
29
|
readonly owner: (request: Request) => Promise<Response>;
|
|
26
30
|
readonly worker: (request: Request) => Promise<Response>;
|
|
27
31
|
readonly tick: () => Promise<TickReport>;
|
|
32
|
+
readonly watch: () => Promise<WatchReport>;
|
|
28
33
|
readonly seedStartedAttempt: (phase: PhaseName) => Promise<AttemptRow>;
|
|
29
34
|
}
|
|
30
35
|
export declare function createTestServer(options?: TestServerOptions): Promise<TestServer>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boxxy/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "The boxxy server: the API behind its three doors, and the runner loop",
|
|
5
5
|
"homepage": "https://github.com/zgeoff/boxxy/tree/main/apps/server#readme",
|
|
6
6
|
"bugs": "https://github.com/zgeoff/boxxy/issues",
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
"typecheck": "tsrs --noEmit"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@boxxy/caller-proof-imp": "0.1.
|
|
36
|
-
"@boxxy/closeout": "0.1.
|
|
37
|
-
"@boxxy/content-hash": "0.1.
|
|
38
|
-
"@boxxy/contract": "0.1.
|
|
39
|
-
"@boxxy/dispatch": "0.1.
|
|
40
|
-
"@boxxy/forge-github": "0.1.
|
|
41
|
-
"@boxxy/model": "0.1.
|
|
42
|
-
"@boxxy/notifier-atc": "0.1.
|
|
43
|
-
"@boxxy/pepys": "0.1.
|
|
44
|
-
"@boxxy/planning": "0.1.
|
|
45
|
-
"@boxxy/rules": "0.1.
|
|
46
|
-
"@boxxy/store-sqlite": "0.1.
|
|
47
|
-
"@boxxy/worker-atc": "0.1.
|
|
35
|
+
"@boxxy/caller-proof-imp": "0.1.4",
|
|
36
|
+
"@boxxy/closeout": "0.1.4",
|
|
37
|
+
"@boxxy/content-hash": "0.1.4",
|
|
38
|
+
"@boxxy/contract": "0.1.4",
|
|
39
|
+
"@boxxy/dispatch": "0.1.4",
|
|
40
|
+
"@boxxy/forge-github": "0.1.4",
|
|
41
|
+
"@boxxy/model": "0.1.4",
|
|
42
|
+
"@boxxy/notifier-atc": "0.1.4",
|
|
43
|
+
"@boxxy/pepys": "0.1.4",
|
|
44
|
+
"@boxxy/planning": "0.1.4",
|
|
45
|
+
"@boxxy/rules": "0.1.4",
|
|
46
|
+
"@boxxy/store-sqlite": "0.1.4",
|
|
47
|
+
"@boxxy/worker-atc": "0.1.4",
|
|
48
48
|
"@modelcontextprotocol/server": "2.4.0",
|
|
49
49
|
"@orpc/client": "2.0.0-beta.50",
|
|
50
50
|
"@orpc/mcp": "2.0.0-beta.50",
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { watchPullRequests } from '@boxxy/dispatch';
|
|
2
|
+
import type { WatchReport } from '@boxxy/dispatch';
|
|
1
3
|
import type { FakeForge } from '@boxxy/dispatch/test-utils/create-fake-forge';
|
|
2
4
|
import { createFakeForge } from '@boxxy/dispatch/test-utils/create-fake-forge';
|
|
3
5
|
import type { TestDispatch } from '@boxxy/dispatch/test-utils/create-test-dispatch';
|
|
4
6
|
import { createTestDispatch } from '@boxxy/dispatch/test-utils/create-test-dispatch';
|
|
7
|
+
import type { ClosableClaimStore } from '@boxxy/dispatch/test-utils/types';
|
|
5
8
|
import type {
|
|
6
9
|
AttemptId,
|
|
7
10
|
AttemptRow,
|
|
8
11
|
CallerProof,
|
|
9
12
|
Clock,
|
|
13
|
+
PepysReader,
|
|
10
14
|
PhaseName,
|
|
11
15
|
SessionReading,
|
|
12
16
|
} from '@boxxy/model';
|
|
@@ -33,6 +37,12 @@ export interface TestServerOptions {
|
|
|
33
37
|
// the server's real proof in place of the fake one, built on the test's clock; the fake that
|
|
34
38
|
// `callerProof` returns then proves nothing
|
|
35
39
|
readonly makeCallerProof?: (clock: Clock) => Promise<CallerProof>;
|
|
40
|
+
|
|
41
|
+
// the reader of a pepys under test in place of the fake one, which `pepys` then still returns
|
|
42
|
+
readonly pepys?: PepysReader;
|
|
43
|
+
|
|
44
|
+
// the memory store when left out
|
|
45
|
+
readonly store?: ClosableClaimStore;
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
export interface TestServer {
|
|
@@ -57,6 +67,9 @@ export interface TestServer {
|
|
|
57
67
|
// one runner tick at the clock's time
|
|
58
68
|
readonly tick: () => Promise<TickReport>;
|
|
59
69
|
|
|
70
|
+
// one pass of the pull request watch at the clock's time
|
|
71
|
+
readonly watch: () => Promise<WatchReport>;
|
|
72
|
+
|
|
60
73
|
// an item at the phase, claimed and started by the fake worker; its row carries the caller
|
|
61
74
|
// that its session reports
|
|
62
75
|
readonly seedStartedAttempt: (phase: PhaseName) => Promise<AttemptRow>;
|
|
@@ -65,7 +78,9 @@ export interface TestServer {
|
|
|
65
78
|
// The server's two listeners on the memory store, the fake worker, the fake clock, a fake pepys
|
|
66
79
|
// reader, a fake notifier and a fake forge, with the example rules. No port is opened.
|
|
67
80
|
export async function createTestServer(options: TestServerOptions = {}): Promise<TestServer> {
|
|
68
|
-
const
|
|
81
|
+
const dispatchOptions = options.store === undefined ? {} : { store: options.store };
|
|
82
|
+
|
|
83
|
+
const dispatch = await createTestDispatch(dispatchOptions);
|
|
69
84
|
|
|
70
85
|
const callerProof = createFakeCallerProof();
|
|
71
86
|
const pepys = createFakePepysReader();
|
|
@@ -95,7 +110,7 @@ export async function createTestServer(options: TestServerOptions = {}): Promise
|
|
|
95
110
|
? callerProof
|
|
96
111
|
: await options.makeCallerProof(dispatch.clock),
|
|
97
112
|
workerTokenDigest: buildTokenDigest(workerToken),
|
|
98
|
-
pepys: options.hasPepys === false ? null : pepys,
|
|
113
|
+
pepys: options.hasPepys === false ? null : (options.pepys ?? pepys),
|
|
99
114
|
forge,
|
|
100
115
|
outbox: createOffOutbox(dispatch.store, dispatch.clock),
|
|
101
116
|
readings,
|
|
@@ -129,6 +144,15 @@ export async function createTestServer(options: TestServerOptions = {}): Promise
|
|
|
129
144
|
readings,
|
|
130
145
|
log,
|
|
131
146
|
}),
|
|
147
|
+
watch: () =>
|
|
148
|
+
watchPullRequests({
|
|
149
|
+
store: dispatch.store,
|
|
150
|
+
forge,
|
|
151
|
+
rules: dispatch.rules(),
|
|
152
|
+
runner: dispatch.runner,
|
|
153
|
+
now: dispatch.clock.now(),
|
|
154
|
+
newId: dispatch.newId,
|
|
155
|
+
}),
|
|
132
156
|
seedStartedAttempt: async (phase) => {
|
|
133
157
|
await dispatch.seedItem({ phase });
|
|
134
158
|
|