tricache 1.0.0 → 1.0.2

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 (97) hide show
  1. package/README.md +36 -28
  2. package/dist/{cache-service-pJ-nFcVj.d.ts → cache-service-B108FzER.d.ts} +63 -3
  3. package/dist/cache-service-CWI4jkS7.d.cts +963 -0
  4. package/dist/{cache-service-26GCO3UU.js → cache-service-GYPZFB7O.js} +2 -2
  5. package/dist/{chunk-IITRFWHY.js → chunk-EUKB7RKP.js} +21 -4
  6. package/dist/{chunk-2AJKEQMZ.js → chunk-H4GFLQ26.js} +7 -4
  7. package/dist/{chunk-7RV5ZVBB.js → chunk-JNSLMK4Q.js} +111 -29
  8. package/dist/chunk-OYDU3SMI.js +89 -0
  9. package/dist/{chunk-VXFTFZ5N.js → chunk-VNRDL5RA.js} +117 -138
  10. package/dist/{chunk-7SZSQS55.js → chunk-WYF7NOAT.js} +1831 -759
  11. package/dist/cli.cjs +1757 -777
  12. package/dist/cli.d.cts +12 -0
  13. package/dist/cli.js +27 -6
  14. package/dist/dashboard/index.cjs +111 -29
  15. package/dist/dashboard/index.d.cts +185 -0
  16. package/dist/dashboard/index.d.ts +5 -3
  17. package/dist/dashboard/index.js +1 -1
  18. package/dist/drizzle/index.cjs +1757 -773
  19. package/dist/drizzle/index.d.cts +46 -0
  20. package/dist/drizzle/index.d.ts +2 -2
  21. package/dist/drizzle/index.js +1 -1
  22. package/dist/edge/index.cjs +280 -153
  23. package/dist/edge/index.d.cts +127 -0
  24. package/dist/edge/index.d.ts +3 -3
  25. package/dist/edge/index.js +254 -147
  26. package/dist/hono/index.cjs +1805 -793
  27. package/dist/hono/index.d.cts +93 -0
  28. package/dist/hono/index.d.ts +7 -5
  29. package/dist/hono/index.js +16 -9
  30. package/dist/{hono-DuNvciyq.d.ts → hono-3rDMYVtY.d.ts} +23 -3
  31. package/dist/hono-C886ok3X.d.cts +391 -0
  32. package/dist/http/index.cjs +1946 -842
  33. package/dist/http/index.d.cts +103 -0
  34. package/dist/http/index.d.ts +13 -5
  35. package/dist/http/index.js +137 -57
  36. package/dist/index.cjs +2073 -937
  37. package/dist/index.d.cts +1006 -0
  38. package/dist/index.d.ts +40 -8
  39. package/dist/index.js +8 -8
  40. package/dist/murmur3-CMGw9PbV.d.cts +98 -0
  41. package/dist/nestjs/index.cjs +1849 -806
  42. package/dist/nestjs/index.d.cts +285 -0
  43. package/dist/nestjs/index.d.ts +103 -30
  44. package/dist/nestjs/index.js +115 -32
  45. package/dist/next/index.cjs +1913 -887
  46. package/dist/next/index.d.cts +232 -0
  47. package/dist/next/index.d.ts +33 -11
  48. package/dist/next/index.js +174 -107
  49. package/dist/prisma/index.cjs +11 -1
  50. package/dist/prisma/index.d.cts +62 -0
  51. package/dist/prisma/index.d.ts +2 -2
  52. package/dist/prisma/index.js +11 -1
  53. package/dist/serialize-worker.d.cts +2 -0
  54. package/dist/{types-5HXqBfAf.d.ts → types-BA4pz1A0.d.cts} +26 -9
  55. package/dist/types-BA4pz1A0.d.ts +1519 -0
  56. package/dist/{utils-CEsU_Z0s.d.ts → utils-Bvzn-rKS.d.cts} +3 -1
  57. package/dist/utils-Bvzn-rKS.d.ts +29 -0
  58. package/package.json +96 -36
  59. package/src/adapters/auto-pipeliner.ts +107 -24
  60. package/src/adapters/node-redis.ts +123 -25
  61. package/src/cache-service.ts +1238 -659
  62. package/src/cli.ts +24 -6
  63. package/src/cross-region.ts +21 -3
  64. package/src/dashboard/handler.ts +26 -6
  65. package/src/dashboard/html.ts +35 -10
  66. package/src/dashboard/index.ts +35 -13
  67. package/src/dashboard/types.ts +3 -1
  68. package/src/disk-tier.ts +171 -65
  69. package/src/edge/cache.ts +202 -129
  70. package/src/edge/hono.ts +23 -6
  71. package/src/edge/types.ts +2 -0
  72. package/src/hono/index.ts +19 -9
  73. package/src/http/express.ts +110 -26
  74. package/src/http/fastify.ts +38 -28
  75. package/src/http/utils.ts +54 -20
  76. package/src/ipc-telemetry.ts +35 -9
  77. package/src/nestjs/decorators.ts +1 -1
  78. package/src/nestjs/index.ts +2 -0
  79. package/src/nestjs/keyv-adapter.ts +68 -0
  80. package/src/nestjs/tricache.module.ts +13 -11
  81. package/src/nestjs/tricache.store.ts +51 -20
  82. package/src/nestjs/types.ts +29 -15
  83. package/src/next/cache-handler.ts +132 -57
  84. package/src/next/index.ts +1 -0
  85. package/src/next/isr-handler.ts +1 -4
  86. package/src/next/types.ts +21 -0
  87. package/src/prisma/index.ts +12 -1
  88. package/src/smart-memory-cache.ts +65 -27
  89. package/src/types.ts +27 -2
  90. package/src/utils/cgroup.ts +12 -0
  91. package/src/utils/deadline.ts +14 -0
  92. package/src/utils/diagnostics.ts +27 -0
  93. package/src/utils/redis-slot.ts +13 -0
  94. package/src/wasm/bloom-filter-wasm.ts +9 -4
  95. package/src/worker-pool.ts +17 -8
  96. package/src/wtiny-lfu.ts +20 -6
  97. package/dist/chunk-BQRURGGD.js +0 -60
@@ -0,0 +1,127 @@
1
+ import { I as IEdgeRemoteStorage, U as UpstashRedisOptions, a as CloudflareKVNamespace, d as CloudflareDOStorage } from '../hono-C886ok3X.cjs';
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-C886ok3X.cjs';
3
+ export { B as BloomFilterStats, M as Murmur3BloomFilter, W as WasmBloomFilter, m as murmur3_32 } from '../murmur3-CMGw9PbV.cjs';
4
+ import '../types-BA4pz1A0.cjs';
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 };
@@ -1,7 +1,7 @@
1
- import { I as IEdgeRemoteStorage, U as UpstashRedisOptions, a as CloudflareKVNamespace, d as CloudflareDOStorage } from '../hono-DuNvciyq.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-DuNvciyq.js';
1
+ import { I as IEdgeRemoteStorage, U as UpstashRedisOptions, a as CloudflareKVNamespace, d as CloudflareDOStorage } from '../hono-3rDMYVtY.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-3rDMYVtY.js';
3
3
  export { B as BloomFilterStats, M as Murmur3BloomFilter, W as WasmBloomFilter, m as murmur3_32 } from '../murmur3-CMGw9PbV.js';
4
- import '../types-5HXqBfAf.js';
4
+ import '../types-BA4pz1A0.js';
5
5
  import 'crypto';
6
6
 
7
7
  type WebCryptoMode = 'aes-256-gcm' | 'aes-128-gcm';