Skip to content

Commit

Permalink
make new subtype for pre-deployment with configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchetti committed Apr 3, 2024
1 parent ab16a17 commit a6e7285
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions extensions/vscode/src/api/types/deployments.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2023 by Posit Software, PBC.

import { AgentError } from "./error";
import { Configuration } from "./configurations";
import { Configuration, ConfigurationLocation } from "./configurations";
import { SchemaURL } from "./schema";
import { ServerType } from "./accounts";

Expand Down Expand Up @@ -33,10 +33,10 @@ type DeploymentRecord = {

export type PreDeployment = {
state: DeploymentState.NEW;
configurationName: string | undefined;
configurationPath: string | undefined;
} & DeploymentRecord;

export type PreDeploymentWithConfig = PreDeployment & ConfigurationLocation;

export type Deployment = {
id: string;
bundleId: string;
Expand All @@ -46,12 +46,14 @@ export type Deployment = {
files: string[];
deployedAt: string;
state: DeploymentState.DEPLOYED;
configurationName: string;
configurationPath: string;
} & DeploymentRecord &
Configuration;

export type AllDeploymentTypes = Deployment | PreDeployment | DeploymentError;
export type AllDeploymentTypes =
| Deployment
| PreDeployment
| PreDeploymentWithConfig
| DeploymentError;

export function isSuccessful(
d: AllDeploymentTypes | undefined,
Expand Down Expand Up @@ -87,6 +89,16 @@ export function isPreDeployment(
return Boolean(d && d.state === DeploymentState.NEW);
}

export function isPreDeploymentWithConfig(
d: AllDeploymentTypes | undefined,
): d is PreDeploymentWithConfig {
return Boolean(
d &&
d.state === DeploymentState.NEW &&
(d as PreDeploymentWithConfig).configurationName !== undefined,
);
}

export function isSuccessfulPreDeployment(
d: AllDeploymentTypes | undefined,
): d is PreDeployment {
Expand Down

0 comments on commit a6e7285

Please sign in to comment.