@milesroxas/design-hub 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,16 +7,20 @@
7
7
  import { base64url, hex, sha256 } from '../bytes.ts';
8
8
  import {
9
9
  type Access,
10
+ type Anchor,
11
+ type Audience,
10
12
  accessEnd,
11
13
  authorOf,
12
14
  type Checked,
13
15
  type Comment,
14
16
  checkAccess,
15
17
  checkAnchor,
18
+ checkAudience,
16
19
  checkBody,
17
20
  checkPersonInput,
18
21
  checkStates,
19
22
  checkTriage,
23
+ checkViewAs,
20
24
  DEFAULT_ACCESS,
21
25
  hasAccess,
22
26
  isProfile,
@@ -24,9 +28,10 @@ import {
24
28
  LINK_DAYS,
25
29
  type Link,
26
30
  type Person,
31
+ readComment,
27
32
  type Triage,
28
33
  } from './model.ts';
29
- import { type Action, can } from './policy.ts';
34
+ import { type Action, audienceFor, can, viewOf, visibleTo } from './policy.ts';
30
35
  import { KEY, type KV } from './store.ts';
31
36
 
32
37
  export type ErrorCode = 'unauthorized' | 'forbidden' | 'not_found' | 'invalid';
@@ -79,9 +84,14 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
79
84
  }
80
85
  };
81
86
 
82
- function allow(actor: Person | null, action: Action, subject?: Comment): asserts actor is Person {
87
+ function allow(
88
+ actor: Person | null,
89
+ action: Action,
90
+ root?: Comment,
91
+ subject?: Comment,
92
+ ): asserts actor is Person {
83
93
  if (!actor) throw new ReviewError('unauthorized', 'Sign in with your link to do that.');
84
- if (!can(actor, action, subject)) throw new ReviewError('forbidden', 'You cannot do that.');
94
+ if (!can(actor, action, root, subject)) throw new ReviewError('forbidden', 'You cannot do that.');
85
95
  }
86
96
 
87
97
  function valid<T>(checked: Checked<T>): T {
@@ -90,10 +100,10 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
90
100
  }
91
101
 
92
102
  // Every field checked before any throws, so one save names every problem.
93
- function validAll<A, B>(a: Checked<A>, b: Checked<B>): [A, B] {
94
- const problems = [...(a.ok ? [] : a.problems), ...(b.ok ? [] : b.problems)];
95
- if (!a.ok || !b.ok) throw new ReviewError('invalid', 'Some fields are not valid.', problems);
96
- return [a.value, b.value];
103
+ function validAll<T extends unknown[]>(...checks: { [K in keyof T]: Checked<T[K]> }): T {
104
+ const problems = checks.flatMap((c) => (c.ok ? [] : c.problems));
105
+ if (problems.length) throw new ReviewError('invalid', 'Some fields are not valid.', problems);
106
+ return checks.map((c) => (c as { value: unknown }).value) as T;
97
107
  }
98
108
 
99
109
  // A person is three records. The profile (KEY.people) is read-modify-write, so
@@ -176,24 +186,56 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
176
186
  return p;
177
187
  }
178
188
 
189
+ // Every comment read goes through readComment, so a record with no audience reads as internal.
190
+ // Unfiltered: nothing below hands these out without visibleTo or seen.
179
191
  const commentsOf = async (prototype: string) =>
180
192
  Object.values(await kv.hgetall(KEY.comments(prototype)))
181
- .map((json) => JSON.parse(json) as Comment)
193
+ .map(readComment)
182
194
  .sort((a, b) => a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id));
183
195
 
196
+ const commentAt = async (prototype: string, id: string): Promise<Comment | null> => {
197
+ const json = await kv.hget(KEY.comments(prototype), id);
198
+ return json === null ? null : readComment(json);
199
+ };
200
+
184
201
  const saveComment = (prototype: string, c: Comment) =>
185
202
  kv.hset(KEY.comments(prototype), c.id, JSON.stringify(c));
186
203
 
187
- async function needComment(prototype: string, id: string): Promise<Comment> {
188
- const c = parse<Comment>(await kv.hget(KEY.comments(prototype), id));
189
- if (!c) throw new ReviewError('not_found', 'No such comment.');
190
- return c;
204
+ /**
205
+ * A comment and its thread's root, if `actor` may see both; else null. A
206
+ * reply whose root is gone is not there either.
207
+ */
208
+ async function seen(
209
+ actor: Person,
210
+ prototype: string,
211
+ id: string,
212
+ ): Promise<{ comment: Comment; root: Comment } | null> {
213
+ const comment = await commentAt(prototype, id);
214
+ if (!comment) return null;
215
+ const root = isRoot(comment) ? comment : await commentAt(prototype, comment.thread);
216
+ return root && can(actor, 'read', root, comment) ? { comment, root } : null;
217
+ }
218
+
219
+ /**
220
+ * The comment an op names, and its root. One that `actor` may not see gets
221
+ * the same answer as one that does not exist, so an id never tells a Client
222
+ * an internal thread is there.
223
+ */
224
+ async function needThread(
225
+ actor: Person | null,
226
+ prototype: string,
227
+ id: string,
228
+ ): Promise<{ comment: Comment; root: Comment }> {
229
+ allow(actor, 'read');
230
+ const found = await seen(actor, prototype, id);
231
+ if (!found) throw new ReviewError('not_found', 'No such comment.');
232
+ return found;
191
233
  }
192
234
 
193
- async function needRoot(prototype: string, id: string): Promise<Comment> {
194
- const c = await needComment(prototype, id);
195
- if (!isRoot(c)) throw new ReviewError('invalid', 'That is a reply; act on its thread.');
196
- return c;
235
+ async function needRoot(actor: Person | null, prototype: string, id: string): Promise<Comment> {
236
+ const { comment } = await needThread(actor, prototype, id);
237
+ if (!isRoot(comment)) throw new ReviewError('invalid', 'That is a reply; act on its thread.');
238
+ return comment;
197
239
  }
198
240
 
199
241
  return {
@@ -315,23 +357,38 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
315
357
  return active(after) && after.epoch === p.epoch ? after : null;
316
358
  },
317
359
 
318
- async listComments(actor: Person | null, prototype: string): Promise<Comment[]> {
360
+ /**
361
+ * A prototype's comments as the actor's view sees them. `viewAs: 'client'`
362
+ * is Studio's Client view; it never widens a Client's.
363
+ */
364
+ async listComments(actor: Person | null, prototype: string, viewAs?: unknown): Promise<Comment[]> {
319
365
  allow(actor, 'read');
320
- return commentsOf(prototype);
366
+ const view = viewOf(actor, valid(checkViewAs(viewAs)));
367
+ return visibleTo(view, await commentsOf(prototype));
321
368
  },
322
369
 
323
- /** Every comment on every prototype, for the CLI, which holds the store's own credentials. */
324
- async allComments(): Promise<Comment[]> {
370
+ /** Every comment on every prototype the actor may see, for the CLI (which acts as Studio). */
371
+ async allComments(actor: Person | null): Promise<Comment[]> {
372
+ allow(actor, 'read');
325
373
  const prototypes = await kv.smembers(KEY.prototypes);
326
- return (await Promise.all(prototypes.map(commentsOf))).flat();
374
+ return visibleTo(viewOf(actor), (await Promise.all(prototypes.map(commentsOf))).flat());
327
375
  },
328
376
 
377
+ /**
378
+ * A new thread. A Client's is client-facing whatever the input says;
379
+ * Studio's is internal unless `audience` is 'client'. Its number is the
380
+ * prototype's next, never one used before.
381
+ */
329
382
  async add(
330
383
  actor: Person | null,
331
- input: { body?: unknown; anchor?: unknown; states?: unknown },
384
+ input: { body?: unknown; anchor?: unknown; states?: unknown; audience?: unknown },
332
385
  ): Promise<Comment> {
333
386
  allow(actor, 'comment');
334
- const [body, anchor] = validAll(checkBody(input.body), checkAnchor(input.anchor));
387
+ const [body, anchor, asked] = validAll<[string, Anchor, Audience | null]>(
388
+ checkBody(input.body),
389
+ checkAnchor(input.anchor),
390
+ checkAudience(input.audience),
391
+ );
335
392
  const id = newId();
336
393
  const triage = deps.triage
337
394
  ? await deps
@@ -350,6 +407,9 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
350
407
  status: 'open',
351
408
  resolvedBy: null,
352
409
  triage,
410
+ audience: audienceFor(actor, asked),
411
+ // Atomic and only raised: two threads at once get two numbers, and a failed save skips one.
412
+ number: await kv.hincrby(KEY.counters, anchor.prototype, 1),
353
413
  };
354
414
  await kv.sadd(KEY.prototypes, anchor.prototype);
355
415
  await saveComment(anchor.prototype, c);
@@ -360,8 +420,8 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
360
420
  actor: Person | null,
361
421
  input: { prototype: string; thread: string; body?: unknown },
362
422
  ): Promise<Comment> {
363
- allow(actor, 'comment');
364
- const root = await needRoot(input.prototype, input.thread);
423
+ const root = await needRoot(actor, input.prototype, input.thread);
424
+ allow(actor, 'comment', root);
365
425
  const id = newId();
366
426
  const c: Comment = {
367
427
  id,
@@ -374,6 +434,9 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
374
434
  status: 'open',
375
435
  resolvedBy: null,
376
436
  triage: null,
437
+ // A reply follows its thread; nobody sets it.
438
+ audience: root.audience,
439
+ number: root.number,
377
440
  };
378
441
  await saveComment(input.prototype, c);
379
442
  return c;
@@ -383,8 +446,8 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
383
446
  actor: Person | null,
384
447
  input: { prototype: string; id: string; body?: unknown },
385
448
  ): Promise<Comment> {
386
- const c = await needComment(input.prototype, input.id);
387
- allow(actor, 'edit', c);
449
+ const { comment: c, root } = await needThread(actor, input.prototype, input.id);
450
+ allow(actor, 'edit', root, c);
388
451
  const next = { ...c, body: valid(checkBody(input.body)), editedAt: now() };
389
452
  await saveComment(input.prototype, next);
390
453
  return next;
@@ -392,20 +455,20 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
392
455
 
393
456
  /** Deletes a comment; deleting a thread's root deletes its replies with it. */
394
457
  async remove(actor: Person | null, input: { prototype: string; id: string }): Promise<string[]> {
395
- const c = await needComment(input.prototype, input.id);
396
- allow(actor, 'delete', c);
397
- const gone = isRoot(c)
398
- ? (await commentsOf(input.prototype)).filter((x) => x.thread === c.id).map((x) => x.id)
399
- : [c.id];
400
- for (const id of gone) await kv.hdel(KEY.comments(input.prototype), id);
401
- return gone;
458
+ const { comment: c, root } = await needThread(actor, input.prototype, input.id);
459
+ allow(actor, 'delete', root, c);
460
+ const gone = isRoot(c) ? (await commentsOf(input.prototype)).filter((x) => x.thread === c.id) : [c];
461
+ for (const x of gone) await kv.hdel(KEY.comments(input.prototype), x.id);
462
+ // The answer names only what the actor may see, judged with the thread's root beside it.
463
+ const shown = new Set(visibleTo(viewOf(actor), [root, ...gone]).map((x) => x.id));
464
+ return gone.filter((x) => shown.has(x.id)).map((x) => x.id);
402
465
  },
403
466
 
404
467
  async resolve(
405
468
  actor: Person | null,
406
469
  input: { prototype: string; id: string; resolved: boolean },
407
470
  ): Promise<Comment> {
408
- const c = await needRoot(input.prototype, input.id);
471
+ const c = await needRoot(actor, input.prototype, input.id);
409
472
  allow(actor, 'resolve', c);
410
473
  const next: Comment = input.resolved
411
474
  ? { ...c, status: 'resolved', resolvedBy: authorOf(actor) }
@@ -419,7 +482,7 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
419
482
  input: { prototype: string; id: string; triage?: unknown; states?: unknown },
420
483
  ): Promise<Comment> {
421
484
  allow(actor, 'triage');
422
- const c = await needRoot(input.prototype, input.id);
485
+ const c = await needRoot(actor, input.prototype, input.id);
423
486
  const states = checkStates(input.states);
424
487
  const { kind, state } = valid(checkTriage(input.triage, states.length ? states : null));
425
488
  const next: Comment = { ...c, triage: { kind, state, by: 'person', confidence: null } };
@@ -427,11 +490,12 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
427
490
  return next;
428
491
  },
429
492
 
430
- /** Where a comment lives, for the CLI, which has an id and no prototype. */
431
- async locate(id: string): Promise<{ prototype: string; comment: Comment } | null> {
493
+ /** Where a comment lives, for the CLI, which has an id and no prototype; null when the actor may not see it. */
494
+ async locate(actor: Person | null, id: string): Promise<{ prototype: string; comment: Comment } | null> {
495
+ allow(actor, 'read');
432
496
  for (const prototype of await kv.smembers(KEY.prototypes)) {
433
- const c = parse<Comment>(await kv.hget(KEY.comments(prototype), id));
434
- if (c) return { prototype, comment: c };
497
+ const found = await seen(actor, prototype, id);
498
+ if (found) return { prototype, comment: found.comment };
435
499
  }
436
500
  return null;
437
501
  },
@@ -34,6 +34,8 @@ export const KEY = {
34
34
  /** Project settings, one field each: `access` is the default access length. */
35
35
  settings: `${PREFIX}settings`,
36
36
  prototypes: `${PREFIX}prototypes`,
37
+ /** The last thread number given on each prototype, one field per prototype, only ever raised by HINCRBY. */
38
+ counters: `${PREFIX}counters`,
37
39
  comments: (prototype: string) => `${PREFIX}comments:${prototype}`,
38
40
  } as const;
39
41
 
@@ -1,6 +1,12 @@
1
1
  /** Which side a person is on: the studio that makes the work, or the client it is for. */
2
2
  export declare const PERSON_KINDS: readonly ['studio', 'client'];
3
3
  export type PersonKind = (typeof PERSON_KINDS)[number];
4
+ /**
5
+ * Who a thread is for. Internal stays inside the studio; client-facing is
6
+ * read by everyone. Fixed when the thread is made: no op changes it.
7
+ */
8
+ declare const AUDIENCES: readonly ['internal', 'client'];
9
+ export type Audience = (typeof AUDIENCES)[number];
4
10
  /** How a comment is triaged: something broken, a design opinion, or the words. */
5
11
  export declare const KINDS: readonly ['bug', 'taste', 'copy'];
6
12
  export type Kind = (typeof KINDS)[number];
@@ -87,7 +93,20 @@ export type Comment = {
87
93
  status: 'open' | 'resolved';
88
94
  resolvedBy: Author | null;
89
95
  triage: Triage | null;
96
+ /** The thread's audience. Set on the root when it is made and copied onto every reply; never changed. */
97
+ audience: Audience;
98
+ /**
99
+ * The thread's number on its prototype, from 1, copied onto every reply. Never reused, so a
100
+ * deleted or hidden thread moves no other number. 0 for a thread stored before numbers existed.
101
+ */
102
+ number: number;
90
103
  };
104
+ /**
105
+ * A stored comment as the rules read it. A record with no audience, or one
106
+ * that is not a known value, is internal: a missing field never shows a
107
+ * Client anything. A missing or broken number reads as 0, no number.
108
+ */
109
+ export declare function readComment(json: string): Comment;
91
110
  /** Whether a stored profile (a person without revocation and epoch) is well formed. */
92
111
  export declare function isProfile(v: unknown): v is Omit<Person, 'revokedAt' | 'epoch'>;
93
112
  /**
@@ -110,8 +129,13 @@ export type PersonInput = Pick<Person, 'name' | 'team' | 'kind'> & {
110
129
  access: Access | null;
111
130
  };
112
131
  export declare function checkPersonInput(input: unknown): Checked<PersonInput>;
132
+ /** A new thread's audience as asked: one of AUDIENCES, or null when none is given. */
133
+ export declare function checkAudience(input: unknown): Checked<Audience | null>;
134
+ /** Whose view of the comments is asked for: a person kind, or null for the caller's own. */
135
+ export declare function checkViewAs(input: unknown): Checked<PersonKind | null>;
113
136
  export declare function checkBody(body: unknown): Checked<string>;
114
137
  export declare function checkAnchor(input: unknown): Checked<Anchor>;
115
138
  /** The README states a client offers for triage: trimmed, capped, de-duplicated. */
116
139
  export declare function checkStates(input: unknown): string[];
117
140
  export declare function checkTriage(input: unknown, states: string[] | null): Checked<Pick<Triage, 'kind' | 'state'>>;
141
+ export {};
@@ -6,6 +6,11 @@
6
6
  import { SLUG } from '../feature.js';
7
7
  /** Which side a person is on: the studio that makes the work, or the client it is for. */
8
8
  export const PERSON_KINDS = ['studio', 'client'];
9
+ /**
10
+ * Who a thread is for. Internal stays inside the studio; client-facing is
11
+ * read by everyone. Fixed when the thread is made: no op changes it.
12
+ */
13
+ const AUDIENCES = ['internal', 'client'];
9
14
  /** How a comment is triaged: something broken, a design opinion, or the words. */
10
15
  export const KINDS = ['bug', 'taste', 'copy'];
11
16
  /** How long an unused sign-in link lasts. A link signs in one device, then stops working. */
@@ -41,6 +46,17 @@ export const LIMITS = {
41
46
  states: 50,
42
47
  stateName: 120,
43
48
  };
49
+ /**
50
+ * A stored comment as the rules read it. A record with no audience, or one
51
+ * that is not a known value, is internal: a missing field never shows a
52
+ * Client anything. A missing or broken number reads as 0, no number.
53
+ */
54
+ export function readComment(json) {
55
+ const c = JSON.parse(json);
56
+ const audience = c.audience === 'client' ? 'client' : 'internal';
57
+ const number = Number.isInteger(c.number) && c.number > 0 ? c.number : 0;
58
+ return { ...c, audience, number };
59
+ }
44
60
  const isText = (v) => typeof v === 'string';
45
61
  const isTextOrNull = (v) => v === null || typeof v === 'string';
46
62
  /** What a stored profile must hold to be a person; anything else is no person at all. */
@@ -109,6 +125,22 @@ export function checkPersonInput(input) {
109
125
  ? { ok: false, problems }
110
126
  : { ok: true, value: { name, team, kind: kind, access: access } };
111
127
  }
128
+ /** A new thread's audience as asked: one of AUDIENCES, or null when none is given. */
129
+ export function checkAudience(input) {
130
+ if (input === undefined || input === null)
131
+ return { ok: true, value: null };
132
+ return AUDIENCES.includes(input)
133
+ ? { ok: true, value: input }
134
+ : { ok: false, problems: [`audience: one of ${AUDIENCES.join(', ')}`] };
135
+ }
136
+ /** Whose view of the comments is asked for: a person kind, or null for the caller's own. */
137
+ export function checkViewAs(input) {
138
+ if (input === undefined || input === null)
139
+ return { ok: true, value: null };
140
+ return PERSON_KINDS.includes(input)
141
+ ? { ok: true, value: input }
142
+ : { ok: false, problems: [`viewAs: one of ${PERSON_KINDS.join(', ')}`] };
143
+ }
112
144
  export function checkBody(body) {
113
145
  const problems = [];
114
146
  const value = text(body, 'body', LIMITS.body, problems);
@@ -1,6 +1,25 @@
1
- import type { Comment, Person } from './model.ts';
1
+ import type { Audience, Comment, Person, PersonKind } from './model.ts';
2
2
  export type Action = 'read' | 'comment' | 'edit' | 'delete' | 'resolve' | 'triage' | 'people';
3
3
  /** Only what the rules read, so the browser's signed-in person (no epoch) is checked by the same rules. */
4
4
  type Actor = Pick<Person, 'id' | 'kind' | 'revokedAt'>;
5
- export declare function can(actor: Actor | null, action: Action, subject?: Comment): boolean;
5
+ /**
6
+ * `root` is the thread acted on, `subject` the comment in it when that is a
7
+ * reply (edit or delete one); without `subject`, the root is the subject.
8
+ * Without a root, the action is on no thread: listing, or a new thread.
9
+ */
10
+ export declare function can(actor: Actor | null, action: Action, root?: Comment, subject?: Comment): boolean;
11
+ /**
12
+ * The view a person gets: their own kind, or a narrower one they ask for.
13
+ * Studio may look as a Client does (Client view); a Client asking for
14
+ * Studio's still gets a Client's, so the view is never wider than the person.
15
+ */
16
+ export declare function viewOf(actor: Pick<Person, 'kind'> | null, viewAs?: PersonKind | null): PersonKind;
17
+ /**
18
+ * The comments a view may see. Studio sees all. A Client sees a client-facing
19
+ * thread and its client-facing replies; a reply whose thread is not among
20
+ * them is not seen either.
21
+ */
22
+ export declare function visibleTo(viewAs: PersonKind, comments: Comment[]): Comment[];
23
+ /** A new thread's audience: a Client's is always client-facing; Studio's is internal unless Studio asks otherwise. */
24
+ export declare function audienceFor(actor: Pick<Person, 'kind'>, asked: Audience | null): Audience;
6
25
  export {};
@@ -1,8 +1,17 @@
1
- export function can(actor, action, subject) {
1
+ /** Whether a comment reaches a Client. Only the exact value counts, so a record without one stays inside. */
2
+ const clientFacing = (c) => c.audience === 'client';
3
+ /**
4
+ * `root` is the thread acted on, `subject` the comment in it when that is a
5
+ * reply (edit or delete one); without `subject`, the root is the subject.
6
+ * Without a root, the action is on no thread: listing, or a new thread.
7
+ */
8
+ export function can(actor, action, root, subject) {
2
9
  if (!actor || actor.revokedAt)
3
10
  return false;
4
11
  const studio = actor.kind === 'studio';
5
- const own = subject?.author.id === actor.id;
12
+ if (!studio && [root, subject].some((c) => c && !clientFacing(c)))
13
+ return false;
14
+ const own = (subject ?? root)?.author.id === actor.id;
6
15
  switch (action) {
7
16
  case 'read':
8
17
  case 'comment':
@@ -17,3 +26,26 @@ export function can(actor, action, subject) {
17
26
  return studio;
18
27
  }
19
28
  }
29
+ /**
30
+ * The view a person gets: their own kind, or a narrower one they ask for.
31
+ * Studio may look as a Client does (Client view); a Client asking for
32
+ * Studio's still gets a Client's, so the view is never wider than the person.
33
+ */
34
+ export function viewOf(actor, viewAs) {
35
+ return actor?.kind === 'studio' && viewAs !== 'client' ? 'studio' : 'client';
36
+ }
37
+ /**
38
+ * The comments a view may see. Studio sees all. A Client sees a client-facing
39
+ * thread and its client-facing replies; a reply whose thread is not among
40
+ * them is not seen either.
41
+ */
42
+ export function visibleTo(viewAs, comments) {
43
+ if (viewAs === 'studio')
44
+ return comments;
45
+ const roots = new Set(comments.filter((c) => c.thread === c.id && clientFacing(c)).map((c) => c.id));
46
+ return comments.filter((c) => clientFacing(c) && roots.has(c.thread));
47
+ }
48
+ /** A new thread's audience: a Client's is always client-facing; Studio's is internal unless Studio asks otherwise. */
49
+ export function audienceFor(actor, asked) {
50
+ return actor.kind === 'studio' ? (asked ?? 'internal') : 'client';
51
+ }
@@ -54,13 +54,23 @@ export declare function createReview(kv: KV, overrides?: Partial<Deps>): {
54
54
  * read and checked first, so the delete is the last store call.
55
55
  */
56
56
  useLink(token: string): Promise<Person | null>;
57
- listComments(actor: Person | null, prototype: string): Promise<Comment[]>;
58
- /** Every comment on every prototype, for the CLI, which holds the store's own credentials. */
59
- allComments(): Promise<Comment[]>;
57
+ /**
58
+ * A prototype's comments as the actor's view sees them. `viewAs: 'client'`
59
+ * is Studio's Client view; it never widens a Client's.
60
+ */
61
+ listComments(actor: Person | null, prototype: string, viewAs?: unknown): Promise<Comment[]>;
62
+ /** Every comment on every prototype the actor may see, for the CLI (which acts as Studio). */
63
+ allComments(actor: Person | null): Promise<Comment[]>;
64
+ /**
65
+ * A new thread. A Client's is client-facing whatever the input says;
66
+ * Studio's is internal unless `audience` is 'client'. Its number is the
67
+ * prototype's next, never one used before.
68
+ */
60
69
  add(actor: Person | null, input: {
61
70
  body?: unknown;
62
71
  anchor?: unknown;
63
72
  states?: unknown;
73
+ audience?: unknown;
64
74
  }): Promise<Comment>;
65
75
  reply(actor: Person | null, input: {
66
76
  prototype: string;
@@ -88,8 +98,8 @@ export declare function createReview(kv: KV, overrides?: Partial<Deps>): {
88
98
  triage?: unknown;
89
99
  states?: unknown;
90
100
  }): Promise<Comment>;
91
- /** Where a comment lives, for the CLI, which has an id and no prototype. */
92
- locate(id: string): Promise<{
101
+ /** Where a comment lives, for the CLI, which has an id and no prototype; null when the actor may not see it. */
102
+ locate(actor: Person | null, id: string): Promise<{
93
103
  prototype: string;
94
104
  comment: Comment;
95
105
  } | null>;