@shipfox/api-triggers 2.0.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.
- package/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-type$colon$emit.log +1 -0
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +224 -0
- package/LICENSE +21 -0
- package/README.md +300 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +42 -0
- package/dist/config.js.map +1 -0
- package/dist/core/compute-next-fire-at.d.ts +9 -0
- package/dist/core/compute-next-fire-at.d.ts.map +1 -0
- package/dist/core/compute-next-fire-at.js +28 -0
- package/dist/core/compute-next-fire-at.js.map +1 -0
- package/dist/core/config.d.ts +26 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +68 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/dispatch-integration-event.d.ts +14 -0
- package/dist/core/dispatch-integration-event.d.ts.map +1 -0
- package/dist/core/dispatch-integration-event.js +136 -0
- package/dist/core/dispatch-integration-event.js.map +1 -0
- package/dist/core/drain-cron-schedules.d.ts +30 -0
- package/dist/core/drain-cron-schedules.d.ts.map +1 -0
- package/dist/core/drain-cron-schedules.js +76 -0
- package/dist/core/drain-cron-schedules.js.map +1 -0
- package/dist/core/entities/cron-schedule.d.ts +11 -0
- package/dist/core/entities/cron-schedule.d.ts.map +1 -0
- package/dist/core/entities/cron-schedule.js +3 -0
- package/dist/core/entities/cron-schedule.js.map +1 -0
- package/dist/core/entities/decision.d.ts +23 -0
- package/dist/core/entities/decision.d.ts.map +1 -0
- package/dist/core/entities/decision.js +7 -0
- package/dist/core/entities/decision.js.map +1 -0
- package/dist/core/entities/index.d.ts +3 -0
- package/dist/core/entities/index.d.ts.map +1 -0
- package/dist/core/entities/index.js +3 -0
- package/dist/core/entities/index.js.map +1 -0
- package/dist/core/entities/job-listener-subscription.d.ts +14 -0
- package/dist/core/entities/job-listener-subscription.d.ts.map +1 -0
- package/dist/core/entities/job-listener-subscription.js +3 -0
- package/dist/core/entities/job-listener-subscription.js.map +1 -0
- package/dist/core/entities/received-event.d.ts +28 -0
- package/dist/core/entities/received-event.d.ts.map +1 -0
- package/dist/core/entities/received-event.js +14 -0
- package/dist/core/entities/received-event.js.map +1 -0
- package/dist/core/entities/subscription.d.ts +13 -0
- package/dist/core/entities/subscription.d.ts.map +1 -0
- package/dist/core/entities/subscription.js +3 -0
- package/dist/core/entities/subscription.js.map +1 -0
- package/dist/core/errors.d.ts +25 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +41 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/fire-cron.d.ts +28 -0
- package/dist/core/fire-cron.d.ts.map +1 -0
- package/dist/core/fire-cron.js +85 -0
- package/dist/core/fire-cron.js.map +1 -0
- package/dist/core/fire-manual.d.ts +9 -0
- package/dist/core/fire-manual.d.ts.map +1 -0
- package/dist/core/fire-manual.js +87 -0
- package/dist/core/fire-manual.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +10 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/record-trigger-history.d.ts +35 -0
- package/dist/core/record-trigger-history.d.ts.map +1 -0
- package/dist/core/record-trigger-history.js +75 -0
- package/dist/core/record-trigger-history.js.map +1 -0
- package/dist/core/route-event-to-job-listeners.d.ts +31 -0
- package/dist/core/route-event-to-job-listeners.d.ts.map +1 -0
- package/dist/core/route-event-to-job-listeners.js +140 -0
- package/dist/core/route-event-to-job-listeners.js.map +1 -0
- package/dist/db/cron-schedules.d.ts +36 -0
- package/dist/db/cron-schedules.d.ts.map +1 -0
- package/dist/db/cron-schedules.js +104 -0
- package/dist/db/cron-schedules.js.map +1 -0
- package/dist/db/db.d.ts +2515 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +28 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/event-history.d.ts +50 -0
- package/dist/db/event-history.d.ts.map +1 -0
- package/dist/db/event-history.js +207 -0
- package/dist/db/event-history.js.map +1 -0
- package/dist/db/event-queries.d.ts +38 -0
- package/dist/db/event-queries.d.ts.map +1 -0
- package/dist/db/event-queries.js +78 -0
- package/dist/db/event-queries.js.map +1 -0
- package/dist/db/index.d.ts +11 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +14 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/job-listener-subscriptions.d.ts +24 -0
- package/dist/db/job-listener-subscriptions.d.ts.map +1 -0
- package/dist/db/job-listener-subscriptions.js +69 -0
- package/dist/db/job-listener-subscriptions.js.map +1 -0
- package/dist/db/received-events.d.ts +7 -0
- package/dist/db/received-events.d.ts.map +1 -0
- package/dist/db/received-events.js +11 -0
- package/dist/db/received-events.js.map +1 -0
- package/dist/db/schema/common.d.ts +2 -0
- package/dist/db/schema/common.d.ts.map +1 -0
- package/dist/db/schema/common.js +4 -0
- package/dist/db/schema/common.js.map +1 -0
- package/dist/db/schema/cron-schedules.d.ts +148 -0
- package/dist/db/schema/cron-schedules.d.ts.map +1 -0
- package/dist/db/schema/cron-schedules.js +39 -0
- package/dist/db/schema/cron-schedules.js.map +1 -0
- package/dist/db/schema/decisions.d.ts +284 -0
- package/dist/db/schema/decisions.d.ts.map +1 -0
- package/dist/db/schema/decisions.js +70 -0
- package/dist/db/schema/decisions.js.map +1 -0
- package/dist/db/schema/job-listener-subscriptions.d.ts +185 -0
- package/dist/db/schema/job-listener-subscriptions.d.ts.map +1 -0
- package/dist/db/schema/job-listener-subscriptions.js +41 -0
- package/dist/db/schema/job-listener-subscriptions.js.map +1 -0
- package/dist/db/schema/outbox.d.ts +195 -0
- package/dist/db/schema/outbox.d.ts.map +1 -0
- package/dist/db/schema/outbox.js +5 -0
- package/dist/db/schema/outbox.js.map +1 -0
- package/dist/db/schema/received-events.d.ts +544 -0
- package/dist/db/schema/received-events.d.ts.map +1 -0
- package/dist/db/schema/received-events.js +86 -0
- package/dist/db/schema/received-events.js.map +1 -0
- package/dist/db/schema/subscriptions.d.ts +182 -0
- package/dist/db/schema/subscriptions.d.ts.map +1 -0
- package/dist/db/schema/subscriptions.js +39 -0
- package/dist/db/schema/subscriptions.js.map +1 -0
- package/dist/db/subscriptions.d.ts +26 -0
- package/dist/db/subscriptions.d.ts.map +1 -0
- package/dist/db/subscriptions.js +103 -0
- package/dist/db/subscriptions.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/index.d.ts +3 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +4 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/instance.d.ts +15 -0
- package/dist/metrics/instance.d.ts.map +1 -0
- package/dist/metrics/instance.js +32 -0
- package/dist/metrics/instance.js.map +1 -0
- package/dist/metrics/service.d.ts +2 -0
- package/dist/metrics/service.d.ts.map +1 -0
- package/dist/metrics/service.js +15 -0
- package/dist/metrics/service.js.map +1 -0
- package/dist/presentation/dto/trigger-events.d.ts +7 -0
- package/dist/presentation/dto/trigger-events.d.ts.map +1 -0
- package/dist/presentation/dto/trigger-events.js +47 -0
- package/dist/presentation/dto/trigger-events.js.map +1 -0
- package/dist/presentation/index.d.ts +3 -0
- package/dist/presentation/index.d.ts.map +1 -0
- package/dist/presentation/index.js +4 -0
- package/dist/presentation/index.js.map +1 -0
- package/dist/presentation/routes/fire-manual.d.ts +2 -0
- package/dist/presentation/routes/fire-manual.d.ts.map +1 -0
- package/dist/presentation/routes/fire-manual.js +71 -0
- package/dist/presentation/routes/fire-manual.js.map +1 -0
- package/dist/presentation/routes/get-trigger-event.d.ts +2 -0
- package/dist/presentation/routes/get-trigger-event.d.ts.map +1 -0
- package/dist/presentation/routes/get-trigger-event.js +37 -0
- package/dist/presentation/routes/get-trigger-event.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +3 -0
- package/dist/presentation/routes/index.d.ts.map +1 -0
- package/dist/presentation/routes/index.js +27 -0
- package/dist/presentation/routes/index.js.map +1 -0
- package/dist/presentation/routes/list-trigger-event-facets.d.ts +2 -0
- package/dist/presentation/routes/list-trigger-event-facets.d.ts.map +1 -0
- package/dist/presentation/routes/list-trigger-event-facets.js +29 -0
- package/dist/presentation/routes/list-trigger-event-facets.js.map +1 -0
- package/dist/presentation/routes/list-trigger-events.d.ts +2 -0
- package/dist/presentation/routes/list-trigger-events.d.ts.map +1 -0
- package/dist/presentation/routes/list-trigger-events.js +56 -0
- package/dist/presentation/routes/list-trigger-events.js.map +1 -0
- package/dist/presentation/subscribers/index.d.ts +6 -0
- package/dist/presentation/subscribers/index.d.ts.map +1 -0
- package/dist/presentation/subscribers/index.js +7 -0
- package/dist/presentation/subscribers/index.js.map +1 -0
- package/dist/presentation/subscribers/on-definition-deleted.d.ts +3 -0
- package/dist/presentation/subscribers/on-definition-deleted.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-definition-deleted.js +8 -0
- package/dist/presentation/subscribers/on-definition-deleted.js.map +1 -0
- package/dist/presentation/subscribers/on-definition-resolved.d.ts +3 -0
- package/dist/presentation/subscribers/on-definition-resolved.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-definition-resolved.js +11 -0
- package/dist/presentation/subscribers/on-definition-resolved.js.map +1 -0
- package/dist/presentation/subscribers/on-integration-event-received.d.ts +4 -0
- package/dist/presentation/subscribers/on-integration-event-received.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-integration-event-received.js +17 -0
- package/dist/presentation/subscribers/on-integration-event-received.js.map +1 -0
- package/dist/presentation/subscribers/on-job-activated.d.ts +3 -0
- package/dist/presentation/subscribers/on-job-activated.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-job-activated.js +13 -0
- package/dist/presentation/subscribers/on-job-activated.js.map +1 -0
- package/dist/presentation/subscribers/on-job-terminated.d.ts +3 -0
- package/dist/presentation/subscribers/on-job-terminated.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-job-terminated.js +6 -0
- package/dist/presentation/subscribers/on-job-terminated.js.map +1 -0
- package/dist/temporal/activities/drain-cron-batch.d.ts +4 -0
- package/dist/temporal/activities/drain-cron-batch.d.ts.map +1 -0
- package/dist/temporal/activities/drain-cron-batch.js +20 -0
- package/dist/temporal/activities/drain-cron-batch.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +10 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +15 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/activities/prune-trigger-events.d.ts +4 -0
- package/dist/temporal/activities/prune-trigger-events.d.ts.map +1 -0
- package/dist/temporal/activities/prune-trigger-events.js +11 -0
- package/dist/temporal/activities/prune-trigger-events.js.map +1 -0
- package/dist/temporal/constants.d.ts +7 -0
- package/dist/temporal/constants.d.ts.map +1 -0
- package/dist/temporal/constants.js +7 -0
- package/dist/temporal/constants.js.map +1 -0
- package/dist/temporal/workflows/cron-tick-cron.d.ts +9 -0
- package/dist/temporal/workflows/cron-tick-cron.d.ts.map +1 -0
- package/dist/temporal/workflows/cron-tick-cron.js +54 -0
- package/dist/temporal/workflows/cron-tick-cron.js.map +1 -0
- package/dist/temporal/workflows/index.d.ts +3 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +4 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/temporal/workflows/prune-trigger-events-cron.d.ts +2 -0
- package/dist/temporal/workflows/prune-trigger-events-cron.d.ts.map +1 -0
- package/dist/temporal/workflows/prune-trigger-events-cron.js +18 -0
- package/dist/temporal/workflows/prune-trigger-events-cron.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/drizzle/0000_initial.sql +109 -0
- package/drizzle/meta/0000_snapshot.json +905 -0
- package/drizzle/meta/_journal.json +13 -0
- package/drizzle.config.ts +14 -0
- package/package.json +83 -0
- package/src/config.test.ts +33 -0
- package/src/config.ts +53 -0
- package/src/core/compute-next-fire-at.test.ts +69 -0
- package/src/core/compute-next-fire-at.ts +37 -0
- package/src/core/config.test.ts +213 -0
- package/src/core/config.ts +86 -0
- package/src/core/dispatch-integration-event.history-failure.test.ts +66 -0
- package/src/core/dispatch-integration-event.test.ts +1006 -0
- package/src/core/dispatch-integration-event.ts +150 -0
- package/src/core/drain-cron-schedules.test.ts +265 -0
- package/src/core/drain-cron-schedules.ts +90 -0
- package/src/core/entities/cron-schedule.ts +10 -0
- package/src/core/entities/decision.ts +24 -0
- package/src/core/entities/index.ts +5 -0
- package/src/core/entities/job-listener-subscription.ts +14 -0
- package/src/core/entities/received-event.ts +36 -0
- package/src/core/entities/subscription.ts +12 -0
- package/src/core/errors.ts +63 -0
- package/src/core/fire-cron.test.ts +146 -0
- package/src/core/fire-cron.ts +98 -0
- package/src/core/fire-manual.test.ts +157 -0
- package/src/core/fire-manual.ts +92 -0
- package/src/core/index.ts +34 -0
- package/src/core/record-trigger-history.test.ts +159 -0
- package/src/core/record-trigger-history.ts +145 -0
- package/src/core/route-event-to-job-listeners.test.ts +369 -0
- package/src/core/route-event-to-job-listeners.ts +184 -0
- package/src/db/cron-schedules.test.ts +358 -0
- package/src/db/cron-schedules.ts +163 -0
- package/src/db/db.ts +31 -0
- package/src/db/event-history.test.ts +421 -0
- package/src/db/event-history.ts +279 -0
- package/src/db/event-queries.ts +140 -0
- package/src/db/index.ts +51 -0
- package/src/db/job-listener-subscriptions.test.ts +270 -0
- package/src/db/job-listener-subscriptions.ts +133 -0
- package/src/db/received-events.ts +16 -0
- package/src/db/schema/common.ts +3 -0
- package/src/db/schema/cron-schedules.ts +37 -0
- package/src/db/schema/decisions.test.ts +279 -0
- package/src/db/schema/decisions.ts +77 -0
- package/src/db/schema/job-listener-subscriptions.ts +65 -0
- package/src/db/schema/outbox.ts +4 -0
- package/src/db/schema/received-events.test.ts +135 -0
- package/src/db/schema/received-events.ts +93 -0
- package/src/db/schema/subscriptions.ts +46 -0
- package/src/db/subscriptions.test.ts +340 -0
- package/src/db/subscriptions.ts +179 -0
- package/src/index.ts +108 -0
- package/src/metrics/index.ts +8 -0
- package/src/metrics/instance.ts +33 -0
- package/src/metrics/service.ts +18 -0
- package/src/presentation/dto/trigger-events.test.ts +144 -0
- package/src/presentation/dto/trigger-events.ts +60 -0
- package/src/presentation/index.ts +6 -0
- package/src/presentation/routes/fire-manual.test.ts +118 -0
- package/src/presentation/routes/fire-manual.ts +70 -0
- package/src/presentation/routes/get-trigger-event.test.ts +184 -0
- package/src/presentation/routes/get-trigger-event.ts +37 -0
- package/src/presentation/routes/index.ts +21 -0
- package/src/presentation/routes/list-trigger-event-facets.test.ts +116 -0
- package/src/presentation/routes/list-trigger-event-facets.ts +29 -0
- package/src/presentation/routes/list-trigger-events.test.ts +379 -0
- package/src/presentation/routes/list-trigger-events.ts +68 -0
- package/src/presentation/subscribers/index.ts +5 -0
- package/src/presentation/subscribers/on-definition-deleted.test.ts +42 -0
- package/src/presentation/subscribers/on-definition-deleted.ts +6 -0
- package/src/presentation/subscribers/on-definition-resolved.test.ts +67 -0
- package/src/presentation/subscribers/on-definition-resolved.ts +11 -0
- package/src/presentation/subscribers/on-integration-event-received.test.ts +53 -0
- package/src/presentation/subscribers/on-integration-event-received.ts +21 -0
- package/src/presentation/subscribers/on-job-activated.ts +14 -0
- package/src/presentation/subscribers/on-job-terminated.ts +6 -0
- package/src/temporal/activities/drain-cron-batch.ts +20 -0
- package/src/temporal/activities/index.ts +15 -0
- package/src/temporal/activities/prune-trigger-events.test.ts +78 -0
- package/src/temporal/activities/prune-trigger-events.ts +9 -0
- package/src/temporal/constants.ts +7 -0
- package/src/temporal/workflows/cron-tick-cron.ts +56 -0
- package/src/temporal/workflows/index.ts +2 -0
- package/src/temporal/workflows/prune-trigger-events-cron.ts +17 -0
- package/test/env.ts +8 -0
- package/test/factories/cron-schedule.ts +34 -0
- package/test/factories/decision.ts +49 -0
- package/test/factories/job-listener-subscription.ts +42 -0
- package/test/factories/received-event.ts +49 -0
- package/test/factories/subscription.ts +38 -0
- package/test/globalSetup.ts +20 -0
- package/test/index.ts +5 -0
- package/test/setup.ts +17 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/tsconfig.test.json +8 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function toTriggerEventListItemDto(event) {
|
|
2
|
+
return {
|
|
3
|
+
id: event.id,
|
|
4
|
+
event_ref: event.eventRef,
|
|
5
|
+
origin: event.origin,
|
|
6
|
+
workspace_id: event.workspaceId,
|
|
7
|
+
provider: event.provider,
|
|
8
|
+
source: event.source,
|
|
9
|
+
event: event.event,
|
|
10
|
+
delivery_id: event.deliveryId,
|
|
11
|
+
connection_id: event.connectionId,
|
|
12
|
+
outcome: event.outcome,
|
|
13
|
+
matched_count: event.matchedCount,
|
|
14
|
+
received_at: event.receivedAt.toISOString(),
|
|
15
|
+
processed_at: event.processedAt?.toISOString() ?? null,
|
|
16
|
+
created_at: event.createdAt.toISOString()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function toTriggerEventDto(event) {
|
|
20
|
+
return {
|
|
21
|
+
...toTriggerEventListItemDto(event),
|
|
22
|
+
connection_name: event.connectionName,
|
|
23
|
+
payload: event.payload
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function toTriggerDecisionDto(decision) {
|
|
27
|
+
return {
|
|
28
|
+
id: decision.id,
|
|
29
|
+
received_event_id: decision.receivedEventId,
|
|
30
|
+
subscription_kind: decision.subscriptionKind,
|
|
31
|
+
subscription_id: decision.subscriptionId,
|
|
32
|
+
subscription_name: decision.subscriptionName,
|
|
33
|
+
workflow_definition_id: decision.workflowDefinitionId,
|
|
34
|
+
project_id: decision.projectId,
|
|
35
|
+
workflow_run_id: decision.workflowRunId,
|
|
36
|
+
job_id: decision.jobId,
|
|
37
|
+
matcher_kind: decision.matcherKind,
|
|
38
|
+
matcher_ordinal: decision.matcherOrdinal,
|
|
39
|
+
decision: decision.decision,
|
|
40
|
+
run_id: decision.runId,
|
|
41
|
+
run_name: decision.runName,
|
|
42
|
+
reason: decision.reason,
|
|
43
|
+
created_at: decision.createdAt.toISOString()
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=trigger-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/dto/trigger-events.ts"],"sourcesContent":["import type {\n TriggerDecisionDto,\n TriggerEventDto,\n TriggerEventListItemDto,\n} from '@shipfox/api-triggers-dto';\nimport type {TriggerDecision} from '#core/entities/decision.js';\nimport type {\n TriggerReceivedEvent,\n TriggerReceivedEventSummary,\n} from '#core/entities/received-event.js';\n\nexport function toTriggerEventListItemDto(\n event: TriggerReceivedEventSummary,\n): TriggerEventListItemDto {\n return {\n id: event.id,\n event_ref: event.eventRef,\n origin: event.origin,\n workspace_id: event.workspaceId,\n provider: event.provider,\n source: event.source,\n event: event.event,\n delivery_id: event.deliveryId,\n connection_id: event.connectionId,\n outcome: event.outcome,\n matched_count: event.matchedCount,\n received_at: event.receivedAt.toISOString(),\n processed_at: event.processedAt?.toISOString() ?? null,\n created_at: event.createdAt.toISOString(),\n };\n}\n\nexport function toTriggerEventDto(event: TriggerReceivedEvent): TriggerEventDto {\n return {\n ...toTriggerEventListItemDto(event),\n connection_name: event.connectionName,\n payload: event.payload,\n };\n}\n\nexport function toTriggerDecisionDto(decision: TriggerDecision): TriggerDecisionDto {\n return {\n id: decision.id,\n received_event_id: decision.receivedEventId,\n subscription_kind: decision.subscriptionKind,\n subscription_id: decision.subscriptionId,\n subscription_name: decision.subscriptionName,\n workflow_definition_id: decision.workflowDefinitionId,\n project_id: decision.projectId,\n workflow_run_id: decision.workflowRunId,\n job_id: decision.jobId,\n matcher_kind: decision.matcherKind,\n matcher_ordinal: decision.matcherOrdinal,\n decision: decision.decision,\n run_id: decision.runId,\n run_name: decision.runName,\n reason: decision.reason,\n created_at: decision.createdAt.toISOString(),\n };\n}\n"],"names":["toTriggerEventListItemDto","event","id","event_ref","eventRef","origin","workspace_id","workspaceId","provider","source","delivery_id","deliveryId","connection_id","connectionId","outcome","matched_count","matchedCount","received_at","receivedAt","toISOString","processed_at","processedAt","created_at","createdAt","toTriggerEventDto","connection_name","connectionName","payload","toTriggerDecisionDto","decision","received_event_id","receivedEventId","subscription_kind","subscriptionKind","subscription_id","subscriptionId","subscription_name","subscriptionName","workflow_definition_id","workflowDefinitionId","project_id","projectId","workflow_run_id","workflowRunId","job_id","jobId","matcher_kind","matcherKind","matcher_ordinal","matcherOrdinal","run_id","runId","run_name","runName","reason"],"mappings":"AAWA,OAAO,SAASA,0BACdC,KAAkC;IAElC,OAAO;QACLC,IAAID,MAAMC,EAAE;QACZC,WAAWF,MAAMG,QAAQ;QACzBC,QAAQJ,MAAMI,MAAM;QACpBC,cAAcL,MAAMM,WAAW;QAC/BC,UAAUP,MAAMO,QAAQ;QACxBC,QAAQR,MAAMQ,MAAM;QACpBR,OAAOA,MAAMA,KAAK;QAClBS,aAAaT,MAAMU,UAAU;QAC7BC,eAAeX,MAAMY,YAAY;QACjCC,SAASb,MAAMa,OAAO;QACtBC,eAAed,MAAMe,YAAY;QACjCC,aAAahB,MAAMiB,UAAU,CAACC,WAAW;QACzCC,cAAcnB,MAAMoB,WAAW,EAAEF,iBAAiB;QAClDG,YAAYrB,MAAMsB,SAAS,CAACJ,WAAW;IACzC;AACF;AAEA,OAAO,SAASK,kBAAkBvB,KAA2B;IAC3D,OAAO;QACL,GAAGD,0BAA0BC,MAAM;QACnCwB,iBAAiBxB,MAAMyB,cAAc;QACrCC,SAAS1B,MAAM0B,OAAO;IACxB;AACF;AAEA,OAAO,SAASC,qBAAqBC,QAAyB;IAC5D,OAAO;QACL3B,IAAI2B,SAAS3B,EAAE;QACf4B,mBAAmBD,SAASE,eAAe;QAC3CC,mBAAmBH,SAASI,gBAAgB;QAC5CC,iBAAiBL,SAASM,cAAc;QACxCC,mBAAmBP,SAASQ,gBAAgB;QAC5CC,wBAAwBT,SAASU,oBAAoB;QACrDC,YAAYX,SAASY,SAAS;QAC9BC,iBAAiBb,SAASc,aAAa;QACvCC,QAAQf,SAASgB,KAAK;QACtBC,cAAcjB,SAASkB,WAAW;QAClCC,iBAAiBnB,SAASoB,cAAc;QACxCpB,UAAUA,SAASA,QAAQ;QAC3BqB,QAAQrB,SAASsB,KAAK;QACtBC,UAAUvB,SAASwB,OAAO;QAC1BC,QAAQzB,SAASyB,MAAM;QACvBhC,YAAYO,SAASN,SAAS,CAACJ,WAAW;IAC5C;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presentation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,IAAI,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/presentation/index.ts"],"sourcesContent":["export {triggerRoutes as routes} from './routes/index.js';\nexport {\n onDefinitionDeleted,\n onDefinitionResolved,\n onIntegrationEventReceived,\n} from './subscribers/index.js';\n"],"names":["triggerRoutes","routes","onDefinitionDeleted","onDefinitionResolved","onIntegrationEventReceived"],"mappings":"AAAA,SAAQA,iBAAiBC,MAAM,QAAO,oBAAoB;AAC1D,SACEC,mBAAmB,EACnBC,oBAAoB,EACpBC,0BAA0B,QACrB,yBAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fire-manual.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/fire-manual.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,iDAyDjC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { requireUserContext } from '@shipfox/api-auth-context';
|
|
2
|
+
import { fireManualTriggerBodySchema, fireManualTriggerResponseSchema } from '@shipfox/api-triggers-dto';
|
|
3
|
+
import { InterpolationUnresolvableError } from '@shipfox/api-workflows';
|
|
4
|
+
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { ManualTriggerNotFoundError } from '#core/errors.js';
|
|
7
|
+
import { fireManualSubscription } from '#core/fire-manual.js';
|
|
8
|
+
import { getManualSubscriptionByDefinitionId } from '#db/subscriptions.js';
|
|
9
|
+
export const fireManualTriggerRoute = defineRoute({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/:definitionId/fire-manual',
|
|
12
|
+
description: 'Fire the manual trigger of a workflow definition, creating a workflow run.',
|
|
13
|
+
schema: {
|
|
14
|
+
params: z.object({
|
|
15
|
+
definitionId: z.string().uuid()
|
|
16
|
+
}),
|
|
17
|
+
body: fireManualTriggerBodySchema,
|
|
18
|
+
response: {
|
|
19
|
+
201: fireManualTriggerResponseSchema,
|
|
20
|
+
422: z.object({
|
|
21
|
+
code: z.string(),
|
|
22
|
+
details: z.object({
|
|
23
|
+
field: z.string(),
|
|
24
|
+
source: z.string(),
|
|
25
|
+
env_key: z.string().optional()
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
errorHandler: (error)=>{
|
|
31
|
+
if (error instanceof ManualTriggerNotFoundError) {
|
|
32
|
+
throw new ClientError(error.message, 'manual-trigger-not-found', {
|
|
33
|
+
status: 404
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (error instanceof InterpolationUnresolvableError) {
|
|
37
|
+
throw new ClientError(error.message, 'workflow-interpolation-unresolvable', {
|
|
38
|
+
status: 422,
|
|
39
|
+
details: {
|
|
40
|
+
field: error.field,
|
|
41
|
+
source: error.source,
|
|
42
|
+
...error.envKey === undefined ? {} : {
|
|
43
|
+
env_key: error.envKey
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
throw error;
|
|
49
|
+
},
|
|
50
|
+
handler: async (request, reply)=>{
|
|
51
|
+
const { definitionId } = request.params;
|
|
52
|
+
const userContext = requireUserContext(request);
|
|
53
|
+
const subscription = await getManualSubscriptionByDefinitionId(definitionId);
|
|
54
|
+
// 404 covers both "no such manual trigger" and "not your workspace" to avoid leaking existence.
|
|
55
|
+
if (!subscription || !userContext.canAccess(subscription.workspaceId)) {
|
|
56
|
+
throw new ManualTriggerNotFoundError(definitionId);
|
|
57
|
+
}
|
|
58
|
+
const run = await fireManualSubscription({
|
|
59
|
+
subscriptionId: subscription.id,
|
|
60
|
+
callerWorkspaceId: subscription.workspaceId,
|
|
61
|
+
userId: userContext.userId,
|
|
62
|
+
inputs: request.body.inputs
|
|
63
|
+
});
|
|
64
|
+
reply.status(201);
|
|
65
|
+
return {
|
|
66
|
+
workflow_run_id: run.id
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=fire-manual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/fire-manual.ts"],"sourcesContent":["import {requireUserContext} from '@shipfox/api-auth-context';\nimport {\n fireManualTriggerBodySchema,\n fireManualTriggerResponseSchema,\n} from '@shipfox/api-triggers-dto';\nimport {InterpolationUnresolvableError} from '@shipfox/api-workflows';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {ManualTriggerNotFoundError} from '#core/errors.js';\nimport {fireManualSubscription} from '#core/fire-manual.js';\nimport {getManualSubscriptionByDefinitionId} from '#db/subscriptions.js';\n\nexport const fireManualTriggerRoute = defineRoute({\n method: 'POST',\n path: '/:definitionId/fire-manual',\n description: 'Fire the manual trigger of a workflow definition, creating a workflow run.',\n schema: {\n params: z.object({\n definitionId: z.string().uuid(),\n }),\n body: fireManualTriggerBodySchema,\n response: {\n 201: fireManualTriggerResponseSchema,\n 422: z.object({\n code: z.string(),\n details: z.object({\n field: z.string(),\n source: z.string(),\n env_key: z.string().optional(),\n }),\n }),\n },\n },\n errorHandler: (error) => {\n if (error instanceof ManualTriggerNotFoundError) {\n throw new ClientError(error.message, 'manual-trigger-not-found', {status: 404});\n }\n if (error instanceof InterpolationUnresolvableError) {\n throw new ClientError(error.message, 'workflow-interpolation-unresolvable', {\n status: 422,\n details: {\n field: error.field,\n source: error.source,\n ...(error.envKey === undefined ? {} : {env_key: error.envKey}),\n },\n });\n }\n throw error;\n },\n handler: async (request, reply) => {\n const {definitionId} = request.params;\n const userContext = requireUserContext(request);\n\n const subscription = await getManualSubscriptionByDefinitionId(definitionId);\n // 404 covers both \"no such manual trigger\" and \"not your workspace\" to avoid leaking existence.\n if (!subscription || !userContext.canAccess(subscription.workspaceId)) {\n throw new ManualTriggerNotFoundError(definitionId);\n }\n\n const run = await fireManualSubscription({\n subscriptionId: subscription.id,\n callerWorkspaceId: subscription.workspaceId,\n userId: userContext.userId,\n inputs: request.body.inputs,\n });\n\n reply.status(201);\n return {workflow_run_id: run.id};\n },\n});\n"],"names":["requireUserContext","fireManualTriggerBodySchema","fireManualTriggerResponseSchema","InterpolationUnresolvableError","ClientError","defineRoute","z","ManualTriggerNotFoundError","fireManualSubscription","getManualSubscriptionByDefinitionId","fireManualTriggerRoute","method","path","description","schema","params","object","definitionId","string","uuid","body","response","code","details","field","source","env_key","optional","errorHandler","error","message","status","envKey","undefined","handler","request","reply","userContext","subscription","canAccess","workspaceId","run","subscriptionId","id","callerWorkspaceId","userId","inputs","workflow_run_id"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,4BAA4B;AAC7D,SACEC,2BAA2B,EAC3BC,+BAA+B,QAC1B,4BAA4B;AACnC,SAAQC,8BAA8B,QAAO,yBAAyB;AACtE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,0BAA0B,QAAO,kBAAkB;AAC3D,SAAQC,sBAAsB,QAAO,uBAAuB;AAC5D,SAAQC,mCAAmC,QAAO,uBAAuB;AAEzE,OAAO,MAAMC,yBAAyBL,YAAY;IAChDM,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,QAAQT,EAAEU,MAAM,CAAC;YACfC,cAAcX,EAAEY,MAAM,GAAGC,IAAI;QAC/B;QACAC,MAAMnB;QACNoB,UAAU;YACR,KAAKnB;YACL,KAAKI,EAAEU,MAAM,CAAC;gBACZM,MAAMhB,EAAEY,MAAM;gBACdK,SAASjB,EAAEU,MAAM,CAAC;oBAChBQ,OAAOlB,EAAEY,MAAM;oBACfO,QAAQnB,EAAEY,MAAM;oBAChBQ,SAASpB,EAAEY,MAAM,GAAGS,QAAQ;gBAC9B;YACF;QACF;IACF;IACAC,cAAc,CAACC;QACb,IAAIA,iBAAiBtB,4BAA4B;YAC/C,MAAM,IAAIH,YAAYyB,MAAMC,OAAO,EAAE,4BAA4B;gBAACC,QAAQ;YAAG;QAC/E;QACA,IAAIF,iBAAiB1B,gCAAgC;YACnD,MAAM,IAAIC,YAAYyB,MAAMC,OAAO,EAAE,uCAAuC;gBAC1EC,QAAQ;gBACRR,SAAS;oBACPC,OAAOK,MAAML,KAAK;oBAClBC,QAAQI,MAAMJ,MAAM;oBACpB,GAAII,MAAMG,MAAM,KAAKC,YAAY,CAAC,IAAI;wBAACP,SAASG,MAAMG,MAAM;oBAAA,CAAC;gBAC/D;YACF;QACF;QACA,MAAMH;IACR;IACAK,SAAS,OAAOC,SAASC;QACvB,MAAM,EAACnB,YAAY,EAAC,GAAGkB,QAAQpB,MAAM;QACrC,MAAMsB,cAAcrC,mBAAmBmC;QAEvC,MAAMG,eAAe,MAAM7B,oCAAoCQ;QAC/D,gGAAgG;QAChG,IAAI,CAACqB,gBAAgB,CAACD,YAAYE,SAAS,CAACD,aAAaE,WAAW,GAAG;YACrE,MAAM,IAAIjC,2BAA2BU;QACvC;QAEA,MAAMwB,MAAM,MAAMjC,uBAAuB;YACvCkC,gBAAgBJ,aAAaK,EAAE;YAC/BC,mBAAmBN,aAAaE,WAAW;YAC3CK,QAAQR,YAAYQ,MAAM;YAC1BC,QAAQX,QAAQf,IAAI,CAAC0B,MAAM;QAC7B;QAEAV,MAAML,MAAM,CAAC;QACb,OAAO;YAACgB,iBAAiBN,IAAIE,EAAE;QAAA;IACjC;AACF,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-trigger-event.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-trigger-event.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,oBAAoB,iDA6B/B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { requireUserContext } from '@shipfox/api-auth-context';
|
|
2
|
+
import { triggerEventDetailResponseSchema } from '@shipfox/api-triggers-dto';
|
|
3
|
+
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { getTriggerEventById, listDecisionsByReceivedEventId } from '#db/index.js';
|
|
6
|
+
import { toTriggerDecisionDto, toTriggerEventDto } from '#presentation/dto/trigger-events.js';
|
|
7
|
+
export const getTriggerEventRoute = defineRoute({
|
|
8
|
+
method: 'GET',
|
|
9
|
+
path: '/:id',
|
|
10
|
+
description: 'Get a trigger event by ID with its routing decisions.',
|
|
11
|
+
schema: {
|
|
12
|
+
params: z.object({
|
|
13
|
+
id: z.string().uuid()
|
|
14
|
+
}),
|
|
15
|
+
response: {
|
|
16
|
+
200: triggerEventDetailResponseSchema
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
handler: async (request)=>{
|
|
20
|
+
const { id } = request.params;
|
|
21
|
+
const userContext = requireUserContext(request);
|
|
22
|
+
const event = await getTriggerEventById(id);
|
|
23
|
+
// 404 covers both "no such event" and "not your workspace" to avoid leaking existence.
|
|
24
|
+
if (!event || !userContext.canAccess(event.workspaceId)) {
|
|
25
|
+
throw new ClientError('Trigger event not found', 'not-found', {
|
|
26
|
+
status: 404
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const decisions = await listDecisionsByReceivedEventId(event.id);
|
|
30
|
+
return {
|
|
31
|
+
...toTriggerEventDto(event),
|
|
32
|
+
decisions: decisions.map(toTriggerDecisionDto)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=get-trigger-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/get-trigger-event.ts"],"sourcesContent":["import {requireUserContext} from '@shipfox/api-auth-context';\nimport {triggerEventDetailResponseSchema} from '@shipfox/api-triggers-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {getTriggerEventById, listDecisionsByReceivedEventId} from '#db/index.js';\nimport {toTriggerDecisionDto, toTriggerEventDto} from '#presentation/dto/trigger-events.js';\n\nexport const getTriggerEventRoute = defineRoute({\n method: 'GET',\n path: '/:id',\n description: 'Get a trigger event by ID with its routing decisions.',\n schema: {\n params: z.object({\n id: z.string().uuid(),\n }),\n response: {\n 200: triggerEventDetailResponseSchema,\n },\n },\n handler: async (request) => {\n const {id} = request.params;\n const userContext = requireUserContext(request);\n\n const event = await getTriggerEventById(id);\n // 404 covers both \"no such event\" and \"not your workspace\" to avoid leaking existence.\n if (!event || !userContext.canAccess(event.workspaceId)) {\n throw new ClientError('Trigger event not found', 'not-found', {status: 404});\n }\n\n const decisions = await listDecisionsByReceivedEventId(event.id);\n\n return {\n ...toTriggerEventDto(event),\n decisions: decisions.map(toTriggerDecisionDto),\n };\n },\n});\n"],"names":["requireUserContext","triggerEventDetailResponseSchema","ClientError","defineRoute","z","getTriggerEventById","listDecisionsByReceivedEventId","toTriggerDecisionDto","toTriggerEventDto","getTriggerEventRoute","method","path","description","schema","params","object","id","string","uuid","response","handler","request","userContext","event","canAccess","workspaceId","status","decisions","map"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,4BAA4B;AAC7D,SAAQC,gCAAgC,QAAO,4BAA4B;AAC3E,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,mBAAmB,EAAEC,8BAA8B,QAAO,eAAe;AACjF,SAAQC,oBAAoB,EAAEC,iBAAiB,QAAO,sCAAsC;AAE5F,OAAO,MAAMC,uBAAuBN,YAAY;IAC9CO,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,QAAQV,EAAEW,MAAM,CAAC;YACfC,IAAIZ,EAAEa,MAAM,GAAGC,IAAI;QACrB;QACAC,UAAU;YACR,KAAKlB;QACP;IACF;IACAmB,SAAS,OAAOC;QACd,MAAM,EAACL,EAAE,EAAC,GAAGK,QAAQP,MAAM;QAC3B,MAAMQ,cAActB,mBAAmBqB;QAEvC,MAAME,QAAQ,MAAMlB,oBAAoBW;QACxC,uFAAuF;QACvF,IAAI,CAACO,SAAS,CAACD,YAAYE,SAAS,CAACD,MAAME,WAAW,GAAG;YACvD,MAAM,IAAIvB,YAAY,2BAA2B,aAAa;gBAACwB,QAAQ;YAAG;QAC5E;QAEA,MAAMC,YAAY,MAAMrB,+BAA+BiB,MAAMP,EAAE;QAE/D,OAAO;YACL,GAAGR,kBAAkBe,MAAM;YAC3BI,WAAWA,UAAUC,GAAG,CAACrB;QAC3B;IACF;AACF,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAMtD,eAAO,MAAM,aAAa,EAAE,UAAU,EAarC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AUTH_USER } from '@shipfox/api-auth-context';
|
|
2
|
+
import { fireManualTriggerRoute } from './fire-manual.js';
|
|
3
|
+
import { getTriggerEventRoute } from './get-trigger-event.js';
|
|
4
|
+
import { listTriggerEventFacetsRoute } from './list-trigger-event-facets.js';
|
|
5
|
+
import { listTriggerEventsRoute } from './list-trigger-events.js';
|
|
6
|
+
export const triggerRoutes = [
|
|
7
|
+
{
|
|
8
|
+
prefix: '/workflow-definitions',
|
|
9
|
+
auth: AUTH_USER,
|
|
10
|
+
routes: [
|
|
11
|
+
fireManualTriggerRoute
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
// The static /facets path is matched ahead of the /:id detail route by Fastify's
|
|
16
|
+
// radix router, so registration order does not affect resolution.
|
|
17
|
+
prefix: '/trigger-events',
|
|
18
|
+
auth: AUTH_USER,
|
|
19
|
+
routes: [
|
|
20
|
+
listTriggerEventFacetsRoute,
|
|
21
|
+
listTriggerEventsRoute,
|
|
22
|
+
getTriggerEventRoute
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/index.ts"],"sourcesContent":["import {AUTH_USER} from '@shipfox/api-auth-context';\nimport type {RouteGroup} from '@shipfox/node-fastify';\nimport {fireManualTriggerRoute} from './fire-manual.js';\nimport {getTriggerEventRoute} from './get-trigger-event.js';\nimport {listTriggerEventFacetsRoute} from './list-trigger-event-facets.js';\nimport {listTriggerEventsRoute} from './list-trigger-events.js';\n\nexport const triggerRoutes: RouteGroup[] = [\n {\n prefix: '/workflow-definitions',\n auth: AUTH_USER,\n routes: [fireManualTriggerRoute],\n },\n {\n // The static /facets path is matched ahead of the /:id detail route by Fastify's\n // radix router, so registration order does not affect resolution.\n prefix: '/trigger-events',\n auth: AUTH_USER,\n routes: [listTriggerEventFacetsRoute, listTriggerEventsRoute, getTriggerEventRoute],\n },\n];\n"],"names":["AUTH_USER","fireManualTriggerRoute","getTriggerEventRoute","listTriggerEventFacetsRoute","listTriggerEventsRoute","triggerRoutes","prefix","auth","routes"],"mappings":"AAAA,SAAQA,SAAS,QAAO,4BAA4B;AAEpD,SAAQC,sBAAsB,QAAO,mBAAmB;AACxD,SAAQC,oBAAoB,QAAO,yBAAyB;AAC5D,SAAQC,2BAA2B,QAAO,iCAAiC;AAC3E,SAAQC,sBAAsB,QAAO,2BAA2B;AAEhE,OAAO,MAAMC,gBAA8B;IACzC;QACEC,QAAQ;QACRC,MAAMP;QACNQ,QAAQ;YAACP;SAAuB;IAClC;IACA;QACE,iFAAiF;QACjF,kEAAkE;QAClEK,QAAQ;QACRC,MAAMP;QACNQ,QAAQ;YAACL;YAA6BC;YAAwBF;SAAqB;IACrF;CACD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-trigger-event-facets.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-trigger-event-facets.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,2BAA2B,iDAoBtC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { requireUserContext } from '@shipfox/api-auth-context';
|
|
2
|
+
import { triggerEventFacetsQuerySchema, triggerEventFacetsResponseSchema } from '@shipfox/api-triggers-dto';
|
|
3
|
+
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
4
|
+
import { listTriggerEventFacets } from '#db/index.js';
|
|
5
|
+
export const listTriggerEventFacetsRoute = defineRoute({
|
|
6
|
+
method: 'GET',
|
|
7
|
+
path: '/facets',
|
|
8
|
+
description: 'Distinct source and event filter values (with counts) for a workspace.',
|
|
9
|
+
schema: {
|
|
10
|
+
querystring: triggerEventFacetsQuerySchema,
|
|
11
|
+
response: {
|
|
12
|
+
200: triggerEventFacetsResponseSchema
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
handler: async (request)=>{
|
|
16
|
+
const { workspace_id: workspaceId } = request.query;
|
|
17
|
+
const userContext = requireUserContext(request);
|
|
18
|
+
if (!userContext.canAccess(workspaceId)) {
|
|
19
|
+
throw new ClientError('Not a member of this workspace', 'forbidden', {
|
|
20
|
+
status: 403
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return await listTriggerEventFacets({
|
|
24
|
+
workspaceId
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=list-trigger-event-facets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/list-trigger-event-facets.ts"],"sourcesContent":["import {requireUserContext} from '@shipfox/api-auth-context';\nimport {\n triggerEventFacetsQuerySchema,\n triggerEventFacetsResponseSchema,\n} from '@shipfox/api-triggers-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {listTriggerEventFacets} from '#db/index.js';\n\nexport const listTriggerEventFacetsRoute = defineRoute({\n method: 'GET',\n path: '/facets',\n description: 'Distinct source and event filter values (with counts) for a workspace.',\n schema: {\n querystring: triggerEventFacetsQuerySchema,\n response: {\n 200: triggerEventFacetsResponseSchema,\n },\n },\n handler: async (request) => {\n const {workspace_id: workspaceId} = request.query;\n\n const userContext = requireUserContext(request);\n if (!userContext.canAccess(workspaceId)) {\n throw new ClientError('Not a member of this workspace', 'forbidden', {status: 403});\n }\n\n return await listTriggerEventFacets({workspaceId});\n },\n});\n"],"names":["requireUserContext","triggerEventFacetsQuerySchema","triggerEventFacetsResponseSchema","ClientError","defineRoute","listTriggerEventFacets","listTriggerEventFacetsRoute","method","path","description","schema","querystring","response","handler","request","workspace_id","workspaceId","query","userContext","canAccess","status"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,4BAA4B;AAC7D,SACEC,6BAA6B,EAC7BC,gCAAgC,QAC3B,4BAA4B;AACnC,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,sBAAsB,QAAO,eAAe;AAEpD,OAAO,MAAMC,8BAA8BF,YAAY;IACrDG,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,aAAaV;QACbW,UAAU;YACR,KAAKV;QACP;IACF;IACAW,SAAS,OAAOC;QACd,MAAM,EAACC,cAAcC,WAAW,EAAC,GAAGF,QAAQG,KAAK;QAEjD,MAAMC,cAAclB,mBAAmBc;QACvC,IAAI,CAACI,YAAYC,SAAS,CAACH,cAAc;YACvC,MAAM,IAAIb,YAAY,kCAAkC,aAAa;gBAACiB,QAAQ;YAAG;QACnF;QAEA,OAAO,MAAMf,uBAAuB;YAACW;QAAW;IAClD;AACF,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-trigger-events.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-trigger-events.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,sBAAsB,iDAyDjC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { requireUserContext } from '@shipfox/api-auth-context';
|
|
2
|
+
import { triggerEventListQuerySchema, triggerEventListResponseSchema } from '@shipfox/api-triggers-dto';
|
|
3
|
+
import { decodeTimestampIdCursor, encodeTimestampIdCursor } from '@shipfox/node-drizzle';
|
|
4
|
+
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
5
|
+
import { listTriggerEvents } from '#db/index.js';
|
|
6
|
+
import { toTriggerEventListItemDto } from '#presentation/dto/trigger-events.js';
|
|
7
|
+
export const listTriggerEventsRoute = defineRoute({
|
|
8
|
+
method: 'GET',
|
|
9
|
+
path: '/',
|
|
10
|
+
description: 'List trigger events for a workspace, newest first.',
|
|
11
|
+
schema: {
|
|
12
|
+
querystring: triggerEventListQuerySchema,
|
|
13
|
+
response: {
|
|
14
|
+
200: triggerEventListResponseSchema
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
handler: async (request)=>{
|
|
18
|
+
const { workspace_id: workspaceId, source, event, outcome: outcomes, from, to, limit, cursor } = request.query;
|
|
19
|
+
const userContext = requireUserContext(request);
|
|
20
|
+
if (!userContext.canAccess(workspaceId)) {
|
|
21
|
+
throw new ClientError('Not a member of this workspace', 'forbidden', {
|
|
22
|
+
status: 403
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const decodedCursor = decodeTimestampIdCursor(cursor);
|
|
26
|
+
if (cursor && !decodedCursor) {
|
|
27
|
+
throw new ClientError('Invalid cursor', 'invalid-cursor', {
|
|
28
|
+
status: 400
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const result = await listTriggerEvents({
|
|
32
|
+
workspaceId,
|
|
33
|
+
limit,
|
|
34
|
+
cursor: decodedCursor ? {
|
|
35
|
+
receivedAt: decodedCursor.createdAt,
|
|
36
|
+
id: decodedCursor.id
|
|
37
|
+
} : undefined,
|
|
38
|
+
filters: {
|
|
39
|
+
source,
|
|
40
|
+
event,
|
|
41
|
+
outcomes,
|
|
42
|
+
from: from ? new Date(from) : undefined,
|
|
43
|
+
to: to ? new Date(to) : undefined
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
trigger_events: result.events.map(toTriggerEventListItemDto),
|
|
48
|
+
next_cursor: result.nextCursor ? encodeTimestampIdCursor({
|
|
49
|
+
createdAt: result.nextCursor.receivedAt,
|
|
50
|
+
id: result.nextCursor.id
|
|
51
|
+
}) : null
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=list-trigger-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/list-trigger-events.ts"],"sourcesContent":["import {requireUserContext} from '@shipfox/api-auth-context';\nimport {\n triggerEventListQuerySchema,\n triggerEventListResponseSchema,\n} from '@shipfox/api-triggers-dto';\nimport {decodeTimestampIdCursor, encodeTimestampIdCursor} from '@shipfox/node-drizzle';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {listTriggerEvents} from '#db/index.js';\nimport {toTriggerEventListItemDto} from '#presentation/dto/trigger-events.js';\n\nexport const listTriggerEventsRoute = defineRoute({\n method: 'GET',\n path: '/',\n description: 'List trigger events for a workspace, newest first.',\n schema: {\n querystring: triggerEventListQuerySchema,\n response: {\n 200: triggerEventListResponseSchema,\n },\n },\n handler: async (request) => {\n const {\n workspace_id: workspaceId,\n source,\n event,\n outcome: outcomes,\n from,\n to,\n limit,\n cursor,\n } = request.query;\n\n const userContext = requireUserContext(request);\n if (!userContext.canAccess(workspaceId)) {\n throw new ClientError('Not a member of this workspace', 'forbidden', {status: 403});\n }\n\n const decodedCursor = decodeTimestampIdCursor(cursor);\n if (cursor && !decodedCursor) {\n throw new ClientError('Invalid cursor', 'invalid-cursor', {status: 400});\n }\n\n const result = await listTriggerEvents({\n workspaceId,\n limit,\n cursor: decodedCursor\n ? {receivedAt: decodedCursor.createdAt, id: decodedCursor.id}\n : undefined,\n filters: {\n source,\n event,\n outcomes,\n from: from ? new Date(from) : undefined,\n to: to ? new Date(to) : undefined,\n },\n });\n\n return {\n trigger_events: result.events.map(toTriggerEventListItemDto),\n next_cursor: result.nextCursor\n ? encodeTimestampIdCursor({\n createdAt: result.nextCursor.receivedAt,\n id: result.nextCursor.id,\n })\n : null,\n };\n },\n});\n"],"names":["requireUserContext","triggerEventListQuerySchema","triggerEventListResponseSchema","decodeTimestampIdCursor","encodeTimestampIdCursor","ClientError","defineRoute","listTriggerEvents","toTriggerEventListItemDto","listTriggerEventsRoute","method","path","description","schema","querystring","response","handler","request","workspace_id","workspaceId","source","event","outcome","outcomes","from","to","limit","cursor","query","userContext","canAccess","status","decodedCursor","result","receivedAt","createdAt","id","undefined","filters","Date","trigger_events","events","map","next_cursor","nextCursor"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,4BAA4B;AAC7D,SACEC,2BAA2B,EAC3BC,8BAA8B,QACzB,4BAA4B;AACnC,SAAQC,uBAAuB,EAAEC,uBAAuB,QAAO,wBAAwB;AACvF,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,iBAAiB,QAAO,eAAe;AAC/C,SAAQC,yBAAyB,QAAO,sCAAsC;AAE9E,OAAO,MAAMC,yBAAyBH,YAAY;IAChDI,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,aAAab;QACbc,UAAU;YACR,KAAKb;QACP;IACF;IACAc,SAAS,OAAOC;QACd,MAAM,EACJC,cAAcC,WAAW,EACzBC,MAAM,EACNC,KAAK,EACLC,SAASC,QAAQ,EACjBC,IAAI,EACJC,EAAE,EACFC,KAAK,EACLC,MAAM,EACP,GAAGV,QAAQW,KAAK;QAEjB,MAAMC,cAAc7B,mBAAmBiB;QACvC,IAAI,CAACY,YAAYC,SAAS,CAACX,cAAc;YACvC,MAAM,IAAId,YAAY,kCAAkC,aAAa;gBAAC0B,QAAQ;YAAG;QACnF;QAEA,MAAMC,gBAAgB7B,wBAAwBwB;QAC9C,IAAIA,UAAU,CAACK,eAAe;YAC5B,MAAM,IAAI3B,YAAY,kBAAkB,kBAAkB;gBAAC0B,QAAQ;YAAG;QACxE;QAEA,MAAME,SAAS,MAAM1B,kBAAkB;YACrCY;YACAO;YACAC,QAAQK,gBACJ;gBAACE,YAAYF,cAAcG,SAAS;gBAAEC,IAAIJ,cAAcI,EAAE;YAAA,IAC1DC;YACJC,SAAS;gBACPlB;gBACAC;gBACAE;gBACAC,MAAMA,OAAO,IAAIe,KAAKf,QAAQa;gBAC9BZ,IAAIA,KAAK,IAAIc,KAAKd,MAAMY;YAC1B;QACF;QAEA,OAAO;YACLG,gBAAgBP,OAAOQ,MAAM,CAACC,GAAG,CAAClC;YAClCmC,aAAaV,OAAOW,UAAU,GAC1BxC,wBAAwB;gBACtB+B,WAAWF,OAAOW,UAAU,CAACV,UAAU;gBACvCE,IAAIH,OAAOW,UAAU,CAACR,EAAE;YAC1B,KACA;QACN;IACF;AACF,GAAG"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { onDefinitionDeleted } from './on-definition-deleted.js';
|
|
2
|
+
export { onDefinitionResolved } from './on-definition-resolved.js';
|
|
3
|
+
export { onIntegrationEventReceived } from './on-integration-event-received.js';
|
|
4
|
+
export { onJobActivated } from './on-job-activated.js';
|
|
5
|
+
export { onJobTerminated } from './on-job-terminated.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAC,0BAA0B,EAAC,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { onDefinitionDeleted } from './on-definition-deleted.js';
|
|
2
|
+
export { onDefinitionResolved } from './on-definition-resolved.js';
|
|
3
|
+
export { onIntegrationEventReceived } from './on-integration-event-received.js';
|
|
4
|
+
export { onJobActivated } from './on-job-activated.js';
|
|
5
|
+
export { onJobTerminated } from './on-job-terminated.js';
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/subscribers/index.ts"],"sourcesContent":["export {onDefinitionDeleted} from './on-definition-deleted.js';\nexport {onDefinitionResolved} from './on-definition-resolved.js';\nexport {onIntegrationEventReceived} from './on-integration-event-received.js';\nexport {onJobActivated} from './on-job-activated.js';\nexport {onJobTerminated} from './on-job-terminated.js';\n"],"names":["onDefinitionDeleted","onDefinitionResolved","onIntegrationEventReceived","onJobActivated","onJobTerminated"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,6BAA6B;AAC/D,SAAQC,oBAAoB,QAAO,8BAA8B;AACjE,SAAQC,0BAA0B,QAAO,qCAAqC;AAC9E,SAAQC,cAAc,QAAO,wBAAwB;AACrD,SAAQC,eAAe,QAAO,yBAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-definition-deleted.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/on-definition-deleted.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,8BAA8B,CAAC;AAGzE,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAExF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { deleteSubscriptionsForDefinition } from '#db/subscriptions.js';
|
|
2
|
+
export async function onDefinitionDeleted(payload) {
|
|
3
|
+
await deleteSubscriptionsForDefinition({
|
|
4
|
+
workflowDefinitionId: payload.definitionId
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=on-definition-deleted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/subscribers/on-definition-deleted.ts"],"sourcesContent":["import type {DefinitionDeletedEvent} from '@shipfox/api-definitions-dto';\nimport {deleteSubscriptionsForDefinition} from '#db/subscriptions.js';\n\nexport async function onDefinitionDeleted(payload: DefinitionDeletedEvent): Promise<void> {\n await deleteSubscriptionsForDefinition({workflowDefinitionId: payload.definitionId});\n}\n"],"names":["deleteSubscriptionsForDefinition","onDefinitionDeleted","payload","workflowDefinitionId","definitionId"],"mappings":"AACA,SAAQA,gCAAgC,QAAO,uBAAuB;AAEtE,OAAO,eAAeC,oBAAoBC,OAA+B;IACvE,MAAMF,iCAAiC;QAACG,sBAAsBD,QAAQE,YAAY;IAAA;AACpF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-definition-resolved.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/on-definition-resolved.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAG1E,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAO1F"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { projectDefinitionTriggers } from '#db/subscriptions.js';
|
|
2
|
+
export async function onDefinitionResolved(payload) {
|
|
3
|
+
await projectDefinitionTriggers({
|
|
4
|
+
workspaceId: payload.workspaceId,
|
|
5
|
+
projectId: payload.projectId,
|
|
6
|
+
workflowDefinitionId: payload.definitionId,
|
|
7
|
+
triggers: payload.triggers
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=on-definition-resolved.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/subscribers/on-definition-resolved.ts"],"sourcesContent":["import type {DefinitionResolvedEvent} from '@shipfox/api-definitions-dto';\nimport {projectDefinitionTriggers} from '#db/subscriptions.js';\n\nexport async function onDefinitionResolved(payload: DefinitionResolvedEvent): Promise<void> {\n await projectDefinitionTriggers({\n workspaceId: payload.workspaceId,\n projectId: payload.projectId,\n workflowDefinitionId: payload.definitionId,\n triggers: payload.triggers,\n });\n}\n"],"names":["projectDefinitionTriggers","onDefinitionResolved","payload","workspaceId","projectId","workflowDefinitionId","definitionId","triggers"],"mappings":"AACA,SAAQA,yBAAyB,QAAO,uBAAuB;AAE/D,OAAO,eAAeC,qBAAqBC,OAAgC;IACzE,MAAMF,0BAA0B;QAC9BG,aAAaD,QAAQC,WAAW;QAChCC,WAAWF,QAAQE,SAAS;QAC5BC,sBAAsBH,QAAQI,YAAY;QAC1CC,UAAUL,QAAQK,QAAQ;IAC5B;AACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IntegrationEventReceivedEvent } from '@shipfox/api-integration-core-dto';
|
|
2
|
+
import type { DomainEvent } from '@shipfox/node-outbox';
|
|
3
|
+
export declare function onIntegrationEventReceived(envelope: IntegrationEventReceivedEvent, event: DomainEvent<IntegrationEventReceivedEvent>): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=on-integration-event-received.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-integration-event-received.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/on-integration-event-received.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,mCAAmC,CAAC;AACrF,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAGtD,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,6BAA6B,EACvC,KAAK,EAAE,WAAW,CAAC,6BAA6B,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC,CAaf"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { dispatchIntegrationEvent } from '#core/dispatch-integration-event.js';
|
|
2
|
+
export async function onIntegrationEventReceived(envelope, event) {
|
|
3
|
+
await dispatchIntegrationEvent({
|
|
4
|
+
eventRef: event.id,
|
|
5
|
+
workspaceId: envelope.workspaceId,
|
|
6
|
+
provider: envelope.provider,
|
|
7
|
+
source: envelope.source,
|
|
8
|
+
event: envelope.event,
|
|
9
|
+
deliveryId: envelope.deliveryId,
|
|
10
|
+
connectionId: envelope.connectionId,
|
|
11
|
+
connectionName: envelope.connectionName ?? null,
|
|
12
|
+
payload: envelope.payload,
|
|
13
|
+
receivedAt: new Date(envelope.receivedAt)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=on-integration-event-received.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/subscribers/on-integration-event-received.ts"],"sourcesContent":["import type {IntegrationEventReceivedEvent} from '@shipfox/api-integration-core-dto';\nimport type {DomainEvent} from '@shipfox/node-outbox';\nimport {dispatchIntegrationEvent} from '#core/dispatch-integration-event.js';\n\nexport async function onIntegrationEventReceived(\n envelope: IntegrationEventReceivedEvent,\n event: DomainEvent<IntegrationEventReceivedEvent>,\n): Promise<void> {\n await dispatchIntegrationEvent({\n eventRef: event.id,\n workspaceId: envelope.workspaceId,\n provider: envelope.provider,\n source: envelope.source,\n event: envelope.event,\n deliveryId: envelope.deliveryId,\n connectionId: envelope.connectionId,\n connectionName: envelope.connectionName ?? null,\n payload: envelope.payload,\n receivedAt: new Date(envelope.receivedAt),\n });\n}\n"],"names":["dispatchIntegrationEvent","onIntegrationEventReceived","envelope","event","eventRef","id","workspaceId","provider","source","deliveryId","connectionId","connectionName","payload","receivedAt","Date"],"mappings":"AAEA,SAAQA,wBAAwB,QAAO,sCAAsC;AAE7E,OAAO,eAAeC,2BACpBC,QAAuC,EACvCC,KAAiD;IAEjD,MAAMH,yBAAyB;QAC7BI,UAAUD,MAAME,EAAE;QAClBC,aAAaJ,SAASI,WAAW;QACjCC,UAAUL,SAASK,QAAQ;QAC3BC,QAAQN,SAASM,MAAM;QACvBL,OAAOD,SAASC,KAAK;QACrBM,YAAYP,SAASO,UAAU;QAC/BC,cAAcR,SAASQ,YAAY;QACnCC,gBAAgBT,SAASS,cAAc,IAAI;QAC3CC,SAASV,SAASU,OAAO;QACzBC,YAAY,IAAIC,KAAKZ,SAASW,UAAU;IAC1C;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-job-activated.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/on-job-activated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,4BAA4B,CAAC;AAG9E,wBAAsB,cAAc,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAU1F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { projectJobListenerSubscriptions } from '#db/job-listener-subscriptions.js';
|
|
2
|
+
export async function onJobActivated(payload) {
|
|
3
|
+
if (payload.mode !== 'listening') return;
|
|
4
|
+
await projectJobListenerSubscriptions({
|
|
5
|
+
workspaceId: payload.workspaceId,
|
|
6
|
+
workflowRunId: payload.workflowRunId,
|
|
7
|
+
jobId: payload.jobId,
|
|
8
|
+
on: payload.on,
|
|
9
|
+
until: payload.until
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=on-job-activated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/subscribers/on-job-activated.ts"],"sourcesContent":["import type {WorkflowsJobActivatedEventDto} from '@shipfox/api-workflows-dto';\nimport {projectJobListenerSubscriptions} from '#db/job-listener-subscriptions.js';\n\nexport async function onJobActivated(payload: WorkflowsJobActivatedEventDto): Promise<void> {\n if (payload.mode !== 'listening') return;\n\n await projectJobListenerSubscriptions({\n workspaceId: payload.workspaceId,\n workflowRunId: payload.workflowRunId,\n jobId: payload.jobId,\n on: payload.on,\n until: payload.until,\n });\n}\n"],"names":["projectJobListenerSubscriptions","onJobActivated","payload","mode","workspaceId","workflowRunId","jobId","on","until"],"mappings":"AACA,SAAQA,+BAA+B,QAAO,oCAAoC;AAElF,OAAO,eAAeC,eAAeC,OAAsC;IACzE,IAAIA,QAAQC,IAAI,KAAK,aAAa;IAElC,MAAMH,gCAAgC;QACpCI,aAAaF,QAAQE,WAAW;QAChCC,eAAeH,QAAQG,aAAa;QACpCC,OAAOJ,QAAQI,KAAK;QACpBC,IAAIL,QAAQK,EAAE;QACdC,OAAON,QAAQM,KAAK;IACtB;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-job-terminated.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/on-job-terminated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,4BAA4B,CAAC;AAG/E,wBAAsB,eAAe,CAAC,OAAO,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/subscribers/on-job-terminated.ts"],"sourcesContent":["import type {WorkflowsJobTerminatedEventDto} from '@shipfox/api-workflows-dto';\nimport {removeJobListenerSubscriptionsForJob} from '#db/job-listener-subscriptions.js';\n\nexport async function onJobTerminated(payload: WorkflowsJobTerminatedEventDto): Promise<void> {\n await removeJobListenerSubscriptionsForJob(payload.jobId);\n}\n"],"names":["removeJobListenerSubscriptionsForJob","onJobTerminated","payload","jobId"],"mappings":"AACA,SAAQA,oCAAoC,QAAO,oCAAoC;AAEvF,OAAO,eAAeC,gBAAgBC,OAAuC;IAC3E,MAAMF,qCAAqCE,QAAQC,KAAK;AAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drain-cron-batch.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/drain-cron-batch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,gBAAgB,EAAwB,MAAM,+BAA+B,CAAC;AAE3F,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAOxE;AAMD,wBAAgB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAExD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Context } from '@temporalio/activity';
|
|
2
|
+
import { config } from '#config.js';
|
|
3
|
+
import { drainDueCronSchedules } from '#core/drain-cron-schedules.js';
|
|
4
|
+
export async function drainCronBatchActivity() {
|
|
5
|
+
const ctx = Context.current();
|
|
6
|
+
return await drainDueCronSchedules({
|
|
7
|
+
batchSize: config.TRIGGER_CRON_CLAIM_BATCH,
|
|
8
|
+
jitterWindowSeconds: config.TRIGGER_CRON_JITTER_WINDOW_SECONDS,
|
|
9
|
+
onScheduleProcessed: ()=>ctx.heartbeat()
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
// Read at runtime rather than baked into the cron workflow's start args: a start arg
|
|
13
|
+
// would freeze fanout at first launch (a restart re-skips the already-running workflow),
|
|
14
|
+
// so an activity read lets a config change take effect on the next tick after a worker
|
|
15
|
+
// restart, consistent with how TRIGGER_CRON_CLAIM_BATCH is read in the drain activity.
|
|
16
|
+
export function readCronFanoutActivity() {
|
|
17
|
+
return Promise.resolve(config.TRIGGER_CRON_FANOUT);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=drain-cron-batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/activities/drain-cron-batch.ts"],"sourcesContent":["import {Context} from '@temporalio/activity';\nimport {config} from '#config.js';\nimport {type CronDrainSummary, drainDueCronSchedules} from '#core/drain-cron-schedules.js';\n\nexport async function drainCronBatchActivity(): Promise<CronDrainSummary> {\n const ctx = Context.current();\n return await drainDueCronSchedules({\n batchSize: config.TRIGGER_CRON_CLAIM_BATCH,\n jitterWindowSeconds: config.TRIGGER_CRON_JITTER_WINDOW_SECONDS,\n onScheduleProcessed: () => ctx.heartbeat(),\n });\n}\n\n// Read at runtime rather than baked into the cron workflow's start args: a start arg\n// would freeze fanout at first launch (a restart re-skips the already-running workflow),\n// so an activity read lets a config change take effect on the next tick after a worker\n// restart, consistent with how TRIGGER_CRON_CLAIM_BATCH is read in the drain activity.\nexport function readCronFanoutActivity(): Promise<number> {\n return Promise.resolve(config.TRIGGER_CRON_FANOUT);\n}\n"],"names":["Context","config","drainDueCronSchedules","drainCronBatchActivity","ctx","current","batchSize","TRIGGER_CRON_CLAIM_BATCH","jitterWindowSeconds","TRIGGER_CRON_JITTER_WINDOW_SECONDS","onScheduleProcessed","heartbeat","readCronFanoutActivity","Promise","resolve","TRIGGER_CRON_FANOUT"],"mappings":"AAAA,SAAQA,OAAO,QAAO,uBAAuB;AAC7C,SAAQC,MAAM,QAAO,aAAa;AAClC,SAA+BC,qBAAqB,QAAO,gCAAgC;AAE3F,OAAO,eAAeC;IACpB,MAAMC,MAAMJ,QAAQK,OAAO;IAC3B,OAAO,MAAMH,sBAAsB;QACjCI,WAAWL,OAAOM,wBAAwB;QAC1CC,qBAAqBP,OAAOQ,kCAAkC;QAC9DC,qBAAqB,IAAMN,IAAIO,SAAS;IAC1C;AACF;AAEA,qFAAqF;AACrF,yFAAyF;AACzF,uFAAuF;AACvF,uFAAuF;AACvF,OAAO,SAASC;IACd,OAAOC,QAAQC,OAAO,CAACb,OAAOc,mBAAmB;AACnD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { drainCronBatchActivity, readCronFanoutActivity } from './drain-cron-batch.js';
|
|
2
|
+
import { pruneTriggerEventsActivity } from './prune-trigger-events.js';
|
|
3
|
+
export declare function createTriggersMaintenanceActivities(): {
|
|
4
|
+
pruneTriggerEventsActivity: typeof pruneTriggerEventsActivity;
|
|
5
|
+
};
|
|
6
|
+
export declare function createTriggersCronActivities(): {
|
|
7
|
+
drainCronBatchActivity: typeof drainCronBatchActivity;
|
|
8
|
+
readCronFanoutActivity: typeof readCronFanoutActivity;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|