auto-harness-client 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -192,6 +192,11 @@ that `auto-harness`'s own
192
192
  uses, so a consuming
193
193
  workflow's inline script and a bundled composite action stay in sync with the same validation.
194
194
 
195
+ The same module also covers session drain from a workflow: `isHarnessDrainOperation` (a type
196
+ guard for the `start-drain`/`get-drain`/`wait-for-drain`/`release-drain` operation vocabulary) and
197
+ `writeDrainOutputs` (writes `operation-id`/`status`/`queued-count`/`running-count`/
198
+ `cancelled-count`/`failure-code` to `GITHUB_OUTPUT` for a `SessionDrain`).
199
+
195
200
  ```js
196
201
  import { parseHarnessTarget, requiredEnvironmentValue } from "auto-harness-client/actions";
197
202
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-harness-client",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Dependency-free client for the Auto Harness automation API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,8 @@
1
+ export function isHarnessDrainOperation(value) {
2
+ return (
3
+ value === "start-drain" ||
4
+ value === "get-drain" ||
5
+ value === "wait-for-drain" ||
6
+ value === "release-drain"
7
+ );
8
+ }
@@ -1,4 +1,4 @@
1
- import type { TargetSpec } from "../index.js";
1
+ import type { SessionDrain, TargetSpec } from "../index.js";
2
2
 
3
3
  /** Dependency-free env→`CreateSessionInput` adapter for GitHub Actions consumers of Auto Harness. */
4
4
 
@@ -66,3 +66,17 @@ export function writeOutputs(
66
66
  result: DispatchResult,
67
67
  route?: TargetSpec[],
68
68
  ): void;
69
+
70
+ export type HarnessDrainOperation =
71
+ | "start-drain"
72
+ | "get-drain"
73
+ | "wait-for-drain"
74
+ | "release-drain";
75
+
76
+ export function isHarnessDrainOperation(value: string | undefined): value is HarnessDrainOperation;
77
+
78
+ /**
79
+ * Writes `operation-id`/`status`/`queued-count`/`running-count`/`cancelled-count`/`failure-code`
80
+ * to `GITHUB_OUTPUT`, only when it is set.
81
+ */
82
+ export function writeDrainOutputs(environment: ActionEnvironment, drain: SessionDrain): void;
@@ -1,5 +1,6 @@
1
1
  export { requiredEnvironmentValue } from "./env.js";
2
2
  export { HarnessDispatchError } from "./errors.js";
3
+ export { isHarnessDrainOperation } from "./drain.js";
3
4
  export {
4
5
  parseApiOrigin,
5
6
  parseConcurrencyId,
@@ -9,4 +10,5 @@ export {
9
10
  parseRequiredLabels,
10
11
  } from "./parse.js";
11
12
  export { TARGET_SPEC_KEYS, parseHarnessFallbacks, parseHarnessTarget } from "./parse-target.js";
13
+ export { writeDrainOutputs } from "./write-drain-outputs.js";
12
14
  export { writeOutputs } from "./write-outputs.js";
@@ -0,0 +1,18 @@
1
+ import { appendFileSync } from "node:fs";
2
+
3
+ export function writeDrainOutputs(environment, drain) {
4
+ if (!environment.GITHUB_OUTPUT) return;
5
+ appendFileSync(
6
+ environment.GITHUB_OUTPUT,
7
+ [
8
+ `operation-id=${drain.operationId}`,
9
+ `status=${drain.status}`,
10
+ `queued-count=${drain.queuedCount}`,
11
+ `running-count=${drain.runningCount}`,
12
+ `cancelled-count=${drain.cancelledCount}`,
13
+ `failure-code=${drain.failureCode ?? ""}`,
14
+ "",
15
+ ].join("\n"),
16
+ "utf8",
17
+ );
18
+ }