@friggframework/core 2.0.0--canary.654.0c31bb1.0 → 2.0.0--canary.654.70623e2.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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { Router } = require('express');
|
|
2
|
+
const { runInContext, LOGGER_SCOPE_KEY } = require('../logs/context');
|
|
2
3
|
const { Worker } = require('@friggframework/core');
|
|
3
4
|
const {
|
|
4
5
|
IntegrationEventDispatcher,
|
|
@@ -19,6 +20,7 @@ const {
|
|
|
19
20
|
const {
|
|
20
21
|
getModulesDefinitionFromIntegrationClasses,
|
|
21
22
|
} = require('../integrations/utils/map-integration-dto');
|
|
23
|
+
const { processNotFound } = require('../integrations/use-cases/process-errors');
|
|
22
24
|
|
|
23
25
|
const loadRouterFromObject = (IntegrationClass, routerObject) => {
|
|
24
26
|
const router = Router();
|
|
@@ -37,12 +39,11 @@ const loadRouterFromObject = (IntegrationClass, routerObject) => {
|
|
|
37
39
|
const dispatcher = new IntegrationEventDispatcher(
|
|
38
40
|
integrationInstance
|
|
39
41
|
);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
req,
|
|
43
|
-
res,
|
|
44
|
-
|
|
45
|
-
});
|
|
42
|
+
// Logs only: a route :integrationId is unauthenticated input.
|
|
43
|
+
const result = await runInContext(
|
|
44
|
+
{ [LOGGER_SCOPE_KEY]: { integrationId: req.params?.integrationId } },
|
|
45
|
+
() => dispatcher.dispatchHttp({ event, req, res, next })
|
|
46
|
+
);
|
|
46
47
|
res.json(result);
|
|
47
48
|
} catch (error) {
|
|
48
49
|
next(error);
|
|
@@ -149,7 +150,7 @@ const loadIntegrationForProcess = async (processId, integrationClass) => {
|
|
|
149
150
|
const process = await processRepository.findById(processId);
|
|
150
151
|
|
|
151
152
|
if (!process) {
|
|
152
|
-
throw
|
|
153
|
+
throw processNotFound(`Process not found: ${processId}`);
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
const instance = await getIntegrationInstance.execute(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { createAppHandler } = require('./../app-handler-helpers');
|
|
2
2
|
const { loadAppDefinition } = require('../app-definition-loader');
|
|
3
3
|
const { Router } = require('express');
|
|
4
|
+
const { runInContext, LOGGER_SCOPE_KEY } = require('../../logs/context');
|
|
4
5
|
const {
|
|
5
6
|
IntegrationEventDispatcher,
|
|
6
7
|
} = require('../integration-event-dispatcher');
|
|
@@ -55,12 +56,18 @@ for (const IntegrationClass of integrationClasses) {
|
|
|
55
56
|
const dispatcher = new IntegrationEventDispatcher(
|
|
56
57
|
integrationInstance
|
|
57
58
|
);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
// Logs only: the id comes from an unauthenticated URL, so it must
|
|
60
|
+
// not reach the telemetry context that drives usage attribution.
|
|
61
|
+
await runInContext(
|
|
62
|
+
{ [LOGGER_SCOPE_KEY]: { integrationId: req.params.integrationId } },
|
|
63
|
+
() =>
|
|
64
|
+
dispatcher.dispatchHttp({
|
|
65
|
+
event: 'WEBHOOK_RECEIVED',
|
|
66
|
+
req,
|
|
67
|
+
res,
|
|
68
|
+
next,
|
|
69
|
+
})
|
|
70
|
+
);
|
|
64
71
|
} catch (error) {
|
|
65
72
|
next(error);
|
|
66
73
|
}
|
package/logs/context.js
CHANGED
|
@@ -77,8 +77,15 @@ function getLoggerScope() {
|
|
|
77
77
|
for (const key of INTEGRATION_KEYS) {
|
|
78
78
|
if (store[key] !== undefined) scope[key] = store[key];
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
// A set (hydrated) id beats a logger-only one, e.g. from a URL or a
|
|
81
|
+
// message body; a null id leaves the logger-only value in place.
|
|
82
|
+
const loggerKeys = store[LOGGER_SCOPE_KEY];
|
|
83
|
+
if (isPlainObject(loggerKeys)) {
|
|
84
|
+
for (const [key, value] of Object.entries(loggerKeys)) {
|
|
85
|
+
if (scope[key] === undefined || scope[key] === null) {
|
|
86
|
+
scope[key] = value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
82
89
|
}
|
|
83
90
|
scope = Object.freeze(scope);
|
|
84
91
|
scopeByStore.set(store, scope);
|
package/logs/summarize-event.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
const { redactUrl } = require('./redact');
|
|
2
2
|
|
|
3
3
|
// Best-effort extraction of the logical event/processId/integrationId from a
|
|
4
|
-
// JSON message body. Used only for log
|
|
4
|
+
// JSON message body: `data.*` first, then the top level. Used only for log
|
|
5
|
+
// correlation. Never throws.
|
|
5
6
|
function summarizeMessageBody(bodyStr) {
|
|
6
7
|
try {
|
|
7
8
|
const parsed = JSON.parse(bodyStr);
|
|
8
9
|
return {
|
|
9
10
|
event: parsed?.event,
|
|
10
|
-
processId: parsed?.data?.processId,
|
|
11
|
-
integrationId: parsed?.data?.integrationId,
|
|
11
|
+
processId: parsed?.data?.processId ?? parsed?.processId,
|
|
12
|
+
integrationId: parsed?.data?.integrationId ?? parsed?.integrationId,
|
|
12
13
|
};
|
|
13
14
|
} catch {
|
|
14
15
|
return {};
|
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.654.
|
|
4
|
+
"version": "2.0.0--canary.654.70623e2.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.588.0",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@friggframework/eslint-config": "2.0.0--canary.654.
|
|
51
|
-
"@friggframework/prettier-config": "2.0.0--canary.654.
|
|
52
|
-
"@friggframework/test": "2.0.0--canary.654.
|
|
50
|
+
"@friggframework/eslint-config": "2.0.0--canary.654.70623e2.0",
|
|
51
|
+
"@friggframework/prettier-config": "2.0.0--canary.654.70623e2.0",
|
|
52
|
+
"@friggframework/test": "2.0.0--canary.654.70623e2.0",
|
|
53
53
|
"@prisma/client": "^6.19.3",
|
|
54
54
|
"@types/lodash": "4.17.15",
|
|
55
55
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "70623e2fbe9d93afb370528085ea543c784775c4"
|
|
93
93
|
}
|