@checkstack/integration-frontend 0.4.3 → 0.4.4
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/integration-frontend
|
|
2
2
|
|
|
3
|
+
## 0.4.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a06b899: Render integration provider `setupGuide` content as markdown instead of plain text. The `ProviderDocumentation` panel was wrapping `setupGuide` in a `whitespace-pre-wrap` div, so markdown syntax (headings, links, lists, bold) shipped by providers (e.g. Jira) showed up raw in the subscription dialog. Now uses `MarkdownBlock` from `@checkstack/ui` so the same formatting providers author renders correctly.
|
|
8
|
+
- a06b899: Overhaul shell + inline-script health checks with real shell semantics, real ESM execution, and upstream Node/Bun IntelliSense.
|
|
9
|
+
|
|
10
|
+
**BREAKING CHANGES**
|
|
11
|
+
|
|
12
|
+
- **Shell collector** — the `Execute Script` collector now takes a single `script` string instead of `{ command, args }`. Existing configs are auto-migrated to v2: `command` + `args` are joined with POSIX single-quote escaping into the new `script` field, so behaviour is preserved. Custom UIs that hard-coded `command`/`args` field names need to switch to `script`.
|
|
13
|
+
- **Inline collector** — scripts are now executed as real ES modules in a Bun subprocess (was: `new Function()` inside a Web Worker). The legacy `return X;` style still works (it's auto-wrapped in an async IIFE), but mixed scripts that `import` _and_ `return` at the top level need to use `export default` for their result.
|
|
14
|
+
|
|
15
|
+
**FIXES**
|
|
16
|
+
|
|
17
|
+
- Shell scripts containing pipes, redirects, `awk`, command substitution, conditionals etc. no longer fail with `ENOENT`. The collector now runs through `sh -c <script>` instead of passing the full expression as `Bun.spawn`'s argv[0]. This was the original `awk … failed with ENOENT` regression.
|
|
18
|
+
- Inline scripts can now `import { loadavg } from "node:os"` (and any other `node:*` or `bun` import). They could not before, because the executor wrapped user code inside `new Function(...)` and ran it in a Web Worker that had no Node module access; the wrapper also made top-level `import` syntactically invalid (`Unexpected token '{'`).
|
|
19
|
+
- Healthcheck editor fields no longer reset while you're editing. The page was re-running its form-state init `useEffect` on every refetch of the configuration query — and that query is invalidated on every realtime `HEALTH_CHECK_RUN_COMPLETED` signal across the platform, so in-progress edits got wiped within seconds. Replaced the naive `useEffect([existingConfig])` with a new `useInitOnceForKey` hook from `@checkstack/ui` that initialises the form only on first load per healthcheck id and ignores background refetches. The hook's decision logic is a pure function (`shouldInitForKey`) and is unit-tested in `useInitOnceForKey.test.ts`.
|
|
20
|
+
- Switching between healthcheck collectors no longer mis-applies the previous collector's tokenizer / language service to the new editor. `MultiTypeEditorField` was reusing the same React instance across collector switches (same `key="script"` in both `DynamicForm` renders) and `selectedType` was initialised from `useState` only once on first mount. After a shell→typescript switch the new collector's TS content rendered through the shell branch (no TS highlighting, no IntelliSense); the reverse direction tokenised shell content through TS and surfaced nonsense errors like `2304 "Cannot find name 'and'"` on shell comments. Now a `useEffect` re-derives `selectedType` whenever `editorTypes` changes to a set that doesn't contain the current selection.
|
|
21
|
+
- Monaco workers are now bundled locally via Vite `?worker` imports and wired up through `MonacoEnvironment.getWorker` in a new `monacoWorkers.ts` module. The default `@monaco-editor/loader` CDN path silently failed CORS on worker scripts in some browsers, leaving Monaco's TS service with only the generic `editorWorkerService` — which is enough for tokenizer-only languages like shell but breaks TypeScript's semantic features entirely. Same module configures the TS service singleton (compiler options, eager-model-sync, diagnostics-options-ignore-1108) at module load instead of inside per-editor `onMount`, so the service starts pre-configured regardless of which language opens first. Migrated from the deprecated `monaco.languages.typescript.*` path to `monaco.typescript.*` (the old path is marked `{ deprecated: true }` in monaco-editor 0.55).
|
|
22
|
+
- `defineIntegration` / `defineHealthCheck` callback parameters are now typed against the schema. Previously the virtual module declared them as `(ctx: unknown) => …`, so writing `defineIntegration(async (context) => { console.log(context.event.eventId) })` produced `'context' is of type 'unknown'. (18046)`. The result type and the shared `IntegrationScriptContext` / `HealthCheckScriptContext` interfaces are now generated together in `scriptContext.ts`, so both the function-arg form and the ambient `declare const context` reference the same schema-typed shape.
|
|
23
|
+
- The shell starter template no longer uses Linux-only `/proc/loadavg` (which fails on macOS satellites with `awk: can't open file /proc/loadavg`). It now reads the 1-minute load average via `uptime` and parses both the Linux (`load average: 0.00, 0.01, 0.05`) and macOS (`load averages: 0.45 0.55 0.65`) output formats with a portable `sed`/`awk`/`tr` pipeline.
|
|
24
|
+
- Starter-template seeding is now self-healing. `DynamicForm`'s schema-defaults `useEffect` fires AFTER child seed effects in React's child-before-parent order, so the previous one-shot seed got clobbered back to `""` by the defaults call on first mount and never re-fired. Replaced the `[]`-deps effect with a two-effect pattern: an observer that latches `hasSeededRef = true` the first time `value` is observed non-empty, and a seed effect that keeps re-installing the starter while the latch is open. Once the seed sticks the latch closes; subsequent edits and realtime refetches don't re-trigger.
|
|
25
|
+
|
|
26
|
+
**NEW**
|
|
27
|
+
|
|
28
|
+
- The Monaco editor for inline scripts now mounts the real upstream `@types/node` + `bun-types` declarations as a virtual filesystem (lazy-loaded as its own JS chunk), so IntelliSense covers the full Node/Bun stdlib, the `Bun` global, `process.env`, `Buffer`, etc. DOM types are deliberately excluded so suggestions stay focused on the backend surface. `context.config` is typed from the collector's own JSON Schema.
|
|
29
|
+
- New `healthcheckScriptContext` / `integrationScriptContext` helpers (exported from `@checkstack/ui`) build a complete editor bundle in one call: TS declarations (`context.config` / `context.event.payload` + the virtual `@checkstack/healthcheck` / `@checkstack/integration` result-type modules), starter templates per language, and the shell env-var list (with platform-injected `EVENT_ID` / `DELIVERY_ID` / `PAYLOAD_*` for integrations). Both call sites — `CollectorSection.tsx` and `CreateSubscriptionDialog.tsx` — were rewired to use them, fixing a long-standing wiring gap where IntelliSense for injected values silently never reached the editor.
|
|
30
|
+
- Inline scripts can now `import { defineHealthCheck } from "@checkstack/healthcheck"` (or `defineIntegration` for integrations) for a typed return-shape assertion. The editor catches `{ success: "yes" }` as a type error against `HealthCheckScriptResult`. The runtime is just an identity function — the collector rewrites the import to a sibling helper file in the temp dir before executing.
|
|
31
|
+
- Shell editors now autocomplete env-vars after `$` and `${`. The completion list is supplied by `healthcheckScriptContext` (safe-vars whitelist) and `integrationScriptContext` (whitelist + `EVENT_ID` etc. + `PAYLOAD_*` flattened from the event's payload schema). The matcher is pure and unit-tested in `shellEnvVarMatcher.test.ts` so regex regressions are caught locally.
|
|
32
|
+
- Empty editor fields are now seeded with a working starter template per language (inline TS uses `defineHealthCheck`, inline shell does the `awk` load-average check, integration TS shows `defineIntegration` with `context.event`, integration shell lists the `$EVENT_ID` / `$PAYLOAD_*` env vars). Users see a runnable example instead of a blank canvas; once they edit, we leave their content alone.
|
|
33
|
+
- Hardened concurrency + cleanup model documented and tested: each invocation gets its own `mkdtemp` directory + UUID result marker; the `finally` block clears the timeout handle, kills any surviving subprocess (idempotent), and removes the temp directory on success, throw, _and_ timeout. New `concurrency.test.ts` proves 20 parallel inline scripts don't cross wires and that the temp-dir count returns to baseline after throws and timeouts.
|
|
34
|
+
|
|
35
|
+
**TESTING**
|
|
36
|
+
|
|
37
|
+
Tight unit tests added so changes to the editor surface don't need smoke testing:
|
|
38
|
+
|
|
39
|
+
- `scriptContext.test.ts` — 18 tests covering the generated type declarations (including explicit regression guards for `defineIntegration` / `defineHealthCheck` callback params being typed against the shared context interface rather than `unknown`), starter templates (including a guard that the shell starter doesn't depend on Linux-only `/proc/loadavg`), shell env-vars for both healthcheck + integration flavours, plus the schema-flattening utility.
|
|
40
|
+
- `shellEnvVarMatcher.test.ts` — 12 tests covering the bare `$` / braced `${` / partial-name / case-insensitive matching logic that powers Monaco's shell completion.
|
|
41
|
+
- `inline-script-normaliser.test.ts` — 13 tests covering the legacy `return X;` → IIFE wrap path, the ESM-passthrough path, and the `@checkstack/healthcheck` import rewriter.
|
|
42
|
+
- `inline-script-collector.test.ts` — 18 tests including ones that actually execute a script importing `defineHealthCheck` (named-import form) AND using the global `defineHealthCheck` (no import) to prove both code paths resolve at runtime.
|
|
43
|
+
- `concurrency.test.ts` — 4 tests proving 20 parallel runs don't collide and that the temp-dir count returns to baseline after success, throw, and timeout.
|
|
44
|
+
- `useInitOnceForKey.test.ts` — 10 tests proving the healthcheck-editor form state isn't reset when react-query refetches in the background (the original "fields reset while I'm typing" regression).
|
|
45
|
+
- `starterTemplateSelector.test.ts` — 7 tests for the pure decision function powering empty-field seeding.
|
|
46
|
+
- `security.test.ts` — added an integration test that actually executes the portable load-average pipeline through `Bun.spawn` on the current OS, catching `/proc/loadavg`-style regressions at CI time on macOS runners.
|
|
47
|
+
|
|
48
|
+
**SECURITY**
|
|
49
|
+
|
|
50
|
+
- Same env-var whitelist as before (`PATH`, `HOME`, `USER`, `LANG`, `LC_ALL`, `LC_CTYPE`, `TZ`, `TMPDIR`, `HOSTNAME`, `SHELL`). Backend secrets in the satellite process's environment remain invisible to user scripts.
|
|
51
|
+
|
|
52
|
+
See `docs/src/content/docs/backend/script-healthchecks.md` for the full user-facing guide.
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [a06b899]
|
|
55
|
+
- @checkstack/ui@1.9.0
|
|
56
|
+
- @checkstack/tips-frontend@0.2.4
|
|
57
|
+
|
|
3
58
|
## 0.4.3
|
|
4
59
|
|
|
5
60
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/integration-frontend",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"license": "Elastic-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.tsx",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"@checkstack/frontend-api": "0.5.1",
|
|
18
18
|
"@checkstack/integration-common": "0.4.0",
|
|
19
19
|
"@checkstack/signal-frontend": "0.1.3",
|
|
20
|
-
"@checkstack/tips-frontend": "0.2.
|
|
21
|
-
"@checkstack/ui": "1.8.
|
|
20
|
+
"@checkstack/tips-frontend": "0.2.3",
|
|
21
|
+
"@checkstack/ui": "1.8.3",
|
|
22
22
|
"lucide-react": "^0.344.0",
|
|
23
23
|
"react": "^18.2.0",
|
|
24
24
|
"react-router-dom": "^6.22.0"
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
Textarea,
|
|
14
14
|
DynamicForm,
|
|
15
15
|
DynamicIcon,
|
|
16
|
+
integrationScriptContext,
|
|
17
|
+
type JsonSchemaProperty,
|
|
16
18
|
useToast,
|
|
17
19
|
Select,
|
|
18
20
|
SelectContent,
|
|
@@ -103,6 +105,21 @@ export const SubscriptionDialog = ({
|
|
|
103
105
|
const payloadProperties: PayloadProperty[] =
|
|
104
106
|
payloadSchemaData?.availableProperties ?? [];
|
|
105
107
|
|
|
108
|
+
// Build the editor IntelliSense + starter-template + shell-env-var
|
|
109
|
+
// bundle for this event. When the payload schema isn't available yet,
|
|
110
|
+
// we still get the result-shape virtual module and the platform-injected
|
|
111
|
+
// env vars (EVENT_ID, DELIVERY_ID, ...) — just no per-payload-field
|
|
112
|
+
// PAYLOAD_* hints. Recomputes only when the schema actually changes.
|
|
113
|
+
const editorScriptContext = useMemo(
|
|
114
|
+
() =>
|
|
115
|
+
integrationScriptContext({
|
|
116
|
+
eventPayloadSchema: payloadSchemaData?.payloadSchema as
|
|
117
|
+
| JsonSchemaProperty
|
|
118
|
+
| undefined,
|
|
119
|
+
}),
|
|
120
|
+
[payloadSchemaData?.payloadSchema],
|
|
121
|
+
);
|
|
122
|
+
|
|
106
123
|
// Mutations
|
|
107
124
|
const createMutation = client.createSubscription.useMutation({
|
|
108
125
|
onSuccess: (result) => {
|
|
@@ -537,6 +554,11 @@ export const SubscriptionDialog = ({
|
|
|
537
554
|
onValidChange={setProviderConfigValid}
|
|
538
555
|
optionsResolvers={optionsResolvers}
|
|
539
556
|
templateProperties={payloadProperties}
|
|
557
|
+
typeDefinitions={editorScriptContext.typeDefinitions}
|
|
558
|
+
shellEnvVars={editorScriptContext.shellEnvVars}
|
|
559
|
+
starterTemplates={
|
|
560
|
+
editorScriptContext.starterTemplates
|
|
561
|
+
}
|
|
540
562
|
/>
|
|
541
563
|
</div>
|
|
542
564
|
</div>
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
Card,
|
|
4
4
|
Button,
|
|
5
5
|
Badge,
|
|
6
|
+
MarkdownBlock,
|
|
6
7
|
Table,
|
|
7
8
|
TableBody,
|
|
8
9
|
TableCell,
|
|
@@ -70,8 +71,10 @@ export const ProviderDocumentation = ({
|
|
|
70
71
|
{documentation.setupGuide && (
|
|
71
72
|
<div>
|
|
72
73
|
<h4 className="text-sm font-medium mb-2">Setup Guide</h4>
|
|
73
|
-
<div className="bg-muted/50 p-3 rounded-md
|
|
74
|
-
|
|
74
|
+
<div className="bg-muted/50 p-3 rounded-md">
|
|
75
|
+
<MarkdownBlock size="sm">
|
|
76
|
+
{documentation.setupGuide}
|
|
77
|
+
</MarkdownBlock>
|
|
75
78
|
</div>
|
|
76
79
|
</div>
|
|
77
80
|
)}
|