@graphql-hive/core 0.19.0 → 0.20.0-rc-20260107125616-c72aa9a25a868a0108f9af39de795a75f28c1c3b
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/cjs/client/persisted-documents.js +16 -6
- package/cjs/version.js +1 -1
- package/esm/client/persisted-documents.js +16 -6
- package/esm/version.js +1 -1
- package/package.json +1 -1
- package/typings/client/types.d.cts +5 -0
- package/typings/client/types.d.ts +5 -0
- package/typings/version.d.cts +1 -1
- package/typings/version.d.ts +1 -1
|
@@ -67,14 +67,24 @@ function createValidationError(documentId, error) {
|
|
|
67
67
|
return new PersistedDocumentValidationError(documentId, error);
|
|
68
68
|
}
|
|
69
69
|
function createPersistedDocuments(config) {
|
|
70
|
-
var _a, _b, _c, _d, _e, _f;
|
|
70
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
71
71
|
// L1
|
|
72
72
|
const persistedDocumentsCache = (0, tiny_lru_1.default)((_a = config.cache) !== null && _a !== void 0 ? _a : 10000);
|
|
73
73
|
// L2
|
|
74
74
|
const layer2Cache = (_b = config.layer2Cache) === null || _b === void 0 ? void 0 : _b.cache;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
75
|
+
let layer2TtlSeconds = (_c = config.layer2Cache) === null || _c === void 0 ? void 0 : _c.ttlSeconds;
|
|
76
|
+
let layer2NotFoundTtlSeconds = (_e = (_d = config.layer2Cache) === null || _d === void 0 ? void 0 : _d.notFoundTtlSeconds) !== null && _e !== void 0 ? _e : 60;
|
|
77
|
+
const layer2KeyPrefix = (_g = (_f = config.layer2Cache) === null || _f === void 0 ? void 0 : _f.keyPrefix) !== null && _g !== void 0 ? _g : '';
|
|
78
|
+
const layer2WaitUntil = (_h = config.layer2Cache) === null || _h === void 0 ? void 0 : _h.waitUntil;
|
|
79
|
+
// Validate L2 cache options
|
|
80
|
+
if (layer2TtlSeconds !== undefined && layer2TtlSeconds < 0) {
|
|
81
|
+
config.logger.warn('Negative ttlSeconds (%d) provided for L2 cache; treating as no expiration', layer2TtlSeconds);
|
|
82
|
+
layer2TtlSeconds = undefined;
|
|
83
|
+
}
|
|
84
|
+
if (layer2NotFoundTtlSeconds !== undefined && layer2NotFoundTtlSeconds < 0) {
|
|
85
|
+
config.logger.warn('Negative notFoundTtlSeconds (%d) provided for L2 cache; treating as no expiration', layer2NotFoundTtlSeconds);
|
|
86
|
+
layer2NotFoundTtlSeconds = undefined;
|
|
87
|
+
}
|
|
78
88
|
let allowArbitraryDocuments;
|
|
79
89
|
if (typeof config.allowArbitraryDocuments === 'boolean') {
|
|
80
90
|
let value = config.allowArbitraryDocuments;
|
|
@@ -123,7 +133,7 @@ function createPersistedDocuments(config) {
|
|
|
123
133
|
}
|
|
124
134
|
let cached;
|
|
125
135
|
try {
|
|
126
|
-
cached = await layer2Cache.get(documentId);
|
|
136
|
+
cached = await layer2Cache.get(layer2KeyPrefix + documentId);
|
|
127
137
|
}
|
|
128
138
|
catch (error) {
|
|
129
139
|
// L2 cache failure should not break the request
|
|
@@ -155,7 +165,7 @@ function createPersistedDocuments(config) {
|
|
|
155
165
|
const cacheValue = value === null ? types_js_1.PERSISTED_DOCUMENT_NOT_FOUND : value;
|
|
156
166
|
const ttl = value === null ? layer2NotFoundTtlSeconds : layer2TtlSeconds;
|
|
157
167
|
// Fire-and-forget. don't await, don't block
|
|
158
|
-
const setPromise = layer2Cache.set(documentId, cacheValue, ttl ? { ttl } : undefined);
|
|
168
|
+
const setPromise = layer2Cache.set(layer2KeyPrefix + documentId, cacheValue, ttl ? { ttl } : undefined);
|
|
159
169
|
if (setPromise) {
|
|
160
170
|
const handledPromise = Promise.resolve(setPromise).then(() => {
|
|
161
171
|
config.logger.debug('L2 cache set succeeded for document %s', documentId);
|
package/cjs/version.js
CHANGED
|
@@ -63,14 +63,24 @@ function createValidationError(documentId, error) {
|
|
|
63
63
|
return new PersistedDocumentValidationError(documentId, error);
|
|
64
64
|
}
|
|
65
65
|
export function createPersistedDocuments(config) {
|
|
66
|
-
var _a, _b, _c, _d, _e, _f;
|
|
66
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
67
67
|
// L1
|
|
68
68
|
const persistedDocumentsCache = LRU((_a = config.cache) !== null && _a !== void 0 ? _a : 10000);
|
|
69
69
|
// L2
|
|
70
70
|
const layer2Cache = (_b = config.layer2Cache) === null || _b === void 0 ? void 0 : _b.cache;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
71
|
+
let layer2TtlSeconds = (_c = config.layer2Cache) === null || _c === void 0 ? void 0 : _c.ttlSeconds;
|
|
72
|
+
let layer2NotFoundTtlSeconds = (_e = (_d = config.layer2Cache) === null || _d === void 0 ? void 0 : _d.notFoundTtlSeconds) !== null && _e !== void 0 ? _e : 60;
|
|
73
|
+
const layer2KeyPrefix = (_g = (_f = config.layer2Cache) === null || _f === void 0 ? void 0 : _f.keyPrefix) !== null && _g !== void 0 ? _g : '';
|
|
74
|
+
const layer2WaitUntil = (_h = config.layer2Cache) === null || _h === void 0 ? void 0 : _h.waitUntil;
|
|
75
|
+
// Validate L2 cache options
|
|
76
|
+
if (layer2TtlSeconds !== undefined && layer2TtlSeconds < 0) {
|
|
77
|
+
config.logger.warn('Negative ttlSeconds (%d) provided for L2 cache; treating as no expiration', layer2TtlSeconds);
|
|
78
|
+
layer2TtlSeconds = undefined;
|
|
79
|
+
}
|
|
80
|
+
if (layer2NotFoundTtlSeconds !== undefined && layer2NotFoundTtlSeconds < 0) {
|
|
81
|
+
config.logger.warn('Negative notFoundTtlSeconds (%d) provided for L2 cache; treating as no expiration', layer2NotFoundTtlSeconds);
|
|
82
|
+
layer2NotFoundTtlSeconds = undefined;
|
|
83
|
+
}
|
|
74
84
|
let allowArbitraryDocuments;
|
|
75
85
|
if (typeof config.allowArbitraryDocuments === 'boolean') {
|
|
76
86
|
let value = config.allowArbitraryDocuments;
|
|
@@ -119,7 +129,7 @@ export function createPersistedDocuments(config) {
|
|
|
119
129
|
}
|
|
120
130
|
let cached;
|
|
121
131
|
try {
|
|
122
|
-
cached = await layer2Cache.get(documentId);
|
|
132
|
+
cached = await layer2Cache.get(layer2KeyPrefix + documentId);
|
|
123
133
|
}
|
|
124
134
|
catch (error) {
|
|
125
135
|
// L2 cache failure should not break the request
|
|
@@ -151,7 +161,7 @@ export function createPersistedDocuments(config) {
|
|
|
151
161
|
const cacheValue = value === null ? PERSISTED_DOCUMENT_NOT_FOUND : value;
|
|
152
162
|
const ttl = value === null ? layer2NotFoundTtlSeconds : layer2TtlSeconds;
|
|
153
163
|
// Fire-and-forget. don't await, don't block
|
|
154
|
-
const setPromise = layer2Cache.set(documentId, cacheValue, ttl ? { ttl } : undefined);
|
|
164
|
+
const setPromise = layer2Cache.set(layer2KeyPrefix + documentId, cacheValue, ttl ? { ttl } : undefined);
|
|
155
165
|
if (setPromise) {
|
|
156
166
|
const handledPromise = Promise.resolve(setPromise).then(() => {
|
|
157
167
|
config.logger.debug('L2 cache set succeeded for document %s', documentId);
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.
|
|
1
|
+
export const version = '0.20.0-rc-20260107125616-c72aa9a25a868a0108f9af39de795a75f28c1c3b';
|
package/package.json
CHANGED
|
@@ -345,6 +345,11 @@ export type Layer2CacheConfiguration = {
|
|
|
345
345
|
* @default 60 (1 minute)
|
|
346
346
|
*/
|
|
347
347
|
notFoundTtlSeconds?: number;
|
|
348
|
+
/**
|
|
349
|
+
* Key prefix for cached persisted documents.
|
|
350
|
+
* @default "" (no prefix)
|
|
351
|
+
*/
|
|
352
|
+
keyPrefix?: string;
|
|
348
353
|
/**
|
|
349
354
|
* Optional function to register background work in serverless environments if not available in context.
|
|
350
355
|
*/
|
|
@@ -345,6 +345,11 @@ export type Layer2CacheConfiguration = {
|
|
|
345
345
|
* @default 60 (1 minute)
|
|
346
346
|
*/
|
|
347
347
|
notFoundTtlSeconds?: number;
|
|
348
|
+
/**
|
|
349
|
+
* Key prefix for cached persisted documents.
|
|
350
|
+
* @default "" (no prefix)
|
|
351
|
+
*/
|
|
352
|
+
keyPrefix?: string;
|
|
348
353
|
/**
|
|
349
354
|
* Optional function to register background work in serverless environments if not available in context.
|
|
350
355
|
*/
|
package/typings/version.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "0.20.0-rc-20260107125616-c72aa9a25a868a0108f9af39de795a75f28c1c3b";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/typings/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "0.20.0-rc-20260107125616-c72aa9a25a868a0108f9af39de795a75f28c1c3b";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|