@friggframework/core 2.0.0--canary.397.b7e1978.0 → 2.0.0--canary.397.1b51778.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,8 +2,10 @@ const { Router } = require('express');
2
2
  const { Worker } = require('@friggframework/core');
3
3
  const { loadAppDefinition } = require('./app-definition-loader');
4
4
  const { IntegrationRepository } = require('../integrations/integration-repository');
5
- const { ModuleService } = require('../modules/module-service');
5
+ const { ModuleFactory } = require('../modules/module-factory');
6
6
  const { GetIntegrationInstance } = require('../integrations/use-cases/get-integration-instance');
7
+ const { getModulesDefinitionFromIntegrationClasses } = require('../integrations/utils/map-integration-dto');
8
+ const { ModuleRepository } = require('../modules/module-repository');
7
9
 
8
10
  const loadRouterFromObject = (IntegrationClass, routerObject) => {
9
11
  const router = Router();
@@ -42,12 +44,16 @@ const createQueueWorker = (integrationClass) => {
42
44
  } else {
43
45
  const { integrations: integrationClasses } = loadAppDefinition();
44
46
  const integrationRepository = new IntegrationRepository();
45
- const moduleService = new ModuleService();
47
+ const moduleRepository = new ModuleRepository();
48
+ const moduleFactory = new ModuleFactory({
49
+ moduleRepository,
50
+ moduleDefinitions: getModulesDefinitionFromIntegrationClasses(integrationClasses),
51
+ });
46
52
 
47
53
  const getIntegrationInstance = new GetIntegrationInstance({
48
54
  integrationRepository,
49
55
  integrationClasses,
50
- moduleService,
56
+ moduleFactory,
51
57
  });
52
58
 
53
59
  // todo: are we going to have the userId available here?
@@ -8,7 +8,7 @@ const { GetIntegrationsForUser } = require('./use-cases/get-integrations-for-use
8
8
  const { CredentialRepository } = require('../credential/credential-repository');
9
9
  const { GetCredentialForUser } = require('../credential/use-cases/get-credential-for-user');
10
10
  const { CreateIntegration } = require('./use-cases/create-integration');
11
- const { ModuleService } = require('../modules/module-service');
11
+ const { ModuleFactory } = require('../modules/module-factory');
12
12
  const { ModuleRepository } = require('../modules/module-repository');
13
13
  const { GetEntitiesForUser } = require('../modules/use-cases/get-entities-for-user');
14
14
  const { loadAppDefinition } = require('../handlers/app-definition-loader');
@@ -36,7 +36,7 @@ function createIntegrationRouter(params) {
36
36
  const integrationRepository = new IntegrationRepository();
37
37
  const credentialRepository = new CredentialRepository();
38
38
 
39
- const moduleService = new ModuleService({
39
+ const moduleFactory = new ModuleFactory({
40
40
  moduleRepository,
41
41
  moduleDefinitions: getModulesDefinitionFromIntegrationClasses(integrationClasses),
42
42
  });
@@ -48,7 +48,7 @@ function createIntegrationRouter(params) {
48
48
  const getIntegrationsForUser = new GetIntegrationsForUser({
49
49
  integrationRepository,
50
50
  integrationClasses,
51
- moduleService,
51
+ moduleFactory,
52
52
  moduleRepository,
53
53
  });
54
54
 
@@ -59,7 +59,7 @@ function createIntegrationRouter(params) {
59
59
  const createIntegration = new CreateIntegration({
60
60
  integrationRepository,
61
61
  integrationClasses,
62
- moduleService,
62
+ moduleFactory,
63
63
  });
64
64
 
65
65
  const getEntitiesForUser = new GetEntitiesForUser({
@@ -70,13 +70,13 @@ function createIntegrationRouter(params) {
70
70
  const getIntegrationInstance = new GetIntegrationInstance({
71
71
  integrationRepository,
72
72
  integrationClasses,
73
- moduleService,
73
+ moduleFactory,
74
74
  });
75
75
 
76
76
  const updateIntegration = new UpdateIntegration({
77
77
  integrationRepository,
78
78
  integrationClasses,
79
- moduleService,
79
+ moduleFactory,
80
80
  });
81
81
 
82
82
  const getModuleInstanceFromType = new GetModuleInstanceFromType({
@@ -119,7 +119,7 @@ class Integration {
119
119
  // -----------------------------------------------------------------
120
120
  // Inject the real Module instances (with credentials) so that any
121
121
  // behaviour code accessing `this.<moduleName>.api` hits the
122
- // correctly authenticated requester created by ModuleService.
122
+ // correctly authenticated requester created by ModuleFactory.
123
123
  // -----------------------------------------------------------------
124
124
  for (const mod of this._moduleInstances) {
125
125
  const key = typeof mod.getName === 'function' ? mod.getName() : mod.name;
@@ -6,12 +6,12 @@ class CreateIntegration {
6
6
  * @param {Object} params
7
7
  * @param {import('../integration-repository').IntegrationRepository} params.integrationRepository
8
8
  * @param {import('../integration-classes').IntegrationClasses} params.integrationClasses
9
- * @param {import('../../modules/module-service').ModuleService} params.moduleService
9
+ * @param {import('../../modules/module-factory').ModuleFactory} params.moduleFactory
10
10
  */
11
- constructor({ integrationRepository, integrationClasses, moduleService }) {
11
+ constructor({ integrationRepository, integrationClasses, moduleFactory }) {
12
12
  this.integrationRepository = integrationRepository;
13
13
  this.integrationClasses = integrationClasses;
14
- this.moduleService = moduleService;
14
+ this.moduleFactory = moduleFactory;
15
15
  }
16
16
 
17
17
  async execute(entities, userId, config) {
@@ -28,7 +28,7 @@ class CreateIntegration {
28
28
 
29
29
  const modules = [];
30
30
  for (const entityId of integrationRecord.entitiesIds) {
31
- const moduleInstance = await this.moduleService.getModuleInstance(
31
+ const moduleInstance = await this.moduleFactory.getModuleInstance(
32
32
  entityId,
33
33
  integrationRecord.userId
34
34
  );
@@ -2,14 +2,14 @@ const { Integration } = require('../integration');
2
2
  const { mapIntegrationClassToIntegrationDTO } = require('../utils/map-integration-dto');
3
3
 
4
4
  class GetIntegrationForUser {
5
- constructor({ integrationRepository, integrationClasses, moduleService, moduleRepository }) {
5
+ constructor({ integrationRepository, integrationClasses, moduleFactory, moduleRepository }) {
6
6
 
7
7
  /**
8
8
  * @type {import('../integration-repository').IntegrationRepository}
9
9
  */
10
10
  this.integrationRepository = integrationRepository;
11
11
  this.integrationClasses = integrationClasses;
12
- this.moduleService = moduleService;
12
+ this.moduleFactory = moduleFactory;
13
13
  this.moduleRepository = moduleRepository;
14
14
  }
15
15
 
@@ -36,7 +36,7 @@ class GetIntegrationForUser {
36
36
 
37
37
  const modules = [];
38
38
  for (const entity of entities) {
39
- const moduleInstance = await this.moduleService.getModuleInstance(
39
+ const moduleInstance = await this.moduleFactory.getModuleInstance(
40
40
  entity._id,
41
41
  integrationRecord.user
42
42
  );
@@ -8,16 +8,16 @@ class GetIntegrationInstance {
8
8
  * @param {Object} params
9
9
  * @param {import('../integration-repository').IntegrationRepository} params.integrationRepository - Repository for integration data access
10
10
  * @param {Array<import('../integration').Integration>} params.integrationClasses - Array of available integration classes
11
- * @param {import('../module-plugin/module-service').ModuleService} params.moduleService - Service for module instantiation and management
11
+ * @param {import('../../modules/module-factory').ModuleFactory} params.moduleFactory - Service for module instantiation and management
12
12
  */
13
13
  constructor({
14
14
  integrationRepository,
15
15
  integrationClasses,
16
- moduleService,
16
+ moduleFactory,
17
17
  }) {
18
18
  this.integrationRepository = integrationRepository;
19
19
  this.integrationClasses = integrationClasses;
20
- this.moduleService = moduleService;
20
+ this.moduleFactory = moduleFactory;
21
21
  }
22
22
 
23
23
  async execute(integrationId, userId) {
@@ -44,7 +44,7 @@ class GetIntegrationInstance {
44
44
 
45
45
  const modules = [];
46
46
  for (const entityId of integrationRecord.entitiesIds) {
47
- const moduleInstance = await this.moduleService.getModuleInstance(
47
+ const moduleInstance = await this.moduleFactory.getModuleInstance(
48
48
  entityId,
49
49
  integrationRecord.userId
50
50
  );
@@ -2,14 +2,14 @@ const { Integration } = require('../integration');
2
2
  const { mapIntegrationClassToIntegrationDTO } = require('../utils/map-integration-dto');
3
3
 
4
4
  class GetIntegrationsForUser {
5
- constructor({ integrationRepository, integrationClasses, moduleService, moduleRepository }) {
5
+ constructor({ integrationRepository, integrationClasses, moduleFactory, moduleRepository }) {
6
6
 
7
7
  /**
8
8
  * @type {import('../integration-repository').IntegrationRepository}
9
9
  */
10
10
  this.integrationRepository = integrationRepository;
11
11
  this.integrationClasses = integrationClasses;
12
- this.moduleService = moduleService;
12
+ this.moduleFactory = moduleFactory;
13
13
  this.moduleRepository = moduleRepository;
14
14
  }
15
15
 
@@ -31,7 +31,7 @@ class GetIntegrationsForUser {
31
31
 
32
32
  const modules = [];
33
33
  for (const entity of entities) {
34
- const moduleInstance = await this.moduleService.getModuleInstance(
34
+ const moduleInstance = await this.moduleFactory.getModuleInstance(
35
35
  entity.id,
36
36
  integrationRecord.userId
37
37
  );
@@ -10,16 +10,16 @@ class UpdateIntegration {
10
10
  * @param {Object} params
11
11
  * @param {import('../integration-repository').IntegrationRepository} params.integrationRepository - Repository for integration data access
12
12
  * @param {Array<import('../integration').Integration>} params.integrationClasses - Array of available integration classes
13
- * @param {import('../module-plugin/module-service').ModuleService} params.moduleService - Service for module instantiation and management
13
+ * @param {import('../../modules/module-factory').ModuleFactory} params.moduleFactory - Service for module instantiation and management
14
14
  */
15
15
  constructor({
16
16
  integrationRepository,
17
17
  integrationClasses,
18
- moduleService,
18
+ moduleFactory,
19
19
  }) {
20
20
  this.integrationRepository = integrationRepository;
21
21
  this.integrationClasses = integrationClasses;
22
- this.moduleService = moduleService;
22
+ this.moduleFactory = moduleFactory;
23
23
  }
24
24
 
25
25
  async execute(integrationId, userId, config) {
@@ -49,7 +49,7 @@ class UpdateIntegration {
49
49
  // 3. Load modules based on entity references
50
50
  const modules = [];
51
51
  for (const entityId of integrationRecord.entitiesIds) {
52
- const moduleInstance = await this.moduleService.getModuleInstance(
52
+ const moduleInstance = await this.moduleFactory.getModuleInstance(
53
53
  entityId,
54
54
  integrationRecord.userId
55
55
  );
@@ -1,6 +1,11 @@
1
1
  const { Module } = require('./module');
2
2
 
3
- class ModuleService {
3
+ /**
4
+ * Acts as a factory for fully-hydrated domain Module instances.
5
+ * Provides methods to retrieve and construct Module objects with their associated
6
+ * entity and definition.
7
+ */
8
+ class ModuleFactory {
4
9
  /**
5
10
  * @param {Object} params - Configuration parameters.
6
11
  * @param {import('./module-repository').ModuleRepository} params.moduleRepository - Repository for module data operations.
@@ -46,4 +51,4 @@ class ModuleService {
46
51
  }
47
52
  }
48
53
 
49
- module.exports = { ModuleService };
54
+ module.exports = { ModuleFactory };
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.397.b7e1978.0",
4
+ "version": "2.0.0--canary.397.1b51778.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.397.b7e1978.0",
26
- "@friggframework/prettier-config": "2.0.0--canary.397.b7e1978.0",
27
- "@friggframework/test": "2.0.0--canary.397.b7e1978.0",
25
+ "@friggframework/eslint-config": "2.0.0--canary.397.1b51778.0",
26
+ "@friggframework/prettier-config": "2.0.0--canary.397.1b51778.0",
27
+ "@friggframework/test": "2.0.0--canary.397.1b51778.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": "b7e197879d90d5bd782c5299aa55f312eb7d4b63"
56
+ "gitHead": "1b51778697149cbb26c6ba4de50e507461663f48"
57
57
  }