@qawolf/ci-sdk 2.1.0 → 2.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.
Files changed (42) hide show
  1. package/README.md +15 -0
  2. package/dist/index.cjs +401 -184
  3. package/dist/index.cjs.map +7 -1
  4. package/dist/index.d.ts +4 -534
  5. package/dist/index.js +376 -182
  6. package/dist/index.js.map +7 -1
  7. package/dist/lib/api/ci-greenlight-bug-data.d.ts +67 -0
  8. package/dist/lib/api/ci-greenlight.d.ts +76 -0
  9. package/dist/lib/api/generate-signed-url-for-run-inputs-executables.d.ts +4 -0
  10. package/dist/lib/api/generate-signed-url-for-team-storage.d.ts +4 -0
  11. package/dist/lib/api/index.d.ts +2 -0
  12. package/dist/lib/api/log.d.ts +6 -0
  13. package/dist/lib/api/signed-url.d.ts +11 -0
  14. package/dist/lib/api-types.d.ts +5 -0
  15. package/dist/lib/other.d.ts +5 -0
  16. package/dist/lib/sdk/defaults/fetch.d.ts +1 -0
  17. package/dist/lib/sdk/defaults/log.d.ts +2 -0
  18. package/dist/lib/sdk/defaults/serviceBase.d.ts +1 -0
  19. package/dist/lib/sdk/defaults/userAgent.d.ts +1 -0
  20. package/dist/lib/sdk/dependencies.d.ts +7 -0
  21. package/dist/lib/sdk/domain/attemptDeploy/deployConfig.d.ts +37 -0
  22. package/dist/lib/sdk/domain/attemptDeploy/deploySuccessWireResponse.d.ts +39 -0
  23. package/dist/lib/sdk/domain/attemptDeploy/handleSuccessResponse.d.ts +3 -0
  24. package/dist/lib/sdk/domain/attemptDeploy/index.d.ts +4 -0
  25. package/dist/lib/sdk/domain/attemptDeploy/mapDeploySuccessResponse.d.ts +3 -0
  26. package/dist/lib/sdk/domain/attemptDeploy/parseDeploySuccessWireResponse.d.ts +2 -0
  27. package/dist/lib/sdk/domain/attemptDeploy/types.d.ts +129 -0
  28. package/dist/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-run-inputs-executables.d.ts +4 -0
  29. package/dist/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-team-storage.d.ts +16 -0
  30. package/dist/lib/sdk/domain/generateSignedUrls/types.d.ts +28 -0
  31. package/dist/lib/sdk/domain/notifyTerminatedEphemeralEnvironment/index.d.ts +4 -0
  32. package/dist/lib/sdk/domain/notifyTerminatedEphemeralEnvironment/types.d.ts +48 -0
  33. package/dist/lib/sdk/domain/pollCiGreenlight/buildCompletedRunResult.d.ts +8 -0
  34. package/dist/lib/sdk/domain/pollCiGreenlight/consts.d.ts +7 -0
  35. package/dist/lib/sdk/domain/pollCiGreenlight/index.d.ts +4 -0
  36. package/dist/lib/sdk/domain/pollCiGreenlight/iterator.d.ts +43 -0
  37. package/dist/lib/sdk/domain/pollCiGreenlight/logging.d.ts +25 -0
  38. package/dist/lib/sdk/domain/pollCiGreenlight/mapIteratorAbortToGreenlightStatus.d.ts +7 -0
  39. package/dist/lib/sdk/domain/pollCiGreenlight/types.d.ts +145 -0
  40. package/dist/lib/sdk/index.d.ts +26 -0
  41. package/package.json +13 -12
  42. package/dist/index.d.cts +0 -534
@@ -0,0 +1 @@
1
+ export declare const defaultFetch: typeof fetch;
@@ -0,0 +1,2 @@
1
+ import type { LogDriver } from "../dependencies.js";
2
+ export declare const defaultLogDriver: LogDriver;
@@ -0,0 +1 @@
1
+ export declare const defaultServiceBase = "https://app.qawolf.com/";
@@ -0,0 +1 @@
1
+ export declare const defaultUserAgent: string;
@@ -0,0 +1,7 @@
1
+ import type { LogDriver } from "@qawolf/ci-utils";
2
+ export type { LogDriver };
3
+ export type FetchDriver = typeof fetch;
4
+ export type SdkDependencies = {
5
+ fetch: FetchDriver;
6
+ log: LogDriver;
7
+ };
@@ -0,0 +1,37 @@
1
+ type BaseDeployConfig = {
2
+ branch: string | undefined;
3
+ commitUrl: string | undefined;
4
+ deduplicationKey: string | undefined;
5
+ deploymentType: string | undefined;
6
+ deploymentUrl: string | undefined;
7
+ sha: string | undefined;
8
+ variables: Record<string, string> | undefined;
9
+ /**
10
+ * The workspace this deployment belongs to. Required when authenticating with
11
+ * an organization API key, which is not tied to a single workspace. Omit it
12
+ * when authenticating with a workspace API key, which already implies one.
13
+ */
14
+ workspaceId?: string;
15
+ };
16
+ export type GitHubDeployConfig = BaseDeployConfig & {
17
+ hostingService: "GitHub" | undefined;
18
+ pullRequestNumber: number | undefined;
19
+ repository: {
20
+ name: string;
21
+ owner: string;
22
+ } | undefined;
23
+ };
24
+ export type GitLabDeployConfig = BaseDeployConfig & {
25
+ hostingService: "GitLab" | undefined;
26
+ mergeRequestNumber: number | undefined;
27
+ repository: {
28
+ name: string;
29
+ namespace: string;
30
+ } | undefined;
31
+ };
32
+ export type EphemeralDeployConfig = BaseDeployConfig & {
33
+ deploymentUrl: string;
34
+ ephemeralEnvironment: true;
35
+ };
36
+ export type DeployConfig = GitHubDeployConfig | GitLabDeployConfig | EphemeralDeployConfig;
37
+ export {};
@@ -0,0 +1,39 @@
1
+ type WireSuiteResult = {
2
+ created_suite_id: string;
3
+ outcome: "created";
4
+ trigger_id: string;
5
+ } | {
6
+ failure_code?: string;
7
+ failure_message?: string;
8
+ failure_reason: string;
9
+ outcome: "failed";
10
+ trigger_id: string;
11
+ } | {
12
+ duplicate_suite_id: string;
13
+ outcome: "skipped";
14
+ skip_reason: string;
15
+ trigger_id: string;
16
+ } | {
17
+ outcome?: undefined;
18
+ trigger_id: string;
19
+ };
20
+ export type DeploySuccessWireResponse = {
21
+ environment: {
22
+ alias?: string;
23
+ id: string;
24
+ isStatic: boolean;
25
+ } | undefined;
26
+ results: WireSuiteResult[];
27
+ skipped_deployment?: {
28
+ message: string;
29
+ reason: string;
30
+ };
31
+ skipped_triggers?: {
32
+ environment_id: string;
33
+ message: string;
34
+ reason: string;
35
+ trigger_id: string;
36
+ }[];
37
+ warning?: string;
38
+ };
39
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { LogDriver } from "../../dependencies.js";
2
+ import type { DeployStatus, NotifyDeployStatus } from "./types.js";
3
+ export declare function handleSuccessResponse(data: DeployStatus, log: LogDriver): Promise<NotifyDeployStatus>;
@@ -0,0 +1,4 @@
1
+ import type { ApiConfig } from "../../../api-types.js";
2
+ import type { SdkDependencies } from "../../dependencies.js";
3
+ import type { DeployConfig, NotifyDeployStatus } from "./types.js";
4
+ export declare function attemptNotifyDeploy(deps: SdkDependencies, apiConfig: ApiConfig, config: Partial<DeployConfig>): Promise<NotifyDeployStatus>;
@@ -0,0 +1,3 @@
1
+ import type { DeploySuccessWireResponse } from "./deploySuccessWireResponse.js";
2
+ import type { DeployStatus } from "./types.js";
3
+ export declare function mapDeploySuccessResponse(wire: DeploySuccessWireResponse): DeployStatus;
@@ -0,0 +1,2 @@
1
+ import type { DeploySuccessWireResponse } from "./deploySuccessWireResponse.js";
2
+ export declare function parseDeploySuccessWireResponse(value: unknown): DeploySuccessWireResponse | "invalid";
@@ -0,0 +1,129 @@
1
+ export type { DeployConfig, EphemeralDeployConfig, GitHubDeployConfig, GitLabDeployConfig, } from "./deployConfig.js";
2
+ /**
3
+ * Refer to our official documentation for more information:
4
+ * https://qawolf.notion.site/dd72e46ceb7f451dae4e9ef06f64a2cc
5
+ */
6
+ export type { DeploySuccessWireResponse } from "./deploySuccessWireResponse.js";
7
+ export type DeploySuccessSuiteCreatedResult = {
8
+ createdSuiteId: string;
9
+ triggerId: string;
10
+ };
11
+ export type DeploySuccessSuiteCreationFailureResult = {
12
+ failureCode?: string;
13
+ failureMessage?: string;
14
+ /**
15
+ * @deprecated Read `failureCode` to branch and `failureMessage` to display.
16
+ * This carries an internal diagnostic whose values change without notice.
17
+ */
18
+ failureReason: string;
19
+ triggerId: string;
20
+ };
21
+ export type DeploySuccessSuiteAlreadyExistsResult = {
22
+ duplicateSuiteId: string;
23
+ skipReason: string;
24
+ triggerId: string;
25
+ };
26
+ export type DeploySuccessSuiteUnrecognizedResult = {
27
+ triggerId: string;
28
+ unrecognized: true;
29
+ };
30
+ export type DeploySuccessSuiteResult = DeploySuccessSuiteCreatedResult | DeploySuccessSuiteCreationFailureResult | DeploySuccessSuiteAlreadyExistsResult | DeploySuccessSuiteUnrecognizedResult;
31
+ export type DeploySuccessSkippedTrigger = {
32
+ environmentId: string;
33
+ message: string;
34
+ reason: string;
35
+ triggerId: string;
36
+ };
37
+ export type DeploySuccessDeploymentSkipped = {
38
+ message: string;
39
+ reason: string;
40
+ };
41
+ export type DeployStatus = {
42
+ environment: {
43
+ alias?: string;
44
+ id: string;
45
+ isStatic: boolean;
46
+ } | undefined;
47
+ results: Array<DeploySuccessSuiteResult>;
48
+ skippedDeployment?: DeploySuccessDeploymentSkipped;
49
+ skippedTriggers?: DeploySuccessSkippedTrigger[];
50
+ warning?: string;
51
+ };
52
+ export type DeployStatusSuccessResponse = {
53
+ data: DeployStatus;
54
+ ok: true;
55
+ status: number;
56
+ };
57
+ export type DeployStatusErrorResponse = {
58
+ data: undefined;
59
+ ok: false;
60
+ status: number | undefined;
61
+ };
62
+ export type DeployStatusResponse = DeployStatusSuccessResponse | DeployStatusErrorResponse;
63
+ export type AttemptDeployHttpAbortReason = "4XX-client-error" | "401-unauthorized" | "403-forbidden" | "5XX-server-error" | "network-error";
64
+ export type AttemptDeployNonHttpAbortReason = "network-error" | "invalid-response-body";
65
+ export type AttemptDeployAbortReason = AttemptDeployHttpAbortReason | AttemptDeployNonHttpAbortReason;
66
+ export type NotifyDeployStatus = {
67
+ /**
68
+ * Environment ID associated with the deployment.
69
+ */
70
+ environmentId: string;
71
+ /**
72
+ * Deployment notification successful.
73
+ */
74
+ outcome: "success";
75
+ /**
76
+ * Run ID might be undefined if the deployment is a preview deployment.
77
+ */
78
+ runId: string | undefined;
79
+ } | {
80
+ /**
81
+ * One or more triggers matched the deployment but could not run (e.g. the
82
+ * environment was still syncing). A precondition was not met, so this is a
83
+ * failure rather than a skip: retrying once the environment is ready may
84
+ * create a run.
85
+ */
86
+ failReason: "trigger-skipped";
87
+ outcome: "failed";
88
+ skippedTriggers: DeploySuccessSkippedTrigger[];
89
+ } | {
90
+ /**
91
+ * No trigger matched the deployment. This is deterministic given the
92
+ * current configuration (repeating the request with the same config
93
+ * yields the same result), so it is a skip rather than a failure, and the
94
+ * caller should not treat it as an error. `skippedDeployment` carries the
95
+ * server's reason when it provided one (undefined on older servers or the
96
+ * legacy arm); there is no separate SDK-level reason code, since
97
+ * `outcome: "skipped"` only ever means no trigger matched.
98
+ */
99
+ outcome: "skipped";
100
+ skippedDeployment: DeploySuccessDeploymentSkipped | undefined;
101
+ } | {
102
+ /**
103
+ * `unknown-result` means the response carried a result arm this SDK
104
+ * version does not recognize (the backend is newer). The caller should
105
+ * upgrade the SDK; the outcome could not be classified.
106
+ */
107
+ failReason: "no-environment" | "run-could-not-be-created" | "unknown-result";
108
+ /**
109
+ * A run could not be created.
110
+ */
111
+ outcome: "failed";
112
+ } | {
113
+ abortReason: AttemptDeployNonHttpAbortReason;
114
+ httpStatus?: never;
115
+ /**
116
+ * An unrecoverable error occurred.
117
+ */
118
+ outcome: "aborted";
119
+ } | {
120
+ abortReason: AttemptDeployHttpAbortReason;
121
+ httpStatus: number | undefined;
122
+ /**
123
+ * An unrecoverable HTTP error occurred.
124
+ */
125
+ outcome: "aborted";
126
+ };
127
+ export type AttemptDeployFailedReason = Extract<NotifyDeployStatus, {
128
+ outcome: "failed";
129
+ }>["failReason"];
@@ -0,0 +1,4 @@
1
+ import type { ApiConfig } from "../../../api-types.js";
2
+ import type { SdkDependencies } from "../../dependencies.js";
3
+ import type { GenerateSignedUrlConfig, GenerateSignedUrlStatus } from "./types.js";
4
+ export declare function generateSignedUrlForRunInputsExecutablesStorage(deps: SdkDependencies, apiConfig: ApiConfig, config: GenerateSignedUrlConfig): Promise<GenerateSignedUrlStatus>;
@@ -0,0 +1,16 @@
1
+ import type { ApiConfig } from "../../../api-types.js";
2
+ import type { SdkDependencies } from "../../dependencies.js";
3
+ import type { GenerateSignedUrlConfig } from "./types.js";
4
+ type GenerateSignedUrlStatus = {
5
+ fileLocation?: string;
6
+ playgroundFileLocation?: string;
7
+ success: true;
8
+ uploadUrl?: string;
9
+ } | {
10
+ abortReason: GenerateSignedUrlAbortReason;
11
+ httpStatus?: number;
12
+ success: false;
13
+ };
14
+ export type GenerateSignedUrlAbortReason = "client-network-error" | "sdk-argument-validation-failed" | "400-invalid-request" | "401-invalid-credentials" | "403-forbidden" | "5XX-server-error" | "XXX-other-http-code";
15
+ export declare function generateSignedUrlForTempTeamStorage(deps: SdkDependencies, apiConfig: ApiConfig, config: GenerateSignedUrlConfig): Promise<GenerateSignedUrlStatus>;
16
+ export {};
@@ -0,0 +1,28 @@
1
+ export type GenerateSignedUrlStatus = {
2
+ fileLocation?: string;
3
+ playgroundFileLocation?: string;
4
+ success: true;
5
+ uploadUrl?: string;
6
+ } | {
7
+ abortReason: GenerateSignedUrlAbortReason;
8
+ httpStatus?: number;
9
+ success: false;
10
+ };
11
+ export type GenerateSignedUrlAbortReason = "client-network-error" | "sdk-argument-validation-failed" | "400-invalid-request" | "401-invalid-credentials" | "403-forbidden" | "5XX-server-error" | "XXX-other-http-code";
12
+ export type GenerateSignedUrlConfig = {
13
+ destinationFilePath: string;
14
+ /**
15
+ * The workspace to generate the URL for. Required when authenticating with an
16
+ * organization API key, which is not tied to a single workspace. Omit it when
17
+ * authenticating with a workspace API key, which already implies one.
18
+ */
19
+ workspaceId?: string;
20
+ };
21
+ export type GenerateSignedUrlResponse = {
22
+ errorMessage?: string;
23
+ fileLocation?: string;
24
+ httpStatus: number;
25
+ playgroundFileLocation?: string;
26
+ signedUrl?: string;
27
+ success: boolean;
28
+ };
@@ -0,0 +1,4 @@
1
+ import type { ApiConfig } from "../../../api-types.js";
2
+ import type { SdkDependencies } from "../../dependencies.js";
3
+ import type { NotifyTerminatedEphemeralEnvironmentInput, NotifyTerminatedEphemeralEnvironmentResult } from "./types.js";
4
+ export declare const notifyTerminatedEphemeralEnvironment: (deps: SdkDependencies, apiConfig: ApiConfig, config: NotifyTerminatedEphemeralEnvironmentInput) => Promise<NotifyTerminatedEphemeralEnvironmentResult>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The workspace that owns the environment. Required when authenticating with an
3
+ * organization API key, which is not tied to a single workspace. Omit it when
4
+ * authenticating with a workspace API key, which already implies one.
5
+ *
6
+ * Absent from the `environmentId` lookup, where the environment identifies its
7
+ * own workspace.
8
+ */
9
+ type WorkspaceLookup = {
10
+ workspaceId?: string;
11
+ };
12
+ export type NotifyTerminatedEphemeralEnvironmentInput = {
13
+ environmentId: string;
14
+ } | ({
15
+ deploymentUrl: string;
16
+ } & WorkspaceLookup) | ({
17
+ environmentAlias: string;
18
+ } & WorkspaceLookup);
19
+ export type NotifyTerminatedEphemeralEnvironmentFailedReason = "environmentNotFound" | "missingLookup" | "alreadyTerminated";
20
+ export type NotifyTerminatedEphemeralEnvironmentHttpAbortReason = "4XX-client-error" | "401-unauthorized" | "403-forbidden" | "409-conflict" | "5XX-server-error" | "network-error";
21
+ export type NotifyTerminatedEphemeralEnvironmentNonHttpAbortReason = "network-error";
22
+ export type NotifyTerminatedEphemeralEnvironmentAbortReason = NotifyTerminatedEphemeralEnvironmentHttpAbortReason | NotifyTerminatedEphemeralEnvironmentNonHttpAbortReason;
23
+ export type TerminatedEphemeralEnvironmentSuccessResult = {
24
+ environmentId: string;
25
+ warning?: string;
26
+ };
27
+ export type NotifyTerminatedEphemeralEnvironmentResult = {
28
+ environmentId: string;
29
+ /**
30
+ * Environment termination successful.
31
+ */
32
+ outcome: "success";
33
+ } | {
34
+ abortReason: NotifyTerminatedEphemeralEnvironmentAbortReason;
35
+ httpStatus?: never;
36
+ /**
37
+ * An unrecoverable error occurred.
38
+ */
39
+ outcome: "aborted";
40
+ } | {
41
+ abortReason: NotifyTerminatedEphemeralEnvironmentHttpAbortReason;
42
+ httpStatus: number | undefined;
43
+ /**
44
+ * An unrecoverable HTTP error occurred.
45
+ */
46
+ outcome: "aborted";
47
+ };
48
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { CiGreenlightStatus } from "../../../api/ci-greenlight.js";
2
+ import type { PollCiGreenlightStatus } from "./types.js";
3
+ /**
4
+ * Build the result for a completed run
5
+ */
6
+ export declare function buildCompletedRunResult(status: Extract<CiGreenlightStatus, {
7
+ runStage: "completed";
8
+ }>): PollCiGreenlightStatus;
@@ -0,0 +1,7 @@
1
+ import type { PollCiGreenlightPollConfig } from "./types.js";
2
+ /**
3
+ * Safe default values for polling configuration.
4
+ * If you change these values, make sure you update the JSDoc
5
+ * comments in the PollCiGreenlightPollConfig type.
6
+ */
7
+ export declare const pollCiGreenlightDefaults: PollCiGreenlightPollConfig;
@@ -0,0 +1,4 @@
1
+ import type { ApiConfig } from "../../../api-types.js";
2
+ import type { SdkDependencies } from "../../dependencies.js";
3
+ import type { PollCiGreenlightParams, PollCiGreenlightStatus } from "./types.js";
4
+ export declare function pollCiGreenlightStatus(deps: SdkDependencies, apiConfig: ApiConfig, { onRunStageChanged, runId, ...pollConfig }: PollCiGreenlightParams): Promise<PollCiGreenlightStatus>;
@@ -0,0 +1,43 @@
1
+ import type { ApiConfig } from "../../../api-types.js";
2
+ import type { SdkDependencies } from "../../dependencies.js";
3
+ import type { MakePollCiGreenlightStatusIteratorParams, PollCiGreenlightIteration } from "./types.js";
4
+ /**
5
+ * Creates an async generator that yields CI greenlight status updates or abort notifications.
6
+ *
7
+ * This low-level API gives you full control over the polling loop, allowing you to:
8
+ * - Inspect status after each fetch
9
+ * - Break out of the loop based on custom criteria
10
+ * - Add custom logging or side effects
11
+ * - Handle abort conditions without exceptions
12
+ *
13
+ * The iterator yields a discriminated union with `isAborted` property:
14
+ * - `isAborted: false` - Normal status update with run information
15
+ * - `isAborted: true` - Terminal condition (timeout, error, canceled, etc.)
16
+ *
17
+ * Note: This function does not throw errors. All error conditions are yielded as
18
+ * abort results that you must check and handle.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const greenlightIterator = makePollCiGreenlightStatusIterator({ runId: "my-run-id" });
23
+ *
24
+ * for await (const lastPoll of greenlightIterator) {
25
+ * // Check for abort conditions first
26
+ * if (lastPoll.isAborted) {
27
+ * console.error(`Aborted: ${lastPoll.abortReason}`);
28
+ * process.exit(1);
29
+ * }
30
+ *
31
+ * // Handle normal status updates
32
+ * const { status } = lastPoll;
33
+ * console.log(`Current stage: ${status.runStage}`);
34
+ *
35
+ * // Exit with error if run reached a terminal stage without greenlight
36
+ * if (lastPoll.isFailedTerminalStage) {
37
+ * process.exit(1);
38
+ * }
39
+ * }
40
+ * ```
41
+ *
42
+ */
43
+ export declare function makePollCiGreenlightStatusIterator(deps: SdkDependencies, apiConfig: ApiConfig, { runId, ...pollConfig }: MakePollCiGreenlightStatusIteratorParams): AsyncGenerator<PollCiGreenlightIteration, void, unknown>;
@@ -0,0 +1,25 @@
1
+ import type { CiGreenlightStatus } from "../../../api/ci-greenlight.js";
2
+ /**
3
+ * Build log message for successful completed run
4
+ */
5
+ export declare function buildSuccessLogMessage(status: Extract<CiGreenlightStatus, {
6
+ runStage: "completed";
7
+ }>): string;
8
+ /**
9
+ * Build log message for failed completed run
10
+ */
11
+ export declare function buildFailedLogMessage(status: Extract<CiGreenlightStatus, {
12
+ runStage: "completed";
13
+ }>): string;
14
+ /**
15
+ * Build log message for superseded run (aborting)
16
+ */
17
+ export declare function buildSupersededAbortLogMessage(rootRunUrl: string, relevantRunUrl: string): string;
18
+ /**
19
+ * Build log message for superseded run (continuing)
20
+ */
21
+ export declare function buildSupersededContinueLogMessage(rootRunUrl: string, relevantRunUrl: string): string;
22
+ /**
23
+ * Build log messages for different run stages
24
+ */
25
+ export declare function buildRunStageLogMessage(runStage: CiGreenlightStatus["runStage"], relevantRunUrl: string): string;
@@ -0,0 +1,7 @@
1
+ import type { SdkDependencies } from "../../dependencies.js";
2
+ import type { PollCiGreenlightIteratorHttpAborted, PollCiGreenlightIteratorNonHttpAborted, PollCiGreenlightStatus } from "./types.js";
3
+ /**
4
+ * Handles aborted iterations from the CI greenlight poll iterator
5
+ * and converts them to appropriate result objects with logging
6
+ */
7
+ export declare function mapIteratorAbortToGreenlightStatus(iteration: PollCiGreenlightIteratorHttpAborted | PollCiGreenlightIteratorNonHttpAborted, pollTimeout: number, deps: SdkDependencies): PollCiGreenlightStatus;
@@ -0,0 +1,145 @@
1
+ import type { CiGreenlightStatus } from "../../../api/ci-greenlight.js";
2
+ export type PollCiGreenlightPollConfig = {
3
+ /**
4
+ * If true, the job will be aborted when a superseding run is detected.
5
+ *
6
+ * @default false
7
+ */
8
+ abortOnSuperseded: boolean;
9
+ /**
10
+ * Maximum number of network operations retries before aborting the job.
11
+ *
12
+ * @default 10
13
+ */
14
+ maxRetries: number;
15
+ /**
16
+ * Timeout in milliseconds before aborting this polling operation.
17
+ *
18
+ * @default 120 minutes
19
+ */
20
+ pollTimeout: number;
21
+ /**
22
+ * Interval in milliseconds between network operations retries.
23
+ *
24
+ * @default 10 seconds
25
+ */
26
+ retryInterval: number;
27
+ /**
28
+ * Interval in milliseconds between polling for a run in progress.
29
+ *
30
+ * @default 30 seconds
31
+ */
32
+ runInProgressInterval: number;
33
+ /**
34
+ * Interval in milliseconds between polling for a run under review.
35
+ *
36
+ * @default 60 minutes
37
+ */
38
+ runUnderReviewInterval: number;
39
+ };
40
+ export type PollCiGreenlightHttpAbortReason = "4XX-client-error" | "404-run-not-found" | "5XX-server-error" | "XXX-other-http-code";
41
+ export type PollCiGreenlightNonHttpAbortReason = "poll-timed-out" | "run-canceled" | "network-error" | "superseded-run";
42
+ export type PollCiGreenlightAbortReason = PollCiGreenlightNonHttpAbortReason | PollCiGreenlightHttpAbortReason;
43
+ export type PollCiGreenlightStatus = {
44
+ greenlightStatus: Extract<CiGreenlightStatus, {
45
+ runStage: "completed";
46
+ }>;
47
+ /**
48
+ * No blocking bugs were found in the run.
49
+ */
50
+ outcome: "success";
51
+ } | {
52
+ greenlightStatus: Extract<CiGreenlightStatus, {
53
+ runStage: "completed";
54
+ }>;
55
+ /**
56
+ * Blocking bugs were found in the run.
57
+ */
58
+ outcome: "failed";
59
+ } | {
60
+ abortReason: PollCiGreenlightHttpAbortReason;
61
+ httpStatus: number;
62
+ /**
63
+ * The run was aborted due to an unrecoverable error.
64
+ */
65
+ outcome: "aborted";
66
+ } | {
67
+ abortReason: PollCiGreenlightNonHttpAbortReason;
68
+ httpStatus: undefined;
69
+ /**
70
+ * The run was aborted due to an unrecoverable error.
71
+ */
72
+ outcome: "aborted";
73
+ };
74
+ export type PollCiGreenlightParams = {
75
+ /**
76
+ * Callback to be called when the lifecycle stage of the run changes.
77
+ */
78
+ onRunStageChanged?: (current: CiGreenlightStatus, previous: CiGreenlightStatus | undefined) => unknown | Promise<unknown>;
79
+ runId: string;
80
+ } & Partial<PollCiGreenlightPollConfig>;
81
+ /**
82
+ * Successful status iteration containing greenlight status and metadata
83
+ */
84
+ export type PollCiGreenlightStatusIteration = {
85
+ /**
86
+ * Milliseconds elapsed since polling started
87
+ */
88
+ elapsedMs: number;
89
+ /**
90
+ * False when this is a successful status iteration
91
+ */
92
+ isAborted: false;
93
+ /**
94
+ * Whether the run reached a terminal stage without greenlight.
95
+ * True when the run completed without greenlight or was canceled.
96
+ * You should exit with an error code when this is true.
97
+ */
98
+ isFailedTerminalStage: boolean;
99
+ /**
100
+ * The previous status, if any
101
+ */
102
+ previousStatus: CiGreenlightStatus | undefined;
103
+ /**
104
+ * Whether the run stage changed from the previous iteration
105
+ */
106
+ stageChanged: boolean;
107
+ /**
108
+ * The current greenlight status from the API
109
+ */
110
+ status: CiGreenlightStatus;
111
+ };
112
+ /**
113
+ * Iterator aborted due to unrecoverable HTTP client error (4XX)
114
+ */
115
+ export type PollCiGreenlightIteratorHttpAborted = {
116
+ abortReason: PollCiGreenlightHttpAbortReason;
117
+ elapsedMs: number;
118
+ httpStatus: number;
119
+ /**
120
+ * True when the iterator was aborted
121
+ */
122
+ isAborted: true;
123
+ };
124
+ /**
125
+ * Iterator aborted due to non-HTTP reasons (timeout, canceled, network, superseded)
126
+ */
127
+ export type PollCiGreenlightIteratorNonHttpAborted = {
128
+ abortReason: Exclude<PollCiGreenlightNonHttpAbortReason, "superseded-run">;
129
+ elapsedMs: number;
130
+ httpStatus: undefined;
131
+ /**
132
+ * True when the iterator was aborted
133
+ */
134
+ isAborted: true;
135
+ };
136
+ /**
137
+ * Yielded value from the async generator - either a status update or a terminal abort condition
138
+ */
139
+ export type PollCiGreenlightIteration = PollCiGreenlightStatusIteration | PollCiGreenlightIteratorHttpAborted | PollCiGreenlightIteratorNonHttpAborted;
140
+ /**
141
+ * Parameters for the async generator
142
+ */
143
+ export type MakePollCiGreenlightStatusIteratorParams = {
144
+ runId: string;
145
+ } & Partial<PollCiGreenlightPollConfig>;
@@ -0,0 +1,26 @@
1
+ import type { SdkDependencies } from "./dependencies.js";
2
+ export declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
3
+ apiKey: string;
4
+ serviceBase?: string;
5
+ userAgent?: string;
6
+ }, { fetch, log, }?: Partial<SdkDependencies>): {
7
+ attemptNotifyDeploy: (config: Partial<import("./domain/attemptDeploy/deployConfig.js").DeployConfig>) => Promise<import("./domain/attemptDeploy/types.js").NotifyDeployStatus>;
8
+ generateSignedUrlForRunInputsExecutablesStorage: (config: import("./domain/generateSignedUrls/types.js").GenerateSignedUrlConfig) => Promise<import("./domain/generateSignedUrls/types.js").GenerateSignedUrlStatus>;
9
+ generateSignedUrlForTempTeamStorage: (config: import("./domain/generateSignedUrls/types.js").GenerateSignedUrlConfig) => Promise<{
10
+ fileLocation?: string;
11
+ playgroundFileLocation?: string;
12
+ success: true;
13
+ uploadUrl?: string;
14
+ } | {
15
+ abortReason: import("./domain/generateSignedUrls/generate-signed-url-for-team-storage.js").GenerateSignedUrlAbortReason;
16
+ httpStatus?: number;
17
+ success: false;
18
+ }>;
19
+ makePollCiGreenlightStatusIterator: (args_0: import("./domain/pollCiGreenlight/types.js").MakePollCiGreenlightStatusIteratorParams) => AsyncGenerator<import("./domain/pollCiGreenlight/types.js").PollCiGreenlightIteration, void, unknown>;
20
+ notifyTerminatedEphemeralEnvironment: (config: import("./domain/notifyTerminatedEphemeralEnvironment/types.js").NotifyTerminatedEphemeralEnvironmentInput) => Promise<import("./domain/notifyTerminatedEphemeralEnvironment/types.js").NotifyTerminatedEphemeralEnvironmentResult>;
21
+ pollCiGreenlightStatus: (args_0: import("./domain/pollCiGreenlight/types.js").PollCiGreenlightParams) => Promise<import("./domain/pollCiGreenlight/types.js").PollCiGreenlightStatus>;
22
+ };
23
+ export type * from "./domain/attemptDeploy/index.js";
24
+ export type * from "./domain/generateSignedUrls/types.js";
25
+ export type * from "./domain/notifyTerminatedEphemeralEnvironment/types.js";
26
+ export type * from "./domain/pollCiGreenlight/types.js";