Skip to content

Commit

Permalink
Merge pull request #221 from HubSpot/update-project-types
Browse files Browse the repository at this point in the history
Chore: update project types
  • Loading branch information
camden11 authored Dec 17, 2024
2 parents a078c41 + b3c75af commit e6f20c3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
6 changes: 1 addition & 5 deletions api/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
UploadProjectResponse,
ProjectSettings,
FetchPlatformVersionResponse,
WarnLogsResponse,
} from '../types/Project';
import { Build, FetchProjectBuildsResponse } from '../types/Build';
import {
ComponentStructureResponse,
ProjectComponentsMetadata,
} from '../types/ComponentStructure';
import { Deploy, ProjectDeployResponse } from '../types/Deploy';
import { ProjectLog } from '../types/ProjectLog';
import {
MigrateAppResponse,
CloneAppResponse,
Expand Down Expand Up @@ -272,10 +272,6 @@ export function cancelStagedBuild(
});
}

type WarnLogsResponse = {
logs: Array<ProjectLog>;
};

export function fetchBuildWarnLogs(
accountId: number,
projectName: string,
Expand Down
6 changes: 4 additions & 2 deletions types/Build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ import {
} from '../enums/build';
import { ActivitySource } from './Activity';
import { DeployStatusTaskLocator } from './Deploy';
import { OptionalError } from './Error';
import { ProjectStandardError } from './Project';

export type SubbuildStatus = {
buildName: string;
buildType: ValueOf<typeof SUBBUILD_TYPES>;
errorMessage: string;
finishedAt: string;
rootPath: string;
standardError?: OptionalError;
standardError: ProjectStandardError | null;
startedAt: string;
status: ValueOf<typeof BUILD_STATUS>;
id: string;
visible: boolean;
};

export type Build = {
Expand All @@ -35,6 +36,7 @@ export type Build = {
status: ValueOf<typeof BUILD_STATUS>;
subbuildStatuses: Array<SubbuildStatus>;
uploadMessage: string;
autoDeployId: number;
};

export type FetchProjectBuildsResponse = {
Expand Down
5 changes: 3 additions & 2 deletions types/Deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ValueOf } from './Utils';
import { ACTIVITY_SOURCE } from '../enums/project';
import { DEPLOY_ACTION, DEPLOY_STATUS } from '../enums/deploy';
import { COMPONENT_TYPES, SUBCOMPONENT_TYPES } from '../enums/build';
import { OptionalError } from './Error';
import { ProjectStandardError } from './Project';

export type DeployStatus = ValueOf<typeof DEPLOY_STATUS>;

Expand All @@ -14,10 +14,11 @@ export type SubdeployStatus = {
| ValueOf<typeof SUBCOMPONENT_TYPES>;
errorMessage: string;
finishedAt: string;
standardError?: OptionalError;
standardError: ProjectStandardError | null;
startedAt: string;
status: DeployStatus;
id: string;
visible: boolean;
};

export type Deploy = {
Expand Down
1 change: 1 addition & 0 deletions types/Error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface HubSpotHttpErrorContext extends FileSystemErrorContext {
projectName?: string;
}

// TODO: Remove in next major release
export type OptionalError = BaseError | null | undefined;

export type ErrorContext = {
Expand Down
5 changes: 3 additions & 2 deletions types/Migration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ValueOf } from './Utils';
import { OptionalError } from './Error';
import { ProjectStandardError } from './Project';

export const MIGRATION_STATUS = {
BUILDING: 'BUILDING',
FAILURE: 'FAILURE',
Expand All @@ -21,6 +22,6 @@ export type CloneAppResponse = {
export type PollAppResponse = {
id: number;
project?: { id: number; name: string; buildId: number; deployId: number };
error?: OptionalError;
error: ProjectStandardError | null;
status: ValueOf<typeof MIGRATION_STATUS>;
};
22 changes: 22 additions & 0 deletions types/Project.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Build } from './Build';
import { GithubSourceData } from './Github';
import { ProjectLog } from './ProjectLog';

export type Project = {
createdAt: number;
Expand Down Expand Up @@ -45,3 +46,24 @@ export type FetchPlatformVersionResponse = {
defaultPlatformVersion: string;
activePlatformVersions: Array<string>;
};

export type ProjectStandardError = {
status: string;
id?: string;
category: string;
subCategory?: string;
message?: string;
errors?: Array<{
message: string;
in?: string;
code?: string;
subcateogy?: string;
context: object;
}>;
context: object;
links: { [key: string]: string };
};

export type WarnLogsResponse = {
logs: Array<ProjectLog>;
};

0 comments on commit e6f20c3

Please sign in to comment.