@soffits/dsh-card-board 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.0
4
+
5
+ A board can say who may act on it: `actors` in `board.json` lists the viewers who may press its buttons, and without it every viewer may, so existing boards behave as before. Someone who may see a board but isn't an actor gets it with its `done`, `snooze`, `step` and `event` buttons left out (chat and link stay, and a chat button never names someone else's session), a "View only" note beside the title (English, French and Chinese) and a 403 on any press or undo. All decided on the server. Why: `docs/decisions/board-actors.md`.
6
+
7
+ ## 0.15.1
8
+
9
+ A labelled `done` on a row is a choice, not a tick: it stays a button of its own, so a row can offer several answers (an ask's options). Only an unlabelled done becomes the row's checkbox; before, the first done of any kind did and the others vanished.
10
+
3
11
  ## 0.15.0
4
12
 
5
13
  A shared board can keep a card for only some of its viewers: `cardViewers` in `board.json` maps a card id to the people who may see it. Everyone else gets the board without it; its route answers 404, the events stream leaves it out and its buttons refuse a press, all decided on the server.
package/README.md CHANGED
@@ -48,6 +48,8 @@ With no `people` and no `peopleFile`, the plugin assumes a single-person DSH: ev
48
48
 
49
49
  With a mapping, each request is checked on the server. The plugin asks the `requestIdentity` service who made the request, maps that user id to a person id, and serves only boards whose `viewers` list that person. A request without a verified identity sees no boards; a board the person may not see answers 403, the same as one that doesn't exist. The tabs in the page come only from the server's list. Person ids compare without regard to case.
50
50
 
51
+ Seeing and acting are separate. A board can name `actors`, the people who may press its buttons; without it, the viewers may, so a board that never heard of `actors` behaves as it always did. Someone who may see a board but isn't an actor gets it with its `done`, `snooze`, `step` and `event` buttons left out and a "View only" note beside the title, and their presses answer 403. Chat and link buttons stay (a chat button opens a draft in the viewer's own conversation, never in a session the card names). Acting needs seeing: naming someone in `actors` who isn't in `viewers` gives them nothing. Reading, marking cards seen and arranging the board for yourself stay open to every viewer, since they only touch the viewer's own view. This is how a person lets someone they trust look at their board without that person's taps landing on their items: `"viewers": ["alex", "sam"], "actors": ["alex"]`. Why it is shaped this way: [docs/decisions/board-actors.md](docs/decisions/board-actors.md).
52
+
51
53
  `requestIdentity` is a small service any sign-in plugin can provide. [dsh-oidc](https://github.com/soffits/dsh-oidc) (0.3.0-alpha.9 or later) does; another plugin can provide the same interface:
52
54
 
53
55
  ```ts
@@ -78,6 +80,7 @@ Board and card ids are lowercase letters, digits, `-` and `_`, up to 64 characte
78
80
  {
79
81
  "title": "Home",
80
82
  "viewers": ["alex", "sam"],
83
+ "actors": ["alex"],
81
84
  "cardViewers": { "alex-todo": ["alex"] },
82
85
  "order": ["weather", "savings", "energy"],
83
86
  "layout": { "weather": { "size": "small" }, "energy": { "size": "wide" } },
@@ -85,7 +88,7 @@ Board and card ids are lowercase letters, digits, `-` and `_`, up to 64 characte
85
88
  }
86
89
  ```
87
90
 
88
- `cardViewers` is optional: a card listed there shows only to the people it names ([Who sees what](#who-sees-what)). `order` lists cards to put first; the rest follow by id. This is the default: each person can [arrange their own view](#order-pins-and-raised-cards). `layout` sets how wide a card is: `small` (a third of a wide screen), `medium` (a half), `large` (two thirds) or `wide` (all of it). Without it a card takes its type's default: `summary` and `timeline` are wide, `countdown` large, `stat` small, the rest medium; a summary is always wide. On a tablet small and medium cards take half the width and large and wide ones all of it; on a phone every card is full width. Heights are the cards' own: the board packs them like masonry, so a long card never stretches its neighbours and short ones fill the space beside it. A list longer than six rows shows six, then "N more", which opens the rest in place (a row that is new or just changed always shows). `assistant` is optional: the name the chat buttons ask ("Ask Robin" instead of "Ask"). `title` can be [text in several languages](#languages).
91
+ `actors` is optional: the viewers who may also press the board's buttons, all of them when it is left out (`[]` makes a board nobody can press). `cardViewers` is optional: a card listed there shows only to the people it names ([Who sees what](#who-sees-what)). `order` lists cards to put first; the rest follow by id. This is the default: each person can [arrange their own view](#order-pins-and-raised-cards). `layout` sets how wide a card is: `small` (a third of a wide screen), `medium` (a half), `large` (two thirds) or `wide` (all of it). Without it a card takes its type's default: `summary` and `timeline` are wide, `countdown` large, `stat` small, the rest medium; a summary is always wide. On a tablet small and medium cards take half the width and large and wide ones all of it; on a phone every card is full width. Heights are the cards' own: the board packs them like masonry, so a long card never stretches its neighbours and short ones fill the space beside it. A list longer than six rows shows six, then "N more", which opens the rest in place (a row that is new or just changed always shows). `assistant` is optional: the name the chat buttons ask ("Ask Robin" instead of "Ask"). `title` can be [text in several languages](#languages).
89
92
 
90
93
  A card:
91
94
 
@@ -226,7 +229,7 @@ Each bar has a single `value` or named `values`; with `values` and no `stacked`,
226
229
  }
227
230
  ```
228
231
 
229
- A row with a `done` action shows a checkbox, and ticking it presses that action (the row's separate done button then goes); `checked: true` shows it ticked. A row without a `done` action shows no checkbox. `progress` draws a ring above the rows, with its `label` and an optional `sub`.
232
+ A row with a `done` action shows a checkbox, and ticking it presses that action (the row's separate done button then goes); `checked: true` shows it ticked. A row without a `done` action shows no checkbox. A `done` with a `label` is a choice rather than a tick (one answer of a question, say "White" or "Oak"): it stays a button of its own, so a row can offer several. `progress` draws a ring above the rows, with its `label` and an optional `sub`.
230
233
 
231
234
  Rows (of lists and status cards) may also have an `icon` and a `tone` (a tile before the row), a `key` (a stable id, so the page can tell which row changed) and `active: { from, to }`: during that window the row is highlighted and says "now", earlier the same day it says "from 18:00". The page decides when, so nobody has to rewrite the file at noon. A row's `date` shows relative to today ("tomorrow", "in 3 days") and moves on by itself. A row may have a `link` (an `http(s)` URL, opened in a new tab, or a `/path` of this app, opened in place): tapping the row goes there. A keyed row may have a `detail` (below): tapping it opens it. Stat items take a `link` too.
232
235
 
package/client.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @soffits/dsh-card-board 0.15.0: built by scripts/build.mjs from src/client/. Do not edit. */
1
+ /* @soffits/dsh-card-board 0.16.0: built by scripts/build.mjs from src/client/. Do not edit. */
2
2
  window.__ModuleLoader__.load({
3
3
  id: "@soffits/dsh-card-board",
4
4
  factory: (require) => {
@@ -262,6 +262,7 @@ button.cb-cardMore{border:0;background:transparent;padding:0;font:inherit;cursor
262
262
  .cb-card[data-axis=y][data-drop=after]::after{bottom:-9px;left:6px;right:6px;height:3px}
263
263
  .cb-heading .cb-sub{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px}
264
264
  .cb-reset{margin:-4px 0}
265
+ .cb-readOnly{padding:0 8px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;color:var(--dsw-alias-label-secondary);font-size:12px}
265
266
  .cb-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
266
267
  /* The point under the pointer on a chart */
267
268
  .cb-chart{position:relative}
@@ -967,7 +968,7 @@ function dropAfter(rect, x, y, single) {
967
968
  }
968
969
 
969
970
  // src/client/ticks.js
970
- var doneOf = (row) => row?.actions?.find((action) => action.kind === "done");
971
+ var doneOf = (row) => row?.actions?.find((action) => action.kind === "done" && action.label === void 0);
971
972
  function keepOf(row, index) {
972
973
  const done = doneOf(row);
973
974
  return done === void 0 ? void 0 : { id: done.id, index, row: { ...row, checked: true, actions: [done] } };
@@ -1157,7 +1158,7 @@ function ListCard({ data, live, locale, t, rowActions, ask, all = false, onOpenR
1157
1158
  listed.length === 0 ? (0, import_react6.createElement)("p", { className: "cb-muted" }, data.empty ?? t("listEmpty")) : (0, import_react6.createElement)("ul", { className: "cb-rows" }, rows.map((row, i) => (0, import_react6.createElement)(Row, {
1158
1159
  key: row.key ?? i,
1159
1160
  index: data.rows.indexOf(row),
1160
- row: doneOf(row) && rowControls ? { ...row, actions: row.actions.filter((a) => a.kind !== "done") } : row,
1161
+ row: doneOf(row) && rowControls ? { ...row, actions: row.actions.filter((a) => a !== doneOf(row)) } : row,
1161
1162
  rowActions: data.rows.includes(row) ? rowActions : void 0,
1162
1163
  ask,
1163
1164
  onOpenRow,
@@ -2158,6 +2159,7 @@ function BoardsPage() {
2158
2159
  "div",
2159
2160
  { className: "cb-sub" },
2160
2161
  (0, import_react15.createElement)(kit.LiveStatus, { status, updatedAt: newest || void 0 }),
2162
+ board.readOnly && (0, import_react15.createElement)("span", { className: "cb-readOnly", title: t("readOnly.hint") }, t("readOnly")),
2161
2163
  board.arrangement && (0, import_react15.createElement)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", className: "cb-reset", title: t("arrange.resetHint"), onClick: () => {
2162
2164
  keepArrangement(null, board.id);
2163
2165
  setSaid(t("arrange.resetDone"));
package/locale/en.json CHANGED
@@ -53,6 +53,8 @@
53
53
  "arrange.unpin": "Unpin",
54
54
  "arrange.up": "Move up",
55
55
  "arrange.down": "Move down",
56
+ "readOnly": "View only",
57
+ "readOnly.hint": "You can see this board, but only the people it belongs to can press its buttons",
56
58
  "arrange.reset": "Reset order",
57
59
  "arrange.resetHint": "Back to the order this board comes with",
58
60
  "arrange.raised": "Up for now",
package/locale/fr.json CHANGED
@@ -53,6 +53,8 @@
53
53
  "arrange.unpin": "Désépingler",
54
54
  "arrange.up": "Monter",
55
55
  "arrange.down": "Descendre",
56
+ "readOnly": "Lecture seule",
57
+ "readOnly.hint": "Vous pouvez voir ce tableau, mais seules les personnes à qui il appartient peuvent en actionner les boutons",
56
58
  "arrange.reset": "Rétablir l’ordre",
57
59
  "arrange.resetHint": "Revenir à l’ordre d’origine de ce tableau",
58
60
  "arrange.raised": "En haut pour l’instant",
package/locale/zh.json CHANGED
@@ -53,6 +53,8 @@
53
53
  "arrange.unpin": "取消置顶",
54
54
  "arrange.up": "上移",
55
55
  "arrange.down": "下移",
56
+ "readOnly": "仅查看",
57
+ "readOnly.hint": "你可以看这个看板,但只有它的主人能按上面的按钮",
56
58
  "arrange.reset": "恢复默认顺序",
57
59
  "arrange.resetHint": "回到这个看板自带的顺序",
58
60
  "arrange.raised": "暂时靠前",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-card-board",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "A data-driven card board for DeepSeek Harness: scripts write small JSON cards, the Web UI shows each person the boards they may see.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/access.js CHANGED
@@ -5,7 +5,9 @@
5
5
  * plugin that verifies the person behind an `/api` request can provide it
6
6
  * (`current()` returns `{ id, ... }` or null). The verified user id maps to a
7
7
  * person id through the configured mapping, and a board lists the person ids
8
- * that may see it in `viewers`.
8
+ * that may see it in `viewers`. A board can also say who may act on it (press its done, snooze, step and event
9
+ * buttons) in `actors`; without `actors` the viewers may, so a board that never heard of the field behaves as before.
10
+ * Acting needs seeing: a name in `actors` that isn't in `viewers` gets nothing extra.
9
11
  *
10
12
  * Two modes:
11
13
  * - people: a mapping is configured. A request needs a verified identity that
@@ -15,6 +17,7 @@
15
17
  * which is what a single-person DSH wants.
16
18
  */
17
19
  import { readFile, stat } from 'node:fs/promises'
20
+ import { PRESS_KINDS } from './schema.js'
18
21
 
19
22
  /** Person ids compare without regard to case or surrounding space. */
20
23
  export function personKey(value) {
@@ -101,3 +104,32 @@ export function maySee(viewer, board) {
101
104
  if (viewer.person === undefined || board === undefined) return false
102
105
  return (board.viewers ?? []).some(person => personKey(person) === viewer.person)
103
106
  }
107
+
108
+ /** Whether a viewer who may see `board` may also act on it: be named in `actors`, or in `viewers` when there are no `actors`. */
109
+ export function mayAct(viewer, board) {
110
+ if (viewer.mode === 'owner') return true
111
+ if (!maySee(viewer, board)) return false
112
+ return (board.actors ?? board.viewers ?? []).some(person => personKey(person) === viewer.person)
113
+ }
114
+
115
+ /**
116
+ * A card as someone who may see but not act gets it: the buttons that press something on the server (done, snooze,
117
+ * step, event) are left out, so nothing on it can change another person's item. Chat and link buttons stay; a chat
118
+ * button names no session, so its draft opens in the viewer's own conversation and never in one the card's owner has.
119
+ */
120
+ export function withoutPresses(card) {
121
+ const own = action => {
122
+ if (action.kind !== 'chat' || action.payload?.session === undefined) return action
123
+ const { session: _theirs, ...payload } = action.payload
124
+ return { ...action, payload }
125
+ }
126
+ /** `holder` without its `actions` key, then with the ones that stay if any. */
127
+ const trimmed = holder => {
128
+ const { actions, ...rest } = holder
129
+ const kept = (actions ?? []).filter(action => !PRESS_KINDS.includes(action.kind)).map(own)
130
+ return kept.length > 0 ? { ...rest, actions: kept } : rest
131
+ }
132
+ const rows = card.data?.rows
133
+ const result = trimmed(card)
134
+ return Array.isArray(rows) ? { ...result, data: { ...card.data, rows: rows.map(trimmed) } } : result
135
+ }
package/src/routes.js CHANGED
@@ -17,7 +17,7 @@
17
17
  * in it is new since the viewer last looked, `fresh: { card: true, rows: [keys] }`.
18
18
  */
19
19
  import { join } from 'node:path'
20
- import { maySee, maySeeCard, viewerOf } from './access.js'
20
+ import { mayAct, maySee, maySeeCard, viewerOf, withoutPresses } from './access.js'
21
21
  import { parseArrangement } from './arrange.js'
22
22
  import { LANGUAGE_ID } from './messages.js'
23
23
  import { ID_PATTERN, PRESS_KINDS, findAction } from './schema.js'
@@ -72,11 +72,12 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
72
72
  // In people mode a missing board and a forbidden one answer the same, so ids don't leak.
73
73
  if (viewer.mode === 'people' && !maySee(viewer, entry?.board)) return { refused: json(403, { error: 'You can’t see this board.' }) }
74
74
  if (entry === undefined) return { refused: json(404, { error: 'No such board.' }) }
75
- return { viewer, root, entry, person: viewer.mode === 'owner' ? 'owner' : viewer.person }
75
+ return { viewer, root, entry, person: viewer.mode === 'owner' ? 'owner' : viewer.person, canAct: mayAct(viewer, entry.board) }
76
76
  }
77
77
 
78
78
  /** A card entry with its versions, its press states and what is new in it for this viewer. */
79
- function decorate(card, states, seenBoard) {
79
+ function decorate(card, states, seenBoard, canAct) {
80
+ if (!canAct && card.card !== undefined) card = { ...card, card: withoutPresses(card.card) }
80
81
  let entry = states[card.id] ? { ...card, presses: states[card.id] } : card
81
82
  if (card.card === undefined) return entry
82
83
  const versions = cardVersions(card.card)
@@ -108,16 +109,16 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
108
109
  if (!ID_PATTERN.test(id)) return json(400, { error: 'Not a board id.' })
109
110
  const found = await access(id)
110
111
  if (found.refused) return found.refused
111
- const { viewer, root, entry, person } = found
112
- const states = await pressStates(root, id)
113
- const tag = await boardTag(root, id, `${version}\0${viewer.mode}\0${person ?? ''}\0${await seen.tag(person)}\0${await arrange.tag(person)}\0${JSON.stringify(states)}`)
112
+ const { viewer, root, entry, person, canAct } = found
113
+ const states = canAct ? await pressStates(root, id) : {}
114
+ const tag = await boardTag(root, id, `${version}\0${viewer.mode}\0${person ?? ''}\0${canAct}\0${await seen.tag(person)}\0${await arrange.tag(person)}\0${JSON.stringify(states)}`)
114
115
  if (request.headers.get('if-none-match') === tag) return new Response(null, { status: 304, headers: { ...HEADERS, etag: tag } })
115
116
  const seenBoard = await seen.board(person, id)
116
117
  const cards = (await readCards(root, id, entry.board))
117
118
  .filter(card => maySeeCard(viewer, entry.board, card.id))
118
- .map(card => decorate(card, states, seenBoard))
119
+ .map(card => decorate(card, states, seenBoard, canAct))
119
120
  const arrangement = await arrange.get(person, id)
120
- return json(200, { id, title: entry.board?.title ?? id, ...(entry.board?.assistant ? { assistant: entry.board.assistant } : {}), ...(arrangement ? { arrangement } : {}), problems: entry.problems, cards }, { etag: tag })
121
+ return json(200, { id, title: entry.board?.title ?? id, ...(entry.board?.assistant ? { assistant: entry.board.assistant } : {}), ...(canAct ? {} : { readOnly: true }), ...(arrangement ? { arrangement } : {}), problems: entry.problems, cards }, { etag: tag })
121
122
  }
122
123
 
123
124
  async function card(request) {
@@ -127,15 +128,15 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
127
128
  if (!ID_PATTERN.test(boardId) || !ID_PATTERN.test(id)) return json(400, { error: 'Say which board and card.' })
128
129
  const found = await access(boardId)
129
130
  if (found.refused) return found.refused
130
- const { viewer, root, entry, person } = found
131
+ const { viewer, root, entry, person, canAct } = found
131
132
  // A card someone may not see answers like one that isn't there.
132
133
  if (!maySeeCard(viewer, entry.board, id)) return json(404, { error: 'No such card.' })
133
- const states = await pressStates(root, boardId)
134
- const tag = await cardTag(root, boardId, id, `${version}\0${viewer.mode}\0${person ?? ''}\0${await seen.tag(person)}\0${JSON.stringify(states[id] ?? null)}`)
134
+ const states = canAct ? await pressStates(root, boardId) : {}
135
+ const tag = await cardTag(root, boardId, id, `${version}\0${viewer.mode}\0${person ?? ''}\0${canAct}\0${await seen.tag(person)}\0${JSON.stringify(states[id] ?? null)}`)
135
136
  if (request.headers.get('if-none-match') === tag) return new Response(null, { status: 304, headers: { ...HEADERS, etag: tag } })
136
137
  const one = (await readCards(root, boardId, entry.board, id))[0]
137
138
  if (one === undefined) return json(404, { error: 'No such card.' })
138
- return json(200, decorate(one, states, await seen.board(person, boardId)), { etag: tag })
139
+ return json(200, decorate(one, states, await seen.board(person, boardId), canAct), { etag: tag })
139
140
  }
140
141
 
141
142
  async function events(request) {
@@ -256,7 +257,7 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
256
257
  if (viewer.unavailable) return json(503, { error: NO_PROVIDER })
257
258
  const root = await resolveDataDir(dataDir)
258
259
  const entry = root === undefined ? undefined : await readBoard(root, board)
259
- if (!maySee(viewer, entry?.board) || entry === undefined || !maySeeCard(viewer, entry.board, card)) return json(403, { error: 'You can’t act on this board.' })
260
+ if (!mayAct(viewer, entry?.board) || entry === undefined || !maySeeCard(viewer, entry.board, card)) return json(403, { error: 'You can’t act on this board.' })
260
261
  const found = findAction(await readCard(root, board, card), id, row)
261
262
  if (found === undefined || !PRESS_KINDS.includes(found.kind)) return json(409, { error: 'This action isn’t on the card any more.' })
262
263
  const payload = { ...(found.payload ?? {}), ...(found.kind === 'snooze' && until !== undefined && found.payload?.until === undefined ? { until } : {}) }
@@ -280,7 +281,7 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
280
281
  if (viewer.unavailable) return json(503, { error: NO_PROVIDER })
281
282
  const root = await resolveDataDir(dataDir)
282
283
  const entry = root === undefined ? undefined : await readBoard(root, board)
283
- if (!maySee(viewer, entry?.board) || entry === undefined || !maySeeCard(viewer, entry.board, card)) return json(403, { error: 'You can’t act on this board.' })
284
+ if (!mayAct(viewer, entry?.board) || entry === undefined || !maySeeCard(viewer, entry.board, card)) return json(403, { error: 'You can’t act on this board.' })
284
285
  const result = await presses.undo({ press: undo, person: viewer.mode === 'owner' ? 'owner' : viewer.person, user: identity()?.current?.()?.id, board, card })
285
286
  if (result.problem === 'forbidden') return json(403, { error: 'You can’t act on this board.' })
286
287
  if (result.problem) return json(409, { error: 'This action can’t be undone.' })
package/src/schema.js CHANGED
@@ -608,12 +608,13 @@ export function findAction(card, actionId, row) {
608
608
  /** Problems with a board.json's parsed content. */
609
609
  export function checkBoard(board) {
610
610
  const c = new Check()
611
- if (!c.object(board, '', ['title'], ['viewers', 'cardViewers', 'order', 'layout', 'assistant'])) return c.problems
611
+ if (!c.object(board, '', ['title'], ['viewers', 'actors', 'cardViewers', 'order', 'layout', 'assistant'])) return c.problems
612
612
  c.label(board.title, 'title', { max: 80 })
613
613
  c.optional(board, 'assistant', v => c.text(v, 'assistant', { max: 40 }))
614
- c.optional(board, 'viewers', viewers => {
615
- if (c.array(viewers, 'viewers', { max: 100 })) viewers.forEach((v, i) => c.text(v, join('viewers', i), { max: 100 }))
616
- })
614
+ for (const key of ['viewers', 'actors'])
615
+ c.optional(board, key, people => {
616
+ if (c.array(people, key, { max: 100 })) people.forEach((v, i) => c.text(v, join(key, i), { max: 100 }))
617
+ })
617
618
  c.optional(board, 'cardViewers', only => {
618
619
  if (typeof only !== 'object' || only === null || Array.isArray(only)) return c.fail('cardViewers', 'must be an object of card id to viewers')
619
620
  for (const [id, viewers] of Object.entries(only)) {