tricache 0.7.1 → 0.9.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 (102) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +89 -1371
  3. package/dashboards/prometheus-scrape.yml +18 -0
  4. package/dashboards/tricache-alerts.yaml +54 -0
  5. package/dashboards/tricache-grafana.json +548 -0
  6. package/dist/cache-service-DVvroyqA.d.ts +886 -0
  7. package/dist/cache-service-KI5ACF3F.js +12 -0
  8. package/dist/chunk-7RV5ZVBB.js +1023 -0
  9. package/dist/chunk-BQRURGGD.js +60 -0
  10. package/dist/chunk-IITRFWHY.js +196 -0
  11. package/dist/{chunk-X5AXHPVD.js → chunk-LJ5QJB5O.js} +90 -5
  12. package/dist/{chunk-EUGYR7KR.js → chunk-PL5J3ZNT.js} +3184 -514
  13. package/dist/chunk-QNU7B43J.js +687 -0
  14. package/dist/chunk-UGD4VEPD.js +138 -0
  15. package/dist/chunk-XZL45ABR.js +108 -0
  16. package/dist/cli.cjs +3122 -495
  17. package/dist/cli.d.ts +1 -0
  18. package/dist/cli.js +121 -5
  19. package/dist/dashboard/index.cjs +1065 -0
  20. package/dist/dashboard/index.d.ts +183 -0
  21. package/dist/dashboard/index.js +22 -0
  22. package/dist/drizzle/index.cjs +2846 -494
  23. package/dist/drizzle/index.d.ts +3 -1
  24. package/dist/drizzle/index.js +1 -1
  25. package/dist/edge/index.cjs +1559 -0
  26. package/dist/edge/index.d.ts +127 -0
  27. package/dist/edge/index.js +1109 -0
  28. package/dist/hono/index.cjs +7760 -0
  29. package/dist/hono/index.d.ts +91 -0
  30. package/dist/hono/index.js +185 -0
  31. package/dist/hono-VA9A1m0I.d.ts +371 -0
  32. package/dist/http/index.cjs +3281 -587
  33. package/dist/http/index.d.ts +85 -23
  34. package/dist/http/index.js +176 -78
  35. package/dist/index.cjs +7212 -2505
  36. package/dist/index.d.ts +547 -30
  37. package/dist/index.js +104 -5
  38. package/dist/murmur3-CMGw9PbV.d.ts +98 -0
  39. package/dist/nestjs/index.cjs +2787 -487
  40. package/dist/nestjs/index.d.ts +3 -1
  41. package/dist/nestjs/index.js +6 -3
  42. package/dist/next/index.cjs +2804 -501
  43. package/dist/next/index.d.ts +4 -2
  44. package/dist/next/index.js +14 -10
  45. package/dist/prisma/index.d.ts +3 -1
  46. package/dist/serialize-worker.cjs +5 -4
  47. package/dist/serialize-worker.js +1 -1
  48. package/dist/{cache-service-D8tIXmzb.d.ts → types-B_QkVwJ7.d.ts} +622 -662
  49. package/dist/utils-CEsU_Z0s.d.ts +27 -0
  50. package/package.json +48 -10
  51. package/src/adapters/auto-pipeliner.ts +206 -0
  52. package/src/adapters/node-redis.ts +370 -0
  53. package/src/cache-service.ts +1619 -415
  54. package/src/cli.ts +137 -2
  55. package/src/codec.ts +72 -0
  56. package/src/cross-region.ts +245 -0
  57. package/src/dashboard/handler.ts +392 -0
  58. package/src/dashboard/html.ts +594 -0
  59. package/src/dashboard/index.ts +195 -0
  60. package/src/dashboard/types.ts +96 -0
  61. package/src/disk-tier.ts +449 -47
  62. package/src/drizzle/index.ts +86 -86
  63. package/src/edge/adapters/cloudflare-do.ts +130 -0
  64. package/src/edge/adapters/cloudflare-kv.ts +115 -0
  65. package/src/edge/adapters/upstash.ts +143 -0
  66. package/src/edge/cache.ts +797 -0
  67. package/src/edge/crypto.ts +182 -0
  68. package/src/edge/hono.ts +284 -0
  69. package/src/edge/index.ts +37 -0
  70. package/src/edge/types.ts +230 -0
  71. package/src/edge/utils/base64.ts +63 -0
  72. package/src/edge/utils/murmur3.ts +179 -0
  73. package/src/encryption.ts +127 -5
  74. package/src/hono/index.ts +316 -0
  75. package/src/http/express.ts +195 -0
  76. package/src/http/fastify.ts +260 -0
  77. package/src/http/index.ts +44 -258
  78. package/src/http/utils.ts +92 -0
  79. package/src/index.ts +149 -47
  80. package/src/ipc-telemetry.ts +509 -0
  81. package/src/latency-watchdog.ts +282 -0
  82. package/src/nestjs/decorators.ts +161 -161
  83. package/src/nestjs/index.ts +23 -23
  84. package/src/nestjs/tricache.module.ts +104 -104
  85. package/src/nestjs/tricache.store.ts +97 -97
  86. package/src/nestjs/types.ts +79 -79
  87. package/src/next/cache-handler.ts +12 -9
  88. package/src/next/index.ts +37 -37
  89. package/src/next/isr-handler.ts +105 -105
  90. package/src/next/types.ts +130 -130
  91. package/src/remote-snapshot.ts +153 -0
  92. package/src/serialize-worker.ts +120 -120
  93. package/src/sigv4-snapshot-adapter.ts +260 -0
  94. package/src/smart-memory-cache.ts +91 -8
  95. package/src/types.ts +315 -2
  96. package/src/utils/cgroup.ts +100 -0
  97. package/src/utils/tracing.ts +54 -0
  98. package/src/wasm/bloom-filter-wasm.ts +109 -102
  99. package/src/worker-pool.ts +299 -299
  100. package/src/wtiny-lfu.ts +624 -0
  101. package/dist/cache-service-5GATUYAK.js +0 -7
  102. package/dist/chunk-UBSR5UYA.js +0 -0
@@ -0,0 +1,127 @@
1
+ import { I as IEdgeRemoteStorage, U as UpstashRedisOptions, a as CloudflareKVNamespace, d as CloudflareDOStorage } from '../hono-VA9A1m0I.js';
2
+ export { C as CachedEdgeHttpResponse, e as CloudflareR2Bucket, f as CloudflareR2Object, E as EdgeCacheOptions, g as EdgeCacheService, i as EdgeExportSnapshotOptions, j as EdgeGetOptions, k as EdgeHydrateOptions, l as EdgeSnapshotPayload, m as EdgeSnapshotSource, H as HonoEdgeCacheOptions, n as IEdgeBloomFilter, b as buildEdgeDeterministicKey, c as computeEdgeETag, h as honoEdgeCache } from '../hono-VA9A1m0I.js';
3
+ export { B as BloomFilterStats, M as Murmur3BloomFilter, W as WasmBloomFilter, m as murmur3_32 } from '../murmur3-CMGw9PbV.js';
4
+ import '../types-B_QkVwJ7.js';
5
+ import 'crypto';
6
+
7
+ type WebCryptoMode = 'aes-256-gcm' | 'aes-128-gcm';
8
+ interface WebCryptoOptions {
9
+ keyBase64: string;
10
+ prevKeyBase64?: string;
11
+ mode?: WebCryptoMode;
12
+ }
13
+ /**
14
+ * Pure Web Crypto API implementation of TriCache AEAD encryption.
15
+ * Compatible with Cloudflare Workers, Fastly Compute, Vercel Edge, Deno, and modern browsers.
16
+ *
17
+ * Interoperates with Node.js `CacheEncryption` by reordering Web Crypto's trailing tag
18
+ * into TriCache's standard wire envelope:
19
+ * Envelope = IV[12] || Tag[16] || Ciphertext[N]
20
+ */
21
+ declare class WebCryptoEncryption {
22
+ readonly isEnabled: boolean;
23
+ private readonly mode;
24
+ private keyPromise;
25
+ private prevKeyPromise;
26
+ constructor(options?: WebCryptoOptions);
27
+ private _importKey;
28
+ /**
29
+ * Encrypts a plaintext string into a TriCache standard wire envelope.
30
+ * Format: `enc:v1:<base64(IV[12] | Tag[16] | Ciphertext)>`
31
+ */
32
+ encrypt(plaintext: string): Promise<string>;
33
+ /**
34
+ * Decrypts a TriCache standard wire envelope into plaintext.
35
+ * Handles envelopes created by both WebCryptoEncryption and Node.js CacheEncryption.
36
+ */
37
+ decrypt(envelopeStr: string): Promise<string>;
38
+ private _decryptWithKey;
39
+ }
40
+
41
+ /**
42
+ * High-performance HTTP-based Redis driver for Upstash.
43
+ * Compatible with pure V8 Edge Isolates (Cloudflare Workers, Vercel Edge, Fastly Compute).
44
+ *
45
+ * Communicates over HTTPS REST with zero native socket dependencies.
46
+ */
47
+ declare class UpstashRedisAdapter implements IEdgeRemoteStorage {
48
+ private readonly baseUrl;
49
+ private readonly token;
50
+ private readonly customFetch;
51
+ constructor(options: UpstashRedisOptions);
52
+ private _executeCommand;
53
+ private _executePipeline;
54
+ get(key: string): Promise<string | null>;
55
+ set(key: string, value: string, ttlSeconds?: number): Promise<void>;
56
+ delete(key: string): Promise<void>;
57
+ mget(keys: string[]): Promise<(string | null)[]>;
58
+ mset(entries: Record<string, string>, ttlSeconds?: number): Promise<void>;
59
+ clear(prefix?: string): Promise<void>;
60
+ incrementTagVersion(tag: string): Promise<number>;
61
+ getTagVersion(tag: string): Promise<number>;
62
+ batchGetTagVersions(tags: string[]): Promise<Record<string, number>>;
63
+ }
64
+
65
+ /**
66
+ * Storage adapter for Cloudflare Workers KV.
67
+ *
68
+ * Mitigates Cloudflare KV's strict 60-second TTL floor by wrapping sub-minute
69
+ * TTLs in a lightweight timestamp envelope and validating expiry on read.
70
+ */
71
+ declare class CloudflareKVAdapter implements IEdgeRemoteStorage {
72
+ private readonly kv;
73
+ constructor(kv: CloudflareKVNamespace);
74
+ get(key: string): Promise<string | null>;
75
+ set(key: string, value: string, ttlSeconds?: number): Promise<void>;
76
+ delete(key: string): Promise<void>;
77
+ mget(keys: string[]): Promise<(string | null)[]>;
78
+ mset(entries: Record<string, string>, ttlSeconds?: number): Promise<void>;
79
+ clear(prefix?: string): Promise<void>;
80
+ incrementTagVersion(tag: string): Promise<number>;
81
+ getTagVersion(tag: string): Promise<number>;
82
+ batchGetTagVersions(tags: string[]): Promise<Record<string, number>>;
83
+ }
84
+
85
+ /**
86
+ * Storage adapter for Cloudflare Durable Objects transactional storage (`state.storage`).
87
+ * Enables strongly-consistent edge caching and coordination across edge isolates.
88
+ */
89
+ declare class CloudflareDOStorageAdapter implements IEdgeRemoteStorage {
90
+ private readonly storage;
91
+ constructor(storage: CloudflareDOStorage);
92
+ get(key: string): Promise<string | null>;
93
+ set(key: string, value: string, ttlSeconds?: number): Promise<void>;
94
+ delete(key: string): Promise<void>;
95
+ mget(keys: string[]): Promise<(string | null)[]>;
96
+ mset(entries: Record<string, string>, ttlSeconds?: number): Promise<void>;
97
+ clear(prefix?: string): Promise<void>;
98
+ incrementTagVersion(tag: string): Promise<number>;
99
+ getTagVersion(tag: string): Promise<number>;
100
+ batchGetTagVersions(tags: string[]): Promise<Record<string, number>>;
101
+ }
102
+
103
+ /**
104
+ * Zero-dependency Base64 <-> Uint8Array utilities designed for pure Edge isolates
105
+ * (Cloudflare Workers without nodejs_compat, Deno, Fastly Compute, browsers).
106
+ *
107
+ * Avoids call stack overflow (RangeError: Maximum call stack size exceeded)
108
+ * on payloads > 64 KB by chunking binary data into safe 8 KB slices.
109
+ */
110
+ /**
111
+ * Converts a Uint8Array to a standard Base64 string safely across all JS runtimes.
112
+ */
113
+ declare function uint8ArrayToBase64(bytes: Uint8Array): string;
114
+ /**
115
+ * Converts a Base64 string to a Uint8Array safely across all JS runtimes.
116
+ */
117
+ declare function base64ToUint8Array(base64: string): Uint8Array;
118
+ /**
119
+ * Encodes a UTF-8 string to a Uint8Array using standard TextEncoder.
120
+ */
121
+ declare function utf8ToUint8Array(str: string): Uint8Array;
122
+ /**
123
+ * Decodes a Uint8Array to a UTF-8 string using standard TextDecoder.
124
+ */
125
+ declare function uint8ArrayToUtf8(bytes: Uint8Array): string;
126
+
127
+ export { CloudflareDOStorage, CloudflareDOStorageAdapter, CloudflareKVAdapter, CloudflareKVNamespace, IEdgeRemoteStorage, UpstashRedisAdapter, UpstashRedisOptions, WebCryptoEncryption, type WebCryptoMode, type WebCryptoOptions, base64ToUint8Array, uint8ArrayToBase64, uint8ArrayToUtf8, utf8ToUint8Array };