@kurvball/rehearse 1.15.0 → 1.17.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/dist/commands/drive.js +42 -12
- package/dist/commands/inbox.d.ts +10 -0
- package/dist/commands/inbox.js +40 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/up.js +7 -3
- package/dist/drive/open.js +19 -10
- package/dist/drive/state.d.ts +1 -0
- package/dist/inbox/html.d.ts +2 -0
- package/dist/inbox/html.js +163 -0
- package/dist/inbox/index.d.ts +4 -0
- package/dist/inbox/index.js +4 -0
- package/dist/inbox/mail.d.ts +9 -0
- package/dist/inbox/mail.js +148 -0
- package/dist/inbox/messages.d.ts +9 -0
- package/dist/inbox/messages.js +40 -0
- package/dist/inbox/server.d.ts +1 -0
- package/dist/inbox/server.js +9 -0
- package/dist/inbox/smtp.d.ts +9 -0
- package/dist/inbox/smtp.js +158 -0
- package/dist/manifest/inbox.d.ts +3 -0
- package/dist/manifest/inbox.js +22 -0
- package/dist/manifest/index.d.ts +2 -0
- package/dist/manifest/index.js +2 -0
- package/dist/manifest/load.js +16 -0
- package/dist/manifest/order.d.ts +8 -0
- package/dist/manifest/order.js +53 -0
- package/dist/manifest/types.d.ts +2 -0
- package/dist/run/cache.js +3 -2
- package/dist/run/session.js +10 -8
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -0
- package/dist/stage/sending.js +4 -3
- package/llms.txt +2 -1
- package/package.json +1 -1
- package/schema/v1/inbox.schema.json +70 -0
- package/schema/v1/manifest.schema.json +5 -0
- package/schema/v1/samples/inbox.json +17 -0
package/dist/commands/drive.js
CHANGED
|
@@ -6,7 +6,7 @@ import { checkoutOf, manifestOf, said } from './command.js';
|
|
|
6
6
|
import { addToWalk, beginWalk, failed, driveArgv, exitOf, parseDrive, resultText, VERBS, forgetDriving, readDriving, walked, writeDriving, } from '../drive/index.js';
|
|
7
7
|
import { sh, tail } from '../exec.js';
|
|
8
8
|
import { knowKeys } from '../keys/index.js';
|
|
9
|
-
import { fillEnv } from '../manifest/index.js';
|
|
9
|
+
import { fillEnv, withWhatTheyName } from '../manifest/index.js';
|
|
10
10
|
import { applyWorld, baseVars } from '../run/index.js';
|
|
11
11
|
import { alive, runningServices, stateDir, bringDown, bringUp, cwdOf, envOf, handoverSettled, release, } from '../services/index.js';
|
|
12
12
|
import { copiesFor, rootsOf } from '../repositories/index.js';
|
|
@@ -70,26 +70,51 @@ Each answers in the drive result shape (schema/v1/drive.schema.json): 0 done, 1
|
|
|
70
70
|
const world = options.world ?? m.defaults.world;
|
|
71
71
|
let running = runningServices(m.dir).filter((r) => path.resolve(r.checkout) === path.resolve(checkout));
|
|
72
72
|
const already = running.some((r) => r.name === svc.name);
|
|
73
|
+
const alsoStarted = [];
|
|
73
74
|
if (already)
|
|
74
75
|
await knowKeys(m, svc);
|
|
75
76
|
else {
|
|
76
77
|
if (world)
|
|
77
78
|
await applyWorld(m, world, 'before', checkout, baseVars(m, checkout, running));
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
const roots = rootsOf(await copiesFor(m, {}, checkout, ctx.progress, ctx.cwd));
|
|
80
|
+
const startedHere = [];
|
|
81
|
+
try {
|
|
82
|
+
for (const named of withWhatTheyName(m, [svc.name])) {
|
|
83
|
+
if (running.some((r) => r.name === named))
|
|
84
|
+
continue;
|
|
85
|
+
const r = await bringUp(m, m.services[named], checkout, {
|
|
86
|
+
world,
|
|
87
|
+
real: new Set(),
|
|
88
|
+
vars: baseVars(m, checkout, running),
|
|
89
|
+
roots,
|
|
90
|
+
progress: ctx.progress,
|
|
91
|
+
});
|
|
92
|
+
startedHere.push(r);
|
|
93
|
+
if (named === svc.name)
|
|
94
|
+
await handoverSettled(r);
|
|
95
|
+
else
|
|
96
|
+
alsoStarted.push(named);
|
|
97
|
+
release(r);
|
|
98
|
+
running = [...running, r];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
for (const r of startedHere.toReversed())
|
|
103
|
+
await bringDown(m, r, ctx.progress);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
88
106
|
if (world)
|
|
89
107
|
await applyWorld(m, world, 'add', checkout, baseVars(m, checkout, running));
|
|
90
108
|
}
|
|
91
109
|
const since = new Date().toISOString();
|
|
92
|
-
writeDriving(m.dir, {
|
|
110
|
+
writeDriving(m.dir, {
|
|
111
|
+
driver: 'service',
|
|
112
|
+
service: svc.name,
|
|
113
|
+
checkout,
|
|
114
|
+
started: !already,
|
|
115
|
+
...(alsoStarted.length && { alsoStarted }),
|
|
116
|
+
since,
|
|
117
|
+
});
|
|
93
118
|
beginWalk(m.dir, {
|
|
94
119
|
driver: 'service',
|
|
95
120
|
service: svc.name,
|
|
@@ -187,6 +212,11 @@ Each answers in the drive result shape (schema/v1/drive.schema.json): 0 done, 1
|
|
|
187
212
|
if (command.command === 'stop') {
|
|
188
213
|
if (running && driving.started)
|
|
189
214
|
await bringDown(m, running, ctx.progress);
|
|
215
|
+
for (const named of (driving.alsoStarted ?? []).toReversed()) {
|
|
216
|
+
const up = runningServices(m.dir).find((r) => r.name === named && path.resolve(r.checkout) === path.resolve(driving.checkout));
|
|
217
|
+
if (up)
|
|
218
|
+
await bringDown(m, up, ctx.progress);
|
|
219
|
+
}
|
|
190
220
|
forgetDriving(m.dir);
|
|
191
221
|
return answer({
|
|
192
222
|
v: 1,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Command } from './command.ts';
|
|
2
|
+
import { type Message } from '../inbox/index.ts';
|
|
3
|
+
import { type Manifest } from '../manifest/index.ts';
|
|
4
|
+
export declare function inboxOut(m: Manifest, checkout: string, to: string | null): Promise<{
|
|
5
|
+
v: 1;
|
|
6
|
+
checkout: string;
|
|
7
|
+
url: string | null;
|
|
8
|
+
messages: Message[];
|
|
9
|
+
}>;
|
|
10
|
+
export declare const inbox: Command;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { checkoutOf, manifestOf, said } from './command.js';
|
|
2
|
+
import { one } from '../args.js';
|
|
3
|
+
import { RehearseError } from '../errors.js';
|
|
4
|
+
import { messagesIn } from '../inbox/index.js';
|
|
5
|
+
import { INBOX } from '../manifest/index.js';
|
|
6
|
+
import { liveServices } from '../services/index.js';
|
|
7
|
+
export async function inboxOut(m, checkout, to) {
|
|
8
|
+
if (!m.inbox)
|
|
9
|
+
throw new RehearseError('no_inbox', 'The manifest has no inbox: add inbox: {} to rehearse.yaml, and give a service {{inbox_url}}.');
|
|
10
|
+
const up = (await liveServices(m, checkout)).find((r) => r.name === INBOX);
|
|
11
|
+
return {
|
|
12
|
+
v: 1,
|
|
13
|
+
checkout,
|
|
14
|
+
url: up?.url ?? null,
|
|
15
|
+
messages: up?.scratch ? messagesIn(up.scratch, to) : [],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const messageText = (message) => [
|
|
19
|
+
`${message.id} ${message.at.slice(0, 16).replace('T', ' ')} ${message.from ?? '(no sender)'} → ${message.to.join(', ')}`,
|
|
20
|
+
` ${message.subject ?? '(no subject)'}`,
|
|
21
|
+
...message.links.map((link) => ` ${link}`),
|
|
22
|
+
].join('\n');
|
|
23
|
+
export const inbox = {
|
|
24
|
+
name: 'inbox',
|
|
25
|
+
summary: "What Rehearse's test inbox kept: the mail services sent it while it was up.",
|
|
26
|
+
usage: `rehearse inbox [--on <checkout>] [--to <address>] [--json]
|
|
27
|
+
|
|
28
|
+
With inbox: {} in rehearse.yaml, Rehearse runs its own SMTP server as the service inbox, and a service that names
|
|
29
|
+
{{inbox_url}} or {{inbox_port}} brings it up first. It sends nothing on. It keeps mail only while it is up.`,
|
|
30
|
+
spec: { valued: ['on', 'to'], bare: [] },
|
|
31
|
+
async run(args, ctx) {
|
|
32
|
+
const m = manifestOf(ctx);
|
|
33
|
+
const out = await inboxOut(m, checkoutOf(m, one(args, 'on'), ctx.cwd), one(args, 'to'));
|
|
34
|
+
if (out.url === null)
|
|
35
|
+
return said(out, `Rehearse's inbox isn't up in ${out.checkout}: it comes up with a service that names {{inbox_url}}, or with rehearse up inbox.\n`);
|
|
36
|
+
if (out.messages.length === 0)
|
|
37
|
+
return said(out, `Rehearse's inbox at ${out.url} has kept nothing yet.\n`);
|
|
38
|
+
return said(out, `Rehearse's inbox at ${out.url} kept ${out.messages.length === 1 ? 'one message' : `${out.messages.length} messages`}:\n\n${out.messages.map(messageText).join('\n\n')}\n`);
|
|
39
|
+
},
|
|
40
|
+
};
|
package/dist/commands/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { open } from './open.js';
|
|
|
9
9
|
import { record } from './record.js';
|
|
10
10
|
import { run } from './run.js';
|
|
11
11
|
import { down, up } from './up.js';
|
|
12
|
+
import { inbox } from './inbox.js';
|
|
12
13
|
import { init } from './init.js';
|
|
13
14
|
import { keys } from './keys.js';
|
|
14
15
|
import { people } from './people.js';
|
|
@@ -31,6 +32,7 @@ export const COMMANDS = [
|
|
|
31
32
|
list,
|
|
32
33
|
up,
|
|
33
34
|
down,
|
|
35
|
+
inbox,
|
|
34
36
|
run,
|
|
35
37
|
compare,
|
|
36
38
|
announce,
|
package/dist/commands/up.js
CHANGED
|
@@ -7,6 +7,7 @@ import { copiesFor, refsOf, rootsOf } from '../repositories/index.js';
|
|
|
7
7
|
import { baseVars } from '../run/index.js';
|
|
8
8
|
import { applyWorld } from '../worlds/index.js';
|
|
9
9
|
import { overlay } from '../git/index.js';
|
|
10
|
+
import { upOrder, withWhatTheyName } from '../manifest/index.js';
|
|
10
11
|
const rowOf = (r) => ({
|
|
11
12
|
name: r.name,
|
|
12
13
|
checkout: r.checkout,
|
|
@@ -24,10 +25,11 @@ export const up = {
|
|
|
24
25
|
async run(args, ctx) {
|
|
25
26
|
const m = manifestOf(ctx);
|
|
26
27
|
const checkout = checkoutOf(m, one(args, 'on'), ctx.cwd);
|
|
27
|
-
const
|
|
28
|
-
for (const n of
|
|
28
|
+
const asked = args.positional.length ? args.positional : Object.keys(m.services);
|
|
29
|
+
for (const n of asked)
|
|
29
30
|
if (!m.services[n])
|
|
30
31
|
throw new RehearseError('no_service', `There is no service “${n}”: there is ${Object.keys(m.services).join(', ') || 'none'}.`);
|
|
32
|
+
const names = withWhatTheyName(m, asked);
|
|
31
33
|
const world = one(args, 'world') ?? m.defaults.world;
|
|
32
34
|
overlay(m, checkout);
|
|
33
35
|
await makeRoom(m, checkout, ctx.progress);
|
|
@@ -76,7 +78,9 @@ export const down = {
|
|
|
76
78
|
const checkout = all ? null : checkoutOf(m, one(args, 'on'), ctx.cwd);
|
|
77
79
|
const these = runningServices(m.dir).filter((r) => (checkout === null || path.resolve(r.checkout) === path.resolve(checkout)) &&
|
|
78
80
|
(args.positional.length === 0 || args.positional.includes(r.name)));
|
|
79
|
-
|
|
81
|
+
const order = upOrder(m);
|
|
82
|
+
const namersFirst = these.toSorted((a, b) => order.indexOf(b.name) - order.indexOf(a.name));
|
|
83
|
+
for (const r of namersFirst)
|
|
80
84
|
await bringDown(m, r, ctx.progress);
|
|
81
85
|
const out = { v: 1, checkout, world: null, services: these.map(rowOf) };
|
|
82
86
|
return said(out, these.length
|
package/dist/drive/open.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { knowKeys } from '../keys/index.js';
|
|
3
|
-
import { fill } from '../manifest/index.js';
|
|
3
|
+
import { fill, withWhatTheyName } from '../manifest/index.js';
|
|
4
4
|
import { scrub, signIn } from '../people/index.js';
|
|
5
5
|
import { startPieceServer } from '../kinds/index.js';
|
|
6
6
|
import { applyWorld, baseVars } from '../run/index.js';
|
|
@@ -54,18 +54,27 @@ export async function openPage(m, checkout, o, showing = {}) {
|
|
|
54
54
|
else {
|
|
55
55
|
if (o.world)
|
|
56
56
|
await applyWorld(m, o.world, 'before', checkout, baseVars(m, checkout, running));
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
const roots = rootsOf(await copiesFor(m, {}, checkout, showing.progress ?? (() => undefined)));
|
|
58
|
+
for (const named of withWhatTheyName(m, [svc.name])) {
|
|
59
|
+
if (running.some((r) => r.name === named))
|
|
60
|
+
continue;
|
|
61
|
+
const r = await bringUp(m, m.services[named], checkout, {
|
|
62
|
+
world: o.world,
|
|
63
|
+
real: new Set(),
|
|
64
|
+
vars: baseVars(m, checkout, running),
|
|
65
|
+
roots,
|
|
66
|
+
...(showing.progress && { progress: showing.progress }),
|
|
67
|
+
});
|
|
68
|
+
started.push(r);
|
|
69
|
+
running = [...running, r];
|
|
70
|
+
if (named === svc.name)
|
|
71
|
+
mine = r;
|
|
72
|
+
}
|
|
66
73
|
if (o.world)
|
|
67
74
|
await applyWorld(m, o.world, 'add', checkout, baseVars(m, checkout, running));
|
|
68
75
|
}
|
|
76
|
+
if (!mine)
|
|
77
|
+
throw new Error(`${svc.name} didn't come up.`);
|
|
69
78
|
if (!mine.url)
|
|
70
79
|
throw new Error(`${svc.name} has no URL to open.`);
|
|
71
80
|
url = new URL(o.start ?? '/', mine.url).href;
|
package/dist/drive/state.d.ts
CHANGED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
const ENTITIES = {
|
|
2
|
+
amp: '&',
|
|
3
|
+
lt: '<',
|
|
4
|
+
gt: '>',
|
|
5
|
+
quot: '"',
|
|
6
|
+
apos: "'",
|
|
7
|
+
nbsp: ' ',
|
|
8
|
+
lsquo: '‘',
|
|
9
|
+
rsquo: '’',
|
|
10
|
+
ldquo: '“',
|
|
11
|
+
rdquo: '”',
|
|
12
|
+
laquo: '«',
|
|
13
|
+
raquo: '»',
|
|
14
|
+
ndash: '–',
|
|
15
|
+
mdash: '—',
|
|
16
|
+
hellip: '…',
|
|
17
|
+
bull: '•',
|
|
18
|
+
middot: '·',
|
|
19
|
+
copy: '©',
|
|
20
|
+
reg: '®',
|
|
21
|
+
trade: '™',
|
|
22
|
+
euro: '€',
|
|
23
|
+
pound: '£',
|
|
24
|
+
times: '×',
|
|
25
|
+
deg: '°',
|
|
26
|
+
};
|
|
27
|
+
const isCharacter = (code) => Number.isFinite(code) && code > 0 && code < 0x110000 && (code < 0xd800 || code > 0xdfff);
|
|
28
|
+
export const withEntitiesDecoded = (text) => text.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z]+);/gi, (asWritten, name) => {
|
|
29
|
+
if (name.startsWith('#')) {
|
|
30
|
+
const code = name[1]?.toLowerCase() === 'x' ? parseInt(name.slice(2), 16) : parseInt(name.slice(1), 10);
|
|
31
|
+
return isCharacter(code) ? String.fromCodePoint(code) : asWritten;
|
|
32
|
+
}
|
|
33
|
+
const key = name.toLowerCase();
|
|
34
|
+
return Object.hasOwn(ENTITIES, key) ? (ENTITIES[key] ?? asWritten) : asWritten;
|
|
35
|
+
});
|
|
36
|
+
const UNREAD = new Set(['script', 'style', 'head', 'title', 'template', 'noscript']);
|
|
37
|
+
const ON_ITS_OWN_LINE = new Set([
|
|
38
|
+
'address',
|
|
39
|
+
'article',
|
|
40
|
+
'aside',
|
|
41
|
+
'blockquote',
|
|
42
|
+
'br',
|
|
43
|
+
'dd',
|
|
44
|
+
'div',
|
|
45
|
+
'dl',
|
|
46
|
+
'dt',
|
|
47
|
+
'fieldset',
|
|
48
|
+
'figcaption',
|
|
49
|
+
'figure',
|
|
50
|
+
'footer',
|
|
51
|
+
'form',
|
|
52
|
+
'h1',
|
|
53
|
+
'h2',
|
|
54
|
+
'h3',
|
|
55
|
+
'h4',
|
|
56
|
+
'h5',
|
|
57
|
+
'h6',
|
|
58
|
+
'header',
|
|
59
|
+
'hr',
|
|
60
|
+
'li',
|
|
61
|
+
'main',
|
|
62
|
+
'nav',
|
|
63
|
+
'ol',
|
|
64
|
+
'p',
|
|
65
|
+
'pre',
|
|
66
|
+
'section',
|
|
67
|
+
'table',
|
|
68
|
+
'tbody',
|
|
69
|
+
'tfoot',
|
|
70
|
+
'thead',
|
|
71
|
+
'tr',
|
|
72
|
+
'ul',
|
|
73
|
+
]);
|
|
74
|
+
const BETWEEN_CELLS = new Set(['td', 'th']);
|
|
75
|
+
const STARTS_A_TAG = /[A-Za-z/!?]/;
|
|
76
|
+
const SPACE = /\s/;
|
|
77
|
+
const ENDS_A_NAME = /[\s/>]/;
|
|
78
|
+
function endOfTag(html, at) {
|
|
79
|
+
let quote = null;
|
|
80
|
+
let afterEquals = false;
|
|
81
|
+
for (let i = at + 1; i < html.length; i++) {
|
|
82
|
+
const char = html[i] ?? '';
|
|
83
|
+
if (quote !== null) {
|
|
84
|
+
if (char === quote)
|
|
85
|
+
quote = null;
|
|
86
|
+
}
|
|
87
|
+
else if (char === '>')
|
|
88
|
+
return i + 1;
|
|
89
|
+
else if ((char === '"' || char === "'") && afterEquals)
|
|
90
|
+
quote = char;
|
|
91
|
+
else if (char === '=')
|
|
92
|
+
afterEquals = true;
|
|
93
|
+
else if (!SPACE.test(char))
|
|
94
|
+
afterEquals = false;
|
|
95
|
+
}
|
|
96
|
+
return -1;
|
|
97
|
+
}
|
|
98
|
+
function closingTagOf(html, name, from) {
|
|
99
|
+
for (let i = html.indexOf('</', from); i !== -1; i = html.indexOf('</', i + 2)) {
|
|
100
|
+
const named = html.slice(i + 2, i + 2 + name.length).toLowerCase() === name;
|
|
101
|
+
if (named && ENDS_A_NAME.test(html[i + 2 + name.length] ?? '>'))
|
|
102
|
+
return i;
|
|
103
|
+
}
|
|
104
|
+
return -1;
|
|
105
|
+
}
|
|
106
|
+
function tidied(text) {
|
|
107
|
+
const lines = [];
|
|
108
|
+
for (const line of text.split('\n')) {
|
|
109
|
+
const trimmed = line.trim();
|
|
110
|
+
if (trimmed === '' && (lines.length === 0 || lines.at(-1) === ''))
|
|
111
|
+
continue;
|
|
112
|
+
lines.push(trimmed);
|
|
113
|
+
}
|
|
114
|
+
while (lines.at(-1) === '')
|
|
115
|
+
lines.pop();
|
|
116
|
+
return lines.join('\n');
|
|
117
|
+
}
|
|
118
|
+
export function textOfHtml(html) {
|
|
119
|
+
const pieces = [];
|
|
120
|
+
const asText = (from, to) => pieces.push(html.slice(from, to).replace(/\s+/g, ' '));
|
|
121
|
+
let at = 0;
|
|
122
|
+
while (at < html.length) {
|
|
123
|
+
const open = html.indexOf('<', at);
|
|
124
|
+
if (open === -1) {
|
|
125
|
+
asText(at, html.length);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
asText(at, open);
|
|
129
|
+
if (html.startsWith('<!--', open)) {
|
|
130
|
+
const end = html.indexOf('-->', open + 4);
|
|
131
|
+
if (end === -1)
|
|
132
|
+
break;
|
|
133
|
+
at = end + 3;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (!STARTS_A_TAG.test(html[open + 1] ?? '')) {
|
|
137
|
+
pieces.push('<');
|
|
138
|
+
at = open + 1;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const end = endOfTag(html, open);
|
|
142
|
+
if (end === -1) {
|
|
143
|
+
asText(open, html.length);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
const inside = html.slice(open + 1, end - 1);
|
|
147
|
+
const closing = inside.startsWith('/');
|
|
148
|
+
const name = /^\/?\s*([A-Za-z][A-Za-z0-9-]*)/.exec(inside)?.[1]?.toLowerCase() ?? '';
|
|
149
|
+
at = end;
|
|
150
|
+
if (!closing && UNREAD.has(name)) {
|
|
151
|
+
const closer = closingTagOf(html, name, end);
|
|
152
|
+
const after = closer === -1 ? -1 : html.indexOf('>', closer);
|
|
153
|
+
if (after === -1)
|
|
154
|
+
break;
|
|
155
|
+
at = after + 1;
|
|
156
|
+
}
|
|
157
|
+
else if (ON_ITS_OWN_LINE.has(name))
|
|
158
|
+
pieces.push('\n');
|
|
159
|
+
else if (closing && BETWEEN_CELLS.has(name))
|
|
160
|
+
pieces.push(' ');
|
|
161
|
+
}
|
|
162
|
+
return tidied(withEntitiesDecoded(pieces.join('')));
|
|
163
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { textOfHtml, withEntitiesDecoded } from './html.js';
|
|
2
|
+
function decoded(bytes, charset) {
|
|
3
|
+
try {
|
|
4
|
+
return new TextDecoder(charset ?? 'utf-8').decode(bytes);
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return new TextDecoder('utf-8').decode(bytes);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const ENCODED_WORD = /=\?([^?*]+)(?:\*[^?]*)?\?([BbQq])\?([^?]*)\?=/g;
|
|
11
|
+
function fromQuotedPrintable(text, inAHeader) {
|
|
12
|
+
const bytes = [];
|
|
13
|
+
const source = (inAHeader ? text.replace(/_/g, ' ') : text).replace(/=\r?\n/g, '');
|
|
14
|
+
for (let i = 0; i < source.length; i++) {
|
|
15
|
+
const hex = source[i] === '=' ? source.slice(i + 1, i + 3) : '';
|
|
16
|
+
if (/^[0-9A-Fa-f]{2}$/.test(hex)) {
|
|
17
|
+
bytes.push(parseInt(hex, 16));
|
|
18
|
+
i += 2;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const code = source.charCodeAt(i);
|
|
22
|
+
if (code < 0x100)
|
|
23
|
+
bytes.push(code);
|
|
24
|
+
else
|
|
25
|
+
bytes.push(...Buffer.from(source[i], 'utf8'));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return Buffer.from(bytes);
|
|
29
|
+
}
|
|
30
|
+
const runText = (run) => run === null ? '' : decoded(Buffer.concat(run.bytes), run.charset);
|
|
31
|
+
export function headerText(value) {
|
|
32
|
+
let out = '';
|
|
33
|
+
let at = 0;
|
|
34
|
+
let run = null;
|
|
35
|
+
for (const word of value.matchAll(ENCODED_WORD)) {
|
|
36
|
+
const between = value.slice(at, word.index);
|
|
37
|
+
const charset = (word[1] ?? 'utf-8').toLowerCase();
|
|
38
|
+
const text = word[3] ?? '';
|
|
39
|
+
const bytes = word[2]?.toUpperCase() === 'B' ? Buffer.from(text, 'base64') : fromQuotedPrintable(text, true);
|
|
40
|
+
const onlySpace = /^\s*$/.test(between);
|
|
41
|
+
if (run !== null && onlySpace && run.charset === charset)
|
|
42
|
+
run.bytes.push(bytes);
|
|
43
|
+
else {
|
|
44
|
+
out += runText(run);
|
|
45
|
+
if (run === null || !onlySpace)
|
|
46
|
+
out += between;
|
|
47
|
+
run = { charset, bytes: [bytes] };
|
|
48
|
+
}
|
|
49
|
+
at = word.index + word[0].length;
|
|
50
|
+
}
|
|
51
|
+
return out + runText(run) + value.slice(at);
|
|
52
|
+
}
|
|
53
|
+
function partOf(raw) {
|
|
54
|
+
const text = raw.toString('latin1');
|
|
55
|
+
const split = /\r?\n\r?\n/.exec(text);
|
|
56
|
+
const head = split ? text.slice(0, split.index) : text;
|
|
57
|
+
const body = split ? raw.subarray(split.index + split[0].length) : Buffer.alloc(0);
|
|
58
|
+
const headers = new Map();
|
|
59
|
+
for (const line of head.replace(/\r?\n[ \t]+/g, ' ').split(/\r?\n/)) {
|
|
60
|
+
const colon = line.indexOf(':');
|
|
61
|
+
if (colon > 0) {
|
|
62
|
+
const name = line.slice(0, colon).trim().toLowerCase();
|
|
63
|
+
if (!headers.has(name))
|
|
64
|
+
headers.set(name, Buffer.from(line.slice(colon + 1).trim(), 'latin1').toString('utf8'));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { headers, body };
|
|
68
|
+
}
|
|
69
|
+
function parameterOf(header, name) {
|
|
70
|
+
const found = new RegExp(`;\\s*${name}\\s*=\\s*(?:"([^"]*)"|([^;\\s]+))`, 'i').exec(header);
|
|
71
|
+
return found?.[1] ?? found?.[2];
|
|
72
|
+
}
|
|
73
|
+
function bodyOf(part) {
|
|
74
|
+
const encoding = (part.headers.get('content-transfer-encoding') ?? '').toLowerCase();
|
|
75
|
+
const charset = parameterOf(part.headers.get('content-type') ?? '', 'charset');
|
|
76
|
+
const raw = part.body.toString('latin1');
|
|
77
|
+
const bytes = encoding === 'base64'
|
|
78
|
+
? Buffer.from(raw.replace(/\s+/g, ''), 'base64')
|
|
79
|
+
: encoding === 'quoted-printable'
|
|
80
|
+
? fromQuotedPrintable(raw, false)
|
|
81
|
+
: part.body;
|
|
82
|
+
return decoded(bytes, charset);
|
|
83
|
+
}
|
|
84
|
+
const literalPattern = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
85
|
+
function leaves(part, depth = 0) {
|
|
86
|
+
const type = part.headers.get('content-type') ?? 'text/plain';
|
|
87
|
+
const boundary = parameterOf(type, 'boundary');
|
|
88
|
+
if (!/^multipart\//i.test(type) || !boundary || depth > 8)
|
|
89
|
+
return [part];
|
|
90
|
+
const text = `\r\n${part.body.toString('latin1')}`;
|
|
91
|
+
const delimiter = new RegExp(`\\r?\\n--${literalPattern(boundary)}`);
|
|
92
|
+
const found = [];
|
|
93
|
+
for (const piece of text.split(delimiter).slice(1)) {
|
|
94
|
+
if (piece.startsWith('--'))
|
|
95
|
+
break;
|
|
96
|
+
const content = piece.replace(/^[^\n]*\n/, '');
|
|
97
|
+
found.push(...leaves(partOf(Buffer.from(content, 'latin1')), depth + 1));
|
|
98
|
+
}
|
|
99
|
+
return found;
|
|
100
|
+
}
|
|
101
|
+
const LINK_IN_TEXT = /https?:\/\/[^\s<>"]+/gi;
|
|
102
|
+
const LINK_IN_HTML = /\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi;
|
|
103
|
+
const count = (text, char) => text.split(char).length - 1;
|
|
104
|
+
const TRAILING = /[.,;:!?'*]/;
|
|
105
|
+
function withoutTrailingPunctuation(link) {
|
|
106
|
+
const opened = { ')': count(link, '('), ']': count(link, '[') };
|
|
107
|
+
const closed = { ')': count(link, ')'), ']': count(link, ']') };
|
|
108
|
+
let end = link.length;
|
|
109
|
+
while (end > 0) {
|
|
110
|
+
const last = link[end - 1] ?? '';
|
|
111
|
+
if (last === ')' || last === ']') {
|
|
112
|
+
if (closed[last] <= opened[last])
|
|
113
|
+
break;
|
|
114
|
+
closed[last] -= 1;
|
|
115
|
+
}
|
|
116
|
+
else if (!TRAILING.test(last))
|
|
117
|
+
break;
|
|
118
|
+
end -= 1;
|
|
119
|
+
}
|
|
120
|
+
return link.slice(0, end);
|
|
121
|
+
}
|
|
122
|
+
const linksInText = (text) => [...text.matchAll(LINK_IN_TEXT)].map((m) => withoutTrailingPunctuation(m[0]));
|
|
123
|
+
const isAttachment = (part) => /^\s*attachment/i.test(part.headers.get('content-disposition') ?? '');
|
|
124
|
+
export function readMail(raw) {
|
|
125
|
+
const top = partOf(raw);
|
|
126
|
+
const all = leaves(top).filter((p) => !isAttachment(p));
|
|
127
|
+
const plain = all.find((p) => /^text\/plain/i.test(p.headers.get('content-type') ?? 'text/plain'));
|
|
128
|
+
const html = all.find((p) => /^text\/html/i.test(p.headers.get('content-type') ?? ''));
|
|
129
|
+
const plainText = plain ? bodyOf(plain) : null;
|
|
130
|
+
const htmlText = html ? bodyOf(html) : null;
|
|
131
|
+
const htmlAsText = htmlText === null ? null : textOfHtml(htmlText);
|
|
132
|
+
const links = [
|
|
133
|
+
...(htmlText
|
|
134
|
+
? [...htmlText.matchAll(LINK_IN_HTML)].map((m) => withEntitiesDecoded(m[1] ?? m[2] ?? m[3] ?? '').trim())
|
|
135
|
+
: []),
|
|
136
|
+
...(htmlAsText ? linksInText(htmlAsText) : []),
|
|
137
|
+
...(plainText ? linksInText(plainText) : []),
|
|
138
|
+
].filter((link) => /^https?:\/\//i.test(link));
|
|
139
|
+
const from = top.headers.get('from');
|
|
140
|
+
const subject = top.headers.get('subject');
|
|
141
|
+
return {
|
|
142
|
+
from: from === undefined ? null : headerText(from),
|
|
143
|
+
subject: subject === undefined ? null : headerText(subject),
|
|
144
|
+
text: plainText !== null ? plainText.replace(/\r\n/g, '\n').trim() : htmlAsText,
|
|
145
|
+
html: htmlText !== null,
|
|
146
|
+
links: [...new Set(links)],
|
|
147
|
+
};
|
|
148
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Envelope } from './smtp.ts';
|
|
2
|
+
export interface Message extends Envelope {
|
|
3
|
+
subject: string | null;
|
|
4
|
+
text: string | null;
|
|
5
|
+
html: boolean;
|
|
6
|
+
links: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function messageIn(dir: string, id: string): Message | null;
|
|
9
|
+
export declare function messagesIn(scratch: string, to?: string | null): Message[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { readMail } from './mail.js';
|
|
4
|
+
import { mailDir } from './smtp.js';
|
|
5
|
+
export function messageIn(dir, id) {
|
|
6
|
+
const envelope = path.join(dir, `${id}.json`);
|
|
7
|
+
const raw = path.join(dir, `${id}.eml`);
|
|
8
|
+
if (!existsSync(envelope) || !existsSync(raw))
|
|
9
|
+
return null;
|
|
10
|
+
let kept;
|
|
11
|
+
try {
|
|
12
|
+
kept = JSON.parse(readFileSync(envelope, 'utf8'));
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const read = readMail(readFileSync(raw));
|
|
18
|
+
return {
|
|
19
|
+
id: kept.id,
|
|
20
|
+
at: kept.at,
|
|
21
|
+
from: read.from ?? kept.from,
|
|
22
|
+
to: kept.to,
|
|
23
|
+
subject: read.subject,
|
|
24
|
+
text: read.text,
|
|
25
|
+
html: read.html,
|
|
26
|
+
links: read.links,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function messagesIn(scratch, to = null) {
|
|
30
|
+
const dir = mailDir(scratch);
|
|
31
|
+
if (!existsSync(dir))
|
|
32
|
+
return [];
|
|
33
|
+
const wanted = to?.toLowerCase() ?? null;
|
|
34
|
+
return readdirSync(dir)
|
|
35
|
+
.filter((f) => f.endsWith('.json'))
|
|
36
|
+
.sort()
|
|
37
|
+
.map((f) => messageIn(dir, f.slice(0, -'.json'.length)))
|
|
38
|
+
.filter((m) => m !== null)
|
|
39
|
+
.filter((m) => wanted === null || m.to.some((address) => address.toLowerCase() === wanted));
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { mailDir, listen } from './smtp.js';
|
|
2
|
+
const port = Number(process.argv[2]);
|
|
3
|
+
const scratch = process.env.REHEARSE_SCRATCH;
|
|
4
|
+
if (!Number.isInteger(port) || port <= 0 || !scratch) {
|
|
5
|
+
process.stderr.write('Rehearse starts its inbox as a service, with a port and REHEARSE_SCRATCH.\n');
|
|
6
|
+
process.exit(2);
|
|
7
|
+
}
|
|
8
|
+
await listen(port, mailDir(scratch));
|
|
9
|
+
process.stdout.write(`Rehearse's inbox is listening on 127.0.0.1:${port}\n`);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Server } from 'node:net';
|
|
2
|
+
export declare const mailDir: (scratch: string) => string;
|
|
3
|
+
export interface Envelope {
|
|
4
|
+
id: string;
|
|
5
|
+
at: string;
|
|
6
|
+
from: string | null;
|
|
7
|
+
to: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function listen(port: number, dir: string, onMail?: (e: Envelope) => void): Promise<Server>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { mkdirSync, readdirSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { createServer } from 'node:net';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
const MOST_A_MESSAGE_HOLDS = 25 * 1024 * 1024;
|
|
5
|
+
const MOST_A_LINE_HOLDS = 1024 * 1024;
|
|
6
|
+
export const mailDir = (scratch) => path.join(scratch, 'mail');
|
|
7
|
+
const addressIn = (text) => {
|
|
8
|
+
const inBrackets = /<([^>]*)>/.exec(text)?.[1];
|
|
9
|
+
const address = (inBrackets ?? text.trim().split(/\s/)[0] ?? '').trim();
|
|
10
|
+
return address === '' ? null : address;
|
|
11
|
+
};
|
|
12
|
+
function nextIdIn(dir) {
|
|
13
|
+
const taken = readdirSync(dir).filter((f) => f.endsWith('.eml')).length;
|
|
14
|
+
return String(taken + 1).padStart(6, '0');
|
|
15
|
+
}
|
|
16
|
+
function keep(dir, envelope, raw) {
|
|
17
|
+
mkdirSync(dir, { recursive: true });
|
|
18
|
+
const kept = { id: nextIdIn(dir), at: new Date().toISOString(), ...envelope };
|
|
19
|
+
writeFileSync(path.join(dir, `${kept.id}.eml`), raw);
|
|
20
|
+
const file = path.join(dir, `${kept.id}.json`);
|
|
21
|
+
writeFileSync(`${file}.part`, `${JSON.stringify(kept)}\n`);
|
|
22
|
+
renameSync(`${file}.part`, file);
|
|
23
|
+
return kept;
|
|
24
|
+
}
|
|
25
|
+
function converse(socket, dir, onMail) {
|
|
26
|
+
let waiting = 'command';
|
|
27
|
+
let from = null;
|
|
28
|
+
let to = [];
|
|
29
|
+
let pending = Buffer.alloc(0);
|
|
30
|
+
let data = [];
|
|
31
|
+
let size = 0;
|
|
32
|
+
const say = (line) => socket.write(`${line}\r\n`);
|
|
33
|
+
const reset = () => {
|
|
34
|
+
from = null;
|
|
35
|
+
to = [];
|
|
36
|
+
data = [];
|
|
37
|
+
size = 0;
|
|
38
|
+
};
|
|
39
|
+
const command = (line) => {
|
|
40
|
+
const verb = line.slice(0, 4).toUpperCase();
|
|
41
|
+
const rest = line.slice(4).trim();
|
|
42
|
+
if (verb === 'EHLO') {
|
|
43
|
+
socket.write('250-rehearse inbox\r\n250-AUTH PLAIN LOGIN\r\n250-SIZE 26214400\r\n250 8BITMIME\r\n');
|
|
44
|
+
}
|
|
45
|
+
else if (verb === 'HELO')
|
|
46
|
+
say('250 rehearse inbox');
|
|
47
|
+
else if (verb === 'MAIL') {
|
|
48
|
+
reset();
|
|
49
|
+
from = addressIn(rest.replace(/^FROM:/i, ''));
|
|
50
|
+
say('250 OK');
|
|
51
|
+
}
|
|
52
|
+
else if (verb === 'RCPT') {
|
|
53
|
+
const address = addressIn(rest.replace(/^TO:/i, ''));
|
|
54
|
+
if (address)
|
|
55
|
+
to.push(address);
|
|
56
|
+
say('250 OK');
|
|
57
|
+
}
|
|
58
|
+
else if (verb === 'DATA') {
|
|
59
|
+
if (to.length === 0)
|
|
60
|
+
say('554 No one to send it to');
|
|
61
|
+
else {
|
|
62
|
+
waiting = 'data';
|
|
63
|
+
say('354 End it with a line holding only a dot');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (verb === 'AUTH') {
|
|
67
|
+
const [kind, initial] = rest.split(/\s+/);
|
|
68
|
+
if (kind?.toUpperCase() === 'PLAIN') {
|
|
69
|
+
if (initial)
|
|
70
|
+
say('235 Signed in');
|
|
71
|
+
else {
|
|
72
|
+
waiting = 'auth-plain';
|
|
73
|
+
say('334 ');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (kind?.toUpperCase() === 'LOGIN') {
|
|
77
|
+
waiting = initial ? 'auth-login-password' : 'auth-login-user';
|
|
78
|
+
say(initial ? '334 UGFzc3dvcmQ6' : '334 VXNlcm5hbWU6');
|
|
79
|
+
}
|
|
80
|
+
else
|
|
81
|
+
say('504 Only PLAIN and LOGIN');
|
|
82
|
+
}
|
|
83
|
+
else if (verb === 'RSET') {
|
|
84
|
+
reset();
|
|
85
|
+
say('250 OK');
|
|
86
|
+
}
|
|
87
|
+
else if (verb === 'NOOP')
|
|
88
|
+
say('250 OK');
|
|
89
|
+
else if (verb === 'QUIT') {
|
|
90
|
+
say('221 Bye');
|
|
91
|
+
socket.end();
|
|
92
|
+
}
|
|
93
|
+
else
|
|
94
|
+
say('502 Not something this inbox does');
|
|
95
|
+
};
|
|
96
|
+
const line = (text) => {
|
|
97
|
+
if (waiting === 'command')
|
|
98
|
+
return command(text);
|
|
99
|
+
if (waiting === 'auth-plain') {
|
|
100
|
+
waiting = 'command';
|
|
101
|
+
return say('235 Signed in');
|
|
102
|
+
}
|
|
103
|
+
if (waiting === 'auth-login-user') {
|
|
104
|
+
waiting = 'auth-login-password';
|
|
105
|
+
return say('334 UGFzc3dvcmQ6');
|
|
106
|
+
}
|
|
107
|
+
if (waiting === 'auth-login-password') {
|
|
108
|
+
waiting = 'command';
|
|
109
|
+
return say('235 Signed in');
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const dataLine = (raw) => {
|
|
113
|
+
const text = raw.toString('latin1');
|
|
114
|
+
if (text === '.\r\n' || text === '.\n') {
|
|
115
|
+
waiting = 'command';
|
|
116
|
+
if (size > MOST_A_MESSAGE_HOLDS)
|
|
117
|
+
say('552 Larger than this inbox keeps');
|
|
118
|
+
else {
|
|
119
|
+
const kept = keep(dir, { from, to }, Buffer.concat(data));
|
|
120
|
+
onMail(kept);
|
|
121
|
+
say(`250 Kept as ${kept.id}`);
|
|
122
|
+
}
|
|
123
|
+
reset();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const unstuffed = text.startsWith('..') ? raw.subarray(1) : raw;
|
|
127
|
+
size += unstuffed.length;
|
|
128
|
+
if (size <= MOST_A_MESSAGE_HOLDS)
|
|
129
|
+
data.push(unstuffed);
|
|
130
|
+
};
|
|
131
|
+
socket.on('data', (chunk) => {
|
|
132
|
+
pending = Buffer.concat([pending, chunk]);
|
|
133
|
+
if (pending.indexOf(10) === -1 && pending.length > MOST_A_LINE_HOLDS) {
|
|
134
|
+
say('500 A line longer than this inbox reads');
|
|
135
|
+
socket.end();
|
|
136
|
+
pending = Buffer.alloc(0);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
for (let end = pending.indexOf(10); end !== -1; end = pending.indexOf(10)) {
|
|
140
|
+
const raw = pending.subarray(0, end + 1);
|
|
141
|
+
pending = pending.subarray(end + 1);
|
|
142
|
+
if (waiting === 'data')
|
|
143
|
+
dataLine(raw);
|
|
144
|
+
else
|
|
145
|
+
line(raw.toString('utf8').replace(/\r?\n$/, ''));
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
socket.on('error', () => socket.destroy());
|
|
149
|
+
say('220 rehearse inbox: it keeps what it is sent, and sends nothing on');
|
|
150
|
+
}
|
|
151
|
+
export function listen(port, dir, onMail = () => undefined) {
|
|
152
|
+
mkdirSync(dir, { recursive: true });
|
|
153
|
+
const server = createServer((socket) => converse(socket, dir, onMail));
|
|
154
|
+
return new Promise((resolve, reject) => {
|
|
155
|
+
server.once('error', reject);
|
|
156
|
+
server.listen(port, '127.0.0.1', () => resolve(server));
|
|
157
|
+
});
|
|
158
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
export const INBOX = 'inbox';
|
|
4
|
+
const here = fileURLToPath(import.meta.url);
|
|
5
|
+
const serverFile = path.join(path.dirname(here), '..', 'inbox', `server${path.extname(here)}`);
|
|
6
|
+
const quoted = (text) => `'${text.replace(/'/g, `'\\''`)}'`;
|
|
7
|
+
export const inboxService = () => ({
|
|
8
|
+
name: INBOX,
|
|
9
|
+
describe: "Rehearse's test inbox: it keeps the mail services send it, and sends none on.",
|
|
10
|
+
up: `${quoted(process.execPath)} ${quoted(serverFile)} {{port}}`,
|
|
11
|
+
cwd: null,
|
|
12
|
+
port: 'auto',
|
|
13
|
+
url: 'smtp://127.0.0.1:{{port}}',
|
|
14
|
+
ready: { log: "Rehearse's inbox is listening" },
|
|
15
|
+
timeoutMs: 15_000,
|
|
16
|
+
down: null,
|
|
17
|
+
env: {},
|
|
18
|
+
isolate: null,
|
|
19
|
+
drive: null,
|
|
20
|
+
keys: {},
|
|
21
|
+
repository: null,
|
|
22
|
+
});
|
package/dist/manifest/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { fill, fillEnv, placeholdersIn } from './fill.ts';
|
|
2
|
+
export { INBOX } from './inbox.ts';
|
|
2
3
|
export { STARTER, STARTER_BLOCKS, STARTER_HEAD } from './init.ts';
|
|
4
|
+
export { servicesNamedBy, upOrder, withWhatTheyName } from './order.ts';
|
|
3
5
|
export { findManifest, hashOf, INERT_BY_DEFAULT, loadManifest, MANIFEST_FILE, manifestFrom } from './load.ts';
|
|
4
6
|
export { KIND_BLOCK, KINDS, type Key, type Kind, type Manifest, type PathEntry, type Person, type Real, type Repository, type Service, type Standin, type World, } from './types.ts';
|
|
5
7
|
export { readYaml } from './yaml.ts';
|
package/dist/manifest/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { fill, fillEnv, placeholdersIn } from './fill.js';
|
|
2
|
+
export { INBOX } from './inbox.js';
|
|
2
3
|
export { STARTER, STARTER_BLOCKS, STARTER_HEAD } from './init.js';
|
|
4
|
+
export { servicesNamedBy, upOrder, withWhatTheyName } from './order.js';
|
|
3
5
|
export { findManifest, hashOf, INERT_BY_DEFAULT, loadManifest, MANIFEST_FILE, manifestFrom } from './load.js';
|
|
4
6
|
export { KIND_BLOCK, KINDS, } from './types.js';
|
|
5
7
|
export { readYaml } from './yaml.js';
|
package/dist/manifest/load.js
CHANGED
|
@@ -3,6 +3,8 @@ import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { RehearseError } from '../errors.js';
|
|
5
5
|
import { validate } from '../schema.js';
|
|
6
|
+
import { INBOX, inboxService } from './inbox.js';
|
|
7
|
+
import { NamedInACircle, upOrder } from './order.js';
|
|
6
8
|
import { readYaml } from './yaml.js';
|
|
7
9
|
export const INERT_BY_DEFAULT = [
|
|
8
10
|
'.changeset/*.md',
|
|
@@ -173,6 +175,14 @@ function checkWhatTheSchemaCant(m) {
|
|
|
173
175
|
if (alsoFrom)
|
|
174
176
|
refuse(m.file, at(['services', s.name, 'keys', env]), `${s.name} gets ${env} from both ${alsoFrom.includes(' ') || alsoFrom === 'Rehearse' ? alsoFrom : `the stand-in ${alsoFrom}`} and its keys: give it one of them.`);
|
|
175
177
|
}
|
|
178
|
+
try {
|
|
179
|
+
upOrder(m);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (!(error instanceof NamedInACircle))
|
|
183
|
+
throw error;
|
|
184
|
+
refuse(m.file, at(['services', error.circle[0]]), error.message);
|
|
185
|
+
}
|
|
176
186
|
for (const [i, rule] of [...m.setAside.keys, ...m.setAside.values].entries()) {
|
|
177
187
|
try {
|
|
178
188
|
void new RegExp(rule);
|
|
@@ -232,6 +242,11 @@ export function manifestFrom(text, file) {
|
|
|
232
242
|
? { command: raw.signIn, service: null, cwd: null }
|
|
233
243
|
: { command: raw.signIn.command, service: raw.signIn.service ?? null, cwd: raw.signIn.cwd ?? null };
|
|
234
244
|
const firstService = Object.values(services).find((s) => s.url !== null)?.name ?? Object.keys(services)[0] ?? null;
|
|
245
|
+
if (raw.inbox !== undefined) {
|
|
246
|
+
if (INBOX in services)
|
|
247
|
+
refuse(file, read.lineOf(['services', INBOX]), "Rehearse's own inbox is the service “inbox”, so yours can't have its name: rename it, or leave inbox out.");
|
|
248
|
+
services[INBOX] = inboxService();
|
|
249
|
+
}
|
|
235
250
|
const m = {
|
|
236
251
|
file,
|
|
237
252
|
dir,
|
|
@@ -261,6 +276,7 @@ export function manifestFrom(text, file) {
|
|
|
261
276
|
budget: { services: raw.budget?.services ?? 1, checkouts: raw.budget?.checkouts ?? 3 },
|
|
262
277
|
keys: Object.fromEntries(Object.entries(raw.keys ?? {}).map(([n, k]) => [n, keyOf(n, k)])),
|
|
263
278
|
repositories: Object.fromEntries(Object.entries(raw.repositories ?? {}).map(([n, r]) => [n, repositoryOf(dir, n, r)])),
|
|
279
|
+
inbox: raw.inbox !== undefined,
|
|
264
280
|
lineOf: (at, key) => read.lineOf(at, key),
|
|
265
281
|
};
|
|
266
282
|
checkWhatTheSchemaCant(m);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Manifest, Service } from './types.ts';
|
|
2
|
+
export declare function servicesNamedBy(m: Manifest, s: Service): string[];
|
|
3
|
+
export declare class NamedInACircle extends Error {
|
|
4
|
+
readonly circle: readonly string[];
|
|
5
|
+
constructor(circle: readonly string[]);
|
|
6
|
+
}
|
|
7
|
+
export declare const upOrder: (m: Manifest) => string[];
|
|
8
|
+
export declare const withWhatTheyName: (m: Manifest, names: Iterable<string>) => string[];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { placeholdersIn } from './fill.js';
|
|
2
|
+
const ANOTHERS_ADDRESS = /^([A-Za-z_][A-Za-z0-9_-]*)_(?:url|port)$/;
|
|
3
|
+
const serviceNamed = (m, name) => Object.hasOwn(m.services, name) ? m.services[name] : undefined;
|
|
4
|
+
function textsOf(m, s) {
|
|
5
|
+
const standins = Object.values(m.standins).filter((x) => x.services === null || x.services.includes(s.name));
|
|
6
|
+
return [
|
|
7
|
+
s.up,
|
|
8
|
+
s.url,
|
|
9
|
+
s.down,
|
|
10
|
+
...(s.ready === null ? [] : Object.values(s.ready)),
|
|
11
|
+
...Object.values(s.env),
|
|
12
|
+
...standins.flatMap((x) => [...Object.values(x.env), ...Object.values(x.real?.env ?? {})]),
|
|
13
|
+
].filter((t) => typeof t === 'string');
|
|
14
|
+
}
|
|
15
|
+
export function servicesNamedBy(m, s) {
|
|
16
|
+
const named = new Set();
|
|
17
|
+
for (const text of textsOf(m, s))
|
|
18
|
+
for (const placeholder of placeholdersIn(text)) {
|
|
19
|
+
const name = ANOTHERS_ADDRESS.exec(placeholder)?.[1];
|
|
20
|
+
if (name !== undefined && name !== s.name && serviceNamed(m, name))
|
|
21
|
+
named.add(name);
|
|
22
|
+
}
|
|
23
|
+
return Object.keys(m.services).filter((name) => named.has(name));
|
|
24
|
+
}
|
|
25
|
+
export class NamedInACircle extends Error {
|
|
26
|
+
circle;
|
|
27
|
+
constructor(circle) {
|
|
28
|
+
super(`${circle
|
|
29
|
+
.slice(0, -1)
|
|
30
|
+
.map((name, i) => `${name} names ${circle[i + 1]}'s address`)
|
|
31
|
+
.join(', ')}, so none of them can come up first.`);
|
|
32
|
+
this.circle = circle;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function dependenciesFirst(m, names) {
|
|
36
|
+
const order = [];
|
|
37
|
+
const visit = (name, path) => {
|
|
38
|
+
if (order.includes(name))
|
|
39
|
+
return;
|
|
40
|
+
if (path.includes(name))
|
|
41
|
+
throw new NamedInACircle([...path.slice(path.indexOf(name)), name]);
|
|
42
|
+
const s = serviceNamed(m, name);
|
|
43
|
+
if (s)
|
|
44
|
+
for (const named of servicesNamedBy(m, s))
|
|
45
|
+
visit(named, [...path, name]);
|
|
46
|
+
order.push(name);
|
|
47
|
+
};
|
|
48
|
+
for (const name of names)
|
|
49
|
+
visit(name, []);
|
|
50
|
+
return order;
|
|
51
|
+
}
|
|
52
|
+
export const upOrder = (m) => dependenciesFirst(m, Object.keys(m.services));
|
|
53
|
+
export const withWhatTheyName = (m, names) => dependenciesFirst(m, names);
|
package/dist/manifest/types.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export interface RawManifest {
|
|
|
48
48
|
};
|
|
49
49
|
keys?: Record<string, RawKey>;
|
|
50
50
|
repositories?: Record<string, RawRepository>;
|
|
51
|
+
inbox?: Record<string, never>;
|
|
51
52
|
}
|
|
52
53
|
export interface RawRepository {
|
|
53
54
|
from: string;
|
|
@@ -282,5 +283,6 @@ export interface Manifest {
|
|
|
282
283
|
};
|
|
283
284
|
keys: Record<string, Key>;
|
|
284
285
|
repositories: Record<string, Repository>;
|
|
286
|
+
inbox: boolean;
|
|
285
287
|
lineOf(at: readonly string[], key?: string): number | undefined;
|
|
286
288
|
}
|
package/dist/run/cache.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { hashOf } from '../manifest/index.js';
|
|
4
|
+
import { hashOf, withWhatTheyName } from '../manifest/index.js';
|
|
5
5
|
import { stateDir } from '../services/index.js';
|
|
6
6
|
import { chainOf } from '../worlds/index.js';
|
|
7
7
|
import { dirtyAnywhere } from './observation.js';
|
|
@@ -60,7 +60,8 @@ export async function groupsOf(m, scenarios, world) {
|
|
|
60
60
|
return out;
|
|
61
61
|
}
|
|
62
62
|
export function cacheKeyOf(p) {
|
|
63
|
-
const
|
|
63
|
+
const own = p.runner.services(p.scenario, p.manifest);
|
|
64
|
+
const services = [...own, ...withWhatTheyName(p.manifest, own).filter((name) => !own.includes(name))];
|
|
64
65
|
return hashOf({
|
|
65
66
|
commit: p.commit,
|
|
66
67
|
...(p.copies && { copies: p.copies }),
|
package/dist/run/session.js
CHANGED
|
@@ -5,7 +5,7 @@ import { toPosix, refOf } from '../scenarios/index.js';
|
|
|
5
5
|
import { RehearseError, errorText } from '../errors.js';
|
|
6
6
|
import { broken, runnerOf, } from '../kinds/index.js';
|
|
7
7
|
import { knowKeys, withoutKeysDeep } from '../keys/index.js';
|
|
8
|
-
import { fill } from '../manifest/index.js';
|
|
8
|
+
import { fill, upOrder, withWhatTheyName } from '../manifest/index.js';
|
|
9
9
|
import { signIn } from '../people/index.js';
|
|
10
10
|
import { rootsOf } from '../repositories/index.js';
|
|
11
11
|
import { stateDir, bringDown, bringUp, handoverSettled, inUse, liveServices, makeRoom, release, standinsFor, upFromAnotherCopy, } from '../services/index.js';
|
|
@@ -79,18 +79,20 @@ async function planOf(m, world, group) {
|
|
|
79
79
|
...everyServiceWhenTheWorldAdds(m, world),
|
|
80
80
|
...(m.signIn?.service ? [m.signIn.service] : []),
|
|
81
81
|
];
|
|
82
|
-
const needed = new Set([
|
|
82
|
+
const needed = new Set(withWhatTheyName(m, [
|
|
83
83
|
...group.flatMap((s) => runners.get(s.kind).services(s, m)),
|
|
84
84
|
...everyServiceWhenTheWorldAdds(m, world),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
needed.add(m.signIn.service);
|
|
85
|
+
...(m.signIn?.service ? [m.signIn.service] : []),
|
|
86
|
+
]));
|
|
88
87
|
return {
|
|
89
88
|
world,
|
|
90
89
|
group,
|
|
91
90
|
runners,
|
|
92
91
|
needed,
|
|
93
|
-
servicesOf: (s) =>
|
|
92
|
+
servicesOf: (s) => {
|
|
93
|
+
const own = [...new Set([...runners.get(s.kind).services(s, m), ...forEveryScenario])];
|
|
94
|
+
return [...own, ...withWhatTheyName(m, own).filter((name) => !own.includes(name))];
|
|
95
|
+
},
|
|
94
96
|
};
|
|
95
97
|
}
|
|
96
98
|
function undeclaredIn(m, needed) {
|
|
@@ -130,7 +132,7 @@ async function runGroup(side, world, group, runners, needed, upAlready, rehearse
|
|
|
130
132
|
await makeRoom(m, checkout, o.progress);
|
|
131
133
|
if (world && fresh.length)
|
|
132
134
|
await applyWorld(m, world, 'before', checkout, vars());
|
|
133
|
-
for (const name of
|
|
135
|
+
for (const name of upOrder(m).filter((n) => fresh.includes(n))) {
|
|
134
136
|
bringingUp = name;
|
|
135
137
|
const r = await bringUp(m, m.services[name], checkout, {
|
|
136
138
|
world,
|
|
@@ -144,7 +146,7 @@ async function runGroup(side, world, group, runners, needed, upAlready, rehearse
|
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
catch (error) {
|
|
147
|
-
for (const r of started)
|
|
149
|
+
for (const r of started.toReversed())
|
|
148
150
|
await bringDown(m, r, o.progress);
|
|
149
151
|
out.broke = {
|
|
150
152
|
step: error instanceof RehearseError && error.code === 'world' ? 'world' : 'up',
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ErrorObject, type ValidateFunction } from 'ajv/dist/2020.js';
|
|
2
2
|
export declare const SCHEMA_DIR: string;
|
|
3
|
-
export declare const SCHEMAS: readonly ['manifest', 'flow', 'file-scenario', 'announce', 'services', 'keys', 'people', 'worlds', 'list', 'observation', 'comparison', 'drive', 'open', 'stage', 'static', 'try', 'error', 'dependents', 'check', 'init', 'validate', 'up', 'clean', 'record'];
|
|
3
|
+
export declare const SCHEMAS: readonly ['manifest', 'flow', 'file-scenario', 'announce', 'services', 'keys', 'people', 'worlds', 'list', 'observation', 'comparison', 'drive', 'open', 'stage', 'static', 'try', 'error', 'dependents', 'check', 'init', 'validate', 'up', 'clean', 'record', 'inbox'];
|
|
4
4
|
export type SchemaName = (typeof SCHEMAS)[number];
|
|
5
5
|
export declare const schemaId: (name: SchemaName | 'common') => string;
|
|
6
6
|
export declare function validatorOf(name: SchemaName): ValidateFunction;
|
package/dist/schema.js
CHANGED
package/dist/stage/sending.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RehearseError } from '../errors.js';
|
|
2
|
-
import { fill } from '../manifest/index.js';
|
|
2
|
+
import { fill, upOrder } from '../manifest/index.js';
|
|
3
3
|
import { signIn } from '../people/index.js';
|
|
4
4
|
import { applyWorld, baseVars } from '../run/index.js';
|
|
5
5
|
import { rootsOf } from '../repositories/index.js';
|
|
@@ -29,10 +29,11 @@ export function servicesForSending(m, checkoutOf, copiesOn, progress) {
|
|
|
29
29
|
throw new RehearseError('service', `${already.name} is already up on the ${side} with ${already.world ? `the world ${already.world}` : 'no world'}: bring it down with rehearse down to send in ${world ? `the world ${world}` : 'no world'}.`);
|
|
30
30
|
const started = [];
|
|
31
31
|
try {
|
|
32
|
-
const
|
|
32
|
+
const inOrder = upOrder(m).map((name) => m.services[name]);
|
|
33
|
+
const fresh = inOrder.some((s) => !running.some((r) => r.name === s.name));
|
|
33
34
|
if (world && fresh)
|
|
34
35
|
await applyWorld(m, world, 'before', checkout, baseVars(m, checkout, running));
|
|
35
|
-
for (const s of
|
|
36
|
+
for (const s of inOrder) {
|
|
36
37
|
if (running.some((r) => r.name === s.name))
|
|
37
38
|
continue;
|
|
38
39
|
const r = await bringUp(m, s, checkout, {
|
package/llms.txt
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
- `rehearse keys [--check] [--json]` and `rehearse keys add <key>`: the keys services need (manifest `keys`: an op:// reference, or this computer's key store), where each comes from and who gets it as which variable; --check looks each up (found, missing, live, short, unreadable; exit 1 when one isn't there); add keeps one on this computer from stdin. Never prints a key (schema keys).
|
|
11
11
|
- `rehearse list [--affected <file>… | --since <ref>] [--json]`: the scenarios, or those a change reaches, each with reachedBy (schema list).
|
|
12
12
|
- `rehearse up [<service>…] [--on <checkout>] [--repository <name=ref|folder>]… [--world] [--real <stand-in>]` and `rehearse down [--all]`: services left running with a world built on them (schema up).
|
|
13
|
+
- `rehearse inbox [--on <checkout>] [--to <address>] --json`: with top-level `inbox: {}`, Rehearse runs its own SMTP server as the service `inbox` (smtp://127.0.0.1:<port>), which keeps every message and sends none on; a service that names {{inbox_url}} or {{inbox_port}} brings it up first. inbox lists what it kept while up, oldest first: {checkout, url (null when down), messages: [{id, at, from, to, subject, text, html, links}]} (schema inbox); refuses with code no_inbox when the manifest has none.
|
|
13
14
|
- `rehearse run <scenario> [--on <checkout|ref>] [--repository <name=ref|folder>]… [--world] [--as <person>] [--real <stand-in>] [--keep] [--parallel <n>] --json`: one observation (schema observation). A service whose manifest entry names a `repository` (top-level `repositories: {name: {from, base?, prepare?}}`) runs in a fresh, prepared copy of that repository at its base, or at what --repository names; checkout.repositories gives each copy's {path, ref, commit, dirty}.
|
|
14
15
|
- `rehearse compare [<id or glob>…] [--affected] [--base <ref|./folder>] [--head <ref|./folder>] [--base-repository <name=ref|folder>]… [--head-repository <name=ref|folder>]… [--announce <file>] [--announce-from changesets] [--said <id>]… [--world] [--as] [--real] [--fresh] [--parallel <n>] [--gate [--preview <url>]] --json`: a verdict per scenario (schema comparison). --gate prints a gate answer instead ({v, ok, summary, details, annotations, links, tool}; exit 0 ok, 1 not, 2 can't compare). --announce-from changesets also reads the `announce` blocks of the changesets the change adds. Exit 0 when both sides came up and nothing fails on the head or changed without saying so. --parallel runs groups that share no service at once, and the base beside the head when budget.services allows two; the result is the same as one at a time.
|
|
15
16
|
- `rehearse announce [<id or glob>…] [--draft] [--base] [--head] [--announce <file>] [--announce-from changesets] [--said <id>]… [--format yaml|changeset] --json`: what a comparison would read as announced (schema announce); with --draft (and compare's own options) it compares and proposes {scenario, why} for each scenario whose verdict is unsaid, its why the first difference, for you to rewrite as the reason. --format changeset prints an `announce` block for a changeset. It writes no file; refuses with code not_compared when the base or head doesn't come up.
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
## Schemas (schema/v1/)
|
|
40
41
|
|
|
41
42
|
- manifest.schema.json: rehearse.yaml. flow.schema.json: *.flow.yaml. file-scenario.schema.json: *.rehearse.yaml. announce.schema.json: announcements, and what `rehearse announce --json` prints.
|
|
42
|
-
- check, init, services, keys, people, worlds, list, up, observation, comparison, drive, record, open, static, try, clean, validate, error: one per command's --json output, each with a sample in schema/v1/samples/.
|
|
43
|
+
- check, init, services, keys, people, worlds, list, up, inbox, observation, comparison, drive, record, open, static, try, clean, validate, error: one per command's --json output, each with a sample in schema/v1/samples/.
|
|
43
44
|
- dependents.schema.json: what Rehearse reads from an import graph (`ashlar dependents <files> --json`, or the manifest's affected.graph).
|
|
44
45
|
- Within v1 an output only gains optional fields, and open string fields may gain values: readers ignore what they don't know.
|
|
45
46
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurvball/rehearse",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Rehearse a change before it ships: bring the product up, sign in as named people, start from named worlds, and compare any scenario on the base and on the head.",
|
|
5
5
|
"homepage": "https://rehearse.kurvball.ca/",
|
|
6
6
|
"repository": {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://rehearse.kurvball.ca/schema/v1/inbox.schema.json",
|
|
4
|
+
"title": "Rehearse v1: rehearse inbox --json",
|
|
5
|
+
"description": "What Rehearse's test inbox kept in one checkout: the mail its services sent while it was up, oldest first.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["v", "checkout", "url", "messages"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"v": {
|
|
10
|
+
"$ref": "common.schema.json#/$defs/v"
|
|
11
|
+
},
|
|
12
|
+
"checkout": {
|
|
13
|
+
"description": "The checkout whose inbox this is.",
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"url": {
|
|
17
|
+
"description": "Where the inbox listens, smtp://127.0.0.1:<port>, or null when it isn't up. It keeps mail only while it is up.",
|
|
18
|
+
"type": ["string", "null"]
|
|
19
|
+
},
|
|
20
|
+
"messages": {
|
|
21
|
+
"description": "What it kept, oldest first.",
|
|
22
|
+
"type": "array",
|
|
23
|
+
"items": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"required": ["id", "at", "from", "to", "subject", "text", "html", "links"],
|
|
26
|
+
"properties": {
|
|
27
|
+
"id": {
|
|
28
|
+
"description": "Its number in this inbox, from 000001.",
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"at": {
|
|
32
|
+
"description": "When the inbox got it.",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"format": "date-time"
|
|
35
|
+
},
|
|
36
|
+
"from": {
|
|
37
|
+
"description": "Its From header, else the address it was sent from.",
|
|
38
|
+
"type": ["string", "null"]
|
|
39
|
+
},
|
|
40
|
+
"to": {
|
|
41
|
+
"description": "The addresses it was sent to.",
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"subject": {
|
|
48
|
+
"description": "Its Subject header, decoded.",
|
|
49
|
+
"type": ["string", "null"]
|
|
50
|
+
},
|
|
51
|
+
"text": {
|
|
52
|
+
"description": "Its plain text, or the text of its HTML when it has no plain part. It is text, never markup: show it as text, since it can hold < and > as the mail wrote them.",
|
|
53
|
+
"type": ["string", "null"]
|
|
54
|
+
},
|
|
55
|
+
"html": {
|
|
56
|
+
"description": "Whether it has an HTML part.",
|
|
57
|
+
"type": "boolean"
|
|
58
|
+
},
|
|
59
|
+
"links": {
|
|
60
|
+
"description": "Every http and https link in it, in order, once each.",
|
|
61
|
+
"type": "array",
|
|
62
|
+
"items": {
|
|
63
|
+
"type": "string"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -139,6 +139,11 @@
|
|
|
139
139
|
"propertyNames": { "$ref": "#/$defs/name" },
|
|
140
140
|
"additionalProperties": { "$ref": "#/$defs/key" }
|
|
141
141
|
},
|
|
142
|
+
"inbox": {
|
|
143
|
+
"description": "Rehearse's own test inbox, run as the service inbox: an SMTP server on 127.0.0.1 that keeps the mail services send it, and sends none on. A service that names {{inbox_url}} (smtp://127.0.0.1:<port>) or {{inbox_port}} brings it up first. Write inbox: {}.",
|
|
144
|
+
"type": "object",
|
|
145
|
+
"additionalProperties": false
|
|
146
|
+
},
|
|
142
147
|
"repositories": {
|
|
143
148
|
"description": "Other repositories services run from, by name. Rehearse keeps a clone of each and runs a service in a fresh copy of the commit each side needs: its base, unless the change names another.",
|
|
144
149
|
"type": "object",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"v": 1,
|
|
3
|
+
"checkout": "/work/shop",
|
|
4
|
+
"url": "smtp://127.0.0.1:41733",
|
|
5
|
+
"messages": [
|
|
6
|
+
{
|
|
7
|
+
"id": "000001",
|
|
8
|
+
"at": "2026-12-06T10:02:11.482Z",
|
|
9
|
+
"from": "Shop <orders@shop.example>",
|
|
10
|
+
"to": ["ada@example.com"],
|
|
11
|
+
"subject": "Your sign-in link",
|
|
12
|
+
"text": "Sign in to the shop:\nhttp://127.0.0.1:5173/sign-in?code=4821",
|
|
13
|
+
"html": false,
|
|
14
|
+
"links": ["http://127.0.0.1:5173/sign-in?code=4821"]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|