@xeplr/monitor 1.2.0 → 1.2.1
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
CHANGED
|
@@ -44,6 +44,8 @@ Each route checks its own permission (`requireApi` from `@xeplr/base-apis`) agai
|
|
|
44
44
|
| `monitor:control` | start, stop, restart, kill | Super Admin, CompanyAdmin, Admin, Editor |
|
|
45
45
|
| `monitor:manage` | add, edit, remove a watched service | Super Admin, CompanyAdmin, Admin |
|
|
46
46
|
| `monitor:audit` | the audit log | Super Admin, CompanyAdmin, Admin |
|
|
47
|
+
| `jobs:view`, `jobs:create`, `jobs:run` | the Jobs page: see, make and run backup jobs | Super Admin, CompanyAdmin, Admin, Editor, Creator (Viewer: `jobs:view` only) |
|
|
48
|
+
| `jobs:manage` | pause and resume a schedule | Super Admin, CompanyAdmin, Admin |
|
|
47
49
|
|
|
48
50
|
A route somebody's roles do not include answers 403, and the page says so.
|
|
49
51
|
|
|
@@ -183,6 +185,7 @@ npm test # at the root: the API's tests (api/test)
|
|
|
183
185
|
```
|
|
184
186
|
|
|
185
187
|
- `test/apiRoleMappings.test.cjs` — the auth catalog built from `migrations-auth`: every route `routes/monitor.js` checks has its `apis` row, every row a group, every group a role besides Super Admin, and the Monitor menu row is the key the side rail uses.
|
|
188
|
+
- `test/authMigrations.test.cjs` — the permission files run as on a fresh install, into an empty auth database, in `authMigrations()`'s order (the packages' first, then the app's): Admin gets all of jobs, Editor all but pause/resume, Viewer only sees.
|
|
186
189
|
- `test/catalog.test.cjs` — what the API registers with auth (`routes/catalog.js`) is exactly what its routers serve, listed from the real routers; every label is an `apis` row of `migrations-auth` in the route's group; the backups and jobs routers are mounted with their own catalogs.
|
|
187
190
|
- `test/systemd.test.cjs` — `lib/systemd` against a real systemd: a small unit written into `/run/systemd/system`, then read (what runs it, memory against its limit, CPU %, its processes), followed, searched, restarted, killed, stopped and started; and `deploy/control.sh` through sudo — refusing a name that is not plain, an option, another action, a second name — then starting, restarting, killing and stopping a service; and `test/host.test.cjs` — the Home page's numbers: memory the way `free` counts it, CPU use from two readings, and on Linux the same figures as `free -b` and `df` on that machine. Needs Linux with systemd and passwordless sudo — GitHub's ubuntu runners have both, so CI runs it; elsewhere it is skipped and says why.
|
|
188
191
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
-- 0011_jobs_admin_editor.sql — the backup jobs for Admin and Editor.
|
|
2
|
+
--
|
|
3
|
+
-- @xeplr/jobs' own migrations-auth grants its groups to Super Admin,
|
|
4
|
+
-- CompanyAdmin, Creator and Viewer only, so in this app Admin and Editor could
|
|
5
|
+
-- not open Jobs at all. Here:
|
|
6
|
+
-- Admin jobs:view, jobs:create, jobs:run, jobs:manage (as CompanyAdmin)
|
|
7
|
+
-- Editor jobs:view, jobs:create, jobs:run (as Creator: no pause/resume)
|
|
8
|
+
--
|
|
9
|
+
-- Granted by GROUP, so it reaches every row of the group: jobs' label rows
|
|
10
|
+
-- ('List jobs', …) and the `METHOD /path` rows the API registered from jobs'
|
|
11
|
+
-- catalog at startup (/api/jobs/…). A row registered later copies these grants
|
|
12
|
+
-- from its group. Insert-if-absent, safe to run again.
|
|
13
|
+
|
|
14
|
+
WITH grants(role, "group") AS (VALUES
|
|
15
|
+
('Admin', 'jobs:view'), ('Admin', 'jobs:create'), ('Admin', 'jobs:run'), ('Admin', 'jobs:manage'),
|
|
16
|
+
('Editor', 'jobs:view'), ('Editor', 'jobs:create'), ('Editor', 'jobs:run')
|
|
17
|
+
)
|
|
18
|
+
INSERT INTO "apisRolesMapping" (id, "roleId", "apiId", "isActive", "mtId1", "recordCreatedDate", "recordModifiedDate")
|
|
19
|
+
SELECT encode(gen_random_bytes(12), 'hex'), r.id, a.id, true, '*', now(), now()
|
|
20
|
+
FROM grants g
|
|
21
|
+
JOIN "roles" r ON r.name = g.role
|
|
22
|
+
JOIN "apis" a ON a."apiGroup" = g."group"
|
|
23
|
+
WHERE NOT EXISTS (SELECT 1 FROM "apisRolesMapping" m WHERE m."roleId" = r.id AND m."apiId" = a.id);
|
|
24
|
+
|
|
25
|
+
-- The Jobs and Job Runs menus (both jobs:view).
|
|
26
|
+
INSERT INTO "menuRolesMapping" (id, "menuId", "roleId", "isActive", "mtId1", "recordCreatedDate", "recordModifiedDate")
|
|
27
|
+
SELECT encode(gen_random_bytes(12), 'hex'), m.id, r.id, true, '*', now(), now()
|
|
28
|
+
FROM "roles" r JOIN "menus" m ON m."menuGroup" = 'jobs:view'
|
|
29
|
+
WHERE r.name IN ('Admin', 'Editor')
|
|
30
|
+
AND NOT EXISTS (SELECT 1 FROM "menuRolesMapping" x WHERE x."roleId" = r.id AND x."menuId" = m.id);
|
package/api/setup.schema.js
CHANGED
|
@@ -181,8 +181,12 @@ function packageDir(name) {
|
|
|
181
181
|
* so it always names the release that is running, whatever the env file
|
|
182
182
|
* says; the installer passes it to its migrate step the same way.
|
|
183
183
|
*/
|
|
184
|
+
// The packages' permission files first, then the app's: the app's may grant
|
|
185
|
+
// the packages' rows (migrations-auth/0011 gives jobs' groups to Admin and
|
|
186
|
+
// Editor), which only works once those rows exist. On a fresh install the
|
|
187
|
+
// other order granted nothing — the ledger runs each file once.
|
|
184
188
|
function authMigrations() {
|
|
185
|
-
return [path.join(
|
|
189
|
+
return [path.join(packageDir('@xeplr/jobs'), 'migrations-auth'), path.join(packageDir('@xeplr/backups'), 'migrations-auth'), path.join(__dirname, 'migrations-auth')];
|
|
186
190
|
}
|
|
187
191
|
|
|
188
192
|
function config(apiDir, env, opts) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xeplr/monitor",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@xeplr/monitor",
|
|
9
|
-
"version": "1.2.
|
|
9
|
+
"version": "1.2.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-s3": "^3.1168.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xeplr/monitor",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "See a server and control its systemd services from a web page: how each is doing, start / stop / restart / kill, live logs, memory, CPU, requests and errors over time, database backups to S3. A xeplr app: run `npx @xeplr/monitor` on the server to install it there.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|