diff --git a/tsp-typescript-client/fixtures/tsp-client/experiment-outputs-0.json b/tsp-typescript-client/fixtures/tsp-client/experiment-outputs-0.json index 0b3587b..7809522 100644 --- a/tsp-typescript-client/fixtures/tsp-client/experiment-outputs-0.json +++ b/tsp-typescript-client/fixtures/tsp-client/experiment-outputs-0.json @@ -23,12 +23,22 @@ "description": "Output description", "type": "TIME_GRAPH" }, + { + "id": "timegraph.output.id1", + "name": "Output name (Config)", + "description": "Output description (Config)", + "type": "TIME_GRAPH", + "capabilities": { + "canCreate": true, + "canDelete": false + } + }, { "id": "timegraph.output.id2", "name": "Output name (Config)", "description": "Output description (Config)", "type": "TIME_GRAPH", - "parentId": "timegraph.output.id", + "parentId": "timegraph.output.id1", "configuration" : { "id": "my-config-1-id", "name": "My configuration 1", @@ -37,6 +47,10 @@ "parameters": { "path": "/home/user/tmp" } + }, + "capabilities": { + "canCreate": false, + "canDelete": true } } ] diff --git a/tsp-typescript-client/src/models/output-capabilities.ts b/tsp-typescript-client/src/models/output-capabilities.ts new file mode 100644 index 0000000..8a9514a --- /dev/null +++ b/tsp-typescript-client/src/models/output-capabilities.ts @@ -0,0 +1,19 @@ +/** + * Capabilities class indicating capabilities of a data provider, such as + * "canCreate" and "canDelete" capability. + * + * "canCreate" indicates that a given data provider can create a derived data + * provider. "canDelete" indicates that a given data provider can be deleted. + * + */ +export class OutputCapabilities { + /** + * Whether the data provider can create derived data providers. 'false' if absent. + */ + canCreate?: boolean; + + /** + * Whether the data provider can be deleted. 'false' if absent. + */ + canDelete?: boolean; +} diff --git a/tsp-typescript-client/src/models/output-descriptor.ts b/tsp-typescript-client/src/models/output-descriptor.ts index 7392c9b..d60de74 100644 --- a/tsp-typescript-client/src/models/output-descriptor.ts +++ b/tsp-typescript-client/src/models/output-descriptor.ts @@ -1,5 +1,6 @@ import { createNormalizer } from '../protocol/serialization'; import { Configuration } from './configuration'; +import { OutputCapabilities } from './output-capabilities'; export const OutputDescriptor = createNormalizer({ end: BigInt, @@ -98,4 +99,9 @@ export interface OutputDescriptor { * Configuration used to create this data provider. */ configuration?: Configuration; + + /** + * The output (data provider) capabilities instance. If absent all capabilities are false. + */ + capabilities?: OutputCapabilities; } diff --git a/tsp-typescript-client/src/protocol/tsp-client.test.ts b/tsp-typescript-client/src/protocol/tsp-client.test.ts index 98853df..5074720 100644 --- a/tsp-typescript-client/src/protocol/tsp-client.test.ts +++ b/tsp-typescript-client/src/protocol/tsp-client.test.ts @@ -125,8 +125,21 @@ describe('HttpTspClient Deserialization', () => { httpRequestMock.mockReturnValueOnce(fixtures.asResponse('experiment-outputs-0.json')); const response = await client.experimentOutputs('not-relevant'); const outputs = response.getModel()!; + expect(outputs).toHaveLength(6); - expect(outputs).toHaveLength(5); + let output = outputs.find((item) => item.id === 'timegraph.output.id1'); + expect(output).toBeDefined(); + expect(output?.capabilities).toBeDefined(); + expect(output?.capabilities?.canCreate).toBeTruthy(); + expect(output?.capabilities?.canDelete).toBeFalsy(); + expect(output?.configuration).toBeUndefined(); + + output = outputs.find((item) => item.id === 'timegraph.output.id2'); + expect(output).toBeDefined(); + expect(output?.capabilities).toBeDefined(); + expect(output?.capabilities?.canCreate).toBeFalsy(); + expect(output?.capabilities?.canDelete).toBeTruthy(); + expect(output?.configuration).toBeDefined(); }); it('fetchAnnotationsCategories', async () => {