@tomsd/redis-client 1.3.1 → 1.4.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 CHANGED
@@ -9,7 +9,6 @@ See [redis-client.netlify.app](https://redis-client.netlify.app/) also.
9
9
  ![ci](https://img.shields.io/github/actions/workflow/status/tomsdoo/redis-client/ci.yml?style=social&logo=github)
10
10
  ![checks](https://img.shields.io/github/check-runs/tomsdoo/redis-client/main?style=social&logo=github)
11
11
  ![top language](https://img.shields.io/github/languages/top/tomsdoo/redis-client?style=social&logo=typescript)
12
- ![Maintenance](https://img.shields.io/maintenance/yes/2025?style=social&logo=github)
13
12
  ![depends on ioredis@5](https://img.shields.io/badge/ioredis-ioredis@5-informational?style=social&logo=redis)
14
13
  ![depends on node greater or equal 20](https://img.shields.io/badge/node.js-%3E%3D%2020-lightyellow?style=social&logo=nodedotjs)
15
14
 
package/dist/index.cjs CHANGED
@@ -1,88 +1,74 @@
1
- "use strict";
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getProtoOf = Object.getPrototypeOf;
7
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
9
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
19
18
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- Redis: () => Redis
34
- });
35
- module.exports = __toCommonJS(index_exports);
36
- var import_ioredis = __toESM(require("ioredis"), 1);
37
- var import_uuid = require("uuid");
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let ioredis = require("ioredis");
25
+ ioredis = __toESM(ioredis, 1);
26
+ let uuid = require("uuid");
27
+ //#region src/index.ts
38
28
  var Redis = class {
39
- config;
40
- redis;
41
- constructor(config) {
42
- this.config = config;
43
- this.redis = void 0;
44
- }
45
- get keyProp() {
46
- return this.config.keyProp ?? "_id";
47
- }
48
- get expireSeconds() {
49
- return this.config.expireSeconds;
50
- }
51
- getRedis() {
52
- this.redis = this.redis ?? new import_ioredis.default(this.config.options);
53
- return this.redis;
54
- }
55
- async getKeys() {
56
- const keyFilter = `${this.config?.options?.keyPrefix ?? ""}*`;
57
- const sliceKey = (s) => s.slice(this.config?.options?.keyPrefix?.length ?? 0);
58
- return await this.getRedis().keys(keyFilter).then((keys) => keys.map(sliceKey));
59
- }
60
- async get(key) {
61
- return await this.getRedis().get(key).then((value) => {
62
- if (value == null) {
63
- return void 0;
64
- }
65
- return JSON.parse(value);
66
- });
67
- }
68
- async set(value) {
69
- const redis = this.getRedis();
70
- const savingObj = {
71
- [this.keyProp]: (0, import_uuid.v4)(),
72
- ...value
73
- };
74
- const key = savingObj[this.keyProp];
75
- return this.expireSeconds !== void 0 ? await redis.set(key, JSON.stringify(savingObj), "EX", this.expireSeconds).then(() => savingObj) : await redis.set(key, JSON.stringify(savingObj)).then(() => savingObj);
76
- }
77
- async del(key) {
78
- return await this.getRedis().del(key);
79
- }
80
- disconnect() {
81
- this.getRedis().disconnect();
82
- this.redis = void 0;
83
- }
29
+ config;
30
+ redis;
31
+ constructor(config) {
32
+ this.config = config;
33
+ this.redis = void 0;
34
+ }
35
+ get keyProp() {
36
+ return this.config.keyProp ?? "_id";
37
+ }
38
+ get expireSeconds() {
39
+ return this.config.expireSeconds;
40
+ }
41
+ getRedis() {
42
+ this.redis = this.redis ?? new ioredis.default(this.config.options);
43
+ return this.redis;
44
+ }
45
+ async getKeys() {
46
+ const keyFilter = `${this.config?.options?.keyPrefix ?? ""}*`;
47
+ const sliceKey = (s) => s.slice(this.config?.options?.keyPrefix?.length ?? 0);
48
+ return await this.getRedis().keys(keyFilter).then((keys) => keys.map(sliceKey));
49
+ }
50
+ async get(key) {
51
+ return await this.getRedis().get(key).then((value) => {
52
+ if (value == null) return;
53
+ return JSON.parse(value);
54
+ });
55
+ }
56
+ async set(value) {
57
+ const redis = this.getRedis();
58
+ const savingObj = {
59
+ [this.keyProp]: (0, uuid.v4)(),
60
+ ...value
61
+ };
62
+ const key = savingObj[this.keyProp];
63
+ return this.expireSeconds !== void 0 ? await redis.set(key, JSON.stringify(savingObj), "EX", this.expireSeconds).then(() => savingObj) : await redis.set(key, JSON.stringify(savingObj)).then(() => savingObj);
64
+ }
65
+ async del(key) {
66
+ return await this.getRedis().del(key);
67
+ }
68
+ disconnect() {
69
+ this.getRedis().disconnect();
70
+ this.redis = void 0;
71
+ }
84
72
  };
85
- // Annotate the CommonJS export names for ESM import in node:
86
- 0 && (module.exports = {
87
- Redis
88
- });
73
+ //#endregion
74
+ exports.Redis = Redis;
package/dist/index.d.cts CHANGED
@@ -1,22 +1,23 @@
1
- import IORedis, { RedisOptions } from 'ioredis';
1
+ import IORedis, { RedisOptions } from "ioredis";
2
2
 
3
+ //#region src/index.d.ts
3
4
  interface EasyRedisConfig {
4
- keyProp?: string;
5
- expireSeconds?: number;
6
- options: RedisOptions;
5
+ keyProp?: string;
6
+ expireSeconds?: number;
7
+ options: RedisOptions;
7
8
  }
8
9
  declare class Redis<T = any> {
9
- config: EasyRedisConfig;
10
- protected redis: IORedis | undefined;
11
- constructor(config: EasyRedisConfig);
12
- get keyProp(): string;
13
- get expireSeconds(): number | undefined;
14
- getRedis(): IORedis;
15
- getKeys(): Promise<string[]>;
16
- get(key: string): Promise<T>;
17
- set(value: T | Partial<T>): Promise<T>;
18
- del(key: string): Promise<number>;
19
- disconnect(): void;
10
+ config: EasyRedisConfig;
11
+ protected redis: IORedis | undefined;
12
+ constructor(config: EasyRedisConfig);
13
+ get keyProp(): string;
14
+ get expireSeconds(): number | undefined;
15
+ getRedis(): IORedis;
16
+ getKeys(): Promise<string[]>;
17
+ get(key: string): Promise<T>;
18
+ set(value: T | Partial<T>): Promise<T>;
19
+ del(key: string): Promise<number>;
20
+ disconnect(): void;
20
21
  }
21
-
22
- export { Redis };
22
+ //#endregion
23
+ export { Redis };
@@ -0,0 +1,23 @@
1
+ import IORedis, { RedisOptions } from "ioredis";
2
+
3
+ //#region src/index.d.ts
4
+ interface EasyRedisConfig {
5
+ keyProp?: string;
6
+ expireSeconds?: number;
7
+ options: RedisOptions;
8
+ }
9
+ declare class Redis<T = any> {
10
+ config: EasyRedisConfig;
11
+ protected redis: IORedis | undefined;
12
+ constructor(config: EasyRedisConfig);
13
+ get keyProp(): string;
14
+ get expireSeconds(): number | undefined;
15
+ getRedis(): IORedis;
16
+ getKeys(): Promise<string[]>;
17
+ get(key: string): Promise<T>;
18
+ set(value: T | Partial<T>): Promise<T>;
19
+ del(key: string): Promise<number>;
20
+ disconnect(): void;
21
+ }
22
+ //#endregion
23
+ export { Redis };
package/dist/index.mjs ADDED
@@ -0,0 +1,50 @@
1
+ import IORedis from "ioredis";
2
+ import { v4 } from "uuid";
3
+ //#region src/index.ts
4
+ var Redis = class {
5
+ config;
6
+ redis;
7
+ constructor(config) {
8
+ this.config = config;
9
+ this.redis = void 0;
10
+ }
11
+ get keyProp() {
12
+ return this.config.keyProp ?? "_id";
13
+ }
14
+ get expireSeconds() {
15
+ return this.config.expireSeconds;
16
+ }
17
+ getRedis() {
18
+ this.redis = this.redis ?? new IORedis(this.config.options);
19
+ return this.redis;
20
+ }
21
+ async getKeys() {
22
+ const keyFilter = `${this.config?.options?.keyPrefix ?? ""}*`;
23
+ const sliceKey = (s) => s.slice(this.config?.options?.keyPrefix?.length ?? 0);
24
+ return await this.getRedis().keys(keyFilter).then((keys) => keys.map(sliceKey));
25
+ }
26
+ async get(key) {
27
+ return await this.getRedis().get(key).then((value) => {
28
+ if (value == null) return;
29
+ return JSON.parse(value);
30
+ });
31
+ }
32
+ async set(value) {
33
+ const redis = this.getRedis();
34
+ const savingObj = {
35
+ [this.keyProp]: v4(),
36
+ ...value
37
+ };
38
+ const key = savingObj[this.keyProp];
39
+ return this.expireSeconds !== void 0 ? await redis.set(key, JSON.stringify(savingObj), "EX", this.expireSeconds).then(() => savingObj) : await redis.set(key, JSON.stringify(savingObj)).then(() => savingObj);
40
+ }
41
+ async del(key) {
42
+ return await this.getRedis().del(key);
43
+ }
44
+ disconnect() {
45
+ this.getRedis().disconnect();
46
+ this.redis = void 0;
47
+ }
48
+ };
49
+ //#endregion
50
+ export { Redis };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@tomsd/redis-client",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "It's a wrapper of ioredis.",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
- "types": "./dist/index.d.ts",
9
- "import": "./dist/index.js",
8
+ "types": "./dist/index.d.mts",
9
+ "import": "./dist/index.mjs",
10
10
  "require": "./dist/index.cjs"
11
11
  }
12
12
  },
@@ -14,7 +14,7 @@
14
14
  "dist"
15
15
  ],
16
16
  "scripts": {
17
- "build": "tsup",
17
+ "build": "tsdown",
18
18
  "lint": "biome check",
19
19
  "prepare": "husky",
20
20
  "start-redis": "docker compose up -d",
@@ -45,19 +45,19 @@
45
45
  },
46
46
  "homepage": "https://github.com/tomsdoo/redis-client#readme",
47
47
  "devDependencies": {
48
- "@biomejs/biome": "2.4.1",
48
+ "@biomejs/biome": "2.4.12",
49
49
  "@tomsd/md-book": "2.0.7",
50
- "@types/node": "25.2.3",
50
+ "@types/node": "25.6.0",
51
51
  "@types/uuid": "11.0.0",
52
52
  "husky": "9.1.7",
53
- "lint-staged": "16.2.7",
53
+ "lint-staged": "16.4.0",
54
54
  "ts-node": "10.9.2",
55
- "tsup": "8.5.1",
56
- "typescript": "5.9.3",
57
- "vitest": "4.0.18"
55
+ "tsdown": "0.21.10",
56
+ "typescript": "6.0.3",
57
+ "vitest": "4.1.4"
58
58
  },
59
59
  "dependencies": {
60
- "ioredis": "5.9.3",
61
- "uuid": "13.0.0"
60
+ "ioredis": "5.10.1",
61
+ "uuid": "14.0.0"
62
62
  }
63
63
  }
package/dist/index.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import IORedis, { RedisOptions } from 'ioredis';
2
-
3
- interface EasyRedisConfig {
4
- keyProp?: string;
5
- expireSeconds?: number;
6
- options: RedisOptions;
7
- }
8
- declare class Redis<T = any> {
9
- config: EasyRedisConfig;
10
- protected redis: IORedis | undefined;
11
- constructor(config: EasyRedisConfig);
12
- get keyProp(): string;
13
- get expireSeconds(): number | undefined;
14
- getRedis(): IORedis;
15
- getKeys(): Promise<string[]>;
16
- get(key: string): Promise<T>;
17
- set(value: T | Partial<T>): Promise<T>;
18
- del(key: string): Promise<number>;
19
- disconnect(): void;
20
- }
21
-
22
- export { Redis };
package/dist/index.js DELETED
@@ -1,53 +0,0 @@
1
- // src/index.ts
2
- import IORedis from "ioredis";
3
- import { v4 as uuid } from "uuid";
4
- var Redis = class {
5
- config;
6
- redis;
7
- constructor(config) {
8
- this.config = config;
9
- this.redis = void 0;
10
- }
11
- get keyProp() {
12
- return this.config.keyProp ?? "_id";
13
- }
14
- get expireSeconds() {
15
- return this.config.expireSeconds;
16
- }
17
- getRedis() {
18
- this.redis = this.redis ?? new IORedis(this.config.options);
19
- return this.redis;
20
- }
21
- async getKeys() {
22
- const keyFilter = `${this.config?.options?.keyPrefix ?? ""}*`;
23
- const sliceKey = (s) => s.slice(this.config?.options?.keyPrefix?.length ?? 0);
24
- return await this.getRedis().keys(keyFilter).then((keys) => keys.map(sliceKey));
25
- }
26
- async get(key) {
27
- return await this.getRedis().get(key).then((value) => {
28
- if (value == null) {
29
- return void 0;
30
- }
31
- return JSON.parse(value);
32
- });
33
- }
34
- async set(value) {
35
- const redis = this.getRedis();
36
- const savingObj = {
37
- [this.keyProp]: uuid(),
38
- ...value
39
- };
40
- const key = savingObj[this.keyProp];
41
- return this.expireSeconds !== void 0 ? await redis.set(key, JSON.stringify(savingObj), "EX", this.expireSeconds).then(() => savingObj) : await redis.set(key, JSON.stringify(savingObj)).then(() => savingObj);
42
- }
43
- async del(key) {
44
- return await this.getRedis().del(key);
45
- }
46
- disconnect() {
47
- this.getRedis().disconnect();
48
- this.redis = void 0;
49
- }
50
- };
51
- export {
52
- Redis
53
- };