@spytecgps/nova-orm 1.4.241 → 1.4.243
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/dist/cache/LruQueryResultCache.d.ts +8 -0
- package/dist/cache/LruQueryResultCache.js +1 -1
- package/dist/cache/buildCache.d.ts +48 -0
- package/dist/cache/buildCache.js +1 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.js +1 -1
- package/dist/migration/_virtual/_virtual_multi-entry.js +2 -2
- package/package.json +1 -1
- package/schema.sql +2 -2
|
@@ -6,7 +6,15 @@ export interface LruQueryResultCacheConfig {
|
|
|
6
6
|
}
|
|
7
7
|
export declare class LruQueryResultCache implements QueryResultCache {
|
|
8
8
|
private readonly cache;
|
|
9
|
+
private readonly maxSize;
|
|
9
10
|
constructor(config?: LruQueryResultCacheConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Emit `nova.cache.lru.size` and `nova.cache.lru.max` as observable gauges so
|
|
13
|
+
* dashboards can tell "is the LRU full?" directly instead of inferring from
|
|
14
|
+
* hit-rate decay. Filter by `ServiceName` to disambiguate when multiple
|
|
15
|
+
* DataSources share a process.
|
|
16
|
+
*/
|
|
17
|
+
private registerSizeGauges;
|
|
10
18
|
connect(): Promise<void>;
|
|
11
19
|
disconnect(): Promise<void>;
|
|
12
20
|
synchronize(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("lru-cache");exports.LruQueryResultCache=class LruQueryResultCache{cache;constructor(
|
|
1
|
+
"use strict";var e=require("@opentelemetry/api"),c=require("lru-cache");exports.LruQueryResultCache=class LruQueryResultCache{cache;maxSize;constructor(e={}){this.maxSize=e.max??1e3,this.cache=new c.LRUCache({max:this.maxSize,ttl:e.maxTtlMs}),this.registerSizeGauges()}registerSizeGauges(){const c=e.metrics.getMeter("@spytecgps/nova-orm");c.createObservableGauge("nova.cache.lru.size",{description:"Current entry count in the in-process LRU query result cache"}).addCallback((e=>{e.observe(this.cache.size)})),c.createObservableGauge("nova.cache.lru.max",{description:"Configured max entry count for the in-process LRU query result cache"}).addCallback((e=>{e.observe(this.maxSize)}))}async connect(){}async disconnect(){this.cache.clear()}async synchronize(){}async getFromCache(e){const c=this.keyFor(e);if(c)return this.cache.get(c)}async storeInCache(e){const c=this.keyFor(e);if(!c)return;const t={...e,time:e.time??Date.now()};this.cache.set(c,t)}isExpired(e){const c=e.time??0;return Date.now()-c>=e.duration}async remove(e){for(const c of e)this.cache.delete(c)}async clear(){this.cache.clear()}keyFor(e){return e.identifier??e.query}};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the TypeORM `cache:` config object from an explicit Redis config.
|
|
3
|
+
*
|
|
4
|
+
* Consumers own the env-var reading (so the wiring is visible in their config
|
|
5
|
+
* tree) and pass us a plain object. We translate it into the TypeORM-native
|
|
6
|
+
* shape, handling the standalone-vs-cluster fork plus the ElastiCache
|
|
7
|
+
* cluster-mode safety defaults (enableOfflineQueue:false, checkServerIdentity
|
|
8
|
+
* bypass for TLS — see project_elasticache_cluster_ioredis_tls).
|
|
9
|
+
*/
|
|
10
|
+
export type CacheMode = 'standalone' | 'cluster';
|
|
11
|
+
/**
|
|
12
|
+
* `host` is `string | undefined` so consumers can populate this directly from
|
|
13
|
+
* env vars without a guarding ternary — when REDIS_HOST is unset in dev/test,
|
|
14
|
+
* `buildCache()` returns undefined and no cache is installed.
|
|
15
|
+
*/
|
|
16
|
+
export interface RedisConfig {
|
|
17
|
+
host: string | undefined;
|
|
18
|
+
port: number;
|
|
19
|
+
tls: boolean;
|
|
20
|
+
mode: CacheMode;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Matches the shape of TypeORM's `DataSourceOptions.cache`. Fields are typed
|
|
24
|
+
* loose (`any` / `unknown`) deliberately — TypeORM's own type is loose, and
|
|
25
|
+
* tightening here would force `as any` casts at every consumer's callsite when
|
|
26
|
+
* the result is spread into a `DeepPartial<DataSourceOptions>` config tree.
|
|
27
|
+
*/
|
|
28
|
+
export interface BuiltCacheConfig {
|
|
29
|
+
type?: 'ioredis';
|
|
30
|
+
options?: any;
|
|
31
|
+
client?: unknown;
|
|
32
|
+
ignoreErrors?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns undefined when `config` is missing or has no host. Consumers can write:
|
|
36
|
+
*
|
|
37
|
+
* redis: {
|
|
38
|
+
* host: process.env.REDIS_HOST, // string | undefined
|
|
39
|
+
* port: Number(process.env.REDIS_PORT ?? '6379'),
|
|
40
|
+
* tls: process.env.REDIS_TLS === 'true',
|
|
41
|
+
* mode: (process.env.REDIS_MODE ?? 'standalone') as Cache.CacheMode,
|
|
42
|
+
* }
|
|
43
|
+
* cache: Cache.buildCache(config.redis)
|
|
44
|
+
*
|
|
45
|
+
* No ternary, no cast. In dev/test where REDIS_HOST is unset the cache is
|
|
46
|
+
* simply not installed.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildCache(config: RedisConfig | undefined): BuiltCacheConfig | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";let r;exports.buildCache=function(e){if(!e?.host)return;const{host:t,port:o,tls:i,mode:s}=e;if("cluster"===s){const e=function(){if(void 0!==r)return r;try{r=require("ioredis")}catch{r=null}return r}();if(!e)throw new Error("buildCache: mode=cluster requires `ioredis` to be installed");return{client:new e.Cluster([{host:t,port:o}],{redisOptions:i?{tls:{checkServerIdentity:()=>{}}}:{},enableOfflineQueue:!1}),ignoreErrors:!0}}return{type:"ioredis",options:{host:t,port:o,tls:i?{}:void 0},ignoreErrors:!0}};
|
package/dist/cache/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { attachIoredisErrorHandler, RedisQueryResultCacheLike } from './attachIoredisErrorHandler';
|
|
2
|
+
export { buildCache, BuiltCacheConfig, CacheMode, RedisConfig } from './buildCache';
|
|
2
3
|
export { CacheKind, InstrumentedQueryResultCache, InstrumentedQueryResultCacheOptions, } from './InstrumentedQueryResultCache';
|
|
3
4
|
export { LruQueryResultCache, LruQueryResultCacheConfig } from './LruQueryResultCache';
|
package/dist/cache/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./attachIoredisErrorHandler.js"),r=require("./InstrumentedQueryResultCache.js"),t=require("./LruQueryResultCache.js");exports.attachIoredisErrorHandler=e.attachIoredisErrorHandler,exports.
|
|
1
|
+
"use strict";var e=require("./attachIoredisErrorHandler.js"),r=require("./buildCache.js"),u=require("./InstrumentedQueryResultCache.js"),t=require("./LruQueryResultCache.js");exports.attachIoredisErrorHandler=e.attachIoredisErrorHandler,exports.buildCache=r.buildCache,exports.InstrumentedQueryResultCache=u.InstrumentedQueryResultCache,exports.LruQueryResultCache=t.LruQueryResultCache;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var _1684483704434AddLowerCaseIndex = require('../1684483704434-addLowerCaseIndex.js');
|
|
4
4
|
var _1684483705001UpdateSecurityUserViewsV1 = require('../1684483705001-updateSecurityUserViewsV1.js');
|
|
5
|
-
var _1684483705002UpdateSecurityUserViewsV2 = require('../1684483705002-updateSecurityUserViewsV2.js');
|
|
6
5
|
var _1746434400000AddQuickSearchFulltextIndexes = require('../1746434400000-addQuickSearchFulltextIndexes.js');
|
|
6
|
+
var _1684483705002UpdateSecurityUserViewsV2 = require('../1684483705002-updateSecurityUserViewsV2.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
exports.addLowerCaseIndex1684483704434 = _1684483704434AddLowerCaseIndex.addLowerCaseIndex1684483704434;
|
|
11
11
|
exports.updateSecurityUserViewsV11684483705001 = _1684483705001UpdateSecurityUserViewsV1.updateSecurityUserViewsV11684483705001;
|
|
12
|
-
exports.updateSecurityUserViewsV21684483705002 = _1684483705002UpdateSecurityUserViewsV2.updateSecurityUserViewsV21684483705002;
|
|
13
12
|
exports.addQuickSearchFulltextIndexes1746434400000 = _1746434400000AddQuickSearchFulltextIndexes.addQuickSearchFulltextIndexes1746434400000;
|
|
13
|
+
exports.updateSecurityUserViewsV21684483705002 = _1684483705002UpdateSecurityUserViewsV2.updateSecurityUserViewsV21684483705002;
|
package/package.json
CHANGED
package/schema.sql
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
-- nova-orm-schema-checksum:
|
|
1
|
+
-- nova-orm-schema-checksum: 2cf05ba22d935b6ff23e793dd72eb97d
|
|
2
2
|
-- Nova ORM Schema Dump
|
|
3
|
-
-- Generated at: 2026-05-
|
|
3
|
+
-- Generated at: 2026-05-25T05:05:23.896Z
|
|
4
4
|
|
|
5
5
|
SET FOREIGN_KEY_CHECKS = 0;
|
|
6
6
|
|