@opencxh/domain 1.233.1 → 1.235.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.
@@ -1,153 +1,12 @@
1
1
  /**
2
- * The blocks an artifact is built from.
2
+ * The artifact vocabulary, under its original names.
3
3
  *
4
- * This is a **document** vocabulary, not the row vocabulary of the timeline
5
- * (`../activity/blocks.ts`). Those two look alike and deliberately are not: a timeline row sits
6
- * among dozens of others and may therefore hold only ten blocks, has no paragraphs or headings,
7
- * and its text nodes are *paths* into an activity. An artifact is a document — it has headings,
8
- * paragraphs, a table and a KPI row, and its text is just text.
4
+ * The blocks moved to `platform/document-blocks.ts` when a second and third writer appeared: a
5
+ * knowledge base article and a quote are the same list of blocks, and a vocabulary with three
6
+ * consumers is a platform contract rather than one entity's model. See
7
+ * `plans/DOCUMENTS-2026-09-14.md`.
9
8
  *
10
- * What is carried over is that file's *discipline*, because it proved itself:
11
- *
12
- * - an optional `block_id`, so a block can be pointed at without rewriting the whole document;
13
- * - {@link normalizeArtifactBlocks} **prunes instead of refusing** — one bad block must not make a
14
- * whole document disappear — and reports *every* drop, because silent pruning makes "why is my
15
- * table missing?" unanswerable;
16
- * - unknown block types are skipped, so a newer writer can coexist with an older renderer;
17
- * - semantic tones only, no free colours, so dark mode keeps working.
18
- *
19
- * **The inert boundary.** An artifact is stored data, not a program, and that is a property of the
20
- * *model* rather than the outcome of a filter afterwards. Block texts are **markdown, never
21
- * HTML**: the renderer hands them to ui-kit's `RichText` with `as="markdown"`, and that branch
22
- * (react-markdown + remark-gfm) emits no raw HTML, so a `<script>` in the text reaches the screen
23
- * as literal characters. Hence no tag stripping here — that would break "a < b" and win nothing.
24
- * What *is* stripped is the only thing markdown itself makes dangerous: a link to a scheme outside
25
- * {@link ALLOWED_LINK_SCHEMES}, and inline images. See {@link sanitizeInline}.
26
- */
27
- /** Semantic colour. No free colours, so dark mode and the tokens keep working. */
28
- export type ArtifactTone = "info" | "success" | "warning" | "destructive";
29
- /**
30
- * One line in a list.
31
- *
32
- * `lead` exists because a findings list puts its point up front in bold ("**Yealink outages
33
- * dominate.** 14 of the 184 calls..."). Without a field of its own the writer has to invent
34
- * markdown asterisks in a place where the formatting is supposed to be fixed — and then the text
35
- * shows whether someone forgot.
36
- */
37
- export interface ArtifactListItem {
38
- lead?: string;
39
- text: string;
40
- }
41
- export interface ArtifactTableColumn {
42
- label: string;
43
- /** Numbers right. Left by default. */
44
- align?: "left" | "right";
45
- }
46
- export interface ArtifactKpiItem {
47
- /** Already formatted by the writer ("1u 12m", "184", "-12%"). */
48
- value: string;
49
- label: string;
50
- /** Only set when this number stands out; a tint on every tile is wallpaper. */
51
- tone?: ArtifactTone;
52
- }
53
- export type ArtifactBlock = {
54
- block_id?: string;
55
- type: "heading";
56
- level: 1 | 2 | 3;
57
- text: string;
58
- } | {
59
- block_id?: string;
60
- type: "paragraph";
61
- text: string;
62
- } | {
63
- block_id?: string;
64
- type: "list";
65
- style: "bulleted" | "numbered";
66
- items: ArtifactListItem[];
67
- } | {
68
- block_id?: string;
69
- type: "quote";
70
- text: string;
71
- } | {
72
- block_id?: string;
73
- type: "code";
74
- lang?: string;
75
- text: string;
76
- } | {
77
- block_id?: string;
78
- type: "divider";
79
- } | {
80
- block_id?: string;
81
- type: "table";
82
- columns: ArtifactTableColumn[];
83
- rows: string[][];
84
- caption?: string;
85
- } | {
86
- block_id?: string;
87
- type: "kpi";
88
- items: ArtifactKpiItem[];
89
- } | {
90
- block_id?: string;
91
- type: "callout";
92
- tone: ArtifactTone;
93
- title?: string;
94
- text: string;
95
- };
96
- export type ArtifactBlockType = ArtifactBlock["type"];
97
- /**
98
- * Ceilings. Wider than the timeline (which sits at 10 blocks) because this is a document, but not
99
- * unlimited: the body travels as JSON through the same invoke channel as everything else and ends
100
- * up in a single column.
101
- */
102
- export declare const ARTIFACT_MAX_BLOCKS = 200;
103
- export declare const ARTIFACT_MAX_LIST_ITEMS = 100;
104
- export declare const ARTIFACT_MAX_TABLE_ROWS = 200;
105
- export declare const ARTIFACT_MAX_TABLE_COLUMNS = 12;
106
- export declare const ARTIFACT_MAX_KPI_ITEMS = 4;
107
- export declare const ARTIFACT_MAX_TEXT_LEN = 4000;
108
- export declare const ARTIFACT_MAX_CELL_LEN = 500;
109
- /** Hard upper bound on the serialized body. */
110
- export declare const ARTIFACT_MAX_BODY_BYTES: number;
111
- /**
112
- * Schemes a link in an artifact may carry.
113
- *
114
- * `javascript:` and `data:` are not among them, and that is the entire reason this list exists:
115
- * those two are the only way markdown gets something executable into the document.
116
- */
117
- export declare const ALLOWED_LINK_SCHEMES: readonly ["http:", "https:", "mailto:", "tel:"];
118
- /**
119
- * Makes one piece of inline markdown safe while keeping it readable.
120
- *
121
- * Three interventions, in this order:
122
- *
123
- * 1. **Inline images disappear**, with their alt text as replacement. This version has no `image`
124
- * block precisely because the product has no publicly loadable URL (bytes come through the
125
- * invoke channel as base64). An inline `![](…)` would open that gap through the back door and
126
- * tell an external host who opens the document.
127
- * 2. **Links to a forbidden scheme become plain text** — the label stays. Dropping the label would
128
- * break the sentence over the link.
129
- * 3. **Reference definitions to a forbidden scheme disappear.** Without this step `[click][x]`
130
- * with `[x]: javascript:…` below it escapes step 2.
131
- */
132
- export declare function sanitizeInline(text: string): string;
133
- /**
134
- * Prunes a written block list down to something a renderer can safely draw.
135
- *
136
- * Always returns **new** objects: the input comes from a model or an API client, and the sanitized
137
- * text must not leak back into the original.
138
- *
139
- * `onDrop` should log or report back to the writer — a tool losing its table because it sent zero
140
- * columns has to be able to hear that.
141
- */
142
- export declare function normalizeArtifactBlocks(blocks: unknown, onDrop?: (reason: string) => void): ArtifactBlock[];
143
- /** How many bytes this body costs on the wire. */
144
- export declare function artifactBodyBytes(blocks: ArtifactBlock[]): number;
145
- /**
146
- * A short summary of what is inside, for the thumbnail on a card and for what the assistant sees
147
- * when it wants to update an artifact without reading the whole body.
9
+ * These aliases exist so `apps/storage` and the AI tools keep compiling unchanged. New code reads
10
+ * the document names.
148
11
  */
149
- export declare function artifactOutline(blocks: ArtifactBlock[]): {
150
- blocks: number;
151
- types: ArtifactBlockType[];
152
- headings: string[];
153
- };
12
+ export { ALLOWED_LINK_SCHEMES, DOCUMENT_MAX_BLOCKS as ARTIFACT_MAX_BLOCKS, DOCUMENT_MAX_BODY_BYTES as ARTIFACT_MAX_BODY_BYTES, DOCUMENT_MAX_CELL_LEN as ARTIFACT_MAX_CELL_LEN, DOCUMENT_MAX_KPI_ITEMS as ARTIFACT_MAX_KPI_ITEMS, DOCUMENT_MAX_LIST_ITEMS as ARTIFACT_MAX_LIST_ITEMS, DOCUMENT_MAX_TABLE_COLUMNS as ARTIFACT_MAX_TABLE_COLUMNS, DOCUMENT_MAX_TABLE_ROWS as ARTIFACT_MAX_TABLE_ROWS, DOCUMENT_MAX_TEXT_LEN as ARTIFACT_MAX_TEXT_LEN, type DocumentBlock as ArtifactBlock, type DocumentBlockType as ArtifactBlockType, type DocumentKpiItem as ArtifactKpiItem, type DocumentListItem as ArtifactListItem, type DocumentTableColumn as ArtifactTableColumn, type DocumentTone as ArtifactTone, documentBodyBytes as artifactBodyBytes, documentOutline as artifactOutline, normalizeDocumentBlocks as normalizeArtifactBlocks, sanitizeInline, } from '../../platform/document-blocks';
@@ -1,6 +1,2 @@
1
- import { ArtifactBlock } from './blocks';
2
- /**
3
- * The whole document as markdown. `title` goes on top as an H1 when the blocks carry none
4
- * themselves — an export without a title cannot be found back in a downloads folder.
5
- */
6
- export declare function artifactToMarkdown(blocks: ArtifactBlock[], title?: string): string;
1
+ /** See `./blocks`: the serializer moved to `platform/document-markdown.ts` with the vocabulary. */
2
+ export { documentToMarkdown as artifactToMarkdown } from '../../platform/document-markdown';
@@ -48,8 +48,14 @@ export interface CapacitySources {
48
48
  */
49
49
  export declare function capacityTotal(range: DateRange, sources: CapacitySources): CapacityTotal;
50
50
  export interface PersonCoverage {
51
- /** `null` is the pot nobody has taken yet — what is still to be divided. */
52
- userId: string | null;
51
+ /**
52
+ * **Absent** is the pot nobody has taken yet — what is still to be divided.
53
+ *
54
+ * Absent and not `null`: a `null` in a response arrives at the client as `[]`, which is
55
+ * truthy, so `row.userId ? …` took the wrong branch and handed an array to everything that
56
+ * expected a name. An omitted key survives the wire as an omitted key.
57
+ */
58
+ userId?: string;
53
59
  requiredSeconds: number;
54
60
  capacitySeconds: number;
55
61
  /** `capacity − required`. Negative = this person is over-committed. */
@@ -65,5 +71,42 @@ export interface PersonCoverage {
65
71
  * Work nobody has taken stays a pot of its own rather than being divided over the team: it is
66
72
  * precisely what is still to be assigned, and pretending it is already somebody's would erase the
67
73
  * one thing that is actionable.
74
+ *
75
+ * > **A source that names nobody gets no answer at all — not a table of zeroes.**
76
+ * > A queue or a fixed staffing level is demand on a *team*: four hundred conversations are not
77
+ * > Daan's and not Iris's, and they never will be. Answering anyway produced a row per rostered
78
+ * > person reading `0 / 8u` and a pot claiming the whole week was "still to be divided", which is
79
+ * > not an empty answer but a false one. Only a source that attributes *some* work to *somebody*
80
+ * > — a sprint with assignees, where an unassigned item genuinely is still to be handed out — can
81
+ * > be asked this question.
68
82
  */
69
83
  export declare function coverageByPerson(points: readonly DemandPointResponse[], capacity: CapacityTotal): PersonCoverage[];
84
+ export interface PersonAvailability {
85
+ userId: string;
86
+ /** Hours this person has in the window, by the ladder, after approved absence. */
87
+ capacitySeconds: number;
88
+ /** Of that, already earmarked for this workstream. */
89
+ onThisSeconds: number;
90
+ /** Of that, spoken for by something else: another workstream, a meeting, training, travel. */
91
+ elsewhereSeconds: number;
92
+ /** `capacity − onThis − elsewhere`, floored at zero. What a planner can still hand out. */
93
+ freeSeconds: number;
94
+ }
95
+ /**
96
+ * Who is still free, and for how long.
97
+ *
98
+ * The other half of the planner's question, and the one `coverageByPerson` cannot answer. That
99
+ * one asks *who has too much work* — which needs a source that names people, so a queue or a
100
+ * fixed staffing level has no answer at all. This one asks *who is left*, and every source can
101
+ * answer it, because it reads the roster rather than the demand.
102
+ *
103
+ * > **A shift makes time; it does not spend it — unless it is earmarked.**
104
+ * > An unearmarked eight-hour shift is eight hours a planner can still fill. The same shift with
105
+ * > a workstream on it is eight hours already promised. Everything that is not a shift and not
106
+ * > absence spends time whatever it is: a meeting, training, travel, a break.
107
+ *
108
+ * Absence never appears here as spent time. It has already been taken off the capacity by
109
+ * `capacityTotal`, and subtracting it twice is the shrinkage mistake this file keeps warning
110
+ * about — a day of leave would read as minus eight hours of freedom on a day with none.
111
+ */
112
+ export declare function availabilityByPerson(entries: readonly ScheduleEntry[], workstreamId: string, range: DateRange, capacity: CapacityTotal): PersonAvailability[];
@@ -42,10 +42,14 @@ export interface WorkPattern {
42
42
  updatedAt?: number;
43
43
  }
44
44
  /**
45
- * Whole calendar days between two instants.
45
+ * Whole days between two instants, rounded.
46
46
  *
47
- * Counted through `Date`, not by dividing milliseconds: two days a year are 23 or 25 hours long,
48
- * and a rotation that slips a day every March is a rota nobody trusts again.
47
+ * **Deliberately timezone-free.** An earlier version normalised both sides to local noon, which
48
+ * reads the *evaluating* machine's clock and the two timestamps come from the browser. On a
49
+ * UTC server a CEST Monday midnight floors to the previous Sunday, the week walks eight days
50
+ * instead of seven, and the eighth wraps onto cycle day zero: five eight-hour days silently
51
+ * became six. Rounding the raw difference needs no shared timezone and absorbs the 23- and
52
+ * 25-hour days of a daylight-saving change on its own.
49
53
  */
50
54
  export declare function calendarDaysBetween(from: number, to: number): number;
51
55
  /** Which day of the cycle a date falls on. Negative offsets wrap the right way round. */