@qawolf/ci-sdk
Advanced tools
Comparing version 0.13.0 to 0.14.0
@@ -38,2 +38,3 @@ "use strict"; | ||
httpStatus: resp.status, | ||
errorType: "client", | ||
ok: false, | ||
@@ -40,0 +41,0 @@ }; |
@@ -52,3 +52,3 @@ "use strict"; | ||
return { | ||
failureReason: "server-error", | ||
failureReason: "5XX-server-error", | ||
httpStatus: response.status, | ||
@@ -60,3 +60,3 @@ success: false, | ||
return { | ||
failureReason: "unauthorized", | ||
failureReason: "401-unauthorized", | ||
httpStatus: response.status, | ||
@@ -68,3 +68,3 @@ success: false, | ||
return { | ||
failureReason: "forbidden", | ||
failureReason: "403-forbidden", | ||
httpStatus: response.status, | ||
@@ -75,3 +75,3 @@ success: false, | ||
return { | ||
failureReason: "unrecoverable-error", | ||
failureReason: "4XX-client-error", | ||
httpStatus: response.status, | ||
@@ -78,0 +78,0 @@ success: false, |
@@ -12,19 +12,19 @@ "use strict"; | ||
log.error(`đĢ No trigger matched the request. Please contact support.`); | ||
return { outcome: "failed" }; | ||
return { outcome: "failed", failReason: "no-matched-trigger" }; | ||
} | ||
else if (responseState.failureReason === "run-could-not-be-created") { | ||
log.error(`đĢ Run could not be created. Reason: "${responseState.details}". Please contact support.`); | ||
return { outcome: "failed" }; | ||
return { outcome: "failed", failReason: "run-could-not-be-created" }; | ||
} | ||
if (responseState.failureReason === "network-error") | ||
log.error(`đĢ Network error from deploy_success, aborting.`); | ||
else if (responseState.failureReason === "server-error") | ||
else if (responseState.failureReason === "5XX-server-error") | ||
log.error(`đĢ Server error from deploy_success (status ${responseState.httpStatus}), aborting. Please contact support.`); | ||
else if (responseState.failureReason === "unrecoverable-error") { | ||
else if (responseState.failureReason === "4XX-client-error") { | ||
log.error(`đĢ Unrecoverable error from deploy_success (status ${responseState.httpStatus}), aborting. Please contact support.`); | ||
} | ||
else if (responseState.failureReason === "forbidden") { | ||
else if (responseState.failureReason === "403-forbidden") { | ||
log.error(`đĢ Forbidden error from deploy_success (status ${responseState.httpStatus}), aborting. Please contact support.`); | ||
} | ||
else if (responseState.failureReason === "unauthorized") { | ||
else if (responseState.failureReason === "401-unauthorized") { | ||
log.error(`đĢ Unauthorized error from deploy_success (status ${responseState.httpStatus}), aborting. Please contact support.`); | ||
@@ -35,3 +35,14 @@ } | ||
} | ||
return { outcome: "aborted" }; | ||
if (responseState.failureReason === "network-error") { | ||
return { | ||
outcome: "aborted", | ||
abortReason: "network-error", | ||
httpStatus: undefined, | ||
}; | ||
} | ||
return { | ||
outcome: "aborted", | ||
abortReason: responseState.failureReason, | ||
httpStatus: responseState.httpStatus, | ||
}; | ||
} | ||
@@ -38,0 +49,0 @@ log.info(`â Run created with ID: ${responseState.runId}`); |
@@ -35,2 +35,3 @@ export async function fetchCiGreenlightStatus({ serviceBase, apiKey }, { runId, }, { fetch: localFetch }) { | ||
httpStatus: resp.status, | ||
errorType: "client", | ||
ok: false, | ||
@@ -37,0 +38,0 @@ }; |
@@ -49,3 +49,3 @@ export async function postDeploySuccess({ apiKey, serviceBase }, { branch, commitUrl, deduplicationKey, deploymentType, deploymentUrl, hostingService, sha, variables, }, { fetch: localFetch }) { | ||
return { | ||
failureReason: "server-error", | ||
failureReason: "5XX-server-error", | ||
httpStatus: response.status, | ||
@@ -57,3 +57,3 @@ success: false, | ||
return { | ||
failureReason: "unauthorized", | ||
failureReason: "401-unauthorized", | ||
httpStatus: response.status, | ||
@@ -65,3 +65,3 @@ success: false, | ||
return { | ||
failureReason: "forbidden", | ||
failureReason: "403-forbidden", | ||
httpStatus: response.status, | ||
@@ -72,3 +72,3 @@ success: false, | ||
return { | ||
failureReason: "unrecoverable-error", | ||
failureReason: "4XX-client-error", | ||
httpStatus: response.status, | ||
@@ -75,0 +75,0 @@ success: false, |
@@ -9,19 +9,19 @@ import { postDeploySuccess } from "../../api/deploy.js"; | ||
log.error(`đĢ No trigger matched the request. Please contact support.`); | ||
return { outcome: "failed" }; | ||
return { outcome: "failed", failReason: "no-matched-trigger" }; | ||
} | ||
else if (responseState.failureReason === "run-could-not-be-created") { | ||
log.error(`đĢ Run could not be created. Reason: "${responseState.details}". Please contact support.`); | ||
return { outcome: "failed" }; | ||
return { outcome: "failed", failReason: "run-could-not-be-created" }; | ||
} | ||
if (responseState.failureReason === "network-error") | ||
log.error(`đĢ Network error from deploy_success, aborting.`); | ||
else if (responseState.failureReason === "server-error") | ||
else if (responseState.failureReason === "5XX-server-error") | ||
log.error(`đĢ Server error from deploy_success (status ${responseState.httpStatus}), aborting. Please contact support.`); | ||
else if (responseState.failureReason === "unrecoverable-error") { | ||
else if (responseState.failureReason === "4XX-client-error") { | ||
log.error(`đĢ Unrecoverable error from deploy_success (status ${responseState.httpStatus}), aborting. Please contact support.`); | ||
} | ||
else if (responseState.failureReason === "forbidden") { | ||
else if (responseState.failureReason === "403-forbidden") { | ||
log.error(`đĢ Forbidden error from deploy_success (status ${responseState.httpStatus}), aborting. Please contact support.`); | ||
} | ||
else if (responseState.failureReason === "unauthorized") { | ||
else if (responseState.failureReason === "401-unauthorized") { | ||
log.error(`đĢ Unauthorized error from deploy_success (status ${responseState.httpStatus}), aborting. Please contact support.`); | ||
@@ -32,3 +32,14 @@ } | ||
} | ||
return { outcome: "aborted" }; | ||
if (responseState.failureReason === "network-error") { | ||
return { | ||
outcome: "aborted", | ||
abortReason: "network-error", | ||
httpStatus: undefined, | ||
}; | ||
} | ||
return { | ||
outcome: "aborted", | ||
abortReason: responseState.failureReason, | ||
httpStatus: responseState.httpStatus, | ||
}; | ||
} | ||
@@ -35,0 +46,0 @@ log.info(`â Run created with ID: ${responseState.runId}`); |
@@ -104,5 +104,5 @@ import { ApiConfig } from "../api-types.js"; | ||
readonly httpStatus: number; | ||
readonly errorType: "client"; | ||
readonly ok: false; | ||
readonly greenlightStatus?: never; | ||
readonly errorType?: never; | ||
} | { | ||
@@ -109,0 +109,0 @@ readonly canRetry: true; |
@@ -42,3 +42,3 @@ import { ApiConfig } from "../api-types.js"; | ||
} | { | ||
readonly failureReason: "server-error"; | ||
readonly failureReason: "5XX-server-error"; | ||
readonly httpStatus: number; | ||
@@ -49,3 +49,3 @@ readonly success: false; | ||
} | { | ||
readonly failureReason: "unauthorized"; | ||
readonly failureReason: "401-unauthorized"; | ||
readonly httpStatus: 401; | ||
@@ -56,3 +56,3 @@ readonly success: false; | ||
} | { | ||
readonly failureReason: "forbidden"; | ||
readonly failureReason: "403-forbidden"; | ||
readonly httpStatus: 403; | ||
@@ -63,3 +63,3 @@ readonly success: false; | ||
} | { | ||
readonly failureReason: "unrecoverable-error"; | ||
readonly failureReason: "4XX-client-error"; | ||
readonly httpStatus: number; | ||
@@ -66,0 +66,0 @@ readonly success: false; |
import { DeployConfig } from "../../api/deploy.js"; | ||
import { SdkDependencies } from "../dependencies.js"; | ||
import { ApiConfig } from "../../api-types.js"; | ||
export type AttemptDeployFailedReason = "no-matched-trigger" | "run-could-not-be-created"; | ||
export type AttemptDeployHttpAbortReason = "4XX-client-error" | "401-unauthorized" | "403-forbidden" | "5XX-server-error"; | ||
export type AttemptDeployNonHttpAbortReason = "network-error"; | ||
export type AttemptDeployAbortReason = AttemptDeployHttpAbortReason | AttemptDeployNonHttpAbortReason; | ||
export type NotifyDeployStatus = { | ||
@@ -15,2 +19,3 @@ /** | ||
outcome: "failed"; | ||
failReason: AttemptDeployFailedReason; | ||
} | { | ||
@@ -21,3 +26,12 @@ /** | ||
outcome: "aborted"; | ||
abortReason: AttemptDeployNonHttpAbortReason; | ||
httpStatus: undefined; | ||
} | { | ||
/** | ||
* An unrecoverable HTTP error occurred. | ||
*/ | ||
outcome: "aborted"; | ||
abortReason: AttemptDeployHttpAbortReason; | ||
httpStatus: number; | ||
}; | ||
export declare function attemptNotifyDeploy(deps: SdkDependencies, apiConfig: ApiConfig, config: Partial<DeployConfig>): Promise<NotifyDeployStatus>; |
import { CiGreenlightStatus } from "../../api/ci-greenlight.js"; | ||
import { ApiConfig } from "../../api-types.js"; | ||
import { SdkDependencies } from "../dependencies.js"; | ||
export type PollConfig = { | ||
export type PollCiGreenlightPollConfig = { | ||
/** | ||
@@ -36,5 +36,5 @@ * Maximum number of network operations retries before aborting the job. | ||
}; | ||
export type HttpRelatedAbortReason = "4XX-client-error" | "404-run-not-found" | "5XX-server-error" | "XXX-other-http-code"; | ||
export type NonHttpRelatedAbortReason = "poll-timed-out" | "run-canceled" | "network-error"; | ||
export type AbortReason = NonHttpRelatedAbortReason | HttpRelatedAbortReason; | ||
export type PollCiGreenlightHttpAbortReason = "4XX-client-error" | "404-run-not-found" | "5XX-server-error" | "XXX-other-http-code"; | ||
export type PollCiGreenlightNonHttpAbortReason = "poll-timed-out" | "run-canceled" | "network-error"; | ||
export type PollCiGreenlightAbortReason = PollCiGreenlightNonHttpAbortReason | PollCiGreenlightHttpAbortReason; | ||
export type PollCiGreenlightStatus = { | ||
@@ -61,3 +61,3 @@ /** | ||
outcome: "aborted"; | ||
abortReason: HttpRelatedAbortReason; | ||
abortReason: PollCiGreenlightHttpAbortReason; | ||
httpStatus: number; | ||
@@ -69,3 +69,3 @@ } | { | ||
outcome: "aborted"; | ||
abortReason: NonHttpRelatedAbortReason; | ||
abortReason: PollCiGreenlightNonHttpAbortReason; | ||
httpStatus: undefined; | ||
@@ -79,3 +79,3 @@ }; | ||
onRunStageChanged?: (current: CiGreenlightStatus, previous: CiGreenlightStatus | undefined) => unknown | Promise<unknown>; | ||
} & Partial<PollConfig>; | ||
} & Partial<PollCiGreenlightPollConfig>; | ||
export declare function pollCiGreenlightStatus(deps: SdkDependencies, apiConfig: ApiConfig, { runId, onRunStageChanged: onRunStageChanged, ...pollConfig }: PollCiGreenlightParams): Promise<PollCiGreenlightStatus>; |
@@ -9,1 +9,3 @@ import { SdkDependencies } from "./dependencies.js"; | ||
}; | ||
export type * from "./domain/poll-ci-greenlight.js"; | ||
export type * from "./domain/attempt-deploy.js"; |
{ | ||
"name": "@qawolf/ci-sdk", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"description": "A simple SDK for interacting with QAWolf in CI scripts.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -104,2 +104,8 @@ # QAWolf CI SDK | ||
## v0.14.0 | ||
- New `failReason`, `abortReason` and `httpStatus` fields added to the `attemptNotifyDeploy` | ||
function result object to provide more context on why the operation failed or was aborted. | ||
- Exported missing TypeScript typings describing result objects and fields for both functions. | ||
## v0.13.0 | ||
@@ -142,3 +148,3 @@ | ||
- Renamed `attemptDeploy` to `attemptNotifyDeploy`. | ||
- Renamed `attemptDeploy` to `attemptNotifyDeploy` . | ||
@@ -145,0 +151,0 @@ ## v0.10.2 |
50612
1130
166