Skip to content

Commit

Permalink
Separated out status for upload and flows (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
proksh authored Nov 21, 2024
1 parent b53ea3a commit c220d1d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
5 changes: 3 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"singleQuote": true,
"semi": true,
"semi": false,
"useTabs": false,
"trailingComma": "none",
"tabWidth": 2,
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"printWidth": 120
"printWidth": 80
}
36 changes: 24 additions & 12 deletions ApiClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import fetch, { fileFromSync, FormData } from 'node-fetch'

export enum BenchmarkStatus {
export enum FlowStatus {
PENDING = 'PENDING',
PREPARING = 'PREPARING',
INSTALLING = 'INSTALLING',
RUNNING = 'RUNNING',
SUCCESS = 'SUCCESS',
ERROR = 'ERROR',
CANCELED = 'CANCELED',
WARNING = 'WARNING',
STOPPED = 'STOPPED'
}

export enum UploadStatus {
PENDING = 'PENDING',
PREPARING = 'PREPARING',
INSTALLING = 'INSTALLING',
Expand Down Expand Up @@ -70,19 +82,19 @@ export enum CancellationReason {
BENCHMARK_DEPENDENCY_FAILED = 'BENCHMARK_DEPENDENCY_FAILED',
INFRA_ERROR = 'INFRA_ERROR',
OVERLAPPING_BENCHMARK = 'OVERLAPPING_BENCHMARK',
TIMEOUT = 'TIMEOUT',
TIMEOUT = 'TIMEOUT'
}

export type Flow = {
name: string
status: BenchmarkStatus
status: FlowStatus
errors?: string[]
cancellationReason?: CancellationReason
}

export type UploadStatusResponse = {
uploadId: string
status: BenchmarkStatus
status: UploadStatus
completed: boolean
flows: Flow[]
}
Expand Down Expand Up @@ -114,9 +126,9 @@ export default class ApiClient {
const res = await fetch(`${this.apiUrl}/v2/upload`, {
method: 'POST',
headers: {
Authorization: `Bearer ${this.apiKey}`,
Authorization: `Bearer ${this.apiKey}`
},
body: formData,
body: formData
})
if (!res.ok) {
const body = await res.text()
Expand Down Expand Up @@ -147,9 +159,9 @@ export default class ApiClient {
const res = await fetch(`${this.apiUrl}/runMaestroTest`, {
method: 'POST',
headers: {
Authorization: `Bearer ${this.apiKey}`,
Authorization: `Bearer ${this.apiKey}`
},
body: formData,
body: formData
})
if (!res.ok) {
const body = await res.text()
Expand All @@ -164,8 +176,8 @@ export default class ApiClient {
const res = await fetch(`${this.apiUrl}/upload/${uploadId}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${this.apiKey}`,
},
Authorization: `Bearer ${this.apiKey}`
}
})
if (!res.ok) {
const body = await res.text()
Expand All @@ -186,8 +198,8 @@ export default class ApiClient {
{
method: 'GET',
headers: {
Authorization: `Bearer ${this.apiKey}`,
},
Authorization: `Bearer ${this.apiKey}`
}
}
)
if (!res.ok) {
Expand Down

0 comments on commit c220d1d

Please sign in to comment.