@or-sdk/idw 3.1.1 → 4.0.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 +13 -0
- package/dist/cjs/index.js +1 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/types/api/channelApi.d.ts +3 -1
- package/dist/types/api/channelApi.d.ts.map +1 -1
- package/dist/types/api/memoryApi.d.ts +1 -1
- package/dist/types/api/memoryApi.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/config.d.ts +0 -7
- package/dist/types/types/config.d.ts.map +1 -1
- package/package.json +3 -9
- package/src/api/channelApi.ts +1 -1
- package/src/api/memoryApi.ts +1 -1
- package/src/index.ts +0 -3
- package/src/types/config.ts +0 -28
- package/dist/cjs/idw.js +0 -323
- package/dist/cjs/idw.js.map +0 -1
- package/dist/cjs/migration-base.js +0 -72
- package/dist/cjs/migration-base.js.map +0 -1
- package/dist/cjs/migration-handler.js +0 -183
- package/dist/cjs/migration-handler.js.map +0 -1
- package/dist/cjs/migrations/Migration__1.js +0 -108
- package/dist/cjs/migrations/Migration__1.js.map +0 -1
- package/dist/cjs/migrations/Migration__2.js +0 -155
- package/dist/cjs/migrations/Migration__2.js.map +0 -1
- package/dist/cjs/migrations/Migration__3.js +0 -108
- package/dist/cjs/migrations/Migration__3.js.map +0 -1
- package/dist/cjs/migrations/index.js +0 -13
- package/dist/cjs/migrations/index.js.map +0 -1
- package/dist/esm/idw.js +0 -252
- package/dist/esm/idw.js.map +0 -1
- package/dist/esm/migration-base.js +0 -30
- package/dist/esm/migration-base.js.map +0 -1
- package/dist/esm/migration-handler.js +0 -86
- package/dist/esm/migration-handler.js.map +0 -1
- package/dist/esm/migrations/Migration__1.js +0 -40
- package/dist/esm/migrations/Migration__1.js.map +0 -1
- package/dist/esm/migrations/Migration__2.js +0 -80
- package/dist/esm/migrations/Migration__2.js.map +0 -1
- package/dist/esm/migrations/Migration__3.js +0 -53
- package/dist/esm/migrations/Migration__3.js.map +0 -1
- package/dist/esm/migrations/index.js +0 -4
- package/dist/esm/migrations/index.js.map +0 -1
- package/dist/types/idw.d.ts +0 -23
- package/dist/types/idw.d.ts.map +0 -1
- package/dist/types/migration-base.d.ts +0 -24
- package/dist/types/migration-base.d.ts.map +0 -1
- package/dist/types/migration-handler.d.ts +0 -20
- package/dist/types/migration-handler.d.ts.map +0 -1
- package/dist/types/migrations/Migration__1.d.ts +0 -6
- package/dist/types/migrations/Migration__1.d.ts.map +0 -1
- package/dist/types/migrations/Migration__2.d.ts +0 -7
- package/dist/types/migrations/Migration__2.d.ts.map +0 -1
- package/dist/types/migrations/Migration__3.d.ts +0 -5
- package/dist/types/migrations/Migration__3.d.ts.map +0 -1
- package/dist/types/migrations/index.d.ts +0 -4
- package/dist/types/migrations/index.d.ts.map +0 -1
- package/src/idw.ts +0 -291
- package/src/migration-base.ts +0 -35
- package/src/migration-handler.ts +0 -94
- package/src/migrations/Migration__1.ts +0 -33
- package/src/migrations/Migration__2.ts +0 -69
- package/src/migrations/Migration__3.ts +0 -45
- package/src/migrations/index.ts +0 -3
package/dist/esm/idw.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
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 { Settings } from '@or-sdk/settings';
|
|
11
|
-
import { Base } from '@or-sdk/base';
|
|
12
|
-
import { Graphs } from '@or-sdk/graph';
|
|
13
|
-
import { Users } from '@or-sdk/users';
|
|
14
|
-
import { Accounts } from '@or-sdk/accounts';
|
|
15
|
-
import { GRAPH_NAME, SERVICE_KEY } from './constants';
|
|
16
|
-
import MigrationHandler from './migration-handler';
|
|
17
|
-
import { Flows } from '@or-sdk/flows';
|
|
18
|
-
export class IDW extends Base {
|
|
19
|
-
constructor(params) {
|
|
20
|
-
const { accountId, discoveryUrl, graphUrl, sdkApiUrl, token, } = params;
|
|
21
|
-
super({
|
|
22
|
-
accountId,
|
|
23
|
-
discoveryUrl,
|
|
24
|
-
serviceKey: SERVICE_KEY,
|
|
25
|
-
token,
|
|
26
|
-
});
|
|
27
|
-
this.graphApi = new Graphs({
|
|
28
|
-
accountId,
|
|
29
|
-
discoveryUrl,
|
|
30
|
-
graphUrl,
|
|
31
|
-
token,
|
|
32
|
-
});
|
|
33
|
-
this.users = new Users({
|
|
34
|
-
accountId,
|
|
35
|
-
token,
|
|
36
|
-
discoveryUrl,
|
|
37
|
-
sdkUrl: sdkApiUrl,
|
|
38
|
-
});
|
|
39
|
-
this.accounts = new Accounts({
|
|
40
|
-
token,
|
|
41
|
-
discoveryUrl,
|
|
42
|
-
sdkUrl: sdkApiUrl,
|
|
43
|
-
});
|
|
44
|
-
this.settings = new Settings({
|
|
45
|
-
token,
|
|
46
|
-
sdkUrl: sdkApiUrl,
|
|
47
|
-
});
|
|
48
|
-
this.flows = new Flows({
|
|
49
|
-
token,
|
|
50
|
-
discoveryUrl,
|
|
51
|
-
});
|
|
52
|
-
this.accountId = accountId;
|
|
53
|
-
this.migrationHandler = new MigrationHandler(this.graphApi, this.users, this.accounts, this.settings, this.accountId, this.flows);
|
|
54
|
-
}
|
|
55
|
-
runMigrations() {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
yield this.migrationHandler.applyMigrations();
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
checkOrCreateDb() {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
try {
|
|
63
|
-
yield this.graphApi.getGraphInfo(GRAPH_NAME);
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
this.createDb();
|
|
67
|
-
this.migrationHandler.deleteMigrationVersion();
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
createDb() {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
yield this.graphApi.createGraph({ name: GRAPH_NAME });
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
createOrUpdateFlow(flow) {
|
|
77
|
-
var _a, _b, _c, _d, _e, _f;
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
const id = flow.id;
|
|
80
|
-
if (id === undefined) {
|
|
81
|
-
throw new Error('Only flows with id can be added to the IDW graph');
|
|
82
|
-
}
|
|
83
|
-
if (flow.isDeleted) {
|
|
84
|
-
return yield this.deleteFlow(id);
|
|
85
|
-
}
|
|
86
|
-
const { username, userId } = yield this.users.getCurrentUser();
|
|
87
|
-
yield this.graphQuery(`
|
|
88
|
-
MERGE (flow:FLOW { id: $id })
|
|
89
|
-
ON MATCH
|
|
90
|
-
SET flow.createdAt = $createdAt,
|
|
91
|
-
flow.createdBy = $userId,
|
|
92
|
-
flow.description = $description,
|
|
93
|
-
flow.groupId = $groupId,
|
|
94
|
-
flow.name = $name,
|
|
95
|
-
flow.updatedAt = $updatedAt,
|
|
96
|
-
flow.updatedBy = $username,
|
|
97
|
-
flow.steps = $steps
|
|
98
|
-
ON CREATE
|
|
99
|
-
SET flow.createdAt = $createdAt,
|
|
100
|
-
flow.createdBy = $userId,
|
|
101
|
-
flow.description = $description,
|
|
102
|
-
flow.groupId = $groupId,
|
|
103
|
-
flow.isActive = false,
|
|
104
|
-
flow.name = $name,
|
|
105
|
-
flow.updatedAt = $updatedAt,
|
|
106
|
-
flow.updatedBy = $username,
|
|
107
|
-
flow.steps = $steps
|
|
108
|
-
RETURN flow
|
|
109
|
-
`, {
|
|
110
|
-
createdAt: flow.dateCreated,
|
|
111
|
-
description: flow.data.description,
|
|
112
|
-
groupId: flow.botId,
|
|
113
|
-
id,
|
|
114
|
-
name: flow.data.label,
|
|
115
|
-
updatedAt: flow.dateModified,
|
|
116
|
-
username,
|
|
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,
|
|
119
|
-
});
|
|
120
|
-
yield this.graphQuery(`
|
|
121
|
-
MATCH (flow:FLOW { id: $id })
|
|
122
|
-
OPTIONAL MATCH (flow)-[channelRelations:IMPLEMENTS { isActive: false }]->(:CHANNEL)
|
|
123
|
-
OPTIONAL MATCH (flow)-[skillRelations:IMPLEMENTS { isActive: false }]->(:SKILL)
|
|
124
|
-
DELETE channelRelations, skillRelations
|
|
125
|
-
`, { id });
|
|
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;
|
|
128
|
-
if (channel !== undefined && channel.length !== 0) {
|
|
129
|
-
yield this.graphQuery(`
|
|
130
|
-
MATCH (flow:FLOW { id: $id }),
|
|
131
|
-
(channel:CHANNEL { id: $channel })
|
|
132
|
-
MERGE (flow)-[relationship:IMPLEMENTS]->(channel)
|
|
133
|
-
ON CREATE
|
|
134
|
-
SET relationship.isActive = false
|
|
135
|
-
`, {
|
|
136
|
-
channel,
|
|
137
|
-
id,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
if (skills === null || skills === void 0 ? void 0 : skills.length) {
|
|
141
|
-
const preparedIds = skills.map(id => `'${id}'`);
|
|
142
|
-
yield this.graphQuery(`
|
|
143
|
-
MATCH (flow:FLOW { id: $id }), (skill:SKILL)
|
|
144
|
-
WHERE skill.id in [${preparedIds}]
|
|
145
|
-
MERGE (flow)-[relationship:IMPLEMENTS]->(skill)
|
|
146
|
-
ON CREATE
|
|
147
|
-
SET relationship.isActive = false
|
|
148
|
-
`, {
|
|
149
|
-
id,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
deleteFlow(id) {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
yield this.graphQuery(`
|
|
157
|
-
MATCH (flow:FLOW { id: $id })
|
|
158
|
-
DETACH DELETE flow
|
|
159
|
-
`, { id });
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
deleteFlows(ids) {
|
|
163
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
-
if (ids.length) {
|
|
165
|
-
yield this.graphQuery(`
|
|
166
|
-
MATCH (flow:FLOW)
|
|
167
|
-
where flow.id in [${ids.map(id => `'${id}'`)}]
|
|
168
|
-
DETACH DELETE flow
|
|
169
|
-
`);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
activateFlow(flow) {
|
|
174
|
-
var _a, _b;
|
|
175
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
-
const id = flow.id;
|
|
177
|
-
if (id === undefined) {
|
|
178
|
-
throw new Error('Only flows with id can be added to the IDW graph');
|
|
179
|
-
}
|
|
180
|
-
yield this.graphQuery(`
|
|
181
|
-
MATCH (flow:FLOW { id: $id })
|
|
182
|
-
OPTIONAL MATCH (flow)-[channelRelations:IMPLEMENTS]->(:CHANNEL)
|
|
183
|
-
OPTIONAL MATCH (flow)-[skillRelations:IMPLEMENTS]->(:SKILL)
|
|
184
|
-
DELETE channelRelations, skillRelations
|
|
185
|
-
SET flow.activatedAt = $activatedAt,
|
|
186
|
-
flow.isActive = true
|
|
187
|
-
`, {
|
|
188
|
-
activatedAt: Date.now(),
|
|
189
|
-
id,
|
|
190
|
-
});
|
|
191
|
-
const channel = (_a = flow.data.meta.idw) === null || _a === void 0 ? void 0 : _a.channel;
|
|
192
|
-
const skills = (_b = flow.data.meta.idw) === null || _b === void 0 ? void 0 : _b.skills;
|
|
193
|
-
if (channel !== undefined && channel.length !== 0) {
|
|
194
|
-
yield this.graphQuery(`
|
|
195
|
-
MATCH (flow:FLOW { id: $id }),
|
|
196
|
-
(channel:CHANNEL { id: $channel })
|
|
197
|
-
MERGE (flow)-[relationship:IMPLEMENTS]->(channel)
|
|
198
|
-
SET relationship.isActive = true
|
|
199
|
-
`, {
|
|
200
|
-
channel,
|
|
201
|
-
id,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
if (skills === null || skills === void 0 ? void 0 : skills.length) {
|
|
205
|
-
const preparedIds = skills.map(id => `'${id}'`);
|
|
206
|
-
yield this.graphQuery(`
|
|
207
|
-
MATCH (flow:FLOW { id: $id }), (skill:SKILL)
|
|
208
|
-
WHERE skill.id in [${preparedIds}]
|
|
209
|
-
MERGE (flow)-[relationship:IMPLEMENTS]->(skill)
|
|
210
|
-
SET relationship.isActive = true
|
|
211
|
-
`, {
|
|
212
|
-
id,
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
deactivateFlow(id) {
|
|
218
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
219
|
-
yield this.graphQuery(`
|
|
220
|
-
MATCH (flow:FLOW { id: $id })
|
|
221
|
-
OPTIONAL MATCH (flow)-[channelRelations:IMPLEMENTS]->(:CHANNEL)
|
|
222
|
-
OPTIONAL MATCH (flow)-[skillRelations:IMPLEMENTS]->(:SKILL)
|
|
223
|
-
SET flow.isActive = false,
|
|
224
|
-
channelRelations.isActive = false,
|
|
225
|
-
skillRelations.isActive = false
|
|
226
|
-
REMOVE flow.activatedAt
|
|
227
|
-
RETURN flow
|
|
228
|
-
`, { id });
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
graphQuery(query, params) {
|
|
232
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
-
try {
|
|
234
|
-
yield this.checkOrCreateDb();
|
|
235
|
-
}
|
|
236
|
-
catch (e) {
|
|
237
|
-
console.warn(e);
|
|
238
|
-
}
|
|
239
|
-
try {
|
|
240
|
-
return yield this.graphApi.query({
|
|
241
|
-
graph: GRAPH_NAME,
|
|
242
|
-
params,
|
|
243
|
-
query,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
catch (e) {
|
|
247
|
-
console.warn(e);
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
//# sourceMappingURL=idw.js.map
|
package/dist/esm/idw.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EACT,KAAK,GACN,GAAG,MAAM,CAAC;QAEX,KAAK,CAAC;YACJ,SAAS;YACT,YAAY;YACZ,UAAU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AO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACjD,MAAM,IAAI,CAAC,UAAU,CAAC;;;;;OAKrB,EAAE;oBACD,OAAO;oBACP,EAAE;iBACH,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"}
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
export class MigrationBase {
|
|
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;
|
|
18
|
-
}
|
|
19
|
-
resolveAccountId() {
|
|
20
|
-
var _a;
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
return (_a = this.accountId) !== null && _a !== void 0 ? _a : (() => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const { accountId } = yield this.users.getCurrentUser();
|
|
24
|
-
this.accountId = accountId;
|
|
25
|
-
return accountId;
|
|
26
|
-
}))();
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=migration-base.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,86 +0,0 @@
|
|
|
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 { SERVICE_KEY, VERSION_PROP } from './constants';
|
|
11
|
-
import * as migrations from './migrations';
|
|
12
|
-
const PREFIX = 'Migration__';
|
|
13
|
-
export default class MigrationHandler {
|
|
14
|
-
constructor(graphApi, users, accounts, settings, accountId, flows) {
|
|
15
|
-
this.graphApi = graphApi;
|
|
16
|
-
this.users = users;
|
|
17
|
-
this.accounts = accounts;
|
|
18
|
-
this.settings = settings;
|
|
19
|
-
this.accountId = accountId;
|
|
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
|
-
]));
|
|
25
|
-
}
|
|
26
|
-
applyMigrations() {
|
|
27
|
-
var _a;
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const accountsLatestVersion = (_a = (yield this.findAccountsMigrationVersion())) !== null && _a !== void 0 ? _a : 0;
|
|
30
|
-
const migrationVersions = Array.from(this.migrations.keys()).map(migrationName => {
|
|
31
|
-
const [, version] = migrationName.split(PREFIX);
|
|
32
|
-
return Number(version);
|
|
33
|
-
}).sort();
|
|
34
|
-
for (let i = 0; i < migrationVersions.length; i++) {
|
|
35
|
-
if (migrationVersions[i] > accountsLatestVersion) {
|
|
36
|
-
const migration = this.migrations.get(PREFIX + migrationVersions[i]);
|
|
37
|
-
if (migration) {
|
|
38
|
-
try {
|
|
39
|
-
yield migration.up();
|
|
40
|
-
yield this.saveVersion(migrationVersions[i]);
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
throw new Error(`Migration ${migration.constructor.name} is not applied`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
saveVersion(currentLatestVersion) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
try {
|
|
53
|
-
const params = {
|
|
54
|
-
key: `${SERVICE_KEY}.${VERSION_PROP}`,
|
|
55
|
-
value: currentLatestVersion,
|
|
56
|
-
};
|
|
57
|
-
yield this.settings.setAccountSettings(params);
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
throw new Error(`Error while saving migration "${PREFIX + currentLatestVersion}"`);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
deleteMigrationVersion() {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const params = {
|
|
67
|
-
key: `${SERVICE_KEY}.${VERSION_PROP}`,
|
|
68
|
-
};
|
|
69
|
-
yield this.settings.deleteAccountSettings(params);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
findAccountsMigrationVersion() {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
try {
|
|
75
|
-
const params = {
|
|
76
|
-
key: `${SERVICE_KEY}.${VERSION_PROP}`,
|
|
77
|
-
};
|
|
78
|
-
return yield this.settings.getAccountSettings(params);
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
throw new Error('Error while getting account settings');
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=migration-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,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;QAGpB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CACvB,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;aACtB,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,CACjB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,KAAK,CACX;SACF,CAAC,CACL,CAAC;IACJ,CAAC;IAEK,eAAe;;;YACnB,MAAM,qBAAqB,GAAG,MAA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,iCAAiC,MAAM,GAAG,oBAAoB,GAAG,CAAC,CAAC;aACpF;QACH,CAAC;KAAA;IAEK,sBAAsB;;YAC1B,MAAM,MAAM,GAAG;gBACb,GAAG,EAAE,GAAG,WAAW,IAAI,YAAY,EAAE;aACT,CAAC;YAC/B,MAAM,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC;KAAA;IAEK,4BAA4B;;YAChC,IAAI;gBACF,MAAM,MAAM,GAAG;oBACb,GAAG,EAAE,GAAG,WAAW,IAAI,YAAY,EAAE;iBACtC,CAAC;gBACF,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;aACvD;YAAC,OAAO,CAAC,EAAE;gBAEV,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;aACzD;QACH,CAAC;KAAA;CACF"}
|
|
@@ -1,40 +0,0 @@
|
|
|
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 { MigrationBase } from '../migration-base';
|
|
11
|
-
const idwSetupData = {
|
|
12
|
-
description: 'Add a fancy description to your IDW',
|
|
13
|
-
role: 'You can set your IDW\'s role/s just by chatting with the embedded RWC',
|
|
14
|
-
avatar: 'https://files.qa.api.onereach.ai/public/03db4abe-0477-47c0-ae4e-4c68f1047d59/IDW/IDWs-media-data/Img.png',
|
|
15
|
-
};
|
|
16
|
-
export default class Migration__1 extends MigrationBase {
|
|
17
|
-
up() {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
yield this.checkOrSetupIDWInfo();
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
checkOrSetupIDWInfo() {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const accountId = yield this.resolveAccountId();
|
|
25
|
-
const idwData = yield this.accounts.getIdwData(accountId);
|
|
26
|
-
const hasIdwInfo = Boolean(idwData && idwData.name && idwData.role);
|
|
27
|
-
if (!hasIdwInfo) {
|
|
28
|
-
const { name, role, description, avatar } = idwData;
|
|
29
|
-
yield this.accounts.updateIdwData(accountId, {
|
|
30
|
-
name,
|
|
31
|
-
role: (role === null || role === void 0 ? void 0 : role.trim()) || idwSetupData.role,
|
|
32
|
-
description: (description === null || description === void 0 ? void 0 : description.trim()) || idwSetupData.description,
|
|
33
|
-
avatar: (avatar === null || avatar === void 0 ? void 0 : avatar.trim()) || idwSetupData.avatar,
|
|
34
|
-
});
|
|
35
|
-
return new Promise(res => setTimeout(res, 60000));
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=Migration__1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Migration__1.js","sourceRoot":"","sources":["../../../src/migrations/Migration__1.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,YAAY,GAAG;IACnB,WAAW,EAAE,qCAAqC;IAClD,IAAI,EAAE,uEAAuE;IAC7E,MAAM,EAAE,0GAA0G;CACnH,CAAC;AAGF,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,aAAa;IAC/C,EAAE;;YACN,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACnC,CAAC;KAAA;IAEK,mBAAmB;;YACvB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAChD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;YAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;YAEpE,IAAI,CAAC,UAAU,EAAE;gBACf,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;gBACpD,MAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE;oBAC3C,IAAI;oBAEJ,IAAI,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,KAAI,YAAY,CAAC,IAAI;oBACvC,WAAW,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,EAAE,KAAI,YAAY,CAAC,WAAW;oBAC5D,MAAM,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,EAAE,KAAI,YAAY,CAAC,MAAM;iBAC9C,CAAC,CAAC;gBAEH,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;aACnD;QACH,CAAC;KAAA;CACF"}
|
|
@@ -1,80 +0,0 @@
|
|
|
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
|
-
const startUpChannels = [
|
|
13
|
-
{
|
|
14
|
-
id: 'facebook-messenger',
|
|
15
|
-
name: 'Facebook Messenger',
|
|
16
|
-
icon: 'https://files.qa.api.onereach.ai/public/9c1b43df-0f7c-43fe-819f-be9df1f39759/channel-icons/messenger.png',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: 'sms',
|
|
20
|
-
name: 'SMS',
|
|
21
|
-
icon: 'https://files.qa.api.onereach.ai/public/9c1b43df-0f7c-43fe-819f-be9df1f39759/channel-icons/sms.png',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
id: 'telegram',
|
|
25
|
-
name: 'Telegram',
|
|
26
|
-
icon: 'https://files.qa.api.onereach.ai/public/9c1b43df-0f7c-43fe-819f-be9df1f39759/channel-icons/telegram.png',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
id: 'twitter',
|
|
30
|
-
name: 'Twitter',
|
|
31
|
-
icon: 'https://files.qa.api.onereach.ai/public/9c1b43df-0f7c-43fe-819f-be9df1f39759/channel-icons/twitter.png',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: 'viber',
|
|
35
|
-
name: 'Viber',
|
|
36
|
-
icon: 'https://files.qa.api.onereach.ai/public/9c1b43df-0f7c-43fe-819f-be9df1f39759/channel-icons/viber.png',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: 'viber-business',
|
|
40
|
-
name: 'Viber Business',
|
|
41
|
-
icon: 'https://files.qa.api.onereach.ai/public/9c1b43df-0f7c-43fe-819f-be9df1f39759/channel-icons/viber.png',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: 'whatsapp',
|
|
45
|
-
name: 'WhatsApp',
|
|
46
|
-
icon: 'https://files.qa.api.onereach.ai/public/9c1b43df-0f7c-43fe-819f-be9df1f39759/channel-icons/whatsapp.png',
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
export default class Migration__2 extends MigrationBase {
|
|
50
|
-
up() {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const channelsExist = yield this.checkIfChannelsExist();
|
|
53
|
-
if (!channelsExist) {
|
|
54
|
-
yield this.createChannels();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
createChannels() {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
yield this.graphApi.query({
|
|
61
|
-
graph: GRAPH_NAME,
|
|
62
|
-
query: `CREATE ${startUpChannels.map(({ id, name, icon }) => {
|
|
63
|
-
return `(:CHANNEL {id: '${id}', name: '${name}', icon: '${icon}'})`;
|
|
64
|
-
}).join(', ')}`,
|
|
65
|
-
params: {},
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
checkIfChannelsExist() {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const [data] = yield this.graphApi.query({
|
|
72
|
-
graph: GRAPH_NAME,
|
|
73
|
-
query: 'MATCH (channels: CHANNEL) RETURN collect(DISTINCT channels) as channels',
|
|
74
|
-
params: {},
|
|
75
|
-
});
|
|
76
|
-
return data.channels.length > 0;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=Migration__2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Migration__2.js","sourceRoot":"","sources":["../../../src/migrations/Migration__2.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,eAAe,GAA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AAM,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAuB;gBAC7D,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,yEAAyE;gBAChF,MAAM,EAAE,EAAE;aACX,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QAClC,CAAC;KAAA;CACF"}
|
|
@@ -1,53 +0,0 @@
|
|
|
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 { 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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/types/idw.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Base } from '@or-sdk/base';
|
|
2
|
-
import { IDWConfig } from './types';
|
|
3
|
-
import { Flow } from '@or-sdk/deployer';
|
|
4
|
-
export declare class IDW extends Base {
|
|
5
|
-
private readonly graphApi;
|
|
6
|
-
private readonly users;
|
|
7
|
-
private readonly accounts;
|
|
8
|
-
private readonly settings;
|
|
9
|
-
private readonly flows;
|
|
10
|
-
private accountId;
|
|
11
|
-
private migrationHandler;
|
|
12
|
-
constructor(params: IDWConfig);
|
|
13
|
-
runMigrations(): Promise<void>;
|
|
14
|
-
checkOrCreateDb(): Promise<void>;
|
|
15
|
-
private createDb;
|
|
16
|
-
createOrUpdateFlow(flow: Flow): Promise<void>;
|
|
17
|
-
deleteFlow(id: string): Promise<void>;
|
|
18
|
-
deleteFlows(ids: string[]): Promise<void>;
|
|
19
|
-
activateFlow(flow: Flow): Promise<void>;
|
|
20
|
-
deactivateFlow(id: string): Promise<void>;
|
|
21
|
-
private graphQuery;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=idw.d.ts.map
|
package/dist/types/idw.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE;IAUzB,YAAY,CAAC,IAAI,EAAE,IAAI;IA8CvB,cAAc,CAAC,EAAE,EAAE,MAAM;YAajB,UAAU;CAoBzB"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Accounts } from '@or-sdk/accounts';
|
|
2
|
-
import { Graphs } from '@or-sdk/graph';
|
|
3
|
-
import { Settings } from '@or-sdk/settings';
|
|
4
|
-
import { Users } from '@or-sdk/users';
|
|
5
|
-
import { Flows } from '@or-sdk/flows';
|
|
6
|
-
export interface MigrationsParams {
|
|
7
|
-
graphApi: Graphs;
|
|
8
|
-
users: Users;
|
|
9
|
-
accounts: Accounts;
|
|
10
|
-
settings: Settings;
|
|
11
|
-
accountId: string | undefined;
|
|
12
|
-
}
|
|
13
|
-
export declare abstract class MigrationBase {
|
|
14
|
-
protected graphApi: Graphs;
|
|
15
|
-
protected users: Users;
|
|
16
|
-
protected accounts: Accounts;
|
|
17
|
-
protected settings: Settings;
|
|
18
|
-
protected accountId: string | undefined;
|
|
19
|
-
protected flows: Flows;
|
|
20
|
-
constructor(graphApi: Graphs, users: Users, accounts: Accounts, settings: Settings, accountId: string | undefined, flows: Flows);
|
|
21
|
-
abstract up(): Promise<void>;
|
|
22
|
-
protected resolveAccountId(): Promise<string>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=migration-base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|