@friggframework/core 2.0.0--canary.396.5afebde.0 → 2.0.0--canary.396.55167ab.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.
|
@@ -2,7 +2,16 @@ const { IntegrationModel } = require('./integration-model');
|
|
|
2
2
|
|
|
3
3
|
class IntegrationRepository {
|
|
4
4
|
async findIntegrationsByUserId(userId) {
|
|
5
|
-
|
|
5
|
+
const integrationRecords = await IntegrationModel.find({ user: userId }, '', { lean: true }).populate('entities');
|
|
6
|
+
return integrationRecords.map(integrationRecord => ({
|
|
7
|
+
id: integrationRecord._id,
|
|
8
|
+
entitiesIds: integrationRecord.entities.map(e => e._id),
|
|
9
|
+
userId: integrationRecord.user,
|
|
10
|
+
config: integrationRecord.config,
|
|
11
|
+
version: integrationRecord.version,
|
|
12
|
+
status: integrationRecord.status,
|
|
13
|
+
messages: integrationRecord.messages,
|
|
14
|
+
}));
|
|
6
15
|
}
|
|
7
16
|
|
|
8
17
|
async deleteIntegrationById(integrationId) {
|
|
@@ -2,7 +2,7 @@ const { Integration } = require('../integration');
|
|
|
2
2
|
const { mapIntegrationClassToIntegrationDTO } = require('../utils/map-integration-dto');
|
|
3
3
|
|
|
4
4
|
class GetIntegrationsForUser {
|
|
5
|
-
constructor({ integrationRepository, integrationClasses, moduleService }) {
|
|
5
|
+
constructor({ integrationRepository, integrationClasses, moduleService, moduleRepository }) {
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @type {import('../integration-repository').IntegrationRepository}
|
|
@@ -10,6 +10,7 @@ class GetIntegrationsForUser {
|
|
|
10
10
|
this.integrationRepository = integrationRepository;
|
|
11
11
|
this.integrationClasses = integrationClasses;
|
|
12
12
|
this.moduleService = moduleService;
|
|
13
|
+
this.moduleRepository = moduleRepository;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -22,24 +23,25 @@ class GetIntegrationsForUser {
|
|
|
22
23
|
const integrations = []
|
|
23
24
|
|
|
24
25
|
for (const integrationRecord of integrationRecords) {
|
|
26
|
+
const entities = await this.moduleRepository.findEntitiesByIds(integrationRecords.entitiesIds);
|
|
25
27
|
|
|
26
28
|
const integrationClass = this.integrationClasses.find(
|
|
27
29
|
(integrationClass) => integrationClass.Definition.name === integrationRecord.config.type
|
|
28
30
|
);
|
|
29
31
|
|
|
30
32
|
const modules = {};
|
|
31
|
-
for (const [key, entity] of Object.entries(
|
|
33
|
+
for (const [key, entity] of Object.entries(entities)) {
|
|
32
34
|
const moduleInstance = await this.moduleService.getModuleInstance(
|
|
33
|
-
entity.
|
|
35
|
+
entity.id,
|
|
34
36
|
integrationRecord.user
|
|
35
37
|
);
|
|
36
38
|
modules[key] = moduleInstance;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
const integrationInstance = new Integration({
|
|
40
|
-
id: integrationRecord.
|
|
42
|
+
id: integrationRecord.id,
|
|
41
43
|
userId: integrationRecord.user,
|
|
42
|
-
entities:
|
|
44
|
+
entities: entities,
|
|
43
45
|
config: integrationRecord.config,
|
|
44
46
|
status: integrationRecord.status,
|
|
45
47
|
version: integrationRecord.version,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.396.
|
|
4
|
+
"version": "2.0.0--canary.396.55167ab.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/boom": "^10.0.1",
|
|
7
7
|
"aws-sdk": "^2.1200.0",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"uuid": "^9.0.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@friggframework/eslint-config": "2.0.0--canary.396.
|
|
26
|
-
"@friggframework/prettier-config": "2.0.0--canary.396.
|
|
27
|
-
"@friggframework/test": "2.0.0--canary.396.
|
|
25
|
+
"@friggframework/eslint-config": "2.0.0--canary.396.55167ab.0",
|
|
26
|
+
"@friggframework/prettier-config": "2.0.0--canary.396.55167ab.0",
|
|
27
|
+
"@friggframework/test": "2.0.0--canary.396.55167ab.0",
|
|
28
28
|
"@types/lodash": "4.17.15",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
30
30
|
"chai": "^4.3.6",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/friggframework/frigg#readme",
|
|
55
55
|
"description": "",
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "55167ab7bbeabe9d61924cb7ba8b62edaa2e1dd4"
|
|
57
57
|
}
|