theokit 0.12.0 → 0.12.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/dist/adapters/web-shim.d.ts +67 -0
- package/dist/adapters/ws-shim.d.ts +55 -0
- package/dist/agent-events-DosDXkSV.d.ts +94 -0
- package/dist/audit-log-BQWM5YLG.d.ts +60 -0
- package/dist/boot/index.d.ts +39 -0
- package/dist/client/index.d.ts +362 -0
- package/dist/csrf-BBrEZSBW.d.ts +107 -0
- package/dist/csrf-readiness-store-CjIoub3U.d.ts +43 -0
- package/dist/define-websocket-CdK94O-D.d.ts +64 -0
- package/dist/devtools/entry.d.ts +5 -0
- package/dist/error-envelope-BsNzzAV5.d.ts +62 -0
- package/dist/health-route-C0hk64_U.d.ts +57 -0
- package/dist/index-B40qUSrQ.d.ts +575 -0
- package/dist/index.d.ts +361 -0
- package/dist/job-backend-CgC8Xf33.d.ts +68 -0
- package/dist/match-CfbEFRG4.d.ts +26 -0
- package/dist/plugin-runner-BGBkzgi0.d.ts +95 -0
- package/dist/plugin-types-DNJGxr4Z.d.ts +79 -0
- package/dist/rate-limit-BdNDZ3vt.d.ts +58 -0
- package/dist/rate-limit-store-BEJnhWdw.d.ts +72 -0
- package/dist/react-query/index.d.ts +33 -0
- package/dist/schema-BpH6ivDY.d.ts +74 -0
- package/dist/server/agent/index.d.ts +229 -0
- package/dist/server/auth/index.d.ts +419 -0
- package/dist/server/cost/index.d.ts +177 -0
- package/dist/server/cron/index.d.ts +208 -0
- package/dist/server/define/index.d.ts +313 -0
- package/dist/server/http/index.d.ts +11 -0
- package/dist/server/index.d.ts +848 -0
- package/dist/server/jobs/index.d.ts +348 -0
- package/dist/server/observability/index.d.ts +324 -0
- package/dist/server/plugins/index.d.ts +17 -0
- package/dist/server/rate-limit/index.d.ts +105 -0
- package/dist/server/realtime/index.d.ts +15 -0
- package/dist/server/scan/index.d.ts +106 -0
- package/dist/server/security/index.d.ts +193 -0
- package/dist/server/storage/index.d.ts +22 -0
- package/dist/server/webhook/index.d.ts +148 -0
- package/dist/storage-manager-C4jsO0Tp.d.ts +89 -0
- package/dist/storage-types-DsDTCPbp.d.ts +96 -0
- package/dist/vite-plugin/index.d.ts +115 -0
- package/package.json +4 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { T as TheoErrorEnvelope } from './error-envelope-BsNzzAV5.js';
|
|
3
|
+
export { theoPlugin } from './vite-plugin/index.js';
|
|
4
|
+
import 'vite';
|
|
5
|
+
import './rate-limit-BdNDZ3vt.js';
|
|
6
|
+
import 'node:http';
|
|
7
|
+
import './rate-limit-store-BEJnhWdw.js';
|
|
8
|
+
import './csrf-readiness-store-CjIoub3U.js';
|
|
9
|
+
import './schema-BpH6ivDY.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* G5 T1.3 — formatError hook signature (blueprint ADR D3).
|
|
13
|
+
*
|
|
14
|
+
* Type-inferred functional transformer that runs at framework error-boundary
|
|
15
|
+
* time. Producer-side analog of trpc's `errorFormatter`. The return type is
|
|
16
|
+
* `TheoErrorEnvelope<TExt>` for arbitrary `TExt` so the inference flows into
|
|
17
|
+
* `@theo/client` codegen + UI consumers.
|
|
18
|
+
*/
|
|
19
|
+
interface FormatErrorContext {
|
|
20
|
+
readonly route?: string;
|
|
21
|
+
readonly action?: string;
|
|
22
|
+
readonly agentRunId?: string;
|
|
23
|
+
}
|
|
24
|
+
type FormatErrorHook = (envelope: TheoErrorEnvelope, ctx: FormatErrorContext) => TheoErrorEnvelope;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Root `theo.config.ts` schema — composer assembled from the per-concern
|
|
28
|
+
* primitives re-exported above.
|
|
29
|
+
*
|
|
30
|
+
* Embedded blocks that exist ONLY as part of the root config (`agents`,
|
|
31
|
+
* `ui`, `devtools`, `jobs`, `openapi`) stay inline below. They have no
|
|
32
|
+
* external consumers; splitting them would create lonely files (M5
|
|
33
|
+
* smell) without comprehension benefit.
|
|
34
|
+
*/
|
|
35
|
+
declare const theoConfigSchema: z.ZodObject<{
|
|
36
|
+
name: z.ZodOptional<z.ZodString>;
|
|
37
|
+
appDir: z.ZodDefault<z.ZodString>;
|
|
38
|
+
serverDir: z.ZodDefault<z.ZodString>;
|
|
39
|
+
distDir: z.ZodDefault<z.ZodString>;
|
|
40
|
+
agents: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
maxRegistries: z.ZodDefault<z.ZodNumber>;
|
|
42
|
+
registry: z.ZodOptional<z.ZodObject<{
|
|
43
|
+
maxAgents: z.ZodDefault<z.ZodNumber>;
|
|
44
|
+
idleTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
48
|
+
host: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
49
|
+
open: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
50
|
+
strictPort: z.ZodDefault<z.ZodBoolean>;
|
|
51
|
+
forwardConsole: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
52
|
+
unhandledErrors: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
logLevels: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
54
|
+
error: "error";
|
|
55
|
+
info: "info";
|
|
56
|
+
warn: "warn";
|
|
57
|
+
debug: "debug";
|
|
58
|
+
log: "log";
|
|
59
|
+
}>>>;
|
|
60
|
+
}, z.core.$strip>]>>;
|
|
61
|
+
warmup: z.ZodOptional<z.ZodObject<{
|
|
62
|
+
clientFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
ssrFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
ssr: z.ZodDefault<z.ZodBoolean>;
|
|
66
|
+
ssrStreaming: z.ZodDefault<z.ZodBoolean>;
|
|
67
|
+
rateLimit: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
68
|
+
windowMs: z.ZodNumber;
|
|
69
|
+
max: z.ZodNumber;
|
|
70
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
71
|
+
default: z.ZodOptional<z.ZodObject<{
|
|
72
|
+
windowMs: z.ZodNumber;
|
|
73
|
+
max: z.ZodNumber;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
routes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
76
|
+
windowMs: z.ZodNumber;
|
|
77
|
+
max: z.ZodNumber;
|
|
78
|
+
}, z.core.$strip>>>;
|
|
79
|
+
keyBy: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
80
|
+
ip: "ip";
|
|
81
|
+
session: "session";
|
|
82
|
+
user: "user";
|
|
83
|
+
}>, z.ZodFunction<z.ZodTuple<[z.ZodUnknown], null>, z.ZodString>]>>;
|
|
84
|
+
cookieName: z.ZodOptional<z.ZodString>;
|
|
85
|
+
}, z.core.$strip>]>>;
|
|
86
|
+
upload: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
maxFileSize: z.ZodDefault<z.ZodNumber>;
|
|
88
|
+
maxFiles: z.ZodDefault<z.ZodNumber>;
|
|
89
|
+
maxFieldSize: z.ZodDefault<z.ZodNumber>;
|
|
90
|
+
}, z.core.$strip>>;
|
|
91
|
+
logging: z.ZodOptional<z.ZodObject<{
|
|
92
|
+
level: z.ZodDefault<z.ZodEnum<{
|
|
93
|
+
error: "error";
|
|
94
|
+
info: "info";
|
|
95
|
+
warn: "warn";
|
|
96
|
+
debug: "debug";
|
|
97
|
+
silent: "silent";
|
|
98
|
+
}>>;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
security: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
csrf: z.ZodDefault<z.ZodEnum<{
|
|
102
|
+
warn: "warn";
|
|
103
|
+
off: "off";
|
|
104
|
+
strict: "strict";
|
|
105
|
+
}>>;
|
|
106
|
+
headers: z.ZodOptional<z.ZodObject<{
|
|
107
|
+
csp: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
|
|
108
|
+
cspMode: z.ZodDefault<z.ZodEnum<{
|
|
109
|
+
enforce: "enforce";
|
|
110
|
+
"report-only": "report-only";
|
|
111
|
+
off: "off";
|
|
112
|
+
}>>;
|
|
113
|
+
hsts: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
|
|
114
|
+
frameOptions: z.ZodDefault<z.ZodEnum<{
|
|
115
|
+
DENY: "DENY";
|
|
116
|
+
SAMEORIGIN: "SAMEORIGIN";
|
|
117
|
+
}>>;
|
|
118
|
+
contentTypeOptions: z.ZodDefault<z.ZodLiteral<"nosniff">>;
|
|
119
|
+
referrerPolicy: z.ZodDefault<z.ZodString>;
|
|
120
|
+
permissionsPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
|
|
121
|
+
}, z.core.$strip>>;
|
|
122
|
+
disallowed: z.ZodOptional<z.ZodObject<{
|
|
123
|
+
routes: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>]>>;
|
|
124
|
+
behavior: z.ZodDefault<z.ZodEnum<{
|
|
125
|
+
warn: "warn";
|
|
126
|
+
raise: "raise";
|
|
127
|
+
}>>;
|
|
128
|
+
}, z.core.$strip>>;
|
|
129
|
+
cors: z.ZodOptional<z.ZodObject<{
|
|
130
|
+
origins: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>]>>, z.ZodFunction<z.ZodTuple<[z.ZodString], null>, z.ZodBoolean>]>;
|
|
131
|
+
methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
132
|
+
GET: "GET";
|
|
133
|
+
HEAD: "HEAD";
|
|
134
|
+
OPTIONS: "OPTIONS";
|
|
135
|
+
POST: "POST";
|
|
136
|
+
PUT: "PUT";
|
|
137
|
+
PATCH: "PATCH";
|
|
138
|
+
DELETE: "DELETE";
|
|
139
|
+
}>>>;
|
|
140
|
+
allowedHeaders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
141
|
+
exposedHeaders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
142
|
+
credentials: z.ZodDefault<z.ZodBoolean>;
|
|
143
|
+
maxAge: z.ZodDefault<z.ZodNumber>;
|
|
144
|
+
}, z.core.$strip>>;
|
|
145
|
+
}, z.core.$strip>>;
|
|
146
|
+
serialization: z.ZodDefault<z.ZodEnum<{
|
|
147
|
+
json: "json";
|
|
148
|
+
superjson: "superjson";
|
|
149
|
+
}>>;
|
|
150
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
151
|
+
batching: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
152
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
153
|
+
}, z.core.$strip>]>>;
|
|
154
|
+
audit: z.ZodOptional<z.ZodObject<{
|
|
155
|
+
logger: z.ZodOptional<z.ZodUnknown>;
|
|
156
|
+
}, z.core.$strip>>;
|
|
157
|
+
ui: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
|
|
158
|
+
theme: z.ZodOptional<z.ZodEnum<{
|
|
159
|
+
"violet-forge": "violet-forge";
|
|
160
|
+
noir: "noir";
|
|
161
|
+
paper: "paper";
|
|
162
|
+
}>>;
|
|
163
|
+
fonts: z.ZodOptional<z.ZodEnum<{
|
|
164
|
+
bundled: "bundled";
|
|
165
|
+
cdn: "cdn";
|
|
166
|
+
}>>;
|
|
167
|
+
}, z.core.$strip>]>>;
|
|
168
|
+
cache: z.ZodOptional<z.ZodObject<{
|
|
169
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
170
|
+
storage: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"memory">, z.ZodCustom<unknown, unknown>]>>;
|
|
171
|
+
maxEntries: z.ZodDefault<z.ZodNumber>;
|
|
172
|
+
defaults: z.ZodDefault<z.ZodObject<{
|
|
173
|
+
maxAge: z.ZodDefault<z.ZodNumber>;
|
|
174
|
+
swr: z.ZodOptional<z.ZodNumber>;
|
|
175
|
+
cacheErrors: z.ZodDefault<z.ZodBoolean>;
|
|
176
|
+
}, z.core.$strip>>;
|
|
177
|
+
keyDerivation: z.ZodDefault<z.ZodObject<{
|
|
178
|
+
excludeQuery: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
179
|
+
sortQuery: z.ZodDefault<z.ZodBoolean>;
|
|
180
|
+
lowercaseHost: z.ZodDefault<z.ZodBoolean>;
|
|
181
|
+
}, z.core.$strip>>;
|
|
182
|
+
routeRules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
183
|
+
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
184
|
+
swr: z.ZodOptional<z.ZodNumber>;
|
|
185
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
186
|
+
}, z.core.$strip>>>;
|
|
187
|
+
}, z.core.$strip>>;
|
|
188
|
+
devtools: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
|
|
189
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
190
|
+
"top-left": "top-left";
|
|
191
|
+
"top-right": "top-right";
|
|
192
|
+
"bottom-left": "bottom-left";
|
|
193
|
+
"bottom-right": "bottom-right";
|
|
194
|
+
}>>;
|
|
195
|
+
theme: z.ZodOptional<z.ZodEnum<{
|
|
196
|
+
light: "light";
|
|
197
|
+
dark: "dark";
|
|
198
|
+
system: "system";
|
|
199
|
+
}>>;
|
|
200
|
+
}, z.core.$strip>]>>;
|
|
201
|
+
adapters: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
202
|
+
viteOptimizeDeps: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
203
|
+
jobs: z.ZodOptional<z.ZodObject<{
|
|
204
|
+
backend: z.ZodCustom<unknown, unknown>;
|
|
205
|
+
}, z.core.$strip>>;
|
|
206
|
+
storage: z.ZodOptional<z.ZodObject<{
|
|
207
|
+
servers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
208
|
+
host: z.ZodString;
|
|
209
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
210
|
+
user: z.ZodString;
|
|
211
|
+
password: z.ZodString;
|
|
212
|
+
tls: z.ZodOptional<z.ZodObject<{
|
|
213
|
+
rejectUnauthorized: z.ZodOptional<z.ZodBoolean>;
|
|
214
|
+
caCert: z.ZodOptional<z.ZodString>;
|
|
215
|
+
clientCert: z.ZodOptional<z.ZodString>;
|
|
216
|
+
clientKey: z.ZodOptional<z.ZodString>;
|
|
217
|
+
}, z.core.$strip>>;
|
|
218
|
+
}, z.core.$strip>>>;
|
|
219
|
+
databases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
220
|
+
server: z.ZodString;
|
|
221
|
+
database: z.ZodString;
|
|
222
|
+
pool: z.ZodOptional<z.ZodObject<{
|
|
223
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
224
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
225
|
+
connectionTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
226
|
+
idleTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
}, z.core.$strip>>;
|
|
228
|
+
}, z.core.$strip>>>;
|
|
229
|
+
redis: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
230
|
+
host: z.ZodString;
|
|
231
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
user: z.ZodString;
|
|
233
|
+
password: z.ZodString;
|
|
234
|
+
tls: z.ZodOptional<z.ZodObject<{
|
|
235
|
+
rejectUnauthorized: z.ZodOptional<z.ZodBoolean>;
|
|
236
|
+
caCert: z.ZodOptional<z.ZodString>;
|
|
237
|
+
clientCert: z.ZodOptional<z.ZodString>;
|
|
238
|
+
clientKey: z.ZodOptional<z.ZodString>;
|
|
239
|
+
}, z.core.$strip>>;
|
|
240
|
+
db: z.ZodOptional<z.ZodNumber>;
|
|
241
|
+
maxRetriesPerRequest: z.ZodOptional<z.ZodNumber>;
|
|
242
|
+
}, z.core.$strip>>>;
|
|
243
|
+
}, z.core.$strip>>;
|
|
244
|
+
services: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
245
|
+
runtime: z.ZodEnum<{
|
|
246
|
+
python: "python";
|
|
247
|
+
node: "node";
|
|
248
|
+
}>;
|
|
249
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
250
|
+
server: "server";
|
|
251
|
+
worker: "worker";
|
|
252
|
+
}>>;
|
|
253
|
+
port: z.ZodNumber;
|
|
254
|
+
proxy: z.ZodString;
|
|
255
|
+
dev: z.ZodString;
|
|
256
|
+
build: z.ZodOptional<z.ZodString>;
|
|
257
|
+
start: z.ZodString;
|
|
258
|
+
openapi: z.ZodOptional<z.ZodURL>;
|
|
259
|
+
healthcheck: z.ZodDefault<z.ZodString>;
|
|
260
|
+
cors: z.ZodDefault<z.ZodBoolean>;
|
|
261
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
262
|
+
dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
263
|
+
passSetCookie: z.ZodDefault<z.ZodBoolean>;
|
|
264
|
+
}, z.core.$strip>>>;
|
|
265
|
+
openapi: z.ZodOptional<z.ZodObject<{
|
|
266
|
+
servers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
267
|
+
url: z.ZodURL;
|
|
268
|
+
description: z.ZodOptional<z.ZodString>;
|
|
269
|
+
}, z.core.$strip>>>;
|
|
270
|
+
specVersion: z.ZodDefault<z.ZodEnum<{
|
|
271
|
+
"3.1.0": "3.1.0";
|
|
272
|
+
"3.0.3": "3.0.3";
|
|
273
|
+
}>>;
|
|
274
|
+
title: z.ZodDefault<z.ZodString>;
|
|
275
|
+
version: z.ZodDefault<z.ZodString>;
|
|
276
|
+
outDir: z.ZodDefault<z.ZodString>;
|
|
277
|
+
}, z.core.$strip>>;
|
|
278
|
+
formatError: z.ZodOptional<z.ZodCustom<FormatErrorHook, FormatErrorHook>>;
|
|
279
|
+
}, z.core.$strip>;
|
|
280
|
+
type TheoConfig = z.infer<typeof theoConfigSchema>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Define Theo framework configuration.
|
|
284
|
+
* Identity function — provides type inference for theo.config.ts.
|
|
285
|
+
* Runtime validation happens in loadConfig(), not here.
|
|
286
|
+
*/
|
|
287
|
+
declare function defineConfig(config: Partial<TheoConfig>): Partial<TheoConfig>;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Deep merges two plain objects. Override values take precedence.
|
|
291
|
+
* Arrays are replaced (not concatenated).
|
|
292
|
+
* Protects against prototype pollution (EC-4).
|
|
293
|
+
*/
|
|
294
|
+
declare function deepMerge(base: Record<string, unknown>, override: Record<string, unknown>): Record<string, unknown>;
|
|
295
|
+
declare function loadConfig(dir: string): Promise<TheoConfig>;
|
|
296
|
+
|
|
297
|
+
interface ConfigIssue {
|
|
298
|
+
field: string;
|
|
299
|
+
message: string;
|
|
300
|
+
}
|
|
301
|
+
declare class TheoConfigError extends Error {
|
|
302
|
+
readonly issues: ConfigIssue[];
|
|
303
|
+
readonly configPath: string;
|
|
304
|
+
constructor(issues: ConfigIssue[], configPath: string);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
declare function validateProjectStructure(rootDir: string): void;
|
|
308
|
+
|
|
309
|
+
declare class TheoProjectError extends Error {
|
|
310
|
+
readonly errors: string[];
|
|
311
|
+
readonly rootDir: string;
|
|
312
|
+
constructor(errors: string[], rootDir: string);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* core/contracts/route-node.ts
|
|
317
|
+
*
|
|
318
|
+
* Canonical home for `RouteNode` (file-system route tree shape) — consumed
|
|
319
|
+
* by `router/`, `vite-plugin/`, AND `devtools/server-side/`. Moved here in
|
|
320
|
+
* T2.2 of architecture-cleanup so `devtools → core/contracts` is the legal
|
|
321
|
+
* edge (replacing the prior `devtools → router` violation).
|
|
322
|
+
*/
|
|
323
|
+
/**
|
|
324
|
+
* Dynamic-segment metadata for a file-system route node.
|
|
325
|
+
* Set when the directory name is `[param]` (single segment) or `[...slug]`
|
|
326
|
+
* (catch-all). `generate.ts` turns this into react-router `:param` / `*` syntax.
|
|
327
|
+
*/
|
|
328
|
+
interface RouteNodeDynamic {
|
|
329
|
+
/** The param name (`slug` for `[slug]` / `[...slug]`). Always `[A-Za-z0-9_]+`. */
|
|
330
|
+
paramName: string;
|
|
331
|
+
/** True for catch-all `[...slug]`, false for single dynamic `[slug]`. */
|
|
332
|
+
catchAll: boolean;
|
|
333
|
+
}
|
|
334
|
+
interface RouteNode {
|
|
335
|
+
segment: string;
|
|
336
|
+
path: string;
|
|
337
|
+
page?: string;
|
|
338
|
+
layout?: string;
|
|
339
|
+
error?: string;
|
|
340
|
+
loading?: string;
|
|
341
|
+
notFound?: string;
|
|
342
|
+
/** Present only for dynamic / catch-all segments (additive — static routes omit it). */
|
|
343
|
+
dynamic?: RouteNodeDynamic;
|
|
344
|
+
children: RouteNode[];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
declare function isRouteFile(filename: string): boolean;
|
|
348
|
+
|
|
349
|
+
declare function scanRoutes(appDir: string): RouteNode;
|
|
350
|
+
|
|
351
|
+
declare function generateRouteManifest(tree: RouteNode): string;
|
|
352
|
+
|
|
353
|
+
interface EntryClientOptions {
|
|
354
|
+
theoUi?: {
|
|
355
|
+
fonts?: 'bundled' | 'cdn';
|
|
356
|
+
theme?: 'violet-forge' | 'noir' | 'paper';
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
declare function generateEntryClient(ssr?: boolean, opts?: EntryClientOptions): string;
|
|
360
|
+
|
|
361
|
+
export { type ConfigIssue, type RouteNode, type TheoConfig, TheoConfigError, TheoProjectError, deepMerge, defineConfig, generateEntryClient, generateRouteManifest, isRouteFile, loadConfig, scanRoutes, theoConfigSchema, validateProjectStructure };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neutral `JobBackend` interface per ADR-0002.
|
|
3
|
+
*
|
|
4
|
+
* Implementations ship in core:
|
|
5
|
+
* - `InMemoryJobBackend` (T2.2) — dev + tests; no external deps
|
|
6
|
+
* - `PostgresJobBackend` (T3.1) — production; requires `pg` peer dep
|
|
7
|
+
*
|
|
8
|
+
* Community packages (`@theokit/jobs-redis`, `@theokit/jobs-sqs`, etc.)
|
|
9
|
+
* implement this same interface to plug in alternate substrates without
|
|
10
|
+
* modifying TheoKit core.
|
|
11
|
+
*/
|
|
12
|
+
interface JobEnqueueInput {
|
|
13
|
+
/** The job name (matches a `defineJob` declaration). */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Validated input (already passed through Zod or equivalent at the queue-client layer). */
|
|
16
|
+
input: unknown;
|
|
17
|
+
/** Optional idempotency key for at-most-once dispatch within TTL. */
|
|
18
|
+
idempotencyKey?: string;
|
|
19
|
+
/** Optional delay before the job becomes available for dispatch. */
|
|
20
|
+
delaySeconds?: number;
|
|
21
|
+
/** W3C Trace Context propagation per ADR/R0.5.9. */
|
|
22
|
+
traceparent?: string;
|
|
23
|
+
/** Maximum dispatch attempts (read from JobDefinition by the queue client). */
|
|
24
|
+
maxAttempts?: number;
|
|
25
|
+
}
|
|
26
|
+
interface JobLease {
|
|
27
|
+
readonly jobId: string;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly input: unknown;
|
|
30
|
+
readonly attempts: number;
|
|
31
|
+
readonly maxAttempts: number;
|
|
32
|
+
readonly traceparent?: string;
|
|
33
|
+
readonly lockExpiresAt: Date;
|
|
34
|
+
}
|
|
35
|
+
interface JobBackend {
|
|
36
|
+
/** Human-readable name for logging (e.g., "memory", "postgres"). */
|
|
37
|
+
readonly name: string;
|
|
38
|
+
/** Persist a job for later dispatch. Returns the generated jobId. */
|
|
39
|
+
enqueue(input: JobEnqueueInput): Promise<{
|
|
40
|
+
jobId: string;
|
|
41
|
+
}>;
|
|
42
|
+
/** Worker loop polls for the next available leases. */
|
|
43
|
+
dequeue(opts: {
|
|
44
|
+
batchSize?: number;
|
|
45
|
+
lockSeconds?: number;
|
|
46
|
+
}): Promise<JobLease[]>;
|
|
47
|
+
/** Mark a job complete (success). */
|
|
48
|
+
ack(jobId: string): Promise<void>;
|
|
49
|
+
/** Mark a job failed; backend decides retry vs DLQ via attempts. */
|
|
50
|
+
nack(jobId: string, opts: {
|
|
51
|
+
error: string;
|
|
52
|
+
nonRetryable?: boolean;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
/** Optional: return existing jobId if `key` was enqueued within `ttlSeconds`. */
|
|
55
|
+
idempotency?(key: string, ttlSeconds: number): Promise<{
|
|
56
|
+
jobId: string;
|
|
57
|
+
} | null>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Thrown from a job handler to opt out of retry policy. The backend MUST
|
|
61
|
+
* nack with `nonRetryable: true` and permanently remove the job.
|
|
62
|
+
*/
|
|
63
|
+
declare class NonRetryableError extends Error {
|
|
64
|
+
readonly code = "NON_RETRYABLE";
|
|
65
|
+
constructor(message: string);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { type JobBackend as J, NonRetryableError as N, type JobEnqueueInput as a, type JobLease as b };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ViteDevServer } from 'vite';
|
|
2
|
+
|
|
3
|
+
type LoadModule = (path: string) => Promise<Record<string, unknown>>;
|
|
4
|
+
declare function createViteLoader(vite: ViteDevServer): LoadModule;
|
|
5
|
+
declare function createProductionLoader(): LoadModule;
|
|
6
|
+
|
|
7
|
+
interface ServerRouteNode {
|
|
8
|
+
filePath: string;
|
|
9
|
+
routePath: string;
|
|
10
|
+
paramNames: string[];
|
|
11
|
+
pattern: RegExp;
|
|
12
|
+
/** HTTP methods (uppercase) the route file exports. Optional for backward
|
|
13
|
+
* compatibility with manifests generated before G1. Empty array means the
|
|
14
|
+
* file has no HTTP exports (util-only); undefined means "not detected". */
|
|
15
|
+
methods?: string[];
|
|
16
|
+
}
|
|
17
|
+
declare function compilePattern(routePath: string): {
|
|
18
|
+
pattern: RegExp;
|
|
19
|
+
paramNames: string[];
|
|
20
|
+
};
|
|
21
|
+
declare function matchRoute(url: string, routes: ServerRouteNode[]): {
|
|
22
|
+
route: ServerRouteNode;
|
|
23
|
+
params: Record<string, string>;
|
|
24
|
+
} | null;
|
|
25
|
+
|
|
26
|
+
export { type LoadModule as L, type ServerRouteNode as S, createProductionLoader as a, createViteLoader as b, compilePattern as c, matchRoute as m };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { T as TheoPlugin, a as TheoApp, P as PluginContext, H as HookResult, R as RunHookOptions } from './plugin-types-DNJGxr4Z.js';
|
|
2
|
+
|
|
3
|
+
declare class DuplicatePluginError extends Error {
|
|
4
|
+
constructor(name: string);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Per T3.1 (C1 plugin scope encapsulation) — duplicate decoration
|
|
8
|
+
* keys across sibling plugins are now PERMITTED because each plugin gets its
|
|
9
|
+
* own child scope via `Object.create(parent)` (Fastify pattern, ADR-0028
|
|
10
|
+
* blueprint D1). This class is retained for one minor cycle so consumers who
|
|
11
|
+
* `instanceof DuplicateDecorationError` continue to compile; the constructor
|
|
12
|
+
* is no longer reachable from `PluginRunner.register()`. Removal scheduled
|
|
13
|
+
* for 0.x+2 per CHANGELOG.
|
|
14
|
+
*/
|
|
15
|
+
declare class DuplicateDecorationError extends Error {
|
|
16
|
+
constructor(key: string, existingPlugin: string, newPlugin: string);
|
|
17
|
+
}
|
|
18
|
+
declare class PluginRunner {
|
|
19
|
+
private plugins;
|
|
20
|
+
private pluginScopes;
|
|
21
|
+
private onRequestHooks;
|
|
22
|
+
private preHandlerHooks;
|
|
23
|
+
private onResponseHooks;
|
|
24
|
+
private onErrorHooks;
|
|
25
|
+
/**
|
|
26
|
+
* Parent app — proto-chain root for all child scopes. Has its OWN empty
|
|
27
|
+
* decorations map (parent never receives `decorateRequest` calls under
|
|
28
|
+
* the T3.1 contract; only child scopes do).
|
|
29
|
+
*/
|
|
30
|
+
private parentDecorations;
|
|
31
|
+
private parentApp;
|
|
32
|
+
has(name: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Per T3.1 (C1 plugin scope encapsulation):
|
|
35
|
+
* 1. Reserve the plugin name (still rejects duplicates).
|
|
36
|
+
* 2. Build a CHILD TheoApp via `Object.create(parentApp)` — Fastify
|
|
37
|
+
* `plugin-override.js:38` pattern. The child's own `decorateRequest`
|
|
38
|
+
* populates per-scope `decorations`; the child's `addHook` still
|
|
39
|
+
* forwards into the shared hook lists (hooks ARE process-global —
|
|
40
|
+
* only decorations are scoped, mirroring Fastify's decoration vs
|
|
41
|
+
* hook semantics).
|
|
42
|
+
* 3. Invoke `plugin.register(childApp)`.
|
|
43
|
+
*
|
|
44
|
+
* Cross-plugin decoration-key collisions are PERMITTED (per blueprint
|
|
45
|
+
* D1). The legacy `DuplicateDecorationError` is no longer thrown.
|
|
46
|
+
*/
|
|
47
|
+
register(plugin: TheoPlugin): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Build the parent app facade. Hooks forward to shared lists.
|
|
50
|
+
* `decorateRequest` writes into the parent decorations map — used only
|
|
51
|
+
* if a future consumer registers a non-plugin "app-level" decoration
|
|
52
|
+
* directly. T3.1 contract: plugins decorate ONLY through child scopes.
|
|
53
|
+
*/
|
|
54
|
+
private buildParentAppFacade;
|
|
55
|
+
/**
|
|
56
|
+
* Build a child scope via `Object.create(parentApp)` so the child
|
|
57
|
+
* inherits the parent's facade methods through the prototype chain.
|
|
58
|
+
* Then override `decorateRequest` on the child instance so writes
|
|
59
|
+
* land in the per-scope `decorations` map (parent is NOT mutated).
|
|
60
|
+
*/
|
|
61
|
+
private buildPluginScope;
|
|
62
|
+
private routeHookByName;
|
|
63
|
+
/**
|
|
64
|
+
* Apply ALL plugin scopes' decorations into the request ctx. Per T3.1,
|
|
65
|
+
* sibling plugins MAY decorate the same key — last-writer-wins at apply
|
|
66
|
+
* time (ordering = registration order). This keeps the legacy
|
|
67
|
+
* `ctx.<key>` flat surface working for consumers that already aggregate
|
|
68
|
+
* decorations into a single bag.
|
|
69
|
+
*/
|
|
70
|
+
applyDecorations(ctx: Record<string, unknown>): void;
|
|
71
|
+
/**
|
|
72
|
+
* Apply ONLY one plugin's scoped decorations into `target`. Used by
|
|
73
|
+
* the T1.1 RED-3 test (sibling isolation proof) and by future scope-aware
|
|
74
|
+
* dispatch paths. Throws if the plugin name isn't registered.
|
|
75
|
+
*/
|
|
76
|
+
applyScopedDecorations(pluginName: string, target: Record<string, unknown>): void;
|
|
77
|
+
/** T1.1 RED-1/RED-4 introspection: returns the child TheoApp built for `pluginName`. */
|
|
78
|
+
getPluginScope(pluginName: string): TheoApp;
|
|
79
|
+
/** T1.1 RED-4: returns the parent TheoApp (root of every child's proto chain). */
|
|
80
|
+
getParentApp(): TheoApp;
|
|
81
|
+
/** T1.1 RED-2: returns the parent's decorations map (NEVER touched by plugin decorate calls under T3.1 contract). */
|
|
82
|
+
getParentDecorations(): Map<string, unknown>;
|
|
83
|
+
runOnRequest(ctx: PluginContext): Promise<HookResult>;
|
|
84
|
+
runPreHandler(ctx: PluginContext): Promise<HookResult>;
|
|
85
|
+
runOnResponse(ctx: PluginContext, options?: RunHookOptions): Promise<HookResult>;
|
|
86
|
+
/**
|
|
87
|
+
* Run all onError hooks. Swallows errors thrown inside hooks themselves to
|
|
88
|
+
* prevent recursion (an error in an error handler must not trigger onError
|
|
89
|
+
* again).
|
|
90
|
+
*/
|
|
91
|
+
runOnError(ctx: PluginContext, error: unknown): Promise<HookResult>;
|
|
92
|
+
private runHookList;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { DuplicateDecorationError as D, PluginRunner as P, DuplicatePluginError as a };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
|
|
3
|
+
interface PluginContext {
|
|
4
|
+
request: IncomingMessage;
|
|
5
|
+
response: ServerResponse;
|
|
6
|
+
ctx: Record<string, unknown>;
|
|
7
|
+
requestId: string;
|
|
8
|
+
}
|
|
9
|
+
interface PluginErrorContext extends PluginContext {
|
|
10
|
+
error: unknown;
|
|
11
|
+
}
|
|
12
|
+
interface RunHookOptions {
|
|
13
|
+
inErrorPath?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface HookResult {
|
|
16
|
+
shortCircuited: boolean;
|
|
17
|
+
}
|
|
18
|
+
type OnRequestHook = (ctx: PluginContext) => void | Promise<void>;
|
|
19
|
+
type PreHandlerHook = (ctx: PluginContext) => void | Promise<void>;
|
|
20
|
+
type OnResponseHook = (ctx: PluginContext) => void | Promise<void>;
|
|
21
|
+
type OnErrorHook = (ctx: PluginErrorContext) => void | Promise<void>;
|
|
22
|
+
type HookName = 'onRequest' | 'preHandler' | 'onResponse' | 'onError';
|
|
23
|
+
type HookByName<K extends HookName> = K extends 'onError' ? OnErrorHook : K extends 'onRequest' ? OnRequestHook : K extends 'preHandler' ? PreHandlerHook : K extends 'onResponse' ? OnResponseHook : never;
|
|
24
|
+
interface TheoApp {
|
|
25
|
+
addHook<K extends HookName>(name: K, fn: HookByName<K>): void;
|
|
26
|
+
decorateRequest<T>(key: string, value: T): void;
|
|
27
|
+
}
|
|
28
|
+
interface TheoPlugin {
|
|
29
|
+
name: string;
|
|
30
|
+
register(app: TheoApp): void | Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Identity function for plugin authors. Provides auto-completion + type
|
|
34
|
+
* inference at the call site (TanStack/Vite/Astro pattern). Pure runtime
|
|
35
|
+
* no-op — returns the input unchanged.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* import { definePlugin } from 'theokit/server'
|
|
39
|
+
* export default definePlugin({
|
|
40
|
+
* name: 'my-plugin',
|
|
41
|
+
* register(app) {
|
|
42
|
+
* app.addHook('onRequest', (req) => { ... })
|
|
43
|
+
* },
|
|
44
|
+
* })
|
|
45
|
+
*
|
|
46
|
+
* Equivalent to `const p: TheoPlugin = {...}` but more ergonomic. See
|
|
47
|
+
* ADR-0008 (D1 + D6) for the rationale.
|
|
48
|
+
*/
|
|
49
|
+
declare function definePlugin(plugin: TheoPlugin): TheoPlugin;
|
|
50
|
+
/**
|
|
51
|
+
* Web-Standards plugin context. Available during all 4 hook lifecycle
|
|
52
|
+
* stages (onRequest, preHandler, onResponse, onError).
|
|
53
|
+
*
|
|
54
|
+
* - `request` — the incoming Web Request (read-only at the runtime level;
|
|
55
|
+
* plugins can call `request.headers.get()`, `request.clone()`, etc.).
|
|
56
|
+
* - `responseHeaders` — a mutable `Headers` instance the runtime threads
|
|
57
|
+
* through the hook chain. Plugins append (e.g., CORS, Set-Cookie); the
|
|
58
|
+
* final Response composes these.
|
|
59
|
+
* - `response` — set to the handler's Response AFTER the handler returns.
|
|
60
|
+
* Available during `onResponse` / `onError`. `undefined` during
|
|
61
|
+
* `onRequest` / `preHandler` (which fire before the handler runs).
|
|
62
|
+
* - `ctx` / `requestId` — same semantics as the IncomingMessage path.
|
|
63
|
+
*/
|
|
64
|
+
interface WebPluginContext {
|
|
65
|
+
request: Request;
|
|
66
|
+
responseHeaders: Headers;
|
|
67
|
+
response?: Response;
|
|
68
|
+
ctx: Record<string, unknown>;
|
|
69
|
+
requestId: string;
|
|
70
|
+
}
|
|
71
|
+
interface WebPluginErrorContext extends WebPluginContext {
|
|
72
|
+
error: unknown;
|
|
73
|
+
}
|
|
74
|
+
type WebOnRequestHook = (ctx: WebPluginContext) => void | Promise<void>;
|
|
75
|
+
type WebPreHandlerHook = (ctx: WebPluginContext) => void | Promise<void>;
|
|
76
|
+
type WebOnResponseHook = (ctx: WebPluginContext) => void | Promise<void>;
|
|
77
|
+
type WebOnErrorHook = (ctx: WebPluginErrorContext) => void | Promise<void>;
|
|
78
|
+
|
|
79
|
+
export { type HookResult as H, type OnErrorHook as O, type PluginContext as P, type RunHookOptions as R, type TheoPlugin as T, type WebOnRequestHook as W, type TheoApp as a, type WebPreHandlerHook as b, type WebOnResponseHook as c, type WebOnErrorHook as d, type HookName as e, type OnRequestHook as f, type OnResponseHook as g, type PluginErrorContext as h, type PreHandlerHook as i, definePlugin as j };
|