neru-alpha
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -10,9 +10,9 @@ import { CommandService, NeruLogger } from '../services/index.js'; | ||
del: (key: string) => Promise<any>; | ||
hdel: (htable: any, key: string) => Promise<any>; | ||
hexists: (htable: any, key: string) => Promise<any>; | ||
hgetall: (htable: any) => Promise<any>; | ||
hmget: (htable: any, ids: any) => Promise<any>; | ||
hvals: (htable: any) => Promise<any>; | ||
hget: (htable: any, key: string) => Promise<any>; | ||
hset: (htable: any, keyValuePairs: any) => Promise<any>; | ||
hdel: (htable: string, key: string) => Promise<any>; | ||
hexists: (htable: string, key: string) => Promise<any>; | ||
hgetall: (htable: string) => Promise<any>; | ||
hmget: (htable: string, keys: [string]) => Promise<any>; | ||
hvals: (htable: string) => Promise<any>; | ||
hget: (htable: string, key: string) => Promise<any>; | ||
hset: (htable: string, keyValuePairs: Record<string, unknown>) => Promise<any>; | ||
rpush: (list: string, value: any) => Promise<any>; | ||
@@ -19,0 +19,0 @@ lpush: (list: string, value: any) => Promise<any>; |
@@ -83,3 +83,3 @@ "use strict"; | ||
res = _a.sent(); | ||
return [2 /*return*/, JSON.parse(JSON.parse(res))]; // TODO: temporarily solution. Requires a fix on backend (neru-platform) | ||
return [2 /*return*/, JSON.parse(res)]; | ||
} | ||
@@ -102,4 +102,2 @@ }); | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, null]; | ||
return [2 /*return*/, JSON.parse(res)]; | ||
@@ -148,4 +146,2 @@ } | ||
result = {}; | ||
if (!res) | ||
return [2 /*return*/, result]; | ||
for (i = 0; i < res.length; i = i + 2) { | ||
@@ -158,3 +154,3 @@ result[res[i]] = JSON.parse(res[i + 1]); | ||
}); }; | ||
this.hmget = function (htable, ids) { return __awaiter(_this, void 0, void 0, function () { | ||
this.hmget = function (htable, keys) { return __awaiter(_this, void 0, void 0, function () { | ||
var cmd, res; | ||
@@ -168,3 +164,3 @@ return __generator(this, function (_a) { | ||
key: htable, | ||
args: ids.map(function (id) { return JSON.stringify(id); }), | ||
args: keys, | ||
}; | ||
@@ -174,5 +170,3 @@ return [4 /*yield*/, this.commandService.executeCommandSync(constants_js_1.Providers.State, cmd)]; | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, []]; | ||
return [2 /*return*/, res.map(function (j) { return JSON.parse(j); })]; | ||
return [2 /*return*/, res.map(function (key) { return JSON.parse(key); })]; | ||
} | ||
@@ -195,6 +189,3 @@ }); | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, []]; | ||
console.log('hvals(htable)', res); | ||
return [2 /*return*/, res.map(function (j) { return JSON.parse(j); })]; | ||
return [2 /*return*/, res.map(function (key) { return JSON.parse(key); })]; | ||
} | ||
@@ -204,11 +195,17 @@ }); | ||
this.hget = function (htable, key) { return __awaiter(_this, void 0, void 0, function () { | ||
var cmd; | ||
var cmd, result; | ||
return __generator(this, function (_a) { | ||
cmd = { | ||
operation: 'HGET', | ||
namespace: this.namespace, | ||
key: htable, | ||
args: [key], | ||
}; | ||
return [2 /*return*/, this.commandService.executeCommandSync(constants_js_1.Providers.State, cmd)]; | ||
switch (_a.label) { | ||
case 0: | ||
cmd = { | ||
operation: 'HGET', | ||
namespace: this.namespace, | ||
key: htable, | ||
args: [key], | ||
}; | ||
return [4 /*yield*/, this.commandService.executeCommandSync(constants_js_1.Providers.State, cmd)]; | ||
case 1: | ||
result = _a.sent(); | ||
return [2 /*return*/, JSON.parse(result)]; | ||
} | ||
}); | ||
@@ -244,4 +241,2 @@ }); }; | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, null]; | ||
return [2 /*return*/, JSON.parse(res)]; | ||
@@ -265,4 +260,2 @@ } | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, null]; | ||
return [2 /*return*/, JSON.parse(res)]; | ||
@@ -286,4 +279,2 @@ } | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, null]; | ||
return [2 /*return*/, JSON.parse(res)]; | ||
@@ -294,3 +285,3 @@ } | ||
this.lrange = function (list, startPos, endPos) { return __awaiter(_this, void 0, void 0, function () { | ||
var cmd, res, array; | ||
var cmd, res; | ||
return __generator(this, function (_a) { | ||
@@ -312,6 +303,3 @@ switch (_a.label) { | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, null]; | ||
array = JSON.parse(res); | ||
return [2 /*return*/, array.map(function (a) { return JSON.parse(a); })]; | ||
return [2 /*return*/, res.map(function (item) { return JSON.parse(item); })]; | ||
} | ||
@@ -318,0 +306,0 @@ }); |
@@ -52,3 +52,3 @@ "use strict"; | ||
exports.CommandService = void 0; | ||
var got_1 = __importDefault(require("got")); | ||
var axios_1 = __importDefault(require("axios")); | ||
var tsyringe_1 = require("tsyringe"); | ||
@@ -80,3 +80,3 @@ var utils_js_1 = require("./utils.js"); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, res, e_1; | ||
var result, e_1; | ||
return __generator(this, function (_a) { | ||
@@ -86,22 +86,6 @@ switch (_a.label) { | ||
_a.trys.push([0, 2, , 3]); | ||
response = void 0; | ||
return [4 /*yield*/, got_1.default.post(url, { | ||
headers: headers, | ||
json: payload, | ||
})]; | ||
return [4 /*yield*/, axios_1.default.post(url, payload, { headers: headers })]; | ||
case 1: | ||
res = _a.sent(); | ||
if (this.utils.isJson(res.headers)) { | ||
// TODO: temporarily fix with trycatch until all providers return correct json | ||
try { | ||
response = JSON.parse(res.body); | ||
} | ||
catch (error) { | ||
response = res.body; | ||
} | ||
} | ||
else { | ||
response = res.body; | ||
} | ||
return [2 /*return*/, response]; | ||
result = _a.sent(); | ||
return [2 /*return*/, result.data]; | ||
case 2: | ||
@@ -108,0 +92,0 @@ e_1 = _a.sent(); |
@@ -36,3 +36,3 @@ "use strict"; | ||
else { | ||
return this.config.executeUrl + "/" + value + ":8080"; | ||
return "" + this.config.executeUrl + value + ":8080"; | ||
} | ||
@@ -39,0 +39,0 @@ }; |
@@ -10,9 +10,9 @@ import { CommandService, NeruLogger } from '../services/index.js'; | ||
del: (key: string) => Promise<any>; | ||
hdel: (htable: any, key: string) => Promise<any>; | ||
hexists: (htable: any, key: string) => Promise<any>; | ||
hgetall: (htable: any) => Promise<any>; | ||
hmget: (htable: any, ids: any) => Promise<any>; | ||
hvals: (htable: any) => Promise<any>; | ||
hget: (htable: any, key: string) => Promise<any>; | ||
hset: (htable: any, keyValuePairs: any) => Promise<any>; | ||
hdel: (htable: string, key: string) => Promise<any>; | ||
hexists: (htable: string, key: string) => Promise<any>; | ||
hgetall: (htable: string) => Promise<any>; | ||
hmget: (htable: string, keys: [string]) => Promise<any>; | ||
hvals: (htable: string) => Promise<any>; | ||
hget: (htable: string, key: string) => Promise<any>; | ||
hset: (htable: string, keyValuePairs: Record<string, unknown>) => Promise<any>; | ||
rpush: (list: string, value: any) => Promise<any>; | ||
@@ -19,0 +19,0 @@ lpush: (list: string, value: any) => Promise<any>; |
@@ -80,3 +80,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
res = _a.sent(); | ||
return [2 /*return*/, JSON.parse(JSON.parse(res))]; // TODO: temporarily solution. Requires a fix on backend (neru-platform) | ||
return [2 /*return*/, JSON.parse(res)]; | ||
} | ||
@@ -99,4 +99,2 @@ }); | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, null]; | ||
return [2 /*return*/, JSON.parse(res)]; | ||
@@ -145,4 +143,2 @@ } | ||
result = {}; | ||
if (!res) | ||
return [2 /*return*/, result]; | ||
for (i = 0; i < res.length; i = i + 2) { | ||
@@ -155,3 +151,3 @@ result[res[i]] = JSON.parse(res[i + 1]); | ||
}); }; | ||
this.hmget = function (htable, ids) { return __awaiter(_this, void 0, void 0, function () { | ||
this.hmget = function (htable, keys) { return __awaiter(_this, void 0, void 0, function () { | ||
var cmd, res; | ||
@@ -165,3 +161,3 @@ return __generator(this, function (_a) { | ||
key: htable, | ||
args: ids.map(function (id) { return JSON.stringify(id); }), | ||
args: keys, | ||
}; | ||
@@ -171,5 +167,3 @@ return [4 /*yield*/, this.commandService.executeCommandSync(Providers.State, cmd)]; | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, []]; | ||
return [2 /*return*/, res.map(function (j) { return JSON.parse(j); })]; | ||
return [2 /*return*/, res.map(function (key) { return JSON.parse(key); })]; | ||
} | ||
@@ -192,6 +186,3 @@ }); | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, []]; | ||
console.log('hvals(htable)', res); | ||
return [2 /*return*/, res.map(function (j) { return JSON.parse(j); })]; | ||
return [2 /*return*/, res.map(function (key) { return JSON.parse(key); })]; | ||
} | ||
@@ -201,11 +192,17 @@ }); | ||
this.hget = function (htable, key) { return __awaiter(_this, void 0, void 0, function () { | ||
var cmd; | ||
var cmd, result; | ||
return __generator(this, function (_a) { | ||
cmd = { | ||
operation: 'HGET', | ||
namespace: this.namespace, | ||
key: htable, | ||
args: [key], | ||
}; | ||
return [2 /*return*/, this.commandService.executeCommandSync(Providers.State, cmd)]; | ||
switch (_a.label) { | ||
case 0: | ||
cmd = { | ||
operation: 'HGET', | ||
namespace: this.namespace, | ||
key: htable, | ||
args: [key], | ||
}; | ||
return [4 /*yield*/, this.commandService.executeCommandSync(Providers.State, cmd)]; | ||
case 1: | ||
result = _a.sent(); | ||
return [2 /*return*/, JSON.parse(result)]; | ||
} | ||
}); | ||
@@ -241,4 +238,2 @@ }); }; | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, null]; | ||
return [2 /*return*/, JSON.parse(res)]; | ||
@@ -262,4 +257,2 @@ } | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, null]; | ||
return [2 /*return*/, JSON.parse(res)]; | ||
@@ -283,4 +276,2 @@ } | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, null]; | ||
return [2 /*return*/, JSON.parse(res)]; | ||
@@ -291,3 +282,3 @@ } | ||
this.lrange = function (list, startPos, endPos) { return __awaiter(_this, void 0, void 0, function () { | ||
var cmd, res, array; | ||
var cmd, res; | ||
return __generator(this, function (_a) { | ||
@@ -309,6 +300,3 @@ switch (_a.label) { | ||
res = _a.sent(); | ||
if (!res) | ||
return [2 /*return*/, null]; | ||
array = JSON.parse(res); | ||
return [2 /*return*/, array.map(function (a) { return JSON.parse(a); })]; | ||
return [2 /*return*/, res.map(function (item) { return JSON.parse(item); })]; | ||
} | ||
@@ -315,0 +303,0 @@ }); |
@@ -46,3 +46,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
}; | ||
import got from 'got'; | ||
import axios from 'axios'; | ||
import { autoInjectable } from 'tsyringe'; | ||
@@ -74,3 +74,3 @@ import { Utils } from './utils.js'; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, res, e_1; | ||
var result, e_1; | ||
return __generator(this, function (_a) { | ||
@@ -80,22 +80,6 @@ switch (_a.label) { | ||
_a.trys.push([0, 2, , 3]); | ||
response = void 0; | ||
return [4 /*yield*/, got.post(url, { | ||
headers: headers, | ||
json: payload, | ||
})]; | ||
return [4 /*yield*/, axios.post(url, payload, { headers: headers })]; | ||
case 1: | ||
res = _a.sent(); | ||
if (this.utils.isJson(res.headers)) { | ||
// TODO: temporarily fix with trycatch until all providers return correct json | ||
try { | ||
response = JSON.parse(res.body); | ||
} | ||
catch (error) { | ||
response = res.body; | ||
} | ||
} | ||
else { | ||
response = res.body; | ||
} | ||
return [2 /*return*/, response]; | ||
result = _a.sent(); | ||
return [2 /*return*/, result.data]; | ||
case 2: | ||
@@ -102,0 +86,0 @@ e_1 = _a.sent(); |
@@ -30,3 +30,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
else { | ||
return this.config.executeUrl + "/" + value + ":8080"; | ||
return "" + this.config.executeUrl + value + ":8080"; | ||
} | ||
@@ -33,0 +33,0 @@ }; |
{ | ||
"name": "neru-alpha", | ||
"type": "module", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "", | ||
@@ -31,4 +31,4 @@ "main": "dist/cjs/index.js", | ||
"dependencies": { | ||
"axios": "^0.21.1", | ||
"express": "^4.17.1", | ||
"got": "^11.8.2", | ||
"reflect-metadata": "^0.1.13", | ||
@@ -35,0 +35,0 @@ "tsyringe": "^4.6.0", |
@@ -30,3 +30,3 @@ import { autoInjectable } from 'tsyringe'; | ||
return JSON.parse(JSON.parse(res)); // TODO: temporarily solution. Requires a fix on backend (neru-platform) | ||
return JSON.parse(res); | ||
}; | ||
@@ -42,7 +42,6 @@ | ||
const res = await this.commandService.executeCommandSync(Providers.State, cmd); | ||
if (!res) return null; | ||
return JSON.parse(res); | ||
}; | ||
hdel = async (htable, key: string): Promise<any> => { | ||
hdel = async (htable: string, key: string): Promise<any> => { | ||
const cmd = { | ||
@@ -57,3 +56,3 @@ operation: 'HDEL', | ||
hexists = async (htable, key: string): Promise<any> => { | ||
hexists = async (htable: string, key: string): Promise<any> => { | ||
const cmd = { | ||
@@ -68,3 +67,3 @@ operation: 'HEXISTS', | ||
hgetall = async (htable): Promise<any> => { | ||
hgetall = async (htable: string): Promise<any> => { | ||
const cmd = { | ||
@@ -78,5 +77,3 @@ operation: 'HGETALL', | ||
const res = await this.commandService.executeCommandSync(Providers.State, cmd); | ||
const result = {}; | ||
if (!res) return result; | ||
@@ -89,3 +86,3 @@ for (let i = 0; i < res.length; i = i + 2) { | ||
hmget = async (htable, ids): Promise<any> => { | ||
hmget = async (htable: string, keys: [string]): Promise<any> => { | ||
const cmd = { | ||
@@ -95,10 +92,9 @@ operation: 'HMGET', | ||
key: htable, | ||
args: ids.map((id) => JSON.stringify(id)), | ||
args: keys, | ||
}; | ||
const res = await this.commandService.executeCommandSync(Providers.State, cmd); | ||
if (!res) return []; | ||
return res.map((j) => JSON.parse(j)); | ||
return res.map((key) => JSON.parse(key)); | ||
}; | ||
hvals = async (htable): Promise<any> => { | ||
hvals = async (htable: string): Promise<any> => { | ||
const cmd = { | ||
@@ -110,9 +106,9 @@ operation: 'HVALS', | ||
}; | ||
const res = await this.commandService.executeCommandSync(Providers.State, cmd); | ||
if (!res) return []; | ||
console.log('hvals(htable)', res); | ||
return res.map((j) => JSON.parse(j)); | ||
return res.map((key) => JSON.parse(key)); | ||
}; | ||
hget = async (htable, key: string): Promise<any> => { | ||
hget = async (htable: string, key: string): Promise<any> => { | ||
const cmd = { | ||
@@ -124,6 +120,7 @@ operation: 'HGET', | ||
}; | ||
return this.commandService.executeCommandSync(Providers.State, cmd); | ||
const result = await this.commandService.executeCommandSync(Providers.State, cmd); | ||
return JSON.parse(result); | ||
}; | ||
hset = async (htable, keyValuePairs): Promise<any> => { | ||
hset = async (htable: string, keyValuePairs: Record<string, unknown>): Promise<any> => { | ||
const args = Object.keys(keyValuePairs).flatMap((k) => [k, JSON.stringify(keyValuePairs[k])]); | ||
@@ -148,3 +145,2 @@ console.log('hset args', args); | ||
const res = await this.commandService.executeCommandSync(Providers.State, cmd); | ||
if (!res) return null; | ||
return JSON.parse(res); | ||
@@ -161,3 +157,2 @@ }; | ||
const res = await this.commandService.executeCommandSync(Providers.State, cmd); | ||
if (!res) return null; | ||
return JSON.parse(res); | ||
@@ -174,3 +169,2 @@ }; | ||
const res = await this.commandService.executeCommandSync(Providers.State, cmd); | ||
if (!res) return null; | ||
return JSON.parse(res); | ||
@@ -190,6 +184,4 @@ }; | ||
const res = await this.commandService.executeCommandSync(Providers.State, cmd); | ||
if (!res) return null; | ||
const array = JSON.parse(res); | ||
return array.map((a) => JSON.parse(a)); | ||
return res.map((item) => JSON.parse(item)); | ||
}; | ||
} |
@@ -1,2 +0,3 @@ | ||
import got from 'got'; | ||
import axios from 'axios'; | ||
import { autoInjectable } from 'tsyringe'; | ||
@@ -22,20 +23,5 @@ import { Command, RequestHeaders } from '../types'; | ||
try { | ||
let response; | ||
const res = await got.post(url, { | ||
headers, | ||
json: payload, | ||
}); | ||
const result = await axios.post(url, payload, { headers }); | ||
if (this.utils.isJson(res.headers)) { | ||
// TODO: temporarily fix with trycatch until all providers return correct json | ||
try { | ||
response = JSON.parse(res.body); | ||
} catch (error) { | ||
response = res.body; | ||
} | ||
} else { | ||
response = res.body; | ||
} | ||
return response; | ||
return result.data; | ||
} catch (e) { | ||
@@ -42,0 +28,0 @@ throw new Error('executeCommand failed: ' + e.message); |
@@ -20,3 +20,3 @@ import { URL } from 'url'; | ||
} else { | ||
return `${this.config.executeUrl}/${value}:8080`; | ||
return `${this.config.executeUrl}${value}:8080`; | ||
} | ||
@@ -23,0 +23,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
279303
136
5809
+ Addedaxios@^0.21.1
+ Addedaxios@0.21.4(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
- Removedgot@^11.8.2
- Removed@sindresorhus/is@4.6.0(transitive)
- Removed@szmarczak/http-timer@4.0.6(transitive)
- Removed@types/cacheable-request@6.0.3(transitive)
- Removed@types/http-cache-semantics@4.0.4(transitive)
- Removed@types/keyv@3.1.4(transitive)
- Removed@types/node@22.9.3(transitive)
- Removed@types/responselike@1.0.3(transitive)
- Removedcacheable-lookup@5.0.4(transitive)
- Removedcacheable-request@7.0.4(transitive)
- Removedclone-response@1.0.3(transitive)
- Removeddecompress-response@6.0.0(transitive)
- Removeddefer-to-connect@2.0.1(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedget-stream@5.2.0(transitive)
- Removedgot@11.8.6(transitive)
- Removedhttp-cache-semantics@4.1.1(transitive)
- Removedhttp2-wrapper@1.0.3(transitive)
- Removedjson-buffer@3.0.1(transitive)
- Removedkeyv@4.5.4(transitive)
- Removedlowercase-keys@2.0.0(transitive)
- Removedmimic-response@1.0.13.1.0(transitive)
- Removednormalize-url@6.1.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedp-cancelable@2.1.1(transitive)
- Removedpump@3.0.2(transitive)
- Removedquick-lru@5.1.1(transitive)
- Removedresolve-alpn@1.2.1(transitive)
- Removedresponselike@2.0.1(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedwrappy@1.0.2(transitive)