@or-sdk/idw 1.1.0-beta.1277.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/README.md +1 -0
- package/dist/cjs/constants.js +6 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/idw.js +228 -0
- package/dist/cjs/idw.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/esm/constants.js +3 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/idw.js +124 -0
- package/dist/esm/idw.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/types/constants.d.ts +3 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/idw.d.ts +20 -0
- package/dist/types/idw.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +13 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +33 -0
- package/src/constants.ts +2 -0
- package/src/idw.ts +200 -0
- package/src/index.ts +2 -0
- package/src/types.ts +29 -0
- package/tsconfig.dev.json +8 -0
- package/tsconfig.esm.json +12 -0
- package/tsconfig.json +7 -0
- package/tsconfig.types.json +10 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Installation:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,KAAK,CAAC;AACnB,QAAA,WAAW,GAAG,KAAK,CAAC"}
|
package/dist/cjs/idw.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.IDW = void 0;
|
|
55
|
+
var base_1 = require("@or-sdk/base");
|
|
56
|
+
var graph_1 = require("@or-sdk/graph");
|
|
57
|
+
var constants_1 = require("./constants");
|
|
58
|
+
var IDW = (function (_super) {
|
|
59
|
+
__extends(IDW, _super);
|
|
60
|
+
function IDW(params) {
|
|
61
|
+
var _this = this;
|
|
62
|
+
var accountId = params.accountId, discoveryUrl = params.discoveryUrl, graphUrl = params.graphUrl, token = params.token;
|
|
63
|
+
_this = _super.call(this, {
|
|
64
|
+
accountId: accountId,
|
|
65
|
+
discoveryUrl: discoveryUrl,
|
|
66
|
+
serviceKey: constants_1.SERVICE_KEY,
|
|
67
|
+
token: token,
|
|
68
|
+
}) || this;
|
|
69
|
+
_this.graphApi = new graph_1.Graphs({
|
|
70
|
+
accountId: accountId,
|
|
71
|
+
discoveryUrl: discoveryUrl,
|
|
72
|
+
graphUrl: graphUrl,
|
|
73
|
+
token: token,
|
|
74
|
+
});
|
|
75
|
+
return _this;
|
|
76
|
+
}
|
|
77
|
+
IDW.prototype.createOrUpdateFlow = function (flow, _a) {
|
|
78
|
+
var userId = _a.userId;
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var meta;
|
|
81
|
+
return __generator(this, function (_b) {
|
|
82
|
+
switch (_b.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
if (flow.id === undefined) {
|
|
85
|
+
throw new Error('Only flows with id can be added to the IDW graph');
|
|
86
|
+
}
|
|
87
|
+
if (!flow.isDeleted) return [3, 2];
|
|
88
|
+
return [4, this.deleteFlow(flow.id)];
|
|
89
|
+
case 1: return [2, _b.sent()];
|
|
90
|
+
case 2: return [4, this.graphQuery('\
|
|
91
|
+
MERGE (flow:FLOW { id: $id } )\n\
|
|
92
|
+
SET createdAt = $createdAt\n\
|
|
93
|
+
SET createdBy = $userId\n\
|
|
94
|
+
SET description = $description\n\
|
|
95
|
+
SET groupId = groupId\n\
|
|
96
|
+
SET isActive = false\n\
|
|
97
|
+
SET name = $name\n\
|
|
98
|
+
SET updatedAt = $updatedAt\n\
|
|
99
|
+
SET updatedBy = $userId\n\
|
|
100
|
+
', {
|
|
101
|
+
createdAt: flow.dateCreated,
|
|
102
|
+
description: flow.data.description,
|
|
103
|
+
groupId: flow.botId,
|
|
104
|
+
id: flow.id,
|
|
105
|
+
name: flow.data.label,
|
|
106
|
+
updatedAt: flow.dateModified,
|
|
107
|
+
userId: userId,
|
|
108
|
+
})];
|
|
109
|
+
case 3:
|
|
110
|
+
_b.sent();
|
|
111
|
+
meta = flow.data.meta.idw;
|
|
112
|
+
if (meta) {
|
|
113
|
+
}
|
|
114
|
+
return [2];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
IDW.prototype.deleteFlow = function (id) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0: return [4, this.graphQuery('\
|
|
124
|
+
MATCH (flow:FLOW { id: $id } )\n\
|
|
125
|
+
DETACH DELETE flow\
|
|
126
|
+
', { id: id })];
|
|
127
|
+
case 1:
|
|
128
|
+
_a.sent();
|
|
129
|
+
return [2];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
IDW.prototype.activateFlow = function (id, activatedAt) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
+
return __generator(this, function (_a) {
|
|
137
|
+
switch (_a.label) {
|
|
138
|
+
case 0: return [4, this.graphQuery('\
|
|
139
|
+
MATCH (flow:FLOW { id: $id } )\n\
|
|
140
|
+
SET flow.isActive = true\
|
|
141
|
+
SET flow.activatedAt = $activatedAt\
|
|
142
|
+
', {
|
|
143
|
+
activatedAt: activatedAt,
|
|
144
|
+
id: id,
|
|
145
|
+
})];
|
|
146
|
+
case 1:
|
|
147
|
+
_a.sent();
|
|
148
|
+
return [2];
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
IDW.prototype.deactivateFlow = function (id) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0: return [4, this.graphQuery('\
|
|
158
|
+
MATCH (flow:FLOW { id: $id } )\n\
|
|
159
|
+
SET flow.isActive = false\
|
|
160
|
+
REMOVE flow.activatedAt\
|
|
161
|
+
', { id: id })];
|
|
162
|
+
case 1:
|
|
163
|
+
_a.sent();
|
|
164
|
+
return [2];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
IDW.prototype.graphQuery = function (query, params) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
171
|
+
var e_1;
|
|
172
|
+
return __generator(this, function (_a) {
|
|
173
|
+
switch (_a.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
_a.trys.push([0, 2, , 3]);
|
|
176
|
+
return [4, this.graphApi.query({
|
|
177
|
+
graph: constants_1.GRAPH_NAME,
|
|
178
|
+
params: params,
|
|
179
|
+
query: query,
|
|
180
|
+
})];
|
|
181
|
+
case 1: return [2, _a.sent()];
|
|
182
|
+
case 2:
|
|
183
|
+
e_1 = _a.sent();
|
|
184
|
+
return [3, 3];
|
|
185
|
+
case 3: return [2];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
IDW.prototype.afterSave = function () {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
192
|
+
return __generator(this, function (_a) {
|
|
193
|
+
return [2];
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
IDW.prototype.afterActivate = function () {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
return __generator(this, function (_a) {
|
|
200
|
+
return [2];
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
IDW.prototype.afterDeactivate = function () {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
+
return __generator(this, function (_a) {
|
|
207
|
+
return [2];
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
IDW.prototype.splitFromTree = function () {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
return __generator(this, function (_a) {
|
|
214
|
+
return [2];
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
IDW.prototype.deleteFromTree = function () {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
return [2];
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
return IDW;
|
|
226
|
+
}(base_1.Base));
|
|
227
|
+
exports.IDW = IDW;
|
|
228
|
+
//# sourceMappingURL=idw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idw.js","sourceRoot":"","sources":["../../src/idw.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAoC;AAEpC,uCAAuC;AACvC,yCAAsD;AAUtD;IAAyB,uBAAI;IAc3B,aAAY,MAAiB;QAA7B,iBAqBC;QAnBG,IAAA,SAAS,GAIP,MAAM,UAJC,EACT,YAAY,GAGV,MAAM,aAHI,EACZ,QAAQ,GAEN,MAAM,SAFA,EACR,KAAK,GACH,MAAM,MADH,CACI;gBAEX,kBAAM;YACJ,SAAS,WAAA;YACT,YAAY,cAAA;YACZ,UAAU,EAAE,uBAAW;YACvB,KAAK,OAAA;SACN,CAAC;QAEF,KAAI,CAAC,QAAQ,GAAG,IAAI,cAAM,CAAC;YACzB,SAAS,WAAA;YACT,YAAY,cAAA;YACZ,QAAQ,UAAA;YACR,KAAK,OAAA;SACN,CAAC,CAAC;;IACL,CAAC;IAEK,gCAAkB,GAAxB,UAAyB,IAAU,EAAE,EAA+B;YAA7B,MAAM,YAAA;;;;;;wBAC3C,IAAI,IAAI,CAAC,EAAE,KAAK,SAAS,EAAE;4BACzB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;yBACrE;6BAEG,IAAI,CAAC,SAAS,EAAd,cAAc;wBACT,WAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAA;4BAArC,WAAO,SAA8B,EAAC;4BAGxC,WAAM,IAAI,CAAC,UAAU,CAAC;;;;;;;;;;KAUrB,EAAE;4BACD,SAAS,EAAE,IAAI,CAAC,WAAW;4BAC3B,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW;4BAClC,OAAO,EAAE,IAAI,CAAC,KAAK;4BACnB,EAAE,EAAE,IAAI,CAAC,EAAY;4BACrB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;4BACrB,SAAS,EAAE,IAAI,CAAC,YAAY;4BAC5B,MAAM,QAAA;yBACP,CAAC,EAAA;;wBAlBF,SAkBE,CAAC;wBAEG,IAAI,GAAI,IAAI,CAAC,IAAI,CAAC,IAAiB,CAAC,GAAG,CAAC;wBAC9C,IAAI,IAAI,EAAE;yBAET;;;;;KACF;IAEK,wBAAU,GAAhB,UAAiB,EAAU;;;;4BACzB,WAAM,IAAI,CAAC,UAAU,CAAC;;;KAGrB,EAAE,EAAE,EAAE,IAAA,EAAE,CAAC,EAAA;;wBAHV,SAGU,CAAC;;;;;KACZ;IAEK,0BAAY,GAAlB,UAAmB,EAAU,EAAE,WAAmB;;;;4BAChD,WAAM,IAAI,CAAC,UAAU,CAAC;;;;KAIrB,EAAE;4BACD,WAAW,aAAA;4BACX,EAAE,IAAA;yBACH,CAAC,EAAA;;wBAPF,SAOE,CAAC;;;;;KACJ;IAEK,4BAAc,GAApB,UAAqB,EAAU;;;;4BAC7B,WAAM,IAAI,CAAC,UAAU,CAAC;;;;KAIrB,EAAE,EAAE,EAAE,IAAA,EAAE,CAAC,EAAA;;wBAJV,SAIU,CAAC;;;;;KACZ;IAEa,wBAAU,GAAxB,UAAyB,KAAa,EAAE,MAAyD;;;;;;;wBAEtF,WAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;gCAC/B,KAAK,EAAE,sBAAU;gCACjB,MAAM,QAAA;gCACN,KAAK,OAAA;6BACN,CAAC,EAAA;4BAJF,WAAO,SAIL,EAAC;;;;;;;;KAIN;IAMK,uBAAS,GAAf;;;;;;KAWC;IAKK,2BAAa,GAAnB;;;;;;KAIC;IAKK,6BAAe,GAArB;;;;;;KAIC;IASK,2BAAa,GAAnB;;;;;;KAaC;IASK,4BAAc,GAApB;;;;;;KAUC;IACH,UAAC;AAAD,CAAC,AAzLD,CAAyB,WAAI,GAyL5B;AAzLY,kBAAG"}
|
|
@@ -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.IDW = void 0;
|
|
18
|
+
var idw_1 = require("./idw");
|
|
19
|
+
Object.defineProperty(exports, "IDW", { enumerable: true, get: function () { return idw_1.IDW; } });
|
|
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,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AACZ,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC"}
|
package/dist/esm/idw.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
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 } from '@or-sdk/base';
|
|
11
|
+
import { Graphs } from '@or-sdk/graph';
|
|
12
|
+
import { GRAPH_NAME, SERVICE_KEY } from './constants';
|
|
13
|
+
export class IDW extends Base {
|
|
14
|
+
constructor(params) {
|
|
15
|
+
const { accountId, discoveryUrl, graphUrl, token, } = params;
|
|
16
|
+
super({
|
|
17
|
+
accountId,
|
|
18
|
+
discoveryUrl,
|
|
19
|
+
serviceKey: SERVICE_KEY,
|
|
20
|
+
token,
|
|
21
|
+
});
|
|
22
|
+
this.graphApi = new Graphs({
|
|
23
|
+
accountId,
|
|
24
|
+
discoveryUrl,
|
|
25
|
+
graphUrl,
|
|
26
|
+
token,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
createOrUpdateFlow(flow, { userId }) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (flow.id === undefined) {
|
|
32
|
+
throw new Error('Only flows with id can be added to the IDW graph');
|
|
33
|
+
}
|
|
34
|
+
if (flow.isDeleted) {
|
|
35
|
+
return yield this.deleteFlow(flow.id);
|
|
36
|
+
}
|
|
37
|
+
yield this.graphQuery('\
|
|
38
|
+
MERGE (flow:FLOW { id: $id } )\n\
|
|
39
|
+
SET createdAt = $createdAt\n\
|
|
40
|
+
SET createdBy = $userId\n\
|
|
41
|
+
SET description = $description\n\
|
|
42
|
+
SET groupId = groupId\n\
|
|
43
|
+
SET isActive = false\n\
|
|
44
|
+
SET name = $name\n\
|
|
45
|
+
SET updatedAt = $updatedAt\n\
|
|
46
|
+
SET updatedBy = $userId\n\
|
|
47
|
+
', {
|
|
48
|
+
createdAt: flow.dateCreated,
|
|
49
|
+
description: flow.data.description,
|
|
50
|
+
groupId: flow.botId,
|
|
51
|
+
id: flow.id,
|
|
52
|
+
name: flow.data.label,
|
|
53
|
+
updatedAt: flow.dateModified,
|
|
54
|
+
userId,
|
|
55
|
+
});
|
|
56
|
+
const meta = flow.data.meta.idw;
|
|
57
|
+
if (meta) {
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
deleteFlow(id) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
yield this.graphQuery('\
|
|
64
|
+
MATCH (flow:FLOW { id: $id } )\n\
|
|
65
|
+
DETACH DELETE flow\
|
|
66
|
+
', { id });
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
activateFlow(id, activatedAt) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
yield this.graphQuery('\
|
|
72
|
+
MATCH (flow:FLOW { id: $id } )\n\
|
|
73
|
+
SET flow.isActive = true\
|
|
74
|
+
SET flow.activatedAt = $activatedAt\
|
|
75
|
+
', {
|
|
76
|
+
activatedAt,
|
|
77
|
+
id,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
deactivateFlow(id) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
yield this.graphQuery('\
|
|
84
|
+
MATCH (flow:FLOW { id: $id } )\n\
|
|
85
|
+
SET flow.isActive = false\
|
|
86
|
+
REMOVE flow.activatedAt\
|
|
87
|
+
', { id });
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
graphQuery(query, params) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
try {
|
|
93
|
+
return yield this.graphApi.query({
|
|
94
|
+
graph: GRAPH_NAME,
|
|
95
|
+
params,
|
|
96
|
+
query,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
afterSave() {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
afterActivate() {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
afterDeactivate() {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
splitFromTree() {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
deleteFromTree() {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=idw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idw.js","sourceRoot":"","sources":["../../src/idw.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAUtD,MAAM,OAAO,GAAI,SAAQ,IAAI;IAc3B,YAAY,MAAiB;QAC3B,MAAM,EACJ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,KAAK,GACN,GAAG,MAAM,CAAC;QAEX,KAAK,CAAC;YACJ,SAAS;YACT,YAAY;YACZ,UAAU,EAAE,WAAW;YACvB,KAAK;SACN,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,GAAG,IAAI,MAAM,CAAC;YACzB,SAAS;YACT,YAAY;YACZ,QAAQ;YACR,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAEK,kBAAkB,CAAC,IAAU,EAAE,EAAE,MAAM,EAAuB;;YAClE,IAAI,IAAI,CAAC,EAAE,KAAK,SAAS,EAAE;gBACzB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;aACrE;YAED,IAAI,IAAI,CAAC,SAAS,EAAE;gBAClB,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aACvC;YAED,MAAM,IAAI,CAAC,UAAU,CAAC;;;;;;;;;;KAUrB,EAAE;gBACD,SAAS,EAAE,IAAI,CAAC,WAAW;gBAC3B,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW;gBAClC,OAAO,EAAE,IAAI,CAAC,KAAK;gBACnB,EAAE,EAAE,IAAI,CAAC,EAAY;gBACrB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;gBACrB,SAAS,EAAE,IAAI,CAAC,YAAY;gBAC5B,MAAM;aACP,CAAC,CAAC;YAEH,MAAM,IAAI,GAAI,IAAI,CAAC,IAAI,CAAC,IAAiB,CAAC,GAAG,CAAC;YAC9C,IAAI,IAAI,EAAE;aAET;QACH,CAAC;KAAA;IAEK,UAAU,CAAC,EAAU;;YACzB,MAAM,IAAI,CAAC,UAAU,CAAC;;;KAGrB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACb,CAAC;KAAA;IAEK,YAAY,CAAC,EAAU,EAAE,WAAmB;;YAChD,MAAM,IAAI,CAAC,UAAU,CAAC;;;;KAIrB,EAAE;gBACD,WAAW;gBACX,EAAE;aACH,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,cAAc,CAAC,EAAU;;YAC7B,MAAM,IAAI,CAAC,UAAU,CAAC;;;;KAIrB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACb,CAAC;KAAA;IAEa,UAAU,CAAC,KAAa,EAAE,MAAyD;;YAC/F,IAAI;gBACF,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;oBAC/B,KAAK,EAAE,UAAU;oBACjB,MAAM;oBACN,KAAK;iBACN,CAAC,CAAC;aACJ;YAAC,OAAO,CAAC,EAAE;aAEX;QACH,CAAC;KAAA;IAMK,SAAS;;QAWf,CAAC;KAAA;IAKK,aAAa;;QAInB,CAAC;KAAA;IAKK,eAAe;;QAIrB,CAAC;KAAA;IASK,aAAa;;QAanB,CAAC;KAAA;IASK,cAAc;;QAUpB,CAAC;KAAA;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,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":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,QAAQ,CAAC;AAChC,eAAO,MAAM,WAAW,QAAQ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Base } from '@or-sdk/base';
|
|
2
|
+
import { Flow } from '@or-sdk/deployer';
|
|
3
|
+
import { IDWConfig } from './types';
|
|
4
|
+
export declare class IDW extends Base {
|
|
5
|
+
private readonly graphApi;
|
|
6
|
+
constructor(params: IDWConfig);
|
|
7
|
+
createOrUpdateFlow(flow: Flow, { userId }: {
|
|
8
|
+
userId: string;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
deleteFlow(id: string): Promise<void>;
|
|
11
|
+
activateFlow(id: string, activatedAt: number): Promise<void>;
|
|
12
|
+
deactivateFlow(id: string): Promise<void>;
|
|
13
|
+
private graphQuery;
|
|
14
|
+
afterSave(): Promise<void>;
|
|
15
|
+
afterActivate(): Promise<void>;
|
|
16
|
+
afterDeactivate(): Promise<void>;
|
|
17
|
+
splitFromTree(): Promise<void>;
|
|
18
|
+
deleteFromTree(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=idw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idw.d.ts","sourceRoot":"","sources":["../../src/idw.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,OAAO,EAAY,SAAS,EAAE,MAAM,SAAS,CAAC;AAS9C,qBAAa,GAAI,SAAQ,IAAI;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAatB,MAAM,EAAE,SAAS;IAuBvB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;KAAE;IAmC9D,UAAU,CAAC,EAAE,EAAE,MAAM;IAOrB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAW5C,cAAc,CAAC,EAAE,EAAE,MAAM;YAQjB,UAAU;IAgBlB,SAAS;IAgBT,aAAa;IASb,eAAe;IAaf,aAAa;IAsBb,cAAc;CAWrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Token } from '@or-sdk/base';
|
|
2
|
+
export type IDWConfig = {
|
|
3
|
+
accountId?: string;
|
|
4
|
+
discoveryUrl?: string;
|
|
5
|
+
graphUrl?: string;
|
|
6
|
+
token: Token;
|
|
7
|
+
};
|
|
8
|
+
export interface FlowMeta {
|
|
9
|
+
idw?: {
|
|
10
|
+
channel: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,MAAM,MAAM,SAAS,GAAG;IAItB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAKlB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;KACjB,GAAG,SAAS,CAAC;CACf"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.1.0-beta.1277.0",
|
|
3
|
+
"name": "@or-sdk/idw",
|
|
4
|
+
"main": "dist/cjs/index.js",
|
|
5
|
+
"module": "dist/esm/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "pnpm clean && pnpm build:esm && pnpm build:cjs",
|
|
9
|
+
"build:cjs": "tsc --project tsconfig.json",
|
|
10
|
+
"build:esm": "tsc --project tsconfig.esm.json",
|
|
11
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
12
|
+
"build:watch": "concurrently -r --hide 1,2 \"pnpm build:watch:cjs\" \"pnpm build:watch:esm\" \"pnpm build:watch:types\"",
|
|
13
|
+
"build:watch:cjs": "tsc --project tsconfig.json -w",
|
|
14
|
+
"build:watch:esm": "tsc --project tsconfig.esm.json -w",
|
|
15
|
+
"build:watch:types": "tsc --project tsconfig.types.json -w",
|
|
16
|
+
"clean": "rm -rf ./dist",
|
|
17
|
+
"dev": "pnpm build:watch:esm"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"concurrently": "^6.4.0",
|
|
21
|
+
"typescript": "^4.4.4"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@or-sdk/base": "workspace:^",
|
|
28
|
+
"@or-sdk/deployer": "workspace:^",
|
|
29
|
+
"@or-sdk/graph": "workspace:^",
|
|
30
|
+
"@or-sdk/sdk-api": "workspace:^",
|
|
31
|
+
"lodash": "^4.17.21"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/constants.ts
ADDED
package/src/idw.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
|
|
2
|
+
import { Base } from '@or-sdk/base';
|
|
3
|
+
import { Flow } from '@or-sdk/deployer';
|
|
4
|
+
import { Graphs } from '@or-sdk/graph';
|
|
5
|
+
import { GRAPH_NAME, SERVICE_KEY } from './constants';
|
|
6
|
+
import { FlowMeta, IDWConfig } from './types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* OneReach IDW service client
|
|
10
|
+
* ## Installation:
|
|
11
|
+
* ```
|
|
12
|
+
* $ npm i @or-sdk/idw
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class IDW extends Base {
|
|
16
|
+
private readonly graphApi: Graphs;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { IDW } from '@or-sdk/idw'
|
|
21
|
+
* import config from '../config';
|
|
22
|
+
*
|
|
23
|
+
* const idw = new IDW({
|
|
24
|
+
* graphUrl: config.GRAPHS_API_URL,
|
|
25
|
+
* token: 'account-token-string'
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
constructor(params: IDWConfig) {
|
|
30
|
+
const {
|
|
31
|
+
accountId,
|
|
32
|
+
discoveryUrl,
|
|
33
|
+
graphUrl,
|
|
34
|
+
token,
|
|
35
|
+
} = params;
|
|
36
|
+
|
|
37
|
+
super({
|
|
38
|
+
accountId,
|
|
39
|
+
discoveryUrl,
|
|
40
|
+
serviceKey: SERVICE_KEY,
|
|
41
|
+
token,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
this.graphApi = new Graphs({
|
|
45
|
+
accountId,
|
|
46
|
+
discoveryUrl,
|
|
47
|
+
graphUrl,
|
|
48
|
+
token,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async createOrUpdateFlow(flow: Flow, { userId }: { userId: string; }) {
|
|
53
|
+
if (flow.id === undefined) {
|
|
54
|
+
throw new Error('Only flows with id can be added to the IDW graph');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (flow.isDeleted) {
|
|
58
|
+
return await this.deleteFlow(flow.id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
await this.graphQuery('\
|
|
62
|
+
MERGE (flow:FLOW { id: $id } )\n\
|
|
63
|
+
SET createdAt = $createdAt\n\
|
|
64
|
+
SET createdBy = $userId\n\
|
|
65
|
+
SET description = $description\n\
|
|
66
|
+
SET groupId = groupId\n\
|
|
67
|
+
SET isActive = false\n\
|
|
68
|
+
SET name = $name\n\
|
|
69
|
+
SET updatedAt = $updatedAt\n\
|
|
70
|
+
SET updatedBy = $userId\n\
|
|
71
|
+
', {
|
|
72
|
+
createdAt: flow.dateCreated,
|
|
73
|
+
description: flow.data.description,
|
|
74
|
+
groupId: flow.botId,
|
|
75
|
+
id: flow.id as string,
|
|
76
|
+
name: flow.data.label,
|
|
77
|
+
updatedAt: flow.dateModified,
|
|
78
|
+
userId,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const meta = (flow.data.meta as FlowMeta).idw;
|
|
82
|
+
if (meta) {
|
|
83
|
+
// TODO: process channel meta
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async deleteFlow(id: string) {
|
|
88
|
+
await this.graphQuery('\
|
|
89
|
+
MATCH (flow:FLOW { id: $id } )\n\
|
|
90
|
+
DETACH DELETE flow\
|
|
91
|
+
', { id });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async activateFlow(id: string, activatedAt: number) {
|
|
95
|
+
await this.graphQuery('\
|
|
96
|
+
MATCH (flow:FLOW { id: $id } )\n\
|
|
97
|
+
SET flow.isActive = true\
|
|
98
|
+
SET flow.activatedAt = $activatedAt\
|
|
99
|
+
', {
|
|
100
|
+
activatedAt,
|
|
101
|
+
id,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async deactivateFlow(id: string) {
|
|
106
|
+
await this.graphQuery('\
|
|
107
|
+
MATCH (flow:FLOW { id: $id } )\n\
|
|
108
|
+
SET flow.isActive = false\
|
|
109
|
+
REMOVE flow.activatedAt\
|
|
110
|
+
', { id });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private async graphQuery(query: string, params?: Record<string, null | number | string | boolean>) {
|
|
114
|
+
try {
|
|
115
|
+
return await this.graphApi.query({
|
|
116
|
+
graph: GRAPH_NAME,
|
|
117
|
+
params,
|
|
118
|
+
query,
|
|
119
|
+
});
|
|
120
|
+
} catch (e) {
|
|
121
|
+
// TODO: if 'idw' graph doesn't exist - create it, seed with channels data, and retry query
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Create new node FLOW {activatede: false}
|
|
127
|
+
* Create relationship FLOW-[:IMPLAMENTS]-CHANNEL
|
|
128
|
+
*/
|
|
129
|
+
async afterSave() {
|
|
130
|
+
// TODO: do we need this? this should be processed on flow save triggered from datahub
|
|
131
|
+
|
|
132
|
+
// const channel = await this.getChannel();
|
|
133
|
+
// const flow = await this.getFlow();
|
|
134
|
+
|
|
135
|
+
// if (_.isEmpty(channel)) this.createChannel();
|
|
136
|
+
|
|
137
|
+
// if (_.isEmpty(flow)) {
|
|
138
|
+
// await this.createFlow();
|
|
139
|
+
// }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Set FLOW {activated: true}
|
|
144
|
+
*/
|
|
145
|
+
async afterActivate() {
|
|
146
|
+
// TODO: do we need this? this should be processed on activation triggered from deployer
|
|
147
|
+
|
|
148
|
+
// this.setActivated(true);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Set FLOW {activated: false}
|
|
153
|
+
*/
|
|
154
|
+
async afterDeactivate() {
|
|
155
|
+
// TODO: do we need this? this should be processed on deactivation triggered from deployer
|
|
156
|
+
|
|
157
|
+
// this.setActivated(false);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Set FLOW {activated: false}
|
|
162
|
+
* Remove relationship FLOW-[:IMPLAMENTS]-CHANNEL
|
|
163
|
+
* Remove flow.data.meta.idwData
|
|
164
|
+
*/
|
|
165
|
+
// TODO: should be called by what it does, not the hook name - setChannelDataInFlowMeta
|
|
166
|
+
// TODO: should accept parameters from the actual hook, not rely on properties of the IDW instance
|
|
167
|
+
async splitFromTree() {
|
|
168
|
+
// TODO: do we need this? AFAIU only meta should be updated
|
|
169
|
+
|
|
170
|
+
// await this.setActivated(false);
|
|
171
|
+
// await this.deleteRelationship(
|
|
172
|
+
// 'FLOW',
|
|
173
|
+
// { id: `'${this.flowId}'` },
|
|
174
|
+
// 'CHANNEL',
|
|
175
|
+
// { id: `'${this.channel}'` },
|
|
176
|
+
// 'IMPLEMENTS'
|
|
177
|
+
// );
|
|
178
|
+
|
|
179
|
+
// delete this.flow.data.meta.idw;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Set FLOW {activated: false}
|
|
184
|
+
* Remove relationship FLOW-[:IMPLAMENTS]-CHANNEL
|
|
185
|
+
* Remove flow.data.meta.idwData
|
|
186
|
+
*/
|
|
187
|
+
// TODO: should be called by what it does, not the hook name - deleteChannelDataFromFlowMeta?
|
|
188
|
+
// TODO: should accept parameters from the actual hook, not rely on properties of the IDW instance
|
|
189
|
+
async deleteFromTree() {
|
|
190
|
+
// await this.setActivated(false);
|
|
191
|
+
// await this.deleteRelationship(
|
|
192
|
+
// 'FLOW',
|
|
193
|
+
// { id: `'${this.flowId}'` },
|
|
194
|
+
// 'CHANNEL',
|
|
195
|
+
// { id: `'${this.channel}'` },
|
|
196
|
+
// 'IMPLEMENTS'
|
|
197
|
+
// );
|
|
198
|
+
// delete this.flow.data.meta.idwData;
|
|
199
|
+
}
|
|
200
|
+
}
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Token } from '@or-sdk/base';
|
|
2
|
+
|
|
3
|
+
export type IDWConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* Account ID for cross-account requests (super admin only)
|
|
6
|
+
*/
|
|
7
|
+
accountId?: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Url of OneReach service discovery api
|
|
11
|
+
*/
|
|
12
|
+
discoveryUrl?: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Url of OneReach graph api
|
|
16
|
+
*/
|
|
17
|
+
graphUrl?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* token
|
|
21
|
+
*/
|
|
22
|
+
token: Token;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export interface FlowMeta {
|
|
26
|
+
idw?: {
|
|
27
|
+
channel: string;
|
|
28
|
+
} | undefined;
|
|
29
|
+
}
|
package/tsconfig.json
ADDED