@contember/engine-actions 2.2.0-alpha.13 → 2.2.0-alpha.14
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/dist/development/src/ActionsExecutionContainerHookFactory.cjs +10 -1
- package/dist/development/src/ActionsExecutionContainerHookFactory.cjs.map +1 -1
- package/dist/development/src/ActionsExecutionContainerHookFactory.js +10 -1
- package/dist/development/src/ActionsExecutionContainerHookFactory.js.map +1 -1
- package/dist/production/src/ActionsExecutionContainerHookFactory.cjs +10 -1
- package/dist/production/src/ActionsExecutionContainerHookFactory.cjs.map +1 -1
- package/dist/production/src/ActionsExecutionContainerHookFactory.js +10 -1
- package/dist/production/src/ActionsExecutionContainerHookFactory.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ActionsExecutionContainerHookFactory.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/ActionsExecutionContainerHookFactory.ts +13 -2
package/package.json
CHANGED
|
@@ -22,27 +22,27 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@contember/authorization": "2.2.0-alpha.
|
|
26
|
-
"@contember/database": "2.2.0-alpha.
|
|
27
|
-
"@contember/database-migrations": "2.2.0-alpha.
|
|
28
|
-
"@contember/engine-common": "2.2.0-alpha.
|
|
29
|
-
"@contember/engine-content-api": "2.2.0-alpha.
|
|
30
|
-
"@contember/engine-http": "2.2.0-alpha.
|
|
31
|
-
"@contember/engine-plugins": "2.2.0-alpha.
|
|
32
|
-
"@contember/engine-system-api": "2.2.0-alpha.
|
|
33
|
-
"@contember/engine-tenant-api": "2.2.0-alpha.
|
|
34
|
-
"@contember/graphql-utils": "2.2.0-alpha.
|
|
35
|
-
"@contember/logger": "2.2.0-alpha.
|
|
36
|
-
"@contember/schema": "2.2.0-alpha.
|
|
37
|
-
"@contember/schema-utils": "2.2.0-alpha.
|
|
38
|
-
"@contember/telemetry": "2.2.0-alpha.
|
|
39
|
-
"@contember/typesafe": "2.2.0-alpha.
|
|
25
|
+
"@contember/authorization": "2.2.0-alpha.14",
|
|
26
|
+
"@contember/database": "2.2.0-alpha.14",
|
|
27
|
+
"@contember/database-migrations": "2.2.0-alpha.14",
|
|
28
|
+
"@contember/engine-common": "2.2.0-alpha.14",
|
|
29
|
+
"@contember/engine-content-api": "2.2.0-alpha.14",
|
|
30
|
+
"@contember/engine-http": "2.2.0-alpha.14",
|
|
31
|
+
"@contember/engine-plugins": "2.2.0-alpha.14",
|
|
32
|
+
"@contember/engine-system-api": "2.2.0-alpha.14",
|
|
33
|
+
"@contember/engine-tenant-api": "2.2.0-alpha.14",
|
|
34
|
+
"@contember/graphql-utils": "2.2.0-alpha.14",
|
|
35
|
+
"@contember/logger": "2.2.0-alpha.14",
|
|
36
|
+
"@contember/schema": "2.2.0-alpha.14",
|
|
37
|
+
"@contember/schema-utils": "2.2.0-alpha.14",
|
|
38
|
+
"@contember/telemetry": "2.2.0-alpha.14",
|
|
39
|
+
"@contember/typesafe": "2.2.0-alpha.14",
|
|
40
40
|
"@graphql-tools/schema": "^10.0.31",
|
|
41
41
|
"graphql-tag": "^2.12.6",
|
|
42
42
|
"prom-client": "^12.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@contember/database-tester": "2.2.0-alpha.
|
|
45
|
+
"@contember/database-tester": "2.2.0-alpha.14",
|
|
46
46
|
"@types/bun": "^1.3.10",
|
|
47
47
|
"@types/ws": "^8.18.1",
|
|
48
48
|
"graphql": "^16.13.1"
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"pg": "^8.20.0"
|
|
53
53
|
},
|
|
54
54
|
"type": "module",
|
|
55
|
-
"version": "2.2.0-alpha.
|
|
55
|
+
"version": "2.2.0-alpha.14",
|
|
56
56
|
"repository": {
|
|
57
57
|
"type": "git",
|
|
58
58
|
"url": "git+https://github.com/contember/contember.git",
|
|
@@ -2,9 +2,19 @@ import { TriggerHandler, TriggerIndirectChangesFetcher, TriggerPayloadManager }
|
|
|
2
2
|
import { ListenerStoreProvider } from './ListenerStoreProvider.js'
|
|
3
3
|
import { TriggerPayloadBuilder } from './triggers/TriggerPayloadBuilder.js'
|
|
4
4
|
import { TriggerPayloadPersister } from './triggers/TriggerPayloadPersister.js'
|
|
5
|
-
import { ExecutionContainerHook } from '@contember/engine-content-api'
|
|
5
|
+
import { ExecutionContainerHook, InMemoryTriggeredActionsCollector, Mapper, TriggeredActionsCollector } from '@contember/engine-content-api'
|
|
6
6
|
import { ActionsMetrics } from './ActionsMetrics.js'
|
|
7
7
|
|
|
8
|
+
// Each transaction attempt has its own mapper. Its action IDs reach the request collector only once the attempt
|
|
9
|
+
// commits, so a rolled-back or retried attempt reports no event that was never stored.
|
|
10
|
+
const collectAfterCommit = (mapper: Mapper, requestCollector: TriggeredActionsCollector): TriggeredActionsCollector => {
|
|
11
|
+
const attemptCollector = new InMemoryTriggeredActionsCollector()
|
|
12
|
+
mapper.eventManager.listen('AfterCommitEvent', async () => {
|
|
13
|
+
requestCollector.add(attemptCollector.getEvents())
|
|
14
|
+
})
|
|
15
|
+
return attemptCollector
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
export class ActionsExecutionContainerHookFactory {
|
|
9
19
|
constructor(
|
|
10
20
|
private readonly listenerStoreProvider: ListenerStoreProvider,
|
|
@@ -24,6 +34,7 @@ export class ActionsExecutionContainerHookFactory {
|
|
|
24
34
|
) => {
|
|
25
35
|
const projectMetrics = this.metricsProvider()?.forProject(project.slug)
|
|
26
36
|
mapperFactory.hooks.push(mapper => {
|
|
37
|
+
const attemptCollector = triggeredActionsCollector ? collectAfterCommit(mapper, triggeredActionsCollector) : undefined
|
|
27
38
|
const triggerPayloadPersister = new TriggerPayloadPersister(
|
|
28
39
|
mapper,
|
|
29
40
|
mapper.db.forSchema(systemSchema),
|
|
@@ -33,7 +44,7 @@ export class ActionsExecutionContainerHookFactory {
|
|
|
33
44
|
schemaMeta.id,
|
|
34
45
|
mapper.identityId,
|
|
35
46
|
userInfo,
|
|
36
|
-
|
|
47
|
+
attemptCollector,
|
|
37
48
|
projectMetrics,
|
|
38
49
|
)
|
|
39
50
|
const triggerPayloadBuilder = new TriggerPayloadBuilder(mapper)
|