@fedify/fedify 2.4.0-dev.1668 → 2.4.0-dev.1740

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 (151) hide show
  1. package/README.md +1 -1
  2. package/dist/{assert-CJ1KXcvv.mjs → assert-CebeUf0C.mjs} +1 -1
  3. package/dist/assert_exists-DtzkXC47.mjs +28 -0
  4. package/dist/assert_false-3pLLLsO4.mjs +23 -0
  5. package/dist/assert_greater_or_equal-BApOTh1h.mjs +30 -0
  6. package/dist/{assert_instance_of-Q9KTBnrf.mjs → assert_instance_of-g3WcyYNR.mjs} +1 -1
  7. package/dist/{assert_not_equals-EPJPoxuf.mjs → assert_not_equals-BN7yDMWe.mjs} +1 -1
  8. package/dist/assert_rejects-wFbSPn1O.mjs +39 -0
  9. package/dist/{assert_strict_equals-Ec20AUwa.mjs → assert_strict_equals-Bpjl4Psw.mjs} +1 -1
  10. package/dist/{assert_throws-NiFfqbnH.mjs → assert_throws-BJ5wuvR2.mjs} +1 -1
  11. package/dist/{builder-iXZ5jNVg.mjs → builder-Bw6LVKGw.mjs} +5 -3
  12. package/dist/{circuit-breaker-CBGyz5F7.mjs → circuit-breaker-BT7CiPbz.mjs} +191 -9
  13. package/dist/circuit-breaker-test-utils-BYIHoliq.mjs +14 -0
  14. package/dist/{client-CjF5IYQS.mjs → client-CtxvmazV.mjs} +63 -5
  15. package/dist/{collection-BIhlldqK.mjs → collection-CnnP1UAv.mjs} +1 -1
  16. package/dist/compat/mod.cjs +1 -1
  17. package/dist/compat/mod.d.cts +1 -1
  18. package/dist/compat/mod.d.ts +1 -1
  19. package/dist/compat/mod.js +1 -1
  20. package/dist/compat/outgoing-jsonld.test.mjs +3 -3
  21. package/dist/compat/public-audience.test.mjs +3 -3
  22. package/dist/compat/transformers.test.mjs +5 -5
  23. package/dist/{context-C05Rgxmu.d.cts → context-B-dsBjZ9.d.cts} +281 -7
  24. package/dist/{context-Cjnr0ig1.d.ts → context-DrLXudbA.d.ts} +281 -7
  25. package/dist/{deno-DtHcfB0f.mjs → deno-tRdp8MCl.mjs} +1 -1
  26. package/dist/{docloader-0vAfF6XW.mjs → docloader-Dg_7gMC7.mjs} +2 -2
  27. package/dist/{esm-yYQfPhIY.mjs → esm-BHXXx4Wx.mjs} +13 -6
  28. package/dist/federation/builder.test.mjs +18 -5
  29. package/dist/federation/circuit-breaker.test.mjs +626 -7
  30. package/dist/federation/collection.test.mjs +3 -3
  31. package/dist/federation/handler.test.mjs +14 -13
  32. package/dist/federation/idempotency.test.mjs +6 -6
  33. package/dist/federation/inbox.test.mjs +3 -3
  34. package/dist/federation/keycache.test.mjs +5 -5
  35. package/dist/federation/kv.test.mjs +3 -3
  36. package/dist/federation/metrics.test.mjs +4 -4
  37. package/dist/federation/middleware.test.mjs +37 -28
  38. package/dist/federation/mod.cjs +18 -540
  39. package/dist/federation/mod.d.cts +3 -4
  40. package/dist/federation/mod.d.ts +3 -4
  41. package/dist/federation/mod.js +1 -1
  42. package/dist/federation/mq.test.mjs +32 -5
  43. package/dist/federation/negotiation.test.mjs +4 -4
  44. package/dist/federation/retry.test.mjs +3 -3
  45. package/dist/federation/router.test.mjs +7 -7
  46. package/dist/federation/send.test.mjs +28 -26
  47. package/dist/federation/tasks/codec.test.mjs +4 -4
  48. package/dist/federation/tasks/enqueue.test.mjs +4 -4
  49. package/dist/federation/tasks/tasks.test.mjs +6 -6
  50. package/dist/federation/temporal.test.mjs +4 -4
  51. package/dist/federation/webfinger.test.mjs +74 -12
  52. package/dist/{middleware-DzIUFRO2.cjs → federation-BJBpt_Am.cjs} +855 -114
  53. package/dist/{http-BbnOMQoy.js → http-BIxGa6AG.js} +3 -3
  54. package/dist/{http-DUmWq5Pw.mjs → http-Day1kcpT.mjs} +5 -5
  55. package/dist/{temporal-polyfill-BCdTHexd.cjs → http-DggG1scN.cjs} +2801 -104
  56. package/dist/{key-CM7wDnZG.mjs → key-igh0AMsL.mjs} +2 -2
  57. package/dist/{kv-cache-ZQ22hm44.js → kv-cache-BIAB0HKx.js} +1 -1
  58. package/dist/{kv-cache-DEXKemJ9.mjs → kv-cache-Bz6aQOOX.mjs} +1 -1
  59. package/dist/{kv-cache-zmgG1HUp.cjs → kv-cache-C4U_uBqD.cjs} +2 -4
  60. package/dist/{ld-BttH_-8K.mjs → ld-DnT9sCWa.mjs} +5 -5
  61. package/dist/metrics-DVKYY6K1.d.cts +36 -0
  62. package/dist/{metrics-DT-CnD1g.mjs → metrics-DbdNnWIt.mjs} +2 -2
  63. package/dist/metrics-DoRtI0qU.d.ts +36 -0
  64. package/dist/{middleware-ChlYS0Af.mjs → middleware-B6GweVcg.mjs} +1 -1
  65. package/dist/{middleware-D3IAVMcT.js → middleware-CnsPXG0O.js} +241 -40
  66. package/dist/{middleware-DrroX3aD.mjs → middleware-DPIS4fsB.mjs} +60 -43
  67. package/dist/{mod-BrpVsSfY.d.cts → mod-CLHkCwLm.d.cts} +3 -3
  68. package/dist/{mod-B0hW12_O.d.cts → mod-CnGLNoVw.d.cts} +86 -4
  69. package/dist/{mod-DdONo-ep.d.cts → mod-D-abvu2C.d.cts} +1 -1
  70. package/dist/{mod-BsCE5Ihq.d.ts → mod-D6O8C7eN.d.ts} +1 -1
  71. package/dist/{mod-CNef4in0.d.ts → mod-DypxPS9H.d.ts} +3 -3
  72. package/dist/{mod-COIAjwRS.d.ts → mod-DzRXACM5.d.ts} +86 -4
  73. package/dist/mod.cjs +25 -25
  74. package/dist/mod.d.cts +10 -11
  75. package/dist/mod.d.ts +10 -11
  76. package/dist/mod.js +8 -8
  77. package/dist/nodeinfo/client.test.mjs +64 -4
  78. package/dist/nodeinfo/handler.test.mjs +5 -5
  79. package/dist/nodeinfo/mod.cjs +1 -1
  80. package/dist/nodeinfo/mod.d.cts +1 -1
  81. package/dist/nodeinfo/mod.d.ts +1 -1
  82. package/dist/nodeinfo/mod.js +1 -1
  83. package/dist/nodeinfo/types.test.mjs +4 -4
  84. package/dist/otel/exporter.test.mjs +3 -3
  85. package/dist/otel/mod.cjs +0 -1
  86. package/dist/otel/mod.d.cts +1 -1
  87. package/dist/otel/mod.d.ts +1 -1
  88. package/dist/{outgoing-jsonld-URuqsICz.mjs → outgoing-jsonld-BQSHRLhg.mjs} +2 -2
  89. package/dist/{owner-DZALmhdl.mjs → owner-B3ef8GfJ.mjs} +2 -2
  90. package/dist/{proof-CqA-2nfW.js → proof-BBLQXRWw.js} +608 -36
  91. package/dist/{proof-a60oVJ_4.cjs → proof-Cqk2TcLX.cjs} +616 -39
  92. package/dist/proof-DVoDZ8d7.mjs +890 -0
  93. package/dist/{public-audience-Cr5MsnMq.mjs → public-audience--9hx7IGx.mjs} +1 -1
  94. package/dist/runtime/mod.cjs +1 -1
  95. package/dist/runtime/mod.js +1 -1
  96. package/dist/{send-DcwZnQWG.mjs → send-PbBSZ7Qk.mjs} +3 -3
  97. package/dist/sig/accept.test.mjs +1 -1
  98. package/dist/sig/http.test.mjs +37 -11
  99. package/dist/sig/key.test.mjs +6 -6
  100. package/dist/sig/ld.test.mjs +9 -7
  101. package/dist/sig/mod.cjs +3 -2
  102. package/dist/sig/mod.d.cts +4 -4
  103. package/dist/sig/mod.d.ts +4 -4
  104. package/dist/sig/mod.js +3 -3
  105. package/dist/sig/owner.test.mjs +6 -6
  106. package/dist/sig/proof.test.mjs +965 -15
  107. package/dist/std__assert-CxFT0MNt.mjs +8 -0
  108. package/dist/{temporal-Bpxpsl2k.mjs → temporal-DLQIjuTn.mjs} +3 -3
  109. package/dist/testing/mod.d.mts +10 -0
  110. package/dist/testing/mod.mjs +2 -2
  111. package/dist/{testing-CO7ftO8A.mjs → testing-BX0Nicyq.mjs} +2 -2
  112. package/dist/{transformers-DGwl-hD1.cjs → transformers-BalCrSsr.cjs} +0 -1
  113. package/dist/{types-DC1pNgJA.js → types-Dtyf8lVj.js} +63 -5
  114. package/dist/{types-CPym83zc.cjs → types-RXm5YxpC.cjs} +62 -5
  115. package/dist/utils/docloader.test.mjs +7 -7
  116. package/dist/utils/kv-cache.test.mjs +1 -1
  117. package/dist/utils/mod.cjs +1 -1
  118. package/dist/utils/mod.d.cts +1 -1
  119. package/dist/utils/mod.d.ts +1 -1
  120. package/dist/utils/mod.js +1 -1
  121. package/package.json +7 -7
  122. package/skills/fedify/SKILL.md +462 -0
  123. package/dist/assert_rejects-EgstcQy5.mjs +0 -82
  124. package/dist/http-BpT5cE6r.cjs +0 -2694
  125. package/dist/metrics-DN13mCAw.d.cts +0 -294
  126. package/dist/metrics-v_e0n5GQ.d.ts +0 -294
  127. package/dist/proof-DiQ0uBal.mjs +0 -316
  128. package/dist/std__assert-B2NnY9bq.mjs +0 -79
  129. /package/dist/{accept-8PiolDP7.mjs → accept-CPVqki78.mjs} +0 -0
  130. /package/dist/{activity-listener-BtTSxZWA.mjs → activity-listener-C-BSbKI7.mjs} +0 -0
  131. /package/dist/{assert_equals-BV7oLMxm.mjs → assert_equals-CBlRfA-_.mjs} +0 -0
  132. /package/dist/{client-CAM_bQXx.d.cts → client-D-XP_Ccb.d.cts} +0 -0
  133. /package/dist/{client-CSddvgWN.d.ts → client-D-XP_Ccb.d.ts} +0 -0
  134. /package/dist/{codec-BBga-FWI.mjs → codec-peqOdBaE.mjs} +0 -0
  135. /package/dist/{context-BJXxPElm.mjs → context-Dt36KFEJ.mjs} +0 -0
  136. /package/dist/{http-VyDTd4G3.d.cts → http-6TI0tI03.d.cts} +0 -0
  137. /package/dist/{http-lf8Hsd91.d.ts → http-CdrSn2ip.d.ts} +0 -0
  138. /package/dist/{keycache-_DHqz5z_.mjs → keycache-0Jk78XmB.mjs} +0 -0
  139. /package/dist/{keys-Dbyd7bhl.mjs → keys-DIJNHW-Y.mjs} +0 -0
  140. /package/dist/{kv-D6hNiMTK.d.ts → kv-BhNbN8Ed.d.cts} +0 -0
  141. /package/dist/{kv-gJ8LYbxX.d.cts → kv-BhNbN8Ed.d.ts} +0 -0
  142. /package/dist/{kv-CXBAok3k.mjs → kv-DCHkaJ9-.mjs} +0 -0
  143. /package/dist/{mq-Bo7Etgh6.mjs → mq-Dm1Wmtm-.mjs} +0 -0
  144. /package/dist/{negotiation-RuwrPFqi.mjs → negotiation-CCocWT_N.mjs} +0 -0
  145. /package/dist/{owner-CnngXDNJ.d.ts → owner-DGSfntI-.d.ts} +0 -0
  146. /package/dist/{owner-DEvZuyOE.d.cts → owner-r_waTiQj.d.cts} +0 -0
  147. /package/dist/{retry-DgFqeS5k.mjs → retry-zX5xw5e0.mjs} +0 -0
  148. /package/dist/{chunk-D5IdezsZ.js → rolldown-runtime-BC-Eo5Mj.js} +0 -0
  149. /package/dist/{chunk-Czpeue4M.cjs → rolldown-runtime-Dmm3t92W.cjs} +0 -0
  150. /package/dist/{transformers-DXze6FUB.js → transformers-DAtXl_Kc.js} +0 -0
  151. /package/dist/{types-CrtdVuDP.mjs → types-DE_LV1JB.mjs} +0 -0
@@ -1,4 +1,4 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "../transformers-DXze6FUB.js";
3
+ import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "../transformers-DAtXl_Kc.js";
4
4
  export { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers };
@@ -1,9 +1,9 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-BV7oLMxm.mjs";
5
- import { t as assertStrictEquals } from "../assert_strict_equals-Ec20AUwa.mjs";
6
- import { n as normalizeAttachmentArrays, r as normalizeOutgoingActivityJsonLd, t as isPreloadedContextAttachmentSafe } from "../outgoing-jsonld-URuqsICz.mjs";
4
+ import { t as assertEquals } from "../assert_equals-CBlRfA-_.mjs";
5
+ import { t as assertStrictEquals } from "../assert_strict_equals-Bpjl4Psw.mjs";
6
+ import { n as normalizeAttachmentArrays, r as normalizeOutgoingActivityJsonLd, t as isPreloadedContextAttachmentSafe } from "../outgoing-jsonld-BQSHRLhg.mjs";
7
7
  import { Create, Document, Note, PUBLIC_COLLECTION } from "@fedify/vocab";
8
8
  import { mockDocumentLoader, test } from "@fedify/fixture";
9
9
  //#region src/compat/outgoing-jsonld.test.ts
@@ -1,9 +1,9 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-BV7oLMxm.mjs";
5
- import { t as assertNotEquals } from "../assert_not_equals-EPJPoxuf.mjs";
6
- import { t as normalizePublicAudience } from "../public-audience-Cr5MsnMq.mjs";
4
+ import { t as assertEquals } from "../assert_equals-CBlRfA-_.mjs";
5
+ import { t as assertNotEquals } from "../assert_not_equals-BN7yDMWe.mjs";
6
+ import { t as normalizePublicAudience } from "../public-audience--9hx7IGx.mjs";
7
7
  import { Create, Note, PUBLIC_COLLECTION } from "@fedify/vocab";
8
8
  import { test } from "@fedify/fixture";
9
9
  import { getDocumentLoader, preloadedContexts } from "@fedify/vocab-runtime";
@@ -1,11 +1,11 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as MemoryKvStore } from "../kv-CXBAok3k.mjs";
5
- import { t as assertEquals } from "../assert_equals-BV7oLMxm.mjs";
6
- import { t as assertInstanceOf } from "../assert_instance_of-Q9KTBnrf.mjs";
7
- import { t as assert } from "../assert-CJ1KXcvv.mjs";
8
- import { b as autoIdAssigner, n as FederationImpl, y as actorDehydrator } from "../middleware-DrroX3aD.mjs";
4
+ import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
5
+ import { t as assertEquals } from "../assert_equals-CBlRfA-_.mjs";
6
+ import { t as assertInstanceOf } from "../assert_instance_of-g3WcyYNR.mjs";
7
+ import { t as assert } from "../assert-CebeUf0C.mjs";
8
+ import { b as autoIdAssigner, n as FederationImpl, y as actorDehydrator } from "../middleware-DPIS4fsB.mjs";
9
9
  import { Follow, Person } from "@fedify/vocab";
10
10
  import { test } from "@fedify/fixture";
11
11
  //#region src/compat/transformers.test.ts
@@ -1,9 +1,8 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-CAM_bQXx.cjs";
3
- import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-VyDTd4G3.cjs";
4
- import { n as GetKeyOwnerOptions } from "./owner-DEvZuyOE.cjs";
5
- import { n as KvStore, t as KvKey } from "./kv-gJ8LYbxX.cjs";
6
- import { i as MessageQueue } from "./metrics-DN13mCAw.cjs";
2
+ import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-D-XP_Ccb.cjs";
3
+ import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-6TI0tI03.cjs";
4
+ import { n as GetKeyOwnerOptions } from "./owner-r_waTiQj.cjs";
5
+ import { n as KvStore, t as KvKey } from "./kv-BhNbN8Ed.cjs";
7
6
  import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
8
7
  import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
9
8
  import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
@@ -507,6 +506,16 @@ type CircuitBreakerOptions = CircuitBreakerFailurePolicy & {
507
506
  */
508
507
  readonly releaseInterval?: Temporal.Duration | Temporal.DurationLike;
509
508
  /**
509
+ * How long Fedify keeps circuit breaker state in the configured key-value
510
+ * store.
511
+ *
512
+ * When omitted, Fedify derives this from `failureWindow`, `recoveryDelay`, and
513
+ * `heldActivityTtl` for the default numeric failure policy. Custom `failure`
514
+ * callbacks do not have an inspectable time window, so custom policies do not
515
+ * expire their stored state unless this option is provided.
516
+ */
517
+ readonly stateTtl?: Temporal.Duration | Temporal.DurationLike;
518
+ /**
510
519
  * Called whenever the circuit state changes.
511
520
  */
512
521
  readonly onStateChange?: (remoteHost: string, previousState: CircuitBreakerState, newState: CircuitBreakerState) => void | Promise<void>;
@@ -525,6 +534,7 @@ interface NormalizedCircuitBreakerOptions {
525
534
  readonly recoveryDelay: Temporal.Duration;
526
535
  readonly heldActivityTtl: Temporal.Duration;
527
536
  readonly releaseInterval: Temporal.Duration;
537
+ readonly stateTtl: Temporal.Duration | undefined;
528
538
  readonly onStateChange?: CircuitBreakerOptions["onStateChange"];
529
539
  readonly onActivityDrop?: CircuitBreakerOptions["onActivityDrop"];
530
540
  }
@@ -585,6 +595,11 @@ declare class CircuitBreaker {
585
595
  recordFailure(remoteHost: string): Promise<CircuitBreakerStateChange | undefined>;
586
596
  dropActivity(remoteHost: string, details: CircuitBreakerActivityDrop): Promise<void>;
587
597
  getState(remoteHost: string): Promise<CircuitBreakerKvState | undefined>;
598
+ /**
599
+ * The currently running background legacy sweep, if any.
600
+ * @internal
601
+ */
602
+ get pendingSweep(): Promise<void> | undefined;
588
603
  }
589
604
  /**
590
605
  * Normalizes user-provided circuit breaker options into the internal policy
@@ -593,7 +608,8 @@ declare class CircuitBreaker {
593
608
  * @param options The public circuit breaker options supplied to Fedify.
594
609
  * @returns The normalized failure predicate, failure pruning function,
595
610
  * duration values, and optional callbacks with defaults applied.
596
- * @throws {RangeError} If any configured duration is not positive.
611
+ * @throws {RangeError} If any configured duration is not positive, or if
612
+ * `stateTtl` is shorter than `recoveryDelay`.
597
613
  * @throws {TypeError} If `failureThreshold` is not a positive integer.
598
614
  */
599
615
  declare function normalizeCircuitBreakerOptions(options: CircuitBreakerOptions): NormalizedCircuitBreakerOptions;
@@ -606,6 +622,264 @@ declare function normalizeCircuitBreakerOptions(options: CircuitBreakerOptions):
606
622
  */
607
623
  declare function parseCircuitBreakerKvState(value: unknown): CircuitBreakerKvState | undefined;
608
624
  //#endregion
625
+ //#region src/federation/mq.d.ts
626
+ /**
627
+ * Additional options for enqueuing a message in a queue.
628
+ *
629
+ * @since 0.5.0
630
+ */
631
+ interface MessageQueueEnqueueOptions {
632
+ /**
633
+ * The delay before the message is enqueued. No delay by default.
634
+ *
635
+ * It must not be negative.
636
+ */
637
+ readonly delay?: Temporal.Duration;
638
+ /**
639
+ * An optional key that ensures messages with the same ordering key are
640
+ * processed sequentially (one at a time). Messages with different ordering
641
+ * keys (or no ordering key) may be processed in parallel.
642
+ *
643
+ * This is useful for ensuring that related messages are processed in order,
644
+ * such as ensuring that a `Delete` activity is processed after a `Create`
645
+ * activity for the same object.
646
+ *
647
+ * @since 2.0.0
648
+ */
649
+ readonly orderingKey?: string;
650
+ /**
651
+ * An optional key requesting at-most-once enqueue semantics for messages
652
+ * that share it. A backend that declares
653
+ * {@link MessageQueue.nativeDeduplication} `true` owns the check: a message
654
+ * whose `deduplicationKey` was already seen within the backend's
655
+ * deduplication window is dropped instead of enqueued. Backends without
656
+ * native deduplication ignore this field; Fedify performs its own
657
+ * best-effort deduplication before reaching them on the paths that support
658
+ * it.
659
+ *
660
+ * @since 2.4.0
661
+ */
662
+ readonly deduplicationKey?: string;
663
+ }
664
+ /**
665
+ * Additional options for listening to a message queue.
666
+ *
667
+ * @since 1.0.0
668
+ */
669
+ interface MessageQueueListenOptions {
670
+ /**
671
+ * The signal to abort listening to the message queue.
672
+ */
673
+ signal?: AbortSignal;
674
+ }
675
+ /**
676
+ * The number of messages waiting in a message queue.
677
+ *
678
+ * @since 2.3.0
679
+ */
680
+ interface MessageQueueDepth {
681
+ /**
682
+ * The total number of messages still waiting in the backend queue.
683
+ *
684
+ * This does not include messages that have already been handed to a worker
685
+ * for processing.
686
+ */
687
+ readonly queued: number;
688
+ /**
689
+ * The number of queued messages eligible for immediate processing.
690
+ *
691
+ * Queue backends that cannot cheaply distinguish ready and delayed messages
692
+ * may omit this field.
693
+ */
694
+ readonly ready?: number;
695
+ /**
696
+ * The number of queued messages scheduled for later delivery.
697
+ *
698
+ * Queue backends that cannot cheaply distinguish ready and delayed messages
699
+ * may omit this field.
700
+ */
701
+ readonly delayed?: number;
702
+ }
703
+ /**
704
+ * An abstract interface for a message queue.
705
+ *
706
+ * @since 0.5.0
707
+ */
708
+ interface MessageQueue {
709
+ /**
710
+ * Whether the message queue backend provides native retry mechanisms.
711
+ * When `true`, Fedify will skip its own retry logic and rely on the backend
712
+ * to handle retries. When `false` or omitted, Fedify will handle retries
713
+ * using its own retry policies.
714
+ *
715
+ * @default `false`
716
+ * @since 1.7.0
717
+ */
718
+ readonly nativeRetrial?: boolean;
719
+ /**
720
+ * Whether the message queue backend deduplicates messages that share a
721
+ * {@link MessageQueueEnqueueOptions.deduplicationKey} natively. When `true`,
722
+ * Fedify forwards the `deduplicationKey` and relies on the backend to drop
723
+ * duplicates; when `false` or omitted, Fedify applies its own best-effort
724
+ * key–value deduplication on the paths that request it.
725
+ *
726
+ * @default `false`
727
+ * @since 2.4.0
728
+ */
729
+ readonly nativeDeduplication?: boolean;
730
+ /**
731
+ * Whether {@link enqueueMany} accepts either every message or no messages.
732
+ * Backends that implement `enqueueMany()` by sending messages individually
733
+ * must set this to `false`, so Fedify does not use that method for a batch
734
+ * governed by one `deduplicationKey`. `true` by default when `enqueueMany`
735
+ * is implemented.
736
+ *
737
+ * @default `true`
738
+ * @since 2.4.0
739
+ */
740
+ readonly atomicEnqueueMany?: boolean;
741
+ /**
742
+ * Enqueues a message in the queue.
743
+ * @param message The message to enqueue.
744
+ * @param options Additional options for enqueuing the message.
745
+ */
746
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
747
+ /**
748
+ * Enqueues multiple messages in the queue. This operation is optional,
749
+ * and may not be supported by all implementations. If not supported,
750
+ * Fedify will invoke {@link enqueue} for each message. An implementation
751
+ * that may accept only part of a batch before rejecting must declare
752
+ * {@link atomicEnqueueMany} `false`.
753
+ *
754
+ * @param messages The messages to enqueue.
755
+ * @param options Additional options for enqueuing the messages.
756
+ */
757
+ enqueueMany?: (messages: readonly any[], options?: MessageQueueEnqueueOptions) => Promise<void>;
758
+ /**
759
+ * Listens for messages in the queue.
760
+ * @param handler The handler for messages in the queue.
761
+ * @param options Additional options for listening to the message queue.
762
+ * @returns A promise that resolves when the listening is done. It never
763
+ * rejects, and is resolved when the signal is aborted. If no
764
+ * signal is provided, it never resolves.
765
+ */
766
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
767
+ /**
768
+ * Gets the number of messages waiting in the queue.
769
+ *
770
+ * This operation is optional, and may not be supported by all
771
+ * implementations. The returned counts exclude messages currently being
772
+ * handled by a worker.
773
+ *
774
+ * @since 2.3.0
775
+ */
776
+ getDepth?(): Promise<MessageQueueDepth>;
777
+ }
778
+ /**
779
+ * Additional options for {@link InProcessMessageQueue}.
780
+ * @since 1.0.0
781
+ */
782
+ interface InProcessMessageQueueOptions {
783
+ /**
784
+ * The interval to poll for messages in the queue. 5 seconds by default.
785
+ * @default `{ seconds: 5 }`
786
+ */
787
+ pollInterval?: Temporal.Duration | Temporal.DurationLike;
788
+ }
789
+ /**
790
+ * A message queue that processes messages in the same process.
791
+ * Do not use this in production as it does neither persist messages nor
792
+ * distribute them across multiple processes.
793
+ *
794
+ * @since 0.5.0
795
+ */
796
+ declare class InProcessMessageQueue implements MessageQueue {
797
+ #private;
798
+ /**
799
+ * In-process message queue does not provide native retry mechanisms.
800
+ * @since 1.7.0
801
+ */
802
+ readonly nativeRetrial = false;
803
+ /**
804
+ * In-process message queue does not deduplicate messages natively.
805
+ * @since 2.4.0
806
+ */
807
+ readonly nativeDeduplication = false;
808
+ /**
809
+ * Constructs a new {@link InProcessMessageQueue} with the given options.
810
+ * @param options Additional options for the in-process message queue.
811
+ */
812
+ constructor(options?: InProcessMessageQueueOptions);
813
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
814
+ enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
815
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
816
+ getDepth(): Promise<MessageQueueDepth>;
817
+ }
818
+ /**
819
+ * A message queue that processes messages in parallel. It takes another
820
+ * {@link MessageQueue}, and processes messages in parallel up to a certain
821
+ * number of workers.
822
+ *
823
+ * Actually, it's rather a decorator than a queue itself.
824
+ *
825
+ * Note that the workers do not run in truly parallel, in the sense that they
826
+ * are not running in separate threads or processes. They are running in the
827
+ * same process, but are scheduled to run in parallel. Hence, this is useful
828
+ * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
829
+ * workloads.
830
+ *
831
+ * When using `ParallelMessageQueue`, the ordering guarantee is preserved
832
+ * *only if* the underlying queue implementation delivers messages in a wrapper
833
+ * format that includes the `__fedify_ordering_key__` property. Currently,
834
+ * only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
835
+ * For other queue implementations (e.g., `InProcessMessageQueue`,
836
+ * `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
837
+ * `AmqpMessageQueue`), the ordering key cannot be detected by
838
+ * `ParallelMessageQueue`, so ordering guarantees are handled by those
839
+ * implementations directly rather than at the `ParallelMessageQueue` level.
840
+ *
841
+ * Messages with the same ordering key will never be processed concurrently
842
+ * by different workers, ensuring sequential processing within each key.
843
+ * Messages with different ordering keys (or no ordering key) can still be
844
+ * processed in parallel.
845
+ *
846
+ * @since 1.0.0
847
+ */
848
+ declare class ParallelMessageQueue implements MessageQueue {
849
+ #private;
850
+ readonly queue: MessageQueue;
851
+ readonly workers: number;
852
+ /**
853
+ * Inherits the native retry capability from the wrapped queue.
854
+ * @since 1.7.0
855
+ */
856
+ readonly nativeRetrial?: boolean;
857
+ /**
858
+ * Inherits the native deduplication capability from the wrapped queue.
859
+ * @since 2.4.0
860
+ */
861
+ readonly nativeDeduplication?: boolean;
862
+ /**
863
+ * Inherits the atomic batch capability from the wrapped queue.
864
+ * @since 2.4.0
865
+ */
866
+ readonly atomicEnqueueMany?: boolean;
867
+ readonly getDepth?: () => Promise<MessageQueueDepth>;
868
+ /**
869
+ * Constructs a new {@link ParallelMessageQueue} with the given queue and
870
+ * number of workers.
871
+ * @param queue The message queue to use under the hood. Note that
872
+ * {@link ParallelMessageQueue} cannot be nested.
873
+ * @param workers The number of workers to process messages in parallel.
874
+ * @throws {TypeError} If the given queue is an instance of
875
+ * {@link ParallelMessageQueue}.
876
+ */
877
+ constructor(queue: MessageQueue, workers: number);
878
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
879
+ enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
880
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
881
+ }
882
+ //#endregion
609
883
  //#region src/federation/handler.d.ts
610
884
  /**
611
885
  * Options for the {@link respondWithObject} and
@@ -3248,4 +3522,4 @@ interface ActorKeyPair extends CryptoKeyPair {
3248
3522
  readonly multikey: Multikey;
3249
3523
  }
3250
3524
  //#endregion
3251
- export { CircuitBreakerCreateOptions as $, OutboxListenerSetters as A, UnverifiedActivityHandler as At, TaskEnqueueOptions as B, FederationStartQueueOptions as C, ObjectAuthorizePredicate as Ct, InboxListenerSetters as D, OutboxListenerErrorHandler as Dt, InboxChallengePolicy as E, OutboxListener as Et, createFederation as F, PageItems as Ft, RetryPolicy as G, TaskRegistry as H, Message as I, buildCollectionSynchronizationHeader as It, respondWithObject as J, createExponentialBackoffPolicy as K, createFederationBuilder as L, digest as Lt, FederationKvPrefixes as M, WebFingerLinksDispatcher as Mt, FederationOrigin as N, SendActivityError as Nt, MediaUploaderSetters as O, OutboxPermanentFailureHandler as Ot, FederationQueueOptions as P, SenderKeyPair as Pt, CircuitBreakerBeforeSendDecision as Q, TaskDefinition as R, ActivityTransformer as Rt, FederationOptions as S, NodeInfoDispatcher as St, IdempotencyStrategy as T, OutboxErrorHandler as Tt, CreateExponentialBackoffPolicyOptions as U, TaskHandler as V, RetryContext as W, CircuitBreaker as X, respondWithObjectIfAcceptable as Y, CircuitBreakerActivityDrop as Z, Federatable as _, CustomCollectionCursor as _t, GetSignedKeyOptions as a, NormalizedCircuitBreakerOptions as at, FederationBuilder as b, InboxListener as bt, ParseUriResult as c, ActorAliasMapper as ct, SendActivityOptions as d, ActorKeyPairsDispatcher as dt, CircuitBreakerFailurePolicy as et, SendActivityOptionsForCollection as f, AuthorizePredicate as ft, CustomCollectionCallbackSetters as g, CustomCollectionCounter as gt, ConstructorWithTypeId as h, CollectionDispatcher as ht, GetActorOptions as i, CircuitBreakerStateChange as it, Rfc6570Expression as j, UnverifiedActivityReason as jt, ObjectCallbackSetters as k, SharedInboxKeyDispatcher as kt, RequestContext as l, ActorDispatcher as lt, CollectionCallbackSetters as m, CollectionCursor as mt, Context as n, CircuitBreakerOptions as nt, InboxContext as o, normalizeCircuitBreakerOptions as ot, ActorCallbackSetters as p, CollectionCounter as pt, RespondWithObjectOptions as q, ForwardActivityOptions as r, CircuitBreakerState as rt, OutboxContext as s, parseCircuitBreakerKvState as st, ActorKeyPair as t, CircuitBreakerKvState as tt, RouteActivityOptions as u, ActorHandleMapper as ut, Federation as v, CustomCollectionDispatcher as vt, IdempotencyKeyCallback as w, ObjectDispatcher as wt, FederationFetchOptions as x, MediaUploaderCallback as xt, FederationBenchmarkOptions as y, InboxErrorHandler as yt, TaskDefinitionOptions as z };
3525
+ export { MessageQueueDepth as $, OutboxListenerSetters as A, ObjectAuthorizePredicate as At, TaskEnqueueOptions as B, SendActivityError as Bt, FederationStartQueueOptions as C, CustomCollectionCounter as Ct, InboxListenerSetters as D, InboxListener as Dt, InboxChallengePolicy as E, InboxErrorHandler as Et, createFederation as F, OutboxPermanentFailureHandler as Ft, RetryPolicy as G, ActivityTransformer as Gt, TaskRegistry as H, PageItems as Ht, Message as I, SharedInboxKeyDispatcher as It, respondWithObject as J, createExponentialBackoffPolicy as K, createFederationBuilder as L, UnverifiedActivityHandler as Lt, FederationKvPrefixes as M, OutboxErrorHandler as Mt, FederationOrigin as N, OutboxListener as Nt, MediaUploaderSetters as O, MediaUploaderCallback as Ot, FederationQueueOptions as P, OutboxListenerErrorHandler as Pt, MessageQueue as Q, TaskDefinition as R, UnverifiedActivityReason as Rt, FederationOptions as S, CollectionDispatcher as St, IdempotencyStrategy as T, CustomCollectionDispatcher as Tt, CreateExponentialBackoffPolicyOptions as U, buildCollectionSynchronizationHeader as Ut, TaskHandler as V, SenderKeyPair as Vt, RetryContext as W, digest as Wt, InProcessMessageQueue as X, respondWithObjectIfAcceptable as Y, InProcessMessageQueueOptions as Z, Federatable as _, ActorHandleMapper as _t, GetSignedKeyOptions as a, CircuitBreakerBeforeSendDecision as at, FederationBuilder as b, CollectionCounter as bt, ParseUriResult as c, CircuitBreakerKvState as ct, SendActivityOptions as d, CircuitBreakerStateChange as dt, MessageQueueEnqueueOptions as et, SendActivityOptionsForCollection as f, NormalizedCircuitBreakerOptions as ft, CustomCollectionCallbackSetters as g, ActorDispatcher as gt, ConstructorWithTypeId as h, ActorAliasMapper as ht, GetActorOptions as i, CircuitBreakerActivityDrop as it, Rfc6570Expression as j, ObjectDispatcher as jt, ObjectCallbackSetters as k, NodeInfoDispatcher as kt, RequestContext as l, CircuitBreakerOptions as lt, CollectionCallbackSetters as m, parseCircuitBreakerKvState as mt, Context as n, ParallelMessageQueue as nt, InboxContext as o, CircuitBreakerCreateOptions as ot, ActorCallbackSetters as p, normalizeCircuitBreakerOptions as pt, RespondWithObjectOptions as q, ForwardActivityOptions as r, CircuitBreaker as rt, OutboxContext as s, CircuitBreakerFailurePolicy as st, ActorKeyPair as t, MessageQueueListenOptions as tt, RouteActivityOptions as u, CircuitBreakerState as ut, Federation as v, ActorKeyPairsDispatcher as vt, IdempotencyKeyCallback as w, CustomCollectionCursor as wt, FederationFetchOptions as x, CollectionCursor as xt, FederationBenchmarkOptions as y, AuthorizePredicate as yt, TaskDefinitionOptions as z, WebFingerLinksDispatcher as zt };