@checkstack/satellite 0.2.11 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # @checkstack/satellite
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 35bc682: feat(healthcheck): expose check + system run-context to script collectors
8
+
9
+ Script health checks can now read which check and system a run is for.
10
+ Previously shell scripts got only a curated env whitelist and inline
11
+ scripts only `context.config`, so a script had no built-in way to know
12
+ its own check name or the system it was checking.
13
+
14
+ - `@checkstack/backend-api`: new `CollectorRunContext` type
15
+ (`{ check: { id, name, intervalSeconds }, system: { id, name } }`) and
16
+ an optional `runContext` param on `CollectorStrategy.execute`. Optional,
17
+ so existing collector implementations are unaffected.
18
+ - Shell-script collector: injects reserved `CHECKSTACK_CHECK_ID`,
19
+ `CHECKSTACK_CHECK_NAME`, `CHECKSTACK_CHECK_INTERVAL_SECONDS`,
20
+ `CHECKSTACK_SYSTEM_ID`, `CHECKSTACK_SYSTEM_NAME` env vars (user-supplied
21
+ `env` still wins on collision).
22
+ - Inline-script collector: exposes `context.check` and `context.system`
23
+ alongside `context.config`; the inline-script editor now types them for
24
+ autocomplete.
25
+ - Shell editors (health-check collectors and automation shell actions) now
26
+ also suggest the user's own `env` (JSON) keys as `$NAME` completions, via
27
+ the new exported `customShellEnvVars` helper. Keys that aren't valid shell
28
+ identifiers are omitted.
29
+ - Fix: the Typefox `CodeEditor` captured a stale `onChange` at editor start,
30
+ so editing one `DynamicForm` field reverted sibling fields changed since
31
+ mount (e.g. typing in a shell `script` field wiped an unsaved `env` value,
32
+ or deleted a sibling automation action added after mount). The change
33
+ handler now routes through a ref to the current `onChange`.
34
+ - Fix: focusing a JSON editor threw "LanguageStatusService.addStatus is not
35
+ supported" because the standalone service set omitted `ILanguageStatusService`.
36
+ That one service is now registered via `serviceOverrides`.
37
+ - Fix: the automation trigger card nested a `<Badge>` (a `<div>`) inside a
38
+ `<p>`, producing a `validateDOMNesting` warning. Switched the wrapper to a
39
+ `<div>`.
40
+ - Local runs (`queue-executor`) and satellite runs both populate the
41
+ context. `SatelliteAssignment` (and the `getAssignmentsForSatellite`
42
+ RPC output) gained optional `configName` / `systemName` so the metadata
43
+ reaches satellite-side execution; `HealthCheckService` resolves the
44
+ system name via the catalog client.
45
+
46
+ BREAKING CHANGE: `createHealthCheckRouter` now requires a `catalogClient`
47
+ option (used to resolve system names for satellite assignments). Update
48
+ call sites to pass the catalog RPC client.
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies [6d52276]
53
+ - Updated dependencies [35bc682]
54
+ - @checkstack/common@0.12.0
55
+ - @checkstack/backend-api@0.18.0
56
+ - @checkstack/satellite-common@0.6.0
57
+
3
58
  ## 0.2.11
4
59
 
5
60
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/satellite",
3
- "version": "0.2.11",
3
+ "version": "0.3.0",
4
4
  "license": "Elastic-2.0",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -11,8 +11,8 @@
11
11
  "lint:code": "eslint . --max-warnings 0"
12
12
  },
13
13
  "dependencies": {
14
- "@checkstack/satellite-common": "0.5.2",
15
- "@checkstack/backend-api": "0.17.0",
14
+ "@checkstack/satellite-common": "0.5.3",
15
+ "@checkstack/backend-api": "0.17.1",
16
16
  "@checkstack/common": "0.11.0"
17
17
  },
18
18
  "devDependencies": {
package/src/index.ts CHANGED
@@ -5,10 +5,12 @@ import type {
5
5
  import type {
6
6
  ConnectedClient,
7
7
  TransportClient,
8
+ CollectorRunContext,
8
9
  } from "@checkstack/backend-api";
9
10
  import { SatelliteClient } from "./satellite-client";
10
11
  import { Scheduler } from "./scheduler";
11
12
  import { loadStrategies } from "./strategy-loader";
13
+ import { buildRunContext } from "./run-context";
12
14
 
13
15
  // =============================================================================
14
16
  // Environment validation — fail fast if required vars are missing
@@ -92,6 +94,11 @@ async function executeAssignment(
92
94
  };
93
95
  }
94
96
 
97
+ // Curated, read-only run-context metadata exposed to collectors.
98
+ // Mirrors the core queue-executor; falls back to IDs when the optional
99
+ // name fields are absent (version-skew safety).
100
+ const runContext: CollectorRunContext = buildRunContext({ assignment });
101
+
95
102
  const start = performance.now();
96
103
  let connectedClient:
97
104
  | ConnectedClient<TransportClient<never, unknown>>
@@ -125,6 +132,7 @@ async function executeAssignment(
125
132
  config: collectorEntry.config,
126
133
  client: connectedClient!.client,
127
134
  pluginId: assignment.strategyId,
135
+ runContext,
128
136
  });
129
137
 
130
138
  return {
@@ -0,0 +1,53 @@
1
+ import { describe, test, expect } from "bun:test";
2
+ import { buildRunContext } from "./run-context";
3
+ import type { SatelliteAssignment } from "@checkstack/satellite-common";
4
+
5
+ function makeAssignment(
6
+ overrides?: Partial<SatelliteAssignment>,
7
+ ): SatelliteAssignment {
8
+ return {
9
+ configId: "config-1",
10
+ systemId: "system-1",
11
+ strategyId: "http",
12
+ config: {},
13
+ intervalSeconds: 60,
14
+ ...overrides,
15
+ };
16
+ }
17
+
18
+ describe("buildRunContext", () => {
19
+ test("uses configName and systemName when present", () => {
20
+ const assignment = makeAssignment({
21
+ configName: "API health",
22
+ systemName: "Production API",
23
+ });
24
+
25
+ const runContext = buildRunContext({ assignment });
26
+
27
+ expect(runContext).toEqual({
28
+ check: { id: "config-1", name: "API health", intervalSeconds: 60 },
29
+ system: { id: "system-1", name: "Production API" },
30
+ });
31
+ });
32
+
33
+ test("falls back to ids when name fields are absent", () => {
34
+ const assignment = makeAssignment();
35
+
36
+ const runContext = buildRunContext({ assignment });
37
+
38
+ expect(runContext.check.name).toBe("config-1");
39
+ expect(runContext.check.id).toBe("config-1");
40
+ expect(runContext.check.intervalSeconds).toBe(60);
41
+ expect(runContext.system.name).toBe("system-1");
42
+ expect(runContext.system.id).toBe("system-1");
43
+ });
44
+
45
+ test("falls back per-field when only one name is present", () => {
46
+ const assignment = makeAssignment({ configName: "API health" });
47
+
48
+ const runContext = buildRunContext({ assignment });
49
+
50
+ expect(runContext.check.name).toBe("API health");
51
+ expect(runContext.system.name).toBe("system-1");
52
+ });
53
+ });
@@ -0,0 +1,28 @@
1
+ import type { SatelliteAssignment } from "@checkstack/satellite-common";
2
+ import type { CollectorRunContext } from "@checkstack/backend-api";
3
+
4
+ /**
5
+ * Build the curated, read-only run-context metadata exposed to collectors
6
+ * from a satellite assignment.
7
+ *
8
+ * Mirrors the core queue-executor's run-context. The `configName` and
9
+ * `systemName` assignment fields are optional for version-skew safety, so
10
+ * they fall back to the corresponding IDs when absent.
11
+ */
12
+ export function buildRunContext({
13
+ assignment,
14
+ }: {
15
+ assignment: SatelliteAssignment;
16
+ }): CollectorRunContext {
17
+ return {
18
+ check: {
19
+ id: assignment.configId,
20
+ name: assignment.configName ?? assignment.configId,
21
+ intervalSeconds: assignment.intervalSeconds,
22
+ },
23
+ system: {
24
+ id: assignment.systemId,
25
+ name: assignment.systemName ?? assignment.systemId,
26
+ },
27
+ };
28
+ }