clavarium 0.2.326-next.1 → 0.2.327-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/demandes.mjs +72 -65
- package/web/app.js +1 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.327-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.327-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
13
13
|
"@xterm/xterm": "^6.0.0",
|
|
14
14
|
"clavarium-binder": "0.1.60-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.2-next.2",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
16
|
+
"clavarium-parley": "0.17.70-next.1",
|
|
17
17
|
"clavarium-tether": "0.1.0-next.49",
|
|
18
18
|
"mammoth": "1.13.0",
|
|
19
19
|
"mermaid": "11.17.2",
|
|
@@ -787,9 +787,9 @@
|
|
|
787
787
|
}
|
|
788
788
|
},
|
|
789
789
|
"node_modules/clavarium-parley": {
|
|
790
|
-
"version": "0.17.
|
|
791
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.
|
|
792
|
-
"integrity": "sha512-
|
|
790
|
+
"version": "0.17.70-next.1",
|
|
791
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.70-next.1.tgz",
|
|
792
|
+
"integrity": "sha512-DfoNmVWNt32vIXLjtV9Mtvzj6PgIVy+Up4AtJQ5rwtW+4z3988hSYZni4PwRW+yYtZ991WPE8mGg1r6iIvr9/w==",
|
|
793
793
|
"license": "MIT",
|
|
794
794
|
"bin": {
|
|
795
795
|
"parley": "bin/parley.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.327-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
47
|
"clavarium-binder": "0.1.60-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.2-next.2",
|
|
49
|
-
"clavarium-parley": "0.17.
|
|
49
|
+
"clavarium-parley": "0.17.70-next.1",
|
|
50
50
|
"clavarium-tether": "0.1.0-next.49",
|
|
51
51
|
"mammoth": "1.13.0",
|
|
52
52
|
"mermaid": "11.17.2",
|
package/server/demandes.mjs
CHANGED
|
@@ -15,15 +15,17 @@
|
|
|
15
15
|
export const HOLD_S = 5;
|
|
16
16
|
const KINDS = new Set(['mail', 'calendar', 'contacts', 'files', 'terminal', 'browser', 'screen', 'device']);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
/* EACH TEXT A WORD AND ITS VALUES ({k, v}), said by each screen in its own language (Parley's
|
|
19
|
+
* dictionary, the req-* words): the interface language may be each device's, so none is chosen
|
|
20
|
+
* here. Data stays as it is (subjects, addresses, names, paths); a day and time is {at, end} (ISO),
|
|
21
|
+
* written by the screen the locale's way; a count picks its word, one or several. */
|
|
22
|
+
const w = (k, v) => (v ? { k, v } : { k });
|
|
23
|
+
const count = (n, key) => w(n === 1 ? `${key}-one` : key, { count: n });
|
|
24
|
+
const when = (at, end) => (/^\d{4}-\d{2}-\d{2}/.test(String(at ?? '')) ? { at: String(at), ...(end ? { end: String(end) } : {}) } : String(at ?? ''));
|
|
22
25
|
const nameOfAddr = (a) => { const m = /^\s*"?([^"<]*?)"?\s*<([^>]+)>/.exec(String(a ?? '')); return m && m[1] ? m[1] : String(a ?? '').split('@')[0]; };
|
|
23
|
-
const
|
|
24
|
-
const sizeOf = (kb) => (kb >= 1024 ?
|
|
25
|
-
const filesLine = (files) => (files
|
|
26
|
-
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
26
|
+
const quoted = (s, none) => (s ? w('req-quoted', { text: String(s) }) : w(none));
|
|
27
|
+
const sizeOf = (kb) => (kb >= 1024 ? w('req-size-mb', { n: Math.round((kb / 1024) * 10) / 10 }) : w('req-size-kb', { n: kb }));
|
|
28
|
+
const filesLine = (files) => ({ list: (files ?? []).map((f) => (f.kb ? w('req-file-size', { name: String(f.name), size: sizeOf(f.kb) }) : String(f.name))) });
|
|
27
29
|
/* Whom: the first, and how many more. */
|
|
28
30
|
const whom = (list) => (list.length ? `${list[0]}${list.length > 1 ? ` +${list.length - 1}` : ''}` : '');
|
|
29
31
|
/* The body as it will read: the Markdown marks taken off. */
|
|
@@ -36,95 +38,100 @@ export function demandeView(q) {
|
|
|
36
38
|
const own = String(c.self ?? '').split('@')[1] ?? '';
|
|
37
39
|
const outside = (list) => (own ? (list ?? []).filter((x) => !String(x).toLowerCase().endsWith(`@${own}`)) : []);
|
|
38
40
|
const chips = (list, ext = []) => (list ?? []).map((x) => ({ text: String(x), ...(ext.includes(x) ? { ext: true } : {}) }));
|
|
41
|
+
const fact = (key, value) => [w(`req-fact-${key}`), value];
|
|
39
42
|
const where = q?.target?.title ?? '';
|
|
40
|
-
const v = { kind, title: '',
|
|
43
|
+
const v = { kind, title: '', risk: [], facts: [], irreversible: false, yes: 'accept' };
|
|
41
44
|
const sub = [];
|
|
45
|
+
const raw = (action) => `${action} ${q?.detail ?? ''}`.trim();
|
|
42
46
|
if (c.kind === 'mail') {
|
|
43
47
|
const recipients = [...(c.to ?? []), ...(c.cc ?? []), ...(c.bcc ?? [])];
|
|
44
48
|
const ext = outside(recipients);
|
|
45
49
|
const sending = ['send', 'reply', 'forward'].includes(c.action);
|
|
46
|
-
if (sending && ext.length) v.risk.push('
|
|
47
|
-
const sendWord = c.draft ? '
|
|
50
|
+
if (sending && ext.length) v.risk.push(w('req-risk-outside'));
|
|
51
|
+
const sendWord = c.draft ? 'save-draft' : c.at ? 'schedule' : 'send';
|
|
48
52
|
const to = whom(c.to ?? []);
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
const subject = quoted(c.subject, 'req-a-message');
|
|
54
|
+
const aboutSubject = quoted(about.subject, 'req-a-message');
|
|
55
|
+
if (c.action === 'send') { const verb = c.draft ? 'draft' : c.at ? 'schedule' : 'send'; v.title = w(`req-mail-${verb}${to ? '-to' : ''}`, { subject, ...(to ? { to } : {}) }); v.yes = sendWord; }
|
|
56
|
+
else if (c.action === 'reply') { v.title = w(`req-mail-reply${c.all ? '-all' : ''}${about.subject ? '-on' : ''}`, { who: about.from ? nameOfAddr(about.from) : w('req-a-message'), ...(about.subject ? { subject: quoted(about.subject) } : {}) }); v.yes = sendWord; }
|
|
51
57
|
else if (c.action === 'forward') {
|
|
52
|
-
v.title = `
|
|
58
|
+
v.title = w(`req-mail-forward${to ? '-to' : ''}`, { subject: aboutSubject, ...(to ? { to } : {}) }); v.yes = c.draft ? 'save-draft' : 'forward';
|
|
53
59
|
const k = String(c.keep ?? 'all').toLowerCase();
|
|
54
|
-
v.facts.push(
|
|
55
|
-
} else if (c.action === 'move') { v.title =
|
|
56
|
-
else if (c.action === 'flag') { v.title =
|
|
57
|
-
else if (c.action === 'delete') { v.title =
|
|
58
|
-
else v.title =
|
|
60
|
+
v.facts.push(fact('keeps', /^(none|false|no)$/.test(k) ? w('req-keeps-none') : /^(all|true|yes|)$/.test(k) ? (about.files?.length ? filesLine(about.files) : w('req-keeps-files')) : String(c.keep)));
|
|
61
|
+
} else if (c.action === 'move') { v.title = w('req-mail-move', { subject: aboutSubject, folder: c.mailbox ?? w('req-a-folder') }); v.yes = 'move'; }
|
|
62
|
+
else if (c.action === 'flag') { v.title = w('req-mail-flag', { subject: aboutSubject, flag: String(c.flag ?? '') }); v.yes = 'mark'; }
|
|
63
|
+
else if (c.action === 'delete') { v.title = w('req-mail-delete', { subject: aboutSubject }); v.yes = 'delete'; v.irreversible = true; }
|
|
64
|
+
else v.title = raw(c.action ?? 'mail');
|
|
59
65
|
if (sending && !c.draft && ext.length) v.irreversible = true;
|
|
60
|
-
if (about.from && c.action !== 'reply') v.facts.push(
|
|
61
|
-
if (about.date && !sending) v.facts.push(
|
|
62
|
-
if (c.to?.length) v.facts.push(
|
|
63
|
-
if (c.cc?.length) v.facts.push(
|
|
64
|
-
if (c.bcc?.length) v.facts.push(
|
|
65
|
-
if (c.files?.length) v.facts.push(
|
|
66
|
-
if (c.at) v.facts.push(
|
|
66
|
+
if (about.from && c.action !== 'reply') v.facts.push(fact('from', String(about.from)));
|
|
67
|
+
if (about.date && !sending) v.facts.push(fact('date', when(about.date)));
|
|
68
|
+
if (c.to?.length) v.facts.push(fact('to', chips(c.to, ext)));
|
|
69
|
+
if (c.cc?.length) v.facts.push(fact('cc', chips(c.cc, ext)));
|
|
70
|
+
if (c.bcc?.length) v.facts.push(fact('bcc', chips(c.bcc, ext)));
|
|
71
|
+
if (c.files?.length) v.facts.push(fact('joined', filesLine(c.files)));
|
|
72
|
+
if (c.at) v.facts.push(fact('leaves', w('req-leaves', { when: when(c.at) })));
|
|
67
73
|
if (where) sub.push(where);
|
|
68
|
-
if (c.body) {
|
|
69
|
-
if (c.files?.length) sub.push(
|
|
74
|
+
if (c.body) { sub.push(count(String(c.body).split('\n').length, 'req-lines')); v.quote = plain(c.body); }
|
|
75
|
+
if (c.files?.length) sub.push(count(c.files.length, 'req-attachments'));
|
|
70
76
|
} else if (c.kind === 'calendar') {
|
|
71
|
-
const answer = { accept: '
|
|
77
|
+
const answer = { accept: 'accept', yes: 'accept', decline: 'decline', no: 'decline', refuse: 'decline', tentative: 'maybe', maybe: 'maybe' }[String(c.answer ?? '').toLowerCase()] ?? '';
|
|
72
78
|
const was = c.action === 'create' ? null : about;
|
|
73
79
|
const ev = c.action === 'create' ? c : { ...about, ...Object.fromEntries(Object.entries(c).filter(([k]) => ['title', 'start', 'end', 'where'].includes(k))) };
|
|
74
|
-
const name = was?.title || c.title
|
|
80
|
+
const name = quoted(was?.title || c.title, 'req-an-event');
|
|
75
81
|
const guests = c.action === 'create' || c.action === 'update' ? (c.with?.length ? c.with : (about.attendees ?? [])) : (about.attendees ?? []);
|
|
76
82
|
const ext = outside(c.with ?? []);
|
|
77
|
-
if (c.action === 'respond') v.title =
|
|
78
|
-
else if (c.action === 'create') v.title = `
|
|
79
|
-
else if (c.action === 'delete') v.title = `
|
|
80
|
-
else if (c.action === 'update') v.title = (c.start && c.start !== about.start) ?
|
|
81
|
-
else if (c.action === 'attach') v.title =
|
|
82
|
-
else v.title =
|
|
83
|
+
if (c.action === 'respond') v.title = w(`req-cal-respond${about.start ? '-when' : ''}`, { answer: w(`req-yes-${answer || 'answer'}`), name: quoted(about.title, 'req-an-invitation'), ...(about.start ? { when: when(about.start, about.end) } : {}) });
|
|
84
|
+
else if (c.action === 'create') v.title = w(`req-cal-create${c.start ? '-when' : ''}`, { name: c.title ? quoted(c.title) : w('req-new-event'), ...(c.start ? { when: when(c.start, c.end) } : {}) });
|
|
85
|
+
else if (c.action === 'delete') v.title = w(`req-cal-delete${about.start ? '-when' : ''}`, { name, ...(about.start ? { when: when(about.start, about.end) } : {}) });
|
|
86
|
+
else if (c.action === 'update') v.title = (c.start && c.start !== about.start) ? w('req-cal-move', { name, when: when(c.start, c.end ?? about.end) }) : w('req-cal-change', { name });
|
|
87
|
+
else if (c.action === 'attach') v.title = w('req-cal-attach', { files: filesLine(c.files), name });
|
|
88
|
+
else v.title = raw(c.action ?? 'calendar');
|
|
83
89
|
/* Before -> after: what changes of a change, and the event itself otherwise. */
|
|
84
90
|
if (c.action === 'update' && was?.start) {
|
|
85
|
-
v.before = [
|
|
86
|
-
v.after = [
|
|
87
|
-
sub.push(
|
|
88
|
-
} else if (ev.start) { if (c.action !== 'respond' && c.action !== 'delete' && c.action !== 'create') sub.push(
|
|
89
|
-
if (guests.length && ['update', 'delete'].includes(c.action)) { sub.push(
|
|
90
|
-
if (about.clashes?.length) v.risk.push(
|
|
91
|
-
if (ext.length) v.risk.push('
|
|
92
|
-
if (about.organizer && c.action === 'respond') v.facts.push(
|
|
93
|
-
if (guests.length) v.facts.push(
|
|
94
|
-
if (c.online === 'teams' || (c.action === 'create' && (c.with ?? []).length && !c.online)) v.facts.push(
|
|
91
|
+
v.before = [when(was.start, was.end), was.where].filter(Boolean);
|
|
92
|
+
v.after = [when(ev.start, ev.end), ev.where].filter(Boolean);
|
|
93
|
+
sub.push(w('req-was', { when: when(was.start, was.end) }));
|
|
94
|
+
} else if (ev.start) { if (c.action !== 'respond' && c.action !== 'delete' && c.action !== 'create') sub.push(when(ev.start, ev.end)); if (ev.where) v.facts.push(fact('where', String(ev.where))); }
|
|
95
|
+
if (guests.length && ['update', 'delete'].includes(c.action)) { sub.push(count(guests.length, 'req-guests-told')); v.irreversible = true; }
|
|
96
|
+
if (about.clashes?.length) v.risk.push(w('req-risk-clash', { what: { list: about.clashes.map(String) } }));
|
|
97
|
+
if (ext.length) v.risk.push(w('req-risk-invites-outside'));
|
|
98
|
+
if (about.organizer && c.action === 'respond') v.facts.push(fact('from', String(about.organizer)));
|
|
99
|
+
if (guests.length) v.facts.push(fact('guests', chips(guests, ext)));
|
|
100
|
+
if (c.online === 'teams' || (c.action === 'create' && (c.with ?? []).length && !c.online)) v.facts.push(fact('online', w('req-teams')));
|
|
95
101
|
if (where) sub.unshift(where);
|
|
96
102
|
if (c.notes) v.quote = String(c.notes);
|
|
97
|
-
v.yes = c.action === 'respond' ? (answer || '
|
|
103
|
+
v.yes = c.action === 'respond' ? (answer || 'answer') : c.action === 'create' ? ((c.with ?? []).length ? 'create-invite' : 'create') : c.action === 'delete' ? 'delete' : c.action === 'update' ? (v.before ? 'move' : 'change') : 'accept';
|
|
98
104
|
if (c.action === 'delete') v.irreversible = true;
|
|
99
105
|
} else if (c.kind === 'contacts') {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (c.
|
|
103
|
-
if (c.
|
|
106
|
+
const who = (x) => (x ? String(x) : w('req-a-contact'));
|
|
107
|
+
v.title = c.action === 'create' ? w('req-contact-add', { who: who(c.name || c.email) }) : c.action === 'update' ? w('req-contact-update', { who: who(c.name) }) : c.action === 'delete' ? w('req-contact-delete', { who: who(c.name) }) : c.action === 'attach' ? w('req-contact-photo', { who: who(c.name) }) : raw(c.action ?? 'contacts');
|
|
108
|
+
if (c.name && c.action !== 'create') v.facts.push(fact('name', String(c.name)));
|
|
109
|
+
if (c.email) v.facts.push(fact('email', String(c.email)));
|
|
110
|
+
if (c.phone) v.facts.push(fact('phone', String(c.phone)));
|
|
104
111
|
if (where) sub.push(where);
|
|
105
112
|
if (c.email && c.action === 'create') sub.push(String(c.email));
|
|
106
|
-
v.yes = c.action === 'create' ? '
|
|
113
|
+
v.yes = c.action === 'create' ? 'add' : c.action === 'delete' ? 'delete' : 'update';
|
|
107
114
|
if (c.action === 'delete') v.irreversible = true;
|
|
108
115
|
} else if (c.kind === 'terminal') {
|
|
109
|
-
const on = where || 'a
|
|
110
|
-
v.title = c.action === 'run' ?
|
|
111
|
-
if (/^\s*sudo\b/.test(c.command ?? '')) v.risk.push('
|
|
116
|
+
const on = where || w('req-a-machine');
|
|
117
|
+
v.title = w(c.action === 'run' ? 'req-term-run' : c.action === 'type' ? 'req-term-type' : 'req-term-open', { on });
|
|
118
|
+
if (/^\s*sudo\b/.test(c.command ?? '')) v.risk.push(w('req-risk-admin'));
|
|
112
119
|
if (c.command || c.text) { v.code = String(c.command ?? c.text); sub.push(v.code.split('\n')[0].slice(0, 60)); }
|
|
113
|
-
v.yes = c.action === 'run' ? '
|
|
120
|
+
v.yes = c.action === 'run' ? 'run' : c.action === 'type' ? 'type' : 'open';
|
|
114
121
|
if (c.action === 'run') v.irreversible = true;
|
|
115
122
|
} else if (c.kind === 'files') {
|
|
116
|
-
v.title = c.action === 'write' ?
|
|
123
|
+
v.title = c.action === 'write' ? w('req-files-write', { path: String(c.path) }) : c.action === 'delete' ? w('req-files-delete', { path: String(c.path) }) : c.action === 'move' ? w('req-files-move', { from: String(c.from), to: String(c.to) }) : `${c.action ?? 'files'} ${c.path ?? ''}`.trim();
|
|
117
124
|
if (where) sub.push(where);
|
|
118
|
-
if (c.bytes !== undefined) { const size = c.bytes >= 1024 ?
|
|
125
|
+
if (c.bytes !== undefined) { const size = c.bytes >= 1024 ? w('req-size-kb', { n: Math.round(c.bytes / 1024) }) : w('req-size-bytes', { n: c.bytes }); sub.push(size); v.facts.push(fact('size', size)); }
|
|
119
126
|
if (c.action === 'move') { v.before = [String(c.from ?? '')]; v.after = [String(c.to ?? '')]; }
|
|
120
|
-
else if (c.path) v.facts.push(
|
|
121
|
-
v.yes = c.action === 'delete' ? '
|
|
122
|
-
if (c.action === 'delete') { v.irreversible = true; v.risk.push('
|
|
123
|
-
} else if (c.kind === 'browser' && c.action === 'open') { v.title =
|
|
127
|
+
else if (c.path) v.facts.push(fact('path', String(c.path)));
|
|
128
|
+
v.yes = c.action === 'delete' ? 'delete' : c.action === 'move' ? 'move' : 'write';
|
|
129
|
+
if (c.action === 'delete') { v.irreversible = true; v.risk.push(w('req-risk-final')); }
|
|
130
|
+
} else if (c.kind === 'browser' && c.action === 'open') { v.title = w('req-browser-open', { url: String(c.url) }); v.yes = 'open'; if (where) sub.push(where); }
|
|
124
131
|
else { v.title = `${q?.verb ?? 'action'}${q?.detail ? ` ${q.detail}` : ''}`; if (where) sub.push(where); }
|
|
125
132
|
const id = String(q?.id ?? '');
|
|
126
133
|
return {
|
|
127
|
-
kind, title: v.title ||
|
|
134
|
+
kind, title: v.title || (q?.verb ? String(q.verb) : w('req-a-request')), sub: sub.filter(Boolean).slice(0, 3),
|
|
128
135
|
...(v.risk.length ? { risk: v.risk } : {}), ...(v.facts.length ? { facts: v.facts } : {}),
|
|
129
136
|
...(v.before ? { before: v.before, after: v.after } : {}),
|
|
130
137
|
...(v.quote ? { quote: v.quote } : {}), ...(v.code ? { code: v.code } : {}),
|
|
@@ -132,9 +139,9 @@ export function demandeView(q) {
|
|
|
132
139
|
/* The technical line, in "See all" only. */
|
|
133
140
|
detail: [q?.verb, q?.detail].filter(Boolean).join(' — '),
|
|
134
141
|
irreversible: v.irreversible,
|
|
135
|
-
yes: { id: `allow:${id}`, label: v.yes }, no: { id: `deny:${id}`, label: '
|
|
142
|
+
yes: { id: `allow:${id}`, label: w(`req-yes-${v.yes}`) }, no: { id: `deny:${id}`, label: w('req-no') },
|
|
136
143
|
/* "Always allow ...": behind "⋯", as before. */
|
|
137
|
-
...(q?.rule ? { others: [{ id: `always:${id}`, label:
|
|
144
|
+
...(q?.rule ? { others: [{ id: `always:${id}`, label: q.rule.value ? w('req-always', { what: String(q.rule.value) }) : w('req-always-this') }] } : {}),
|
|
138
145
|
hold: HOLD_S,
|
|
139
146
|
};
|
|
140
147
|
}
|
package/web/app.js
CHANGED
|
@@ -4825,7 +4825,7 @@
|
|
|
4825
4825
|
cardSteps ??= P.stepper({ open: (name, close) => nav.over(`demande-${name}`, () => close(), { stack: true }), closed: (step) => { if (step) nav.drop(step); } });
|
|
4826
4826
|
for (const q of approvals) {
|
|
4827
4827
|
if (!q.view) continue;
|
|
4828
|
-
const view = withWho && q.agent?.name ? { ...q.view, sub: [q.agent.name, q.view.sub].filter(Boolean)
|
|
4828
|
+
const view = withWho && q.agent?.name ? { ...q.view, sub: [q.agent.name, ...(Array.isArray(q.view.sub) ? q.view.sub : [q.view.sub])].filter(Boolean) } : q.view;
|
|
4829
4829
|
box.append(P.requestCard(view, { act, words, steps: cardSteps, host: document.body }));
|
|
4830
4830
|
}
|
|
4831
4831
|
});
|