Skip to content

Commit 4ef9473

Browse files
authored
Add shared types for benchmark APIs (#1921)
Fixes OPS-3548. ## Additional Notes
1 parent ff307ff commit 4ef9473

File tree

9 files changed

+111
-0
lines changed

9 files changed

+111
-0
lines changed

packages/shared/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export * from './lib/authentication/dto/sign-up-request';
1414
export * from './lib/authentication/model/authentication-type';
1515
export * from './lib/authentication/model/principal';
1616
export * from './lib/authentication/model/principal-type';
17+
export * from './lib/benchmark';
1718
export * from './lib/blocks';
1819
export * from './lib/code/dto/code-request';
1920
export * from './lib/common';
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Static, Type } from '@sinclair/typebox';
2+
import { BenchmarkWorkflowBase } from './create-benchmark-response';
3+
4+
export enum BenchmarkStatus {
5+
RUNNING = 'RUNNING',
6+
SUCCEEDED = 'SUCCEEDED',
7+
FAILED = 'FAILED',
8+
}
9+
10+
export const BenchmarkWorkflowStatusItem = Type.Intersect([
11+
BenchmarkWorkflowBase,
12+
Type.Object({
13+
runStatus: Type.String(),
14+
runId: Type.Optional(Type.String()),
15+
}),
16+
]);
17+
18+
export type BenchmarkWorkflowStatusItem = Static<
19+
typeof BenchmarkWorkflowStatusItem
20+
>;
21+
22+
export const BenchmarkStatusResponse = Type.Object({
23+
benchmarkId: Type.String(),
24+
status: Type.Enum(BenchmarkStatus),
25+
workflows: Type.Array(BenchmarkWorkflowStatusItem),
26+
});
27+
28+
export type BenchmarkStatusResponse = Static<typeof BenchmarkStatusResponse>;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Static, Type } from '@sinclair/typebox';
2+
import { BenchmarkConfiguration } from './wizard-request';
3+
4+
export const CreateBenchmarkRequest = Type.Object({
5+
benchmarkConfiguration: BenchmarkConfiguration,
6+
});
7+
8+
export type CreateBenchmarkRequest = Static<typeof CreateBenchmarkRequest>;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Static, Type } from '@sinclair/typebox';
2+
3+
export const BenchmarkWorkflowBase = Type.Object({
4+
flowId: Type.String(),
5+
displayName: Type.String(),
6+
isOrchestrator: Type.Boolean(),
7+
});
8+
9+
export type BenchmarkWorkflowBase = Static<typeof BenchmarkWorkflowBase>;
10+
11+
export const CreateBenchmarkResponse = Type.Object({
12+
benchmarkId: Type.String(),
13+
folderId: Type.String(),
14+
workflows: Type.Array(BenchmarkWorkflowBase),
15+
});
16+
17+
export type CreateBenchmarkResponse = Static<typeof CreateBenchmarkResponse>;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export * from './benchmark-status-response';
2+
export * from './create-benchmark-request';
3+
export * from './create-benchmark-response';
4+
export * from './run-benchmark-response';
5+
export * from './wizard-request';
6+
export * from './wizard-response';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Static, Type } from '@sinclair/typebox';
2+
3+
export const RunBenchmarkResponse = Type.Object({
4+
orchestratorRunId: Type.String(),
5+
});
6+
7+
export type RunBenchmarkResponse = Static<typeof RunBenchmarkResponse>;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Static, Type } from '@sinclair/typebox';
2+
3+
export const BenchmarkConfiguration = Type.Record(
4+
Type.String(),
5+
Type.Array(Type.String()),
6+
);
7+
8+
export type BenchmarkConfiguration = Static<typeof BenchmarkConfiguration>;
9+
10+
export const BenchmarkWizardRequest = Type.Object({
11+
currentStep: Type.Optional(Type.String()),
12+
benchmarkConfiguration: Type.Optional(BenchmarkConfiguration),
13+
});
14+
15+
export type BenchmarkWizardRequest = Static<typeof BenchmarkWizardRequest>;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Static, Type } from '@sinclair/typebox';
2+
3+
export const BenchmarkWizardOption = Type.Object({
4+
id: Type.String(),
5+
displayName: Type.String(),
6+
imageLogoUrl: Type.Optional(Type.String()),
7+
metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
8+
});
9+
10+
export type BenchmarkWizardOption = Static<typeof BenchmarkWizardOption>;
11+
12+
export const BenchmarkWizardStepResponse = Type.Object({
13+
currentStep: Type.String(),
14+
title: Type.String(),
15+
description: Type.Optional(Type.String()),
16+
nextStep: Type.Union([Type.String(), Type.Null()]),
17+
selectionType: Type.Union([
18+
Type.Literal('single'),
19+
Type.Literal('multi-select'),
20+
]),
21+
options: Type.Array(BenchmarkWizardOption),
22+
stepIndex: Type.Number(),
23+
totalSteps: Type.Number(),
24+
});
25+
26+
export type BenchmarkWizardStepResponse = Static<
27+
typeof BenchmarkWizardStepResponse
28+
>;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dto';

0 commit comments

Comments
 (0)