theokit 0.12.0 → 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.
- package/dist/{actions-virtual-module-SQDY3V5X.js → actions-virtual-module-3CDQTWOC.js} +6 -6
- package/dist/{actions-virtual-module-PNPRCEOS.js → actions-virtual-module-EIPXX4ZB.js} +3 -3
- 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/agents-typed-client-SAWAAH7K.js +142 -0
- package/dist/agents-typed-client-SAWAAH7K.js.map +1 -0
- package/dist/agents-typed-client-UTEQUA63.js +143 -0
- package/dist/agents-typed-client-UTEQUA63.js.map +1 -0
- package/dist/{app-typed-client-5GYEOYP3.js → app-typed-client-7PBFWZUE.js} +3 -3
- package/dist/{app-typed-client-QG7BVZYW.js → app-typed-client-CSOK7NPC.js} +6 -6
- package/dist/audit-log-BQWM5YLG.d.ts +60 -0
- package/dist/body-parser-web-FV5HWCY3.js +71 -0
- package/dist/body-parser-web-FV5HWCY3.js.map +1 -0
- package/dist/boot/index.d.ts +39 -0
- package/dist/{build-QFRLSEZ4.js → build-HXND27XG.js} +11 -11
- package/dist/{chunk-223EFY5X.js → chunk-2J7XU3PW.js} +68 -27
- package/dist/chunk-2J7XU3PW.js.map +1 -0
- package/dist/{chunk-RESN62GB.js → chunk-2KZQPDYR.js} +5 -48
- package/dist/chunk-2KZQPDYR.js.map +1 -0
- package/dist/chunk-3S3BNW5K.js +445 -0
- package/dist/chunk-3S3BNW5K.js.map +1 -0
- package/dist/{chunk-6FYD34NX.js → chunk-BQDGES7C.js} +28 -28
- package/dist/{chunk-6FYD34NX.js.map → chunk-BQDGES7C.js.map} +1 -1
- package/dist/chunk-EXP56GFQ.js +52 -0
- package/dist/chunk-EXP56GFQ.js.map +1 -0
- package/dist/chunk-F4YUPDJ2.js +115 -0
- package/dist/chunk-F4YUPDJ2.js.map +1 -0
- package/dist/{chunk-NAZ4E2GT.js → chunk-KXA37ONC.js} +2 -2
- package/dist/chunk-NHJMZCAS.js +32 -0
- package/dist/chunk-NHJMZCAS.js.map +1 -0
- package/dist/{chunk-43D6XNDR.js → chunk-O62MW4MT.js} +91 -18
- package/dist/chunk-O62MW4MT.js.map +1 -0
- package/dist/chunk-RSVN727G.js +1 -0
- package/dist/{chunk-7CBRKNQA.js → chunk-RYTZYFSD.js} +198 -6
- package/dist/chunk-RYTZYFSD.js.map +1 -0
- package/dist/chunk-UNLA45FY.js +235 -0
- package/dist/chunk-UNLA45FY.js.map +1 -0
- package/dist/{chunk-GFMQJHXX.js → chunk-WR4F4EEZ.js} +1082 -1074
- package/dist/chunk-WR4F4EEZ.js.map +1 -0
- package/dist/{chunk-AD74EAK3.js → chunk-ZSTZXR2D.js} +1 -30
- package/dist/chunk-ZSTZXR2D.js.map +1 -0
- package/dist/cli/index.js +5 -5
- package/dist/client/index.d.ts +418 -0
- package/dist/client/index.js +84 -3
- package/dist/client/index.js.map +1 -1
- 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/{dev-GBXOTXUP.js → dev-OWW4XVIH.js} +10 -10
- package/dist/{dev-emit-FEFEDLZF.js → dev-emit-5MDSBP5D.js} +3 -3
- package/dist/{dev-emit-O4EGOSNV.js → dev-emit-QH2YGZXN.js} +2 -2
- 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/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/internal-api-4YTJDITC.js +83 -0
- package/dist/internal-api-EFKZWIYZ.js +66 -0
- package/dist/internal-api-EFKZWIYZ.js.map +1 -0
- package/dist/job-backend-CgC8Xf33.d.ts +68 -0
- package/dist/match-CfbEFRG4.d.ts +26 -0
- package/dist/{openapi-VR6AFBLJ.js → openapi-FHY6HC6I.js} +7 -7
- 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/{registry-Q2TZQLUH.js → registry-34LL7NF4.js} +1 -1
- package/dist/{routes-LRYOIIAI.js → routes-EW7TP7NJ.js} +2 -2
- package/dist/schema-BpH6ivDY.d.ts +74 -0
- package/dist/server/agent/index.d.ts +229 -0
- package/dist/server/agent/index.js +2 -1
- 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/define/index.js +4 -2
- package/dist/server/http/index.d.ts +11 -0
- package/dist/server/index.d.ts +848 -0
- package/dist/server/index.js +9 -294
- package/dist/server/index.js.map +1 -1
- 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 +126 -0
- package/dist/server/scan/index.js +1 -1
- 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/{start-3ZHAXSJE.js → start-KIQ5TTLR.js} +76 -13
- package/dist/start-KIQ5TTLR.js.map +1 -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/dist/vite-plugin/index.js +6 -4
- package/dist/{vite-plugin-WO72VLYR.js → vite-plugin-RK66K26Z.js} +7 -7
- package/dist/vite-plugin-RK66K26Z.js.map +1 -0
- package/package.json +4 -4
- package/dist/chunk-223EFY5X.js.map +0 -1
- package/dist/chunk-3LVRAGAZ.js +0 -73
- package/dist/chunk-3LVRAGAZ.js.map +0 -1
- package/dist/chunk-43D6XNDR.js.map +0 -1
- package/dist/chunk-7CBRKNQA.js.map +0 -1
- package/dist/chunk-AD74EAK3.js.map +0 -1
- package/dist/chunk-GFMQJHXX.js.map +0 -1
- package/dist/chunk-PBEH6NXR.js +0 -44
- package/dist/chunk-PBEH6NXR.js.map +0 -1
- package/dist/chunk-PIVX3DYW.js +0 -142
- package/dist/chunk-PIVX3DYW.js.map +0 -1
- package/dist/chunk-PPPR5DGR.js +0 -1
- package/dist/chunk-RESN62GB.js.map +0 -1
- package/dist/start-3ZHAXSJE.js.map +0 -1
- /package/dist/{actions-virtual-module-SQDY3V5X.js.map → actions-virtual-module-3CDQTWOC.js.map} +0 -0
- /package/dist/{actions-virtual-module-PNPRCEOS.js.map → actions-virtual-module-EIPXX4ZB.js.map} +0 -0
- /package/dist/{app-typed-client-5GYEOYP3.js.map → app-typed-client-7PBFWZUE.js.map} +0 -0
- /package/dist/{app-typed-client-QG7BVZYW.js.map → app-typed-client-CSOK7NPC.js.map} +0 -0
- /package/dist/{build-QFRLSEZ4.js.map → build-HXND27XG.js.map} +0 -0
- /package/dist/{chunk-NAZ4E2GT.js.map → chunk-KXA37ONC.js.map} +0 -0
- /package/dist/{chunk-PPPR5DGR.js.map → chunk-RSVN727G.js.map} +0 -0
- /package/dist/{dev-GBXOTXUP.js.map → dev-OWW4XVIH.js.map} +0 -0
- /package/dist/{dev-emit-FEFEDLZF.js.map → dev-emit-5MDSBP5D.js.map} +0 -0
- /package/dist/{dev-emit-O4EGOSNV.js.map → dev-emit-QH2YGZXN.js.map} +0 -0
- /package/dist/{vite-plugin-WO72VLYR.js.map → internal-api-4YTJDITC.js.map} +0 -0
- /package/dist/{openapi-VR6AFBLJ.js.map → openapi-FHY6HC6I.js.map} +0 -0
- /package/dist/{registry-Q2TZQLUH.js.map → registry-34LL7NF4.js.map} +0 -0
- /package/dist/{routes-LRYOIIAI.js.map → routes-EW7TP7NJ.js.map} +0 -0
|
@@ -0,0 +1,848 @@
|
|
|
1
|
+
import { RouteConfig } from './define/index.js';
|
|
2
|
+
export { ActionAccept, ActionConfig, AgentEndpointConfig, AgentEndpointHandlerArgs, ChannelHandler, CustomTool, DefineAgentToolSpec, MiddlewareHandler, WebChannelHandler, defineAction, defineAgentEndpoint, defineAgentTool, defineChannel, defineMiddleware, defineRoute, defineTheoPlugin, defineWebChannel, uiMessageStreamResponse } from './define/index.js';
|
|
3
|
+
export { W as WebSocketHandler, a as WebSocketHandlerWeb, b as WebSocketLike, d as defineWebSocket, c as defineWebSocketWeb } from '../define-websocket-CdK94O-D.js';
|
|
4
|
+
export { H as HEALTH_PATH, a as HealthRouteConfig, b as READY_PATH, c as ReadyRouteConfig, d as ReservedResponse, R as ReservedRoutes, e as defineHealthRoute, f as defineReadyRoute, s as serveReservedRoute } from '../health-route-C0hk64_U.js';
|
|
5
|
+
export { B as BATCH_PATH, a as BatchExecuteFn, b as BatchPathConflictError, c as BatchPayload, d as BatchRequestItem, e as BatchResponse, f as BatchResultItem, C as CookieOptions, g as CorsConfig, h as CorsHandler, i as CorsOrigin, j as CorsWebHandler, k as CustomErrorPages, E as ExecuteActionOptions, l as ExecuteRouteContext, H as HandleBatchOptions, M as MAX_ERROR_HTML_BYTES, m as MiddlewareResult, N as NotFoundError, S as STRIPPED_HEADERS, n as SendErrorInput, o as SendErrorOptions, T as TRACE_HEADER, p as TRACE_PARENT_HEADER, q as TheoError, r as TheoTransformer, _ as _resetMiddlewareCacheForTests, s as appendCookieToHeaders, t as appendDeleteCookieToHeaders, u as createCorsHandler, v as createCorsWebHandler, w as deleteCookie, x as envelopeCodeToStatus, y as executeAction, z as executeRoute, A as extractTraceId, D as extractTraceIdFromRequest, F as fromUnknown, G as getCookie, I as getCookieFromRequest, J as handleBatchRequest, K as handleRequestError, L as handleWebRequestError, O as jsonTransformer, P as loadCustomErrorPages, Q as matchesOrigin, R as parseCookieHeader, U as parseTraceparent, V as resolveTransformer, W as runMiddlewareAndContext, X as sendError, Y as sendJson, Z as serializeCookie, $ as serveStaticFile, a0 as serverErrorToEnvelope, a1 as setCookie, a2 as superjsonTransformer } from '../index-B40qUSrQ.js';
|
|
6
|
+
export { ActionNode, ActionScanError, LoadedManifest, ManifestAction, ManifestAgent, ManifestRoute, ManifestWebSocket, TheoManifest, WebSocketRouteNode, generateManifest, loadManifest, scanMiddlewares, scanServerActions, scanServerActionsEnriched, scanServerRoutes, scanWebSocketRoutes, writeManifest } from './scan/index.js';
|
|
7
|
+
export { L as LoadModule, S as ServerRouteNode, c as compilePattern, a as createProductionLoader, b as createViteLoader, m as matchRoute } from '../match-CfbEFRG4.js';
|
|
8
|
+
import { T as TheoErrorEnvelope, a as TheoErrorCode, V as ValidationFieldsExt } from '../error-envelope-BsNzzAV5.js';
|
|
9
|
+
export { AgentRunLike, AgentRunResult, AgentRunStreamMessage, ConversationHistoryArgs, ConversationHistoryResult, ConversationStorageLike, SdkAgent, SdkAgentOptions, SdkRunLike, createConversationHistory, errorToEvent, streamAgentRun } from './agent/index.js';
|
|
10
|
+
export { a as AgentErrorEvent, A as AgentEvent, b as AgentMessageEvent, f as AgentRunErrorCode, c as AgentThinkingEvent, d as AgentToolCallEvent, e as AgentToolResultEvent } from '../agent-events-DosDXkSV.js';
|
|
11
|
+
export { AuthRequiredError, BackupCode, BackupCodeOptions, OidcMetadata, PkceChallenge, SessionConfig, SessionManager, SessionManagerWeb, SessionMeta, ThrottleOptions, ThrottleState, TotpAlgorithm, TotpOptions, TotpUriOptions, VerifyTotpOptions, _resetKeyCacheForTests, assertProductionSecret, checkThrottle, clearOidcCache, createSessionManager, createSessionManagerWeb, decrypt, discoverOidcProvider, encrypt, generateBackupCodes, generateNonce, generateOAuthState, generatePkceChallenge, generateTotp, generateTotpSecret, pkceChallengeFromVerifier, recordAttempt, requireAuth, rotateIfNeeded, rotateIfNeededWeb, totpUri, verifyBackupCode, verifyOAuthState, verifyTotp } from './auth/index.js';
|
|
12
|
+
export { InMemoryUsageStorage, ToolHookEvent, ToolUsageRecord, TrackAgentRunInput, TrackAgentRunOptions, TrackAgentToolsHooks, TrackAgentToolsOptions, UsageQuery, UsageRecord, UsageResult, UsageStorageAdapter, trackAgentRun, trackAgentTools } from './cost/index.js';
|
|
13
|
+
export { CRON_MANIFEST_SCHEMA_VERSION, CronConcurrencyPolicy, CronContext, CronDefinition, CronManifest, CronManifestEntry, CronNode, CronOptions, CronScheduler, DuplicateCronNameError, ExistingConfigUnparseableError, buildCronManifest, convertToAwsCron, createCronScheduler, defineCron, scanCrons, translateCronToAws, translateCronToCloudflare, translateCronToDeno, translateCronToVercel, validateCronSchedule, writeCronManifest } from './cron/index.js';
|
|
14
|
+
export { DuplicateContextKeyError, DuplicateJobNameError, EnqueueOptions, InMemoryJobBackend, InMemoryJobBackendOptions, JOB_MANIFEST_SCHEMA_VERSION, JobContext, JobDefinition, JobManifest, JobManifestEntry, JobNode, JobOptions, JobRegistry, JobRunner, Outbox, OutboxFlushOptions, PostgresJobBackend, PostgresJobBackendOptions, QueueClient, buildJobManifest, createJobRunner, createOutbox, createOutboxDispatcher, createQueueClient, defineJob, scanJobs, writeJobManifest } from './jobs/index.js';
|
|
15
|
+
export { J as JobBackend, a as JobEnqueueInput, b as JobLease, N as NonRetryableError } from '../job-backend-CgC8Xf33.js';
|
|
16
|
+
export { ConsoleObservabilityAdapter, LogLevel, LoggerFn, NoopObservabilityAdapter, NoopSpan, ObservabilityAdapter, RequestLog, SpanAttributes, SpanHandle, SpanImpl, StructuredLog, TheoCloudObservabilityAdapter, TheoLogger, _resetWarnOnceForTests, createLogger, createObservabilityPlugin, defineObservabilityAdapter, findSuggestion, levenshtein, logRequest, resolveAdapter, serializeSpansToOtlp, warnOnce } from './observability/index.js';
|
|
17
|
+
export { a as AuditEvent, A as AuditLogger, J as JsonStdoutSink, c as createNoOpLogger, s as safeAudit } from '../audit-log-BQWM5YLG.js';
|
|
18
|
+
export { D as DuplicateDecorationError, a as DuplicatePluginError, P as PluginRunner } from '../plugin-runner-BGBkzgi0.js';
|
|
19
|
+
export { InvalidPluginShapeError, createPluginRunnerFromConfig } from './plugins/index.js';
|
|
20
|
+
export { R as RateLimitConfig, a as RateLimitResult, c as createRateLimiter, b as createRateLimiterWeb } from '../rate-limit-BdNDZ3vt.js';
|
|
21
|
+
export { I as InMemoryStore, a as RateLimitState, R as RateLimitStore } from '../rate-limit-store-BEJnhWdw.js';
|
|
22
|
+
export { DeriveKeyRequestContext, KeyByMode, RouteRateLimitConfig, createRouteRateLimiter, createRouteRateLimiterWeb, deriveKey, deriveKeyFromRequest, matchRoutePattern } from './rate-limit/index.js';
|
|
23
|
+
export { ChannelManager } from './realtime/index.js';
|
|
24
|
+
export { CSP_REPORT_PATH, CSRF_READINESS_PATH, CSRF_READINESS_RESET_PATH, CspMode, CspReportHandlerOptions, CspViolation, DEFAULT_CSP, DEFAULT_PERMISSIONS_POLICY, SecurityEnv, SecurityHeadersConfig, SecurityHeadersOptions, applySecurityHeaders, buildSecurityHeaders, handleCspReport, handleCspReportRequest, handleCsrfReadiness, handleCsrfReadinessRequest, normalizeLegacy, normalizeNew } from './security/index.js';
|
|
25
|
+
export { C as CSRF_WARN_CODE, a as CSRF_WARN_DOCS_URL, b as CsrfLogger, c as CsrfMode, d as CsrfWarnPayload, D as DisallowedConfig, e as enforceCsrf, m as matchDisallowed, v as validateCsrf, f as validateCsrfRequest } from '../csrf-BBrEZSBW.js';
|
|
26
|
+
export { a as CsrfReadinessRouteSummary, C as CsrfReadinessStore, b as CsrfReadinessSummary, c as CsrfWarnRecord } from '../csrf-readiness-store-CjIoub3U.js';
|
|
27
|
+
export { P as PostgresFactory, R as RedisFactory, S as StorageManager, g as getStorageManager } from '../storage-manager-C4jsO0Tp.js';
|
|
28
|
+
export { Db0Database, UnstorageInstance, useDatabase, useUnstorage } from './storage/index.js';
|
|
29
|
+
export { G as GenericFactory, a as PoolLike, P as PostgresDatabaseConfig, c as RedisLike, R as RedisServerConfig, S as ServerConfig, d as StorageAdapter, b as StorageConfig, T as TlsConfig } from '../storage-types-DsDTCPbp.js';
|
|
30
|
+
export { BodyTooLargeError, DEFAULT_MAX_BODY_BYTES, DefineWebhookOptions, RawBodyResult, ReadRawBodyOptions, VerifyFn, VerifyResult, WebhookContext, WebhookDefinition, defineWebhook, dispatchWebhook, readRawBody, timingSafeEqual } from './webhook/index.js';
|
|
31
|
+
import { z } from 'zod';
|
|
32
|
+
import { IncomingMessage } from 'node:http';
|
|
33
|
+
import { W as WebOnRequestHook, b as WebPreHandlerHook, c as WebOnResponseHook, d as WebOnErrorHook } from '../plugin-types-DNJGxr4Z.js';
|
|
34
|
+
export { e as HookName, H as HookResult, O as OnErrorHook, f as OnRequestHook, g as OnResponseHook, P as PluginContext, h as PluginErrorContext, i as PreHandlerHook, R as RunHookOptions, a as TheoApp, T as TheoPlugin, j as definePlugin } from '../plugin-types-DNJGxr4Z.js';
|
|
35
|
+
export { a as ServiceDefinition, S as ServicesConfig, b as ServicesConfigInput, c as ServicesConfigOutput } from '../schema-BpH6ivDY.js';
|
|
36
|
+
import 'ai';
|
|
37
|
+
import 'vite';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Action protocol — cross-boundary contract for `defineAction` + `useAction`.
|
|
41
|
+
*
|
|
42
|
+
* Per plan g3-server-actions-and-useaction v1.2 § Phase 0 / T0.1, ADRs D1 (encoding)
|
|
43
|
+
* + D6 (full dot-notation path) + D7 (PII mask) — types and runtime referenced
|
|
44
|
+
* by server (`server/http/action-execute.ts`, `server/define/define-action.ts`)
|
|
45
|
+
* and client (`@theokit/react/useAction`, `vite-plugin/actions-virtual-module`).
|
|
46
|
+
*
|
|
47
|
+
* Lives in `core/contracts/` per architecture.md v3.1 exception — cross-module
|
|
48
|
+
* deep imports ALLOWED for this file. Core depends on NOTHING intra-monorepo;
|
|
49
|
+
* `extractUniversalIssues` is implemented INLINE (NOT imported from `@theokit/sdk`)
|
|
50
|
+
* to honor dep-cruiser `core-depends-on-nothing` invariant (EC-1 absorbed).
|
|
51
|
+
*
|
|
52
|
+
* Field-key convention (D6 + EC-13): dot-notation full path. Nested objects use
|
|
53
|
+
* `'user.address.zip'`; array indices use `'items.0.name'` (NOT bracket
|
|
54
|
+
* `'items[0].name'`). Root-level errors (path = []) use empty string `''`
|
|
55
|
+
* (EC-7). Consumers needing bracket notation can write a small `dotToBracket`
|
|
56
|
+
* helper in userland.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* HTTP-status mapping per IANA HTTP Status Code Registry (subset relevant to
|
|
61
|
+
* action surface). VALIDATION_ERROR → 422 is preferred over Astro's BAD_REQUEST/400
|
|
62
|
+
* (more semantic for input-shape mismatch). PAYLOAD_TOO_LARGE → 413 covers EC-3
|
|
63
|
+
* (response-side size limit; request-side reuses standard 413).
|
|
64
|
+
*/
|
|
65
|
+
type ActionErrorCode = 'VALIDATION_ERROR' | 'BAD_REQUEST' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'METHOD_NOT_ALLOWED' | 'CONFLICT' | 'CONTENT_TOO_LARGE' | 'PAYLOAD_TOO_LARGE' | 'UNSUPPORTED_MEDIA_TYPE' | 'TOO_MANY_REQUESTS' | 'INTERNAL_SERVER_ERROR';
|
|
66
|
+
/**
|
|
67
|
+
* Universal zod issue shape covering BOTH v3 (`z.ZodIssue`) and v4 (`$ZodIssue`).
|
|
68
|
+
* Duck-typed minimum surface: `{path, message}`. Implemented per EC-1 absorbed —
|
|
69
|
+
* consumers chain may ship either zod major; constructor accepts `unknown` and
|
|
70
|
+
* normalizes via `extractUniversalIssues`.
|
|
71
|
+
*/
|
|
72
|
+
interface UniversalZodIssue {
|
|
73
|
+
readonly path: readonly (string | number)[];
|
|
74
|
+
readonly message: string;
|
|
75
|
+
readonly code?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* `ActionError` — general server-side action failure. Discriminator `type` is
|
|
79
|
+
* literal `'TheoActionError'`; used by `ActionError.fromJson` to distinguish
|
|
80
|
+
* from `ActionInputError`.
|
|
81
|
+
*/
|
|
82
|
+
declare class ActionError extends Error {
|
|
83
|
+
readonly type: 'TheoActionError' | 'TheoActionInputError';
|
|
84
|
+
readonly code: ActionErrorCode;
|
|
85
|
+
readonly status: number;
|
|
86
|
+
constructor(params: {
|
|
87
|
+
code: ActionErrorCode;
|
|
88
|
+
message?: string;
|
|
89
|
+
stack?: string;
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* G5 T2.4 — canonical envelope view of the action error. Maps the G3
|
|
93
|
+
* ActionErrorCode to a canonical TheoErrorCode (VALIDATION_ERROR ↔
|
|
94
|
+
* UNPROCESSABLE_ENTITY, CONTENT_TOO_LARGE ↔ PAYLOAD_TOO_LARGE) so consumer
|
|
95
|
+
* UI / SDK code can switch on the unified envelope.
|
|
96
|
+
*
|
|
97
|
+
* Subclasses override to populate `ext` (see `ActionInputError.envelope`).
|
|
98
|
+
*/
|
|
99
|
+
get envelope(): TheoErrorEnvelope;
|
|
100
|
+
/**
|
|
101
|
+
* Translate G3 ActionErrorCode → canonical TheoErrorCode (blueprint
|
|
102
|
+
* Recommendations § "G3 ActionError becomes inaugural envelope user").
|
|
103
|
+
*/
|
|
104
|
+
static toTheoErrorCode(code: ActionErrorCode): TheoErrorCode;
|
|
105
|
+
static codeToStatus(code: ActionErrorCode): number;
|
|
106
|
+
static statusToCode(status: number): ActionErrorCode;
|
|
107
|
+
/**
|
|
108
|
+
* Parse a serialized error JSON back into the typed class hierarchy.
|
|
109
|
+
* Distinguishes `TheoActionInputError` (with `issues` array) from
|
|
110
|
+
* `TheoActionError` via the `type` discriminator. Falls back to
|
|
111
|
+
* `INTERNAL_SERVER_ERROR` for malformed bodies (non-object, missing
|
|
112
|
+
* `type`, unknown `code`).
|
|
113
|
+
*/
|
|
114
|
+
static fromJson(body: unknown): ActionError;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* `ActionInputError` — validation failure with field-level mapping.
|
|
118
|
+
*
|
|
119
|
+
* `fields` is auto-derived from `issues`: for each issue, key = full
|
|
120
|
+
* dot-notation path (`'user.address.zip'`; root-level `path:[]` → `''`;
|
|
121
|
+
* array indices as numeric segments → `'items.0.name'`). Multiple messages
|
|
122
|
+
* for the same key accumulate; duplicate (path, message) tuples are deduped.
|
|
123
|
+
*/
|
|
124
|
+
declare class ActionInputError extends ActionError {
|
|
125
|
+
readonly type: "TheoActionInputError";
|
|
126
|
+
readonly issues: readonly UniversalZodIssue[];
|
|
127
|
+
readonly fields: Record<string, string[]>;
|
|
128
|
+
constructor(rawIssues: unknown);
|
|
129
|
+
/**
|
|
130
|
+
* G5 T2.4 — envelope view with ValidationFieldsExt populated from .fields.
|
|
131
|
+
* UI consumers can `switch (env.code)` on `UNPROCESSABLE_ENTITY` and read
|
|
132
|
+
* `(env.ext as ValidationFieldsExt).fields` for field-level rendering.
|
|
133
|
+
*/
|
|
134
|
+
get envelope(): TheoErrorEnvelope<ValidationFieldsExt>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Normalize zod v3 (`z.ZodIssue`) and v4 (`$ZodIssue`) raw issues to
|
|
138
|
+
* `UniversalZodIssue[]` (EC-1 absorbed). Duck-typed on `{path, message}` —
|
|
139
|
+
* does NOT import zod types (`core/contracts/` depends on no intra-monorepo
|
|
140
|
+
* + zod is consumer-controlled across the boundary).
|
|
141
|
+
*
|
|
142
|
+
* Silently skips entries missing required fields or shape mismatches; returns
|
|
143
|
+
* empty array on non-array input.
|
|
144
|
+
*/
|
|
145
|
+
declare function extractUniversalIssues(raw: unknown): UniversalZodIssue[];
|
|
146
|
+
/**
|
|
147
|
+
* Type guard for `ActionError` (and its subclass `ActionInputError`). True
|
|
148
|
+
* iff the value is an instance of `ActionError`. Use `isInputError` to
|
|
149
|
+
* narrow specifically to validation failures.
|
|
150
|
+
*/
|
|
151
|
+
declare function isActionError(value: unknown): value is ActionError;
|
|
152
|
+
/**
|
|
153
|
+
* Type guard narrowing to `ActionInputError`. Requires `instanceof` check
|
|
154
|
+
* (not duck-typing on `type`) to prevent attacker-controlled JSON from
|
|
155
|
+
* being mistaken for a real error instance.
|
|
156
|
+
*/
|
|
157
|
+
declare function isInputError(value: unknown): value is ActionInputError;
|
|
158
|
+
/**
|
|
159
|
+
* `ActionResult<TData, TError>` — discriminated union returned by client-side
|
|
160
|
+
* action invocation. Either `{data, error: undefined}` (success) or
|
|
161
|
+
* `{data: undefined, error}` (failure). Mirrors Astro `SafeResult` shape.
|
|
162
|
+
*/
|
|
163
|
+
type ActionResult<TData = unknown, TError extends ActionError = ActionError> = {
|
|
164
|
+
data: TData;
|
|
165
|
+
error: undefined;
|
|
166
|
+
} | {
|
|
167
|
+
data: undefined;
|
|
168
|
+
error: TError;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* `SerializedActionResult` — wire-shape emitted by `serializeActionResult`
|
|
172
|
+
* in `server/http/serialize-action-result.ts` (T1.3). Discriminator `type`
|
|
173
|
+
* distinguishes data (devalue-encoded), error (JSON), and empty (204) cases.
|
|
174
|
+
*/
|
|
175
|
+
type SerializedActionResult = {
|
|
176
|
+
type: 'data';
|
|
177
|
+
status: number;
|
|
178
|
+
contentType: 'application/json+devalue';
|
|
179
|
+
body: string;
|
|
180
|
+
} | {
|
|
181
|
+
type: 'error';
|
|
182
|
+
status: number;
|
|
183
|
+
contentType: 'application/json';
|
|
184
|
+
body: string;
|
|
185
|
+
} | {
|
|
186
|
+
type: 'empty';
|
|
187
|
+
status: 204;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* `ActionManifestEntry` — per-action metadata emitted by `action-scan.ts`
|
|
191
|
+
* (T1.4) into `.theokit/actions-manifest.json`. Consumed by virtual module
|
|
192
|
+
* `@theo/actions` (T3.1) and G4 devtools "Actions" tab (T5.1).
|
|
193
|
+
*/
|
|
194
|
+
interface ActionManifestEntry {
|
|
195
|
+
readonly name: string;
|
|
196
|
+
readonly filePath: string;
|
|
197
|
+
readonly urlPath: string;
|
|
198
|
+
readonly accept: 'form' | 'json';
|
|
199
|
+
readonly hasInput: boolean;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
interface OpenApiDocsOptions {
|
|
203
|
+
/** Path to serve Scalar UI (default: '/api/docs'). */
|
|
204
|
+
docsPath?: string;
|
|
205
|
+
/** Path to serve the JSON spec (default: '/api/docs/openapi.json'). */
|
|
206
|
+
openapiJsonPath?: string;
|
|
207
|
+
/** Path to the spec file on disk (default: '.theokit/openapi.json'). */
|
|
208
|
+
specFilePath?: string;
|
|
209
|
+
/** Page title (default: 'API Reference'). */
|
|
210
|
+
pageTitle?: string;
|
|
211
|
+
/** Scalar CDN URL (default: jsdelivr). Must be HTTPS. */
|
|
212
|
+
cdnUrl?: string;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Creates a request handler that serves OpenAPI docs.
|
|
216
|
+
* Returns `null` for non-matching requests (passthrough).
|
|
217
|
+
*/
|
|
218
|
+
declare function createOpenApiHandler(opts?: OpenApiDocsOptions): (request: Request) => Response | null;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* A cached value persisted by a CacheStorageAdapter.
|
|
222
|
+
*
|
|
223
|
+
* For function caches: `status`/`headers` carry no semantics (use 200 + []).
|
|
224
|
+
* For route caches: `status` + `headers` reproduce the original Response.
|
|
225
|
+
*
|
|
226
|
+
* `body` is always a serialized payload (string or binary). The caller
|
|
227
|
+
* (engine + middleware) owns serialization/deserialization.
|
|
228
|
+
*/
|
|
229
|
+
interface CacheEntry {
|
|
230
|
+
body: string | Uint8Array;
|
|
231
|
+
status: number;
|
|
232
|
+
headers: [string, string][];
|
|
233
|
+
/** epoch ms when written */
|
|
234
|
+
storedAt: number;
|
|
235
|
+
/** seconds; validity window from storedAt */
|
|
236
|
+
maxAge: number;
|
|
237
|
+
/** seconds; stale window after maxAge expires */
|
|
238
|
+
swr: number;
|
|
239
|
+
/** accumulated tags (user + path-derived) */
|
|
240
|
+
tags: string[];
|
|
241
|
+
/** header names that affect the key (informational; key already includes them) */
|
|
242
|
+
vary?: string[];
|
|
243
|
+
/** explicit version stamp; mismatch bypasses cache */
|
|
244
|
+
cacheVersion?: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Hot-path storage contract — every request hits these 4 methods.
|
|
248
|
+
*
|
|
249
|
+
* ISP split (T4.4 of architecture-review-remediation-plan, PV-8): an adapter
|
|
250
|
+
* author implementing a Redis/D1/KV backend can implement ONLY this surface
|
|
251
|
+
* (admin methods are optional via `CacheStoreAdmin`).
|
|
252
|
+
*
|
|
253
|
+
* Invariants:
|
|
254
|
+
* - `get(key)` returns `undefined` if missing — never throws.
|
|
255
|
+
* - `set(key, entry)` is idempotent (last write wins).
|
|
256
|
+
* - `delete(key)` is idempotent (returns false if missing, never throws).
|
|
257
|
+
* - `deleteByTag(tag)` removes ALL entries carrying the tag and returns the count.
|
|
258
|
+
* - Tag index invariant: `get(key)?.tags.includes(tag)` ↔ `deleteByTag(tag)` removes `key`.
|
|
259
|
+
*
|
|
260
|
+
* Complexity (in-memory reference impl):
|
|
261
|
+
* - get/set/delete: O(1) amortized.
|
|
262
|
+
* - deleteByTag: O(matched-keys) via reverse index.
|
|
263
|
+
*/
|
|
264
|
+
interface CacheStore {
|
|
265
|
+
readonly name: string;
|
|
266
|
+
get(key: string): Promise<CacheEntry | undefined>;
|
|
267
|
+
set(key: string, entry: CacheEntry): Promise<void>;
|
|
268
|
+
delete(key: string): Promise<boolean>;
|
|
269
|
+
/** Fan-out invalidation by tag. Returns # entries removed. */
|
|
270
|
+
deleteByTag(tag: string): Promise<number>;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Admin surface — used by tests, devtools, debug introspection.
|
|
274
|
+
*
|
|
275
|
+
* Optional for third-party adapters. Engine guards admin calls with `typeof`
|
|
276
|
+
* checks so a hot-only adapter works correctly in production.
|
|
277
|
+
*/
|
|
278
|
+
interface CacheStoreAdmin {
|
|
279
|
+
size(): Promise<number>;
|
|
280
|
+
clear(): Promise<void>;
|
|
281
|
+
keys(prefix?: string): AsyncIterableIterator<string>;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Full storage backend contract — Hot path + Admin combined.
|
|
285
|
+
*
|
|
286
|
+
* The framework's `InMemoryCacheAdapter` implements both. Public type
|
|
287
|
+
* `CacheStorageAdapter = CacheStore & Partial<CacheStoreAdmin>` (backward
|
|
288
|
+
* compatible: existing implementations declaring all 7 methods continue to
|
|
289
|
+
* satisfy the type; new minimal implementations may omit admin).
|
|
290
|
+
*/
|
|
291
|
+
type CacheStorageAdapter = CacheStore & Partial<CacheStoreAdmin>;
|
|
292
|
+
|
|
293
|
+
type CacheStatus = 'hit' | 'stale' | 'miss';
|
|
294
|
+
interface CacheEngineOptions {
|
|
295
|
+
storage: CacheStorageAdapter;
|
|
296
|
+
defaults?: {
|
|
297
|
+
maxAge?: number;
|
|
298
|
+
swr?: number;
|
|
299
|
+
cacheVersion?: string;
|
|
300
|
+
};
|
|
301
|
+
onError?: (err: unknown, ctx: {
|
|
302
|
+
phase: 'get' | 'set' | 'revalidate';
|
|
303
|
+
key: string;
|
|
304
|
+
}) => void;
|
|
305
|
+
}
|
|
306
|
+
interface GetOrComputeOptions<T> {
|
|
307
|
+
maxAge: number;
|
|
308
|
+
swr?: number;
|
|
309
|
+
tags?: string[];
|
|
310
|
+
cacheVersion?: string;
|
|
311
|
+
transform?: (raw: T) => T;
|
|
312
|
+
validate?: (raw: T) => boolean;
|
|
313
|
+
/**
|
|
314
|
+
* When `true`, the value is returned but NOT written to cache.
|
|
315
|
+
* Used by route middleware to bypass cache for uncacheable responses
|
|
316
|
+
* (Set-Cookie, oversized body, status >= 400 with cacheErrors=false).
|
|
317
|
+
*/
|
|
318
|
+
skipCacheWhen?: (raw: T) => boolean;
|
|
319
|
+
}
|
|
320
|
+
interface CacheEngine {
|
|
321
|
+
getOrCompute<T>(key: string, fn: () => Promise<T>, opts: GetOrComputeOptions<T>): Promise<{
|
|
322
|
+
value: T;
|
|
323
|
+
status: CacheStatus;
|
|
324
|
+
}>;
|
|
325
|
+
/**
|
|
326
|
+
* Public canonical cache read (T4.2 of architecture-review-remediation-plan,
|
|
327
|
+
* PV-5 DRY consolidation). Returns the parsed value + status (`hit` | `stale`)
|
|
328
|
+
* for callers that DON'T want to bind a loader function (e.g., HTTP route
|
|
329
|
+
* middleware that may want to bypass on miss instead of running a loader).
|
|
330
|
+
*
|
|
331
|
+
* Returns undefined when:
|
|
332
|
+
* - Entry not present in storage
|
|
333
|
+
* - `opts.cacheVersion` mismatch with entry
|
|
334
|
+
* - Body is not a JSON string (parse failed)
|
|
335
|
+
* - `opts.validate` returns false (or throws — caller's onError invoked)
|
|
336
|
+
* - Entry is fully expired (past maxAge + swr)
|
|
337
|
+
*/
|
|
338
|
+
tryReadCached<T>(key: string, opts: {
|
|
339
|
+
cacheVersion?: string;
|
|
340
|
+
validate?: (v: T) => boolean;
|
|
341
|
+
}): Promise<{
|
|
342
|
+
value: T;
|
|
343
|
+
status: 'hit' | 'stale';
|
|
344
|
+
} | undefined>;
|
|
345
|
+
set(key: string, entry: CacheEntry): Promise<void>;
|
|
346
|
+
invalidate(key: string): Promise<boolean>;
|
|
347
|
+
invalidateTag(tag: string): Promise<number>;
|
|
348
|
+
revalidatePath(path: string, type?: 'layout' | 'page'): Promise<number>;
|
|
349
|
+
/** Storage adapter passthrough (read-only access for diagnostics). */
|
|
350
|
+
readonly storage: CacheStorageAdapter;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Build a cache engine wrapping a storage adapter.
|
|
354
|
+
*
|
|
355
|
+
* Implements:
|
|
356
|
+
* - SWR (fresh / stale / expired branching) — Astro `memory-provider.ts:423`-style.
|
|
357
|
+
* - In-flight dedupe via `Map<key, Promise>` — Next.js `pendingRevalidates` pattern.
|
|
358
|
+
* - Tag-based invalidation via adapter's deleteByTag.
|
|
359
|
+
* - Path-as-tag encoding (revalidatePath sugar) — Next.js `revalidate.ts:105`.
|
|
360
|
+
*
|
|
361
|
+
* EC-8: Math.max(0, age) guards clock skew.
|
|
362
|
+
* EC-9: validate callback wrapped in try/catch.
|
|
363
|
+
* EC-10: loader returning undefined skips cache write + warns once.
|
|
364
|
+
*
|
|
365
|
+
* NOTE on max-lines-per-function disable below: createCacheEngine is a factory
|
|
366
|
+
* closure that owns the in-flight/bg/warned maps. Splitting would force the
|
|
367
|
+
* helpers across modules and re-introduce the shared mutable state through
|
|
368
|
+
* parameter lists.
|
|
369
|
+
*/
|
|
370
|
+
declare function createCacheEngine(opts: CacheEngineOptions): CacheEngine;
|
|
371
|
+
|
|
372
|
+
interface DefineCachedFunctionOptions<TArgs extends unknown[], TReturn> {
|
|
373
|
+
/** Required cache namespace; appears in keys as "fn:${name}:..." */
|
|
374
|
+
name: string;
|
|
375
|
+
/** seconds; defaults to DEFAULT_MAX_AGE (1) */
|
|
376
|
+
maxAge?: number;
|
|
377
|
+
/** seconds; stale-while-revalidate window */
|
|
378
|
+
swr?: number;
|
|
379
|
+
/** Custom key derivation from args. Default: JSON.stringify(args). */
|
|
380
|
+
getKey?: (...args: TArgs) => string;
|
|
381
|
+
/** Static or dynamic tags. */
|
|
382
|
+
tags?: string[] | ((...args: TArgs) => string[]);
|
|
383
|
+
/** Version stamp; bump to invalidate all entries under this name. */
|
|
384
|
+
cacheVersion?: string;
|
|
385
|
+
/** Transform returned value before caching. */
|
|
386
|
+
transform?: (raw: TReturn) => TReturn;
|
|
387
|
+
/** Skip cache if validate returns false (treats existing entry as miss). */
|
|
388
|
+
validate?: (raw: TReturn) => boolean;
|
|
389
|
+
/** Called on any error in the cache pipeline. */
|
|
390
|
+
onError?: (err: unknown, ctx: {
|
|
391
|
+
args: TArgs;
|
|
392
|
+
}) => void;
|
|
393
|
+
}
|
|
394
|
+
type CachedFunction<TArgs extends unknown[], TReturn> = ((...args: TArgs) => Promise<TReturn>) & {
|
|
395
|
+
/** Bust the cache entry for these specific args. */
|
|
396
|
+
invalidate: (...args: TArgs) => Promise<void>;
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* Wrap an async function with cache semantics.
|
|
400
|
+
* Returns a callable that memoizes by `(name + args)` and exposes `.invalidate(args)`.
|
|
401
|
+
*
|
|
402
|
+
* The engine is supplied by the caller (avoids module-level singleton coupling
|
|
403
|
+
* during testing; framework wiring provides it in production).
|
|
404
|
+
*/
|
|
405
|
+
declare function defineCachedFunction<TArgs extends unknown[], TReturn>(engine: CacheEngine, fn: (...args: TArgs) => TReturn | Promise<TReturn>, opts: DefineCachedFunctionOptions<TArgs, TReturn>): CachedFunction<TArgs, TReturn>;
|
|
406
|
+
|
|
407
|
+
/** Default 10 MB cap per cached route entry (EC-3). */
|
|
408
|
+
declare const DEFAULT_MAX_ENTRY_SIZE: number;
|
|
409
|
+
interface RouteCacheOptions {
|
|
410
|
+
maxAge?: number;
|
|
411
|
+
swr?: number;
|
|
412
|
+
tags?: string[];
|
|
413
|
+
varies?: string[];
|
|
414
|
+
getKey?: (req: Request) => string | Promise<string>;
|
|
415
|
+
bypassWhen?: (req: Request) => boolean | Promise<boolean>;
|
|
416
|
+
cacheVersion?: string;
|
|
417
|
+
cacheErrors?: boolean;
|
|
418
|
+
methods?: string[];
|
|
419
|
+
cacheable?: (response: Response) => boolean;
|
|
420
|
+
/** Max body bytes (EC-3); default DEFAULT_MAX_ENTRY_SIZE. */
|
|
421
|
+
maxEntrySize?: number;
|
|
422
|
+
}
|
|
423
|
+
interface CachedRouteConfig<TQuery extends z.ZodType = z.ZodUndefined, TBody extends z.ZodType = z.ZodUndefined, TParams extends z.ZodType = z.ZodUndefined, TCtx = unknown> extends Omit<RouteConfig<TQuery, TBody, TParams, TCtx>, 'handler'> {
|
|
424
|
+
cache: RouteCacheOptions;
|
|
425
|
+
handler: (ctx: {
|
|
426
|
+
query: z.infer<TQuery>;
|
|
427
|
+
body: z.infer<TBody>;
|
|
428
|
+
params: z.infer<TParams>;
|
|
429
|
+
request: Request;
|
|
430
|
+
ctx: TCtx;
|
|
431
|
+
}) => unknown;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Wrap a `RouteConfig` with cache-aware handler logic.
|
|
435
|
+
*
|
|
436
|
+
* Architecture: wraps the user `handler` so cache lookup happens AT
|
|
437
|
+
* handler-invocation time, AFTER router middleware (auth/csrf/etc) ran.
|
|
438
|
+
* This structurally satisfies EC-4 (cache-after-auth) without modifying
|
|
439
|
+
* the router internals.
|
|
440
|
+
*
|
|
441
|
+
* Algorithm per request:
|
|
442
|
+
* 1. Method check + bypassWhen + maxAge=0 → call handler raw
|
|
443
|
+
* 2. Derive key (path + sortedQuery + varies, prefix by method)
|
|
444
|
+
* 3. Cache lookup → HIT/STALE return cached Response
|
|
445
|
+
* 4. Miss → run handler, check cacheability (Set-Cookie / status / size / SSE / streaming)
|
|
446
|
+
* 5. Cacheable → write entry + return Response with X-Theo-Cache: MISS (dev)
|
|
447
|
+
* 6. Not cacheable → return original Response unchanged
|
|
448
|
+
*
|
|
449
|
+
* Concurrent dedupe is INTENTIONALLY NOT used for routes — Response objects
|
|
450
|
+
* cannot be safely shared across concurrent callers (body is single-use stream).
|
|
451
|
+
* Each request that misses runs the handler independently.
|
|
452
|
+
*/
|
|
453
|
+
declare function defineCachedRoute<TQuery extends z.ZodType = z.ZodUndefined, TBody extends z.ZodType = z.ZodUndefined, TParams extends z.ZodType = z.ZodUndefined, TCtx = unknown>(engine: CacheEngine, config: CachedRouteConfig<TQuery, TBody, TParams, TCtx>): RouteConfig<TQuery, TBody, TParams, TCtx, Response>;
|
|
454
|
+
|
|
455
|
+
interface RevalidateResult {
|
|
456
|
+
deleted: number;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Invalidate all cache entries carrying the given tag.
|
|
460
|
+
* Safe to call from any context (route handler, action, webhook).
|
|
461
|
+
*
|
|
462
|
+
* `opts.expire` accepted for API compatibility with Next.js; at MVP we delete
|
|
463
|
+
* immediately (no SWR-with-expire semantics). A non-zero value emits one warn.
|
|
464
|
+
*/
|
|
465
|
+
declare function revalidateTag(tag: string, opts?: {
|
|
466
|
+
expire?: number;
|
|
467
|
+
}): Promise<RevalidateResult>;
|
|
468
|
+
/**
|
|
469
|
+
* Immediate invalidation (no SWR), Server-Action-safe.
|
|
470
|
+
* Same semantics as revalidateTag at MVP; kept as separate name for
|
|
471
|
+
* call-site clarity ("I want fresh data NOW").
|
|
472
|
+
*/
|
|
473
|
+
declare function updateTag(tag: string): Promise<RevalidateResult>;
|
|
474
|
+
/**
|
|
475
|
+
* Invalidate cached entries for a route path.
|
|
476
|
+
* Sugar over `revalidateTag('_THEO_T_/${path}/${type?}')`.
|
|
477
|
+
*/
|
|
478
|
+
declare function revalidatePath(path: string, opts?: {
|
|
479
|
+
type?: 'layout' | 'page';
|
|
480
|
+
expire?: number;
|
|
481
|
+
}): Promise<RevalidateResult>;
|
|
482
|
+
|
|
483
|
+
interface InMemoryCacheAdapterOptions {
|
|
484
|
+
/** Maximum number of entries before LRU eviction. Default 1000. */
|
|
485
|
+
maxEntries?: number;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* In-memory cache adapter with LRU eviction + reverse tag index.
|
|
489
|
+
*
|
|
490
|
+
* Uses Map insertion-order for O(1) LRU (Astro LRUMap pattern).
|
|
491
|
+
* Reverse index `tagIndex: Map<tag, Set<key>>` makes deleteByTag O(matched-keys).
|
|
492
|
+
*
|
|
493
|
+
* Invariants:
|
|
494
|
+
* - `entries.size <= maxEntries` post-set.
|
|
495
|
+
* - `tagIndex[tag].has(key)` ↔ `entries.get(key)?.tags.includes(tag)`.
|
|
496
|
+
*
|
|
497
|
+
* eslint-disable @typescript-eslint/require-await — the CacheStorageAdapter
|
|
498
|
+
* interface is intentionally async so Redis/file/external adapters fit. The
|
|
499
|
+
* in-memory variant returns immediately but keeps the async signature to
|
|
500
|
+
* satisfy the contract.
|
|
501
|
+
*/
|
|
502
|
+
declare class InMemoryCacheAdapter implements CacheStorageAdapter {
|
|
503
|
+
#private;
|
|
504
|
+
readonly name = "memory";
|
|
505
|
+
constructor(opts?: InMemoryCacheAdapterOptions);
|
|
506
|
+
get(key: string): Promise<CacheEntry | undefined>;
|
|
507
|
+
set(key: string, entry: CacheEntry): Promise<void>;
|
|
508
|
+
delete(key: string): Promise<boolean>;
|
|
509
|
+
deleteByTag(tag: string): Promise<number>;
|
|
510
|
+
size(): Promise<number>;
|
|
511
|
+
clear(): Promise<void>;
|
|
512
|
+
keys(prefix?: string): AsyncIterableIterator<string>;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
interface NormalizedCacheConfig {
|
|
516
|
+
enabled: boolean;
|
|
517
|
+
storage: 'memory' | CacheStorageAdapter;
|
|
518
|
+
maxEntries: number;
|
|
519
|
+
defaults: {
|
|
520
|
+
maxAge: number;
|
|
521
|
+
swr?: number;
|
|
522
|
+
cacheErrors: boolean;
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Initialize the singleton cache engine for this process.
|
|
527
|
+
* Throws if called twice; tests should call `_resetCacheEngine()` between.
|
|
528
|
+
*/
|
|
529
|
+
declare function initCacheEngine(config: NormalizedCacheConfig, hooks?: Pick<CacheEngineOptions, 'onError'>): CacheEngine;
|
|
530
|
+
/**
|
|
531
|
+
* Resolve the singleton cache engine.
|
|
532
|
+
* Throws a clear error if not initialized — usually means the framework
|
|
533
|
+
* bootstrap missed calling initCacheEngine, or cache.enabled is false.
|
|
534
|
+
*/
|
|
535
|
+
declare function getCacheEngine(): CacheEngine;
|
|
536
|
+
/**
|
|
537
|
+
* Test-only: clear the singleton so the next test can re-init.
|
|
538
|
+
* Production code MUST NOT call this.
|
|
539
|
+
*/
|
|
540
|
+
declare function _resetCacheEngine(): void;
|
|
541
|
+
|
|
542
|
+
interface RouteRule {
|
|
543
|
+
maxAge?: number;
|
|
544
|
+
swr?: number;
|
|
545
|
+
tags?: string[];
|
|
546
|
+
}
|
|
547
|
+
type RouteRules = Record<string, RouteRule>;
|
|
548
|
+
interface CompiledRouteRule {
|
|
549
|
+
matcher: (path: string) => boolean;
|
|
550
|
+
rule: RouteRule;
|
|
551
|
+
/** Original glob pattern (for debugging). */
|
|
552
|
+
pattern: string;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Compile route-rule glob patterns into matcher functions.
|
|
556
|
+
* First-match-wins semantics (preserves insertion order).
|
|
557
|
+
*
|
|
558
|
+
* EC-5: picomatch is a direct production dependency (see plan T7.2).
|
|
559
|
+
*/
|
|
560
|
+
declare function compileRouteRules(rules: RouteRules): CompiledRouteRule[];
|
|
561
|
+
/**
|
|
562
|
+
* Resolve the first matching rule for `path`, or `undefined` if none match.
|
|
563
|
+
*/
|
|
564
|
+
declare function resolveRouteRule(path: string, compiled: CompiledRouteRule[]): RouteRule | undefined;
|
|
565
|
+
|
|
566
|
+
interface CacheControlInput {
|
|
567
|
+
/** seconds; 0 forces no-cache */
|
|
568
|
+
maxAge: number;
|
|
569
|
+
/** stale-while-revalidate window in seconds; 0 or undefined omits directive */
|
|
570
|
+
swr?: number;
|
|
571
|
+
/** emit `private,` prefix (skips shared CDN caching) */
|
|
572
|
+
isPrivate?: boolean;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Build a canonical Cache-Control header value.
|
|
576
|
+
*
|
|
577
|
+
* `maxAge === 0` always yields the strict no-cache directive regardless
|
|
578
|
+
* of `swr` or `isPrivate` — defensive default.
|
|
579
|
+
*
|
|
580
|
+
* EC-13: pure function intentional — caller is responsible for input
|
|
581
|
+
* validation (see validateMaxAge / validateExpire in validation.ts).
|
|
582
|
+
*/
|
|
583
|
+
declare function getCacheControlHeader(input: CacheControlInput): string;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Default tracking/analytics query parameters excluded from cache keys.
|
|
587
|
+
* Mirrors Astro's DEFAULT_EXCLUDED_PARAMS list (memory-provider.ts:117).
|
|
588
|
+
* Set as exact-match (not glob) for KISS + zero-dep.
|
|
589
|
+
*/
|
|
590
|
+
declare const DEFAULT_EXCLUDED_QUERY_PARAMS: string[];
|
|
591
|
+
interface KeyDerivationOptions {
|
|
592
|
+
/** Total override — when provided, bypasses all internal logic. */
|
|
593
|
+
getKey?: (req: Request) => string | Promise<string>;
|
|
594
|
+
/** Exact-match query param names to drop. Defaults to DEFAULT_EXCLUDED_QUERY_PARAMS. */
|
|
595
|
+
excludeQuery?: string[];
|
|
596
|
+
/** Whether to sort query params alphabetically. Defaults to true. */
|
|
597
|
+
sortQuery?: boolean;
|
|
598
|
+
/** Header names whose values are appended as `\0name=value` suffix. */
|
|
599
|
+
varies?: string[];
|
|
600
|
+
/** Namespace prefix (e.g., route name). */
|
|
601
|
+
prefix?: string;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Derive a deterministic cache key from a Request.
|
|
605
|
+
*
|
|
606
|
+
* Default behaviour: `${prefix?}${protocol}//${lower(host)}${path}${?sortedFilteredQuery}` + Vary suffix.
|
|
607
|
+
* `\0` separator chosen because it cannot appear in URLs or HTTP header values.
|
|
608
|
+
*
|
|
609
|
+
* EC-6: malformed URL on getKey path is caller's responsibility.
|
|
610
|
+
* EC-7: enforces getKey returns string.
|
|
611
|
+
*/
|
|
612
|
+
declare function deriveKey(req: Request, opts?: KeyDerivationOptions): Promise<string>;
|
|
613
|
+
|
|
614
|
+
interface ValidationResult<T> {
|
|
615
|
+
valid: T[];
|
|
616
|
+
dropped: {
|
|
617
|
+
value: unknown;
|
|
618
|
+
reason: string;
|
|
619
|
+
}[];
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Validate an array of cache tags.
|
|
623
|
+
* Drops invalid entries (type / length / reserved-prefix / overflow) with warn log.
|
|
624
|
+
* NEVER throws on runtime input — caller-facing safety.
|
|
625
|
+
*
|
|
626
|
+
* EC-1: defensive guard for non-array input (e.g., undefined from optional chain).
|
|
627
|
+
*/
|
|
628
|
+
declare function validateTags(tags: unknown, description: string): ValidationResult<string>;
|
|
629
|
+
/**
|
|
630
|
+
* Validate a `maxAge` value in seconds.
|
|
631
|
+
* Throws on invalid input (config-time validation).
|
|
632
|
+
* Returns DEFAULT_MAX_AGE when undefined.
|
|
633
|
+
*/
|
|
634
|
+
declare function validateMaxAge(maxAge: unknown, description: string): number;
|
|
635
|
+
/**
|
|
636
|
+
* Validate an `expire` value in seconds, optionally cross-checked against `revalidate`.
|
|
637
|
+
* Throws on invalid input (config-time validation).
|
|
638
|
+
*/
|
|
639
|
+
declare function validateExpire(expire: unknown, revalidate: number | undefined, description: string): number | undefined;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Single source of truth for cache subsystem constants.
|
|
643
|
+
* Limits mirror Next.js (NEXT_CACHE_TAG_MAX_LENGTH / NEXT_CACHE_TAG_MAX_ITEMS)
|
|
644
|
+
* — see reference doc §3.2 and ADR D6 of caching-and-revalidation-plan.md.
|
|
645
|
+
*/
|
|
646
|
+
declare const CACHE_TAG_MAX_LENGTH = 256;
|
|
647
|
+
declare const CACHE_TAG_MAX_ITEMS = 128;
|
|
648
|
+
declare const THEO_T_PREFIX = "_THEO_T_";
|
|
649
|
+
declare const DEFAULT_MAX_AGE = 1;
|
|
650
|
+
declare const DEFAULT_SWR_MULTIPLIER = 60;
|
|
651
|
+
|
|
652
|
+
interface UploadedFile {
|
|
653
|
+
fieldname: string;
|
|
654
|
+
filename: string;
|
|
655
|
+
encoding: string;
|
|
656
|
+
mimeType: string;
|
|
657
|
+
buffer: Buffer;
|
|
658
|
+
size: number;
|
|
659
|
+
}
|
|
660
|
+
interface ParsedBody {
|
|
661
|
+
fields: Record<string, string>;
|
|
662
|
+
files: UploadedFile[];
|
|
663
|
+
json?: unknown;
|
|
664
|
+
}
|
|
665
|
+
interface BodyParserOptions {
|
|
666
|
+
maxFileSize?: number;
|
|
667
|
+
maxFiles?: number;
|
|
668
|
+
maxFieldSize?: number;
|
|
669
|
+
}
|
|
670
|
+
declare class FileTooLargeError extends Error {
|
|
671
|
+
readonly truncatedFilenames: string[];
|
|
672
|
+
readonly maxFileSize: number;
|
|
673
|
+
readonly code = "FILE_TOO_LARGE";
|
|
674
|
+
readonly status = 413;
|
|
675
|
+
constructor(message: string, truncatedFilenames: string[], maxFileSize: number);
|
|
676
|
+
}
|
|
677
|
+
declare function parseRequestBody(req: IncomingMessage, options?: BodyParserOptions): Promise<ParsedBody>;
|
|
678
|
+
|
|
679
|
+
interface SerializedResponse {
|
|
680
|
+
json: unknown;
|
|
681
|
+
meta?: unknown;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Serialize data using superjson for rich type support (Date, Map, Set, BigInt, etc.)
|
|
685
|
+
*/
|
|
686
|
+
declare function serializeResponse(data: unknown): SerializedResponse;
|
|
687
|
+
/**
|
|
688
|
+
* Deserialize data that was serialized with superjson.
|
|
689
|
+
*/
|
|
690
|
+
declare function deserializeResponse(serialized: SerializedResponse): unknown;
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* T3.2 — Web-Standards middleware runner for the `executeWebRequest` path.
|
|
694
|
+
*
|
|
695
|
+
* The Node request path (`http/execute.ts`) runs middleware via
|
|
696
|
+
* `runMiddlewareAndContext`, which is coupled to Node `req`/`res`. Per G8
|
|
697
|
+
* (Web Standards over Node APIs) the Web path needs a `Request`-shaped runner;
|
|
698
|
+
* this is it. Extracted to a sibling so `web-handler.ts` stays under its LoC
|
|
699
|
+
* budget (G6).
|
|
700
|
+
*
|
|
701
|
+
* Ordering invariant (EC-3): the caller runs the CSRF gate BEFORE invoking this
|
|
702
|
+
* runner, mirroring the Node path (CSRF stage precedes user middleware).
|
|
703
|
+
*
|
|
704
|
+
* NOTE (D4 / EC-12): this is its own middleware contract — `(request, context)`.
|
|
705
|
+
* Full semantic parity with the Node `defineMiddleware` contract is part of the
|
|
706
|
+
* deferred Node→Web pipeline convergence, not this slice.
|
|
707
|
+
*/
|
|
708
|
+
/** A Web-path middleware: mutate `context`, or return a `Response` to short-circuit. */
|
|
709
|
+
type WebMiddleware = (request: Request, context: Record<string, unknown>) => Promise<Response | undefined> | Response | undefined | void;
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* The route module exported by a `server/routes/*.ts` file (after T2.6 G6
|
|
713
|
+
* router lockdown). Method-named exports map to `defineRoute` results.
|
|
714
|
+
*/
|
|
715
|
+
type WebRouteModule = Partial<Record<'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', unknown>>;
|
|
716
|
+
/**
|
|
717
|
+
* Optional behavior knobs for `executeWebRequest`. Each knob defaults to
|
|
718
|
+
* the safe "no-op" stance so existing Phase A consumers (T1.2 fixture
|
|
719
|
+
* tests) keep working unchanged.
|
|
720
|
+
*
|
|
721
|
+
* **`csrfMode`** (T5a.2 Phase B slice 1/6) — when set to `'strict'`, the
|
|
722
|
+
* Web-Standards request gate runs `validateCsrfRequest` BEFORE method
|
|
723
|
+
* dispatch on state-changing methods (POST/PUT/PATCH/DELETE) and emits a
|
|
724
|
+
* `403 FORBIDDEN` envelope when the check fails. Default: `'off'` (no
|
|
725
|
+
* CSRF enforcement) to preserve Phase A backward compat. Production
|
|
726
|
+
* consumers SHOULD pass `csrfMode: 'strict'`.
|
|
727
|
+
*
|
|
728
|
+
* Per the T5a.2 plan v1.0 § Phase B header-only leaves: csrf.ts is the
|
|
729
|
+
* first leaf to be migrated (slice 1/6); 5 more sibling leaves remain
|
|
730
|
+
* (csrf-multi-header, csrf-readiness-endpoint, csp-report, cors, cookies).
|
|
731
|
+
*/
|
|
732
|
+
interface ExecuteWebRequestOptions {
|
|
733
|
+
csrfMode?: 'off' | 'strict';
|
|
734
|
+
/**
|
|
735
|
+
* T3.1 — route params resolved upstream by `matchRoute` (e.g. `{ id: '42' }`
|
|
736
|
+
* for `/users/:id`). Threaded to the handler's `params` input and validated
|
|
737
|
+
* against `config.params` (Zod) when declared. Defaults to `{}` — callers
|
|
738
|
+
* that don't supply params keep the prior behavior (additive, backward-compat).
|
|
739
|
+
*/
|
|
740
|
+
params?: Record<string, string>;
|
|
741
|
+
/**
|
|
742
|
+
* T3.2 — Web-Standards middleware chain. Runs in order AFTER the CSRF gate
|
|
743
|
+
* (EC-3) and BEFORE the handler. A middleware returning a `Response`
|
|
744
|
+
* short-circuits (handler not reached); mutating `context` passes data to
|
|
745
|
+
* the handler. Omitted → zero overhead (handler runs directly).
|
|
746
|
+
*/
|
|
747
|
+
middleware?: readonly WebMiddleware[];
|
|
748
|
+
/**
|
|
749
|
+
* T5a.2 Phase E — body parser strategy.
|
|
750
|
+
*
|
|
751
|
+
* - `'inline'` (default): handle `application/json` + `text/*` only.
|
|
752
|
+
* Returns the parsed value (object for JSON, string for text). Other
|
|
753
|
+
* content-types (e.g., multipart) return `undefined`.
|
|
754
|
+
* - `'full'`: delegate to `parseWebRequestBody` for multipart support
|
|
755
|
+
* + per-file size caps + max-files cap (Web Standards `request.formData()`
|
|
756
|
+
* under the hood). Returns a `ParsedWebBody` object:
|
|
757
|
+
* `{ json?, fields, files }`. Multipart consumers MUST opt into this
|
|
758
|
+
* mode; JSON-only routes pay zero cost staying on `'inline'`.
|
|
759
|
+
*/
|
|
760
|
+
bodyParser?: 'inline' | 'full';
|
|
761
|
+
/**
|
|
762
|
+
* T5a.2 Phase G slice 1/N — plugin lifecycle hooks.
|
|
763
|
+
*
|
|
764
|
+
* Adapters (Node, CF Workers, Bun, Deno) wire `WebPluginContext`-shaped
|
|
765
|
+
* hooks at the executeWebRequest lifecycle. Lifecycle order mirrors the
|
|
766
|
+
* Fastify / Hono convention:
|
|
767
|
+
*
|
|
768
|
+
* 1. CSRF check (when opts.csrfMode === 'strict')
|
|
769
|
+
* 2. onRequest — earliest, before body parsing. Plugins can short-circuit
|
|
770
|
+
* by setting `ctx.response` (handler skipped; subsequent hooks see
|
|
771
|
+
* the short-circuit response).
|
|
772
|
+
* 3. body parse (inline OR full per opts.bodyParser)
|
|
773
|
+
* 4. preHandler — after body parsed, before handler runs. Same
|
|
774
|
+
* short-circuit semantic.
|
|
775
|
+
* 5. handler invocation
|
|
776
|
+
* 6. onResponse — after handler returns OR after a hook short-circuit.
|
|
777
|
+
* `ctx.response` is populated.
|
|
778
|
+
* 7. onError — fires if any of (handler, onRequest, preHandler) throws.
|
|
779
|
+
* `ctx.response` is the envelope-shaped error response built via
|
|
780
|
+
* serverErrorToEnvelope.
|
|
781
|
+
*
|
|
782
|
+
* `responseHeaders` is shared across hooks; the final Response merges
|
|
783
|
+
* them with the handler's Response headers (handler headers win on
|
|
784
|
+
* conflict; hook headers add new ones). Decorations made via
|
|
785
|
+
* `ctx.ctx[key] = value` persist across hooks (request-scoped state).
|
|
786
|
+
*
|
|
787
|
+
* `hooks: undefined` (default) → no plugin lifecycle, Phase A behavior
|
|
788
|
+
* preserved. Production consumers wire via the WebPluginRunner facade
|
|
789
|
+
* (a future Phase G slice).
|
|
790
|
+
*/
|
|
791
|
+
hooks?: {
|
|
792
|
+
onRequest?: readonly WebOnRequestHook[];
|
|
793
|
+
preHandler?: readonly WebPreHandlerHook[];
|
|
794
|
+
onResponse?: readonly WebOnResponseHook[];
|
|
795
|
+
onError?: readonly WebOnErrorHook[];
|
|
796
|
+
};
|
|
797
|
+
/**
|
|
798
|
+
* Stable request identifier propagated into hook contexts. Adapters
|
|
799
|
+
* resolve via traceparent / x-request-id / generated UUID (see
|
|
800
|
+
* `extractTraceIdFromRequest` from Phase C slice 1/2). Default:
|
|
801
|
+
* `globalThis.crypto.randomUUID()`.
|
|
802
|
+
*/
|
|
803
|
+
requestId?: string;
|
|
804
|
+
}
|
|
805
|
+
declare function executeWebRequest(request: Request, routeModule: WebRouteModule, opts?: ExecuteWebRequestOptions): Promise<Response>;
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* Types for `loadEnv()` — env auto-load utility (Phase 1 of
|
|
809
|
+
* docs/plans/framework-zero-config-polish-plan.md).
|
|
810
|
+
*
|
|
811
|
+
* The shape mirrors Next.js's `LoadedEnvFiles` (`next-env/index.ts:114`).
|
|
812
|
+
*/
|
|
813
|
+
interface LoadEnvOptions {
|
|
814
|
+
/** Project root. Default: `process.cwd()` */
|
|
815
|
+
cwd?: string;
|
|
816
|
+
/** Mode (`development` | `production` | `test`). Default: `process.env.NODE_ENV ?? 'development'` */
|
|
817
|
+
mode?: string;
|
|
818
|
+
/** Bypass module-level cache. Default: `false` */
|
|
819
|
+
forceReload?: boolean;
|
|
820
|
+
}
|
|
821
|
+
interface LoadEnvResult {
|
|
822
|
+
/** Map of all keys that were APPLIED to process.env by this call. */
|
|
823
|
+
loaded: Record<string, string>;
|
|
824
|
+
/** Absolute paths of files that were actually read, in priority order (top wins). */
|
|
825
|
+
loadedFromFiles: string[];
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* `loadEnv()` — auto-loads `.env` files into `process.env` for server code.
|
|
830
|
+
*
|
|
831
|
+
* Implements the Next.js `loadEnvConfig` algorithm
|
|
832
|
+
* (`referencias/next.js/packages/next-env/index.ts:114-180`) with TheoKit
|
|
833
|
+
* adaptations:
|
|
834
|
+
*
|
|
835
|
+
* - EC-1: 1MB file-size cap (anti-OOM, anti-supply-chain).
|
|
836
|
+
* - EC-2: `_resetEnvCache()` test-only side-door.
|
|
837
|
+
* - EC-8: `dotenv-expand` circular-ref safe (lib-provided).
|
|
838
|
+
* - EC-13: log when `.env` is a symlink (transparency).
|
|
839
|
+
* - D6: real `process.env` wins over `.env`-file values.
|
|
840
|
+
* - NODE_ENV stash: `.env`-set NODE_ENV NEVER overrides the real
|
|
841
|
+
* `process.env.NODE_ENV`. Stashed in `__THEOKIT_USER_NODE_ENV` instead.
|
|
842
|
+
*/
|
|
843
|
+
|
|
844
|
+
/** Test-only side-door for EC-2 — clear the module-level cache between vitest test files. */
|
|
845
|
+
declare function _resetEnvCache(): void;
|
|
846
|
+
declare function loadEnv(options?: LoadEnvOptions): LoadEnvResult;
|
|
847
|
+
|
|
848
|
+
export { ActionError, type ActionErrorCode, ActionInputError, type ActionManifestEntry, type ActionResult, type BodyParserOptions, DEFAULT_MAX_AGE as CACHE_DEFAULT_MAX_AGE, DEFAULT_MAX_ENTRY_SIZE as CACHE_DEFAULT_MAX_ENTRY_SIZE, DEFAULT_SWR_MULTIPLIER as CACHE_DEFAULT_SWR_MULTIPLIER, CACHE_TAG_MAX_ITEMS, CACHE_TAG_MAX_LENGTH, type CacheControlInput, type CacheEngine, type CacheEngineOptions, type CacheEntry, type CacheStatus, type CacheStorageAdapter, type CacheStore, type CacheStoreAdmin, type ValidationResult as CacheValidationResult, type CachedFunction, type CachedRouteConfig, type CompiledRouteRule, DEFAULT_EXCLUDED_QUERY_PARAMS, type DefineCachedFunctionOptions, FileTooLargeError, type GetOrComputeOptions, InMemoryCacheAdapter, type InMemoryCacheAdapterOptions, type KeyDerivationOptions, type LoadEnvOptions, type LoadEnvResult, type NormalizedCacheConfig, type OpenApiDocsOptions, type ParsedBody, type RevalidateResult, type RouteCacheOptions, RouteConfig, type RouteRule, type RouteRules, type SerializedActionResult, type SerializedResponse, THEO_T_PREFIX, type UniversalZodIssue, type UploadedFile, _resetCacheEngine, _resetEnvCache, compileRouteRules, createCacheEngine, createOpenApiHandler, defineCachedFunction, defineCachedRoute, deriveKey as deriveCacheKey, deserializeResponse, executeWebRequest, extractUniversalIssues, getCacheControlHeader, getCacheEngine, initCacheEngine, isActionError, isInputError, loadEnv, parseRequestBody, resolveRouteRule, revalidatePath, revalidateTag, serializeResponse, updateTag, validateExpire as validateCacheExpire, validateMaxAge as validateCacheMaxAge, validateTags as validateCacheTags };
|