@shipfox/api-triggers 5.0.0 → 7.0.1

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.
Files changed (97) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +51 -0
  3. package/README.md +23 -3
  4. package/dist/core/dispatch-integration-event.d.ts +2 -0
  5. package/dist/core/dispatch-integration-event.d.ts.map +1 -1
  6. package/dist/core/dispatch-integration-event.js +9 -5
  7. package/dist/core/dispatch-integration-event.js.map +1 -1
  8. package/dist/core/drain-cron-schedules.d.ts +2 -0
  9. package/dist/core/drain-cron-schedules.d.ts.map +1 -1
  10. package/dist/core/drain-cron-schedules.js +1 -0
  11. package/dist/core/drain-cron-schedules.js.map +1 -1
  12. package/dist/core/fire-cron.d.ts +6 -2
  13. package/dist/core/fire-cron.d.ts.map +1 -1
  14. package/dist/core/fire-cron.js +8 -5
  15. package/dist/core/fire-cron.js.map +1 -1
  16. package/dist/core/fire-manual.d.ts +6 -2
  17. package/dist/core/fire-manual.d.ts.map +1 -1
  18. package/dist/core/fire-manual.js +8 -4
  19. package/dist/core/fire-manual.js.map +1 -1
  20. package/dist/core/route-event-to-job-listeners.d.ts +2 -0
  21. package/dist/core/route-event-to-job-listeners.d.ts.map +1 -1
  22. package/dist/core/route-event-to-job-listeners.js +2 -3
  23. package/dist/core/route-event-to-job-listeners.js.map +1 -1
  24. package/dist/core/workflows-client.d.ts +69 -0
  25. package/dist/core/workflows-client.d.ts.map +1 -0
  26. package/dist/core/workflows-client.js +20 -0
  27. package/dist/core/workflows-client.js.map +1 -0
  28. package/dist/db/job-listener-subscriptions.d.ts +1 -0
  29. package/dist/db/job-listener-subscriptions.d.ts.map +1 -1
  30. package/dist/db/job-listener-subscriptions.js +6 -0
  31. package/dist/db/job-listener-subscriptions.js.map +1 -1
  32. package/dist/index.d.ts +5 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +56 -50
  35. package/dist/index.js.map +1 -1
  36. package/dist/presentation/e2e-routes.d.ts +3 -0
  37. package/dist/presentation/e2e-routes.d.ts.map +1 -0
  38. package/dist/presentation/e2e-routes.js +31 -0
  39. package/dist/presentation/e2e-routes.js.map +1 -0
  40. package/dist/presentation/index.d.ts +2 -2
  41. package/dist/presentation/index.d.ts.map +1 -1
  42. package/dist/presentation/index.js +2 -2
  43. package/dist/presentation/index.js.map +1 -1
  44. package/dist/presentation/routes/fire-manual.d.ts +2 -1
  45. package/dist/presentation/routes/fire-manual.d.ts.map +1 -1
  46. package/dist/presentation/routes/fire-manual.js +61 -58
  47. package/dist/presentation/routes/fire-manual.js.map +1 -1
  48. package/dist/presentation/routes/index.d.ts +2 -1
  49. package/dist/presentation/routes/index.d.ts.map +1 -1
  50. package/dist/presentation/routes/index.js +23 -21
  51. package/dist/presentation/routes/index.js.map +1 -1
  52. package/dist/presentation/subscribers/index.d.ts +1 -1
  53. package/dist/presentation/subscribers/index.d.ts.map +1 -1
  54. package/dist/presentation/subscribers/index.js +1 -1
  55. package/dist/presentation/subscribers/index.js.map +1 -1
  56. package/dist/presentation/subscribers/on-integration-event-received.d.ts +2 -1
  57. package/dist/presentation/subscribers/on-integration-event-received.d.ts.map +1 -1
  58. package/dist/presentation/subscribers/on-integration-event-received.js +16 -13
  59. package/dist/presentation/subscribers/on-integration-event-received.js.map +1 -1
  60. package/dist/temporal/activities/drain-cron-batch.d.ts +2 -1
  61. package/dist/temporal/activities/drain-cron-batch.d.ts.map +1 -1
  62. package/dist/temporal/activities/drain-cron-batch.js +2 -1
  63. package/dist/temporal/activities/drain-cron-batch.js.map +1 -1
  64. package/dist/temporal/activities/index.d.ts +4 -3
  65. package/dist/temporal/activities/index.d.ts.map +1 -1
  66. package/dist/temporal/activities/index.js +2 -2
  67. package/dist/temporal/activities/index.js.map +1 -1
  68. package/dist/tsconfig.test.tsbuildinfo +1 -1
  69. package/package.json +14 -12
  70. package/src/core/dispatch-integration-event.history-failure.test.ts +11 -6
  71. package/src/core/dispatch-integration-event.test.ts +50 -36
  72. package/src/core/dispatch-integration-event.ts +8 -5
  73. package/src/core/drain-cron-schedules.test.ts +30 -29
  74. package/src/core/drain-cron-schedules.ts +3 -0
  75. package/src/core/fire-cron.test.ts +35 -24
  76. package/src/core/fire-cron.ts +9 -7
  77. package/src/core/fire-manual.test.ts +19 -22
  78. package/src/core/fire-manual.ts +9 -6
  79. package/src/core/record-trigger-history.test.ts +3 -5
  80. package/src/core/route-event-to-job-listeners.test.ts +5 -4
  81. package/src/core/route-event-to-job-listeners.ts +5 -4
  82. package/src/core/workflows-client.test.ts +73 -0
  83. package/src/core/workflows-client.ts +32 -0
  84. package/src/db/job-listener-subscriptions.ts +9 -0
  85. package/src/index.ts +51 -42
  86. package/src/presentation/e2e-routes.test.ts +44 -0
  87. package/src/presentation/e2e-routes.ts +24 -0
  88. package/src/presentation/index.ts +2 -2
  89. package/src/presentation/routes/fire-manual.test.ts +14 -30
  90. package/src/presentation/routes/fire-manual.ts +62 -54
  91. package/src/presentation/routes/index.ts +18 -15
  92. package/src/presentation/subscribers/index.ts +1 -1
  93. package/src/presentation/subscribers/on-integration-event-received.test.ts +6 -3
  94. package/src/presentation/subscribers/on-integration-event-received.ts +20 -16
  95. package/src/temporal/activities/drain-cron-batch.ts +5 -1
  96. package/src/temporal/activities/index.ts +3 -2
  97. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,3 +1,4 @@
1
+ import type { WorkflowsModuleClient } from '@shipfox/api-workflows-dto/inter-module';
1
2
  import type { RouteGroup } from '@shipfox/node-fastify';
2
- export declare const triggerRoutes: RouteGroup[];
3
+ export declare function createTriggerRoutes(workflows: WorkflowsModuleClient): RouteGroup[];
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yCAAyC,CAAC;AACnF,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAMtD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,qBAAqB,GAAG,UAAU,EAAE,CAelF"}
@@ -1,27 +1,29 @@
1
1
  import { AUTH_USER } from '@shipfox/api-auth-context';
2
- import { fireManualTriggerRoute } from './fire-manual.js';
2
+ import { createFireManualTriggerRoute } from './fire-manual.js';
3
3
  import { getTriggerEventRoute } from './get-trigger-event.js';
4
4
  import { listTriggerEventFacetsRoute } from './list-trigger-event-facets.js';
5
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
- ];
6
+ export function createTriggerRoutes(workflows) {
7
+ return [
8
+ {
9
+ prefix: '/workflow-definitions',
10
+ auth: AUTH_USER,
11
+ routes: [
12
+ createFireManualTriggerRoute(workflows)
13
+ ]
14
+ },
15
+ {
16
+ // The static /facets path is matched ahead of the /:id detail route by Fastify's
17
+ // radix router, so registration order does not affect resolution.
18
+ prefix: '/trigger-events',
19
+ auth: AUTH_USER,
20
+ routes: [
21
+ listTriggerEventFacetsRoute,
22
+ listTriggerEventsRoute,
23
+ getTriggerEventRoute
24
+ ]
25
+ }
26
+ ];
27
+ }
26
28
 
27
29
  //# sourceMappingURL=index.js.map
@@ -1 +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"}
1
+ {"version":3,"sources":["../../../src/presentation/routes/index.ts"],"sourcesContent":["import {AUTH_USER} from '@shipfox/api-auth-context';\nimport type {WorkflowsModuleClient} from '@shipfox/api-workflows-dto/inter-module';\nimport type {RouteGroup} from '@shipfox/node-fastify';\nimport {createFireManualTriggerRoute} 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 function createTriggerRoutes(workflows: WorkflowsModuleClient): RouteGroup[] {\n return [\n {\n prefix: '/workflow-definitions',\n auth: AUTH_USER,\n routes: [createFireManualTriggerRoute(workflows)],\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}\n"],"names":["AUTH_USER","createFireManualTriggerRoute","getTriggerEventRoute","listTriggerEventFacetsRoute","listTriggerEventsRoute","createTriggerRoutes","workflows","prefix","auth","routes"],"mappings":"AAAA,SAAQA,SAAS,QAAO,4BAA4B;AAGpD,SAAQC,4BAA4B,QAAO,mBAAmB;AAC9D,SAAQC,oBAAoB,QAAO,yBAAyB;AAC5D,SAAQC,2BAA2B,QAAO,iCAAiC;AAC3E,SAAQC,sBAAsB,QAAO,2BAA2B;AAEhE,OAAO,SAASC,oBAAoBC,SAAgC;IAClE,OAAO;QACL;YACEC,QAAQ;YACRC,MAAMR;YACNS,QAAQ;gBAACR,6BAA6BK;aAAW;QACnD;QACA;YACE,iFAAiF;YACjF,kEAAkE;YAClEC,QAAQ;YACRC,MAAMR;YACNS,QAAQ;gBAACN;gBAA6BC;gBAAwBF;aAAqB;QACrF;KACD;AACH"}
@@ -1,6 +1,6 @@
1
1
  export { onDefinitionDeleted } from './on-definition-deleted.js';
2
2
  export { onDefinitionResolved } from './on-definition-resolved.js';
3
- export { onIntegrationEventReceived } from './on-integration-event-received.js';
3
+ export { createOnIntegrationEventReceived } from './on-integration-event-received.js';
4
4
  export { onJobActivated } from './on-job-activated.js';
5
5
  export { onJobTerminated } from './on-job-terminated.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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,gCAAgC,EAAC,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export { onDefinitionDeleted } from './on-definition-deleted.js';
2
2
  export { onDefinitionResolved } from './on-definition-resolved.js';
3
- export { onIntegrationEventReceived } from './on-integration-event-received.js';
3
+ export { createOnIntegrationEventReceived } from './on-integration-event-received.js';
4
4
  export { onJobActivated } from './on-job-activated.js';
5
5
  export { onJobTerminated } from './on-job-terminated.js';
6
6
 
@@ -1 +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"}
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 {createOnIntegrationEventReceived} from './on-integration-event-received.js';\nexport {onJobActivated} from './on-job-activated.js';\nexport {onJobTerminated} from './on-job-terminated.js';\n"],"names":["onDefinitionDeleted","onDefinitionResolved","createOnIntegrationEventReceived","onJobActivated","onJobTerminated"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,6BAA6B;AAC/D,SAAQC,oBAAoB,QAAO,8BAA8B;AACjE,SAAQC,gCAAgC,QAAO,qCAAqC;AACpF,SAAQC,cAAc,QAAO,wBAAwB;AACrD,SAAQC,eAAe,QAAO,yBAAyB"}
@@ -1,4 +1,5 @@
1
1
  import type { IntegrationEventReceivedEvent } from '@shipfox/api-integration-core-dto';
2
+ import type { WorkflowsModuleClient } from '@shipfox/api-workflows-dto/inter-module';
2
3
  import type { DomainEvent } from '@shipfox/node-outbox';
3
- export declare function onIntegrationEventReceived(envelope: IntegrationEventReceivedEvent, event: DomainEvent<IntegrationEventReceivedEvent>): Promise<void>;
4
+ export declare function createOnIntegrationEventReceived(workflows: WorkflowsModuleClient): (envelope: IntegrationEventReceivedEvent, event: DomainEvent<IntegrationEventReceivedEvent>) => Promise<void>;
4
5
  //# sourceMappingURL=on-integration-event-received.d.ts.map
@@ -1 +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"}
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,qBAAqB,EAAC,MAAM,yCAAyC,CAAC;AACnF,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAGtD,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,qBAAqB,IAE7E,UAAU,6BAA6B,EACvC,OAAO,WAAW,CAAC,6BAA6B,CAAC,KAChD,OAAO,CAAC,IAAI,CAAC,CAejB"}
@@ -1,17 +1,20 @@
1
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
- });
2
+ export function createOnIntegrationEventReceived(workflows) {
3
+ return async function onIntegrationEventReceived(envelope, event) {
4
+ await dispatchIntegrationEvent({
5
+ workflows,
6
+ eventRef: event.id,
7
+ workspaceId: envelope.workspaceId,
8
+ provider: envelope.provider,
9
+ source: envelope.source,
10
+ event: envelope.event,
11
+ deliveryId: envelope.deliveryId,
12
+ connectionId: envelope.connectionId,
13
+ connectionName: envelope.connectionName ?? null,
14
+ payload: envelope.payload,
15
+ receivedAt: new Date(envelope.receivedAt)
16
+ });
17
+ };
15
18
  }
16
19
 
17
20
  //# sourceMappingURL=on-integration-event-received.js.map
@@ -1 +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"}
1
+ {"version":3,"sources":["../../../src/presentation/subscribers/on-integration-event-received.ts"],"sourcesContent":["import type {IntegrationEventReceivedEvent} from '@shipfox/api-integration-core-dto';\nimport type {WorkflowsModuleClient} from '@shipfox/api-workflows-dto/inter-module';\nimport type {DomainEvent} from '@shipfox/node-outbox';\nimport {dispatchIntegrationEvent} from '#core/dispatch-integration-event.js';\n\nexport function createOnIntegrationEventReceived(workflows: WorkflowsModuleClient) {\n return async function onIntegrationEventReceived(\n envelope: IntegrationEventReceivedEvent,\n event: DomainEvent<IntegrationEventReceivedEvent>,\n ): Promise<void> {\n await dispatchIntegrationEvent({\n workflows,\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}\n"],"names":["dispatchIntegrationEvent","createOnIntegrationEventReceived","workflows","onIntegrationEventReceived","envelope","event","eventRef","id","workspaceId","provider","source","deliveryId","connectionId","connectionName","payload","receivedAt","Date"],"mappings":"AAGA,SAAQA,wBAAwB,QAAO,sCAAsC;AAE7E,OAAO,SAASC,iCAAiCC,SAAgC;IAC/E,OAAO,eAAeC,2BACpBC,QAAuC,EACvCC,KAAiD;QAEjD,MAAML,yBAAyB;YAC7BE;YACAI,UAAUD,MAAME,EAAE;YAClBC,aAAaJ,SAASI,WAAW;YACjCC,UAAUL,SAASK,QAAQ;YAC3BC,QAAQN,SAASM,MAAM;YACvBL,OAAOD,SAASC,KAAK;YACrBM,YAAYP,SAASO,UAAU;YAC/BC,cAAcR,SAASQ,YAAY;YACnCC,gBAAgBT,SAASS,cAAc,IAAI;YAC3CC,SAASV,SAASU,OAAO;YACzBC,YAAY,IAAIC,KAAKZ,SAASW,UAAU;QAC1C;IACF;AACF"}
@@ -1,4 +1,5 @@
1
+ import type { WorkflowsModuleClient } from '@shipfox/api-workflows-dto/inter-module';
1
2
  import { type CronDrainSummary } from '#core/drain-cron-schedules.js';
2
- export declare function drainCronBatchActivity(): Promise<CronDrainSummary>;
3
+ export declare function drainCronBatchActivity(workflows: WorkflowsModuleClient): Promise<CronDrainSummary>;
3
4
  export declare function readCronFanoutActivity(): Promise<number>;
4
5
  //# sourceMappingURL=drain-cron-batch.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"drain-cron-batch.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/drain-cron-batch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yCAAyC,CAAC;AAGnF,OAAO,EAAC,KAAK,gBAAgB,EAAwB,MAAM,+BAA+B,CAAC;AAE3F,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,qBAAqB,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CAQ3B;AAMD,wBAAgB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAExD"}
@@ -1,9 +1,10 @@
1
1
  import { Context } from '@temporalio/activity';
2
2
  import { config } from '#config.js';
3
3
  import { drainDueCronSchedules } from '#core/drain-cron-schedules.js';
4
- export async function drainCronBatchActivity() {
4
+ export async function drainCronBatchActivity(workflows) {
5
5
  const ctx = Context.current();
6
6
  return await drainDueCronSchedules({
7
+ workflows,
7
8
  batchSize: config.TRIGGER_CRON_CLAIM_BATCH,
8
9
  jitterWindowSeconds: config.TRIGGER_CRON_JITTER_WINDOW_SECONDS,
9
10
  onScheduleProcessed: ()=>ctx.heartbeat()
@@ -1 +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"}
1
+ {"version":3,"sources":["../../../src/temporal/activities/drain-cron-batch.ts"],"sourcesContent":["import type {WorkflowsModuleClient} from '@shipfox/api-workflows-dto/inter-module';\nimport {Context} from '@temporalio/activity';\nimport {config} from '#config.js';\nimport {type CronDrainSummary, drainDueCronSchedules} from '#core/drain-cron-schedules.js';\n\nexport async function drainCronBatchActivity(\n workflows: WorkflowsModuleClient,\n): Promise<CronDrainSummary> {\n const ctx = Context.current();\n return await drainDueCronSchedules({\n workflows,\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","workflows","ctx","current","batchSize","TRIGGER_CRON_CLAIM_BATCH","jitterWindowSeconds","TRIGGER_CRON_JITTER_WINDOW_SECONDS","onScheduleProcessed","heartbeat","readCronFanoutActivity","Promise","resolve","TRIGGER_CRON_FANOUT"],"mappings":"AACA,SAAQA,OAAO,QAAO,uBAAuB;AAC7C,SAAQC,MAAM,QAAO,aAAa;AAClC,SAA+BC,qBAAqB,QAAO,gCAAgC;AAE3F,OAAO,eAAeC,uBACpBC,SAAgC;IAEhC,MAAMC,MAAML,QAAQM,OAAO;IAC3B,OAAO,MAAMJ,sBAAsB;QACjCE;QACAG,WAAWN,OAAOO,wBAAwB;QAC1CC,qBAAqBR,OAAOS,kCAAkC;QAC9DC,qBAAqB,IAAMN,IAAIO,SAAS;IAC1C;AACF;AAEA,qFAAqF;AACrF,yFAAyF;AACzF,uFAAuF;AACvF,uFAAuF;AACvF,OAAO,SAASC;IACd,OAAOC,QAAQC,OAAO,CAACd,OAAOe,mBAAmB;AACnD"}
@@ -1,10 +1,11 @@
1
- import { drainCronBatchActivity, readCronFanoutActivity } from './drain-cron-batch.js';
1
+ import type { WorkflowsModuleClient } from '@shipfox/api-workflows-dto/inter-module';
2
+ import { readCronFanoutActivity } from './drain-cron-batch.js';
2
3
  import { pruneTriggerEventsActivity } from './prune-trigger-events.js';
3
4
  export declare function createTriggersMaintenanceActivities(): {
4
5
  pruneTriggerEventsActivity: typeof pruneTriggerEventsActivity;
5
6
  };
6
- export declare function createTriggersCronActivities(): {
7
- drainCronBatchActivity: typeof drainCronBatchActivity;
7
+ export declare function createTriggersCronActivities(workflows: WorkflowsModuleClient): {
8
+ drainCronBatchActivity: () => Promise<import("../../core/drain-cron-schedules.js").CronDrainSummary>;
8
9
  readCronFanoutActivity: typeof readCronFanoutActivity;
9
10
  };
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAyB,sBAAsB,EAAC,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAC,0BAA0B,EAAC,MAAM,2BAA2B,CAAC;AAErE,wBAAgB,mCAAmC;;EAIlD;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,qBAAqB;;;EAK5E"}
@@ -5,9 +5,9 @@ export function createTriggersMaintenanceActivities() {
5
5
  pruneTriggerEventsActivity
6
6
  };
7
7
  }
8
- export function createTriggersCronActivities() {
8
+ export function createTriggersCronActivities(workflows) {
9
9
  return {
10
- drainCronBatchActivity,
10
+ drainCronBatchActivity: ()=>drainCronBatchActivity(workflows),
11
11
  readCronFanoutActivity
12
12
  };
13
13
  }
@@ -1 +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"}
1
+ {"version":3,"sources":["../../../src/temporal/activities/index.ts"],"sourcesContent":["import type {WorkflowsModuleClient} from '@shipfox/api-workflows-dto/inter-module';\nimport {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(workflows: WorkflowsModuleClient) {\n return {\n drainCronBatchActivity: () => drainCronBatchActivity(workflows),\n readCronFanoutActivity,\n };\n}\n"],"names":["drainCronBatchActivity","readCronFanoutActivity","pruneTriggerEventsActivity","createTriggersMaintenanceActivities","createTriggersCronActivities","workflows"],"mappings":"AACA,SAAQA,sBAAsB,EAAEC,sBAAsB,QAAO,wBAAwB;AACrF,SAAQC,0BAA0B,QAAO,4BAA4B;AAErE,OAAO,SAASC;IACd,OAAO;QACLD;IACF;AACF;AAEA,OAAO,SAASE,6BAA6BC,SAAgC;IAC3E,OAAO;QACLL,wBAAwB,IAAMA,uBAAuBK;QACrDJ;IACF;AACF"}