@friggframework/core 2.0.0--canary.463.e30794c.0 → 2.0.0--canary.464.f9d3fc0.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.
@@ -19,7 +19,6 @@ const {
19
19
  const {
20
20
  getModulesDefinitionFromIntegrationClasses,
21
21
  } = require('../integrations/utils/map-integration-dto');
22
- const { loadAppDefinition } = require('./app-definition-loader');
23
22
 
24
23
  const loadRouterFromObject = (IntegrationClass, routerObject) => {
25
24
  const router = Router();
@@ -51,29 +50,37 @@ const loadRouterFromObject = (IntegrationClass, routerObject) => {
51
50
  };
52
51
 
53
52
  const initializeRepositories = () => {
54
- return {
55
- processRepository: createProcessRepository(),
56
- integrationRepository: createIntegrationRepository(),
57
- moduleRepository: createModuleRepository(),
58
- };
53
+ const processRepository = createProcessRepository();
54
+ const integrationRepository = createIntegrationRepository();
55
+ const moduleRepository = createModuleRepository();
56
+
57
+ return { processRepository, integrationRepository, moduleRepository };
58
+ };
59
+
60
+ const createModuleFactoryWithDefinitions = (
61
+ moduleRepository,
62
+ integrationClasses
63
+ ) => {
64
+ const moduleDefinitions =
65
+ getModulesDefinitionFromIntegrationClasses(integrationClasses);
66
+
67
+ return new ModuleFactory({
68
+ moduleRepository,
69
+ moduleDefinitions,
70
+ });
59
71
  };
60
72
 
61
- /**
62
- * Load hydrated integration instance for webhook events WITH integrationId.
63
- * Must load app definition to find all integration classes, then match
64
- * against the integration record's type.
65
- */
66
73
  const loadIntegrationForWebhook = async (integrationId) => {
74
+ const { loadAppDefinition } = require('./app-definition-loader');
67
75
  const { integrations: integrationClasses } = loadAppDefinition();
68
- const { integrationRepository, moduleRepository } = initializeRepositories();
69
76
 
70
- const moduleDefinitions = getModulesDefinitionFromIntegrationClasses(
77
+ const { integrationRepository, moduleRepository } =
78
+ initializeRepositories();
79
+
80
+ const moduleFactory = createModuleFactoryWithDefinitions(
81
+ moduleRepository,
71
82
  integrationClasses
72
83
  );
73
- const moduleFactory = new ModuleFactory({
74
- moduleRepository,
75
- moduleDefinitions,
76
- });
77
84
 
78
85
  const getIntegrationInstance = new GetIntegrationInstance({
79
86
  integrationRepository,
@@ -85,42 +92,19 @@ const loadIntegrationForWebhook = async (integrationId) => {
85
92
  integrationId
86
93
  );
87
94
 
88
- if (!integrationRecord) {
89
- throw new Error(
90
- `No integration found by the ID of ${integrationId}`
91
- );
92
- }
93
-
94
95
  return await getIntegrationInstance.execute(
95
96
  integrationId,
96
97
  integrationRecord.userId
97
98
  );
98
99
  };
99
100
 
100
- /**
101
- * Load hydrated integration instance for process-based events.
102
- * Integration class is already known from queue worker context,
103
- * so we receive it as a parameter rather than loading all classes.
104
- */
105
101
  const loadIntegrationForProcess = async (processId, integrationClass) => {
106
- if (!integrationClass) {
107
- throw new Error('integrationClass parameter is required');
108
- }
109
-
110
- if (!processId) {
111
- throw new Error('processId is required in queue message data');
112
- }
113
-
114
102
  const { processRepository, integrationRepository, moduleRepository } =
115
103
  initializeRepositories();
116
104
 
117
- const moduleDefinitions = getModulesDefinitionFromIntegrationClasses([
105
+ const moduleFactory = createModuleFactoryWithDefinitions(moduleRepository, [
118
106
  integrationClass,
119
107
  ]);
120
- const moduleFactory = new ModuleFactory({
121
- moduleRepository,
122
- moduleDefinitions,
123
- });
124
108
 
125
109
  const getIntegrationInstance = new GetIntegrationInstance({
126
110
  integrationRepository,
@@ -128,6 +112,10 @@ const loadIntegrationForProcess = async (processId, integrationClass) => {
128
112
  moduleFactory,
129
113
  });
130
114
 
115
+ if (!processId) {
116
+ throw new Error('processId is required in queue message data');
117
+ }
118
+
131
119
  const process = await processRepository.findById(processId);
132
120
 
133
121
  if (!process) {
@@ -20,7 +20,7 @@ for (const IntegrationClass of integrationClasses) {
20
20
  console.log(`\n│ Configuring webhook routes for ${IntegrationClass.Definition.name}:`);
21
21
 
22
22
  // General webhook route (no integration ID)
23
- router.post('/', async (req, res, next) => {
23
+ router.post(basePath, async (req, res, next) => {
24
24
  try {
25
25
  const integrationInstance = new IntegrationClass();
26
26
  const dispatcher = new IntegrationEventDispatcher(integrationInstance);
@@ -37,7 +37,7 @@ for (const IntegrationClass of integrationClasses) {
37
37
  console.log(`│ POST ${basePath}`);
38
38
 
39
39
  // Integration-specific webhook route (with integration ID)
40
- router.post('/:integrationId', async (req, res, next) => {
40
+ router.post(`${basePath}/:integrationId`, async (req, res, next) => {
41
41
  try {
42
42
  const integrationInstance = new IntegrationClass();
43
43
  const dispatcher = new IntegrationEventDispatcher(integrationInstance);
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.463.e30794c.0",
4
+ "version": "2.0.0--canary.464.f9d3fc0.0",
5
5
  "dependencies": {
6
6
  "@hapi/boom": "^10.0.1",
7
7
  "@prisma/client": "^6.16.3",
@@ -23,9 +23,9 @@
23
23
  "uuid": "^9.0.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@friggframework/eslint-config": "2.0.0--canary.463.e30794c.0",
27
- "@friggframework/prettier-config": "2.0.0--canary.463.e30794c.0",
28
- "@friggframework/test": "2.0.0--canary.463.e30794c.0",
26
+ "@friggframework/eslint-config": "2.0.0--canary.464.f9d3fc0.0",
27
+ "@friggframework/prettier-config": "2.0.0--canary.464.f9d3fc0.0",
28
+ "@friggframework/test": "2.0.0--canary.464.f9d3fc0.0",
29
29
  "@types/lodash": "4.17.15",
30
30
  "@typescript-eslint/eslint-plugin": "^8.0.0",
31
31
  "chai": "^4.3.6",
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "e30794cb481bbedf7cf57ef3356ae276e2988320"
67
+ "gitHead": "f9d3fc0e7c7135c87a6b6b1befc7d7912966f86a"
68
68
  }