@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.
- package/README.md +49 -12
- package/dist/openapi.json.js +4038 -0
- package/dist/scripts/openapiInfo.d.ts +15 -0
- package/dist/src/catalog/browserSafe.test.d.ts +4 -0
- package/dist/src/catalog/contentEntries.d.ts +468 -0
- package/dist/src/catalog/contentEntries.js +150 -0
- package/dist/src/catalog/contentSchemas.d.ts +179 -0
- package/dist/src/catalog/contentSchemas.js +195 -0
- package/dist/src/catalog/descriptions.d.ts +52 -0
- package/dist/src/catalog/descriptions.js +54 -0
- package/dist/src/catalog/eventEntries.d.ts +70 -0
- package/dist/src/catalog/eventEntries.js +59 -0
- package/dist/src/catalog/fileMutateSchema.d.ts +41 -0
- package/dist/src/catalog/fileMutateSchema.js +77 -0
- package/dist/src/catalog/index.d.ts +15 -0
- package/dist/src/catalog/index.js +10 -0
- package/dist/src/catalog/oauthEntries.d.ts +125 -0
- package/dist/src/catalog/oauthEntries.js +92 -0
- package/dist/src/catalog/route.d.ts +137 -0
- package/dist/src/catalog/route.js +92 -0
- package/dist/src/catalog/runnerEntries.d.ts +145 -0
- package/dist/src/catalog/runnerEntries.js +69 -0
- package/dist/src/catalog/schemas.test.d.ts +4 -0
- package/dist/src/catalog/serverCatalog.d.ts +1143 -0
- package/dist/src/catalog/serverCatalog.js +37 -0
- package/dist/src/catalog/serverCatalog.test.d.ts +4 -0
- package/dist/src/catalog/sharingEntries.d.ts +200 -0
- package/dist/src/catalog/sharingEntries.js +146 -0
- package/dist/src/catalog/statusSchemas.d.ts +87 -0
- package/dist/src/catalog/statusSchemas.js +119 -0
- package/dist/src/catalog/utilityEntries.d.ts +151 -0
- package/dist/src/catalog/utilityEntries.js +62 -0
- package/dist/src/catalog/utilitySchemas.d.ts +98 -0
- package/dist/src/catalog/utilitySchemas.js +131 -0
- package/dist/src/configAuthSchema.d.ts +100 -0
- package/dist/src/configAuthSchema.js +119 -0
- package/dist/src/configFeatureSchemas.d.ts +43 -0
- package/dist/src/configFeatureSchemas.js +53 -0
- package/dist/src/configPrintStyles.d.ts +63 -0
- package/dist/src/configPrintStyles.js +98 -0
- package/dist/src/configPrintStyles.test.d.ts +1 -0
- package/dist/src/crypto.d.ts +6 -13
- package/dist/src/crypto.js +7 -32
- package/dist/src/crypto.test.d.ts +7 -0
- package/dist/src/errors.d.ts +51 -0
- package/dist/src/errors.js +97 -0
- package/dist/src/errors.test.d.ts +4 -0
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.js +17 -3
- package/dist/src/openapi.d.ts +13 -0
- package/dist/src/openapi.js +17 -0
- package/dist/src/openapi.test.d.ts +4 -0
- package/dist/src/schema.d.ts +20 -122
- package/dist/src/schema.js +17 -153
- package/dist/src/types.d.ts +2 -0
- package/openapi.json +3934 -0
- package/package.json +26 -13
- package/dist/src/endpoints.d.ts +0 -34
- package/dist/src/endpoints.js +0 -248
- /package/dist/src/{endpoints.test.d.ts → configAuthSchema.test.d.ts} +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The utility entries of the server catalog: the liveness probe, auth status and magic link, the machine-key exchange routes and search. Pure.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/** The utility entries. */
|
|
8
|
+
export declare const UTILITY_ENTRIES: readonly [{
|
|
9
|
+
readonly response: z.ZodObject<{
|
|
10
|
+
ok: z.ZodLiteral<true>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
readonly auth: "none";
|
|
13
|
+
readonly kind: "read";
|
|
14
|
+
readonly name: "health";
|
|
15
|
+
readonly method: "GET";
|
|
16
|
+
readonly path: "/health";
|
|
17
|
+
readonly description: "Liveness check: returns { ok: true }, with no downstream checks.";
|
|
18
|
+
}, {
|
|
19
|
+
readonly query: z.ZodObject<{
|
|
20
|
+
exp: z.ZodOptional<z.ZodString>;
|
|
21
|
+
d: z.ZodOptional<z.ZodString>;
|
|
22
|
+
dirs: z.ZodOptional<z.ZodString>;
|
|
23
|
+
s: z.ZodOptional<z.ZodString>;
|
|
24
|
+
key: z.ZodOptional<z.ZodString>;
|
|
25
|
+
path: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
readonly response: z.ZodObject<{
|
|
28
|
+
authenticated: z.ZodBoolean;
|
|
29
|
+
email: z.ZodOptional<z.ZodString>;
|
|
30
|
+
picture: z.ZodOptional<z.ZodString>;
|
|
31
|
+
isInsider: z.ZodBoolean;
|
|
32
|
+
keyCreatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
searchEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
readonly auth: "none";
|
|
36
|
+
readonly kind: "read";
|
|
37
|
+
readonly name: "authStatus";
|
|
38
|
+
readonly method: "GET";
|
|
39
|
+
readonly path: "/api/auth/status";
|
|
40
|
+
readonly description: "Check current authentication status. Returns whether authenticated, email, insider status, and key metadata.";
|
|
41
|
+
}, {
|
|
42
|
+
readonly body: z.ZodObject<{
|
|
43
|
+
email: z.ZodOptional<z.ZodString>;
|
|
44
|
+
returnTo: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
readonly response: z.ZodObject<{
|
|
47
|
+
verifyUrl: z.ZodString;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
readonly auth: "none";
|
|
50
|
+
readonly kind: "write";
|
|
51
|
+
readonly name: "sendMagicLink";
|
|
52
|
+
readonly method: "POST";
|
|
53
|
+
readonly path: "/api/auth/magic";
|
|
54
|
+
readonly description: "Request a sign-in link by email. Always answers with a verification URL, whether or not the email belongs to an insider.";
|
|
55
|
+
}, {
|
|
56
|
+
readonly query: z.ZodObject<{
|
|
57
|
+
path: z.ZodString;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
readonly response: z.ZodObject<{
|
|
60
|
+
path: z.ZodString;
|
|
61
|
+
key: z.ZodString;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
readonly auth: {
|
|
64
|
+
readonly schemes: readonly [{
|
|
65
|
+
readonly in: "header";
|
|
66
|
+
readonly name: "X-API-Key";
|
|
67
|
+
}];
|
|
68
|
+
};
|
|
69
|
+
readonly kind: "read";
|
|
70
|
+
readonly name: "pathKey";
|
|
71
|
+
readonly method: "GET";
|
|
72
|
+
readonly path: "/key";
|
|
73
|
+
readonly description: "Compute the outsider path key for a path from the machine seed sent in X-API-Key.";
|
|
74
|
+
}, {
|
|
75
|
+
readonly response: z.ZodObject<{
|
|
76
|
+
key: z.ZodString;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
readonly auth: {
|
|
79
|
+
readonly schemes: readonly [{
|
|
80
|
+
readonly in: "header";
|
|
81
|
+
readonly name: "X-API-Key";
|
|
82
|
+
}];
|
|
83
|
+
};
|
|
84
|
+
readonly kind: "read";
|
|
85
|
+
readonly name: "insiderKey";
|
|
86
|
+
readonly method: "GET";
|
|
87
|
+
readonly path: "/insider-key";
|
|
88
|
+
readonly description: "Compute the insider key for the machine seed sent in X-API-Key.";
|
|
89
|
+
}, {
|
|
90
|
+
readonly body: z.ZodObject<{
|
|
91
|
+
query: z.ZodString;
|
|
92
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
readonly response: z.ZodObject<{
|
|
96
|
+
results: z.ZodArray<z.ZodObject<{
|
|
97
|
+
filePath: z.ZodString;
|
|
98
|
+
browsePath: z.ZodString;
|
|
99
|
+
fileName: z.ZodString;
|
|
100
|
+
bestScore: z.ZodNumber;
|
|
101
|
+
domains: z.ZodArray<z.ZodUnknown>;
|
|
102
|
+
title: z.ZodOptional<z.ZodUnknown>;
|
|
103
|
+
author: z.ZodOptional<z.ZodUnknown>;
|
|
104
|
+
participants: z.ZodOptional<z.ZodUnknown>;
|
|
105
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
106
|
+
chunks: z.ZodArray<z.ZodObject<{
|
|
107
|
+
text: z.ZodString;
|
|
108
|
+
index: z.ZodNumber;
|
|
109
|
+
score: z.ZodNumber;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
mtime: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strip>>;
|
|
113
|
+
metadata: z.ZodObject<{
|
|
114
|
+
domains: z.ZodArray<z.ZodUnknown>;
|
|
115
|
+
authors: z.ZodArray<z.ZodUnknown>;
|
|
116
|
+
participants: z.ZodArray<z.ZodUnknown>;
|
|
117
|
+
}, z.core.$strip>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
readonly auth: {
|
|
120
|
+
readonly schemes: readonly [{
|
|
121
|
+
readonly in: "query";
|
|
122
|
+
readonly name: "k";
|
|
123
|
+
}, {
|
|
124
|
+
readonly in: "cookie";
|
|
125
|
+
readonly name: "jeeves_session";
|
|
126
|
+
}];
|
|
127
|
+
readonly insiderOnly: true;
|
|
128
|
+
};
|
|
129
|
+
readonly kind: "read";
|
|
130
|
+
readonly name: "search";
|
|
131
|
+
readonly method: "POST";
|
|
132
|
+
readonly path: "/api/search";
|
|
133
|
+
readonly description: "Semantic search through jeeves-watcher, grouped by file and filtered to the scopes of the caller.";
|
|
134
|
+
}, {
|
|
135
|
+
readonly response: z.ZodUnknown;
|
|
136
|
+
readonly auth: {
|
|
137
|
+
readonly schemes: readonly [{
|
|
138
|
+
readonly in: "query";
|
|
139
|
+
readonly name: "k";
|
|
140
|
+
}, {
|
|
141
|
+
readonly in: "cookie";
|
|
142
|
+
readonly name: "jeeves_session";
|
|
143
|
+
}];
|
|
144
|
+
readonly insiderOnly: true;
|
|
145
|
+
};
|
|
146
|
+
readonly kind: "read";
|
|
147
|
+
readonly name: "searchFacets";
|
|
148
|
+
readonly method: "GET";
|
|
149
|
+
readonly path: "/api/search/facets";
|
|
150
|
+
readonly description: "Search facets from jeeves-watcher, passed through unchanged.";
|
|
151
|
+
}];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PUBLIC, MACHINE_SEED, INSIDER_ONLY, route } from './route.js';
|
|
3
|
+
import { healthResponseSchema, authStatusResponseSchema, authStatusQuerySchema, sendMagicLinkResponseSchema, sendMagicLinkBodySchema, pathKeyResponseSchema, insiderKeyResponseSchema, searchResponseSchema, searchBodySchema } from './utilitySchemas.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The utility entries of the server catalog: the liveness probe, auth status and magic link, the machine-key exchange routes and search. Pure.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
/** The utility entries. */
|
|
11
|
+
const UTILITY_ENTRIES = [
|
|
12
|
+
{
|
|
13
|
+
...route('health', 'GET', '/health'),
|
|
14
|
+
response: healthResponseSchema,
|
|
15
|
+
auth: PUBLIC,
|
|
16
|
+
kind: 'read',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
...route('authStatus', 'GET', '/api/auth/status'),
|
|
20
|
+
query: authStatusQuerySchema,
|
|
21
|
+
response: authStatusResponseSchema,
|
|
22
|
+
auth: PUBLIC,
|
|
23
|
+
kind: 'read',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
...route('sendMagicLink', 'POST', '/api/auth/magic'),
|
|
27
|
+
body: sendMagicLinkBodySchema,
|
|
28
|
+
response: sendMagicLinkResponseSchema,
|
|
29
|
+
auth: PUBLIC,
|
|
30
|
+
kind: 'write',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
...route('pathKey', 'GET', '/key'),
|
|
34
|
+
query: z.object({
|
|
35
|
+
path: z.string().describe('Path to compute the outsider key for.'),
|
|
36
|
+
}),
|
|
37
|
+
response: pathKeyResponseSchema,
|
|
38
|
+
auth: MACHINE_SEED,
|
|
39
|
+
kind: 'read',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
...route('insiderKey', 'GET', '/insider-key'),
|
|
43
|
+
response: insiderKeyResponseSchema,
|
|
44
|
+
auth: MACHINE_SEED,
|
|
45
|
+
kind: 'read',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
...route('search', 'POST', '/api/search'),
|
|
49
|
+
body: searchBodySchema,
|
|
50
|
+
response: searchResponseSchema,
|
|
51
|
+
auth: INSIDER_ONLY,
|
|
52
|
+
kind: 'read',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
...route('searchFacets', 'GET', '/api/search/facets'),
|
|
56
|
+
response: z.unknown(),
|
|
57
|
+
auth: INSIDER_ONLY,
|
|
58
|
+
kind: 'read',
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
export { UTILITY_ENTRIES };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request and response schemas of the utility entries: health, auth status, magic link, the key-exchange routes and search, describing what the service's handlers send. Pure.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/** `health` response. */
|
|
8
|
+
export declare const healthResponseSchema: z.ZodObject<{
|
|
9
|
+
ok: z.ZodLiteral<true>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
/**
|
|
12
|
+
* `authStatus` query: the share parameters (a share credential is resolved
|
|
13
|
+
* like any other) and the path it is checked against.
|
|
14
|
+
*/
|
|
15
|
+
export declare const authStatusQuerySchema: z.ZodObject<{
|
|
16
|
+
exp: z.ZodOptional<z.ZodString>;
|
|
17
|
+
d: z.ZodOptional<z.ZodString>;
|
|
18
|
+
dirs: z.ZodOptional<z.ZodString>;
|
|
19
|
+
s: z.ZodOptional<z.ZodString>;
|
|
20
|
+
key: z.ZodOptional<z.ZodString>;
|
|
21
|
+
path: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
/** `authStatus` response. */
|
|
24
|
+
export declare const authStatusResponseSchema: z.ZodObject<{
|
|
25
|
+
authenticated: z.ZodBoolean;
|
|
26
|
+
email: z.ZodOptional<z.ZodString>;
|
|
27
|
+
picture: z.ZodOptional<z.ZodString>;
|
|
28
|
+
isInsider: z.ZodBoolean;
|
|
29
|
+
keyCreatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
searchEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
/** `sendMagicLink` body. */
|
|
33
|
+
export declare const sendMagicLinkBodySchema: z.ZodObject<{
|
|
34
|
+
email: z.ZodOptional<z.ZodString>;
|
|
35
|
+
returnTo: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
/** `sendMagicLink` response. */
|
|
38
|
+
export declare const sendMagicLinkResponseSchema: z.ZodObject<{
|
|
39
|
+
verifyUrl: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
/** `pathKey` response. */
|
|
42
|
+
export declare const pathKeyResponseSchema: z.ZodObject<{
|
|
43
|
+
path: z.ZodString;
|
|
44
|
+
key: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
/** `insiderKey` response. */
|
|
47
|
+
export declare const insiderKeyResponseSchema: z.ZodObject<{
|
|
48
|
+
key: z.ZodString;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
/** `search` body. */
|
|
51
|
+
export declare const searchBodySchema: z.ZodObject<{
|
|
52
|
+
query: z.ZodString;
|
|
53
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
/** One file of the search results, with its matching chunks. */
|
|
57
|
+
export declare const searchResultSchema: z.ZodObject<{
|
|
58
|
+
filePath: z.ZodString;
|
|
59
|
+
browsePath: z.ZodString;
|
|
60
|
+
fileName: z.ZodString;
|
|
61
|
+
bestScore: z.ZodNumber;
|
|
62
|
+
domains: z.ZodArray<z.ZodUnknown>;
|
|
63
|
+
title: z.ZodOptional<z.ZodUnknown>;
|
|
64
|
+
author: z.ZodOptional<z.ZodUnknown>;
|
|
65
|
+
participants: z.ZodOptional<z.ZodUnknown>;
|
|
66
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
67
|
+
chunks: z.ZodArray<z.ZodObject<{
|
|
68
|
+
text: z.ZodString;
|
|
69
|
+
index: z.ZodNumber;
|
|
70
|
+
score: z.ZodNumber;
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
mtime: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
/** `search` response. */
|
|
75
|
+
export declare const searchResponseSchema: z.ZodObject<{
|
|
76
|
+
results: z.ZodArray<z.ZodObject<{
|
|
77
|
+
filePath: z.ZodString;
|
|
78
|
+
browsePath: z.ZodString;
|
|
79
|
+
fileName: z.ZodString;
|
|
80
|
+
bestScore: z.ZodNumber;
|
|
81
|
+
domains: z.ZodArray<z.ZodUnknown>;
|
|
82
|
+
title: z.ZodOptional<z.ZodUnknown>;
|
|
83
|
+
author: z.ZodOptional<z.ZodUnknown>;
|
|
84
|
+
participants: z.ZodOptional<z.ZodUnknown>;
|
|
85
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
86
|
+
chunks: z.ZodArray<z.ZodObject<{
|
|
87
|
+
text: z.ZodString;
|
|
88
|
+
index: z.ZodNumber;
|
|
89
|
+
score: z.ZodNumber;
|
|
90
|
+
}, z.core.$strip>>;
|
|
91
|
+
mtime: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
metadata: z.ZodObject<{
|
|
94
|
+
domains: z.ZodArray<z.ZodUnknown>;
|
|
95
|
+
authors: z.ZodArray<z.ZodUnknown>;
|
|
96
|
+
participants: z.ZodArray<z.ZodUnknown>;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { shareQuerySchema } from './route.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Request and response schemas of the utility entries: health, auth status, magic link, the key-exchange routes and search, describing what the service's handlers send. Pure.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/** `health` response. */
|
|
10
|
+
const healthResponseSchema = z.object({
|
|
11
|
+
/** Always true. */
|
|
12
|
+
ok: z.literal(true),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* `authStatus` query: the share parameters (a share credential is resolved
|
|
16
|
+
* like any other) and the path it is checked against.
|
|
17
|
+
*/
|
|
18
|
+
const authStatusQuerySchema = shareQuerySchema.extend({
|
|
19
|
+
/** Path a share credential is verified against (default `/`). */
|
|
20
|
+
path: z
|
|
21
|
+
.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Path a share credential is verified against (default /).'),
|
|
24
|
+
});
|
|
25
|
+
/** `authStatus` response. */
|
|
26
|
+
const authStatusResponseSchema = z.object({
|
|
27
|
+
/** Whether a credential was recognised. */
|
|
28
|
+
authenticated: z.boolean(),
|
|
29
|
+
/** Session email, or `key:<name>` for a key. */
|
|
30
|
+
email: z.string().optional(),
|
|
31
|
+
/** Profile picture URL of a Google session. */
|
|
32
|
+
picture: z.string().optional(),
|
|
33
|
+
/** Whether the caller is an insider. */
|
|
34
|
+
isInsider: z.boolean(),
|
|
35
|
+
/** When the insider's key was last rotated (ISO), or null. */
|
|
36
|
+
keyCreatedAt: z.string().nullable().optional(),
|
|
37
|
+
/** Sessions only: search is available. */
|
|
38
|
+
searchEnabled: z.boolean().optional(),
|
|
39
|
+
});
|
|
40
|
+
/** `sendMagicLink` body. */
|
|
41
|
+
const sendMagicLinkBodySchema = z.object({
|
|
42
|
+
/** Email to send the link to. */
|
|
43
|
+
email: z.string().optional().describe('Email address to sign in with.'),
|
|
44
|
+
/** Page to open after sign-in (server-relative). */
|
|
45
|
+
returnTo: z
|
|
46
|
+
.string()
|
|
47
|
+
.optional()
|
|
48
|
+
.describe('Page to open after sign-in (server-relative).'),
|
|
49
|
+
});
|
|
50
|
+
/** `sendMagicLink` response. */
|
|
51
|
+
const sendMagicLinkResponseSchema = z.object({
|
|
52
|
+
/** Page where the emailed code is entered (same for every email). */
|
|
53
|
+
verifyUrl: z.string(),
|
|
54
|
+
});
|
|
55
|
+
/** `pathKey` response. */
|
|
56
|
+
const pathKeyResponseSchema = z.object({
|
|
57
|
+
/** The path asked for. */
|
|
58
|
+
path: z.string(),
|
|
59
|
+
/** Its outsider path key. */
|
|
60
|
+
key: z.string(),
|
|
61
|
+
});
|
|
62
|
+
/** `insiderKey` response. */
|
|
63
|
+
const insiderKeyResponseSchema = z.object({
|
|
64
|
+
/** The insider key of the machine seed. */
|
|
65
|
+
key: z.string(),
|
|
66
|
+
});
|
|
67
|
+
/** `search` body. */
|
|
68
|
+
const searchBodySchema = z.object({
|
|
69
|
+
/** Search text. */
|
|
70
|
+
query: z.string().describe('Search text.'),
|
|
71
|
+
/** Files to return (default 20). */
|
|
72
|
+
limit: z
|
|
73
|
+
.number()
|
|
74
|
+
.int()
|
|
75
|
+
.positive()
|
|
76
|
+
.optional()
|
|
77
|
+
.describe('Files to return (default 20).'),
|
|
78
|
+
/** Qdrant filter, passed to jeeves-watcher. */
|
|
79
|
+
filter: z
|
|
80
|
+
.record(z.string(), z.unknown())
|
|
81
|
+
.optional()
|
|
82
|
+
.describe('Qdrant filter, passed to jeeves-watcher.'),
|
|
83
|
+
});
|
|
84
|
+
/** One file of the search results, with its matching chunks. */
|
|
85
|
+
const searchResultSchema = z.object({
|
|
86
|
+
/** Filesystem path the watcher indexed. */
|
|
87
|
+
filePath: z.string(),
|
|
88
|
+
/** Browse path. */
|
|
89
|
+
browsePath: z.string(),
|
|
90
|
+
/** File name. */
|
|
91
|
+
fileName: z.string(),
|
|
92
|
+
/** Best chunk score. */
|
|
93
|
+
bestScore: z.number(),
|
|
94
|
+
/** Domains from the index metadata. */
|
|
95
|
+
domains: z.array(z.unknown()),
|
|
96
|
+
/** `title` from the index metadata. */
|
|
97
|
+
title: z.unknown().optional(),
|
|
98
|
+
/** `author` from the index metadata. */
|
|
99
|
+
author: z.unknown().optional(),
|
|
100
|
+
/** `participants` from the index metadata. */
|
|
101
|
+
participants: z.unknown().optional(),
|
|
102
|
+
/** Other index metadata. */
|
|
103
|
+
metadata: z.record(z.string(), z.unknown()),
|
|
104
|
+
/** Matching chunks, in document order. */
|
|
105
|
+
chunks: z.array(z.object({
|
|
106
|
+
/** Chunk text. */
|
|
107
|
+
text: z.string(),
|
|
108
|
+
/** Chunk index. */
|
|
109
|
+
index: z.number(),
|
|
110
|
+
/** Chunk score. */
|
|
111
|
+
score: z.number(),
|
|
112
|
+
})),
|
|
113
|
+
/** File modification time (ISO), when readable. */
|
|
114
|
+
mtime: z.string().optional(),
|
|
115
|
+
});
|
|
116
|
+
/** `search` response. */
|
|
117
|
+
const searchResponseSchema = z.object({
|
|
118
|
+
/** Files, best first. */
|
|
119
|
+
results: z.array(searchResultSchema),
|
|
120
|
+
/** Distinct values across the results, for filter chips. */
|
|
121
|
+
metadata: z.object({
|
|
122
|
+
/** Distinct domains. */
|
|
123
|
+
domains: z.array(z.unknown()),
|
|
124
|
+
/** Distinct authors. */
|
|
125
|
+
authors: z.array(z.unknown()),
|
|
126
|
+
/** Distinct participants. */
|
|
127
|
+
participants: z.array(z.unknown()),
|
|
128
|
+
}),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
export { authStatusQuerySchema, authStatusResponseSchema, healthResponseSchema, insiderKeyResponseSchema, pathKeyResponseSchema, searchBodySchema, searchResponseSchema, searchResultSchema, sendMagicLinkBodySchema, sendMagicLinkResponseSchema };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config schemas for access: auth modes, Google and email login, event
|
|
3
|
+
* webhooks, access scopes, insiders and keys.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/** Supported authentication methods */
|
|
9
|
+
export declare const authModeSchema: z.ZodEnum<{
|
|
10
|
+
google: "google";
|
|
11
|
+
keys: "keys";
|
|
12
|
+
email: "email";
|
|
13
|
+
}>;
|
|
14
|
+
/** Google OAuth configuration */
|
|
15
|
+
export declare const googleAuthSchema: z.ZodObject<{
|
|
16
|
+
clientId: z.ZodString;
|
|
17
|
+
clientSecret: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/** Email (magic link) authentication configuration */
|
|
20
|
+
export declare const emailAuthSchema: z.ZodObject<{
|
|
21
|
+
smtpUrl: z.ZodString;
|
|
22
|
+
fromAddress: z.ZodEmail;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
/** Auth configuration */
|
|
25
|
+
export declare const authSchema: z.ZodObject<{
|
|
26
|
+
modes: z.ZodArray<z.ZodEnum<{
|
|
27
|
+
google: "google";
|
|
28
|
+
keys: "keys";
|
|
29
|
+
email: "email";
|
|
30
|
+
}>>;
|
|
31
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
32
|
+
clientId: z.ZodString;
|
|
33
|
+
clientSecret: z.ZodString;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
sessionSecret: z.ZodOptional<z.ZodString>;
|
|
36
|
+
email: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
smtpUrl: z.ZodString;
|
|
38
|
+
fromAddress: z.ZodEmail;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
accessContact: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
/** Event webhook configuration */
|
|
43
|
+
export declare const eventConfigSchema: z.ZodObject<{
|
|
44
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
45
|
+
cmd: z.ZodString;
|
|
46
|
+
map: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
47
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
/**
|
|
50
|
+
* Scopes configuration — controls which paths a user/key can access.
|
|
51
|
+
*
|
|
52
|
+
* Three forms:
|
|
53
|
+
* - `string` — single allow pattern (e.g. '/d/*')
|
|
54
|
+
* - `string[]` — array of allow patterns (shorthand for \{ allow: [...] \})
|
|
55
|
+
* - `\{ allow?: string[], deny?: string[] \}` — explicit allow/deny rules
|
|
56
|
+
*
|
|
57
|
+
* Semantics:
|
|
58
|
+
* - Path must match at least one allow rule AND NOT match any deny rule
|
|
59
|
+
* - Omitting `allow` = implicit ['/*'] (allow everything)
|
|
60
|
+
* - Omitting `deny` = no exclusions
|
|
61
|
+
* - Omitting scopes entirely = unrestricted access
|
|
62
|
+
*/
|
|
63
|
+
export declare const scopesObjectSchema: z.ZodObject<{
|
|
64
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export declare const scopesSchema: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodObject<{
|
|
68
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
}, z.core.$strip>]>;
|
|
71
|
+
/** Insider entry (identity + scopes + optional persisted seed) */
|
|
72
|
+
export declare const insiderEntrySchema: z.ZodObject<{
|
|
73
|
+
scopes: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodObject<{
|
|
74
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
75
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
76
|
+
}, z.core.$strip>]>>;
|
|
77
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
78
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
79
|
+
seed: z.ZodOptional<z.ZodString>;
|
|
80
|
+
keyCreatedAt: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
/** Key entry — plain string (seed, no scopes) or object with key + optional scopes */
|
|
83
|
+
export declare const keyEntrySchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
84
|
+
key: z.ZodString;
|
|
85
|
+
scopes: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodObject<{
|
|
86
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
|
+
}, z.core.$strip>]>>;
|
|
89
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
90
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
91
|
+
}, z.core.$strip>]>;
|
|
92
|
+
/** Check if a string is a named scope identifier (not a path glob). */
|
|
93
|
+
export declare function isScopeName(v: string): boolean;
|
|
94
|
+
/** Helper: collect named scope references from a scopes field value.
|
|
95
|
+
*
|
|
96
|
+
* Backward-compat note: `scopes` has historically accepted path globs like "/**" or ["/a","/b"].
|
|
97
|
+
* We only treat values as *named scope references* if they look like identifiers
|
|
98
|
+
* (e.g. "restricted", "no-vc") rather than path globs.
|
|
99
|
+
*/
|
|
100
|
+
export declare function getScopeRefs(scopes: unknown): string[];
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Config schemas for access: auth modes, Google and email login, event
|
|
5
|
+
* webhooks, access scopes, insiders and keys.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/** Supported authentication methods */
|
|
10
|
+
const authModeSchema = z.enum(['google', 'keys', 'email']);
|
|
11
|
+
/** Google OAuth configuration */
|
|
12
|
+
const googleAuthSchema = z.object({
|
|
13
|
+
clientId: z.string().min(1),
|
|
14
|
+
clientSecret: z.string().min(1),
|
|
15
|
+
});
|
|
16
|
+
/** Email (magic link) authentication configuration */
|
|
17
|
+
const emailAuthSchema = z.object({
|
|
18
|
+
/** SMTP connection string (e.g. smtps://user:pass\@smtp.example.com:465) */
|
|
19
|
+
smtpUrl: z.string().min(1),
|
|
20
|
+
/** Sender email address for magic link emails */
|
|
21
|
+
fromAddress: z.email(),
|
|
22
|
+
});
|
|
23
|
+
/** Auth configuration */
|
|
24
|
+
const authSchema = z.object({
|
|
25
|
+
/** Active authentication methods. Order determines priority. */
|
|
26
|
+
modes: z
|
|
27
|
+
.array(authModeSchema)
|
|
28
|
+
.min(1, { message: 'At least one auth mode is required' }),
|
|
29
|
+
/** Google OAuth config. Required if modes includes "google". */
|
|
30
|
+
google: googleAuthSchema.optional(),
|
|
31
|
+
/** Session cookie signing secret. Required if modes includes "google". */
|
|
32
|
+
sessionSecret: z.string().min(1).optional(),
|
|
33
|
+
/** Email (magic link) auth config. Required if modes includes "email". */
|
|
34
|
+
email: emailAuthSchema.optional(),
|
|
35
|
+
/**
|
|
36
|
+
* Who to ask for access, shown on the page a refused Google sign-in
|
|
37
|
+
* gets (#304): free text such as a name and email (an email in it
|
|
38
|
+
* becomes a `mailto:` link). Without it the page says to ask the
|
|
39
|
+
* administrator of the server.
|
|
40
|
+
*/
|
|
41
|
+
accessContact: z.string().trim().min(1).optional(),
|
|
42
|
+
});
|
|
43
|
+
/** Event webhook configuration */
|
|
44
|
+
const eventConfigSchema = z.object({
|
|
45
|
+
schema: z.record(z.string(), z.unknown()),
|
|
46
|
+
cmd: z.string(),
|
|
47
|
+
map: z.record(z.string(), z.unknown()).optional(),
|
|
48
|
+
timeoutMs: z.number().positive().optional(),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Scopes configuration — controls which paths a user/key can access.
|
|
52
|
+
*
|
|
53
|
+
* Three forms:
|
|
54
|
+
* - `string` — single allow pattern (e.g. '/d/*')
|
|
55
|
+
* - `string[]` — array of allow patterns (shorthand for \{ allow: [...] \})
|
|
56
|
+
* - `\{ allow?: string[], deny?: string[] \}` — explicit allow/deny rules
|
|
57
|
+
*
|
|
58
|
+
* Semantics:
|
|
59
|
+
* - Path must match at least one allow rule AND NOT match any deny rule
|
|
60
|
+
* - Omitting `allow` = implicit ['/*'] (allow everything)
|
|
61
|
+
* - Omitting `deny` = no exclusions
|
|
62
|
+
* - Omitting scopes entirely = unrestricted access
|
|
63
|
+
*/
|
|
64
|
+
const scopesObjectSchema = z.object({
|
|
65
|
+
allow: z.array(z.string()).optional(),
|
|
66
|
+
deny: z.array(z.string()).optional(),
|
|
67
|
+
});
|
|
68
|
+
const scopesSchema = z.union([
|
|
69
|
+
z.string(),
|
|
70
|
+
z.array(z.string()),
|
|
71
|
+
scopesObjectSchema,
|
|
72
|
+
]);
|
|
73
|
+
/** Insider entry (identity + scopes + optional persisted seed) */
|
|
74
|
+
const insiderEntrySchema = z.object({
|
|
75
|
+
scopes: scopesSchema.optional(),
|
|
76
|
+
/** Extra allow patterns merged on top of named scope references */
|
|
77
|
+
allow: z.array(z.string()).optional(),
|
|
78
|
+
/** Extra deny patterns merged on top of named scope references */
|
|
79
|
+
deny: z.array(z.string()).optional(),
|
|
80
|
+
/** Auto-generated insider seed, persisted in config.json */
|
|
81
|
+
seed: z.string().min(1).optional(),
|
|
82
|
+
/** ISO timestamp of when the seed was created */
|
|
83
|
+
keyCreatedAt: z.string().optional(),
|
|
84
|
+
});
|
|
85
|
+
/** Key entry — plain string (seed, no scopes) or object with key + optional scopes */
|
|
86
|
+
const keyEntrySchema = z.union([
|
|
87
|
+
z.string().min(1),
|
|
88
|
+
z.object({
|
|
89
|
+
key: z.string().min(1),
|
|
90
|
+
scopes: scopesSchema.optional(),
|
|
91
|
+
/** Extra allow patterns merged on top of named scope references */
|
|
92
|
+
allow: z.array(z.string()).optional(),
|
|
93
|
+
/** Extra deny patterns merged on top of named scope references */
|
|
94
|
+
deny: z.array(z.string()).optional(),
|
|
95
|
+
}),
|
|
96
|
+
]);
|
|
97
|
+
/** Check if a string is a named scope identifier (not a path glob). */
|
|
98
|
+
function isScopeName(v) {
|
|
99
|
+
return /^[A-Za-z0-9_-]+$/.test(v);
|
|
100
|
+
}
|
|
101
|
+
/** Helper: collect named scope references from a scopes field value.
|
|
102
|
+
*
|
|
103
|
+
* Backward-compat note: `scopes` has historically accepted path globs like "/**" or ["/a","/b"].
|
|
104
|
+
* We only treat values as *named scope references* if they look like identifiers
|
|
105
|
+
* (e.g. "restricted", "no-vc") rather than path globs.
|
|
106
|
+
*/
|
|
107
|
+
function getScopeRefs(scopes) {
|
|
108
|
+
if (typeof scopes === 'string')
|
|
109
|
+
return isScopeName(scopes) ? [scopes] : [];
|
|
110
|
+
if (Array.isArray(scopes) && scopes.length > 0) {
|
|
111
|
+
const strs = scopes.filter((v) => typeof v === 'string');
|
|
112
|
+
if (strs.length !== scopes.length)
|
|
113
|
+
return [];
|
|
114
|
+
return strs.filter((v) => isScopeName(v));
|
|
115
|
+
}
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { authModeSchema, authSchema, emailAuthSchema, eventConfigSchema, getScopeRefs, googleAuthSchema, insiderEntrySchema, isScopeName, keyEntrySchema, scopesObjectSchema, scopesSchema };
|