@openstatus/health-trigger-dev 0.1.4-dev.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 +76 -0
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/mod.cjs +36 -0
- package/dist/mod.d.cts +23 -0
- package/dist/mod.d.cts.map +1 -0
- package/dist/mod.d.ts +23 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +34 -0
- package/dist/mod.js.map +1 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @openstatus/health-trigger-dev
|
|
2
|
+
|
|
3
|
+
[Trigger.dev](https://trigger.dev/) probe for
|
|
4
|
+
[`@openstatus/health`](https://jsr.io/@openstatus/health). Sends
|
|
5
|
+
`GET {baseUrl}/api/v1/runs?page[size]=1` to the Trigger.dev API with your
|
|
6
|
+
secret key as a bearer header, so it proves both that the API answers and
|
|
7
|
+
that the key is valid — with `fetch` alone, on every runtime.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
deno add jsr:@openstatus/health jsr:@openstatus/health-trigger-dev
|
|
11
|
+
npm install @openstatus/health @openstatus/health-trigger-dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { createHealthHandler, readEnv } from "@openstatus/health";
|
|
16
|
+
import { triggerDevProbe } from "@openstatus/health-trigger-dev";
|
|
17
|
+
|
|
18
|
+
const secretKey = readEnv("TRIGGER_SECRET_KEY");
|
|
19
|
+
|
|
20
|
+
Deno.serve(
|
|
21
|
+
createHealthHandler({
|
|
22
|
+
probes: [
|
|
23
|
+
// the factory validates `secretKey` at construction, so pass a
|
|
24
|
+
// placeholder and let `skip` keep the unconfigured check from running.
|
|
25
|
+
triggerDevProbe({
|
|
26
|
+
secretKey: secretKey || "unconfigured",
|
|
27
|
+
skip: () => !secretKey,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`secretKey` is the `TRIGGER_SECRET_KEY` of the environment you deploy to
|
|
35
|
+
(`tr_dev_…` or `tr_prod_…`). `baseUrl` defaults to `https://api.trigger.dev`
|
|
36
|
+
and takes the `TRIGGER_API_URL` of a self-hosted instance. Like every probe
|
|
37
|
+
here, this one never reads the environment itself — pass the values in, and
|
|
38
|
+
use `skip` for environments where Trigger.dev is not configured.
|
|
39
|
+
|
|
40
|
+
Listing one run is a cheap read that triggers nothing, so the probe can run
|
|
41
|
+
on every health request without side effects. It checks the API your tasks
|
|
42
|
+
are triggered through, not that a worker is online to run them.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
triggerDevProbe({
|
|
46
|
+
secretKey,
|
|
47
|
+
baseUrl: readEnv("TRIGGER_API_URL"), // self-hosted; undefined keeps the default
|
|
48
|
+
// optional overrides from the Probe contract
|
|
49
|
+
name: "jobs",
|
|
50
|
+
critical: true,
|
|
51
|
+
timeoutMs: 2000,
|
|
52
|
+
skip: () => !secretKey,
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Non-critical by default: Trigger.dev usually carries background work, so an
|
|
57
|
+
outage degrades the report instead of taking the service out of rotation.
|
|
58
|
+
Set `critical: true` when requests cannot complete without triggering a task.
|
|
59
|
+
|
|
60
|
+
## About openstatus
|
|
61
|
+
|
|
62
|
+
[openstatus](https://www.openstatus.dev/) is the open-source uptime monitoring
|
|
63
|
+
and status page platform. This package is part of
|
|
64
|
+
[`@openstatus/health`](https://github.com/openstatusHQ/health), the `/health`
|
|
65
|
+
endpoints behind openstatus's own services, extracted so any JavaScript server
|
|
66
|
+
can expose one. Point an
|
|
67
|
+
[openstatus monitor](https://www.openstatus.dev/docs/reference/http-monitor)
|
|
68
|
+
at the endpoint and assert on `status` in the body to be alerted on
|
|
69
|
+
`degraded` before it becomes `unhealthy`.
|
|
70
|
+
|
|
71
|
+
Source: [github.com/openstatusHQ/health](https://github.com/openstatusHQ/health).
|
|
72
|
+
Issues and PRs welcome.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
[MIT](https://github.com/openstatusHQ/health/blob/main/LICENSE)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, '__toESM', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return __toESM;
|
|
29
|
+
}
|
|
30
|
+
});
|
package/dist/mod.cjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const __openstatus_health = require_rolldown_runtime.__toESM(require("@openstatus/health"));
|
|
3
|
+
|
|
4
|
+
//#region src/mod.ts
|
|
5
|
+
/** API base URL when `baseUrl` is unset. */
|
|
6
|
+
const triggerDevDefaultBaseUrl = "https://api.trigger.dev";
|
|
7
|
+
/** Probe name when `name` is unset. */
|
|
8
|
+
const triggerDevDefaultName = "trigger";
|
|
9
|
+
/** A probe that expects 2xx from `GET {baseUrl}/api/v1/runs?page[size]=1` with `secretKey` as a bearer token; non-critical by default. Throws `ProbeConfigError` for an empty `secretKey` or an invalid `baseUrl`. */
|
|
10
|
+
function triggerDevProbe(options) {
|
|
11
|
+
const doFetch = options.fetch ?? globalThis.fetch;
|
|
12
|
+
const url = (0, __openstatus_health.probeUrl)({
|
|
13
|
+
probe: "triggerDevProbe",
|
|
14
|
+
field: "baseUrl",
|
|
15
|
+
value: options.baseUrl ?? triggerDevDefaultBaseUrl,
|
|
16
|
+
path: "/api/v1/runs?page[size]=1"
|
|
17
|
+
});
|
|
18
|
+
if (typeof options.secretKey !== "string" || options.secretKey.length === 0) throw new __openstatus_health.ProbeConfigError("triggerDevProbe", "secretKey", typeof options.secretKey !== "string" ? `must be a string, got ${String(options.secretKey)}` : "must not be empty");
|
|
19
|
+
const headers = { authorization: `Bearer ${options.secretKey}` };
|
|
20
|
+
return {
|
|
21
|
+
name: options.name ?? triggerDevDefaultName,
|
|
22
|
+
critical: options.critical ?? false,
|
|
23
|
+
timeoutMs: options.timeoutMs,
|
|
24
|
+
skip: options.skip,
|
|
25
|
+
run: (signal) => (0, __openstatus_health.expectOk)(doFetch(url, {
|
|
26
|
+
method: "GET",
|
|
27
|
+
headers,
|
|
28
|
+
signal
|
|
29
|
+
}))
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.triggerDevDefaultBaseUrl = triggerDevDefaultBaseUrl;
|
|
35
|
+
exports.triggerDevDefaultName = triggerDevDefaultName;
|
|
36
|
+
exports.triggerDevProbe = triggerDevProbe;
|
package/dist/mod.d.cts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Probe, ProbeOverrides } from "@openstatus/health";
|
|
2
|
+
|
|
3
|
+
//#region src/mod.d.ts
|
|
4
|
+
|
|
5
|
+
/** API base URL when `baseUrl` is unset. */
|
|
6
|
+
declare const triggerDevDefaultBaseUrl = "https://api.trigger.dev";
|
|
7
|
+
/** Probe name when `name` is unset. */
|
|
8
|
+
declare const triggerDevDefaultName = "trigger";
|
|
9
|
+
/** Options for `triggerDevProbe()`. */
|
|
10
|
+
interface TriggerDevProbeOptions extends ProbeOverrides {
|
|
11
|
+
/** The `TRIGGER_SECRET_KEY` of the environment (`tr_dev_…` / `tr_prod_…`). */
|
|
12
|
+
readonly secretKey: string;
|
|
13
|
+
/** API host. Default `triggerDevDefaultBaseUrl`. */
|
|
14
|
+
readonly baseUrl?: string | URL;
|
|
15
|
+
/** Replacement `fetch`, for tests. */
|
|
16
|
+
readonly fetch?: typeof fetch;
|
|
17
|
+
}
|
|
18
|
+
/** A probe that expects 2xx from `GET {baseUrl}/api/v1/runs?page[size]=1` with `secretKey` as a bearer token; non-critical by default. Throws `ProbeConfigError` for an empty `secretKey` or an invalid `baseUrl`. */
|
|
19
|
+
declare function triggerDevProbe(options: TriggerDevProbeOptions): Probe;
|
|
20
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
21
|
+
//#endregion
|
|
22
|
+
export { TriggerDevProbeOptions, triggerDevDefaultBaseUrl, triggerDevDefaultName, triggerDevProbe };
|
|
23
|
+
//# sourceMappingURL=mod.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAoCyC,cAf5B,wBAAA,GAe4B,yBAAA;;AAA8B,cAb1D,qBAAA,GAa0D,SAAA;;UAVtD,sBAAA,SAA+B;;;;8BAIlB;;0BAEJ;;;iBAIV,eAAA,UAAyB,yBAAyB"}
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Probe, ProbeOverrides } from "@openstatus/health";
|
|
2
|
+
|
|
3
|
+
//#region src/mod.d.ts
|
|
4
|
+
|
|
5
|
+
/** API base URL when `baseUrl` is unset. */
|
|
6
|
+
declare const triggerDevDefaultBaseUrl = "https://api.trigger.dev";
|
|
7
|
+
/** Probe name when `name` is unset. */
|
|
8
|
+
declare const triggerDevDefaultName = "trigger";
|
|
9
|
+
/** Options for `triggerDevProbe()`. */
|
|
10
|
+
interface TriggerDevProbeOptions extends ProbeOverrides {
|
|
11
|
+
/** The `TRIGGER_SECRET_KEY` of the environment (`tr_dev_…` / `tr_prod_…`). */
|
|
12
|
+
readonly secretKey: string;
|
|
13
|
+
/** API host. Default `triggerDevDefaultBaseUrl`. */
|
|
14
|
+
readonly baseUrl?: string | URL;
|
|
15
|
+
/** Replacement `fetch`, for tests. */
|
|
16
|
+
readonly fetch?: typeof fetch;
|
|
17
|
+
}
|
|
18
|
+
/** A probe that expects 2xx from `GET {baseUrl}/api/v1/runs?page[size]=1` with `secretKey` as a bearer token; non-critical by default. Throws `ProbeConfigError` for an empty `secretKey` or an invalid `baseUrl`. */
|
|
19
|
+
declare function triggerDevProbe(options: TriggerDevProbeOptions): Probe;
|
|
20
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
21
|
+
//#endregion
|
|
22
|
+
export { TriggerDevProbeOptions, triggerDevDefaultBaseUrl, triggerDevDefaultName, triggerDevProbe };
|
|
23
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAoCyC,cAf5B,wBAAA,GAe4B,yBAAA;;AAA8B,cAb1D,qBAAA,GAa0D,SAAA;;UAVtD,sBAAA,SAA+B;;;;8BAIlB;;0BAEJ;;;iBAIV,eAAA,UAAyB,yBAAyB"}
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ProbeConfigError, expectOk, probeUrl } from "@openstatus/health";
|
|
2
|
+
|
|
3
|
+
//#region src/mod.ts
|
|
4
|
+
/** API base URL when `baseUrl` is unset. */
|
|
5
|
+
const triggerDevDefaultBaseUrl = "https://api.trigger.dev";
|
|
6
|
+
/** Probe name when `name` is unset. */
|
|
7
|
+
const triggerDevDefaultName = "trigger";
|
|
8
|
+
/** A probe that expects 2xx from `GET {baseUrl}/api/v1/runs?page[size]=1` with `secretKey` as a bearer token; non-critical by default. Throws `ProbeConfigError` for an empty `secretKey` or an invalid `baseUrl`. */
|
|
9
|
+
function triggerDevProbe(options) {
|
|
10
|
+
const doFetch = options.fetch ?? globalThis.fetch;
|
|
11
|
+
const url = probeUrl({
|
|
12
|
+
probe: "triggerDevProbe",
|
|
13
|
+
field: "baseUrl",
|
|
14
|
+
value: options.baseUrl ?? triggerDevDefaultBaseUrl,
|
|
15
|
+
path: "/api/v1/runs?page[size]=1"
|
|
16
|
+
});
|
|
17
|
+
if (typeof options.secretKey !== "string" || options.secretKey.length === 0) throw new ProbeConfigError("triggerDevProbe", "secretKey", typeof options.secretKey !== "string" ? `must be a string, got ${String(options.secretKey)}` : "must not be empty");
|
|
18
|
+
const headers = { authorization: `Bearer ${options.secretKey}` };
|
|
19
|
+
return {
|
|
20
|
+
name: options.name ?? triggerDevDefaultName,
|
|
21
|
+
critical: options.critical ?? false,
|
|
22
|
+
timeoutMs: options.timeoutMs,
|
|
23
|
+
skip: options.skip,
|
|
24
|
+
run: (signal) => expectOk(doFetch(url, {
|
|
25
|
+
method: "GET",
|
|
26
|
+
headers,
|
|
27
|
+
signal
|
|
28
|
+
}))
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { triggerDevDefaultBaseUrl, triggerDevDefaultName, triggerDevProbe };
|
|
34
|
+
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","names":["options: TriggerDevProbeOptions"],"sources":["../src/mod.ts"],"sourcesContent":["/**\n * Trigger.dev reachability probe for `@openstatus/health`, against `/api/v1/runs?page[size]=1`.\n *\n * ```ts\n * import { triggerDevProbe } from \"@openstatus/health-trigger-dev\";\n *\n * const probe = triggerDevProbe({ secretKey: env.TRIGGER_SECRET_KEY });\n * ```\n *\n * @module\n */\n\nimport {\n expectOk,\n type Probe,\n ProbeConfigError,\n type ProbeOverrides,\n probeUrl,\n} from \"@openstatus/health\";\n\n/** API base URL when `baseUrl` is unset. */\nexport const triggerDevDefaultBaseUrl = \"https://api.trigger.dev\";\n/** Probe name when `name` is unset. */\nexport const triggerDevDefaultName = \"trigger\";\n\n/** Options for `triggerDevProbe()`. */\nexport interface TriggerDevProbeOptions extends ProbeOverrides {\n /** The `TRIGGER_SECRET_KEY` of the environment (`tr_dev_…` / `tr_prod_…`). */\n readonly secretKey: string;\n /** API host. Default `triggerDevDefaultBaseUrl`. */\n readonly baseUrl?: string | URL;\n /** Replacement `fetch`, for tests. */\n readonly fetch?: typeof fetch;\n}\n\n/** A probe that expects 2xx from `GET {baseUrl}/api/v1/runs?page[size]=1` with `secretKey` as a bearer token; non-critical by default. Throws `ProbeConfigError` for an empty `secretKey` or an invalid `baseUrl`. */\nexport function triggerDevProbe(options: TriggerDevProbeOptions): Probe {\n const doFetch = options.fetch ?? globalThis.fetch;\n const url = probeUrl({\n probe: \"triggerDevProbe\",\n field: \"baseUrl\",\n value: options.baseUrl ?? triggerDevDefaultBaseUrl,\n path: \"/api/v1/runs?page[size]=1\",\n });\n if (typeof options.secretKey !== \"string\" || options.secretKey.length === 0) {\n throw new ProbeConfigError(\n \"triggerDevProbe\",\n \"secretKey\",\n typeof options.secretKey !== \"string\"\n ? `must be a string, got ${String(options.secretKey)}`\n : \"must not be empty\",\n );\n }\n const headers = { authorization: `Bearer ${options.secretKey}` };\n return {\n name: options.name ?? triggerDevDefaultName,\n critical: options.critical ?? false,\n timeoutMs: options.timeoutMs,\n skip: options.skip,\n run: (signal) => expectOk(doFetch(url, { method: \"GET\", headers, signal })),\n };\n}\n"],"mappings":";;;;AAqBA,MAAa,2BAA2B;;AAExC,MAAa,wBAAwB;;AAarC,SAAgB,gBAAgBA,SAAwC;CACtE,MAAM,UAAU,QAAQ,SAAS,WAAW;CAC5C,MAAM,MAAM,SAAS;EACnB,OAAO;EACP,OAAO;EACP,OAAO,QAAQ,WAAW;EAC1B,MAAM;CACP,EAAC;AACF,YAAW,QAAQ,cAAc,YAAY,QAAQ,UAAU,WAAW,EACxE,OAAM,IAAI,iBACR,mBACA,oBACO,QAAQ,cAAc,YACxB,wBAAwB,OAAO,QAAQ,UAAU,CAAC,IACnD;CAGR,MAAM,UAAU,EAAE,gBAAgB,SAAS,QAAQ,UAAU,EAAG;AAChE,QAAO;EACL,MAAM,QAAQ,QAAQ;EACtB,UAAU,QAAQ,YAAY;EAC9B,WAAW,QAAQ;EACnB,MAAM,QAAQ;EACd,KAAK,CAAC,WAAW,SAAS,QAAQ,KAAK;GAAE,QAAQ;GAAO;GAAS;EAAQ,EAAC,CAAC;CAC5E;AACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openstatus/health-trigger-dev",
|
|
3
|
+
"version": "0.1.4-dev.0",
|
|
4
|
+
"description": "Trigger.dev probe for @openstatus/health",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"openstatus",
|
|
7
|
+
"health",
|
|
8
|
+
"healthcheck",
|
|
9
|
+
"trigger.dev",
|
|
10
|
+
"trigger",
|
|
11
|
+
"background-jobs",
|
|
12
|
+
"queue"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "openstatus",
|
|
17
|
+
"url": "https://www.openstatus.dev/"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/openstatusHQ/health",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/openstatusHQ/health.git",
|
|
23
|
+
"directory": "packages/trigger-dev/"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/openstatusHQ/health/issues"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"module": "./dist/mod.js",
|
|
30
|
+
"main": "./dist/mod.cjs",
|
|
31
|
+
"types": "./dist/mod.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": {
|
|
35
|
+
"import": "./dist/mod.d.ts",
|
|
36
|
+
"require": "./dist/mod.d.cts"
|
|
37
|
+
},
|
|
38
|
+
"import": "./dist/mod.js",
|
|
39
|
+
"require": "./dist/mod.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"files": [
|
|
45
|
+
"dist/"
|
|
46
|
+
],
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=22"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@openstatus/health": "^0.1.4-dev.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"tsdown": "^0.12.7",
|
|
55
|
+
"typescript": "^5.8.3"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsdown",
|
|
59
|
+
"prepack": "tsdown",
|
|
60
|
+
"test": "node --experimental-transform-types --test"
|
|
61
|
+
}
|
|
62
|
+
}
|