@qawolf/ci-sdk 3.3.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -12
- package/dist/index.js +190 -113
- package/dist/index.js.map +4 -4
- package/dist/lib/sdk/domain/environment/promote.d.ts +9 -0
- package/dist/lib/sdk/domain/environment/terminate.d.ts +8 -0
- package/dist/lib/sdk/domain/environment/types.d.ts +27 -0
- package/dist/lib/sdk/domain/generateSignedUrls/types.d.ts +3 -3
- package/dist/lib/sdk/domain/promotion/get.d.ts +5 -0
- package/dist/lib/sdk/domain/promotion/testSeed.d.ts +14 -0
- package/dist/lib/sdk/domain/promotion/types.d.ts +17 -0
- package/dist/lib/sdk/index.d.ts +30 -6
- package/dist/lib/sdk/publicApi/callContract.d.ts +2 -0
- package/dist/lib/sdk/publicApi/mapFailure.d.ts +47 -0
- package/package.json +7 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ApiConfig } from "../../../api-types.js";
|
|
2
|
+
import type { SdkDependencies } from "../../dependencies.js";
|
|
3
|
+
import type { PromoteEnvironmentParams, PromoteEnvironmentResult } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Declares a preview environment's work accepted: its flow changes are merged
|
|
6
|
+
* into its base and the environment is terminated once they land. The merge
|
|
7
|
+
* runs in the background, so the promotion comes back `pending`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function promoteEnvironment(deps: SdkDependencies, apiConfig: ApiConfig, params: PromoteEnvironmentParams): Promise<PromoteEnvironmentResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ApiConfig } from "../../../api-types.js";
|
|
2
|
+
import type { SdkDependencies } from "../../dependencies.js";
|
|
3
|
+
import type { TerminateEnvironmentParams, TerminateEnvironmentResult } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Terminates a preview environment whose work is abandoned: its runs are
|
|
6
|
+
* canceled and its flow changes are never promoted into its base.
|
|
7
|
+
*/
|
|
8
|
+
export declare function terminateEnvironment(deps: SdkDependencies, apiConfig: ApiConfig, params: TerminateEnvironmentParams): Promise<TerminateEnvironmentResult>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PublicApiInput, PublicApiOutput, publicContractsV1 } from "@qawolf/api-contracts";
|
|
2
|
+
import type { PublicApiFailureResult } from "../../publicApi/mapFailure.js";
|
|
3
|
+
import type { Promotion } from "../promotion/types.js";
|
|
4
|
+
export type PromoteEnvironmentParams = PublicApiInput<typeof publicContractsV1.environment.promote>;
|
|
5
|
+
export type TerminateEnvironmentParams = PublicApiInput<typeof publicContractsV1.environment.terminate>;
|
|
6
|
+
/**
|
|
7
|
+
* The environment as the `environment.terminate` contract describes it, with
|
|
8
|
+
* `terminatedAt` set.
|
|
9
|
+
*/
|
|
10
|
+
export type TerminatedEnvironment = PublicApiOutput<typeof publicContractsV1.environment.terminate>;
|
|
11
|
+
/**
|
|
12
|
+
* Refusals shared by both environment writes. `invalid-request` covers a
|
|
13
|
+
* terminated environment, for a promotion an environment with no base, and an
|
|
14
|
+
* alias sent without the `workspaceId` an organization or user API key needs
|
|
15
|
+
* to resolve it; `not-found` covers an unknown environment.
|
|
16
|
+
*/
|
|
17
|
+
export type EnvironmentWriteFailure = PublicApiFailureResult;
|
|
18
|
+
export type PromoteEnvironmentResult =
|
|
19
|
+
/** The promotion was requested. It starts `pending`; `promotion.get` says how it settles. */
|
|
20
|
+
{
|
|
21
|
+
outcome: "requested";
|
|
22
|
+
promotion: Promotion;
|
|
23
|
+
} | EnvironmentWriteFailure;
|
|
24
|
+
export type TerminateEnvironmentResult = {
|
|
25
|
+
environment: TerminatedEnvironment;
|
|
26
|
+
outcome: "terminated";
|
|
27
|
+
} | EnvironmentWriteFailure;
|
|
@@ -14,9 +14,9 @@ export type GenerateSignedUrlAbortReason = "client-network-error" | "sdk-argumen
|
|
|
14
14
|
export type GenerateSignedUrlConfig = {
|
|
15
15
|
destinationFilePath: string;
|
|
16
16
|
/**
|
|
17
|
-
* The workspace to generate the URL for. Required
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* The workspace to generate the URL for. Required for an organization or user
|
|
18
|
+
* API key whose organization has several enabled workspaces; when omitted, the
|
|
19
|
+
* only enabled workspace is used. A workspace API key already implies one.
|
|
20
20
|
*/
|
|
21
21
|
workspaceId?: string;
|
|
22
22
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ApiConfig } from "../../../api-types.js";
|
|
2
|
+
import type { SdkDependencies } from "../../dependencies.js";
|
|
3
|
+
import type { GetPromotionParams, GetPromotionResult } from "./types.js";
|
|
4
|
+
/** Reads one promotion, typically to learn how `environment.promote` settled. */
|
|
5
|
+
export declare function getPromotion(deps: SdkDependencies, apiConfig: ApiConfig, params: GetPromotionParams): Promise<GetPromotionResult>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Promotion } from "./types.js";
|
|
2
|
+
/** A pending promotion as the public API serializes it. */
|
|
3
|
+
export declare function buildPendingPromotion(): Promotion;
|
|
4
|
+
/** A tRPC error body as the server's superjson transformer serializes it. */
|
|
5
|
+
export declare function buildTrpcErrorBody(message: string): {
|
|
6
|
+
error: {
|
|
7
|
+
json: {
|
|
8
|
+
data: {
|
|
9
|
+
eventId: string;
|
|
10
|
+
};
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PublicApiInput, PublicApiOutput, publicContractsV1 } from "@qawolf/api-contracts";
|
|
2
|
+
import type { PublicApiFailureResult } from "../../publicApi/mapFailure.js";
|
|
3
|
+
export type GetPromotionParams = PublicApiInput<typeof publicContractsV1.promotion.get>;
|
|
4
|
+
/**
|
|
5
|
+
* A promotion exactly as the `promotion.get` contract describes it. `status`
|
|
6
|
+
* starts `pending` and settles as `promoted`, `no-changes` or `abandoned`;
|
|
7
|
+
* `conflicted` and `resolving` wait on a resolution, with `conflict` naming
|
|
8
|
+
* the paths.
|
|
9
|
+
*/
|
|
10
|
+
export type Promotion = PublicApiOutput<typeof publicContractsV1.promotion.get>;
|
|
11
|
+
export type PromotionStatus = Promotion["status"];
|
|
12
|
+
export type GetPromotionResult = {
|
|
13
|
+
outcome: "found";
|
|
14
|
+
promotion: Promotion;
|
|
15
|
+
}
|
|
16
|
+
/** `not-found` covers an unknown promotion id. */
|
|
17
|
+
| PublicApiFailureResult;
|
package/dist/lib/sdk/index.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
|
|
|
41
41
|
blockingBugCount: number;
|
|
42
42
|
runId: string;
|
|
43
43
|
runUrl: string;
|
|
44
|
-
status: "canceled" | "failed" | "
|
|
44
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
45
45
|
triggerName: string;
|
|
46
46
|
supersededBy?: {
|
|
47
47
|
runId: string;
|
|
@@ -56,7 +56,7 @@ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
|
|
|
56
56
|
blockingBugCount: number;
|
|
57
57
|
runId: string;
|
|
58
58
|
runUrl: string;
|
|
59
|
-
status: "canceled" | "failed" | "
|
|
59
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
60
60
|
triggerName: string;
|
|
61
61
|
supersededBy?: {
|
|
62
62
|
runId: string;
|
|
@@ -79,7 +79,7 @@ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
|
|
|
79
79
|
blockingBugCount: number;
|
|
80
80
|
runId: string;
|
|
81
81
|
runUrl: string;
|
|
82
|
-
status: "canceled" | "failed" | "
|
|
82
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
83
83
|
triggerName: string;
|
|
84
84
|
supersededBy?: {
|
|
85
85
|
runId: string;
|
|
@@ -93,7 +93,7 @@ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
|
|
|
93
93
|
blockingBugCount: number;
|
|
94
94
|
runId: string;
|
|
95
95
|
runUrl: string;
|
|
96
|
-
status: "canceled" | "failed" | "
|
|
96
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
97
97
|
triggerName: string;
|
|
98
98
|
supersededBy?: {
|
|
99
99
|
runId: string;
|
|
@@ -117,7 +117,7 @@ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
|
|
|
117
117
|
blockingBugCount: number;
|
|
118
118
|
runId: string;
|
|
119
119
|
runUrl: string;
|
|
120
|
-
status: "canceled" | "failed" | "
|
|
120
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
121
121
|
triggerName: string;
|
|
122
122
|
supersededBy?: {
|
|
123
123
|
runId: string;
|
|
@@ -131,7 +131,7 @@ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
|
|
|
131
131
|
blockingBugCount: number;
|
|
132
132
|
runId: string;
|
|
133
133
|
runUrl: string;
|
|
134
|
-
status: "canceled" | "failed" | "
|
|
134
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
135
135
|
triggerName: string;
|
|
136
136
|
supersededBy?: {
|
|
137
137
|
runId: string;
|
|
@@ -166,6 +166,16 @@ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
|
|
|
166
166
|
outcome: "invalid-response-body";
|
|
167
167
|
}>;
|
|
168
168
|
};
|
|
169
|
+
environment: {
|
|
170
|
+
promote: (params: {
|
|
171
|
+
environmentId: string;
|
|
172
|
+
workspaceId?: string | undefined;
|
|
173
|
+
}) => Promise<import("./domain/environment/types.js").PromoteEnvironmentResult>;
|
|
174
|
+
terminate: (params: {
|
|
175
|
+
environmentId: string;
|
|
176
|
+
workspaceId?: string | undefined;
|
|
177
|
+
}) => Promise<import("./domain/environment/types.js").TerminateEnvironmentResult>;
|
|
178
|
+
};
|
|
169
179
|
generateSignedUrlForRunInputsExecutablesStorage: (config: import("./domain/generateSignedUrls/types.js").GenerateSignedUrlConfig) => Promise<import("./domain/generateSignedUrls/types.js").GenerateSignedUrlStatus>;
|
|
170
180
|
generateSignedUrlForTempTeamStorage: (config: import("./domain/generateSignedUrls/types.js").GenerateSignedUrlConfig) => Promise<{
|
|
171
181
|
fileLocation?: string;
|
|
@@ -179,16 +189,30 @@ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
|
|
|
179
189
|
success: false;
|
|
180
190
|
}>;
|
|
181
191
|
makePollCiGreenlightStatusIterator: (args_0: import("./domain/pollCiGreenlight/types.js").MakePollCiGreenlightStatusIteratorParams) => AsyncGenerator<import("./domain/pollCiGreenlight/types.js").PollCiGreenlightIteration, void, unknown>;
|
|
192
|
+
/**
|
|
193
|
+
* @deprecated Despite its name this performs a promote: the legacy
|
|
194
|
+
* `environment_terminated` webhook merges the environment's flow changes
|
|
195
|
+
* into its base and then terminates it. Use `environment.promote` for
|
|
196
|
+
* accepted work, and `environment.terminate` to discard abandoned work,
|
|
197
|
+
* which this method has never done.
|
|
198
|
+
*/
|
|
182
199
|
notifyTerminatedEphemeralEnvironment: (config: import("./domain/notifyTerminatedEphemeralEnvironment/types.js").NotifyTerminatedEphemeralEnvironmentInput) => Promise<import("./domain/notifyTerminatedEphemeralEnvironment/types.js").NotifyTerminatedEphemeralEnvironmentResult>;
|
|
183
200
|
/**
|
|
184
201
|
* @deprecated Polls a run id that only `attemptNotifyDeploy` returns, so it
|
|
185
202
|
* keeps the pipeline on the legacy `deploy_success` webhook.
|
|
186
203
|
*/
|
|
187
204
|
pollCiGreenlightStatus: (args_0: import("./domain/pollCiGreenlight/types.js").PollCiGreenlightParams) => Promise<import("./domain/pollCiGreenlight/types.js").PollCiGreenlightStatus>;
|
|
205
|
+
promotion: {
|
|
206
|
+
get: (params: {
|
|
207
|
+
promotionId: string;
|
|
208
|
+
}) => Promise<import("./domain/promotion/types.js").GetPromotionResult>;
|
|
209
|
+
};
|
|
188
210
|
};
|
|
189
211
|
export type * from "./domain/attemptDeploy/index.js";
|
|
212
|
+
export type * from "./domain/environment/types.js";
|
|
190
213
|
export type * from "./domain/generateSignedUrls/types.js";
|
|
191
214
|
export type * from "./domain/notifyTerminatedEphemeralEnvironment/types.js";
|
|
192
215
|
export type * from "./domain/pollCiGreenlight/types.js";
|
|
216
|
+
export type * from "./domain/promotion/types.js";
|
|
193
217
|
export type * from "./domain/reportDeployment/types.js";
|
|
194
218
|
export type * from "./domain/waitForVerdict/types.js";
|
|
@@ -7,6 +7,8 @@ import type { SdkDependencies } from "../dependencies.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export type PublicApiContract<InputData = unknown, OutputData = unknown> = {
|
|
9
9
|
input: z.ZodType<unknown, InputData>;
|
|
10
|
+
/** A `read` is served as a tRPC query, which the server only accepts as GET. */
|
|
11
|
+
kind: "read" | "write";
|
|
10
12
|
name: string;
|
|
11
13
|
output: z.ZodType<OutputData>;
|
|
12
14
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PublicApiCallFailure } from "./callContract.js";
|
|
2
|
+
/**
|
|
3
|
+
* The refusals every contract-backed function answers with, keyed by the HTTP
|
|
4
|
+
* status the public API uses for them. Each function documents what the
|
|
5
|
+
* statuses mean for its own contract.
|
|
6
|
+
*/
|
|
7
|
+
export type PublicApiFailureResult =
|
|
8
|
+
/** The input did not satisfy the contract, or a business rule refused it. HTTP 400. */
|
|
9
|
+
{
|
|
10
|
+
message: string | undefined;
|
|
11
|
+
outcome: "invalid-request";
|
|
12
|
+
}
|
|
13
|
+
/** The API key is unknown, or may not act on this workspace. HTTP 401 and 403. */
|
|
14
|
+
| {
|
|
15
|
+
message: string | undefined;
|
|
16
|
+
outcome: "unauthorized";
|
|
17
|
+
}
|
|
18
|
+
/** The entity the call names does not exist. HTTP 404. */
|
|
19
|
+
| {
|
|
20
|
+
message: string | undefined;
|
|
21
|
+
outcome: "not-found";
|
|
22
|
+
}
|
|
23
|
+
/** The call clashes with the entity's current state. HTTP 409. */
|
|
24
|
+
| {
|
|
25
|
+
message: string | undefined;
|
|
26
|
+
outcome: "conflict";
|
|
27
|
+
}
|
|
28
|
+
/** QA Wolf failed to answer; retrying is reasonable. HTTP 5XX. */
|
|
29
|
+
| {
|
|
30
|
+
httpStatus: number;
|
|
31
|
+
outcome: "server-error";
|
|
32
|
+
}
|
|
33
|
+
/** A status this SDK version does not map, carrying what the server sent. */
|
|
34
|
+
| {
|
|
35
|
+
httpStatus: number;
|
|
36
|
+
message: string | undefined;
|
|
37
|
+
outcome: "unexpected-status";
|
|
38
|
+
}
|
|
39
|
+
/** The request never reached QA Wolf, or the connection dropped. */
|
|
40
|
+
| {
|
|
41
|
+
outcome: "network-error";
|
|
42
|
+
}
|
|
43
|
+
/** The server answered 2xx with a body the contract's output rejects. */
|
|
44
|
+
| {
|
|
45
|
+
outcome: "invalid-response-body";
|
|
46
|
+
};
|
|
47
|
+
export declare function mapPublicApiFailure(result: PublicApiCallFailure): PublicApiFailureResult;
|
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qawolf/ci-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A simple SDK for interacting with QAWolf in CI scripts.",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "Jules Sam. Randolph<jules@qawolf.com>",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/qawolf/platform.git",
|
|
12
|
+
"directory": "packages-published-public/ci-sdk"
|
|
13
|
+
},
|
|
9
14
|
"files": [
|
|
10
15
|
"/dist",
|
|
11
16
|
"/README.md"
|
|
@@ -29,7 +34,7 @@
|
|
|
29
34
|
"tsc:check": "tsc --noEmit"
|
|
30
35
|
},
|
|
31
36
|
"dependencies": {
|
|
32
|
-
"@qawolf/api-contracts": ">=0.
|
|
37
|
+
"@qawolf/api-contracts": ">=0.89.0",
|
|
33
38
|
"@qawolf/ci-utils": "^2.0.0",
|
|
34
39
|
"@sinonjs/fake-timers": "^10.3.0",
|
|
35
40
|
"tslib": "^2.6.2",
|