@soffits/dsh-card-board 0.15.1 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +5 -2
- package/client.js +3 -1
- package/locale/en.json +2 -0
- package/locale/fr.json +2 -0
- package/locale/zh.json +2 -0
- package/package.json +1 -1
- package/src/access.js +28 -1
- package/src/routes.js +15 -14
- package/src/schema.js +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.16.1
|
|
4
|
+
|
|
5
|
+
Someone who may see a board but isn't an actor no longer gets its declared chat buttons. Those are the board owner's buttons, often a prompt in the owner's own words ("My answer to …:"), so a view-only viewer could still speak for the owner through a conversation. Now only plain `link` buttons survive the filter, plus the page's own "Chat about this" and "Ask", which ask about what the viewer sees in their own new conversation. A row whose chat button is taken away gets the built-in "Ask" back.
|
|
6
|
+
|
|
7
|
+
## 0.16.0
|
|
8
|
+
|
|
9
|
+
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`.
|
|
10
|
+
|
|
3
11
|
## 0.15.1
|
|
4
12
|
|
|
5
13
|
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.
|
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 without any button the board declares (`done`, `snooze`, `step`, `event` and `chat`; plain `link` buttons stay) and with a "View only" note beside the title, and their presses answer 403. A declared chat button is the board owner's, speaking in the owner's words, so it goes with the rest; the page's own "Chat about this" and "Ask" stay, since they ask the assistant about what the viewer sees, in the viewer's own new conversation. 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
|
|
|
@@ -305,7 +308,7 @@ A card, a list row or a status row can carry up to six buttons (a list or status
|
|
|
305
308
|
]
|
|
306
309
|
```
|
|
307
310
|
|
|
308
|
-
- `chat` opens a new conversation (or the session named in `payload.session`) with a draft that quotes the card or row and carries its ids as JSON, after `payload.prompt` if you gave one. Nothing is sent until the person sends it, so the message comes from them like any other. Every card also has a chat button in its corner without declaring one ("Chat about this"), and every list and status row has one at the end of its buttons ("Ask"), about that row and its card; a row that declares a `chat` action keeps its own, and one with six buttons already gets none. Set `ask: false` on a row, or on a card for all its rows, where asking makes no sense (a row that only says "nothing else today"). When the board names an `assistant` the buttons say who they ask ("Ask Robin"). A `label` and `payload.prompt` can be text in several languages.
|
|
311
|
+
- `chat` opens a new conversation (or the session named in `payload.session`) with a draft that quotes the card or row and carries its ids as JSON, after `payload.prompt` if you gave one. Nothing is sent until the person sends it, so the message comes from them like any other. Every card also has a chat button in its corner without declaring one ("Chat about this"), and every list and status row has one at the end of its buttons ("Ask"), about that row and its card; a row that declares a `chat` action keeps its own, and one with six buttons already gets none. Set `ask: false` on a row, or on a card for all its rows, where asking makes no sense (a row that only says "nothing else today"). When the board names an `assistant` the buttons say who they ask ("Ask Robin"). A `label` and `payload.prompt` can be text in several languages. People who may see a board but not act on it ([Who sees what](#who-sees-what)) get none of its declared buttons, chat included, only the built-in two.
|
|
309
312
|
- `step` is a suggested next step the assistant starts on one tap (on a row it sits with the row's other buttons, "Start" for instance): the label says the step plainly ("Renew the books online") and the tap is the person's go-ahead for exactly that. The press is recorded on the server like `done`, then the page sends the step (`payload.prompt` when it needs more words than the label, never more than it authorises; otherwise the label) with the card or row into a new session (or `payload.session`) as the person, with no draft to confirm, and the button links to that session. At most 3 steps per card or row; add one only where the data has a clear next step. The label (up to 80 characters) is required.
|
|
310
313
|
- `done`, `snooze` and `event` are pressed on the server. A snooze without `payload.until` asks: in 3 hours, tomorrow at 9:00, or a time.
|
|
311
314
|
- `link` opens `payload.url`.
|
package/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @soffits/dsh-card-board 0.
|
|
1
|
+
/* @soffits/dsh-card-board 0.16.1: 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}
|
|
@@ -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soffits/dsh-card-board",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
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 (use the buttons it declares) in `actors`;
|
|
9
|
+
* 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
|
|
@@ -101,3 +103,28 @@ export function maySee(viewer, board) {
|
|
|
101
103
|
if (viewer.person === undefined || board === undefined) return false
|
|
102
104
|
return (board.viewers ?? []).some(person => personKey(person) === viewer.person)
|
|
103
105
|
}
|
|
106
|
+
|
|
107
|
+
/** Whether a viewer who may see `board` may also act on it: be named in `actors`, or in `viewers` when there are no `actors`. */
|
|
108
|
+
export function mayAct(viewer, board) {
|
|
109
|
+
if (viewer.mode === 'owner') return true
|
|
110
|
+
if (!maySee(viewer, board)) return false
|
|
111
|
+
return (board.actors ?? board.viewers ?? []).some(person => personKey(person) === viewer.person)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A card as someone who may see but not act gets it: every button it declares is left out except plain links. Buttons
|
|
116
|
+
* belong to the people who may act on the board, and a declared chat button is one of them (it asks in the owner's
|
|
117
|
+
* words, for the owner), only routed through a conversation. The page's own "Chat about this" and "Ask" are not on
|
|
118
|
+
* the card, so they stay: they ask about what the viewer sees, in the viewer's own new conversation.
|
|
119
|
+
*/
|
|
120
|
+
export function withoutActions(card) {
|
|
121
|
+
/** `holder` without its `actions` key, then with the links if any. */
|
|
122
|
+
const trimmed = holder => {
|
|
123
|
+
const { actions, ...rest } = holder
|
|
124
|
+
const kept = (actions ?? []).filter(action => action.kind === 'link')
|
|
125
|
+
return kept.length > 0 ? { ...rest, actions: kept } : rest
|
|
126
|
+
}
|
|
127
|
+
const rows = card.data?.rows
|
|
128
|
+
const result = trimmed(card)
|
|
129
|
+
return Array.isArray(rows) ? { ...result, data: { ...card.data, rows: rows.map(trimmed) } } : result
|
|
130
|
+
}
|
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, withoutActions } 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: withoutActions(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 (!
|
|
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 (!
|
|
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
|
-
|
|
615
|
-
|
|
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)) {
|