@soffits/dsh-card-board 0.7.1 → 0.9.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 +16 -0
- package/README.md +24 -6
- package/client.js +592 -232
- package/examples/boards/home/board.json +6 -9
- package/examples/boards/home/cards/chores.json +46 -3
- package/examples/boards/home/cards/weather.json +2 -1
- package/locale/en.json +8 -2
- package/locale/fr.json +8 -2
- package/locale/zh.json +8 -2
- package/package.json +1 -1
- package/src/presses.js +3 -1
- package/src/schema.js +56 -7
- package/src/store.js +1 -1
|
@@ -19,17 +19,14 @@
|
|
|
19
19
|
"house"
|
|
20
20
|
],
|
|
21
21
|
"layout": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"h": 1
|
|
22
|
+
"weather": {
|
|
23
|
+
"size": "small"
|
|
25
24
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"h": 1
|
|
25
|
+
"energy": {
|
|
26
|
+
"size": "medium"
|
|
29
27
|
},
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"h": 1
|
|
28
|
+
"spending": {
|
|
29
|
+
"size": "medium"
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
}
|
|
@@ -67,7 +67,26 @@
|
|
|
67
67
|
}
|
|
68
68
|
],
|
|
69
69
|
"key": "chore-2",
|
|
70
|
-
"icon": "book-open"
|
|
70
|
+
"icon": "book-open",
|
|
71
|
+
"detail": {
|
|
72
|
+
"text": "Three books, due at the branch on Elm Street.",
|
|
73
|
+
"facts": [
|
|
74
|
+
{
|
|
75
|
+
"label": "Renewals left",
|
|
76
|
+
"value": 1
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"label": "Fine per day",
|
|
80
|
+
"value": "0.25 EUR"
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"history": [
|
|
84
|
+
{
|
|
85
|
+
"at": "2026-02-20T15:10:00+01:00",
|
|
86
|
+
"text": "Borrowed"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
71
90
|
},
|
|
72
91
|
{
|
|
73
92
|
"title": {
|
|
@@ -100,7 +119,8 @@
|
|
|
100
119
|
}
|
|
101
120
|
],
|
|
102
121
|
"key": "chore-3",
|
|
103
|
-
"icon": "trash-2"
|
|
122
|
+
"icon": "trash-2",
|
|
123
|
+
"link": "https://example.com/heating"
|
|
104
124
|
}
|
|
105
125
|
],
|
|
106
126
|
"empty": {
|
|
@@ -109,5 +129,28 @@
|
|
|
109
129
|
}
|
|
110
130
|
},
|
|
111
131
|
"icon": "list-todo",
|
|
112
|
-
"tone": "accent"
|
|
132
|
+
"tone": "accent",
|
|
133
|
+
"detail": {
|
|
134
|
+
"text": "Chores for the flat, from the shared list.",
|
|
135
|
+
"facts": [
|
|
136
|
+
{
|
|
137
|
+
"label": "Done this week",
|
|
138
|
+
"value": 4
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"label": "Left",
|
|
142
|
+
"value": 3
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
"history": [
|
|
146
|
+
{
|
|
147
|
+
"at": "2026-03-02T08:30:00+01:00",
|
|
148
|
+
"text": "Watered the plants"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"at": "2026-03-01T18:05:00+01:00",
|
|
152
|
+
"text": "Took the recycling out"
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
113
156
|
}
|
package/locale/en.json
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"open": "Open",
|
|
17
17
|
"listEmpty": "Nothing here.",
|
|
18
18
|
"checked": "Done",
|
|
19
|
-
"unchecked": "Not done",
|
|
20
19
|
"error.forbidden": "You can’t see this board.",
|
|
21
20
|
"error.notFound": "This board isn’t there any more.",
|
|
22
21
|
"error.gone": "This action isn’t on the card any more.",
|
|
@@ -34,6 +33,13 @@
|
|
|
34
33
|
"dayPart.morning": "morning",
|
|
35
34
|
"dayPart.afternoon": "afternoon",
|
|
36
35
|
"dayPart.evening": "evening",
|
|
37
|
-
"dayPart.night": "night"
|
|
36
|
+
"dayPart.night": "night",
|
|
37
|
+
"showMore": "{n} more",
|
|
38
|
+
"showFewer": "Show fewer",
|
|
39
|
+
"details": "Details",
|
|
40
|
+
"close": "Close",
|
|
41
|
+
"history": "History",
|
|
42
|
+
"markDone": "Mark done",
|
|
43
|
+
"rowGone": "This item is no longer on the card."
|
|
38
44
|
}
|
|
39
45
|
}
|
package/locale/fr.json
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"open": "Ouvrir",
|
|
17
17
|
"listEmpty": "Rien ici.",
|
|
18
18
|
"checked": "Fait",
|
|
19
|
-
"unchecked": "Pas fait",
|
|
20
19
|
"error.forbidden": "Vous n’avez pas accès à ce tableau.",
|
|
21
20
|
"error.notFound": "Ce tableau n’existe plus.",
|
|
22
21
|
"error.gone": "Cette action n’est plus sur la carte.",
|
|
@@ -34,6 +33,13 @@
|
|
|
34
33
|
"dayPart.morning": "matin",
|
|
35
34
|
"dayPart.afternoon": "après-midi",
|
|
36
35
|
"dayPart.evening": "soir",
|
|
37
|
-
"dayPart.night": "nuit"
|
|
36
|
+
"dayPart.night": "nuit",
|
|
37
|
+
"showMore": "{n} de plus",
|
|
38
|
+
"showFewer": "Afficher moins",
|
|
39
|
+
"details": "Détails",
|
|
40
|
+
"close": "Fermer",
|
|
41
|
+
"history": "Historique",
|
|
42
|
+
"markDone": "Marquer comme fait",
|
|
43
|
+
"rowGone": "Cet élément n’est plus sur la carte."
|
|
38
44
|
}
|
|
39
45
|
}
|
package/locale/zh.json
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"open": "打开",
|
|
17
17
|
"listEmpty": "暂无",
|
|
18
18
|
"checked": "已完成",
|
|
19
|
-
"unchecked": "未完成",
|
|
20
19
|
"error.forbidden": "你没有权限查看这个面板。",
|
|
21
20
|
"error.notFound": "这个面板已经不存在了。",
|
|
22
21
|
"error.gone": "这个操作已经不在卡片上了。",
|
|
@@ -34,6 +33,13 @@
|
|
|
34
33
|
"dayPart.morning": "上午",
|
|
35
34
|
"dayPart.afternoon": "下午",
|
|
36
35
|
"dayPart.evening": "傍晚",
|
|
37
|
-
"dayPart.night": "夜里"
|
|
36
|
+
"dayPart.night": "夜里",
|
|
37
|
+
"showMore": "还有 {n} 项",
|
|
38
|
+
"showFewer": "收起",
|
|
39
|
+
"details": "详情",
|
|
40
|
+
"close": "关闭",
|
|
41
|
+
"history": "记录",
|
|
42
|
+
"markDone": "标为完成",
|
|
43
|
+
"rowGone": "这一项已经不在卡片上了。"
|
|
38
44
|
}
|
|
39
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soffits/dsh-card-board",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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/presses.js
CHANGED
|
@@ -108,7 +108,9 @@ export function createPresses({ logPath, publisher, notify = () => {}, timeoutSe
|
|
|
108
108
|
const at = now()
|
|
109
109
|
return events.map(event => {
|
|
110
110
|
const time = Date.parse(event.at)
|
|
111
|
-
|
|
111
|
+
// A step is carried out by sending it to the assistant (dsh-ui-actions does that right after the press), so it
|
|
112
|
+
// is done once recorded; the others wait for their owner to write the card again.
|
|
113
|
+
const state = event.action === 'step' || written > time ? 'done' : at - time > timeoutSeconds * 1000 ? 'unhandled' : 'pending'
|
|
112
114
|
return { press: event.press, id: event.id, ...(event.source.row === undefined ? {} : { row: event.source.row }), at: event.at, state }
|
|
113
115
|
})
|
|
114
116
|
}
|
package/src/schema.js
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
* fails at write time instead of quietly not showing.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
/** How wide a card is on the board: a third, a half, two thirds or the whole width (on a wide screen). */
|
|
12
|
+
export const SIZES = Object.freeze(['small', 'medium', 'large', 'wide'])
|
|
13
|
+
|
|
11
14
|
export const CARD_TYPES = Object.freeze(['summary', 'countdown', 'stat', 'line', 'bar', 'donut', 'list', 'timeline', 'status'])
|
|
12
15
|
export const TONES = Object.freeze(['ok', 'warn', 'bad', 'muted', 'accent', 'violet'])
|
|
13
16
|
/** Icon names: the page draws the ones its icon set has (Lucide names) and nothing for the rest. */
|
|
@@ -207,12 +210,56 @@ function actions(c, list, path) {
|
|
|
207
210
|
})
|
|
208
211
|
}
|
|
209
212
|
|
|
213
|
+
/**
|
|
214
|
+
* The more a card or a row shows when it is opened: some text, facts (label and value), a chart (a line or bar card's
|
|
215
|
+
* data) and a history, newest first. Every part is optional; the opened view also shows the whole body and all actions.
|
|
216
|
+
* Exported so other row shapes can check theirs the same way.
|
|
217
|
+
*/
|
|
218
|
+
export function checkDetail(c, detail, path) {
|
|
219
|
+
if (!c.object(detail, path, [], ['text', 'facts', 'chart', 'history'])) return
|
|
220
|
+
c.optional(detail, 'text', v => c.label(v, join(path, 'text'), { max: 2000 }))
|
|
221
|
+
c.optional(detail, 'facts', facts => {
|
|
222
|
+
if (!c.array(facts, join(path, 'facts'), { max: 24 })) return
|
|
223
|
+
facts.forEach((fact, i) => {
|
|
224
|
+
const fp = join(join(path, 'facts'), i)
|
|
225
|
+
if (!c.object(fact, fp, ['label', 'value'])) return
|
|
226
|
+
c.label(fact.label, join(fp, 'label'), { max: 60 })
|
|
227
|
+
c.labelOrNumber(fact.value, join(fp, 'value'))
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
c.optional(detail, 'chart', chart => {
|
|
231
|
+
const cp = join(path, 'chart')
|
|
232
|
+
if (!c.object(chart, cp, ['type', 'data'])) return
|
|
233
|
+
if (!c.oneOf(chart.type, join(cp, 'type'), ['line', 'bar'])) return
|
|
234
|
+
DATA[chart.type](c, chart.data, join(cp, 'data'))
|
|
235
|
+
})
|
|
236
|
+
c.optional(detail, 'history', history => {
|
|
237
|
+
if (!c.array(history, join(path, 'history'), { max: 100 })) return
|
|
238
|
+
history.forEach((entry, i) => {
|
|
239
|
+
const hp = join(join(path, 'history'), i)
|
|
240
|
+
if (!c.object(entry, hp, ['at', 'text'])) return
|
|
241
|
+
c.dateTime(entry.at, join(hp, 'at'))
|
|
242
|
+
c.label(entry.text, join(hp, 'text'), { max: 400 })
|
|
243
|
+
})
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** A row's `link` (where a tap goes) and `detail` (what opening it shows; the row needs a `key` to be opened). */
|
|
248
|
+
function rowOpen(c, row, path) {
|
|
249
|
+
c.optional(row, 'link', v => isSafeLink(v) || c.fail(join(path, 'link'), 'must be an http(s) URL or a path starting with /'))
|
|
250
|
+
c.optional(row, 'detail', v => {
|
|
251
|
+
checkDetail(c, v, join(path, 'detail'))
|
|
252
|
+
if (row.key === undefined) c.fail(join(path, 'key'), 'is required on a row with a detail: it is how the row is opened')
|
|
253
|
+
})
|
|
254
|
+
}
|
|
255
|
+
|
|
210
256
|
function statData(c, data, path) {
|
|
211
257
|
if (!c.object(data, path, ['items'])) return
|
|
212
258
|
if (!c.array(data.items, join(path, 'items'), { min: 1, max: 6 })) return
|
|
213
259
|
data.items.forEach((item, i) => {
|
|
214
260
|
const p = join(join(path, 'items'), i)
|
|
215
|
-
if (!c.object(item, p, ['label', 'value'], ['unit', 'delta', 'sub', 'tone', 'spark', 'progress', 'strip'])) return
|
|
261
|
+
if (!c.object(item, p, ['label', 'value'], ['unit', 'delta', 'sub', 'tone', 'spark', 'progress', 'strip', 'link'])) return
|
|
262
|
+
c.optional(item, 'link', v => isSafeLink(v) || c.fail(join(p, 'link'), 'must be an http(s) URL or a path starting with /'))
|
|
216
263
|
c.label(item.label, join(p, 'label'))
|
|
217
264
|
c.labelOrNumber(item.value, join(p, 'value'))
|
|
218
265
|
c.optional(item, 'unit', v => c.label(v, join(p, 'unit'), { max: 20 }))
|
|
@@ -347,7 +394,8 @@ function listData(c, data, path) {
|
|
|
347
394
|
if (c.array(data.rows, join(path, 'rows'), { max: 100 }))
|
|
348
395
|
data.rows.forEach((row, i) => {
|
|
349
396
|
const p = join(join(path, 'rows'), i)
|
|
350
|
-
if (!c.object(row, p, ['title'], ['sub', 'chip', 'checked', 'date', 'actions', 'icon', 'tone', 'key', 'active'])) return
|
|
397
|
+
if (!c.object(row, p, ['title'], ['sub', 'chip', 'checked', 'date', 'actions', 'icon', 'tone', 'key', 'active', 'link', 'detail'])) return
|
|
398
|
+
rowOpen(c, row, p)
|
|
351
399
|
rowLook(c, row, p, keys)
|
|
352
400
|
c.optional(row, 'actions', v => actions(c, v, join(p, 'actions')))
|
|
353
401
|
c.label(row.title, join(p, 'title'))
|
|
@@ -409,7 +457,8 @@ function statusData(c, data, path) {
|
|
|
409
457
|
const keys = new Set()
|
|
410
458
|
data.rows.forEach((row, i) => {
|
|
411
459
|
const p = join(join(path, 'rows'), i)
|
|
412
|
-
if (!c.object(row, p, ['label', 'value', 'tone'], ['sub', 'spark', 'actions', 'icon', 'key', 'active'])) return
|
|
460
|
+
if (!c.object(row, p, ['label', 'value', 'tone'], ['sub', 'spark', 'actions', 'icon', 'key', 'active', 'link', 'detail'])) return
|
|
461
|
+
rowOpen(c, row, p)
|
|
413
462
|
rowLook(c, row, p, keys, { toneRequired: true })
|
|
414
463
|
c.optional(row, 'actions', v => actions(c, v, join(p, 'actions')))
|
|
415
464
|
c.label(row.label, join(p, 'label'))
|
|
@@ -488,7 +537,8 @@ export function isSafeLink(value) {
|
|
|
488
537
|
/** Problems with one card file's parsed content. */
|
|
489
538
|
export function checkCard(card) {
|
|
490
539
|
const c = new Check()
|
|
491
|
-
if (!c.object(card, '', ['type', 'title', 'updatedAt', 'data'], ['staleAfter', 'link', 'stat', 'actions', 'icon', 'tone'])) return c.problems
|
|
540
|
+
if (!c.object(card, '', ['type', 'title', 'updatedAt', 'data'], ['staleAfter', 'link', 'stat', 'actions', 'icon', 'tone', 'detail'])) return c.problems
|
|
541
|
+
c.optional(card, 'detail', v => checkDetail(c, v, 'detail'))
|
|
492
542
|
if (!c.oneOf(card.type, 'type', CARD_TYPES)) return c.problems
|
|
493
543
|
c.label(card.title, 'title', { max: 120 })
|
|
494
544
|
c.dateTime(card.updatedAt, 'updatedAt')
|
|
@@ -533,9 +583,8 @@ export function checkBoard(board) {
|
|
|
533
583
|
for (const [id, size] of Object.entries(layout)) {
|
|
534
584
|
const p = join('layout', id)
|
|
535
585
|
if (!ID_PATTERN.test(id)) c.fail(p, 'is not a card id')
|
|
536
|
-
if (!c.object(size, p, [], ['
|
|
537
|
-
c.optional(size, '
|
|
538
|
-
c.optional(size, 'h', v => (Number.isInteger(v) && v >= 1 && v <= 3) || c.fail(join(p, 'h'), 'must be 1, 2 or 3'))
|
|
586
|
+
if (!c.object(size, p, [], ['size'])) continue
|
|
587
|
+
c.optional(size, 'size', v => SIZES.includes(v) || c.fail(join(p, 'size'), `must be one of ${SIZES.join(', ')}`))
|
|
539
588
|
}
|
|
540
589
|
})
|
|
541
590
|
return c.problems
|
package/src/store.js
CHANGED
|
@@ -147,7 +147,7 @@ export async function readCards(root, id, board, only) {
|
|
|
147
147
|
const cards = []
|
|
148
148
|
const ids = await cardFiles(root, id, board?.order)
|
|
149
149
|
for (const card of only === undefined ? ids : ids.filter(card => card === only)) {
|
|
150
|
-
const size =
|
|
150
|
+
const size = layout[card]?.size ? { size: layout[card].size } : {}
|
|
151
151
|
const result = await readJson(root, join(root, id, 'cards', `${card}.json`), MAX_CARD_BYTES, checkCard)
|
|
152
152
|
cards.push(result.problems.length > 0 ? { id: card, ...size, problems: result.problems.slice(0, 5) } : { id: card, ...size, card: result.value })
|
|
153
153
|
}
|