@powfix/core-js 0.11.3 → 0.11.5
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/src/services/redis/RedisClient.d.ts +1 -0
- package/dist/src/services/redis/RedisClient.js +5 -0
- package/dist/src/utils/ObjectIdUtils.d.ts +4 -0
- package/dist/src/utils/ObjectIdUtils.js +24 -0
- package/dist/src/utils/UuidUtils.d.ts +1 -1
- package/dist/src/utils/UuidUtils.js +0 -5
- package/dist/src/utils/index.d.ts +3 -1
- package/dist/src/utils/index.js +3 -1
- package/package.json +2 -1
|
@@ -4,6 +4,7 @@ export declare class RedisClient {
|
|
|
4
4
|
private status;
|
|
5
5
|
readonly client: RedisClientType<RedisDefaultModules & RedisModules, RedisFunctions, RedisScripts>;
|
|
6
6
|
constructor(options?: RedisClient.RedisClientOptions);
|
|
7
|
+
getStatus(): RedisClient.Status;
|
|
7
8
|
start(): Promise<RedisClient.Status>;
|
|
8
9
|
stop(): Promise<RedisClient.Status>;
|
|
9
10
|
private handleOnConnect;
|
|
@@ -27,13 +27,18 @@ class RedisClient {
|
|
|
27
27
|
this.client = (0, redis_1.createClient)({});
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
getStatus() {
|
|
31
|
+
return this.status;
|
|
32
|
+
}
|
|
30
33
|
start() {
|
|
31
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
35
|
console.log(LOG_PREFIX, 'trying to start');
|
|
33
36
|
// register event callback
|
|
34
37
|
this.client.on('connect', this.handleOnConnect);
|
|
35
38
|
this.client.on('error', this.handleOnError);
|
|
39
|
+
console.log('before connect');
|
|
36
40
|
yield this.client.connect();
|
|
41
|
+
console.log('after connect');
|
|
37
42
|
this.status = RedisClient.Status.RUNNING;
|
|
38
43
|
console.log(LOG_PREFIX, 'now started');
|
|
39
44
|
return this.status;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectIdUtils = void 0;
|
|
4
|
+
const UuidUtils_1 = require("./UuidUtils");
|
|
5
|
+
class ObjectIdUtils {
|
|
6
|
+
static toUuid(objectId, pad = 'start') {
|
|
7
|
+
const result = Buffer.alloc(16);
|
|
8
|
+
Buffer.from(objectId, 'hex').copy(result, pad === 'start' ? 4 : 0);
|
|
9
|
+
return UuidUtils_1.UuidUtils.toString(result);
|
|
10
|
+
}
|
|
11
|
+
static fromUuid(uuid, pad) {
|
|
12
|
+
const buffer = UuidUtils_1.UuidUtils.toBuffer(uuid);
|
|
13
|
+
const isPadEnd = buffer.subarray(buffer.length - 4).every(byte => byte === 0);
|
|
14
|
+
if (isPadEnd || pad === 'end') {
|
|
15
|
+
return buffer.subarray(0, buffer.length - 4).toString('hex');
|
|
16
|
+
}
|
|
17
|
+
const isPadStart = buffer.subarray(0, 4).every(byte => byte === 0);
|
|
18
|
+
if (!isPadStart) {
|
|
19
|
+
console.warn('buffer is not pad start and pad end');
|
|
20
|
+
}
|
|
21
|
+
return buffer.subarray(4).toString('hex');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ObjectIdUtils = ObjectIdUtils;
|
|
@@ -7,7 +7,7 @@ export declare class UuidUtils {
|
|
|
7
7
|
* @param binary UUID
|
|
8
8
|
* @returns {string|null} When binary not exists return null
|
|
9
9
|
*/
|
|
10
|
-
static toString(binary
|
|
10
|
+
static toString(binary: Buffer): string;
|
|
11
11
|
/** (UUID: string) to (UUID: Buffer) */
|
|
12
12
|
static toBuffer(uuid: string): Buffer;
|
|
13
13
|
static isValidUUID(uuid: string): boolean;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export * from './global';
|
|
2
2
|
export * from './StringUtils';
|
|
3
|
-
export * from './NumberUtils';
|
|
4
3
|
export * from './UuidUtils';
|
|
5
4
|
export * from './ArrayUtils';
|
|
6
5
|
export * from './BooleanUtils';
|
|
7
6
|
export * from './CoordinateUtils';
|
|
8
7
|
export * from './DateUtils';
|
|
8
|
+
export * from './NumberUtils';
|
|
9
|
+
export * from './ObjectIdUtils';
|
|
10
|
+
export * from './Point3Utils';
|
|
9
11
|
export * from './RandomUtils';
|
|
10
12
|
export * from './Validator';
|
|
11
13
|
export * from './JuminNumberUtils';
|
package/dist/src/utils/index.js
CHANGED
|
@@ -16,12 +16,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./global"), exports);
|
|
18
18
|
__exportStar(require("./StringUtils"), exports);
|
|
19
|
-
__exportStar(require("./NumberUtils"), exports);
|
|
20
19
|
__exportStar(require("./UuidUtils"), exports);
|
|
21
20
|
__exportStar(require("./ArrayUtils"), exports);
|
|
22
21
|
__exportStar(require("./BooleanUtils"), exports);
|
|
23
22
|
__exportStar(require("./CoordinateUtils"), exports);
|
|
24
23
|
__exportStar(require("./DateUtils"), exports);
|
|
24
|
+
__exportStar(require("./NumberUtils"), exports);
|
|
25
|
+
__exportStar(require("./ObjectIdUtils"), exports);
|
|
26
|
+
__exportStar(require("./Point3Utils"), exports);
|
|
25
27
|
__exportStar(require("./RandomUtils"), exports);
|
|
26
28
|
__exportStar(require("./Validator"), exports);
|
|
27
29
|
__exportStar(require("./JuminNumberUtils"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powfix/core-js",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"description": "core package",
|
|
5
5
|
"author": "Kwon Kyung-Min <powfix@gmail.com>",
|
|
6
6
|
"private": false,
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@types/uuid": "9.0.7",
|
|
38
38
|
"axios": "1.7.9",
|
|
39
39
|
"moment": "^2.30.1",
|
|
40
|
+
"ts-node": "^10.9.2",
|
|
40
41
|
"typescript": "5.1.6"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|