@or-sdk/discovery 1.0.1-377.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/dist/cjs/Discovery.js +116 -0
- package/dist/cjs/Discovery.js.map +1 -0
- package/dist/cjs/constants.js +19 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/convertUrlsResult.js +10 -0
- package/dist/cjs/utils/convertUrlsResult.js.map +1 -0
- package/dist/cjs/utils/index.js +9 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/esm/Discovery.js +41 -0
- package/dist/esm/Discovery.js.map +1 -0
- package/dist/esm/constants.js +16 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/convertUrlsResult.js +8 -0
- package/dist/esm/utils/convertUrlsResult.js.map +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/Discovery.d.ts +9 -0
- package/dist/types/constants.d.ts +14 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/types.d.ts +9 -0
- package/dist/types/utils/convertUrlsResult.d.ts +4 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +28 -0
- package/src/Discovery.ts +60 -0
- package/src/constants.ts +14 -0
- package/src/index.ts +2 -0
- package/src/types.ts +18 -0
- package/src/utils/convertUrlsResult.ts +11 -0
- package/src/utils/index.ts +5 -0
- package/tsconfig.esm.json +9 -0
- package/tsconfig.json +7 -0
- package/tsconfig.types.json +9 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
54
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
55
|
+
if (ar || !(i in from)) {
|
|
56
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
57
|
+
ar[i] = from[i];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
61
|
+
};
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.Discovery = void 0;
|
|
64
|
+
var base_1 = require("@or-sdk/base");
|
|
65
|
+
var utils_1 = require("./utils");
|
|
66
|
+
var Discovery = (function (_super) {
|
|
67
|
+
__extends(Discovery, _super);
|
|
68
|
+
function Discovery(_a) {
|
|
69
|
+
var token = _a.token, discoveryUrl = _a.discoveryUrl;
|
|
70
|
+
var _this = _super.call(this, {
|
|
71
|
+
token: token,
|
|
72
|
+
serviceUrl: discoveryUrl,
|
|
73
|
+
serviceKey: '',
|
|
74
|
+
}) || this;
|
|
75
|
+
_this.route = "api/".concat(base_1.VERSION);
|
|
76
|
+
return _this;
|
|
77
|
+
}
|
|
78
|
+
Discovery.prototype.getServiceUrl = function (serviceName) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var url;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0: return [4, this.callApi({
|
|
84
|
+
method: 'GET',
|
|
85
|
+
route: this.route,
|
|
86
|
+
params: {
|
|
87
|
+
serviceName: serviceName,
|
|
88
|
+
},
|
|
89
|
+
})];
|
|
90
|
+
case 1:
|
|
91
|
+
url = (_a.sent()).url;
|
|
92
|
+
return [2, url];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
Discovery.prototype.getServiceUrls = function (serviceNames) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
+
var uniqNames, resArr;
|
|
100
|
+
var _this = this;
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
switch (_a.label) {
|
|
103
|
+
case 0:
|
|
104
|
+
uniqNames = __spreadArray([], new Set(serviceNames), true);
|
|
105
|
+
return [4, Promise.all(uniqNames.map(function (serviceName) { return _this.getServiceUrl(serviceName); }))];
|
|
106
|
+
case 1:
|
|
107
|
+
resArr = _a.sent();
|
|
108
|
+
return [2, (0, utils_1.convertUrlsResult)(uniqNames, resArr)];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
return Discovery;
|
|
114
|
+
}(base_1.Base));
|
|
115
|
+
exports.Discovery = Discovery;
|
|
116
|
+
//# sourceMappingURL=Discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Discovery.js","sourceRoot":"","sources":["../../src/Discovery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAuE;AAGvE,iCAA4C;AAS5C;IAA+B,6BAAI;IASjC,mBAAY,EAAwC;YAAtC,KAAK,WAAA,EAAE,YAAY,kBAAA;QAAjC,YACE,kBAAM;YACJ,KAAK,EAAE,KAAM;YACb,UAAU,EAAE,YAAY;YACxB,UAAU,EAAE,EAAE;SACf,CAAC,SACH;QAdgB,WAAK,GAAG,cAAO,cAAO,CAAE,CAAC;;IAc1C,CAAC;IAQY,iCAAa,GAA1B,UAA2B,WAAuB;;;;;4BAChC,WAAM,IAAI,CAAC,OAAO,CAA2B;4BAC3D,MAAM,EAAE,KAAK;4BACb,KAAK,EAAE,IAAI,CAAC,KAAK;4BACjB,MAAM,EAAE;gCACN,WAAW,aAAA;6BACZ;yBACF,CAAC,EAAA;;wBANM,GAAG,GAAK,CAAA,SAMd,CAAA,IANS;wBAQX,WAAO,GAAG,EAAC;;;;KACZ;IAQY,kCAAc,GAA3B,UAA4B,YAA0B;;;;;;;wBAC9C,SAAS,qBAAO,IAAI,GAAG,CAAC,YAAY,CAAiC,OAAC,CAAC;wBAC9D,WAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,UAAA,WAAW,IAAI,OAAA,KAAI,CAAC,aAAa,CAAC,WAAW,CAAC,EAA/B,CAA+B,CAAC,CAAC,EAAA;;wBAAzF,MAAM,GAAG,SAAgF;wBAE/F,WAAO,IAAA,yBAAiB,EAAC,SAAS,EAAE,MAAM,CAAC,EAAC;;;;KAC7C;IACH,gBAAC;AAAD,CAAC,AA/CD,CAA+B,WAAI,GA+ClC;AA/CY,8BAAS"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serviceKey = void 0;
|
|
4
|
+
var serviceKey;
|
|
5
|
+
(function (serviceKey) {
|
|
6
|
+
serviceKey["data-hub"] = "data-hub";
|
|
7
|
+
serviceKey["deployer"] = "deployer";
|
|
8
|
+
serviceKey["event-manager"] = "event-manager";
|
|
9
|
+
serviceKey["graphdb"] = "graphdb";
|
|
10
|
+
serviceKey["hitl-api"] = "hitl-api";
|
|
11
|
+
serviceKey["nlu-api"] = "nlu-api";
|
|
12
|
+
serviceKey["pgsql"] = "pgsql";
|
|
13
|
+
serviceKey["sdk-api"] = "sdk-api";
|
|
14
|
+
serviceKey["store-api"] = "store-api";
|
|
15
|
+
serviceKey["tables-api"] = "tables-api";
|
|
16
|
+
serviceKey["tickets-api"] = "tickets-api";
|
|
17
|
+
serviceKey["users-api"] = "users-api";
|
|
18
|
+
})(serviceKey = exports.serviceKey || (exports.serviceKey = {}));
|
|
19
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAaX;AAbD,WAAY,UAAU;IACpB,mCAAuB,CAAA;IACvB,mCAAqB,CAAA;IACrB,6CAAiC,CAAA;IACjC,iCAAmB,CAAA;IACnB,mCAAuB,CAAA;IACvB,iCAAqB,CAAA;IACrB,6BAAe,CAAA;IACf,iCAAqB,CAAA;IACrB,qCAAyB,CAAA;IACzB,uCAA2B,CAAA;IAC3B,yCAA6B,CAAA;IAC7B,qCAAyB,CAAA;AAC3B,CAAC,EAbW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAarB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Discovery = void 0;
|
|
18
|
+
var Discovery_1 = require("./Discovery");
|
|
19
|
+
Object.defineProperty(exports, "Discovery", { enumerable: true, get: function () { return Discovery_1.Discovery; } });
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function convertUrlsResult(serviceKeysArr, urlsArr) {
|
|
4
|
+
return serviceKeysArr.reduce(function (acc, key, i) {
|
|
5
|
+
acc[key] = urlsArr[i];
|
|
6
|
+
return acc;
|
|
7
|
+
}, {});
|
|
8
|
+
}
|
|
9
|
+
exports.default = convertUrlsResult;
|
|
10
|
+
//# sourceMappingURL=convertUrlsResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertUrlsResult.js","sourceRoot":"","sources":["../../../src/utils/convertUrlsResult.ts"],"names":[],"mappings":";;AAGA,SAAS,iBAAiB,CAAC,cAA4B,EAAE,OAAiB;IACxE,OAAO,cAAc,CAAC,MAAM,CAAC,UAAC,GAAyB,EAAE,GAAe,EAAE,CAAC;QACzE,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAA0B,CAAC,CAAC;AACjC,CAAC;AAED,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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.convertUrlsResult = void 0;
|
|
7
|
+
var convertUrlsResult_1 = require("./convertUrlsResult");
|
|
8
|
+
Object.defineProperty(exports, "convertUrlsResult", { enumerable: true, get: function () { return __importDefault(convertUrlsResult_1).default; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;AAIA,yDAAmE;AAA1D,uIAAA,OAAO,OAAqB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Base, VERSION } from '@or-sdk/base';
|
|
11
|
+
import { convertUrlsResult } from './utils';
|
|
12
|
+
export class Discovery extends Base {
|
|
13
|
+
constructor({ token, discoveryUrl }) {
|
|
14
|
+
super({
|
|
15
|
+
token: token,
|
|
16
|
+
serviceUrl: discoveryUrl,
|
|
17
|
+
serviceKey: '',
|
|
18
|
+
});
|
|
19
|
+
this.route = `api/${VERSION}`;
|
|
20
|
+
}
|
|
21
|
+
getServiceUrl(serviceName) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const { url } = yield this.callApi({
|
|
24
|
+
method: 'GET',
|
|
25
|
+
route: this.route,
|
|
26
|
+
params: {
|
|
27
|
+
serviceName,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return url;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
getServiceUrls(serviceNames) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const uniqNames = [...new Set(serviceNames)];
|
|
36
|
+
const resArr = yield Promise.all(uniqNames.map(serviceName => this.getServiceUrl(serviceName)));
|
|
37
|
+
return convertUrlsResult(uniqNames, resArr);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=Discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Discovery.js","sourceRoot":"","sources":["../../src/Discovery.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAA4B,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAS5C,MAAM,OAAO,SAAU,SAAQ,IAAI;IASjC,YAAY,EAAE,KAAK,EAAE,YAAY,EAAmB;QAClD,KAAK,CAAC;YACJ,KAAK,EAAE,KAAM;YACb,UAAU,EAAE,YAAY;YACxB,UAAU,EAAE,EAAE;SACf,CAAC,CAAC;QAbY,UAAK,GAAG,OAAO,OAAO,EAAE,CAAC;IAc1C,CAAC;IAQY,aAAa,CAAC,WAAuB;;YAChD,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAA2B;gBAC3D,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE;oBACN,WAAW;iBACZ;aACF,CAAC,CAAC;YAEH,OAAO,GAAG,CAAC;QACb,CAAC;KAAA;IAQY,cAAc,CAAC,YAA0B;;YACpD,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,YAAY,CAAiC,CAAC,CAAC;YAC7E,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAEhG,OAAO,iBAAiB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC9C,CAAC;KAAA;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var serviceKey;
|
|
2
|
+
(function (serviceKey) {
|
|
3
|
+
serviceKey["data-hub"] = "data-hub";
|
|
4
|
+
serviceKey["deployer"] = "deployer";
|
|
5
|
+
serviceKey["event-manager"] = "event-manager";
|
|
6
|
+
serviceKey["graphdb"] = "graphdb";
|
|
7
|
+
serviceKey["hitl-api"] = "hitl-api";
|
|
8
|
+
serviceKey["nlu-api"] = "nlu-api";
|
|
9
|
+
serviceKey["pgsql"] = "pgsql";
|
|
10
|
+
serviceKey["sdk-api"] = "sdk-api";
|
|
11
|
+
serviceKey["store-api"] = "store-api";
|
|
12
|
+
serviceKey["tables-api"] = "tables-api";
|
|
13
|
+
serviceKey["tickets-api"] = "tickets-api";
|
|
14
|
+
serviceKey["users-api"] = "users-api";
|
|
15
|
+
})(serviceKey || (serviceKey = {}));
|
|
16
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAaX;AAbD,WAAY,UAAU;IACpB,mCAAuB,CAAA;IACvB,mCAAqB,CAAA;IACrB,6CAAiC,CAAA;IACjC,iCAAmB,CAAA;IACnB,mCAAuB,CAAA;IACvB,iCAAqB,CAAA;IACrB,6BAAe,CAAA;IACf,iCAAqB,CAAA;IACrB,qCAAyB,CAAA;IACzB,uCAA2B,CAAA;IAC3B,yCAA6B,CAAA;IAC7B,qCAAyB,CAAA;AAC3B,CAAC,EAbW,UAAU,KAAV,UAAU,QAarB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertUrlsResult.js","sourceRoot":"","sources":["../../../src/utils/convertUrlsResult.ts"],"names":[],"mappings":"AAGA,SAAS,iBAAiB,CAAC,cAA4B,EAAE,OAAiB;IACxE,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,GAAyB,EAAE,GAAe,EAAE,CAAC,EAAE,EAAE;QAC7E,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAA0B,CAAC,CAAC;AACjC,CAAC;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Base } from '@or-sdk/base';
|
|
2
|
+
import { DiscoveryConfig, GetServiceUrlsResult } from './types';
|
|
3
|
+
import { serviceKey } from './constants';
|
|
4
|
+
export declare class Discovery extends Base {
|
|
5
|
+
private readonly route;
|
|
6
|
+
constructor({ token, discoveryUrl }: DiscoveryConfig);
|
|
7
|
+
getServiceUrl(serviceName: serviceKey): Promise<string>;
|
|
8
|
+
getServiceUrls(serviceNames: serviceKey[]): Promise<GetServiceUrlsResult>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum serviceKey {
|
|
2
|
+
'data-hub' = "data-hub",
|
|
3
|
+
deployer = "deployer",
|
|
4
|
+
'event-manager' = "event-manager",
|
|
5
|
+
graphdb = "graphdb",
|
|
6
|
+
'hitl-api' = "hitl-api",
|
|
7
|
+
'nlu-api' = "nlu-api",
|
|
8
|
+
pgsql = "pgsql",
|
|
9
|
+
'sdk-api' = "sdk-api",
|
|
10
|
+
'store-api' = "store-api",
|
|
11
|
+
'tables-api' = "tables-api",
|
|
12
|
+
'tickets-api' = "tickets-api",
|
|
13
|
+
'users-api' = "users-api"
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as convertUrlsResult } from './convertUrlsResult';
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.1-377.0",
|
|
3
|
+
"name": "@or-sdk/discovery",
|
|
4
|
+
"main": "dist/cjs/index.js",
|
|
5
|
+
"module": "dist/esm/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "npm run clean && concurrently \"npm run build:cjs\" \"npm run build:esm\" \"npm run build:types\"",
|
|
9
|
+
"build:watch": "concurrently -r --hide 1,2 \"npm run build:watch:cjs\" \"npm run build:watch:esm\" \"npm run build:watch:types\"",
|
|
10
|
+
"build:cjs": "tsc --project tsconfig.json",
|
|
11
|
+
"build:watch:cjs": "tsc --project tsconfig.json -w",
|
|
12
|
+
"build:esm": "tsc --project tsconfig.esm.json",
|
|
13
|
+
"build:watch:esm": "tsc --project tsconfig.esm.json -w",
|
|
14
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
15
|
+
"build:watch:types": "tsc --project tsconfig.types.json -w",
|
|
16
|
+
"clean": "rm -rf ./dist"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"concurrently": "^6.4.0",
|
|
20
|
+
"typescript": "^4.4.4"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@or-sdk/base": "^0.23.1"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/Discovery.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Base, ServiceDiscoveryResponse, VERSION } from '@or-sdk/base';
|
|
2
|
+
import { DiscoveryConfig, GetServiceUrlsResult } from './types';
|
|
3
|
+
import { serviceKey } from './constants';
|
|
4
|
+
import { convertUrlsResult } from './utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* OneReach Discovery service client
|
|
8
|
+
* ## Installation:
|
|
9
|
+
* ```
|
|
10
|
+
* $ npm i @or-sdk/discovery
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export class Discovery extends Base {
|
|
14
|
+
private readonly route = `api/${VERSION}`;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { Discovery } from '@or-sdk/discovery'
|
|
19
|
+
* const discovery = new Discovery({token: 'my-account-token-string', discoveryUrl: 'http://example.discovery/endpoint'});
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
constructor({ token, discoveryUrl }: DiscoveryConfig) {
|
|
23
|
+
super({
|
|
24
|
+
token: token!,
|
|
25
|
+
serviceUrl: discoveryUrl,
|
|
26
|
+
serviceKey: '',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get service url
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const result = await discovery.getServiceUrl('serviceName');
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
public async getServiceUrl(serviceName: serviceKey): Promise<string> {
|
|
37
|
+
const { url } = await this.callApi<ServiceDiscoveryResponse>({
|
|
38
|
+
method: 'GET',
|
|
39
|
+
route: this.route,
|
|
40
|
+
params: {
|
|
41
|
+
serviceName,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return url;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get multiple service urls
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const result = await discovery.getServiceUrls(['serviceName']);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
public async getServiceUrls(serviceNames: serviceKey[]): Promise<GetServiceUrlsResult> {
|
|
55
|
+
const uniqNames = [...new Set(serviceNames) as unknown as Array<serviceKey>];
|
|
56
|
+
const resArr = await Promise.all(uniqNames.map(serviceName => this.getServiceUrl(serviceName)));
|
|
57
|
+
|
|
58
|
+
return convertUrlsResult(uniqNames, resArr);
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export enum serviceKey {
|
|
2
|
+
'data-hub' = 'data-hub',
|
|
3
|
+
deployer = 'deployer',
|
|
4
|
+
'event-manager' = 'event-manager',
|
|
5
|
+
graphdb = 'graphdb',
|
|
6
|
+
'hitl-api' = 'hitl-api',
|
|
7
|
+
'nlu-api' = 'nlu-api',
|
|
8
|
+
pgsql = 'pgsql',
|
|
9
|
+
'sdk-api' = 'sdk-api',
|
|
10
|
+
'store-api' = 'store-api',
|
|
11
|
+
'tables-api' = 'tables-api',
|
|
12
|
+
'tickets-api' = 'tickets-api',
|
|
13
|
+
'users-api' = 'users-api',
|
|
14
|
+
}
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Token } from '@or-sdk/base';
|
|
2
|
+
import { serviceKey } from './constants';
|
|
3
|
+
|
|
4
|
+
export type DiscoveryConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* token
|
|
7
|
+
*/
|
|
8
|
+
token?: Token;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Url of OneReach service discovery api
|
|
12
|
+
*/
|
|
13
|
+
discoveryUrl: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type GetServiceUrlsResult = {
|
|
17
|
+
[key in serviceKey]: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GetServiceUrlsResult } from '../types';
|
|
2
|
+
import { serviceKey } from '../constants';
|
|
3
|
+
|
|
4
|
+
function convertUrlsResult(serviceKeysArr: serviceKey[], urlsArr: string[]): GetServiceUrlsResult {
|
|
5
|
+
return serviceKeysArr.reduce((acc: GetServiceUrlsResult, key: serviceKey, i) => {
|
|
6
|
+
acc[key] = urlsArr[i];
|
|
7
|
+
return acc;
|
|
8
|
+
}, {} as GetServiceUrlsResult);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default convertUrlsResult;
|
package/tsconfig.json
ADDED