tricache 0.7.1 → 0.8.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 (95) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +87 -1371
  3. package/dashboards/tricache-alerts.yaml +54 -0
  4. package/dashboards/tricache-grafana.json +548 -0
  5. package/dist/cache-service-5MZXFIGK.js +12 -0
  6. package/dist/cache-service-CyLdpo77.d.ts +871 -0
  7. package/dist/{chunk-EUGYR7KR.js → chunk-6PQ5MOWR.js} +2871 -490
  8. package/dist/chunk-7RV5ZVBB.js +1023 -0
  9. package/dist/{chunk-X5AXHPVD.js → chunk-LJ5QJB5O.js} +90 -5
  10. package/dist/chunk-QNU7B43J.js +687 -0
  11. package/dist/chunk-UGD4VEPD.js +138 -0
  12. package/dist/chunk-XZL45ABR.js +108 -0
  13. package/dist/chunk-ZTSWCFYO.js +135 -0
  14. package/dist/cli.cjs +2790 -471
  15. package/dist/cli.d.ts +1 -0
  16. package/dist/cli.js +103 -5
  17. package/dist/dashboard/index.cjs +1065 -0
  18. package/dist/dashboard/index.d.ts +183 -0
  19. package/dist/dashboard/index.js +22 -0
  20. package/dist/drizzle/index.cjs +2553 -470
  21. package/dist/drizzle/index.d.ts +3 -1
  22. package/dist/drizzle/index.js +1 -1
  23. package/dist/edge/index.cjs +1498 -0
  24. package/dist/edge/index.d.ts +127 -0
  25. package/dist/edge/index.js +1109 -0
  26. package/dist/hono-DQRS1Xd7.d.ts +370 -0
  27. package/dist/http/index.cjs +2926 -562
  28. package/dist/http/index.d.ts +109 -23
  29. package/dist/http/index.js +220 -72
  30. package/dist/index.cjs +6936 -2518
  31. package/dist/index.d.ts +547 -30
  32. package/dist/index.js +104 -5
  33. package/dist/murmur3-CMGw9PbV.d.ts +98 -0
  34. package/dist/nestjs/index.cjs +2494 -463
  35. package/dist/nestjs/index.d.ts +3 -1
  36. package/dist/nestjs/index.js +6 -3
  37. package/dist/next/index.cjs +2517 -483
  38. package/dist/next/index.d.ts +4 -2
  39. package/dist/next/index.js +14 -10
  40. package/dist/prisma/index.d.ts +3 -1
  41. package/dist/serialize-worker.cjs +5 -4
  42. package/dist/serialize-worker.js +1 -1
  43. package/dist/{cache-service-D8tIXmzb.d.ts → types-B6krw64X.d.ts} +596 -659
  44. package/package.json +34 -6
  45. package/src/adapters/auto-pipeliner.ts +206 -0
  46. package/src/adapters/node-redis.ts +370 -0
  47. package/src/cache-service.ts +1339 -402
  48. package/src/cli.ts +120 -2
  49. package/src/codec.ts +72 -0
  50. package/src/cross-region.ts +245 -0
  51. package/src/dashboard/handler.ts +392 -0
  52. package/src/dashboard/html.ts +594 -0
  53. package/src/dashboard/index.ts +195 -0
  54. package/src/dashboard/types.ts +96 -0
  55. package/src/disk-tier.ts +449 -47
  56. package/src/drizzle/index.ts +86 -86
  57. package/src/edge/adapters/cloudflare-do.ts +130 -0
  58. package/src/edge/adapters/cloudflare-kv.ts +115 -0
  59. package/src/edge/adapters/upstash.ts +143 -0
  60. package/src/edge/cache.ts +797 -0
  61. package/src/edge/crypto.ts +182 -0
  62. package/src/edge/hono.ts +203 -0
  63. package/src/edge/index.ts +37 -0
  64. package/src/edge/types.ts +230 -0
  65. package/src/edge/utils/base64.ts +63 -0
  66. package/src/edge/utils/murmur3.ts +179 -0
  67. package/src/encryption.ts +127 -5
  68. package/src/http/express.ts +195 -0
  69. package/src/http/fastify.ts +260 -0
  70. package/src/http/index.ts +39 -258
  71. package/src/http/utils.ts +92 -0
  72. package/src/index.ts +149 -47
  73. package/src/ipc-telemetry.ts +481 -0
  74. package/src/latency-watchdog.ts +282 -0
  75. package/src/nestjs/decorators.ts +161 -161
  76. package/src/nestjs/index.ts +23 -23
  77. package/src/nestjs/tricache.module.ts +104 -104
  78. package/src/nestjs/tricache.store.ts +97 -97
  79. package/src/nestjs/types.ts +79 -79
  80. package/src/next/cache-handler.ts +12 -9
  81. package/src/next/index.ts +37 -37
  82. package/src/next/isr-handler.ts +105 -105
  83. package/src/next/types.ts +130 -130
  84. package/src/remote-snapshot.ts +153 -0
  85. package/src/serialize-worker.ts +120 -120
  86. package/src/sigv4-snapshot-adapter.ts +260 -0
  87. package/src/smart-memory-cache.ts +91 -8
  88. package/src/types.ts +290 -2
  89. package/src/utils/cgroup.ts +100 -0
  90. package/src/utils/tracing.ts +54 -0
  91. package/src/wasm/bloom-filter-wasm.ts +109 -102
  92. package/src/worker-pool.ts +299 -299
  93. package/src/wtiny-lfu.ts +624 -0
  94. package/dist/cache-service-5GATUYAK.js +0 -7
  95. package/dist/chunk-UBSR5UYA.js +0 -0
@@ -0,0 +1,183 @@
1
+ import http, { IncomingMessage, ServerResponse } from 'node:http';
2
+ import { C as CacheService } from '../cache-service-CyLdpo77.js';
3
+ import '../types-B6krw64X.js';
4
+ import 'crypto';
5
+
6
+ interface DashboardPeerInstance {
7
+ name: string;
8
+ url: string;
9
+ }
10
+ interface DashboardActionEvent {
11
+ action: 'clear' | 'invalidate-tag';
12
+ target?: string;
13
+ user?: string;
14
+ ip?: string;
15
+ timestamp: number;
16
+ success: boolean;
17
+ error?: string;
18
+ }
19
+ interface DashboardOptions {
20
+ /**
21
+ * TriCache instance to monitor and manage.
22
+ */
23
+ cache: CacheService;
24
+ /**
25
+ * Base mounting path for the dashboard (e.g. '/cache/dashboard' or '/admin/cache').
26
+ * Used for generating relative links and API request paths.
27
+ * @default ''
28
+ */
29
+ basePath?: string;
30
+ /**
31
+ * Custom title displayed in the browser tab and dashboard header.
32
+ * @default 'TriCache Observability'
33
+ */
34
+ title?: string;
35
+ /**
36
+ * Identifier for the local container/pod/process.
37
+ * Defaults to process.env.POD_NAME, process.env.HOSTNAME, or os.hostname().
38
+ */
39
+ instanceId?: string;
40
+ /**
41
+ * Optional list of sibling peer instance URLs for pod switching in multi-pod clusters.
42
+ */
43
+ peerInstances?: DashboardPeerInstance[];
44
+ /**
45
+ * HTTP Basic Authentication credentials.
46
+ * Evaluated using timing-safe comparison (crypto.timingSafeEqual with SHA-256).
47
+ */
48
+ auth?: {
49
+ username: string;
50
+ password: string;
51
+ };
52
+ /**
53
+ * Bearer token or URL token query parameter ('?token=...') for API authentication.
54
+ * Evaluated using timing-safe comparison.
55
+ */
56
+ authSecret?: string;
57
+ /**
58
+ * Enforces read-only mode: disables and blocks all mutating operations
59
+ * (e.g. invalidate tag, clear cache tier). Mutating endpoints return 403 Forbidden.
60
+ * @default false
61
+ */
62
+ readOnly?: boolean;
63
+ /**
64
+ * Server-Sent Events (SSE) metric stream push interval in milliseconds.
65
+ * @default 2000
66
+ */
67
+ streamIntervalMs?: number;
68
+ /**
69
+ * Enterprise audit logging hook invoked when an administrative action is attempted.
70
+ * Allows piping security/audit events to Datadog, CloudWatch, Splunk, etc.
71
+ */
72
+ onAction?: (event: DashboardActionEvent) => void;
73
+ }
74
+ interface StandaloneDashboardOptions extends DashboardOptions {
75
+ /**
76
+ * Port to listen on.
77
+ * @default 9090
78
+ */
79
+ port?: number;
80
+ /**
81
+ * Host / IP interface to bind. Defaults to '127.0.0.1' for security.
82
+ * Use '0.0.0.0' only inside private VPCs or behind authenticated reverse proxies.
83
+ * @default '127.0.0.1'
84
+ */
85
+ host?: string;
86
+ }
87
+
88
+ /**
89
+ * Timing-safe string comparison routine using SHA-256 digests to neutralize
90
+ * both length-leakage side-channels and buffer-length mismatch exceptions.
91
+ */
92
+ declare function safeCompare(a: string, b: string): boolean;
93
+ /**
94
+ * Resolve local instance/pod identifier from options or environment.
95
+ */
96
+ declare function resolveInstanceId(custom?: string): string;
97
+ /**
98
+ * Build the JSON snapshot payload for /api/metrics and SSE stream events.
99
+ */
100
+ declare function buildMetricsPayload(options: DashboardOptions): Record<string, unknown>;
101
+ /**
102
+ * Framework-agnostic Web Standards request handler for the TriCache dashboard.
103
+ * Accepts a Web Standard Request and returns a Web Standard Response.
104
+ */
105
+ declare function handleDashboardRequest(req: Request, options: DashboardOptions): Promise<Response>;
106
+
107
+ /**
108
+ * Embedded Single-Page Observability Dashboard for TriCache.
109
+ *
110
+ * Design features:
111
+ * - 100% self-contained & air-gapped (zero external CDN or font dependencies)
112
+ * - Modern dark glassmorphic UI with high contrast and smooth micro-animations
113
+ * - Server-Sent Events (SSE) live streaming with auto-reconnect and polling fallback
114
+ * - Pod vs. Fleet cluster awareness indicators
115
+ * - Immutable HTML pre-compressed with Gzip at module initialization
116
+ */
117
+ declare const DASHBOARD_HTML: string;
118
+ /**
119
+ * Pre-compressed Gzip binary representation of the immutable dashboard HTML.
120
+ * Served directly with Content-Encoding: gzip to minimize latency and CPU overhead.
121
+ */
122
+ declare const DASHBOARD_GZIP_BUFFER: Buffer;
123
+
124
+ /**
125
+ * Connect/Express/Fastify middleware adapter for the TriCache observability dashboard.
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * import { tricacheDashboard } from 'tricache/dashboard';
130
+ *
131
+ * app.use('/admin/cache', tricacheDashboard({
132
+ * cache,
133
+ * auth: { username: 'admin', password: process.env.DASHBOARD_PASSWORD },
134
+ * readOnly: process.env.NODE_ENV === 'production',
135
+ * }));
136
+ * ```
137
+ */
138
+ declare function tricacheDashboard(options: DashboardOptions): (req: IncomingMessage, res: ServerResponse, next?: (err?: unknown) => void) => Promise<void>;
139
+ /**
140
+ * Next.js App Router route handlers for the TriCache dashboard.
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * // app/admin/cache/[...slug]/route.ts
145
+ * import { createNextDashboardHandlers } from 'tricache/dashboard';
146
+ * import { cache } from '@/lib/cache';
147
+ *
148
+ * export const { GET, POST } = createNextDashboardHandlers({
149
+ * cache,
150
+ * basePath: '/admin/cache',
151
+ * readOnly: true,
152
+ * });
153
+ * ```
154
+ */
155
+ declare function createNextDashboardHandlers(options: DashboardOptions): {
156
+ GET: (req: Request) => Promise<Response>;
157
+ POST: (req: Request) => Promise<Response>;
158
+ };
159
+ /**
160
+ * Starts a standalone, dedicated HTTP management server for the TriCache dashboard.
161
+ * Ideal for microservices, background workers, and Kubernetes pods via `kubectl port-forward`.
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * import { startDashboardServer } from 'tricache/dashboard';
166
+ *
167
+ * const mgmt = await startDashboardServer({
168
+ * cache,
169
+ * port: 9090,
170
+ * host: '127.0.0.1',
171
+ * authSecret: process.env.MANAGEMENT_SECRET,
172
+ * });
173
+ * console.log(`Observability dashboard running at http://localhost:${mgmt.port}`);
174
+ * ```
175
+ */
176
+ declare function startDashboardServer(options: StandaloneDashboardOptions): Promise<{
177
+ server: http.Server;
178
+ port: number;
179
+ host: string;
180
+ close: () => Promise<void>;
181
+ }>;
182
+
183
+ export { DASHBOARD_GZIP_BUFFER, DASHBOARD_HTML, type DashboardActionEvent, type DashboardOptions, type DashboardPeerInstance, type StandaloneDashboardOptions, buildMetricsPayload, createNextDashboardHandlers, handleDashboardRequest, resolveInstanceId, safeCompare, startDashboardServer, tricacheDashboard };
@@ -0,0 +1,22 @@
1
+ import {
2
+ DASHBOARD_GZIP_BUFFER,
3
+ DASHBOARD_HTML,
4
+ buildMetricsPayload,
5
+ createNextDashboardHandlers,
6
+ handleDashboardRequest,
7
+ resolveInstanceId,
8
+ safeCompare,
9
+ startDashboardServer,
10
+ tricacheDashboard
11
+ } from "../chunk-7RV5ZVBB.js";
12
+ export {
13
+ DASHBOARD_GZIP_BUFFER,
14
+ DASHBOARD_HTML,
15
+ buildMetricsPayload,
16
+ createNextDashboardHandlers,
17
+ handleDashboardRequest,
18
+ resolveInstanceId,
19
+ safeCompare,
20
+ startDashboardServer,
21
+ tricacheDashboard
22
+ };