Skip to content

Commit

Permalink
feat: tweak trajectories api
Browse files Browse the repository at this point in the history
  • Loading branch information
x-oflisback committed Oct 10, 2022
1 parent 2f0d2d2 commit 9cd0cff
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
49 changes: 28 additions & 21 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Cookie, CookieJar } from 'tough-cookie'
import { ModelicaExperiment } from './ModelicaExperiment'
import {
Case,
CaseTrajectories,
CustomFunction,
ExperimentId,
Trajectories,
ExperimentTrajectories,
Workspace,
} from './types'

Expand Down Expand Up @@ -272,22 +273,23 @@ export class Client {
workspaceId: string
}): Promise<void> {
return new Promise((resolve, reject) => {
this.ensureImpactToken().then(() => {
this.axios
.post(
`${this.baseUrl}${this.jhUserPath}/impact/api/workspaces/${workspaceId}/experiments/${experimentId}/execution`,
{
includeCases: {
ids: cases,
},
options: {
forceCompilation: true,
},
}
)
.then(() => resolve())
.catch((e) => reject(e))
})
this.ensureImpactToken()
.then(() => {
this.axios
.post(
`${this.baseUrl}${this.jhUserPath}/impact/api/workspaces/${workspaceId}/experiments/${experimentId}/execution`,
{
includeCases: {
ids: cases,
},
options: {
forceCompilation: true,
},
}
)
.then(() => resolve())
.catch((e) => reject(e))
})
.catch((e) => reject(e))
})
}
Expand Down Expand Up @@ -332,7 +334,7 @@ export class Client {
workspaceId,
})
} catch (e) {
throw e;
throw e
}
}
}
Expand Down Expand Up @@ -409,7 +411,7 @@ export class Client {
experimentId: string
variableNames: string[]
workspaceId: string
}): Promise<Trajectories | undefined> {
}): Promise<ExperimentTrajectories> {
return new Promise((resolve, reject) => {
this.ensureImpactToken()
.then(() => {
Expand Down Expand Up @@ -439,14 +441,19 @@ export class Client {
experimentId: string
variableNames: string[]
workspaceId: string
}): Promise<Trajectories | undefined> {
}): Promise<CaseTrajectories> {
return new Promise((resolve, reject) => {
this.ensureImpactToken()
.then(() => {
this.axios
.post(
`${this.baseUrl}${this.jhUserPath}impact/api/workspaces/${workspaceId}/experiments/${experimentId}/cases/${caseId}/trajectories`,
{ variable_names: variableNames }
{ variable_names: variableNames },
{
headers: {
Accept: 'application/vnd.impact.trajectories.v2+json',
},
}
)
.then((res) => resolve(res.data))
.catch((e) => reject(e))
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ import { Client } from './Client'
import { ModelicaExperiment } from './ModelicaExperiment'
import {
Case,
CaseTrajectories,
CustomFunction,
ExperimentId,
Trajectories,
ExperimentTrajectories,
Workspace,
} from './types/index.d'

export {
Case,
CaseTrajectories,
Client,
CustomFunction,
ExperimentId,
ExperimentTrajectories,
ModelicaExperiment,
Trajectories,
Workspace,
}
7 changes: 5 additions & 2 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export type ModelicaExperimentParameters =

export type ModelicaExperimentModifiers = components['schemas']['Modifiers']

export type Trajectories =
operations['getTrajectories']['responses']['200']['content']['application/vnd.impact.trajectories.v2+json']['data']['items']
export type CaseTrajectories =
operations['getTrajectories']['responses']['200']['content']['application/vnd.impact.trajectories.v2+json']['items']

export type ExperimentTrajectories =
operations['getTrajectories']['responses']['200']['content']['application/vnd.impact.trajectories.v2+json']['items']

export type ExperimentId = string

0 comments on commit 9cd0cff

Please sign in to comment.