@checkstack/automation-common 0.2.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 +442 -0
- package/package.json +33 -0
- package/src/access.ts +32 -0
- package/src/index.ts +8 -0
- package/src/plugin-metadata.ts +9 -0
- package/src/routes.ts +19 -0
- package/src/rpc-contract.ts +246 -0
- package/src/schemas.ts +682 -0
- package/src/shell-env.test.ts +28 -0
- package/src/shell-env.ts +33 -0
- package/src/signals.ts +58 -0
- package/src/variable-scope.test.ts +1045 -0
- package/src/variable-scope.ts +1029 -0
- package/tsconfig.json +17 -0
package/src/shell-env.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared naming rule for the run-context environment variables exposed to
|
|
3
|
+
* `run_shell` script actions.
|
|
4
|
+
*
|
|
5
|
+
* Two sides depend on this and must never drift:
|
|
6
|
+
*
|
|
7
|
+
* - the backend (`integration-script-backend`) injects `NAME=value`
|
|
8
|
+
* pairs into the shell subprocess at run time, and
|
|
9
|
+
* - the automation editor lists the available `NAME`s for `$`
|
|
10
|
+
* autocomplete.
|
|
11
|
+
*
|
|
12
|
+
* Keeping the derivation here, in the package both reach, guarantees the
|
|
13
|
+
* names the editor suggests are exactly the ones the script receives.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Prefix on every auto-injected run-context shell env var. */
|
|
17
|
+
export const SHELL_ENV_PREFIX = "CHECKSTACK_";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Derive the shell env-var name a scope path is exposed under.
|
|
21
|
+
*
|
|
22
|
+
* Rule: uppercase, collapse each run of non-alphanumeric characters to a
|
|
23
|
+
* single `_`, trim leading/trailing `_`, then prefix with `CHECKSTACK_`.
|
|
24
|
+
* So `trigger.payload.title` becomes `CHECKSTACK_TRIGGER_PAYLOAD_TITLE`
|
|
25
|
+
* and `artifact.jira.issue.key` becomes `CHECKSTACK_ARTIFACT_JIRA_ISSUE_KEY`.
|
|
26
|
+
*/
|
|
27
|
+
export function toShellEnvKey(path: string): string {
|
|
28
|
+
const normalized = path
|
|
29
|
+
.toUpperCase()
|
|
30
|
+
.replaceAll(/[^A-Z0-9]+/g, "_")
|
|
31
|
+
.replaceAll(/^_+|_+$/g, "");
|
|
32
|
+
return `${SHELL_ENV_PREFIX}${normalized}`;
|
|
33
|
+
}
|
package/src/signals.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createSignal } from "@checkstack/signal-common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { pluginMetadata } from "./plugin-metadata";
|
|
4
|
+
import { RunStatusSchema, StepStatusSchema } from "./schemas";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fired when an automation definition is created, updated, or deleted.
|
|
8
|
+
* Frontends use this to invalidate caches.
|
|
9
|
+
*/
|
|
10
|
+
export const AUTOMATION_DEFINITION_CHANGED = createSignal({
|
|
11
|
+
pluginMetadata,
|
|
12
|
+
event: "automation_definition_changed",
|
|
13
|
+
payloadSchema: z.object({
|
|
14
|
+
action: z.enum(["created", "updated", "deleted"]),
|
|
15
|
+
automationId: z.string(),
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Fired when an automation run starts.
|
|
21
|
+
*/
|
|
22
|
+
export const AUTOMATION_RUN_STARTED = createSignal({
|
|
23
|
+
pluginMetadata,
|
|
24
|
+
event: "automation_run_started",
|
|
25
|
+
payloadSchema: z.object({
|
|
26
|
+
runId: z.string(),
|
|
27
|
+
automationId: z.string(),
|
|
28
|
+
triggerId: z.string(),
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Fired when a run transitions to a terminal state.
|
|
34
|
+
*/
|
|
35
|
+
export const AUTOMATION_RUN_COMPLETED = createSignal({
|
|
36
|
+
pluginMetadata,
|
|
37
|
+
event: "automation_run_completed",
|
|
38
|
+
payloadSchema: z.object({
|
|
39
|
+
runId: z.string(),
|
|
40
|
+
automationId: z.string(),
|
|
41
|
+
status: RunStatusSchema,
|
|
42
|
+
errorMessage: z.string().optional(),
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Fired when a single action step completes — useful for the run-detail
|
|
48
|
+
* page to refresh step status live.
|
|
49
|
+
*/
|
|
50
|
+
export const AUTOMATION_RUN_STEP_COMPLETED = createSignal({
|
|
51
|
+
pluginMetadata,
|
|
52
|
+
event: "automation_run_step_completed",
|
|
53
|
+
payloadSchema: z.object({
|
|
54
|
+
runId: z.string(),
|
|
55
|
+
stepId: z.string(),
|
|
56
|
+
status: StepStatusSchema,
|
|
57
|
+
}),
|
|
58
|
+
});
|