@mulingai-npm/redis 2.12.2 → 2.12.4

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.
@@ -1,96 +1,96 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RedisClient = void 0;
7
- const ioredis_1 = __importDefault(require("ioredis"));
8
- class RedisClient {
9
- constructor(config) {
10
- this.client = new ioredis_1.default({
11
- host: config.host,
12
- port: config.port,
13
- password: config.password,
14
- db: config.db
15
- });
16
- this.client.on('error', (err) => {
17
- console.error('Redis error:', err);
18
- });
19
- }
20
- // existing set/get
21
- async set(key, value) {
22
- await this.client.set(key, value);
23
- }
24
- async get(key) {
25
- return this.client.get(key);
26
- }
27
- async del(key) {
28
- return this.client.del(key);
29
- }
30
- // Insert one or more values into a set
31
- async sadd(key, ...values) {
32
- return this.client.sadd(key, values);
33
- }
34
- async srem(key, ...values) {
35
- return this.client.srem(key, values);
36
- }
37
- // Get all set members
38
- async smembers(key) {
39
- return this.client.smembers(key);
40
- }
41
- // Search for all keys matching a pattern
42
- // NOTE: If you have lots of keys in Redis, you should look into using SCAN instead of KEYS
43
- async keys(pattern) {
44
- return this.client.keys(pattern);
45
- }
46
- // add these methods for hash, sets, keys, etc.
47
- async hset(key, data) {
48
- return this.client.hset(key, data);
49
- }
50
- async hgetall(key) {
51
- return this.client.hgetall(key);
52
- }
53
- // flush methods
54
- async flushAll() {
55
- console.log('Flushing All Redis Data!');
56
- return this.client.flushall();
57
- }
58
- async flushDb() {
59
- console.log('Flushing Redis Data from DB!');
60
- return this.client.flushdb();
61
- }
62
- async expire(key, seconds) {
63
- return this.client.expire(key, seconds);
64
- }
65
- async jsonSet(key, path, value) {
66
- const result = await this.client.call('JSON.SET', key, path, JSON.stringify(value));
67
- return result;
68
- }
69
- async jsonGet(key, path) {
70
- const result = (await this.client.call('JSON.GET', key, path));
71
- if (!result) {
72
- return null;
73
- }
74
- return JSON.parse(result);
75
- }
76
- async jsonDel(key, path) {
77
- const result = await this.client.call('JSON.DEL', key, path);
78
- return Number(result);
79
- }
80
- async jsonArrAppend(key, path, ...values) {
81
- const stringifiedValues = values.map((v) => JSON.stringify(v));
82
- const result = await this.client.call('JSON.ARRAPPEND', key, path, ...stringifiedValues);
83
- return Number(result);
84
- }
85
- async jsonArrLen(key, path) {
86
- const result = await this.client.call('JSON.ARRLEN', key, path);
87
- return result === null ? null : Number(result);
88
- }
89
- async jsonArrPop(key, path, index) {
90
- if (index !== undefined) {
91
- return this.client.call('JSON.ARRPOP', key, path, index);
92
- }
93
- return this.client.call('JSON.ARRPOP', key, path);
94
- }
95
- }
96
- exports.RedisClient = RedisClient;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RedisClient = void 0;
7
+ const ioredis_1 = __importDefault(require("ioredis"));
8
+ class RedisClient {
9
+ constructor(config) {
10
+ this.client = new ioredis_1.default({
11
+ host: config.host,
12
+ port: config.port,
13
+ password: config.password,
14
+ db: config.db
15
+ });
16
+ this.client.on('error', (err) => {
17
+ console.error('Redis error:', err);
18
+ });
19
+ }
20
+ // existing set/get
21
+ async set(key, value) {
22
+ await this.client.set(key, value);
23
+ }
24
+ async get(key) {
25
+ return this.client.get(key);
26
+ }
27
+ async del(key) {
28
+ return this.client.del(key);
29
+ }
30
+ // Insert one or more values into a set
31
+ async sadd(key, ...values) {
32
+ return this.client.sadd(key, values);
33
+ }
34
+ async srem(key, ...values) {
35
+ return this.client.srem(key, values);
36
+ }
37
+ // Get all set members
38
+ async smembers(key) {
39
+ return this.client.smembers(key);
40
+ }
41
+ // Search for all keys matching a pattern
42
+ // NOTE: If you have lots of keys in Redis, you should look into using SCAN instead of KEYS
43
+ async keys(pattern) {
44
+ return this.client.keys(pattern);
45
+ }
46
+ // add these methods for hash, sets, keys, etc.
47
+ async hset(key, data) {
48
+ return this.client.hset(key, data);
49
+ }
50
+ async hgetall(key) {
51
+ return this.client.hgetall(key);
52
+ }
53
+ // flush methods
54
+ async flushAll() {
55
+ console.log('Flushing All Redis Data!');
56
+ return this.client.flushall();
57
+ }
58
+ async flushDb() {
59
+ console.log('Flushing Redis Data from DB!');
60
+ return this.client.flushdb();
61
+ }
62
+ async expire(key, seconds) {
63
+ return this.client.expire(key, seconds);
64
+ }
65
+ async jsonSet(key, path, value) {
66
+ const result = await this.client.call('JSON.SET', key, path, JSON.stringify(value));
67
+ return result;
68
+ }
69
+ async jsonGet(key, path) {
70
+ const result = (await this.client.call('JSON.GET', key, path));
71
+ if (!result) {
72
+ return null;
73
+ }
74
+ return JSON.parse(result);
75
+ }
76
+ async jsonDel(key, path) {
77
+ const result = await this.client.call('JSON.DEL', key, path);
78
+ return Number(result);
79
+ }
80
+ async jsonArrAppend(key, path, ...values) {
81
+ const stringifiedValues = values.map((v) => JSON.stringify(v));
82
+ const result = await this.client.call('JSON.ARRAPPEND', key, path, ...stringifiedValues);
83
+ return Number(result);
84
+ }
85
+ async jsonArrLen(key, path) {
86
+ const result = await this.client.call('JSON.ARRLEN', key, path);
87
+ return result === null ? null : Number(result);
88
+ }
89
+ async jsonArrPop(key, path, index) {
90
+ if (index !== undefined) {
91
+ return this.client.call('JSON.ARRPOP', key, path, index);
92
+ }
93
+ return this.client.call('JSON.ARRPOP', key, path);
94
+ }
95
+ }
96
+ exports.RedisClient = RedisClient;
@@ -1 +1 @@
1
- export declare function getMappedLanguage(lang: string, targetLanguages: string[], shortCodeTargetLanguages: string[]): string | null;
1
+ export declare function getMappedLanguage(lang: string, targetLanguages: string[], shortCodeTargetLanguages: string[]): string | null;
@@ -1,18 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMappedLanguage = void 0;
4
- function getMappedLanguage(lang, targetLanguages, shortCodeTargetLanguages) {
5
- // Full → short
6
- let idx = targetLanguages.indexOf(lang);
7
- if (idx !== -1) {
8
- return shortCodeTargetLanguages[idx];
9
- }
10
- // Short → full
11
- idx = shortCodeTargetLanguages.indexOf(lang);
12
- if (idx !== -1) {
13
- return targetLanguages[idx];
14
- }
15
- // No match
16
- return '';
17
- }
18
- exports.getMappedLanguage = getMappedLanguage;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMappedLanguage = void 0;
4
+ function getMappedLanguage(lang, targetLanguages, shortCodeTargetLanguages) {
5
+ // Full → short
6
+ let idx = targetLanguages.indexOf(lang);
7
+ if (idx !== -1) {
8
+ return shortCodeTargetLanguages[idx];
9
+ }
10
+ // Short → full
11
+ idx = shortCodeTargetLanguages.indexOf(lang);
12
+ if (idx !== -1) {
13
+ return targetLanguages[idx];
14
+ }
15
+ // No match
16
+ return '';
17
+ }
18
+ exports.getMappedLanguage = getMappedLanguage;
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
- {
2
- "name": "@mulingai-npm/redis",
3
- "version": "2.12.2",
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/mulingai/mulingai-backend.git"
9
- },
10
- "publishConfig": {
11
- "registry": "https://registry.npmjs.org/"
12
- },
13
- "private": false,
14
- "scripts": {
15
- "dev": "rm -f tsconfig.tsbuildinfo && tsc --watch",
16
- "build": "rm -f tsconfig.tsbuildinfo && tsc",
17
- "prepublishOnly": "npm run build"
18
- },
19
- "dependencies": {
20
- "ioredis": "^5.6.0",
21
- "uuid": "^11.1.0"
22
- },
23
- "devDependencies": {
24
- "concurrently": "^9.1.2",
25
- "copyfiles": "^2.4.1",
26
- "nodemon": "^3.1.9",
27
- "typescript": "^4.9.5"
28
- },
29
- "files": [
30
- "dist",
31
- "package.json",
32
- "README.md"
33
- ]
34
- }
1
+ {
2
+ "name": "@mulingai-npm/redis",
3
+ "version": "2.12.4",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/mulingai/mulingai-backend.git"
9
+ },
10
+ "publishConfig": {
11
+ "registry": "https://registry.npmjs.org/"
12
+ },
13
+ "private": false,
14
+ "scripts": {
15
+ "dev": "rm -f tsconfig.tsbuildinfo && tsc --watch",
16
+ "build": "rm -f tsconfig.tsbuildinfo && tsc",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "dependencies": {
20
+ "ioredis": "^5.6.0",
21
+ "uuid": "^11.1.0"
22
+ },
23
+ "devDependencies": {
24
+ "concurrently": "^9.1.2",
25
+ "copyfiles": "^2.4.1",
26
+ "nodemon": "^3.1.9",
27
+ "typescript": "^4.9.5"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "package.json",
32
+ "README.md"
33
+ ]
34
+ }