tricache 0.8.0 → 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.
- package/README.md +4 -2
- package/dashboards/prometheus-scrape.yml +18 -0
- package/dist/{cache-service-CyLdpo77.d.ts → cache-service-DVvroyqA.d.ts} +16 -1
- package/dist/{cache-service-5MZXFIGK.js → cache-service-KI5ACF3F.js} +1 -1
- package/dist/chunk-BQRURGGD.js +60 -0
- package/dist/chunk-IITRFWHY.js +196 -0
- package/dist/{chunk-6PQ5MOWR.js → chunk-PL5J3ZNT.js} +370 -81
- package/dist/cli.cjs +392 -84
- package/dist/cli.js +22 -4
- package/dist/dashboard/index.d.ts +2 -2
- package/dist/drizzle/index.cjs +350 -81
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +1 -1
- package/dist/edge/index.cjs +99 -38
- package/dist/edge/index.d.ts +3 -3
- package/dist/edge/index.js +5 -5
- package/dist/hono/index.cjs +7760 -0
- package/dist/hono/index.d.ts +91 -0
- package/dist/hono/index.js +185 -0
- package/dist/{hono-DQRS1Xd7.d.ts → hono-VA9A1m0I.d.ts} +3 -2
- package/dist/http/index.cjs +449 -119
- package/dist/http/index.d.ts +6 -30
- package/dist/http/index.js +9 -59
- package/dist/index.cjs +370 -81
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/nestjs/index.cjs +350 -81
- package/dist/nestjs/index.d.ts +2 -2
- package/dist/nestjs/index.js +1 -1
- package/dist/next/index.cjs +350 -81
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +1 -1
- package/dist/prisma/index.d.ts +2 -2
- package/dist/{types-B6krw64X.d.ts → types-B_QkVwJ7.d.ts} +23 -0
- package/dist/utils-CEsU_Z0s.d.ts +27 -0
- package/package.json +16 -6
- package/src/cache-service.ts +302 -35
- package/src/cli.ts +21 -4
- package/src/edge/hono.ts +123 -42
- package/src/hono/index.ts +316 -0
- package/src/http/index.ts +5 -0
- package/src/ipc-telemetry.ts +29 -1
- package/src/types.ts +25 -0
- package/dist/chunk-ZTSWCFYO.js +0 -135
package/dist/drizzle/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CacheService } from '../cache-service-
|
|
2
|
-
import { W as WrapOptions } from '../types-
|
|
1
|
+
import { C as CacheService } from '../cache-service-DVvroyqA.js';
|
|
2
|
+
import { W as WrapOptions } from '../types-B_QkVwJ7.js';
|
|
3
3
|
import 'crypto';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/drizzle/index.js
CHANGED
|
@@ -9,7 +9,7 @@ async function withCache(query, options = {}) {
|
|
|
9
9
|
const { cache, key, ttl = 300, swr, priority, tags, dependsOn, refreshAhead, xfetchBeta, notFoundTtl } = options;
|
|
10
10
|
let activeCache = cache;
|
|
11
11
|
if (!activeCache) {
|
|
12
|
-
const { CacheService } = await import("../cache-service-
|
|
12
|
+
const { CacheService } = await import("../cache-service-KI5ACF3F.js");
|
|
13
13
|
activeCache = CacheService.create();
|
|
14
14
|
}
|
|
15
15
|
let cacheKey = key;
|
package/dist/edge/index.cjs
CHANGED
|
@@ -1403,6 +1403,15 @@ function buildEdgeDeterministicKey(c, options) {
|
|
|
1403
1403
|
}
|
|
1404
1404
|
return key;
|
|
1405
1405
|
}
|
|
1406
|
+
var NonCacheableEdgeResponseError = class extends Error {
|
|
1407
|
+
constructor(response) {
|
|
1408
|
+
super(`Non-cacheable status: ${response.status}`);
|
|
1409
|
+
this.response = response;
|
|
1410
|
+
this.name = "NonCacheableEdgeResponseError";
|
|
1411
|
+
}
|
|
1412
|
+
response;
|
|
1413
|
+
isNonCacheable = true;
|
|
1414
|
+
};
|
|
1406
1415
|
function honoEdgeCache(options = {}) {
|
|
1407
1416
|
const {
|
|
1408
1417
|
cache,
|
|
@@ -1435,49 +1444,101 @@ function honoEdgeCache(options = {}) {
|
|
|
1435
1444
|
const key = buildEdgeDeterministicKey(c, { keyGenerator, headerWhitelist });
|
|
1436
1445
|
const ifNoneMatch = c.req.header?.("if-none-match") || c.req.header?.("If-None-Match");
|
|
1437
1446
|
const resolvedTags = typeof tags === "function" ? tags(c) : tags;
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1447
|
+
let ranNext = false;
|
|
1448
|
+
try {
|
|
1449
|
+
const cached = await cache.get(
|
|
1450
|
+
key,
|
|
1451
|
+
async () => {
|
|
1452
|
+
ranNext = true;
|
|
1453
|
+
await next();
|
|
1454
|
+
const res = c.res;
|
|
1455
|
+
if (!res) {
|
|
1456
|
+
return null;
|
|
1457
|
+
}
|
|
1458
|
+
const contentType = res.headers?.get?.("content-type") || "text/plain; charset=utf-8";
|
|
1459
|
+
if (contentType.toLowerCase().includes("text/event-stream")) {
|
|
1460
|
+
throw new NonCacheableEdgeResponseError({
|
|
1461
|
+
body: "",
|
|
1462
|
+
contentType,
|
|
1463
|
+
status: 0
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
const cc2 = res.headers?.get?.("cache-control");
|
|
1467
|
+
if (cc2) {
|
|
1468
|
+
const lowerCc = cc2.toLowerCase();
|
|
1469
|
+
if (lowerCc.includes("no-store") || lowerCc.includes("no-cache") || lowerCc.includes("private")) {
|
|
1470
|
+
throw new NonCacheableEdgeResponseError({
|
|
1471
|
+
body: "",
|
|
1472
|
+
contentType,
|
|
1473
|
+
status: 0
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
const statusCode = res.status ?? 200;
|
|
1478
|
+
if (statusCode < 200 || statusCode >= 300 || statusCode === 206) {
|
|
1479
|
+
throw new NonCacheableEdgeResponseError({
|
|
1480
|
+
body: "",
|
|
1481
|
+
contentType,
|
|
1482
|
+
status: statusCode
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
const clone = res.clone();
|
|
1486
|
+
const text = await clone.text();
|
|
1487
|
+
const bodyEtag = etag ? await computeEdgeETag(text) : void 0;
|
|
1488
|
+
const capturedHeaders = {};
|
|
1489
|
+
if (res.headers && typeof res.headers.forEach === "function") {
|
|
1490
|
+
res.headers.forEach((value, name) => {
|
|
1491
|
+
const lower = name.toLowerCase();
|
|
1492
|
+
if (lower !== "content-length" && lower !== "transfer-encoding" && lower !== "connection" && lower !== "etag" && lower !== "content-type") {
|
|
1493
|
+
capturedHeaders[name] = value;
|
|
1494
|
+
}
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
const snapshot = {
|
|
1498
|
+
body: text,
|
|
1499
|
+
contentType,
|
|
1500
|
+
headers: capturedHeaders,
|
|
1501
|
+
etag: bodyEtag,
|
|
1502
|
+
status: statusCode
|
|
1503
|
+
};
|
|
1504
|
+
return snapshot;
|
|
1505
|
+
},
|
|
1506
|
+
ttl,
|
|
1507
|
+
{
|
|
1508
|
+
swr,
|
|
1509
|
+
tags: resolvedTags,
|
|
1510
|
+
ctx: c.executionCtx
|
|
1445
1511
|
}
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
const bodyEtag = etag ? await computeEdgeETag(text) : void 0;
|
|
1450
|
-
const contentType = res.headers.get("content-type") || "text/plain; charset=utf-8";
|
|
1451
|
-
return {
|
|
1452
|
-
body: text,
|
|
1453
|
-
contentType,
|
|
1454
|
-
etag: bodyEtag,
|
|
1455
|
-
status: statusCode
|
|
1456
|
-
};
|
|
1457
|
-
},
|
|
1458
|
-
ttl,
|
|
1459
|
-
{
|
|
1460
|
-
swr,
|
|
1461
|
-
tags: resolvedTags,
|
|
1462
|
-
ctx: c.executionCtx
|
|
1512
|
+
);
|
|
1513
|
+
if (!cached) {
|
|
1514
|
+
return;
|
|
1463
1515
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
return c.body
|
|
1516
|
+
if (cached.etag && ifNoneMatch === cached.etag) {
|
|
1517
|
+
const notModifiedHeaders = { ETag: cached.etag };
|
|
1518
|
+
if (cached.headers?.["cache-control"]) notModifiedHeaders["Cache-Control"] = cached.headers["cache-control"];
|
|
1519
|
+
if (cached.headers?.["vary"]) notModifiedHeaders["Vary"] = cached.headers["vary"];
|
|
1520
|
+
return applyEdgeResponse(c, null, 304, notModifiedHeaders);
|
|
1521
|
+
}
|
|
1522
|
+
const headers = { ...cached.headers };
|
|
1523
|
+
if (cached.etag) headers["ETag"] = cached.etag;
|
|
1524
|
+
if (cached.contentType) headers["Content-Type"] = cached.contentType;
|
|
1525
|
+
return applyEdgeResponse(c, cached.body, cached.status ?? 200, headers);
|
|
1526
|
+
} catch (err) {
|
|
1527
|
+
if (err instanceof NonCacheableEdgeResponseError) {
|
|
1528
|
+
if (!ranNext) {
|
|
1529
|
+
return await next();
|
|
1530
|
+
}
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
throw err;
|
|
1474
1534
|
}
|
|
1475
|
-
const headers = {};
|
|
1476
|
-
if (cached.etag) headers["ETag"] = cached.etag;
|
|
1477
|
-
if (cached.contentType) headers["Content-Type"] = cached.contentType;
|
|
1478
|
-
return c.body(cached.body, cached.status ?? 200, headers);
|
|
1479
1535
|
};
|
|
1480
1536
|
}
|
|
1537
|
+
function applyEdgeResponse(c, body, status, headers) {
|
|
1538
|
+
const response = c.body(body, status, headers);
|
|
1539
|
+
c.res = response;
|
|
1540
|
+
return response;
|
|
1541
|
+
}
|
|
1481
1542
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1482
1543
|
0 && (module.exports = {
|
|
1483
1544
|
CloudflareDOStorageAdapter,
|
package/dist/edge/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { I as IEdgeRemoteStorage, U as UpstashRedisOptions, a as CloudflareKVNamespace, d as CloudflareDOStorage } from '../hono-
|
|
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-
|
|
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
3
|
export { B as BloomFilterStats, M as Murmur3BloomFilter, W as WasmBloomFilter, m as murmur3_32 } from '../murmur3-CMGw9PbV.js';
|
|
4
|
-
import '../types-
|
|
4
|
+
import '../types-B_QkVwJ7.js';
|
|
5
5
|
import 'crypto';
|
|
6
6
|
|
|
7
7
|
type WebCryptoMode = 'aes-256-gcm' | 'aes-128-gcm';
|
package/dist/edge/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildEdgeDeterministicKey,
|
|
3
|
-
computeEdgeETag,
|
|
4
|
-
honoEdgeCache
|
|
5
|
-
} from "../chunk-ZTSWCFYO.js";
|
|
6
1
|
import {
|
|
7
2
|
Murmur3BloomFilter,
|
|
8
3
|
murmur3_32
|
|
@@ -14,6 +9,11 @@ import {
|
|
|
14
9
|
uint8ArrayToUtf8,
|
|
15
10
|
utf8ToUint8Array
|
|
16
11
|
} from "../chunk-XZL45ABR.js";
|
|
12
|
+
import {
|
|
13
|
+
buildEdgeDeterministicKey,
|
|
14
|
+
computeEdgeETag,
|
|
15
|
+
honoEdgeCache
|
|
16
|
+
} from "../chunk-IITRFWHY.js";
|
|
17
17
|
|
|
18
18
|
// src/edge/crypto.ts
|
|
19
19
|
var PREFIX_256 = "enc:v1:";
|