@company-semantics/contracts 13.17.0 → 13.18.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@company-semantics/contracts",
3
- "version": "13.17.0",
3
+ "version": "13.18.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,6 +64,10 @@
64
64
  "types": "./src/impersonation/index.ts",
65
65
  "default": "./src/impersonation/index.ts"
66
66
  },
67
+ "./ingestion": {
68
+ "types": "./src/ingestion/index.ts",
69
+ "default": "./src/ingestion/index.ts"
70
+ },
67
71
  "./schemas/guard-result.schema.json": "./schemas/guard-result.schema.json"
68
72
  },
69
73
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -779,3 +779,8 @@ export * from "./meetings";
779
779
  // AccessLevel / OrgChartRole / AccessSource — see ADR-CTRL-084..088.
780
780
  // No consumers in this PRD; cutover starts in AUTH-002 (PRD-00670).
781
781
  export * from "./permissions";
782
+
783
+ // Document-ingestion accept-set vocabulary — see ADR-CONT-075.
784
+ // Single source of truth for upload formats; the backend normalizer joins its
785
+ // private dispatch fields locally, the app derives its accept-set + copy.
786
+ export * from "./ingestion";
@@ -0,0 +1,35 @@
1
+ # ingestion/
2
+
3
+ Shared vocabulary for the document-ingestion accept-set.
4
+
5
+ ## Purpose
6
+
7
+ The single source of truth for which file formats the platform accepts for
8
+ upload — their MIME types, filename extensions, human label groups, and
9
+ per-format byte caps. The backend normalizer joins these entries with its
10
+ private dispatch table; the app upload UI derives its file-input `accept`
11
+ attribute and supported-formats copy from the same data.
12
+
13
+ ## Invariants
14
+
15
+ - `INGESTION_FORMATS` is the canonical list; `mime` is unique across entries.
16
+ - Entries are ordered text → documents → images/diagrams → audio/video. The
17
+ backend's MIME-order test and the derived UI strings depend on this order.
18
+ - `INGEST_ACCEPT` and `SUPPORTED_LABEL` are **derived** from the registry, never
19
+ hand-maintained — adding a format updates both automatically.
20
+ - No normalizer-routing fields here (`canonicalKind`, `normalizerKey` are
21
+ backend-only). This package stays pure vocabulary.
22
+
23
+ ## Public API
24
+
25
+ - `IngestionFormat` — `{ mime, extensions, label, maxBytes }`.
26
+ - `INGESTION_FORMATS: readonly IngestionFormat[]`.
27
+ - `byMime(mime)`, `acceptExtensions()`, `humanLabels()`.
28
+ - `INGEST_ACCEPT: string` — comma-joined extensions for an `accept` attribute.
29
+ - `SUPPORTED_LABEL: string` — human-readable supported-formats summary.
30
+
31
+ ## Dependencies
32
+
33
+ None beyond `./types`. (The backend registry at
34
+ `company-semantics-backend/src/orgs/ingestion/normalize/format-registry.ts`
35
+ consumes this and adds its private dispatch fields.)
@@ -0,0 +1,44 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import {
3
+ INGESTION_FORMATS,
4
+ byMime,
5
+ acceptExtensions,
6
+ humanLabels,
7
+ INGEST_ACCEPT,
8
+ SUPPORTED_LABEL,
9
+ } from "../registry";
10
+
11
+ describe("ingestion registry", () => {
12
+ it("has a unique MIME per entry", () => {
13
+ const mimes = INGESTION_FORMATS.map((e) => e.mime);
14
+ expect(new Set(mimes).size).toBe(mimes.length);
15
+ });
16
+
17
+ it("uses lowercase, dot-prefixed extensions", () => {
18
+ for (const entry of INGESTION_FORMATS) {
19
+ for (const ext of entry.extensions) {
20
+ expect(ext).toMatch(/^\.[a-z0-9]+$/);
21
+ }
22
+ }
23
+ });
24
+
25
+ it("byMime resolves a known format and rejects unknown", () => {
26
+ expect(byMime("application/pdf")?.label).toBe("PDF");
27
+ expect(byMime("audio/mpeg")?.label).toBe("Audio");
28
+ expect(byMime("application/x-unknown")).toBeUndefined();
29
+ });
30
+
31
+ it("derives INGEST_ACCEPT from every extension in registry order", () => {
32
+ expect(INGEST_ACCEPT).toBe(acceptExtensions().join(","));
33
+ expect(INGEST_ACCEPT).toBe(
34
+ ".txt,.md,.html,.htm,.csv,.rtf,.docx,.doc,.pptx,.xlsx,.odt,.pdf,.png,.jpg,.jpeg,.webp,.gif,.heic,.svg,.drawio,.mp3,.m4a,.wav,.aac,.mp4,.m4v,.mov",
35
+ );
36
+ });
37
+
38
+ it("derives SUPPORTED_LABEL from the unique group labels", () => {
39
+ expect(SUPPORTED_LABEL).toBe(`Supported: ${humanLabels().join(", ")}`);
40
+ expect(SUPPORTED_LABEL).toBe(
41
+ "Supported: Text, Markdown, HTML, CSV, RTF, Word, PowerPoint, Excel, OpenDocument, PDF, Image, Diagram, Audio, Video",
42
+ );
43
+ });
44
+ });
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Ingestion Domain Barrel
3
+ *
4
+ * Re-exports the public document-ingestion format vocabulary.
5
+ * Import from '@company-semantics/contracts/ingestion'.
6
+ *
7
+ * @see ADR-CONT-075 for design rationale
8
+ */
9
+
10
+ export type { IngestionFormat } from "./types";
11
+
12
+ export {
13
+ INGESTION_FORMATS,
14
+ byMime,
15
+ acceptExtensions,
16
+ humanLabels,
17
+ INGEST_ACCEPT,
18
+ SUPPORTED_LABEL,
19
+ } from "./registry";
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Ingestion Format Registry
3
+ *
4
+ * THE single source of truth for the public document-ingestion accept-set. The
5
+ * backend normalizer joins these entries with its private dispatch table; the
6
+ * app derives its file-input `accept` attribute and supported-formats copy from
7
+ * the helpers below. Neither side re-spells the extension or label list.
8
+ *
9
+ * Invariants:
10
+ * - Entries are ordered text → documents → images/diagrams → audio/video; the
11
+ * backend's MIME-order test and the derived UI strings depend on this order.
12
+ * - `INGEST_ACCEPT` and `SUPPORTED_LABEL` are DERIVED, never hand-maintained —
13
+ * adding a format here updates both automatically.
14
+ *
15
+ * @see ADR-CONT-075 for design rationale
16
+ */
17
+
18
+ import type { IngestionFormat } from "./types";
19
+
20
+ /** The canonical public format registry. */
21
+ export const INGESTION_FORMATS: readonly IngestionFormat[] = [
22
+ {
23
+ mime: "text/plain",
24
+ extensions: [".txt"],
25
+ label: "Text",
26
+ maxBytes: 10_000_000,
27
+ },
28
+ {
29
+ mime: "text/markdown",
30
+ extensions: [".md"],
31
+ label: "Markdown",
32
+ maxBytes: 10_000_000,
33
+ },
34
+ {
35
+ mime: "text/html",
36
+ extensions: [".html", ".htm"],
37
+ label: "HTML",
38
+ maxBytes: 10_000_000,
39
+ },
40
+ {
41
+ mime: "text/csv",
42
+ extensions: [".csv"],
43
+ label: "CSV",
44
+ maxBytes: 25_000_000,
45
+ },
46
+ {
47
+ mime: "application/rtf",
48
+ extensions: [".rtf"],
49
+ label: "RTF",
50
+ maxBytes: 25_000_000,
51
+ },
52
+ {
53
+ mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
54
+ extensions: [".docx"],
55
+ label: "Word",
56
+ maxBytes: 25_000_000,
57
+ },
58
+ {
59
+ mime: "application/msword",
60
+ extensions: [".doc"],
61
+ label: "Word",
62
+ maxBytes: 25_000_000,
63
+ },
64
+ {
65
+ mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
66
+ extensions: [".pptx"],
67
+ label: "PowerPoint",
68
+ maxBytes: 50_000_000,
69
+ },
70
+ {
71
+ mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
72
+ extensions: [".xlsx"],
73
+ label: "Excel",
74
+ maxBytes: 50_000_000,
75
+ },
76
+ {
77
+ mime: "application/vnd.oasis.opendocument.text",
78
+ extensions: [".odt"],
79
+ label: "OpenDocument",
80
+ maxBytes: 25_000_000,
81
+ },
82
+ {
83
+ mime: "application/pdf",
84
+ extensions: [".pdf"],
85
+ label: "PDF",
86
+ maxBytes: 50_000_000,
87
+ },
88
+ {
89
+ mime: "image/png",
90
+ extensions: [".png"],
91
+ label: "Image",
92
+ maxBytes: 25_000_000,
93
+ },
94
+ {
95
+ mime: "image/jpeg",
96
+ extensions: [".jpg", ".jpeg"],
97
+ label: "Image",
98
+ maxBytes: 25_000_000,
99
+ },
100
+ {
101
+ mime: "image/webp",
102
+ extensions: [".webp"],
103
+ label: "Image",
104
+ maxBytes: 25_000_000,
105
+ },
106
+ {
107
+ mime: "image/gif",
108
+ extensions: [".gif"],
109
+ label: "Image",
110
+ maxBytes: 25_000_000,
111
+ },
112
+ {
113
+ mime: "image/heic",
114
+ extensions: [".heic"],
115
+ label: "Image",
116
+ maxBytes: 25_000_000,
117
+ },
118
+ {
119
+ mime: "image/svg+xml",
120
+ extensions: [".svg"],
121
+ label: "Diagram",
122
+ maxBytes: 10_000_000,
123
+ },
124
+ {
125
+ mime: "application/vnd.jgraph.mxfile",
126
+ extensions: [".drawio"],
127
+ label: "Diagram",
128
+ maxBytes: 10_000_000,
129
+ },
130
+ {
131
+ mime: "audio/mpeg",
132
+ extensions: [".mp3"],
133
+ label: "Audio",
134
+ maxBytes: 500_000_000,
135
+ },
136
+ {
137
+ mime: "audio/x-m4a",
138
+ extensions: [".m4a"],
139
+ label: "Audio",
140
+ maxBytes: 500_000_000,
141
+ },
142
+ {
143
+ mime: "audio/wav",
144
+ extensions: [".wav"],
145
+ label: "Audio",
146
+ maxBytes: 500_000_000,
147
+ },
148
+ {
149
+ mime: "audio/aac",
150
+ extensions: [".aac"],
151
+ label: "Audio",
152
+ maxBytes: 500_000_000,
153
+ },
154
+ {
155
+ mime: "video/mp4",
156
+ extensions: [".mp4", ".m4v"],
157
+ label: "Video",
158
+ maxBytes: 500_000_000,
159
+ },
160
+ {
161
+ mime: "video/quicktime",
162
+ extensions: [".mov"],
163
+ label: "Video",
164
+ maxBytes: 500_000_000,
165
+ },
166
+ ];
167
+
168
+ /** Look up the entry for a canonical MIME; undefined means unsupported. */
169
+ export function byMime(mime: string): IngestionFormat | undefined {
170
+ return INGESTION_FORMATS.find((entry) => entry.mime === mime);
171
+ }
172
+
173
+ /** All accepted filename extensions, in registry order. */
174
+ export function acceptExtensions(): string[] {
175
+ return INGESTION_FORMATS.flatMap((entry) => [...entry.extensions]);
176
+ }
177
+
178
+ /** Unique group labels for human display, in registry order. */
179
+ export function humanLabels(): string[] {
180
+ return [...new Set(INGESTION_FORMATS.map((entry) => entry.label))];
181
+ }
182
+
183
+ /**
184
+ * Comma-joined extension string for a file input's `accept` attribute.
185
+ * Derived from {@link acceptExtensions} — never hand-maintained.
186
+ */
187
+ export const INGEST_ACCEPT: string = acceptExtensions().join(",");
188
+
189
+ /**
190
+ * Human-readable supported-formats summary, derived from {@link humanLabels}.
191
+ * Names every accepted group (in registry order) so the copy can't undersell
192
+ * what actually works.
193
+ */
194
+ export const SUPPORTED_LABEL: string = `Supported: ${humanLabels().join(", ")}`;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Ingestion Format Types
3
+ *
4
+ * The public vocabulary for the document-ingestion accept-set: which file
5
+ * formats the platform accepts for upload, their human label groups, and the
6
+ * per-format byte caps. Shared by the backend normalizer (which adds its own
7
+ * private dispatch fields locally) and the app upload UI (which derives its
8
+ * `accept` attribute and supported-formats copy from this).
9
+ *
10
+ * Types only — no runtime behavior. The backend-only normalizer routing
11
+ * (`canonicalKind`, `normalizerKey`) deliberately does NOT live here; it is an
12
+ * implementation detail of the backend dispatch and would pollute the shared
13
+ * vocabulary.
14
+ *
15
+ * @see ADR-CONT-075 for design rationale
16
+ */
17
+
18
+ /**
19
+ * One accepted upload format, keyed by its canonical MIME type.
20
+ *
21
+ * Invariants:
22
+ * - `mime` is unique across the registry.
23
+ * - `extensions` are lowercase, dot-prefixed (e.g. `.docx`).
24
+ * - `label` is the human display GROUP and is intentionally shared across
25
+ * related formats (`.docx` + `.doc` are both `Word`; the rasters are all
26
+ * `Image`; `.svg` + `.drawio` are `Diagram`).
27
+ */
28
+ export interface IngestionFormat {
29
+ /** Canonical MIME type (the registry key). */
30
+ mime: string;
31
+ /** Lowercase, dot-prefixed filename extensions for this format. */
32
+ extensions: readonly string[];
33
+ /** Human display group label (e.g. `Word`, `Image`, `Audio`). */
34
+ label: string;
35
+ /** Per-format upload byte cap. */
36
+ maxBytes: number;
37
+ }