@qawolf/ci-sdk 1.0.1 → 1.1.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 CHANGED
@@ -78,6 +78,19 @@ const deployConfig: GitLabDeployConfig = {
78
78
  },
79
79
  };
80
80
 
81
+ // Example for Ephemeral deployments
82
+ const deployConfig: EphemeralDeployConfig = {
83
+ branch: undefined,
84
+ commitUrl: undefined,
85
+ deduplicationKey: undefined,
86
+ // Required only if the target trigger requires matching a deployment type
87
+ deploymentType: "staging", // e.g., "production", "staging", "qa"
88
+ deploymentUrl: "https://preview.environment.com",
89
+ ephemeralEnvironment: true,
90
+ sha: undefined,
91
+ variables: undefined,
92
+ };
93
+
81
94
  // General Example
82
95
  // Edit this to your needs.
83
96
  const deployConfig: DeployConfig = {
@@ -125,6 +138,10 @@ Once enabled, to use PR/MR testing functionality:
125
138
 
126
139
  - Pass `hostingService: "GitLab"`, `repository` information, and `mergeRequestNumber` while notifying a deployment as described in the [Notify Deployment](#notify-deployment) section
127
140
 
141
+ 3. For `Ephemeral` deployments (no code hosting integration):
142
+
143
+ - Pass `ephemeralEnvironment: true` and `deploymentUrl` while notifying a deployment as described in the [Notify Deployment](#notify-deployment) section
144
+
128
145
  <a id="ci-greenlight"></a>
129
146
 
130
147
  ## Poll for CI Greenlight Status
@@ -277,6 +294,10 @@ This package follows the [SemVer](https://semver.org/) versioning scheme. Additi
277
294
 
278
295
  # Changelog
279
296
 
297
+ ## v1.1.0
298
+
299
+ - New `ephemeralEnvironment` parameter for `attemptNotifyDeploy`
300
+
280
301
  ## v1.0.1
281
302
 
282
303
  - Internal ESM-related refactoring
package/dist/index.cjs CHANGED
@@ -38,51 +38,7 @@ var defaultServiceBase = "https://app.qawolf.com/";
38
38
 
39
39
  // package.json
40
40
  var package_default = {
41
- name: "@qawolf/ci-sdk",
42
- version: "1.0.1",
43
- private: false,
44
- description: "A simple SDK for interacting with QAWolf in CI scripts.",
45
- keywords: [],
46
- license: "MIT",
47
- author: "Jules Sam. Randolph<jules@qawolf.com>",
48
- type: "module",
49
- exports: {
50
- ".": {
51
- types: "./dist/index.d.ts",
52
- require: "./dist/index.cjs",
53
- import: "./dist/index.js",
54
- default: "./dist/index.js"
55
- }
56
- },
57
- main: "./dist/index.cjs",
58
- module: "./dist/index.js",
59
- types: "./dist/index.d.ts",
60
- files: [
61
- "/dist",
62
- "/README.md"
63
- ],
64
- scripts: {
65
- build: "tsup src/index.ts --format esm,cjs --dts --clean --splitting --treeshake --sourcemap --outDir dist --target es2022",
66
- lint: "cycle-import-scan . && eslint . --ext js,jsx,mjs,ts,tsx --quiet && prettier --check .",
67
- "lint:fix": "eslint . --ext js,jsx,mjs,ts,tsx --fix --quiet && prettier --log-level=warn --write .",
68
- "lint:warnings": "eslint . --ext js,jsx,mjs,ts,tsx",
69
- prepublishOnly: "nx run ci-sdk:build",
70
- test: 'NODE_OPTIONS="--experimental-vm-modules" NODE_NO_WARNINGS=1 jest',
71
- "tsc:check": "tsc --noEmit"
72
- },
73
- dependencies: {
74
- "@qawolf/ci-utils": "^1.0.0",
75
- "@sinonjs/fake-timers": "^10.3.0",
76
- slugify: "^1.6.6",
77
- tslib: "^2.6.2"
78
- },
79
- devDependencies: {
80
- tsup: "8.3.5"
81
- },
82
- engines: {
83
- node: ">=16"
84
- }
85
- };
41
+ version: "1.1.1"};
86
42
 
87
43
  // src/lib/sdk/defaults/userAgent.ts
88
44
  var defaultUserAgent = `ci-sdk/${package_default.version}`;
@@ -105,8 +61,8 @@ async function logFetchError({ log, methodName, response }) {
105
61
  };
106
62
  } catch {
107
63
  return {
108
- eventId: undefined,
109
- failureMessage: undefined
64
+ eventId: void 0,
65
+ failureMessage: void 0
110
66
  };
111
67
  }
112
68
  })();
@@ -128,10 +84,14 @@ async function attemptNotifyDeploy(deps, apiConfig, config) {
128
84
  deduplication_key: config.deduplicationKey,
129
85
  deployment_type: config.deploymentType,
130
86
  deployment_url: config.deploymentUrl,
131
- hosting_service: config.hostingService,
132
- merge_request_number: config.hostingService === "GitLab" ? config.mergeRequestNumber : void 0,
133
- pull_request_number: config.hostingService === "GitHub" ? config.pullRequestNumber : void 0,
134
- repository: config.repository,
87
+ ..."ephemeralEnvironment" in config ? {
88
+ ephemeral_environment: config.ephemeralEnvironment
89
+ } : "hostingService" in config && {
90
+ hosting_service: config.hostingService,
91
+ merge_request_number: config.hostingService === "GitLab" ? config.mergeRequestNumber : void 0,
92
+ pull_request_number: config.hostingService === "GitHub" ? config.pullRequestNumber : void 0,
93
+ repository: config.repository
94
+ },
135
95
  sha: config.sha,
136
96
  variables: config.variables
137
97
  }),
@@ -149,7 +109,7 @@ async function attemptNotifyDeploy(deps, apiConfig, config) {
149
109
  log.error(`\u{1F6AB} Network error from deploy_success, aborting.`);
150
110
  return {
151
111
  abortReason: "network-error",
152
- httpStatus: undefined,
112
+ httpStatus: void 0,
153
113
  outcome: "aborted"
154
114
  };
155
115
  }
@@ -158,7 +118,7 @@ __name(attemptNotifyDeploy, "attemptNotifyDeploy");
158
118
  async function handleErrorResponse(response, log) {
159
119
  const status = response.status;
160
120
  let abortReason;
161
- if (status === undefined) abortReason = "network-error";
121
+ if (status === void 0) abortReason = "network-error";
162
122
  else if (status === 401) abortReason = "401-unauthorized";
163
123
  else if (status === 403) abortReason = "403-forbidden";
164
124
  else if (status >= 500) abortReason = "5XX-server-error";
@@ -188,10 +148,10 @@ async function handleSuccessResponse(data, log) {
188
148
  return {
189
149
  environmentId: environment.id,
190
150
  outcome: "success",
191
- runId: undefined
151
+ runId: void 0
192
152
  };
193
153
  }
194
- log.error(`\u{1F6AB} No trigger matched the request. Please contact support.`);
154
+ log.error(`\u{1F6AB} No trigger matched the request. Please make sure there is at least one active test in the QA Wolf environment, or contact support.`);
195
155
  return {
196
156
  failReason: "no-matched-trigger",
197
157
  outcome: "failed"
@@ -462,11 +422,11 @@ var safeDefaults = {
462
422
  runInProgressInterval: 30 * 1e3,
463
423
  runUnderReviewInterval: 60 * 1e3
464
424
  };
465
- async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = /* @__PURE__ */ __name(() => undefined, "onRunStageChanged"), runId, ...pollConfig }) {
425
+ async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = /* @__PURE__ */ __name(() => void 0, "onRunStageChanged"), runId, ...pollConfig }) {
466
426
  let retries = 0;
467
427
  const { log } = deps;
468
428
  const { abortOnSuperseded = safeDefaults.abortOnSuperseded, maxRetries = safeDefaults.maxRetries, pollTimeout = safeDefaults.pollTimeout, retryInterval = safeDefaults.retryInterval, runInProgressInterval = safeDefaults.runInProgressInterval, runUnderReviewInterval = safeDefaults.runUnderReviewInterval } = pollConfig;
469
- let currentStatus = undefined;
429
+ let currentStatus = void 0;
470
430
  const startedAt = Date.now();
471
431
  let hasTimedOut = false;
472
432
  while (!(hasTimedOut = Date.now() - startedAt > pollTimeout)) {
@@ -488,7 +448,7 @@ async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = /*
488
448
  if (responseState.errorType === "network") {
489
449
  return {
490
450
  abortReason: "network-error",
491
- httpStatus: undefined,
451
+ httpStatus: void 0,
492
452
  outcome: "aborted"
493
453
  };
494
454
  }
@@ -531,7 +491,7 @@ async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = /*
531
491
  log.warn(`\u274C Aborting due to superseded run (option 'abortOnSuperseded' is enabled).${supersedingDetails}`);
532
492
  return {
533
493
  abortReason: "superseded-run",
534
- httpStatus: undefined,
494
+ httpStatus: void 0,
535
495
  outcome: "aborted"
536
496
  };
537
497
  }
@@ -569,7 +529,7 @@ You may review the priority of certain bugs to mark these non-blocking and retry
569
529
  ${urlInfo}`);
570
530
  return {
571
531
  abortReason: "run-canceled",
572
- httpStatus: undefined,
532
+ httpStatus: void 0,
573
533
  outcome: "aborted"
574
534
  };
575
535
  }
@@ -577,7 +537,7 @@ ${urlInfo}`);
577
537
  log.warn(`\u274C Poll timed out after ${pollTimeout / 1e3}s. Aborting...`);
578
538
  return {
579
539
  abortReason: "poll-timed-out",
580
- httpStatus: undefined,
540
+ httpStatus: void 0,
581
541
  outcome: "aborted"
582
542
  };
583
543
  }
@@ -592,7 +552,7 @@ ${urlInfo}`);
592
552
  log.warn(`\u274C Poll timed out after ${pollTimeout / 1e3}s. Aborting...`);
593
553
  return {
594
554
  abortReason: "poll-timed-out",
595
- httpStatus: undefined,
555
+ httpStatus: void 0,
596
556
  outcome: "aborted"
597
557
  };
598
558
  }
@@ -605,8 +565,10 @@ function makeQaWolfSdk({ apiKey, serviceBase = defaultServiceBase, userAgent = d
605
565
  We recommend 'undici' package for that purpose. See the Requirement section of our README for more guidance.`);
606
566
  }
607
567
  const deps = {
608
- // Versions of fetch may have different default timeouts. For consistency, we explicitly set it to 60 seconds here.
609
- fetch: buildFetchWithTimeout(fetch, 6e4),
568
+ // Versions of fetch may have different default timeouts. For consistency, we explicitly set it to 2 minutes here.
569
+ // The increased timeout helps avoid edge cases where we need to search for a commit against multiple
570
+ // code hosting service repositories as a fallback when not finding the repository based on organization/name.
571
+ fetch: buildFetchWithTimeout(fetch, 12e4),
610
572
  log
611
573
  };
612
574
  const apiConfig = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/other.ts","../src/lib/sdk/defaults/fetch.ts","../src/lib/sdk/defaults/log.ts","../src/lib/sdk/defaults/serviceBase.ts","../package.json","../src/lib/sdk/defaults/userAgent.ts","../src/lib/api/log.ts","../src/lib/sdk/domain/attemptDeploy/index.ts","../src/lib/api/generate-signed-url-for-run-inputs-executables.ts","../src/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-run-inputs-executables.ts","../src/lib/api/generate-signed-url-for-team-storage.ts","../src/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-team-storage.ts","../src/lib/api/ci-greenlight.ts","../src/lib/sdk/domain/poll-ci-greenlight.ts","../src/lib/sdk/index.ts"],"names":["sleep","ms","Promise","resolve","setTimeout","pluralize","count","buildFetchWithTimeout","fetch","timeout","args","signal","AbortSignal","defaultFetch","globalThis","defaultLogDriver","error","message","console","info","log","warn","defaultServiceBase","defaultUserAgent","packageJson","version","logFetchError","methodName","response","ok","eventId","failureMessage","body","json","catch","text","undefined","eventIdSuffix","messageSuffix","statusText","status","attemptNotifyDeploy","deps","apiConfig","config","localFetch","URL","serviceBase","JSON","stringify","branch","commit_url","commitUrl","deduplication_key","deduplicationKey","deployment_type","deploymentType","deployment_url","deploymentUrl","hosting_service","hostingService","merge_request_number","mergeRequestNumber","pull_request_number","pullRequestNumber","repository","sha","variables","headers","Authorization","apiKey","userAgent","method","handleErrorResponse","data","handleSuccessResponse","abortReason","httpStatus","outcome","environment","results","isPreviewDeployment","isStatic","logPrefix","alias","id","length","environmentId","runId","failReason","failedTrigger","find","t","failure_reason","duplicateSuite","duplicate_suite_id","successfulTrigger","created_suite_id","callGenerateSignedUrlForRunInputsExecutablesStorage","destinationFilePath","encodeURIComponent","fileLocation","playgroundFileLocation","signedUrl","success","errorMessage","e","generateSignedUrlForRunInputsExecutablesStorage","responseState","uploadUrl","callGenerateSignedUrlForTempTeamStorage","generateSignedUrlForTempTeamStorage","fetchCiGreenlightStatus","resp","greenlightStatus","canRetry","errorType","safeDefaults","abortOnSuperseded","maxRetries","pollTimeout","retryInterval","runInProgressInterval","runUnderReviewInterval","pollCiGreenlightStatus","onRunStageChanged","pollConfig","retries","currentStatus","startedAt","Date","now","hasTimedOut","retryLabel","previousStatus","runStage","urlInfo","relevantRunUrl","greenlight","relevantRunId","relevantRunWithBugsUrl","rootRunId","rootRunUrl","supersedingDetails","blockingBugsCount","blockingBugUrls","nonBlockingBugsCount","nonBlockingBugUrls","blockingBugList","map","url","join","nonBlockingBugList","bugsListInText","Error","makeQaWolfSdk","bind"],"mappings":";;;;;;AAEO,SAASA,MAAMC,EAAU,EAAA;AAC9B,EAAA,OAAO,IAAIC,OAAQ,CAAA,CAACC,YAAYC,UAAWD,CAAAA,OAAAA,EAASF,EAAAA,CAAAA,CAAAA;AACtD;AAFgB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,IAAAA,+CAAAA,EACEA,+CAAgDiD,CAAAA,IAAAA,CAC9C,IACAlH,EAAAA,IAAAA,EACAC,SAAAA,CAAAA;AAEJoE,IAAAA,mCAAAA,EACEA,mCAAoC6C,CAAAA,IAAAA,CAAK,IAAMlH,EAAAA,IAAAA,EAAMC,SAAAA,CAAAA;AACvDiF,IAAAA,sBAAAA,EAAwBA,sBAAuBgC,CAAAA,IAAAA,CAAK,IAAMlH,EAAAA,IAAAA,EAAMC,SAAAA;AAClE,GAAA;AACF;AAxCgBgH,MAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA","file":"index.cjs","sourcesContent":["import { type FetchDriver } from \"./sdk/dependencies.js\";\n\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function pluralize(count: number) {\n return count === 1 ? \"\" : \"s\";\n}\n\nexport function getBackoffMs(\n attemptNumber: number,\n minWaitMs = 1000,\n maxWaitMs = 10000,\n): number {\n return Math.min(maxWaitMs, minWaitMs * 1.2 ** attemptNumber);\n}\n\nexport const buildFetchWithTimeout =\n (fetch: FetchDriver, timeout: number) =>\n async (...args: Parameters<FetchDriver>) =>\n fetch(args[0], { ...args[1], signal: AbortSignal.timeout(timeout) });\n","export const defaultFetch = globalThis.fetch;\n","import { type LogDriver } from \"../dependencies.js\";\n\nexport const defaultLogDriver: LogDriver = {\n error(message, error) {\n console.error(message, error);\n },\n info(message) {\n console.log(message);\n },\n warn(message) {\n console.warn(message);\n },\n};\n","export const defaultServiceBase = \"https://app.qawolf.com/\";\n","{\n \"name\": \"@qawolf/ci-sdk\",\n \"version\": \"1.0.1\",\n \"private\": false,\n \"description\": \"A simple SDK for interacting with QAWolf in CI scripts.\",\n \"keywords\": [],\n \"license\": \"MIT\",\n \"author\": \"Jules Sam. Randolph<jules@qawolf.com>\",\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"require\": \"./dist/index.cjs\",\n \"import\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n }\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"/dist\",\n \"/README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/index.ts --format esm,cjs --dts --clean --splitting --treeshake --sourcemap --outDir dist --target es2022\",\n \"lint\": \"cycle-import-scan . && eslint . --ext js,jsx,mjs,ts,tsx --quiet && prettier --check .\",\n \"lint:fix\": \"eslint . --ext js,jsx,mjs,ts,tsx --fix --quiet && prettier --log-level=warn --write .\",\n \"lint:warnings\": \"eslint . --ext js,jsx,mjs,ts,tsx\",\n \"prepublishOnly\": \"nx run ci-sdk:build\",\n \"test\": \"NODE_OPTIONS=\\\"--experimental-vm-modules\\\" NODE_NO_WARNINGS=1 jest\",\n \"tsc:check\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@qawolf/ci-utils\": \"^1.0.0\",\n \"@sinonjs/fake-timers\": \"^10.3.0\",\n \"slugify\": \"^1.6.6\",\n \"tslib\": \"^2.6.2\"\n },\n \"devDependencies\": {\n \"tsup\": \"8.3.5\"\n },\n \"engines\": {\n \"node\": \">=16\"\n }\n}\n","import packageJson from \"../../../../package.json\" with { type: \"json\" };\n\nexport const defaultUserAgent = `ci-sdk/${packageJson.version}`;\n","import { type LogDriver } from \"@qawolf/ci-utils\";\n\nexport async function logFetchError({\n log,\n methodName,\n response,\n}: {\n log: LogDriver;\n methodName: string;\n response: Response;\n}) {\n if (response.ok) return;\n\n const { eventId, failureMessage } = await (async () => {\n try {\n const body = (await response.json().catch(() => response.text())) as\n | Record<string, unknown>\n | string;\n if (typeof body === \"object\" && body !== null) {\n return {\n eventId: body.eventId,\n failureMessage: body.failureMessage,\n };\n }\n // If body is not an object (i.e., it's the text from catch)\n return {\n eventId: undefined,\n failureMessage: body,\n };\n } catch {\n // If both parsing attempts somehow fail\n return {\n eventId: undefined,\n failureMessage: undefined,\n };\n }\n })();\n\n const eventIdSuffix = eventId ? ` (Event ID: ${eventId})` : \"\";\n const messageSuffix = failureMessage ? `: ${failureMessage}` : \"\";\n\n const statusText =\n response.status >= 500\n ? \"Server Error\"\n : response.statusText || \"Unknown Error\";\n\n log.error(\n `āŒ [${methodName}] ${response.status} ${statusText}${eventIdSuffix}${messageSuffix}`,\n );\n}\n","import { type ApiConfig } from \"../../../api-types.js\";\nimport { logFetchError } from \"../../../api/log.js\";\nimport { type LogDriver, type SdkDependencies } from \"../../dependencies.js\";\n\nimport {\n type AttemptDeployHttpAbortReason,\n type DeployConfig,\n type DeployStatus,\n type NotifyDeployStatus,\n} from \"./types.js\";\n\nexport async function attemptNotifyDeploy(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: Partial<DeployConfig>,\n): Promise<NotifyDeployStatus> {\n const { fetch: localFetch, log } = deps;\n try {\n const response = await localFetch(\n new URL(\"/api/webhooks/deploy_success\", apiConfig.serviceBase),\n {\n body: JSON.stringify({\n branch: config.branch,\n commit_url: config.commitUrl,\n deduplication_key: config.deduplicationKey,\n deployment_type: config.deploymentType,\n deployment_url: config.deploymentUrl,\n hosting_service: config.hostingService,\n merge_request_number:\n config.hostingService === \"GitLab\"\n ? config.mergeRequestNumber\n : undefined,\n pull_request_number:\n config.hostingService === \"GitHub\"\n ? config.pullRequestNumber\n : undefined,\n repository: config.repository,\n sha: config.sha,\n variables: config.variables,\n }),\n headers: {\n Authorization: `Bearer ${apiConfig.apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": apiConfig.userAgent,\n },\n method: \"POST\",\n },\n );\n\n if (!response.ok) return handleErrorResponse(response, log);\n const data = (await response.json()) as DeployStatus;\n return handleSuccessResponse(data, log);\n } catch (error) {\n log.error(`🚫 Network error from deploy_success, aborting.`);\n return {\n abortReason: \"network-error\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n}\n\nasync function handleErrorResponse(\n response: Response,\n log: LogDriver,\n): Promise<NotifyDeployStatus> {\n const status = response.status;\n let abortReason: AttemptDeployHttpAbortReason;\n if (status === undefined) abortReason = \"network-error\";\n else if (status === 401) abortReason = \"401-unauthorized\";\n else if (status === 403) abortReason = \"403-forbidden\";\n else if (status >= 500) abortReason = \"5XX-server-error\";\n else abortReason = \"4XX-client-error\";\n await logFetchError({\n log,\n methodName: \"attemptNotifyDeploy\",\n response,\n });\n return {\n abortReason,\n httpStatus: status,\n outcome: \"aborted\",\n };\n}\n\nasync function handleSuccessResponse(\n data: DeployStatus,\n log: LogDriver,\n): Promise<NotifyDeployStatus> {\n const { environment, results } = data;\n const isPreviewDeployment = environment && !environment.isStatic;\n\n if (environment) {\n const logPrefix = environment.isStatic\n ? \"Static environment\"\n : \"Preview environment\";\n log.info(`${logPrefix}: ${environment.alias} (id: ${environment.id})`);\n }\n\n // No triggers were matched\n if (results.length === 0) {\n if (isPreviewDeployment) {\n log.info(\n `āœ… Deployment notification was successful. No run was created for this deployment.`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: undefined,\n };\n }\n log.error(`🚫 No trigger matched the request. Please contact support.`);\n return { failReason: \"no-matched-trigger\", outcome: \"failed\" };\n }\n\n // If there are results, environment must be defined\n if (!environment) {\n log.error(`🚫 No environment matched the request. Please contact support.`);\n return { failReason: \"no-environment\", outcome: \"failed\" };\n }\n\n const failedTrigger = results.find((t) => \"failure_reason\" in t);\n if (failedTrigger) {\n log.error(\n `🚫 Run could not be created. Reason: \"${failedTrigger.failure_reason}\". Please contact support.`,\n );\n return { failReason: \"run-could-not-be-created\", outcome: \"failed\" };\n }\n\n const duplicateSuite = results.find((t) => \"duplicate_suite_id\" in t);\n if (duplicateSuite) {\n log.info(\n `āœ… Deployment notification was successful. Previous run ID: ${duplicateSuite.duplicate_suite_id} already exists for this deployment.`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: duplicateSuite.duplicate_suite_id,\n };\n }\n\n const successfulTrigger = results.find((t) => \"created_suite_id\" in t);\n if (!successfulTrigger) {\n log.error(`🚫 No trigger matched the request. Please contact support.`);\n return { failReason: \"no-matched-trigger\", outcome: \"failed\" };\n }\n log.info(\n `āœ… Deployment notification was successful. Run created with ID: ${successfulTrigger.created_suite_id}`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: successfulTrigger.created_suite_id,\n };\n}\n","import { type ApiConfig } from \"../api-types.js\";\nimport { type SdkDependencies } from \"../sdk/dependencies.js\";\nimport {\n type GenerateSignedUrlConfig,\n type GenerateSignedUrlResponse,\n} from \"../sdk/domain/generateSignedUrls/types.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport async function callGenerateSignedUrlForRunInputsExecutablesStorage(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n { destinationFilePath }: GenerateSignedUrlConfig,\n { fetch: localFetch, log }: SdkDependencies,\n): Promise<GenerateSignedUrlResponse> {\n try {\n const response = await localFetch(\n new URL(\n `${serviceBase}/api/v0/run-inputs-executables-signed-urls?file=${encodeURIComponent(destinationFilePath)}`,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": userAgent,\n },\n method: \"GET\",\n },\n );\n\n if (response.status === 200) {\n const json =\n (await response.json()) as Partial<GenerateSignedUrlResponse>;\n return {\n fileLocation: json.fileLocation,\n httpStatus: response.status,\n playgroundFileLocation: json.playgroundFileLocation,\n signedUrl: json.signedUrl,\n success: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"callGenerateSignedUrlForRunInputsExecutablesStorage\",\n response,\n });\n return {\n errorMessage: await response.text(),\n httpStatus: response.status,\n success: false,\n } as const;\n } catch (e) {\n return {\n errorMessage: \"Network error, aborting request to generate signed URL\",\n httpStatus: 0,\n success: false,\n } as const;\n }\n}\n","import { type ApiConfig } from \"../../../api-types.js\";\nimport { callGenerateSignedUrlForRunInputsExecutablesStorage } from \"../../../api/generate-signed-url-for-run-inputs-executables.js\";\nimport { type SdkDependencies } from \"../../dependencies.js\";\n\nimport {\n type GenerateSignedUrlAbortReason,\n type GenerateSignedUrlConfig,\n type GenerateSignedUrlStatus,\n} from \"./types.js\";\n\nexport async function generateSignedUrlForRunInputsExecutablesStorage(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: GenerateSignedUrlConfig,\n): Promise<GenerateSignedUrlStatus> {\n const { log } = deps;\n\n if (!config.destinationFilePath) {\n log.error(`🚫 destinationFilePath is a required config parameter`);\n return {\n abortReason: \"sdk-argument-validation-failed\",\n success: false,\n };\n }\n\n const responseState =\n await callGenerateSignedUrlForRunInputsExecutablesStorage(\n apiConfig,\n config,\n deps,\n );\n if (!responseState.success) {\n let abortReason: GenerateSignedUrlAbortReason = \"XXX-other-http-code\";\n\n if (responseState.httpStatus >= 500) {\n abortReason = \"5XX-server-error\";\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: aborting.`,\n );\n } else {\n if (responseState.httpStatus === 400) abortReason = \"400-invalid-request\";\n else if (responseState.httpStatus === 401)\n abortReason = \"401-invalid-credentials\";\n else if (responseState.httpStatus === 403) abortReason = \"403-forbidden\";\n else if (responseState.httpStatus === 0)\n abortReason = \"client-network-error\";\n\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: ${responseState.errorMessage ? `${responseState.errorMessage}.` : \"\"} aborting.`,\n );\n }\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n success: false,\n };\n }\n\n log.info(`āœ… Generated Signed Upload URL: ${responseState.signedUrl}.`);\n return {\n fileLocation: responseState.fileLocation,\n playgroundFileLocation: responseState.playgroundFileLocation,\n success: true,\n uploadUrl: responseState.signedUrl,\n };\n}\n","import { type ApiConfig } from \"../api-types.js\";\nimport { type SdkDependencies } from \"../sdk/dependencies.js\";\nimport {\n type GenerateSignedUrlConfig,\n type GenerateSignedUrlResponse,\n} from \"../sdk/domain/generateSignedUrls/types.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport async function callGenerateSignedUrlForTempTeamStorage(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n { destinationFilePath }: Partial<GenerateSignedUrlConfig>,\n { fetch: localFetch, log }: SdkDependencies,\n): Promise<GenerateSignedUrlResponse> {\n try {\n const response = await localFetch(\n new URL(\n `${serviceBase}/api/v0/team-storage-signed-url?file=${destinationFilePath}`,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": userAgent,\n },\n method: \"GET\",\n },\n );\n\n if (response.status === 200) {\n const json =\n (await response.json()) as Partial<GenerateSignedUrlResponse>;\n return {\n fileLocation: json.fileLocation,\n httpStatus: response.status,\n playgroundFileLocation: json.playgroundFileLocation,\n signedUrl: json.signedUrl,\n success: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"callGenerateSignedUrlForTempTeamStorage\",\n response,\n });\n return {\n errorMessage: await response.text(),\n httpStatus: response.status,\n success: false,\n } as const;\n } catch (e) {\n return {\n errorMessage: \"Network error, aborting request to generate signed URL\",\n httpStatus: 0,\n success: false,\n } as const;\n }\n}\n","import { type ApiConfig } from \"../../../api-types.js\";\nimport { callGenerateSignedUrlForTempTeamStorage } from \"../../../api/generate-signed-url-for-team-storage.js\";\nimport { type SdkDependencies } from \"../../dependencies.js\";\n\nimport { type GenerateSignedUrlConfig } from \"./types.js\";\n\ntype GenerateSignedUrlStatus =\n | {\n fileLocation?: string;\n playgroundFileLocation?: string;\n success: true;\n uploadUrl?: string;\n }\n | {\n abortReason: GenerateSignedUrlAbortReason;\n httpStatus?: number;\n success: false;\n };\n\nexport type GenerateSignedUrlAbortReason =\n | \"client-network-error\"\n | \"sdk-argument-validation-failed\"\n | \"400-invalid-request\"\n | \"401-invalid-credentials\"\n | \"403-forbidden\"\n | \"5XX-server-error\"\n | \"XXX-other-http-code\";\n\nexport async function generateSignedUrlForTempTeamStorage(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: GenerateSignedUrlConfig,\n): Promise<GenerateSignedUrlStatus> {\n const { log } = deps;\n\n if (!config.destinationFilePath) {\n log.error(`🚫 destinationFilePath is a required config parameter`);\n return {\n abortReason: \"sdk-argument-validation-failed\",\n success: false,\n };\n }\n\n const responseState = await callGenerateSignedUrlForTempTeamStorage(\n apiConfig,\n config,\n deps,\n );\n if (!responseState.success) {\n let abortReason: GenerateSignedUrlAbortReason = \"XXX-other-http-code\";\n\n if (responseState.httpStatus >= 500) {\n abortReason = \"5XX-server-error\";\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: aborting.`,\n );\n } else {\n if (responseState.httpStatus === 400) abortReason = \"400-invalid-request\";\n else if (responseState.httpStatus === 401)\n abortReason = \"401-invalid-credentials\";\n else if (responseState.httpStatus === 403) abortReason = \"403-forbidden\";\n else if (responseState.httpStatus === 0)\n abortReason = \"client-network-error\";\n\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: ${responseState.errorMessage ? `${responseState.errorMessage}.` : \"\"} aborting.`,\n );\n }\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n success: false,\n };\n }\n\n log.info(`āœ… Generated Signed Upload URL: ${responseState.signedUrl}.`);\n return {\n fileLocation: responseState.fileLocation,\n playgroundFileLocation: responseState.playgroundFileLocation,\n success: true,\n uploadUrl: responseState.signedUrl,\n };\n}\n","import { type ApiConfig } from \"../api-types.js\";\nimport { type SdkDependencies } from \"../sdk/dependencies.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport type CiGreenlightBugDetails = {\n /**\n * The URL of this BR in the QAWolf application.\n */\n applicationUrl: string;\n /**\n * If this bug report is linked to an external issue, it will\n * show up here.\n */\n externalIssue:\n | {\n /**\n * The URL of the external issue in the external platform\n * application.\n */\n applicationUrl: string;\n /**\n * The ID of this issue in the external platform.\n */\n externalIssueId: string;\n /**\n * Lowercase platform name (e.g. \"jira\").\n */\n platform: string;\n }\n | undefined;\n /**\n * True if the bug is blocking.\n */\n isBlocking: boolean;\n /**\n * True if the bug has been found in this run.\n */\n isNew: boolean;\n /**\n * The name of this bug.\n */\n name: string;\n /**\n * The bug number.\n */\n number: number;\n /**\n * The priority of this bug.\n */\n priority: \"medium\" | \"unprioritized\" | \"low\" | \"high\" | \"urgent\";\n};\n\nexport type CiGreenlightBugData = {\n /**\n * The count of blocking bugs reproduced in the run.\n */\n blockingBugsCount: number;\n /**\n * The URLs of the blocking bugs.\n *\n * @deprecated This field will be removed in the next major version.\n * Prefer using `reproducedBugs` filtered by `isBlocking: true`, reading\n * the `applicationUrl` field.\n */\n blockingBugUrls: string[];\n /**\n * The count of non-blocking bugs reproduced in the run.\n */\n nonBlockingBugsCount: number;\n /**\n * The URLs of the non-blocking bugs.\n *\n * @deprecated This field will be removed in the next major version.\n * Prefer using `reproducedBugs` filtered by `isBlocking: false`, reading\n * the `applicationUrl` field.\n */\n nonBlockingBugUrls: string[];\n /**\n * Blocking bugs that were not reproduced in this run, but are still\n * opened in the run environment. This may happen when the run only covers a\n * subset of the workflows in environment.\n */\n otherBlockingBugsInEnvironment: CiGreenlightBugDetails[];\n /**\n * Bugs that were reproduced in this run. This includes newly found bugs.\n */\n reproducedBugs: CiGreenlightBugDetails[];\n};\n\n/**\n * @deprecated This type will be removed in the next major version. Use `CiGreenlightBugData` instead.\n */\nexport type CiGreenlightCompletedSuiteDetails = CiGreenlightBugData;\n\nexport type CiGreenlightStatusBase = {\n relevantRunId: string;\n relevantRunUrl: string;\n relevantRunWithBugsUrl: string;\n rootRunId: string;\n rootRunUrl: string;\n workflowsDisabledAfterRunCount: number;\n workflowsInRunCount: number;\n workflowsUnderInvestigationCount: number;\n};\n\n/**\n * The status of a CI greenlight run. See the API documentation here for\n * more details: https://qawolf.notion.site/1b170576efea411fa785842a71e7c99e\n */\nexport type CiGreenlightStatus = CiGreenlightStatusBase &\n (\n | ({\n greenlight: boolean;\n runStage: \"completed\";\n } & CiGreenlightBugData)\n | ({\n greenlight: false;\n runStage: \"underReview\";\n } & CiGreenlightBugData)\n | {\n greenlight: false;\n runStage: \"initializing\" | \"underReview\" | \"canceled\";\n }\n );\n\nexport async function fetchCiGreenlightStatus(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n {\n runId,\n }: {\n runId: string;\n },\n { fetch: localFetch, log }: SdkDependencies,\n) {\n try {\n const resp = await localFetch(\n new URL(\n `/api/v0/ci-greenlight/${encodeURIComponent(runId)}`,\n serviceBase,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"User-Agent\": userAgent,\n },\n },\n );\n\n if (resp.ok) {\n const greenlightStatus = (await resp.json()) as CiGreenlightStatus;\n return {\n greenlightStatus,\n httpStatus: resp.status,\n ok: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"fetchCiGreenlightStatus\",\n response: resp,\n });\n if (resp.status === 404) {\n return {\n canRetry: true,\n errorType: \"not-found\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n }\n if (resp.status >= 500) {\n return {\n canRetry: true,\n errorType: \"server\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n }\n return {\n canRetry: false,\n errorType: \"client\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n } catch (e) {\n return {\n canRetry: true,\n errorType: \"network\",\n httpStatus: 0,\n ok: false,\n } as const;\n }\n}\n","/* eslint-disable @qawolf/max-lines -- Technical debt */\n\nimport { type ApiConfig } from \"../../api-types.js\";\nimport {\n type CiGreenlightStatus,\n fetchCiGreenlightStatus,\n} from \"../../api/ci-greenlight.js\";\nimport { pluralize, sleep } from \"../../other.js\";\nimport { type SdkDependencies } from \"../dependencies.js\";\n\nexport type PollCiGreenlightPollConfig = {\n /**\n * If true, the job will be aborted when a superseding run is detected.\n *\n * @default false\n */\n abortOnSuperseded: boolean;\n /**\n * Maximum number of network operations retries before aborting the job.\n *\n * @default 10\n */\n maxRetries: number;\n /**\n * Timeout in milliseconds before aborting this polling operation.\n *\n * @default 120 minutes\n */\n pollTimeout: number;\n /**\n * Interval in milliseconds between network operations retries.\n *\n * @default 10 seconds\n */\n retryInterval: number;\n /**\n * Interval in milliseconds between polling for a run in progress.\n *\n * @default 30 seconds\n */\n runInProgressInterval: number;\n /**\n * Interval in milliseconds between polling for a run under review.\n *\n * @default 60 minutes\n */\n runUnderReviewInterval: number;\n};\n\nexport type PollCiGreenlightHttpAbortReason =\n | \"4XX-client-error\"\n | \"404-run-not-found\"\n | \"5XX-server-error\"\n | \"XXX-other-http-code\";\n\nexport type PollCiGreenlightNonHttpAbortReason =\n | \"poll-timed-out\"\n | \"run-canceled\"\n | \"network-error\"\n | \"superseded-run\";\n\nexport type PollCiGreenlightAbortReason =\n | PollCiGreenlightNonHttpAbortReason\n | PollCiGreenlightHttpAbortReason;\n\nexport type PollCiGreenlightStatus =\n | {\n greenlightStatus: Extract<CiGreenlightStatus, { runStage: \"completed\" }>;\n /**\n * No blocking bugs were found in the run.\n */\n outcome: \"success\";\n }\n | {\n greenlightStatus: Extract<CiGreenlightStatus, { runStage: \"completed\" }>;\n /**\n * Blocking bugs were found in the run.\n */\n outcome: \"failed\";\n }\n | {\n abortReason: PollCiGreenlightHttpAbortReason;\n httpStatus: number;\n /**\n * The run was aborted due to an unrecoverable error.\n */\n outcome: \"aborted\";\n }\n | {\n abortReason: PollCiGreenlightNonHttpAbortReason;\n httpStatus: undefined;\n /**\n * The run was aborted due to an unrecoverable error.\n */\n outcome: \"aborted\";\n };\n\nexport type PollCiGreenlightParams = {\n /**\n * Callback to be called when the lifecycle stage of the run changes.\n */\n onRunStageChanged?: (\n current: CiGreenlightStatus,\n previous: CiGreenlightStatus | undefined,\n ) => unknown | Promise<unknown>;\n runId: string;\n} & Partial<PollCiGreenlightPollConfig>;\n\n// If you change these values, make sure you update the JSDoc\n// comments in the PollConfig type.\nconst safeDefaults: PollCiGreenlightPollConfig = {\n abortOnSuperseded: false,\n maxRetries: 10,\n pollTimeout: 120 * 60 * 1000,\n retryInterval: 10 * 1000,\n runInProgressInterval: 30 * 1000,\n runUnderReviewInterval: 60 * 1000,\n};\n\nexport async function pollCiGreenlightStatus(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n {\n onRunStageChanged: onRunStageChanged = () => undefined,\n runId,\n ...pollConfig\n }: PollCiGreenlightParams,\n): Promise<PollCiGreenlightStatus> {\n let retries = 0;\n const { log } = deps;\n const {\n abortOnSuperseded = safeDefaults.abortOnSuperseded,\n maxRetries = safeDefaults.maxRetries,\n pollTimeout = safeDefaults.pollTimeout,\n retryInterval = safeDefaults.retryInterval,\n runInProgressInterval = safeDefaults.runInProgressInterval,\n runUnderReviewInterval = safeDefaults.runUnderReviewInterval,\n } = pollConfig;\n let currentStatus: CiGreenlightStatus | undefined = undefined;\n const startedAt = Date.now();\n let hasTimedOut = false;\n while (!(hasTimedOut = Date.now() - startedAt > pollTimeout)) {\n const responseState = await fetchCiGreenlightStatus(\n apiConfig,\n {\n runId,\n },\n deps,\n );\n if (!responseState.ok && !responseState.canRetry) {\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) from CI greenlight, aborting.`,\n );\n return {\n abortReason: \"4XX-client-error\",\n httpStatus: responseState.httpStatus,\n outcome: \"aborted\",\n };\n }\n if (!responseState.ok) {\n // This is a non-OK retryable status.\n retries += 1;\n if (retries > maxRetries) {\n log.error(\n `🚫 Unrecoverable error${\n responseState.httpStatus\n ? ` (status ${responseState.httpStatus})`\n : \"\"\n } from CI greenlight, aborting after ${maxRetries} attempts.`,\n );\n if (responseState.errorType === \"network\") {\n return {\n abortReason: \"network-error\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n let abortReason: PollCiGreenlightAbortReason = \"XXX-other-http-code\";\n\n if (responseState.errorType === \"not-found\")\n abortReason = \"404-run-not-found\";\n else if (responseState.errorType === \"server\")\n abortReason = \"5XX-server-error\";\n else responseState satisfies never;\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n outcome: \"aborted\",\n };\n }\n const { errorType, httpStatus } = responseState;\n const retryLabel = `${\n httpStatus ? ` (status ${httpStatus})` : \"\"\n }, will try again... (${retries}/${maxRetries})`;\n if (errorType === \"network\") log.warn(`āŒ Network error${retryLabel}`);\n else if (errorType === \"not-found\")\n log.info(`ā³ Run not found${retryLabel}`);\n else if (errorType === \"server\") log.warn(`āŒ Server error${retryLabel}`);\n\n await sleep(retryInterval);\n continue;\n }\n // responseState.ok === true\n retries = 0;\n const { greenlightStatus } = responseState;\n const previousStatus = currentStatus;\n currentStatus = greenlightStatus;\n if (\n !previousStatus ||\n previousStatus.runStage !== greenlightStatus.runStage\n ) {\n try {\n await onRunStageChanged(greenlightStatus, previousStatus);\n } catch (e) {\n log.error(`Error in onRunStageChanged callback`, e);\n }\n }\n const urlInfo = `See ${greenlightStatus.relevantRunUrl}`;\n const {\n greenlight,\n relevantRunId,\n relevantRunUrl,\n relevantRunWithBugsUrl,\n rootRunId,\n rootRunUrl,\n runStage,\n } = greenlightStatus;\n if (rootRunId !== relevantRunId) {\n const supersedingDetails = `\n - Root: ${rootRunUrl}\n - Superseding: ${relevantRunUrl}`;\n if (abortOnSuperseded) {\n log.warn(\n `āŒ Aborting due to superseded run (option 'abortOnSuperseded' is enabled).${supersedingDetails}`,\n );\n return {\n abortReason: \"superseded-run\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n log.info(`Root run was superseded:${supersedingDetails}`);\n }\n if (runStage === \"completed\") {\n const {\n blockingBugsCount,\n blockingBugUrls = [],\n nonBlockingBugsCount,\n nonBlockingBugUrls = [],\n } = greenlightStatus;\n const blockingBugList = blockingBugUrls\n .map((url) => `\\n• ${url}`)\n .join(\"\");\n const nonBlockingBugList = nonBlockingBugUrls\n .map((url) => `\\n• ${url}`)\n .join(\"\");\n const bugsListInText = `${\n blockingBugUrls.length > 0 ? `\\nBLOCKING BUGS:${blockingBugList}` : \"\"\n }${\n nonBlockingBugUrls.length > 0\n ? `\\nNON BLOCKING BUGS:${nonBlockingBugList}`\n : \"\"\n }`;\n if (greenlight) {\n log.info(\n `āœ… Run passed and no blocking bugs found${\n nonBlockingBugsCount > 0\n ? ` and ${nonBlockingBugsCount} non-blocking bug${pluralize(\n nonBlockingBugsCount,\n )} found`\n : \"\"\n }.\\n${urlInfo}`,\n );\n return { greenlightStatus, outcome: \"success\" };\n } else {\n log.warn(\n `āŒ Run failed and ${blockingBugsCount} blocking bug${pluralize(\n blockingBugsCount,\n )} found${\n nonBlockingBugsCount\n ? ` and ${nonBlockingBugsCount} non-blocking bug${pluralize(\n nonBlockingBugsCount,\n )}`\n : \"\"\n }.\\nSee ${relevantRunWithBugsUrl}\\n` +\n \"You may review the priority of certain bugs to mark these non-blocking and retry the job.\\n\" +\n bugsListInText,\n );\n return { greenlightStatus, outcome: \"failed\" };\n }\n }\n if (runStage === \"canceled\") {\n log.info(\n `🚫 Run was canceled. Aborting... Please contact support.\\n${urlInfo}`,\n );\n return {\n abortReason: \"run-canceled\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n // Non-terminal run stages\n if (hasTimedOut) {\n log.warn(`āŒ Poll timed out after ${pollTimeout / 1000}s. Aborting...`);\n return {\n abortReason: \"poll-timed-out\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n if (runStage === \"initializing\") {\n log.info(`ā³ Run is in progress... ${urlInfo}`);\n await sleep(runInProgressInterval);\n } else if (runStage === \"underReview\") {\n log.info(`šŸ•µļø Run is under review... ${urlInfo}`);\n await sleep(runUnderReviewInterval);\n } else throw Error(`Unexpected run stage: ${runStage satisfies never}`);\n }\n\n log.warn(`āŒ Poll timed out after ${pollTimeout / 1000}s. Aborting...`);\n return {\n abortReason: \"poll-timed-out\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n}\n","import { type ApiConfig } from \"../api-types.js\";\nimport { buildFetchWithTimeout } from \"../other.js\";\n\nimport { defaultFetch } from \"./defaults/fetch.js\";\nimport { defaultLogDriver } from \"./defaults/log.js\";\nimport { defaultServiceBase } from \"./defaults/serviceBase.js\";\nimport { defaultUserAgent } from \"./defaults/userAgent.js\";\nimport { type SdkDependencies } from \"./dependencies.js\";\nimport { attemptNotifyDeploy } from \"./domain/attemptDeploy/index.js\";\nimport { generateSignedUrlForRunInputsExecutablesStorage } from \"./domain/generateSignedUrls/generate-signed-url-for-run-inputs-executables.js\";\nimport { generateSignedUrlForTempTeamStorage } from \"./domain/generateSignedUrls/generate-signed-url-for-team-storage.js\";\nimport { pollCiGreenlightStatus } from \"./domain/poll-ci-greenlight.js\";\n\nexport function makeQaWolfSdk(\n {\n apiKey,\n serviceBase = defaultServiceBase,\n userAgent = defaultUserAgent,\n }: {\n apiKey: string;\n serviceBase?: string;\n userAgent?: string;\n },\n {\n fetch = defaultFetch,\n log = defaultLogDriver,\n }: Partial<SdkDependencies> = {},\n) {\n if (typeof fetch !== \"function\") {\n throw Error(\n `QA Wolf CI-SDK requires fetch to be defined. Make sure you are using NodeJS 18+, OR pass a fetch polyfill to the makeQaWolfSdk function.\nWe recommend 'undici' package for that purpose. See the Requirement section of our README for more guidance.`,\n );\n }\n\n const deps: SdkDependencies = {\n // Versions of fetch may have different default timeouts. For consistency, we explicitly set it to 60 seconds here.\n fetch: buildFetchWithTimeout(fetch, 60000),\n log,\n };\n const apiConfig: ApiConfig = { apiKey, serviceBase, userAgent };\n return {\n attemptNotifyDeploy: attemptNotifyDeploy.bind(null, deps, apiConfig),\n generateSignedUrlForRunInputsExecutablesStorage:\n generateSignedUrlForRunInputsExecutablesStorage.bind(\n null,\n deps,\n apiConfig,\n ),\n generateSignedUrlForTempTeamStorage:\n generateSignedUrlForTempTeamStorage.bind(null, deps, apiConfig),\n pollCiGreenlightStatus: pollCiGreenlightStatus.bind(null, deps, apiConfig),\n };\n}\n\nexport type * from \"./domain/attemptDeploy/index.js\";\nexport type * from \"./domain/generateSignedUrls/types.js\";\nexport type * from \"./domain/poll-ci-greenlight.js\";\n"]}
1
+ {"version":3,"sources":["../src/lib/other.ts","../src/lib/sdk/defaults/fetch.ts","../src/lib/sdk/defaults/log.ts","../src/lib/sdk/defaults/serviceBase.ts","../package.json","../src/lib/sdk/defaults/userAgent.ts","../src/lib/api/log.ts","../src/lib/sdk/domain/attemptDeploy/index.ts","../src/lib/api/generate-signed-url-for-run-inputs-executables.ts","../src/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-run-inputs-executables.ts","../src/lib/api/generate-signed-url-for-team-storage.ts","../src/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-team-storage.ts","../src/lib/api/ci-greenlight.ts","../src/lib/sdk/domain/poll-ci-greenlight.ts","../src/lib/sdk/index.ts"],"names":["sleep","ms","Promise","resolve","setTimeout","pluralize","count","buildFetchWithTimeout","fetch","timeout","args","signal","AbortSignal","defaultFetch","globalThis","defaultLogDriver","error","message","console","info","log","warn","defaultServiceBase","defaultUserAgent","packageJson","version","logFetchError","methodName","response","ok","eventId","failureMessage","body","json","catch","text","undefined","eventIdSuffix","messageSuffix","statusText","status","attemptNotifyDeploy","deps","apiConfig","config","localFetch","URL","serviceBase","JSON","stringify","branch","commit_url","commitUrl","deduplication_key","deduplicationKey","deployment_type","deploymentType","deployment_url","deploymentUrl","ephemeral_environment","ephemeralEnvironment","hosting_service","hostingService","merge_request_number","mergeRequestNumber","pull_request_number","pullRequestNumber","repository","sha","variables","headers","Authorization","apiKey","userAgent","method","handleErrorResponse","data","handleSuccessResponse","abortReason","httpStatus","outcome","environment","results","isPreviewDeployment","isStatic","logPrefix","alias","id","length","environmentId","runId","failReason","failedTrigger","find","t","failure_reason","duplicateSuite","duplicate_suite_id","successfulTrigger","created_suite_id","callGenerateSignedUrlForRunInputsExecutablesStorage","destinationFilePath","encodeURIComponent","fileLocation","playgroundFileLocation","signedUrl","success","errorMessage","e","generateSignedUrlForRunInputsExecutablesStorage","responseState","uploadUrl","callGenerateSignedUrlForTempTeamStorage","generateSignedUrlForTempTeamStorage","fetchCiGreenlightStatus","resp","greenlightStatus","canRetry","errorType","safeDefaults","abortOnSuperseded","maxRetries","pollTimeout","retryInterval","runInProgressInterval","runUnderReviewInterval","pollCiGreenlightStatus","onRunStageChanged","pollConfig","retries","currentStatus","startedAt","Date","now","hasTimedOut","retryLabel","previousStatus","runStage","urlInfo","relevantRunUrl","greenlight","relevantRunId","relevantRunWithBugsUrl","rootRunId","rootRunUrl","supersedingDetails","blockingBugsCount","blockingBugUrls","nonBlockingBugsCount","nonBlockingBugUrls","blockingBugList","map","url","join","nonBlockingBugList","bugsListInText","Error","makeQaWolfSdk","bind"],"mappings":";;;;;;AAEO,SAASA,MAAMC,EAAAA,EAAU;AAC9B,EAAA,OAAO,IAAIC,OAAAA,CAAQ,CAACC,YAAYC,UAAAA,CAAWD,OAAAA,EAASF,EAAAA,CAAAA,CAAAA;AACtD;AAFgBD,MAAAA,CAAAA,KAAAA,EAAAA,OAAAA,CAAAA;AAIT,SAASK,UAAUC,KAAAA,EAAa;AACrC,EAAA,OAAOA,KAAAA,KAAU,IAAI,EAAA,GAAK,GAAA;AAC5B;AAFgBD,MAAAA,CAAAA,SAAAA,EAAAA,WAAAA,CAAAA;AAYT,IAAME,qBAAAA,2BACVC,KAAAA,EAAoBC,OAAAA,KACrB,UAAUC,IAAAA,KACRF,KAAAA,CAAME,IAAAA,CAAK,CAAA,CAAA,EAAI;AAAE,EAAA,GAAGA,KAAK,CAAA,CAAA;EAAIC,MAAAA,EAAQC,WAAAA,CAAYH,QAAQA,OAAAA;AAAS,CAAA,CAAA,EAFpE,uBAAA,CAAA;;;ACnBK,IAAMI,eAAeC,UAAAA,CAAWN,KAAAA;;;ACEhC,IAAMO,gBAAAA,GAA8B;AACzCC,EAAAA,KAAAA,CAAMC,SAASD,KAAAA,EAAK;AAClBE,IAAAA,OAAAA,CAAQF,KAAAA,CAAMC,SAASD,KAAAA,CAAAA;AACzB,EAAA,CAAA;AACAG,EAAAA,IAAAA,CAAKF,OAAAA,EAAO;AACVC,IAAAA,OAAAA,CAAQE,IAAIH,OAAAA,CAAAA;AACd,EAAA,CAAA;AACAI,EAAAA,IAAAA,CAAKJ,OAAAA,EAAO;AACVC,IAAAA,OAAAA,CAA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AAAA,CAAAA;AAC1DkE,IAAAA,+CAAAA,EACEA,+CAAAA,CAAgDiD,IAAAA,CAC9C,IAAA,EACApH,IAAAA,EACAC,SAAAA,CAAAA;AAEJsE,IAAAA,mCAAAA,EACEA,mCAAAA,CAAoC6C,IAAAA,CAAK,IAAA,EAAMpH,IAAAA,EAAMC,SAAAA,CAAAA;AACvDmF,IAAAA,sBAAAA,EAAwBA,sBAAAA,CAAuBgC,IAAAA,CAAK,IAAA,EAAMpH,IAAAA,EAAMC,SAAAA;AAClE,GAAA;AACF;AA1CgBkH,MAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA","file":"index.cjs","sourcesContent":["import type { FetchDriver } from \"./sdk/dependencies.js\";\n\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function pluralize(count: number) {\n return count === 1 ? \"\" : \"s\";\n}\n\nexport function getBackoffMs(\n attemptNumber: number,\n minWaitMs = 1000,\n maxWaitMs = 10000,\n): number {\n return Math.min(maxWaitMs, minWaitMs * 1.2 ** attemptNumber);\n}\n\nexport const buildFetchWithTimeout =\n (fetch: FetchDriver, timeout: number) =>\n async (...args: Parameters<FetchDriver>) =>\n fetch(args[0], { ...args[1], signal: AbortSignal.timeout(timeout) });\n","export const defaultFetch = globalThis.fetch;\n","import type { LogDriver } from \"../dependencies.js\";\n\nexport const defaultLogDriver: LogDriver = {\n error(message, error) {\n console.error(message, error);\n },\n info(message) {\n console.log(message);\n },\n warn(message) {\n console.warn(message);\n },\n};\n","export const defaultServiceBase = \"https://app.qawolf.com/\";\n","{\n \"name\": \"@qawolf/ci-sdk\",\n \"version\": \"1.1.1\",\n \"private\": false,\n \"description\": \"A simple SDK for interacting with QAWolf in CI scripts.\",\n \"keywords\": [],\n \"license\": \"MIT\",\n \"author\": \"Jules Sam. Randolph<jules@qawolf.com>\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"require\": \"./dist/index.cjs\",\n \"import\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n }\n },\n \"files\": [\n \"/dist\",\n \"/README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/index.ts --format esm,cjs --dts --clean --splitting --treeshake --sourcemap --outDir dist --target es2022\",\n \"lint\": \"dpdm --exit-code circular:1 --no-tree --no-warning --transform --include='.*' --exclude='/(dist|node_modules)/' '**/*' && eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx --quiet && prettier --check .\",\n \"lint:fix\": \"eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx --fix --quiet && prettier --log-level=warn --write .\",\n \"lint:warnings\": \"eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx\",\n \"prepublishOnly\": \"nx run ci-sdk:build\",\n \"test\": \"NODE_OPTIONS=\\\"--experimental-vm-modules\\\" NODE_NO_WARNINGS=1 jest\",\n \"tsc:check\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@qawolf/ci-utils\": \"^1.0.0\",\n \"@sinonjs/fake-timers\": \"^10.3.0\",\n \"slugify\": \"^1.6.6\",\n \"tslib\": \"^2.6.2\"\n },\n \"devDependencies\": {\n \"tsup\": \"^8.3.5\"\n },\n \"engines\": {\n \"node\": \">=20\"\n }\n}\n","import packageJson from \"../../../../package.json\" with { type: \"json\" };\n\nexport const defaultUserAgent = `ci-sdk/${packageJson.version}`;\n","import type { LogDriver } from \"@qawolf/ci-utils\";\n\nexport async function logFetchError({\n log,\n methodName,\n response,\n}: {\n log: LogDriver;\n methodName: string;\n response: Response;\n}) {\n if (response.ok) return;\n\n const { eventId, failureMessage } = await (async () => {\n try {\n const body = (await response.json().catch(() => response.text())) as\n | Record<string, unknown>\n | string;\n if (typeof body === \"object\" && body !== null) {\n return {\n eventId: body.eventId,\n failureMessage: body.failureMessage,\n };\n }\n // If body is not an object (i.e., it's the text from catch)\n return {\n eventId: undefined,\n failureMessage: body,\n };\n } catch {\n // If both parsing attempts somehow fail\n return {\n eventId: undefined,\n failureMessage: undefined,\n };\n }\n })();\n\n const eventIdSuffix = eventId ? ` (Event ID: ${eventId})` : \"\";\n const messageSuffix = failureMessage ? `: ${failureMessage}` : \"\";\n\n const statusText =\n response.status >= 500\n ? \"Server Error\"\n : response.statusText || \"Unknown Error\";\n\n log.error(\n `āŒ [${methodName}] ${response.status} ${statusText}${eventIdSuffix}${messageSuffix}`,\n );\n}\n","import type { ApiConfig } from \"../../../api-types.js\";\nimport { logFetchError } from \"../../../api/log.js\";\nimport type { LogDriver, SdkDependencies } from \"../../dependencies.js\";\n\nimport type {\n AttemptDeployHttpAbortReason,\n DeployConfig,\n DeployStatus,\n NotifyDeployStatus,\n} from \"./types.js\";\n\nexport async function attemptNotifyDeploy(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: Partial<DeployConfig>,\n): Promise<NotifyDeployStatus> {\n const { fetch: localFetch, log } = deps;\n try {\n const response = await localFetch(\n new URL(\"/api/webhooks/deploy_success\", apiConfig.serviceBase),\n {\n body: JSON.stringify({\n branch: config.branch,\n commit_url: config.commitUrl,\n deduplication_key: config.deduplicationKey,\n deployment_type: config.deploymentType,\n deployment_url: config.deploymentUrl,\n ...(\"ephemeralEnvironment\" in config\n ? {\n ephemeral_environment: config.ephemeralEnvironment,\n }\n : \"hostingService\" in config && {\n hosting_service: config.hostingService,\n merge_request_number:\n config.hostingService === \"GitLab\"\n ? config.mergeRequestNumber\n : undefined,\n pull_request_number:\n config.hostingService === \"GitHub\"\n ? config.pullRequestNumber\n : undefined,\n repository: config.repository,\n }),\n sha: config.sha,\n variables: config.variables,\n }),\n headers: {\n Authorization: `Bearer ${apiConfig.apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": apiConfig.userAgent,\n },\n method: \"POST\",\n },\n );\n\n if (!response.ok) return handleErrorResponse(response, log);\n const data = (await response.json()) as DeployStatus;\n return handleSuccessResponse(data, log);\n } catch (error) {\n log.error(`🚫 Network error from deploy_success, aborting.`);\n return {\n abortReason: \"network-error\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n}\n\nasync function handleErrorResponse(\n response: Response,\n log: LogDriver,\n): Promise<NotifyDeployStatus> {\n const status = response.status;\n let abortReason: AttemptDeployHttpAbortReason;\n if (status === undefined) abortReason = \"network-error\";\n else if (status === 401) abortReason = \"401-unauthorized\";\n else if (status === 403) abortReason = \"403-forbidden\";\n else if (status >= 500) abortReason = \"5XX-server-error\";\n else abortReason = \"4XX-client-error\";\n await logFetchError({\n log,\n methodName: \"attemptNotifyDeploy\",\n response,\n });\n return {\n abortReason,\n httpStatus: status,\n outcome: \"aborted\",\n };\n}\n\nasync function handleSuccessResponse(\n data: DeployStatus,\n log: LogDriver,\n): Promise<NotifyDeployStatus> {\n const { environment, results } = data;\n const isPreviewDeployment = environment && !environment.isStatic;\n\n if (environment) {\n const logPrefix = environment.isStatic\n ? \"Static environment\"\n : \"Preview environment\";\n log.info(`${logPrefix}: ${environment.alias} (id: ${environment.id})`);\n }\n\n // No triggers were matched\n if (results.length === 0) {\n if (isPreviewDeployment) {\n log.info(\n `āœ… Deployment notification was successful. No run was created for this deployment.`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: undefined,\n };\n }\n log.error(\n `🚫 No trigger matched the request. Please make sure there is at least one active test in the QA Wolf environment, or contact support.`,\n );\n return { failReason: \"no-matched-trigger\", outcome: \"failed\" };\n }\n\n // If there are results, environment must be defined\n if (!environment) {\n log.error(`🚫 No environment matched the request. Please contact support.`);\n return { failReason: \"no-environment\", outcome: \"failed\" };\n }\n\n const failedTrigger = results.find((t) => \"failure_reason\" in t);\n if (failedTrigger) {\n log.error(\n `🚫 Run could not be created. Reason: \"${failedTrigger.failure_reason}\". Please contact support.`,\n );\n return { failReason: \"run-could-not-be-created\", outcome: \"failed\" };\n }\n\n const duplicateSuite = results.find((t) => \"duplicate_suite_id\" in t);\n if (duplicateSuite) {\n log.info(\n `āœ… Deployment notification was successful. Previous run ID: ${duplicateSuite.duplicate_suite_id} already exists for this deployment.`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: duplicateSuite.duplicate_suite_id,\n };\n }\n\n const successfulTrigger = results.find((t) => \"created_suite_id\" in t);\n if (!successfulTrigger) {\n log.error(`🚫 No trigger matched the request. Please contact support.`);\n return { failReason: \"no-matched-trigger\", outcome: \"failed\" };\n }\n log.info(\n `āœ… Deployment notification was successful. Run created with ID: ${successfulTrigger.created_suite_id}`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: successfulTrigger.created_suite_id,\n };\n}\n","import type { ApiConfig } from \"../api-types.js\";\nimport type { SdkDependencies } from \"../sdk/dependencies.js\";\nimport type {\n GenerateSignedUrlConfig,\n GenerateSignedUrlResponse,\n} from \"../sdk/domain/generateSignedUrls/types.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport async function callGenerateSignedUrlForRunInputsExecutablesStorage(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n { destinationFilePath }: GenerateSignedUrlConfig,\n { fetch: localFetch, log }: SdkDependencies,\n): Promise<GenerateSignedUrlResponse> {\n try {\n const response = await localFetch(\n new URL(\n `${serviceBase}/api/v0/run-inputs-executables-signed-urls?file=${encodeURIComponent(destinationFilePath)}`,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": userAgent,\n },\n method: \"GET\",\n },\n );\n\n if (response.status === 200) {\n const json =\n (await response.json()) as Partial<GenerateSignedUrlResponse>;\n return {\n fileLocation: json.fileLocation,\n httpStatus: response.status,\n playgroundFileLocation: json.playgroundFileLocation,\n signedUrl: json.signedUrl,\n success: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"callGenerateSignedUrlForRunInputsExecutablesStorage\",\n response,\n });\n return {\n errorMessage: await response.text(),\n httpStatus: response.status,\n success: false,\n } as const;\n } catch (e) {\n return {\n errorMessage: \"Network error, aborting request to generate signed URL\",\n httpStatus: 0,\n success: false,\n } as const;\n }\n}\n","import type { ApiConfig } from \"../../../api-types.js\";\nimport { callGenerateSignedUrlForRunInputsExecutablesStorage } from \"../../../api/generate-signed-url-for-run-inputs-executables.js\";\nimport type { SdkDependencies } from \"../../dependencies.js\";\n\nimport type {\n GenerateSignedUrlAbortReason,\n GenerateSignedUrlConfig,\n GenerateSignedUrlStatus,\n} from \"./types.js\";\n\nexport async function generateSignedUrlForRunInputsExecutablesStorage(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: GenerateSignedUrlConfig,\n): Promise<GenerateSignedUrlStatus> {\n const { log } = deps;\n\n if (!config.destinationFilePath) {\n log.error(`🚫 destinationFilePath is a required config parameter`);\n return {\n abortReason: \"sdk-argument-validation-failed\",\n success: false,\n };\n }\n\n const responseState =\n await callGenerateSignedUrlForRunInputsExecutablesStorage(\n apiConfig,\n config,\n deps,\n );\n if (!responseState.success) {\n let abortReason: GenerateSignedUrlAbortReason = \"XXX-other-http-code\";\n\n if (responseState.httpStatus >= 500) {\n abortReason = \"5XX-server-error\";\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: aborting.`,\n );\n } else {\n if (responseState.httpStatus === 400) abortReason = \"400-invalid-request\";\n else if (responseState.httpStatus === 401)\n abortReason = \"401-invalid-credentials\";\n else if (responseState.httpStatus === 403) abortReason = \"403-forbidden\";\n else if (responseState.httpStatus === 0)\n abortReason = \"client-network-error\";\n\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: ${responseState.errorMessage ? `${responseState.errorMessage}.` : \"\"} aborting.`,\n );\n }\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n success: false,\n };\n }\n\n log.info(`āœ… Generated Signed Upload URL: ${responseState.signedUrl}.`);\n return {\n fileLocation: responseState.fileLocation,\n playgroundFileLocation: responseState.playgroundFileLocation,\n success: true,\n uploadUrl: responseState.signedUrl,\n };\n}\n","import type { ApiConfig } from \"../api-types.js\";\nimport type { SdkDependencies } from \"../sdk/dependencies.js\";\nimport type {\n GenerateSignedUrlConfig,\n GenerateSignedUrlResponse,\n} from \"../sdk/domain/generateSignedUrls/types.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport async function callGenerateSignedUrlForTempTeamStorage(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n { destinationFilePath }: Partial<GenerateSignedUrlConfig>,\n { fetch: localFetch, log }: SdkDependencies,\n): Promise<GenerateSignedUrlResponse> {\n try {\n const response = await localFetch(\n new URL(\n `${serviceBase}/api/v0/team-storage-signed-url?file=${destinationFilePath}`,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": userAgent,\n },\n method: \"GET\",\n },\n );\n\n if (response.status === 200) {\n const json =\n (await response.json()) as Partial<GenerateSignedUrlResponse>;\n return {\n fileLocation: json.fileLocation,\n httpStatus: response.status,\n playgroundFileLocation: json.playgroundFileLocation,\n signedUrl: json.signedUrl,\n success: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"callGenerateSignedUrlForTempTeamStorage\",\n response,\n });\n return {\n errorMessage: await response.text(),\n httpStatus: response.status,\n success: false,\n } as const;\n } catch (e) {\n return {\n errorMessage: \"Network error, aborting request to generate signed URL\",\n httpStatus: 0,\n success: false,\n } as const;\n }\n}\n","import type { ApiConfig } from \"../../../api-types.js\";\nimport { callGenerateSignedUrlForTempTeamStorage } from \"../../../api/generate-signed-url-for-team-storage.js\";\nimport type { SdkDependencies } from \"../../dependencies.js\";\n\nimport type { GenerateSignedUrlConfig } from \"./types.js\";\n\ntype GenerateSignedUrlStatus =\n | {\n fileLocation?: string;\n playgroundFileLocation?: string;\n success: true;\n uploadUrl?: string;\n }\n | {\n abortReason: GenerateSignedUrlAbortReason;\n httpStatus?: number;\n success: false;\n };\n\nexport type GenerateSignedUrlAbortReason =\n | \"client-network-error\"\n | \"sdk-argument-validation-failed\"\n | \"400-invalid-request\"\n | \"401-invalid-credentials\"\n | \"403-forbidden\"\n | \"5XX-server-error\"\n | \"XXX-other-http-code\";\n\nexport async function generateSignedUrlForTempTeamStorage(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: GenerateSignedUrlConfig,\n): Promise<GenerateSignedUrlStatus> {\n const { log } = deps;\n\n if (!config.destinationFilePath) {\n log.error(`🚫 destinationFilePath is a required config parameter`);\n return {\n abortReason: \"sdk-argument-validation-failed\",\n success: false,\n };\n }\n\n const responseState = await callGenerateSignedUrlForTempTeamStorage(\n apiConfig,\n config,\n deps,\n );\n if (!responseState.success) {\n let abortReason: GenerateSignedUrlAbortReason = \"XXX-other-http-code\";\n\n if (responseState.httpStatus >= 500) {\n abortReason = \"5XX-server-error\";\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: aborting.`,\n );\n } else {\n if (responseState.httpStatus === 400) abortReason = \"400-invalid-request\";\n else if (responseState.httpStatus === 401)\n abortReason = \"401-invalid-credentials\";\n else if (responseState.httpStatus === 403) abortReason = \"403-forbidden\";\n else if (responseState.httpStatus === 0)\n abortReason = \"client-network-error\";\n\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: ${responseState.errorMessage ? `${responseState.errorMessage}.` : \"\"} aborting.`,\n );\n }\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n success: false,\n };\n }\n\n log.info(`āœ… Generated Signed Upload URL: ${responseState.signedUrl}.`);\n return {\n fileLocation: responseState.fileLocation,\n playgroundFileLocation: responseState.playgroundFileLocation,\n success: true,\n uploadUrl: responseState.signedUrl,\n };\n}\n","import type { ApiConfig } from \"../api-types.js\";\nimport type { SdkDependencies } from \"../sdk/dependencies.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport type CiGreenlightBugDetails = {\n /**\n * The URL of this BR in the QAWolf application.\n */\n applicationUrl: string;\n /**\n * If this bug report is linked to an external issue, it will\n * show up here.\n */\n externalIssue:\n | {\n /**\n * The URL of the external issue in the external platform\n * application.\n */\n applicationUrl: string;\n /**\n * The ID of this issue in the external platform.\n */\n externalIssueId: string;\n /**\n * Lowercase platform name (e.g. \"jira\").\n */\n platform: string;\n }\n | undefined;\n /**\n * True if the bug is blocking.\n */\n isBlocking: boolean;\n /**\n * True if the bug has been found in this run.\n */\n isNew: boolean;\n /**\n * The name of this bug.\n */\n name: string;\n /**\n * The bug number.\n */\n number: number;\n /**\n * The priority of this bug.\n */\n priority: \"medium\" | \"unprioritized\" | \"low\" | \"high\" | \"urgent\";\n};\n\nexport type CiGreenlightBugData = {\n /**\n * The count of blocking bugs reproduced in the run.\n */\n blockingBugsCount: number;\n /**\n * The URLs of the blocking bugs.\n *\n * @deprecated This field will be removed in the next major version.\n * Prefer using `reproducedBugs` filtered by `isBlocking: true`, reading\n * the `applicationUrl` field.\n */\n blockingBugUrls: string[];\n /**\n * The count of non-blocking bugs reproduced in the run.\n */\n nonBlockingBugsCount: number;\n /**\n * The URLs of the non-blocking bugs.\n *\n * @deprecated This field will be removed in the next major version.\n * Prefer using `reproducedBugs` filtered by `isBlocking: false`, reading\n * the `applicationUrl` field.\n */\n nonBlockingBugUrls: string[];\n /**\n * Blocking bugs that were not reproduced in this run, but are still\n * opened in the run environment. This may happen when the run only covers a\n * subset of the workflows in environment.\n */\n otherBlockingBugsInEnvironment: CiGreenlightBugDetails[];\n /**\n * Bugs that were reproduced in this run. This includes newly found bugs.\n */\n reproducedBugs: CiGreenlightBugDetails[];\n};\n\n/**\n * @deprecated This type will be removed in the next major version. Use `CiGreenlightBugData` instead.\n */\nexport type CiGreenlightCompletedSuiteDetails = CiGreenlightBugData;\n\nexport type CiGreenlightStatusBase = {\n relevantRunId: string;\n relevantRunUrl: string;\n relevantRunWithBugsUrl: string;\n rootRunId: string;\n rootRunUrl: string;\n workflowsDisabledAfterRunCount: number;\n workflowsInRunCount: number;\n workflowsUnderInvestigationCount: number;\n};\n\n/**\n * The status of a CI greenlight run. See the API documentation here for\n * more details: https://qawolf.notion.site/1b170576efea411fa785842a71e7c99e\n */\nexport type CiGreenlightStatus = CiGreenlightStatusBase &\n (\n | ({\n greenlight: boolean;\n runStage: \"completed\";\n } & CiGreenlightBugData)\n | ({\n greenlight: false;\n runStage: \"underReview\";\n } & CiGreenlightBugData)\n | {\n greenlight: false;\n runStage: \"initializing\" | \"underReview\" | \"canceled\";\n }\n );\n\nexport async function fetchCiGreenlightStatus(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n {\n runId,\n }: {\n runId: string;\n },\n { fetch: localFetch, log }: SdkDependencies,\n) {\n try {\n const resp = await localFetch(\n new URL(\n `/api/v0/ci-greenlight/${encodeURIComponent(runId)}`,\n serviceBase,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"User-Agent\": userAgent,\n },\n },\n );\n\n if (resp.ok) {\n const greenlightStatus = (await resp.json()) as CiGreenlightStatus;\n return {\n greenlightStatus,\n httpStatus: resp.status,\n ok: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"fetchCiGreenlightStatus\",\n response: resp,\n });\n if (resp.status === 404) {\n return {\n canRetry: true,\n errorType: \"not-found\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n }\n if (resp.status >= 500) {\n return {\n canRetry: true,\n errorType: \"server\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n }\n return {\n canRetry: false,\n errorType: \"client\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n } catch (e) {\n return {\n canRetry: true,\n errorType: \"network\",\n httpStatus: 0,\n ok: false,\n } as const;\n }\n}\n","/* eslint-disable @qawolf/max-lines -- Old technical debt */\n\nimport type { ApiConfig } from \"../../api-types.js\";\nimport {\n type CiGreenlightStatus,\n fetchCiGreenlightStatus,\n} from \"../../api/ci-greenlight.js\";\nimport { pluralize, sleep } from \"../../other.js\";\nimport type { SdkDependencies } from \"../dependencies.js\";\n\nexport type PollCiGreenlightPollConfig = {\n /**\n * If true, the job will be aborted when a superseding run is detected.\n *\n * @default false\n */\n abortOnSuperseded: boolean;\n /**\n * Maximum number of network operations retries before aborting the job.\n *\n * @default 10\n */\n maxRetries: number;\n /**\n * Timeout in milliseconds before aborting this polling operation.\n *\n * @default 120 minutes\n */\n pollTimeout: number;\n /**\n * Interval in milliseconds between network operations retries.\n *\n * @default 10 seconds\n */\n retryInterval: number;\n /**\n * Interval in milliseconds between polling for a run in progress.\n *\n * @default 30 seconds\n */\n runInProgressInterval: number;\n /**\n * Interval in milliseconds between polling for a run under review.\n *\n * @default 60 minutes\n */\n runUnderReviewInterval: number;\n};\n\nexport type PollCiGreenlightHttpAbortReason =\n | \"4XX-client-error\"\n | \"404-run-not-found\"\n | \"5XX-server-error\"\n | \"XXX-other-http-code\";\n\nexport type PollCiGreenlightNonHttpAbortReason =\n | \"poll-timed-out\"\n | \"run-canceled\"\n | \"network-error\"\n | \"superseded-run\";\n\nexport type PollCiGreenlightAbortReason =\n | PollCiGreenlightNonHttpAbortReason\n | PollCiGreenlightHttpAbortReason;\n\nexport type PollCiGreenlightStatus =\n | {\n greenlightStatus: Extract<CiGreenlightStatus, { runStage: \"completed\" }>;\n /**\n * No blocking bugs were found in the run.\n */\n outcome: \"success\";\n }\n | {\n greenlightStatus: Extract<CiGreenlightStatus, { runStage: \"completed\" }>;\n /**\n * Blocking bugs were found in the run.\n */\n outcome: \"failed\";\n }\n | {\n abortReason: PollCiGreenlightHttpAbortReason;\n httpStatus: number;\n /**\n * The run was aborted due to an unrecoverable error.\n */\n outcome: \"aborted\";\n }\n | {\n abortReason: PollCiGreenlightNonHttpAbortReason;\n httpStatus: undefined;\n /**\n * The run was aborted due to an unrecoverable error.\n */\n outcome: \"aborted\";\n };\n\nexport type PollCiGreenlightParams = {\n /**\n * Callback to be called when the lifecycle stage of the run changes.\n */\n onRunStageChanged?: (\n current: CiGreenlightStatus,\n previous: CiGreenlightStatus | undefined,\n ) => unknown | Promise<unknown>;\n runId: string;\n} & Partial<PollCiGreenlightPollConfig>;\n\n// If you change these values, make sure you update the JSDoc\n// comments in the PollConfig type.\nconst safeDefaults: PollCiGreenlightPollConfig = {\n abortOnSuperseded: false,\n maxRetries: 10,\n pollTimeout: 120 * 60 * 1000,\n retryInterval: 10 * 1000,\n runInProgressInterval: 30 * 1000,\n runUnderReviewInterval: 60 * 1000,\n};\n\nexport async function pollCiGreenlightStatus(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n {\n onRunStageChanged: onRunStageChanged = () => undefined,\n runId,\n ...pollConfig\n }: PollCiGreenlightParams,\n): Promise<PollCiGreenlightStatus> {\n let retries = 0;\n const { log } = deps;\n const {\n abortOnSuperseded = safeDefaults.abortOnSuperseded,\n maxRetries = safeDefaults.maxRetries,\n pollTimeout = safeDefaults.pollTimeout,\n retryInterval = safeDefaults.retryInterval,\n runInProgressInterval = safeDefaults.runInProgressInterval,\n runUnderReviewInterval = safeDefaults.runUnderReviewInterval,\n } = pollConfig;\n let currentStatus: CiGreenlightStatus | undefined = undefined;\n const startedAt = Date.now();\n let hasTimedOut = false;\n while (!(hasTimedOut = Date.now() - startedAt > pollTimeout)) {\n const responseState = await fetchCiGreenlightStatus(\n apiConfig,\n {\n runId,\n },\n deps,\n );\n if (!responseState.ok && !responseState.canRetry) {\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) from CI greenlight, aborting.`,\n );\n return {\n abortReason: \"4XX-client-error\",\n httpStatus: responseState.httpStatus,\n outcome: \"aborted\",\n };\n }\n if (!responseState.ok) {\n // This is a non-OK retryable status.\n retries += 1;\n if (retries > maxRetries) {\n log.error(\n `🚫 Unrecoverable error${\n responseState.httpStatus\n ? ` (status ${responseState.httpStatus})`\n : \"\"\n } from CI greenlight, aborting after ${maxRetries} attempts.`,\n );\n if (responseState.errorType === \"network\") {\n return {\n abortReason: \"network-error\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n let abortReason: PollCiGreenlightAbortReason = \"XXX-other-http-code\";\n\n if (responseState.errorType === \"not-found\")\n abortReason = \"404-run-not-found\";\n else if (responseState.errorType === \"server\")\n abortReason = \"5XX-server-error\";\n else responseState satisfies never;\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n outcome: \"aborted\",\n };\n }\n const { errorType, httpStatus } = responseState;\n const retryLabel = `${\n httpStatus ? ` (status ${httpStatus})` : \"\"\n }, will try again... (${retries}/${maxRetries})`;\n if (errorType === \"network\") log.warn(`āŒ Network error${retryLabel}`);\n else if (errorType === \"not-found\")\n log.info(`ā³ Run not found${retryLabel}`);\n else if (errorType === \"server\") log.warn(`āŒ Server error${retryLabel}`);\n\n await sleep(retryInterval);\n continue;\n }\n // responseState.ok === true\n retries = 0;\n const { greenlightStatus } = responseState;\n const previousStatus = currentStatus;\n currentStatus = greenlightStatus;\n if (\n !previousStatus ||\n previousStatus.runStage !== greenlightStatus.runStage\n ) {\n try {\n await onRunStageChanged(greenlightStatus, previousStatus);\n } catch (e) {\n log.error(`Error in onRunStageChanged callback`, e);\n }\n }\n const urlInfo = `See ${greenlightStatus.relevantRunUrl}`;\n const {\n greenlight,\n relevantRunId,\n relevantRunUrl,\n relevantRunWithBugsUrl,\n rootRunId,\n rootRunUrl,\n runStage,\n } = greenlightStatus;\n if (rootRunId !== relevantRunId) {\n const supersedingDetails = `\n - Root: ${rootRunUrl}\n - Superseding: ${relevantRunUrl}`;\n if (abortOnSuperseded) {\n log.warn(\n `āŒ Aborting due to superseded run (option 'abortOnSuperseded' is enabled).${supersedingDetails}`,\n );\n return {\n abortReason: \"superseded-run\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n log.info(`Root run was superseded:${supersedingDetails}`);\n }\n if (runStage === \"completed\") {\n const {\n blockingBugsCount,\n blockingBugUrls = [],\n nonBlockingBugsCount,\n nonBlockingBugUrls = [],\n } = greenlightStatus;\n const blockingBugList = blockingBugUrls\n .map((url) => `\\n• ${url}`)\n .join(\"\");\n const nonBlockingBugList = nonBlockingBugUrls\n .map((url) => `\\n• ${url}`)\n .join(\"\");\n const bugsListInText = `${\n blockingBugUrls.length > 0 ? `\\nBLOCKING BUGS:${blockingBugList}` : \"\"\n }${\n nonBlockingBugUrls.length > 0\n ? `\\nNON BLOCKING BUGS:${nonBlockingBugList}`\n : \"\"\n }`;\n if (greenlight) {\n log.info(\n `āœ… Run passed and no blocking bugs found${\n nonBlockingBugsCount > 0\n ? ` and ${nonBlockingBugsCount} non-blocking bug${pluralize(\n nonBlockingBugsCount,\n )} found`\n : \"\"\n }.\\n${urlInfo}`,\n );\n return { greenlightStatus, outcome: \"success\" };\n } else {\n log.warn(\n `āŒ Run failed and ${blockingBugsCount} blocking bug${pluralize(\n blockingBugsCount,\n )} found${\n nonBlockingBugsCount\n ? ` and ${nonBlockingBugsCount} non-blocking bug${pluralize(\n nonBlockingBugsCount,\n )}`\n : \"\"\n }.\\nSee ${relevantRunWithBugsUrl}\\n` +\n \"You may review the priority of certain bugs to mark these non-blocking and retry the job.\\n\" +\n bugsListInText,\n );\n return { greenlightStatus, outcome: \"failed\" };\n }\n }\n if (runStage === \"canceled\") {\n log.info(\n `🚫 Run was canceled. Aborting... Please contact support.\\n${urlInfo}`,\n );\n return {\n abortReason: \"run-canceled\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n // Non-terminal run stages\n if (hasTimedOut) {\n log.warn(`āŒ Poll timed out after ${pollTimeout / 1000}s. Aborting...`);\n return {\n abortReason: \"poll-timed-out\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n if (runStage === \"initializing\") {\n log.info(`ā³ Run is in progress... ${urlInfo}`);\n await sleep(runInProgressInterval);\n } else if (runStage === \"underReview\") {\n log.info(`šŸ•µļø Run is under review... ${urlInfo}`);\n await sleep(runUnderReviewInterval);\n } else throw Error(`Unexpected run stage: ${runStage satisfies never}`);\n }\n\n log.warn(`āŒ Poll timed out after ${pollTimeout / 1000}s. Aborting...`);\n return {\n abortReason: \"poll-timed-out\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n}\n","import type { ApiConfig } from \"../api-types.js\";\nimport { buildFetchWithTimeout } from \"../other.js\";\n\nimport { defaultFetch } from \"./defaults/fetch.js\";\nimport { defaultLogDriver } from \"./defaults/log.js\";\nimport { defaultServiceBase } from \"./defaults/serviceBase.js\";\nimport { defaultUserAgent } from \"./defaults/userAgent.js\";\nimport type { SdkDependencies } from \"./dependencies.js\";\nimport { attemptNotifyDeploy } from \"./domain/attemptDeploy/index.js\";\nimport { generateSignedUrlForRunInputsExecutablesStorage } from \"./domain/generateSignedUrls/generate-signed-url-for-run-inputs-executables.js\";\nimport { generateSignedUrlForTempTeamStorage } from \"./domain/generateSignedUrls/generate-signed-url-for-team-storage.js\";\nimport { pollCiGreenlightStatus } from \"./domain/poll-ci-greenlight.js\";\n\nexport function makeQaWolfSdk(\n {\n apiKey,\n serviceBase = defaultServiceBase,\n userAgent = defaultUserAgent,\n }: {\n apiKey: string;\n serviceBase?: string;\n userAgent?: string;\n },\n {\n fetch = defaultFetch,\n log = defaultLogDriver,\n }: Partial<SdkDependencies> = {},\n) {\n if (typeof fetch !== \"function\") {\n throw Error(\n `QA Wolf CI-SDK requires fetch to be defined. Make sure you are using NodeJS 18+, OR pass a fetch polyfill to the makeQaWolfSdk function.\nWe recommend 'undici' package for that purpose. See the Requirement section of our README for more guidance.`,\n );\n }\n\n const deps: SdkDependencies = {\n // Versions of fetch may have different default timeouts. For consistency, we explicitly set it to 2 minutes here.\n // The increased timeout helps avoid edge cases where we need to search for a commit against multiple\n // code hosting service repositories as a fallback when not finding the repository based on organization/name.\n fetch: buildFetchWithTimeout(fetch, 120000),\n log,\n };\n const apiConfig: ApiConfig = { apiKey, serviceBase, userAgent };\n return {\n attemptNotifyDeploy: attemptNotifyDeploy.bind(null, deps, apiConfig),\n generateSignedUrlForRunInputsExecutablesStorage:\n generateSignedUrlForRunInputsExecutablesStorage.bind(\n null,\n deps,\n apiConfig,\n ),\n generateSignedUrlForTempTeamStorage:\n generateSignedUrlForTempTeamStorage.bind(null, deps, apiConfig),\n pollCiGreenlightStatus: pollCiGreenlightStatus.bind(null, deps, apiConfig),\n };\n}\n\nexport type * from \"./domain/attemptDeploy/index.js\";\nexport type * from \"./domain/generateSignedUrls/types.js\";\nexport type * from \"./domain/poll-ci-greenlight.js\";\n"]}
package/dist/index.d.cts CHANGED
@@ -171,7 +171,11 @@ type GitLabDeployConfig = BaseDeployConfig & {
171
171
  namespace: string;
172
172
  } | undefined;
173
173
  };
174
- type DeployConfig = GitHubDeployConfig | GitLabDeployConfig;
174
+ type EphemeralDeployConfig = BaseDeployConfig & {
175
+ deploymentUrl: string;
176
+ ephemeralEnvironment: true;
177
+ };
178
+ type DeployConfig = GitHubDeployConfig | GitLabDeployConfig | EphemeralDeployConfig;
175
179
  type DeploySuccessSuiteCreatedResult = {
176
180
  created_suite_id: string;
177
181
  trigger_id: string;
@@ -349,4 +353,4 @@ declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
349
353
  pollCiGreenlightStatus: (args_0: PollCiGreenlightParams) => Promise<PollCiGreenlightStatus>;
350
354
  };
351
355
 
352
- export { type AttemptDeployAbortReason, type AttemptDeployFailedReason, type AttemptDeployHttpAbortReason, type AttemptDeployNonHttpAbortReason, type CiGreenlightStatus, type CiGreenlightStatusBase, type DeployConfig, type DeployStatus, type DeployStatusErrorResponse, type DeployStatusResponse, type DeployStatusSuccessResponse, type DeploySuccessSuiteAlreadyExistsResult, type DeploySuccessSuiteCreatedResult, type DeploySuccessSuiteCreationFailureResult, type DeploySuccessSuiteResult, type FetchDriver, type GenerateSignedUrlAbortReason$1 as GenerateSignedUrlAbortReason, type GenerateSignedUrlConfig, type GenerateSignedUrlResponse, type GenerateSignedUrlStatus, type GitHubDeployConfig, type GitLabDeployConfig, type NotifyDeployStatus, type PollCiGreenlightAbortReason, type PollCiGreenlightHttpAbortReason, type PollCiGreenlightNonHttpAbortReason, type PollCiGreenlightParams, type PollCiGreenlightPollConfig, type PollCiGreenlightStatus, type SdkDependencies, attemptNotifyDeploy, makeQaWolfSdk, pollCiGreenlightStatus };
356
+ export { type AttemptDeployAbortReason, type AttemptDeployFailedReason, type AttemptDeployHttpAbortReason, type AttemptDeployNonHttpAbortReason, type CiGreenlightStatus, type CiGreenlightStatusBase, type DeployConfig, type DeployStatus, type DeployStatusErrorResponse, type DeployStatusResponse, type DeployStatusSuccessResponse, type DeploySuccessSuiteAlreadyExistsResult, type DeploySuccessSuiteCreatedResult, type DeploySuccessSuiteCreationFailureResult, type DeploySuccessSuiteResult, type EphemeralDeployConfig, type FetchDriver, type GenerateSignedUrlAbortReason$1 as GenerateSignedUrlAbortReason, type GenerateSignedUrlConfig, type GenerateSignedUrlResponse, type GenerateSignedUrlStatus, type GitHubDeployConfig, type GitLabDeployConfig, type NotifyDeployStatus, type PollCiGreenlightAbortReason, type PollCiGreenlightHttpAbortReason, type PollCiGreenlightNonHttpAbortReason, type PollCiGreenlightParams, type PollCiGreenlightPollConfig, type PollCiGreenlightStatus, type SdkDependencies, attemptNotifyDeploy, makeQaWolfSdk, pollCiGreenlightStatus };
package/dist/index.d.ts CHANGED
@@ -171,7 +171,11 @@ type GitLabDeployConfig = BaseDeployConfig & {
171
171
  namespace: string;
172
172
  } | undefined;
173
173
  };
174
- type DeployConfig = GitHubDeployConfig | GitLabDeployConfig;
174
+ type EphemeralDeployConfig = BaseDeployConfig & {
175
+ deploymentUrl: string;
176
+ ephemeralEnvironment: true;
177
+ };
178
+ type DeployConfig = GitHubDeployConfig | GitLabDeployConfig | EphemeralDeployConfig;
175
179
  type DeploySuccessSuiteCreatedResult = {
176
180
  created_suite_id: string;
177
181
  trigger_id: string;
@@ -349,4 +353,4 @@ declare function makeQaWolfSdk({ apiKey, serviceBase, userAgent, }: {
349
353
  pollCiGreenlightStatus: (args_0: PollCiGreenlightParams) => Promise<PollCiGreenlightStatus>;
350
354
  };
351
355
 
352
- export { type AttemptDeployAbortReason, type AttemptDeployFailedReason, type AttemptDeployHttpAbortReason, type AttemptDeployNonHttpAbortReason, type CiGreenlightStatus, type CiGreenlightStatusBase, type DeployConfig, type DeployStatus, type DeployStatusErrorResponse, type DeployStatusResponse, type DeployStatusSuccessResponse, type DeploySuccessSuiteAlreadyExistsResult, type DeploySuccessSuiteCreatedResult, type DeploySuccessSuiteCreationFailureResult, type DeploySuccessSuiteResult, type FetchDriver, type GenerateSignedUrlAbortReason$1 as GenerateSignedUrlAbortReason, type GenerateSignedUrlConfig, type GenerateSignedUrlResponse, type GenerateSignedUrlStatus, type GitHubDeployConfig, type GitLabDeployConfig, type NotifyDeployStatus, type PollCiGreenlightAbortReason, type PollCiGreenlightHttpAbortReason, type PollCiGreenlightNonHttpAbortReason, type PollCiGreenlightParams, type PollCiGreenlightPollConfig, type PollCiGreenlightStatus, type SdkDependencies, attemptNotifyDeploy, makeQaWolfSdk, pollCiGreenlightStatus };
356
+ export { type AttemptDeployAbortReason, type AttemptDeployFailedReason, type AttemptDeployHttpAbortReason, type AttemptDeployNonHttpAbortReason, type CiGreenlightStatus, type CiGreenlightStatusBase, type DeployConfig, type DeployStatus, type DeployStatusErrorResponse, type DeployStatusResponse, type DeployStatusSuccessResponse, type DeploySuccessSuiteAlreadyExistsResult, type DeploySuccessSuiteCreatedResult, type DeploySuccessSuiteCreationFailureResult, type DeploySuccessSuiteResult, type EphemeralDeployConfig, type FetchDriver, type GenerateSignedUrlAbortReason$1 as GenerateSignedUrlAbortReason, type GenerateSignedUrlConfig, type GenerateSignedUrlResponse, type GenerateSignedUrlStatus, type GitHubDeployConfig, type GitLabDeployConfig, type NotifyDeployStatus, type PollCiGreenlightAbortReason, type PollCiGreenlightHttpAbortReason, type PollCiGreenlightNonHttpAbortReason, type PollCiGreenlightParams, type PollCiGreenlightPollConfig, type PollCiGreenlightStatus, type SdkDependencies, attemptNotifyDeploy, makeQaWolfSdk, pollCiGreenlightStatus };
package/dist/index.js CHANGED
@@ -36,51 +36,7 @@ var defaultServiceBase = "https://app.qawolf.com/";
36
36
 
37
37
  // package.json
38
38
  var package_default = {
39
- name: "@qawolf/ci-sdk",
40
- version: "1.0.1",
41
- private: false,
42
- description: "A simple SDK for interacting with QAWolf in CI scripts.",
43
- keywords: [],
44
- license: "MIT",
45
- author: "Jules Sam. Randolph<jules@qawolf.com>",
46
- type: "module",
47
- exports: {
48
- ".": {
49
- types: "./dist/index.d.ts",
50
- require: "./dist/index.cjs",
51
- import: "./dist/index.js",
52
- default: "./dist/index.js"
53
- }
54
- },
55
- main: "./dist/index.cjs",
56
- module: "./dist/index.js",
57
- types: "./dist/index.d.ts",
58
- files: [
59
- "/dist",
60
- "/README.md"
61
- ],
62
- scripts: {
63
- build: "tsup src/index.ts --format esm,cjs --dts --clean --splitting --treeshake --sourcemap --outDir dist --target es2022",
64
- lint: "cycle-import-scan . && eslint . --ext js,jsx,mjs,ts,tsx --quiet && prettier --check .",
65
- "lint:fix": "eslint . --ext js,jsx,mjs,ts,tsx --fix --quiet && prettier --log-level=warn --write .",
66
- "lint:warnings": "eslint . --ext js,jsx,mjs,ts,tsx",
67
- prepublishOnly: "nx run ci-sdk:build",
68
- test: 'NODE_OPTIONS="--experimental-vm-modules" NODE_NO_WARNINGS=1 jest',
69
- "tsc:check": "tsc --noEmit"
70
- },
71
- dependencies: {
72
- "@qawolf/ci-utils": "^1.0.0",
73
- "@sinonjs/fake-timers": "^10.3.0",
74
- slugify: "^1.6.6",
75
- tslib: "^2.6.2"
76
- },
77
- devDependencies: {
78
- tsup: "8.3.5"
79
- },
80
- engines: {
81
- node: ">=16"
82
- }
83
- };
39
+ version: "1.1.1"};
84
40
 
85
41
  // src/lib/sdk/defaults/userAgent.ts
86
42
  var defaultUserAgent = `ci-sdk/${package_default.version}`;
@@ -103,8 +59,8 @@ async function logFetchError({ log, methodName, response }) {
103
59
  };
104
60
  } catch {
105
61
  return {
106
- eventId: undefined,
107
- failureMessage: undefined
62
+ eventId: void 0,
63
+ failureMessage: void 0
108
64
  };
109
65
  }
110
66
  })();
@@ -126,10 +82,14 @@ async function attemptNotifyDeploy(deps, apiConfig, config) {
126
82
  deduplication_key: config.deduplicationKey,
127
83
  deployment_type: config.deploymentType,
128
84
  deployment_url: config.deploymentUrl,
129
- hosting_service: config.hostingService,
130
- merge_request_number: config.hostingService === "GitLab" ? config.mergeRequestNumber : void 0,
131
- pull_request_number: config.hostingService === "GitHub" ? config.pullRequestNumber : void 0,
132
- repository: config.repository,
85
+ ..."ephemeralEnvironment" in config ? {
86
+ ephemeral_environment: config.ephemeralEnvironment
87
+ } : "hostingService" in config && {
88
+ hosting_service: config.hostingService,
89
+ merge_request_number: config.hostingService === "GitLab" ? config.mergeRequestNumber : void 0,
90
+ pull_request_number: config.hostingService === "GitHub" ? config.pullRequestNumber : void 0,
91
+ repository: config.repository
92
+ },
133
93
  sha: config.sha,
134
94
  variables: config.variables
135
95
  }),
@@ -147,7 +107,7 @@ async function attemptNotifyDeploy(deps, apiConfig, config) {
147
107
  log.error(`\u{1F6AB} Network error from deploy_success, aborting.`);
148
108
  return {
149
109
  abortReason: "network-error",
150
- httpStatus: undefined,
110
+ httpStatus: void 0,
151
111
  outcome: "aborted"
152
112
  };
153
113
  }
@@ -156,7 +116,7 @@ __name(attemptNotifyDeploy, "attemptNotifyDeploy");
156
116
  async function handleErrorResponse(response, log) {
157
117
  const status = response.status;
158
118
  let abortReason;
159
- if (status === undefined) abortReason = "network-error";
119
+ if (status === void 0) abortReason = "network-error";
160
120
  else if (status === 401) abortReason = "401-unauthorized";
161
121
  else if (status === 403) abortReason = "403-forbidden";
162
122
  else if (status >= 500) abortReason = "5XX-server-error";
@@ -186,10 +146,10 @@ async function handleSuccessResponse(data, log) {
186
146
  return {
187
147
  environmentId: environment.id,
188
148
  outcome: "success",
189
- runId: undefined
149
+ runId: void 0
190
150
  };
191
151
  }
192
- log.error(`\u{1F6AB} No trigger matched the request. Please contact support.`);
152
+ log.error(`\u{1F6AB} No trigger matched the request. Please make sure there is at least one active test in the QA Wolf environment, or contact support.`);
193
153
  return {
194
154
  failReason: "no-matched-trigger",
195
155
  outcome: "failed"
@@ -460,11 +420,11 @@ var safeDefaults = {
460
420
  runInProgressInterval: 30 * 1e3,
461
421
  runUnderReviewInterval: 60 * 1e3
462
422
  };
463
- async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = /* @__PURE__ */ __name(() => undefined, "onRunStageChanged"), runId, ...pollConfig }) {
423
+ async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = /* @__PURE__ */ __name(() => void 0, "onRunStageChanged"), runId, ...pollConfig }) {
464
424
  let retries = 0;
465
425
  const { log } = deps;
466
426
  const { abortOnSuperseded = safeDefaults.abortOnSuperseded, maxRetries = safeDefaults.maxRetries, pollTimeout = safeDefaults.pollTimeout, retryInterval = safeDefaults.retryInterval, runInProgressInterval = safeDefaults.runInProgressInterval, runUnderReviewInterval = safeDefaults.runUnderReviewInterval } = pollConfig;
467
- let currentStatus = undefined;
427
+ let currentStatus = void 0;
468
428
  const startedAt = Date.now();
469
429
  let hasTimedOut = false;
470
430
  while (!(hasTimedOut = Date.now() - startedAt > pollTimeout)) {
@@ -486,7 +446,7 @@ async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = /*
486
446
  if (responseState.errorType === "network") {
487
447
  return {
488
448
  abortReason: "network-error",
489
- httpStatus: undefined,
449
+ httpStatus: void 0,
490
450
  outcome: "aborted"
491
451
  };
492
452
  }
@@ -529,7 +489,7 @@ async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = /*
529
489
  log.warn(`\u274C Aborting due to superseded run (option 'abortOnSuperseded' is enabled).${supersedingDetails}`);
530
490
  return {
531
491
  abortReason: "superseded-run",
532
- httpStatus: undefined,
492
+ httpStatus: void 0,
533
493
  outcome: "aborted"
534
494
  };
535
495
  }
@@ -567,7 +527,7 @@ You may review the priority of certain bugs to mark these non-blocking and retry
567
527
  ${urlInfo}`);
568
528
  return {
569
529
  abortReason: "run-canceled",
570
- httpStatus: undefined,
530
+ httpStatus: void 0,
571
531
  outcome: "aborted"
572
532
  };
573
533
  }
@@ -575,7 +535,7 @@ ${urlInfo}`);
575
535
  log.warn(`\u274C Poll timed out after ${pollTimeout / 1e3}s. Aborting...`);
576
536
  return {
577
537
  abortReason: "poll-timed-out",
578
- httpStatus: undefined,
538
+ httpStatus: void 0,
579
539
  outcome: "aborted"
580
540
  };
581
541
  }
@@ -590,7 +550,7 @@ ${urlInfo}`);
590
550
  log.warn(`\u274C Poll timed out after ${pollTimeout / 1e3}s. Aborting...`);
591
551
  return {
592
552
  abortReason: "poll-timed-out",
593
- httpStatus: undefined,
553
+ httpStatus: void 0,
594
554
  outcome: "aborted"
595
555
  };
596
556
  }
@@ -603,8 +563,10 @@ function makeQaWolfSdk({ apiKey, serviceBase = defaultServiceBase, userAgent = d
603
563
  We recommend 'undici' package for that purpose. See the Requirement section of our README for more guidance.`);
604
564
  }
605
565
  const deps = {
606
- // Versions of fetch may have different default timeouts. For consistency, we explicitly set it to 60 seconds here.
607
- fetch: buildFetchWithTimeout(fetch, 6e4),
566
+ // Versions of fetch may have different default timeouts. For consistency, we explicitly set it to 2 minutes here.
567
+ // The increased timeout helps avoid edge cases where we need to search for a commit against multiple
568
+ // code hosting service repositories as a fallback when not finding the repository based on organization/name.
569
+ fetch: buildFetchWithTimeout(fetch, 12e4),
608
570
  log
609
571
  };
610
572
  const apiConfig = {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/other.ts","../src/lib/sdk/defaults/fetch.ts","../src/lib/sdk/defaults/log.ts","../src/lib/sdk/defaults/serviceBase.ts","../package.json","../src/lib/sdk/defaults/userAgent.ts","../src/lib/api/log.ts","../src/lib/sdk/domain/attemptDeploy/index.ts","../src/lib/api/generate-signed-url-for-run-inputs-executables.ts","../src/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-run-inputs-executables.ts","../src/lib/api/generate-signed-url-for-team-storage.ts","../src/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-team-storage.ts","../src/lib/api/ci-greenlight.ts","../src/lib/sdk/domain/poll-ci-greenlight.ts","../src/lib/sdk/index.ts"],"names":["sleep","ms","Promise","resolve","setTimeout","pluralize","count","buildFetchWithTimeout","fetch","timeout","args","signal","AbortSignal","defaultFetch","globalThis","defaultLogDriver","error","message","console","info","log","warn","defaultServiceBase","defaultUserAgent","packageJson","version","logFetchError","methodName","response","ok","eventId","failureMessage","body","json","catch","text","undefined","eventIdSuffix","messageSuffix","statusText","status","attemptNotifyDeploy","deps","apiConfig","config","localFetch","URL","serviceBase","JSON","stringify","branch","commit_url","commitUrl","deduplication_key","deduplicationKey","deployment_type","deploymentType","deployment_url","deploymentUrl","hosting_service","hostingService","merge_request_number","mergeRequestNumber","pull_request_number","pullRequestNumber","repository","sha","variables","headers","Authorization","apiKey","userAgent","method","handleErrorResponse","data","handleSuccessResponse","abortReason","httpStatus","outcome","environment","results","isPreviewDeployment","isStatic","logPrefix","alias","id","length","environmentId","runId","failReason","failedTrigger","find","t","failure_reason","duplicateSuite","duplicate_suite_id","successfulTrigger","created_suite_id","callGenerateSignedUrlForRunInputsExecutablesStorage","destinationFilePath","encodeURIComponent","fileLocation","playgroundFileLocation","signedUrl","success","errorMessage","e","generateSignedUrlForRunInputsExecutablesStorage","responseState","uploadUrl","callGenerateSignedUrlForTempTeamStorage","generateSignedUrlForTempTeamStorage","fetchCiGreenlightStatus","resp","greenlightStatus","canRetry","errorType","safeDefaults","abortOnSuperseded","maxRetries","pollTimeout","retryInterval","runInProgressInterval","runUnderReviewInterval","pollCiGreenlightStatus","onRunStageChanged","pollConfig","retries","currentStatus","startedAt","Date","now","hasTimedOut","retryLabel","previousStatus","runStage","urlInfo","relevantRunUrl","greenlight","relevantRunId","relevantRunWithBugsUrl","rootRunId","rootRunUrl","supersedingDetails","blockingBugsCount","blockingBugUrls","nonBlockingBugsCount","nonBlockingBugUrls","blockingBugList","map","url","join","nonBlockingBugList","bugsListInText","Error","makeQaWolfSdk","bind"],"mappings":";;;;AAEO,SAASA,MAAMC,EAAU,EAAA;AAC9B,EAAA,OAAO,IAAIC,OAAQ,CAAA,CAACC,YAAYC,UAAWD,CAA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AMlH,EAAAA,IAAAA,EAAMC,SAAAA,CAAAA;AAC1DgE,IAAAA,+CAAAA,EACEA,+CAAgDiD,CAAAA,IAAAA,CAC9C,IACAlH,EAAAA,IAAAA,EACAC,SAAAA,CAAAA;AAEJoE,IAAAA,mCAAAA,EACEA,mCAAoC6C,CAAAA,IAAAA,CAAK,IAAMlH,EAAAA,IAAAA,EAAMC,SAAAA,CAAAA;AACvDiF,IAAAA,sBAAAA,EAAwBA,sBAAuBgC,CAAAA,IAAAA,CAAK,IAAMlH,EAAAA,IAAAA,EAAMC,SAAAA;AAClE,GAAA;AACF;AAxCgBgH,MAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA","file":"index.js","sourcesContent":["import { type FetchDriver } from \"./sdk/dependencies.js\";\n\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function pluralize(count: number) {\n return count === 1 ? \"\" : \"s\";\n}\n\nexport function getBackoffMs(\n attemptNumber: number,\n minWaitMs = 1000,\n maxWaitMs = 10000,\n): number {\n return Math.min(maxWaitMs, minWaitMs * 1.2 ** attemptNumber);\n}\n\nexport const buildFetchWithTimeout =\n (fetch: FetchDriver, timeout: number) =>\n async (...args: Parameters<FetchDriver>) =>\n fetch(args[0], { ...args[1], signal: AbortSignal.timeout(timeout) });\n","export const defaultFetch = globalThis.fetch;\n","import { type LogDriver } from \"../dependencies.js\";\n\nexport const defaultLogDriver: LogDriver = {\n error(message, error) {\n console.error(message, error);\n },\n info(message) {\n console.log(message);\n },\n warn(message) {\n console.warn(message);\n },\n};\n","export const defaultServiceBase = \"https://app.qawolf.com/\";\n","{\n \"name\": \"@qawolf/ci-sdk\",\n \"version\": \"1.0.1\",\n \"private\": false,\n \"description\": \"A simple SDK for interacting with QAWolf in CI scripts.\",\n \"keywords\": [],\n \"license\": \"MIT\",\n \"author\": \"Jules Sam. Randolph<jules@qawolf.com>\",\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"require\": \"./dist/index.cjs\",\n \"import\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n }\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"/dist\",\n \"/README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/index.ts --format esm,cjs --dts --clean --splitting --treeshake --sourcemap --outDir dist --target es2022\",\n \"lint\": \"cycle-import-scan . && eslint . --ext js,jsx,mjs,ts,tsx --quiet && prettier --check .\",\n \"lint:fix\": \"eslint . --ext js,jsx,mjs,ts,tsx --fix --quiet && prettier --log-level=warn --write .\",\n \"lint:warnings\": \"eslint . --ext js,jsx,mjs,ts,tsx\",\n \"prepublishOnly\": \"nx run ci-sdk:build\",\n \"test\": \"NODE_OPTIONS=\\\"--experimental-vm-modules\\\" NODE_NO_WARNINGS=1 jest\",\n \"tsc:check\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@qawolf/ci-utils\": \"^1.0.0\",\n \"@sinonjs/fake-timers\": \"^10.3.0\",\n \"slugify\": \"^1.6.6\",\n \"tslib\": \"^2.6.2\"\n },\n \"devDependencies\": {\n \"tsup\": \"8.3.5\"\n },\n \"engines\": {\n \"node\": \">=16\"\n }\n}\n","import packageJson from \"../../../../package.json\" with { type: \"json\" };\n\nexport const defaultUserAgent = `ci-sdk/${packageJson.version}`;\n","import { type LogDriver } from \"@qawolf/ci-utils\";\n\nexport async function logFetchError({\n log,\n methodName,\n response,\n}: {\n log: LogDriver;\n methodName: string;\n response: Response;\n}) {\n if (response.ok) return;\n\n const { eventId, failureMessage } = await (async () => {\n try {\n const body = (await response.json().catch(() => response.text())) as\n | Record<string, unknown>\n | string;\n if (typeof body === \"object\" && body !== null) {\n return {\n eventId: body.eventId,\n failureMessage: body.failureMessage,\n };\n }\n // If body is not an object (i.e., it's the text from catch)\n return {\n eventId: undefined,\n failureMessage: body,\n };\n } catch {\n // If both parsing attempts somehow fail\n return {\n eventId: undefined,\n failureMessage: undefined,\n };\n }\n })();\n\n const eventIdSuffix = eventId ? ` (Event ID: ${eventId})` : \"\";\n const messageSuffix = failureMessage ? `: ${failureMessage}` : \"\";\n\n const statusText =\n response.status >= 500\n ? \"Server Error\"\n : response.statusText || \"Unknown Error\";\n\n log.error(\n `āŒ [${methodName}] ${response.status} ${statusText}${eventIdSuffix}${messageSuffix}`,\n );\n}\n","import { type ApiConfig } from \"../../../api-types.js\";\nimport { logFetchError } from \"../../../api/log.js\";\nimport { type LogDriver, type SdkDependencies } from \"../../dependencies.js\";\n\nimport {\n type AttemptDeployHttpAbortReason,\n type DeployConfig,\n type DeployStatus,\n type NotifyDeployStatus,\n} from \"./types.js\";\n\nexport async function attemptNotifyDeploy(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: Partial<DeployConfig>,\n): Promise<NotifyDeployStatus> {\n const { fetch: localFetch, log } = deps;\n try {\n const response = await localFetch(\n new URL(\"/api/webhooks/deploy_success\", apiConfig.serviceBase),\n {\n body: JSON.stringify({\n branch: config.branch,\n commit_url: config.commitUrl,\n deduplication_key: config.deduplicationKey,\n deployment_type: config.deploymentType,\n deployment_url: config.deploymentUrl,\n hosting_service: config.hostingService,\n merge_request_number:\n config.hostingService === \"GitLab\"\n ? config.mergeRequestNumber\n : undefined,\n pull_request_number:\n config.hostingService === \"GitHub\"\n ? config.pullRequestNumber\n : undefined,\n repository: config.repository,\n sha: config.sha,\n variables: config.variables,\n }),\n headers: {\n Authorization: `Bearer ${apiConfig.apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": apiConfig.userAgent,\n },\n method: \"POST\",\n },\n );\n\n if (!response.ok) return handleErrorResponse(response, log);\n const data = (await response.json()) as DeployStatus;\n return handleSuccessResponse(data, log);\n } catch (error) {\n log.error(`🚫 Network error from deploy_success, aborting.`);\n return {\n abortReason: \"network-error\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n}\n\nasync function handleErrorResponse(\n response: Response,\n log: LogDriver,\n): Promise<NotifyDeployStatus> {\n const status = response.status;\n let abortReason: AttemptDeployHttpAbortReason;\n if (status === undefined) abortReason = \"network-error\";\n else if (status === 401) abortReason = \"401-unauthorized\";\n else if (status === 403) abortReason = \"403-forbidden\";\n else if (status >= 500) abortReason = \"5XX-server-error\";\n else abortReason = \"4XX-client-error\";\n await logFetchError({\n log,\n methodName: \"attemptNotifyDeploy\",\n response,\n });\n return {\n abortReason,\n httpStatus: status,\n outcome: \"aborted\",\n };\n}\n\nasync function handleSuccessResponse(\n data: DeployStatus,\n log: LogDriver,\n): Promise<NotifyDeployStatus> {\n const { environment, results } = data;\n const isPreviewDeployment = environment && !environment.isStatic;\n\n if (environment) {\n const logPrefix = environment.isStatic\n ? \"Static environment\"\n : \"Preview environment\";\n log.info(`${logPrefix}: ${environment.alias} (id: ${environment.id})`);\n }\n\n // No triggers were matched\n if (results.length === 0) {\n if (isPreviewDeployment) {\n log.info(\n `āœ… Deployment notification was successful. No run was created for this deployment.`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: undefined,\n };\n }\n log.error(`🚫 No trigger matched the request. Please contact support.`);\n return { failReason: \"no-matched-trigger\", outcome: \"failed\" };\n }\n\n // If there are results, environment must be defined\n if (!environment) {\n log.error(`🚫 No environment matched the request. Please contact support.`);\n return { failReason: \"no-environment\", outcome: \"failed\" };\n }\n\n const failedTrigger = results.find((t) => \"failure_reason\" in t);\n if (failedTrigger) {\n log.error(\n `🚫 Run could not be created. Reason: \"${failedTrigger.failure_reason}\". Please contact support.`,\n );\n return { failReason: \"run-could-not-be-created\", outcome: \"failed\" };\n }\n\n const duplicateSuite = results.find((t) => \"duplicate_suite_id\" in t);\n if (duplicateSuite) {\n log.info(\n `āœ… Deployment notification was successful. Previous run ID: ${duplicateSuite.duplicate_suite_id} already exists for this deployment.`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: duplicateSuite.duplicate_suite_id,\n };\n }\n\n const successfulTrigger = results.find((t) => \"created_suite_id\" in t);\n if (!successfulTrigger) {\n log.error(`🚫 No trigger matched the request. Please contact support.`);\n return { failReason: \"no-matched-trigger\", outcome: \"failed\" };\n }\n log.info(\n `āœ… Deployment notification was successful. Run created with ID: ${successfulTrigger.created_suite_id}`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: successfulTrigger.created_suite_id,\n };\n}\n","import { type ApiConfig } from \"../api-types.js\";\nimport { type SdkDependencies } from \"../sdk/dependencies.js\";\nimport {\n type GenerateSignedUrlConfig,\n type GenerateSignedUrlResponse,\n} from \"../sdk/domain/generateSignedUrls/types.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport async function callGenerateSignedUrlForRunInputsExecutablesStorage(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n { destinationFilePath }: GenerateSignedUrlConfig,\n { fetch: localFetch, log }: SdkDependencies,\n): Promise<GenerateSignedUrlResponse> {\n try {\n const response = await localFetch(\n new URL(\n `${serviceBase}/api/v0/run-inputs-executables-signed-urls?file=${encodeURIComponent(destinationFilePath)}`,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": userAgent,\n },\n method: \"GET\",\n },\n );\n\n if (response.status === 200) {\n const json =\n (await response.json()) as Partial<GenerateSignedUrlResponse>;\n return {\n fileLocation: json.fileLocation,\n httpStatus: response.status,\n playgroundFileLocation: json.playgroundFileLocation,\n signedUrl: json.signedUrl,\n success: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"callGenerateSignedUrlForRunInputsExecutablesStorage\",\n response,\n });\n return {\n errorMessage: await response.text(),\n httpStatus: response.status,\n success: false,\n } as const;\n } catch (e) {\n return {\n errorMessage: \"Network error, aborting request to generate signed URL\",\n httpStatus: 0,\n success: false,\n } as const;\n }\n}\n","import { type ApiConfig } from \"../../../api-types.js\";\nimport { callGenerateSignedUrlForRunInputsExecutablesStorage } from \"../../../api/generate-signed-url-for-run-inputs-executables.js\";\nimport { type SdkDependencies } from \"../../dependencies.js\";\n\nimport {\n type GenerateSignedUrlAbortReason,\n type GenerateSignedUrlConfig,\n type GenerateSignedUrlStatus,\n} from \"./types.js\";\n\nexport async function generateSignedUrlForRunInputsExecutablesStorage(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: GenerateSignedUrlConfig,\n): Promise<GenerateSignedUrlStatus> {\n const { log } = deps;\n\n if (!config.destinationFilePath) {\n log.error(`🚫 destinationFilePath is a required config parameter`);\n return {\n abortReason: \"sdk-argument-validation-failed\",\n success: false,\n };\n }\n\n const responseState =\n await callGenerateSignedUrlForRunInputsExecutablesStorage(\n apiConfig,\n config,\n deps,\n );\n if (!responseState.success) {\n let abortReason: GenerateSignedUrlAbortReason = \"XXX-other-http-code\";\n\n if (responseState.httpStatus >= 500) {\n abortReason = \"5XX-server-error\";\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: aborting.`,\n );\n } else {\n if (responseState.httpStatus === 400) abortReason = \"400-invalid-request\";\n else if (responseState.httpStatus === 401)\n abortReason = \"401-invalid-credentials\";\n else if (responseState.httpStatus === 403) abortReason = \"403-forbidden\";\n else if (responseState.httpStatus === 0)\n abortReason = \"client-network-error\";\n\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: ${responseState.errorMessage ? `${responseState.errorMessage}.` : \"\"} aborting.`,\n );\n }\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n success: false,\n };\n }\n\n log.info(`āœ… Generated Signed Upload URL: ${responseState.signedUrl}.`);\n return {\n fileLocation: responseState.fileLocation,\n playgroundFileLocation: responseState.playgroundFileLocation,\n success: true,\n uploadUrl: responseState.signedUrl,\n };\n}\n","import { type ApiConfig } from \"../api-types.js\";\nimport { type SdkDependencies } from \"../sdk/dependencies.js\";\nimport {\n type GenerateSignedUrlConfig,\n type GenerateSignedUrlResponse,\n} from \"../sdk/domain/generateSignedUrls/types.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport async function callGenerateSignedUrlForTempTeamStorage(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n { destinationFilePath }: Partial<GenerateSignedUrlConfig>,\n { fetch: localFetch, log }: SdkDependencies,\n): Promise<GenerateSignedUrlResponse> {\n try {\n const response = await localFetch(\n new URL(\n `${serviceBase}/api/v0/team-storage-signed-url?file=${destinationFilePath}`,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": userAgent,\n },\n method: \"GET\",\n },\n );\n\n if (response.status === 200) {\n const json =\n (await response.json()) as Partial<GenerateSignedUrlResponse>;\n return {\n fileLocation: json.fileLocation,\n httpStatus: response.status,\n playgroundFileLocation: json.playgroundFileLocation,\n signedUrl: json.signedUrl,\n success: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"callGenerateSignedUrlForTempTeamStorage\",\n response,\n });\n return {\n errorMessage: await response.text(),\n httpStatus: response.status,\n success: false,\n } as const;\n } catch (e) {\n return {\n errorMessage: \"Network error, aborting request to generate signed URL\",\n httpStatus: 0,\n success: false,\n } as const;\n }\n}\n","import { type ApiConfig } from \"../../../api-types.js\";\nimport { callGenerateSignedUrlForTempTeamStorage } from \"../../../api/generate-signed-url-for-team-storage.js\";\nimport { type SdkDependencies } from \"../../dependencies.js\";\n\nimport { type GenerateSignedUrlConfig } from \"./types.js\";\n\ntype GenerateSignedUrlStatus =\n | {\n fileLocation?: string;\n playgroundFileLocation?: string;\n success: true;\n uploadUrl?: string;\n }\n | {\n abortReason: GenerateSignedUrlAbortReason;\n httpStatus?: number;\n success: false;\n };\n\nexport type GenerateSignedUrlAbortReason =\n | \"client-network-error\"\n | \"sdk-argument-validation-failed\"\n | \"400-invalid-request\"\n | \"401-invalid-credentials\"\n | \"403-forbidden\"\n | \"5XX-server-error\"\n | \"XXX-other-http-code\";\n\nexport async function generateSignedUrlForTempTeamStorage(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: GenerateSignedUrlConfig,\n): Promise<GenerateSignedUrlStatus> {\n const { log } = deps;\n\n if (!config.destinationFilePath) {\n log.error(`🚫 destinationFilePath is a required config parameter`);\n return {\n abortReason: \"sdk-argument-validation-failed\",\n success: false,\n };\n }\n\n const responseState = await callGenerateSignedUrlForTempTeamStorage(\n apiConfig,\n config,\n deps,\n );\n if (!responseState.success) {\n let abortReason: GenerateSignedUrlAbortReason = \"XXX-other-http-code\";\n\n if (responseState.httpStatus >= 500) {\n abortReason = \"5XX-server-error\";\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: aborting.`,\n );\n } else {\n if (responseState.httpStatus === 400) abortReason = \"400-invalid-request\";\n else if (responseState.httpStatus === 401)\n abortReason = \"401-invalid-credentials\";\n else if (responseState.httpStatus === 403) abortReason = \"403-forbidden\";\n else if (responseState.httpStatus === 0)\n abortReason = \"client-network-error\";\n\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: ${responseState.errorMessage ? `${responseState.errorMessage}.` : \"\"} aborting.`,\n );\n }\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n success: false,\n };\n }\n\n log.info(`āœ… Generated Signed Upload URL: ${responseState.signedUrl}.`);\n return {\n fileLocation: responseState.fileLocation,\n playgroundFileLocation: responseState.playgroundFileLocation,\n success: true,\n uploadUrl: responseState.signedUrl,\n };\n}\n","import { type ApiConfig } from \"../api-types.js\";\nimport { type SdkDependencies } from \"../sdk/dependencies.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport type CiGreenlightBugDetails = {\n /**\n * The URL of this BR in the QAWolf application.\n */\n applicationUrl: string;\n /**\n * If this bug report is linked to an external issue, it will\n * show up here.\n */\n externalIssue:\n | {\n /**\n * The URL of the external issue in the external platform\n * application.\n */\n applicationUrl: string;\n /**\n * The ID of this issue in the external platform.\n */\n externalIssueId: string;\n /**\n * Lowercase platform name (e.g. \"jira\").\n */\n platform: string;\n }\n | undefined;\n /**\n * True if the bug is blocking.\n */\n isBlocking: boolean;\n /**\n * True if the bug has been found in this run.\n */\n isNew: boolean;\n /**\n * The name of this bug.\n */\n name: string;\n /**\n * The bug number.\n */\n number: number;\n /**\n * The priority of this bug.\n */\n priority: \"medium\" | \"unprioritized\" | \"low\" | \"high\" | \"urgent\";\n};\n\nexport type CiGreenlightBugData = {\n /**\n * The count of blocking bugs reproduced in the run.\n */\n blockingBugsCount: number;\n /**\n * The URLs of the blocking bugs.\n *\n * @deprecated This field will be removed in the next major version.\n * Prefer using `reproducedBugs` filtered by `isBlocking: true`, reading\n * the `applicationUrl` field.\n */\n blockingBugUrls: string[];\n /**\n * The count of non-blocking bugs reproduced in the run.\n */\n nonBlockingBugsCount: number;\n /**\n * The URLs of the non-blocking bugs.\n *\n * @deprecated This field will be removed in the next major version.\n * Prefer using `reproducedBugs` filtered by `isBlocking: false`, reading\n * the `applicationUrl` field.\n */\n nonBlockingBugUrls: string[];\n /**\n * Blocking bugs that were not reproduced in this run, but are still\n * opened in the run environment. This may happen when the run only covers a\n * subset of the workflows in environment.\n */\n otherBlockingBugsInEnvironment: CiGreenlightBugDetails[];\n /**\n * Bugs that were reproduced in this run. This includes newly found bugs.\n */\n reproducedBugs: CiGreenlightBugDetails[];\n};\n\n/**\n * @deprecated This type will be removed in the next major version. Use `CiGreenlightBugData` instead.\n */\nexport type CiGreenlightCompletedSuiteDetails = CiGreenlightBugData;\n\nexport type CiGreenlightStatusBase = {\n relevantRunId: string;\n relevantRunUrl: string;\n relevantRunWithBugsUrl: string;\n rootRunId: string;\n rootRunUrl: string;\n workflowsDisabledAfterRunCount: number;\n workflowsInRunCount: number;\n workflowsUnderInvestigationCount: number;\n};\n\n/**\n * The status of a CI greenlight run. See the API documentation here for\n * more details: https://qawolf.notion.site/1b170576efea411fa785842a71e7c99e\n */\nexport type CiGreenlightStatus = CiGreenlightStatusBase &\n (\n | ({\n greenlight: boolean;\n runStage: \"completed\";\n } & CiGreenlightBugData)\n | ({\n greenlight: false;\n runStage: \"underReview\";\n } & CiGreenlightBugData)\n | {\n greenlight: false;\n runStage: \"initializing\" | \"underReview\" | \"canceled\";\n }\n );\n\nexport async function fetchCiGreenlightStatus(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n {\n runId,\n }: {\n runId: string;\n },\n { fetch: localFetch, log }: SdkDependencies,\n) {\n try {\n const resp = await localFetch(\n new URL(\n `/api/v0/ci-greenlight/${encodeURIComponent(runId)}`,\n serviceBase,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"User-Agent\": userAgent,\n },\n },\n );\n\n if (resp.ok) {\n const greenlightStatus = (await resp.json()) as CiGreenlightStatus;\n return {\n greenlightStatus,\n httpStatus: resp.status,\n ok: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"fetchCiGreenlightStatus\",\n response: resp,\n });\n if (resp.status === 404) {\n return {\n canRetry: true,\n errorType: \"not-found\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n }\n if (resp.status >= 500) {\n return {\n canRetry: true,\n errorType: \"server\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n }\n return {\n canRetry: false,\n errorType: \"client\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n } catch (e) {\n return {\n canRetry: true,\n errorType: \"network\",\n httpStatus: 0,\n ok: false,\n } as const;\n }\n}\n","/* eslint-disable @qawolf/max-lines -- Technical debt */\n\nimport { type ApiConfig } from \"../../api-types.js\";\nimport {\n type CiGreenlightStatus,\n fetchCiGreenlightStatus,\n} from \"../../api/ci-greenlight.js\";\nimport { pluralize, sleep } from \"../../other.js\";\nimport { type SdkDependencies } from \"../dependencies.js\";\n\nexport type PollCiGreenlightPollConfig = {\n /**\n * If true, the job will be aborted when a superseding run is detected.\n *\n * @default false\n */\n abortOnSuperseded: boolean;\n /**\n * Maximum number of network operations retries before aborting the job.\n *\n * @default 10\n */\n maxRetries: number;\n /**\n * Timeout in milliseconds before aborting this polling operation.\n *\n * @default 120 minutes\n */\n pollTimeout: number;\n /**\n * Interval in milliseconds between network operations retries.\n *\n * @default 10 seconds\n */\n retryInterval: number;\n /**\n * Interval in milliseconds between polling for a run in progress.\n *\n * @default 30 seconds\n */\n runInProgressInterval: number;\n /**\n * Interval in milliseconds between polling for a run under review.\n *\n * @default 60 minutes\n */\n runUnderReviewInterval: number;\n};\n\nexport type PollCiGreenlightHttpAbortReason =\n | \"4XX-client-error\"\n | \"404-run-not-found\"\n | \"5XX-server-error\"\n | \"XXX-other-http-code\";\n\nexport type PollCiGreenlightNonHttpAbortReason =\n | \"poll-timed-out\"\n | \"run-canceled\"\n | \"network-error\"\n | \"superseded-run\";\n\nexport type PollCiGreenlightAbortReason =\n | PollCiGreenlightNonHttpAbortReason\n | PollCiGreenlightHttpAbortReason;\n\nexport type PollCiGreenlightStatus =\n | {\n greenlightStatus: Extract<CiGreenlightStatus, { runStage: \"completed\" }>;\n /**\n * No blocking bugs were found in the run.\n */\n outcome: \"success\";\n }\n | {\n greenlightStatus: Extract<CiGreenlightStatus, { runStage: \"completed\" }>;\n /**\n * Blocking bugs were found in the run.\n */\n outcome: \"failed\";\n }\n | {\n abortReason: PollCiGreenlightHttpAbortReason;\n httpStatus: number;\n /**\n * The run was aborted due to an unrecoverable error.\n */\n outcome: \"aborted\";\n }\n | {\n abortReason: PollCiGreenlightNonHttpAbortReason;\n httpStatus: undefined;\n /**\n * The run was aborted due to an unrecoverable error.\n */\n outcome: \"aborted\";\n };\n\nexport type PollCiGreenlightParams = {\n /**\n * Callback to be called when the lifecycle stage of the run changes.\n */\n onRunStageChanged?: (\n current: CiGreenlightStatus,\n previous: CiGreenlightStatus | undefined,\n ) => unknown | Promise<unknown>;\n runId: string;\n} & Partial<PollCiGreenlightPollConfig>;\n\n// If you change these values, make sure you update the JSDoc\n// comments in the PollConfig type.\nconst safeDefaults: PollCiGreenlightPollConfig = {\n abortOnSuperseded: false,\n maxRetries: 10,\n pollTimeout: 120 * 60 * 1000,\n retryInterval: 10 * 1000,\n runInProgressInterval: 30 * 1000,\n runUnderReviewInterval: 60 * 1000,\n};\n\nexport async function pollCiGreenlightStatus(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n {\n onRunStageChanged: onRunStageChanged = () => undefined,\n runId,\n ...pollConfig\n }: PollCiGreenlightParams,\n): Promise<PollCiGreenlightStatus> {\n let retries = 0;\n const { log } = deps;\n const {\n abortOnSuperseded = safeDefaults.abortOnSuperseded,\n maxRetries = safeDefaults.maxRetries,\n pollTimeout = safeDefaults.pollTimeout,\n retryInterval = safeDefaults.retryInterval,\n runInProgressInterval = safeDefaults.runInProgressInterval,\n runUnderReviewInterval = safeDefaults.runUnderReviewInterval,\n } = pollConfig;\n let currentStatus: CiGreenlightStatus | undefined = undefined;\n const startedAt = Date.now();\n let hasTimedOut = false;\n while (!(hasTimedOut = Date.now() - startedAt > pollTimeout)) {\n const responseState = await fetchCiGreenlightStatus(\n apiConfig,\n {\n runId,\n },\n deps,\n );\n if (!responseState.ok && !responseState.canRetry) {\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) from CI greenlight, aborting.`,\n );\n return {\n abortReason: \"4XX-client-error\",\n httpStatus: responseState.httpStatus,\n outcome: \"aborted\",\n };\n }\n if (!responseState.ok) {\n // This is a non-OK retryable status.\n retries += 1;\n if (retries > maxRetries) {\n log.error(\n `🚫 Unrecoverable error${\n responseState.httpStatus\n ? ` (status ${responseState.httpStatus})`\n : \"\"\n } from CI greenlight, aborting after ${maxRetries} attempts.`,\n );\n if (responseState.errorType === \"network\") {\n return {\n abortReason: \"network-error\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n let abortReason: PollCiGreenlightAbortReason = \"XXX-other-http-code\";\n\n if (responseState.errorType === \"not-found\")\n abortReason = \"404-run-not-found\";\n else if (responseState.errorType === \"server\")\n abortReason = \"5XX-server-error\";\n else responseState satisfies never;\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n outcome: \"aborted\",\n };\n }\n const { errorType, httpStatus } = responseState;\n const retryLabel = `${\n httpStatus ? ` (status ${httpStatus})` : \"\"\n }, will try again... (${retries}/${maxRetries})`;\n if (errorType === \"network\") log.warn(`āŒ Network error${retryLabel}`);\n else if (errorType === \"not-found\")\n log.info(`ā³ Run not found${retryLabel}`);\n else if (errorType === \"server\") log.warn(`āŒ Server error${retryLabel}`);\n\n await sleep(retryInterval);\n continue;\n }\n // responseState.ok === true\n retries = 0;\n const { greenlightStatus } = responseState;\n const previousStatus = currentStatus;\n currentStatus = greenlightStatus;\n if (\n !previousStatus ||\n previousStatus.runStage !== greenlightStatus.runStage\n ) {\n try {\n await onRunStageChanged(greenlightStatus, previousStatus);\n } catch (e) {\n log.error(`Error in onRunStageChanged callback`, e);\n }\n }\n const urlInfo = `See ${greenlightStatus.relevantRunUrl}`;\n const {\n greenlight,\n relevantRunId,\n relevantRunUrl,\n relevantRunWithBugsUrl,\n rootRunId,\n rootRunUrl,\n runStage,\n } = greenlightStatus;\n if (rootRunId !== relevantRunId) {\n const supersedingDetails = `\n - Root: ${rootRunUrl}\n - Superseding: ${relevantRunUrl}`;\n if (abortOnSuperseded) {\n log.warn(\n `āŒ Aborting due to superseded run (option 'abortOnSuperseded' is enabled).${supersedingDetails}`,\n );\n return {\n abortReason: \"superseded-run\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n log.info(`Root run was superseded:${supersedingDetails}`);\n }\n if (runStage === \"completed\") {\n const {\n blockingBugsCount,\n blockingBugUrls = [],\n nonBlockingBugsCount,\n nonBlockingBugUrls = [],\n } = greenlightStatus;\n const blockingBugList = blockingBugUrls\n .map((url) => `\\n• ${url}`)\n .join(\"\");\n const nonBlockingBugList = nonBlockingBugUrls\n .map((url) => `\\n• ${url}`)\n .join(\"\");\n const bugsListInText = `${\n blockingBugUrls.length > 0 ? `\\nBLOCKING BUGS:${blockingBugList}` : \"\"\n }${\n nonBlockingBugUrls.length > 0\n ? `\\nNON BLOCKING BUGS:${nonBlockingBugList}`\n : \"\"\n }`;\n if (greenlight) {\n log.info(\n `āœ… Run passed and no blocking bugs found${\n nonBlockingBugsCount > 0\n ? ` and ${nonBlockingBugsCount} non-blocking bug${pluralize(\n nonBlockingBugsCount,\n )} found`\n : \"\"\n }.\\n${urlInfo}`,\n );\n return { greenlightStatus, outcome: \"success\" };\n } else {\n log.warn(\n `āŒ Run failed and ${blockingBugsCount} blocking bug${pluralize(\n blockingBugsCount,\n )} found${\n nonBlockingBugsCount\n ? ` and ${nonBlockingBugsCount} non-blocking bug${pluralize(\n nonBlockingBugsCount,\n )}`\n : \"\"\n }.\\nSee ${relevantRunWithBugsUrl}\\n` +\n \"You may review the priority of certain bugs to mark these non-blocking and retry the job.\\n\" +\n bugsListInText,\n );\n return { greenlightStatus, outcome: \"failed\" };\n }\n }\n if (runStage === \"canceled\") {\n log.info(\n `🚫 Run was canceled. Aborting... Please contact support.\\n${urlInfo}`,\n );\n return {\n abortReason: \"run-canceled\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n // Non-terminal run stages\n if (hasTimedOut) {\n log.warn(`āŒ Poll timed out after ${pollTimeout / 1000}s. Aborting...`);\n return {\n abortReason: \"poll-timed-out\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n if (runStage === \"initializing\") {\n log.info(`ā³ Run is in progress... ${urlInfo}`);\n await sleep(runInProgressInterval);\n } else if (runStage === \"underReview\") {\n log.info(`šŸ•µļø Run is under review... ${urlInfo}`);\n await sleep(runUnderReviewInterval);\n } else throw Error(`Unexpected run stage: ${runStage satisfies never}`);\n }\n\n log.warn(`āŒ Poll timed out after ${pollTimeout / 1000}s. Aborting...`);\n return {\n abortReason: \"poll-timed-out\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n}\n","import { type ApiConfig } from \"../api-types.js\";\nimport { buildFetchWithTimeout } from \"../other.js\";\n\nimport { defaultFetch } from \"./defaults/fetch.js\";\nimport { defaultLogDriver } from \"./defaults/log.js\";\nimport { defaultServiceBase } from \"./defaults/serviceBase.js\";\nimport { defaultUserAgent } from \"./defaults/userAgent.js\";\nimport { type SdkDependencies } from \"./dependencies.js\";\nimport { attemptNotifyDeploy } from \"./domain/attemptDeploy/index.js\";\nimport { generateSignedUrlForRunInputsExecutablesStorage } from \"./domain/generateSignedUrls/generate-signed-url-for-run-inputs-executables.js\";\nimport { generateSignedUrlForTempTeamStorage } from \"./domain/generateSignedUrls/generate-signed-url-for-team-storage.js\";\nimport { pollCiGreenlightStatus } from \"./domain/poll-ci-greenlight.js\";\n\nexport function makeQaWolfSdk(\n {\n apiKey,\n serviceBase = defaultServiceBase,\n userAgent = defaultUserAgent,\n }: {\n apiKey: string;\n serviceBase?: string;\n userAgent?: string;\n },\n {\n fetch = defaultFetch,\n log = defaultLogDriver,\n }: Partial<SdkDependencies> = {},\n) {\n if (typeof fetch !== \"function\") {\n throw Error(\n `QA Wolf CI-SDK requires fetch to be defined. Make sure you are using NodeJS 18+, OR pass a fetch polyfill to the makeQaWolfSdk function.\nWe recommend 'undici' package for that purpose. See the Requirement section of our README for more guidance.`,\n );\n }\n\n const deps: SdkDependencies = {\n // Versions of fetch may have different default timeouts. For consistency, we explicitly set it to 60 seconds here.\n fetch: buildFetchWithTimeout(fetch, 60000),\n log,\n };\n const apiConfig: ApiConfig = { apiKey, serviceBase, userAgent };\n return {\n attemptNotifyDeploy: attemptNotifyDeploy.bind(null, deps, apiConfig),\n generateSignedUrlForRunInputsExecutablesStorage:\n generateSignedUrlForRunInputsExecutablesStorage.bind(\n null,\n deps,\n apiConfig,\n ),\n generateSignedUrlForTempTeamStorage:\n generateSignedUrlForTempTeamStorage.bind(null, deps, apiConfig),\n pollCiGreenlightStatus: pollCiGreenlightStatus.bind(null, deps, apiConfig),\n };\n}\n\nexport type * from \"./domain/attemptDeploy/index.js\";\nexport type * from \"./domain/generateSignedUrls/types.js\";\nexport type * from \"./domain/poll-ci-greenlight.js\";\n"]}
1
+ {"version":3,"sources":["../src/lib/other.ts","../src/lib/sdk/defaults/fetch.ts","../src/lib/sdk/defaults/log.ts","../src/lib/sdk/defaults/serviceBase.ts","../package.json","../src/lib/sdk/defaults/userAgent.ts","../src/lib/api/log.ts","../src/lib/sdk/domain/attemptDeploy/index.ts","../src/lib/api/generate-signed-url-for-run-inputs-executables.ts","../src/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-run-inputs-executables.ts","../src/lib/api/generate-signed-url-for-team-storage.ts","../src/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-team-storage.ts","../src/lib/api/ci-greenlight.ts","../src/lib/sdk/domain/poll-ci-greenlight.ts","../src/lib/sdk/index.ts"],"names":["sleep","ms","Promise","resolve","setTimeout","pluralize","count","buildFetchWithTimeout","fetch","timeout","args","signal","AbortSignal","defaultFetch","globalThis","defaultLogDriver","error","message","console","info","log","warn","defaultServiceBase","defaultUserAgent","packageJson","version","logFetchError","methodName","response","ok","eventId","failureMessage","body","json","catch","text","undefined","eventIdSuffix","messageSuffix","statusText","status","attemptNotifyDeploy","deps","apiConfig","config","localFetch","URL","serviceBase","JSON","stringify","branch","commit_url","commitUrl","deduplication_key","deduplicationKey","deployment_type","deploymentType","deployment_url","deploymentUrl","ephemeral_environment","ephemeralEnvironment","hosting_service","hostingService","merge_request_number","mergeRequestNumber","pull_request_number","pullRequestNumber","repository","sha","variables","headers","Authorization","apiKey","userAgent","method","handleErrorResponse","data","handleSuccessResponse","abortReason","httpStatus","outcome","environment","results","isPreviewDeployment","isStatic","logPrefix","alias","id","length","environmentId","runId","failReason","failedTrigger","find","t","failure_reason","duplicateSuite","duplicate_suite_id","successfulTrigger","created_suite_id","callGenerateSignedUrlForRunInputsExecutablesStorage","destinationFilePath","encodeURIComponent","fileLocation","playgroundFileLocation","signedUrl","success","errorMessage","e","generateSignedUrlForRunInputsExecutablesStorage","responseState","uploadUrl","callGenerateSignedUrlForTempTeamStorage","generateSignedUrlForTempTeamStorage","fetchCiGreenlightStatus","resp","greenlightStatus","canRetry","errorType","safeDefaults","abortOnSuperseded","maxRetries","pollTimeout","retryInterval","runInProgressInterval","runUnderReviewInterval","pollCiGreenlightStatus","onRunStageChanged","pollConfig","retries","currentStatus","startedAt","Date","now","hasTimedOut","retryLabel","previousStatus","runStage","urlInfo","relevantRunUrl","greenlight","relevantRunId","relevantRunWithBugsUrl","rootRunId","rootRunUrl","supersedingDetails","blockingBugsCount","blockingBugUrls","nonBlockingBugsCount","nonBlockingBugUrls","blockingBugList","map","url","join","nonBlockingBugList","bugsListInText","Error","makeQaWolfSdk","bind"],"mappings":";;;;AAEO,SAASA,MAAMC,EAAAA,EAAU;AAC9B,EAAA,OAAO,IAAIC,OAAAA,CAAQ,CAACC,YAAYC,UAAAA,CAAWD,OAAAA,EAASF,EAAAA,CAAAA,CAAAA;AACtD;AAFgBD,MAAAA,CAAAA,KAAAA,EAAAA,OAAAA,CAAAA;AAIT,SAASK,UAAUC,KAAAA,EAAa;AACrC,EAAA,OAAOA,KAAAA,KAAU,IAAI,EAAA,GAAK,GAAA;AAC5B;AAFgBD,MAAAA,CAAAA,SAAAA,EAAAA,WAAAA,CAAAA;AAYT,IAAME,qBAAAA,2BACVC,KAAAA,EAAoBC,OAAAA,KACrB,UAAUC,IAAAA,KACRF,KAAAA,CAAME,IAAAA,CAAK,CAAA,CAAA,EAAI;AAAE,EAAA,GAAGA,KAAK,CAAA,CAAA;EAAIC,MAAAA,EAAQC,WAAAA,CAAYH,QAAQA,OAAAA;AAAS,CAAA,CAAA,EAFpE,uBAAA,CAAA;;;ACnBK,IAAMI,eAAeC,UAAAA,CAAWN,KAAAA;;;ACEhC,IAAMO,gBAAAA,GAA8B;AACzCC,EAAAA,KAAAA,CAAMC,SAASD,KAAAA,EAAK;AAClBE,IAAAA,OAAAA,CAAQF,KAAAA,CAAMC,SAASD,KAAAA,CAAAA;AACzB,EAAA,CAAA;AACAG,EAAAA,IAAAA,CAAKF,OAAAA,EAAO;AACVC,IAAAA,OAAAA,CAAQE,IAAIH,OAAAA,CAAAA;AACd,EAAA,CAAA;AACAI,EAAAA,IAAAA,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H,IAAAA,CAAK,IAAA,EAAMpH,IAAAA,EAAMC,SAAAA,CAAAA;AAC1DkE,IAAAA,+CAAAA,EACEA,+CAAAA,CAAgDiD,IAAAA,CAC9C,IAAA,EACApH,IAAAA,EACAC,SAAAA,CAAAA;AAEJsE,IAAAA,mCAAAA,EACEA,mCAAAA,CAAoC6C,IAAAA,CAAK,IAAA,EAAMpH,IAAAA,EAAMC,SAAAA,CAAAA;AACvDmF,IAAAA,sBAAAA,EAAwBA,sBAAAA,CAAuBgC,IAAAA,CAAK,IAAA,EAAMpH,IAAAA,EAAMC,SAAAA;AAClE,GAAA;AACF;AA1CgBkH,MAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA","file":"index.js","sourcesContent":["import type { FetchDriver } from \"./sdk/dependencies.js\";\n\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function pluralize(count: number) {\n return count === 1 ? \"\" : \"s\";\n}\n\nexport function getBackoffMs(\n attemptNumber: number,\n minWaitMs = 1000,\n maxWaitMs = 10000,\n): number {\n return Math.min(maxWaitMs, minWaitMs * 1.2 ** attemptNumber);\n}\n\nexport const buildFetchWithTimeout =\n (fetch: FetchDriver, timeout: number) =>\n async (...args: Parameters<FetchDriver>) =>\n fetch(args[0], { ...args[1], signal: AbortSignal.timeout(timeout) });\n","export const defaultFetch = globalThis.fetch;\n","import type { LogDriver } from \"../dependencies.js\";\n\nexport const defaultLogDriver: LogDriver = {\n error(message, error) {\n console.error(message, error);\n },\n info(message) {\n console.log(message);\n },\n warn(message) {\n console.warn(message);\n },\n};\n","export const defaultServiceBase = \"https://app.qawolf.com/\";\n","{\n \"name\": \"@qawolf/ci-sdk\",\n \"version\": \"1.1.1\",\n \"private\": false,\n \"description\": \"A simple SDK for interacting with QAWolf in CI scripts.\",\n \"keywords\": [],\n \"license\": \"MIT\",\n \"author\": \"Jules Sam. Randolph<jules@qawolf.com>\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"require\": \"./dist/index.cjs\",\n \"import\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n }\n },\n \"files\": [\n \"/dist\",\n \"/README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/index.ts --format esm,cjs --dts --clean --splitting --treeshake --sourcemap --outDir dist --target es2022\",\n \"lint\": \"dpdm --exit-code circular:1 --no-tree --no-warning --transform --include='.*' --exclude='/(dist|node_modules)/' '**/*' && eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx --quiet && prettier --check .\",\n \"lint:fix\": \"eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx --fix --quiet && prettier --log-level=warn --write .\",\n \"lint:warnings\": \"eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx\",\n \"prepublishOnly\": \"nx run ci-sdk:build\",\n \"test\": \"NODE_OPTIONS=\\\"--experimental-vm-modules\\\" NODE_NO_WARNINGS=1 jest\",\n \"tsc:check\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@qawolf/ci-utils\": \"^1.0.0\",\n \"@sinonjs/fake-timers\": \"^10.3.0\",\n \"slugify\": \"^1.6.6\",\n \"tslib\": \"^2.6.2\"\n },\n \"devDependencies\": {\n \"tsup\": \"^8.3.5\"\n },\n \"engines\": {\n \"node\": \">=20\"\n }\n}\n","import packageJson from \"../../../../package.json\" with { type: \"json\" };\n\nexport const defaultUserAgent = `ci-sdk/${packageJson.version}`;\n","import type { LogDriver } from \"@qawolf/ci-utils\";\n\nexport async function logFetchError({\n log,\n methodName,\n response,\n}: {\n log: LogDriver;\n methodName: string;\n response: Response;\n}) {\n if (response.ok) return;\n\n const { eventId, failureMessage } = await (async () => {\n try {\n const body = (await response.json().catch(() => response.text())) as\n | Record<string, unknown>\n | string;\n if (typeof body === \"object\" && body !== null) {\n return {\n eventId: body.eventId,\n failureMessage: body.failureMessage,\n };\n }\n // If body is not an object (i.e., it's the text from catch)\n return {\n eventId: undefined,\n failureMessage: body,\n };\n } catch {\n // If both parsing attempts somehow fail\n return {\n eventId: undefined,\n failureMessage: undefined,\n };\n }\n })();\n\n const eventIdSuffix = eventId ? ` (Event ID: ${eventId})` : \"\";\n const messageSuffix = failureMessage ? `: ${failureMessage}` : \"\";\n\n const statusText =\n response.status >= 500\n ? \"Server Error\"\n : response.statusText || \"Unknown Error\";\n\n log.error(\n `āŒ [${methodName}] ${response.status} ${statusText}${eventIdSuffix}${messageSuffix}`,\n );\n}\n","import type { ApiConfig } from \"../../../api-types.js\";\nimport { logFetchError } from \"../../../api/log.js\";\nimport type { LogDriver, SdkDependencies } from \"../../dependencies.js\";\n\nimport type {\n AttemptDeployHttpAbortReason,\n DeployConfig,\n DeployStatus,\n NotifyDeployStatus,\n} from \"./types.js\";\n\nexport async function attemptNotifyDeploy(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: Partial<DeployConfig>,\n): Promise<NotifyDeployStatus> {\n const { fetch: localFetch, log } = deps;\n try {\n const response = await localFetch(\n new URL(\"/api/webhooks/deploy_success\", apiConfig.serviceBase),\n {\n body: JSON.stringify({\n branch: config.branch,\n commit_url: config.commitUrl,\n deduplication_key: config.deduplicationKey,\n deployment_type: config.deploymentType,\n deployment_url: config.deploymentUrl,\n ...(\"ephemeralEnvironment\" in config\n ? {\n ephemeral_environment: config.ephemeralEnvironment,\n }\n : \"hostingService\" in config && {\n hosting_service: config.hostingService,\n merge_request_number:\n config.hostingService === \"GitLab\"\n ? config.mergeRequestNumber\n : undefined,\n pull_request_number:\n config.hostingService === \"GitHub\"\n ? config.pullRequestNumber\n : undefined,\n repository: config.repository,\n }),\n sha: config.sha,\n variables: config.variables,\n }),\n headers: {\n Authorization: `Bearer ${apiConfig.apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": apiConfig.userAgent,\n },\n method: \"POST\",\n },\n );\n\n if (!response.ok) return handleErrorResponse(response, log);\n const data = (await response.json()) as DeployStatus;\n return handleSuccessResponse(data, log);\n } catch (error) {\n log.error(`🚫 Network error from deploy_success, aborting.`);\n return {\n abortReason: \"network-error\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n}\n\nasync function handleErrorResponse(\n response: Response,\n log: LogDriver,\n): Promise<NotifyDeployStatus> {\n const status = response.status;\n let abortReason: AttemptDeployHttpAbortReason;\n if (status === undefined) abortReason = \"network-error\";\n else if (status === 401) abortReason = \"401-unauthorized\";\n else if (status === 403) abortReason = \"403-forbidden\";\n else if (status >= 500) abortReason = \"5XX-server-error\";\n else abortReason = \"4XX-client-error\";\n await logFetchError({\n log,\n methodName: \"attemptNotifyDeploy\",\n response,\n });\n return {\n abortReason,\n httpStatus: status,\n outcome: \"aborted\",\n };\n}\n\nasync function handleSuccessResponse(\n data: DeployStatus,\n log: LogDriver,\n): Promise<NotifyDeployStatus> {\n const { environment, results } = data;\n const isPreviewDeployment = environment && !environment.isStatic;\n\n if (environment) {\n const logPrefix = environment.isStatic\n ? \"Static environment\"\n : \"Preview environment\";\n log.info(`${logPrefix}: ${environment.alias} (id: ${environment.id})`);\n }\n\n // No triggers were matched\n if (results.length === 0) {\n if (isPreviewDeployment) {\n log.info(\n `āœ… Deployment notification was successful. No run was created for this deployment.`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: undefined,\n };\n }\n log.error(\n `🚫 No trigger matched the request. Please make sure there is at least one active test in the QA Wolf environment, or contact support.`,\n );\n return { failReason: \"no-matched-trigger\", outcome: \"failed\" };\n }\n\n // If there are results, environment must be defined\n if (!environment) {\n log.error(`🚫 No environment matched the request. Please contact support.`);\n return { failReason: \"no-environment\", outcome: \"failed\" };\n }\n\n const failedTrigger = results.find((t) => \"failure_reason\" in t);\n if (failedTrigger) {\n log.error(\n `🚫 Run could not be created. Reason: \"${failedTrigger.failure_reason}\". Please contact support.`,\n );\n return { failReason: \"run-could-not-be-created\", outcome: \"failed\" };\n }\n\n const duplicateSuite = results.find((t) => \"duplicate_suite_id\" in t);\n if (duplicateSuite) {\n log.info(\n `āœ… Deployment notification was successful. Previous run ID: ${duplicateSuite.duplicate_suite_id} already exists for this deployment.`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: duplicateSuite.duplicate_suite_id,\n };\n }\n\n const successfulTrigger = results.find((t) => \"created_suite_id\" in t);\n if (!successfulTrigger) {\n log.error(`🚫 No trigger matched the request. Please contact support.`);\n return { failReason: \"no-matched-trigger\", outcome: \"failed\" };\n }\n log.info(\n `āœ… Deployment notification was successful. Run created with ID: ${successfulTrigger.created_suite_id}`,\n );\n return {\n environmentId: environment.id,\n outcome: \"success\",\n runId: successfulTrigger.created_suite_id,\n };\n}\n","import type { ApiConfig } from \"../api-types.js\";\nimport type { SdkDependencies } from \"../sdk/dependencies.js\";\nimport type {\n GenerateSignedUrlConfig,\n GenerateSignedUrlResponse,\n} from \"../sdk/domain/generateSignedUrls/types.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport async function callGenerateSignedUrlForRunInputsExecutablesStorage(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n { destinationFilePath }: GenerateSignedUrlConfig,\n { fetch: localFetch, log }: SdkDependencies,\n): Promise<GenerateSignedUrlResponse> {\n try {\n const response = await localFetch(\n new URL(\n `${serviceBase}/api/v0/run-inputs-executables-signed-urls?file=${encodeURIComponent(destinationFilePath)}`,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": userAgent,\n },\n method: \"GET\",\n },\n );\n\n if (response.status === 200) {\n const json =\n (await response.json()) as Partial<GenerateSignedUrlResponse>;\n return {\n fileLocation: json.fileLocation,\n httpStatus: response.status,\n playgroundFileLocation: json.playgroundFileLocation,\n signedUrl: json.signedUrl,\n success: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"callGenerateSignedUrlForRunInputsExecutablesStorage\",\n response,\n });\n return {\n errorMessage: await response.text(),\n httpStatus: response.status,\n success: false,\n } as const;\n } catch (e) {\n return {\n errorMessage: \"Network error, aborting request to generate signed URL\",\n httpStatus: 0,\n success: false,\n } as const;\n }\n}\n","import type { ApiConfig } from \"../../../api-types.js\";\nimport { callGenerateSignedUrlForRunInputsExecutablesStorage } from \"../../../api/generate-signed-url-for-run-inputs-executables.js\";\nimport type { SdkDependencies } from \"../../dependencies.js\";\n\nimport type {\n GenerateSignedUrlAbortReason,\n GenerateSignedUrlConfig,\n GenerateSignedUrlStatus,\n} from \"./types.js\";\n\nexport async function generateSignedUrlForRunInputsExecutablesStorage(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: GenerateSignedUrlConfig,\n): Promise<GenerateSignedUrlStatus> {\n const { log } = deps;\n\n if (!config.destinationFilePath) {\n log.error(`🚫 destinationFilePath is a required config parameter`);\n return {\n abortReason: \"sdk-argument-validation-failed\",\n success: false,\n };\n }\n\n const responseState =\n await callGenerateSignedUrlForRunInputsExecutablesStorage(\n apiConfig,\n config,\n deps,\n );\n if (!responseState.success) {\n let abortReason: GenerateSignedUrlAbortReason = \"XXX-other-http-code\";\n\n if (responseState.httpStatus >= 500) {\n abortReason = \"5XX-server-error\";\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: aborting.`,\n );\n } else {\n if (responseState.httpStatus === 400) abortReason = \"400-invalid-request\";\n else if (responseState.httpStatus === 401)\n abortReason = \"401-invalid-credentials\";\n else if (responseState.httpStatus === 403) abortReason = \"403-forbidden\";\n else if (responseState.httpStatus === 0)\n abortReason = \"client-network-error\";\n\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: ${responseState.errorMessage ? `${responseState.errorMessage}.` : \"\"} aborting.`,\n );\n }\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n success: false,\n };\n }\n\n log.info(`āœ… Generated Signed Upload URL: ${responseState.signedUrl}.`);\n return {\n fileLocation: responseState.fileLocation,\n playgroundFileLocation: responseState.playgroundFileLocation,\n success: true,\n uploadUrl: responseState.signedUrl,\n };\n}\n","import type { ApiConfig } from \"../api-types.js\";\nimport type { SdkDependencies } from \"../sdk/dependencies.js\";\nimport type {\n GenerateSignedUrlConfig,\n GenerateSignedUrlResponse,\n} from \"../sdk/domain/generateSignedUrls/types.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport async function callGenerateSignedUrlForTempTeamStorage(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n { destinationFilePath }: Partial<GenerateSignedUrlConfig>,\n { fetch: localFetch, log }: SdkDependencies,\n): Promise<GenerateSignedUrlResponse> {\n try {\n const response = await localFetch(\n new URL(\n `${serviceBase}/api/v0/team-storage-signed-url?file=${destinationFilePath}`,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": userAgent,\n },\n method: \"GET\",\n },\n );\n\n if (response.status === 200) {\n const json =\n (await response.json()) as Partial<GenerateSignedUrlResponse>;\n return {\n fileLocation: json.fileLocation,\n httpStatus: response.status,\n playgroundFileLocation: json.playgroundFileLocation,\n signedUrl: json.signedUrl,\n success: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"callGenerateSignedUrlForTempTeamStorage\",\n response,\n });\n return {\n errorMessage: await response.text(),\n httpStatus: response.status,\n success: false,\n } as const;\n } catch (e) {\n return {\n errorMessage: \"Network error, aborting request to generate signed URL\",\n httpStatus: 0,\n success: false,\n } as const;\n }\n}\n","import type { ApiConfig } from \"../../../api-types.js\";\nimport { callGenerateSignedUrlForTempTeamStorage } from \"../../../api/generate-signed-url-for-team-storage.js\";\nimport type { SdkDependencies } from \"../../dependencies.js\";\n\nimport type { GenerateSignedUrlConfig } from \"./types.js\";\n\ntype GenerateSignedUrlStatus =\n | {\n fileLocation?: string;\n playgroundFileLocation?: string;\n success: true;\n uploadUrl?: string;\n }\n | {\n abortReason: GenerateSignedUrlAbortReason;\n httpStatus?: number;\n success: false;\n };\n\nexport type GenerateSignedUrlAbortReason =\n | \"client-network-error\"\n | \"sdk-argument-validation-failed\"\n | \"400-invalid-request\"\n | \"401-invalid-credentials\"\n | \"403-forbidden\"\n | \"5XX-server-error\"\n | \"XXX-other-http-code\";\n\nexport async function generateSignedUrlForTempTeamStorage(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n config: GenerateSignedUrlConfig,\n): Promise<GenerateSignedUrlStatus> {\n const { log } = deps;\n\n if (!config.destinationFilePath) {\n log.error(`🚫 destinationFilePath is a required config parameter`);\n return {\n abortReason: \"sdk-argument-validation-failed\",\n success: false,\n };\n }\n\n const responseState = await callGenerateSignedUrlForTempTeamStorage(\n apiConfig,\n config,\n deps,\n );\n if (!responseState.success) {\n let abortReason: GenerateSignedUrlAbortReason = \"XXX-other-http-code\";\n\n if (responseState.httpStatus >= 500) {\n abortReason = \"5XX-server-error\";\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: aborting.`,\n );\n } else {\n if (responseState.httpStatus === 400) abortReason = \"400-invalid-request\";\n else if (responseState.httpStatus === 401)\n abortReason = \"401-invalid-credentials\";\n else if (responseState.httpStatus === 403) abortReason = \"403-forbidden\";\n else if (responseState.httpStatus === 0)\n abortReason = \"client-network-error\";\n\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) when generating signed upload url: ${responseState.errorMessage ? `${responseState.errorMessage}.` : \"\"} aborting.`,\n );\n }\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n success: false,\n };\n }\n\n log.info(`āœ… Generated Signed Upload URL: ${responseState.signedUrl}.`);\n return {\n fileLocation: responseState.fileLocation,\n playgroundFileLocation: responseState.playgroundFileLocation,\n success: true,\n uploadUrl: responseState.signedUrl,\n };\n}\n","import type { ApiConfig } from \"../api-types.js\";\nimport type { SdkDependencies } from \"../sdk/dependencies.js\";\n\nimport { logFetchError } from \"./log.js\";\n\nexport type CiGreenlightBugDetails = {\n /**\n * The URL of this BR in the QAWolf application.\n */\n applicationUrl: string;\n /**\n * If this bug report is linked to an external issue, it will\n * show up here.\n */\n externalIssue:\n | {\n /**\n * The URL of the external issue in the external platform\n * application.\n */\n applicationUrl: string;\n /**\n * The ID of this issue in the external platform.\n */\n externalIssueId: string;\n /**\n * Lowercase platform name (e.g. \"jira\").\n */\n platform: string;\n }\n | undefined;\n /**\n * True if the bug is blocking.\n */\n isBlocking: boolean;\n /**\n * True if the bug has been found in this run.\n */\n isNew: boolean;\n /**\n * The name of this bug.\n */\n name: string;\n /**\n * The bug number.\n */\n number: number;\n /**\n * The priority of this bug.\n */\n priority: \"medium\" | \"unprioritized\" | \"low\" | \"high\" | \"urgent\";\n};\n\nexport type CiGreenlightBugData = {\n /**\n * The count of blocking bugs reproduced in the run.\n */\n blockingBugsCount: number;\n /**\n * The URLs of the blocking bugs.\n *\n * @deprecated This field will be removed in the next major version.\n * Prefer using `reproducedBugs` filtered by `isBlocking: true`, reading\n * the `applicationUrl` field.\n */\n blockingBugUrls: string[];\n /**\n * The count of non-blocking bugs reproduced in the run.\n */\n nonBlockingBugsCount: number;\n /**\n * The URLs of the non-blocking bugs.\n *\n * @deprecated This field will be removed in the next major version.\n * Prefer using `reproducedBugs` filtered by `isBlocking: false`, reading\n * the `applicationUrl` field.\n */\n nonBlockingBugUrls: string[];\n /**\n * Blocking bugs that were not reproduced in this run, but are still\n * opened in the run environment. This may happen when the run only covers a\n * subset of the workflows in environment.\n */\n otherBlockingBugsInEnvironment: CiGreenlightBugDetails[];\n /**\n * Bugs that were reproduced in this run. This includes newly found bugs.\n */\n reproducedBugs: CiGreenlightBugDetails[];\n};\n\n/**\n * @deprecated This type will be removed in the next major version. Use `CiGreenlightBugData` instead.\n */\nexport type CiGreenlightCompletedSuiteDetails = CiGreenlightBugData;\n\nexport type CiGreenlightStatusBase = {\n relevantRunId: string;\n relevantRunUrl: string;\n relevantRunWithBugsUrl: string;\n rootRunId: string;\n rootRunUrl: string;\n workflowsDisabledAfterRunCount: number;\n workflowsInRunCount: number;\n workflowsUnderInvestigationCount: number;\n};\n\n/**\n * The status of a CI greenlight run. See the API documentation here for\n * more details: https://qawolf.notion.site/1b170576efea411fa785842a71e7c99e\n */\nexport type CiGreenlightStatus = CiGreenlightStatusBase &\n (\n | ({\n greenlight: boolean;\n runStage: \"completed\";\n } & CiGreenlightBugData)\n | ({\n greenlight: false;\n runStage: \"underReview\";\n } & CiGreenlightBugData)\n | {\n greenlight: false;\n runStage: \"initializing\" | \"underReview\" | \"canceled\";\n }\n );\n\nexport async function fetchCiGreenlightStatus(\n { apiKey, serviceBase, userAgent }: ApiConfig,\n {\n runId,\n }: {\n runId: string;\n },\n { fetch: localFetch, log }: SdkDependencies,\n) {\n try {\n const resp = await localFetch(\n new URL(\n `/api/v0/ci-greenlight/${encodeURIComponent(runId)}`,\n serviceBase,\n ),\n {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"User-Agent\": userAgent,\n },\n },\n );\n\n if (resp.ok) {\n const greenlightStatus = (await resp.json()) as CiGreenlightStatus;\n return {\n greenlightStatus,\n httpStatus: resp.status,\n ok: true,\n } as const;\n }\n await logFetchError({\n log,\n methodName: \"fetchCiGreenlightStatus\",\n response: resp,\n });\n if (resp.status === 404) {\n return {\n canRetry: true,\n errorType: \"not-found\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n }\n if (resp.status >= 500) {\n return {\n canRetry: true,\n errorType: \"server\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n }\n return {\n canRetry: false,\n errorType: \"client\",\n httpStatus: resp.status,\n ok: false,\n } as const;\n } catch (e) {\n return {\n canRetry: true,\n errorType: \"network\",\n httpStatus: 0,\n ok: false,\n } as const;\n }\n}\n","/* eslint-disable @qawolf/max-lines -- Old technical debt */\n\nimport type { ApiConfig } from \"../../api-types.js\";\nimport {\n type CiGreenlightStatus,\n fetchCiGreenlightStatus,\n} from \"../../api/ci-greenlight.js\";\nimport { pluralize, sleep } from \"../../other.js\";\nimport type { SdkDependencies } from \"../dependencies.js\";\n\nexport type PollCiGreenlightPollConfig = {\n /**\n * If true, the job will be aborted when a superseding run is detected.\n *\n * @default false\n */\n abortOnSuperseded: boolean;\n /**\n * Maximum number of network operations retries before aborting the job.\n *\n * @default 10\n */\n maxRetries: number;\n /**\n * Timeout in milliseconds before aborting this polling operation.\n *\n * @default 120 minutes\n */\n pollTimeout: number;\n /**\n * Interval in milliseconds between network operations retries.\n *\n * @default 10 seconds\n */\n retryInterval: number;\n /**\n * Interval in milliseconds between polling for a run in progress.\n *\n * @default 30 seconds\n */\n runInProgressInterval: number;\n /**\n * Interval in milliseconds between polling for a run under review.\n *\n * @default 60 minutes\n */\n runUnderReviewInterval: number;\n};\n\nexport type PollCiGreenlightHttpAbortReason =\n | \"4XX-client-error\"\n | \"404-run-not-found\"\n | \"5XX-server-error\"\n | \"XXX-other-http-code\";\n\nexport type PollCiGreenlightNonHttpAbortReason =\n | \"poll-timed-out\"\n | \"run-canceled\"\n | \"network-error\"\n | \"superseded-run\";\n\nexport type PollCiGreenlightAbortReason =\n | PollCiGreenlightNonHttpAbortReason\n | PollCiGreenlightHttpAbortReason;\n\nexport type PollCiGreenlightStatus =\n | {\n greenlightStatus: Extract<CiGreenlightStatus, { runStage: \"completed\" }>;\n /**\n * No blocking bugs were found in the run.\n */\n outcome: \"success\";\n }\n | {\n greenlightStatus: Extract<CiGreenlightStatus, { runStage: \"completed\" }>;\n /**\n * Blocking bugs were found in the run.\n */\n outcome: \"failed\";\n }\n | {\n abortReason: PollCiGreenlightHttpAbortReason;\n httpStatus: number;\n /**\n * The run was aborted due to an unrecoverable error.\n */\n outcome: \"aborted\";\n }\n | {\n abortReason: PollCiGreenlightNonHttpAbortReason;\n httpStatus: undefined;\n /**\n * The run was aborted due to an unrecoverable error.\n */\n outcome: \"aborted\";\n };\n\nexport type PollCiGreenlightParams = {\n /**\n * Callback to be called when the lifecycle stage of the run changes.\n */\n onRunStageChanged?: (\n current: CiGreenlightStatus,\n previous: CiGreenlightStatus | undefined,\n ) => unknown | Promise<unknown>;\n runId: string;\n} & Partial<PollCiGreenlightPollConfig>;\n\n// If you change these values, make sure you update the JSDoc\n// comments in the PollConfig type.\nconst safeDefaults: PollCiGreenlightPollConfig = {\n abortOnSuperseded: false,\n maxRetries: 10,\n pollTimeout: 120 * 60 * 1000,\n retryInterval: 10 * 1000,\n runInProgressInterval: 30 * 1000,\n runUnderReviewInterval: 60 * 1000,\n};\n\nexport async function pollCiGreenlightStatus(\n deps: SdkDependencies,\n apiConfig: ApiConfig,\n {\n onRunStageChanged: onRunStageChanged = () => undefined,\n runId,\n ...pollConfig\n }: PollCiGreenlightParams,\n): Promise<PollCiGreenlightStatus> {\n let retries = 0;\n const { log } = deps;\n const {\n abortOnSuperseded = safeDefaults.abortOnSuperseded,\n maxRetries = safeDefaults.maxRetries,\n pollTimeout = safeDefaults.pollTimeout,\n retryInterval = safeDefaults.retryInterval,\n runInProgressInterval = safeDefaults.runInProgressInterval,\n runUnderReviewInterval = safeDefaults.runUnderReviewInterval,\n } = pollConfig;\n let currentStatus: CiGreenlightStatus | undefined = undefined;\n const startedAt = Date.now();\n let hasTimedOut = false;\n while (!(hasTimedOut = Date.now() - startedAt > pollTimeout)) {\n const responseState = await fetchCiGreenlightStatus(\n apiConfig,\n {\n runId,\n },\n deps,\n );\n if (!responseState.ok && !responseState.canRetry) {\n log.error(\n `🚫 Unrecoverable error (status ${responseState.httpStatus}) from CI greenlight, aborting.`,\n );\n return {\n abortReason: \"4XX-client-error\",\n httpStatus: responseState.httpStatus,\n outcome: \"aborted\",\n };\n }\n if (!responseState.ok) {\n // This is a non-OK retryable status.\n retries += 1;\n if (retries > maxRetries) {\n log.error(\n `🚫 Unrecoverable error${\n responseState.httpStatus\n ? ` (status ${responseState.httpStatus})`\n : \"\"\n } from CI greenlight, aborting after ${maxRetries} attempts.`,\n );\n if (responseState.errorType === \"network\") {\n return {\n abortReason: \"network-error\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n let abortReason: PollCiGreenlightAbortReason = \"XXX-other-http-code\";\n\n if (responseState.errorType === \"not-found\")\n abortReason = \"404-run-not-found\";\n else if (responseState.errorType === \"server\")\n abortReason = \"5XX-server-error\";\n else responseState satisfies never;\n\n return {\n abortReason,\n httpStatus: responseState.httpStatus,\n outcome: \"aborted\",\n };\n }\n const { errorType, httpStatus } = responseState;\n const retryLabel = `${\n httpStatus ? ` (status ${httpStatus})` : \"\"\n }, will try again... (${retries}/${maxRetries})`;\n if (errorType === \"network\") log.warn(`āŒ Network error${retryLabel}`);\n else if (errorType === \"not-found\")\n log.info(`ā³ Run not found${retryLabel}`);\n else if (errorType === \"server\") log.warn(`āŒ Server error${retryLabel}`);\n\n await sleep(retryInterval);\n continue;\n }\n // responseState.ok === true\n retries = 0;\n const { greenlightStatus } = responseState;\n const previousStatus = currentStatus;\n currentStatus = greenlightStatus;\n if (\n !previousStatus ||\n previousStatus.runStage !== greenlightStatus.runStage\n ) {\n try {\n await onRunStageChanged(greenlightStatus, previousStatus);\n } catch (e) {\n log.error(`Error in onRunStageChanged callback`, e);\n }\n }\n const urlInfo = `See ${greenlightStatus.relevantRunUrl}`;\n const {\n greenlight,\n relevantRunId,\n relevantRunUrl,\n relevantRunWithBugsUrl,\n rootRunId,\n rootRunUrl,\n runStage,\n } = greenlightStatus;\n if (rootRunId !== relevantRunId) {\n const supersedingDetails = `\n - Root: ${rootRunUrl}\n - Superseding: ${relevantRunUrl}`;\n if (abortOnSuperseded) {\n log.warn(\n `āŒ Aborting due to superseded run (option 'abortOnSuperseded' is enabled).${supersedingDetails}`,\n );\n return {\n abortReason: \"superseded-run\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n log.info(`Root run was superseded:${supersedingDetails}`);\n }\n if (runStage === \"completed\") {\n const {\n blockingBugsCount,\n blockingBugUrls = [],\n nonBlockingBugsCount,\n nonBlockingBugUrls = [],\n } = greenlightStatus;\n const blockingBugList = blockingBugUrls\n .map((url) => `\\n• ${url}`)\n .join(\"\");\n const nonBlockingBugList = nonBlockingBugUrls\n .map((url) => `\\n• ${url}`)\n .join(\"\");\n const bugsListInText = `${\n blockingBugUrls.length > 0 ? `\\nBLOCKING BUGS:${blockingBugList}` : \"\"\n }${\n nonBlockingBugUrls.length > 0\n ? `\\nNON BLOCKING BUGS:${nonBlockingBugList}`\n : \"\"\n }`;\n if (greenlight) {\n log.info(\n `āœ… Run passed and no blocking bugs found${\n nonBlockingBugsCount > 0\n ? ` and ${nonBlockingBugsCount} non-blocking bug${pluralize(\n nonBlockingBugsCount,\n )} found`\n : \"\"\n }.\\n${urlInfo}`,\n );\n return { greenlightStatus, outcome: \"success\" };\n } else {\n log.warn(\n `āŒ Run failed and ${blockingBugsCount} blocking bug${pluralize(\n blockingBugsCount,\n )} found${\n nonBlockingBugsCount\n ? ` and ${nonBlockingBugsCount} non-blocking bug${pluralize(\n nonBlockingBugsCount,\n )}`\n : \"\"\n }.\\nSee ${relevantRunWithBugsUrl}\\n` +\n \"You may review the priority of certain bugs to mark these non-blocking and retry the job.\\n\" +\n bugsListInText,\n );\n return { greenlightStatus, outcome: \"failed\" };\n }\n }\n if (runStage === \"canceled\") {\n log.info(\n `🚫 Run was canceled. Aborting... Please contact support.\\n${urlInfo}`,\n );\n return {\n abortReason: \"run-canceled\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n // Non-terminal run stages\n if (hasTimedOut) {\n log.warn(`āŒ Poll timed out after ${pollTimeout / 1000}s. Aborting...`);\n return {\n abortReason: \"poll-timed-out\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n }\n if (runStage === \"initializing\") {\n log.info(`ā³ Run is in progress... ${urlInfo}`);\n await sleep(runInProgressInterval);\n } else if (runStage === \"underReview\") {\n log.info(`šŸ•µļø Run is under review... ${urlInfo}`);\n await sleep(runUnderReviewInterval);\n } else throw Error(`Unexpected run stage: ${runStage satisfies never}`);\n }\n\n log.warn(`āŒ Poll timed out after ${pollTimeout / 1000}s. Aborting...`);\n return {\n abortReason: \"poll-timed-out\",\n httpStatus: undefined,\n outcome: \"aborted\",\n };\n}\n","import type { ApiConfig } from \"../api-types.js\";\nimport { buildFetchWithTimeout } from \"../other.js\";\n\nimport { defaultFetch } from \"./defaults/fetch.js\";\nimport { defaultLogDriver } from \"./defaults/log.js\";\nimport { defaultServiceBase } from \"./defaults/serviceBase.js\";\nimport { defaultUserAgent } from \"./defaults/userAgent.js\";\nimport type { SdkDependencies } from \"./dependencies.js\";\nimport { attemptNotifyDeploy } from \"./domain/attemptDeploy/index.js\";\nimport { generateSignedUrlForRunInputsExecutablesStorage } from \"./domain/generateSignedUrls/generate-signed-url-for-run-inputs-executables.js\";\nimport { generateSignedUrlForTempTeamStorage } from \"./domain/generateSignedUrls/generate-signed-url-for-team-storage.js\";\nimport { pollCiGreenlightStatus } from \"./domain/poll-ci-greenlight.js\";\n\nexport function makeQaWolfSdk(\n {\n apiKey,\n serviceBase = defaultServiceBase,\n userAgent = defaultUserAgent,\n }: {\n apiKey: string;\n serviceBase?: string;\n userAgent?: string;\n },\n {\n fetch = defaultFetch,\n log = defaultLogDriver,\n }: Partial<SdkDependencies> = {},\n) {\n if (typeof fetch !== \"function\") {\n throw Error(\n `QA Wolf CI-SDK requires fetch to be defined. Make sure you are using NodeJS 18+, OR pass a fetch polyfill to the makeQaWolfSdk function.\nWe recommend 'undici' package for that purpose. See the Requirement section of our README for more guidance.`,\n );\n }\n\n const deps: SdkDependencies = {\n // Versions of fetch may have different default timeouts. For consistency, we explicitly set it to 2 minutes here.\n // The increased timeout helps avoid edge cases where we need to search for a commit against multiple\n // code hosting service repositories as a fallback when not finding the repository based on organization/name.\n fetch: buildFetchWithTimeout(fetch, 120000),\n log,\n };\n const apiConfig: ApiConfig = { apiKey, serviceBase, userAgent };\n return {\n attemptNotifyDeploy: attemptNotifyDeploy.bind(null, deps, apiConfig),\n generateSignedUrlForRunInputsExecutablesStorage:\n generateSignedUrlForRunInputsExecutablesStorage.bind(\n null,\n deps,\n apiConfig,\n ),\n generateSignedUrlForTempTeamStorage:\n generateSignedUrlForTempTeamStorage.bind(null, deps, apiConfig),\n pollCiGreenlightStatus: pollCiGreenlightStatus.bind(null, deps, apiConfig),\n };\n}\n\nexport type * from \"./domain/attemptDeploy/index.js\";\nexport type * from \"./domain/generateSignedUrls/types.js\";\nexport type * from \"./domain/poll-ci-greenlight.js\";\n"]}
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@qawolf/ci-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.1.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
+ "sideEffects": false,
9
10
  "type": "module",
10
11
  "exports": {
11
12
  ".": {
@@ -15,18 +16,15 @@
15
16
  "default": "./dist/index.js"
16
17
  }
17
18
  },
18
- "main": "./dist/index.cjs",
19
- "module": "./dist/index.js",
20
- "types": "./dist/index.d.ts",
21
19
  "files": [
22
20
  "/dist",
23
21
  "/README.md"
24
22
  ],
25
23
  "scripts": {
26
24
  "build": "tsup src/index.ts --format esm,cjs --dts --clean --splitting --treeshake --sourcemap --outDir dist --target es2022",
27
- "lint": "cycle-import-scan . && eslint . --ext js,jsx,mjs,ts,tsx --quiet && prettier --check .",
28
- "lint:fix": "eslint . --ext js,jsx,mjs,ts,tsx --fix --quiet && prettier --log-level=warn --write .",
29
- "lint:warnings": "eslint . --ext js,jsx,mjs,ts,tsx",
25
+ "lint": "dpdm --exit-code circular:1 --no-tree --no-warning --transform --include='.*' --exclude='/(dist|node_modules)/' '**/*' && eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx --quiet && prettier --check .",
26
+ "lint:fix": "eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx --fix --quiet && prettier --log-level=warn --write .",
27
+ "lint:warnings": "eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx",
30
28
  "prepublishOnly": "nx run ci-sdk:build",
31
29
  "test": "NODE_OPTIONS=\"--experimental-vm-modules\" NODE_NO_WARNINGS=1 jest",
32
30
  "tsc:check": "tsc --noEmit"
@@ -38,9 +36,9 @@
38
36
  "tslib": "^2.6.2"
39
37
  },
40
38
  "devDependencies": {
41
- "tsup": "8.3.5"
39
+ "tsup": "^8.3.5"
42
40
  },
43
41
  "engines": {
44
- "node": ">=16"
42
+ "node": ">=20"
45
43
  }
46
44
  }