@skillre/dsh-plugin-work-dashboard 0.10.1 → 0.11.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/lib/form.d.ts CHANGED
@@ -146,11 +146,67 @@ export interface FormProject {
146
146
  progress: FormProgress;
147
147
  /** How many entries the project already has (so `seq` can continue). */
148
148
  existingProgressCount: number;
149
+ /**
150
+ * The G4 conclusion block.
151
+ *
152
+ * It was missing entirely: the form could collect a progress round but not the
153
+ * one thing a G4 project exists to state — what was proved, what the customer
154
+ * accepted, and what business step follows. Every field is optional because
155
+ * only a G4 form shows them.
156
+ */
157
+ outcome: {
158
+ achievement: string;
159
+ customer_recognition: string;
160
+ our_proof: string;
161
+ proved: string;
162
+ recognized: string;
163
+ next_business: string;
164
+ milestone: string;
165
+ businessOwner: string;
166
+ businessDeadline: string;
167
+ businessStatus: string;
168
+ overall: string;
169
+ };
149
170
  }
171
+ /**
172
+ * What the colleague is here to do.
173
+ *
174
+ * Two orthogonal questions decide what the form asks, and conflating them is
175
+ * what made the old form a 20-field wall:
176
+ *
177
+ * - the **stage** says which fields are the subject (a G1 project is about the
178
+ * plan, a G3 project is about the proof);
179
+ * - the **intent** says how deep to go (registering a new project, filling in
180
+ * the current stage, or appending one round of progress).
181
+ *
182
+ * The same G2 project needs completely different forms for "first test" and
183
+ * "weekly sync", so a stage-only split would still force a colleague to scroll
184
+ * past everything they are not editing.
185
+ */
186
+ export type FormIntent = 'new' | 'supplement' | 'progress';
187
+ /** The section groups a form can show. Order is reading order. */
188
+ export type FormSection = 'identity' | 'gate0' | 'plan' | 'gate12' | 'progress' | 'outcome';
189
+ /**
190
+ * Resolve what a form should ask, given the intent and the project's stage.
191
+ *
192
+ * Returns the editable sections (the subject) and the context sections (shown
193
+ * read-only so the colleague knows what they are adding to). An unknown stage
194
+ * falls back to G0's set: a project whose stage is unrecognised is, for form
195
+ * purposes, still being set up.
196
+ */
197
+ export declare function resolveSections(intent: FormIntent, stage: string): {
198
+ editable: FormSection[];
199
+ context: FormSection[];
200
+ };
150
201
  /** Options for one generation run. */
151
202
  export interface FormOptions {
152
203
  /** `fill` pre-fills from the ledger; `blank` is an empty new-project form. */
153
204
  mode: 'fill' | 'blank';
205
+ /**
206
+ * What the colleague is doing. Defaults from `mode`: `blank` → `new`,
207
+ * `fill` → `supplement`. `progress` is the one-screen append form.
208
+ */
209
+ intent?: FormIntent;
154
210
  /** Projects to include; one blank project for `blank` mode. */
155
211
  projects: FormProject[];
156
212
  /** Clock injection so the generated header and default dates are testable. */
@@ -185,8 +241,107 @@ export declare function draftKeyFor(mode: 'fill' | 'blank', pocIds: readonly str
185
241
  * Empty plan/progress blocks are emitted as empty collections, not omitted: the
186
242
  * ledger's parser tolerates absence, but a colleague reopening the file should
187
243
  * see the shape they are expected to fill.
244
+ *
245
+ * **This is not the download format.** The form ships a change set (see
246
+ * {@link projectToChangeSet}); a complete file would have to carry the ledger's
247
+ * derived fields (`gate0.missing`, `priority`, scenario status), and those are
248
+ * owned by `tools/derive.mjs` — writing them here would either be wrong or be
249
+ * overwritten by CI. `projectToYaml` remains for tests and for a full-file
250
+ * preview.
188
251
  */
189
252
  export declare function projectToYaml(project: FormProject): string;
253
+ /**
254
+ * One project's change set: what the colleague touched, and nothing else.
255
+ *
256
+ * ## Why a change set rather than a file
257
+ *
258
+ * A `projects/*.yaml` file carries three kinds of value: what a human wrote, what
259
+ * the ledger derives (`gate0.missing`, `gate0.complete`, `priority`, per-scenario
260
+ * status), and what the clock implies. Only the first belongs to a form. The
261
+ * derived ones are computed by `tools/derive.mjs` and asserted by CI, so a form
262
+ * that wrote them would either be wrong or be overwritten — and a form that
263
+ * omitted them would produce a file CI rejects.
264
+ *
265
+ * So the form ships only the human half, `poc-submit` merges it into the existing
266
+ * file (preserving everything it did not touch), and CI recomputes the rest.
267
+ *
268
+ * `schema_version` IS included even though it is a constant: the ledger refuses a
269
+ * file without it (`E-VERSION`), and a brand-new project has no existing file to
270
+ * inherit the stamp from.
271
+ */
272
+ export interface FormChangeSet {
273
+ schema_version: string;
274
+ poc_id: string;
275
+ name: string;
276
+ org: {
277
+ system: string | null;
278
+ company: string | null;
279
+ department: string | null;
280
+ };
281
+ amount_wan: number | null;
282
+ poc_type: string | null;
283
+ owner: string | null;
284
+ sales: string | null;
285
+ tech_owner: string | null;
286
+ exec_sponsor: string | null;
287
+ stage: string;
288
+ status: string;
289
+ stage_since: string | null;
290
+ gate0: {
291
+ why_customer: string | null;
292
+ why_us: string | null;
293
+ decision_chain: string | null;
294
+ post_poc_decision: string | null;
295
+ competitor: string | null;
296
+ review: {
297
+ conclusion: string | null;
298
+ reviewer: string | null;
299
+ reviewed_at: string | null;
300
+ };
301
+ };
302
+ plan: {
303
+ customer_pain: string | null;
304
+ expected_recognition: string | null;
305
+ our_edge: string | null;
306
+ criteria: Array<Record<string, unknown>>;
307
+ scenarios: Array<Record<string, unknown>>;
308
+ risks: Array<Record<string, unknown>>;
309
+ timeline: {
310
+ start: string | null;
311
+ end: string | null;
312
+ };
313
+ gate1: {
314
+ conclusion: string | null;
315
+ };
316
+ gate2: {
317
+ ready: string | null;
318
+ };
319
+ };
320
+ /** The rounds this form ADDS; empty when the colleague recorded none. */
321
+ progress: Array<Record<string, unknown>>;
322
+ }
323
+ /**
324
+ * Build one project's change set from the form state.
325
+ *
326
+ * Every field the form can edit appears, so `poc-submit` can apply the whole
327
+ * object with `setIfPresent` semantics: a blank field means "I did not change
328
+ * this", which the merge step must not read as "delete it".
329
+ */
330
+ export declare function projectToChangeSet(project: FormProject): FormChangeSet;
331
+ /** The whole download: one change set per project, plus provenance. */
332
+ export interface FormChangeDocument {
333
+ schemaVersion: string;
334
+ generatedAt: string;
335
+ generatedBy: string;
336
+ intent: FormIntent;
337
+ changes: FormChangeSet[];
338
+ }
339
+ /** Build the document a colleague sends back. */
340
+ export declare function buildChangeDocument(options: {
341
+ projects: readonly FormProject[];
342
+ intent: FormIntent;
343
+ now?: Date;
344
+ }): FormChangeDocument;
190
345
  /** The enums, mirrored from `schemas/enums.yaml`. */
191
346
  declare const ENUMS: {
192
347
  pocType: string[];
@@ -204,26 +359,50 @@ declare const ENUMS: {
204
359
  gate3_2: string[];
205
360
  evidenceType: string[];
206
361
  system: string[];
362
+ achievement: string[];
363
+ businessStatus: string[];
207
364
  };
208
365
  /**
209
366
  * The schema generation this form emits.
210
367
  *
211
368
  * Stamped into every generated page so a returned form can be checked against
212
- * the schema that will read it. A v3.0 form uses `items` and string scenarios;
213
- * importing it as v3.1 would silently drop every scenario and criterion
214
- * reference, which is exactly the failure this constant exists to catch.
369
+ * the schema that will read it. There is deliberately **no older-shape
370
+ * fallback**: the ledger declares one shape version and its validator rejects
371
+ * anything else outright (`E-VERSION`). A tolerant reader here would only move
372
+ * that failure later — to a point where the colleague already believes their
373
+ * work was recorded.
215
374
  */
216
375
  export declare const FORM_SCHEMA_VERSION = "3.1";
217
- /** The schema generation a v3.0 form emitted; recognised only to reject it. */
376
+ /**
377
+ * The stamp a pre-v3.1 form carries.
378
+ *
379
+ * A named constant only so the refusal message can name it. This is not a
380
+ * supported shape: nothing parses it, nothing converts it, and importing one is
381
+ * refused rather than half-applied.
382
+ */
218
383
  export declare const LEGACY_FORM_SCHEMA_VERSION = "3.0";
219
384
  /** The state the generated page boots from. */
220
385
  export interface FormPayload {
221
386
  mode: 'fill' | 'blank';
387
+ /** What the colleague is doing; decides how much of the page is editable. */
388
+ intent: FormIntent;
222
389
  /** The schema this page writes. Absent means a pre-v3.1 form. */
223
390
  schemaVersion: string;
224
391
  generatedAt: string;
225
392
  today: string;
226
393
  projects: FormProject[];
394
+ /**
395
+ * Per-project section resolution, index-aligned with `projects`.
396
+ *
397
+ * Resolved on the Host rather than in the page because the mapping is a
398
+ * statement about the ledger's own structure, and the browser has no way to
399
+ * check it. Sending it also keeps the payload inspectable: reading the JSON
400
+ * tells you exactly what the page will let you edit.
401
+ */
402
+ sections: Array<{
403
+ editable: FormSection[];
404
+ context: FormSection[];
405
+ }>;
227
406
  draftKey: string;
228
407
  enums: typeof ENUMS;
229
408
  /** The G0 fields, in schema order, with their prompt text. */
@@ -254,13 +433,14 @@ export { YAML };
254
433
  * Whether a returned form was generated by this schema generation.
255
434
  *
256
435
  * `poc-export` produces a standalone HTML file that colleagues fill in offline,
257
- * so **old copies keep circulating** long after the schema moves. The v3.0 form
258
- * carries `progress[].items` and a string array of scenarios; reading it as v3.1
259
- * would drop every scenario and criterion reference without an error, and the
260
- * ledger's whole proof chain hangs off those ids.
436
+ * so **old copies keep circulating** long after the schema moves. A pre-v3.1
437
+ * form carries `progress[].items` and a string array of scenarios; reading it as
438
+ * v3.1 would drop every scenario and criterion reference without an error, and
439
+ * the ledger's whole proof chain hangs off those ids.
261
440
  *
262
441
  * So this is a hard gate rather than a tolerant reader: a stale form is refused
263
- * with an explanation, not silently half-imported.
442
+ * with an explanation, not silently half-imported. There is no conversion path
443
+ * and none is planned — the ledger itself rejects any other shape version.
264
444
  */
265
445
  export interface FormCompatibility {
266
446
  compatible: boolean;