Skip to content

Commit 87e01fd

Browse files
authored
Merge pull request #1796 from finos/correct-missing-contexts
Add missing contexts to ContextTypes enum and TS type
2 parents ae3c077 + 217cbba commit 87e01fd

5 files changed

Lines changed: 78 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4747
* Fix to ensure that Adding A Channel Change Event Listener Doesn't Send addEventListenerRequest - Conformance 2.2 ([#1606](https://github.com/finos/FDC3/pull/1606))
4848
* Updated Conformance tests to allow agents that fully qualify app Ids (as recommended in the Standard) to pass the conformance tests ([#1767](https://github.com/finos/FDC3/pull/1767))
4949
* Fixed import file extensions and module type to be esm module compliant ([#1677](https://github.com/finos/FDC3/pull/1677))
50+
* Added mising context types to types and enums in. ContextTypes.ts and implemented tests to ensure they stay in sync with the fdc3-context package ([#1796](https://github.com/finos/FDC3/pull/1796))
5051

5152
## [FDC3 Standard 2.2](https://github.com/finos/FDC3/compare/v2.1..v2.2) - 2025-03-12
5253

packages/fdc3-standard/src/context/ContextType.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ export type StandardContextType =
1818
| 'fdc3.country'
1919
| 'fdc3.currency'
2020
| 'fdc3.email'
21+
| 'fdc3.fileAttachment'
2122
| 'fdc3.instrument'
2223
| 'fdc3.instrumentList'
2324
| 'fdc3.interaction'
2425
| 'fdc3.message'
26+
| 'fdc3.nothing'
2527
| 'fdc3.organization'
2628
| 'fdc3.portfolio'
2729
| 'fdc3.position'
28-
| 'fdc3.nothing'
2930
| 'fdc3.timeRange'
3031
| 'fdc3.transactionResult'
3132
| 'fdc3.valuation';
@@ -49,23 +50,32 @@ export type ContextType = StandardContextType | ExperimentalContextType | (strin
4950
* @deprecated Use {@link StandardContextType} instead
5051
*/
5152
export enum ContextTypes {
53+
Action = 'fdc3.action',
5254
Chart = 'fdc3.chart',
5355
ChatInitSettings = 'fdc3.chat.initSettings',
56+
ChatMessage = 'fdc3.chat.message',
5457
ChatRoom = 'fdc3.chat.room',
58+
ChatSearchCriteria = 'fdc3.chat.searchCriteria',
5559
Contact = 'fdc3.contact',
5660
ContactList = 'fdc3.contactList',
5761
Country = 'fdc3.country',
5862
Currency = 'fdc3.currency',
5963
Email = 'fdc3.email',
64+
FileAttachment = 'fdc3.fileAttachment',
6065
Instrument = 'fdc3.instrument',
6166
InstrumentList = 'fdc3.instrumentList',
6267
Interaction = 'fdc3.interaction',
68+
Message = 'fdc3.message',
6369
Nothing = 'fdc3.nothing',
70+
Order = 'fdc3.order',
71+
OrderList = 'fdc3.orderList',
6472
Organization = 'fdc3.organization',
6573
Portfolio = 'fdc3.portfolio',
6674
Position = 'fdc3.position',
67-
ChatSearchCriteria = 'fdc3.chat.searchCriteria',
75+
Product = 'fdc3.product',
6876
TimeRange = 'fdc3.timeRange',
77+
Trade = 'fdc3.trade',
78+
TradeList = 'fdc3.tradeList',
6979
TransactionResult = 'fdc3.transactionResult',
7080
Valuation = 'fdc3.valuation',
7181
}

packages/fdc3-standard/src/intents/standard intents.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"StartChat",
88
"StartEmail",
99
"ViewAnalysis",
10-
"ViewChart",
1110
"ViewChat",
11+
"ViewChart",
1212
"ViewContact",
1313
"ViewHoldings",
1414
"ViewInstrument",

packages/fdc3-standard/src/internal/contextConfiguration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ const STANDARD_CONTEXT_TYPES = exhaustiveStringTuple<StandardContextType>()(
1313
'fdc3.country',
1414
'fdc3.currency',
1515
'fdc3.email',
16+
'fdc3.fileAttachment',
1617
'fdc3.instrument',
1718
'fdc3.instrumentList',
1819
'fdc3.interaction',
1920
'fdc3.message',
21+
'fdc3.nothing',
2022
'fdc3.organization',
2123
'fdc3.portfolio',
2224
'fdc3.position',
23-
'fdc3.nothing',
2425
'fdc3.timeRange',
2526
'fdc3.transactionResult',
2627
'fdc3.valuation'
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { readdirSync, readFileSync } from 'fs';
3+
import { resolve, dirname } from 'path';
4+
import { createRequire } from 'module';
5+
import { ContextTypes } from '../src/context/ContextType.js';
6+
7+
const require = createRequire(import.meta.url);
8+
9+
/**
10+
* Extracts the fdc3 context type string from a schema file by finding
11+
* the "const" value of the "type" property.
12+
*/
13+
function extractContextType(schemaPath: string): string | null {
14+
const schema = JSON.parse(readFileSync(schemaPath, 'utf-8'));
15+
for (const entry of schema.allOf ?? []) {
16+
const typeConst = entry?.properties?.type?.const;
17+
if (typeof typeConst === 'string' && typeConst.startsWith('fdc3.')) {
18+
return typeConst;
19+
}
20+
}
21+
return null;
22+
}
23+
24+
/**
25+
* Reads all context schemas from the fdc3-context package and returns
26+
* the set of fdc3.* type strings they define.
27+
*/
28+
function getSchemaContextTypes(): Set<string> {
29+
const fdc3ContextEntry = require.resolve('@finos/fdc3-context');
30+
const schemasDir = resolve(dirname(fdc3ContextEntry), '../schemas/context');
31+
const types = new Set<string>();
32+
33+
for (const file of readdirSync(schemasDir)) {
34+
if (!file.endsWith('.schema.json')) continue;
35+
const contextType = extractContextType(resolve(schemasDir, file));
36+
if (contextType) types.add(contextType);
37+
}
38+
39+
return types;
40+
}
41+
42+
describe('Context type definitions stay in sync with fdc3-context schemas', () => {
43+
const schemaTypes = getSchemaContextTypes();
44+
const enumValues = new Set(Object.values(ContextTypes));
45+
46+
it('should find context types in the schemas', () => {
47+
expect(schemaTypes.size).toBeGreaterThan(0);
48+
});
49+
50+
it('ContextTypes enum should include every schema-defined context type', () => {
51+
const missingFromEnum = [...schemaTypes].filter(t => !enumValues.has(t)).sort();
52+
53+
if (missingFromEnum.length > 0) {
54+
console.error(
55+
'\n❌ Context types defined in fdc3-context schemas but missing from ContextTypes enum:\n' +
56+
missingFromEnum.map(t => ` • ${t}`).join('\n')
57+
);
58+
}
59+
60+
expect(missingFromEnum).toEqual([]);
61+
});
62+
});

0 commit comments

Comments
 (0)