@ossy/platform 3.20.1 → 3.20.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/platform",
|
|
3
|
-
"version": "3.20.
|
|
3
|
+
"version": "3.20.2",
|
|
4
4
|
"description": "Ossy application server runtime",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"Dockerfile",
|
|
80
80
|
"docker-healthcheck.js"
|
|
81
81
|
],
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "d0e5d69906917105609af4bb8bbdd2340d9fbaf1"
|
|
83
83
|
}
|
|
@@ -16,6 +16,18 @@ import { resolveClientIp, runWithEventContext } from '@ossy/event-store'
|
|
|
16
16
|
const SCHEDULER_INTERVAL_MS = 60_000
|
|
17
17
|
const _serviceLog = createLogger('TaskService')
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Written on the request path. Dispatch must not resolve workspace triggers
|
|
21
|
+
* for these — that lists task instances once per configurable task.
|
|
22
|
+
* Projections still fold them on the change stream (#1026).
|
|
23
|
+
* Same set as aggregate-rebuild `excludeTypes`.
|
|
24
|
+
*/
|
|
25
|
+
const AUDIT_DISPATCH_TYPES = new Set([
|
|
26
|
+
'@ossy/platform/schema/task-run',
|
|
27
|
+
'@ossy/platform/schema/action-invocation',
|
|
28
|
+
'@ossy/platform/schema/meter-event',
|
|
29
|
+
])
|
|
30
|
+
|
|
19
31
|
function buildTaskContext (baseContext, extras = {}) {
|
|
20
32
|
return {
|
|
21
33
|
...baseContext,
|
|
@@ -356,6 +368,7 @@ export class TaskService {
|
|
|
356
368
|
*/
|
|
357
369
|
static async dispatch(event, { sdk } = {}) {
|
|
358
370
|
if (!event) return
|
|
371
|
+
if (AUDIT_DISPATCH_TYPES.has(event.type)) return
|
|
359
372
|
|
|
360
373
|
const baseSdk = sdk ?? await sdkBoundTo()
|
|
361
374
|
const effectiveSdk = typeof baseSdk?.withEventContext === 'function'
|
|
@@ -122,6 +122,61 @@ describe('TaskService triggers', () => {
|
|
|
122
122
|
TaskService.setInstanceTriggersResolver(null)
|
|
123
123
|
})
|
|
124
124
|
|
|
125
|
+
it('skips audit events before resolving instance triggers', async () => {
|
|
126
|
+
const calls = []
|
|
127
|
+
const previousTasks = TaskService._tasks
|
|
128
|
+
const previousById = TaskService._tasksById
|
|
129
|
+
TaskService._tasks = []
|
|
130
|
+
TaskService._tasksById = new Map()
|
|
131
|
+
TaskService.setInstanceTriggersResolver(async ({ taskId, workspaceId }) => {
|
|
132
|
+
calls.push({ taskId, workspaceId })
|
|
133
|
+
return []
|
|
134
|
+
})
|
|
135
|
+
TaskService.registerTask({
|
|
136
|
+
metadata: {
|
|
137
|
+
id: '@ossy/media-tasks/tasks/resize-common-web',
|
|
138
|
+
configurable: true,
|
|
139
|
+
triggers: [{ type: '@ossy/platform/schema/file', event: 'Created' }],
|
|
140
|
+
},
|
|
141
|
+
run () {},
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
const auditEvent = (type) => ({
|
|
145
|
+
id: `evt-${type}`,
|
|
146
|
+
type,
|
|
147
|
+
event: 'Recorded',
|
|
148
|
+
resourceId: 'r1',
|
|
149
|
+
payload: { belongsTo: 'ws1' },
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
for (const type of [
|
|
154
|
+
'@ossy/platform/schema/task-run',
|
|
155
|
+
'@ossy/platform/schema/action-invocation',
|
|
156
|
+
'@ossy/platform/schema/meter-event',
|
|
157
|
+
]) {
|
|
158
|
+
await TaskService.dispatch(auditEvent(type), { sdk: {} })
|
|
159
|
+
}
|
|
160
|
+
expect(calls).toEqual([])
|
|
161
|
+
|
|
162
|
+
await TaskService.dispatch({
|
|
163
|
+
id: 'evt-file',
|
|
164
|
+
type: '@ossy/platform/schema/file',
|
|
165
|
+
event: 'Created',
|
|
166
|
+
resourceId: 'file1',
|
|
167
|
+
payload: { belongsTo: 'ws1', location: '/incoming/a.jpg' },
|
|
168
|
+
}, { sdk: {} })
|
|
169
|
+
expect(calls).toEqual([{
|
|
170
|
+
taskId: '@ossy/media-tasks/tasks/resize-common-web',
|
|
171
|
+
workspaceId: 'ws1',
|
|
172
|
+
}])
|
|
173
|
+
} finally {
|
|
174
|
+
TaskService._tasks = previousTasks
|
|
175
|
+
TaskService._tasksById = previousById
|
|
176
|
+
TaskService.setInstanceTriggersResolver(null)
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
|
|
125
180
|
it('uses instance triggers for configurable tasks', async () => {
|
|
126
181
|
const instanceTriggers = [{
|
|
127
182
|
kind: 'on_event',
|