lattris 0.2.2 → 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/dist/build.json +1 -1
- package/dist/dispatch-form.js +22 -5
- package/dist/memory/access.js +3 -1
- package/dist/nouns/share.js +73 -10
- package/dist/nouns/words.js +1 -0
- package/dist/registry/memory.js +5 -2
- package/dist/render/shares.js +28 -0
- package/package.json +1 -1
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,6 +3,7 @@ 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";
|
|
@@ -126,9 +127,22 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
126
127
|
}
|
|
127
128
|
if (steps.memory === 'always' || (steps.memory === 'at-tty' && io.stdin.isTTY)) {
|
|
128
129
|
const fetched = await io.api(accessToken, `${cfg.apiUrl}/memories/${encodeURIComponent(typed.positionals[0])}`);
|
|
129
|
-
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 {
|
|
130
139
|
return refusalOf(fetched, ambiguousText(fetched.body));
|
|
131
|
-
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (steps.noAudienceReport &&
|
|
143
|
+
typed.flags[steps.noAudienceReport.key] === undefined &&
|
|
144
|
+
context.gone) {
|
|
145
|
+
return refuse(steps.noAudienceReport.first);
|
|
132
146
|
}
|
|
133
147
|
if (steps.noAudienceReport && typed.flags[steps.noAudienceReport.key] === undefined) {
|
|
134
148
|
const title = sanitizeForTerminal(context.memory?.title ?? '(untitled)');
|
|
@@ -148,8 +162,10 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
148
162
|
: steps.confirm.question, {
|
|
149
163
|
...Object.fromEntries(typed.positionals.map((p, i) => [`p${i}`, sanitizeForTerminal(p)])),
|
|
150
164
|
name,
|
|
151
|
-
title:
|
|
152
|
-
|
|
165
|
+
title: context.gone
|
|
166
|
+
? NO_LONGER_SHARED
|
|
167
|
+
: sanitizeForTerminal(context.memory?.title ?? '(untitled)'),
|
|
168
|
+
'memory.id': context.memory?.id ?? sanitizeForTerminal(typed.positionals[0] ?? ''),
|
|
153
169
|
'contact.id': context.contact?.id ?? '',
|
|
154
170
|
email: sanitizeForTerminal(context.email ?? ''),
|
|
155
171
|
audience: context.contact?.displayName ?? describeAudience(selector ?? '')
|
|
@@ -244,7 +260,8 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
244
260
|
emit(io, result.data, result.rawText, (data) => form.render(data, typedView));
|
|
245
261
|
const next = form.page ? result.data[form.page.cursor] : undefined;
|
|
246
262
|
if (form.page && typeof next === 'string' && io.stdout.isTTY) {
|
|
247
|
-
|
|
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`);
|
|
248
265
|
}
|
|
249
266
|
};
|
|
250
267
|
//# sourceMappingURL=dispatch-form.js.map
|
package/dist/memory/access.js
CHANGED
|
@@ -20,7 +20,9 @@ export const GET_ACCESS_HELP = [
|
|
|
20
20
|
'',
|
|
21
21
|
'Answers open or shut, and the rows that decided it: the denies that reach',
|
|
22
22
|
'the contact when one does, the allows that reach them when open, or',
|
|
23
|
-
'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.'
|
|
24
26
|
].join('\n');
|
|
25
27
|
const ACCESS_FLAGS = { '--for': 'for' };
|
|
26
28
|
const isPhoneWord = (word) => word.startsWith('+');
|
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';
|
|
@@ -23,7 +24,8 @@ export const SHARE_HELP = [
|
|
|
23
24
|
'',
|
|
24
25
|
'A deny on the memory beats any allow: the answer names who is still shut',
|
|
25
26
|
'out, and `lattris remove deny` lifts it. Sharing with an audience that',
|
|
26
|
-
'already has access succeeds and changes nothing.',
|
|
27
|
+
'already has access succeeds and changes nothing. `lattris get shares`',
|
|
28
|
+
'lists every share and deny you have set.',
|
|
27
29
|
'',
|
|
28
30
|
'Alias: publish → share'
|
|
29
31
|
].join('\n');
|
|
@@ -41,7 +43,8 @@ export const DENY_HELP = [
|
|
|
41
43
|
'',
|
|
42
44
|
'A deny cannot hold while the memory is public or shared on the website',
|
|
43
45
|
'with the person it would shut out; the refusal names the share in the',
|
|
44
|
-
'way. `lattris remove deny` lifts a deny
|
|
46
|
+
'way. `lattris remove deny` lifts a deny, and `lattris get shares` lists',
|
|
47
|
+
'the ones you have set.'
|
|
45
48
|
].join('\n');
|
|
46
49
|
export const REMOVE_DENY_HELP = [
|
|
47
50
|
'remove deny — lift a deny from a memory, for one contact or for all your',
|
|
@@ -52,6 +55,10 @@ export const REMOVE_DENY_HELP = [
|
|
|
52
55
|
'Usage:',
|
|
53
56
|
' lattris remove deny [memory] <id-or-prefix> --to <all-contacts | contact> [--yes]',
|
|
54
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
|
+
'',
|
|
55
62
|
'Alias: undeny memory <id> → remove deny <id>'
|
|
56
63
|
].join('\n');
|
|
57
64
|
const isAccessGrant = (grant) => typeof grant === 'object' &&
|
|
@@ -184,6 +191,7 @@ const liftingForm = {
|
|
|
184
191
|
refusedWords: { public: PUBLIC_CANNOT_BE_DENIED }
|
|
185
192
|
},
|
|
186
193
|
memory: 'at-tty',
|
|
194
|
+
memoryMayBeGone: true,
|
|
187
195
|
confirm: {
|
|
188
196
|
question: 'Lift the deny on "{title}" ({memory.id}) for {audience}? [y/N] ',
|
|
189
197
|
onNo: { text: 'Cancelled.\n', to: 'stderr' },
|
|
@@ -198,7 +206,12 @@ const liftingForm = {
|
|
|
198
206
|
ambiguousRefusal: true,
|
|
199
207
|
refusalWords: otherEffectWords('deny'),
|
|
200
208
|
renderTo: 'stderr',
|
|
201
|
-
render: (_data, context) =>
|
|
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}`;
|
|
214
|
+
}
|
|
202
215
|
};
|
|
203
216
|
const removeDenyVerb = {
|
|
204
217
|
verb: 'remove',
|
|
@@ -222,7 +235,9 @@ export const UNSHARE_HELP = [
|
|
|
222
235
|
'',
|
|
223
236
|
'Bare (no --with): refuses and shows what the memory is currently shared',
|
|
224
237
|
'with, so you can see the state and the fix in one line. A deny is lifted',
|
|
225
|
-
'with `lattris remove deny`, not here.',
|
|
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.',
|
|
226
241
|
'',
|
|
227
242
|
'Alias: unpublish → unshare'
|
|
228
243
|
].join('\n');
|
|
@@ -237,6 +252,7 @@ const unshareVerb = {
|
|
|
237
252
|
steps: {
|
|
238
253
|
contact: { from: ['flag:with'], publicWord: 'public', reserved: [ALL_CONTACTS] },
|
|
239
254
|
memory: 'always',
|
|
255
|
+
memoryMayBeGone: true,
|
|
240
256
|
noAudienceReport: {
|
|
241
257
|
key: 'with',
|
|
242
258
|
first: AUDIENCE_WORDS,
|
|
@@ -257,11 +273,58 @@ const unshareVerb = {
|
|
|
257
273
|
ambiguousRefusal: true,
|
|
258
274
|
refusalWords: otherEffectWords('allow'),
|
|
259
275
|
renderTo: 'stderr',
|
|
260
|
-
render: (_data, context) =>
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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)
|
|
265
328
|
}
|
|
266
329
|
};
|
|
267
330
|
export const audiencesOf = (memory) => formatAudiences(memory.audiences);
|
|
@@ -269,6 +332,6 @@ export const grants = {
|
|
|
269
332
|
name: 'grants',
|
|
270
333
|
words: { singular: 'grant', plural: 'grants' },
|
|
271
334
|
help: SHARE_HELP,
|
|
272
|
-
verbs: [shareVerb, unshareVerb, denyVerb, removeDenyVerb, undenyVerb, consent]
|
|
335
|
+
verbs: [shareVerb, unshareVerb, denyVerb, removeDenyVerb, undenyVerb, getSharesVerb, consent]
|
|
273
336
|
};
|
|
274
337
|
//# sourceMappingURL=share.js.map
|
package/dist/nouns/words.js
CHANGED
|
@@ -38,6 +38,7 @@ export const USAGE_LINES = [
|
|
|
38
38
|
' lattris deny memory <id> Shut it to a contact or all contacts, whatever allows it (--to)',
|
|
39
39
|
' lattris remove deny <id> Lift a deny (--to all-contacts | <contact>)',
|
|
40
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)',
|
|
41
42
|
' lattris consent <id> Put a memory shared with you on your graph (--withdraw reverses)',
|
|
42
43
|
' lattris link <from> <to> State that one memory leads to another (--verb, --reason)',
|
|
43
44
|
' lattris unlink <from> <to> Remove that claim (--verb; the blocks stay)',
|
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: {
|
|
@@ -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
|