@soffits/dsh-card-board 0.14.2 → 0.15.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 +4 -0
- package/README.md +4 -1
- package/client.js +1 -1
- package/package.json +6 -6
- package/src/access.js +11 -0
- package/src/routes.js +14 -5
- package/src/schema.js +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
3
7
|
## 0.14.2
|
|
4
8
|
|
|
5
9
|
An opened card or row that is taller than the window scrolls inside its sheet instead of running off the screen. `@deepseek-ai/schemastery` is a peer dependency, so an update never moves a private copy out from under the plugin.
|
package/README.md
CHANGED
|
@@ -57,6 +57,8 @@ interface RequestIdentityService {
|
|
|
57
57
|
}
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
A shared board can carry cards meant for only some of its viewers: `cardViewers` in `board.json` maps a card id to the people who may see it (a person's own to-do card on a family board). Everyone else gets the board without that card: it is left out of the board, its own route answers 404 as if it weren't there, the events stream never mentions it, and its buttons can't be pressed. The board's `viewers` still decide who sees the board at all.
|
|
61
|
+
|
|
60
62
|
The card board reads it with `ctx.get('requestIdentity')` at request time, so it doesn't depend on any one sign-in plugin. Deciding who a request is, including one that reaches DSH without passing the sign-in (a local port), is the provider's job; the board only maps the id it gets. With a mapping configured and no provider running, the board routes answer 503 rather than showing everything.
|
|
61
63
|
|
|
62
64
|
## Data layout
|
|
@@ -76,13 +78,14 @@ Board and card ids are lowercase letters, digits, `-` and `_`, up to 64 characte
|
|
|
76
78
|
{
|
|
77
79
|
"title": "Home",
|
|
78
80
|
"viewers": ["alex", "sam"],
|
|
81
|
+
"cardViewers": { "alex-todo": ["alex"] },
|
|
79
82
|
"order": ["weather", "savings", "energy"],
|
|
80
83
|
"layout": { "weather": { "size": "small" }, "energy": { "size": "wide" } },
|
|
81
84
|
"assistant": "Robin"
|
|
82
85
|
}
|
|
83
86
|
```
|
|
84
87
|
|
|
85
|
-
`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).
|
|
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).
|
|
86
89
|
|
|
87
90
|
A card:
|
|
88
91
|
|
package/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @soffits/dsh-card-board 0.
|
|
1
|
+
/* @soffits/dsh-card-board 0.15.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) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soffits/dsh-card-board",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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",
|
|
@@ -74,11 +74,11 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@deepseek-ai/cordis": "^4.1.0",
|
|
77
|
-
"@deepseek-ai/dsh-client-connection": "0.2.2-rc.
|
|
78
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.
|
|
79
|
-
"@deepseek-ai/dsh-credentials": "0.2.2-rc.
|
|
80
|
-
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.
|
|
81
|
-
"@deepseek-ai/schemastery": "3.
|
|
77
|
+
"@deepseek-ai/dsh-client-connection": "0.2.2-rc.3",
|
|
78
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.3",
|
|
79
|
+
"@deepseek-ai/dsh-credentials": "0.2.2-rc.3",
|
|
80
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.3",
|
|
81
|
+
"@deepseek-ai/schemastery": "3.19.0",
|
|
82
82
|
"acorn": "^8.19.0",
|
|
83
83
|
"esbuild": "^0.28.2"
|
|
84
84
|
},
|
package/src/access.js
CHANGED
|
@@ -84,6 +84,17 @@ export async function viewerOf(people, identityService) {
|
|
|
84
84
|
return { mode: 'people', person: await people.personFor(identity?.id) }
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Whether a viewer who may see `board` may also see its card `card`: a card listed in the board's `cardViewers`
|
|
89
|
+
* shows only to the people named there, so a shared board can carry cards about one person.
|
|
90
|
+
*/
|
|
91
|
+
export function maySeeCard(viewer, board, card) {
|
|
92
|
+
if (viewer.mode === 'owner') return true
|
|
93
|
+
const only = board?.cardViewers?.[card]
|
|
94
|
+
if (only === undefined) return true
|
|
95
|
+
return viewer.person !== undefined && only.some(person => personKey(person) === viewer.person)
|
|
96
|
+
}
|
|
97
|
+
|
|
87
98
|
/** Whether a viewer may see a board (its board.json already validated). */
|
|
88
99
|
export function maySee(viewer, board) {
|
|
89
100
|
if (viewer.mode === 'owner') return true
|
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, viewerOf } from './access.js'
|
|
20
|
+
import { maySee, maySeeCard, viewerOf } 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'
|
|
@@ -113,7 +113,9 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
|
|
|
113
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)}`)
|
|
114
114
|
if (request.headers.get('if-none-match') === tag) return new Response(null, { status: 304, headers: { ...HEADERS, etag: tag } })
|
|
115
115
|
const seenBoard = await seen.board(person, id)
|
|
116
|
-
const cards = (await readCards(root, id, entry.board))
|
|
116
|
+
const cards = (await readCards(root, id, entry.board))
|
|
117
|
+
.filter(card => maySeeCard(viewer, entry.board, card.id))
|
|
118
|
+
.map(card => decorate(card, states, seenBoard))
|
|
117
119
|
const arrangement = await arrange.get(person, id)
|
|
118
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 })
|
|
119
121
|
}
|
|
@@ -126,6 +128,8 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
|
|
|
126
128
|
const found = await access(boardId)
|
|
127
129
|
if (found.refused) return found.refused
|
|
128
130
|
const { viewer, root, entry, person } = found
|
|
131
|
+
// A card someone may not see answers like one that isn't there.
|
|
132
|
+
if (!maySeeCard(viewer, entry.board, id)) return json(404, { error: 'No such card.' })
|
|
129
133
|
const states = await pressStates(root, boardId)
|
|
130
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)}`)
|
|
131
135
|
if (request.headers.get('if-none-match') === tag) return new Response(null, { status: 304, headers: { ...HEADERS, etag: tag } })
|
|
@@ -172,6 +176,10 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
|
|
|
172
176
|
return
|
|
173
177
|
}
|
|
174
178
|
}
|
|
179
|
+
if (change.type === 'card') {
|
|
180
|
+
const now = await readBoard(found.root, id)
|
|
181
|
+
if (!maySeeCard(found.viewer, now?.board, change.id)) return
|
|
182
|
+
}
|
|
175
183
|
data(change)
|
|
176
184
|
})
|
|
177
185
|
if (!open) unwatch()
|
|
@@ -195,7 +203,8 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
|
|
|
195
203
|
if (body === undefined) return json(400, { error: 'The body must be { board, cards: { <id>: { v, rows? } } }.' })
|
|
196
204
|
const found = await access(body.board)
|
|
197
205
|
if (found.refused) return found.refused
|
|
198
|
-
const present = new Set((await readCards(found.root, body.board, found.entry.board))
|
|
206
|
+
const present = new Set((await readCards(found.root, body.board, found.entry.board))
|
|
207
|
+
.filter(entry => maySeeCard(found.viewer, found.entry.board, entry.id)).map(entry => entry.id))
|
|
199
208
|
await seen.record(found.person, body.board, body.cards, present)
|
|
200
209
|
return json(200, { ok: true })
|
|
201
210
|
}
|
|
@@ -247,7 +256,7 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
|
|
|
247
256
|
if (viewer.unavailable) return json(503, { error: NO_PROVIDER })
|
|
248
257
|
const root = await resolveDataDir(dataDir)
|
|
249
258
|
const entry = root === undefined ? undefined : await readBoard(root, board)
|
|
250
|
-
if (!maySee(viewer, entry?.board) || entry === undefined) return json(403, { error: 'You can’t act on this 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.' })
|
|
251
260
|
const found = findAction(await readCard(root, board, card), id, row)
|
|
252
261
|
if (found === undefined || !PRESS_KINDS.includes(found.kind)) return json(409, { error: 'This action isn’t on the card any more.' })
|
|
253
262
|
const payload = { ...(found.payload ?? {}), ...(found.kind === 'snooze' && until !== undefined && found.payload?.until === undefined ? { until } : {}) }
|
|
@@ -271,7 +280,7 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
|
|
|
271
280
|
if (viewer.unavailable) return json(503, { error: NO_PROVIDER })
|
|
272
281
|
const root = await resolveDataDir(dataDir)
|
|
273
282
|
const entry = root === undefined ? undefined : await readBoard(root, board)
|
|
274
|
-
if (!maySee(viewer, entry?.board) || entry === undefined) return json(403, { error: 'You can’t act on this 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.' })
|
|
275
284
|
const result = await presses.undo({ press: undo, person: viewer.mode === 'owner' ? 'owner' : viewer.person, user: identity()?.current?.()?.id, board, card })
|
|
276
285
|
if (result.problem === 'forbidden') return json(403, { error: 'You can’t act on this board.' })
|
|
277
286
|
if (result.problem) return json(409, { error: 'This action can’t be undone.' })
|
package/src/schema.js
CHANGED
|
@@ -608,12 +608,20 @@ 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', 'order', 'layout', 'assistant'])) return c.problems
|
|
611
|
+
if (!c.object(board, '', ['title'], ['viewers', '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
614
|
c.optional(board, 'viewers', viewers => {
|
|
615
615
|
if (c.array(viewers, 'viewers', { max: 100 })) viewers.forEach((v, i) => c.text(v, join('viewers', i), { max: 100 }))
|
|
616
616
|
})
|
|
617
|
+
c.optional(board, 'cardViewers', only => {
|
|
618
|
+
if (typeof only !== 'object' || only === null || Array.isArray(only)) return c.fail('cardViewers', 'must be an object of card id to viewers')
|
|
619
|
+
for (const [id, viewers] of Object.entries(only)) {
|
|
620
|
+
const p = join('cardViewers', id)
|
|
621
|
+
if (!ID_PATTERN.test(id)) c.fail(p, 'is not a card id')
|
|
622
|
+
if (c.array(viewers, p, { max: 100 })) viewers.forEach((v, i) => c.text(v, join(p, i), { max: 100 }))
|
|
623
|
+
}
|
|
624
|
+
})
|
|
617
625
|
c.optional(board, 'order', order => {
|
|
618
626
|
if (c.array(order, 'order', { max: 200 }))
|
|
619
627
|
order.forEach((id, i) => (typeof id === 'string' && ID_PATTERN.test(id)) || c.fail(join('order', i), 'must be a card id'))
|