@hasna/uptime 0.1.8 → 0.1.10
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 +25 -3
- package/README.md +4 -4
- package/SECURITY.md +4 -2
- package/dist/api.js +104 -47
- package/dist/checks.d.ts +2 -1
- package/dist/checks.d.ts.map +1 -1
- package/dist/checks.js +2 -1
- package/dist/cli/index.js +125 -68
- package/dist/cloud-plan.d.ts +6 -6
- package/dist/cloud-plan.d.ts.map +1 -1
- package/dist/cloud-plan.js +17 -17
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +121 -64
- package/dist/mcp/index.js +92 -37
- package/dist/service.d.ts +33 -9
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +92 -37
- package/dist/store.d.ts +13 -3
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +78 -25
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/aws-deployment-runbook.md +229 -14
- package/infra/aws/README.md +12 -1
- package/infra/aws/main.tf +44 -5
- package/infra/aws/terraform.tfvars.example +9 -1
- package/infra/aws/variables.tf +48 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,28 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.10] - 2026-06-28
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Added hosted workspace scoping for monitor, result, incident, summary, and
|
|
14
|
+
report API reads/writes so hosted tokens cannot see other workspace data.
|
|
15
|
+
- Normalized and redacted probe-submitted browser evidence before persistence.
|
|
16
|
+
- Expanded the AWS deployment runbook with zero-count apply, image digest,
|
|
17
|
+
secret metadata, smoke test, logs, alarms, backup, restore drill, report gate,
|
|
18
|
+
rollback, and evidence-capture procedures.
|
|
19
|
+
- Sanitized the tracked project descriptor so deployment-specific local ids and
|
|
20
|
+
machine labels stay in private metadata rather than the public repo.
|
|
21
|
+
|
|
22
|
+
## [0.1.9] - 2026-06-28
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- AWS Terraform EFS mount targets now use stable list-index keys so deployment
|
|
27
|
+
roots can create private subnets and Open Uptime resources in one plan.
|
|
28
|
+
- AWS Terraform resources now include owner/project/environment/cost-center tags
|
|
29
|
+
and optional AWS Budgets alerts when recipients are configured.
|
|
30
|
+
|
|
9
31
|
## [0.1.8] - 2026-06-28
|
|
10
32
|
|
|
11
33
|
### Added
|
|
@@ -66,12 +88,12 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
66
88
|
- Dry-run AWS deployment plan generator for a reviewed AWS target,
|
|
67
89
|
covering ECS/Fargate services, ECR image commands, ALB/RDS/S3/Secrets/Logs
|
|
68
90
|
resources, rollback steps, and safety assertions.
|
|
69
|
-
-
|
|
91
|
+
- Private-probe hosted-targeted preflight config generator with JSON and
|
|
70
92
|
env-file rendering.
|
|
71
|
-
- CLI commands `uptime cloud plan` and `uptime cloud
|
|
93
|
+
- CLI commands `uptime cloud plan` and `uptime cloud private-probe-config`.
|
|
72
94
|
- SDK export `@hasna/uptime/cloud-plan`.
|
|
73
95
|
- Machine-readable `blocked`/`canApply:false` and `blocked`/`canStart:false`
|
|
74
|
-
gates plus blocker/evidence lists for AWS and
|
|
96
|
+
gates plus blocker/evidence lists for AWS and private-probe planning artifacts.
|
|
75
97
|
|
|
76
98
|
### Security
|
|
77
99
|
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ uptime report-schedules run-due
|
|
|
32
32
|
uptime report-schedules runs
|
|
33
33
|
uptime audit
|
|
34
34
|
uptime cloud plan --json
|
|
35
|
-
uptime cloud
|
|
35
|
+
uptime cloud private-probe-config --probe-id prb_private_01 --machine-id private-probe-01 --env
|
|
36
36
|
uptime incidents
|
|
37
37
|
uptime serve --port 3899 --check
|
|
38
38
|
```
|
|
@@ -41,7 +41,7 @@ Scheduled reports persist endpoint and recipient configuration, but not send
|
|
|
41
41
|
keys or API tokens. Configure `MAILERY_SEND_KEY`, `HASNA_MAILERY_SEND_KEY`,
|
|
42
42
|
`HASNA_LOGS_API_TOKEN`, or the matching service env vars before scheduled runs.
|
|
43
43
|
|
|
44
|
-
The `uptime cloud ...` commands generate dry-run AWS/
|
|
44
|
+
The `uptime cloud ...` commands generate dry-run AWS/private-probe planning artifacts
|
|
45
45
|
only. They do not call AWS, write secrets, or produce an approved deploy script;
|
|
46
46
|
current output is intentionally blocked until the infra and cloud-store evidence
|
|
47
47
|
in `docs/aws-deployment-runbook.md` is satisfied.
|
|
@@ -63,7 +63,7 @@ the published npm package into ECR from inside AWS.
|
|
|
63
63
|
Private/local probes can submit signed results from another machine:
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
-
uptime probes create
|
|
66
|
+
uptime probes create private-probe-01 --private-key-file ./private-probe-01.key.pem
|
|
67
67
|
uptime probes jobs create --monitor <monitor-id> --schedule-slot 2026-06-28T12:00:00Z
|
|
68
68
|
uptime probes jobs claim <job-id> --probe <probe-id>
|
|
69
69
|
uptime probes submit \
|
|
@@ -73,7 +73,7 @@ uptime probes submit \
|
|
|
73
73
|
--fencing-token <claim-fencing-token> \
|
|
74
74
|
--monitor <monitor-id> \
|
|
75
75
|
--monitor-revision <claim-monitor-revision> \
|
|
76
|
-
--private-key-file ./
|
|
76
|
+
--private-key-file ./private-probe-01.key.pem \
|
|
77
77
|
--status up
|
|
78
78
|
```
|
|
79
79
|
|
package/SECURITY.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Security Policy
|
|
2
2
|
|
|
3
3
|
Report security issues privately to the maintainers before opening a public
|
|
4
|
-
issue.
|
|
5
|
-
|
|
4
|
+
issue. Use GitHub private advisories at
|
|
5
|
+
`https://github.com/hasna/uptime/security/advisories/new` or email
|
|
6
|
+
`security@hasna.xyz`. Do not include secrets, private endpoints, or internal
|
|
7
|
+
network details in public reports.
|
|
6
8
|
|
|
7
9
|
## Defaults
|
|
8
10
|
|
package/dist/api.js
CHANGED
|
@@ -844,7 +844,7 @@ var REQUIRED_TABLES = [
|
|
|
844
844
|
];
|
|
845
845
|
var PROBE_TABLES = new Set(["probe_identities", "probe_check_jobs", "probe_submissions"]);
|
|
846
846
|
var REPORT_AUDIT_TABLES = new Set(["report_schedules", "report_runs", "audit_events"]);
|
|
847
|
-
var CURRENT_SCHEMA_VERSION = "
|
|
847
|
+
var CURRENT_SCHEMA_VERSION = "4";
|
|
848
848
|
|
|
849
849
|
class StaleCheckResultError extends Error {
|
|
850
850
|
constructor(message) {
|
|
@@ -905,7 +905,8 @@ class UptimeStore {
|
|
|
905
905
|
this.db.run(`
|
|
906
906
|
CREATE TABLE IF NOT EXISTS monitors (
|
|
907
907
|
id TEXT PRIMARY KEY,
|
|
908
|
-
|
|
908
|
+
workspace_id TEXT NOT NULL DEFAULT 'local',
|
|
909
|
+
name TEXT NOT NULL,
|
|
909
910
|
kind TEXT NOT NULL CHECK (kind IN ('http', 'tcp', 'browser_page')),
|
|
910
911
|
url TEXT,
|
|
911
912
|
host TEXT,
|
|
@@ -920,9 +921,11 @@ class UptimeStore {
|
|
|
920
921
|
last_checked_at TEXT,
|
|
921
922
|
revision INTEGER NOT NULL DEFAULT 1,
|
|
922
923
|
created_at TEXT NOT NULL,
|
|
923
|
-
updated_at TEXT NOT NULL
|
|
924
|
+
updated_at TEXT NOT NULL,
|
|
925
|
+
UNIQUE (workspace_id, name)
|
|
924
926
|
)
|
|
925
927
|
`);
|
|
928
|
+
this.ensureColumn("monitors", "workspace_id", "TEXT NOT NULL DEFAULT 'local'");
|
|
926
929
|
this.ensureColumn("monitors", "revision", "INTEGER NOT NULL DEFAULT 1");
|
|
927
930
|
this.ensureMonitorKindAllowsBrowserPage();
|
|
928
931
|
this.db.run(`
|
|
@@ -1072,6 +1075,7 @@ class UptimeStore {
|
|
|
1072
1075
|
`);
|
|
1073
1076
|
this.db.query("INSERT OR REPLACE INTO schema_migrations (key, value, updated_at) VALUES ('schema_version', ?, ?)").run(CURRENT_SCHEMA_VERSION, new Date().toISOString());
|
|
1074
1077
|
this.db.run("CREATE INDEX IF NOT EXISTS idx_results_monitor_time ON check_results(monitor_id, checked_at DESC)");
|
|
1078
|
+
this.db.run("CREATE INDEX IF NOT EXISTS idx_monitors_workspace_enabled_name ON monitors(workspace_id, enabled, name)");
|
|
1075
1079
|
this.db.run("CREATE INDEX IF NOT EXISTS idx_incidents_monitor_status ON incidents(monitor_id, status)");
|
|
1076
1080
|
this.db.run("CREATE INDEX IF NOT EXISTS idx_check_leases_until ON check_leases(leased_until)");
|
|
1077
1081
|
this.db.run("CREATE INDEX IF NOT EXISTS idx_monitor_provenance_monitor ON monitor_provenance(monitor_id)");
|
|
@@ -1133,8 +1137,10 @@ class UptimeStore {
|
|
|
1133
1137
|
if (this.mode === "hosted")
|
|
1134
1138
|
assertHostedTargetAllowed(normalized);
|
|
1135
1139
|
const now = new Date().toISOString();
|
|
1140
|
+
const workspaceId = normalizeWorkspaceId(options.workspaceId ?? input.workspaceId ?? "local");
|
|
1136
1141
|
const monitor = {
|
|
1137
1142
|
id: newId("mon"),
|
|
1143
|
+
workspaceId,
|
|
1138
1144
|
name: normalized.name,
|
|
1139
1145
|
kind: normalized.kind,
|
|
1140
1146
|
url: normalized.url ?? null,
|
|
@@ -1153,22 +1159,33 @@ class UptimeStore {
|
|
|
1153
1159
|
updatedAt: now
|
|
1154
1160
|
};
|
|
1155
1161
|
this.db.query(`INSERT INTO monitors (
|
|
1156
|
-
id, name, kind, url, host, port, method, expected_status,
|
|
1162
|
+
id, workspace_id, name, kind, url, host, port, method, expected_status,
|
|
1157
1163
|
interval_seconds, timeout_ms, retry_count, enabled, status,
|
|
1158
1164
|
last_checked_at, revision, created_at, updated_at
|
|
1159
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(monitor.id, monitor.name, monitor.kind, monitor.url, monitor.host, monitor.port, monitor.method, monitor.expectedStatus, monitor.intervalSeconds, monitor.timeoutMs, monitor.retryCount, monitor.enabled ? 1 : 0, monitor.status, monitor.lastCheckedAt, monitor.revision, monitor.createdAt, monitor.updatedAt);
|
|
1165
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(monitor.id, monitor.workspaceId, monitor.name, monitor.kind, monitor.url, monitor.host, monitor.port, monitor.method, monitor.expectedStatus, monitor.intervalSeconds, monitor.timeoutMs, monitor.retryCount, monitor.enabled ? 1 : 0, monitor.status, monitor.lastCheckedAt, monitor.revision, monitor.createdAt, monitor.updatedAt);
|
|
1160
1166
|
return monitor;
|
|
1161
1167
|
}
|
|
1162
1168
|
listMonitors(options = {}) {
|
|
1163
|
-
const
|
|
1169
|
+
const workspaceId = options.workspaceId ? normalizeWorkspaceId(options.workspaceId) : undefined;
|
|
1170
|
+
const clauses = [];
|
|
1171
|
+
const args = [];
|
|
1172
|
+
if (workspaceId) {
|
|
1173
|
+
clauses.push("workspace_id = ?");
|
|
1174
|
+
args.push(workspaceId);
|
|
1175
|
+
}
|
|
1176
|
+
if (!options.includeDisabled)
|
|
1177
|
+
clauses.push("enabled = 1");
|
|
1178
|
+
const where = clauses.length ? `WHERE ${clauses.join(" AND ")}` : "";
|
|
1179
|
+
const rows = this.db.query(`SELECT * FROM monitors ${where} ORDER BY name ASC`).all(...args);
|
|
1164
1180
|
return rows.map(monitorFromRow);
|
|
1165
1181
|
}
|
|
1166
|
-
getMonitor(idOrName) {
|
|
1167
|
-
const
|
|
1182
|
+
getMonitor(idOrName, options = {}) {
|
|
1183
|
+
const workspaceId = options.workspaceId ? normalizeWorkspaceId(options.workspaceId) : undefined;
|
|
1184
|
+
const row = this.db.query(`SELECT * FROM monitors WHERE (id = ? OR name = ?)${workspaceId ? " AND workspace_id = ?" : ""}`).get(...workspaceId ? [idOrName, idOrName, workspaceId] : [idOrName, idOrName]);
|
|
1168
1185
|
return row ? monitorFromRow(row) : null;
|
|
1169
1186
|
}
|
|
1170
1187
|
updateMonitor(idOrName, input, options = {}) {
|
|
1171
|
-
const current = this.getMonitor(idOrName);
|
|
1188
|
+
const current = this.getMonitor(idOrName, { workspaceId: options.workspaceId });
|
|
1172
1189
|
if (!current)
|
|
1173
1190
|
throw new Error(`Monitor not found: ${idOrName}`);
|
|
1174
1191
|
if (this.mode === "hosted") {
|
|
@@ -1192,10 +1209,10 @@ class UptimeStore {
|
|
|
1192
1209
|
if (definitionChanged(current, next)) {
|
|
1193
1210
|
this.closeOpenIncident(current.id, updatedAt);
|
|
1194
1211
|
}
|
|
1195
|
-
return this.getMonitor(current.id);
|
|
1212
|
+
return this.getMonitor(current.id, { workspaceId: options.workspaceId });
|
|
1196
1213
|
}
|
|
1197
|
-
deleteMonitor(idOrName) {
|
|
1198
|
-
const current = this.getMonitor(idOrName);
|
|
1214
|
+
deleteMonitor(idOrName, options = {}) {
|
|
1215
|
+
const current = this.getMonitor(idOrName, { workspaceId: options.workspaceId });
|
|
1199
1216
|
if (!current)
|
|
1200
1217
|
return false;
|
|
1201
1218
|
this.db.query("DELETE FROM monitors WHERE id = ?").run(current.id);
|
|
@@ -1572,7 +1589,20 @@ class UptimeStore {
|
|
|
1572
1589
|
}
|
|
1573
1590
|
listResults(options = {}) {
|
|
1574
1591
|
const limit = clampLimit(options.limit ?? 50);
|
|
1575
|
-
const
|
|
1592
|
+
const workspaceId = options.workspaceId ? normalizeWorkspaceId(options.workspaceId) : undefined;
|
|
1593
|
+
const clauses = [];
|
|
1594
|
+
const args = [];
|
|
1595
|
+
if (options.monitorId) {
|
|
1596
|
+
clauses.push("check_results.monitor_id = ?");
|
|
1597
|
+
args.push(options.monitorId);
|
|
1598
|
+
}
|
|
1599
|
+
if (workspaceId) {
|
|
1600
|
+
clauses.push("monitors.workspace_id = ?");
|
|
1601
|
+
args.push(workspaceId);
|
|
1602
|
+
}
|
|
1603
|
+
const where = clauses.length ? `WHERE ${clauses.join(" AND ")}` : "";
|
|
1604
|
+
args.push(limit);
|
|
1605
|
+
const rows = this.db.query(`SELECT check_results.* FROM check_results JOIN monitors ON monitors.id = check_results.monitor_id ${where} ORDER BY checked_at DESC LIMIT ?`).all(...args);
|
|
1576
1606
|
return rows.map(checkResultFromRow);
|
|
1577
1607
|
}
|
|
1578
1608
|
getProvenance(source, sourceId) {
|
|
@@ -1615,24 +1645,28 @@ class UptimeStore {
|
|
|
1615
1645
|
const clauses = [];
|
|
1616
1646
|
const args = [];
|
|
1617
1647
|
if (options.status) {
|
|
1618
|
-
clauses.push("status = ?");
|
|
1648
|
+
clauses.push("incidents.status = ?");
|
|
1619
1649
|
args.push(options.status);
|
|
1620
1650
|
}
|
|
1621
1651
|
if (options.monitorId) {
|
|
1622
|
-
clauses.push("monitor_id = ?");
|
|
1652
|
+
clauses.push("incidents.monitor_id = ?");
|
|
1623
1653
|
args.push(options.monitorId);
|
|
1624
1654
|
}
|
|
1655
|
+
if (options.workspaceId) {
|
|
1656
|
+
clauses.push("monitors.workspace_id = ?");
|
|
1657
|
+
args.push(normalizeWorkspaceId(options.workspaceId));
|
|
1658
|
+
}
|
|
1625
1659
|
const where = clauses.length ? `WHERE ${clauses.join(" AND ")}` : "";
|
|
1626
1660
|
args.push(clampLimit(options.limit ?? 50));
|
|
1627
|
-
const rows = this.db.query(`SELECT
|
|
1661
|
+
const rows = this.db.query(`SELECT incidents.* FROM incidents JOIN monitors ON monitors.id = incidents.monitor_id ${where} ORDER BY opened_at DESC LIMIT ?`).all(...args);
|
|
1628
1662
|
return rows.map(incidentFromRow);
|
|
1629
1663
|
}
|
|
1630
1664
|
getOpenIncident(monitorId) {
|
|
1631
1665
|
const row = this.db.query("SELECT * FROM incidents WHERE monitor_id = ? AND status = 'open' ORDER BY opened_at DESC LIMIT 1").get(monitorId);
|
|
1632
1666
|
return row ? incidentFromRow(row) : null;
|
|
1633
1667
|
}
|
|
1634
|
-
summary() {
|
|
1635
|
-
const monitors = this.listMonitors({ includeDisabled: true });
|
|
1668
|
+
summary(options = {}) {
|
|
1669
|
+
const monitors = this.listMonitors({ includeDisabled: true, workspaceId: options.workspaceId });
|
|
1636
1670
|
const summaries = monitors.map((monitor) => this.monitorSummary(monitor));
|
|
1637
1671
|
return {
|
|
1638
1672
|
generatedAt: new Date().toISOString(),
|
|
@@ -1644,11 +1678,15 @@ class UptimeStore {
|
|
|
1644
1678
|
down: monitors.filter((m) => m.status === "down").length,
|
|
1645
1679
|
paused: monitors.filter((m) => !m.enabled || m.status === "paused").length,
|
|
1646
1680
|
unknown: monitors.filter((m) => m.status === "unknown").length,
|
|
1647
|
-
openIncidents: this.countOpenIncidents()
|
|
1681
|
+
openIncidents: this.countOpenIncidents(options.workspaceId)
|
|
1648
1682
|
}
|
|
1649
1683
|
};
|
|
1650
1684
|
}
|
|
1651
|
-
countOpenIncidents() {
|
|
1685
|
+
countOpenIncidents(workspaceId) {
|
|
1686
|
+
if (workspaceId) {
|
|
1687
|
+
const row2 = this.db.query("SELECT COUNT(*) AS count FROM incidents JOIN monitors ON monitors.id = incidents.monitor_id WHERE incidents.status = 'open' AND monitors.workspace_id = ?").get(normalizeWorkspaceId(workspaceId));
|
|
1688
|
+
return Number(row2?.count ?? 0);
|
|
1689
|
+
}
|
|
1652
1690
|
const row = this.db.query("SELECT COUNT(*) AS count FROM incidents WHERE status = 'open'").get();
|
|
1653
1691
|
return Number(row?.count ?? 0);
|
|
1654
1692
|
}
|
|
@@ -1712,7 +1750,9 @@ class UptimeStore {
|
|
|
1712
1750
|
}
|
|
1713
1751
|
ensureMonitorKindAllowsBrowserPage() {
|
|
1714
1752
|
const row = this.db.query("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'monitors'").get();
|
|
1715
|
-
|
|
1753
|
+
const needsBrowserPage = !row?.sql?.includes("browser_page");
|
|
1754
|
+
const needsWorkspaceUnique = Boolean(row?.sql?.includes("name TEXT NOT NULL UNIQUE"));
|
|
1755
|
+
if (!row?.sql || !needsBrowserPage && !needsWorkspaceUnique)
|
|
1716
1756
|
return;
|
|
1717
1757
|
this.db.run("PRAGMA foreign_keys = OFF");
|
|
1718
1758
|
this.db.run("PRAGMA legacy_alter_table = ON");
|
|
@@ -1722,7 +1762,8 @@ class UptimeStore {
|
|
|
1722
1762
|
this.db.run(`
|
|
1723
1763
|
CREATE TABLE monitors (
|
|
1724
1764
|
id TEXT PRIMARY KEY,
|
|
1725
|
-
|
|
1765
|
+
workspace_id TEXT NOT NULL DEFAULT 'local',
|
|
1766
|
+
name TEXT NOT NULL,
|
|
1726
1767
|
kind TEXT NOT NULL CHECK (kind IN ('http', 'tcp', 'browser_page')),
|
|
1727
1768
|
url TEXT,
|
|
1728
1769
|
host TEXT,
|
|
@@ -1737,17 +1778,18 @@ class UptimeStore {
|
|
|
1737
1778
|
last_checked_at TEXT,
|
|
1738
1779
|
revision INTEGER NOT NULL DEFAULT 1,
|
|
1739
1780
|
created_at TEXT NOT NULL,
|
|
1740
|
-
updated_at TEXT NOT NULL
|
|
1781
|
+
updated_at TEXT NOT NULL,
|
|
1782
|
+
UNIQUE (workspace_id, name)
|
|
1741
1783
|
)
|
|
1742
1784
|
`);
|
|
1743
1785
|
this.db.run(`
|
|
1744
1786
|
INSERT INTO monitors (
|
|
1745
|
-
id, name, kind, url, host, port, method, expected_status,
|
|
1787
|
+
id, workspace_id, name, kind, url, host, port, method, expected_status,
|
|
1746
1788
|
interval_seconds, timeout_ms, retry_count, enabled, status,
|
|
1747
1789
|
last_checked_at, revision, created_at, updated_at
|
|
1748
1790
|
)
|
|
1749
1791
|
SELECT
|
|
1750
|
-
id, name, kind, url, host, port, method, expected_status,
|
|
1792
|
+
id, workspace_id, name, kind, url, host, port, method, expected_status,
|
|
1751
1793
|
interval_seconds, timeout_ms, retry_count, enabled, status,
|
|
1752
1794
|
last_checked_at, revision, created_at, updated_at
|
|
1753
1795
|
FROM monitors_old_kind
|
|
@@ -1947,6 +1989,16 @@ function rejectControlCharacters2(value, label) {
|
|
|
1947
1989
|
throw new Error(`${label} must not contain control characters`);
|
|
1948
1990
|
}
|
|
1949
1991
|
}
|
|
1992
|
+
function normalizeWorkspaceId(value) {
|
|
1993
|
+
const normalized = value.trim();
|
|
1994
|
+
if (!normalized)
|
|
1995
|
+
throw new Error("Workspace id is required");
|
|
1996
|
+
rejectControlCharacters2(normalized, "Workspace id");
|
|
1997
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/.test(normalized)) {
|
|
1998
|
+
throw new Error("Workspace id contains unsupported characters");
|
|
1999
|
+
}
|
|
2000
|
+
return normalized;
|
|
2001
|
+
}
|
|
1950
2002
|
function normalizeScheduleSlot(value) {
|
|
1951
2003
|
const slot = value.trim();
|
|
1952
2004
|
if (!slot)
|
|
@@ -2133,6 +2185,7 @@ function assertIsoTimestamp(value, label) {
|
|
|
2133
2185
|
function monitorFromRow(row) {
|
|
2134
2186
|
return {
|
|
2135
2187
|
id: row.id,
|
|
2188
|
+
workspaceId: row.workspace_id ?? "local",
|
|
2136
2189
|
name: row.name,
|
|
2137
2190
|
kind: row.kind,
|
|
2138
2191
|
url: row.url,
|
|
@@ -2614,20 +2667,20 @@ class UptimeService {
|
|
|
2614
2667
|
close() {
|
|
2615
2668
|
this.store.close();
|
|
2616
2669
|
}
|
|
2617
|
-
createMonitor(input) {
|
|
2618
|
-
return this.store.createMonitor(input);
|
|
2670
|
+
createMonitor(input, options = {}) {
|
|
2671
|
+
return this.store.createMonitor(input, options);
|
|
2619
2672
|
}
|
|
2620
|
-
updateMonitor(idOrName, input) {
|
|
2621
|
-
return this.store.updateMonitor(idOrName, input);
|
|
2673
|
+
updateMonitor(idOrName, input, options = {}) {
|
|
2674
|
+
return this.store.updateMonitor(idOrName, input, options);
|
|
2622
2675
|
}
|
|
2623
|
-
deleteMonitor(idOrName) {
|
|
2624
|
-
return this.store.deleteMonitor(idOrName);
|
|
2676
|
+
deleteMonitor(idOrName, options = {}) {
|
|
2677
|
+
return this.store.deleteMonitor(idOrName, options);
|
|
2625
2678
|
}
|
|
2626
2679
|
listMonitors(options = {}) {
|
|
2627
2680
|
return this.store.listMonitors(options);
|
|
2628
2681
|
}
|
|
2629
|
-
getMonitor(idOrName) {
|
|
2630
|
-
return this.store.getMonitor(idOrName);
|
|
2682
|
+
getMonitor(idOrName, options = {}) {
|
|
2683
|
+
return this.store.getMonitor(idOrName, options);
|
|
2631
2684
|
}
|
|
2632
2685
|
listResults(options = {}) {
|
|
2633
2686
|
return this.store.listResults(options);
|
|
@@ -2635,8 +2688,8 @@ class UptimeService {
|
|
|
2635
2688
|
listIncidents(options = {}) {
|
|
2636
2689
|
return this.store.listIncidents(options);
|
|
2637
2690
|
}
|
|
2638
|
-
summary() {
|
|
2639
|
-
return this.store.summary();
|
|
2691
|
+
summary(options = {}) {
|
|
2692
|
+
return this.store.summary(options);
|
|
2640
2693
|
}
|
|
2641
2694
|
createProbe(input) {
|
|
2642
2695
|
const store = this.probeStore();
|
|
@@ -2692,7 +2745,8 @@ class UptimeService {
|
|
|
2692
2745
|
return this.store.verifyBackup(backupPath);
|
|
2693
2746
|
}
|
|
2694
2747
|
buildReport(options = {}) {
|
|
2695
|
-
|
|
2748
|
+
const { workspaceId, ...reportOptions } = options;
|
|
2749
|
+
return buildUptimeReport(this.summary({ workspaceId }), reportOptions);
|
|
2696
2750
|
}
|
|
2697
2751
|
async sendReport(options = {}) {
|
|
2698
2752
|
if (this.store.mode === "hosted" && (options.email || options.sms || options.logs)) {
|
|
@@ -3016,6 +3070,7 @@ class UptimeService {
|
|
|
3016
3070
|
throw new Error("Probe job fencing token is invalid");
|
|
3017
3071
|
if (!job.leaseExpiresAt || job.leaseExpiresAt <= new Date().toISOString())
|
|
3018
3072
|
throw new Error("Probe job lease expired");
|
|
3073
|
+
const evidence = input.evidence ? normalizeBrowserEvidence(monitor.url ?? monitor.host ?? "https://example.invalid", input.evidence) : null;
|
|
3019
3074
|
const result = this.store.recordCheckResult({
|
|
3020
3075
|
monitorId: monitor.id,
|
|
3021
3076
|
checkedAt: input.checkedAt,
|
|
@@ -3023,7 +3078,7 @@ class UptimeService {
|
|
|
3023
3078
|
latencyMs: input.latencyMs,
|
|
3024
3079
|
statusCode: input.statusCode ?? null,
|
|
3025
3080
|
error: input.error ?? null,
|
|
3026
|
-
evidence
|
|
3081
|
+
evidence,
|
|
3027
3082
|
attemptCount: input.attemptCount ?? 1,
|
|
3028
3083
|
expectedMonitorRevision: input.monitorRevision
|
|
3029
3084
|
});
|
|
@@ -3568,11 +3623,11 @@ async function handleHostedRequest(service, request, url, options) {
|
|
|
3568
3623
|
}
|
|
3569
3624
|
const apiPath = `/api${url.pathname.slice("/api/v1".length)}`;
|
|
3570
3625
|
const scope = hostedScopeFor(request.method, apiPath);
|
|
3571
|
-
requireHostedActor(request, url, options, scope);
|
|
3626
|
+
const actor = requireHostedActor(request, url, options, scope);
|
|
3572
3627
|
if (["POST", "PATCH", "DELETE"].includes(request.method)) {
|
|
3573
3628
|
validateHostedMutationOrigin(request, url, options);
|
|
3574
3629
|
}
|
|
3575
|
-
return handleApiRoute(service, request, url, apiPath, options, true);
|
|
3630
|
+
return handleApiRoute(service, request, url, apiPath, options, true, actor);
|
|
3576
3631
|
}
|
|
3577
3632
|
function validateHostedMutationOrigin(request, url, options) {
|
|
3578
3633
|
const rawOrigin = request.headers.get("origin");
|
|
@@ -3587,12 +3642,12 @@ function validateHostedMutationOrigin(request, url, options) {
|
|
|
3587
3642
|
throw new ApiError("cross-origin mutation rejected", 403);
|
|
3588
3643
|
}
|
|
3589
3644
|
}
|
|
3590
|
-
async function handleApiRoute(service, request, url, apiPath, options, hosted) {
|
|
3645
|
+
async function handleApiRoute(service, request, url, apiPath, options, hosted, actor) {
|
|
3591
3646
|
if (request.method === "GET" && apiPath === "/api/summary") {
|
|
3592
|
-
return json(service.summary());
|
|
3647
|
+
return json(service.summary({ workspaceId: actor?.workspaceId }));
|
|
3593
3648
|
}
|
|
3594
3649
|
if (request.method === "GET" && apiPath === "/api/report") {
|
|
3595
|
-
return json(service.buildReport());
|
|
3650
|
+
return json(service.buildReport({ workspaceId: actor?.workspaceId }));
|
|
3596
3651
|
}
|
|
3597
3652
|
if (request.method === "POST" && apiPath === "/api/report") {
|
|
3598
3653
|
if (hosted)
|
|
@@ -3649,22 +3704,24 @@ async function handleApiRoute(service, request, url, apiPath, options, hosted) {
|
|
|
3649
3704
|
}));
|
|
3650
3705
|
}
|
|
3651
3706
|
if (request.method === "GET" && apiPath === "/api/monitors") {
|
|
3652
|
-
return json(service.listMonitors({ includeDisabled: url.searchParams.get("includeDisabled") === "true" }));
|
|
3707
|
+
return json(service.listMonitors({ includeDisabled: url.searchParams.get("includeDisabled") === "true", workspaceId: actor?.workspaceId }));
|
|
3653
3708
|
}
|
|
3654
3709
|
if (request.method === "POST" && apiPath === "/api/monitors") {
|
|
3655
|
-
return json(service.createMonitor(await jsonBody(request)), 201);
|
|
3710
|
+
return json(service.createMonitor(await jsonBody(request), { workspaceId: actor?.workspaceId }), 201);
|
|
3656
3711
|
}
|
|
3657
3712
|
if (request.method === "GET" && apiPath === "/api/incidents") {
|
|
3658
3713
|
const status = url.searchParams.get("status");
|
|
3659
3714
|
return json(service.listIncidents({
|
|
3660
3715
|
status: status === "open" || status === "closed" ? status : undefined,
|
|
3661
3716
|
monitorId: url.searchParams.get("monitorId") ?? undefined,
|
|
3717
|
+
workspaceId: actor?.workspaceId,
|
|
3662
3718
|
limit: numericParam(url, "limit", 50)
|
|
3663
3719
|
}));
|
|
3664
3720
|
}
|
|
3665
3721
|
if (request.method === "GET" && apiPath === "/api/results") {
|
|
3666
3722
|
return json(service.listResults({
|
|
3667
3723
|
monitorId: url.searchParams.get("monitorId") ?? undefined,
|
|
3724
|
+
workspaceId: actor?.workspaceId,
|
|
3668
3725
|
limit: numericParam(url, "limit", 50)
|
|
3669
3726
|
}));
|
|
3670
3727
|
}
|
|
@@ -3723,14 +3780,14 @@ async function handleApiRoute(service, request, url, apiPath, options, hosted) {
|
|
|
3723
3780
|
if (monitorMatch) {
|
|
3724
3781
|
const id = decodeURIComponent(monitorMatch[1]);
|
|
3725
3782
|
if (request.method === "GET" && !monitorMatch[2]) {
|
|
3726
|
-
const monitor = service.getMonitor(id);
|
|
3783
|
+
const monitor = service.getMonitor(id, { workspaceId: actor?.workspaceId });
|
|
3727
3784
|
return monitor ? json(monitor) : json({ error: "not found" }, 404);
|
|
3728
3785
|
}
|
|
3729
3786
|
if (request.method === "PATCH" && !monitorMatch[2]) {
|
|
3730
|
-
return json(service.updateMonitor(id, await jsonBody(request)));
|
|
3787
|
+
return json(service.updateMonitor(id, await jsonBody(request), { workspaceId: actor?.workspaceId }));
|
|
3731
3788
|
}
|
|
3732
3789
|
if (request.method === "DELETE" && !monitorMatch[2]) {
|
|
3733
|
-
return json({ deleted: service.deleteMonitor(id) });
|
|
3790
|
+
return json({ deleted: service.deleteMonitor(id, { workspaceId: actor?.workspaceId }) });
|
|
3734
3791
|
}
|
|
3735
3792
|
if (request.method === "POST" && monitorMatch[2] === "check") {
|
|
3736
3793
|
if (hosted)
|
package/dist/checks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BrowserFailedRequest, CheckAttemptResult, EvidenceArtifact, Monitor } from "./types.js";
|
|
1
|
+
import type { BrowserFailedRequest, BrowserPageEvidence, CheckAttemptResult, EvidenceArtifact, Monitor } from "./types.js";
|
|
2
2
|
export type FetchLike = (input: string, init: RequestInit) => Promise<{
|
|
3
3
|
status: number;
|
|
4
4
|
}>;
|
|
@@ -29,4 +29,5 @@ export declare function runBrowserPageCheck(monitor: Monitor, options?: {
|
|
|
29
29
|
fetch?: FetchLike;
|
|
30
30
|
runner?: BrowserPageRunner;
|
|
31
31
|
}): Promise<CheckAttemptResult>;
|
|
32
|
+
export declare function normalizeBrowserEvidence(sourceUrl: string, raw: BrowserPageRunnerResult): BrowserPageEvidence;
|
|
32
33
|
//# sourceMappingURL=checks.d.ts.map
|
package/dist/checks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../src/checks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../src/checks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE3H,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAC1F,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEvF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACxC,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IACjF,SAAS,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9E,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,SAAS,CAAC;IAAC,WAAW,CAAC,EAAE,iBAAiB,CAAA;CAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAQzJ;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,GAAE,SAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA+B9G;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsB/E;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAAO,GAC9D,OAAO,CAAC,kBAAkB,CAAC,CAqD7B;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,uBAAuB,GAAG,mBAAmB,CAkB7G"}
|