@flamingo-stack/openframe-frontend-core 0.0.646 → 0.0.647-snapshot.20260917173248
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/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/{chunk-ETEM2ZD4.js → chunk-2A4RLR7R.js} +3 -3
- package/dist/{chunk-JFBUXYDK.cjs → chunk-2ENDIKKP.cjs} +15 -15
- package/dist/{chunk-JFBUXYDK.cjs.map → chunk-2ENDIKKP.cjs.map} +1 -1
- package/dist/{chunk-QS55P2TA.js → chunk-2ULLNHL3.js} +6 -6
- package/dist/chunk-2ULLNHL3.js.map +1 -0
- package/dist/{chunk-DULSS7R6.js → chunk-3ORBE27K.js} +832 -547
- package/dist/chunk-3ORBE27K.js.map +1 -0
- package/dist/{chunk-ZW2BEEX2.cjs → chunk-4JRBRMKO.cjs} +25 -25
- package/dist/{chunk-ZW2BEEX2.cjs.map → chunk-4JRBRMKO.cjs.map} +1 -1
- package/dist/{chunk-7UWJMWDH.cjs → chunk-EFPAKLT5.cjs} +784 -499
- package/dist/chunk-EFPAKLT5.cjs.map +1 -0
- package/dist/{chunk-5C7GMRJU.js → chunk-EKLOXVG2.js} +5 -5
- package/dist/{chunk-AYAZU3BO.cjs → chunk-EW3EIPT5.cjs} +5 -5
- package/dist/{chunk-AYAZU3BO.cjs.map → chunk-EW3EIPT5.cjs.map} +1 -1
- package/dist/{chunk-NKMXFBV5.js → chunk-FQ4TZP6K.js} +4 -4
- package/dist/{chunk-5JVN3EVT.cjs → chunk-HN4DLGKP.cjs} +71 -71
- package/dist/{chunk-5JVN3EVT.cjs.map → chunk-HN4DLGKP.cjs.map} +1 -1
- package/dist/{chunk-WJ7PDBPK.cjs → chunk-HXQWGZYG.cjs} +4 -4
- package/dist/{chunk-WJ7PDBPK.cjs.map → chunk-HXQWGZYG.cjs.map} +1 -1
- package/dist/{chunk-5MZZFTME.js → chunk-IUHU5BC2.js} +5 -5
- package/dist/{chunk-ZGWXD2S3.js → chunk-IWEJCDCB.js} +3 -3
- package/dist/{chunk-N2E26OD6.cjs → chunk-LFCMKMHR.cjs} +45 -45
- package/dist/{chunk-N2E26OD6.cjs.map → chunk-LFCMKMHR.cjs.map} +1 -1
- package/dist/{chunk-XJH5M2B7.js → chunk-M6QCADAT.js} +6 -6
- package/dist/{chunk-NWYSHZG7.cjs → chunk-N7AJUG4C.cjs} +22 -22
- package/dist/{chunk-NWYSHZG7.cjs.map → chunk-N7AJUG4C.cjs.map} +1 -1
- package/dist/{chunk-LDJ4TIDC.cjs → chunk-ODXVLFAQ.cjs} +13 -24
- package/dist/chunk-ODXVLFAQ.cjs.map +1 -0
- package/dist/{chunk-4GOJFHJY.js → chunk-OLPU5IVF.js} +2 -2
- package/dist/{chunk-PD47DDHS.js → chunk-PYAFHT6B.js} +7 -18
- package/dist/chunk-PYAFHT6B.js.map +1 -0
- package/dist/{chunk-H4FQRA5O.cjs → chunk-RM5MF2N3.cjs} +3 -3
- package/dist/{chunk-H4FQRA5O.cjs.map → chunk-RM5MF2N3.cjs.map} +1 -1
- package/dist/{chunk-ZDIDA4QG.js → chunk-SBKNMSQR.js} +2 -2
- package/dist/{chunk-GBZ3IR3S.js → chunk-SNQ5KWLP.js} +2 -2
- package/dist/{chunk-LLT5XMP2.js → chunk-UW7XUQFP.js} +3 -3
- package/dist/{chunk-RRSR2XHJ.cjs → chunk-VPEETTUS.cjs} +167 -167
- package/dist/chunk-VPEETTUS.cjs.map +1 -0
- package/dist/{chunk-UR7BC74V.js → chunk-VTLDEZ5D.js} +3 -3
- package/dist/{chunk-XPPGI7SD.js → chunk-WBRO3MX2.js} +2 -2
- package/dist/{chunk-NZ66W56D.cjs → chunk-WMKXHOOD.cjs} +10 -10
- package/dist/{chunk-NZ66W56D.cjs.map → chunk-WMKXHOOD.cjs.map} +1 -1
- package/dist/{chunk-TZO743LD.cjs → chunk-WPNY4XEL.cjs} +3 -3
- package/dist/{chunk-TZO743LD.cjs.map → chunk-WPNY4XEL.cjs.map} +1 -1
- package/dist/{chunk-XATBOM3X.js → chunk-XE5DNWOR.js} +5 -5
- package/dist/{chunk-C6QUB6IS.cjs → chunk-XI3QJD3N.cjs} +22 -22
- package/dist/{chunk-C6QUB6IS.cjs.map → chunk-XI3QJD3N.cjs.map} +1 -1
- package/dist/{chunk-2V7SCIOG.cjs → chunk-YTOUGDPY.cjs} +33 -33
- package/dist/{chunk-2V7SCIOG.cjs.map → chunk-YTOUGDPY.cjs.map} +1 -1
- package/dist/{chunk-X2VTQ3TL.cjs → chunk-YUXFHVC2.cjs} +10 -10
- package/dist/{chunk-X2VTQ3TL.cjs.map → chunk-YUXFHVC2.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +14 -14
- package/dist/components/case-studies/index.js +3 -3
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +2 -2
- package/dist/components/chat/index.js +1 -1
- package/dist/components/chat/types/message.types.d.ts +5 -0
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/utils/cited-sources.d.ts +5 -0
- package/dist/components/chat/utils/cited-sources.d.ts.map +1 -1
- package/dist/components/chat/utils/source-row-cta.d.ts +2 -7
- package/dist/components/chat/utils/source-row-cta.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +4 -4
- package/dist/components/contact/index.js +3 -3
- package/dist/components/docs/index.cjs +7 -7
- package/dist/components/docs/index.js +6 -6
- package/dist/components/embeds/index.cjs +4 -4
- package/dist/components/embeds/index.js +3 -3
- package/dist/components/faq/index.cjs +4 -4
- package/dist/components/faq/index.js +3 -3
- package/dist/components/features/index.cjs +3 -3
- package/dist/components/features/index.js +2 -2
- package/dist/components/help-center-pages/index.cjs +23 -23
- package/dist/components/help-center-pages/index.js +14 -14
- package/dist/components/index.cjs +39 -39
- package/dist/components/index.js +13 -13
- package/dist/components/meeting-scheduler/index.cjs +24 -24
- package/dist/components/meeting-scheduler/index.js +2 -2
- package/dist/components/navigation/index.cjs +6 -6
- package/dist/components/navigation/index.js +5 -5
- package/dist/components/onboarding-guides/index.cjs +6 -6
- package/dist/components/onboarding-guides/index.js +5 -5
- package/dist/components/shared/doc-search/map-doc-search-results.d.ts.map +1 -1
- package/dist/components/tickets/index.cjs +7 -7
- package/dist/components/tickets/index.js +6 -6
- package/dist/components/ui/data-table/data-table-skeleton.d.ts.map +1 -1
- package/dist/components/ui/index.cjs +3 -3
- package/dist/components/ui/index.js +2 -2
- package/dist/components/ui/markdown/mermaid-diagram.d.ts +31 -9
- package/dist/components/ui/markdown/mermaid-diagram.d.ts.map +1 -1
- package/dist/index.cjs +19 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/dist/utils/index.cjs +163 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +158 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/source-grouping.d.ts +86 -0
- package/dist/utils/source-grouping.d.ts.map +1 -0
- package/dist/utils/source-icons.d.ts +7 -0
- package/dist/utils/source-icons.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/embeddable-chat.tsx +10 -2
- package/src/components/chat/types/message.types.ts +5 -0
- package/src/components/chat/utils/cited-sources.ts +7 -1
- package/src/components/chat/utils/source-row-cta.ts +4 -7
- package/src/components/shared/doc-search/__tests__/map-doc-search-results.test.ts +48 -0
- package/src/components/shared/doc-search/map-doc-search-results.ts +6 -16
- package/src/components/ui/data-table/data-table-skeleton.tsx +15 -7
- package/src/components/ui/markdown/__tests__/mermaid-zoom.test.tsx +117 -0
- package/src/components/ui/markdown/mermaid-diagram.tsx +279 -59
- package/src/utils/__tests__/source-grouping.test.ts +240 -0
- package/src/utils/index.ts +11 -0
- package/src/utils/source-grouping.ts +215 -0
- package/src/utils/source-icons.ts +13 -0
- package/dist/chunk-7UWJMWDH.cjs.map +0 -1
- package/dist/chunk-DULSS7R6.js.map +0 -1
- package/dist/chunk-LDJ4TIDC.cjs.map +0 -1
- package/dist/chunk-PD47DDHS.js.map +0 -1
- package/dist/chunk-QS55P2TA.js.map +0 -1
- package/dist/chunk-RRSR2XHJ.cjs.map +0 -1
- /package/dist/{chunk-ETEM2ZD4.js.map → chunk-2A4RLR7R.js.map} +0 -0
- /package/dist/{chunk-5C7GMRJU.js.map → chunk-EKLOXVG2.js.map} +0 -0
- /package/dist/{chunk-NKMXFBV5.js.map → chunk-FQ4TZP6K.js.map} +0 -0
- /package/dist/{chunk-5MZZFTME.js.map → chunk-IUHU5BC2.js.map} +0 -0
- /package/dist/{chunk-ZGWXD2S3.js.map → chunk-IWEJCDCB.js.map} +0 -0
- /package/dist/{chunk-XJH5M2B7.js.map → chunk-M6QCADAT.js.map} +0 -0
- /package/dist/{chunk-4GOJFHJY.js.map → chunk-OLPU5IVF.js.map} +0 -0
- /package/dist/{chunk-ZDIDA4QG.js.map → chunk-SBKNMSQR.js.map} +0 -0
- /package/dist/{chunk-GBZ3IR3S.js.map → chunk-SNQ5KWLP.js.map} +0 -0
- /package/dist/{chunk-LLT5XMP2.js.map → chunk-UW7XUQFP.js.map} +0 -0
- /package/dist/{chunk-UR7BC74V.js.map → chunk-VTLDEZ5D.js.map} +0 -0
- /package/dist/{chunk-XPPGI7SD.js.map → chunk-WBRO3MX2.js.map} +0 -0
- /package/dist/{chunk-XATBOM3X.js.map → chunk-XE5DNWOR.js.map} +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grouped source chips: THE one owner, for every producer.
|
|
3
|
+
*
|
|
4
|
+
* "ClickUp Tasks (14 records)" with a per-row dropdown is built in exactly one
|
|
5
|
+
* place, `buildGroupedSource`, and WHICH rows group is decided in exactly one
|
|
6
|
+
* place, `groupsByTable`. Three producers call them:
|
|
7
|
+
*
|
|
8
|
+
* 1. the hub's web chat (`buildSourcesMeta`), server-side, over the rows it
|
|
9
|
+
* retrieved;
|
|
10
|
+
* 2. the hub's side-channel chips (my-tickets / my-tasks), server-side, over
|
|
11
|
+
* rows a strategy injected;
|
|
12
|
+
* 3. this chat's strip, client-side, over the FLAT sources a remote MCP tool
|
|
13
|
+
* returns (`groupSourcesByTable`).
|
|
14
|
+
*
|
|
15
|
+
* Why the third one is client-side: an MCP tool result is one self-describing
|
|
16
|
+
* citation per record, which is what a citation contract should be, and a turn
|
|
17
|
+
* that calls several tools yields several flat lists only the client ever sees
|
|
18
|
+
* merged. Grouping is presentation. It is the SAME presentation everywhere
|
|
19
|
+
* because it is the same two functions everywhere.
|
|
20
|
+
*
|
|
21
|
+
* Server-safe: no React, no browser APIs. The hub imports it from the `utils`
|
|
22
|
+
* barrel next to `getSourceLabel`.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { ChatSource } from '../components/chat/types/message.types';
|
|
26
|
+
import { defaultDocumentTypeForTableId, getSourceLabel } from './source-icons';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Doc-table documentTypes: whole documents with their own viewer (markdown =
|
|
30
|
+
* product docs, data_room_doc = data room). They carry an in-app `path`, an
|
|
31
|
+
* embedder keys `docPlatformTargets` by them, and they NEVER group: one chip
|
|
32
|
+
* per document. The hub's per-source contract test pins this list to its
|
|
33
|
+
* doc-table configs.
|
|
34
|
+
*/
|
|
35
|
+
export const DOC_TABLE_TYPES = ['markdown', 'data_room_doc'] as const;
|
|
36
|
+
|
|
37
|
+
/** THE rule: rows of a knowledge table share one chip unless they are whole
|
|
38
|
+
* documents. Decided by `documentType`, the one fact every producer has. */
|
|
39
|
+
export function groupsByTable(documentType: string | null | undefined): boolean {
|
|
40
|
+
return !(DOC_TABLE_TYPES as readonly string[]).includes(documentType ?? '');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** `(1 record)` / `(14 records)`: the count every grouped chip states. */
|
|
44
|
+
export function recordCountLabel(count: number): string {
|
|
45
|
+
return `(${count} ${count === 1 ? 'record' : 'records'})`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type GroupedItem = NonNullable<ChatSource['items']>[number];
|
|
49
|
+
|
|
50
|
+
/** One row of a group. `index` is set only when the row was cited on its own
|
|
51
|
+
* (a flat MCP source); a server-grouped row shares the group's number. */
|
|
52
|
+
export type GroupedSourceRow = GroupedItem;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* THE grouped-chip constructor. Order-preserving: a producer that wants its
|
|
56
|
+
* dropdown by date sorts `rows` first.
|
|
57
|
+
*
|
|
58
|
+
* `items` is ALWAYS populated, rows without a public URL included: per-row
|
|
59
|
+
* `id` + `documentType` is what gives every dropdown row its Ask action, and a
|
|
60
|
+
* chip with `items` never navigates to `path`, which for an entity table is
|
|
61
|
+
* mapper bookkeeping and not a route.
|
|
62
|
+
*/
|
|
63
|
+
export function buildGroupedSource(spec: {
|
|
64
|
+
/** The chip's citation number (and React key). */
|
|
65
|
+
index: number;
|
|
66
|
+
sourceRepo: string;
|
|
67
|
+
rows: GroupedSourceRow[];
|
|
68
|
+
/** Chip-level link, when it is not the first row's own. */
|
|
69
|
+
externalUrl?: string;
|
|
70
|
+
targetPlatform?: string | null;
|
|
71
|
+
}): ChatSource {
|
|
72
|
+
const first = spec.rows[0];
|
|
73
|
+
const externalUrl = spec.externalUrl ?? first?.externalUrl;
|
|
74
|
+
const targetPlatform = spec.targetPlatform !== undefined ? spec.targetPlatform : first?.targetPlatform;
|
|
75
|
+
return {
|
|
76
|
+
index: spec.index,
|
|
77
|
+
name: `${getSourceLabel(spec.sourceRepo)} ${recordCountLabel(spec.rows.length)}`,
|
|
78
|
+
path: first?.path ?? '',
|
|
79
|
+
documentType: first?.documentType ?? '',
|
|
80
|
+
...(externalUrl ? { externalUrl } : {}),
|
|
81
|
+
targetPlatform: targetPlatform ?? null,
|
|
82
|
+
sourceRepo: spec.sourceRepo,
|
|
83
|
+
items: spec.rows,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type TableSource = ChatSource & { sourceRepo: string };
|
|
88
|
+
|
|
89
|
+
/** A chip the server already grouped (it carries `items`). */
|
|
90
|
+
function isGroupedChip(source: ChatSource): boolean {
|
|
91
|
+
return !!source.items && source.items.length > 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** A source's type, or its TABLE's canonical type when the row arrived without
|
|
95
|
+
* one. The table is the stronger fact: a typeless row of a doc table is still
|
|
96
|
+
* a whole document, and a typeless row of an entity table still groups. */
|
|
97
|
+
function typeOf(source: TableSource): string {
|
|
98
|
+
return source.documentType || defaultDocumentTypeForTableId(source.sourceRepo) || '';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** A source that belongs to its table's chip: it names its table and is not a
|
|
102
|
+
* whole document. Both shapes qualify, a flat row AND a chip the server
|
|
103
|
+
* already grouped, so one table is never drawn twice. Naming the table is the
|
|
104
|
+
* ONLY requirement: a row with no `id`, or no `documentType`, still joins (as
|
|
105
|
+
* the hub's server-side chips do). Leaving it out would split one table
|
|
106
|
+
* across a group AND a stray chip. What it lacks only limits its dropdown
|
|
107
|
+
* row: no `id` or no type means Open-only, no Ask. */
|
|
108
|
+
function joinsTableChip(source: ChatSource): source is TableSource {
|
|
109
|
+
if (!source.sourceRepo) return false;
|
|
110
|
+
return groupsByTable(typeOf({ ...source, sourceRepo: source.sourceRepo }));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** A source's dropdown rows: a grouped chip's own items, or the flat row itself. */
|
|
114
|
+
function rowsOf(source: TableSource): GroupedSourceRow[] {
|
|
115
|
+
if (isGroupedChip(source)) return source.items ?? [];
|
|
116
|
+
return [
|
|
117
|
+
{
|
|
118
|
+
index: source.index,
|
|
119
|
+
id: source.id ?? '',
|
|
120
|
+
documentType: typeOf(source),
|
|
121
|
+
name: source.name,
|
|
122
|
+
...(source.externalUrl ? { externalUrl: source.externalUrl } : {}),
|
|
123
|
+
targetPlatform: source.targetPlatform ?? null,
|
|
124
|
+
path: source.path || null,
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** First occurrence wins per record, so a record that arrived both inside a
|
|
130
|
+
* server chip and as a flat row is one dropdown row. Id-less rows cannot be
|
|
131
|
+
* told apart and are all kept. */
|
|
132
|
+
function uniqueRows(rows: GroupedSourceRow[]): GroupedSourceRow[] {
|
|
133
|
+
const seen = new Set<string>();
|
|
134
|
+
return rows.filter(row => {
|
|
135
|
+
if (!row.id) return true;
|
|
136
|
+
const identity = `${row.documentType}:${row.id}`;
|
|
137
|
+
if (seen.has(identity)) return false;
|
|
138
|
+
seen.add(identity);
|
|
139
|
+
return true;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Flat sources in, the strip's chips out: ONE chip per table.
|
|
145
|
+
*
|
|
146
|
+
* Every row that names its table joins that table's chip, a lone record and a
|
|
147
|
+
* row missing its `id` or `documentType` included, exactly as the hub's web chat draws it. Each flat row
|
|
148
|
+
* keeps the citation number it was given, so `[3]` in the answer still
|
|
149
|
+
* resolves inside the group. The chip sits where its table first appeared and
|
|
150
|
+
* takes that source's `index` (unique, members are disjoint), so the strip
|
|
151
|
+
* keeps the order it was handed: reading order for cited sources.
|
|
152
|
+
*
|
|
153
|
+
* A chip the server already grouped passes through UNTOUCHED when it is its
|
|
154
|
+
* table's only source. When flat rows of the same table arrive beside it (a
|
|
155
|
+
* hub-injected chip plus MCP-cited rows in one answer), they merge into it:
|
|
156
|
+
* its rows first, its chip-level link kept, the count restated. Whole
|
|
157
|
+
* documents and rows naming no table pass through as their own chips.
|
|
158
|
+
*/
|
|
159
|
+
export function groupSourcesByTable(sources: ChatSource[]): ChatSource[] {
|
|
160
|
+
const membersByTable = new Map<string, TableSource[]>();
|
|
161
|
+
for (const source of sources) {
|
|
162
|
+
if (!joinsTableChip(source)) continue;
|
|
163
|
+
const members = membersByTable.get(source.sourceRepo) ?? [];
|
|
164
|
+
members.push(source);
|
|
165
|
+
membersByTable.set(source.sourceRepo, members);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const emitted = new Set<string>();
|
|
169
|
+
const chips: ChatSource[] = [];
|
|
170
|
+
for (const source of sources) {
|
|
171
|
+
if (!joinsTableChip(source)) {
|
|
172
|
+
chips.push(source);
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (emitted.has(source.sourceRepo)) continue;
|
|
176
|
+
emitted.add(source.sourceRepo);
|
|
177
|
+
|
|
178
|
+
const members = membersByTable.get(source.sourceRepo) ?? [];
|
|
179
|
+
if (members.length === 1 && isGroupedChip(source)) {
|
|
180
|
+
chips.push(source);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
// A server chip may carry a chip-level link that is not its first row's.
|
|
184
|
+
const serverChip = members.find(isGroupedChip);
|
|
185
|
+
chips.push(
|
|
186
|
+
buildGroupedSource({
|
|
187
|
+
index: source.index,
|
|
188
|
+
sourceRepo: source.sourceRepo,
|
|
189
|
+
rows: uniqueRows(members.flatMap(rowsOf)),
|
|
190
|
+
...(serverChip?.externalUrl ? { externalUrl: serverChip.externalUrl } : {}),
|
|
191
|
+
...(serverChip && serverChip.targetPlatform !== undefined ? { targetPlatform: serverChip.targetPlatform } : {}),
|
|
192
|
+
}),
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
return chips;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The citation numbers a chip answers to, as compact text: `1-3, 7`.
|
|
200
|
+
*
|
|
201
|
+
* A chip grouped from flat sources stands for several `[N]` markers, so it
|
|
202
|
+
* shows all of them. Consecutive numbers fold into a range, which keeps a
|
|
203
|
+
* 25-row group readable.
|
|
204
|
+
*/
|
|
205
|
+
export function formatCitationIndices(indices: number[]): string {
|
|
206
|
+
const sorted = [...new Set(indices)].sort((a, b) => a - b);
|
|
207
|
+
const runs: string[] = [];
|
|
208
|
+
for (let start = 0; start < sorted.length;) {
|
|
209
|
+
let end = start;
|
|
210
|
+
while (end + 1 < sorted.length && sorted[end + 1] === sorted[end] + 1) end++;
|
|
211
|
+
runs.push(end === start ? `${sorted[start]}` : `${sorted[start]}-${sorted[end]}`);
|
|
212
|
+
start = end + 1;
|
|
213
|
+
}
|
|
214
|
+
return runs.join(', ');
|
|
215
|
+
}
|
|
@@ -256,3 +256,16 @@ export const DEFAULT_DOCUMENT_TYPE_TO_TABLE_ID: Record<string, string> = {
|
|
|
256
256
|
export function defaultTableIdForDocumentType(documentType: string): string | null {
|
|
257
257
|
return DEFAULT_DOCUMENT_TYPE_TO_TABLE_ID[documentType] ?? null;
|
|
258
258
|
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The reverse lookup: a table's canonical `documentType`. The map above is
|
|
262
|
+
* 1:1 (the hub's per-source contract test pins one type per table), so a row
|
|
263
|
+
* that names its table but arrived with no type still has one. `null` for a
|
|
264
|
+
* table the map does not list.
|
|
265
|
+
*/
|
|
266
|
+
export function defaultDocumentTypeForTableId(tableId: string): string | null {
|
|
267
|
+
for (const [documentType, table] of Object.entries(DEFAULT_DOCUMENT_TYPE_TO_TABLE_ID)) {
|
|
268
|
+
if (table === tableId) return documentType;
|
|
269
|
+
}
|
|
270
|
+
return null;
|
|
271
|
+
}
|