@soffits/dsh-card-board 0.2.0 → 0.3.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1
4
+
5
+ - Line charts: a goal drawn as points, and markers, no longer run past the plot when they reach beyond the series; x labels that would repeat or overlap are left out.
6
+
7
+ ## 0.3.0
8
+
9
+ - Remove `ownerPerson` again. Who a request is, including one that reaches DSH without passing the sign-in, is for the `requestIdentity` provider to say; the board only maps the id it gets.
10
+
3
11
  ## 0.2.0
4
12
 
5
13
  - Add `ownerPerson`: with a people mapping, requests DSH lets in with its own login (launch link or API token) rather than through the sign-in plugin count as that person instead of seeing nothing. Without an identity provider the routes still answer 503.
package/README.md CHANGED
@@ -32,7 +32,6 @@ Override the row in your profile's `cordis.patch.yml`:
32
32
  | `people` | `{}` | Verified user id → person id, for a DSH several people sign in to. |
33
33
  | `peopleFile` | | A JSON file with more of that mapping, re-read when it changes. `people` wins on a clash. |
34
34
  | `peopleKey` | | The key in `peopleFile` that holds the mapping; empty means the whole file. |
35
- | `ownerPerson` | | With a mapping, the person id for requests DSH lets in with its own login (its launch link or an API token) rather than through the sign-in plugin. Empty (the default): they see no boards. See the note below before setting it. |
36
35
  | `pollSeconds` | `30` | How often an open, visible page checks for changes. A hidden tab doesn't poll. |
37
36
  | `actionLog` | `<dataDir>/.actions.jsonl` | Where action presses are appended. |
38
37
  | `actionTimeoutSeconds` | `300` | A press nobody handles within this time shows as not handled. |
@@ -41,9 +40,7 @@ Override the row in your profile's `cordis.patch.yml`:
41
40
 
42
41
  With no `people` and no `peopleFile`, the plugin assumes a single-person DSH: everyone DSH lets in sees every board.
43
42
 
44
- 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 (or `ownerPerson`'s, if you set it); 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.
45
-
46
- `ownerPerson` maps every request DSH admits without a sign-in identity to that one person. That's only safe when every outside path to DSH goes through the sign-in gate (a forward-auth proxy or a gateway) and the only way around it is local, such as DSH's own port on a private network. Give that person their own boards rather than adding them to everyone's.
43
+ 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.
47
44
 
48
45
  `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:
49
46
 
@@ -54,7 +51,7 @@ interface RequestIdentityService {
54
51
  }
55
52
  ```
56
53
 
57
- The card board reads it with `ctx.get('requestIdentity')` at request time, so it doesn't depend on any one sign-in plugin. With a mapping configured and no provider running, the board routes answer 503 rather than showing everything.
54
+ 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.
58
55
 
59
56
  ## Data layout
60
57
 
package/client.js CHANGED
@@ -195,7 +195,8 @@ window.__ModuleLoader__.load({
195
195
  function LineChart({ data, locale, height }) {
196
196
  const [ref, width] = useWidth()
197
197
  const model = useMemo(() => {
198
- const allX = data.series.flatMap(s => s.points.map(p => p.x))
198
+ // The x range covers the series, a goal drawn as points and the markers, so none of them runs off the plot.
199
+ const allX = [...data.series.flatMap(s => s.points.map(p => p.x)), ...(data.goal?.points ?? []).map(p => p.x), ...(data.markers ?? []).map(m => m.x)]
199
200
  const times = allX.map(toTime)
200
201
  const timeAxis = times.every(Number.isFinite)
201
202
  const numberAxis = !timeAxis && allX.every(x => typeof x === 'number')
@@ -227,7 +228,13 @@ window.__ModuleLoader__.load({
227
228
 
228
229
  const longest = data.series.reduce((best, s) => (s.points.length > best.points.length ? s : best), data.series[0])
229
230
  const labelCount = Math.max(2, Math.floor(plotW / 44))
230
- const xTicks = spread(longest.points.length, labelCount).map(i => longest.points[i].x)
231
+ // Evenly spaced labels, minus any that would print the same text or sit on top of the one before.
232
+ const xTicks = []
233
+ for (const x of spread(longest.points.length, labelCount).map(i => longest.points[i].x)) {
234
+ const last = xTicks[xTicks.length - 1]
235
+ if (last !== undefined && (xLabel(last) === xLabel(x) || sx(x) - sx(last) < 36)) continue
236
+ xTicks.push(x)
237
+ }
231
238
 
232
239
  const path = points => {
233
240
  let d = ''
package/index.js CHANGED
@@ -31,8 +31,6 @@ export const Config = z.object({
31
31
  .description('A JSON file with more of the same mapping, re-read when it changes. Entries in people win.'),
32
32
  peopleKey: z.string().default('')
33
33
  .description('The top-level key in peopleFile that holds the mapping. Empty means the whole file is the mapping.'),
34
- ownerPerson: z.string().default('')
35
- .description('With a mapping: the person id for requests DSH lets in with its own login (launch link or API token) rather than through the sign-in plugin. Empty means such requests see no boards.'),
36
34
  pollSeconds: z.natural().min(5).max(3600).default(30)
37
35
  .description('How often an open, visible page checks for changes.'),
38
36
  actionLog: z.string().default('')
@@ -43,7 +41,7 @@ export const Config = z.object({
43
41
 
44
42
  /**
45
43
  * @param {import('@deepseek-ai/cordis').Context} ctx
46
- * @param {{ dataDir: string, people: Record<string, string>, peopleFile: string, peopleKey: string, ownerPerson: string, pollSeconds: number, actionLog: string, actionTimeoutSeconds: number }} config
44
+ * @param {{ dataDir: string, people: Record<string, string>, peopleFile: string, peopleKey: string, pollSeconds: number, actionLog: string, actionTimeoutSeconds: number }} config
47
45
  */
48
46
  export function apply(ctx, config) {
49
47
  const logger = ctx.logger('card-board')
@@ -71,7 +69,6 @@ export function apply(ctx, config) {
71
69
  identity: () => ctx.get('requestIdentity'),
72
70
  pollSeconds: config.pollSeconds ?? 30,
73
71
  presses,
74
- ownerPerson: config.ownerPerson ?? '',
75
72
  version,
76
73
  })
77
74
  for (const route of routes) ctx.connection.fetch.register(route)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-card-board",
3
- "version": "0.2.0",
3
+ "version": "0.3.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
@@ -76,18 +76,12 @@ export function createPeople({ people = {}, peopleFile = '', peopleKey = '' }, {
76
76
  * `{ mode: 'people', person }` (person may be undefined: sees nothing) or
77
77
  * `{ mode: 'people', unavailable: true }` when a mapping is configured but no
78
78
  * identity provider is installed.
79
- *
80
- * `ownerPerson` names the person behind a request the provider can't name:
81
- * one DSH let in with its own login (its launch link or API token) rather
82
- * than through the sign-in plugin. Without a provider at all nobody can be
83
- * told apart, so that stays unavailable.
84
79
  */
85
- export async function viewerOf(people, identityService, ownerPerson = '') {
80
+ export async function viewerOf(people, identityService) {
86
81
  if (!people.enabled) return { mode: 'owner' }
87
82
  if (identityService === undefined || typeof identityService?.current !== 'function') return { mode: 'people', unavailable: true }
88
83
  const identity = identityService.current()
89
- if (identity === null || identity === undefined) return { mode: 'people', person: ownerPerson ? personKey(ownerPerson) : undefined }
90
- return { mode: 'people', person: await people.personFor(identity.id) }
84
+ return { mode: 'people', person: await people.personFor(identity?.id) }
91
85
  }
92
86
 
93
87
  /** Whether a viewer may see a board (its board.json already validated). */
package/src/routes.js CHANGED
@@ -36,12 +36,11 @@ const NO_PROVIDER = 'This board needs a sign-in plugin that provides requestIden
36
36
  * @param {() => object | undefined} options.identity - the requestIdentity service right now, if any
37
37
  * @param {number} options.pollSeconds
38
38
  * @param {ReturnType<import('./presses.js').createPresses>} options.presses
39
- * @param {string} [options.ownerPerson] - the person for requests DSH admits without a sign-in identity
40
39
  * @param {string} [options.version] - mixed into ETags, so a plugin update refreshes open pages
41
40
  */
42
- export function createRoutes({ dataDir, people, identity, pollSeconds, presses, ownerPerson = '', version = '' }) {
41
+ export function createRoutes({ dataDir, people, identity, pollSeconds, presses, version = '' }) {
43
42
  async function boards() {
44
- const viewer = await viewerOf(people, identity(), ownerPerson)
43
+ const viewer = await viewerOf(people, identity())
45
44
  if (viewer.unavailable) return json(503, { error: NO_PROVIDER })
46
45
  const root = await resolveDataDir(dataDir)
47
46
  const visible = root === undefined ? [] : (await listBoards(root)).filter(entry => viewer.mode === 'owner' || maySee(viewer, entry.board))
@@ -55,7 +54,7 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
55
54
  async function board(request) {
56
55
  const id = new URL(request.url).searchParams.get('id') ?? ''
57
56
  if (!ID_PATTERN.test(id)) return json(400, { error: 'Not a board id.' })
58
- const viewer = await viewerOf(people, identity(), ownerPerson)
57
+ const viewer = await viewerOf(people, identity())
59
58
  if (viewer.unavailable) return json(503, { error: NO_PROVIDER })
60
59
  const root = await resolveDataDir(dataDir)
61
60
  const entry = root === undefined ? undefined : await readBoard(root, id)
@@ -93,7 +92,7 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
93
92
  if (row !== undefined && !(Number.isInteger(row) && row >= 0)) return json(400, { error: 'row must be a row index.' })
94
93
  if (until !== undefined && (typeof until !== 'string' || !DATE_TIME.test(until) || Number.isNaN(Date.parse(until))))
95
94
  return json(400, { error: 'until must be an ISO date-time with a zone.' })
96
- const viewer = await viewerOf(people, identity(), ownerPerson)
95
+ const viewer = await viewerOf(people, identity())
97
96
  if (viewer.unavailable) return json(503, { error: NO_PROVIDER })
98
97
  const root = await resolveDataDir(dataDir)
99
98
  const entry = root === undefined ? undefined : await readBoard(root, board)