@friggframework/core 2.0.0--canary.464.f9d3fc0.0 → 2.0.0--canary.463.62579dd.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,6 +19,7 @@ const {
|
|
|
19
19
|
const {
|
|
20
20
|
getModulesDefinitionFromIntegrationClasses,
|
|
21
21
|
} = require('../integrations/utils/map-integration-dto');
|
|
22
|
+
const { loadAppDefinition } = require('./app-definition-loader');
|
|
22
23
|
|
|
23
24
|
const loadRouterFromObject = (IntegrationClass, routerObject) => {
|
|
24
25
|
const router = Router();
|
|
@@ -50,37 +51,29 @@ const loadRouterFromObject = (IntegrationClass, routerObject) => {
|
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
const initializeRepositories = () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
});
|
|
54
|
+
return {
|
|
55
|
+
processRepository: createProcessRepository(),
|
|
56
|
+
integrationRepository: createIntegrationRepository(),
|
|
57
|
+
moduleRepository: createModuleRepository(),
|
|
58
|
+
};
|
|
71
59
|
};
|
|
72
60
|
|
|
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
|
+
*/
|
|
73
66
|
const loadIntegrationForWebhook = async (integrationId) => {
|
|
74
|
-
const { loadAppDefinition } = require('./app-definition-loader');
|
|
75
67
|
const { integrations: integrationClasses } = loadAppDefinition();
|
|
68
|
+
const { integrationRepository, moduleRepository } = initializeRepositories();
|
|
76
69
|
|
|
77
|
-
const
|
|
78
|
-
initializeRepositories();
|
|
79
|
-
|
|
80
|
-
const moduleFactory = createModuleFactoryWithDefinitions(
|
|
81
|
-
moduleRepository,
|
|
70
|
+
const moduleDefinitions = getModulesDefinitionFromIntegrationClasses(
|
|
82
71
|
integrationClasses
|
|
83
72
|
);
|
|
73
|
+
const moduleFactory = new ModuleFactory({
|
|
74
|
+
moduleRepository,
|
|
75
|
+
moduleDefinitions,
|
|
76
|
+
});
|
|
84
77
|
|
|
85
78
|
const getIntegrationInstance = new GetIntegrationInstance({
|
|
86
79
|
integrationRepository,
|
|
@@ -92,19 +85,42 @@ const loadIntegrationForWebhook = async (integrationId) => {
|
|
|
92
85
|
integrationId
|
|
93
86
|
);
|
|
94
87
|
|
|
88
|
+
if (!integrationRecord) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`No integration found by the ID of ${integrationId}`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
95
94
|
return await getIntegrationInstance.execute(
|
|
96
95
|
integrationId,
|
|
97
96
|
integrationRecord.userId
|
|
98
97
|
);
|
|
99
98
|
};
|
|
100
99
|
|
|
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
|
+
*/
|
|
101
105
|
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
|
+
|
|
102
114
|
const { processRepository, integrationRepository, moduleRepository } =
|
|
103
115
|
initializeRepositories();
|
|
104
116
|
|
|
105
|
-
const
|
|
117
|
+
const moduleDefinitions = getModulesDefinitionFromIntegrationClasses([
|
|
106
118
|
integrationClass,
|
|
107
119
|
]);
|
|
120
|
+
const moduleFactory = new ModuleFactory({
|
|
121
|
+
moduleRepository,
|
|
122
|
+
moduleDefinitions,
|
|
123
|
+
});
|
|
108
124
|
|
|
109
125
|
const getIntegrationInstance = new GetIntegrationInstance({
|
|
110
126
|
integrationRepository,
|
|
@@ -112,10 +128,6 @@ const loadIntegrationForProcess = async (processId, integrationClass) => {
|
|
|
112
128
|
moduleFactory,
|
|
113
129
|
});
|
|
114
130
|
|
|
115
|
-
if (!processId) {
|
|
116
|
-
throw new Error('processId is required in queue message data');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
131
|
const process = await processRepository.findById(processId);
|
|
120
132
|
|
|
121
133
|
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(
|
|
23
|
+
router.post('/', 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(
|
|
40
|
+
router.post('/: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,68 +1,75 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
2
|
+
"name": "@friggframework/core",
|
|
3
|
+
"prettier": "@friggframework/prettier-config",
|
|
4
|
+
"version": "2.0.0--canary.463.62579dd.0",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@hapi/boom": "^10.0.1",
|
|
7
|
+
"@prisma/client": "^6.16.3",
|
|
8
|
+
"bcryptjs": "^2.4.3",
|
|
9
|
+
"body-parser": "^1.20.2",
|
|
10
|
+
"common-tags": "^1.8.2",
|
|
11
|
+
"cors": "^2.8.5",
|
|
12
|
+
"dotenv": "^16.4.7",
|
|
13
|
+
"express": "^4.19.2",
|
|
14
|
+
"express-async-handler": "^1.2.0",
|
|
15
|
+
"form-data": "^4.0.0",
|
|
16
|
+
"fs-extra": "^11.2.0",
|
|
17
|
+
"lodash": "4.17.21",
|
|
18
|
+
"lodash.get": "^4.4.2",
|
|
19
|
+
"mongoose": "6.11.6",
|
|
20
|
+
"node-fetch": "^2.6.7",
|
|
21
|
+
"serverless-http": "^2.7.0",
|
|
22
|
+
"uuid": "^9.0.1"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"aws-sdk": "^2.1200.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependenciesMeta": {
|
|
28
|
+
"aws-sdk": {
|
|
29
|
+
"optional": true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@friggframework/eslint-config": "2.0.0--canary.463.62579dd.0",
|
|
34
|
+
"@friggframework/prettier-config": "2.0.0--canary.463.62579dd.0",
|
|
35
|
+
"@friggframework/test": "2.0.0--canary.463.62579dd.0",
|
|
36
|
+
"@types/lodash": "4.17.15",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
38
|
+
"chai": "^4.3.6",
|
|
39
|
+
"eslint": "^8.22.0",
|
|
40
|
+
"eslint-plugin-import": "^2.29.1",
|
|
41
|
+
"eslint-plugin-n": "^17.10.2",
|
|
42
|
+
"eslint-plugin-promise": "^7.0.0",
|
|
43
|
+
"jest": "^29.7.0",
|
|
44
|
+
"prettier": "^2.7.1",
|
|
45
|
+
"prisma": "^6.16.3",
|
|
46
|
+
"sinon": "^16.1.1",
|
|
47
|
+
"typescript": "^5.0.2"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"lint:fix": "prettier --write --loglevel error . && eslint . --fix",
|
|
51
|
+
"test": "jest --passWithNoTests # TODO",
|
|
52
|
+
"prisma:generate:mongo": "npx prisma generate --schema ./prisma-mongodb/schema.prisma",
|
|
53
|
+
"prisma:generate:postgres": "npx prisma generate --schema ./prisma-postgresql/schema.prisma",
|
|
54
|
+
"prisma:generate": "npm run prisma:generate:mongo && npm run prisma:generate:postgres",
|
|
55
|
+
"prisma:push:mongo": "npx prisma db push --schema ./prisma-mongodb/schema.prisma",
|
|
56
|
+
"prisma:migrate:postgres": "npx prisma migrate dev --schema ./prisma-postgresql/schema.prisma",
|
|
57
|
+
"postinstall": "npm run prisma:generate"
|
|
58
|
+
},
|
|
59
|
+
"author": "",
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"main": "index.js",
|
|
62
|
+
"repository": {
|
|
63
|
+
"type": "git",
|
|
64
|
+
"url": "git+https://github.com/friggframework/frigg.git"
|
|
65
|
+
},
|
|
66
|
+
"bugs": {
|
|
67
|
+
"url": "https://github.com/friggframework/frigg/issues"
|
|
68
|
+
},
|
|
69
|
+
"homepage": "https://github.com/friggframework/frigg#readme",
|
|
70
|
+
"description": "",
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"access": "public"
|
|
73
|
+
},
|
|
74
|
+
"gitHead": "62579dd537cdc5d96c3d36e2441e56778c3a160a"
|
|
68
75
|
}
|