Skip to content

Commit d6cde7b

Browse files
committed
chore(site): remove unecessary types and move types to where they are used
1 parent 9e5a59e commit d6cde7b

File tree

5 files changed

+38
-53
lines changed

5 files changed

+38
-53
lines changed

site/src/api/api.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import axios from "axios";
22
import dayjs from "dayjs";
3-
import * as Types from "./types";
4-
import { DeploymentConfig } from "./types";
53
import * as TypesGen from "./typesGenerated";
64
import { delay } from "utils/delay";
75
import userAgentParser from "ua-parser-js";
@@ -365,8 +363,8 @@ export const createTemplate = async (
365363
export const updateActiveTemplateVersion = async (
366364
templateId: string,
367365
data: TypesGen.UpdateActiveTemplateVersion,
368-
): Promise<Types.Message> => {
369-
const response = await axios.patch<Types.Message>(
366+
) => {
367+
const response = await axios.patch<TypesGen.Response>(
370368
`/api/v2/templates/${templateId}/versions`,
371369
data,
372370
);
@@ -547,7 +545,7 @@ export const deleteWorkspace = (
547545

548546
export const cancelWorkspaceBuild = async (
549547
workspaceBuildId: TypesGen.WorkspaceBuild["id"],
550-
): Promise<Types.Message> => {
548+
): Promise<TypesGen.Response> => {
551549
const response = await axios.patch(
552550
`/api/v2/workspacebuilds/${workspaceBuildId}/cancel`,
553551
);
@@ -595,7 +593,7 @@ export const restartWorkspace = async ({
595593

596594
export const cancelTemplateVersionBuild = async (
597595
templateVersionId: TypesGen.TemplateVersion["id"],
598-
): Promise<Types.Message> => {
596+
): Promise<TypesGen.Response> => {
599597
const response = await axios.patch(
600598
`/api/v2/templateversions/${templateVersionId}/cancel`,
601599
);
@@ -985,6 +983,29 @@ export const getDeploymentSSHConfig =
985983
return response.data;
986984
};
987985

986+
// The Deployment types are not generated on from the Go generator yet because
987+
// it does not know how to generate OptionSet
988+
export interface DeploymentGroup {
989+
readonly name: string;
990+
readonly parent?: DeploymentGroup;
991+
readonly description: string;
992+
readonly children: DeploymentGroup[];
993+
}
994+
export interface DeploymentOption {
995+
readonly name: string;
996+
readonly description: string;
997+
readonly flag: string;
998+
readonly flag_shorthand: string;
999+
readonly value: unknown;
1000+
readonly hidden: boolean;
1001+
readonly group?: DeploymentGroup;
1002+
}
1003+
1004+
type DeploymentConfig = {
1005+
readonly config: TypesGen.DeploymentValues;
1006+
readonly options: DeploymentOption[];
1007+
};
1008+
9881009
export const getDeploymentValues = async (): Promise<DeploymentConfig> => {
9891010
const response = await axios.get(`/api/v2/deployment/config`);
9901011
return response.data;

site/src/api/types.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

site/src/testHelpers/handlers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { rest } from "msw";
2-
import { WorkspaceBuildTransition } from "../api/types";
32
import { CreateWorkspaceBuildRequest } from "../api/typesGenerated";
43
import { permissionsToCheck } from "../xServices/auth/authXService";
54
import * as M from "./entities";
@@ -238,7 +237,7 @@ export const handlers = [
238237
stop: M.MockWorkspaceBuildStop,
239238
delete: M.MockWorkspaceBuildDelete,
240239
};
241-
const result = transitionToBuild[transition as WorkspaceBuildTransition];
240+
const result = transitionToBuild[transition];
242241
return res(ctx.status(200), ctx.json(result));
243242
}),
244243
rest.get("/api/v2/workspaces/:workspaceId/builds", async (req, res, ctx) => {

site/src/utils/deployOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { DeploymentOption, DeploymentGroup } from "api/api";
12
import { useMemo } from "react";
2-
import { DeploymentGroup, DeploymentOption } from "../api/types";
33

44
const deploymentOptions = (
55
options: DeploymentOption[],

site/src/xServices/terminal/terminalXService.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { assign, createMachine } from "xstate";
2-
import * as API from "../../api/api";
3-
import * as Types from "../../api/types";
4-
import * as TypesGen from "../../api/typesGenerated";
2+
import * as API from "api/api";
3+
import * as TypesGen from "api/typesGenerated";
4+
5+
interface ReconnectingPTYRequest {
6+
readonly data?: string;
7+
readonly height?: number;
8+
readonly width?: number;
9+
}
510

611
export interface TerminalContext {
712
workspaceError?: unknown;
@@ -33,7 +38,7 @@ export type TerminalEvent =
3338
workspaceName?: string;
3439
username?: string;
3540
}
36-
| { type: "WRITE"; request: Types.ReconnectingPTYRequest }
41+
| { type: "WRITE"; request: ReconnectingPTYRequest }
3742
| { type: "READ"; data: ArrayBuffer }
3843
| { type: "DISCONNECT" };
3944

0 commit comments

Comments
 (0)