@friggframework/core 2.0.0--canary.396.0dd37aa.0 → 2.0.0--canary.397.216d54b.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/handlers/backend-utils.js +24 -12
- package/handlers/routers/auth.js +1 -7
- package/handlers/routers/integration-defined-routers.js +3 -5
- package/handlers/workers/integration-defined-workers.js +5 -6
- package/index.js +0 -4
- package/integrations/index.js +0 -2
- package/integrations/integration-router.js +105 -176
- package/integrations/integration.js +51 -4
- package/integrations/use-cases/create-integration.js +20 -10
- package/integrations/use-cases/delete-integration-for-user.js +29 -5
- package/integrations/use-cases/get-integration-instance.js +73 -0
- package/integrations/use-cases/get-integrations-for-user.js +1 -1
- package/integrations/use-cases/{get-integration.js → update-integration.js} +12 -13
- package/integrations/utils/map-integration-dto.js +16 -1
- package/module-plugin/index.js +0 -2
- package/module-plugin/module-repository.js +13 -2
- package/module-plugin/module.js +10 -18
- package/module-plugin/use-cases/get-entity-options-by-id.js +58 -0
- package/module-plugin/use-cases/get-entity-options-by-type.js +34 -0
- package/module-plugin/use-cases/get-module-instance-from-type.js +31 -0
- package/module-plugin/use-cases/get-module.js +56 -0
- package/module-plugin/use-cases/refresh-entity-options.js +58 -0
- package/module-plugin/use-cases/test-module-auth.js +54 -0
- package/package.json +5 -5
- package/integrations/integration-factory.js +0 -195
- package/module-plugin/module-factory.js +0 -42
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
const { Router } = require('express');
|
|
2
2
|
const { Worker } = require('@friggframework/core');
|
|
3
|
+
const { loadAppDefinition } = require('./app-definition-loader');
|
|
4
|
+
const { IntegrationRepository } = require('../integrations/integration-repository');
|
|
5
|
+
const { ModuleService } = require('../module-plugin/module-service');
|
|
6
|
+
const { GetIntegrationInstance } = require('../integrations/use-cases/get-integration-instance');
|
|
3
7
|
|
|
4
8
|
const loadRouterFromObject = (IntegrationClass, routerObject) => {
|
|
5
9
|
const router = Router();
|
|
@@ -23,29 +27,37 @@ const loadRouterFromObject = (IntegrationClass, routerObject) => {
|
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
//todo: this should be in a use case class
|
|
26
|
-
const createQueueWorker = (integrationClass
|
|
30
|
+
const createQueueWorker = (integrationClass) => {
|
|
27
31
|
class QueueWorker extends Worker {
|
|
28
32
|
async _run(params, context) {
|
|
29
33
|
try {
|
|
30
|
-
let
|
|
34
|
+
let integrationInstance;
|
|
31
35
|
if (!params.integrationId) {
|
|
32
|
-
|
|
33
|
-
await
|
|
34
|
-
|
|
35
|
-
await instance.registerEventHandlers();
|
|
36
|
+
integrationInstance = new integrationClass();
|
|
37
|
+
await integrationInstance.loadModules();
|
|
38
|
+
await integrationInstance.registerEventHandlers();
|
|
36
39
|
console.log(
|
|
37
40
|
`${params.event} for ${integrationClass.Definition.name} integration with no integrationId`
|
|
38
41
|
);
|
|
39
42
|
} else {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
const { integrations: integrationClasses } = loadAppDefinition();
|
|
44
|
+
const integrationRepository = new IntegrationRepository();
|
|
45
|
+
const moduleService = new ModuleService();
|
|
46
|
+
|
|
47
|
+
const getIntegrationInstance = new GetIntegrationInstance({
|
|
48
|
+
integrationRepository,
|
|
49
|
+
integrationClasses,
|
|
50
|
+
moduleService,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// todo: are we going to have the userId available here?
|
|
54
|
+
integrationInstance = await getIntegrationInstance.execute(params.integrationId, params.userId);
|
|
44
55
|
console.log(
|
|
45
|
-
`${params.event} for ${
|
|
56
|
+
`${params.event} for ${integrationInstance.record.config.type} of integrationId: ${params.integrationId}`
|
|
46
57
|
);
|
|
47
58
|
}
|
|
48
|
-
|
|
59
|
+
|
|
60
|
+
const res = await integrationInstance.send(params.event, {
|
|
49
61
|
data: params.data,
|
|
50
62
|
context,
|
|
51
63
|
});
|
package/handlers/routers/auth.js
CHANGED
|
@@ -4,11 +4,9 @@ const {
|
|
|
4
4
|
loadAppDefinition,
|
|
5
5
|
} = require('../app-definition-loader');
|
|
6
6
|
const { UserRepository } = require('../../user/user-repository');
|
|
7
|
-
const { IntegrationFactory } = require('../../integrations/integration-factory');
|
|
8
7
|
const { GetUserFromBearerToken } = require('../../user/use-cases/get-user-from-bearer-token');
|
|
9
8
|
|
|
10
|
-
const {
|
|
11
|
-
const integrationFactory = new IntegrationFactory(integrations);
|
|
9
|
+
const { userConfig } = loadAppDefinition();
|
|
12
10
|
const userRepository = new UserRepository({ userConfig });
|
|
13
11
|
const getUserFromBearerToken = new GetUserFromBearerToken({
|
|
14
12
|
userRepository,
|
|
@@ -16,10 +14,6 @@ const getUserFromBearerToken = new GetUserFromBearerToken({
|
|
|
16
14
|
});
|
|
17
15
|
|
|
18
16
|
const router = createIntegrationRouter({
|
|
19
|
-
factory: {
|
|
20
|
-
moduleFactory: integrationFactory.moduleFactory,
|
|
21
|
-
integrationFactory,
|
|
22
|
-
},
|
|
23
17
|
getUserFromBearerToken,
|
|
24
18
|
});
|
|
25
19
|
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
const { createAppHandler } = require('./../app-handler-helpers');
|
|
2
2
|
const {
|
|
3
3
|
loadAppDefinition,
|
|
4
|
-
loadRouterFromObject,
|
|
5
4
|
} = require('../app-definition-loader');
|
|
6
5
|
const { Router } = require('express');
|
|
7
|
-
const {
|
|
6
|
+
const { loadRouterFromObject } = require('../backend-utils');
|
|
8
7
|
|
|
9
8
|
const handlers = {};
|
|
10
|
-
const { integrations } = loadAppDefinition();
|
|
11
|
-
const integrationFactory = new IntegrationFactory(integrations);
|
|
9
|
+
const { integrations: integrationClasses } = loadAppDefinition();
|
|
12
10
|
|
|
13
11
|
//todo: this should be in a use case class
|
|
14
|
-
for (const IntegrationClass of
|
|
12
|
+
for (const IntegrationClass of integrationClasses) {
|
|
15
13
|
const router = Router();
|
|
16
14
|
const basePath = `/api/${IntegrationClass.Definition.name}-integration`;
|
|
17
15
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const { createHandler } = require('@friggframework/core');
|
|
2
|
-
const { loadAppDefinition
|
|
3
|
-
const {
|
|
2
|
+
const { loadAppDefinition } = require('../app-definition-loader');
|
|
3
|
+
const { createQueueWorker } = require('../backend-utils');
|
|
4
4
|
|
|
5
5
|
const handlers = {};
|
|
6
|
-
const { integrations } = loadAppDefinition();
|
|
7
|
-
const integrationFactory = new IntegrationFactory(integrations);
|
|
6
|
+
const { integrations: integrationClasses } = loadAppDefinition();
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
const defaultQueueWorker = createQueueWorker(IntegrationClass
|
|
8
|
+
integrationClasses.forEach((IntegrationClass) => {
|
|
9
|
+
const defaultQueueWorker = createQueueWorker(IntegrationClass);
|
|
11
10
|
|
|
12
11
|
handlers[`${IntegrationClass.Definition.name}`] = {
|
|
13
12
|
queueWorker: createHandler({
|
package/index.js
CHANGED
|
@@ -38,7 +38,6 @@ const {
|
|
|
38
38
|
IntegrationModel,
|
|
39
39
|
Options,
|
|
40
40
|
IntegrationMapping,
|
|
41
|
-
IntegrationFactory,
|
|
42
41
|
createIntegrationRouter,
|
|
43
42
|
checkRequiredParams,
|
|
44
43
|
} = require('./integrations/index');
|
|
@@ -53,7 +52,6 @@ const {
|
|
|
53
52
|
OAuth2Requester,
|
|
54
53
|
Requester,
|
|
55
54
|
ModuleConstants,
|
|
56
|
-
ModuleFactory,
|
|
57
55
|
} = require('./module-plugin/index');
|
|
58
56
|
const utils = require('./utils');
|
|
59
57
|
|
|
@@ -105,7 +103,6 @@ module.exports = {
|
|
|
105
103
|
IntegrationModel,
|
|
106
104
|
Options,
|
|
107
105
|
IntegrationMapping,
|
|
108
|
-
IntegrationFactory,
|
|
109
106
|
checkRequiredParams,
|
|
110
107
|
createIntegrationRouter,
|
|
111
108
|
|
|
@@ -126,7 +123,6 @@ module.exports = {
|
|
|
126
123
|
OAuth2Requester,
|
|
127
124
|
Requester,
|
|
128
125
|
ModuleConstants,
|
|
129
|
-
ModuleFactory,
|
|
130
126
|
// queues
|
|
131
127
|
QueuerUtil,
|
|
132
128
|
|
package/integrations/index.js
CHANGED
|
@@ -2,7 +2,6 @@ const { IntegrationBase } = require('./integration-base');
|
|
|
2
2
|
const { IntegrationModel } = require('./integration-model');
|
|
3
3
|
const { Options } = require('./options');
|
|
4
4
|
const { IntegrationMapping } = require('./integration-mapping');
|
|
5
|
-
const { IntegrationFactory } = require('./integration-factory');
|
|
6
5
|
const { createIntegrationRouter, checkRequiredParams } = require('./integration-router');
|
|
7
6
|
|
|
8
7
|
module.exports = {
|
|
@@ -10,7 +9,6 @@ module.exports = {
|
|
|
10
9
|
IntegrationModel,
|
|
11
10
|
Options,
|
|
12
11
|
IntegrationMapping,
|
|
13
|
-
IntegrationFactory,
|
|
14
12
|
createIntegrationRouter,
|
|
15
13
|
checkRequiredParams,
|
|
16
14
|
};
|