create-pmos 0.387.0 → 0.388.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/package.json +13 -13
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +12 -0
- package/workspace/lib/report-setups.js +49 -7
- package/workspace/lib/routes-report-setups.js +38 -7
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.388.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,18 @@
|
|
|
32
32
|
"audit"
|
|
33
33
|
],
|
|
34
34
|
"pmosChanges": [
|
|
35
|
+
{
|
|
36
|
+
"v": "0.388.0",
|
|
37
|
+
"at": "2026-10-21T22:35:51.404Z",
|
|
38
|
+
"f": 2,
|
|
39
|
+
"prs": [
|
|
40
|
+
{
|
|
41
|
+
"n": 1000,
|
|
42
|
+
"t": "Report templates reschedule and delete, drafts discard, issued reports stay",
|
|
43
|
+
"s": "Report templates reschedule and delete, drafts discard, issued reports stay"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
35
47
|
{
|
|
36
48
|
"v": "0.387.0",
|
|
37
49
|
"at": "2026-10-21T15:59:17.829Z",
|
|
@@ -289,18 +301,6 @@
|
|
|
289
301
|
"s": "Insights' first screen shows the list, not the empty card (calmer first screen 2/5)"
|
|
290
302
|
}
|
|
291
303
|
]
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
"v": "0.368.0",
|
|
295
|
-
"at": "2026-10-21T02:13:10.598Z",
|
|
296
|
-
"f": 2,
|
|
297
|
-
"prs": [
|
|
298
|
-
{
|
|
299
|
-
"n": 976,
|
|
300
|
-
"t": "The phone conversation gets the screen when it scrolls",
|
|
301
|
-
"s": "The phone conversation gets the screen when it scrolls"
|
|
302
|
-
}
|
|
303
|
-
]
|
|
304
304
|
}
|
|
305
305
|
]
|
|
306
306
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-21T22:35:48Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-21T22:35:48Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-21T22:35:48Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.388.0",
|
|
4
|
+
"at": "2026-10-21T22:35:51.404Z",
|
|
5
|
+
"f": 2,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1000,
|
|
9
|
+
"t": "Report templates reschedule and delete, drafts discard, issued reports stay",
|
|
10
|
+
"s": "Report templates reschedule and delete, drafts discard, issued reports stay"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
2
14
|
{
|
|
3
15
|
"v": "0.387.0",
|
|
4
16
|
"at": "2026-10-21T15:59:17.829Z",
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* firstSlot(schedule, now) · initialLastRun(schedule, now) · nextDraftAt(schedule, lastRun, now) the bi-weekly parity (below)
|
|
13
13
|
* definitionText(setup, { product, now }) · writeDefinition(root, setup, { now }) the definition a setup writes
|
|
14
14
|
* setUp(root, input, opts) · change(root, id, patch, opts) · pause / resume / remove(root, id, opts) the PM's presses
|
|
15
|
+
* reschedule(root, id, schedule, opts) a template's new schedule; { cadence: 'off' } pauses it, any other resumes a paused one
|
|
16
|
+
* discardDraft(root, rel, opts) · archiveDoc(root, rel, archived, opts) a document's presses. AN ISSUED REPORT IS NEVER DELETED: discard refuses it
|
|
15
17
|
* scheduleFor(setup) · registerSchedule(store, setup, opts) · unregisterSchedule(store, setup) the draft-only schedule
|
|
16
18
|
* askStart / askChange / askCancel / askEnd / fileProposal(file, …) the Ask box
|
|
17
19
|
* fileFinding / dismissFinding / setFinder / findStart / findEnd the weekly finder
|
|
@@ -23,7 +25,9 @@
|
|
|
23
25
|
* setup { id, name, purpose, audience, source: 'work'|'dashboard:<key>', output, schedule, sources[], sections[], learned_from, fixes[],
|
|
24
26
|
* product, ws, last_run, def_sha, from? } the PM pressed Set up. `from` is { ask } or { finding }
|
|
25
27
|
* change { id, …the fields that changed } the PM edited a recurring report
|
|
26
|
-
* pause · resume · remove { id }
|
|
28
|
+
* pause · resume · remove { id } a removed setup is a deleted TEMPLATE: its schedule stops, its documents stay
|
|
29
|
+
* doc-discard { doc, path } the PM discarded an unissued draft (the file is deleted; this line keeps the record)
|
|
30
|
+
* doc-archive { doc, archived } the PM archived (true) or brought back (false) an issued report. The file is never touched
|
|
27
31
|
* drafted { id, slot, path } a dashboard-sourced setup made its document (this is its last run)
|
|
28
32
|
* ask-start { ask, text, ws } the PM typed a request in the Ask box
|
|
29
33
|
* proposal { ask, proposal } the report-setup run filed ONE proposal (a second one revises it)
|
|
@@ -36,8 +40,8 @@
|
|
|
36
40
|
* finder { cadence?, sources? } the finder settings: weekly | off, and the four sources
|
|
37
41
|
* migrated { keys[], count } the one-time move of the dashboard schedules
|
|
38
42
|
*
|
|
39
|
-
* FOLD. { setups: Map id → setup, asks: Map, findings: Map, dismissed: { patterns, names }, finder: { cadence, sources }, finds: [], migrated }.
|
|
40
|
-
* A later line wins field by field; a `remove`
|
|
43
|
+
* FOLD. { setups: Map id → setup, removed: Map id → setup (deleted templates), archived: Set of doc ids, discarded: [{ doc, path, at }], asks: Map, findings: Map, dismissed: { patterns, names }, finder: { cadence, sources }, finds: [], migrated }.
|
|
44
|
+
* A later line wins field by field; a `remove` moves the setup to `removed` (its name stays on its documents); a line that does not parse, or names an unknown event, is skipped.
|
|
41
45
|
*
|
|
42
46
|
* THE BI-WEEKLY PARITY. lib/schedule-logic.js fires a bi-weekly schedule on the first matching weekday slot that is at least 12.5 days after
|
|
43
47
|
* lastRun. A schedule added on a Monday would therefore draft on the Wednesday two weeks out, whatever week the session is in. With an
|
|
@@ -56,7 +60,7 @@ const docSync = require('./doc-sync.js');
|
|
|
56
60
|
|
|
57
61
|
const LEDGER = 'report-setups.jsonl';
|
|
58
62
|
const EVENTS = Object.freeze(['setup', 'change', 'pause', 'resume', 'remove', 'drafted', 'ask-start', 'proposal', 'proposal-change', 'proposal-cancel', 'ask-end',
|
|
59
|
-
'find-start', 'find-end', 'finding', 'finding-dismiss', 'finder', 'migrated']);
|
|
63
|
+
'find-start', 'find-end', 'finding', 'finding-dismiss', 'finder', 'migrated', 'doc-discard', 'doc-archive']);
|
|
60
64
|
const OUTPUTS = Object.freeze(['google-slides', 'google-doc', 'google-sheets', 'confluence', 'pdf']);
|
|
61
65
|
const CADENCES = Object.freeze(['daily', 'weekly', 'bi-weekly', 'monthly']);
|
|
62
66
|
const DAYS = Object.freeze(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']);
|
|
@@ -210,7 +214,7 @@ function checkEvidence(list) {
|
|
|
210
214
|
const SETUP_FIELDS = ['name', 'purpose', 'audience', 'output', 'schedule', 'sources', 'sections', 'learned_from', 'fixes', 'product', 'def_sha'];
|
|
211
215
|
|
|
212
216
|
function fold(lines) {
|
|
213
|
-
const st = { setups: new Map(), asks: new Map(), findings: new Map(), dismissed: { patterns: new Set(), names: new Set() },
|
|
217
|
+
const st = { setups: new Map(), removed: new Map(), archived: new Set(), discarded: [], asks: new Map(), findings: new Map(), dismissed: { patterns: new Set(), names: new Set() },
|
|
214
218
|
finder: { cadence: 'weekly', sources: { ...FINDER_DEFAULTS } }, finds: [], migrated: null };
|
|
215
219
|
for (const l of lines || []) {
|
|
216
220
|
if (!isObj(l)) continue;
|
|
@@ -232,7 +236,9 @@ function fold(lines) {
|
|
|
232
236
|
}
|
|
233
237
|
case 'pause': { const s = st.setups.get(l.id); if (s) s.status = 'paused'; break; }
|
|
234
238
|
case 'resume': { const s = st.setups.get(l.id); if (s) { s.status = 'active'; if (l.last_run) s.last_run = l.last_run; } break; }
|
|
235
|
-
case 'remove': st.setups.delete(l.id); break;
|
|
239
|
+
case 'remove': { const s = st.setups.get(l.id); if (s) { st.removed.set(l.id, { ...s, status: 'removed', removed_at: l.at }); st.setups.delete(l.id); } break; }
|
|
240
|
+
case 'doc-discard': if (typeof l.doc === 'string') { st.discarded.push({ doc: l.doc, path: l.path || null, at: l.at }); st.archived.delete(l.doc); } break;
|
|
241
|
+
case 'doc-archive': if (typeof l.doc === 'string') { if (l.archived === false) st.archived.delete(l.doc); else st.archived.add(l.doc); } break;
|
|
236
242
|
case 'drafted': { const s = st.setups.get(l.id); if (s) { s.last_run = l.at; s.drafted.push({ slot: l.slot, at: l.at, path: l.path || null }); } break; }
|
|
237
243
|
case 'ask-start':
|
|
238
244
|
if (ASK_RE.test(String(l.ask || ''))) st.asks.set(l.ask, { id: l.ask, text: l.text, ws: l.ws || null, state: 'running', changed: false, proposal: null, error: null, started: l.at, changes: [] });
|
|
@@ -560,6 +566,42 @@ function remove(root, id, opts = {}) {
|
|
|
560
566
|
return { ok: true };
|
|
561
567
|
}
|
|
562
568
|
|
|
569
|
+
/** A template's schedule, as the PM changes it. { cadence: 'off' } is Schedule Off: the template pauses and keeps its schedule for later.
|
|
570
|
+
* Any other schedule is checked, changed through change(), and resumes a paused template. → { ok, setup } | { ok: false, status, error } */
|
|
571
|
+
function reschedule(root, id, schedule, opts = {}) {
|
|
572
|
+
if (isObj(schedule) && schedule.cadence === 'off') return setStatus(root, id, 'pause', opts);
|
|
573
|
+
const c = checkSchedule(schedule);
|
|
574
|
+
if (!c.ok) return refuse(400, c.error);
|
|
575
|
+
const r = change(root, id, { schedule: c.schedule }, opts);
|
|
576
|
+
if (!r.ok) return r;
|
|
577
|
+
return r.setup && r.setup.status === 'paused' ? setStatus(root, id, 'resume', opts) : r;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/** The report document at `rel` (repository-relative), as report-needs lists it, else null. */
|
|
581
|
+
function documentAt(root, rel) {
|
|
582
|
+
const list = require('./report-needs.js').reportsOf(root).reports || [];
|
|
583
|
+
return list.find((x) => x.path === String(rel || '')) || null;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/** Discard an unissued draft: the file is deleted and a doc-discard line keeps the record. An issued report is refused (409) and not touched. */
|
|
587
|
+
function discardDraft(root, rel, opts = {}) {
|
|
588
|
+
const d = documentAt(root, rel);
|
|
589
|
+
if (!d) return refuse(404, 'no such report document');
|
|
590
|
+
if (d.issued) return refuse(409, 'this report was issued, so it is kept for good. You can archive it instead');
|
|
591
|
+
try { fs.rmSync(path.join(path.resolve(String(root)), d.path)); } catch (e) { return refuse(500, 'the draft was not deleted: ' + String((e && e.message) || e).slice(0, 160)); }
|
|
592
|
+
append(ledgerFile(root), { ev: 'doc-discard', doc: `${d.cadence}/${d.slot}`, path: d.path }, { now: opts.now, by: opts.by });
|
|
593
|
+
return { ok: true, doc: `${d.cadence}/${d.slot}` };
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** Archive (archived true) or bring back (false) an issued report. Only a line is written; the file is never touched. A draft is refused (409). */
|
|
597
|
+
function archiveDoc(root, rel, archived, opts = {}) {
|
|
598
|
+
const d = documentAt(root, rel);
|
|
599
|
+
if (!d) return refuse(404, 'no such report document');
|
|
600
|
+
if (!d.issued) return refuse(409, 'only an issued report is archived. Discard a draft instead');
|
|
601
|
+
append(ledgerFile(root), { ev: 'doc-archive', doc: `${d.cadence}/${d.slot}`, archived: archived !== false }, { now: opts.now, by: opts.by });
|
|
602
|
+
return { ok: true, doc: `${d.cadence}/${d.slot}`, archived: archived !== false };
|
|
603
|
+
}
|
|
604
|
+
|
|
563
605
|
// ── the Ask box ──────────────────────────────────────────────────────────────────────────────────────
|
|
564
606
|
function askStart(file, { text, ws, by, now }) {
|
|
565
607
|
if (!oneLine(String(text || '').replace(/\s+/g, ' '), LIMITS.text)) return refuse(400, `say what report you want, in up to ${LIMITS.text} characters`);
|
|
@@ -760,6 +802,6 @@ module.exports = {
|
|
|
760
802
|
ledgerFile, stateDir, append, readLines, fold, stateOf, openFindings, isDismissed, slugOf, patternOf, checkProposal, checkEvidence, checkSchedule,
|
|
761
803
|
scheduleLabel, scheduleOf, firstSlot, initialLastRun, nextDraftAt, definitionText, writeDefinition, definitionsOf, definitionFile, shaOf,
|
|
762
804
|
fileScheduleStore, scheduleFor, registerSchedule, updateSchedule, unregisterSchedule,
|
|
763
|
-
setUp, change, pause, resume, remove, askStart, askChange, askCancel, askEnd, fileProposal, findStart, findEnd, fileFinding, dismissFinding, lookupFinding, setFinder,
|
|
805
|
+
setUp, change, pause, resume, remove, reschedule, discardDraft, archiveDoc, documentAt, askStart, askChange, askCancel, askEnd, fileProposal, findStart, findEnd, fileFinding, dismissFinding, lookupFinding, setFinder,
|
|
764
806
|
writeDocument, frameMarkdown, migrate, migratedKeys, dashboardKeys, dashTitle, keyOfSource, longDate, localDay,
|
|
765
807
|
};
|
|
@@ -14,9 +14,14 @@
|
|
|
14
14
|
* POST /api/report-setups/draft { ws, id } → { ok, drafted: { slot, path }, id } Draft it now (the next cycle)
|
|
15
15
|
* POST /api/report-setups/dismiss { ws, finding } → { ok } "Not a report"
|
|
16
16
|
* POST /api/report-setups/pause | resume { ws, id } → { ok, setup }
|
|
17
|
+
* POST /api/report-setups/edit { ws, id, schedule?, name?, audience?, output? } → { ok, setup } change a TEMPLATE (premium-reports-from-chat L1).
|
|
18
|
+
* schedule { cadence: 'off' } pauses it; any other schedule changes it and resumes it
|
|
19
|
+
* POST /api/report-setups/remove { ws, id } → { ok } delete a TEMPLATE: its schedule stops; its drafts and issued reports stay (L2)
|
|
17
20
|
* POST /api/report-setups/from-dashboard { ws, key, name, output, schedule, audience } → { ok, setup }
|
|
18
21
|
* POST /api/report-setups/finder { ws, cadence?, sources? } → { ok, finder }
|
|
19
22
|
* GET /api/report-documents?ws → { docs: [{ path, id, setup, name, slot, state: draft|issued, source, output, made_by: schedule|you|agent, v, copy }] }
|
|
23
|
+
* POST /api/report-documents/discard { ws, path } → { ok, doc } delete an UNISSUED draft; an issued report is 409 and untouched (L3)
|
|
24
|
+
* POST /api/report-documents/archive { ws, path, archived } → { ok, doc, archived } hide (or bring back) an ISSUED report; a draft is 409 (L4)
|
|
20
25
|
* GET /api/report-export?ws&path&fmt=pptx|xlsx|docx|csv → the file, Content-Disposition: attachment. PDF is printed by the browser: there is no route.
|
|
21
26
|
*
|
|
22
27
|
* WHO SETS A REPORT UP. Only a PM press does. Every POST passes pm-guard requirePagePress, and a request that carries an agent session header is
|
|
@@ -25,7 +30,8 @@
|
|
|
25
30
|
* those runs do, sends anything outward (D65: the factory is propose-only).
|
|
26
31
|
*
|
|
27
32
|
* A DOCUMENT is any <state>/reports/<cadence>/<slot>.md, one-offs included, joined to issues.jsonl. Its `id` is "<cadence>/<slot>"; `setup` is the
|
|
28
|
-
* recurring report that made it (the cadence folder is the setup id), or null for a one-off
|
|
33
|
+
* recurring report that made it (the cadence folder is the setup id), or null for a one-off or a deleted template (then `template_deleted` is true and
|
|
34
|
+
* `name` is still the template's). `archived` is true for an issued report the PM archived. AN ISSUED REPORT IS NEVER DELETED: no route removes one. `made_by` reads the file's own `made_by` line; with
|
|
29
35
|
* none, a setup's folder says "schedule" and a one-off says "you". `v` is 1 plus the saves the document sheet kept for the file. `copy` is the linked
|
|
30
36
|
* copy's state from lib/doc-sync-store.js (kind: the output's copy kind; state: none | in-step | pmos-ahead | copy-changed | not-checked).
|
|
31
37
|
*
|
|
@@ -48,7 +54,7 @@ const headless = require('./headless.js');
|
|
|
48
54
|
|
|
49
55
|
const text = (v) => (typeof v === 'string' ? v : '');
|
|
50
56
|
const bad = (status, error) => ({ status, body: { ok: false, error } });
|
|
51
|
-
const POSTS = ['ask', 'change', 'cancel', 'setup', 'draft', 'dismiss', 'pause', 'resume', 'from-dashboard', 'finder'];
|
|
57
|
+
const POSTS = ['ask', 'change', 'cancel', 'setup', 'draft', 'dismiss', 'pause', 'resume', 'from-dashboard', 'finder', 'edit', 'remove', 'documents/discard', 'documents/archive'];
|
|
52
58
|
const MADE_BY = ['schedule', 'you', 'agent'];
|
|
53
59
|
|
|
54
60
|
const runs = new Map(); // ask id → session id, for the report-setup runs this server started
|
|
@@ -108,10 +114,11 @@ function documentsOf(ctx, w) {
|
|
|
108
114
|
for (const x of r.reports) {
|
|
109
115
|
const fm = RN.frontmatter(path.join(abs, x.path));
|
|
110
116
|
const setup = st.setups.get(x.cadence) || null;
|
|
111
|
-
const
|
|
117
|
+
const gone = setup ? null : (st.removed.get(x.cadence) || null);
|
|
118
|
+
const output = fm.output || ((setup || gone) && (setup || gone).output) || null;
|
|
112
119
|
docs.push({
|
|
113
|
-
path: x.path, id: `${x.cadence}/${x.slot}`, setup: setup ? setup.id : null,
|
|
114
|
-
name: setup ? setup.name : (fm.title || x.cadence), slot: x.slot, state: x.issued ? 'issued' : 'draft',
|
|
120
|
+
path: x.path, id: `${x.cadence}/${x.slot}`, setup: setup ? setup.id : null, template_deleted: !!gone,
|
|
121
|
+
name: setup ? setup.name : gone ? gone.name : (fm.title || x.cadence), slot: x.slot, state: x.issued ? 'issued' : 'draft', archived: !!x.issued && st.archived.has(`${x.cadence}/${x.slot}`),
|
|
115
122
|
source: fm.source || (setup ? setup.source : 'work'), output,
|
|
116
123
|
made_by: MADE_BY.includes(fm.made_by) ? fm.made_by : (setup ? 'schedule' : 'you'),
|
|
117
124
|
v: 1 + (saves.get(x.path) || 0), copy: copyOf(linkFor(idx, x.path, output), docSync.copyKindOf(output)),
|
|
@@ -275,9 +282,10 @@ async function handle(req, res, url, ctx) {
|
|
|
275
282
|
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
276
283
|
const isDocs = p === '/api/report-documents' || p.startsWith('/api/report-documents/');
|
|
277
284
|
const isExport = p === '/api/report-export' || p.startsWith('/api/report-export/');
|
|
278
|
-
const
|
|
285
|
+
const docPost = p === '/api/report-documents/discard' || p === '/api/report-documents/archive';
|
|
286
|
+
const sub = docPost ? p.replace(/^\/api\/report-/, '') : isDocs ? 'documents' : isExport ? 'export' : p.replace(/^\/api\/report-setups\/?/, '');
|
|
279
287
|
|
|
280
|
-
if (isDocs || isExport || (sub === '' && req.method === 'GET')) {
|
|
288
|
+
if (!docPost && (isDocs || isExport || (sub === '' && req.method === 'GET'))) {
|
|
281
289
|
if (req.method !== 'GET') return send(bad(405, 'GET only'));
|
|
282
290
|
if ((isDocs && p !== '/api/report-documents') || (isExport && p !== '/api/report-export')) return send(bad(404, 'no such report route'));
|
|
283
291
|
const w = wsOf(ctx, url.searchParams.get('ws'));
|
|
@@ -397,6 +405,29 @@ async function handle(req, res, url, ctx) {
|
|
|
397
405
|
if (!r.ok) return fail(r);
|
|
398
406
|
return send({ status: 200, body: { ok: true, setup: setupOut(r.setup, new Date(), { reports: [] }, new Map(), root) } });
|
|
399
407
|
}
|
|
408
|
+
if (sub === 'edit') {
|
|
409
|
+
const id = text(body.id);
|
|
410
|
+
if (!RS.fold(RS.readLines(file)).setups.has(id)) return send(bad(404, 'no such report'));
|
|
411
|
+
let r = null;
|
|
412
|
+
const patch = {};
|
|
413
|
+
for (const k of ['name', 'audience', 'output']) if (typeof body[k] === 'string' && body[k].trim()) patch[k] = body[k].trim();
|
|
414
|
+
if (Object.keys(patch).length) { r = RS.change(root, id, patch, opts); if (!r.ok) return fail(r); }
|
|
415
|
+
if (body.schedule !== undefined) { r = RS.reschedule(root, id, body.schedule, opts); if (!r.ok) return fail(r); }
|
|
416
|
+
if (!r) return send(bad(400, 'say what to change: schedule, name, audience or output'));
|
|
417
|
+
const now = new Date();
|
|
418
|
+
return send({ status: 200, body: { ok: true, setup: setupOut(RS.fold(RS.readLines(file)).setups.get(id), now, documentsOf(ctx, w), copyIndex(root), root) } });
|
|
419
|
+
}
|
|
420
|
+
if (sub === 'remove') {
|
|
421
|
+
const r = RS.remove(root, text(body.id), opts);
|
|
422
|
+
if (!r.ok) return fail(r);
|
|
423
|
+
return send({ status: 200, body: { ok: true } });
|
|
424
|
+
}
|
|
425
|
+
if (sub === 'documents/discard' || sub === 'documents/archive') {
|
|
426
|
+
const r = sub === 'documents/discard' ? RS.discardDraft(root, text(body.path), opts) : RS.archiveDoc(root, text(body.path), body.archived !== false, opts);
|
|
427
|
+
if (!r.ok) return fail(r);
|
|
428
|
+
if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg();
|
|
429
|
+
return send({ status: 200, body: r });
|
|
430
|
+
}
|
|
400
431
|
if (sub === 'finder') {
|
|
401
432
|
const r = RS.setFinder(file, { cadence: body.cadence, sources: body.sources, by: g.actor });
|
|
402
433
|
if (!r.ok) return fail(r);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.388.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.388.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED