@karmaniverous/jeeves-server-core 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.
Files changed (60) hide show
  1. package/README.md +49 -12
  2. package/dist/openapi.json.js +4038 -0
  3. package/dist/scripts/openapiInfo.d.ts +15 -0
  4. package/dist/src/catalog/browserSafe.test.d.ts +4 -0
  5. package/dist/src/catalog/contentEntries.d.ts +468 -0
  6. package/dist/src/catalog/contentEntries.js +150 -0
  7. package/dist/src/catalog/contentSchemas.d.ts +179 -0
  8. package/dist/src/catalog/contentSchemas.js +195 -0
  9. package/dist/src/catalog/descriptions.d.ts +52 -0
  10. package/dist/src/catalog/descriptions.js +54 -0
  11. package/dist/src/catalog/eventEntries.d.ts +70 -0
  12. package/dist/src/catalog/eventEntries.js +59 -0
  13. package/dist/src/catalog/fileMutateSchema.d.ts +41 -0
  14. package/dist/src/catalog/fileMutateSchema.js +77 -0
  15. package/dist/src/catalog/index.d.ts +15 -0
  16. package/dist/src/catalog/index.js +10 -0
  17. package/dist/src/catalog/oauthEntries.d.ts +125 -0
  18. package/dist/src/catalog/oauthEntries.js +92 -0
  19. package/dist/src/catalog/route.d.ts +137 -0
  20. package/dist/src/catalog/route.js +92 -0
  21. package/dist/src/catalog/runnerEntries.d.ts +145 -0
  22. package/dist/src/catalog/runnerEntries.js +69 -0
  23. package/dist/src/catalog/schemas.test.d.ts +4 -0
  24. package/dist/src/catalog/serverCatalog.d.ts +1143 -0
  25. package/dist/src/catalog/serverCatalog.js +37 -0
  26. package/dist/src/catalog/serverCatalog.test.d.ts +4 -0
  27. package/dist/src/catalog/sharingEntries.d.ts +200 -0
  28. package/dist/src/catalog/sharingEntries.js +146 -0
  29. package/dist/src/catalog/statusSchemas.d.ts +87 -0
  30. package/dist/src/catalog/statusSchemas.js +119 -0
  31. package/dist/src/catalog/utilityEntries.d.ts +151 -0
  32. package/dist/src/catalog/utilityEntries.js +62 -0
  33. package/dist/src/catalog/utilitySchemas.d.ts +98 -0
  34. package/dist/src/catalog/utilitySchemas.js +131 -0
  35. package/dist/src/configAuthSchema.d.ts +100 -0
  36. package/dist/src/configAuthSchema.js +119 -0
  37. package/dist/src/configFeatureSchemas.d.ts +43 -0
  38. package/dist/src/configFeatureSchemas.js +53 -0
  39. package/dist/src/configPrintStyles.d.ts +63 -0
  40. package/dist/src/configPrintStyles.js +98 -0
  41. package/dist/src/configPrintStyles.test.d.ts +1 -0
  42. package/dist/src/crypto.d.ts +6 -13
  43. package/dist/src/crypto.js +7 -32
  44. package/dist/src/crypto.test.d.ts +7 -0
  45. package/dist/src/errors.d.ts +51 -0
  46. package/dist/src/errors.js +97 -0
  47. package/dist/src/errors.test.d.ts +4 -0
  48. package/dist/src/index.d.ts +4 -2
  49. package/dist/src/index.js +17 -3
  50. package/dist/src/openapi.d.ts +13 -0
  51. package/dist/src/openapi.js +17 -0
  52. package/dist/src/openapi.test.d.ts +4 -0
  53. package/dist/src/schema.d.ts +20 -122
  54. package/dist/src/schema.js +17 -153
  55. package/dist/src/types.d.ts +2 -0
  56. package/openapi.json +3934 -0
  57. package/package.json +26 -13
  58. package/dist/src/endpoints.d.ts +0 -34
  59. package/dist/src/endpoints.js +0 -248
  60. /package/dist/src/{endpoints.test.d.ts → configAuthSchema.test.d.ts} +0 -0
package/package.json CHANGED
@@ -1,24 +1,26 @@
1
1
  {
2
2
  "author": "Jeeves",
3
3
  "dependencies": {
4
- "@karmaniverous/jeeves": "0.7.0",
4
+ "@karmaniverous/jeeves": "^0.11.0",
5
5
  "zod": "^4.6.7"
6
6
  },
7
- "description": "Shared cryptographic utilities and API types for jeeves-server packages.",
7
+ "description": "Endpoint catalog, OpenAPI document, error codes, config schema and shared key utilities for jeeves-server packages.",
8
8
  "devDependencies": {
9
- "@dotenvx/dotenvx": "^2.35.0",
9
+ "@dotenvx/dotenvx": "^2.38.2",
10
10
  "@rollup/plugin-commonjs": "^29.0.3",
11
11
  "@rollup/plugin-json": "^6.1.0",
12
12
  "@rollup/plugin-node-resolve": "^16.0.3",
13
- "@rollup/plugin-typescript": "^12.3.0",
13
+ "@rollup/plugin-typescript": "^12.3.1",
14
+ "@seriousme/openapi-schema-validator": "^2.12.0",
14
15
  "cross-env": "^10.1.0",
15
- "release-it": "^21.1.1",
16
- "rollup": "^4.64.6",
17
- "tslib": "^2.8.1",
18
- "vitest": "^5.0.4"
16
+ "release-it": "^21.1.2",
17
+ "rollup": "^4.68.3",
18
+ "tslib": "^2.9.1",
19
+ "vitest": "^5.1.0",
20
+ "zod-openapi": "^6.0.2"
19
21
  },
20
22
  "engines": {
21
- "node": ">=22"
23
+ "node": ">=24.22.2"
22
24
  },
23
25
  "exports": {
24
26
  ".": {
@@ -26,10 +28,18 @@
26
28
  "types": "./dist/src/index.d.ts",
27
29
  "default": "./dist/src/index.js"
28
30
  }
29
- }
31
+ },
32
+ "./catalog": {
33
+ "import": {
34
+ "types": "./dist/src/catalog/index.d.ts",
35
+ "default": "./dist/src/catalog/index.js"
36
+ }
37
+ },
38
+ "./openapi.json": "./openapi.json"
30
39
  },
31
40
  "files": [
32
- "dist"
41
+ "dist",
42
+ "openapi.json"
33
43
  ],
34
44
  "license": "MIT",
35
45
  "name": "@karmaniverous/jeeves-server-core",
@@ -52,7 +62,9 @@
52
62
  "after:bump": [
53
63
  "npx git-cliff --tag core/${version} -o CHANGELOG.md",
54
64
  "npm install --package-lock-only --ignore-scripts",
55
- "git add ../../package-lock.json"
65
+ "npm run openapi",
66
+ "npm run build",
67
+ "git add ../../package-lock.json openapi.json"
56
68
  ],
57
69
  "after:init": [
58
70
  "npm run lint",
@@ -83,6 +95,7 @@
83
95
  "changelog": "git-cliff -o CHANGELOG.md",
84
96
  "lint": "eslint .",
85
97
  "lint:fix": "eslint --fix .",
98
+ "openapi": "tsx scripts/write-openapi.ts",
86
99
  "postbuild": "npx rimraf dist/rollup.config.d.ts dist/rollup.config.d.ts.map",
87
100
  "prebuild": "npx rimraf dist",
88
101
  "release": "dotenvx run -f .env.local -- release-it",
@@ -92,5 +105,5 @@
92
105
  },
93
106
  "type": "module",
94
107
  "types": "dist/src/index.d.ts",
95
- "version": "0.4.0"
108
+ "version": "0.5.0"
96
109
  }
@@ -1,34 +0,0 @@
1
- /**
2
- * Declarative endpoint catalog — single source of truth for the jeeves-server
3
- * API surface. Consumers (CLI, OpenClaw plugin) derive their registrations
4
- * from this catalog.
5
- *
6
- * @packageDocumentation
7
- */
8
- import type { z } from 'zod';
9
- /**
10
- * Describes a single API operation.
11
- */
12
- export interface EndpointEntry {
13
- /** HTTP method. */
14
- method: 'GET' | 'POST' | 'PUT' | 'DELETE';
15
- /** URL path pattern (Fastify-style, e.g. '/api/file/*'). */
16
- path: string;
17
- /** Human-readable operation description. */
18
- description: string;
19
- /** Zod schema for query params (GET) or request body (POST/PUT). */
20
- params?: z.ZodType;
21
- /** Zod schema for the response body. */
22
- response?: z.ZodType;
23
- /** Whether the endpoint requires insider auth. */
24
- insiderOnly?: boolean;
25
- /** Whether the endpoint is unauthenticated. */
26
- unauthenticated?: boolean;
27
- }
28
- /**
29
- * Complete API endpoint catalog for jeeves-server.
30
- *
31
- * Keys are stable operation identifiers used by consumers to reference
32
- * specific endpoints. Values describe the HTTP operation.
33
- */
34
- export declare const serverEndpoints: Record<string, EndpointEntry>;
@@ -1,248 +0,0 @@
1
- /**
2
- * Declarative endpoint catalog — single source of truth for the jeeves-server
3
- * API surface. Consumers (CLI, OpenClaw plugin) derive their registrations
4
- * from this catalog.
5
- *
6
- * @packageDocumentation
7
- */
8
- /**
9
- * Complete API endpoint catalog for jeeves-server.
10
- *
11
- * Keys are stable operation identifiers used by consumers to reference
12
- * specific endpoints. Values describe the HTTP operation.
13
- */
14
- const serverEndpoints = {
15
- // --- Status & Config ---
16
- status: {
17
- method: 'GET',
18
- path: '/status',
19
- description: 'Server health: name, version, uptime, status, health details.',
20
- unauthenticated: true,
21
- },
22
- health: {
23
- method: 'GET',
24
- path: '/health',
25
- description: 'Liveness check: returns { ok: true }, no downstream checks.',
26
- unauthenticated: true,
27
- },
28
- config: {
29
- method: 'GET',
30
- path: '/config',
31
- description: 'Query running config with optional JSONPath filter (?path=).',
32
- unauthenticated: true,
33
- },
34
- 'config-apply': {
35
- method: 'POST',
36
- path: '/config/apply',
37
- description: 'Push config patch to running service (deep-merge + validate + reload).',
38
- insiderOnly: true,
39
- },
40
- // --- Authentication ---
41
- 'auth-status': {
42
- method: 'GET',
43
- path: '/api/auth/status',
44
- description: 'Check current authentication status (no auth required).',
45
- unauthenticated: true,
46
- },
47
- 'auth-login': {
48
- method: 'GET',
49
- path: '/auth/login',
50
- description: 'Redirect to Google OAuth consent screen.',
51
- unauthenticated: true,
52
- },
53
- 'auth-callback': {
54
- method: 'GET',
55
- path: '/auth/callback',
56
- description: 'Handle Google OAuth callback, set session cookie.',
57
- unauthenticated: true,
58
- },
59
- 'auth-logout': {
60
- method: 'GET',
61
- path: '/auth/logout',
62
- description: 'Clear session cookie.',
63
- unauthenticated: true,
64
- },
65
- // --- File Browser ---
66
- drives: {
67
- method: 'GET',
68
- path: '/api/drives',
69
- description: 'List available root drives/labels configured on the server.',
70
- },
71
- path: {
72
- method: 'GET',
73
- path: '/api/path/*',
74
- description: 'Get directory listing for a path.',
75
- },
76
- 'file-get': {
77
- method: 'GET',
78
- path: '/api/file/*',
79
- description: 'Get file content with type-specific handling (markdown, csv, diagrams, etc.).',
80
- },
81
- 'file-put': {
82
- method: 'PUT',
83
- path: '/api/file/*',
84
- description: 'Overwrite file content (insider-only; file must already exist).',
85
- insiderOnly: true,
86
- },
87
- 'file-mutate': {
88
- method: 'POST',
89
- path: '/api/file/*',
90
- description: 'Apply structured .md mutations: edit-block, delete-block, insert-block, edit-cell, toggle-checkbox.',
91
- insiderOnly: true,
92
- },
93
- raw: {
94
- method: 'GET',
95
- path: '/api/raw/*',
96
- description: 'Direct file download with appropriate content type.',
97
- },
98
- // --- Export ---
99
- export: {
100
- method: 'GET',
101
- path: '/api/export/*',
102
- description: 'Trigger export (PDF, DOCX, ZIP) and return download.',
103
- },
104
- 'export-cache-clear': {
105
- method: 'DELETE',
106
- path: '/api/export-cache/*',
107
- description: 'Clear export and diagram caches for a given path.',
108
- insiderOnly: true,
109
- },
110
- 'mermaid-export': {
111
- method: 'GET',
112
- path: '/api/mermaid-export/*',
113
- description: 'Export Mermaid diagram (svg, png, pdf).',
114
- },
115
- 'plantuml-export': {
116
- method: 'GET',
117
- path: '/api/plantuml-export/*',
118
- description: 'Export PlantUML diagram (svg, png, pdf, eps).',
119
- },
120
- // --- Diagrams ---
121
- diagram: {
122
- method: 'GET',
123
- path: '/api/diagram/:type/:hash',
124
- description: 'Fetch rendered diagram by type and content hash.',
125
- unauthenticated: true,
126
- },
127
- // --- Sharing ---
128
- share: {
129
- method: 'POST',
130
- path: '/api/share',
131
- description: 'Generate HMAC-signed share link for a path; the response reports whether the path is a directory (isDirectory).',
132
- insiderOnly: true,
133
- },
134
- 'share-for': {
135
- method: 'POST',
136
- path: '/api/util/share-for',
137
- description: 'Generate share link targeting specific insiders with configurable expiry/depth.',
138
- insiderOnly: true,
139
- },
140
- 'readme-link': {
141
- method: 'GET',
142
- path: '/api/readme-link',
143
- description: 'Pre-computed share link for the first README.md in the directory hierarchy.',
144
- unauthenticated: true,
145
- },
146
- 'content-link': {
147
- method: 'GET',
148
- path: '/api/content-link/:file',
149
- description: 'Pre-computed deep share URL for pinned content files (privacy, terms).',
150
- unauthenticated: true,
151
- },
152
- 'link-info': {
153
- method: 'GET',
154
- path: '/api/link-info/*',
155
- description: 'Query available link types for a path (page, raw, PDF, DOCX, etc.).',
156
- },
157
- 'resolve-path': {
158
- method: 'GET',
159
- path: '/api/resolve-path',
160
- description: 'Map an absolute filesystem path to its browse path and URLs (?fsPath=).',
161
- insiderOnly: true,
162
- },
163
- 'rotate-key': {
164
- method: 'POST',
165
- path: '/api/rotate-key',
166
- description: 'Rotate the authenticated insider API key (invalidates all existing share links).',
167
- insiderOnly: true,
168
- },
169
- // --- Events ---
170
- event: {
171
- method: 'POST',
172
- path: '/event',
173
- description: 'Event gateway webhook receiver (scoped key auth).',
174
- },
175
- events: {
176
- method: 'GET',
177
- path: '/api/events',
178
- description: 'Query recent event log entries (insiders with no scopes configured; limit capped at 100).',
179
- insiderOnly: true,
180
- },
181
- // --- Search ---
182
- search: {
183
- method: 'POST',
184
- path: '/api/search',
185
- description: 'Semantic search (proxied to watcher).',
186
- },
187
- 'search-facets': {
188
- method: 'GET',
189
- path: '/api/search/facets',
190
- description: 'Search facet metadata (proxied to watcher).',
191
- },
192
- // --- Runner ---
193
- runner: {
194
- method: 'GET',
195
- path: '/api/runner/*',
196
- description: 'Runner API proxy (proxied to jeeves-runner).',
197
- },
198
- // --- OAuth ---
199
- 'oauth-start': {
200
- method: 'POST',
201
- path: '/api/oauth/start',
202
- description: 'Initiate OAuth2 authorization code flow.',
203
- insiderOnly: true,
204
- },
205
- 'oauth-status': {
206
- method: 'GET',
207
- path: '/api/oauth/status',
208
- description: 'Check if valid OAuth2 credentials exist for a provider/account.',
209
- insiderOnly: true,
210
- },
211
- 'oauth-token': {
212
- method: 'GET',
213
- path: '/api/oauth/token',
214
- description: 'Retrieve valid access token (with lazy refresh).',
215
- insiderOnly: true,
216
- },
217
- 'oauth-callback': {
218
- method: 'GET',
219
- path: '/oauth/callback',
220
- description: 'OAuth2 callback (browser redirect target, unauthenticated).',
221
- unauthenticated: true,
222
- },
223
- // --- Keys ---
224
- 'insider-key': {
225
- method: 'GET',
226
- path: '/insider-key',
227
- description: 'Get insider key for the authenticated user.',
228
- },
229
- key: {
230
- method: 'GET',
231
- path: '/key',
232
- description: 'Compute path-specific key.',
233
- },
234
- 'share-legacy': {
235
- method: 'GET',
236
- path: '/share',
237
- description: 'Generate outsider share link (top-level legacy route).',
238
- },
239
- // --- Shortlinks ---
240
- go: {
241
- method: 'GET',
242
- path: '/go/:slug',
243
- description: 'Shortlink redirect (unauthenticated).',
244
- unauthenticated: true,
245
- },
246
- };
247
-
248
- export { serverEndpoints };