@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/dist/esm/idw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idw.js","sourceRoot":"","sources":["../../src/idw.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"idw.js","sourceRoot":"","sources":["../../src/idw.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAQtC,MAAM,OAAO,GAAI,SAAQ,IAAI;IAoB3B,YAAY,MAAiB;QAC3B,MAAM,EACJ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,SAAS,EAC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BACH,CAAC,CAAC;aACJ;YAED,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;gBAClB,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;gBAChD,MAAM,IAAI,CAAC,UAAU,CAAC;;6BAEC,WAAW;;;OAGjC,EAAE;oBACD,EAAE;iBACH,CAAC,CAAC;aACJ;;KACF;IAEK,cAAc,CAAC,EAAU;;YAC7B,MAAM,IAAI,CAAC,UAAU,CAAC;;;;;;;;;KASrB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACb,CAAC;KAAA;IAEa,UAAU,CAAC,KAAa,EAAE,MAAyD;;YAE/F,IAAI;gBACF,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;aAC9B;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAEjB;YAED,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;gBACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAEjB;QACH,CAAC;KAAA;CACF"}
|
|
@@ -8,12 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
export class MigrationBase {
|
|
11
|
-
constructor(
|
|
12
|
-
this.graphApi =
|
|
13
|
-
this.users =
|
|
14
|
-
this.accounts =
|
|
15
|
-
this.settings =
|
|
16
|
-
this.accountId =
|
|
11
|
+
constructor(graphApi, users, accounts, settings, accountId, flows) {
|
|
12
|
+
this.graphApi = graphApi;
|
|
13
|
+
this.users = users;
|
|
14
|
+
this.accounts = accounts;
|
|
15
|
+
this.settings = settings;
|
|
16
|
+
this.accountId = accountId;
|
|
17
|
+
this.flows = flows;
|
|
17
18
|
}
|
|
18
19
|
resolveAccountId() {
|
|
19
20
|
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,MAAM,OAAgB,aAAa;IACjC,YACY,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,gBAAgB;;;YAC9B,OAAO,MAAA,IAAI,CAAC,SAAS,mCAAI,CAAC,GAAS,EAAE;gBACnC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;gBACxD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;gBAC3B,OAAO,SAAS,CAAC;YACnB,CAAC,CAAA,CAAC,EAAE,CAAC;;KACN;CACF"}
|
|
@@ -11,24 +11,22 @@ import { SERVICE_KEY, VERSION_PROP } from './constants';
|
|
|
11
11
|
import * as migrations from './migrations';
|
|
12
12
|
const PREFIX = 'Migration__';
|
|
13
13
|
export default class MigrationHandler {
|
|
14
|
-
constructor(graphApi, users, accounts, settings, accountId) {
|
|
14
|
+
constructor(graphApi, users, accounts, settings, accountId, flows) {
|
|
15
15
|
this.graphApi = graphApi;
|
|
16
16
|
this.users = users;
|
|
17
17
|
this.accounts = accounts;
|
|
18
18
|
this.settings = settings;
|
|
19
19
|
this.accountId = accountId;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
accounts,
|
|
24
|
-
|
|
25
|
-
accountId,
|
|
26
|
-
};
|
|
27
|
-
this.migrations = new Map(Object.values(migrations).map(ctor => [ctor.name, new ctor(params)]));
|
|
20
|
+
this.flows = flows;
|
|
21
|
+
this.migrations = new Map(Object.values(migrations)
|
|
22
|
+
.map(ctor => [
|
|
23
|
+
ctor.name, new ctor(this.graphApi, this.users, this.accounts, this.settings, this.accountId, this.flows),
|
|
24
|
+
]));
|
|
28
25
|
}
|
|
29
26
|
applyMigrations() {
|
|
27
|
+
var _a;
|
|
30
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const accountsLatestVersion = yield this.findAccountsMigrationVersion();
|
|
29
|
+
const accountsLatestVersion = (_a = (yield this.findAccountsMigrationVersion())) !== null && _a !== void 0 ? _a : 0;
|
|
32
30
|
const migrationVersions = Array.from(this.migrations.keys()).map(migrationName => {
|
|
33
31
|
const [, version] = migrationName.split(PREFIX);
|
|
34
32
|
return Number(version);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-handler.js","sourceRoot":"","sources":["../../src/migration-handler.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"migration-handler.js","sourceRoot":"","sources":["../../src/migration-handler.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAG3C,MAAM,MAAM,GAAG,aAAa,CAAC;AAE7B,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAGnC,YACU,QAAgB,EAChB,KAAY,EACZ,QAAkB,EAClB,QAAkB,EAClB,SAA6B,EAC7B,KAA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|
|
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 { MigrationBase } from '../migration-base';
|
|
11
|
+
import { GRAPH_NAME } from '../constants';
|
|
12
|
+
export default class Migration__3 extends MigrationBase {
|
|
13
|
+
up() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const flowsIds = yield this.graphApi.query({
|
|
16
|
+
graph: GRAPH_NAME,
|
|
17
|
+
query: `match (flow: FLOW)
|
|
18
|
+
where flow.steps is NULL
|
|
19
|
+
return flow.id as id
|
|
20
|
+
`,
|
|
21
|
+
params: {},
|
|
22
|
+
});
|
|
23
|
+
if (flowsIds.length) {
|
|
24
|
+
const preparedIds = flowsIds.map(f => f.id);
|
|
25
|
+
const flows = yield this.flows.listFlows({
|
|
26
|
+
query: {
|
|
27
|
+
id: preparedIds,
|
|
28
|
+
},
|
|
29
|
+
projection: ['data.trees.main.steps'],
|
|
30
|
+
});
|
|
31
|
+
const pairs = flows.items.map(flow => {
|
|
32
|
+
var _a, _b, _c;
|
|
33
|
+
return ({
|
|
34
|
+
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,
|
|
35
|
+
id: flow.id,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
yield this.graphApi.query({
|
|
39
|
+
graph: GRAPH_NAME,
|
|
40
|
+
query: `
|
|
41
|
+
unwind $list as pairs
|
|
42
|
+
MERGE (flow:FLOW { id: pairs.id })
|
|
43
|
+
SET flow.steps = pairs.steps
|
|
44
|
+
`,
|
|
45
|
+
params: {
|
|
46
|
+
list: pairs,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# 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,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,aAAa;IAC/C,EAAE;;YACN,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAgB;gBACxD,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE;;;eAGE;gBACT,MAAM,EAAE,EAAE;aACX,CAAC,CAAC;YAEH,IAAI,QAAQ,CAAC,MAAM,EAAE;gBACnB,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC5C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;oBACvC,KAAK,EAAE;wBACL,EAAE,EAAE,WAAW;qBAChB;oBACD,UAAU,EAAE,CAAC,uBAAuB,CAAC;iBACtC,CAAC,CAAC;gBAEH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;;oBAAC,OAAA,CACpC;wBACE,KAAK,EAAE,MAAA,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,IAAI,CAAC,KAAK,0CAAE,MAAM,mCAAI,CAAC;wBAC/C,EAAE,EAAE,IAAI,CAAC,EAAE;qBACZ,CAAC,CAAA;iBAAA,CACH,CAAC;gBAEF,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;oBACxB,KAAK,EAAE,UAAU;oBACjB,KAAK,EAAE;;;;eAIA;oBACP,MAAM,EAAE;wBACN,IAAI,EAAE,KAAY;qBACnB;iBACF,CAAC,CAAC;aACJ;QACH,CAAC;KAAA;CACF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 { GRAPH_NAME } from '../constants';
|
|
11
|
+
import { MigrationBase } from '../migration-base';
|
|
12
|
+
export default class Migration__4 extends MigrationBase {
|
|
13
|
+
up() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const channelsExist = yield this.checkIfDomainsExist();
|
|
16
|
+
if (!channelsExist) {
|
|
17
|
+
yield this.createDefaultDomains();
|
|
18
|
+
yield this.connectNodesToDefaultDomains();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
checkIfDomainsExist() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const [data] = yield this.graphApi.query({
|
|
25
|
+
graph: GRAPH_NAME,
|
|
26
|
+
query: 'MATCH (domains: DOMAIN) RETURN collect(DISTINCT domains) as domains',
|
|
27
|
+
params: {},
|
|
28
|
+
});
|
|
29
|
+
return data.domains.length > 0;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
createDefaultDomains() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
yield this.graphApi.query({
|
|
35
|
+
graph: GRAPH_NAME,
|
|
36
|
+
query: `CREATE (sd: DOMAIN {id: "skills-default-domain", name: "Default"}),
|
|
37
|
+
(cd: DOMAIN {id: "channels-default-domain", name: "Default"}),
|
|
38
|
+
(md: DOMAIN {id: "memory-default-domain", name: "Default"})`,
|
|
39
|
+
params: {},
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
connectNodesToDefaultDomains() {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
yield this.graphApi.query({
|
|
46
|
+
graph: GRAPH_NAME,
|
|
47
|
+
query: `MATCH (sd: DOMAIN {id: "skills-default-domain"}), (s: SKILL)
|
|
48
|
+
CREATE (sd)-[r: INCLUDES]->(s)`,
|
|
49
|
+
params: {},
|
|
50
|
+
});
|
|
51
|
+
yield this.graphApi.query({
|
|
52
|
+
graph: GRAPH_NAME,
|
|
53
|
+
query: `MATCH (cd: DOMAIN {id: "channels-default-domain"}), (c: CHANNEL)
|
|
54
|
+
CREATE (cd)-[r: INCLUDES]->(c)`,
|
|
55
|
+
params: {},
|
|
56
|
+
});
|
|
57
|
+
yield this.graphApi.query({
|
|
58
|
+
graph: GRAPH_NAME,
|
|
59
|
+
query: `MATCH (md: DOMAIN {id: "memory-default-domain"}), (m: MEMORY)
|
|
60
|
+
CREATE (md)-[r: INCLUDES]->(m)`,
|
|
61
|
+
params: {},
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=Migration__4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration__4.js","sourceRoot":"","sources":["../../../src/migrations/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AAU;gBACjB,KAAK,EAAE;yCAC4B;gBACnC,MAAM,EAAE,EAAE;aACX,CAAC,CAAC;QACL,CAAC;KAAA;CACF"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { default as Migration__1 } from './Migration__1';
|
|
2
2
|
export { default as Migration__2 } from './Migration__2';
|
|
3
|
+
export { default as Migration__3 } from './Migration__3';
|
|
4
|
+
export { default as Migration__4 } from './Migration__4';
|
|
3
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/types/idw.d.ts
CHANGED
|
@@ -6,11 +6,12 @@ export declare class IDW extends Base {
|
|
|
6
6
|
private readonly users;
|
|
7
7
|
private readonly accounts;
|
|
8
8
|
private readonly settings;
|
|
9
|
+
private readonly flows;
|
|
9
10
|
private accountId;
|
|
10
11
|
private migrationHandler;
|
|
11
12
|
constructor(params: IDWConfig);
|
|
12
13
|
runMigrations(): Promise<void>;
|
|
13
|
-
checkOrCreateDb(): Promise<
|
|
14
|
+
checkOrCreateDb(): Promise<void>;
|
|
14
15
|
private createDb;
|
|
15
16
|
createOrUpdateFlow(flow: Flow): Promise<void>;
|
|
16
17
|
deleteFlow(id: string): Promise<void>;
|
package/dist/types/idw.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idw.d.ts","sourceRoot":"","sources":["../../src/idw.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAKpC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"idw.d.ts","sourceRoot":"","sources":["../../src/idw.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAKpC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AASxC,qBAAa,GAAI,SAAQ,IAAI;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,gBAAgB,CAAmB;gBAa/B,MAAM,EAAE,SAAS;IAsDvB,aAAa;IAIb,eAAe;YAYP,QAAQ;IAIhB,kBAAkB,CAAC,IAAI,EAAE,IAAI;IAmF7B,UAAU,CAAC,EAAE,EAAE,MAAM;IAOrB,YAAY,CAAC,IAAI,EAAE,IAAI;IA8CvB,cAAc,CAAC,EAAE,EAAE,MAAM;YAajB,UAAU;CAoBzB"}
|
|
@@ -2,6 +2,7 @@ import { Accounts } from '@or-sdk/accounts';
|
|
|
2
2
|
import { Graphs } from '@or-sdk/graph';
|
|
3
3
|
import { Settings } from '@or-sdk/settings';
|
|
4
4
|
import { Users } from '@or-sdk/users';
|
|
5
|
+
import { Flows } from '@or-sdk/flows';
|
|
5
6
|
export interface MigrationsParams {
|
|
6
7
|
graphApi: Graphs;
|
|
7
8
|
users: Users;
|
|
@@ -15,7 +16,8 @@ export declare abstract class MigrationBase {
|
|
|
15
16
|
protected accounts: Accounts;
|
|
16
17
|
protected settings: Settings;
|
|
17
18
|
protected accountId: string | undefined;
|
|
18
|
-
|
|
19
|
+
protected flows: Flows;
|
|
20
|
+
constructor(graphApi: Graphs, users: Users, accounts: Accounts, settings: Settings, accountId: string | undefined, flows: Flows);
|
|
19
21
|
abstract up(): Promise<void>;
|
|
20
22
|
protected resolveAccountId(): Promise<string>;
|
|
21
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-base.d.ts","sourceRoot":"","sources":["../../src/migration-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,8BAAsB,aAAa;
|
|
1
|
+
{"version":3,"file":"migration-base.d.ts","sourceRoot":"","sources":["../../src/migration-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,8BAAsB,aAAa;IAE/B,SAAS,CAAC,QAAQ,EAAE,MAAM;IAC1B,SAAS,CAAC,KAAK,EAAE,KAAK;IACtB,SAAS,CAAC,QAAQ,EAAE,QAAQ;IAC5B,SAAS,CAAC,QAAQ,EAAE,QAAQ;IAC5B,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IACvC,SAAS,CAAC,KAAK,EAAE,KAAK;gBALZ,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,KAAK;IAIxB,QAAQ,CAAC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;cAEZ,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;CAOpD"}
|
|
@@ -2,14 +2,16 @@ import { Accounts } from '@or-sdk/accounts';
|
|
|
2
2
|
import { Graphs } from '@or-sdk/graph';
|
|
3
3
|
import { Users } from '@or-sdk/users';
|
|
4
4
|
import { Settings } from '@or-sdk/settings';
|
|
5
|
+
import { Flows } from '@or-sdk/flows';
|
|
5
6
|
export default class MigrationHandler {
|
|
6
7
|
private graphApi;
|
|
7
8
|
private users;
|
|
8
9
|
private accounts;
|
|
9
10
|
private settings;
|
|
10
11
|
private accountId;
|
|
12
|
+
private flows;
|
|
11
13
|
private migrations;
|
|
12
|
-
constructor(graphApi: Graphs, users: Users, accounts: Accounts, settings: Settings, accountId: string | undefined);
|
|
14
|
+
constructor(graphApi: Graphs, users: Users, accounts: Accounts, settings: Settings, accountId: string | undefined, flows: Flows);
|
|
13
15
|
applyMigrations(): Promise<void>;
|
|
14
16
|
saveVersion(currentLatestVersion: number): Promise<void>;
|
|
15
17
|
deleteMigrationVersion(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-handler.d.ts","sourceRoot":"","sources":["../../src/migration-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAA6B,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"migration-handler.d.ts","sourceRoot":"","sources":["../../src/migration-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAA6B,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIvE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAItC,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAIjC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,KAAK;IARf,OAAO,CAAC,UAAU,CAA6B;gBAGrC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,KAAK;IAkBhB,eAAe;IAwBf,WAAW,CAAC,oBAAoB,EAAE,MAAM;IAaxC,sBAAsB;IAOtB,4BAA4B;CAWnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration__3.d.ts","sourceRoot":"","sources":["../../../src/migrations/Migration__3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIlD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,aAAa;IAC/C,EAAE;CAuCT"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MigrationBase } from '../migration-base';
|
|
2
|
+
export default class Migration__4 extends MigrationBase {
|
|
3
|
+
up(): Promise<void>;
|
|
4
|
+
private checkIfDomainsExist;
|
|
5
|
+
private createDefaultDomains;
|
|
6
|
+
private connectNodesToDefaultDomains;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=Migration__4.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration__4.d.ts","sourceRoot":"","sources":["../../../src/migrations/Migration__4.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,aAAa;IAC/C,EAAE;YAQM,mBAAmB;YASnB,oBAAoB;YAUpB,4BAA4B;CAsB3C"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { default as Migration__1 } from './Migration__1';
|
|
2
2
|
export { default as Migration__2 } from './Migration__2';
|
|
3
|
+
export { default as Migration__3 } from './Migration__3';
|
|
4
|
+
export { default as Migration__4 } from './Migration__4';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.4.0-beta.
|
|
2
|
+
"version": "1.4.0-beta.1545.0",
|
|
3
3
|
"name": "@or-sdk/idw",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@or-sdk/accounts": "^1.2.13",
|
|
28
28
|
"@or-sdk/base": "^0.28.3",
|
|
29
29
|
"@or-sdk/deployer": "^1.1.5",
|
|
30
|
+
"@or-sdk/flows": "^2.0.2",
|
|
30
31
|
"@or-sdk/graph": "^1.4.1",
|
|
31
32
|
"@or-sdk/settings": "^0.24.11",
|
|
32
33
|
"@or-sdk/users": "^0.30.2",
|
package/src/idw.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { GRAPH_NAME, SERVICE_KEY } from './constants';
|
|
|
7
7
|
import { IDWConfig } from './types';
|
|
8
8
|
import MigrationHandler from './migration-handler';
|
|
9
9
|
import { Flow } from '@or-sdk/deployer';
|
|
10
|
+
import { Flows } from '@or-sdk/flows';
|
|
10
11
|
/**
|
|
11
12
|
* OneReach IDW service client
|
|
12
13
|
* ## Installation:
|
|
@@ -19,6 +20,7 @@ export class IDW extends Base {
|
|
|
19
20
|
private readonly users: Users;
|
|
20
21
|
private readonly accounts: Accounts;
|
|
21
22
|
private readonly settings: Settings;
|
|
23
|
+
private readonly flows: Flows;
|
|
22
24
|
private accountId: string | undefined;
|
|
23
25
|
private migrationHandler: MigrationHandler;
|
|
24
26
|
|
|
@@ -70,6 +72,10 @@ export class IDW extends Base {
|
|
|
70
72
|
token,
|
|
71
73
|
sdkUrl: sdkApiUrl,
|
|
72
74
|
});
|
|
75
|
+
this.flows = new Flows({
|
|
76
|
+
token,
|
|
77
|
+
discoveryUrl,
|
|
78
|
+
});
|
|
73
79
|
|
|
74
80
|
this.accountId = accountId;
|
|
75
81
|
|
|
@@ -78,7 +84,8 @@ export class IDW extends Base {
|
|
|
78
84
|
this.users,
|
|
79
85
|
this.accounts,
|
|
80
86
|
this.settings,
|
|
81
|
-
this.accountId
|
|
87
|
+
this.accountId,
|
|
88
|
+
this.flows
|
|
82
89
|
);
|
|
83
90
|
}
|
|
84
91
|
|
|
@@ -86,22 +93,15 @@ export class IDW extends Base {
|
|
|
86
93
|
await this.migrationHandler.applyMigrations();
|
|
87
94
|
}
|
|
88
95
|
|
|
89
|
-
|
|
90
|
-
* Checks if the user has a IDW database in place, if not, it creates a new one
|
|
91
|
-
*
|
|
92
|
-
* @returns true is the database already existed, false if not
|
|
93
|
-
*/
|
|
94
|
-
async checkOrCreateDb(): Promise<boolean> {
|
|
96
|
+
async checkOrCreateDb() {
|
|
95
97
|
try {
|
|
96
98
|
await this.graphApi.getGraphInfo(GRAPH_NAME);
|
|
97
|
-
return true;
|
|
98
99
|
} catch (e) {
|
|
99
100
|
this.createDb();
|
|
100
101
|
// TODO: This function removes account setting storing the migration version
|
|
101
102
|
// to apply all migrations after creating db.
|
|
102
103
|
// Will be moved to the backend.
|
|
103
104
|
this.migrationHandler.deleteMigrationVersion();
|
|
104
|
-
return false;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -131,6 +131,7 @@ export class IDW extends Base {
|
|
|
131
131
|
flow.name = $name,
|
|
132
132
|
flow.updatedAt = $updatedAt,
|
|
133
133
|
flow.updatedBy = $username
|
|
134
|
+
flow.steps = $steps
|
|
134
135
|
ON CREATE
|
|
135
136
|
SET flow.createdAt = $createdAt,
|
|
136
137
|
flow.createdBy = $userId,
|
|
@@ -140,6 +141,7 @@ export class IDW extends Base {
|
|
|
140
141
|
flow.name = $name,
|
|
141
142
|
flow.updatedAt = $updatedAt,
|
|
142
143
|
flow.updatedBy = $username
|
|
144
|
+
flow.steps = $steps
|
|
143
145
|
RETURN flow
|
|
144
146
|
`, {
|
|
145
147
|
createdAt: flow.dateCreated,
|
|
@@ -150,6 +152,7 @@ export class IDW extends Base {
|
|
|
150
152
|
updatedAt: flow.dateModified,
|
|
151
153
|
username,
|
|
152
154
|
userId,
|
|
155
|
+
steps: flow.data.trees?.main?.steps?.length ?? 0,
|
|
153
156
|
});
|
|
154
157
|
|
|
155
158
|
await this.graphQuery(`
|
package/src/migration-base.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Accounts } from '@or-sdk/accounts';
|
|
|
2
2
|
import { Graphs } from '@or-sdk/graph';
|
|
3
3
|
import { Settings } from '@or-sdk/settings';
|
|
4
4
|
import { Users } from '@or-sdk/users';
|
|
5
|
+
import { Flows } from '@or-sdk/flows';
|
|
5
6
|
|
|
6
7
|
export interface MigrationsParams {
|
|
7
8
|
graphApi: Graphs;
|
|
@@ -12,18 +13,14 @@ export interface MigrationsParams {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export abstract class MigrationBase {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.users = params.users;
|
|
24
|
-
this.accounts = params.accounts;
|
|
25
|
-
this.settings = params.settings;
|
|
26
|
-
this.accountId = params.accountId;
|
|
16
|
+
constructor(
|
|
17
|
+
protected graphApi: Graphs,
|
|
18
|
+
protected users: Users,
|
|
19
|
+
protected accounts: Accounts,
|
|
20
|
+
protected settings: Settings,
|
|
21
|
+
protected accountId: string | undefined,
|
|
22
|
+
protected flows: Flows
|
|
23
|
+
) {
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
abstract up(): Promise<void>;
|
package/src/migration-handler.ts
CHANGED
|
@@ -5,27 +5,39 @@ import { AccountRouteDeletePayload, Settings } from '@or-sdk/settings';
|
|
|
5
5
|
import { MigrationBase } from './migration-base';
|
|
6
6
|
import { SERVICE_KEY, VERSION_PROP } from './constants';
|
|
7
7
|
import * as migrations from './migrations';
|
|
8
|
+
import { Flows } from '@or-sdk/flows';
|
|
8
9
|
|
|
9
10
|
const PREFIX = 'Migration__';
|
|
10
11
|
|
|
11
12
|
export default class MigrationHandler {
|
|
12
13
|
private migrations: Map<string, MigrationBase>;
|
|
13
14
|
|
|
14
|
-
constructor(
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
15
|
+
constructor(
|
|
16
|
+
private graphApi: Graphs,
|
|
17
|
+
private users: Users,
|
|
18
|
+
private accounts: Accounts,
|
|
19
|
+
private settings: Settings,
|
|
20
|
+
private accountId: string | undefined,
|
|
21
|
+
private flows: Flows
|
|
22
|
+
) {
|
|
23
23
|
|
|
24
|
-
this.migrations = new Map(
|
|
24
|
+
this.migrations = new Map(
|
|
25
|
+
Object.values(migrations)
|
|
26
|
+
.map(ctor => [
|
|
27
|
+
ctor.name, new ctor(
|
|
28
|
+
this.graphApi,
|
|
29
|
+
this.users,
|
|
30
|
+
this.accounts,
|
|
31
|
+
this.settings,
|
|
32
|
+
this.accountId,
|
|
33
|
+
this.flows
|
|
34
|
+
),
|
|
35
|
+
])
|
|
36
|
+
);
|
|
25
37
|
}
|
|
26
38
|
|
|
27
39
|
async applyMigrations() {
|
|
28
|
-
const accountsLatestVersion = await this.findAccountsMigrationVersion();
|
|
40
|
+
const accountsLatestVersion = (await this.findAccountsMigrationVersion()) ?? 0;
|
|
29
41
|
|
|
30
42
|
const migrationVersions = Array.from(this.migrations.keys()).map(migrationName => {
|
|
31
43
|
const [, version] = migrationName.split(PREFIX);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { MigrationBase } from '../migration-base';
|
|
2
|
+
import { GRAPH_NAME } from '../constants';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5
|
+
export default class Migration__3 extends MigrationBase {
|
|
6
|
+
async up() {
|
|
7
|
+
const flowsIds = await this.graphApi.query<{id: string;}>({
|
|
8
|
+
graph: GRAPH_NAME,
|
|
9
|
+
query: `match (flow: FLOW)
|
|
10
|
+
where flow.steps is NULL
|
|
11
|
+
return flow.id as id
|
|
12
|
+
`,
|
|
13
|
+
params: {},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
if (flowsIds.length) {
|
|
17
|
+
const preparedIds = flowsIds.map(f => f.id);
|
|
18
|
+
const flows = await this.flows.listFlows({
|
|
19
|
+
query: {
|
|
20
|
+
id: preparedIds,
|
|
21
|
+
},
|
|
22
|
+
projection: ['data.trees.main.steps'],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const pairs = flows.items.map(flow => (
|
|
26
|
+
{
|
|
27
|
+
steps: flow.data.trees?.main.steps?.length ?? 0,
|
|
28
|
+
id: flow.id,
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
await this.graphApi.query({
|
|
33
|
+
graph: GRAPH_NAME,
|
|
34
|
+
query: `
|
|
35
|
+
unwind $list as pairs
|
|
36
|
+
MERGE (flow:FLOW { id: pairs.id })
|
|
37
|
+
SET flow.steps = pairs.steps
|
|
38
|
+
`,
|
|
39
|
+
params: {
|
|
40
|
+
list: pairs as any,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { GRAPH_NAME } from '../constants';
|
|
2
|
+
import { MigrationBase } from '../migration-base';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5
|
+
export default class Migration__4 extends MigrationBase {
|
|
6
|
+
async up() {
|
|
7
|
+
const channelsExist = await this.checkIfDomainsExist();
|
|
8
|
+
if (!channelsExist) {
|
|
9
|
+
await this.createDefaultDomains();
|
|
10
|
+
await this.connectNodesToDefaultDomains();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private async checkIfDomainsExist() {
|
|
15
|
+
const [data] = await this.graphApi.query<{ domains: any[]; }>({
|
|
16
|
+
graph: GRAPH_NAME,
|
|
17
|
+
query: 'MATCH (domains: DOMAIN) RETURN collect(DISTINCT domains) as domains',
|
|
18
|
+
params: {},
|
|
19
|
+
});
|
|
20
|
+
return data.domains.length > 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private async createDefaultDomains() {
|
|
24
|
+
await this.graphApi.query({
|
|
25
|
+
graph: GRAPH_NAME,
|
|
26
|
+
query: `CREATE (sd: DOMAIN {id: "skills-default-domain", name: "Default"}),
|
|
27
|
+
(cd: DOMAIN {id: "channels-default-domain", name: "Default"}),
|
|
28
|
+
(md: DOMAIN {id: "memory-default-domain", name: "Default"})`,
|
|
29
|
+
params: {},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private async connectNodesToDefaultDomains() {
|
|
34
|
+
await this.graphApi.query({
|
|
35
|
+
graph: GRAPH_NAME,
|
|
36
|
+
query: `MATCH (sd: DOMAIN {id: "skills-default-domain"}), (s: SKILL)
|
|
37
|
+
CREATE (sd)-[r: INCLUDES]->(s)`,
|
|
38
|
+
params: {},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
await this.graphApi.query({
|
|
42
|
+
graph: GRAPH_NAME,
|
|
43
|
+
query: `MATCH (cd: DOMAIN {id: "channels-default-domain"}), (c: CHANNEL)
|
|
44
|
+
CREATE (cd)-[r: INCLUDES]->(c)`,
|
|
45
|
+
params: {},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
await this.graphApi.query({
|
|
49
|
+
graph: GRAPH_NAME,
|
|
50
|
+
query: `MATCH (md: DOMAIN {id: "memory-default-domain"}), (m: MEMORY)
|
|
51
|
+
CREATE (md)-[r: INCLUDES]->(m)`,
|
|
52
|
+
params: {},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|