@friggframework/core 2.0.0--canary.396.d72f334.0 → 2.0.0--canary.396.b49bddf.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/integrations/integration-router.js +1 -1
- package/integrations/use-cases/create-integration.js +4 -5
- package/integrations/use-cases/get-integration-for-user.js +3 -2
- package/integrations/use-cases/get-integration.js +4 -3
- package/integrations/use-cases/get-integrations-for-user.js +7 -3
- package/integrations/utils/map-integration-dto.js +21 -0
- package/module-plugin/use-cases/get-entities-for-user.js +2 -1
- package/module-plugin/utils/map-module-dto.js +16 -0
- package/package.json +5 -5
|
@@ -144,7 +144,7 @@ function setIntegrationRoutes(router, factory, getUserFromBearerToken, integrati
|
|
|
144
144
|
),
|
|
145
145
|
authorized: await getEntitiesForUserUseCase.execute(userId),
|
|
146
146
|
},
|
|
147
|
-
integrations: integrations
|
|
147
|
+
integrations: integrations,
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
res.json(results);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { Integration } = require('../integration');
|
|
2
|
+
const { mapIntegrationClassToIntegrationDTO } = require('../utils/map-integration-dto');
|
|
2
3
|
|
|
3
4
|
class CreateIntegration {
|
|
4
5
|
/**
|
|
@@ -25,7 +26,7 @@ class CreateIntegration {
|
|
|
25
26
|
modules[key] = moduleInstance;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
const
|
|
29
|
+
const integrationInstance = new Integration({
|
|
29
30
|
id: integrationRecord.id,
|
|
30
31
|
userId: integrationRecord.user,
|
|
31
32
|
entities: integrationRecord.entities,
|
|
@@ -38,11 +39,9 @@ class CreateIntegration {
|
|
|
38
39
|
modules
|
|
39
40
|
});
|
|
40
41
|
|
|
42
|
+
await integrationInstance.initialize();
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
await integration.initialize();
|
|
44
|
-
|
|
45
|
-
return integration;
|
|
44
|
+
return mapIntegrationClassToIntegrationDTO(integrationInstance);
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { Integration } = require('../integration');
|
|
2
|
+
const { mapIntegrationClassToIntegrationDTO } = require('../utils/map-integration-dto');
|
|
2
3
|
|
|
3
4
|
class GetIntegrationForUser {
|
|
4
5
|
constructor({ integrationRepository, integrationClasses, moduleService }) {
|
|
@@ -40,7 +41,7 @@ class GetIntegrationForUser {
|
|
|
40
41
|
modules[key] = moduleInstance;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
const
|
|
44
|
+
const integrationInstance = new Integration({
|
|
44
45
|
id: integrationRecord.id,
|
|
45
46
|
userId: integrationRecord.user,
|
|
46
47
|
entities: integrationRecord.entities,
|
|
@@ -53,7 +54,7 @@ class GetIntegrationForUser {
|
|
|
53
54
|
modules
|
|
54
55
|
});
|
|
55
56
|
|
|
56
|
-
return
|
|
57
|
+
return mapIntegrationClassToIntegrationDTO(integrationInstance);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { Integration } = require('../integration');
|
|
2
|
+
const { mapIntegrationClassToIntegrationDTO } = require('../utils/map-integration-dto');
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
// todo: remove this use case
|
|
@@ -48,7 +49,7 @@ class GetIntegration {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
// 4. Create the Integration domain entity with modules
|
|
51
|
-
const
|
|
52
|
+
const integrationInstance = new Integration({
|
|
52
53
|
id: integrationRecord.id,
|
|
53
54
|
userId: integrationRecord.user,
|
|
54
55
|
entities: integrationRecord.entities,
|
|
@@ -63,9 +64,9 @@ class GetIntegration {
|
|
|
63
64
|
|
|
64
65
|
|
|
65
66
|
// 6. Complete async initialization (load dynamic actions, register handlers)
|
|
66
|
-
await
|
|
67
|
+
await integrationInstance.initialize();
|
|
67
68
|
|
|
68
|
-
return
|
|
69
|
+
return mapIntegrationClassToIntegrationDTO(integrationInstance);
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { Integration } = require('../integration');
|
|
2
|
+
const { mapIntegrationClassToIntegrationDTO } = require('../utils/map-integration-dto');
|
|
2
3
|
|
|
3
4
|
class GetIntegrationsForUser {
|
|
4
5
|
constructor({ integrationRepository, integrationClasses, moduleService }) {
|
|
@@ -35,7 +36,7 @@ class GetIntegrationsForUser {
|
|
|
35
36
|
modules[key] = moduleInstance;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
const integrationInstance = new Integration({
|
|
39
40
|
id: integrationRecord.id,
|
|
40
41
|
userId: integrationRecord.user,
|
|
41
42
|
entities: integrationRecord.entities,
|
|
@@ -46,10 +47,13 @@ class GetIntegrationsForUser {
|
|
|
46
47
|
entityReference: integrationRecord.entityReference,
|
|
47
48
|
integrationClass: integrationClass,
|
|
48
49
|
modules
|
|
49
|
-
})
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
integrations.push(
|
|
53
|
+
mapIntegrationClassToIntegrationDTO(integrationInstance)
|
|
54
|
+
);
|
|
52
55
|
|
|
56
|
+
}
|
|
53
57
|
|
|
54
58
|
return integrations;
|
|
55
59
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('../integration').Integration} integration
|
|
3
|
+
* Convert an Integration domain instance to a plain DTO suitable for JSON responses.
|
|
4
|
+
*/
|
|
5
|
+
function mapIntegrationClassToIntegrationDTO(integration) {
|
|
6
|
+
if (!integration) return null;
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
id: integration.id,
|
|
10
|
+
userId: integration.userId,
|
|
11
|
+
entities: integration.entities,
|
|
12
|
+
config: integration.config,
|
|
13
|
+
status: integration.status,
|
|
14
|
+
version: integration.version,
|
|
15
|
+
messages: integration.messages,
|
|
16
|
+
entityReference: integration.entityReference,
|
|
17
|
+
userActions: integration.userActions,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = { mapIntegrationClassToIntegrationDTO };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { Module } = require('../module');
|
|
2
|
+
const { mapModuleClassToModuleDTO } = require('../utils/map-module-dto');
|
|
2
3
|
|
|
3
4
|
class GetEntitiesForUser {
|
|
4
5
|
constructor({ moduleRepository, moduleDefinitions }) {
|
|
@@ -23,7 +24,7 @@ class GetEntitiesForUser {
|
|
|
23
24
|
definition: definition,
|
|
24
25
|
entity: entity,
|
|
25
26
|
});
|
|
26
|
-
return moduleInstance
|
|
27
|
+
return mapModuleClassToModuleDTO(moduleInstance);
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('../module').Module} moduleInstance
|
|
3
|
+
* Convert a Module domain instance to a plain DTO suitable for JSON responses.
|
|
4
|
+
*/
|
|
5
|
+
function mapModuleClassToModuleDTO(moduleInstance) {
|
|
6
|
+
if (!moduleInstance) return null;
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
name: moduleInstance.name,
|
|
10
|
+
userId: moduleInstance.userId,
|
|
11
|
+
entity: moduleInstance.entity,
|
|
12
|
+
credentialId: moduleInstance.credential?._id?.toString(),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = { mapModuleClassToModuleDTO };
|
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.b49bddf.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.b49bddf.0",
|
|
26
|
+
"@friggframework/prettier-config": "2.0.0--canary.396.b49bddf.0",
|
|
27
|
+
"@friggframework/test": "2.0.0--canary.396.b49bddf.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": "b49bddf0a8d75f08f9826caaae0e6dbdee5ca018"
|
|
57
57
|
}
|