@or-sdk/bots 0.7.0 → 0.11.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/Bots.js +18 -28
- package/dist/cjs/Bots.js.map +1 -1
- package/dist/cjs/constants.js +1 -2
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/Bots.js +10 -10
- package/dist/esm/Bots.js.map +1 -1
- package/dist/esm/constants.js +0 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/types/Bots.d.ts +3 -2
- package/dist/types/constants.d.ts +0 -1
- package/package.json +4 -4
- package/src/Bots.ts +10 -10
- package/src/constants.ts +0 -2
package/dist/cjs/Bots.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
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
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -52,23 +37,28 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
52
37
|
};
|
|
53
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
39
|
exports.Bots = void 0;
|
|
55
|
-
var base_1 = require("@or-sdk/base");
|
|
56
40
|
var data_hub_1 = require("@or-sdk/data-hub");
|
|
57
41
|
var constants_1 = require("./constants");
|
|
58
|
-
var Bots = (function (
|
|
59
|
-
__extends(Bots, _super);
|
|
42
|
+
var Bots = (function () {
|
|
60
43
|
function Bots(params) {
|
|
61
|
-
var _this = this;
|
|
62
44
|
var token = params.token, discoveryUrl = params.discoveryUrl;
|
|
63
|
-
|
|
45
|
+
this.dataHub = new data_hub_1.DataHub({
|
|
64
46
|
token: token,
|
|
65
47
|
discoveryUrl: discoveryUrl,
|
|
66
|
-
|
|
67
|
-
requestAccountId: true,
|
|
68
|
-
}) || this;
|
|
69
|
-
_this.dataHub = new data_hub_1.DataHub({ token: token, discoveryUrl: discoveryUrl });
|
|
70
|
-
return _this;
|
|
48
|
+
});
|
|
71
49
|
}
|
|
50
|
+
Bots.prototype.init = function () {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0: return [4, this.dataHub.init()];
|
|
55
|
+
case 1:
|
|
56
|
+
_a.sent();
|
|
57
|
+
return [2];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
72
62
|
Bots.prototype.listBots = function () {
|
|
73
63
|
return __awaiter(this, void 0, void 0, function () {
|
|
74
64
|
var variables, data;
|
|
@@ -98,7 +88,7 @@ var Bots = (function (_super) {
|
|
|
98
88
|
return __generator(this, function (_a) {
|
|
99
89
|
switch (_a.label) {
|
|
100
90
|
case 0:
|
|
101
|
-
route = "/v2/".concat(this.currentAccountId, "/bot/").concat(id);
|
|
91
|
+
route = "/v2/".concat(this.dataHub.currentAccountId, "/bot/").concat(id);
|
|
102
92
|
params = {
|
|
103
93
|
includeDeleted: false,
|
|
104
94
|
includeExisting: true,
|
|
@@ -119,7 +109,7 @@ var Bots = (function (_super) {
|
|
|
119
109
|
return __generator(this, function (_a) {
|
|
120
110
|
switch (_a.label) {
|
|
121
111
|
case 0:
|
|
122
|
-
route = "/v2/".concat(this.currentAccountId, "/bot/").concat(source.id ? source.id : 'new');
|
|
112
|
+
route = "/v2/".concat(this.dataHub.currentAccountId, "/bot/").concat(source.id ? source.id : 'new');
|
|
123
113
|
data = {
|
|
124
114
|
bot: source,
|
|
125
115
|
};
|
|
@@ -164,6 +154,6 @@ var Bots = (function (_super) {
|
|
|
164
154
|
});
|
|
165
155
|
};
|
|
166
156
|
return Bots;
|
|
167
|
-
}(
|
|
157
|
+
}());
|
|
168
158
|
exports.Bots = Bots;
|
|
169
159
|
//# sourceMappingURL=Bots.js.map
|
package/dist/cjs/Bots.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA2F;AAE3F,yCAAoE;AASpE;IAUE,cAAY,MAAkB;QACpB,IAAA,KAAK,GAAmB,MAAM,MAAzB,EAAE,YAAY,GAAK,MAAM,aAAX,CAAY;QAEvC,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAO,CAAC;YACzB,KAAK,OAAA;YACL,YAAY,cAAA;SACb,CAAC,CAAC;IACL,CAAC;IAEK,mBAAI,GAAV;;;;4BACE,WAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAA;;wBAAzB,SAAyB,CAAC;;;;;KAC3B;IAQY,uBAAQ,GAArB;;;;gBACQ,SAAS,GAAG;oBAChB,MAAM,EAAE,uBAAW;oBACnB,MAAM,EAAE;wBACN,WAAW,EAAE,EAAE;wBACf,cAAc,EAAE,KAAK;wB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;6BAChB;yBACF,CAAC;wBAEI,IAAI,GAAG;4BACX,aAAa,EAAE,mBAAmB;4BAClC,KAAK,EAAE,wBAAY;4BACnB,SAAS,WAAA;yBACV,CAAC;wBAEqD,WAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAA6C;gCAChI,MAAM,EAAE,MAAM;gCACd,KAAK,EAAE,UAAU;gCACjB,IAAI,MAAA;6BACL,CAAC,EAAA;;wBAJmC,SAAS,GAAS,CAAA,SAIrD,CAAA,iCAJ4C;wBAM9C,WAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,EAAC;;;;KAC1C;IAEH,WAAC;AAAD,CAAC,AA3HD,IA2HC;AA3HY,oBAAI"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ENTITY_NAME = exports.QUERY_DELETE = exports.QUERY_LIST =
|
|
4
|
-
exports.SERVICE_KEY = 'data-hub';
|
|
3
|
+
exports.ENTITY_NAME = exports.QUERY_DELETE = exports.QUERY_LIST = void 0;
|
|
5
4
|
exports.QUERY_LIST = "query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on Bot {\n id\n data {\n label\n color\n description\n iconUrl\n password\n deploy {\n logsTTL\n }\n }\n tags\n dateModified\n }\n }\n last\n }\n}";
|
|
6
5
|
exports.QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
7
6
|
exports.ENTITY_NAME = 'BOT';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,ibAqBxB,CAAC;AAEU,QAAA,YAAY,GAAG,yLAM1B,CAAC;AAEU,QAAA,WAAW,GAAG,KAAK,CAAC"}
|
package/dist/esm/Bots.js
CHANGED
|
@@ -7,20 +7,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { Base } from '@or-sdk/base';
|
|
11
10
|
import { DataHub } from '@or-sdk/data-hub';
|
|
12
|
-
import {
|
|
13
|
-
export class Bots
|
|
11
|
+
import { QUERY_LIST, QUERY_DELETE, ENTITY_NAME } from './constants';
|
|
12
|
+
export class Bots {
|
|
14
13
|
constructor(params) {
|
|
15
14
|
const { token, discoveryUrl } = params;
|
|
16
|
-
|
|
15
|
+
this.dataHub = new DataHub({
|
|
17
16
|
token,
|
|
18
17
|
discoveryUrl,
|
|
19
|
-
serviceKey: SERVICE_KEY,
|
|
20
|
-
requestAccountId: true,
|
|
21
18
|
});
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
}
|
|
20
|
+
init() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
yield this.dataHub.init();
|
|
23
|
+
});
|
|
24
24
|
}
|
|
25
25
|
listBots() {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -44,7 +44,7 @@ export class Bots extends Base {
|
|
|
44
44
|
}
|
|
45
45
|
getBot(id) {
|
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const route = `/v2/${this.currentAccountId}/bot/${id}`;
|
|
47
|
+
const route = `/v2/${this.dataHub.currentAccountId}/bot/${id}`;
|
|
48
48
|
const params = {
|
|
49
49
|
includeDeleted: false,
|
|
50
50
|
includeExisting: true,
|
|
@@ -58,7 +58,7 @@ export class Bots extends Base {
|
|
|
58
58
|
}
|
|
59
59
|
saveBot(source) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const route = `/v2/${this.currentAccountId}/bot/${source.id ? source.id : 'new'}`;
|
|
61
|
+
const route = `/v2/${this.dataHub.currentAccountId}/bot/${source.id ? source.id : 'new'}`;
|
|
62
62
|
const data = {
|
|
63
63
|
bot: source,
|
|
64
64
|
};
|
package/dist/esm/Bots.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAkD,MAAM,kBAAkB,CAAC;AAE3F,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AASpE,MAAM,OAAO,IAAI;IAUf,YAAY,MAAkB;QAC5B,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;QAEvC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC;YACzB,KAAK;YACL,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAEK,IAAI;;YACR,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAC5B,CAAC;KAAA;IAQY,QAAQ;;YACnB,MAAM,SAAS,GAAG;gBAChB,MAAM,EAAE,WAAW;gBACnB,MAAM,EAAE;oBACN,WAAW,EAAE,EAAE;oBACf,cAAc,EAAE,KAAK;oBACrB,eAAe,EAAE,IAAI;oBACrB,KAAK,EAAE,EAAE;iBACV;gBACD,OAAO,EAAE,KAAK;aACf,CAAC;YAEF,MAAM,IAAI,GAAG;gBACX,aAAa,EAAE,MAAM;gBACrB,KAAK,EAAE,UAAU;gBACjB,SAAS;aACV,CAAC;YAEF,OAAO,IAAI,CAAC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AAK,EAAE,UAAU;gBACjB,IAAI;aACL,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;KAAA;CAEF"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;EAqBxB,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC"}
|
package/dist/types/Bots.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { List } from '@or-sdk/base';
|
|
2
2
|
import { GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
|
|
3
3
|
import { BotsConfig, Bot } from './types';
|
|
4
|
-
export declare class Bots
|
|
4
|
+
export declare class Bots {
|
|
5
5
|
private readonly dataHub;
|
|
6
6
|
constructor(params: BotsConfig);
|
|
7
|
+
init(): Promise<void>;
|
|
7
8
|
listBots(): Promise<List<Bot>>;
|
|
8
9
|
getBot(id: string): Promise<Bot>;
|
|
9
10
|
saveBot(source: Bot): Promise<Bot>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const SERVICE_KEY = "data-hub";
|
|
2
1
|
export declare const QUERY_LIST = "query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on Bot {\n id\n data {\n label\n color\n description\n iconUrl\n password\n deploy {\n logsTTL\n }\n }\n tags\n dateModified\n }\n }\n last\n }\n}";
|
|
3
2
|
export declare const QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
4
3
|
export declare const ENTITY_NAME = "BOT";
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.11.0",
|
|
3
3
|
"name": "@or-sdk/bots",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@or-sdk/base": "^0.
|
|
27
|
-
"@or-sdk/data-hub": "^0.
|
|
26
|
+
"@or-sdk/base": "^0.11.0",
|
|
27
|
+
"@or-sdk/data-hub": "^0.11.0"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "69c6cabbf681fe0fb9616058d58e89b0526e8f77"
|
|
30
30
|
}
|
package/src/Bots.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { List } from '@or-sdk/base';
|
|
2
2
|
import { DataHub, GraphqlResponse, GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
|
|
3
3
|
import { BotsConfig, Bot } from './types';
|
|
4
|
-
import {
|
|
4
|
+
import { QUERY_LIST, QUERY_DELETE, ENTITY_NAME } from './constants';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* OneReach Bots service client
|
|
@@ -10,27 +10,27 @@ import { SERVICE_KEY, QUERY_LIST, QUERY_DELETE, ENTITY_NAME } from './constants'
|
|
|
10
10
|
* $ npm i @or-sdk/bots
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export class Bots
|
|
13
|
+
export class Bots {
|
|
14
14
|
private readonly dataHub: DataHub;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* ```typescript
|
|
18
18
|
* import { Bots } from '@or-sdk/bots'
|
|
19
19
|
* const bots = new Bots({token: 'my-account-token-string', discoveryUrl: 'http://example.bots/endpoint'});
|
|
20
|
+
* await bots.init();
|
|
20
21
|
* ```
|
|
21
22
|
*/
|
|
22
23
|
constructor(params: BotsConfig) {
|
|
23
24
|
const { token, discoveryUrl } = params;
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
this.dataHub = new DataHub({
|
|
26
27
|
token,
|
|
27
28
|
discoveryUrl,
|
|
28
|
-
serviceKey: SERVICE_KEY,
|
|
29
|
-
requestAccountId: true,
|
|
30
29
|
});
|
|
30
|
+
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
async init() {
|
|
33
|
+
await this.dataHub.init();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -67,7 +67,7 @@ export class Bots extends Base {
|
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
69
|
public async getBot(id: string): Promise<Bot> {
|
|
70
|
-
const route = `/v2/${this.currentAccountId}/bot/${id}`;
|
|
70
|
+
const route = `/v2/${this.dataHub.currentAccountId}/bot/${id}`;
|
|
71
71
|
|
|
72
72
|
const params = {
|
|
73
73
|
includeDeleted: false,
|
|
@@ -90,7 +90,7 @@ export class Bots extends Base {
|
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
92
|
public async saveBot(source: Bot): Promise<Bot> {
|
|
93
|
-
const route = `/v2/${this.currentAccountId}/bot/${source.id ? source.id : 'new'}`;
|
|
93
|
+
const route = `/v2/${this.dataHub.currentAccountId}/bot/${source.id ? source.id : 'new'}`;
|
|
94
94
|
|
|
95
95
|
const data = {
|
|
96
96
|
bot: source,
|