@kikiutils/shared 13.6.1 → 14.0.1

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 (52) hide show
  1. package/dist/classes/path.d.ts.map +1 -1
  2. package/dist/storages/lru/keyed-store.d.ts +22 -0
  3. package/dist/storages/lru/keyed-store.d.ts.map +1 -0
  4. package/dist/storages/lru/keyed-store.js +17 -0
  5. package/dist/storages/lru/keyed-store.js.map +1 -0
  6. package/dist/storages/redis/keyed-store.d.ts +16 -0
  7. package/dist/storages/redis/keyed-store.d.ts.map +1 -0
  8. package/dist/storages/redis/keyed-store.js +18 -0
  9. package/dist/storages/redis/keyed-store.js.map +1 -0
  10. package/dist/storages/redis/msgpack.d.ts +7 -0
  11. package/dist/storages/redis/msgpack.d.ts.map +1 -0
  12. package/dist/storages/redis/msgpack.js +23 -0
  13. package/dist/storages/redis/msgpack.js.map +1 -0
  14. package/dist/storages/redis/types.d.ts +22 -0
  15. package/dist/storages/redis/types.d.ts.map +1 -0
  16. package/dist/storages/redis/types.js +1 -0
  17. package/package.json +20 -45
  18. package/src/storages/lru/keyed-store.ts +23 -0
  19. package/src/storages/redis/keyed-store.ts +17 -0
  20. package/src/storages/redis/msgpack.ts +30 -0
  21. package/src/storages/redis/types.ts +19 -0
  22. package/dist/storage/enhanced/local/core.d.ts +0 -61
  23. package/dist/storage/enhanced/local/core.d.ts.map +0 -1
  24. package/dist/storage/enhanced/local/core.js +0 -63
  25. package/dist/storage/enhanced/local/core.js.map +0 -1
  26. package/dist/storage/enhanced/local/index.d.ts +0 -3
  27. package/dist/storage/enhanced/local/index.js +0 -4
  28. package/dist/storage/enhanced/local/keyed-store.d.ts +0 -36
  29. package/dist/storage/enhanced/local/keyed-store.d.ts.map +0 -1
  30. package/dist/storage/enhanced/local/keyed-store.js +0 -36
  31. package/dist/storage/enhanced/local/keyed-store.js.map +0 -1
  32. package/dist/storage/enhanced/redis/core.d.ts +0 -85
  33. package/dist/storage/enhanced/redis/core.d.ts.map +0 -1
  34. package/dist/storage/enhanced/redis/core.js +0 -85
  35. package/dist/storage/enhanced/redis/core.js.map +0 -1
  36. package/dist/storage/enhanced/redis/index.d.ts +0 -3
  37. package/dist/storage/enhanced/redis/index.js +0 -4
  38. package/dist/storage/enhanced/redis/keyed-store.d.ts +0 -44
  39. package/dist/storage/enhanced/redis/keyed-store.d.ts.map +0 -1
  40. package/dist/storage/enhanced/redis/keyed-store.js +0 -41
  41. package/dist/storage/enhanced/redis/keyed-store.js.map +0 -1
  42. package/dist/storage/lru/keyed-store.d.ts +0 -44
  43. package/dist/storage/lru/keyed-store.d.ts.map +0 -1
  44. package/dist/storage/lru/keyed-store.js +0 -40
  45. package/dist/storage/lru/keyed-store.js.map +0 -1
  46. package/src/storage/enhanced/local/core.ts +0 -106
  47. package/src/storage/enhanced/local/index.ts +0 -2
  48. package/src/storage/enhanced/local/keyed-store.ts +0 -36
  49. package/src/storage/enhanced/redis/core.ts +0 -151
  50. package/src/storage/enhanced/redis/index.ts +0 -2
  51. package/src/storage/enhanced/redis/keyed-store.ts +0 -43
  52. package/src/storage/lru/keyed-store.ts +0 -46
@@ -1 +1 @@
1
- {"version":3,"file":"path.d.ts","names":[],"sources":["../../src/classes/path.ts"],"sourcesContent":[],"mappings":";;;;;;;;;KAyBY,wBAAA,UAAkC;KACzC,uDAAuD,WAAW,+BAA+B;AAD1F,KAEA,QAAA,GAAW,EAAA,CAAG,QAFU,GAEC,IAFD;AAAkB;;;;;AAEtD;AAQa,cAAA,IAAA,CAAI;EAGS,CAAA,OAAA;EASrB,WAAO,CAAA,GAAA,KAAA,EATc,QASd,EAAA;EAmBE,CAnBT,MAAA,CAAO,WAAA,EAmBE,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EAgBgB;;;EAOS,IAAA,MAAA,CAAA,CAAA,EAvBzB,IAuByB;EAgB5B;;;EA4BkB,IAAA,KAAA,CAAA,CAAA,EAAA,MAAA;EAOpB;;;EAcE,OAAA,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,8BAAyB;;;;8BAiBnB,gBAAa,QAAA;;;;YAOzC;;;;iCAOyB,iBAAc"}
@@ -0,0 +1,22 @@
1
+ import { LRUCache } from "lru-cache";
2
+
3
+ //#region src/storages/lru/keyed-store.d.ts
4
+ declare function createLruKeyedStore<D = unknown>(lruInstance: LRUCache<any, any, any>): <P extends any[]>(keyFn: (...args: P) => string) => Readonly<{
5
+ /**
6
+ * Return a value from the cache. Will update the recency of the cache entry found.
7
+ *
8
+ * If the key is not found, returns `null`.
9
+ */
10
+ getItem(...args: P): NonNullable<D> | null;
11
+ getItemTtl: (...args: P) => number;
12
+ hasItem: (...args: P) => boolean;
13
+ removeItem: (...args: P) => boolean;
14
+ /**
15
+ * Resolves the full cache key from the given arguments.
16
+ */
17
+ resolveKey: (...args: P) => string;
18
+ setItem: (value: D, ...args: P) => LRUCache<any, any, any>;
19
+ }>;
20
+ //#endregion
21
+ export { createLruKeyedStore };
22
+ //# sourceMappingURL=keyed-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed-store.d.ts","names":[],"sources":["../../../src/storages/lru/keyed-store.ts"],"sourcesContent":[],"mappings":";;;iBAEgB,8CAA8C,6DAChB,iBAAY;;AAD1D;;;;EAO0B,OAAA,CAAA,GAAA,IAAA,EAAD,CAAC,CAAA,EAAA,WAAA,CAAA,CAAA,CAAA,GAAA,IAAA;EAAA,UAAA,EAAA,CAAA,GAAA,IAAA,EAII,CAJJ,EAAA,GAAA,MAAA;EAII,OAAA,EAAA,CAAA,GAAA,IAAA,EACH,CADG,EAAA,GAAA,OAAA;EACH,UAAA,EAAA,CAAA,GAAA,IAAA,EACG,CADH,EAAA,GAAA,OAAA;EACG;;;EAKO,UAAA,EAAA,CAAA,GAAA,IAAA,EADP,CACO,EAAA,GAAA,MAAA;EAAC,OAAA,EAAA,CAAA,KAAA,EAAb,CAAa,EAAA,GAAA,IAAA,EAAD,CAAC,EAAA,GAAA,QAAA,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA;CAjBoB,CAAA"}
@@ -0,0 +1,17 @@
1
+ //#region src/storages/lru/keyed-store.ts
2
+ function createLruKeyedStore(lruInstance) {
3
+ return (keyFn) => Object.freeze({
4
+ getItem(...args) {
5
+ return lruInstance.get(keyFn(...args)) ?? null;
6
+ },
7
+ getItemTtl: (...args) => lruInstance.getRemainingTTL(keyFn(...args)),
8
+ hasItem: (...args) => lruInstance.has(keyFn(...args)),
9
+ removeItem: (...args) => lruInstance.delete(keyFn(...args)),
10
+ resolveKey: (...args) => keyFn(...args),
11
+ setItem: (value, ...args) => lruInstance.set(keyFn(...args), value)
12
+ });
13
+ }
14
+
15
+ //#endregion
16
+ export { createLruKeyedStore };
17
+ //# sourceMappingURL=keyed-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed-store.js","names":[],"sources":["../../../src/storages/lru/keyed-store.ts"],"sourcesContent":["import type { LRUCache } from 'lru-cache';\n\nexport function createLruKeyedStore<D = unknown>(lruInstance: LRUCache<any, any, any>) {\n return <P extends any[]>(keyFn: (...args: P) => string) => Object.freeze({\n /**\n * Return a value from the cache. Will update the recency of the cache entry found.\n *\n * If the key is not found, returns `null`.\n */\n getItem(...args: P) {\n const rawValue = lruInstance.get(keyFn(...args));\n return rawValue as D ?? null;\n },\n getItemTtl: (...args: P) => lruInstance.getRemainingTTL(keyFn(...args)),\n hasItem: (...args: P) => lruInstance.has(keyFn(...args)),\n removeItem: (...args: P) => lruInstance.delete(keyFn(...args)),\n /**\n * Resolves the full cache key from the given arguments.\n */\n resolveKey: (...args: P) => keyFn(...args),\n setItem: (value: D, ...args: P) => lruInstance.set(keyFn(...args), value),\n });\n}\n"],"mappings":";AAEA,SAAgB,oBAAiC,aAAsC;AACnF,SAAyB,UAAkC,OAAO,OAAO;EAMrE,QAAQ,GAAG,MAAS;AAEhB,UADiB,YAAY,IAAI,MAAM,GAAG,KAAK,CAAC,IACxB;;EAE5B,aAAa,GAAG,SAAY,YAAY,gBAAgB,MAAM,GAAG,KAAK,CAAC;EACvE,UAAU,GAAG,SAAY,YAAY,IAAI,MAAM,GAAG,KAAK,CAAC;EACxD,aAAa,GAAG,SAAY,YAAY,OAAO,MAAM,GAAG,KAAK,CAAC;EAI9D,aAAa,GAAG,SAAY,MAAM,GAAG,KAAK;EAC1C,UAAU,OAAU,GAAG,SAAY,YAAY,IAAI,MAAM,GAAG,KAAK,EAAE,MAAM;EAC5E,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { MaybeReadonly, Nullable } from "../../types/index.js";
2
+ import { RedisLikeStorage } from "./types.js";
3
+
4
+ //#region src/storages/redis/keyed-store.d.ts
5
+ declare function createRedisKeyedStore<D = unknown>(storage: MaybeReadonly<RedisLikeStorage>): <P extends any[]>(keyFn: (...args: P) => string) => Readonly<{
6
+ getItem: (...args: P) => Promise<Nullable<D>>;
7
+ getItemTtl: (...args: P) => Promise<number>;
8
+ hasItem: (...args: P) => Promise<boolean>;
9
+ removeItem: (...args: P) => Promise<boolean>;
10
+ resolveKey: (...args: P) => string;
11
+ setItem: (value: D, ...args: P) => Promise<boolean>;
12
+ setItemWithTtl(ttlSeconds: number, value: D, ...args: P): Promise<boolean>;
13
+ }>;
14
+ //#endregion
15
+ export { createRedisKeyedStore };
16
+ //# sourceMappingURL=keyed-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed-store.d.ts","names":[],"sources":["../../../src/storages/redis/keyed-store.ts"],"sourcesContent":[],"mappings":";;;;iBAIgB,4CAA4C,cAAc,uDAC5B,iBAAY;qBAC/B,MAAC,QAAA,SAAA;EAFZ,UAAA,EAAA,CAAA,GAAA,IAAA,EAGc,CAHd,EAAqB,GAGN,OAHM,CAAA,MAAA,CAAA;EAAqC,OAAA,EAAA,CAAA,GAAA,IAAA,EAI/C,CAJ+C,EAAA,GAI9C,OAJ8C,CAAA,OAAA,CAAA;EAAd,UAAA,EAAA,CAAA,GAAA,IAAA,EAK9B,CAL8B,EAAA,GAK7B,OAL6B,CAAA,OAAA,CAAA;EACd,UAAA,EAAA,CAAA,GAAA,IAAA,EAKhB,CALgB,EAAA,GAAA,MAAA;EACnB,OAAA,EAAA,CAAA,KAAA,EAKF,CALE,EAAA,GAAA,IAAA,EAKU,CALV,EAAA,GAKW,OALX,CAAA,OAAA,CAAA;EAAC,cAAA,CAAA,UAAA,EAAA,MAAA,EAAA,KAAA,EAMsB,CANtB,EAAA,GAAA,IAAA,EAMkC,CANlC,CAAA,EAMmC,OANnC,CAAA,OAAA,CAAA;CAAA,CAAA"}
@@ -0,0 +1,18 @@
1
+ //#region src/storages/redis/keyed-store.ts
2
+ function createRedisKeyedStore(storage) {
3
+ return (keyFn) => Object.freeze({
4
+ getItem: (...args) => storage.getItem(keyFn(...args)),
5
+ getItemTtl: (...args) => storage.getItemTtl(keyFn(...args)),
6
+ hasItem: (...args) => storage.hasItem(keyFn(...args)),
7
+ removeItem: (...args) => storage.removeItem(keyFn(...args)),
8
+ resolveKey: (...args) => keyFn(...args),
9
+ setItem: (value, ...args) => storage.setItem(keyFn(...args), value),
10
+ setItemWithTtl(ttlSeconds, value, ...args) {
11
+ return storage.setItemWithTtl(keyFn(...args), ttlSeconds, value);
12
+ }
13
+ });
14
+ }
15
+
16
+ //#endregion
17
+ export { createRedisKeyedStore };
18
+ //# sourceMappingURL=keyed-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed-store.js","names":[],"sources":["../../../src/storages/redis/keyed-store.ts"],"sourcesContent":["import type { MaybeReadonly } from '../../types';\n\nimport type { RedisLikeStorage } from './types';\n\nexport function createRedisKeyedStore<D = unknown>(storage: MaybeReadonly<RedisLikeStorage>) {\n return <P extends any[]>(keyFn: (...args: P) => string) => Object.freeze({\n getItem: (...args: P) => storage.getItem<D>(keyFn(...args)),\n getItemTtl: (...args: P) => storage.getItemTtl(keyFn(...args)),\n hasItem: (...args: P) => storage.hasItem(keyFn(...args)),\n removeItem: (...args: P) => storage.removeItem(keyFn(...args)),\n resolveKey: (...args: P) => keyFn(...args),\n setItem: (value: D, ...args: P) => storage.setItem(keyFn(...args), value),\n setItemWithTtl(ttlSeconds: number, value: D, ...args: P) {\n return storage.setItemWithTtl(keyFn(...args), ttlSeconds, value);\n },\n });\n}\n"],"mappings":";AAIA,SAAgB,sBAAmC,SAA0C;AACzF,SAAyB,UAAkC,OAAO,OAAO;EACrE,UAAU,GAAG,SAAY,QAAQ,QAAW,MAAM,GAAG,KAAK,CAAC;EAC3D,aAAa,GAAG,SAAY,QAAQ,WAAW,MAAM,GAAG,KAAK,CAAC;EAC9D,UAAU,GAAG,SAAY,QAAQ,QAAQ,MAAM,GAAG,KAAK,CAAC;EACxD,aAAa,GAAG,SAAY,QAAQ,WAAW,MAAM,GAAG,KAAK,CAAC;EAC9D,aAAa,GAAG,SAAY,MAAM,GAAG,KAAK;EAC1C,UAAU,OAAU,GAAG,SAAY,QAAQ,QAAQ,MAAM,GAAG,KAAK,EAAE,MAAM;EACzE,eAAe,YAAoB,OAAU,GAAG,MAAS;AACrD,UAAO,QAAQ,eAAe,MAAM,GAAG,KAAK,EAAE,YAAY,MAAM;;EAEvE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { RedisLikeAdapter, RedisLikeStorage } from "./types.js";
2
+
3
+ //#region src/storages/redis/msgpack.d.ts
4
+ declare function createRedisMsgpackStorage(adapter: RedisLikeAdapter): Readonly<RedisLikeStorage>;
5
+ //#endregion
6
+ export { createRedisMsgpackStorage };
7
+ //# sourceMappingURL=msgpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msgpack.d.ts","names":[],"sources":["../../../src/storages/redis/msgpack.ts"],"sourcesContent":[],"mappings":";;;iBAegB,yBAAA,UAAmC,mBAAmB,SAAS"}
@@ -0,0 +1,23 @@
1
+ import { decode, encode, isNativeAccelerationEnabled } from "msgpackr";
2
+
3
+ //#region src/storages/redis/msgpack.ts
4
+ if (!isNativeAccelerationEnabled) console.warn("Native acceleration not enabled for msgpackr, verify that install finished properly");
5
+ function createRedisMsgpackStorage(adapter) {
6
+ return Object.freeze({
7
+ async getItem(key) {
8
+ const rawValue = await adapter.getBuffer(key);
9
+ return rawValue ? decode(rawValue) : null;
10
+ },
11
+ getItemTtl: (key) => adapter.ttl(key),
12
+ hasItem: (key) => adapter.has(key),
13
+ removeItem: async (key) => await adapter.delete(key) === 1,
14
+ setItem: async (key, value) => await adapter.setBuffer(key, encode(value)) === "OK",
15
+ async setItemWithTtl(key, ttlSeconds, value) {
16
+ return await adapter.setBufferEx(key, ttlSeconds, encode(value)) === "OK";
17
+ }
18
+ });
19
+ }
20
+
21
+ //#endregion
22
+ export { createRedisMsgpackStorage };
23
+ //# sourceMappingURL=msgpack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msgpack.js","names":[],"sources":["../../../src/storages/redis/msgpack.ts"],"sourcesContent":["import {\n decode,\n encode,\n isNativeAccelerationEnabled,\n} from 'msgpackr';\n\nimport type {\n RedisLikeAdapter,\n RedisLikeStorage,\n} from './types';\n\nif (!isNativeAccelerationEnabled) {\n console.warn('Native acceleration not enabled for msgpackr, verify that install finished properly');\n}\n\nexport function createRedisMsgpackStorage(adapter: RedisLikeAdapter): Readonly<RedisLikeStorage> {\n return Object.freeze({\n async getItem<T = unknown>(key: string) {\n const rawValue = await adapter.getBuffer(key);\n return rawValue ? decode(rawValue) as T : null;\n },\n getItemTtl: (key: string) => adapter.ttl(key),\n hasItem: (key: string) => adapter.has(key),\n removeItem: async (key: string) => await adapter.delete(key) === 1,\n setItem: async (key: string, value: any) => await adapter.setBuffer(key, encode(value)) === 'OK',\n async setItemWithTtl(key: string, ttlSeconds: number, value: any) {\n return await adapter.setBufferEx(key, ttlSeconds, encode(value)) === 'OK';\n },\n });\n}\n"],"mappings":";;;AAWA,IAAI,CAAC,4BACD,SAAQ,KAAK,sFAAsF;AAGvG,SAAgB,0BAA0B,SAAuD;AAC7F,QAAO,OAAO,OAAO;EACjB,MAAM,QAAqB,KAAa;GACpC,MAAM,WAAW,MAAM,QAAQ,UAAU,IAAI;AAC7C,UAAO,WAAW,OAAO,SAAS,GAAQ;;EAE9C,aAAa,QAAgB,QAAQ,IAAI,IAAI;EAC7C,UAAU,QAAgB,QAAQ,IAAI,IAAI;EAC1C,YAAY,OAAO,QAAgB,MAAM,QAAQ,OAAO,IAAI,KAAK;EACjE,SAAS,OAAO,KAAa,UAAe,MAAM,QAAQ,UAAU,KAAK,OAAO,MAAM,CAAC,KAAK;EAC5F,MAAM,eAAe,KAAa,YAAoB,OAAY;AAC9D,UAAO,MAAM,QAAQ,YAAY,KAAK,YAAY,OAAO,MAAM,CAAC,KAAK;;EAE5E,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { Nullable } from "../../types/index.js";
2
+
3
+ //#region src/storages/redis/types.d.ts
4
+ interface RedisLikeAdapter {
5
+ delete: (key: string) => Promise<number>;
6
+ getBuffer: (key: string) => Promise<Nullable<Uint8Array>>;
7
+ has: (key: string) => Promise<boolean>;
8
+ setBuffer: (key: string, value: Uint8Array) => Promise<'OK' | void>;
9
+ setBufferEx: (key: string, ttlSeconds: number, value: Uint8Array) => Promise<'OK' | void>;
10
+ ttl: (key: string) => Promise<number>;
11
+ }
12
+ interface RedisLikeStorage {
13
+ getItem: <T = unknown>(key: string) => Promise<Nullable<T>>;
14
+ getItemTtl: (key: string) => Promise<number>;
15
+ hasItem: (key: string) => Promise<boolean>;
16
+ removeItem: (key: string) => Promise<boolean>;
17
+ setItem: (key: string, value: any) => Promise<boolean>;
18
+ setItemWithTtl: (key: string, ttlSeconds: number, value: any) => Promise<boolean>;
19
+ }
20
+ //#endregion
21
+ export { RedisLikeAdapter, RedisLikeStorage };
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/storages/redis/types.ts"],"sourcesContent":[],"mappings":";;;UAEiB,gBAAA;2BACY;EADZ,SAAA,EAAA,CAAA,GAAA,EAAA,MAAgB,EAAA,GAED,OAFC,CAEO,QAFP,CAEgB,UAFhB,CAAA,CAAA;EACJ,GAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAEH,OAFG,CAAA,OAAA,CAAA;EACoB,SAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAEb,UAFa,EAAA,GAEE,OAFF,CAAA,IAAA,GAAA,IAAA,CAAA;EAAT,WAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,KAAA,EAGkB,UAHlB,EAAA,GAGiC,OAHjC,CAAA,IAAA,GAAA,IAAA,CAAA;EAAR,GAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAIN,OAJM,CAAA,MAAA,CAAA;;AAEI,UAKnB,gBAAA,CALmB;EAAe,OAAA,EAAA,CAAA,IAAA,OAAA,CAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAMR,OANQ,CAMA,QANA,CAMS,CANT,CAAA,CAAA;EACO,UAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAMzB,OANyB,CAAA,MAAA,CAAA;EAAe,OAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAO3C,OAP2C,CAAA,OAAA,CAAA;EAC/C,UAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAOO,OAPP,CAAA,OAAA,CAAA;EAAO,OAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAAA,GAAA,EAAA,GAQS,OART,CAAA,OAAA,CAAA;EAGhB,cAAA,EAAA,CAAA,GAAgB,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,KAAA,EAAA,GAAA,EAAA,GAMoC,OANpC,CAAA,OAAA,CAAA"}
@@ -0,0 +1 @@
1
+ export { };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kikiutils/shared",
3
3
  "type": "module",
4
- "version": "13.6.1",
4
+ "version": "14.0.1",
5
5
  "description": "A lightweight and modular utility library for modern JavaScript and TypeScript — includes secure hashing, flexible logging, datetime tools, Vue/web helpers, storage abstraction, and more.",
6
6
  "author": "kiki-kanri",
7
7
  "license": "MIT",
@@ -35,26 +35,6 @@
35
35
  "exports": {
36
36
  "./*": "./dist/*.js",
37
37
  "./package.json": "./package.json",
38
- "./storage/enhanced/local": {
39
- "types": "./dist/storage/enhanced/local/index.d.ts",
40
- "import": "./dist/storage/enhanced/local/index.js",
41
- "require": null
42
- },
43
- "./storage/enhanced/local/index": {
44
- "types": null,
45
- "import": null,
46
- "require": null
47
- },
48
- "./storage/enhanced/redis": {
49
- "types": "./dist/storage/enhanced/redis/index.d.ts",
50
- "import": "./dist/storage/enhanced/redis/index.js",
51
- "require": null
52
- },
53
- "./storage/enhanced/redis/index": {
54
- "types": null,
55
- "import": null,
56
- "require": null
57
- },
58
38
  "./types": {
59
39
  "types": "./dist/types/index.d.ts",
60
40
  "import": null,
@@ -90,7 +70,7 @@
90
70
  "@noble/hashes": "^2.0.0",
91
71
  "@types/fs-extra": "^11.0.4",
92
72
  "@types/jsonfile": "^6.1.4",
93
- "@types/node": "^24.5.2",
73
+ "@types/node": ">= 24",
94
74
  "@types/ssh2": "^1.15.5",
95
75
  "async-validator": "^4.2.5",
96
76
  "bson": "^7.0.0",
@@ -99,13 +79,12 @@
99
79
  "decimal.js": "^10.6.0",
100
80
  "element-plus": "^2.11.3",
101
81
  "fs-extra": "^11.3.2",
102
- "ioredis": "^5.7.0",
103
- "lru-cache": "^11.2.1",
82
+ "lru-cache": "^11.2.4",
104
83
  "millify": "^6.1.0",
84
+ "msgpackr": "^1.11.5",
105
85
  "node-ssh": "^13.2.1",
106
86
  "pino": "^10.0.0",
107
87
  "pino-pretty": "^13.1.1",
108
- "superjson": "^2.2.2",
109
88
  "vue": "^3.5.21",
110
89
  "vue-router": "^4.5.1"
111
90
  },
@@ -146,15 +125,15 @@
146
125
  "fs-extra": {
147
126
  "optional": true
148
127
  },
149
- "ioredis": {
150
- "optional": true
151
- },
152
128
  "lru-cache": {
153
129
  "optional": true
154
130
  },
155
131
  "millify": {
156
132
  "optional": true
157
133
  },
134
+ "msgpackr": {
135
+ "optional": true
136
+ },
158
137
  "node-ssh": {
159
138
  "optional": true
160
139
  },
@@ -164,9 +143,6 @@
164
143
  "pino-pretty": {
165
144
  "optional": true
166
145
  },
167
- "superjson": {
168
- "optional": true
169
- },
170
146
  "vue": {
171
147
  "optional": true
172
148
  },
@@ -175,15 +151,15 @@
175
151
  }
176
152
  },
177
153
  "devDependencies": {
178
- "@antfu/eslint-config": "^6.3.0",
154
+ "@antfu/eslint-config": "^6.7.3",
179
155
  "@kikiutils/eslint-config": "^5.0.0",
180
156
  "@kikiutils/tsconfigs": "^5.0.5",
181
157
  "@noble/hashes": "^2.0.1",
182
158
  "@types/fs-extra": "^11.0.4",
183
159
  "@types/jsonfile": "^6.1.4",
184
- "@types/node": "^24.10.1",
160
+ "@types/node": "^25.0.3",
185
161
  "@types/ssh2": "^1.15.5",
186
- "@vitest/coverage-v8": "^4.0.15",
162
+ "@vitest/coverage-v8": "^4.0.16",
187
163
  "async-validator": "^4.2.5",
188
164
  "bson": "^7.0.0",
189
165
  "changelogen": "^0.6.2",
@@ -192,30 +168,29 @@
192
168
  "date-fns": "^4.1.0",
193
169
  "decimal.js": "^10.6.0",
194
170
  "depcheck": "^1.4.7",
195
- "element-plus": "^2.11.9",
196
- "fs-extra": "^11.3.2",
197
- "ioredis": "^5.8.2",
198
- "jsdom": "^27.2.0",
171
+ "element-plus": "^2.13.0",
172
+ "fs-extra": "^11.3.3",
173
+ "jsdom": "^27.3.0",
199
174
  "lru-cache": "^11.2.4",
200
175
  "millify": "^6.1.0",
176
+ "msgpackr": "^1.11.8",
201
177
  "node-ssh": "^13.2.1",
202
178
  "pino": "^10.1.0",
203
179
  "pino-pretty": "^13.1.3",
204
- "publint": "^0.3.15",
205
- "redis": "^5.10.0",
206
- "superjson": "^2.2.6",
180
+ "publint": "^0.3.16",
207
181
  "ts-unused-exports": "^11.0.1",
208
- "tsdown": "^0.16.8",
182
+ "tsdown": "^0.18.3",
209
183
  "typescript": "^5.9.3",
210
184
  "unplugin-unused": "^0.5.6",
211
- "vitest": "^4.0.15",
212
- "vue": "^3.5.25",
213
- "vue-router": "^4.6.3"
185
+ "vitest": "^4.0.16",
186
+ "vue": "^3.5.26",
187
+ "vue-router": "^4.6.4"
214
188
  },
215
189
  "pnpm": {
216
190
  "onlyBuiltDependencies": [
217
191
  "cpu-features",
218
192
  "esbuild",
193
+ "msgpackr-extract",
219
194
  "ssh2",
220
195
  "vue-demi"
221
196
  ]
@@ -0,0 +1,23 @@
1
+ import type { LRUCache } from 'lru-cache';
2
+
3
+ export function createLruKeyedStore<D = unknown>(lruInstance: LRUCache<any, any, any>) {
4
+ return <P extends any[]>(keyFn: (...args: P) => string) => Object.freeze({
5
+ /**
6
+ * Return a value from the cache. Will update the recency of the cache entry found.
7
+ *
8
+ * If the key is not found, returns `null`.
9
+ */
10
+ getItem(...args: P) {
11
+ const rawValue = lruInstance.get(keyFn(...args));
12
+ return rawValue as D ?? null;
13
+ },
14
+ getItemTtl: (...args: P) => lruInstance.getRemainingTTL(keyFn(...args)),
15
+ hasItem: (...args: P) => lruInstance.has(keyFn(...args)),
16
+ removeItem: (...args: P) => lruInstance.delete(keyFn(...args)),
17
+ /**
18
+ * Resolves the full cache key from the given arguments.
19
+ */
20
+ resolveKey: (...args: P) => keyFn(...args),
21
+ setItem: (value: D, ...args: P) => lruInstance.set(keyFn(...args), value),
22
+ });
23
+ }
@@ -0,0 +1,17 @@
1
+ import type { MaybeReadonly } from '../../types';
2
+
3
+ import type { RedisLikeStorage } from './types';
4
+
5
+ export function createRedisKeyedStore<D = unknown>(storage: MaybeReadonly<RedisLikeStorage>) {
6
+ return <P extends any[]>(keyFn: (...args: P) => string) => Object.freeze({
7
+ getItem: (...args: P) => storage.getItem<D>(keyFn(...args)),
8
+ getItemTtl: (...args: P) => storage.getItemTtl(keyFn(...args)),
9
+ hasItem: (...args: P) => storage.hasItem(keyFn(...args)),
10
+ removeItem: (...args: P) => storage.removeItem(keyFn(...args)),
11
+ resolveKey: (...args: P) => keyFn(...args),
12
+ setItem: (value: D, ...args: P) => storage.setItem(keyFn(...args), value),
13
+ setItemWithTtl(ttlSeconds: number, value: D, ...args: P) {
14
+ return storage.setItemWithTtl(keyFn(...args), ttlSeconds, value);
15
+ },
16
+ });
17
+ }
@@ -0,0 +1,30 @@
1
+ import {
2
+ decode,
3
+ encode,
4
+ isNativeAccelerationEnabled,
5
+ } from 'msgpackr';
6
+
7
+ import type {
8
+ RedisLikeAdapter,
9
+ RedisLikeStorage,
10
+ } from './types';
11
+
12
+ if (!isNativeAccelerationEnabled) {
13
+ console.warn('Native acceleration not enabled for msgpackr, verify that install finished properly');
14
+ }
15
+
16
+ export function createRedisMsgpackStorage(adapter: RedisLikeAdapter): Readonly<RedisLikeStorage> {
17
+ return Object.freeze({
18
+ async getItem<T = unknown>(key: string) {
19
+ const rawValue = await adapter.getBuffer(key);
20
+ return rawValue ? decode(rawValue) as T : null;
21
+ },
22
+ getItemTtl: (key: string) => adapter.ttl(key),
23
+ hasItem: (key: string) => adapter.has(key),
24
+ removeItem: async (key: string) => await adapter.delete(key) === 1,
25
+ setItem: async (key: string, value: any) => await adapter.setBuffer(key, encode(value)) === 'OK',
26
+ async setItemWithTtl(key: string, ttlSeconds: number, value: any) {
27
+ return await adapter.setBufferEx(key, ttlSeconds, encode(value)) === 'OK';
28
+ },
29
+ });
30
+ }
@@ -0,0 +1,19 @@
1
+ import type { Nullable } from '../../types';
2
+
3
+ export interface RedisLikeAdapter {
4
+ delete: (key: string) => Promise<number>;
5
+ getBuffer: (key: string) => Promise<Nullable<Uint8Array>>;
6
+ has: (key: string) => Promise<boolean>;
7
+ setBuffer: (key: string, value: Uint8Array) => Promise<'OK' | void>;
8
+ setBufferEx: (key: string, ttlSeconds: number, value: Uint8Array) => Promise<'OK' | void>;
9
+ ttl: (key: string) => Promise<number>;
10
+ }
11
+
12
+ export interface RedisLikeStorage {
13
+ getItem: <T = unknown>(key: string) => Promise<Nullable<T>>;
14
+ getItemTtl: (key: string) => Promise<number>;
15
+ hasItem: (key: string) => Promise<boolean>;
16
+ removeItem: (key: string) => Promise<boolean>;
17
+ setItem: (key: string, value: any) => Promise<boolean>;
18
+ setItemWithTtl: (key: string, ttlSeconds: number, value: any) => Promise<boolean>;
19
+ }
@@ -1,61 +0,0 @@
1
- //#region src/storage/enhanced/local/core.d.ts
2
- /**
3
- * An enhanced localStorage wrapper that supports storing
4
- * complex data types (e.g. Dates, Maps, Sets) using SuperJSON encoding.
5
- *
6
- * This utility preserves type structure when saving and retrieving values.
7
- *
8
- * @example
9
- * ```typescript
10
- * import { enhancedLocalStorage } from '@kikiutils/shared/storage/enhanced/local';
11
- *
12
- * enhancedLocalStorage.setItem('user', { name: 'user', createdAt: new Date() });
13
- * const user = enhancedLocalStorage.getItem<{ name: string, createdAt: Date }>('user');
14
- * ```
15
- */
16
- declare const enhancedLocalStorage: Readonly<{
17
- /**
18
- * Removes all items from localStorage.
19
- */
20
- clear: () => void;
21
- /**
22
- * Retrieves a value by key and decodes it using SuperJSON or raw string.
23
- *
24
- * @template T - The expected type of the value
25
- *
26
- * @param {string} key - The key of the value to retrieve
27
- *
28
- * @returns {null | T} The decoded value or null if not found
29
- */
30
- getItem<T = unknown>(key: string): T | null;
31
- /**
32
- * Checks whether a key exists in localStorage.
33
- *
34
- * @param {string} key - The key to check
35
- *
36
- * @returns {boolean} True if the key exists, false otherwise
37
- */
38
- hasItem: (key: string) => boolean;
39
- /**
40
- * Returns the number of items stored in localStorage.
41
- *
42
- * @returns {number} The number of items stored in localStorage
43
- */
44
- readonly length: number;
45
- /**
46
- * Removes a specific key from localStorage.
47
- *
48
- * @param {string} key - The key to remove
49
- */
50
- removeItem: (key: string) => void;
51
- /**
52
- * Stores a value in localStorage with automatic serialization.
53
- *
54
- * @param {string} key - The key to store the value under
55
- * @param {any} value - The value to store
56
- */
57
- setItem: (key: string, value: any) => void;
58
- }>;
59
- //#endregion
60
- export { enhancedLocalStorage };
61
- //# sourceMappingURL=core.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.d.ts","names":[],"sources":["../../../../src/storage/enhanced/local/core.ts"],"sourcesContent":[],"mappings":";;AA4BA;;;;;;;;;;;;;cAAa,sBAAoB;;;;;;;;;;;;;;qCAcG"}
@@ -1,63 +0,0 @@
1
- import { deserialize, serialize } from "superjson";
2
-
3
- //#region src/storage/enhanced/local/core.ts
4
- var StorageValueEncodingType = /* @__PURE__ */ function(StorageValueEncodingType$1) {
5
- StorageValueEncodingType$1["Json"] = "0";
6
- StorageValueEncodingType$1["String"] = "1";
7
- return StorageValueEncodingType$1;
8
- }(StorageValueEncodingType || {});
9
- const customValueHeader = "​⁠";
10
- const customValueHeaderLength = 3;
11
- const toCustomValue = (type, payload) => `${customValueHeader}${type}${payload}`;
12
- /**
13
- * An enhanced localStorage wrapper that supports storing
14
- * complex data types (e.g. Dates, Maps, Sets) using SuperJSON encoding.
15
- *
16
- * This utility preserves type structure when saving and retrieving values.
17
- *
18
- * @example
19
- * ```typescript
20
- * import { enhancedLocalStorage } from '@kikiutils/shared/storage/enhanced/local';
21
- *
22
- * enhancedLocalStorage.setItem('user', { name: 'user', createdAt: new Date() });
23
- * const user = enhancedLocalStorage.getItem<{ name: string, createdAt: Date }>('user');
24
- * ```
25
- */
26
- const enhancedLocalStorage = Object.freeze({
27
- clear: () => window.localStorage.clear(),
28
- getItem(key) {
29
- const rawValue = window.localStorage.getItem(key);
30
- return rawValue ? decodeStorageValue(rawValue) : null;
31
- },
32
- hasItem: (key) => window.localStorage.getItem(key) !== null,
33
- get length() {
34
- return window.localStorage.length;
35
- },
36
- removeItem: (key) => window.localStorage.removeItem(key),
37
- setItem: (key, value) => window.localStorage.setItem(key, encodeToStorageValue(value))
38
- });
39
- function decodeStorageValue(data) {
40
- if (!isCustomFormat(data)) return data;
41
- const payload = data.substring(customValueHeaderLength);
42
- const type = data.charAt(2);
43
- switch (type) {
44
- case StorageValueEncodingType.Json: try {
45
- return deserialize(JSON.parse(payload));
46
- } catch {
47
- throw new Error("[EnhancedLocalStorage] Failed to parse JSON payload");
48
- }
49
- case StorageValueEncodingType.String: return payload;
50
- default: throw new Error(`[EnhancedLocalStorage] Unknown encoding type: ${type}`);
51
- }
52
- }
53
- function encodeToStorageValue(value) {
54
- if (typeof value === "string") return toCustomValue(StorageValueEncodingType.String, value);
55
- return toCustomValue(StorageValueEncodingType.Json, JSON.stringify(serialize(value)));
56
- }
57
- function isCustomFormat(data) {
58
- return data.length >= customValueHeaderLength && data[0] === customValueHeader[0] && data[1] === customValueHeader[1];
59
- }
60
-
61
- //#endregion
62
- export { enhancedLocalStorage };
63
- //# sourceMappingURL=core.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.js","names":[],"sources":["../../../../src/storage/enhanced/local/core.ts"],"sourcesContent":["import {\n deserialize,\n serialize,\n} from 'superjson';\n\nenum StorageValueEncodingType {\n Json = '0',\n String = '1',\n}\n\nconst customValueHeader = '​⁠';\nconst customValueHeaderLength = customValueHeader.length + 1;\nconst toCustomValue = (type: StorageValueEncodingType, payload: string) => `${customValueHeader}${type}${payload}`;\n\n/**\n * An enhanced localStorage wrapper that supports storing\n * complex data types (e.g. Dates, Maps, Sets) using SuperJSON encoding.\n *\n * This utility preserves type structure when saving and retrieving values.\n *\n * @example\n * ```typescript\n * import { enhancedLocalStorage } from '@kikiutils/shared/storage/enhanced/local';\n *\n * enhancedLocalStorage.setItem('user', { name: 'user', createdAt: new Date() });\n * const user = enhancedLocalStorage.getItem<{ name: string, createdAt: Date }>('user');\n * ```\n */\nexport const enhancedLocalStorage = Object.freeze({\n /**\n * Removes all items from localStorage.\n */\n clear: () => window.localStorage.clear(),\n /**\n * Retrieves a value by key and decodes it using SuperJSON or raw string.\n *\n * @template T - The expected type of the value\n *\n * @param {string} key - The key of the value to retrieve\n *\n * @returns {null | T} The decoded value or null if not found\n */\n getItem<T = unknown>(key: string) {\n const rawValue = window.localStorage.getItem(key);\n return rawValue ? decodeStorageValue(rawValue) as T : null;\n },\n /**\n * Checks whether a key exists in localStorage.\n *\n * @param {string} key - The key to check\n *\n * @returns {boolean} True if the key exists, false otherwise\n */\n hasItem: (key: string) => window.localStorage.getItem(key) !== null,\n /**\n * Returns the number of items stored in localStorage.\n *\n * @returns {number} The number of items stored in localStorage\n */\n get length() {\n return window.localStorage.length;\n },\n /**\n * Removes a specific key from localStorage.\n *\n * @param {string} key - The key to remove\n */\n removeItem: (key: string) => window.localStorage.removeItem(key),\n /**\n * Stores a value in localStorage with automatic serialization.\n *\n * @param {string} key - The key to store the value under\n * @param {any} value - The value to store\n */\n setItem: (key: string, value: any) => window.localStorage.setItem(key, encodeToStorageValue(value)),\n});\n\nfunction decodeStorageValue(data: string) {\n if (!isCustomFormat(data)) return data;\n const payload = data.substring(customValueHeaderLength);\n const type = data.charAt(customValueHeader.length);\n switch (type) {\n case StorageValueEncodingType.Json:\n try {\n return deserialize(JSON.parse(payload));\n } catch {\n throw new Error('[EnhancedLocalStorage] Failed to parse JSON payload');\n }\n case StorageValueEncodingType.String: return payload;\n default:\n throw new Error(`[EnhancedLocalStorage] Unknown encoding type: ${type}`);\n }\n}\n\nfunction encodeToStorageValue(value: any) {\n if (typeof value === 'string') return toCustomValue(StorageValueEncodingType.String, value);\n return toCustomValue(StorageValueEncodingType.Json, JSON.stringify(serialize(value)));\n}\n\nfunction isCustomFormat(data: string) {\n return (\n data.length >= customValueHeaderLength\n && data[0] === customValueHeader[0]\n && data[1] === customValueHeader[1]\n );\n}\n"],"mappings":";;;AAKA,IAAK,gFAAL;AACI;AACA;;EAFC;AAKL,MAAM,oBAAoB;AAC1B,MAAM,0BAA0B;AAChC,MAAM,iBAAiB,MAAgC,YAAoB,GAAG,oBAAoB,OAAO;;;;;;;;;;;;;;;AAgBzG,MAAa,uBAAuB,OAAO,OAAO;CAI9C,aAAa,OAAO,aAAa,OAAO;CAUxC,QAAqB,KAAa;EAC9B,MAAM,WAAW,OAAO,aAAa,QAAQ,IAAI;AACjD,SAAO,WAAW,mBAAmB,SAAS,GAAQ;;CAS1D,UAAU,QAAgB,OAAO,aAAa,QAAQ,IAAI,KAAK;CAM/D,IAAI,SAAS;AACT,SAAO,OAAO,aAAa;;CAO/B,aAAa,QAAgB,OAAO,aAAa,WAAW,IAAI;CAOhE,UAAU,KAAa,UAAe,OAAO,aAAa,QAAQ,KAAK,qBAAqB,MAAM,CAAC;CACtG,CAAC;AAEF,SAAS,mBAAmB,MAAc;AACtC,KAAI,CAAC,eAAe,KAAK,CAAE,QAAO;CAClC,MAAM,UAAU,KAAK,UAAU,wBAAwB;CACvD,MAAM,OAAO,KAAK,OAAO,EAAyB;AAClD,SAAQ,MAAR;EACI,KAAK,yBAAyB,KAC1B,KAAI;AACA,UAAO,YAAY,KAAK,MAAM,QAAQ,CAAC;UACnC;AACJ,SAAM,IAAI,MAAM,sDAAsD;;EAE9E,KAAK,yBAAyB,OAAQ,QAAO;EAC7C,QACI,OAAM,IAAI,MAAM,iDAAiD,OAAO;;;AAIpF,SAAS,qBAAqB,OAAY;AACtC,KAAI,OAAO,UAAU,SAAU,QAAO,cAAc,yBAAyB,QAAQ,MAAM;AAC3F,QAAO,cAAc,yBAAyB,MAAM,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;;AAGzF,SAAS,eAAe,MAAc;AAClC,QACI,KAAK,UAAU,2BACZ,KAAK,OAAO,kBAAkB,MAC9B,KAAK,OAAO,kBAAkB"}
@@ -1,3 +0,0 @@
1
- import { enhancedLocalStorage } from "./core.js";
2
- import { createKeyedEnhancedLocalStore } from "./keyed-store.js";
3
- export { createKeyedEnhancedLocalStore, enhancedLocalStorage };
@@ -1,4 +0,0 @@
1
- import { enhancedLocalStorage } from "./core.js";
2
- import { createKeyedEnhancedLocalStore } from "./keyed-store.js";
3
-
4
- export { createKeyedEnhancedLocalStore, enhancedLocalStorage };
@@ -1,36 +0,0 @@
1
- //#region src/storage/enhanced/local/keyed-store.d.ts
2
- /**
3
- * Creates a reusable, type-safe storage interface based on `enhancedLocalStorage`
4
- * and a dynamic key-generation function.
5
- *
6
- * This utility allows you to abstract away key construction logic and work directly
7
- * with scoped key-value operations like `getItem`, `setItem`, and `removeItem`.
8
- *
9
- * @template D - The value type to store
10
- *
11
- * @returns A factory that accepts a key generator function and returns a scoped storage interface
12
- *
13
- * @example
14
- * ```typescript
15
- * import { createKeyedEnhancedLocalStore } from '@kikiutils/shared/storage/enhanced/local';
16
- *
17
- * const userStore = createKeyedEnhancedLocalStore<User>()((id: number) => `user:${id}`);
18
- * userStore.setItem({ id: 123, name: 'user' }, 123);
19
- * const user = userStore.getItem(123);
20
- * ```
21
- */
22
- declare function createKeyedEnhancedLocalStore<D = unknown>(): <P extends any[]>(getKeyFunction: (...args: P) => string) => Readonly<{
23
- getItem: (...args: P) => D | null;
24
- hasItem: (...args: P) => boolean;
25
- removeItem: (...args: P) => void;
26
- /**
27
- * Resolves the storage key from the given arguments.
28
- *
29
- * @returns {string} The final string key used internally
30
- */
31
- resolveKey: (...args: P) => string;
32
- setItem: (value: D, ...args: P) => void;
33
- }>;
34
- //#endregion
35
- export { createKeyedEnhancedLocalStore };
36
- //# sourceMappingURL=keyed-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keyed-store.d.ts","names":[],"sources":["../../../../src/storage/enhanced/local/keyed-store.ts"],"sourcesContent":[],"mappings":";;AAsBA;;;;;;;;;;;;;;;;;;;iBAAgB,0FACuC,iBAAY;qBACxC,MAAC;qBACD;wBACG;;;;;;wBAMA;mBACL,YAAY"}