@qawolf/ci-sdk 3.4.1 → 3.5.0
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 +49 -0
- package/dist/index.js +96 -7
- package/dist/index.js.map +4 -4
- package/dist/lib/sdk/domain/uploadBuild/index.d.ts +9 -0
- package/dist/lib/sdk/domain/uploadBuild/testHarness.d.ts +17 -0
- package/dist/lib/sdk/domain/uploadBuild/testSeed.d.ts +23 -0
- package/dist/lib/sdk/domain/uploadBuild/types.d.ts +66 -0
- package/dist/lib/sdk/domain/uploadBuild/withBuildFile.d.ts +4 -0
- package/dist/lib/sdk/index.d.ts +3 -0
- package/dist/tests/test-lib.d.ts +237 -0
- package/package.json +2 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ApiConfig } from "../../../api-types.js";
|
|
2
|
+
import type { SdkDependencies } from "../../dependencies.js";
|
|
3
|
+
import type { UploadBuildParams, UploadBuildResult } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Uploads an app build and registers it: asks QA Wolf for a create-only
|
|
6
|
+
* upload URL, streams the file there, then creates the build, which reads the
|
|
7
|
+
* app id, version and build number from the file.
|
|
8
|
+
*/
|
|
9
|
+
export declare function uploadBuild(deps: SdkDependencies, apiConfig: ApiConfig, { branch, commitSha, environment, filePath, workspaceId }: UploadBuildParams): Promise<UploadBuildResult>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type MockFetch = {
|
|
2
|
+
mock: {
|
|
3
|
+
calls: unknown[][];
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
export declare const apkFile: {
|
|
7
|
+
contents: string;
|
|
8
|
+
fileName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function readRequestAt(fetch: MockFetch, index: number): {
|
|
11
|
+
init: RequestInit;
|
|
12
|
+
url: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function readJsonBodyAt(fetch: MockFetch, index: number): unknown;
|
|
15
|
+
export declare function requestUploadResponse(): Response;
|
|
16
|
+
export declare function createResponse(): Response;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UploadedBuild } from "./types.js";
|
|
2
|
+
export declare const buildId = "abcdefghijklmnopqrstuvwxobld";
|
|
3
|
+
export declare function buildUploadedBuild(): UploadedBuild;
|
|
4
|
+
export declare function buildRequestUploadAnswer(): {
|
|
5
|
+
buildId: string;
|
|
6
|
+
expiresAt: string;
|
|
7
|
+
uploadHeaders: {
|
|
8
|
+
"Content-Type": string;
|
|
9
|
+
"x-goog-if-generation-match": string;
|
|
10
|
+
};
|
|
11
|
+
uploadUrl: string;
|
|
12
|
+
};
|
|
13
|
+
/** A tRPC error body as the server's superjson transformer serializes it. */
|
|
14
|
+
export declare function buildTrpcErrorBody(message: string): {
|
|
15
|
+
error: {
|
|
16
|
+
json: {
|
|
17
|
+
data: {
|
|
18
|
+
eventId: string;
|
|
19
|
+
};
|
|
20
|
+
message: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { PublicApiInput, PublicApiOutput, publicContractsV1 } from "@qawolf/api-contracts";
|
|
2
|
+
import type { PublicApiFailureResult } from "../../publicApi/mapFailure.js";
|
|
3
|
+
type CreateBuildInput = PublicApiInput<typeof publicContractsV1.build.create>;
|
|
4
|
+
export type UploadBuildParams = {
|
|
5
|
+
/** The branch the build came from. Shown with the build. */
|
|
6
|
+
branch?: CreateBuildInput["branch"];
|
|
7
|
+
/** The commit the build came from. Shown with the build. */
|
|
8
|
+
commitSha?: CreateBuildInput["commitSha"];
|
|
9
|
+
/**
|
|
10
|
+
* The environment whose runs install the build from now on, until a newer
|
|
11
|
+
* build of the same app and platform arrives: `{ id }` for an existing
|
|
12
|
+
* environment, or `{ name, ephemeral?, baseEphemeralEnvironment? }`, which
|
|
13
|
+
* creates the environment when none matches. Omit it for a build that only
|
|
14
|
+
* runs created with it install.
|
|
15
|
+
*/
|
|
16
|
+
environment?: CreateBuildInput["environment"];
|
|
17
|
+
/** Path of the `.apk`, `.aab` or `.ipa` file to upload, at most 500 MB. */
|
|
18
|
+
filePath: string;
|
|
19
|
+
/**
|
|
20
|
+
* The workspace to upload into. Required when authenticating with an
|
|
21
|
+
* organization or user API key.
|
|
22
|
+
*/
|
|
23
|
+
workspaceId?: CreateBuildInput["workspaceId"];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The build as the `build.create` contract describes it: its id, the app id,
|
|
27
|
+
* version and build number read from the file, and the platform.
|
|
28
|
+
*/
|
|
29
|
+
export type UploadedBuild = PublicApiOutput<typeof publicContractsV1.build.create>["build"];
|
|
30
|
+
export type UploadBuildResult = {
|
|
31
|
+
build: UploadedBuild;
|
|
32
|
+
outcome: "uploaded";
|
|
33
|
+
}
|
|
34
|
+
/** `filePath` does not name a readable file. */
|
|
35
|
+
| {
|
|
36
|
+
filePath: string;
|
|
37
|
+
outcome: "file-unreadable";
|
|
38
|
+
}
|
|
39
|
+
/** Storage refused the file's bytes, for example because the upload URL expired. */
|
|
40
|
+
| {
|
|
41
|
+
buildId: string;
|
|
42
|
+
httpStatus: number;
|
|
43
|
+
outcome: "upload-rejected";
|
|
44
|
+
}
|
|
45
|
+
/** The file's bytes never reached storage, or the connection dropped. */
|
|
46
|
+
| {
|
|
47
|
+
buildId: string;
|
|
48
|
+
outcome: "upload-network-error";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* QA Wolf refused to sign the upload. `invalid-request` covers a file that
|
|
52
|
+
* is not an `.apk`, `.aab` or `.ipa`, or is larger than 500 MB.
|
|
53
|
+
*/
|
|
54
|
+
| (PublicApiFailureResult & {
|
|
55
|
+
failedStep: "request-upload";
|
|
56
|
+
})
|
|
57
|
+
/**
|
|
58
|
+
* QA Wolf refused to create the build from the uploaded file.
|
|
59
|
+
* `invalid-request` covers a file that is not an app. The file is already in
|
|
60
|
+
* storage; the `buildId` identifies it.
|
|
61
|
+
*/
|
|
62
|
+
| (PublicApiFailureResult & {
|
|
63
|
+
buildId: string;
|
|
64
|
+
failedStep: "create";
|
|
65
|
+
});
|
|
66
|
+
export {};
|
package/dist/lib/sdk/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
|
|
|
14
14
|
providerDeploymentId: string;
|
|
15
15
|
status: "success" | "pending" | "failure" | "inactive";
|
|
16
16
|
workspaceId: string;
|
|
17
|
+
builds?: string[] | undefined;
|
|
17
18
|
deployTarget?: string | undefined;
|
|
18
19
|
environment?: {
|
|
19
20
|
id: string;
|
|
@@ -207,6 +208,7 @@ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
|
|
|
207
208
|
promotionId: string;
|
|
208
209
|
}) => Promise<import("./domain/promotion/types.js").GetPromotionResult>;
|
|
209
210
|
};
|
|
211
|
+
uploadBuild: (args_0: import("./domain/uploadBuild/types.js").UploadBuildParams) => Promise<import("./domain/uploadBuild/types.js").UploadBuildResult>;
|
|
210
212
|
};
|
|
211
213
|
export type * from "./domain/attemptDeploy/index.js";
|
|
212
214
|
export type * from "./domain/environment/types.js";
|
|
@@ -215,4 +217,5 @@ export type * from "./domain/notifyTerminatedEphemeralEnvironment/types.js";
|
|
|
215
217
|
export type * from "./domain/pollCiGreenlight/types.js";
|
|
216
218
|
export type * from "./domain/promotion/types.js";
|
|
217
219
|
export type * from "./domain/reportDeployment/types.js";
|
|
220
|
+
export type * from "./domain/uploadBuild/types.js";
|
|
218
221
|
export type * from "./domain/waitForVerdict/types.js";
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import FakeTimers from "@sinonjs/fake-timers";
|
|
2
|
+
import type { CiGreenlightStatusBase, CiGreenlightStatusExtended } from "../lib/api/ci-greenlight.js";
|
|
3
|
+
import type { LogDriver } from "../lib/sdk/dependencies.js";
|
|
4
|
+
export declare function makeQaWolfSdkForTest({ apiKey }: {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
}): {
|
|
7
|
+
fetch: import("jest-mock").Mock<() => Promise<Response>>;
|
|
8
|
+
log: LogDriver;
|
|
9
|
+
sdk: {
|
|
10
|
+
attemptNotifyDeploy: (config: Partial<import("../index.js").DeployConfig>) => Promise<import("../index.js").NotifyDeployStatus>;
|
|
11
|
+
deployment: {
|
|
12
|
+
reportStatus: (params: {
|
|
13
|
+
providerDeploymentId: string;
|
|
14
|
+
status: "success" | "pending" | "failure" | "inactive";
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
builds?: string[] | undefined;
|
|
17
|
+
deployTarget?: string | undefined;
|
|
18
|
+
environment?: {
|
|
19
|
+
id: string;
|
|
20
|
+
} | {
|
|
21
|
+
name: string;
|
|
22
|
+
baseEphemeralEnvironment?: string | undefined;
|
|
23
|
+
ephemeral?: boolean | undefined;
|
|
24
|
+
} | undefined;
|
|
25
|
+
environmentVariables?: Record<string, string> | undefined;
|
|
26
|
+
metadata?: {
|
|
27
|
+
commitAuthorName?: string | undefined;
|
|
28
|
+
commitMessage?: string | undefined;
|
|
29
|
+
commitSha?: string | undefined;
|
|
30
|
+
commitUrl?: string | undefined;
|
|
31
|
+
pullRequestNumber?: number | undefined;
|
|
32
|
+
ref?: string | undefined;
|
|
33
|
+
repository?: string | undefined;
|
|
34
|
+
} | undefined;
|
|
35
|
+
service?: string | undefined;
|
|
36
|
+
}) => Promise<import("../lib/sdk/index.js").ReportDeploymentResult>;
|
|
37
|
+
waitForVerdict: (args_0: import("../lib/sdk/index.js").WaitForVerdictParams) => Promise<{
|
|
38
|
+
deploymentId: string;
|
|
39
|
+
outcome: "passed";
|
|
40
|
+
runs: {
|
|
41
|
+
blockingBugCount: number;
|
|
42
|
+
runId: string;
|
|
43
|
+
runUrl: string;
|
|
44
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
45
|
+
triggerName: string;
|
|
46
|
+
supersededBy?: {
|
|
47
|
+
runId: string;
|
|
48
|
+
url: string;
|
|
49
|
+
} | undefined;
|
|
50
|
+
}[];
|
|
51
|
+
} | {
|
|
52
|
+
blockingBugCount: number;
|
|
53
|
+
deploymentId: string;
|
|
54
|
+
outcome: "failed";
|
|
55
|
+
runs: {
|
|
56
|
+
blockingBugCount: number;
|
|
57
|
+
runId: string;
|
|
58
|
+
runUrl: string;
|
|
59
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
60
|
+
triggerName: string;
|
|
61
|
+
supersededBy?: {
|
|
62
|
+
runId: string;
|
|
63
|
+
url: string;
|
|
64
|
+
} | undefined;
|
|
65
|
+
}[];
|
|
66
|
+
} | {
|
|
67
|
+
deploymentId: string;
|
|
68
|
+
outcome: "not-tested";
|
|
69
|
+
reason: "no-trigger-matched" | "no-run-created";
|
|
70
|
+
triggers: {
|
|
71
|
+
message: string;
|
|
72
|
+
triggerName: string;
|
|
73
|
+
reason?: "skipped" | "billing-prevented" | "branch-still-syncing" | "deployment-no-longer-live" | "duplicate-run" | "environment-not-linked-to-branch" | "environment-not-ready" | "environment-terminated" | "internal-error" | "low-risk-change" | "no-flows-to-run" | "no-matching-trigger" | "no-pull-request" | "no-relevant-flows" | "rate-limited" | "run-not-created" | "test-configuration-error" | "trigger-not-found" | "workspace-inactive" | "workspace-not-ready" | undefined;
|
|
74
|
+
}[];
|
|
75
|
+
} | {
|
|
76
|
+
deploymentId: string;
|
|
77
|
+
outcome: "run-canceled";
|
|
78
|
+
runs: {
|
|
79
|
+
blockingBugCount: number;
|
|
80
|
+
runId: string;
|
|
81
|
+
runUrl: string;
|
|
82
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
83
|
+
triggerName: string;
|
|
84
|
+
supersededBy?: {
|
|
85
|
+
runId: string;
|
|
86
|
+
url: string;
|
|
87
|
+
} | undefined;
|
|
88
|
+
}[];
|
|
89
|
+
} | {
|
|
90
|
+
deploymentId: string;
|
|
91
|
+
outcome: "superseded";
|
|
92
|
+
runs: {
|
|
93
|
+
blockingBugCount: number;
|
|
94
|
+
runId: string;
|
|
95
|
+
runUrl: string;
|
|
96
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
97
|
+
triggerName: string;
|
|
98
|
+
supersededBy?: {
|
|
99
|
+
runId: string;
|
|
100
|
+
url: string;
|
|
101
|
+
} | undefined;
|
|
102
|
+
}[];
|
|
103
|
+
supersededBy: {
|
|
104
|
+
runId: string;
|
|
105
|
+
url: string;
|
|
106
|
+
};
|
|
107
|
+
} | {
|
|
108
|
+
deploymentId: string;
|
|
109
|
+
elapsedMs: number;
|
|
110
|
+
lastStage: {
|
|
111
|
+
stage: "waiting-for-evaluation";
|
|
112
|
+
} | {
|
|
113
|
+
matchedTriggerCount: number;
|
|
114
|
+
stage: "waiting-for-run";
|
|
115
|
+
} | {
|
|
116
|
+
runs: {
|
|
117
|
+
blockingBugCount: number;
|
|
118
|
+
runId: string;
|
|
119
|
+
runUrl: string;
|
|
120
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
121
|
+
triggerName: string;
|
|
122
|
+
supersededBy?: {
|
|
123
|
+
runId: string;
|
|
124
|
+
url: string;
|
|
125
|
+
} | undefined;
|
|
126
|
+
}[];
|
|
127
|
+
stage: "waiting-for-verdict";
|
|
128
|
+
};
|
|
129
|
+
outcome: "timed-out";
|
|
130
|
+
runs: {
|
|
131
|
+
blockingBugCount: number;
|
|
132
|
+
runId: string;
|
|
133
|
+
runUrl: string;
|
|
134
|
+
status: "canceled" | "failed" | "running" | "passed" | "superseded" | "queued";
|
|
135
|
+
triggerName: string;
|
|
136
|
+
supersededBy?: {
|
|
137
|
+
runId: string;
|
|
138
|
+
url: string;
|
|
139
|
+
} | undefined;
|
|
140
|
+
}[];
|
|
141
|
+
} | {
|
|
142
|
+
deploymentId: string;
|
|
143
|
+
outcome: "canceled-by-caller";
|
|
144
|
+
} | {
|
|
145
|
+
deploymentId: string;
|
|
146
|
+
outcome: "unauthorized";
|
|
147
|
+
message?: string | undefined;
|
|
148
|
+
} | {
|
|
149
|
+
deploymentId: string;
|
|
150
|
+
outcome: "not-found";
|
|
151
|
+
message?: string | undefined;
|
|
152
|
+
} | {
|
|
153
|
+
deploymentId: string;
|
|
154
|
+
httpStatus: number;
|
|
155
|
+
outcome: "server-error";
|
|
156
|
+
} | {
|
|
157
|
+
deploymentId: string;
|
|
158
|
+
httpStatus: number;
|
|
159
|
+
outcome: "unexpected-status";
|
|
160
|
+
message?: string | undefined;
|
|
161
|
+
} | {
|
|
162
|
+
deploymentId: string;
|
|
163
|
+
outcome: "network-error";
|
|
164
|
+
} | {
|
|
165
|
+
deploymentId: string;
|
|
166
|
+
outcome: "invalid-response-body";
|
|
167
|
+
}>;
|
|
168
|
+
};
|
|
169
|
+
environment: {
|
|
170
|
+
promote: (params: {
|
|
171
|
+
environmentId: string;
|
|
172
|
+
workspaceId?: string | undefined;
|
|
173
|
+
}) => Promise<import("../lib/sdk/index.js").PromoteEnvironmentResult>;
|
|
174
|
+
terminate: (params: {
|
|
175
|
+
environmentId: string;
|
|
176
|
+
workspaceId?: string | undefined;
|
|
177
|
+
}) => Promise<import("../lib/sdk/index.js").TerminateEnvironmentResult>;
|
|
178
|
+
};
|
|
179
|
+
generateSignedUrlForRunInputsExecutablesStorage: (config: import("../lib/sdk/index.js").GenerateSignedUrlConfig) => Promise<import("../lib/sdk/index.js").GenerateSignedUrlStatus>;
|
|
180
|
+
generateSignedUrlForTempTeamStorage: (config: import("../lib/sdk/index.js").GenerateSignedUrlConfig) => Promise<{
|
|
181
|
+
fileLocation?: string;
|
|
182
|
+
interactiveRunFileLocation?: string;
|
|
183
|
+
playgroundFileLocation?: string;
|
|
184
|
+
success: true;
|
|
185
|
+
uploadUrl?: string;
|
|
186
|
+
} | {
|
|
187
|
+
abortReason: import("../lib/sdk/domain/generateSignedUrls/generate-signed-url-for-team-storage.js").GenerateSignedUrlAbortReason;
|
|
188
|
+
httpStatus?: number;
|
|
189
|
+
success: false;
|
|
190
|
+
}>;
|
|
191
|
+
makePollCiGreenlightStatusIterator: (args_0: import("../lib/sdk/index.js").MakePollCiGreenlightStatusIteratorParams) => AsyncGenerator<import("../lib/sdk/index.js").PollCiGreenlightIteration, void, unknown>;
|
|
192
|
+
notifyTerminatedEphemeralEnvironment: (config: import("../lib/sdk/index.js").NotifyTerminatedEphemeralEnvironmentInput) => Promise<import("../lib/sdk/index.js").NotifyTerminatedEphemeralEnvironmentResult>;
|
|
193
|
+
pollCiGreenlightStatus: (args_0: import("../lib/sdk/index.js").PollCiGreenlightParams) => Promise<import("../lib/sdk/index.js").PollCiGreenlightStatus>;
|
|
194
|
+
promotion: {
|
|
195
|
+
get: (params: {
|
|
196
|
+
promotionId: string;
|
|
197
|
+
}) => Promise<import("../lib/sdk/index.js").GetPromotionResult>;
|
|
198
|
+
};
|
|
199
|
+
uploadBuild: (args_0: import("../lib/sdk/index.js").UploadBuildParams) => Promise<import("../lib/sdk/index.js").UploadBuildResult>;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
export declare function buildResponse<ResponseJSON>(response: ResponseJSON, status?: number): Response;
|
|
203
|
+
export declare function buildCiGreenlightStatusBase(): CiGreenlightStatusBase;
|
|
204
|
+
export declare function buildCiGreenlightStatusExtended(): CiGreenlightStatusExtended;
|
|
205
|
+
export declare function setupTimers(): {
|
|
206
|
+
clock: FakeTimers.InstalledClock;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* The JSON body the SDK sent on its most recent request, for tests asserting on
|
|
210
|
+
* what reaches the wire rather than on the mapped response.
|
|
211
|
+
*/
|
|
212
|
+
export declare function readRequestBody(fetch: {
|
|
213
|
+
mock: {
|
|
214
|
+
calls: unknown[][];
|
|
215
|
+
};
|
|
216
|
+
}): unknown;
|
|
217
|
+
/**
|
|
218
|
+
* The JSON input the SDK sent in the query string of its most recent request,
|
|
219
|
+
* which is where a read contract carries it.
|
|
220
|
+
*/
|
|
221
|
+
export declare function readRequestQueryInput(fetch: {
|
|
222
|
+
mock: {
|
|
223
|
+
calls: unknown[][];
|
|
224
|
+
};
|
|
225
|
+
}): unknown;
|
|
226
|
+
/**
|
|
227
|
+
* The URL and init of the SDK's most recent request, for tests asserting on the
|
|
228
|
+
* route and headers it reached.
|
|
229
|
+
*/
|
|
230
|
+
export declare function readRequest(fetch: {
|
|
231
|
+
mock: {
|
|
232
|
+
calls: unknown[][];
|
|
233
|
+
};
|
|
234
|
+
}): {
|
|
235
|
+
init: RequestInit;
|
|
236
|
+
url: string;
|
|
237
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qawolf/ci-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A simple SDK for interacting with QAWolf in CI scripts.",
|
|
6
6
|
"keywords": [],
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"tsc:check": "tsc --noEmit"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@qawolf/api-contracts": ">=0.
|
|
37
|
+
"@qawolf/api-contracts": ">=0.101.0",
|
|
38
38
|
"@qawolf/ci-utils": "^2.0.0",
|
|
39
39
|
"@sinonjs/fake-timers": "^10.3.0",
|
|
40
40
|
"tslib": "^2.6.2",
|