@friggframework/core 2.0.0--canary.396.55167ab.0 → 2.0.0--canary.396.accf516.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.
|
@@ -6,7 +6,7 @@ class IntegrationRepository {
|
|
|
6
6
|
return integrationRecords.map(integrationRecord => ({
|
|
7
7
|
id: integrationRecord._id,
|
|
8
8
|
entitiesIds: integrationRecord.entities.map(e => e._id),
|
|
9
|
-
userId: integrationRecord.user,
|
|
9
|
+
userId: integrationRecord.user.toString(),
|
|
10
10
|
config: integrationRecord.config,
|
|
11
11
|
version: integrationRecord.version,
|
|
12
12
|
status: integrationRecord.status,
|
|
@@ -23,7 +23,7 @@ class GetIntegrationsForUser {
|
|
|
23
23
|
const integrations = []
|
|
24
24
|
|
|
25
25
|
for (const integrationRecord of integrationRecords) {
|
|
26
|
-
const entities = await this.moduleRepository.findEntitiesByIds(
|
|
26
|
+
const entities = await this.moduleRepository.findEntitiesByIds(integrationRecord.entitiesIds);
|
|
27
27
|
|
|
28
28
|
const integrationClass = this.integrationClasses.find(
|
|
29
29
|
(integrationClass) => integrationClass.Definition.name === integrationRecord.config.type
|
|
@@ -33,7 +33,7 @@ class GetIntegrationsForUser {
|
|
|
33
33
|
for (const [key, entity] of Object.entries(entities)) {
|
|
34
34
|
const moduleInstance = await this.moduleService.getModuleInstance(
|
|
35
35
|
entity.id,
|
|
36
|
-
integrationRecord.
|
|
36
|
+
integrationRecord.userId
|
|
37
37
|
);
|
|
38
38
|
modules[key] = moduleInstance;
|
|
39
39
|
}
|
|
@@ -7,16 +7,30 @@ class ModuleRepository {
|
|
|
7
7
|
throw new Error(`Entity ${entityId} not found`);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
return
|
|
10
|
+
return {
|
|
11
|
+
id: entity._id,
|
|
12
|
+
accountId: entity.accountId,
|
|
13
|
+
credential: entity.credential,
|
|
14
|
+
userId: entity.user.toString(),
|
|
15
|
+
name: entity.name,
|
|
16
|
+
externalId: entity.externalId,
|
|
17
|
+
type: entity.__t,
|
|
18
|
+
moduleName: entity.moduleName,
|
|
19
|
+
};
|
|
11
20
|
}
|
|
12
21
|
|
|
13
22
|
async findEntitiesByIds(entitiesIds) {
|
|
14
23
|
const entitiesRecords = await Entity.find({ _id: { $in: entitiesIds } }, '', { lean: true }).populate('credential');
|
|
24
|
+
|
|
25
|
+
if (entitiesRecords.length !== entitiesIds.length) {
|
|
26
|
+
throw new Error(`Some entities not found`);
|
|
27
|
+
}
|
|
28
|
+
|
|
15
29
|
return entitiesRecords.map(e => ({
|
|
16
30
|
id: e._id,
|
|
17
31
|
accountId: e.accountId,
|
|
18
32
|
credential: e.credential,
|
|
19
|
-
userId: e.user,
|
|
33
|
+
userId: e.user.toString(),
|
|
20
34
|
name: e.name,
|
|
21
35
|
externalId: e.externalId,
|
|
22
36
|
type: e.__t,
|
|
@@ -21,13 +21,13 @@ class ModuleService {
|
|
|
21
21
|
throw new Error(`Entity ${entityId} not found`);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
if (entity.
|
|
24
|
+
if (entity.userId !== userId) {
|
|
25
25
|
throw new Error(
|
|
26
26
|
`Entity ${entityId} does not belong to user ${userId}`
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const entityType = entity.
|
|
30
|
+
const entityType = entity.type;
|
|
31
31
|
const moduleDefinition = this.moduleDefinitions.find((def) => {
|
|
32
32
|
const modelName = Module.getEntityModelFromDefinition(def).modelName;
|
|
33
33
|
return entityType === modelName;
|
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.accf516.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.accf516.0",
|
|
26
|
+
"@friggframework/prettier-config": "2.0.0--canary.396.accf516.0",
|
|
27
|
+
"@friggframework/test": "2.0.0--canary.396.accf516.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": "accf516c6aef6b581e2fe68268c28676275efa0d"
|
|
57
57
|
}
|