Skip to content

Commit

Permalink
feat(Simulations): narrow down simulation payload types (#52)
Browse files Browse the repository at this point in the history
* feat(Simulations): narrow down simulation payload types

* refactor(Simulations): rename event map

* fix(Simulations): Include scenarios in union

* refactor(Simulations): rename DiscriminatedEventResponse
  • Loading branch information
danbillson committed Oct 14, 2024
1 parent e3da97f commit 9c01bb8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

import type { SimulationScenarioType } from '../../../enums/index.js';
import type { IEventName } from '../../../notifications/index.js';

export interface CreateSimulationRequestBody {
import type { DiscriminatedSimulationEventResponse } from '../../../types/index.js';
interface BaseCreateSimulationRequestBody {
notificationSettingId: string;
type: IEventName | SimulationScenarioType;
name: string;
payload?: any;
type: IEventName | SimulationScenarioType;
}

export type CreateSimulationRequestBody = DiscriminatedSimulationEventResponse<BaseCreateSimulationRequestBody>;
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/**
* ! Autogenerated code !
* Do not make changes to this file.
* Changes may be overwritten as part of auto-generation.
*/
import type { DiscriminatedSimulationEventResponse } from '../../../types/index.js';
import type { Status } from '../../../enums/index.js';

import type { SimulationScenarioType, Status } from '../../../enums/index.js';
import type { IEventName } from '../../../notifications/index.js';

export interface UpdateSimulationRequestBody {
interface BaseUpdateSimulationRequestBody {
notificationSettingId?: string;
name?: string;
status?: Status;
type?: IEventName | SimulationScenarioType;
payload?: any;
}

type RawUpdateSimulationRequestBody = DiscriminatedSimulationEventResponse<BaseUpdateSimulationRequestBody>;

// Map all properties to be optional
export type UpdateSimulationRequestBody = {
[Key in keyof RawUpdateSimulationRequestBody]?: RawUpdateSimulationRequestBody[Key];
};
1 change: 1 addition & 0 deletions src/types/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ export * from './custom-data.js';
export * from './import-meta-response.js';
export * from './simulation-event-request.js';
export * from './simulation-event-response.js';
export * from './simulation-payload.js';
14 changes: 4 additions & 10 deletions src/types/simulation/simulation-response.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
/**
* ! Autogenerated code !
* Do not make changes to this file.
* Changes may be overwritten as part of auto-generation.
*/
import type { Status } from '../../enums/index.js';
import type { DiscriminatedSimulationEventResponse } from '../shared/simulation-payload.js';

import type { SimulationScenarioType, Status } from '../../enums/index.js';
import type { IEventName } from '../../notifications/index.js';
export type ISimulationResponse = DiscriminatedSimulationEventResponse<BaseSimulationResponse>;

export interface ISimulationResponse {
interface BaseSimulationResponse {
id: string;
status: Status;
notification_setting_id: string;
name: string;
type: IEventName | SimulationScenarioType;
payload?: any;
last_run_at?: string | null;
created_at: string;
updated_at: string;
Expand Down

0 comments on commit 9c01bb8

Please sign in to comment.