Skip to content

Commit 902d07e

Browse files
committed
Add optional OutputCapabilities to the output descriptor
OutputCapabilities indicate capabilities of am output, such as "canCreate" and "canDelete". "canCreate" indicates that a given output can create a derived outputs. "canDelete" indicates that a given output can be deleted. Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
1 parent d2adc0c commit 902d07e

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

tsp-typescript-client/fixtures/tsp-client/experiment-outputs-0.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@
2323
"description": "Output description",
2424
"type": "TIME_GRAPH"
2525
},
26+
{
27+
"id": "timegraph.output.id1",
28+
"name": "Output name (Config)",
29+
"description": "Output description (Config)",
30+
"type": "TIME_GRAPH",
31+
"capabilities": {
32+
"canCreate": true,
33+
"canDelete": false
34+
}
35+
},
2636
{
2737
"id": "timegraph.output.id2",
2838
"name": "Output name (Config)",
2939
"description": "Output description (Config)",
3040
"type": "TIME_GRAPH",
31-
"parentId": "timegraph.output.id",
41+
"parentId": "timegraph.output.id1",
3242
"configuration" : {
3343
"id": "my-config-1-id",
3444
"name": "My configuration 1",
@@ -37,6 +47,10 @@
3747
"parameters": {
3848
"path": "/home/user/tmp"
3949
}
50+
},
51+
"capabilities": {
52+
"canCreate": false,
53+
"canDelete": true
4054
}
4155
}
4256
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Capabilities class indicating capabilities of a data provider, such as
3+
* "canCreate" and "canDelete" capability.
4+
*
5+
* "canCreate" indicates that a given data provider can create a derived data
6+
* provider. "canDelete" indicates that a given data provider can be deleted.
7+
*
8+
*/
9+
export class OutputCapabilities {
10+
/**
11+
* Whether the data provider can create derived data providers. 'false' if absent.
12+
*/
13+
canCreate?: boolean;
14+
15+
/**
16+
* Whether the data provider can be deleted. 'false' if absent.
17+
*/
18+
canDelete?: boolean;
19+
}

tsp-typescript-client/src/models/output-descriptor.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createNormalizer } from '../protocol/serialization';
22
import { Configuration } from './configuration';
3+
import { OutputCapabilities } from './output-capabilities';
34

45
export const OutputDescriptor = createNormalizer<OutputDescriptor>({
56
end: BigInt,
@@ -98,4 +99,9 @@ export interface OutputDescriptor {
9899
* Configuration used to create this data provider.
99100
*/
100101
configuration?: Configuration;
102+
103+
/**
104+
* The output (data provider) capabilities instance. If absent all capabilities are false.
105+
*/
106+
capabilities?: OutputCapabilities;
101107
}

tsp-typescript-client/src/protocol/tsp-client.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,21 @@ describe('HttpTspClient Deserialization', () => {
125125
httpRequestMock.mockReturnValueOnce(fixtures.asResponse('experiment-outputs-0.json'));
126126
const response = await client.experimentOutputs('not-relevant');
127127
const outputs = response.getModel()!;
128+
expect(outputs).toHaveLength(6);
128129

129-
expect(outputs).toHaveLength(5);
130+
let output = outputs.find((item) => item.id === 'timegraph.output.id1');
131+
expect(output).toBeDefined();
132+
expect(output?.capabilities).toBeDefined();
133+
expect(output?.capabilities?.canCreate).toBeTruthy();
134+
expect(output?.capabilities?.canDelete).toBeFalsy();
135+
expect(output?.configuration).toBeUndefined();
136+
137+
output = outputs.find((item) => item.id === 'timegraph.output.id2');
138+
expect(output).toBeDefined();
139+
expect(output?.capabilities).toBeDefined();
140+
expect(output?.capabilities?.canCreate).toBeFalsy();
141+
expect(output?.capabilities?.canDelete).toBeTruthy();
142+
expect(output?.configuration).toBeDefined();
130143
});
131144

132145
it('fetchAnnotationsCategories', async () => {

0 commit comments

Comments
 (0)