theokit 0.11.7 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +201 -0
  2. package/dist/actions-virtual-module-SQDY3V5X.js +0 -0
  3. package/dist/add-W6FNTAFS.js +0 -0
  4. package/dist/app-typed-client-QG7BVZYW.js +0 -0
  5. package/dist/aws-lambda-7GSCNLPY.js +0 -0
  6. package/dist/broadcast-LUMOJIJT.js +0 -0
  7. package/dist/build-QFRLSEZ4.js +0 -0
  8. package/dist/build-request-body-preview-QMWD2IXK.js +0 -0
  9. package/dist/bun-KP2KES6S.js +0 -0
  10. package/dist/check-PD2FTKMM.js +0 -0
  11. package/dist/chunk-3LVRAGAZ.js +0 -0
  12. package/dist/chunk-43D6XNDR.js +0 -0
  13. package/dist/chunk-45C3WUQ7.js +0 -0
  14. package/dist/chunk-5ODOE6EF.js +0 -0
  15. package/dist/chunk-6FYD34NX.js +0 -0
  16. package/dist/chunk-7YZHAQU7.js +0 -0
  17. package/dist/{chunk-GEEMNDPH.js → chunk-AD74EAK3.js} +30 -1
  18. package/dist/chunk-AD74EAK3.js.map +1 -0
  19. package/dist/chunk-FOZIR3TG.js +0 -0
  20. package/dist/chunk-GFMQJHXX.js +0 -0
  21. package/dist/chunk-HGZL5EOI.js +0 -0
  22. package/dist/chunk-HNBWZKIQ.js +0 -0
  23. package/dist/chunk-IEES3CHD.js +0 -0
  24. package/dist/chunk-JAIKGP3Q.js +0 -0
  25. package/dist/chunk-JQSFBJR5.js +0 -0
  26. package/dist/chunk-NAZ4E2GT.js +0 -0
  27. package/dist/chunk-PBEH6NXR.js +0 -0
  28. package/dist/chunk-YJAUJXZS.js +0 -0
  29. package/dist/cloudflare-C6E5SPAE.js +0 -0
  30. package/dist/configure-agent-registry-ZOBVU3MV.js +0 -0
  31. package/dist/db-3UNAMSFK.js +0 -0
  32. package/dist/deno-deploy-RFZN56X4.js +0 -0
  33. package/dist/dev-GBXOTXUP.js +0 -0
  34. package/dist/dev-emit-FEFEDLZF.js +0 -0
  35. package/dist/dispatcher-EJHL6JMJ.js +0 -0
  36. package/dist/docker-LZZB4D5E.js +0 -0
  37. package/dist/generate-OMKHQ7OM.js +0 -0
  38. package/dist/info-OUEUZOT7.js +0 -0
  39. package/dist/netlify-PMLHVPN4.js +0 -0
  40. package/dist/node-BPJ3Z4DT.js +0 -0
  41. package/dist/openapi-VR6AFBLJ.js +0 -0
  42. package/dist/registry-Q2TZQLUH.js +0 -0
  43. package/dist/router-TLEAOFID.js +0 -0
  44. package/dist/routes-LRYOIIAI.js +0 -0
  45. package/dist/scan-7MJC6PYU.js +0 -0
  46. package/dist/schema-7CAY6IZR.js +0 -0
  47. package/dist/server/define/index.js +5 -3
  48. package/dist/server/index.js +4 -2
  49. package/dist/server/index.js.map +1 -1
  50. package/dist/server-error-to-envelope-UUXDSLAZ.js +0 -0
  51. package/dist/server-routes-hmr-VZXOP5YT.js +0 -0
  52. package/dist/services-json-Y3XODNB5.js +0 -0
  53. package/dist/services-typed-client-32KMTTXR.js +0 -0
  54. package/dist/start-3ZHAXSJE.js +0 -0
  55. package/dist/static-55G3LX2I.js +0 -0
  56. package/dist/storage-manager-ZSQFLEYT.js +0 -0
  57. package/dist/theo-cloud-DQRP6S6M.js +0 -0
  58. package/dist/upgrade-readiness-ACGW44JC.js +0 -0
  59. package/dist/vercel-J6G7ZHYQ.js +0 -0
  60. package/dist/vite-plugin-WO72VLYR.js +0 -0
  61. package/package.json +12 -8
  62. package/dist/adapters/web-shim.d.ts +0 -67
  63. package/dist/adapters/ws-shim.d.ts +0 -55
  64. package/dist/agent-events-DosDXkSV.d.ts +0 -94
  65. package/dist/audit-log-BQWM5YLG.d.ts +0 -60
  66. package/dist/boot/index.d.ts +0 -39
  67. package/dist/chunk-GEEMNDPH.js.map +0 -1
  68. package/dist/client/index.d.ts +0 -362
  69. package/dist/csrf-BBrEZSBW.d.ts +0 -107
  70. package/dist/csrf-readiness-store-CjIoub3U.d.ts +0 -43
  71. package/dist/define-websocket-CdK94O-D.d.ts +0 -64
  72. package/dist/devtools/entry.d.ts +0 -5
  73. package/dist/error-envelope-BsNzzAV5.d.ts +0 -62
  74. package/dist/health-route-C0hk64_U.d.ts +0 -57
  75. package/dist/index-B40qUSrQ.d.ts +0 -575
  76. package/dist/index.d.ts +0 -361
  77. package/dist/job-backend-CgC8Xf33.d.ts +0 -68
  78. package/dist/match-CfbEFRG4.d.ts +0 -26
  79. package/dist/plugin-runner-BGBkzgi0.d.ts +0 -95
  80. package/dist/plugin-types-DNJGxr4Z.d.ts +0 -79
  81. package/dist/rate-limit-BdNDZ3vt.d.ts +0 -58
  82. package/dist/rate-limit-store-BEJnhWdw.d.ts +0 -72
  83. package/dist/react-query/index.d.ts +0 -33
  84. package/dist/schema-BpH6ivDY.d.ts +0 -74
  85. package/dist/server/agent/index.d.ts +0 -229
  86. package/dist/server/auth/index.d.ts +0 -419
  87. package/dist/server/cost/index.d.ts +0 -177
  88. package/dist/server/cron/index.d.ts +0 -208
  89. package/dist/server/define/index.d.ts +0 -310
  90. package/dist/server/http/index.d.ts +0 -11
  91. package/dist/server/index.d.ts +0 -847
  92. package/dist/server/jobs/index.d.ts +0 -348
  93. package/dist/server/observability/index.d.ts +0 -324
  94. package/dist/server/plugins/index.d.ts +0 -17
  95. package/dist/server/rate-limit/index.d.ts +0 -105
  96. package/dist/server/realtime/index.d.ts +0 -15
  97. package/dist/server/scan/index.d.ts +0 -106
  98. package/dist/server/security/index.d.ts +0 -193
  99. package/dist/server/storage/index.d.ts +0 -22
  100. package/dist/server/webhook/index.d.ts +0 -148
  101. package/dist/storage-manager-C4jsO0Tp.d.ts +0 -89
  102. package/dist/storage-types-DsDTCPbp.d.ts +0 -96
  103. package/dist/vite-plugin/index.d.ts +0 -115
@@ -1,89 +0,0 @@
1
- import { S as ServerConfig, P as PostgresDatabaseConfig, a as PoolLike, b as StorageConfig, R as RedisServerConfig, c as RedisLike, d as StorageAdapter } from './storage-types-DsDTCPbp.js';
2
-
3
- /**
4
- * StorageManager — per-process singleton coordinating pluggable storage
5
- * adapters (Postgres pools, Redis clients, in-memory adapters).
6
- *
7
- * Architectural decisions: see ADR-0007 (docs/adr/0007-storage-manager-singleton.md).
8
- *
9
- * Lifecycle:
10
- * 1. `getStorageManager()` returns the singleton (D1).
11
- * 2. `configure(storageConfig)` honored once per process (D3). Second call
12
- * warns and is ignored.
13
- * 3. `usePostgres(dbName, factory)` / `useRedis(serverName, factory)`
14
- * lazily create + cache (D2). Factory invoked exactly once per name.
15
- * 4. `register(adapter)` opts the adapter into the SIGTERM drain (D6).
16
- * 5. `dispose()` drains in parallel — adapters + pools + Redis (D5).
17
- * Idempotent. Adapter errors logged + swallowed (do not block shutdown).
18
- *
19
- * Test seam: `__resetForTests()` resets state. Test files MUST call it from
20
- * `beforeEach` to avoid pollution across `it` blocks (EC-3).
21
- */
22
-
23
- type PostgresFactory = (server: ServerConfig, db: PostgresDatabaseConfig) => PoolLike;
24
- type RedisFactory = (config: RedisServerConfig) => RedisLike;
25
- declare class StorageManager {
26
- #private;
27
- /**
28
- * Apply the storage config block from `theo.config.ts`. Second call warns
29
- * and is ignored (D3). Reset only via `__resetForTests()`.
30
- */
31
- configure(config: StorageConfig): void;
32
- /**
33
- * Generic cache + factory for ANY client (MySQL, Mongo, Turso, DynamoDB, …).
34
- * Returns the cached client OR invokes the factory and caches its return.
35
- *
36
- * EC-1 FIX: cache-hit check uses `Map.has(name)`, NOT `cached !== undefined`.
37
- * Factories returning `null` or `undefined` are valid (lazy connect, stubs);
38
- * the `!== undefined` check would re-invoke the factory infinitely for
39
- * undefined returns AND silently cache `null` cast as `T`.
40
- *
41
- * EC-2 (documented type hole): `useStorage<A>('x', fA)` followed by
42
- * `useStorage<B>('x', fB)` returns the cached A cast as B. Same trade-off
43
- * as `Map<string, unknown>` — caller is responsible for using unique names
44
- * per type.
45
- *
46
- * Lifecycle: generic clients are NOT auto-drained by `dispose()`. Call
47
- * `manager.register({ name, dispose })` separately to participate.
48
- *
49
- * Reserved name prefixes (do NOT use): `__pg:`, `__redis:`, `__unstorage:`,
50
- * `__db0:` — these are used internally by the typed helpers.
51
- */
52
- useStorage<T>(name: string, factory: () => T): T;
53
- /**
54
- * Return a Postgres pool for the named database. Lazy + cached. Factory
55
- * invoked exactly once per `dbName` (D2).
56
- *
57
- * Throws if:
58
- * - manager is disposed
59
- * - `dbName` is not in `config.databases`
60
- * - the referenced server is not in `config.servers` (EC-2: deferred
61
- * cross-field validation surfaces here, not at configure time)
62
- */
63
- usePostgres(dbName: string, factory: PostgresFactory): PoolLike;
64
- /**
65
- * Return a Redis client for the named server. Lazy + cached. Factory
66
- * invoked exactly once per `serverName`.
67
- */
68
- useRedis(serverName: string, factory: RedisFactory): RedisLike;
69
- /**
70
- * Register an adapter for graceful shutdown coordination (D6).
71
- *
72
- * EC-4: throws if the manager is already disposed — prevents silent
73
- * leaks in test seams that reset+reuse the manager.
74
- */
75
- register(adapter: StorageAdapter): void;
76
- /**
77
- * Drain in parallel — registered adapters, then PG pools, then Redis
78
- * clients. Idempotent (D5). Errors per resource are logged and swallowed
79
- * — they do NOT prevent shutdown of the remaining resources.
80
- *
81
- * Caller must wrap in a timeout if a bound is needed (EC-7: documented).
82
- * In production, `start.ts` wraps the whole shutdown sequence in a 25 s
83
- * force-exit timer.
84
- */
85
- dispose(): Promise<void>;
86
- }
87
- declare function getStorageManager(): StorageManager;
88
-
89
- export { type PostgresFactory as P, type RedisFactory as R, StorageManager as S, getStorageManager as g };
@@ -1,96 +0,0 @@
1
- /**
2
- * Canonical structural types for the StorageManager (ADR-0007).
3
- *
4
- * `PoolLike` is the minimal pg.Pool subset TheoKit consumes — defined here as
5
- * single source of truth (D7). Adapters that need a Postgres pool import this
6
- * type instead of duplicating the shape.
7
- *
8
- * `RedisLike` is the minimal ioredis subset the manager calls during dispose.
9
- *
10
- * `StorageAdapter` is the lifecycle contract — anything that wants to
11
- * participate in the StorageManager drain on SIGTERM implements this.
12
- */
13
- /**
14
- * Minimal subset of `pg.Pool` we depend on. Accepting this narrower interface
15
- * lets us:
16
- * - test with `pg-mem` (in-memory) without dragging real Postgres into CI
17
- * - swap to any wire-compatible client (postgres.js, slonik, etc.)
18
- *
19
- * Optional `end()` lets the manager call it during dispose; not required for
20
- * pools that handle their own lifecycle (e.g., serverless drivers).
21
- */
22
- interface PoolLike {
23
- query<R = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<{
24
- rows: R[];
25
- rowCount?: number | null;
26
- }>;
27
- /** Optional — manager calls this during dispose(). Pools without end() are silently skipped (EC-5). */
28
- end?: () => Promise<void>;
29
- }
30
- /**
31
- * Minimal subset of ioredis we depend on during graceful shutdown. The full
32
- * Redis API is the user's responsibility — manager only needs lifecycle.
33
- */
34
- interface RedisLike {
35
- /** Graceful close — drains pending commands. */
36
- quit(): Promise<unknown>;
37
- /** Hard close — used as fallback if `quit()` rejects. */
38
- disconnect(): void;
39
- }
40
- /**
41
- * Lifecycle contract for any adapter that participates in StorageManager
42
- * graceful shutdown. Call `manager.register(this)` from your adapter's
43
- * constructor to opt in.
44
- *
45
- * Errors thrown from `dispose()` are swallowed by the manager (D5/D6 — log +
46
- * continue). Do not rely on `dispose()` rejection propagating.
47
- */
48
- interface StorageAdapter {
49
- readonly name: string;
50
- dispose(): Promise<void>;
51
- }
52
- /**
53
- * Generic factory signature for `StorageManager.useStorage<T>(name, factory)`.
54
- * Useful for typing externally-defined factory functions:
55
- *
56
- * ```ts
57
- * const mongoFactory: GenericFactory<MongoClient> = () => new MongoClient({...})
58
- * manager.useStorage('mongo', mongoFactory)
59
- * ```
60
- */
61
- type GenericFactory<T> = () => T;
62
- interface TlsConfig {
63
- rejectUnauthorized?: boolean;
64
- caCert?: string;
65
- clientCert?: string;
66
- clientKey?: string;
67
- }
68
- interface ServerConfig {
69
- host: string;
70
- port?: number;
71
- user: string;
72
- password: string;
73
- tls?: TlsConfig;
74
- }
75
- interface PostgresDatabaseConfig {
76
- /** References a key in `StorageConfig.servers`. */
77
- server: string;
78
- database: string;
79
- pool?: {
80
- min?: number;
81
- max?: number;
82
- connectionTimeoutMillis?: number;
83
- idleTimeoutMillis?: number;
84
- };
85
- }
86
- interface RedisServerConfig extends ServerConfig {
87
- db?: number;
88
- maxRetriesPerRequest?: number;
89
- }
90
- interface StorageConfig {
91
- servers?: Record<string, ServerConfig>;
92
- databases?: Record<string, PostgresDatabaseConfig>;
93
- redis?: Record<string, RedisServerConfig>;
94
- }
95
-
96
- export type { GenericFactory as G, PostgresDatabaseConfig as P, RedisServerConfig as R, ServerConfig as S, TlsConfig as T, PoolLike as a, StorageConfig as b, RedisLike as c, StorageAdapter as d };
@@ -1,115 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { R as RateLimitConfig } from '../rate-limit-BdNDZ3vt.js';
3
- import { C as CsrfReadinessStore } from '../csrf-readiness-store-CjIoub3U.js';
4
- import { S as ServicesConfig } from '../schema-BpH6ivDY.js';
5
- import 'node:http';
6
- import '../rate-limit-store-BEJnhWdw.js';
7
- import 'zod';
8
-
9
- /**
10
- * T3.1 — Vite integration extension API (`defineTheoIntegration`).
11
- *
12
- * Build-time extension system (mirrors Astro Integrations). Lets third
13
- * parties hook into Theo's Vite lifecycle without forking the plugin.
14
- *
15
- * Strictly separated from runtime `defineTheoPlugin` (Phase 4) — different
16
- * concerns, different surfaces. See ADR D7 in the plan.
17
- */
18
- type HookName = 'theo:config:setup' | 'theo:build:start' | 'theo:build:done' | 'theo:dev:start';
19
- interface HookContext {
20
- addVirtualModule?: (id: string, code: string) => void;
21
- addRoute?: (path: string, handler: RouteHandler) => void;
22
- [key: string]: unknown;
23
- }
24
- type Hook = (ctx: HookContext) => void | Promise<void>;
25
- type RouteHandler = (request: Request) => Response | Promise<Response>;
26
- interface TheoIntegration {
27
- name: string;
28
- hooks: Partial<Record<HookName, Hook>>;
29
- }
30
- /**
31
- * Identity factory for type-checking against TheoIntegration shape.
32
- */
33
- declare function defineTheoIntegration(integration: TheoIntegration): TheoIntegration;
34
- declare class IntegrationVirtualModulePrefixError extends Error {
35
- constructor(integrationName: string, id: string);
36
- }
37
- declare class IntegrationRouteCollisionError extends Error {
38
- constructor(integrationName: string, path: string);
39
- }
40
- interface IntegrationRegistryOptions {
41
- /** Routes already scanned from `server/routes/`. Used to detect collisions. */
42
- existingRoutes: string[];
43
- }
44
- interface IntegrationRoute {
45
- path: string;
46
- owner: string;
47
- }
48
- interface IntegrationRegistry {
49
- registerIntegration(integration: TheoIntegration): void;
50
- fire(hookName: HookName, baseCtx: Record<string, unknown>): Promise<void>;
51
- addVirtualModule(integrationName: string, id: string, code: string): void;
52
- addRoute(integrationName: string, path: string, handler: RouteHandler): void;
53
- getVirtualModule(id: string): string | undefined;
54
- listVirtualModules(): string[];
55
- listRoutes(): IntegrationRoute[];
56
- /** Test helper: invoke hook surface directly without firing the lifecycle. */
57
- callHook(integrationName: string, hookName: HookName, extraCtx: Partial<HookContext>): Promise<void>;
58
- }
59
- declare function createIntegrationRegistry(options: IntegrationRegistryOptions): IntegrationRegistry;
60
-
61
- interface TheoPluginOptions {
62
- root?: string;
63
- rateLimit?: RateLimitConfig;
64
- ssr?: boolean;
65
- ssrStreaming?: boolean;
66
- /**
67
- * Wave 2 (T3.1) — polyglot services config. When passed, the
68
- * services-typed-client plugin is wired and generates `clients/<name>.ts`
69
- * per service with an OpenAPI URL. Empty `{}` → no-op.
70
- */
71
- services?: ServicesConfig;
72
- /**
73
- * T4.1 (canvas-ecosystem-refactor / ADR D6) — extra package names appended
74
- * to Vite `optimizeDeps.include`. Required when an installed plugin
75
- * peer-dep is consumed via a literal `import('<pkg>')` (dynamic specifier)
76
- * — Vite cannot trace those without a hint, and the browser receives a
77
- * `Failed to resolve module specifier '<pkg>'` error.
78
- *
79
- * Default targets pre-bundled regardless: `@theokit/ui`, `lucide-react`.
80
- *
81
- * Example:
82
- * viteOptimizeDeps: ['mermaid']
83
- */
84
- viteOptimizeDeps?: string[];
85
- /**
86
- * Optional override for the in-memory CSRF readiness store consumed by
87
- * the `/__theo/csrf-readiness` endpoint and the devtools CSRF Readiness
88
- * tab. When omitted, the plugin auto-instantiates a default in-process
89
- * `CsrfReadinessStore` so the tab works out-of-the-box in dev.
90
- *
91
- * Override with a custom impl when you need cross-worker telemetry
92
- * (e.g., Redis-backed store) or want to silence the tab entirely
93
- * (pass an inert store that discards writes).
94
- */
95
- csrfReadinessStore?: CsrfReadinessStore;
96
- }
97
- /**
98
- * Async factory companion. Returns `[theoPlugin, ...autoChainedPlugins]`.
99
- *
100
- * Why this exists alongside the sync `theoPlugin()` factory: Vite does NOT
101
- * reliably merge plugins returned from a child plugin's `config()` hook
102
- * (verified empirically 2026-05-23 — plugins were silently dropped from
103
- * the resolved chain despite being returned correctly). The canonical
104
- * Vite pattern for plugin-from-plugin is to return `Plugin[]` from the
105
- * plugin factory itself, which Vite flattens into the consumer's
106
- * `plugins` array.
107
- *
108
- * Consumers should prefer `await theoPluginAsync(...)` over `theoPlugin(...)`
109
- * when they want @theokit/ui + @tailwindcss/vite auto-chaining. The sync
110
- * factory remains for backward compatibility and tests.
111
- */
112
- declare function theoPluginAsync(rootOrOptions?: string | TheoPluginOptions): Promise<Plugin[]>;
113
- declare function theoPlugin(rootOrOptions?: string | TheoPluginOptions): Plugin;
114
-
115
- export { type Hook as IntegrationHook, type HookContext as IntegrationHookContext, type HookName as IntegrationHookName, type IntegrationRegistry, type IntegrationRegistryOptions, type IntegrationRoute, IntegrationRouteCollisionError, type RouteHandler as IntegrationRouteHandler, IntegrationVirtualModulePrefixError, type TheoIntegration, type TheoPluginOptions, createIntegrationRegistry, defineTheoIntegration, theoPlugin, theoPluginAsync };