@skillre/dsh-plugin-work-dashboard 0.14.0 → 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/README.en.md +5 -8
- package/README.md +5 -8
- package/lib/client/api.d.ts +3 -3
- package/lib/client/api.js +1 -3
- package/lib/client.js +18 -16
- package/lib/index.js +35 -1
- package/lib/report-contract.d.ts +132 -2
- package/lib/report-contract.js +126 -0
- package/lib/report-form.d.ts +10 -1
- package/lib/report-form.js +26 -2
- package/lib/report-page.js +1989 -1170
- package/lib/report-style.d.ts +24 -13
- package/lib/report-style.js +367 -399
- package/lib/transport.d.ts +5 -5
- package/lib/transport.js +4 -3
- package/lib/types.d.ts +5 -3
- package/package.json +9 -16
- package/compatibility.json +0 -240
- package/docs/DESIGN-0.3.md +0 -122
- package/docs/DESIGN-1.0-/344/274/230/345/214/226/346/226/271/346/241/210.md +0 -212
- package/docs/DESIGN-/344/274/232/350/257/235/344/272/214-SuperAgent/344/270/216/344/273/223/345/272/223/346/224/271/351/200/240.md +0 -275
- package/docs/DESIGN-/345/257/274/345/207/272/350/241/250/345/215/225/351/207/215/350/256/276/350/256/241.md +0 -330
- package/docs/DESIGN-/346/217/220/351/206/222/344/270/216Gate/350/257/204/345/256/241.md +0 -518
- package/docs/DESIGN-/346/226/207/346/234/254/346/210/252/346/226/255.md +0 -565
- package/docs/DESIGN-/350/241/250/345/215/225/345/210/206/351/230/266/346/256/265.md +0 -420
- package/docs/LEDGER-REQUIREMENTS-v3.1.md +0 -367
- package/docs/PLAN-0.7-0.9.md +0 -230
- package/docs/PLAN-v3.1-adaptation.md +0 -237
- package/docs/POC-3.2-/350/277/233/345/261/225/345/245/221/347/272/246.md +0 -21
- package/docs/Super-Agent-3.2-/350/201/224/350/260/203/346/211/213/345/206/214.md +0 -38
- package/docs/TARGET-/345/217/260/350/264/246/344/273/223/345/272/223v3.1.md +0 -500
- package/docs//350/200/201Mac-SuperAgent/346/224/271/351/200/240/350/256/260/345/275/225-/347/254/254/344/272/214/346/255/245.md +0 -233
- package/lib/form.d.ts +0 -597
- package/lib/form.js +0 -3211
package/lib/form.d.ts
DELETED
|
@@ -1,597 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The v3 collection form: a self-contained HTML file a colleague can fill in.
|
|
3
|
-
*
|
|
4
|
-
* ## What changed from the v1 form
|
|
5
|
-
*
|
|
6
|
-
* The v1 generator modelled `why_customer_test` / `success_criteria` /
|
|
7
|
-
* `result` / `timeline` — all removed by v3. Shipping it would have handed
|
|
8
|
-
* colleagues a file the ledger can no longer read, so it was held back while
|
|
9
|
-
* this replacement was written, and then deleted.
|
|
10
|
-
*
|
|
11
|
-
* v3 is **progress-centred**: `gate0` says whether the project is worth doing,
|
|
12
|
-
* `plan` says how to win, and `progress[]` is the append-only history. The form
|
|
13
|
-
* therefore asks for exactly those three, and nothing else:
|
|
14
|
-
*
|
|
15
|
-
* 1. **G0** — the five prerequisites (four here; `tech_owner` is identity, which
|
|
16
|
-
* the blank form asks for too), each with a "why this matters" hint.
|
|
17
|
-
* 2. **Plan** — pain, expected recognition, 2–3 criteria, 3–5 scenarios, ≤3
|
|
18
|
-
* risks, edge. The counts are validated live because the gap rules enforce
|
|
19
|
-
* them and a colleague cannot know that.
|
|
20
|
-
* 3. **Progress** — one new entry, appended. The form never rewrites history.
|
|
21
|
-
*
|
|
22
|
-
* ## What is kept from v1 because it was hard-won
|
|
23
|
-
*
|
|
24
|
-
* - **One file, no server, no CDN.** Everything inlined, works offline.
|
|
25
|
-
* - **Autosave keyed by the project set**, not by a timestamp: regenerating the
|
|
26
|
-
* form for the same projects must find the same draft.
|
|
27
|
-
* - **Real YAML out**, via `yaml`'s own stringifier, so `name: 某某:试点` stays
|
|
28
|
-
* valid.
|
|
29
|
-
* - **One file per project** on download, so two colleagues never clobber a
|
|
30
|
-
* shared file.
|
|
31
|
-
*
|
|
32
|
-
* ## What it deliberately does NOT do
|
|
33
|
-
*
|
|
34
|
-
* It does not write to the ledger. The output is a `.yaml` the owner reviews and
|
|
35
|
-
* commits; submission stays a human-merged PR, which is the ledger's design.
|
|
36
|
-
*/
|
|
37
|
-
import YAML from 'yaml';
|
|
38
|
-
import type { PocRecord, ProgressRecord } from './types.js';
|
|
39
|
-
/** The four G0 prerequisites that live under `gate0` (the fifth is identity). */
|
|
40
|
-
export declare const G0_FIELDS: readonly ["why_customer", "why_us", "decision_chain", "post_poc_decision"];
|
|
41
|
-
/** One plan criterion, as the form edits it. */
|
|
42
|
-
export interface FormCriterion {
|
|
43
|
-
/** `cri-NN`; carried through so a returned form never renumbers the plan. */
|
|
44
|
-
id: string;
|
|
45
|
-
name: string;
|
|
46
|
-
metric: string;
|
|
47
|
-
baseline: string;
|
|
48
|
-
target: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* One plan scenario.
|
|
52
|
-
*
|
|
53
|
-
* v3.1 made this an object with a stable id, because evidence attaches by id:
|
|
54
|
-
* a form that renumbered scenarios would silently orphan every proof it had.
|
|
55
|
-
* `id` is therefore carried through untouched and is not user-editable.
|
|
56
|
-
*/
|
|
57
|
-
export interface FormScenario {
|
|
58
|
-
/** `scn-NN`; stable for the life of the project. */
|
|
59
|
-
id: string;
|
|
60
|
-
name: string;
|
|
61
|
-
goal: string;
|
|
62
|
-
}
|
|
63
|
-
/** One plan risk. */
|
|
64
|
-
export interface FormRisk {
|
|
65
|
-
name: string;
|
|
66
|
-
level: string;
|
|
67
|
-
mitigation: string;
|
|
68
|
-
}
|
|
69
|
-
/** One progress entry the form can append. */
|
|
70
|
-
export interface FormProgress {
|
|
71
|
-
seq: number | null;
|
|
72
|
-
date: string;
|
|
73
|
-
type: string;
|
|
74
|
-
/** v3.1: what moved compared to the previous round. Required. */
|
|
75
|
-
change: string;
|
|
76
|
-
goal: string;
|
|
77
|
-
/** `scn-NN` ids picked from the plan's scenarios. */
|
|
78
|
-
scenarioIds: string[];
|
|
79
|
-
/** `cri-NN` ids picked from the plan's criteria; independent of scenarios. */
|
|
80
|
-
criteriaIds: string[];
|
|
81
|
-
actual: string;
|
|
82
|
-
completion: string;
|
|
83
|
-
evidence: Array<{
|
|
84
|
-
title: string;
|
|
85
|
-
link: string;
|
|
86
|
-
type: string;
|
|
87
|
-
}>;
|
|
88
|
-
customer: {
|
|
89
|
-
synced_with: string;
|
|
90
|
-
feedback: string;
|
|
91
|
-
recognition: string;
|
|
92
|
-
};
|
|
93
|
-
gate3_1: string;
|
|
94
|
-
gate3_2: string;
|
|
95
|
-
next: {
|
|
96
|
-
goal: string;
|
|
97
|
-
owner: string;
|
|
98
|
-
deadline: string;
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* One already-recorded progress round, as the form shows it read-only.
|
|
103
|
-
*
|
|
104
|
-
* This exists because the form used to say only "已有 3 条进展" and never showed
|
|
105
|
-
* them. Two concrete failures came from that:
|
|
106
|
-
*
|
|
107
|
-
* - the colleague could not see what had already been reported, so the same
|
|
108
|
-
* round was filed twice under different wording;
|
|
109
|
-
* - the reviewer opening a returned form could not see the story the new round
|
|
110
|
-
* was supposed to continue, so "这次什么变了" was unverifiable.
|
|
111
|
-
*
|
|
112
|
-
* Read-only by construction: v3 history is append-only, and the form's job is to
|
|
113
|
-
* add a round, never to rewrite one.
|
|
114
|
-
*/
|
|
115
|
-
export interface FormHistoryEntry {
|
|
116
|
-
seq: number | null;
|
|
117
|
-
date: string;
|
|
118
|
-
type: string;
|
|
119
|
-
change: string;
|
|
120
|
-
actual: string;
|
|
121
|
-
completion: string;
|
|
122
|
-
/** Evidence titles, already flattened: the form only lists them. */
|
|
123
|
-
evidence: string[];
|
|
124
|
-
syncedWith: string;
|
|
125
|
-
recognition: string;
|
|
126
|
-
nextGoal: string;
|
|
127
|
-
nextOwner: string;
|
|
128
|
-
nextDeadline: string;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* The project shape the form edits.
|
|
132
|
-
*
|
|
133
|
-
* A flat, all-strings view of one `PocRecord` plus its pending progress entry.
|
|
134
|
-
* Flat because the generated page is plain JS with no schema awareness: the Host
|
|
135
|
-
* normalizes once here instead of repeating the walk in the browser.
|
|
136
|
-
*/
|
|
137
|
-
export interface FormProject {
|
|
138
|
-
pocId: string;
|
|
139
|
-
name: string;
|
|
140
|
-
system: string;
|
|
141
|
-
company: string;
|
|
142
|
-
department: string;
|
|
143
|
-
amountWan: string;
|
|
144
|
-
pocType: string;
|
|
145
|
-
owner: string;
|
|
146
|
-
sales: string;
|
|
147
|
-
techOwner: string;
|
|
148
|
-
execSponsor: string;
|
|
149
|
-
stage: string;
|
|
150
|
-
status: string;
|
|
151
|
-
stageSince: string;
|
|
152
|
-
gate0: {
|
|
153
|
-
why_customer: string;
|
|
154
|
-
why_us: string;
|
|
155
|
-
decision_chain: string;
|
|
156
|
-
post_poc_decision: string;
|
|
157
|
-
competitor: string;
|
|
158
|
-
conclusion: string;
|
|
159
|
-
reviewer: string;
|
|
160
|
-
reviewed_at: string;
|
|
161
|
-
};
|
|
162
|
-
plan: {
|
|
163
|
-
customer_pain: string;
|
|
164
|
-
expected_recognition: string;
|
|
165
|
-
our_edge: string;
|
|
166
|
-
criteria: FormCriterion[];
|
|
167
|
-
scenarios: FormScenario[];
|
|
168
|
-
risks: FormRisk[];
|
|
169
|
-
timeline_start: string;
|
|
170
|
-
timeline_end: string;
|
|
171
|
-
gate1_conclusion: string;
|
|
172
|
-
gate2_ready: string;
|
|
173
|
-
};
|
|
174
|
-
/** The entry this form adds; `null` in a blank form until the user fills it. */
|
|
175
|
-
progress: FormProgress;
|
|
176
|
-
/** How many entries the project already has (so `seq` can continue). */
|
|
177
|
-
existingProgressCount: number;
|
|
178
|
-
/**
|
|
179
|
-
* The recorded rounds, newest first, for the read-only history block.
|
|
180
|
-
*
|
|
181
|
-
* Capped by {@link HISTORY_LIMIT}: a project with forty rounds does not need
|
|
182
|
-
* all forty in a form whose job is to add the forty-first, and an uncapped list
|
|
183
|
-
* would push the fields the colleague must fill below the fold.
|
|
184
|
-
*/
|
|
185
|
-
history: FormHistoryEntry[];
|
|
186
|
-
/**
|
|
187
|
-
* The G4 conclusion block.
|
|
188
|
-
*
|
|
189
|
-
* It was missing entirely: the form could collect a progress round but not the
|
|
190
|
-
* one thing a G4 project exists to state — what was proved, what the customer
|
|
191
|
-
* accepted, and what business step follows. Every field is optional because
|
|
192
|
-
* only a G4 form shows them.
|
|
193
|
-
*/
|
|
194
|
-
outcome: {
|
|
195
|
-
achievement: string;
|
|
196
|
-
customer_recognition: string;
|
|
197
|
-
our_proof: string;
|
|
198
|
-
proved: string;
|
|
199
|
-
recognized: string;
|
|
200
|
-
next_business: string;
|
|
201
|
-
milestone: string;
|
|
202
|
-
businessOwner: string;
|
|
203
|
-
businessDeadline: string;
|
|
204
|
-
businessStatus: string;
|
|
205
|
-
overall: string;
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* What the colleague is here to do.
|
|
210
|
-
*
|
|
211
|
-
* Two orthogonal questions decide what the form asks, and conflating them is
|
|
212
|
-
* what made the old form a 20-field wall:
|
|
213
|
-
*
|
|
214
|
-
* - the **stage** says which fields are the subject (a G1 project is about the
|
|
215
|
-
* plan, a G3 project is about the proof);
|
|
216
|
-
* - the **intent** says how deep to go (registering a new project, filling in
|
|
217
|
-
* the current stage, or appending one round of progress).
|
|
218
|
-
*
|
|
219
|
-
* The same G2 project needs completely different forms for "first test" and
|
|
220
|
-
* "weekly sync", so a stage-only split would still force a colleague to scroll
|
|
221
|
-
* past everything they are not editing.
|
|
222
|
-
*/
|
|
223
|
-
export type FormIntent = 'new' | 'supplement' | 'progress';
|
|
224
|
-
/** The section groups a form can show. Order is reading order. */
|
|
225
|
-
export type FormSection = 'identity' | 'gate0' | 'plan' | 'gate12' | 'progress' | 'outcome';
|
|
226
|
-
/**
|
|
227
|
-
* Resolve what a form should ask, given the intent and the project's stage.
|
|
228
|
-
*
|
|
229
|
-
* Returns the editable sections (the subject) and the context sections (shown
|
|
230
|
-
* read-only so the colleague knows what they are adding to). An unknown stage
|
|
231
|
-
* falls back to G0's set: a project whose stage is unrecognised is, for form
|
|
232
|
-
* purposes, still being set up.
|
|
233
|
-
*/
|
|
234
|
-
export declare function resolveSections(intent: FormIntent, stage: string): {
|
|
235
|
-
editable: FormSection[];
|
|
236
|
-
context: FormSection[];
|
|
237
|
-
};
|
|
238
|
-
/** Options for one generation run. */
|
|
239
|
-
export interface FormOptions {
|
|
240
|
-
/** `fill` pre-fills from the ledger; `blank` is an empty new-project form. */
|
|
241
|
-
mode: 'fill' | 'blank';
|
|
242
|
-
/**
|
|
243
|
-
* What the colleague is doing. Defaults from `mode`: `blank` → `new`,
|
|
244
|
-
* `fill` → `supplement`. `progress` is the one-screen append form.
|
|
245
|
-
*/
|
|
246
|
-
intent?: FormIntent;
|
|
247
|
-
/** Projects to include; one blank project for `blank` mode. */
|
|
248
|
-
projects: FormProject[];
|
|
249
|
-
/** Clock injection so the generated header and default dates are testable. */
|
|
250
|
-
now?: Date;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Convert one ledger record into the form's project shape.
|
|
254
|
-
*
|
|
255
|
-
* Every field becomes a string or a list of strings. A missing block becomes an
|
|
256
|
-
* empty one rather than `undefined`, so the generated script never has to guard.
|
|
257
|
-
*/
|
|
258
|
-
export declare function projectForForm(record: PocRecord): FormProject;
|
|
259
|
-
/** How many recorded rounds the form lists read-only. */
|
|
260
|
-
export declare const HISTORY_LIMIT = 5;
|
|
261
|
-
/**
|
|
262
|
-
* Flatten the recorded rounds for the read-only history block.
|
|
263
|
-
*
|
|
264
|
-
* Newest first, because the round a colleague is about to continue is the newest
|
|
265
|
-
* one: reading it first is what makes "这次什么变了" answerable. The order is
|
|
266
|
-
* reversed rather than re-sorted by date because the ledger's own array order is
|
|
267
|
-
* the append order, and a hand-edited `date` must not reshuffle history.
|
|
268
|
-
*/
|
|
269
|
-
export declare function progressHistory(progress: readonly ProgressRecord[]): FormHistoryEntry[];
|
|
270
|
-
/** One empty progress entry, with `seq` continuing the existing count. */
|
|
271
|
-
export declare function blankProgress(existingCount: number): FormProgress;
|
|
272
|
-
/** The blank project a `blank`-mode form edits. */
|
|
273
|
-
export declare function blankProject(): FormProject;
|
|
274
|
-
/**
|
|
275
|
-
* Build the stable draft key.
|
|
276
|
-
*
|
|
277
|
-
* Sorting the ids makes the key independent of selection order, so the same set
|
|
278
|
-
* of projects always resumes the same draft — even if the user regenerates the
|
|
279
|
-
* form later. A blank form gets a constant key so its draft survives too.
|
|
280
|
-
*/
|
|
281
|
-
export declare function draftKeyFor(mode: 'fill' | 'blank', pocIds: readonly string[]): string;
|
|
282
|
-
/**
|
|
283
|
-
* Serialize one project back to the v3 YAML shape.
|
|
284
|
-
*
|
|
285
|
-
* `yaml`'s own stringifier rather than concatenation: a value containing `: `,
|
|
286
|
-
* `#`, quotes or a newline must be quoted correctly, which hand-built strings
|
|
287
|
-
* get wrong (`name: 某某:试点` produced invalid YAML in the reference tool).
|
|
288
|
-
*
|
|
289
|
-
* Empty plan/progress blocks are emitted as empty collections, not omitted: the
|
|
290
|
-
* ledger's parser tolerates absence, but a colleague reopening the file should
|
|
291
|
-
* see the shape they are expected to fill.
|
|
292
|
-
*
|
|
293
|
-
* **This is not the download format.** The form ships a change set (see
|
|
294
|
-
* {@link projectToChangeSet}); a complete file would have to carry the ledger's
|
|
295
|
-
* derived fields (`gate0.missing`, `priority`, scenario status), and those are
|
|
296
|
-
* owned by `tools/derive.mjs` — writing them here would either be wrong or be
|
|
297
|
-
* overwritten by CI. `projectToYaml` remains for tests and for a full-file
|
|
298
|
-
* preview.
|
|
299
|
-
*/
|
|
300
|
-
export declare function projectToYaml(project: FormProject): string;
|
|
301
|
-
/**
|
|
302
|
-
* One project's change set: what the colleague touched, and nothing else.
|
|
303
|
-
*
|
|
304
|
-
* ## Why a change set rather than a file
|
|
305
|
-
*
|
|
306
|
-
* A `projects/*.yaml` file carries three kinds of value: what a human wrote, what
|
|
307
|
-
* the ledger derives (`gate0.missing`, `gate0.complete`, `priority`, per-scenario
|
|
308
|
-
* status), and what the clock implies. Only the first belongs to a form. The
|
|
309
|
-
* derived ones are computed by `tools/derive.mjs` and asserted by CI, so a form
|
|
310
|
-
* that wrote them would either be wrong or be overwritten — and a form that
|
|
311
|
-
* omitted them would produce a file CI rejects.
|
|
312
|
-
*
|
|
313
|
-
* So the form ships only the human half, `poc-submit` merges it into the existing
|
|
314
|
-
* file (preserving everything it did not touch), and CI recomputes the rest.
|
|
315
|
-
*
|
|
316
|
-
* `schema_version` IS included even though it is a constant: the ledger refuses a
|
|
317
|
-
* file without it (`E-VERSION`), and a brand-new project has no existing file to
|
|
318
|
-
* inherit the stamp from.
|
|
319
|
-
*/
|
|
320
|
-
export interface FormChangeSet {
|
|
321
|
-
schema_version: string;
|
|
322
|
-
poc_id: string;
|
|
323
|
-
name: string;
|
|
324
|
-
org: {
|
|
325
|
-
system: string | null;
|
|
326
|
-
company: string | null;
|
|
327
|
-
department: string | null;
|
|
328
|
-
};
|
|
329
|
-
amount_wan: number | null;
|
|
330
|
-
poc_type: string | null;
|
|
331
|
-
owner: string | null;
|
|
332
|
-
sales: string | null;
|
|
333
|
-
tech_owner: string | null;
|
|
334
|
-
exec_sponsor: string | null;
|
|
335
|
-
stage: string;
|
|
336
|
-
status: string;
|
|
337
|
-
stage_since: string | null;
|
|
338
|
-
gate0: {
|
|
339
|
-
why_customer: string | null;
|
|
340
|
-
why_us: string | null;
|
|
341
|
-
decision_chain: string | null;
|
|
342
|
-
post_poc_decision: string | null;
|
|
343
|
-
competitor: string | null;
|
|
344
|
-
review: {
|
|
345
|
-
conclusion: string | null;
|
|
346
|
-
reviewer: string | null;
|
|
347
|
-
reviewed_at: string | null;
|
|
348
|
-
};
|
|
349
|
-
};
|
|
350
|
-
plan: {
|
|
351
|
-
customer_pain: string | null;
|
|
352
|
-
expected_recognition: string | null;
|
|
353
|
-
our_edge: string | null;
|
|
354
|
-
criteria: Array<Record<string, unknown>>;
|
|
355
|
-
scenarios: Array<Record<string, unknown>>;
|
|
356
|
-
risks: Array<Record<string, unknown>>;
|
|
357
|
-
timeline: {
|
|
358
|
-
start: string | null;
|
|
359
|
-
end: string | null;
|
|
360
|
-
};
|
|
361
|
-
gate1: {
|
|
362
|
-
conclusion: string | null;
|
|
363
|
-
};
|
|
364
|
-
gate2: {
|
|
365
|
-
ready: string | null;
|
|
366
|
-
};
|
|
367
|
-
};
|
|
368
|
-
/**
|
|
369
|
-
* The G4 conclusion block.
|
|
370
|
-
*
|
|
371
|
-
* It was missing from the change set while the form could edit it, which meant a
|
|
372
|
-
* G4 colleague filled in "我们证明了什么 / 客户认可了什么 / 下一步业务动作",
|
|
373
|
-
* downloaded the file, and every one of those answers was silently dropped. The
|
|
374
|
-
* form showed the block; the serializer never wrote it. A G4 form could not
|
|
375
|
-
* record the only thing a G4 form exists to record.
|
|
376
|
-
*/
|
|
377
|
-
outcome: {
|
|
378
|
-
achievement: string | null;
|
|
379
|
-
customer_recognition: string | null;
|
|
380
|
-
our_proof: string | null;
|
|
381
|
-
remaining_risks: string | null;
|
|
382
|
-
conclusion: {
|
|
383
|
-
proved: string | null;
|
|
384
|
-
recognized: string | null;
|
|
385
|
-
next_business: string | null;
|
|
386
|
-
};
|
|
387
|
-
business: {
|
|
388
|
-
milestone: string | null;
|
|
389
|
-
owner: string | null;
|
|
390
|
-
deadline: string | null;
|
|
391
|
-
status: string | null;
|
|
392
|
-
};
|
|
393
|
-
overall: string | null;
|
|
394
|
-
};
|
|
395
|
-
/** The rounds this form ADDS; empty when the colleague recorded none. */
|
|
396
|
-
progress: Array<Record<string, unknown>>;
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Build one project's change set from the form state.
|
|
400
|
-
*
|
|
401
|
-
* Blocks outside the intent's scope are emitted as `null` (or an empty list), which
|
|
402
|
-
* `poc-submit` treats as "not changed" and skips. A blank field inside a block that
|
|
403
|
-
* IS in scope means the same thing: the colleague did not touch it.
|
|
404
|
-
*
|
|
405
|
-
* @param project the form's own view of the project
|
|
406
|
-
* @param intent what the colleague was asked to do; defaults to `supplement`, the
|
|
407
|
-
* widest scope, so an older caller keeps its previous behaviour
|
|
408
|
-
* @param baseline the project's values when the form was generated. When given,
|
|
409
|
-
* a field equal to its seed is emitted as `null` — "I did not touch this".
|
|
410
|
-
*/
|
|
411
|
-
export declare function projectToChangeSet(project: FormProject, intent?: FormIntent, baseline?: FormProject): FormChangeSet;
|
|
412
|
-
/** The whole download: one change set per project, plus provenance. */
|
|
413
|
-
export interface FormChangeDocument {
|
|
414
|
-
schemaVersion: string;
|
|
415
|
-
generatedAt: string;
|
|
416
|
-
generatedBy: string;
|
|
417
|
-
intent: FormIntent;
|
|
418
|
-
changes: FormChangeSet[];
|
|
419
|
-
}
|
|
420
|
-
/** Build the document a colleague sends back. */
|
|
421
|
-
export declare function buildChangeDocument(options: {
|
|
422
|
-
projects: readonly FormProject[];
|
|
423
|
-
intent: FormIntent;
|
|
424
|
-
now?: Date;
|
|
425
|
-
/**
|
|
426
|
-
* The values each project had when the form was GENERATED.
|
|
427
|
-
*
|
|
428
|
-
* When supplied, only fields that differ from their seed are emitted — so a
|
|
429
|
-
* colleague who opened a form, changed one field and sent it back cannot revert
|
|
430
|
-
* the other twenty to the day the form was exported. See
|
|
431
|
-
* {@link projectToChangeSet}.
|
|
432
|
-
*/
|
|
433
|
-
baseline?: readonly FormProject[];
|
|
434
|
-
}): FormChangeDocument;
|
|
435
|
-
/** The enums, mirrored from `schemas/enums.yaml`. */
|
|
436
|
-
declare const ENUMS: {
|
|
437
|
-
pocType: string[];
|
|
438
|
-
stage: string[];
|
|
439
|
-
status: string[];
|
|
440
|
-
g0Conclusion: string[];
|
|
441
|
-
g1Conclusion: string[];
|
|
442
|
-
g2Ready: string[];
|
|
443
|
-
recognition: string[];
|
|
444
|
-
progressType: string[];
|
|
445
|
-
progressChange: string[];
|
|
446
|
-
completion: string[];
|
|
447
|
-
riskLevel: string[];
|
|
448
|
-
gate3_1: string[];
|
|
449
|
-
gate3_2: string[];
|
|
450
|
-
evidenceType: string[];
|
|
451
|
-
system: string[];
|
|
452
|
-
achievement: string[];
|
|
453
|
-
businessStatus: string[];
|
|
454
|
-
};
|
|
455
|
-
/**
|
|
456
|
-
* The schema generation this form emits.
|
|
457
|
-
*
|
|
458
|
-
* Stamped into every generated page so a returned form can be checked against
|
|
459
|
-
* the schema that will read it. There is deliberately **no older-shape
|
|
460
|
-
* fallback**: the ledger declares one shape version and its validator rejects
|
|
461
|
-
* anything else outright (`E-VERSION`). A tolerant reader here would only move
|
|
462
|
-
* that failure later — to a point where the colleague already believes their
|
|
463
|
-
* work was recorded.
|
|
464
|
-
*/
|
|
465
|
-
export declare const FORM_SCHEMA_VERSION = "3.1";
|
|
466
|
-
/**
|
|
467
|
-
* The stamp a pre-v3.1 form carries.
|
|
468
|
-
*
|
|
469
|
-
* A named constant only so the refusal message can name it. This is not a
|
|
470
|
-
* supported shape: nothing parses it, nothing converts it, and importing one is
|
|
471
|
-
* refused rather than half-applied.
|
|
472
|
-
*/
|
|
473
|
-
export declare const LEGACY_FORM_SCHEMA_VERSION = "3.0";
|
|
474
|
-
/** The state the generated page boots from. */
|
|
475
|
-
export interface FormPayload {
|
|
476
|
-
mode: 'fill' | 'blank';
|
|
477
|
-
/** What the colleague is doing; decides how much of the page is editable. */
|
|
478
|
-
intent: FormIntent;
|
|
479
|
-
/** The schema this page writes. Absent means a pre-v3.1 form. */
|
|
480
|
-
schemaVersion: string;
|
|
481
|
-
generatedAt: string;
|
|
482
|
-
today: string;
|
|
483
|
-
projects: FormProject[];
|
|
484
|
-
/**
|
|
485
|
-
* Each project's values at generation time, index-aligned with `projects`.
|
|
486
|
-
*
|
|
487
|
-
* The page compares against this before emitting a change set, so a field the
|
|
488
|
-
* colleague never touched is sent as "unchanged" rather than as its stale
|
|
489
|
-
* pre-filled value.
|
|
490
|
-
*/
|
|
491
|
-
baseline: FormProject[];
|
|
492
|
-
/**
|
|
493
|
-
* Per-project section resolution, index-aligned with `projects`.
|
|
494
|
-
*
|
|
495
|
-
* Resolved on the Host rather than in the page because the mapping is a
|
|
496
|
-
* statement about the ledger's own structure, and the browser has no way to
|
|
497
|
-
* check it. Sending it also keeps the payload inspectable: reading the JSON
|
|
498
|
-
* tells you exactly what the page will let you edit.
|
|
499
|
-
*/
|
|
500
|
-
sections: Array<{
|
|
501
|
-
editable: FormSection[];
|
|
502
|
-
context: FormSection[];
|
|
503
|
-
}>;
|
|
504
|
-
draftKey: string;
|
|
505
|
-
enums: typeof ENUMS;
|
|
506
|
-
/** The G0 fields, in schema order, with their prompt text. */
|
|
507
|
-
g0Fields: Array<{
|
|
508
|
-
key: string;
|
|
509
|
-
label: string;
|
|
510
|
-
hint: string;
|
|
511
|
-
}>;
|
|
512
|
-
/**
|
|
513
|
-
* The returned page's stylesheet.
|
|
514
|
-
*
|
|
515
|
-
* It is shipped in the payload rather than referenced from the page script
|
|
516
|
-
* because the page script is generated code with no module scope: it cannot see
|
|
517
|
-
* a Host constant, and a first attempt that assumed otherwise threw
|
|
518
|
-
* "RETURN_CSS is not defined" at the moment a colleague clicked the button.
|
|
519
|
-
*/
|
|
520
|
-
returnCss: string;
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* Generate the complete HTML form.
|
|
524
|
-
*
|
|
525
|
-
* The returned string is the whole document: no external stylesheet, script,
|
|
526
|
-
* font or image reference.
|
|
527
|
-
*/
|
|
528
|
-
export declare function buildFormHtml(options: FormOptions): string;
|
|
529
|
-
/** A file name for the generated form. */
|
|
530
|
-
export declare function formFileName(options: {
|
|
531
|
-
mode: 'fill' | 'blank';
|
|
532
|
-
pocIds: readonly string[];
|
|
533
|
-
now?: Date;
|
|
534
|
-
}): string;
|
|
535
|
-
/** The file name a colleague should save one project's YAML under. */
|
|
536
|
-
export declare function yamlFileName(project: FormProject, now?: Date): string;
|
|
537
|
-
/** Re-export the YAML library's parse for the round-trip test. */
|
|
538
|
-
export { YAML };
|
|
539
|
-
/**
|
|
540
|
-
* Whether a returned form was generated by this schema generation.
|
|
541
|
-
*
|
|
542
|
-
* `poc-export` produces a standalone HTML file that colleagues fill in offline,
|
|
543
|
-
* so **old copies keep circulating** long after the schema moves. A pre-v3.1
|
|
544
|
-
* form carries `progress[].items` and a string array of scenarios; reading it as
|
|
545
|
-
* v3.1 would drop every scenario and criterion reference without an error, and
|
|
546
|
-
* the ledger's whole proof chain hangs off those ids.
|
|
547
|
-
*
|
|
548
|
-
* So this is a hard gate rather than a tolerant reader: a stale form is refused
|
|
549
|
-
* with an explanation, not silently half-imported. There is no conversion path
|
|
550
|
-
* and none is planned — the ledger itself rejects any other shape version.
|
|
551
|
-
*/
|
|
552
|
-
export interface FormCompatibility {
|
|
553
|
-
compatible: boolean;
|
|
554
|
-
/** The schema the file declares, or empty when it predates the stamp. */
|
|
555
|
-
declared: string;
|
|
556
|
-
/** A message safe to show the person who just filled the form in. */
|
|
557
|
-
reason: string;
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Check a parsed form payload against {@link FORM_SCHEMA_VERSION}.
|
|
561
|
-
*
|
|
562
|
-
* Accepts the raw parsed object rather than a typed payload, because the whole
|
|
563
|
-
* point is to inspect a document whose shape may be from an older generation.
|
|
564
|
-
*/
|
|
565
|
-
export declare function checkFormCompatibility(payload: unknown): FormCompatibility;
|
|
566
|
-
/** The element id the returned page carries its change set in. */
|
|
567
|
-
export declare const RETURN_DATA_ID = "poc-return-data";
|
|
568
|
-
/** What reading a returned file produced. */
|
|
569
|
-
export interface ReturnReadResult {
|
|
570
|
-
/** The change document, or `null` when the file could not be read. */
|
|
571
|
-
document: FormChangeDocument | null;
|
|
572
|
-
/** A message safe to show the person who sent the file back. */
|
|
573
|
-
reason: string;
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Read a returned form — either the `.html` this generator emits or a `.json`
|
|
577
|
-
* change set — back into a change document.
|
|
578
|
-
*
|
|
579
|
-
* ## Why both formats, and why HTML is the default
|
|
580
|
-
*
|
|
581
|
-
* The documented workflow is "colleague fills it in and sends the HTML back on
|
|
582
|
-
* WeChat". That only works if the returned HTML actually carries the answers, so
|
|
583
|
-
* {@link buildFormHtml}'s page writes a `RETURN_DATA_ID` script block holding the
|
|
584
|
-
* exact change set. The same page is also readable by a human: it renders the
|
|
585
|
-
* answers as formatted HTML, so the person who receives it can see what was
|
|
586
|
-
* submitted before handing it to DSH.
|
|
587
|
-
*
|
|
588
|
-
* The `.json` path is kept because it is stricter and smaller, and because forms
|
|
589
|
-
* already in circulation emit it.
|
|
590
|
-
*
|
|
591
|
-
* ## Safety
|
|
592
|
-
*
|
|
593
|
-
* The HTML is never executed and never given to a DOM parser: the block is found
|
|
594
|
-
* with a string search and the slice is handed to `JSON.parse`. Nothing in the
|
|
595
|
-
* returned file can run.
|
|
596
|
-
*/
|
|
597
|
-
export declare function readReturnDocument(input: string): ReturnReadResult;
|