@or-sdk/idw 1.4.0-beta.1535.0 → 1.4.0-beta.1545.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/CHANGELOG.md +9 -0
- package/dist/cjs/idw.js +24 -18
- package/dist/cjs/idw.js.map +1 -1
- package/dist/cjs/migration-base.js +7 -6
- package/dist/cjs/migration-base.js.map +1 -1
- package/dist/cjs/migration-handler.js +17 -18
- package/dist/cjs/migration-handler.js.map +1 -1
- package/dist/cjs/migrations/Migration__3.js +108 -0
- package/dist/cjs/migrations/Migration__3.js.map +1 -0
- package/dist/cjs/migrations/Migration__4.js +148 -0
- package/dist/cjs/migrations/Migration__4.js.map +1 -0
- package/dist/cjs/migrations/index.js +5 -1
- package/dist/cjs/migrations/index.js.map +1 -1
- package/dist/esm/idw.js +12 -6
- package/dist/esm/idw.js.map +1 -1
- package/dist/esm/migration-base.js +7 -6
- package/dist/esm/migration-base.js.map +1 -1
- package/dist/esm/migration-handler.js +8 -10
- package/dist/esm/migration-handler.js.map +1 -1
- package/dist/esm/migrations/Migration__3.js +53 -0
- package/dist/esm/migrations/Migration__3.js.map +1 -0
- package/dist/esm/migrations/Migration__4.js +66 -0
- package/dist/esm/migrations/Migration__4.js.map +1 -0
- package/dist/esm/migrations/index.js +2 -0
- package/dist/esm/migrations/index.js.map +1 -1
- package/dist/types/idw.d.ts +2 -1
- package/dist/types/idw.d.ts.map +1 -1
- package/dist/types/migration-base.d.ts +3 -1
- package/dist/types/migration-base.d.ts.map +1 -1
- package/dist/types/migration-handler.d.ts +3 -1
- package/dist/types/migration-handler.d.ts.map +1 -1
- package/dist/types/migrations/Migration__3.d.ts +5 -0
- package/dist/types/migrations/Migration__3.d.ts.map +1 -0
- package/dist/types/migrations/Migration__4.d.ts +8 -0
- package/dist/types/migrations/Migration__4.d.ts.map +1 -0
- package/dist/types/migrations/index.d.ts +2 -0
- package/dist/types/migrations/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/idw.ts +12 -9
- package/src/migration-base.ts +9 -12
- package/src/migration-handler.ts +23 -11
- package/src/migrations/Migration__3.ts +45 -0
- package/src/migrations/Migration__4.ts +55 -0
- package/src/migrations/index.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.3.8](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/compare/@or-sdk/idw@1.3.7...@or-sdk/idw@1.3.8) (2023-06-30)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **@or-sdk/idw:** synchronize the number of steps with graph nodes ([6c89cbb](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/commit/6c89cbb1de9f62b831ac1cf38b4e657fba9b1dab))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## [1.3.7](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/compare/@or-sdk/idw@1.3.6...@or-sdk/idw@1.3.7) (2023-06-29)
|
|
7
16
|
|
|
8
17
|
|
package/dist/cjs/idw.js
CHANGED
|
@@ -62,6 +62,7 @@ var users_1 = require("@or-sdk/users");
|
|
|
62
62
|
var accounts_1 = require("@or-sdk/accounts");
|
|
63
63
|
var constants_1 = require("./constants");
|
|
64
64
|
var migration_handler_1 = __importDefault(require("./migration-handler"));
|
|
65
|
+
var flows_1 = require("@or-sdk/flows");
|
|
65
66
|
var IDW = (function (_super) {
|
|
66
67
|
__extends(IDW, _super);
|
|
67
68
|
function IDW(params) {
|
|
@@ -94,8 +95,12 @@ var IDW = (function (_super) {
|
|
|
94
95
|
token: token,
|
|
95
96
|
sdkUrl: sdkApiUrl,
|
|
96
97
|
});
|
|
98
|
+
_this.flows = new flows_1.Flows({
|
|
99
|
+
token: token,
|
|
100
|
+
discoveryUrl: discoveryUrl,
|
|
101
|
+
});
|
|
97
102
|
_this.accountId = accountId;
|
|
98
|
-
_this.migrationHandler = new migration_handler_1.default(_this.graphApi, _this.users, _this.accounts, _this.settings, _this.accountId);
|
|
103
|
+
_this.migrationHandler = new migration_handler_1.default(_this.graphApi, _this.users, _this.accounts, _this.settings, _this.accountId, _this.flows);
|
|
99
104
|
return _this;
|
|
100
105
|
}
|
|
101
106
|
IDW.prototype.runMigrations = function () {
|
|
@@ -120,12 +125,12 @@ var IDW = (function (_super) {
|
|
|
120
125
|
return [4, this.graphApi.getGraphInfo(constants_1.GRAPH_NAME)];
|
|
121
126
|
case 1:
|
|
122
127
|
_a.sent();
|
|
123
|
-
return [
|
|
128
|
+
return [3, 3];
|
|
124
129
|
case 2:
|
|
125
130
|
e_1 = _a.sent();
|
|
126
131
|
this.createDb();
|
|
127
132
|
this.migrationHandler.deleteMigrationVersion();
|
|
128
|
-
return [
|
|
133
|
+
return [3, 3];
|
|
129
134
|
case 3: return [2];
|
|
130
135
|
}
|
|
131
136
|
});
|
|
@@ -144,11 +149,11 @@ var IDW = (function (_super) {
|
|
|
144
149
|
});
|
|
145
150
|
};
|
|
146
151
|
IDW.prototype.createOrUpdateFlow = function (flow) {
|
|
147
|
-
var _a, _b;
|
|
152
|
+
var _a, _b, _c, _d, _e, _f;
|
|
148
153
|
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
-
var id,
|
|
150
|
-
return __generator(this, function (
|
|
151
|
-
switch (
|
|
154
|
+
var id, _g, username, userId, channel, skills, preparedIds;
|
|
155
|
+
return __generator(this, function (_h) {
|
|
156
|
+
switch (_h.label) {
|
|
152
157
|
case 0:
|
|
153
158
|
id = flow.id;
|
|
154
159
|
if (id === undefined) {
|
|
@@ -156,11 +161,11 @@ var IDW = (function (_super) {
|
|
|
156
161
|
}
|
|
157
162
|
if (!flow.isDeleted) return [3, 2];
|
|
158
163
|
return [4, this.deleteFlow(id)];
|
|
159
|
-
case 1: return [2,
|
|
164
|
+
case 1: return [2, _h.sent()];
|
|
160
165
|
case 2: return [4, this.users.getCurrentUser()];
|
|
161
166
|
case 3:
|
|
162
|
-
|
|
163
|
-
return [4, this.graphQuery("\n MERGE (flow:FLOW { id: $id })\n ON MATCH\n SET flow.createdAt = $createdAt,\n flow.createdBy = $userId,\n flow.description = $description,\n flow.groupId = $groupId,\n flow.name = $name,\n flow.updatedAt = $updatedAt,\n flow.updatedBy = $username\n ON CREATE\n SET flow.createdAt = $createdAt,\n flow.createdBy = $userId,\n flow.description = $description,\n flow.groupId = $groupId,\n flow.isActive = false,\n flow.name = $name,\n flow.updatedAt = $updatedAt,\n flow.updatedBy = $username\n RETURN flow\n ", {
|
|
167
|
+
_g = _h.sent(), username = _g.username, userId = _g.userId;
|
|
168
|
+
return [4, this.graphQuery("\n MERGE (flow:FLOW { id: $id })\n ON MATCH\n SET flow.createdAt = $createdAt,\n flow.createdBy = $userId,\n flow.description = $description,\n flow.groupId = $groupId,\n flow.name = $name,\n flow.updatedAt = $updatedAt,\n flow.updatedBy = $username\n flow.steps = $steps\n ON CREATE\n SET flow.createdAt = $createdAt,\n flow.createdBy = $userId,\n flow.description = $description,\n flow.groupId = $groupId,\n flow.isActive = false,\n flow.name = $name,\n flow.updatedAt = $updatedAt,\n flow.updatedBy = $username\n flow.steps = $steps\n RETURN flow\n ", {
|
|
164
169
|
createdAt: flow.dateCreated,
|
|
165
170
|
description: flow.data.description,
|
|
166
171
|
groupId: flow.botId,
|
|
@@ -169,22 +174,23 @@ var IDW = (function (_super) {
|
|
|
169
174
|
updatedAt: flow.dateModified,
|
|
170
175
|
username: username,
|
|
171
176
|
userId: userId,
|
|
177
|
+
steps: (_d = (_c = (_b = (_a = flow.data.trees) === null || _a === void 0 ? void 0 : _a.main) === null || _b === void 0 ? void 0 : _b.steps) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
172
178
|
})];
|
|
173
179
|
case 4:
|
|
174
|
-
|
|
180
|
+
_h.sent();
|
|
175
181
|
return [4, this.graphQuery("\n MATCH (flow:FLOW { id: $id })\n OPTIONAL MATCH (flow)-[channelRelations:IMPLEMENTS { isActive: false }]->(:CHANNEL)\n OPTIONAL MATCH (flow)-[skillRelations:IMPLEMENTS { isActive: false }]->(:SKILL)\n DELETE channelRelations, skillRelations\n ", { id: id })];
|
|
176
182
|
case 5:
|
|
177
|
-
|
|
178
|
-
channel = (
|
|
179
|
-
skills = (
|
|
183
|
+
_h.sent();
|
|
184
|
+
channel = (_e = flow.data.meta.idw) === null || _e === void 0 ? void 0 : _e.channel;
|
|
185
|
+
skills = (_f = flow.data.meta.idw) === null || _f === void 0 ? void 0 : _f.skills;
|
|
180
186
|
if (!(channel !== undefined && channel.length !== 0)) return [3, 7];
|
|
181
187
|
return [4, this.graphQuery("\n MATCH (flow:FLOW { id: $id }),\n (channel:CHANNEL { id: $channel })\n MERGE (flow)-[relationship:IMPLEMENTS]->(channel)\n ON CREATE\n SET relationship.isActive = false\n ", {
|
|
182
188
|
channel: channel,
|
|
183
189
|
id: id,
|
|
184
190
|
})];
|
|
185
191
|
case 6:
|
|
186
|
-
|
|
187
|
-
|
|
192
|
+
_h.sent();
|
|
193
|
+
_h.label = 7;
|
|
188
194
|
case 7:
|
|
189
195
|
if (!(skills === null || skills === void 0 ? void 0 : skills.length)) return [3, 9];
|
|
190
196
|
preparedIds = skills.map(function (id) { return "'".concat(id, "'"); });
|
|
@@ -192,8 +198,8 @@ var IDW = (function (_super) {
|
|
|
192
198
|
id: id,
|
|
193
199
|
})];
|
|
194
200
|
case 8:
|
|
195
|
-
|
|
196
|
-
|
|
201
|
+
_h.sent();
|
|
202
|
+
_h.label = 9;
|
|
197
203
|
case 9: return [2];
|
|
198
204
|
}
|
|
199
205
|
});
|
package/dist/cjs/idw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idw.js","sourceRoot":"","sources":["../../src/idw.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;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FAEC,WAAW,iHAGjC,EAAE;gCACD,EAAE,IAAA;6BACH,CAAC,EAAA;;wBAPF,SAOE,CAAC;;;;;;KAEN;IAEK,4BAAc,GAApB,UAAqB,EAAU;;;;4BAC7B,WAAM,IAAI,CAAC,UAAU,CAAC,oWASrB,EAAE,EAAE,EAAE,IAAA,EAAE,CAAC,EAAA;;wBATV,SASU,CAAC;;;;;KACZ;IAEa,wBAAU,GAAxB,UAAyB,KAAa,EAAE,MAAyD;;;;;;;wBAG7F,WAAM,IAAI,CAAC,eAAe,EAAE,EAAA;;wBAA5B,SAA4B,CAAC;;;;wBAE7B,OAAO,CAAC,IAAI,CAAC,GAAC,CAAC,CAAC;;;;wBAKT,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;;;wBAEH,OAAO,CAAC,IAAI,CAAC,GAAC,CAAC,CAAC;;;;;;KAGnB;IACH,UAAC;AAAD,CAAC,AAvQD,CAAyB,WAAI,GAuQ5B;AAvQY,kBAAG"}
|
|
@@ -38,12 +38,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.MigrationBase = void 0;
|
|
40
40
|
var MigrationBase = (function () {
|
|
41
|
-
function MigrationBase(
|
|
42
|
-
this.graphApi =
|
|
43
|
-
this.users =
|
|
44
|
-
this.accounts =
|
|
45
|
-
this.settings =
|
|
46
|
-
this.accountId =
|
|
41
|
+
function MigrationBase(graphApi, users, accounts, settings, accountId, flows) {
|
|
42
|
+
this.graphApi = graphApi;
|
|
43
|
+
this.users = users;
|
|
44
|
+
this.accounts = accounts;
|
|
45
|
+
this.settings = settings;
|
|
46
|
+
this.accountId = accountId;
|
|
47
|
+
this.flows = flows;
|
|
47
48
|
}
|
|
48
49
|
MigrationBase.prototype.resolveAccountId = function () {
|
|
49
50
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-base.js","sourceRoot":"","sources":["../../src/migration-base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"migration-base.js","sourceRoot":"","sources":["../../src/migration-base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;IACE,uBACY,QAAgB,EAChB,KAAY,EACZ,QAAkB,EAClB,QAAkB,EAClB,SAA6B,EAC7B,KAAY;QALZ,aAAQ,GAAR,QAAQ,CAAQ;QAChB,UAAK,GAAL,KAAK,CAAO;QACZ,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAU;QAClB,cAAS,GAAT,SAAS,CAAoB;QAC7B,UAAK,GAAL,KAAK,CAAO;IAExB,CAAC;IAIe,wCAAgB,GAAhC;;;;;gBACE,WAAO,MAAA,IAAI,CAAC,SAAS,mCAAI,CAAC;;;;wCACF,WAAM,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,EAAA;;oCAA/C,SAAS,GAAK,CAAA,SAAiC,CAAA,UAAtC;oCACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;oCAC3B,WAAO,SAAS,EAAC;;;yBAClB,CAAC,EAAE,EAAC;;;KACN;IACH,oBAAC;AAAD,CAAC,AApBD,IAoBC;AApBqB,sCAAa"}
|
|
@@ -63,52 +63,51 @@ var constants_1 = require("./constants");
|
|
|
63
63
|
var migrations = __importStar(require("./migrations"));
|
|
64
64
|
var PREFIX = 'Migration__';
|
|
65
65
|
var MigrationHandler = (function () {
|
|
66
|
-
function MigrationHandler(graphApi, users, accounts, settings, accountId) {
|
|
66
|
+
function MigrationHandler(graphApi, users, accounts, settings, accountId, flows) {
|
|
67
|
+
var _this = this;
|
|
67
68
|
this.graphApi = graphApi;
|
|
68
69
|
this.users = users;
|
|
69
70
|
this.accounts = accounts;
|
|
70
71
|
this.settings = settings;
|
|
71
72
|
this.accountId = accountId;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
accountId: accountId,
|
|
78
|
-
};
|
|
79
|
-
this.migrations = new Map(Object.values(migrations).map(function (ctor) { return [ctor.name, new ctor(params)]; }));
|
|
73
|
+
this.flows = flows;
|
|
74
|
+
this.migrations = new Map(Object.values(migrations)
|
|
75
|
+
.map(function (ctor) { return [
|
|
76
|
+
ctor.name, new ctor(_this.graphApi, _this.users, _this.accounts, _this.settings, _this.accountId, _this.flows),
|
|
77
|
+
]; }));
|
|
80
78
|
}
|
|
81
79
|
MigrationHandler.prototype.applyMigrations = function () {
|
|
80
|
+
var _a;
|
|
82
81
|
return __awaiter(this, void 0, void 0, function () {
|
|
83
82
|
var accountsLatestVersion, migrationVersions, i, migration, e_1;
|
|
84
|
-
return __generator(this, function (
|
|
85
|
-
switch (
|
|
83
|
+
return __generator(this, function (_b) {
|
|
84
|
+
switch (_b.label) {
|
|
86
85
|
case 0: return [4, this.findAccountsMigrationVersion()];
|
|
87
86
|
case 1:
|
|
88
|
-
accountsLatestVersion = _a.sent();
|
|
87
|
+
accountsLatestVersion = (_a = (_b.sent())) !== null && _a !== void 0 ? _a : 0;
|
|
89
88
|
migrationVersions = Array.from(this.migrations.keys()).map(function (migrationName) {
|
|
90
89
|
var _a = migrationName.split(PREFIX), version = _a[1];
|
|
91
90
|
return Number(version);
|
|
92
91
|
}).sort();
|
|
93
92
|
i = 0;
|
|
94
|
-
|
|
93
|
+
_b.label = 2;
|
|
95
94
|
case 2:
|
|
96
95
|
if (!(i < migrationVersions.length)) return [3, 8];
|
|
97
96
|
if (!(migrationVersions[i] > accountsLatestVersion)) return [3, 7];
|
|
98
97
|
migration = this.migrations.get(PREFIX + migrationVersions[i]);
|
|
99
98
|
if (!migration) return [3, 7];
|
|
100
|
-
|
|
99
|
+
_b.label = 3;
|
|
101
100
|
case 3:
|
|
102
|
-
|
|
101
|
+
_b.trys.push([3, 6, , 7]);
|
|
103
102
|
return [4, migration.up()];
|
|
104
103
|
case 4:
|
|
105
|
-
|
|
104
|
+
_b.sent();
|
|
106
105
|
return [4, this.saveVersion(migrationVersions[i])];
|
|
107
106
|
case 5:
|
|
108
|
-
|
|
107
|
+
_b.sent();
|
|
109
108
|
return [3, 7];
|
|
110
109
|
case 6:
|
|
111
|
-
e_1 =
|
|
110
|
+
e_1 = _b.sent();
|
|
112
111
|
throw new Error("Migration ".concat(migration.constructor.name, " is not applied"));
|
|
113
112
|
case 7:
|
|
114
113
|
i++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-handler.js","sourceRoot":"","sources":["../../src/migration-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,yCAAwD;AACxD,uDAA2C;
|
|
1
|
+
{"version":3,"file":"migration-handler.js","sourceRoot":"","sources":["../../src/migration-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,yCAAwD;AACxD,uDAA2C;AAG3C,IAAM,MAAM,GAAG,aAAa,CAAC;AAE7B;IAGE,0BACU,QAAgB,EAChB,KAAY,EACZ,QAAkB,EAClB,QAAkB,EAClB,SAA6B,EAC7B,KAAY;QANtB,iBAsBC;QArBS,aAAQ,GAAR,QAAQ,CAAQ;QAChB,UAAK,GAAL,KAAK,CAAO;QACZ,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAU;QAClB,cAAS,GAAT,SAAS,CAAoB;QAC7B,UAAK,GAAL,KAAK,CAAO;QAGpB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CACvB,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;aACtB,GAAG,CAAC,UAA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AAE,CAAA;;;;;;KAchD;IAEK,sCAAW,GAAjB,UAAkB,oBAA4B;;;;;;;wBAEpC,MAAM,GAAG;4BACb,GAAG,EAAE,UAAG,uBAAW,cAAI,wBAAY,CAAE;4BACrC,KAAK,EAAE,oBAAoB;yBAC5B,CAAC;wBACF,WAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAA;;wBAA9C,SAA8C,CAAC;;;;wBAG/C,MAAM,IAAI,KAAK,CAAC,yCAAiC,MAAM,GAAG,oBAAoB,OAAG,CAAC,CAAC;;;;;KAEtF;IAEK,iDAAsB,GAA5B;;;;;;wBACQ,MAAM,GAAG;4BACb,GAAG,EAAE,UAAG,uBAAW,cAAI,wBAAY,CAAE;yBACT,CAAC;wBAC/B,WAAM,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAA;;wBAAjD,SAAiD,CAAC;;;;;KACnD;IAEK,uDAA4B,GAAlC;;;;;;;wBAEU,MAAM,GAAG;4BACb,GAAG,EAAE,UAAG,uBAAW,cAAI,wBAAY,CAAE;yBACtC,CAAC;wBACK,WAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAA;4BAArD,WAAO,SAA8C,EAAC;;;wBAGtD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;;;;;KAE3D;IACH,uBAAC;AAAD,CAAC,AAlFD,IAkFC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
var migration_base_1 = require("../migration-base");
|
|
55
|
+
var constants_1 = require("../constants");
|
|
56
|
+
var Migration__3 = (function (_super) {
|
|
57
|
+
__extends(Migration__3, _super);
|
|
58
|
+
function Migration__3() {
|
|
59
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
60
|
+
}
|
|
61
|
+
Migration__3.prototype.up = function () {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var flowsIds, preparedIds, flows, pairs;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0: return [4, this.graphApi.query({
|
|
67
|
+
graph: constants_1.GRAPH_NAME,
|
|
68
|
+
query: "match (flow: FLOW)\n where flow.steps is NULL\n return flow.id as id\n ",
|
|
69
|
+
params: {},
|
|
70
|
+
})];
|
|
71
|
+
case 1:
|
|
72
|
+
flowsIds = _a.sent();
|
|
73
|
+
if (!flowsIds.length) return [3, 4];
|
|
74
|
+
preparedIds = flowsIds.map(function (f) { return f.id; });
|
|
75
|
+
return [4, this.flows.listFlows({
|
|
76
|
+
query: {
|
|
77
|
+
id: preparedIds,
|
|
78
|
+
},
|
|
79
|
+
projection: ['data.trees.main.steps'],
|
|
80
|
+
})];
|
|
81
|
+
case 2:
|
|
82
|
+
flows = _a.sent();
|
|
83
|
+
pairs = flows.items.map(function (flow) {
|
|
84
|
+
var _a, _b, _c;
|
|
85
|
+
return ({
|
|
86
|
+
steps: (_c = (_b = (_a = flow.data.trees) === null || _a === void 0 ? void 0 : _a.main.steps) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0,
|
|
87
|
+
id: flow.id,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
return [4, this.graphApi.query({
|
|
91
|
+
graph: constants_1.GRAPH_NAME,
|
|
92
|
+
query: "\n unwind $list as pairs\n MERGE (flow:FLOW { id: pairs.id })\n SET flow.steps = pairs.steps\n ",
|
|
93
|
+
params: {
|
|
94
|
+
list: pairs,
|
|
95
|
+
},
|
|
96
|
+
})];
|
|
97
|
+
case 3:
|
|
98
|
+
_a.sent();
|
|
99
|
+
_a.label = 4;
|
|
100
|
+
case 4: return [2];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
return Migration__3;
|
|
106
|
+
}(migration_base_1.MigrationBase));
|
|
107
|
+
exports.default = Migration__3;
|
|
108
|
+
//# sourceMappingURL=Migration__3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration__3.js","sourceRoot":"","sources":["../../../src/migrations/Migration__3.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAkD;AAClD,0CAA0C;AAG1C;IAA0C,gCAAa;IAAvD;;IAwCA,CAAC;IAvCO,yBAAE,GAAR;;;;;4BACmB,WAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAgB;4BACxD,KAAK,EAAE,sBAAU;4BACjB,KAAK,EAAE,gHAGE;4BACT,MAAM,EAAE,EAAE;yBACX,CAAC,EAAA;;wBAPI,QAAQ,GAAG,SAOf;6BAEE,QAAQ,CAAC,MAAM,EAAf,cAAe;wBACX,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,EAAE,EAAJ,CAAI,CAAC,CAAC;wBAC9B,WAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;gCACvC,KAAK,EAAE;oCACL,EAAE,EAAE,WAAW;iCAChB;gCACD,UAAU,EAAE,CAAC,uBAAuB,CAAC;6BACtC,CAAC,EAAA;;wBALI,KAAK,GAAG,SAKZ;wBAEI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;;4BAAI,OAAA,CACpC;gCACE,KAAK,EAAE,MAAA,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,IAAI,CAAC,KAAK,0CAAE,MAAM,mCAAI,CAAC;gCAC/C,EAAE,EAAE,IAAI,CAAC,EAAE;6BACZ,CAAC,CAAA;yBAAA,CACH,CAAC;wBAEF,WAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;gCACxB,KAAK,EAAE,sBAAU;gCACjB,KAAK,EAAE,2JAIA;gCACP,MAAM,EAAE;oCACN,IAAI,EAAE,KAAY;iCACnB;6BACF,CAAC,EAAA;;wBAVF,SAUE,CAAC;;;;;;KAEN;IACH,mBAAC;AAAD,CAAC,AAxCD,CAA0C,8BAAa,GAwCtD"}
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
var constants_1 = require("../constants");
|
|
55
|
+
var migration_base_1 = require("../migration-base");
|
|
56
|
+
var Migration__4 = (function (_super) {
|
|
57
|
+
__extends(Migration__4, _super);
|
|
58
|
+
function Migration__4() {
|
|
59
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
60
|
+
}
|
|
61
|
+
Migration__4.prototype.up = function () {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var channelsExist;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0: return [4, this.checkIfDomainsExist()];
|
|
67
|
+
case 1:
|
|
68
|
+
channelsExist = _a.sent();
|
|
69
|
+
if (!!channelsExist) return [3, 4];
|
|
70
|
+
return [4, this.createDefaultDomains()];
|
|
71
|
+
case 2:
|
|
72
|
+
_a.sent();
|
|
73
|
+
return [4, this.connectNodesToDefaultDomains()];
|
|
74
|
+
case 3:
|
|
75
|
+
_a.sent();
|
|
76
|
+
_a.label = 4;
|
|
77
|
+
case 4: return [2];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
Migration__4.prototype.checkIfDomainsExist = function () {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
var data;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0: return [4, this.graphApi.query({
|
|
88
|
+
graph: constants_1.GRAPH_NAME,
|
|
89
|
+
query: 'MATCH (domains: DOMAIN) RETURN collect(DISTINCT domains) as domains',
|
|
90
|
+
params: {},
|
|
91
|
+
})];
|
|
92
|
+
case 1:
|
|
93
|
+
data = (_a.sent())[0];
|
|
94
|
+
return [2, data.domains.length > 0];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
Migration__4.prototype.createDefaultDomains = function () {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
switch (_a.label) {
|
|
103
|
+
case 0: return [4, this.graphApi.query({
|
|
104
|
+
graph: constants_1.GRAPH_NAME,
|
|
105
|
+
query: "CREATE (sd: DOMAIN {id: \"skills-default-domain\", name: \"Default\"}),\n (cd: DOMAIN {id: \"channels-default-domain\", name: \"Default\"}),\n (md: DOMAIN {id: \"memory-default-domain\", name: \"Default\"})",
|
|
106
|
+
params: {},
|
|
107
|
+
})];
|
|
108
|
+
case 1:
|
|
109
|
+
_a.sent();
|
|
110
|
+
return [2];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
Migration__4.prototype.connectNodesToDefaultDomains = function () {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
+
return __generator(this, function (_a) {
|
|
118
|
+
switch (_a.label) {
|
|
119
|
+
case 0: return [4, this.graphApi.query({
|
|
120
|
+
graph: constants_1.GRAPH_NAME,
|
|
121
|
+
query: "MATCH (sd: DOMAIN {id: \"skills-default-domain\"}), (s: SKILL)\n CREATE (sd)-[r: INCLUDES]->(s)",
|
|
122
|
+
params: {},
|
|
123
|
+
})];
|
|
124
|
+
case 1:
|
|
125
|
+
_a.sent();
|
|
126
|
+
return [4, this.graphApi.query({
|
|
127
|
+
graph: constants_1.GRAPH_NAME,
|
|
128
|
+
query: "MATCH (cd: DOMAIN {id: \"channels-default-domain\"}), (c: CHANNEL)\n CREATE (cd)-[r: INCLUDES]->(c)",
|
|
129
|
+
params: {},
|
|
130
|
+
})];
|
|
131
|
+
case 2:
|
|
132
|
+
_a.sent();
|
|
133
|
+
return [4, this.graphApi.query({
|
|
134
|
+
graph: constants_1.GRAPH_NAME,
|
|
135
|
+
query: "MATCH (md: DOMAIN {id: \"memory-default-domain\"}), (m: MEMORY)\n CREATE (md)-[r: INCLUDES]->(m)",
|
|
136
|
+
params: {},
|
|
137
|
+
})];
|
|
138
|
+
case 3:
|
|
139
|
+
_a.sent();
|
|
140
|
+
return [2];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
return Migration__4;
|
|
146
|
+
}(migration_base_1.MigrationBase));
|
|
147
|
+
exports.default = Migration__4;
|
|
148
|
+
//# sourceMappingURL=Migration__4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration__4.js","sourceRoot":"","sources":["../../../src/migrations/Migration__4.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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,SAKE,CAAC;wBAEH,WAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;gCACxB,KAAK,EAAE,sBAAU;gCACjB,KAAK,EAAE,2GAC4B;gCACnC,MAAM,EAAE,EAAE;6BACX,CAAC,EAAA;;wBALF,SAKE,CAAC;;;;;KACJ;IACH,mBAAC;AAAD,CAAC,AAlDD,CAA0C,8BAAa,GAkDtD"}
|
|
@@ -3,9 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Migration__2 = exports.Migration__1 = void 0;
|
|
6
|
+
exports.Migration__4 = exports.Migration__3 = exports.Migration__2 = exports.Migration__1 = void 0;
|
|
7
7
|
var Migration__1_1 = require("./Migration__1");
|
|
8
8
|
Object.defineProperty(exports, "Migration__1", { enumerable: true, get: function () { return __importDefault(Migration__1_1).default; } });
|
|
9
9
|
var Migration__2_1 = require("./Migration__2");
|
|
10
10
|
Object.defineProperty(exports, "Migration__2", { enumerable: true, get: function () { return __importDefault(Migration__2_1).default; } });
|
|
11
|
+
var Migration__3_1 = require("./Migration__3");
|
|
12
|
+
Object.defineProperty(exports, "Migration__3", { enumerable: true, get: function () { return __importDefault(Migration__3_1).default; } });
|
|
13
|
+
var Migration__4_1 = require("./Migration__4");
|
|
14
|
+
Object.defineProperty(exports, "Migration__4", { enumerable: true, get: function () { return __importDefault(Migration__4_1).default; } });
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migrations/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB;AAChC,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migrations/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB;AAChC,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB;AAChC,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB;AAChC,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB"}
|
package/dist/esm/idw.js
CHANGED
|
@@ -14,6 +14,7 @@ import { Users } from '@or-sdk/users';
|
|
|
14
14
|
import { Accounts } from '@or-sdk/accounts';
|
|
15
15
|
import { GRAPH_NAME, SERVICE_KEY } from './constants';
|
|
16
16
|
import MigrationHandler from './migration-handler';
|
|
17
|
+
import { Flows } from '@or-sdk/flows';
|
|
17
18
|
export class IDW extends Base {
|
|
18
19
|
constructor(params) {
|
|
19
20
|
const { accountId, discoveryUrl, graphUrl, sdkApiUrl, token, } = params;
|
|
@@ -44,8 +45,12 @@ export class IDW extends Base {
|
|
|
44
45
|
token,
|
|
45
46
|
sdkUrl: sdkApiUrl,
|
|
46
47
|
});
|
|
48
|
+
this.flows = new Flows({
|
|
49
|
+
token,
|
|
50
|
+
discoveryUrl,
|
|
51
|
+
});
|
|
47
52
|
this.accountId = accountId;
|
|
48
|
-
this.migrationHandler = new MigrationHandler(this.graphApi, this.users, this.accounts, this.settings, this.accountId);
|
|
53
|
+
this.migrationHandler = new MigrationHandler(this.graphApi, this.users, this.accounts, this.settings, this.accountId, this.flows);
|
|
49
54
|
}
|
|
50
55
|
runMigrations() {
|
|
51
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -56,12 +61,10 @@ export class IDW extends Base {
|
|
|
56
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
62
|
try {
|
|
58
63
|
yield this.graphApi.getGraphInfo(GRAPH_NAME);
|
|
59
|
-
return true;
|
|
60
64
|
}
|
|
61
65
|
catch (e) {
|
|
62
66
|
this.createDb();
|
|
63
67
|
this.migrationHandler.deleteMigrationVersion();
|
|
64
|
-
return false;
|
|
65
68
|
}
|
|
66
69
|
});
|
|
67
70
|
}
|
|
@@ -71,7 +74,7 @@ export class IDW extends Base {
|
|
|
71
74
|
});
|
|
72
75
|
}
|
|
73
76
|
createOrUpdateFlow(flow) {
|
|
74
|
-
var _a, _b;
|
|
77
|
+
var _a, _b, _c, _d, _e, _f;
|
|
75
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
79
|
const id = flow.id;
|
|
77
80
|
if (id === undefined) {
|
|
@@ -91,6 +94,7 @@ export class IDW extends Base {
|
|
|
91
94
|
flow.name = $name,
|
|
92
95
|
flow.updatedAt = $updatedAt,
|
|
93
96
|
flow.updatedBy = $username
|
|
97
|
+
flow.steps = $steps
|
|
94
98
|
ON CREATE
|
|
95
99
|
SET flow.createdAt = $createdAt,
|
|
96
100
|
flow.createdBy = $userId,
|
|
@@ -100,6 +104,7 @@ export class IDW extends Base {
|
|
|
100
104
|
flow.name = $name,
|
|
101
105
|
flow.updatedAt = $updatedAt,
|
|
102
106
|
flow.updatedBy = $username
|
|
107
|
+
flow.steps = $steps
|
|
103
108
|
RETURN flow
|
|
104
109
|
`, {
|
|
105
110
|
createdAt: flow.dateCreated,
|
|
@@ -110,6 +115,7 @@ export class IDW extends Base {
|
|
|
110
115
|
updatedAt: flow.dateModified,
|
|
111
116
|
username,
|
|
112
117
|
userId,
|
|
118
|
+
steps: (_d = (_c = (_b = (_a = flow.data.trees) === null || _a === void 0 ? void 0 : _a.main) === null || _b === void 0 ? void 0 : _b.steps) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
113
119
|
});
|
|
114
120
|
yield this.graphQuery(`
|
|
115
121
|
MATCH (flow:FLOW { id: $id })
|
|
@@ -117,8 +123,8 @@ export class IDW extends Base {
|
|
|
117
123
|
OPTIONAL MATCH (flow)-[skillRelations:IMPLEMENTS { isActive: false }]->(:SKILL)
|
|
118
124
|
DELETE channelRelations, skillRelations
|
|
119
125
|
`, { id });
|
|
120
|
-
const channel = (
|
|
121
|
-
const skills = (
|
|
126
|
+
const channel = (_e = flow.data.meta.idw) === null || _e === void 0 ? void 0 : _e.channel;
|
|
127
|
+
const skills = (_f = flow.data.meta.idw) === null || _f === void 0 ? void 0 : _f.skills;
|
|
122
128
|
if (channel !== undefined && channel.length !== 0) {
|
|
123
129
|
yield this.graphQuery(`
|
|
124
130
|
MATCH (flow:FLOW { id: $id }),
|