@karmaniverous/jeeves-runner 0.4.0 → 0.5.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.
@@ -6,6 +6,7 @@ import { Cron, CronPattern } from 'croner';
6
6
  import { DatabaseSync } from 'node:sqlite';
7
7
  import { pino } from 'pino';
8
8
  import Fastify from 'fastify';
9
+ import { createConfigQueryHandler } from '@karmaniverous/jeeves';
9
10
  import { request as request$1 } from 'node:http';
10
11
  import { request } from 'node:https';
11
12
  import { spawn } from 'node:child_process';
@@ -208,13 +209,15 @@ function runMigrations(db) {
208
209
  }
209
210
 
210
211
  /**
211
- * Fastify API routes for job management and monitoring. Provides endpoints for job CRUD, run history, manual triggers, and system stats.
212
+ * Fastify API routes for job management and monitoring. Provides endpoints for job CRUD, run history, manual triggers, system stats, and config queries.
213
+ *
214
+ * @module routes
212
215
  */
213
216
  /**
214
217
  * Register all API routes on the Fastify instance.
215
218
  */
216
219
  function registerRoutes(app, deps) {
217
- const { db, scheduler } = deps;
220
+ const { db, scheduler, getConfig } = deps;
218
221
  /** GET /health — Health check. */
219
222
  app.get('/health', () => {
220
223
  return {
@@ -310,6 +313,14 @@ function registerRoutes(app, deps) {
310
313
  errorsLastHour: errorsLastHour.count,
311
314
  };
312
315
  });
316
+ /** GET /config — Query effective configuration via JSONPath. */
317
+ const configHandler = createConfigQueryHandler(getConfig);
318
+ app.get('/config', async (request, reply) => {
319
+ const result = await configHandler({
320
+ path: request.query.path,
321
+ });
322
+ return reply.status(result.status).send(result.body);
323
+ });
313
324
  }
314
325
 
315
326
  /**
@@ -334,7 +345,11 @@ function createServer(deps) {
334
345
  }
335
346
  : false,
336
347
  });
337
- registerRoutes(app, deps);
348
+ registerRoutes(app, {
349
+ db: deps.db,
350
+ scheduler: deps.scheduler,
351
+ getConfig: deps.getConfig,
352
+ });
338
353
  return app;
339
354
  }
340
355
 
@@ -1145,6 +1160,7 @@ function createRunner(config, deps) {
1145
1160
  server = createServer({
1146
1161
  db,
1147
1162
  scheduler,
1163
+ getConfig: () => config,
1148
1164
  loggerConfig: { level: config.log.level, file: config.log.file },
1149
1165
  });
1150
1166
  await server.listen({ port: config.port, host: '127.0.0.1' });
package/dist/index.d.ts CHANGED
@@ -24,11 +24,11 @@ declare const runnerConfigSchema: z.ZodObject<{
24
24
  }, z.core.$strip>>;
25
25
  log: z.ZodDefault<z.ZodObject<{
26
26
  level: z.ZodDefault<z.ZodEnum<{
27
+ error: "error";
27
28
  trace: "trace";
28
29
  debug: "debug";
29
30
  info: "info";
30
31
  warn: "warn";
31
- error: "error";
32
32
  fatal: "fatal";
33
33
  }>>;
34
34
  file: z.ZodOptional<z.ZodString>;
@@ -102,10 +102,10 @@ type Queue = z.infer<typeof queueSchema>;
102
102
 
103
103
  /** Run status enumeration schema (pending, running, ok, error, timeout, skipped). */
104
104
  declare const runStatusSchema: z.ZodEnum<{
105
- error: "error";
106
105
  pending: "pending";
107
106
  running: "running";
108
107
  ok: "ok";
108
+ error: "error";
109
109
  timeout: "timeout";
110
110
  skipped: "skipped";
111
111
  }>;
@@ -120,10 +120,10 @@ declare const runSchema: z.ZodObject<{
120
120
  id: z.ZodNumber;
121
121
  jobId: z.ZodString;
122
122
  status: z.ZodEnum<{
123
- error: "error";
124
123
  pending: "pending";
125
124
  running: "running";
126
125
  ok: "ok";
126
+ error: "error";
127
127
  timeout: "timeout";
128
128
  skipped: "skipped";
129
129
  }>;
package/dist/mjs/index.js CHANGED
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { mkdirSync, existsSync, readFileSync } from 'node:fs';
3
3
  import { pino } from 'pino';
4
4
  import Fastify from 'fastify';
5
+ import { createConfigQueryHandler } from '@karmaniverous/jeeves';
5
6
  import { dirname, extname } from 'node:path';
6
7
  import { DatabaseSync } from 'node:sqlite';
7
8
  import { request as request$1 } from 'node:http';
@@ -170,13 +171,15 @@ const runSchema = z.object({
170
171
  });
171
172
 
172
173
  /**
173
- * Fastify API routes for job management and monitoring. Provides endpoints for job CRUD, run history, manual triggers, and system stats.
174
+ * Fastify API routes for job management and monitoring. Provides endpoints for job CRUD, run history, manual triggers, system stats, and config queries.
175
+ *
176
+ * @module routes
174
177
  */
175
178
  /**
176
179
  * Register all API routes on the Fastify instance.
177
180
  */
178
181
  function registerRoutes(app, deps) {
179
- const { db, scheduler } = deps;
182
+ const { db, scheduler, getConfig } = deps;
180
183
  /** GET /health — Health check. */
181
184
  app.get('/health', () => {
182
185
  return {
@@ -272,6 +275,14 @@ function registerRoutes(app, deps) {
272
275
  errorsLastHour: errorsLastHour.count,
273
276
  };
274
277
  });
278
+ /** GET /config — Query effective configuration via JSONPath. */
279
+ const configHandler = createConfigQueryHandler(getConfig);
280
+ app.get('/config', async (request, reply) => {
281
+ const result = await configHandler({
282
+ path: request.query.path,
283
+ });
284
+ return reply.status(result.status).send(result.body);
285
+ });
275
286
  }
276
287
 
277
288
  /**
@@ -296,7 +307,11 @@ function createServer(deps) {
296
307
  }
297
308
  : false,
298
309
  });
299
- registerRoutes(app, deps);
310
+ registerRoutes(app, {
311
+ db: deps.db,
312
+ scheduler: deps.scheduler,
313
+ getConfig: deps.getConfig,
314
+ });
300
315
  return app;
301
316
  }
302
317
 
@@ -1304,6 +1319,7 @@ function createRunner(config, deps) {
1304
1319
  server = createServer({
1305
1320
  db,
1306
1321
  scheduler,
1322
+ getConfig: () => config,
1307
1323
  loggerConfig: { level: config.log.level, file: config.log.file },
1308
1324
  });
1309
1325
  await server.listen({ port: config.port, host: '127.0.0.1' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karmaniverous/jeeves-runner",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "author": "Jason Williscroft",
5
5
  "description": "Graph-aware job execution engine with SQLite state. Part of the Jeeves platform.",
6
6
  "license": "BSD-3-Clause",
@@ -46,6 +46,7 @@
46
46
  "node": ">=20"
47
47
  },
48
48
  "dependencies": {
49
+ "@karmaniverous/jeeves": "^0.2.0",
49
50
  "commander": "^14.0.3",
50
51
  "croner": "^10.0.1",
51
52
  "fastify": "^5.7.4",
@@ -75,7 +76,7 @@
75
76
  "vitest": "^4.0.18"
76
77
  },
77
78
  "scripts": {
78
- "build": "rimraf dist && cross-env NO_COLOR=1 rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
79
+ "build": "rimraf dist && cross-env NO_COLOR=1 rollup --config rollup.config.mjs",
79
80
  "changelog": "auto-changelog",
80
81
  "diagrams": "cd diagrams && plantuml -tpng -o ../assets -r .",
81
82
  "knip": "knip",
@@ -83,7 +84,7 @@
83
84
  "lint:fix": "eslint --fix .",
84
85
  "release": "dotenvx run -f .env.local -- release-it",
85
86
  "release:pre": "dotenvx run -f .env.local -- release-it --no-git.requireBranch --github.prerelease --preRelease",
86
- "test": "vitest run",
87
+ "test": "npm run build && vitest run",
87
88
  "typecheck": "tsc"
88
89
  },
89
90
  "auto-changelog": {