@leitwerk-dev/test-support 0.2.0 → 0.2.1
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/dist/{chunk-7I4OCTF3.js → chunk-2PCDTYVH.js} +7 -2
- package/dist/chunk-2PCDTYVH.js.map +1 -0
- package/dist/{chunk-KPSK7EMY.js → chunk-5BZSJ4OO.js} +22 -157
- package/dist/chunk-5BZSJ4OO.js.map +1 -0
- package/dist/{chunk-2IICIB6D.js → chunk-ECAWLVYB.js} +38 -4
- package/dist/chunk-ECAWLVYB.js.map +1 -0
- package/dist/{chunk-JUH3LUYK.js → chunk-EXHTWQAE.js} +5 -1
- package/dist/chunk-EXHTWQAE.js.map +1 -0
- package/dist/compact-process-detail-fixture.d.ts +3 -0
- package/dist/compact-process-detail-fixture.d.ts.map +1 -1
- package/dist/fakes/fake-git-ops.d.ts +12 -0
- package/dist/fakes/fake-git-ops.d.ts.map +1 -1
- package/dist/fakes/fake-llm.d.ts +11 -0
- package/dist/fakes/fake-llm.d.ts.map +1 -1
- package/dist/fakes/index.d.ts +1 -1
- package/dist/fakes/index.d.ts.map +1 -1
- package/dist/fakes/index.js +105 -4
- package/dist/fakes/index.js.map +1 -1
- package/dist/fixtures.js +104 -2
- package/dist/fixtures.js.map +1 -1
- package/dist/http-launch.d.ts +2 -1
- package/dist/http-launch.d.ts.map +1 -1
- package/dist/index.d.ts +23 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -53
- package/dist/index.js.map +1 -1
- package/dist/integration-harness.d.ts +36 -1
- package/dist/integration-harness.d.ts.map +1 -1
- package/dist/integration.d.ts +2 -3
- package/dist/integration.d.ts.map +1 -1
- package/dist/integration.js +131 -13
- package/dist/integration.js.map +1 -1
- package/dist/local-git.d.ts +105 -8
- package/dist/local-git.d.ts.map +1 -1
- package/dist/local-git.js +155 -24
- package/dist/local-git.js.map +1 -1
- package/dist/model-provider-fixtures.d.ts +9 -1
- package/dist/model-provider-fixtures.d.ts.map +1 -1
- package/dist/polling.d.ts +1 -0
- package/dist/polling.d.ts.map +1 -1
- package/dist/process-driver.d.ts +5 -1
- package/dist/process-driver.d.ts.map +1 -1
- package/dist/question-fixtures.d.ts +2 -0
- package/dist/question-fixtures.d.ts.map +1 -1
- package/dist/server-extension-test-harness.d.ts +43 -3
- package/dist/server-extension-test-harness.d.ts.map +1 -1
- package/dist/stub-worker-entry.js +1 -1
- package/dist/test-diagnostics.d.ts +14 -0
- package/dist/test-diagnostics.d.ts.map +1 -0
- package/dist/worker-testing/in-process-worker-spawn.d.ts +17 -1
- package/dist/worker-testing/in-process-worker-spawn.d.ts.map +1 -1
- package/dist/worker-testing/index.d.ts +6 -7
- package/dist/worker-testing/index.d.ts.map +1 -1
- package/dist/worker-testing/index.js +32 -22
- package/dist/worker-testing/index.js.map +1 -1
- package/dist/worker-testing/schema-driven-stub-pi.d.ts +5 -0
- package/dist/worker-testing/schema-driven-stub-pi.d.ts.map +1 -1
- package/dist/worker-testing/stub-pi-controls.d.ts +4 -0
- package/dist/worker-testing/stub-pi-controls.d.ts.map +1 -1
- package/dist/worker-testing/stub-pi-tree-handle.d.ts +76 -2
- package/dist/worker-testing/stub-pi-tree-handle.d.ts.map +1 -1
- package/dist/worker-testing/worker-runtime-harness.d.ts +37 -2
- package/dist/worker-testing/worker-runtime-harness.d.ts.map +1 -1
- package/dist/worker-testing/worker-start-payload.d.ts +17 -1
- package/dist/worker-testing/worker-start-payload.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/compact-process-detail-fixture.ts +9 -1
- package/src/fakes/fake-git-ops.ts +12 -0
- package/src/fakes/fake-llm.ts +11 -0
- package/src/fakes/index.ts +1 -1
- package/src/http-launch.ts +2 -1
- package/src/index.ts +28 -42
- package/src/integration-harness.ts +100 -9
- package/src/integration.ts +2 -9
- package/src/local-git.ts +195 -45
- package/src/model-provider-fixtures.ts +15 -2
- package/src/polling.ts +1 -0
- package/src/process-driver.ts +7 -1
- package/src/question-fixtures.ts +2 -0
- package/src/server-extension-test-harness.ts +64 -7
- package/src/test-diagnostics.ts +69 -0
- package/src/worker-testing/in-process-worker-spawn.ts +29 -2
- package/src/worker-testing/index.ts +4 -30
- package/src/worker-testing/schema-driven-stub-pi.ts +8 -1
- package/src/worker-testing/stub-pi-controls.ts +4 -0
- package/src/worker-testing/stub-pi-tree-handle.ts +82 -3
- package/src/worker-testing/worker-runtime-harness.ts +57 -6
- package/src/worker-testing/worker-start-payload.ts +17 -1
- package/dist/chunk-2IICIB6D.js.map +0 -1
- package/dist/chunk-3MQO3NCX.js +0 -15
- package/dist/chunk-3MQO3NCX.js.map +0 -1
- package/dist/chunk-7I4OCTF3.js.map +0 -1
- package/dist/chunk-7ZK5QRGP.js +0 -98
- package/dist/chunk-7ZK5QRGP.js.map +0 -1
- package/dist/chunk-JUH3LUYK.js.map +0 -1
- package/dist/chunk-KPSK7EMY.js.map +0 -1
- package/dist/chunk-MV4W6NOO.js +0 -105
- package/dist/chunk-MV4W6NOO.js.map +0 -1
- package/dist/test-app.d.ts +0 -23
- package/dist/test-app.d.ts.map +0 -1
- package/src/test-app.ts +0 -82
package/dist/local-git.js
CHANGED
|
@@ -10,6 +10,74 @@ import {
|
|
|
10
10
|
writeFileSync
|
|
11
11
|
} from "fs";
|
|
12
12
|
import path from "path";
|
|
13
|
+
|
|
14
|
+
// src/test-diagnostics.ts
|
|
15
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
16
|
+
import { threadId } from "worker_threads";
|
|
17
|
+
var active = new AsyncLocalStorage();
|
|
18
|
+
function createTestDiagnostics(label) {
|
|
19
|
+
const started = performance.now();
|
|
20
|
+
const events = [];
|
|
21
|
+
let dropped = 0;
|
|
22
|
+
const mark = (stage, details = {}) => {
|
|
23
|
+
if (events.length === 512) {
|
|
24
|
+
events.shift();
|
|
25
|
+
dropped++;
|
|
26
|
+
}
|
|
27
|
+
events.push({
|
|
28
|
+
...details,
|
|
29
|
+
stage,
|
|
30
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
31
|
+
elapsedMs: Math.round(performance.now() - started)
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const diagnostics = {
|
|
35
|
+
/** @internal */
|
|
36
|
+
mark,
|
|
37
|
+
/** @internal */
|
|
38
|
+
run(fn) {
|
|
39
|
+
return active.run(diagnostics, fn);
|
|
40
|
+
},
|
|
41
|
+
/** @internal */
|
|
42
|
+
format() {
|
|
43
|
+
return JSON.stringify({ label, pid: process.pid, threadId, dropped, events }, null, 2);
|
|
44
|
+
},
|
|
45
|
+
/** @internal */
|
|
46
|
+
report() {
|
|
47
|
+
mark("diagnostics.report");
|
|
48
|
+
console.error(diagnostics.format());
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
mark("test.start");
|
|
52
|
+
return diagnostics;
|
|
53
|
+
}
|
|
54
|
+
function traceTestSubprocess(operation, run) {
|
|
55
|
+
const trace = active.getStore();
|
|
56
|
+
if (!trace) return run();
|
|
57
|
+
const started = performance.now();
|
|
58
|
+
trace.mark("subprocess.start", { operation });
|
|
59
|
+
try {
|
|
60
|
+
const result = run();
|
|
61
|
+
trace.mark("subprocess.exit", {
|
|
62
|
+
operation,
|
|
63
|
+
status: 0,
|
|
64
|
+
durationMs: Math.round(performance.now() - started)
|
|
65
|
+
});
|
|
66
|
+
return result;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
const details = error;
|
|
69
|
+
trace.mark("subprocess.exit", {
|
|
70
|
+
operation,
|
|
71
|
+
durationMs: Math.round(performance.now() - started),
|
|
72
|
+
status: typeof details?.status === "number" ? details.status : null,
|
|
73
|
+
signal: typeof details?.signal === "string" ? details.signal : null,
|
|
74
|
+
code: typeof details?.code === "string" ? details.code : null
|
|
75
|
+
});
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/local-git.ts
|
|
13
81
|
function localPath(root, relative) {
|
|
14
82
|
if (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
15
83
|
throw new Error("Local provider storage must not contain symlinks");
|
|
@@ -41,6 +109,7 @@ function writeLocalJson(root, file, value) {
|
|
|
41
109
|
renameSync(temporary, target);
|
|
42
110
|
}
|
|
43
111
|
var LocalProviderStore = class {
|
|
112
|
+
/** @public */
|
|
44
113
|
constructor(options, file, initial) {
|
|
45
114
|
this.options = options;
|
|
46
115
|
this.file = file;
|
|
@@ -49,32 +118,49 @@ var LocalProviderStore = class {
|
|
|
49
118
|
}
|
|
50
119
|
options;
|
|
51
120
|
file;
|
|
121
|
+
/** @public */
|
|
52
122
|
git;
|
|
123
|
+
/** @public */
|
|
53
124
|
state;
|
|
125
|
+
/** @public */
|
|
54
126
|
save() {
|
|
55
127
|
writeLocalJson(this.options.root, this.file, this.state);
|
|
56
128
|
}
|
|
129
|
+
/** @internal */
|
|
57
130
|
id() {
|
|
58
131
|
this.state.sequence = Math.max(this.state.sequence + 1, this.options.nextId?.() ?? 0);
|
|
59
132
|
return this.state.sequence;
|
|
60
133
|
}
|
|
134
|
+
/** @internal */
|
|
61
135
|
timestamp() {
|
|
62
136
|
return new Date(this.options.now?.() ?? Date.now()).toISOString();
|
|
63
137
|
}
|
|
64
138
|
};
|
|
65
139
|
var LocalForgeStore = class extends LocalProviderStore {
|
|
140
|
+
/** @public */
|
|
66
141
|
newRepository(seed) {
|
|
67
142
|
const { bare, branch } = this.git.seed(seed);
|
|
68
143
|
return {
|
|
144
|
+
/** @public */
|
|
69
145
|
id: this.id(),
|
|
70
|
-
|
|
146
|
+
/** @public */
|
|
147
|
+
owner: {
|
|
148
|
+
/** @internal */
|
|
149
|
+
login: seed.owner
|
|
150
|
+
},
|
|
151
|
+
/** @public */
|
|
71
152
|
name: seed.name,
|
|
153
|
+
/** @public */
|
|
72
154
|
full_name: `${seed.owner}/${seed.name}`,
|
|
155
|
+
/** @public */
|
|
73
156
|
ssh_url: bare,
|
|
157
|
+
/** @public */
|
|
74
158
|
html_url: `${this.options.baseUrl}/__local`,
|
|
159
|
+
/** @public */
|
|
75
160
|
default_branch: branch
|
|
76
161
|
};
|
|
77
162
|
}
|
|
163
|
+
/** @internal */
|
|
78
164
|
pullRequestClient(repo, missing = "Unknown local pull request") {
|
|
79
165
|
const pull = (owner, name, number) => {
|
|
80
166
|
const pr = repo(owner, name).pulls.find((p) => p.number === number);
|
|
@@ -82,11 +168,14 @@ var LocalForgeStore = class extends LocalProviderStore {
|
|
|
82
168
|
return pr;
|
|
83
169
|
};
|
|
84
170
|
return {
|
|
171
|
+
/** @internal */
|
|
85
172
|
getPullRequest: async (owner, name, number) => this.refresh(repo(owner, name), pull(owner, name, number)),
|
|
173
|
+
/** @internal */
|
|
86
174
|
listPullRequests: async (owner, name, state = "open") => {
|
|
87
175
|
const r = repo(owner, name);
|
|
88
176
|
return r.pulls.filter((p) => state === "all" || p.state === state).map((p) => this.refresh(r, p));
|
|
89
177
|
},
|
|
178
|
+
/** @internal */
|
|
90
179
|
updatePullRequest: async (owner, name, number, patch) => {
|
|
91
180
|
const pr = pull(owner, name, number);
|
|
92
181
|
for (const key of ["title", "body", "state"])
|
|
@@ -96,6 +185,7 @@ var LocalForgeStore = class extends LocalProviderStore {
|
|
|
96
185
|
}
|
|
97
186
|
};
|
|
98
187
|
}
|
|
188
|
+
/** @public */
|
|
99
189
|
refresh(repo, pr) {
|
|
100
190
|
if (pr.state === "open") {
|
|
101
191
|
const { headSha, baseSha, ...mergeability } = this.git.mergeability(
|
|
@@ -109,6 +199,7 @@ var LocalForgeStore = class extends LocalProviderStore {
|
|
|
109
199
|
}
|
|
110
200
|
return structuredClone(pr);
|
|
111
201
|
}
|
|
202
|
+
/** @public */
|
|
112
203
|
merge(repo, number) {
|
|
113
204
|
const pr = repo.pulls.find((p) => p.number === number);
|
|
114
205
|
if (!pr || pr.state !== "open") throw new Error("Pull request is not open");
|
|
@@ -119,6 +210,7 @@ var LocalForgeStore = class extends LocalProviderStore {
|
|
|
119
210
|
this.save();
|
|
120
211
|
return structuredClone(pr);
|
|
121
212
|
}
|
|
213
|
+
/** @public */
|
|
122
214
|
addFeedback(repo, number, input) {
|
|
123
215
|
if (!repo.pulls.some((p) => p.number === number)) throw new Error("Unknown PR");
|
|
124
216
|
const value = { ...input, id: this.id(), createdAt: this.timestamp() };
|
|
@@ -127,30 +219,59 @@ var LocalForgeStore = class extends LocalProviderStore {
|
|
|
127
219
|
this.save();
|
|
128
220
|
return value;
|
|
129
221
|
}
|
|
222
|
+
/** @public */
|
|
130
223
|
newComment(body) {
|
|
131
224
|
return {
|
|
225
|
+
/** @internal */
|
|
132
226
|
id: this.id(),
|
|
227
|
+
/** @internal */
|
|
133
228
|
body,
|
|
134
|
-
|
|
229
|
+
/** @public */
|
|
230
|
+
user: {
|
|
231
|
+
/** @public */
|
|
232
|
+
login: "leitwerk-bot"
|
|
233
|
+
},
|
|
234
|
+
/** @internal */
|
|
135
235
|
created_at: this.timestamp()
|
|
136
236
|
};
|
|
137
237
|
}
|
|
238
|
+
/** @internal */
|
|
138
239
|
newPullRequest(repo, input) {
|
|
139
240
|
const number = this.id();
|
|
140
241
|
return {
|
|
242
|
+
/** @internal */
|
|
141
243
|
number,
|
|
244
|
+
/** @internal */
|
|
142
245
|
title: input.title,
|
|
246
|
+
/** @internal */
|
|
143
247
|
body: input.body,
|
|
248
|
+
/** @internal */
|
|
144
249
|
state: "open",
|
|
250
|
+
/** @internal */
|
|
145
251
|
merged: false,
|
|
252
|
+
/** @internal */
|
|
146
253
|
merge_commit_sha: null,
|
|
254
|
+
/** @internal */
|
|
147
255
|
html_url: `${this.options.baseUrl}/__local#pr-${number}`,
|
|
148
|
-
|
|
149
|
-
|
|
256
|
+
/** @internal */
|
|
257
|
+
head: {
|
|
258
|
+
/** @internal */
|
|
259
|
+
ref: input.head,
|
|
260
|
+
/** @internal */
|
|
261
|
+
sha: this.git.head(repo.repository.ssh_url, input.head)
|
|
262
|
+
},
|
|
263
|
+
/** @internal */
|
|
264
|
+
base: {
|
|
265
|
+
/** @internal */
|
|
266
|
+
ref: input.base,
|
|
267
|
+
/** @internal */
|
|
268
|
+
sha: this.git.head(repo.repository.ssh_url, input.base)
|
|
269
|
+
}
|
|
150
270
|
};
|
|
151
271
|
}
|
|
152
272
|
};
|
|
153
273
|
var LocalGit = class {
|
|
274
|
+
/** @public */
|
|
154
275
|
constructor(root) {
|
|
155
276
|
this.root = root;
|
|
156
277
|
if (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
@@ -158,6 +279,7 @@ var LocalGit = class {
|
|
|
158
279
|
mkdirSync(root, { recursive: true, mode: 448 });
|
|
159
280
|
}
|
|
160
281
|
root;
|
|
282
|
+
/** @public */
|
|
161
283
|
run(directory, args) {
|
|
162
284
|
const base = realpathSync(this.root);
|
|
163
285
|
const directoryPath = path.resolve(directory);
|
|
@@ -166,32 +288,37 @@ var LocalGit = class {
|
|
|
166
288
|
directoryPath
|
|
167
289
|
);
|
|
168
290
|
const cwd = localPath(this.root, relative);
|
|
169
|
-
return
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
291
|
+
return traceTestSubprocess(
|
|
292
|
+
`git ${args[0] ?? ""}`,
|
|
293
|
+
() => execFileSync(
|
|
294
|
+
"git",
|
|
295
|
+
["-c", "protocol.file.allow=always", "-c", "core.hooksPath=/dev/null", ...args],
|
|
296
|
+
{
|
|
297
|
+
cwd,
|
|
298
|
+
encoding: "utf8",
|
|
299
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
300
|
+
env: {
|
|
301
|
+
PATH: process.env.PATH,
|
|
302
|
+
HOME: this.root,
|
|
303
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
304
|
+
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
305
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
306
|
+
GIT_ALLOW_PROTOCOL: "file",
|
|
307
|
+
GIT_AUTHOR_NAME: "Sandbox Developer",
|
|
308
|
+
GIT_AUTHOR_EMAIL: "developer@sandbox.invalid",
|
|
309
|
+
GIT_COMMITTER_NAME: "Sandbox Developer",
|
|
310
|
+
GIT_COMMITTER_EMAIL: "developer@sandbox.invalid"
|
|
311
|
+
}
|
|
187
312
|
}
|
|
188
|
-
|
|
189
|
-
)
|
|
313
|
+
).trim()
|
|
314
|
+
);
|
|
190
315
|
}
|
|
316
|
+
/** @public */
|
|
191
317
|
head(directory, ref) {
|
|
192
318
|
if (!/^[a-zA-Z0-9_./-]+$/.test(ref) || ref.startsWith("-")) throw new Error("Invalid Git ref");
|
|
193
319
|
return this.run(directory, ["rev-parse", "--verify", `${ref}^{commit}`]);
|
|
194
320
|
}
|
|
321
|
+
/** @internal */
|
|
195
322
|
isAncestor(directory, ancestor, descendant) {
|
|
196
323
|
return this.isAncestorCommit(
|
|
197
324
|
directory,
|
|
@@ -209,6 +336,7 @@ var LocalGit = class {
|
|
|
209
336
|
throw error;
|
|
210
337
|
}
|
|
211
338
|
}
|
|
339
|
+
/** @internal */
|
|
212
340
|
mergeability(directory, head, base) {
|
|
213
341
|
const headSha = this.head(directory, head), baseSha = this.head(directory, base);
|
|
214
342
|
const revisions = { headSha, baseSha };
|
|
@@ -223,6 +351,7 @@ var LocalGit = class {
|
|
|
223
351
|
}
|
|
224
352
|
return { ...revisions, mergeable: true, mergeable_state: "behind" };
|
|
225
353
|
}
|
|
354
|
+
/** @internal */
|
|
226
355
|
merge(directory, head, base) {
|
|
227
356
|
const h = this.head(directory, head), b = this.head(directory, base);
|
|
228
357
|
let commit = h;
|
|
@@ -242,6 +371,7 @@ var LocalGit = class {
|
|
|
242
371
|
this.run(directory, ["update-ref", `refs/heads/${base}`, commit, b]);
|
|
243
372
|
return commit;
|
|
244
373
|
}
|
|
374
|
+
/** @internal */
|
|
245
375
|
seed(seed) {
|
|
246
376
|
for (const value of [seed.owner, seed.name, seed.directoryName ?? seed.name])
|
|
247
377
|
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(value))
|
|
@@ -290,6 +420,7 @@ export {
|
|
|
290
420
|
LocalForgeStore,
|
|
291
421
|
LocalGit,
|
|
292
422
|
LocalProviderStore,
|
|
423
|
+
createTestDiagnostics,
|
|
293
424
|
localPath,
|
|
294
425
|
readLocalJson,
|
|
295
426
|
writeLocalJson
|
package/dist/local-git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/local-git.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport {\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treadFileSync,\n\trealpathSync,\n\trenameSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport path from \"node:path\";\nimport type { RepositoryFeedbackItem, RepositoryPullRequest } from \"@leitwerk-dev/process-sdk\";\n\nexport interface LocalRepositorySeed {\n\towner: string;\n\tname: string;\n\tdefaultBranch?: string;\n\tfiles?: Record<string, string>;\n\t/** Retain a pre-existing sandbox checkout layout. */\n\tdirectoryName?: string;\n\tcommitMessage?: string;\n\tsignoff?: boolean;\n}\n\n/** Reject escaping paths and symlinks, including a not-yet-created file's parents. */\nexport function localPath(root: string, relative: string): string {\n\tif (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\tthrow new Error(\"Local provider storage must not contain symlinks\");\n\tconst base = realpathSync(root);\n\tconst target = path.resolve(base, relative);\n\tif (!target.startsWith(`${base}${path.sep}`))\n\t\tthrow new Error(\"Path escapes local provider storage\");\n\tlet current = base;\n\tfor (const part of path.relative(base, target).split(path.sep)) {\n\t\tcurrent = path.join(current, part);\n\t\tif (lstatSync(current, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\t\tthrow new Error(\"Local provider storage must not contain symlinks\");\n\t}\n\treturn target;\n}\n\nexport function readLocalJson<T extends { version: number }>(\n\troot: string,\n\tfile: string,\n\tinitial: T,\n): T {\n\tconst target = localPath(root, file);\n\tif (!existsSync(target)) return structuredClone(initial);\n\tconst value = JSON.parse(readFileSync(target, \"utf8\")) as T;\n\tif (!value || value.version !== initial.version)\n\t\tthrow new Error(`Unsupported local state version in ${file}`);\n\treturn value;\n}\n\nexport function writeLocalJson(root: string, file: string, value: unknown): void {\n\tconst target = localPath(root, file);\n\tconst temporary = localPath(root, `${file}.tmp`);\n\twriteFileSync(temporary, `${JSON.stringify(value, null, 2)}\\n`, { mode: 0o600 });\n\trenameSync(temporary, target);\n}\n\n/** Persist local adapter state with a shared clock and monotonically increasing ids. */\nexport class LocalProviderStore<\n\tS extends { version: number; sequence: number },\n\tO extends { root: string; now?: () => number; nextId?: () => number },\n> {\n\treadonly git: LocalGit;\n\tstate: S;\n\tconstructor(\n\t\treadonly options: O,\n\t\tprivate readonly file: string,\n\t\tinitial: S,\n\t) {\n\t\tthis.git = new LocalGit(options.root);\n\t\tthis.state = readLocalJson(options.root, file, initial);\n\t}\n\tsave() {\n\t\twriteLocalJson(this.options.root, this.file, this.state);\n\t}\n\tid() {\n\t\tthis.state.sequence = Math.max(this.state.sequence + 1, this.options.nextId?.() ?? 0);\n\t\treturn this.state.sequence;\n\t}\n\ttimestamp() {\n\t\treturn new Date(this.options.now?.() ?? Date.now()).toISOString();\n\t}\n}\n\ntype LocalPullRequest = Pick<\n\tRepositoryPullRequest,\n\t\"number\" | \"title\" | \"body\" | \"state\" | \"merged\" | \"merge_commit_sha\" | \"head\" | \"base\"\n>;\ninterface LocalPullRequestRepository<P extends LocalPullRequest> {\n\trepository: { ssh_url: string };\n\tpulls: P[];\n}\n\n/** Common PR operations; adapters retain their provider-specific state and clients. */\nexport class LocalForgeStore<\n\tS extends { version: number; sequence: number },\n\tO extends { root: string; baseUrl: string; now?: () => number; nextId?: () => number },\n> extends LocalProviderStore<S, O> {\n\tnewRepository(seed: LocalRepositorySeed) {\n\t\tconst { bare, branch } = this.git.seed(seed);\n\t\treturn {\n\t\t\tid: this.id(),\n\t\t\towner: { login: seed.owner },\n\t\t\tname: seed.name,\n\t\t\tfull_name: `${seed.owner}/${seed.name}`,\n\t\t\tssh_url: bare,\n\t\t\thtml_url: `${this.options.baseUrl}/__local`,\n\t\t\tdefault_branch: branch,\n\t\t};\n\t}\n\tpullRequestClient<P extends LocalPullRequest>(\n\t\trepo: (owner: string, name: string) => LocalPullRequestRepository<P>,\n\t\tmissing = \"Unknown local pull request\",\n\t) {\n\t\tconst pull = (owner: string, name: string, number: number) => {\n\t\t\tconst pr = repo(owner, name).pulls.find((p) => p.number === number);\n\t\t\tif (!pr) throw new Error(missing);\n\t\t\treturn pr;\n\t\t};\n\t\treturn {\n\t\t\tgetPullRequest: async (owner: string, name: string, number: number) =>\n\t\t\t\tthis.refresh(repo(owner, name), pull(owner, name, number)),\n\t\t\tlistPullRequests: async (owner: string, name: string, state = \"open\") => {\n\t\t\t\tconst r = repo(owner, name);\n\t\t\t\treturn r.pulls\n\t\t\t\t\t.filter((p) => state === \"all\" || p.state === state)\n\t\t\t\t\t.map((p) => this.refresh(r, p));\n\t\t\t},\n\t\t\tupdatePullRequest: async (\n\t\t\t\towner: string,\n\t\t\t\tname: string,\n\t\t\t\tnumber: number,\n\t\t\t\tpatch: Record<string, unknown>,\n\t\t\t) => {\n\t\t\t\tconst pr = pull(owner, name, number);\n\t\t\t\tfor (const key of [\"title\", \"body\", \"state\"] as const)\n\t\t\t\t\tif (typeof patch[key] === \"string\") pr[key] = patch[key];\n\t\t\t\tthis.save();\n\t\t\t\treturn this.refresh(repo(owner, name), pr);\n\t\t\t},\n\t\t};\n\t}\n\trefresh<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, pr: P): P {\n\t\tif (pr.state === \"open\") {\n\t\t\tconst { headSha, baseSha, ...mergeability } = this.git.mergeability(\n\t\t\t\trepo.repository.ssh_url,\n\t\t\t\tpr.head.ref,\n\t\t\t\tpr.base.ref,\n\t\t\t);\n\t\t\tpr.head.sha = headSha;\n\t\t\tpr.base.sha = baseSha;\n\t\t\tObject.assign(pr, mergeability);\n\t\t}\n\t\treturn structuredClone(pr);\n\t}\n\tmerge<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, number: number): P {\n\t\tconst pr = repo.pulls.find((p) => p.number === number);\n\t\tif (!pr || pr.state !== \"open\") throw new Error(\"Pull request is not open\");\n\t\tthis.refresh(repo, pr);\n\t\tpr.merge_commit_sha = this.git.merge(repo.repository.ssh_url, pr.head.ref, pr.base.ref);\n\t\tpr.merged = true;\n\t\tpr.state = \"closed\";\n\t\tthis.save();\n\t\treturn structuredClone(pr);\n\t}\n\taddFeedback<F extends RepositoryFeedbackItem>(\n\t\trepo: { pulls: Array<{ number: number }>; feedback: Record<string, F[]> },\n\t\tnumber: number,\n\t\tinput: Omit<F, \"id\" | \"createdAt\">,\n\t): F {\n\t\tif (!repo.pulls.some((p) => p.number === number)) throw new Error(\"Unknown PR\");\n\t\tconst value = { ...input, id: this.id(), createdAt: this.timestamp() } as F;\n\t\trepo.feedback[number] ??= [];\n\t\trepo.feedback[number].push(value);\n\t\tthis.save();\n\t\treturn value;\n\t}\n\tnewComment(body: string) {\n\t\treturn {\n\t\t\tid: this.id(),\n\t\t\tbody,\n\t\t\tuser: { login: \"leitwerk-bot\" },\n\t\t\tcreated_at: this.timestamp(),\n\t\t};\n\t}\n\tnewPullRequest(\n\t\trepo: { repository: { ssh_url: string } },\n\t\tinput: { title: string; body: string; head: string; base: string },\n\t) {\n\t\tconst number = this.id();\n\t\treturn {\n\t\t\tnumber,\n\t\t\ttitle: input.title,\n\t\t\tbody: input.body,\n\t\t\tstate: \"open\",\n\t\t\tmerged: false,\n\t\t\tmerge_commit_sha: null,\n\t\t\thtml_url: `${this.options.baseUrl}/__local#pr-${number}`,\n\t\t\thead: { ref: input.head, sha: this.git.head(repo.repository.ssh_url, input.head) },\n\t\t\tbase: { ref: input.base, sha: this.git.head(repo.repository.ssh_url, input.base) },\n\t\t};\n\t}\n}\n\n/** Real Git with file-only transport and no ambient credentials or hooks. */\nexport class LocalGit {\n\tconstructor(readonly root: string) {\n\t\tif (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\t\tthrow new Error(\"Local Git root must not be a symlink\");\n\t\tmkdirSync(root, { recursive: true, mode: 0o700 });\n\t}\n\trun(directory: string, args: string[]): string {\n\t\tconst base = realpathSync(this.root);\n\t\tconst directoryPath = path.resolve(directory);\n\t\tconst relative = path.relative(\n\t\t\tdirectoryPath.startsWith(`${base}${path.sep}`) ? base : path.resolve(this.root),\n\t\t\tdirectoryPath,\n\t\t);\n\t\tconst cwd = localPath(this.root, relative);\n\t\treturn execFileSync(\n\t\t\t\"git\",\n\t\t\t[\"-c\", \"protocol.file.allow=always\", \"-c\", \"core.hooksPath=/dev/null\", ...args],\n\t\t\t{\n\t\t\t\tcwd,\n\t\t\t\tencoding: \"utf8\",\n\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\tenv: {\n\t\t\t\t\tPATH: process.env.PATH,\n\t\t\t\t\tHOME: this.root,\n\t\t\t\t\tGIT_CONFIG_NOSYSTEM: \"1\",\n\t\t\t\t\tGIT_CONFIG_GLOBAL: \"/dev/null\",\n\t\t\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\t\t\tGIT_ALLOW_PROTOCOL: \"file\",\n\t\t\t\t\tGIT_AUTHOR_NAME: \"Sandbox Developer\",\n\t\t\t\t\tGIT_AUTHOR_EMAIL: \"developer@sandbox.invalid\",\n\t\t\t\t\tGIT_COMMITTER_NAME: \"Sandbox Developer\",\n\t\t\t\t\tGIT_COMMITTER_EMAIL: \"developer@sandbox.invalid\",\n\t\t\t\t},\n\t\t\t},\n\t\t).trim();\n\t}\n\thead(directory: string, ref: string): string {\n\t\tif (!/^[a-zA-Z0-9_./-]+$/.test(ref) || ref.startsWith(\"-\")) throw new Error(\"Invalid Git ref\");\n\t\treturn this.run(directory, [\"rev-parse\", \"--verify\", `${ref}^{commit}`]);\n\t}\n\tisAncestor(directory: string, ancestor: string, descendant: string): boolean {\n\t\treturn this.isAncestorCommit(\n\t\t\tdirectory,\n\t\t\tthis.head(directory, ancestor),\n\t\t\tthis.head(directory, descendant),\n\t\t);\n\t}\n\tprivate isAncestorCommit(directory: string, ancestor: string, descendant: string): boolean {\n\t\tif (ancestor === descendant) return true;\n\t\ttry {\n\t\t\tthis.run(directory, [\"merge-base\", \"--is-ancestor\", ancestor, descendant]);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif ((error as { status?: number }).status === 1) return false;\n\t\t\tthrow error;\n\t\t}\n\t}\n\tmergeability(\n\t\tdirectory: string,\n\t\thead: string,\n\t\tbase: string,\n\t): { headSha: string; baseSha: string; mergeable: boolean; mergeable_state: string } {\n\t\tconst headSha = this.head(directory, head),\n\t\t\tbaseSha = this.head(directory, base);\n\t\tconst revisions = { headSha, baseSha };\n\t\tif (this.isAncestorCommit(directory, baseSha, headSha))\n\t\t\treturn { ...revisions, mergeable: true, mergeable_state: \"clean\" };\n\t\ttry {\n\t\t\tthis.run(directory, [\"merge-tree\", \"--write-tree\", baseSha, headSha]);\n\t\t} catch (error) {\n\t\t\tif ((error as { status?: number }).status === 1)\n\t\t\t\treturn { ...revisions, mergeable: false, mergeable_state: \"dirty\" };\n\t\t\tthrow error;\n\t\t}\n\t\treturn { ...revisions, mergeable: true, mergeable_state: \"behind\" };\n\t}\n\tmerge(directory: string, head: string, base: string): string {\n\t\tconst h = this.head(directory, head),\n\t\t\tb = this.head(directory, base);\n\t\tlet commit = h;\n\t\tif (!this.isAncestorCommit(directory, b, h)) {\n\t\t\tconst tree = this.run(directory, [\"merge-tree\", \"--write-tree\", b, h]).split(\"\\n\")[0];\n\t\t\tcommit = this.run(directory, [\n\t\t\t\t\"commit-tree\",\n\t\t\t\ttree,\n\t\t\t\t\"-p\",\n\t\t\t\tb,\n\t\t\t\t\"-p\",\n\t\t\t\th,\n\t\t\t\t\"-m\",\n\t\t\t\t\"Merge local pull request\",\n\t\t\t]);\n\t\t}\n\t\tthis.run(directory, [\"update-ref\", `refs/heads/${base}`, commit, b]);\n\t\treturn commit;\n\t}\n\tseed(seed: LocalRepositorySeed): { bare: string; worktree: string; branch: string } {\n\t\tfor (const value of [seed.owner, seed.name, seed.directoryName ?? seed.name])\n\t\t\tif (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(value))\n\t\t\t\tthrow new Error(\"Invalid local repository name\");\n\t\tconst name = seed.directoryName ?? `${seed.owner}--${seed.name}`;\n\t\tconst bare = localPath(this.root, `repositories/${name}.git`);\n\t\tconst worktree = localPath(this.root, `seeds/${name}`);\n\t\tconst branch = seed.defaultBranch ?? \"main\";\n\t\tif (!/^[a-zA-Z0-9][a-zA-Z0-9_./-]*$/.test(branch)) throw new Error(\"Invalid default branch\");\n\t\tmkdirSync(bare, { recursive: true });\n\t\tmkdirSync(worktree, { recursive: true });\n\t\tif (!existsSync(path.join(bare, \"HEAD\")))\n\t\t\tthis.run(bare, [\"init\", \"--bare\", `--initial-branch=${branch}`]);\n\t\ttry {\n\t\t\tthis.head(bare, branch);\n\t\t\treturn { bare, worktree, branch };\n\t\t} catch {\n\t\t\t/* Resume an interrupted seed. */\n\t\t}\n\t\tif (!existsSync(path.join(worktree, \".git\")))\n\t\t\tthis.run(worktree, [\"init\", `--initial-branch=${branch}`]);\n\t\tfor (const [name, contents] of Object.entries(\n\t\t\tseed.files ?? { \"README.md\": `# ${seed.name}\\n` },\n\t\t)) {\n\t\t\tif (name.split(/[\\\\/]/).includes(\".git\"))\n\t\t\t\tthrow new Error(\"Seed must not write Git configuration\");\n\t\t\tconst target = localPath(worktree, name);\n\t\t\tmkdirSync(path.dirname(target), { recursive: true });\n\t\t\twriteFileSync(target, contents);\n\t\t}\n\t\tthis.run(worktree, [\"add\", \".\"]);\n\t\tthis.run(worktree, [\n\t\t\t\"commit\",\n\t\t\t\"--allow-empty\",\n\t\t\t...(seed.signoff ? [\"--signoff\"] : []),\n\t\t\t\"-m\",\n\t\t\tseed.commitMessage ?? \"chore: seed local repository\",\n\t\t]);\n\t\tif (!this.run(worktree, [\"remote\"]).split(\"\\n\").includes(\"origin\"))\n\t\t\tthis.run(worktree, [\"remote\", \"add\", \"origin\", bare]);\n\t\tthis.run(worktree, [\"push\", bare, `HEAD:refs/heads/${branch}`]);\n\t\treturn { bare, worktree, branch };\n\t}\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,UAAU;AAeV,SAAS,UAAU,MAAc,UAA0B;AACjE,MAAI,UAAU,MAAM,EAAE,gBAAgB,MAAM,CAAC,GAAG,eAAe;AAC9D,UAAM,IAAI,MAAM,kDAAkD;AACnE,QAAM,OAAO,aAAa,IAAI;AAC9B,QAAM,SAAS,KAAK,QAAQ,MAAM,QAAQ;AAC1C,MAAI,CAAC,OAAO,WAAW,GAAG,IAAI,GAAG,KAAK,GAAG,EAAE;AAC1C,UAAM,IAAI,MAAM,qCAAqC;AACtD,MAAI,UAAU;AACd,aAAW,QAAQ,KAAK,SAAS,MAAM,MAAM,EAAE,MAAM,KAAK,GAAG,GAAG;AAC/D,cAAU,KAAK,KAAK,SAAS,IAAI;AACjC,QAAI,UAAU,SAAS,EAAE,gBAAgB,MAAM,CAAC,GAAG,eAAe;AACjE,YAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAO;AACR;AAEO,SAAS,cACf,MACA,MACA,SACI;AACJ,QAAM,SAAS,UAAU,MAAM,IAAI;AACnC,MAAI,CAAC,WAAW,MAAM,EAAG,QAAO,gBAAgB,OAAO;AACvD,QAAM,QAAQ,KAAK,MAAM,aAAa,QAAQ,MAAM,CAAC;AACrD,MAAI,CAAC,SAAS,MAAM,YAAY,QAAQ;AACvC,UAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;AAC7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AK,OAAO;AAAA,MACrC,KAAK,SAAS,EAAE,aAAa,KAAK,KAAK,IAAI;AAAA,EAAK;AAAA,IACjD,GAAG;AACF,UAAIA,MAAK,MAAM,OAAO,EAAE,SAAS,MAAM;AACtC,cAAM,IAAI,MAAM,uCAAuC;AACxD,YAAM,SAAS,UAAU,UAAUA,KAAI;AACvC,gBAAU,KAAK,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;AACnD,oBAAc,QAAQ,QAAQ;AAAA,IAC/B;AACA,SAAK,IAAI,UAAU,CAAC,OAAO,GAAG,CAAC;AAC/B,SAAK,IAAI,UAAU;AAAA,MAClB;AAAA,MACA;AAAA,MACA,GAAI,KAAK,UAAU,CAAC,WAAW,IAAI,CAAC;AAAA,MACpC;AAAA,MACA,KAAK,iBAAiB;AAAA,IACvB,CAAC;AACD,QAAI,CAAC,KAAK,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,EAAE,SAAS,QAAQ;AAChE,WAAK,IAAI,UAAU,CAAC,UAAU,OAAO,UAAU,IAAI,CAAC;AACrD,SAAK,IAAI,UAAU,CAAC,QAAQ,MAAM,mBAAmB,MAAM,EAAE,CAAC;AAC9D,WAAO,EAAE,MAAM,UAAU,OAAO;AAAA,EACjC;AACD;","names":["name"]}
|
|
1
|
+
{"version":3,"sources":["../src/local-git.ts","../src/test-diagnostics.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport {\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treadFileSync,\n\trealpathSync,\n\trenameSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport path from \"node:path\";\nimport type { RepositoryFeedbackItem, RepositoryPullRequest } from \"@leitwerk-dev/process-sdk\";\nimport { traceTestSubprocess } from \"./test-diagnostics.js\";\n\nexport { createTestDiagnostics } from \"./test-diagnostics.js\";\n\n/** @public */\nexport interface LocalRepositorySeed {\n\t/** @public */\n\towner: string;\n\t/** @public */\n\tname: string;\n\t/** @internal */\n\tdefaultBranch?: string;\n\t/** @public */\n\tfiles?: Record<string, string>;\n\t/** Retain a pre-existing sandbox checkout layout. @internal */\n\tdirectoryName?: string;\n\t/** @internal */\n\tcommitMessage?: string;\n\t/** @internal */\n\tsignoff?: boolean;\n}\n\n/** Reject escaping paths and symlinks, including a not-yet-created file's parents. @public */\nexport function localPath(root: string, relative: string): string {\n\tif (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\tthrow new Error(\"Local provider storage must not contain symlinks\");\n\tconst base = realpathSync(root);\n\tconst target = path.resolve(base, relative);\n\tif (!target.startsWith(`${base}${path.sep}`))\n\t\tthrow new Error(\"Path escapes local provider storage\");\n\tlet current = base;\n\tfor (const part of path.relative(base, target).split(path.sep)) {\n\t\tcurrent = path.join(current, part);\n\t\tif (lstatSync(current, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\t\tthrow new Error(\"Local provider storage must not contain symlinks\");\n\t}\n\treturn target;\n}\n\n/** @public */\nexport function readLocalJson<\n\tT extends {\n\t\t/** @internal */\n\t\tversion: number;\n\t},\n>(root: string, file: string, initial: T): T {\n\tconst target = localPath(root, file);\n\tif (!existsSync(target)) return structuredClone(initial);\n\tconst value = JSON.parse(readFileSync(target, \"utf8\")) as T;\n\tif (!value || value.version !== initial.version)\n\t\tthrow new Error(`Unsupported local state version in ${file}`);\n\treturn value;\n}\n\n/** @public */\nexport function writeLocalJson(root: string, file: string, value: unknown): void {\n\tconst target = localPath(root, file);\n\tconst temporary = localPath(root, `${file}.tmp`);\n\twriteFileSync(temporary, `${JSON.stringify(value, null, 2)}\\n`, { mode: 0o600 });\n\trenameSync(temporary, target);\n}\n\n/** Persist local adapter state with a shared clock and monotonically increasing ids. @public */\nexport class LocalProviderStore<\n\tS extends {\n\t\t/** @internal */\n\t\tversion: number;\n\t\t/** @internal */\n\t\tsequence: number;\n\t},\n\tO extends {\n\t\t/** @internal */\n\t\troot: string;\n\t\t/** @internal */\n\t\tnow?: () => number;\n\t\t/** @internal */\n\t\tnextId?: () => number;\n\t},\n> {\n\t/** @public */\n\treadonly git: LocalGit;\n\t/** @public */\n\tstate: S;\n\t/** @public */\n\tconstructor(\n\t\t/** @public */\n\t\treadonly options: O,\n\t\tprivate readonly file: string,\n\t\tinitial: S,\n\t) {\n\t\tthis.git = new LocalGit(options.root);\n\t\tthis.state = readLocalJson(options.root, file, initial);\n\t}\n\t/** @public */\n\tsave() {\n\t\twriteLocalJson(this.options.root, this.file, this.state);\n\t}\n\t/** @internal */\n\tid() {\n\t\tthis.state.sequence = Math.max(this.state.sequence + 1, this.options.nextId?.() ?? 0);\n\t\treturn this.state.sequence;\n\t}\n\t/** @internal */\n\ttimestamp() {\n\t\treturn new Date(this.options.now?.() ?? Date.now()).toISOString();\n\t}\n}\n\n/** @public */\ntype LocalPullRequest = Pick<\n\tRepositoryPullRequest,\n\t\"number\" | \"title\" | \"body\" | \"state\" | \"merged\" | \"merge_commit_sha\" | \"head\" | \"base\"\n>;\n/** @public */\ninterface LocalPullRequestRepository<P extends LocalPullRequest> {\n\t/** @public */\n\trepository: {\n\t\t/** @internal */\n\t\tssh_url: string;\n\t};\n\t/** @public */\n\tpulls: P[];\n}\n\n/** Common PR operations; adapters retain their provider-specific state and clients. @public */\nexport class LocalForgeStore<\n\tS extends {\n\t\t/** @internal */\n\t\tversion: number;\n\t\t/** @internal */\n\t\tsequence: number;\n\t},\n\tO extends {\n\t\t/** @internal */\n\t\troot: string;\n\t\t/** @internal */\n\t\tbaseUrl: string;\n\t\t/** @internal */\n\t\tnow?: () => number;\n\t\t/** @internal */\n\t\tnextId?: () => number;\n\t},\n> extends LocalProviderStore<S, O> {\n\t/** @public */\n\tnewRepository(seed: LocalRepositorySeed) {\n\t\tconst { bare, branch } = this.git.seed(seed);\n\t\treturn {\n\t\t\t/** @public */\n\t\t\tid: this.id(),\n\t\t\t/** @public */\n\t\t\towner: {\n\t\t\t\t/** @internal */\n\t\t\t\tlogin: seed.owner,\n\t\t\t},\n\t\t\t/** @public */\n\t\t\tname: seed.name,\n\t\t\t/** @public */\n\t\t\tfull_name: `${seed.owner}/${seed.name}`,\n\t\t\t/** @public */\n\t\t\tssh_url: bare,\n\t\t\t/** @public */\n\t\t\thtml_url: `${this.options.baseUrl}/__local`,\n\t\t\t/** @public */\n\t\t\tdefault_branch: branch,\n\t\t};\n\t}\n\t/** @internal */\n\tpullRequestClient<P extends LocalPullRequest>(\n\t\trepo: (owner: string, name: string) => LocalPullRequestRepository<P>,\n\t\tmissing = \"Unknown local pull request\",\n\t) {\n\t\tconst pull = (owner: string, name: string, number: number) => {\n\t\t\tconst pr = repo(owner, name).pulls.find((p) => p.number === number);\n\t\t\tif (!pr) throw new Error(missing);\n\t\t\treturn pr;\n\t\t};\n\t\treturn {\n\t\t\t/** @internal */\n\t\t\tgetPullRequest: async (owner: string, name: string, number: number) =>\n\t\t\t\tthis.refresh(repo(owner, name), pull(owner, name, number)),\n\t\t\t/** @internal */\n\t\t\tlistPullRequests: async (owner: string, name: string, state = \"open\") => {\n\t\t\t\tconst r = repo(owner, name);\n\t\t\t\treturn r.pulls\n\t\t\t\t\t.filter((p) => state === \"all\" || p.state === state)\n\t\t\t\t\t.map((p) => this.refresh(r, p));\n\t\t\t},\n\t\t\t/** @internal */\n\t\t\tupdatePullRequest: async (\n\t\t\t\towner: string,\n\t\t\t\tname: string,\n\t\t\t\tnumber: number,\n\t\t\t\tpatch: Record<string, unknown>,\n\t\t\t) => {\n\t\t\t\tconst pr = pull(owner, name, number);\n\t\t\t\tfor (const key of [\"title\", \"body\", \"state\"] as const)\n\t\t\t\t\tif (typeof patch[key] === \"string\") pr[key] = patch[key];\n\t\t\t\tthis.save();\n\t\t\t\treturn this.refresh(repo(owner, name), pr);\n\t\t\t},\n\t\t};\n\t}\n\t/** @public */\n\trefresh<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, pr: P): P {\n\t\tif (pr.state === \"open\") {\n\t\t\tconst { headSha, baseSha, ...mergeability } = this.git.mergeability(\n\t\t\t\trepo.repository.ssh_url,\n\t\t\t\tpr.head.ref,\n\t\t\t\tpr.base.ref,\n\t\t\t);\n\t\t\tpr.head.sha = headSha;\n\t\t\tpr.base.sha = baseSha;\n\t\t\tObject.assign(pr, mergeability);\n\t\t}\n\t\treturn structuredClone(pr);\n\t}\n\t/** @public */\n\tmerge<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, number: number): P {\n\t\tconst pr = repo.pulls.find((p) => p.number === number);\n\t\tif (!pr || pr.state !== \"open\") throw new Error(\"Pull request is not open\");\n\t\tthis.refresh(repo, pr);\n\t\tpr.merge_commit_sha = this.git.merge(repo.repository.ssh_url, pr.head.ref, pr.base.ref);\n\t\tpr.merged = true;\n\t\tpr.state = \"closed\";\n\t\tthis.save();\n\t\treturn structuredClone(pr);\n\t}\n\t/** @public */\n\taddFeedback<F extends RepositoryFeedbackItem>(\n\t\trepo: {\n\t\t\t/** @public */\n\t\t\tpulls: Array<{\n\t\t\t\t/** @internal */\n\t\t\t\tnumber: number;\n\t\t\t}>;\n\t\t\t/** @public */\n\t\t\tfeedback: Record<string, F[]>;\n\t\t},\n\t\tnumber: number,\n\t\tinput: Omit<F, \"id\" | \"createdAt\">,\n\t): F {\n\t\tif (!repo.pulls.some((p) => p.number === number)) throw new Error(\"Unknown PR\");\n\t\tconst value = { ...input, id: this.id(), createdAt: this.timestamp() } as F;\n\t\trepo.feedback[number] ??= [];\n\t\trepo.feedback[number].push(value);\n\t\tthis.save();\n\t\treturn value;\n\t}\n\t/** @public */\n\tnewComment(body: string) {\n\t\treturn {\n\t\t\t/** @internal */\n\t\t\tid: this.id(),\n\t\t\t/** @internal */\n\t\t\tbody,\n\t\t\t/** @public */\n\t\t\tuser: {\n\t\t\t\t/** @public */\n\t\t\t\tlogin: \"leitwerk-bot\",\n\t\t\t},\n\t\t\t/** @internal */\n\t\t\tcreated_at: this.timestamp(),\n\t\t};\n\t}\n\t/** @internal */\n\tnewPullRequest(\n\t\trepo: {\n\t\t\t/** @internal */\n\t\t\trepository: {\n\t\t\t\t/** @internal */\n\t\t\t\tssh_url: string;\n\t\t\t};\n\t\t},\n\t\tinput: {\n\t\t\t/** @internal */\n\t\t\ttitle: string;\n\t\t\t/** @internal */\n\t\t\tbody: string;\n\t\t\t/** @internal */\n\t\t\thead: string;\n\t\t\t/** @internal */\n\t\t\tbase: string;\n\t\t},\n\t) {\n\t\tconst number = this.id();\n\t\treturn {\n\t\t\t/** @internal */\n\t\t\tnumber,\n\t\t\t/** @internal */\n\t\t\ttitle: input.title,\n\t\t\t/** @internal */\n\t\t\tbody: input.body,\n\t\t\t/** @internal */\n\t\t\tstate: \"open\",\n\t\t\t/** @internal */\n\t\t\tmerged: false,\n\t\t\t/** @internal */\n\t\t\tmerge_commit_sha: null,\n\t\t\t/** @internal */\n\t\t\thtml_url: `${this.options.baseUrl}/__local#pr-${number}`,\n\t\t\t/** @internal */\n\t\t\thead: {\n\t\t\t\t/** @internal */\n\t\t\t\tref: input.head,\n\t\t\t\t/** @internal */\n\t\t\t\tsha: this.git.head(repo.repository.ssh_url, input.head),\n\t\t\t},\n\t\t\t/** @internal */\n\t\t\tbase: {\n\t\t\t\t/** @internal */\n\t\t\t\tref: input.base,\n\t\t\t\t/** @internal */\n\t\t\t\tsha: this.git.head(repo.repository.ssh_url, input.base),\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** Real Git with file-only transport and no ambient credentials or hooks. @public */\nexport class LocalGit {\n\t/** @public */\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly root: string,\n\t) {\n\t\tif (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\t\tthrow new Error(\"Local Git root must not be a symlink\");\n\t\tmkdirSync(root, { recursive: true, mode: 0o700 });\n\t}\n\t/** @public */\n\trun(directory: string, args: string[]): string {\n\t\tconst base = realpathSync(this.root);\n\t\tconst directoryPath = path.resolve(directory);\n\t\tconst relative = path.relative(\n\t\t\tdirectoryPath.startsWith(`${base}${path.sep}`) ? base : path.resolve(this.root),\n\t\t\tdirectoryPath,\n\t\t);\n\t\tconst cwd = localPath(this.root, relative);\n\t\treturn traceTestSubprocess(`git ${args[0] ?? \"\"}`, () =>\n\t\t\texecFileSync(\n\t\t\t\t\"git\",\n\t\t\t\t[\"-c\", \"protocol.file.allow=always\", \"-c\", \"core.hooksPath=/dev/null\", ...args],\n\t\t\t\t{\n\t\t\t\t\tcwd,\n\t\t\t\t\tencoding: \"utf8\",\n\t\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\tenv: {\n\t\t\t\t\t\tPATH: process.env.PATH,\n\t\t\t\t\t\tHOME: this.root,\n\t\t\t\t\t\tGIT_CONFIG_NOSYSTEM: \"1\",\n\t\t\t\t\t\tGIT_CONFIG_GLOBAL: \"/dev/null\",\n\t\t\t\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\t\t\t\tGIT_ALLOW_PROTOCOL: \"file\",\n\t\t\t\t\t\tGIT_AUTHOR_NAME: \"Sandbox Developer\",\n\t\t\t\t\t\tGIT_AUTHOR_EMAIL: \"developer@sandbox.invalid\",\n\t\t\t\t\t\tGIT_COMMITTER_NAME: \"Sandbox Developer\",\n\t\t\t\t\t\tGIT_COMMITTER_EMAIL: \"developer@sandbox.invalid\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t).trim(),\n\t\t);\n\t}\n\t/** @public */\n\thead(directory: string, ref: string): string {\n\t\tif (!/^[a-zA-Z0-9_./-]+$/.test(ref) || ref.startsWith(\"-\")) throw new Error(\"Invalid Git ref\");\n\t\treturn this.run(directory, [\"rev-parse\", \"--verify\", `${ref}^{commit}`]);\n\t}\n\t/** @internal */\n\tisAncestor(directory: string, ancestor: string, descendant: string): boolean {\n\t\treturn this.isAncestorCommit(\n\t\t\tdirectory,\n\t\t\tthis.head(directory, ancestor),\n\t\t\tthis.head(directory, descendant),\n\t\t);\n\t}\n\tprivate isAncestorCommit(directory: string, ancestor: string, descendant: string): boolean {\n\t\tif (ancestor === descendant) return true;\n\t\ttry {\n\t\t\tthis.run(directory, [\"merge-base\", \"--is-ancestor\", ancestor, descendant]);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif ((error as { status?: number }).status === 1) return false;\n\t\t\tthrow error;\n\t\t}\n\t}\n\t/** @internal */\n\tmergeability(\n\t\tdirectory: string,\n\t\thead: string,\n\t\tbase: string,\n\t): {\n\t\t/** @internal */\n\t\theadSha: string;\n\t\t/** @internal */\n\t\tbaseSha: string;\n\t\t/** @internal */\n\t\tmergeable: boolean;\n\t\t/** @internal */\n\t\tmergeable_state: string;\n\t} {\n\t\tconst headSha = this.head(directory, head),\n\t\t\tbaseSha = this.head(directory, base);\n\t\tconst revisions = { headSha, baseSha };\n\t\tif (this.isAncestorCommit(directory, baseSha, headSha))\n\t\t\treturn { ...revisions, mergeable: true, mergeable_state: \"clean\" };\n\t\ttry {\n\t\t\tthis.run(directory, [\"merge-tree\", \"--write-tree\", baseSha, headSha]);\n\t\t} catch (error) {\n\t\t\tif ((error as { status?: number }).status === 1)\n\t\t\t\treturn { ...revisions, mergeable: false, mergeable_state: \"dirty\" };\n\t\t\tthrow error;\n\t\t}\n\t\treturn { ...revisions, mergeable: true, mergeable_state: \"behind\" };\n\t}\n\t/** @internal */\n\tmerge(directory: string, head: string, base: string): string {\n\t\tconst h = this.head(directory, head),\n\t\t\tb = this.head(directory, base);\n\t\tlet commit = h;\n\t\tif (!this.isAncestorCommit(directory, b, h)) {\n\t\t\tconst tree = this.run(directory, [\"merge-tree\", \"--write-tree\", b, h]).split(\"\\n\")[0];\n\t\t\tcommit = this.run(directory, [\n\t\t\t\t\"commit-tree\",\n\t\t\t\ttree,\n\t\t\t\t\"-p\",\n\t\t\t\tb,\n\t\t\t\t\"-p\",\n\t\t\t\th,\n\t\t\t\t\"-m\",\n\t\t\t\t\"Merge local pull request\",\n\t\t\t]);\n\t\t}\n\t\tthis.run(directory, [\"update-ref\", `refs/heads/${base}`, commit, b]);\n\t\treturn commit;\n\t}\n\t/** @internal */\n\tseed(seed: LocalRepositorySeed): {\n\t\t/** @internal */\n\t\tbare: string;\n\t\t/** @internal */\n\t\tworktree: string;\n\t\t/** @internal */\n\t\tbranch: string;\n\t} {\n\t\tfor (const value of [seed.owner, seed.name, seed.directoryName ?? seed.name])\n\t\t\tif (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(value))\n\t\t\t\tthrow new Error(\"Invalid local repository name\");\n\t\tconst name = seed.directoryName ?? `${seed.owner}--${seed.name}`;\n\t\tconst bare = localPath(this.root, `repositories/${name}.git`);\n\t\tconst worktree = localPath(this.root, `seeds/${name}`);\n\t\tconst branch = seed.defaultBranch ?? \"main\";\n\t\tif (!/^[a-zA-Z0-9][a-zA-Z0-9_./-]*$/.test(branch)) throw new Error(\"Invalid default branch\");\n\t\tmkdirSync(bare, { recursive: true });\n\t\tmkdirSync(worktree, { recursive: true });\n\t\tif (!existsSync(path.join(bare, \"HEAD\")))\n\t\t\tthis.run(bare, [\"init\", \"--bare\", `--initial-branch=${branch}`]);\n\t\ttry {\n\t\t\tthis.head(bare, branch);\n\t\t\treturn { bare, worktree, branch };\n\t\t} catch {\n\t\t\t/* Resume an interrupted seed. */\n\t\t}\n\t\tif (!existsSync(path.join(worktree, \".git\")))\n\t\t\tthis.run(worktree, [\"init\", `--initial-branch=${branch}`]);\n\t\tfor (const [name, contents] of Object.entries(\n\t\t\tseed.files ?? { \"README.md\": `# ${seed.name}\\n` },\n\t\t)) {\n\t\t\tif (name.split(/[\\\\/]/).includes(\".git\"))\n\t\t\t\tthrow new Error(\"Seed must not write Git configuration\");\n\t\t\tconst target = localPath(worktree, name);\n\t\t\tmkdirSync(path.dirname(target), { recursive: true });\n\t\t\twriteFileSync(target, contents);\n\t\t}\n\t\tthis.run(worktree, [\"add\", \".\"]);\n\t\tthis.run(worktree, [\n\t\t\t\"commit\",\n\t\t\t\"--allow-empty\",\n\t\t\t...(seed.signoff ? [\"--signoff\"] : []),\n\t\t\t\"-m\",\n\t\t\tseed.commitMessage ?? \"chore: seed local repository\",\n\t\t]);\n\t\tif (!this.run(worktree, [\"remote\"]).split(\"\\n\").includes(\"origin\"))\n\t\t\tthis.run(worktree, [\"remote\", \"add\", \"origin\", bare]);\n\t\tthis.run(worktree, [\"push\", bare, `HEAD:refs/heads/${branch}`]);\n\t\treturn { bare, worktree, branch };\n\t}\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { threadId } from \"node:worker_threads\";\n\nconst active = new AsyncLocalStorage<ReturnType<typeof createTestDiagnostics>>();\n\n/** @internal Bounded, in-memory trace. Call report from onTestFailed; successful tests stay quiet. */\nexport function createTestDiagnostics(label: string) {\n\tconst started = performance.now();\n\tconst events: Record<string, unknown>[] = [];\n\tlet dropped = 0;\n\tconst mark = (stage: string, details: Record<string, unknown> = {}) => {\n\t\tif (events.length === 512) {\n\t\t\tevents.shift();\n\t\t\tdropped++;\n\t\t}\n\t\tevents.push({\n\t\t\t...details,\n\t\t\tstage,\n\t\t\tat: new Date().toISOString(),\n\t\t\telapsedMs: Math.round(performance.now() - started),\n\t\t});\n\t};\n\tconst diagnostics = {\n\t\t/** @internal */\n\t\tmark,\n\t\t/** @internal */\n\t\trun<T>(fn: () => T): T {\n\t\t\treturn active.run(diagnostics, fn);\n\t\t},\n\t\t/** @internal */\n\t\tformat() {\n\t\t\treturn JSON.stringify({ label, pid: process.pid, threadId, dropped, events }, null, 2);\n\t\t},\n\t\t/** @internal */\n\t\treport() {\n\t\t\tmark(\"diagnostics.report\");\n\t\t\tconsole.error(diagnostics.format());\n\t\t},\n\t};\n\tmark(\"test.start\");\n\treturn diagnostics;\n}\n\n/** @internal Logs only the operation name and exit metadata, never arguments, output or environment. */\nexport function traceTestSubprocess<T>(operation: string, run: () => T): T {\n\tconst trace = active.getStore();\n\tif (!trace) return run();\n\tconst started = performance.now();\n\ttrace.mark(\"subprocess.start\", { operation });\n\ttry {\n\t\tconst result = run();\n\t\ttrace.mark(\"subprocess.exit\", {\n\t\t\toperation,\n\t\t\tstatus: 0,\n\t\t\tdurationMs: Math.round(performance.now() - started),\n\t\t});\n\t\treturn result;\n\t} catch (error) {\n\t\tconst details = error as { status?: unknown; signal?: unknown; code?: unknown } | null;\n\t\ttrace.mark(\"subprocess.exit\", {\n\t\t\toperation,\n\t\t\tdurationMs: Math.round(performance.now() - started),\n\t\t\tstatus: typeof details?.status === \"number\" ? details.status : null,\n\t\t\tsignal: typeof details?.signal === \"string\" ? details.signal : null,\n\t\t\tcode: typeof details?.code === \"string\" ? details.code : null,\n\t\t});\n\t\tthrow error;\n\t}\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,UAAU;;;ACVjB,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AAEzB,IAAM,SAAS,IAAI,kBAA4D;AAGxE,SAAS,sBAAsB,OAAe;AACpD,QAAM,UAAU,YAAY,IAAI;AAChC,QAAM,SAAoC,CAAC;AAC3C,MAAI,UAAU;AACd,QAAM,OAAO,CAAC,OAAe,UAAmC,CAAC,MAAM;AACtE,QAAI,OAAO,WAAW,KAAK;AAC1B,aAAO,MAAM;AACb;AAAA,IACD;AACA,WAAO,KAAK;AAAA,MACX,GAAG;AAAA,MACH;AAAA,MACA,KAAI,oBAAI,KAAK,GAAE,YAAY;AAAA,MAC3B,WAAW,KAAK,MAAM,YAAY,IAAI,IAAI,OAAO;AAAA,IAClD,CAAC;AAAA,EACF;AACA,QAAM,cAAc;AAAA;AAAA,IAEnB;AAAA;AAAA,IAEA,IAAO,IAAgB;AACtB,aAAO,OAAO,IAAI,aAAa,EAAE;AAAA,IAClC;AAAA;AAAA,IAEA,SAAS;AACR,aAAO,KAAK,UAAU,EAAE,OAAO,KAAK,QAAQ,KAAK,UAAU,SAAS,OAAO,GAAG,MAAM,CAAC;AAAA,IACtF;AAAA;AAAA,IAEA,S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G,CAAC;AAC/B,SAAK,IAAI,UAAU;AAAA,MAClB;AAAA,MACA;AAAA,MACA,GAAI,KAAK,UAAU,CAAC,WAAW,IAAI,CAAC;AAAA,MACpC;AAAA,MACA,KAAK,iBAAiB;AAAA,IACvB,CAAC;AACD,QAAI,CAAC,KAAK,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,EAAE,SAAS,QAAQ;AAChE,WAAK,IAAI,UAAU,CAAC,UAAU,OAAO,UAAU,IAAI,CAAC;AACrD,SAAK,IAAI,UAAU,CAAC,QAAQ,MAAM,mBAAmB,MAAM,EAAE,CAAC;AAC9D,WAAO,EAAE,MAAM,UAAU,OAAO;AAAA,EACjC;AACD;","names":["name"]}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { defineModelProviders } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @public */
|
|
3
|
+
export type FixtureModelProviderSet = ReturnType<typeof defineModelProviders>;
|
|
4
|
+
/** @public */
|
|
1
5
|
export declare function fixtureModelProviders(...models: {
|
|
6
|
+
/** @public */
|
|
2
7
|
id: string;
|
|
8
|
+
/** @public */
|
|
3
9
|
modelId: string;
|
|
10
|
+
/** @internal */
|
|
4
11
|
piProvider?: string;
|
|
12
|
+
/** @public */
|
|
5
13
|
server?: boolean;
|
|
6
|
-
}[]):
|
|
14
|
+
}[]): FixtureModelProviderSet;
|
|
7
15
|
//# sourceMappingURL=model-provider-fixtures.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-provider-fixtures.d.ts","sourceRoot":"","sources":["../src/model-provider-fixtures.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-provider-fixtures.d.ts","sourceRoot":"","sources":["../src/model-provider-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,oBAAoB,EACpB,MAAM,2BAA2B,CAAC;AAEnC,cAAc;AACd,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE9E,cAAc;AACd,wBAAgB,qBAAqB,CACpC,GAAG,MAAM,EAAE;IACV,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,EAAE,GACD,uBAAuB,CAczB"}
|
package/dist/polling.d.ts
CHANGED
package/dist/polling.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polling.d.ts","sourceRoot":"","sources":["../src/polling.ts"],"names":[],"mappings":"AAAA,wBAAsB,YAAY,CAAC,CAAC,EACnC,IAAI,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,EAChC,SAAS,SAAQ,GACf,OAAO,CAAC,CAAC,CAAC,CAYZ"}
|
|
1
|
+
{"version":3,"file":"polling.d.ts","sourceRoot":"","sources":["../src/polling.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,wBAAsB,YAAY,CAAC,CAAC,EACnC,IAAI,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,EAChC,SAAS,SAAQ,GACf,OAAO,CAAC,CAAC,CAAC,CAYZ"}
|
package/dist/process-driver.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { ProcessInstance } from "@leitwerk-dev/domain";
|
|
2
2
|
import type { AppContext } from "@leitwerk-dev/server";
|
|
3
|
-
/** Drive a running or restarted app without bypassing process HTTP actions. */
|
|
3
|
+
/** Drive a running or restarted app without bypassing process HTTP actions. @public */
|
|
4
4
|
export declare function createProcessDriver(context: () => AppContext): {
|
|
5
|
+
/** @public */
|
|
5
6
|
post: (url: string, payload?: Record<string, unknown>) => Promise<import("light-my-request").Response>;
|
|
7
|
+
/** @public */
|
|
6
8
|
waitForProcess: (id: string, predicate: (process: ProcessInstance) => boolean, description: string, timeout?: number, allowError?: boolean) => Promise<ProcessInstance>;
|
|
9
|
+
/** @public */
|
|
7
10
|
wait: (id: string, turn: string | null, lifecycle?: string, timeout?: number) => Promise<ProcessInstance>;
|
|
11
|
+
/** @public */
|
|
8
12
|
action: (id: string, action: string, input?: Record<string, unknown>) => Promise<import("light-my-request").Response>;
|
|
9
13
|
};
|
|
10
14
|
//# sourceMappingURL=process-driver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-driver.d.ts","sourceRoot":"","sources":["../src/process-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvD
|
|
1
|
+
{"version":3,"file":"process-driver.d.ts","sourceRoot":"","sources":["../src/process-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvD,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,UAAU;IAsC3D,cAAc;gBApCU,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAsChE,cAAc;yBA9BV,MAAM,aACC,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,eACnC,MAAM,6CAGjB,OAAO,CAAC,eAAe,CAAC;IA2B1B,cAAc;eACH,MAAM,QAAQ,MAAM,GAAG,IAAI;IAQtC,cAAc;iBACD,MAAM,UAAU,MAAM,UAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAKpE"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { NormalizedQuestion, ProcessQuestionRequest } from "@leitwerk-dev/domain";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export declare function createTestQuestion(overrides?: Partial<NormalizedQuestion>): NormalizedQuestion;
|
|
4
|
+
/** @internal */
|
|
3
5
|
export declare function createTestQuestionRequest(overrides?: Partial<ProcessQuestionRequest>): ProcessQuestionRequest;
|
|
4
6
|
//# sourceMappingURL=question-fixtures.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"question-fixtures.d.ts","sourceRoot":"","sources":["../src/question-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEvF,wBAAgB,kBAAkB,CACjC,SAAS,GAAE,OAAO,CAAC,kBAAkB,CAAM,GACzC,kBAAkB,CAQpB;AAED,wBAAgB,yBAAyB,CACxC,SAAS,GAAE,OAAO,CAAC,sBAAsB,CAAM,GAC7C,sBAAsB,CAexB"}
|
|
1
|
+
{"version":3,"file":"question-fixtures.d.ts","sourceRoot":"","sources":["../src/question-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEvF,gBAAgB;AAChB,wBAAgB,kBAAkB,CACjC,SAAS,GAAE,OAAO,CAAC,kBAAkB,CAAM,GACzC,kBAAkB,CAQpB;AAED,gBAAgB;AAChB,wBAAgB,yBAAyB,CACxC,SAAS,GAAE,OAAO,CAAC,sBAAsB,CAAM,GAC7C,sBAAsB,CAexB"}
|
|
@@ -1,46 +1,86 @@
|
|
|
1
1
|
import { type ExtensionCatalog } from "@leitwerk-dev/extension-runtime";
|
|
2
|
+
import { type ExternalWriteLogRepoLike } from "@leitwerk-dev/external-writes/internal";
|
|
2
3
|
import { type CoreServerSetupDeps, createEventBus, type IntegrationToolDefinition, type LeitwerkExtensionModule, type ProvidedCapability, type ServerExtensionAPI } from "@leitwerk-dev/process-sdk";
|
|
3
4
|
import { flushAsyncWork } from "@leitwerk-dev/worker-protocol";
|
|
4
5
|
export { flushAsyncWork };
|
|
5
|
-
/** Register a test provider and expose its poll result without erasing its type. */
|
|
6
|
+
/** Register a test provider and expose its poll result without erasing its type. @public */
|
|
6
7
|
export declare function createPollingTestExtension<T>(manifest: LeitwerkExtensionModule["manifest"], setup: (api: ServerExtensionAPI) => {
|
|
8
|
+
/** @internal */
|
|
7
9
|
poll(): Promise<T>;
|
|
8
10
|
} | undefined): {
|
|
9
|
-
|
|
11
|
+
/** @internal */
|
|
12
|
+
manifest: {
|
|
13
|
+
/** @public */
|
|
14
|
+
id: string;
|
|
15
|
+
/** @public */
|
|
16
|
+
version: string;
|
|
17
|
+
/** @public */
|
|
18
|
+
requires?: readonly string[];
|
|
19
|
+
/** @internal */
|
|
20
|
+
optional?: readonly string[];
|
|
21
|
+
};
|
|
22
|
+
/** @internal */
|
|
10
23
|
setupServer(api: ServerExtensionAPI): void;
|
|
24
|
+
/** @public */
|
|
11
25
|
poll(): Promise<T>;
|
|
12
26
|
};
|
|
13
|
-
|
|
27
|
+
/** @internal */
|
|
28
|
+
export declare function createToolCollector(writes?: ExternalWriteLogRepoLike): {
|
|
29
|
+
/** @internal */
|
|
14
30
|
api: ServerExtensionAPI;
|
|
31
|
+
/** @internal */
|
|
15
32
|
tools: Map<string, IntegrationToolDefinition<Record<string, unknown>>>;
|
|
16
33
|
};
|
|
34
|
+
/** @internal */
|
|
17
35
|
export interface InMemoryExternalWriteLog {
|
|
36
|
+
/** @internal */
|
|
18
37
|
records: {
|
|
38
|
+
/** @internal */
|
|
19
39
|
dedupKey: string;
|
|
20
40
|
}[];
|
|
41
|
+
/** @internal */
|
|
21
42
|
hasDedupKey(key: string): boolean;
|
|
43
|
+
/** @internal */
|
|
22
44
|
record(input: {
|
|
45
|
+
/** @internal */
|
|
23
46
|
dedupKey: string;
|
|
24
47
|
}): {
|
|
48
|
+
/** @internal */
|
|
25
49
|
dedupKey: string;
|
|
26
50
|
};
|
|
51
|
+
/** @internal */
|
|
27
52
|
getDedupKeys(): ReadonlySet<string>;
|
|
28
53
|
}
|
|
54
|
+
/** @internal */
|
|
29
55
|
export declare function createInMemoryExternalWriteLog(): InMemoryExternalWriteLog;
|
|
56
|
+
/** @public */
|
|
30
57
|
export declare function createTestServerSetupCapability(overrides?: Partial<CoreServerSetupDeps>): CoreServerSetupDeps;
|
|
58
|
+
/** @internal */
|
|
31
59
|
export interface ServerExtensionTestHarness {
|
|
60
|
+
/** @internal */
|
|
32
61
|
catalog: ExtensionCatalog;
|
|
62
|
+
/** @internal */
|
|
33
63
|
events: ReturnType<typeof createEventBus>;
|
|
64
|
+
/** @internal */
|
|
34
65
|
serverSetup: CoreServerSetupDeps;
|
|
66
|
+
/** @internal */
|
|
35
67
|
startHooks: Array<() => void | Promise<void>>;
|
|
68
|
+
/** @internal */
|
|
36
69
|
stopHooks: Array<() => void | Promise<void>>;
|
|
70
|
+
/** @internal */
|
|
37
71
|
flushAsyncWork: typeof flushAsyncWork;
|
|
38
72
|
}
|
|
73
|
+
/** @internal */
|
|
39
74
|
export declare function setupServerExtensionTest(input: {
|
|
75
|
+
/** @internal */
|
|
40
76
|
modules: readonly LeitwerkExtensionModule[];
|
|
77
|
+
/** @internal */
|
|
41
78
|
providedCapabilities?: readonly ProvidedCapability[];
|
|
79
|
+
/** @internal */
|
|
42
80
|
serverSetup?: Partial<CoreServerSetupDeps>;
|
|
81
|
+
/** @internal */
|
|
43
82
|
onStart?: (handler: () => void | Promise<void>) => void;
|
|
83
|
+
/** @internal */
|
|
44
84
|
onStop?: (handler: () => void | Promise<void>) => void;
|
|
45
85
|
}): Promise<ServerExtensionTestHarness>;
|
|
46
86
|
//# sourceMappingURL=server-extension-test-harness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-extension-test-harness.d.ts","sourceRoot":"","sources":["../src/server-extension-test-harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAyB,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EACN,KAAK,mBAAmB,EAGxB,cAAc,EACd,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAEvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,
|
|
1
|
+
{"version":3,"file":"server-extension-test-harness.d.ts","sourceRoot":"","sources":["../src/server-extension-test-harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAyB,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAEN,KAAK,wBAAwB,EAC7B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,KAAK,mBAAmB,EAGxB,cAAc,EACd,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAEvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,4FAA4F;AAC5F,wBAAgB,0BAA0B,CAAC,CAAC,EAC3C,QAAQ,EAAE,uBAAuB,CAAC,UAAU,CAAC,EAC7C,KAAK,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAC5B;IACA,gBAAgB;IAChB,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CAClB,GACD,SAAS;IAIX,gBAAgB;;;;;;;;;;;IAEhB,gBAAgB;qBACC,kBAAkB;IAGnC,cAAc;;EAMf;AAED,gBAAgB;AAChB,wBAAgB,mBAAmB,CAClC,MAAM,GAAE,wBAA2D;IAelE,gBAAgB;;IAEhB,gBAAgB;;EAGjB;AAED,gBAAgB;AAChB,MAAM,WAAW,wBAAwB;IACxC,gBAAgB;IAChB,OAAO,EAA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AAC;IAC3C,gBAAgB;IAChB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IACxD,gBAAgB;IAChB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;CACvD,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAsCtC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** @internal Bounded, in-memory trace. Call report from onTestFailed; successful tests stay quiet. */
|
|
2
|
+
export declare function createTestDiagnostics(label: string): {
|
|
3
|
+
/** @internal */
|
|
4
|
+
mark: (stage: string, details?: Record<string, unknown>) => void;
|
|
5
|
+
/** @internal */
|
|
6
|
+
run<T>(fn: () => T): T;
|
|
7
|
+
/** @internal */
|
|
8
|
+
format(): string;
|
|
9
|
+
/** @internal */
|
|
10
|
+
report(): void;
|
|
11
|
+
};
|
|
12
|
+
/** @internal Logs only the operation name and exit metadata, never arguments, output or environment. */
|
|
13
|
+
export declare function traceTestSubprocess<T>(operation: string, run: () => T): T;
|
|
14
|
+
//# sourceMappingURL=test-diagnostics.d.ts.map
|