@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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAE,sBAAsB,EAAC,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAC,0BAA0B,EAAC,MAAM,2BAA2B,CAAC;AAErE,wBAAgB,mCAAmC;;EAIlD;AAED,wBAAgB,4BAA4B;;;EAK3C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { drainCronBatchActivity, readCronFanoutActivity } from './drain-cron-batch.js';
|
|
2
|
+
import { pruneTriggerEventsActivity } from './prune-trigger-events.js';
|
|
3
|
+
export function createTriggersMaintenanceActivities() {
|
|
4
|
+
return {
|
|
5
|
+
pruneTriggerEventsActivity
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export function createTriggersCronActivities() {
|
|
9
|
+
return {
|
|
10
|
+
drainCronBatchActivity,
|
|
11
|
+
readCronFanoutActivity
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/activities/index.ts"],"sourcesContent":["import {drainCronBatchActivity, readCronFanoutActivity} from './drain-cron-batch.js';\nimport {pruneTriggerEventsActivity} from './prune-trigger-events.js';\n\nexport function createTriggersMaintenanceActivities() {\n return {\n pruneTriggerEventsActivity,\n };\n}\n\nexport function createTriggersCronActivities() {\n return {\n drainCronBatchActivity,\n readCronFanoutActivity,\n };\n}\n"],"names":["drainCronBatchActivity","readCronFanoutActivity","pruneTriggerEventsActivity","createTriggersMaintenanceActivities","createTriggersCronActivities"],"mappings":"AAAA,SAAQA,sBAAsB,EAAEC,sBAAsB,QAAO,wBAAwB;AACrF,SAAQC,0BAA0B,QAAO,4BAA4B;AAErE,OAAO,SAASC;IACd,OAAO;QACLD;IACF;AACF;AAEA,OAAO,SAASE;IACd,OAAO;QACLJ;QACAC;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prune-trigger-events.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/prune-trigger-events.ts"],"names":[],"mappings":"AAKA,wBAAsB,0BAA0B,IAAI,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CAG7E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { config } from '#config.js';
|
|
2
|
+
import { pruneTriggerEvents } from '#db/received-events.js';
|
|
3
|
+
const MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
4
|
+
export async function pruneTriggerEventsActivity() {
|
|
5
|
+
const olderThan = new Date(Date.now() - config.TRIGGER_EVENT_RETENTION_DAYS * MS_PER_DAY);
|
|
6
|
+
return await pruneTriggerEvents({
|
|
7
|
+
olderThan
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=prune-trigger-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/activities/prune-trigger-events.ts"],"sourcesContent":["import {config} from '#config.js';\nimport {pruneTriggerEvents} from '#db/received-events.js';\n\nconst MS_PER_DAY = 24 * 60 * 60 * 1000;\n\nexport async function pruneTriggerEventsActivity(): Promise<{deleted: number}> {\n const olderThan = new Date(Date.now() - config.TRIGGER_EVENT_RETENTION_DAYS * MS_PER_DAY);\n return await pruneTriggerEvents({olderThan});\n}\n"],"names":["config","pruneTriggerEvents","MS_PER_DAY","pruneTriggerEventsActivity","olderThan","Date","now","TRIGGER_EVENT_RETENTION_DAYS"],"mappings":"AAAA,SAAQA,MAAM,QAAO,aAAa;AAClC,SAAQC,kBAAkB,QAAO,yBAAyB;AAE1D,MAAMC,aAAa,KAAK,KAAK,KAAK;AAElC,OAAO,eAAeC;IACpB,MAAMC,YAAY,IAAIC,KAAKA,KAAKC,GAAG,KAAKN,OAAOO,4BAA4B,GAAGL;IAC9E,OAAO,MAAMD,mBAAmB;QAACG;IAAS;AAC5C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const TRIGGERS_MAINTENANCE_TASK_QUEUE = "triggers-maintenance";
|
|
2
|
+
/**
|
|
3
|
+
* Dedicated queue for the minute cron tick, so bursty cron-fire load and hourly
|
|
4
|
+
* maintenance load scale independently.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TRIGGERS_CRON_TASK_QUEUE = "triggers-cron";
|
|
7
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/temporal/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B,yBAAyB,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,wBAAwB,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const TRIGGERS_MAINTENANCE_TASK_QUEUE = 'triggers-maintenance';
|
|
2
|
+
/**
|
|
3
|
+
* Dedicated queue for the minute cron tick, so bursty cron-fire load and hourly
|
|
4
|
+
* maintenance load scale independently.
|
|
5
|
+
*/ export const TRIGGERS_CRON_TASK_QUEUE = 'triggers-cron';
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/temporal/constants.ts"],"sourcesContent":["export const TRIGGERS_MAINTENANCE_TASK_QUEUE = 'triggers-maintenance';\n\n/**\n * Dedicated queue for the minute cron tick, so bursty cron-fire load and hourly\n * maintenance load scale independently.\n */\nexport const TRIGGERS_CRON_TASK_QUEUE = 'triggers-cron';\n"],"names":["TRIGGERS_MAINTENANCE_TASK_QUEUE","TRIGGERS_CRON_TASK_QUEUE"],"mappings":"AAAA,OAAO,MAAMA,kCAAkC,uBAAuB;AAEtE;;;CAGC,GACD,OAAO,MAAMC,2BAA2B,gBAAgB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fires once a minute (Temporal never overlaps a cron workflow with itself, so a slow
|
|
3
|
+
* tick delays the next rather than doubling it). Reads the current fanout and runs that
|
|
4
|
+
* many drain activities; Temporal spreads them across the worker fleet, and `SKIP LOCKED`
|
|
5
|
+
* keeps their claims disjoint. The per-tick fire ceiling is
|
|
6
|
+
* `fanout * TRIGGER_CRON_CLAIM_BATCH`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function cronTickCron(): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=cron-tick-cron.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron-tick-cron.d.ts","sourceRoot":"","sources":["../../../src/temporal/workflows/cron-tick-cron.ts"],"names":[],"mappings":"AA0BA;;;;;;GAMG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAsBlD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { log, proxyActivities } from '@temporalio/workflow';
|
|
2
|
+
// Upper bound on per-tick parallelism. A misconfigured TRIGGER_CRON_FANOUT (e.g. a
|
|
3
|
+
// pasted large number) is clamped to this rather than spawning an unbounded fan-out
|
|
4
|
+
// that could stall the tick, so one config mistake cannot stop cron firing.
|
|
5
|
+
const MAX_CRON_FANOUT = 32;
|
|
6
|
+
const { drainCronBatchActivity, readCronFanoutActivity } = proxyActivities({
|
|
7
|
+
// Throughput is governed by fanout and claim batch, not a per-tick time budget, so
|
|
8
|
+
// give the batch drain plenty of room.
|
|
9
|
+
startToCloseTimeout: '5 minutes',
|
|
10
|
+
// The drain heartbeats once per processed schedule, so a hung run stops heartbeating
|
|
11
|
+
// well before the start-to-close timeout. Fail it within a minute (rather than after
|
|
12
|
+
// five) so its FOR UPDATE SKIP LOCKED locks release and the next tick re-claims those
|
|
13
|
+
// rows.
|
|
14
|
+
heartbeatTimeout: '1 minute',
|
|
15
|
+
// No activity retry: the drain is not batch-idempotent across retries. A retry after a
|
|
16
|
+
// committed advance would claim a fresh due batch and fire beyond the
|
|
17
|
+
// fanout * TRIGGER_CRON_CLAIM_BATCH per-tick ceiling. Whole-activity failures roll the
|
|
18
|
+
// batch back (rows stay due) and the once-per-minute cron schedule is the retry.
|
|
19
|
+
retry: {
|
|
20
|
+
maximumAttempts: 1
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Fires once a minute (Temporal never overlaps a cron workflow with itself, so a slow
|
|
25
|
+
* tick delays the next rather than doubling it). Reads the current fanout and runs that
|
|
26
|
+
* many drain activities; Temporal spreads them across the worker fleet, and `SKIP LOCKED`
|
|
27
|
+
* keeps their claims disjoint. The per-tick fire ceiling is
|
|
28
|
+
* `fanout * TRIGGER_CRON_CLAIM_BATCH`.
|
|
29
|
+
*/ export async function cronTickCron() {
|
|
30
|
+
const fanout = await readCronFanoutActivity();
|
|
31
|
+
const requested = Number.isInteger(fanout) && fanout > 0 ? fanout : 1;
|
|
32
|
+
const parallelism = Math.min(requested, MAX_CRON_FANOUT);
|
|
33
|
+
if (parallelism < requested) {
|
|
34
|
+
log.warn('Cron tick fanout exceeds the maximum; clamping', {
|
|
35
|
+
requested,
|
|
36
|
+
max: MAX_CRON_FANOUT
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const summaries = await Promise.all(Array.from({
|
|
40
|
+
length: parallelism
|
|
41
|
+
}, ()=>drainCronBatchActivity()));
|
|
42
|
+
const fired = summaries.reduce((total, summary)=>total + summary.fired, 0);
|
|
43
|
+
const errored = summaries.reduce((total, summary)=>total + summary.errored, 0);
|
|
44
|
+
const retried = summaries.reduce((total, summary)=>total + summary.retried, 0);
|
|
45
|
+
if (fired > 0 || errored > 0 || retried > 0) {
|
|
46
|
+
log.info('Cron tick drained schedules', {
|
|
47
|
+
fired,
|
|
48
|
+
errored,
|
|
49
|
+
retried
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=cron-tick-cron.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/workflows/cron-tick-cron.ts"],"sourcesContent":["import {log, proxyActivities} from '@temporalio/workflow';\nimport type {createTriggersCronActivities} from '../activities/index.js';\n\n// Upper bound on per-tick parallelism. A misconfigured TRIGGER_CRON_FANOUT (e.g. a\n// pasted large number) is clamped to this rather than spawning an unbounded fan-out\n// that could stall the tick, so one config mistake cannot stop cron firing.\nconst MAX_CRON_FANOUT = 32;\n\nconst {drainCronBatchActivity, readCronFanoutActivity} = proxyActivities<\n ReturnType<typeof createTriggersCronActivities>\n>({\n // Throughput is governed by fanout and claim batch, not a per-tick time budget, so\n // give the batch drain plenty of room.\n startToCloseTimeout: '5 minutes',\n // The drain heartbeats once per processed schedule, so a hung run stops heartbeating\n // well before the start-to-close timeout. Fail it within a minute (rather than after\n // five) so its FOR UPDATE SKIP LOCKED locks release and the next tick re-claims those\n // rows.\n heartbeatTimeout: '1 minute',\n // No activity retry: the drain is not batch-idempotent across retries. A retry after a\n // committed advance would claim a fresh due batch and fire beyond the\n // fanout * TRIGGER_CRON_CLAIM_BATCH per-tick ceiling. Whole-activity failures roll the\n // batch back (rows stay due) and the once-per-minute cron schedule is the retry.\n retry: {maximumAttempts: 1},\n});\n\n/**\n * Fires once a minute (Temporal never overlaps a cron workflow with itself, so a slow\n * tick delays the next rather than doubling it). Reads the current fanout and runs that\n * many drain activities; Temporal spreads them across the worker fleet, and `SKIP LOCKED`\n * keeps their claims disjoint. The per-tick fire ceiling is\n * `fanout * TRIGGER_CRON_CLAIM_BATCH`.\n */\nexport async function cronTickCron(): Promise<void> {\n const fanout = await readCronFanoutActivity();\n const requested = Number.isInteger(fanout) && fanout > 0 ? fanout : 1;\n const parallelism = Math.min(requested, MAX_CRON_FANOUT);\n if (parallelism < requested) {\n log.warn('Cron tick fanout exceeds the maximum; clamping', {\n requested,\n max: MAX_CRON_FANOUT,\n });\n }\n\n const summaries = await Promise.all(\n Array.from({length: parallelism}, () => drainCronBatchActivity()),\n );\n\n const fired = summaries.reduce((total, summary) => total + summary.fired, 0);\n const errored = summaries.reduce((total, summary) => total + summary.errored, 0);\n const retried = summaries.reduce((total, summary) => total + summary.retried, 0);\n\n if (fired > 0 || errored > 0 || retried > 0) {\n log.info('Cron tick drained schedules', {fired, errored, retried});\n }\n}\n"],"names":["log","proxyActivities","MAX_CRON_FANOUT","drainCronBatchActivity","readCronFanoutActivity","startToCloseTimeout","heartbeatTimeout","retry","maximumAttempts","cronTickCron","fanout","requested","Number","isInteger","parallelism","Math","min","warn","max","summaries","Promise","all","Array","from","length","fired","reduce","total","summary","errored","retried","info"],"mappings":"AAAA,SAAQA,GAAG,EAAEC,eAAe,QAAO,uBAAuB;AAG1D,mFAAmF;AACnF,oFAAoF;AACpF,4EAA4E;AAC5E,MAAMC,kBAAkB;AAExB,MAAM,EAACC,sBAAsB,EAAEC,sBAAsB,EAAC,GAAGH,gBAEvD;IACA,mFAAmF;IACnF,uCAAuC;IACvCI,qBAAqB;IACrB,qFAAqF;IACrF,qFAAqF;IACrF,sFAAsF;IACtF,QAAQ;IACRC,kBAAkB;IAClB,uFAAuF;IACvF,sEAAsE;IACtE,uFAAuF;IACvF,iFAAiF;IACjFC,OAAO;QAACC,iBAAiB;IAAC;AAC5B;AAEA;;;;;;CAMC,GACD,OAAO,eAAeC;IACpB,MAAMC,SAAS,MAAMN;IACrB,MAAMO,YAAYC,OAAOC,SAAS,CAACH,WAAWA,SAAS,IAAIA,SAAS;IACpE,MAAMI,cAAcC,KAAKC,GAAG,CAACL,WAAWT;IACxC,IAAIY,cAAcH,WAAW;QAC3BX,IAAIiB,IAAI,CAAC,kDAAkD;YACzDN;YACAO,KAAKhB;QACP;IACF;IAEA,MAAMiB,YAAY,MAAMC,QAAQC,GAAG,CACjCC,MAAMC,IAAI,CAAC;QAACC,QAAQV;IAAW,GAAG,IAAMX;IAG1C,MAAMsB,QAAQN,UAAUO,MAAM,CAAC,CAACC,OAAOC,UAAYD,QAAQC,QAAQH,KAAK,EAAE;IAC1E,MAAMI,UAAUV,UAAUO,MAAM,CAAC,CAACC,OAAOC,UAAYD,QAAQC,QAAQC,OAAO,EAAE;IAC9E,MAAMC,UAAUX,UAAUO,MAAM,CAAC,CAACC,OAAOC,UAAYD,QAAQC,QAAQE,OAAO,EAAE;IAE9E,IAAIL,QAAQ,KAAKI,UAAU,KAAKC,UAAU,GAAG;QAC3C9B,IAAI+B,IAAI,CAAC,+BAA+B;YAACN;YAAOI;YAASC;QAAO;IAClE;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/temporal/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/workflows/index.ts"],"sourcesContent":["export {cronTickCron} from './cron-tick-cron.js';\nexport {pruneTriggerEventsCron} from './prune-trigger-events-cron.js';\n"],"names":["cronTickCron","pruneTriggerEventsCron"],"mappings":"AAAA,SAAQA,YAAY,QAAO,sBAAsB;AACjD,SAAQC,sBAAsB,QAAO,iCAAiC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prune-trigger-events-cron.d.ts","sourceRoot":"","sources":["../../../src/temporal/workflows/prune-trigger-events-cron.ts"],"names":[],"mappings":"AAWA,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAK5D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { log, proxyActivities } from '@temporalio/workflow';
|
|
2
|
+
const { pruneTriggerEventsActivity } = proxyActivities({
|
|
3
|
+
startToCloseTimeout: '5 minutes',
|
|
4
|
+
// Let persistent failures fall through so the next hourly run retries with a fresh cutoff.
|
|
5
|
+
retry: {
|
|
6
|
+
maximumAttempts: 5
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export async function pruneTriggerEventsCron() {
|
|
10
|
+
const { deleted } = await pruneTriggerEventsActivity();
|
|
11
|
+
if (deleted > 0) {
|
|
12
|
+
log.info('Pruned trigger received events', {
|
|
13
|
+
deleted
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=prune-trigger-events-cron.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/workflows/prune-trigger-events-cron.ts"],"sourcesContent":["import {log, proxyActivities} from '@temporalio/workflow';\nimport type {createTriggersMaintenanceActivities} from '../activities/index.js';\n\nconst {pruneTriggerEventsActivity} = proxyActivities<\n ReturnType<typeof createTriggersMaintenanceActivities>\n>({\n startToCloseTimeout: '5 minutes',\n // Let persistent failures fall through so the next hourly run retries with a fresh cutoff.\n retry: {maximumAttempts: 5},\n});\n\nexport async function pruneTriggerEventsCron(): Promise<void> {\n const {deleted} = await pruneTriggerEventsActivity();\n if (deleted > 0) {\n log.info('Pruned trigger received events', {deleted});\n }\n}\n"],"names":["log","proxyActivities","pruneTriggerEventsActivity","startToCloseTimeout","retry","maximumAttempts","pruneTriggerEventsCron","deleted","info"],"mappings":"AAAA,SAAQA,GAAG,EAAEC,eAAe,QAAO,uBAAuB;AAG1D,MAAM,EAACC,0BAA0B,EAAC,GAAGD,gBAEnC;IACAE,qBAAqB;IACrB,2FAA2F;IAC3FC,OAAO;QAACC,iBAAiB;IAAC;AAC5B;AAEA,OAAO,eAAeC;IACpB,MAAM,EAACC,OAAO,EAAC,GAAG,MAAML;IACxB,IAAIK,UAAU,GAAG;QACfP,IAAIQ,IAAI,CAAC,kCAAkC;YAACD;QAAO;IACrD;AACF"}
|