@kurvball/rehearse 1.16.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/inbox.d.ts +10 -0
- package/dist/commands/inbox.js +40 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/up.js +4 -2
- 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 +1 -0
- package/dist/manifest/index.js +1 -0
- package/dist/manifest/load.js +7 -0
- package/dist/manifest/types.d.ts +2 -0
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -0
- 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
|
@@ -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,7 +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 { withWhatTheyName } from '../manifest/index.js';
|
|
10
|
+
import { upOrder, withWhatTheyName } from '../manifest/index.js';
|
|
11
11
|
const rowOf = (r) => ({
|
|
12
12
|
name: r.name,
|
|
13
13
|
checkout: r.checkout,
|
|
@@ -78,7 +78,9 @@ export const down = {
|
|
|
78
78
|
const checkout = all ? null : checkoutOf(m, one(args, 'on'), ctx.cwd);
|
|
79
79
|
const these = runningServices(m.dir).filter((r) => (checkout === null || path.resolve(r.checkout) === path.resolve(checkout)) &&
|
|
80
80
|
(args.positional.length === 0 || args.positional.includes(r.name)));
|
|
81
|
-
|
|
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)
|
|
82
84
|
await bringDown(m, r, ctx.progress);
|
|
83
85
|
const out = { v: 1, checkout, world: null, services: these.map(rowOf) };
|
|
84
86
|
return said(out, these.length
|
|
@@ -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,4 +1,5 @@
|
|
|
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';
|
|
3
4
|
export { servicesNamedBy, upOrder, withWhatTheyName } from './order.ts';
|
|
4
5
|
export { findManifest, hashOf, INERT_BY_DEFAULT, loadManifest, MANIFEST_FILE, manifestFrom } from './load.ts';
|
package/dist/manifest/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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';
|
|
3
4
|
export { servicesNamedBy, upOrder, withWhatTheyName } from './order.js';
|
|
4
5
|
export { findManifest, hashOf, INERT_BY_DEFAULT, loadManifest, MANIFEST_FILE, manifestFrom } from './load.js';
|
package/dist/manifest/load.js
CHANGED
|
@@ -3,6 +3,7 @@ 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';
|
|
6
7
|
import { NamedInACircle, upOrder } from './order.js';
|
|
7
8
|
import { readYaml } from './yaml.js';
|
|
8
9
|
export const INERT_BY_DEFAULT = [
|
|
@@ -241,6 +242,11 @@ export function manifestFrom(text, file) {
|
|
|
241
242
|
? { command: raw.signIn, service: null, cwd: null }
|
|
242
243
|
: { command: raw.signIn.command, service: raw.signIn.service ?? null, cwd: raw.signIn.cwd ?? null };
|
|
243
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
|
+
}
|
|
244
250
|
const m = {
|
|
245
251
|
file,
|
|
246
252
|
dir,
|
|
@@ -270,6 +276,7 @@ export function manifestFrom(text, file) {
|
|
|
270
276
|
budget: { services: raw.budget?.services ?? 1, checkouts: raw.budget?.checkouts ?? 3 },
|
|
271
277
|
keys: Object.fromEntries(Object.entries(raw.keys ?? {}).map(([n, k]) => [n, keyOf(n, k)])),
|
|
272
278
|
repositories: Object.fromEntries(Object.entries(raw.repositories ?? {}).map(([n, r]) => [n, repositoryOf(dir, n, r)])),
|
|
279
|
+
inbox: raw.inbox !== undefined,
|
|
273
280
|
lineOf: (at, key) => read.lineOf(at, key),
|
|
274
281
|
};
|
|
275
282
|
checkWhatTheSchemaCant(m);
|
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/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/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
|
+
}
|