lattris 0.2.1 → 0.2.3
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/README.md +1 -1
- package/dist/build.json +1 -1
- package/dist/dispatch-form.js +73 -8
- package/dist/dispatch-words.js +16 -3
- package/dist/dispatch.js +2 -2
- package/dist/entry/setup.js +14 -2
- package/dist/main.js +2 -6
- package/dist/memory/access.js +11 -9
- package/dist/memory/get-help.js +5 -3
- package/dist/memory/views.js +2 -1
- package/dist/nouns/contact.js +43 -8
- package/dist/nouns/index.js +16 -3
- package/dist/nouns/invite.js +45 -19
- package/dist/nouns/questions.js +56 -3
- package/dist/nouns/share.js +122 -51
- package/dist/nouns/words.js +15 -4
- package/dist/registry/memory.js +5 -2
- package/dist/render/rows.js +12 -0
- package/dist/render/shares.js +28 -0
- package/dist/request/door.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ lattris memory read and manage blocks
|
|
|
49
49
|
lattris link connect two blocks
|
|
50
50
|
lattris get read your blocks, questions and invites, and your datasets' rows
|
|
51
51
|
lattris ask ask a question of a tree
|
|
52
|
-
lattris invite invite someone
|
|
52
|
+
lattris invite invite someone, naming the email address the invitation admits
|
|
53
53
|
lattris contact manage contacts
|
|
54
54
|
```
|
|
55
55
|
|
package/dist/build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"commit":"
|
|
1
|
+
{"commit":"2cc00908002bab8c075247652ee18d6d2f82515a","builtAt":"2026-10-11T22:49:48Z"}
|
package/dist/dispatch-form.js
CHANGED
|
@@ -3,12 +3,18 @@ import { emit } from "./render/output.js";
|
|
|
3
3
|
import { confirmAction } from "./render/prompt.js";
|
|
4
4
|
import { ambiguousText, formatContact, groupsNotBuilt, isGroupWord } from "./render/rows.js";
|
|
5
5
|
import { renderRunHint, sanitizeForTerminal } from "./render/text.js";
|
|
6
|
+
import { NO_LONGER_SHARED } from "./render/shares.js";
|
|
6
7
|
import { signedIn } from "./request/access-token.js";
|
|
7
8
|
import { refusalOf } from "./request/api-fetch.js";
|
|
8
9
|
import { EXIT, isRefusal } from "./store/exit.js";
|
|
9
10
|
import { buildBody, describeAudience, fillIn, fillPath, readWords, refuse, resolveContact, urlOf } from "./dispatch-words.js";
|
|
10
11
|
export const runForm = async (cfg, io, form, rest) => {
|
|
11
|
-
const
|
|
12
|
+
const words = form.dropLeadingWords !== undefined &&
|
|
13
|
+
rest.length > 0 &&
|
|
14
|
+
form.dropLeadingWords.includes(rest[0])
|
|
15
|
+
? rest.slice(1)
|
|
16
|
+
: rest;
|
|
17
|
+
const typed = readWords(form, words);
|
|
12
18
|
if (isRefusal(typed))
|
|
13
19
|
return typed;
|
|
14
20
|
const steps = form.steps ?? {};
|
|
@@ -36,6 +42,8 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
36
42
|
}
|
|
37
43
|
if (selector !== undefined && isGroupWord(selector))
|
|
38
44
|
return refuse(groupsNotBuilt(selector));
|
|
45
|
+
if (steps.contact?.createIfMissing && selector?.includes('@'))
|
|
46
|
+
return refuse(`${form.usage}\n`);
|
|
39
47
|
if (steps.pipedNeedsYes && !io.stdin.isTTY && !typed.on.has('--yes')) {
|
|
40
48
|
return refuse(steps.pipedNeedsYes.message);
|
|
41
49
|
}
|
|
@@ -55,6 +63,7 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
55
63
|
if (typeof accessToken !== 'string')
|
|
56
64
|
return accessToken;
|
|
57
65
|
let missingName;
|
|
66
|
+
let recording = false;
|
|
58
67
|
const reserved = [
|
|
59
68
|
...(steps.contact?.publicWord === undefined ? [] : [steps.contact.publicWord]),
|
|
60
69
|
...(steps.contact?.reserved ?? [])
|
|
@@ -95,11 +104,45 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
95
104
|
missingName = resolution.displayName;
|
|
96
105
|
}
|
|
97
106
|
}
|
|
107
|
+
if (steps.contact?.email && context.reserved === undefined && !wantsPublic) {
|
|
108
|
+
const rule = steps.contact.email;
|
|
109
|
+
const typedEmail = typed.flags[rule.flag]?.trim();
|
|
110
|
+
const held = context.contact?.email || undefined;
|
|
111
|
+
const name = sanitizeForTerminal(context.contact?.displayName ?? missingName ?? '');
|
|
112
|
+
if (typedEmail === undefined && held === undefined) {
|
|
113
|
+
return refuse(fillIn(missingName === undefined ? rule.required : rule.requiredNew, { name }));
|
|
114
|
+
}
|
|
115
|
+
if (typedEmail !== undefined &&
|
|
116
|
+
held !== undefined &&
|
|
117
|
+
typedEmail.toLowerCase() !== held.toLowerCase()) {
|
|
118
|
+
return refuse(fillIn(rule.conflict, {
|
|
119
|
+
name,
|
|
120
|
+
typed: sanitizeForTerminal(typedEmail),
|
|
121
|
+
held: sanitizeForTerminal(held),
|
|
122
|
+
'contact.id': context.contact?.id ?? ''
|
|
123
|
+
}), EXIT.GENERIC);
|
|
124
|
+
}
|
|
125
|
+
context.email = held ?? typedEmail;
|
|
126
|
+
recording = held === undefined && context.contact !== undefined;
|
|
127
|
+
}
|
|
98
128
|
if (steps.memory === 'always' || (steps.memory === 'at-tty' && io.stdin.isTTY)) {
|
|
99
129
|
const fetched = await io.api(accessToken, `${cfg.apiUrl}/memories/${encodeURIComponent(typed.positionals[0])}`);
|
|
100
|
-
if (
|
|
130
|
+
if (fetched.ok) {
|
|
131
|
+
context.memory = fetched.data;
|
|
132
|
+
}
|
|
133
|
+
else if (steps.memoryMayBeGone &&
|
|
134
|
+
fetched.status === 404 &&
|
|
135
|
+
fetched.body.code === 'memory:not-found') {
|
|
136
|
+
context.gone = true;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
101
139
|
return refusalOf(fetched, ambiguousText(fetched.body));
|
|
102
|
-
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (steps.noAudienceReport &&
|
|
143
|
+
typed.flags[steps.noAudienceReport.key] === undefined &&
|
|
144
|
+
context.gone) {
|
|
145
|
+
return refuse(steps.noAudienceReport.first);
|
|
103
146
|
}
|
|
104
147
|
if (steps.noAudienceReport && typed.flags[steps.noAudienceReport.key] === undefined) {
|
|
105
148
|
const title = sanitizeForTerminal(context.memory?.title ?? '(untitled)');
|
|
@@ -114,12 +157,17 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
114
157
|
const name = sanitizeForTerminal(context.contact?.displayName ?? missingName ?? '');
|
|
115
158
|
const question = fillIn(missingName !== undefined && steps.confirm.whenMissing
|
|
116
159
|
? steps.confirm.whenMissing
|
|
117
|
-
: steps.confirm.
|
|
160
|
+
: recording && steps.confirm.whenRecording
|
|
161
|
+
? steps.confirm.whenRecording
|
|
162
|
+
: steps.confirm.question, {
|
|
118
163
|
...Object.fromEntries(typed.positionals.map((p, i) => [`p${i}`, sanitizeForTerminal(p)])),
|
|
119
164
|
name,
|
|
120
|
-
title:
|
|
121
|
-
|
|
165
|
+
title: context.gone
|
|
166
|
+
? NO_LONGER_SHARED
|
|
167
|
+
: sanitizeForTerminal(context.memory?.title ?? '(untitled)'),
|
|
168
|
+
'memory.id': context.memory?.id ?? sanitizeForTerminal(typed.positionals[0] ?? ''),
|
|
122
169
|
'contact.id': context.contact?.id ?? '',
|
|
170
|
+
email: sanitizeForTerminal(context.email ?? ''),
|
|
123
171
|
audience: context.contact?.displayName ?? describeAudience(selector ?? '')
|
|
124
172
|
});
|
|
125
173
|
const answer = await confirmAction(io, question);
|
|
@@ -138,7 +186,11 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
138
186
|
const created = await io.api(accessToken, `${cfg.apiUrl}/contacts`, {
|
|
139
187
|
method: 'POST',
|
|
140
188
|
headers: { 'Content-Type': 'application/json' },
|
|
141
|
-
body: JSON.stringify({
|
|
189
|
+
body: JSON.stringify({
|
|
190
|
+
displayName: missingName,
|
|
191
|
+
type: 'person',
|
|
192
|
+
...(context.email === undefined ? {} : { email: context.email })
|
|
193
|
+
})
|
|
142
194
|
});
|
|
143
195
|
if (!created.ok)
|
|
144
196
|
return refusalOf(created);
|
|
@@ -146,6 +198,18 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
146
198
|
context.createdContact = true;
|
|
147
199
|
body = buildBody(form, typed, stdin, context);
|
|
148
200
|
}
|
|
201
|
+
else if (recording && context.contact !== undefined) {
|
|
202
|
+
const updated = await io.api(accessToken, `${cfg.apiUrl}/contacts/${encodeURIComponent(context.contact.id)}`, {
|
|
203
|
+
method: 'PATCH',
|
|
204
|
+
headers: { 'Content-Type': 'application/json' },
|
|
205
|
+
body: JSON.stringify({ email: context.email })
|
|
206
|
+
});
|
|
207
|
+
if (!updated.ok)
|
|
208
|
+
return refusalOf(updated);
|
|
209
|
+
context.contact = updated.data;
|
|
210
|
+
context.recordedEmail = true;
|
|
211
|
+
body = buildBody(form, typed, stdin, context);
|
|
212
|
+
}
|
|
149
213
|
else if (context.contact !== undefined || wantsPublic || context.reserved !== undefined) {
|
|
150
214
|
body = buildBody(form, typed, stdin, context);
|
|
151
215
|
}
|
|
@@ -196,7 +260,8 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
196
260
|
emit(io, result.data, result.rawText, (data) => form.render(data, typedView));
|
|
197
261
|
const next = form.page ? result.data[form.page.cursor] : undefined;
|
|
198
262
|
if (form.page && typeof next === 'string' && io.stdout.isTTY) {
|
|
199
|
-
|
|
263
|
+
const carried = Object.entries(form.page.carry ?? {}).flatMap(([flag, key]) => typed.flags[key] === undefined ? [] : [flag, typed.flags[key]]);
|
|
264
|
+
io.stderr.write(`More: ${renderRunHint([...form.page.hint, ...carried, '--cursor', next])}\n`);
|
|
200
265
|
}
|
|
201
266
|
};
|
|
202
267
|
//# sourceMappingURL=dispatch-form.js.map
|
package/dist/dispatch-words.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { resolveContact } from "./render/rows.js";
|
|
2
|
-
import { renderRunHint } from "./render/text.js";
|
|
2
|
+
import { renderRunHint, sanitizeForTerminal } from "./render/text.js";
|
|
3
3
|
import { parseArgs } from "./request/flags.js";
|
|
4
4
|
import { EXIT, refusal } from "./store/exit.js";
|
|
5
5
|
import { isUuidKey } from "./store/write-identity.js";
|
|
6
6
|
export const refuse = (message, exit = EXIT.USAGE) => refusal(message, exit);
|
|
7
7
|
export const fillIn = (template, values) => template.replace(/\{([\w.]+)(?::([^}]*))?\}/g, (_m, key, arg) => key === 'hint' ? renderRunHint((arg ?? '').split(' ')) : (values[key] ?? ''));
|
|
8
|
+
const looksLikeAnAddress = (word) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(word);
|
|
8
9
|
export const readWords = (form, rest) => {
|
|
9
10
|
const on = new Set();
|
|
10
11
|
const counts = new Map();
|
|
@@ -22,6 +23,11 @@ export const readWords = (form, rest) => {
|
|
|
22
23
|
}
|
|
23
24
|
if (notAnId !== undefined)
|
|
24
25
|
return refuse(notAnId);
|
|
26
|
+
if (form.joinPositionals && positionals.length > 1) {
|
|
27
|
+
if (positionals.some((word) => isUuidKey(word)))
|
|
28
|
+
return refuse(`${form.usage}\n`);
|
|
29
|
+
positionals.splice(0, positionals.length, positionals.join(' '));
|
|
30
|
+
}
|
|
25
31
|
const typed = { positionals, flags: flags, on };
|
|
26
32
|
const tooMany = form.positionalsAtMost ?? form.positionals;
|
|
27
33
|
if (positionals.length < form.positionals ||
|
|
@@ -61,6 +67,12 @@ export const readWords = (form, rest) => {
|
|
|
61
67
|
return refuse(fillIn(rule.message, { value }));
|
|
62
68
|
}
|
|
63
69
|
}
|
|
70
|
+
for (const rule of form.addressFlags ?? []) {
|
|
71
|
+
const value = typed.flags[rule.key];
|
|
72
|
+
if (value !== undefined && !looksLikeAnAddress(value.trim())) {
|
|
73
|
+
return refuse(fillIn(rule.message, { value: sanitizeForTerminal(value.trim()) }));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
64
76
|
for (const rule of form.requireWhen ?? []) {
|
|
65
77
|
const value = typed.flags[rule.key];
|
|
66
78
|
if (value !== undefined &&
|
|
@@ -78,8 +90,9 @@ export const valueOf = (source, typed, stdin, context) => {
|
|
|
78
90
|
return typed.positionals[source.positional];
|
|
79
91
|
if ('stdin' in source)
|
|
80
92
|
return stdin;
|
|
81
|
-
if ('context' in source)
|
|
82
|
-
return context.contact?.id;
|
|
93
|
+
if ('context' in source) {
|
|
94
|
+
return source.context === 'email' ? context.email : context.contact?.id;
|
|
95
|
+
}
|
|
83
96
|
if (!('switch' in source))
|
|
84
97
|
return source.value;
|
|
85
98
|
return typed.on.has(source.switch) ? source.value : source.otherwise;
|
package/dist/dispatch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveVerb } from "./nouns/words.js";
|
|
2
2
|
import { renderRefusal } from "./render/output.js";
|
|
3
3
|
import { sanitizeForTerminal } from "./render/text.js";
|
|
4
4
|
import { HELP_TOKENS } from "./request/flags.js";
|
|
@@ -18,8 +18,8 @@ export const dispatch = async (cfg, io, registry, argv) => {
|
|
|
18
18
|
const typedWord = argv[0];
|
|
19
19
|
if (typedWord === undefined)
|
|
20
20
|
return false;
|
|
21
|
-
const word = VERB_ALIASES[typedWord] ?? typedWord;
|
|
22
21
|
const rest = argv.slice(1);
|
|
22
|
+
const word = resolveVerb(typedWord, rest[0]);
|
|
23
23
|
const nounFirst = registry.nouns.find((n) => n.grammar === 'noun-first' && wordsOf(n).includes(word));
|
|
24
24
|
if (nounFirst) {
|
|
25
25
|
const first = rest[0];
|
package/dist/entry/setup.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
1
2
|
import { dirname, join, resolve } from 'node:path';
|
|
2
3
|
import { promptLine } from "../render/prompt.js";
|
|
3
4
|
import { LATTRIS_PERMISSION_RULE, SETUP_FLAG_NAMES, SETUP_HELP, buildBootFile, buildTransitionInstructions, parseBootRootId, withLattrisPermission } from "../entry/setup-boot.js";
|
|
4
5
|
import { parseArgs } from "../request/flags.js";
|
|
5
6
|
import { HELP_TOKENS } from "../request/flags.js";
|
|
6
7
|
import { sanitizeForTerminal } from "../render/text.js";
|
|
7
|
-
import { refusal } from "../store/exit.js";
|
|
8
|
+
import { isRefusal, refusal } from "../store/exit.js";
|
|
8
9
|
import { refusalOf } from "../request/api-fetch.js";
|
|
9
10
|
import { signedIn } from "../request/access-token.js";
|
|
11
|
+
import { noteWriteHeaders, requireWriteIdentity } from "../store/write-identity.js";
|
|
10
12
|
export const promptAnswer = (answer) => {
|
|
11
13
|
if (answer === null)
|
|
12
14
|
return 'no';
|
|
@@ -91,6 +93,13 @@ export const setup = async (cfg, io, args) => {
|
|
|
91
93
|
return;
|
|
92
94
|
}
|
|
93
95
|
}
|
|
96
|
+
let identity;
|
|
97
|
+
if (flags.root === undefined) {
|
|
98
|
+
const found = requireWriteIdentity(io.store, io.stdin.isTTY);
|
|
99
|
+
if (isRefusal(found))
|
|
100
|
+
return found;
|
|
101
|
+
identity = found;
|
|
102
|
+
}
|
|
94
103
|
let name = flags.name;
|
|
95
104
|
if (flags.root === undefined && name === undefined) {
|
|
96
105
|
if (!io.stdin.isTTY) {
|
|
@@ -118,7 +127,10 @@ export const setup = async (cfg, io, args) => {
|
|
|
118
127
|
else {
|
|
119
128
|
const created = await io.api(accessToken, `${cfg.apiUrl}/memories/notes`, {
|
|
120
129
|
method: 'POST',
|
|
121
|
-
headers: {
|
|
130
|
+
headers: {
|
|
131
|
+
'Content-Type': 'application/json',
|
|
132
|
+
...(identity ? noteWriteHeaders(identity, randomUUID()) : {})
|
|
133
|
+
},
|
|
122
134
|
body: JSON.stringify({
|
|
123
135
|
title: name,
|
|
124
136
|
content: 'Root of this memory tree. Freshly scaffolded by `lattris setup` — ' +
|
package/dist/main.js
CHANGED
|
@@ -17,7 +17,7 @@ import { machinesRoot, resolveActorDir, resolveSessionHome, stateHome } from "./
|
|
|
17
17
|
import { sessionIdentityWarning } from "./store/session.js";
|
|
18
18
|
import { currentPackageVersion, printVersion } from "./version.js";
|
|
19
19
|
import { checkForNewVersion } from "./request/version-check.js";
|
|
20
|
-
import { COMMAND_WORDS,
|
|
20
|
+
import { COMMAND_WORDS, resolveVerb } from "./nouns/words.js";
|
|
21
21
|
import { validAccessToken } from "./request/access-token.js";
|
|
22
22
|
import { apiFetch } from "./request/api-fetch.js";
|
|
23
23
|
import { ask, readAll } from "./request/stdin.js";
|
|
@@ -147,11 +147,7 @@ const main = async () => {
|
|
|
147
147
|
if (isRefusal(cfg))
|
|
148
148
|
return cfg;
|
|
149
149
|
const rawCommand = argv[2];
|
|
150
|
-
const command = rawCommand !== undefined
|
|
151
|
-
? Object.hasOwn(VERB_ALIASES, rawCommand)
|
|
152
|
-
? VERB_ALIASES[rawCommand]
|
|
153
|
-
: rawCommand
|
|
154
|
-
: rawCommand;
|
|
150
|
+
const command = rawCommand !== undefined ? resolveVerb(rawCommand, argv[3]) : rawCommand;
|
|
155
151
|
void checkForNewVersion({ files: here.files, network: io.network, stderr: io.stderr }, {
|
|
156
152
|
currentVersion: currentPackageVersion(here.files),
|
|
157
153
|
stateDir: join(stateHome(here), 'lattris'),
|
package/dist/memory/access.js
CHANGED
|
@@ -7,7 +7,8 @@ import { refusalOf } from "../request/api-fetch.js";
|
|
|
7
7
|
import { EXIT, refusal } from "../store/exit.js";
|
|
8
8
|
export const GET_ACCESS_HELP = [
|
|
9
9
|
'get access — may one contact, or one phone number, see a memory of yours,',
|
|
10
|
-
'and because of which share.',
|
|
10
|
+
'or one someone shared with you, and because of which share. For a shared',
|
|
11
|
+
"memory the answer comes from your own shares and the owner's public one.",
|
|
11
12
|
'',
|
|
12
13
|
'Usage:',
|
|
13
14
|
' lattris get access <memory-id-or-prefix> --for <contact | number>',
|
|
@@ -19,23 +20,24 @@ export const GET_ACCESS_HELP = [
|
|
|
19
20
|
'',
|
|
20
21
|
'Answers open or shut, and the rows that decided it: the denies that reach',
|
|
21
22
|
'the contact when one does, the allows that reach them when open, or',
|
|
22
|
-
'nothing when nothing is set.'
|
|
23
|
+
'nothing when nothing is set. A memory no longer shared with you answers',
|
|
24
|
+
'nothing here: your shares on it decide nothing until it is shared again,',
|
|
25
|
+
'and `lattris get shares` lists them.'
|
|
23
26
|
].join('\n');
|
|
24
27
|
const ACCESS_FLAGS = { '--for': 'for' };
|
|
25
28
|
const isPhoneWord = (word) => word.startsWith('+');
|
|
26
29
|
const formatAccessDecision = (d, asked) => {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const stranger = d.forContact === null ? ` (${describeForContact(null, asked)})` : '';
|
|
30
|
+
const contact = d.forContact ?? null;
|
|
31
|
+
const who = contact === null ? sanitizeForTerminal(asked) : sanitizeForTerminal(contact.displayName);
|
|
32
|
+
const stranger = contact === null ? ` (${describeForContact(null, asked)})` : '';
|
|
31
33
|
const verdict = d.open
|
|
32
34
|
? `open — ${who} may see it${stranger}`
|
|
33
35
|
: `shut — ${who} may not see it${stranger}`;
|
|
34
|
-
const because = d.decidedBy.length === 0
|
|
35
|
-
?
|
|
36
|
+
const because = (d.decidedBy ?? []).length === 0
|
|
37
|
+
? contact === null
|
|
36
38
|
? 'because: no public share'
|
|
37
39
|
: 'because: nothing is set for them'
|
|
38
|
-
: `because: ${d.decidedBy.map(formatAccessRow).join('; ')}`;
|
|
40
|
+
: `because: ${(d.decidedBy ?? []).map(formatAccessRow).join('; ')}`;
|
|
39
41
|
return `${verdict}\n${because}`;
|
|
40
42
|
};
|
|
41
43
|
export const contactIdFor = async (cfg, io, accessToken, word) => {
|
package/dist/memory/get-help.js
CHANGED
|
@@ -34,9 +34,11 @@ export const GET_HELP = [
|
|
|
34
34
|
' session needs it, while a full address carries it',
|
|
35
35
|
' --shared-with-me list memories other people granted to you; each row',
|
|
36
36
|
' names its owner and whether it is on your graph',
|
|
37
|
-
' --for <contact> what one of your contacts may see of your memories
|
|
38
|
-
' exact name or id from
|
|
39
|
-
'
|
|
37
|
+
' --for <contact> what one of your contacts may see of your memories and',
|
|
38
|
+
' of the ones shared with you: an exact name or id from',
|
|
39
|
+
' `lattris contact list`. The rows carry what they would',
|
|
40
|
+
' see, a row of another owner names them, and the first',
|
|
41
|
+
' line names the contact',
|
|
40
42
|
' --for-phone <number> the same for a phone number in full international',
|
|
41
43
|
' form; a number no contact holds is a stranger, who',
|
|
42
44
|
' sees public memories only',
|
package/dist/memory/views.js
CHANGED
|
@@ -3,9 +3,10 @@ import { sanitizeForTerminal } from "../render/text.js";
|
|
|
3
3
|
import { stripTrailingSlash } from "../store/environment.js";
|
|
4
4
|
export const formatDeletedLine = (b) => `${b.id} ${b.deletedAt ?? '-'} rev ${b.revisionNo ?? '-'} ${b.fingerprint ?? '-'} ${sanitizeForTerminal(b.title ?? '(untitled)')}`;
|
|
5
5
|
export const formatDeletedPage = (page) => page.items.map((i) => formatDeletedLine(i)).join('\n');
|
|
6
|
+
const graphWord = (b) => b.consented === undefined ? '' : `${b.consented ? 'on graph' : 'off graph'} `;
|
|
6
7
|
export const formatBlockLine = (b) => b.ownerHandle === undefined
|
|
7
8
|
? `${b.id} ${b.handle} ${b.capturedAt} ${b.intent ?? '-'} ${b.visibility.public ? 'public' : '-'} ${sanitizeForTerminal(b.title ?? '(untitled)')}`
|
|
8
|
-
: `${b.id} ${b.handle} ${b.capturedAt} by ${sanitizeForTerminal(b.ownerDisplayName ?? b.ownerHandle)} (@${b.ownerHandle}) ${b
|
|
9
|
+
: `${b.id} ${b.handle} ${b.capturedAt} by ${sanitizeForTerminal(b.ownerDisplayName ?? b.ownerHandle)} (@${b.ownerHandle}) ${graphWord(b)}${sanitizeForTerminal(b.title ?? '(untitled)')}`;
|
|
9
10
|
const SLUG_MAX = 60;
|
|
10
11
|
const slugify = (title) => (title ?? '')
|
|
11
12
|
.toLowerCase()
|
package/dist/nouns/contact.js
CHANGED
|
@@ -20,22 +20,37 @@ const CONTACT_HELP = [
|
|
|
20
20
|
' it at a block of yours (an AI role at its page)',
|
|
21
21
|
' lattris contact delete <id-or-name> [--yes] remove a contact nothing holds on to: asks at a',
|
|
22
22
|
' terminal, needs --yes on a pipe',
|
|
23
|
+
' lattris contact link <id-or-name> --handle <h>',
|
|
24
|
+
' ask the account at that handle to let this',
|
|
25
|
+
' contact stand for it; they accept from their inbox',
|
|
23
26
|
'',
|
|
24
27
|
' --email <v> the address you keep for this contact. It is your record',
|
|
25
28
|
' alone: the contact never sees it, nobody else reads it,',
|
|
26
29
|
' and changing it asks nobody',
|
|
27
|
-
' --phone <v> the number
|
|
30
|
+
' --phone <v> the number this contact is reached at, in full',
|
|
28
31
|
' international form: + then digits, like +61412345678.',
|
|
29
32
|
' One per contact, and no two of your contacts may hold',
|
|
30
|
-
' one number.
|
|
33
|
+
' one number.',
|
|
31
34
|
' --root <block-id> the full id of one of your own blocks, never a prefix; the',
|
|
32
35
|
' API refuses a block you do not own',
|
|
36
|
+
' --handle <h> the public address of the account you are asking, as it',
|
|
37
|
+
' appears at /by/<handle>. A handle that names nobody is',
|
|
38
|
+
' answered exactly as one that names an account, and nothing',
|
|
39
|
+
' is sent, so a typo is not told apart from a private page',
|
|
33
40
|
'',
|
|
34
41
|
'A contact shows "linked" once it stands for a Lattris account: yours are',
|
|
35
42
|
'linked when someone accepts the invitation you minted for that contact,',
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'a
|
|
43
|
+
'or the link request you sent for it, and the person who invited or asked',
|
|
44
|
+
'you appears among your contacts, linked, the moment you accept. A share',
|
|
45
|
+
'or a deny names any contact, linked or not; a linked contact also sees a',
|
|
46
|
+
'share on the website.',
|
|
47
|
+
'',
|
|
48
|
+
'A link request carries your name and handle to their inbox, nothing else:',
|
|
49
|
+
'not the name you keep for them, not their email. They answer with',
|
|
50
|
+
'`lattris accept contact <id>` or `lattris decline contact <id>`; a decline',
|
|
51
|
+
'is not reported back. The newest ask stands: asking again for a different',
|
|
52
|
+
'account, or a handle that names nobody, takes the earlier request back.',
|
|
53
|
+
'You see the outcome where you see a share: the contact reads linked.',
|
|
39
54
|
'',
|
|
40
55
|
'Another person’s contact is not yours to read or change: the API answers',
|
|
41
56
|
'not found. A block names a contact with --contributor <id>, on capture and',
|
|
@@ -43,7 +58,7 @@ const CONTACT_HELP = [
|
|
|
43
58
|
'',
|
|
44
59
|
'A contact that contributed a memory, that an invitation links, or that a',
|
|
45
60
|
'deny names cannot be deleted: the API refuses and says which. A deny is',
|
|
46
|
-
'lifted with `lattris
|
|
61
|
+
'lifted with `lattris remove deny <id> --to <contact>` first, so the same',
|
|
47
62
|
'number added back later never skips it.'
|
|
48
63
|
].join('\n');
|
|
49
64
|
const deniedBlocksWords = (body, contactId) => {
|
|
@@ -53,8 +68,8 @@ const deniedBlocksWords = (body, contactId) => {
|
|
|
53
68
|
if (!Array.isArray(blocks) || blocks.length === 0)
|
|
54
69
|
return '';
|
|
55
70
|
const lines = blocks.map((b) => ` ${b.id} ${sanitizeForTerminal(b.title ?? '(untitled)')} — ${renderRunHint([
|
|
56
|
-
'
|
|
57
|
-
'
|
|
71
|
+
'remove',
|
|
72
|
+
'deny',
|
|
58
73
|
b.id,
|
|
59
74
|
'--to',
|
|
60
75
|
contactId
|
|
@@ -197,6 +212,26 @@ export const contacts = {
|
|
|
197
212
|
refusalWords: (body, context) => deniedBlocksWords(body, context.contact?.id ?? ''),
|
|
198
213
|
renderTo: 'stderr',
|
|
199
214
|
render: (_answer, context) => `Deleted contact ${sanitizeForTerminal(context.contact?.displayName ?? context.positionals[0])}`
|
|
215
|
+
},
|
|
216
|
+
link: {
|
|
217
|
+
usage: 'Usage: lattris contact link <id-or-name> --handle <h>',
|
|
218
|
+
flags: { '--handle': 'handle' },
|
|
219
|
+
positionals: 1,
|
|
220
|
+
idPositionals: [0],
|
|
221
|
+
requiredFlags: ['handle'],
|
|
222
|
+
steps: {
|
|
223
|
+
contact: {
|
|
224
|
+
from: ['p0'],
|
|
225
|
+
mustBePerson: '{name} is an AI contact; only a person contact can stand for an account.\n'
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
request: {
|
|
229
|
+
method: 'POST',
|
|
230
|
+
path: '/contacts/{contact.id}/link',
|
|
231
|
+
body: { handle: { flag: 'handle' } }
|
|
232
|
+
},
|
|
233
|
+
renderAlways: true,
|
|
234
|
+
render: (_answer, context) => `Asked @${sanitizeForTerminal(context.flags.handle ?? '')} to let ${sanitizeForTerminal(context.contact?.displayName ?? context.positionals[0])} stand for their account. They answer from their inbox; the contact reads linked once they accept.`
|
|
200
235
|
}
|
|
201
236
|
})
|
|
202
237
|
};
|
package/dist/nouns/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import { CONSENT_HELP } from "./consent.js";
|
|
|
5
5
|
import { datasets } from "./datasets.js";
|
|
6
6
|
import { LINK_HELP, edges } from "./edges.js";
|
|
7
7
|
import { INVITE_HELP, invites } from "./invite.js";
|
|
8
|
-
import { ASK_HELP, CLOSE_HELP, CLOSE_USAGE, questions } from "./questions.js";
|
|
9
|
-
import { DENY_HELP,
|
|
8
|
+
import { ACCEPT_HELP, ACCEPT_USAGE, ASK_HELP, CLOSE_HELP, CLOSE_USAGE, DECLINE_HELP, DECLINE_USAGE, questions } from "./questions.js";
|
|
9
|
+
import { DENY_HELP, REMOVE_DENY_HELP, SHARE_HELP, UNSHARE_HELP, grants } from "./share.js";
|
|
10
10
|
export const listNouns = [contacts, questions, edges, invites, grants, datasets];
|
|
11
11
|
export const listVerbs = {
|
|
12
12
|
ask: { help: ASK_HELP, helpBeforeAuth: true },
|
|
@@ -16,6 +16,18 @@ export const listVerbs = {
|
|
|
16
16
|
bareIsHelp: true,
|
|
17
17
|
badNoun: { stderr: `${CLOSE_USAGE}\n` }
|
|
18
18
|
},
|
|
19
|
+
accept: {
|
|
20
|
+
help: ACCEPT_HELP,
|
|
21
|
+
helpBeforeAuth: true,
|
|
22
|
+
bareIsHelp: true,
|
|
23
|
+
badNoun: { stderr: `${ACCEPT_USAGE}\n` }
|
|
24
|
+
},
|
|
25
|
+
decline: {
|
|
26
|
+
help: DECLINE_HELP,
|
|
27
|
+
helpBeforeAuth: true,
|
|
28
|
+
bareIsHelp: true,
|
|
29
|
+
badNoun: { stderr: `${DECLINE_USAGE}\n` }
|
|
30
|
+
},
|
|
19
31
|
link: { help: LINK_HELP, helpBeforeAuth: true, bareIsHelp: true },
|
|
20
32
|
unlink: { help: LINK_HELP, helpBeforeAuth: true, bareIsHelp: true },
|
|
21
33
|
invite: { help: INVITE_HELP },
|
|
@@ -36,8 +48,9 @@ export const listVerbs = {
|
|
|
36
48
|
bareIsHelp: true,
|
|
37
49
|
badNoun: { stderr: 'Usage: lattris deny memory <id> --to <all-contacts | contact>\n' }
|
|
38
50
|
},
|
|
51
|
+
remove: { help: REMOVE_DENY_HELP, helpBeforeAuth: true },
|
|
39
52
|
undeny: {
|
|
40
|
-
help:
|
|
53
|
+
help: REMOVE_DENY_HELP,
|
|
41
54
|
helpBeforeAuth: true,
|
|
42
55
|
bareIsHelp: true,
|
|
43
56
|
badNoun: {
|
package/dist/nouns/invite.js
CHANGED
|
@@ -3,15 +3,16 @@ import { sanitizeForTerminal } from "../render/text.js";
|
|
|
3
3
|
const inviteLink = (webUrl, token) => `${webUrl}/i/${token}`;
|
|
4
4
|
const formatInvite = (webUrl, i) => {
|
|
5
5
|
const label = i.targetName ? ` — ${sanitizeForTerminal(i.targetName)}` : '';
|
|
6
|
+
const admits = i.email ? `\n admits ${sanitizeForTerminal(i.email)}` : '';
|
|
6
7
|
if (i.redeemedAt) {
|
|
7
8
|
const who = i.redeemedBy
|
|
8
9
|
? `${sanitizeForTerminal(i.redeemedBy.displayName ?? i.redeemedBy.handle)} (${sanitizeForTerminal(i.redeemedBy.handle)})`
|
|
9
10
|
: 'someone';
|
|
10
|
-
return `taken${label}\n by ${who} on ${i.redeemedAt}`;
|
|
11
|
+
return `taken${label}${admits}\n by ${who} on ${i.redeemedAt}`;
|
|
11
12
|
}
|
|
12
13
|
if (i.revokedAt)
|
|
13
|
-
return `revoked${label}\n minted ${i.createdAt}`;
|
|
14
|
-
return `live${label}\n ${inviteLink(webUrl, i.token)}\n minted ${i.createdAt}`;
|
|
14
|
+
return `revoked${label}${admits}\n minted ${i.createdAt}`;
|
|
15
|
+
return `live${label}${admits}\n ${inviteLink(webUrl, i.token)}\n minted ${i.createdAt}`;
|
|
15
16
|
};
|
|
16
17
|
const INVITE_HELP = [
|
|
17
18
|
'invite — bring one person in.',
|
|
@@ -25,16 +26,22 @@ const INVITE_HELP = [
|
|
|
25
26
|
'when you send it.',
|
|
26
27
|
'',
|
|
27
28
|
'Usage:',
|
|
28
|
-
' lattris invite <contact-name-or-id> [--yes]',
|
|
29
|
-
' lattris invite --for <name-or-id> [--yes] compatibility spelling',
|
|
29
|
+
' lattris invite <contact-name-or-id> [--email <address>] [--yes]',
|
|
30
|
+
' lattris invite --for <name-or-id> [--email <address>] [--yes] compatibility spelling',
|
|
30
31
|
'',
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
'
|
|
32
|
+
'An invitation admits one email address: the one the person will sign up',
|
|
33
|
+
'with. The contact must be one of yours. A name is matched exactly, ignoring',
|
|
34
|
+
'case, and a name of more than one word needs no quotes. If that name does',
|
|
35
|
+
'not exist, a person contact is created holding that email before minting.',
|
|
36
|
+
'A contact that already holds an email needs no --email, and its email is',
|
|
37
|
+
'the one sent; one that holds a different email is refused, never changed.',
|
|
38
|
+
'A contact holding none has the email recorded on it first. Duplicate names',
|
|
39
|
+
'are never guessed: use the contact id shown by `lattris contact list`.',
|
|
35
40
|
'',
|
|
36
|
-
' --
|
|
37
|
-
'
|
|
41
|
+
' --email <address> the address the invitation admits; needed unless the',
|
|
42
|
+
' contact already holds one',
|
|
43
|
+
' --yes required when not at a terminal (there is no prompt',
|
|
44
|
+
' to answer there); at a terminal you are always asked.',
|
|
38
45
|
'',
|
|
39
46
|
'To see the ones you have out: lattris get invites'
|
|
40
47
|
].join('\n');
|
|
@@ -42,33 +49,52 @@ const inviteVerb = {
|
|
|
42
49
|
verb: 'invite',
|
|
43
50
|
form: {
|
|
44
51
|
usage: INVITE_HELP,
|
|
45
|
-
flags: { '--for': 'for' },
|
|
52
|
+
flags: { '--for': 'for', '--email': 'email' },
|
|
46
53
|
switches: ['--yes'],
|
|
47
54
|
positionals: 0,
|
|
48
55
|
positionalsAtMost: 1,
|
|
56
|
+
joinPositionals: true,
|
|
49
57
|
contradictions: [{ a: 'p0', b: 'for', message: `${INVITE_HELP}\n` }],
|
|
58
|
+
addressFlags: [{ key: 'email', message: '--email takes an email address, not "{value}".\n' }],
|
|
50
59
|
steps: {
|
|
51
60
|
contact: {
|
|
52
61
|
from: ['p0', 'flag:for'],
|
|
53
62
|
required: 'A contact name or id is required.\n',
|
|
54
63
|
mustBePerson: '{name} is an AI contact. An invitation must go to a person contact.\n',
|
|
55
|
-
createIfMissing: true
|
|
64
|
+
createIfMissing: true,
|
|
65
|
+
email: {
|
|
66
|
+
flag: 'email',
|
|
67
|
+
required: 'No email for {name}: an invitation admits one address, and this contact holds none. Pass --email <address>.\n',
|
|
68
|
+
requiredNew: '{name} is not among your contacts. Creating them for an invitation needs --email <address>.\n',
|
|
69
|
+
conflict: '{name} holds {held}, and --email says {typed}. Pass the one the contact holds, or change it first: lattris contact update {contact.id} --email <address>\n'
|
|
70
|
+
}
|
|
56
71
|
},
|
|
57
72
|
pipedNeedsYes: {
|
|
58
73
|
message: 'Refusing to mint without confirmation. Pass --yes once the person has asked you to invite someone.\n'
|
|
59
74
|
},
|
|
60
75
|
confirm: {
|
|
61
|
-
question: 'Mint an invitation for {name}? [y/N] ',
|
|
62
|
-
whenMissing: 'Create person contact "{name}" and mint their invitation? [y/N] ',
|
|
76
|
+
question: 'Mint an invitation for {name}, admitting {email}? [y/N] ',
|
|
77
|
+
whenMissing: 'Create person contact "{name}" holding {email}, and mint their invitation? [y/N] ',
|
|
78
|
+
whenRecording: 'Record {email} on {name}, and mint their invitation? [y/N] ',
|
|
63
79
|
onNo: { text: 'Not minted.\n', to: 'stdout' }
|
|
64
80
|
}
|
|
65
81
|
},
|
|
66
|
-
request: {
|
|
82
|
+
request: {
|
|
83
|
+
method: 'POST',
|
|
84
|
+
path: '/invites',
|
|
85
|
+
body: { contactId: { context: 'contact.id' }, email: { context: 'email' } }
|
|
86
|
+
},
|
|
67
87
|
render: (data, context) => {
|
|
68
88
|
const i = data;
|
|
69
89
|
const contact = context.contact;
|
|
70
|
-
|
|
71
|
-
|
|
90
|
+
const admitted = sanitizeForTerminal(i.email ?? context.email ?? '');
|
|
91
|
+
const first = context.createdContact
|
|
92
|
+
? `Recorded person contact ${formatContact(contact)}.\n\n`
|
|
93
|
+
: context.recordedEmail
|
|
94
|
+
? `Recorded ${admitted} on ${sanitizeForTerminal(contact.displayName)}.\n\n`
|
|
95
|
+
: '';
|
|
96
|
+
return (first +
|
|
97
|
+
`Invitation minted${i.targetName ? ` for ${sanitizeForTerminal(i.targetName)}` : ''}, admitting ${admitted}.\n\n` +
|
|
72
98
|
` ${inviteLink(context.webUrl, i.token)}\n\n` +
|
|
73
99
|
`Hand it to ONE person — it is spent when someone signs up with it.\n` +
|
|
74
100
|
`It is not permission to join; whether they may register is decided separately.\n` +
|
|
@@ -84,7 +110,7 @@ const getInvites = {
|
|
|
84
110
|
positionals: 0,
|
|
85
111
|
request: { method: 'GET', path: '/invites' },
|
|
86
112
|
render: (list, context) => list.length === 0
|
|
87
|
-
? 'No invitations yet. `lattris invite <contact>` mints one.'
|
|
113
|
+
? 'No invitations yet. `lattris invite <contact> --email <address>` mints one.'
|
|
88
114
|
: list.map((i) => formatInvite(context.webUrl, i)).join('\n\n')
|
|
89
115
|
}
|
|
90
116
|
};
|
package/dist/nouns/questions.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatAsked, formatClosed, formatQuestionList } from "../render/rows.js";
|
|
1
|
+
import { formatAsked, formatClosed, formatLinkAnswer, formatQuestionList } from "../render/rows.js";
|
|
2
2
|
export const ASK_HELP = [
|
|
3
3
|
'ask — leave a question on someone’s tree.',
|
|
4
4
|
'',
|
|
@@ -106,11 +106,64 @@ const getQuestions = {
|
|
|
106
106
|
: 'No questions on your tree.'
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
+
const ACCEPT_USAGE = 'Usage: lattris accept contact <id-or-prefix>';
|
|
110
|
+
const DECLINE_USAGE = 'Usage: lattris decline contact <id-or-prefix>';
|
|
111
|
+
export const ACCEPT_HELP = [
|
|
112
|
+
'accept — say yes to a request in your inbox to link you as a contact.',
|
|
113
|
+
'',
|
|
114
|
+
ACCEPT_USAGE,
|
|
115
|
+
'',
|
|
116
|
+
' <id-or-prefix> the request’s full UUID, or a >=4-char hex prefix over',
|
|
117
|
+
' YOUR OWN link requests — an ambiguous prefix refuses and',
|
|
118
|
+
' lists the candidates, like `close question`',
|
|
119
|
+
'',
|
|
120
|
+
'Accepting links both sides at once: their contact comes to stand for your',
|
|
121
|
+
'account, and a contact naming them appears among yours, linked. If you',
|
|
122
|
+
'had asked them too, your contact from that request is the one linked and',
|
|
123
|
+
'that request closes as accepted as well. A request whose contact was',
|
|
124
|
+
'linked elsewhere meanwhile closes as superseded and links nothing.',
|
|
125
|
+
'Your inbox: lattris get questions'
|
|
126
|
+
].join('\n');
|
|
127
|
+
export const DECLINE_HELP = [
|
|
128
|
+
'decline — say no to a request in your inbox to link you as a contact.',
|
|
129
|
+
'',
|
|
130
|
+
DECLINE_USAGE,
|
|
131
|
+
'',
|
|
132
|
+
' <id-or-prefix> the request’s full UUID, or a >=4-char hex prefix over',
|
|
133
|
+
' YOUR OWN link requests',
|
|
134
|
+
'',
|
|
135
|
+
'Declining closes the request and changes nothing else; the person who',
|
|
136
|
+
'asked is not told. Your inbox: lattris get questions'
|
|
137
|
+
].join('\n');
|
|
138
|
+
const acceptVerb = {
|
|
139
|
+
verb: 'accept',
|
|
140
|
+
nouns: ['contact', 'contacts'],
|
|
141
|
+
form: {
|
|
142
|
+
usage: ACCEPT_USAGE,
|
|
143
|
+
idPositionals: [0],
|
|
144
|
+
positionals: 1,
|
|
145
|
+
unknownFlagIsUsage: true,
|
|
146
|
+
request: { method: 'POST', path: '/questions/{p0}/accept' },
|
|
147
|
+
render: (q) => formatLinkAnswer(q)
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const declineVerb = {
|
|
151
|
+
verb: 'decline',
|
|
152
|
+
nouns: ['contact', 'contacts'],
|
|
153
|
+
form: {
|
|
154
|
+
usage: DECLINE_USAGE,
|
|
155
|
+
idPositionals: [0],
|
|
156
|
+
positionals: 1,
|
|
157
|
+
unknownFlagIsUsage: true,
|
|
158
|
+
request: { method: 'POST', path: '/questions/{p0}/decline' },
|
|
159
|
+
render: (q) => formatLinkAnswer(q)
|
|
160
|
+
}
|
|
161
|
+
};
|
|
109
162
|
export const questions = {
|
|
110
163
|
name: 'questions',
|
|
111
164
|
words: { singular: 'question', plural: 'questions' },
|
|
112
165
|
help: CLOSE_HELP,
|
|
113
|
-
verbs: [askVerb, closeVerb, getQuestions]
|
|
166
|
+
verbs: [askVerb, closeVerb, getQuestions, acceptVerb, declineVerb]
|
|
114
167
|
};
|
|
115
|
-
export { CLOSE_USAGE };
|
|
168
|
+
export { ACCEPT_USAGE, CLOSE_USAGE, DECLINE_USAGE };
|
|
116
169
|
//# sourceMappingURL=questions.js.map
|
package/dist/nouns/share.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { audienceOf, formatAccessRow, formatAudiences, waitsForNameSentence } from "../render/rows.js";
|
|
2
2
|
import { renderRunHint, sanitizeForTerminal } from "../render/text.js";
|
|
3
|
+
import { formatSharesPage, goneSentence } from "../render/shares.js";
|
|
3
4
|
import { consent } from "./consent.js";
|
|
4
5
|
const ALL_CONTACTS = 'all-contacts';
|
|
5
6
|
const AUDIENCE_WORDS = '--with is required. Use public, all-contacts, or one of your contact names or ids.\n';
|
|
@@ -8,7 +9,8 @@ const PUBLIC_CANNOT_BE_DENIED = 'public cannot be denied: a deny names a contact
|
|
|
8
9
|
export const SHARE_HELP = [
|
|
9
10
|
'share — allow an audience to see a memory: public, all your contacts,',
|
|
10
11
|
'or one contact. A contact needs no Lattris account; a linked contact also',
|
|
11
|
-
'sees it on the website.',
|
|
12
|
+
'sees it on the website. A memory someone shared with you takes a contact',
|
|
13
|
+
"share too, for your own contacts; public is the owner's alone.",
|
|
12
14
|
'',
|
|
13
15
|
'Usage:',
|
|
14
16
|
' lattris share memory <id-or-prefix> --with <public | all-contacts | contact> [--yes]',
|
|
@@ -21,14 +23,16 @@ export const SHARE_HELP = [
|
|
|
21
23
|
' asked, --yes or not.',
|
|
22
24
|
'',
|
|
23
25
|
'A deny on the memory beats any allow: the answer names who is still shut',
|
|
24
|
-
'out, and `lattris
|
|
25
|
-
'has access succeeds and changes nothing.',
|
|
26
|
+
'out, and `lattris remove deny` lifts it. Sharing with an audience that',
|
|
27
|
+
'already has access succeeds and changes nothing. `lattris get shares`',
|
|
28
|
+
'lists every share and deny you have set.',
|
|
26
29
|
'',
|
|
27
30
|
'Alias: publish → share'
|
|
28
31
|
].join('\n');
|
|
29
32
|
export const DENY_HELP = [
|
|
30
33
|
'deny — shut a memory to one contact or to all your contacts, whatever',
|
|
31
|
-
'else allows it. Nothing is asked: a deny is the safe direction.',
|
|
34
|
+
'else allows it. Nothing is asked: a deny is the safe direction. A memory',
|
|
35
|
+
'someone shared with you takes a deny too, for your own contacts.',
|
|
32
36
|
'',
|
|
33
37
|
'Usage:',
|
|
34
38
|
' lattris deny memory <id-or-prefix> --to <all-contacts | contact>',
|
|
@@ -39,15 +43,23 @@ export const DENY_HELP = [
|
|
|
39
43
|
'',
|
|
40
44
|
'A deny cannot hold while the memory is public or shared on the website',
|
|
41
45
|
'with the person it would shut out; the refusal names the share in the',
|
|
42
|
-
'way. `lattris
|
|
46
|
+
'way. `lattris remove deny` lifts a deny, and `lattris get shares` lists',
|
|
47
|
+
'the ones you have set.'
|
|
43
48
|
].join('\n');
|
|
44
|
-
export const
|
|
45
|
-
'
|
|
49
|
+
export const REMOVE_DENY_HELP = [
|
|
50
|
+
'remove deny — lift a deny from a memory, for one contact or for all your',
|
|
46
51
|
'contacts. It opens the memory to whatever allows it, so it asks at a',
|
|
47
|
-
'terminal and needs --yes on a pipe.',
|
|
52
|
+
'terminal and needs --yes on a pipe. A memory someone shared with you',
|
|
53
|
+
'takes it too, for your own denies.',
|
|
48
54
|
'',
|
|
49
55
|
'Usage:',
|
|
50
|
-
' lattris
|
|
56
|
+
' lattris remove deny [memory] <id-or-prefix> --to <all-contacts | contact> [--yes]',
|
|
57
|
+
'',
|
|
58
|
+
'It works on a memory that is no longer shared with you too, for your own',
|
|
59
|
+
'denies, so a deny never holds a contact for good. `lattris get shares`',
|
|
60
|
+
'lists the denies you have set.',
|
|
61
|
+
'',
|
|
62
|
+
'Alias: undeny memory <id> → remove deny <id>'
|
|
51
63
|
].join('\n');
|
|
52
64
|
const isAccessGrant = (grant) => typeof grant === 'object' &&
|
|
53
65
|
grant !== null &&
|
|
@@ -87,7 +99,7 @@ const otherEffectWords = (asked) => (body, context) => {
|
|
|
87
99
|
const id = context.memory?.id ?? context.positionals[0];
|
|
88
100
|
const who = context.contact?.id ?? ALL_CONTACTS;
|
|
89
101
|
return found === 'deny'
|
|
90
|
-
? `This is a deny, not a share. Lift it with: ${renderRunHint(['
|
|
102
|
+
? `This is a deny, not a share. Lift it with: ${renderRunHint(['remove', 'deny', id, '--to', who])}\n`
|
|
91
103
|
: `This is a share, not a deny. Withdraw it with: ${renderRunHint(['unshare', 'memory', id, '--with', who])}\n`;
|
|
92
104
|
};
|
|
93
105
|
const inTheWay = (body) => {
|
|
@@ -162,46 +174,55 @@ const denyVerb = {
|
|
|
162
174
|
render: (_grant, context) => `Denied memory ${context.positionals[0]} to ${context.contact ? sanitizeForTerminal(context.contact.displayName) : 'all contacts'}`
|
|
163
175
|
}
|
|
164
176
|
};
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
requireFlag: { key: 'to', message: DENY_WORDS },
|
|
176
|
-
pipedNeedsYes: {
|
|
177
|
-
message: 'Refusing to lift a deny without confirmation on a non-interactive session. Pass --yes to skip the prompt.\n'
|
|
178
|
-
},
|
|
179
|
-
contact: {
|
|
180
|
-
from: ['flag:to'],
|
|
181
|
-
reserved: [ALL_CONTACTS],
|
|
182
|
-
refusedWords: { public: PUBLIC_CANNOT_BE_DENIED }
|
|
183
|
-
},
|
|
184
|
-
memory: 'at-tty',
|
|
185
|
-
confirm: {
|
|
186
|
-
question: 'Lift the deny on "{title}" ({memory.id}) for {audience}? [y/N] ',
|
|
187
|
-
onNo: { text: 'Cancelled.\n', to: 'stderr' },
|
|
188
|
-
onInterrupted: { text: 'Cancelled.\n', exit: 1 }
|
|
189
|
-
}
|
|
177
|
+
const liftingForm = {
|
|
178
|
+
usage: 'Usage: lattris remove deny [memory] <id> --to <all-contacts | contact> [--yes]',
|
|
179
|
+
flags: { '--to': 'to' },
|
|
180
|
+
switches: ['--yes'],
|
|
181
|
+
positionals: 1,
|
|
182
|
+
idPositionals: [0],
|
|
183
|
+
steps: {
|
|
184
|
+
requireFlag: { key: 'to', message: DENY_WORDS },
|
|
185
|
+
pipedNeedsYes: {
|
|
186
|
+
message: 'Refusing to lift a deny without confirmation on a non-interactive session. Pass --yes to skip the prompt.\n'
|
|
190
187
|
},
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
188
|
+
contact: {
|
|
189
|
+
from: ['flag:to'],
|
|
190
|
+
reserved: [ALL_CONTACTS],
|
|
191
|
+
refusedWords: { public: PUBLIC_CANNOT_BE_DENIED }
|
|
195
192
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
193
|
+
memory: 'at-tty',
|
|
194
|
+
memoryMayBeGone: true,
|
|
195
|
+
confirm: {
|
|
196
|
+
question: 'Lift the deny on "{title}" ({memory.id}) for {audience}? [y/N] ',
|
|
197
|
+
onNo: { text: 'Cancelled.\n', to: 'stderr' },
|
|
198
|
+
onInterrupted: { text: 'Cancelled.\n', exit: 1 }
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
request: {
|
|
202
|
+
method: 'DELETE',
|
|
203
|
+
path: '/memories/{memory.id}/grants/contact/{contact.id}?effect=deny',
|
|
204
|
+
pathFor: { [ALL_CONTACTS]: '/memories/{memory.id}/grants/all-contacts?effect=deny' }
|
|
205
|
+
},
|
|
206
|
+
ambiguousRefusal: true,
|
|
207
|
+
refusalWords: otherEffectWords('deny'),
|
|
208
|
+
renderTo: 'stderr',
|
|
209
|
+
render: (_data, context) => {
|
|
210
|
+
const who = context.contact ? sanitizeForTerminal(context.contact.displayName) : 'all contacts';
|
|
211
|
+
return context.gone
|
|
212
|
+
? goneSentence(`Your deny for ${who} was lifted.`)
|
|
213
|
+
: `Lifted the deny on memory ${context.memory?.id ?? context.positionals[0]} for ${who}`;
|
|
200
214
|
}
|
|
201
215
|
};
|
|
216
|
+
const removeDenyVerb = {
|
|
217
|
+
verb: 'remove',
|
|
218
|
+
nouns: ['deny'],
|
|
219
|
+
form: { ...liftingForm, dropLeadingWords: ['memory'] }
|
|
220
|
+
};
|
|
221
|
+
const undenyVerb = { verb: 'undeny', nouns: ['memory', 'memories'], form: liftingForm };
|
|
202
222
|
export const UNSHARE_HELP = [
|
|
203
223
|
'unshare — withdraw an audience from a memory. No confirmation — withdrawal',
|
|
204
|
-
'is the safe direction.',
|
|
224
|
+
'is the safe direction. A memory someone shared with you takes it too, for',
|
|
225
|
+
"your own contact shares; public is the owner's alone.",
|
|
205
226
|
'',
|
|
206
227
|
'Usage:',
|
|
207
228
|
' lattris unshare memory <id-or-prefix> --with <public | all-contacts | contact>',
|
|
@@ -214,7 +235,9 @@ export const UNSHARE_HELP = [
|
|
|
214
235
|
'',
|
|
215
236
|
'Bare (no --with): refuses and shows what the memory is currently shared',
|
|
216
237
|
'with, so you can see the state and the fix in one line. A deny is lifted',
|
|
217
|
-
'with `lattris
|
|
238
|
+
'with `lattris remove deny`, not here. On a memory that is no longer',
|
|
239
|
+
'shared with you, it removes your own contact shares still; `lattris get',
|
|
240
|
+
'shares` lists them.',
|
|
218
241
|
'',
|
|
219
242
|
'Alias: unpublish → unshare'
|
|
220
243
|
].join('\n');
|
|
@@ -229,6 +252,7 @@ const unshareVerb = {
|
|
|
229
252
|
steps: {
|
|
230
253
|
contact: { from: ['flag:with'], publicWord: 'public', reserved: [ALL_CONTACTS] },
|
|
231
254
|
memory: 'always',
|
|
255
|
+
memoryMayBeGone: true,
|
|
232
256
|
noAudienceReport: {
|
|
233
257
|
key: 'with',
|
|
234
258
|
first: AUDIENCE_WORDS,
|
|
@@ -249,11 +273,58 @@ const unshareVerb = {
|
|
|
249
273
|
ambiguousRefusal: true,
|
|
250
274
|
refusalWords: otherEffectWords('allow'),
|
|
251
275
|
renderTo: 'stderr',
|
|
252
|
-
render: (_data, context) =>
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
276
|
+
render: (_data, context) => {
|
|
277
|
+
const who = context.contact
|
|
278
|
+
? sanitizeForTerminal(context.contact.displayName)
|
|
279
|
+
: context.reserved === ALL_CONTACTS
|
|
280
|
+
? 'all contacts'
|
|
281
|
+
: 'public';
|
|
282
|
+
return context.gone
|
|
283
|
+
? goneSentence(`Your share with ${who} was removed.`)
|
|
284
|
+
: `Unshared memory ${context.memory?.id ?? ''} from ${who}`;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
export const GET_SHARES_HELP = [
|
|
289
|
+
'get shares — every share and deny you have set, on your memories, on the',
|
|
290
|
+
'ones shared with you, and on ones shared with you once and no longer.',
|
|
291
|
+
'',
|
|
292
|
+
'Usage:',
|
|
293
|
+
' lattris get shares [--for <contact>] [--limit <n>] [--cursor <token>]',
|
|
294
|
+
'',
|
|
295
|
+
' --for one of your contacts, by exact name or id from',
|
|
296
|
+
' `lattris contact list`: the shares and denies that name them,',
|
|
297
|
+
' and the ones you set for all contacts. This is what you said',
|
|
298
|
+
' about them; `lattris get memories --for` is what they may see.',
|
|
299
|
+
' --limit rows per page; --cursor continues where a page stopped.',
|
|
300
|
+
'',
|
|
301
|
+
'A memory no longer shared with you shows its id alone: your shares and',
|
|
302
|
+
'denies on it stay, decide nothing until it is shared again, and',
|
|
303
|
+
'`lattris unshare` and `lattris remove deny` still take them away.'
|
|
304
|
+
].join('\n');
|
|
305
|
+
const getSharesVerb = {
|
|
306
|
+
verb: 'get',
|
|
307
|
+
nouns: ['shares'],
|
|
308
|
+
form: {
|
|
309
|
+
usage: 'Usage: lattris get shares [--for <contact>] [--limit <n>] [--cursor <token>]',
|
|
310
|
+
flags: { '--for': 'for', '--limit': 'limit', '--cursor': 'cursor' },
|
|
311
|
+
positionals: 0,
|
|
312
|
+
steps: { contact: { from: ['flag:for'] } },
|
|
313
|
+
request: {
|
|
314
|
+
method: 'GET',
|
|
315
|
+
path: '/memories/shares',
|
|
316
|
+
query: {
|
|
317
|
+
forContact: { context: 'contact.id' },
|
|
318
|
+
limit: { flag: 'limit' },
|
|
319
|
+
cursor: { flag: 'cursor' }
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
page: {
|
|
323
|
+
cursor: 'nextCursor',
|
|
324
|
+
hint: ['get', 'shares'],
|
|
325
|
+
carry: { '--for': 'for', '--limit': 'limit' }
|
|
326
|
+
},
|
|
327
|
+
render: (page, context) => formatSharesPage(page, context.contact?.displayName ?? context.flags.for)
|
|
257
328
|
}
|
|
258
329
|
};
|
|
259
330
|
export const audiencesOf = (memory) => formatAudiences(memory.audiences);
|
|
@@ -261,6 +332,6 @@ export const grants = {
|
|
|
261
332
|
name: 'grants',
|
|
262
333
|
words: { singular: 'grant', plural: 'grants' },
|
|
263
334
|
help: SHARE_HELP,
|
|
264
|
-
verbs: [shareVerb, unshareVerb, denyVerb, undenyVerb, consent]
|
|
335
|
+
verbs: [shareVerb, unshareVerb, denyVerb, removeDenyVerb, undenyVerb, getSharesVerb, consent]
|
|
265
336
|
};
|
|
266
337
|
//# sourceMappingURL=share.js.map
|
package/dist/nouns/words.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const VERB_ALIASES = {
|
|
2
2
|
read: 'get',
|
|
3
3
|
show: 'get',
|
|
4
4
|
view: 'get',
|
|
@@ -7,6 +7,11 @@ export const VERB_ALIASES = {
|
|
|
7
7
|
publish: 'share',
|
|
8
8
|
unpublish: 'unshare'
|
|
9
9
|
};
|
|
10
|
+
export const resolveVerb = (typed, next) => typed === 'remove' && next === 'deny'
|
|
11
|
+
? 'remove'
|
|
12
|
+
: Object.hasOwn(VERB_ALIASES, typed)
|
|
13
|
+
? VERB_ALIASES[typed]
|
|
14
|
+
: typed;
|
|
10
15
|
export const USAGE_LINES = [
|
|
11
16
|
' lattris login Sign in via the browser (PKCE) and store the session',
|
|
12
17
|
' lattris setup Transition this repo’s Claude to Lattris as its memory system',
|
|
@@ -19,18 +24,21 @@ export const USAGE_LINES = [
|
|
|
19
24
|
' lattris capture session <transcript> Save an AI conversation — the whole chain from its file',
|
|
20
25
|
' lattris capture recording Keep a recording \u2014 held audio, a source, or a transcript file',
|
|
21
26
|
' lattris get memories List your memories, newest first, with filters (--for <contact> for what they may see)',
|
|
22
|
-
' lattris contact create "<name>" Record a person or an AI you work with (--ai, --phone); add, list, get, update, delete',
|
|
23
|
-
' lattris invite <contact>
|
|
27
|
+
' lattris contact create "<name>" Record a person or an AI you work with (--ai, --phone); add, list, get, update, delete, link',
|
|
28
|
+
' lattris invite <contact> [--email <address>] Mint an invitation for one of your person contacts, admitting one address',
|
|
24
29
|
' lattris get invites List the invitations you have minted',
|
|
25
30
|
' lattris get memory <id> Read one memory back \u2014 words and edges (--links/--depth/--content)',
|
|
26
31
|
' lattris ask <handle> Leave a question on someone\u2019s tree \u2014 `echo "\u2026" | lattris ask <handle>`',
|
|
27
32
|
' lattris get questions The questions on your tree, open first (--mine: ones you asked)',
|
|
28
33
|
' lattris close question <id> Close a question (--close-as updated|declined|already-answered)',
|
|
34
|
+
' lattris accept contact <id> Say yes to a request to link you as a contact: both sides link',
|
|
35
|
+
' lattris decline contact <id> Say no to one; nothing changes and the asker is not told',
|
|
29
36
|
' lattris share memory <id> Allow an audience to see it (--with public | all-contacts | <contact>)',
|
|
30
37
|
' lattris unshare memory <id> Withdraw an audience (--with public | all-contacts | <contact>)',
|
|
31
38
|
' lattris deny memory <id> Shut it to a contact or all contacts, whatever allows it (--to)',
|
|
32
|
-
' lattris
|
|
39
|
+
' lattris remove deny <id> Lift a deny (--to all-contacts | <contact>)',
|
|
33
40
|
' lattris get access <id> May a contact or a number see it, and because of what (--for)',
|
|
41
|
+
' lattris get shares Every share and deny you have set (--for <contact>: what you said about them)',
|
|
34
42
|
' lattris consent <id> Put a memory shared with you on your graph (--withdraw reverses)',
|
|
35
43
|
' lattris link <from> <to> State that one memory leads to another (--verb, --reason)',
|
|
36
44
|
' lattris unlink <from> <to> Remove that claim (--verb; the blocks stay)',
|
|
@@ -61,6 +69,8 @@ export const COMMAND_WORDS = new Set([
|
|
|
61
69
|
'get',
|
|
62
70
|
'ask',
|
|
63
71
|
'close',
|
|
72
|
+
'accept',
|
|
73
|
+
'decline',
|
|
64
74
|
'delete',
|
|
65
75
|
'update',
|
|
66
76
|
'link',
|
|
@@ -70,6 +80,7 @@ export const COMMAND_WORDS = new Set([
|
|
|
70
80
|
'unshare',
|
|
71
81
|
'deny',
|
|
72
82
|
'undeny',
|
|
83
|
+
'remove',
|
|
73
84
|
'consent',
|
|
74
85
|
'restore',
|
|
75
86
|
'erase',
|
package/dist/registry/memory.js
CHANGED
|
@@ -6,6 +6,7 @@ import { DELETE_HELP, deleteMemory } from "../memory/delete.js";
|
|
|
6
6
|
import { ERASE_HELP, eraseMemory } from "../memory/erase.js";
|
|
7
7
|
import { GET_ACCESS_HELP, getAccess } from "../memory/access.js";
|
|
8
8
|
import { GET_HELP } from "../memory/get-help.js";
|
|
9
|
+
import { GET_SHARES_HELP } from "../nouns/share.js";
|
|
9
10
|
import { getMemories } from "../memory/get.js";
|
|
10
11
|
import { getDeleted, getHistory } from "../memory/history.js";
|
|
11
12
|
import { CAPTURE_RECORDING_HELP, captureRecording } from "../memory/recording.js";
|
|
@@ -79,10 +80,12 @@ export const memoryVerbs = {
|
|
|
79
80
|
? GET_DATASETS_HELP
|
|
80
81
|
: args[0] === 'access'
|
|
81
82
|
? GET_ACCESS_HELP
|
|
82
|
-
:
|
|
83
|
+
: args[0] === 'shares'
|
|
84
|
+
? GET_SHARES_HELP
|
|
85
|
+
: GET_HELP,
|
|
83
86
|
bareIsHelp: true,
|
|
84
87
|
badNoun: {
|
|
85
|
-
stderr: 'Usage: lattris get memories | lattris get memory <id> | lattris get access <id> --for <contact | number> | lattris get history <id> | lattris get deleted | lattris get invites | lattris get questions | lattris get datasets | lattris get dataset <name> | lattris get rows <name> | lattris get row <name> <id>\n'
|
|
88
|
+
stderr: 'Usage: lattris get memories | lattris get memory <id> | lattris get access <id> --for <contact | number> | lattris get shares [--for <contact>] | lattris get history <id> | lattris get deleted | lattris get invites | lattris get questions | lattris get datasets | lattris get dataset <name> | lattris get rows <name> | lattris get row <name> <id>\n'
|
|
86
89
|
}
|
|
87
90
|
},
|
|
88
91
|
update: {
|
package/dist/render/rows.js
CHANGED
|
@@ -36,12 +36,19 @@ export const formatAccess = (rows) => rows.length === 0 ? '(nothing set)' : rows
|
|
|
36
36
|
export const describeForContact = (c, asked) => c === null
|
|
37
37
|
? `no contact holds ${sanitizeForTerminal(asked ?? 'that number')}; a stranger sees public memories only`
|
|
38
38
|
: `${sanitizeForTerminal(c.displayName)} (${c.type}${c.phone ? `, ${sanitizeForTerminal(c.phone)}` : ''})`;
|
|
39
|
+
const askerLine = (q) => `${sanitizeForTerminal(q.askerName ?? '(unnamed)')} (@${sanitizeForTerminal(q.sharerHandle ?? '(unknown)')})`;
|
|
39
40
|
export const formatQuestion = (q) => {
|
|
40
41
|
const lines = [`id ${q.id}`, `createdAt ${q.createdAt}`];
|
|
41
42
|
if (q.kind === 'share') {
|
|
42
43
|
lines.push(`shared by @${sanitizeForTerminal(q.sharerHandle ?? '(unknown)')}`, `memory ${q.aboutBlockId ?? '(missing)'}`, `seen ${q.seenAt ?? '(unseen)'}`);
|
|
43
44
|
return lines.join('\n');
|
|
44
45
|
}
|
|
46
|
+
if (q.kind === 'contact_link') {
|
|
47
|
+
lines.push(`link request ${askerLine(q)} asks to link you as a contact`, q.closedAs === null
|
|
48
|
+
? `answer ${renderRunHint(['accept', 'contact', q.id])} or ${renderRunHint(['decline', 'contact', q.id])}`
|
|
49
|
+
: `closed as ${sanitizeForTerminal(q.closedAs)}${q.closedAt ? ` ${q.closedAt}` : ''}`);
|
|
50
|
+
return lines.join('\n');
|
|
51
|
+
}
|
|
45
52
|
if (q.aboutBlockId)
|
|
46
53
|
lines.push(`about ${q.aboutBlockId}`);
|
|
47
54
|
lines.push(q.closedAs === null
|
|
@@ -60,6 +67,11 @@ export const formatAsked = (q) => {
|
|
|
60
67
|
lines.push(` createdAt ${q.createdAt}`);
|
|
61
68
|
return lines.join('\n');
|
|
62
69
|
};
|
|
70
|
+
export const formatLinkAnswer = (q) => q.closedAs === 'accepted'
|
|
71
|
+
? `Linked ${askerLine(q)} as a contact; their contact now stands for your account.`
|
|
72
|
+
: q.closedAs === 'superseded'
|
|
73
|
+
? `Nothing linked: a contact on ${askerLine(q)}'s side already stands for an account, so the request is closed as superseded.`
|
|
74
|
+
: `Declined the link request from ${askerLine(q)}. Nothing changed, and they are not told.`;
|
|
63
75
|
export const formatClosed = (q) => `Closed question ${q.id} (${sanitizeForTerminal(q.closedAs ?? '')})${q.closeBlockId ? ` → ${q.closeBlockId}` : ''}`;
|
|
64
76
|
export const formatEdgeReceipt = (heading, e) => [
|
|
65
77
|
`${heading} (verb: ${sanitizeForTerminal(e.verb)})`,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { formatAccessRow } from "./rows.js";
|
|
2
|
+
import { sanitizeForTerminal } from "./text.js";
|
|
3
|
+
export const NO_LONGER_SHARED = '(no longer shared with you)';
|
|
4
|
+
const titleOf = (r) => r.state === 'unshared' ? NO_LONGER_SHARED : sanitizeForTerminal(r.title ?? '(untitled)');
|
|
5
|
+
const ownerOf = (r) => r.state === 'mine'
|
|
6
|
+
? 'mine'
|
|
7
|
+
: r.state === 'deleted'
|
|
8
|
+
? 'mine, in deleted items'
|
|
9
|
+
: `by ${sanitizeForTerminal(r.ownerDisplayName ?? r.ownerHandle)} (@${sanitizeForTerminal(r.ownerHandle)})`;
|
|
10
|
+
export const formatSharesPage = (page, forName) => {
|
|
11
|
+
if (page.items.length === 0) {
|
|
12
|
+
return forName === undefined
|
|
13
|
+
? 'You have set nothing on any memory.'
|
|
14
|
+
: `Nothing you have set names ${sanitizeForTerminal(forName)}.`;
|
|
15
|
+
}
|
|
16
|
+
const lines = [];
|
|
17
|
+
let current;
|
|
18
|
+
for (const row of page.items) {
|
|
19
|
+
if (row.blockId !== current) {
|
|
20
|
+
current = row.blockId;
|
|
21
|
+
lines.push(`${row.blockId} ${titleOf(row)} ${ownerOf(row)}`);
|
|
22
|
+
}
|
|
23
|
+
lines.push(` ${formatAccessRow(row)}`);
|
|
24
|
+
}
|
|
25
|
+
return lines.join('\n');
|
|
26
|
+
};
|
|
27
|
+
export const goneSentence = (done) => `That memory is no longer shared with you. ${done}`;
|
|
28
|
+
//# sourceMappingURL=shares.js.map
|
package/dist/request/door.js
CHANGED
|
@@ -8,6 +8,7 @@ export const parseErrorBody = (text) => {
|
|
|
8
8
|
return {};
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
+
const SECURITY_CODE = /^(?:security|auth)[:/]/;
|
|
11
12
|
export const classifyApiError = (status, body) => {
|
|
12
13
|
if (body.next?.action) {
|
|
13
14
|
return { message: body.message ?? 'Action required.', next: body.next, exit: EXIT.DOOR };
|
|
@@ -19,7 +20,7 @@ export const classifyApiError = (status, body) => {
|
|
|
19
20
|
exit: EXIT.NOAUTH
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
|
-
if (status === 403) {
|
|
23
|
+
if (status === 403 && (body.code === undefined || SECURITY_CODE.test(body.code))) {
|
|
23
24
|
return {
|
|
24
25
|
message: body.message ?? 'Your session lacks a required scope.',
|
|
25
26
|
next: { action: 'login' },
|