@or-sdk/flows 0.6.0 → 0.9.1
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/Flows.js +27 -30
- package/dist/cjs/Flows.js.map +1 -1
- package/dist/cjs/constants.js +2 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/Flows.js +20 -14
- package/dist/esm/Flows.js.map +1 -1
- package/dist/esm/constants.js +0 -3
- package/dist/esm/constants.js.map +1 -1
- package/dist/types/Flows.d.ts +7 -6
- package/dist/types/constants.d.ts +1 -2
- package/dist/types/types.d.ts +1 -2
- package/package.json +5 -5
- package/src/Flows.ts +26 -23
- package/src/constants.ts +0 -4
- package/src/types.ts +1 -3
package/dist/cjs/Flows.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) {
|
|
@@ -65,21 +50,33 @@ var base_1 = require("@or-sdk/base");
|
|
|
65
50
|
var data_hub_1 = require("@or-sdk/data-hub");
|
|
66
51
|
var deployer_1 = require("@or-sdk/deployer");
|
|
67
52
|
var constants_1 = require("./constants");
|
|
68
|
-
var Flows = (function (
|
|
69
|
-
__extends(Flows, _super);
|
|
53
|
+
var Flows = (function () {
|
|
70
54
|
function Flows(params) {
|
|
71
|
-
var _this = this;
|
|
72
55
|
var discoveryUrl = params.discoveryUrl, token = params.token;
|
|
73
|
-
|
|
56
|
+
this.dataHub = new data_hub_1.DataHub({
|
|
57
|
+
token: token,
|
|
74
58
|
discoveryUrl: discoveryUrl,
|
|
59
|
+
});
|
|
60
|
+
this.deployer = new deployer_1.Deployer({
|
|
75
61
|
token: token,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}) || this;
|
|
79
|
-
_this.dataHub = new data_hub_1.DataHub({ token: token, discoveryUrl: discoveryUrl });
|
|
80
|
-
_this.deployer = new deployer_1.Deployer({ token: token, discoveryUrl: discoveryUrl });
|
|
81
|
-
return _this;
|
|
62
|
+
discoveryUrl: discoveryUrl,
|
|
63
|
+
});
|
|
82
64
|
}
|
|
65
|
+
Flows.prototype.init = function () {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
switch (_a.label) {
|
|
69
|
+
case 0: return [4, Promise.all([
|
|
70
|
+
this.dataHub.init(),
|
|
71
|
+
this.deployer.init(),
|
|
72
|
+
])];
|
|
73
|
+
case 1:
|
|
74
|
+
_a.sent();
|
|
75
|
+
return [2];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
83
80
|
Flows.prototype.listFlows = function (botId) {
|
|
84
81
|
return __awaiter(this, void 0, void 0, function () {
|
|
85
82
|
var params, route, result, flowList, query;
|
|
@@ -92,7 +89,7 @@ var Flows = (function (_super) {
|
|
|
92
89
|
projection: JSON.stringify(['id', 'version', 'botId', 'data.label', 'data.color', 'data.description', 'data.isHidden', 'tags', 'dateModified']),
|
|
93
90
|
query: undefined,
|
|
94
91
|
};
|
|
95
|
-
route = "/v2/" + this.currentAccountId + "/flows";
|
|
92
|
+
route = "/v2/" + this.dataHub.currentAccountId + "/flows";
|
|
96
93
|
flowList = [];
|
|
97
94
|
query = { botId: botId ? botId : undefined };
|
|
98
95
|
_a.label = 1;
|
|
@@ -111,7 +108,7 @@ var Flows = (function (_super) {
|
|
|
111
108
|
case 3:
|
|
112
109
|
if (result.last) return [3, 1];
|
|
113
110
|
_a.label = 4;
|
|
114
|
-
case 4: return [2, flowList];
|
|
111
|
+
case 4: return [2, (0, base_1.makeList)(flowList)];
|
|
115
112
|
}
|
|
116
113
|
});
|
|
117
114
|
});
|
|
@@ -122,7 +119,7 @@ var Flows = (function (_super) {
|
|
|
122
119
|
return __generator(this, function (_a) {
|
|
123
120
|
switch (_a.label) {
|
|
124
121
|
case 0:
|
|
125
|
-
route = "/v2/" + this.currentAccountId + "/flow/" + id;
|
|
122
|
+
route = "/v2/" + this.dataHub.currentAccountId + "/flow/" + id;
|
|
126
123
|
params = {
|
|
127
124
|
includeDeleted: false,
|
|
128
125
|
includeExisting: true,
|
|
@@ -144,7 +141,7 @@ var Flows = (function (_super) {
|
|
|
144
141
|
return __generator(this, function (_a) {
|
|
145
142
|
switch (_a.label) {
|
|
146
143
|
case 0:
|
|
147
|
-
route = "/v2/" + this.currentAccountId + "/flow/" + (source.id ? source.id : 'new');
|
|
144
|
+
route = "/v2/" + this.dataHub.currentAccountId + "/flow/" + (source.id ? source.id : 'new');
|
|
148
145
|
data = {
|
|
149
146
|
flow: source,
|
|
150
147
|
previousVersion: source.id ? source.version : undefined,
|
|
@@ -209,6 +206,6 @@ var Flows = (function (_super) {
|
|
|
209
206
|
});
|
|
210
207
|
};
|
|
211
208
|
return Flows;
|
|
212
|
-
}(
|
|
209
|
+
}());
|
|
213
210
|
exports.Flows = Flows;
|
|
214
211
|
//# sourceMappingURL=Flows.js.map
|
package/dist/cjs/Flows.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flows.js","sourceRoot":"","sources":["../../src/Flows.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Flows.js","sourceRoot":"","sources":["../../src/Flows.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA8C;AAC9C,6CAA2F;AAC3F,6CAAgH;AAEhH,yCAAwD;AASxD;IAUE,eAAY,MAAmB;QACrB,IAAA,YAAY,GAAY,MAAM,aAAlB,EAAE,KAAK,GAAK,MAAM,MAAX,CAAY;QAEvC,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAO,CAAC;YACzB,KAAK,OAAA;YACL,YAAY,cAAA;SACb,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC;YAC3B,KAAK,OAAA;YACL,YAAY,cAAA;SACb,CAAC,CAAC;IACL,CAAC;IAEK,oBAAI,GAAV;;;;4BACE,WAAM,OAAO,CAAC,GAAG,CAAC;4BAChB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;4BACnB,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;yBACrB,CAAC,EAAA;;wBAHF,SAGE,CAAC;;;;;KACJ;IAUY,yBAAS,GAAtB,UAAuB,KAAc;;;;;;wBAC7B,MAAM,GAAG;4BACb,cAAc,EAAE,KAAK;4BACrB,eAAe,EAAE,IAAI;4BACrB,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;4BAC/I,KAAK,EAAE,SAAoB;yBAC5B,CAAC;wBAEI,KAAK,GAAG,SAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,WAAQ,CAAC;wBAGvD,QAA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Ac,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC,EAAC;;;KACtE;IAEH,YAAC;AAAD,CAAC,AAtKD,IAsKC;AAtKY,sBAAK"}
|
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 =
|
|
4
|
-
exports.
|
|
5
|
-
exports.QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n __typename\n }\n __typename\n }\n}";
|
|
3
|
+
exports.ENTITY_NAME = exports.QUERY_DELETE = void 0;
|
|
4
|
+
exports.QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
6
5
|
exports.ENTITY_NAME = 'FLOW';
|
|
7
6
|
//# sourceMappingURL=constants.js.map
|
|
@@ -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,YAAY,GAAG,yLAM1B,CAAC;AAEU,QAAA,WAAW,GAAG,MAAM,CAAC"}
|
package/dist/esm/Flows.js
CHANGED
|
@@ -7,23 +7,29 @@ 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 {
|
|
10
|
+
import { makeList } from '@or-sdk/base';
|
|
11
11
|
import { DataHub } from '@or-sdk/data-hub';
|
|
12
12
|
import { Deployer } from '@or-sdk/deployer';
|
|
13
|
-
import {
|
|
14
|
-
export class Flows
|
|
13
|
+
import { QUERY_DELETE, ENTITY_NAME } from './constants';
|
|
14
|
+
export class Flows {
|
|
15
15
|
constructor(params) {
|
|
16
16
|
const { discoveryUrl, token } = params;
|
|
17
|
-
|
|
17
|
+
this.dataHub = new DataHub({
|
|
18
|
+
token,
|
|
18
19
|
discoveryUrl,
|
|
20
|
+
});
|
|
21
|
+
this.deployer = new Deployer({
|
|
19
22
|
token,
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
discoveryUrl,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
init() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
yield Promise.all([
|
|
29
|
+
this.dataHub.init(),
|
|
30
|
+
this.deployer.init(),
|
|
31
|
+
]);
|
|
22
32
|
});
|
|
23
|
-
this.dataHub = new DataHub({ token,
|
|
24
|
-
discoveryUrl });
|
|
25
|
-
this.deployer = new Deployer({ token,
|
|
26
|
-
discoveryUrl });
|
|
27
33
|
}
|
|
28
34
|
listFlows(botId) {
|
|
29
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -33,7 +39,7 @@ export class Flows extends Base {
|
|
|
33
39
|
projection: JSON.stringify(['id', 'version', 'botId', 'data.label', 'data.color', 'data.description', 'data.isHidden', 'tags', 'dateModified']),
|
|
34
40
|
query: undefined,
|
|
35
41
|
};
|
|
36
|
-
const route = `/v2/${this.currentAccountId}/flows`;
|
|
42
|
+
const route = `/v2/${this.dataHub.currentAccountId}/flows`;
|
|
37
43
|
let result;
|
|
38
44
|
let flowList = [];
|
|
39
45
|
const query = { botId: botId ? botId : undefined };
|
|
@@ -47,12 +53,12 @@ export class Flows extends Base {
|
|
|
47
53
|
flowList = [...flowList, ...result.items];
|
|
48
54
|
query.last = result.last;
|
|
49
55
|
} while (result.last);
|
|
50
|
-
return flowList;
|
|
56
|
+
return makeList(flowList);
|
|
51
57
|
});
|
|
52
58
|
}
|
|
53
59
|
getFlow(id) {
|
|
54
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const route = `/v2/${this.currentAccountId}/flow/${id}`;
|
|
61
|
+
const route = `/v2/${this.dataHub.currentAccountId}/flow/${id}`;
|
|
56
62
|
const params = {
|
|
57
63
|
includeDeleted: false,
|
|
58
64
|
includeExisting: true,
|
|
@@ -67,7 +73,7 @@ export class Flows extends Base {
|
|
|
67
73
|
}
|
|
68
74
|
saveFlow(source) {
|
|
69
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const route = `/v2/${this.currentAccountId}/flow/${source.id ? source.id : 'new'}`;
|
|
76
|
+
const route = `/v2/${this.dataHub.currentAccountId}/flow/${source.id ? source.id : 'new'}`;
|
|
71
77
|
const data = {
|
|
72
78
|
flow: source,
|
|
73
79
|
previousVersion: source.id ? source.version : undefined,
|
package/dist/esm/Flows.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flows.js","sourceRoot":"","sources":["../../src/Flows.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Flows.js","sourceRoot":"","sources":["../../src/Flows.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAkD,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAsE,MAAM,kBAAkB,CAAC;AAEhH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AASxD,MAAM,OAAO,KAAK;IAUhB,YAAY,MAAmB;QAC7B,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAEvC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC;YACzB,KAAK;YACL,YAAY;SACb,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC;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AE,IAAI,EAAE,EAAE,iBAAiB,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAA6C;gBAChI,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,UAAU;gBACjB,IAAI;aACL,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;KAAA;IAQY,YAAY,CAAC,MAAY,EAAE,gBAAgB,GAAG,KAAK;;YAC9D,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC9D,CAAC;KAAA;IAQY,cAAc,CAAC,MAAY,EAAE,SAAiB,EAAE,YAAY,GAAG,KAAK;;YAC/E,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QACvE,CAAC;KAAA;CAEF"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
export const SERVICE_KEY = 'sdk-api';
|
|
2
1
|
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
3
2
|
deleteTemporarily(entity: $entity, data: $data) {
|
|
4
3
|
... on AsyncRequest {
|
|
5
4
|
requestId
|
|
6
|
-
__typename
|
|
7
5
|
}
|
|
8
|
-
__typename
|
|
9
6
|
}
|
|
10
7
|
}`;
|
|
11
8
|
export const ENTITY_NAME = 'FLOW';
|
|
@@ -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,YAAY,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC"}
|
package/dist/types/Flows.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { List } from '@or-sdk/base';
|
|
2
|
+
import { GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
|
|
3
3
|
import { Flow, PollingResultActivateSuccess, PollingResultDeactivateSuccess } from '@or-sdk/deployer';
|
|
4
|
-
import {
|
|
5
|
-
export declare class Flows
|
|
4
|
+
import { FlowsConfig } from './types';
|
|
5
|
+
export declare class Flows {
|
|
6
6
|
private readonly dataHub;
|
|
7
7
|
private readonly deployer;
|
|
8
8
|
constructor(params: FlowsConfig);
|
|
9
|
-
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
listFlows(botId?: string): Promise<List<Flow>>;
|
|
10
11
|
getFlow(id: string): Promise<Flow>;
|
|
11
12
|
saveFlow(source: Flow): Promise<Flow>;
|
|
12
|
-
deleteFlow(source: Flow, flowAlias?: string): Promise<
|
|
13
|
+
deleteFlow(source: Flow, flowAlias?: string): Promise<GraphqlResponseCheckExecution>;
|
|
13
14
|
activateFlow(source: Flow, interactiveDebug?: boolean): Promise<PollingResultActivateSuccess>;
|
|
14
15
|
deactivateFlow(source: Flow, flowAlias: string, deleteLambda?: boolean): Promise<PollingResultDeactivateSuccess>;
|
|
15
16
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n __typename\n }\n __typename\n }\n}";
|
|
1
|
+
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}";
|
|
3
2
|
export declare const ENTITY_NAME = "FLOW";
|
package/dist/types/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.9.1",
|
|
3
3
|
"name": "@or-sdk/flows",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@or-sdk/base": "^0.
|
|
27
|
-
"@or-sdk/data-hub": "^0.
|
|
28
|
-
"@or-sdk/deployer": "^0.
|
|
26
|
+
"@or-sdk/base": "^0.9.1",
|
|
27
|
+
"@or-sdk/data-hub": "^0.9.1",
|
|
28
|
+
"@or-sdk/deployer": "^0.9.1"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "19c2221d6f95694979b32f51d729771a558ef189"
|
|
31
31
|
}
|
package/src/Flows.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DataHub,
|
|
1
|
+
import { List, makeList } from '@or-sdk/base';
|
|
2
|
+
import { DataHub, GraphqlResponseCheckExecution, GraphqlResponse } from '@or-sdk/data-hub';
|
|
3
3
|
import { Deployer, Flow, PollingResultActivateSuccess, PollingResultDeactivateSuccess } from '@or-sdk/deployer';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
// import {} from './utils';
|
|
4
|
+
import { FlowsConfig, FlowListResponse } from './types';
|
|
5
|
+
import { QUERY_DELETE, ENTITY_NAME } from './constants';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* OneReach Flows service client
|
|
@@ -12,7 +11,7 @@ import { SERVICE_KEY, QUERY_DELETE, ENTITY_NAME } from './constants';
|
|
|
12
11
|
* $ npm i @or-sdk/flows
|
|
13
12
|
* ```
|
|
14
13
|
*/
|
|
15
|
-
export class Flows
|
|
14
|
+
export class Flows {
|
|
16
15
|
private readonly dataHub: DataHub;
|
|
17
16
|
private readonly deployer: Deployer;
|
|
18
17
|
|
|
@@ -25,17 +24,21 @@ export class Flows extends Base {
|
|
|
25
24
|
constructor(params: FlowsConfig) {
|
|
26
25
|
const { discoveryUrl, token } = params;
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
this.dataHub = new DataHub({
|
|
28
|
+
token,
|
|
29
29
|
discoveryUrl,
|
|
30
|
+
});
|
|
31
|
+
this.deployer = new Deployer({
|
|
30
32
|
token,
|
|
31
|
-
|
|
32
|
-
requestAccountId: true,
|
|
33
|
+
discoveryUrl,
|
|
33
34
|
});
|
|
35
|
+
}
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
async init() {
|
|
38
|
+
await Promise.all([
|
|
39
|
+
this.dataHub.init(),
|
|
40
|
+
this.deployer.init(),
|
|
41
|
+
]);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
/**
|
|
@@ -46,7 +49,7 @@ export class Flows extends Base {
|
|
|
46
49
|
* const flowsList = await flows.listFlows('bot-id');
|
|
47
50
|
* ```
|
|
48
51
|
*/
|
|
49
|
-
public async listFlows(botId?: string): Promise<
|
|
52
|
+
public async listFlows(botId?: string): Promise<List<Flow>> {
|
|
50
53
|
const params = {
|
|
51
54
|
includeDeleted: false,
|
|
52
55
|
includeExisting: true,
|
|
@@ -54,10 +57,10 @@ export class Flows extends Base {
|
|
|
54
57
|
query: undefined as unknown,
|
|
55
58
|
};
|
|
56
59
|
|
|
57
|
-
const route = `/v2/${this.currentAccountId}/flows`;
|
|
60
|
+
const route = `/v2/${this.dataHub.currentAccountId}/flows`;
|
|
58
61
|
|
|
59
62
|
let result: FlowListResponse;
|
|
60
|
-
let flowList:
|
|
63
|
+
let flowList: Flow[] = [];
|
|
61
64
|
const query: { botId?: string; last?: string; } = { botId: botId ? botId : undefined };
|
|
62
65
|
|
|
63
66
|
do {
|
|
@@ -74,7 +77,7 @@ export class Flows extends Base {
|
|
|
74
77
|
|
|
75
78
|
} while (result.last);
|
|
76
79
|
|
|
77
|
-
return flowList;
|
|
80
|
+
return makeList<Flow>(flowList);
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
/**
|
|
@@ -84,7 +87,7 @@ export class Flows extends Base {
|
|
|
84
87
|
* ```
|
|
85
88
|
*/
|
|
86
89
|
public async getFlow(id: string): Promise<Flow> {
|
|
87
|
-
const route = `/v2/${this.currentAccountId}/flow/${id}`;
|
|
90
|
+
const route = `/v2/${this.dataHub.currentAccountId}/flow/${id}`;
|
|
88
91
|
|
|
89
92
|
const params = {
|
|
90
93
|
includeDeleted: false,
|
|
@@ -92,7 +95,7 @@ export class Flows extends Base {
|
|
|
92
95
|
sandbox: false,
|
|
93
96
|
};
|
|
94
97
|
|
|
95
|
-
return await this.dataHub.makeRequest({
|
|
98
|
+
return await this.dataHub.makeRequest<Flow>({
|
|
96
99
|
method: 'GET',
|
|
97
100
|
route,
|
|
98
101
|
params,
|
|
@@ -108,14 +111,14 @@ export class Flows extends Base {
|
|
|
108
111
|
* ```
|
|
109
112
|
*/
|
|
110
113
|
public async saveFlow(source: Flow): Promise<Flow> {
|
|
111
|
-
const route = `/v2/${this.currentAccountId}/flow/${source.id ? source.id : 'new'}`;
|
|
114
|
+
const route = `/v2/${this.dataHub.currentAccountId}/flow/${source.id ? source.id : 'new'}`;
|
|
112
115
|
|
|
113
116
|
const data = {
|
|
114
117
|
flow: source,
|
|
115
118
|
previousVersion: source.id ? source.version : undefined,
|
|
116
119
|
};
|
|
117
120
|
|
|
118
|
-
return await this.dataHub.makeRequest({
|
|
121
|
+
return await this.dataHub.makeRequest<Flow>({
|
|
119
122
|
method: 'POST',
|
|
120
123
|
route,
|
|
121
124
|
data,
|
|
@@ -128,7 +131,7 @@ export class Flows extends Base {
|
|
|
128
131
|
* const result = await flows.deleteFlow(flowSource, flowAlias);
|
|
129
132
|
* ```
|
|
130
133
|
*/
|
|
131
|
-
public async deleteFlow(source: Flow, flowAlias = 'dev'): Promise<
|
|
134
|
+
public async deleteFlow(source: Flow, flowAlias = 'dev'): Promise<GraphqlResponseCheckExecution> {
|
|
132
135
|
const variables = {
|
|
133
136
|
entity: ENTITY_NAME,
|
|
134
137
|
data: {
|
|
@@ -145,7 +148,7 @@ export class Flows extends Base {
|
|
|
145
148
|
variables,
|
|
146
149
|
};
|
|
147
150
|
|
|
148
|
-
const { data: { deleteTemporarily: { requestId } } } = await this.dataHub.makeRequest({
|
|
151
|
+
const { data: { deleteTemporarily: { requestId } } } = await this.dataHub.makeRequest<GraphqlResponse<'deleteTemporarily', void>>({
|
|
149
152
|
method: 'POST',
|
|
150
153
|
route: '/graphql',
|
|
151
154
|
data,
|
package/src/constants.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
export const SERVICE_KEY = 'sdk-api';
|
|
2
|
-
|
|
3
1
|
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
4
2
|
deleteTemporarily(entity: $entity, data: $data) {
|
|
5
3
|
... on AsyncRequest {
|
|
6
4
|
requestId
|
|
7
|
-
__typename
|
|
8
5
|
}
|
|
9
|
-
__typename
|
|
10
6
|
}
|
|
11
7
|
}`;
|
|
12
8
|
|