@karmaniverous/jeeves-watcher 0.11.1 → 0.13.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.
@@ -15,7 +15,7 @@ import addFormats from 'ajv-formats';
15
15
  import chokidar from 'chokidar';
16
16
  import Fastify from 'fastify';
17
17
  import { jsonMapMapSchema, JsonMap } from '@karmaniverous/jsonmap';
18
- import { JSONPath } from 'jsonpath-plus';
18
+ import { createConfigQueryHandler as createConfigQueryHandler$1 } from '@karmaniverous/jeeves';
19
19
  import Handlebars from 'handlebars';
20
20
  import dayjs from 'dayjs';
21
21
  import { toMdast } from 'hast-util-to-mdast';
@@ -2261,36 +2261,40 @@ function resolveReferences(doc, resolveTypes) {
2261
2261
  * @module api/handlers/configQuery
2262
2262
  * Fastify route handler for GET /config. Returns the full resolved merged document,
2263
2263
  * optionally filtered by JSONPath via the `path` query parameter.
2264
+ *
2265
+ * Delegates JSON querying to `createConfigQueryHandler` from `@karmaniverous/jeeves` core.
2264
2266
  */
2265
2267
  /**
2266
2268
  * Create handler for GET /config.
2267
2269
  *
2268
- * Uses direct error handling (returns 400) rather than wrapHandler (which returns 500),
2269
- * because invalid JSONPath expressions are client errors, not server errors.
2270
+ * Uses `createConfigQueryHandler` from core to handle JSONPath querying.
2271
+ * Invalid JSONPath expressions are client errors and return 400.
2270
2272
  *
2271
2273
  * @param deps - Route dependencies.
2272
2274
  */
2273
2275
  function createConfigQueryHandler(deps) {
2276
+ const coreHandler = createConfigQueryHandler$1(() => buildMergedDocument({
2277
+ config: deps.config,
2278
+ valuesManager: deps.valuesManager,
2279
+ issuesManager: deps.issuesManager,
2280
+ helperIntrospection: deps.helperIntrospection,
2281
+ virtualRules: deps.getVirtualRules?.(),
2282
+ }));
2274
2283
  return async (request, reply) => {
2275
2284
  try {
2276
2285
  const { path } = request.query;
2277
- const doc = buildMergedDocument({
2278
- config: deps.config,
2279
- valuesManager: deps.valuesManager,
2280
- issuesManager: deps.issuesManager,
2281
- helperIntrospection: deps.helperIntrospection,
2282
- virtualRules: deps.getVirtualRules?.(),
2283
- });
2284
- if (!path) {
2285
- return doc;
2286
+ const result = await coreHandler({ path });
2287
+ if (result.status >= 400) {
2288
+ return await reply.status(result.status).send(result.body);
2286
2289
  }
2287
- const result = JSONPath({ path, json: doc });
2288
- return { result, count: result.length };
2290
+ return result.body;
2289
2291
  }
2290
2292
  catch (error) {
2291
2293
  const err = normalizeError(error);
2292
2294
  deps.logger.error({ err }, 'Config query failed');
2293
- return reply.status(400).send({ error: err.message || 'Query failed' });
2295
+ return await reply.status(400).send({
2296
+ error: err.message || 'Query failed',
2297
+ });
2294
2298
  }
2295
2299
  };
2296
2300
  }
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { z, ZodError } from 'zod';
9
9
  import { jsonMapMapSchema, JsonMap } from '@karmaniverous/jsonmap';
10
10
  import Ajv from 'ajv';
11
11
  import addFormats from 'ajv-formats';
12
- import { JSONPath } from 'jsonpath-plus';
12
+ import { createConfigQueryHandler as createConfigQueryHandler$1 } from '@karmaniverous/jeeves';
13
13
  import { pathToFileURL, fileURLToPath } from 'node:url';
14
14
  import Handlebars from 'handlebars';
15
15
  import dayjs from 'dayjs';
@@ -1883,36 +1883,40 @@ function resolveReferences(doc, resolveTypes) {
1883
1883
  * @module api/handlers/configQuery
1884
1884
  * Fastify route handler for GET /config. Returns the full resolved merged document,
1885
1885
  * optionally filtered by JSONPath via the `path` query parameter.
1886
+ *
1887
+ * Delegates JSON querying to `createConfigQueryHandler` from `@karmaniverous/jeeves` core.
1886
1888
  */
1887
1889
  /**
1888
1890
  * Create handler for GET /config.
1889
1891
  *
1890
- * Uses direct error handling (returns 400) rather than wrapHandler (which returns 500),
1891
- * because invalid JSONPath expressions are client errors, not server errors.
1892
+ * Uses `createConfigQueryHandler` from core to handle JSONPath querying.
1893
+ * Invalid JSONPath expressions are client errors and return 400.
1892
1894
  *
1893
1895
  * @param deps - Route dependencies.
1894
1896
  */
1895
1897
  function createConfigQueryHandler(deps) {
1898
+ const coreHandler = createConfigQueryHandler$1(() => buildMergedDocument({
1899
+ config: deps.config,
1900
+ valuesManager: deps.valuesManager,
1901
+ issuesManager: deps.issuesManager,
1902
+ helperIntrospection: deps.helperIntrospection,
1903
+ virtualRules: deps.getVirtualRules?.(),
1904
+ }));
1896
1905
  return async (request, reply) => {
1897
1906
  try {
1898
1907
  const { path } = request.query;
1899
- const doc = buildMergedDocument({
1900
- config: deps.config,
1901
- valuesManager: deps.valuesManager,
1902
- issuesManager: deps.issuesManager,
1903
- helperIntrospection: deps.helperIntrospection,
1904
- virtualRules: deps.getVirtualRules?.(),
1905
- });
1906
- if (!path) {
1907
- return doc;
1908
+ const result = await coreHandler({ path });
1909
+ if (result.status >= 400) {
1910
+ return await reply.status(result.status).send(result.body);
1908
1911
  }
1909
- const result = JSONPath({ path, json: doc });
1910
- return { result, count: result.length };
1912
+ return result.body;
1911
1913
  }
1912
1914
  catch (error) {
1913
1915
  const err = normalizeError(error);
1914
1916
  deps.logger.error({ err }, 'Config query failed');
1915
- return reply.status(400).send({ error: err.message || 'Query failed' });
1917
+ return await reply.status(400).send({
1918
+ error: err.message || 'Query failed',
1919
+ });
1916
1920
  }
1917
1921
  };
1918
1922
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karmaniverous/jeeves-watcher",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "author": "Jason Williscroft",
5
5
  "description": "Filesystem watcher that keeps a Qdrant vector store in sync with document changes",
6
6
  "license": "BSD-3-Clause",
@@ -51,6 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@commander-js/extra-typings": "^14.0.0",
54
+ "@karmaniverous/jeeves": "^0.3.0",
54
55
  "@karmaniverous/jsonmap": "^2.1.1",
55
56
  "@langchain/textsplitters": "*",
56
57
  "@qdrant/js-client-rest": "*",
@@ -66,7 +67,6 @@
66
67
  "hast-util-to-mdast": "^10.1.2",
67
68
  "ignore": "^7.0.5",
68
69
  "js-yaml": "*",
69
- "jsonpath-plus": "^10.4.0",
70
70
  "mammoth": "^1.11.0",
71
71
  "mdast-util-from-adf": "^2.2.0",
72
72
  "mdast-util-to-markdown": "^2.1.2",