@fedify/fedify 2.0.0-dev.1561 → 2.0.0-dev.158

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 (297) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +40 -18
  3. package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
  4. package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
  5. package/dist/{builder-C8mpxJD3.js → builder-BnWso6VP.js} +15 -8
  6. package/dist/chunk-DqRYRqnO.cjs +34 -0
  7. package/dist/client-94iWEfQa.d.cts +222 -0
  8. package/dist/{client-DF8anIB5.d.ts → client-BivSNrEg.d.ts} +3 -75
  9. package/dist/{client-DI0GS_3p.js → client-CgMTXmAD.js} +3 -22
  10. package/dist/compat/mod.cjs +10 -0
  11. package/dist/compat/mod.d.cts +7 -0
  12. package/dist/compat/mod.d.ts +6 -12
  13. package/dist/compat/mod.js +5 -5
  14. package/dist/compat/transformers.test.js +21 -20
  15. package/dist/compat-DmDDELst.cjs +4 -0
  16. package/dist/compat-nxUqe4Z-.js +4 -0
  17. package/dist/context-Bns6uTJq.js +109 -0
  18. package/dist/{context-9gCpIkiz.d.ts → context-CYZ2i00R.d.ts} +321 -129
  19. package/dist/context-D2MrtLch.d.cts +2447 -0
  20. package/dist/deno-CQV858ip.js +117 -0
  21. package/dist/{testing-DsuOHyiF.js → dist-B5f6a8Tt.js} +90 -111
  22. package/dist/{authdocloader-CN-tWO4K.js → docloader-Csc8gQux.js} +17 -8
  23. package/dist/{esm-CtgLSZwm.js → esm-DGl7uK1r.js} +32 -17
  24. package/dist/federation/builder.test.js +12 -13
  25. package/dist/federation/collection.test.js +6 -9
  26. package/dist/federation/handler.test.js +115 -148
  27. package/dist/federation/idempotency.test.js +202 -0
  28. package/dist/federation/inbox.test.js +5 -6
  29. package/dist/federation/keycache.test.js +4 -5
  30. package/dist/federation/kv.test.js +61 -9
  31. package/dist/federation/middleware.test.js +311 -131
  32. package/dist/federation/mod.cjs +25 -0
  33. package/dist/federation/mod.d.cts +7 -0
  34. package/dist/federation/mod.d.ts +7 -13
  35. package/dist/federation/mod.js +11 -16
  36. package/dist/federation/mq.test.js +9 -10
  37. package/dist/federation/negotiation.test.js +25 -0
  38. package/dist/federation/retry.test.js +2 -4
  39. package/dist/federation/router.test.js +6 -8
  40. package/dist/federation/send.test.js +55 -15
  41. package/dist/{webfinger/handler.test.js → federation/webfinger.test.js} +27 -26
  42. package/dist/federation-B431K2gm.cjs +266 -0
  43. package/dist/{federation-CMX7WzeL.js → federation-BbZwNNWj.js} +31 -9
  44. package/dist/{http-B_tXwHIe.js → http-BizGfAHd.js} +375 -15
  45. package/dist/{http-DTJgsmYR.js → http-CXG5ZFqn.js} +4 -3
  46. package/dist/http-ClB3pLcL.d.cts +253 -0
  47. package/dist/{http-DqSNLFNY.d.ts → http-DLBDPal9.d.ts} +2 -2
  48. package/dist/http-DbACqYyq.cjs +1222 -0
  49. package/dist/{inbox-Dx8EjUbq.js → inbox-B7ybw6fk.js} +25 -7
  50. package/dist/{key-olV6hEgm.js → key-C27c_yHR.js} +3 -2
  51. package/dist/{keycache-CExtp4Yl.js → keycache-DRxpZ5r9.js} +1 -1
  52. package/dist/{keys-O0-r0NpJ.js → keys-ZbcByPg9.js} +2 -1
  53. package/dist/{kv-C7sopW2E.d.ts → kv-CtOmTRNc.d.ts} +30 -1
  54. package/dist/kv-D8q9fLkA.d.cts +110 -0
  55. package/dist/{kv-CRZrzyXm.js → kv-QzKcOQgP.js} +22 -0
  56. package/dist/kv-cache-B7dwGQFA.js +122 -0
  57. package/dist/kv-cache-BEeqyGER.js +107 -0
  58. package/dist/kv-cache-rPOPQdj9.cjs +134 -0
  59. package/dist/{ld-DR6b11xZ.js → ld-D_Jn1aGa.js} +6 -4
  60. package/dist/middleware-BVqYHBWm.cjs +12 -0
  61. package/dist/{middleware-GT7W03qw.js → middleware-BjS6_zkf.js} +272 -271
  62. package/dist/middleware-CAJR7KGo.cjs +4242 -0
  63. package/dist/{middleware-CUw3Ys9y.js → middleware-ClkhKNXU.js} +230 -327
  64. package/dist/middleware-DSz6sI16.js +26 -0
  65. package/dist/middleware-OcaFHSk8.js +12 -0
  66. package/dist/mod-BrS8tiad.d.cts +266 -0
  67. package/dist/mod-C81L6_lQ.d.cts +1 -0
  68. package/dist/mod-CJgbdSqb.d.ts +109 -0
  69. package/dist/mod-CNNTHyBC.d.cts +80 -0
  70. package/dist/mod-CS-MS7gZ.d.cts +62 -0
  71. package/dist/{mod-Bqxcp7eN.d.ts → mod-D_cmv2il.d.ts} +4 -4
  72. package/dist/mod-DcPRcifg.d.cts +107 -0
  73. package/dist/mod-DqFSzJA0.d.ts +64 -0
  74. package/dist/{mod-Drmz72EK.d.ts → mod-jOa7W503.d.ts} +3 -3
  75. package/dist/mod.cjs +55 -0
  76. package/dist/mod.d.cts +11 -0
  77. package/dist/mod.d.ts +11 -17
  78. package/dist/mod.js +15 -21
  79. package/dist/negotiation-5NPJL6zp.js +71 -0
  80. package/dist/nodeinfo/client.test.js +29 -111
  81. package/dist/nodeinfo/handler.test.js +26 -26
  82. package/dist/nodeinfo/mod.cjs +10 -0
  83. package/dist/nodeinfo/mod.d.cts +3 -0
  84. package/dist/nodeinfo/mod.d.ts +3 -5
  85. package/dist/nodeinfo/mod.js +6 -7
  86. package/dist/nodeinfo/types.test.js +7 -15
  87. package/dist/nodeinfo-BlLsRSiT.js +4 -0
  88. package/dist/nodeinfo-DuMYTpbZ.cjs +4 -0
  89. package/dist/otel/exporter.test.js +899 -0
  90. package/dist/otel/mod.cjs +262 -0
  91. package/dist/otel/mod.d.cts +230 -0
  92. package/dist/otel/mod.d.ts +232 -0
  93. package/dist/otel/mod.js +261 -0
  94. package/dist/{owner-CQPnQVtf.d.ts → owner-BgI8C-VY.d.ts} +2 -3
  95. package/dist/owner-C-zfmVAD.d.cts +66 -0
  96. package/dist/{owner-BtFz-dZ-.js → owner-Dc8rUE-H.js} +45 -8
  97. package/dist/{proof-DsZjVJ0G.js → proof-BdNM3iSl.js} +4 -3
  98. package/dist/proof-Bx2JqJ-D.cjs +709 -0
  99. package/dist/{proof-DKDM7T5F.js → proof-CTYnbjx5.js} +53 -17
  100. package/dist/router-D9eI0s4b.js +118 -0
  101. package/dist/{send-s0_EjVhZ.js → send-DBRRqVMa.js} +9 -4
  102. package/dist/sig/http.test.js +12 -14
  103. package/dist/sig/key.test.js +9 -11
  104. package/dist/sig/ld.test.js +8 -10
  105. package/dist/sig/mod.cjs +26 -0
  106. package/dist/sig/mod.d.cts +4 -0
  107. package/dist/sig/mod.d.ts +3 -7
  108. package/dist/sig/mod.js +6 -10
  109. package/dist/sig/owner.test.js +33 -12
  110. package/dist/sig/proof.test.js +13 -14
  111. package/dist/sig-CwuONEzF.js +4 -0
  112. package/dist/sig-DeXX2xnj.cjs +4 -0
  113. package/dist/testing/mod.d.ts +180 -6946
  114. package/dist/testing/mod.js +4 -4
  115. package/dist/transformers-BjBg6Lag.cjs +116 -0
  116. package/dist/{transformers-Dna8Fg7k.js → transformers-N_ip_y4P.js} +5 -5
  117. package/dist/{types-BIgY6c-l.js → types-BEdCLHqP.js} +1 -3
  118. package/dist/types-Q-qkJXBV.cjs +315 -0
  119. package/dist/{types-CGB4mJU6.js → types-hKTi53FO.js} +8 -169
  120. package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +13 -15
  121. package/dist/utils/kv-cache.test.js +211 -0
  122. package/dist/utils/mod.cjs +10 -0
  123. package/dist/utils/mod.d.cts +4 -0
  124. package/dist/utils/mod.d.ts +6 -0
  125. package/dist/utils/mod.js +9 -0
  126. package/dist/utils-Db0ZmjcD.cjs +4 -0
  127. package/dist/utils-Wranxuoe.js +4 -0
  128. package/package.json +69 -55
  129. package/dist/actor-C22bXuuC.d.ts +0 -130
  130. package/dist/actor-Qc3Ee6k1.js +0 -37311
  131. package/dist/actor-mhluotIb.js +0 -146
  132. package/dist/assert_throws-BOO88avQ.js +0 -39
  133. package/dist/authdocloader-Dp9WS-1G.js +0 -52
  134. package/dist/compat-Bb5myD13.js +0 -4
  135. package/dist/denokv-Bv33Xxea.js +0 -57
  136. package/dist/docloader-CxWcuWqQ.d.ts +0 -221
  137. package/dist/docloader-DIjo5mkd.js +0 -4615
  138. package/dist/fixtures/activitypub.academy/users/brauca_darradiul.json +0 -83
  139. package/dist/fixtures/example.com/announce.json +0 -6
  140. package/dist/fixtures/example.com/collection.json +0 -19
  141. package/dist/fixtures/example.com/create.json +0 -6
  142. package/dist/fixtures/example.com/cross-origin-actor.json +0 -6
  143. package/dist/fixtures/example.com/hong-gildong.json +0 -11
  144. package/dist/fixtures/example.com/invite.json +0 -7
  145. package/dist/fixtures/example.com/key.json +0 -7
  146. package/dist/fixtures/example.com/key2.json +0 -6
  147. package/dist/fixtures/example.com/object.json +0 -6
  148. package/dist/fixtures/example.com/orderedcollectionpage.json +0 -24
  149. package/dist/fixtures/example.com/paged/a.json +0 -13
  150. package/dist/fixtures/example.com/paged/b.json +0 -16
  151. package/dist/fixtures/example.com/paged-collection.json +0 -6
  152. package/dist/fixtures/example.com/person.json +0 -22
  153. package/dist/fixtures/example.com/person2.json +0 -40
  154. package/dist/fixtures/example.com/test.json +0 -5
  155. package/dist/fixtures/example.com/users/handle.json +0 -16
  156. package/dist/fixtures/example.com/wrong-type.json +0 -3
  157. package/dist/fixtures/oeee.cafe/ap/users/3609fd4e-d51d-4db8-9f04-4189815864dd.json +0 -24
  158. package/dist/fixtures/remote.domain/users/bob.json +0 -20
  159. package/dist/fixtures/server.example/users/alice.json +0 -20
  160. package/dist/fixtures/w3id.org/identity/v1.json +0 -152
  161. package/dist/fixtures/w3id.org/security/data-integrity/v1.json +0 -74
  162. package/dist/fixtures/w3id.org/security/multikey/v1.json +0 -35
  163. package/dist/fixtures/w3id.org/security/v1.json +0 -50
  164. package/dist/fixtures/wizard.casa/users/hongminhee.json +0 -69
  165. package/dist/fixtures/www.w3.org/ns/activitystreams.json +0 -379
  166. package/dist/fixtures/www.w3.org/ns/did/v1.json +0 -58
  167. package/dist/key-CGjkGPkw.js +0 -260
  168. package/dist/key-CaFAQSic.js +0 -10
  169. package/dist/key-DcnCet42.js +0 -10
  170. package/dist/lookup-B8Ld9P9G.js +0 -131
  171. package/dist/lookup-IyAhz9I6.js +0 -322
  172. package/dist/middleware-Bx6Sgkth.js +0 -26
  173. package/dist/middleware-DdRB1d4s.js +0 -17
  174. package/dist/mod-Cxt4Kpf6.d.ts +0 -291
  175. package/dist/mod-DBzN0aCM.d.ts +0 -115
  176. package/dist/mod-TFoH2Ql8.d.ts +0 -104
  177. package/dist/mod-g0xFzAP9.d.ts +0 -2
  178. package/dist/mq-CRGm1e_F.d.ts +0 -143
  179. package/dist/nodeinfo/semver.test.js +0 -143
  180. package/dist/nodeinfo-CyEbLjHs.js +0 -4
  181. package/dist/runtime/docloader.test.js +0 -522
  182. package/dist/runtime/key.test.js +0 -103
  183. package/dist/runtime/langstr.test.js +0 -39
  184. package/dist/runtime/mod.d.ts +0 -8
  185. package/dist/runtime/mod.js +0 -13
  186. package/dist/runtime/multibase/multibase.test.d.ts +0 -3
  187. package/dist/runtime/multibase/multibase.test.js +0 -358
  188. package/dist/runtime/url.test.d.ts +0 -3
  189. package/dist/runtime/url.test.js +0 -45
  190. package/dist/runtime-BSkOVUWM.js +0 -4
  191. package/dist/semver-dArNLkR9.js +0 -149
  192. package/dist/sig-BXJO--F9.js +0 -4
  193. package/dist/src/vocab/accept.yaml +0 -15
  194. package/dist/src/vocab/activity.yaml +0 -98
  195. package/dist/src/vocab/add.yaml +0 -16
  196. package/dist/src/vocab/announce.yaml +0 -30
  197. package/dist/src/vocab/application.yaml +0 -324
  198. package/dist/src/vocab/arrive.yaml +0 -15
  199. package/dist/src/vocab/article.yaml +0 -46
  200. package/dist/src/vocab/audio.yaml +0 -11
  201. package/dist/src/vocab/block.yaml +0 -16
  202. package/dist/src/vocab/chatmessage.yaml +0 -50
  203. package/dist/src/vocab/collection.yaml +0 -154
  204. package/dist/src/vocab/collectionpage.yaml +0 -55
  205. package/dist/src/vocab/create.yaml +0 -28
  206. package/dist/src/vocab/dataintegrityproof.yaml +0 -56
  207. package/dist/src/vocab/delete.yaml +0 -27
  208. package/dist/src/vocab/didservice.yaml +0 -22
  209. package/dist/src/vocab/dislike.yaml +0 -14
  210. package/dist/src/vocab/document.yaml +0 -31
  211. package/dist/src/vocab/emoji.yaml +0 -12
  212. package/dist/src/vocab/emojireact.yaml +0 -17
  213. package/dist/src/vocab/endpoints.yaml +0 -85
  214. package/dist/src/vocab/event.yaml +0 -11
  215. package/dist/src/vocab/export.yaml +0 -9
  216. package/dist/src/vocab/flag.yaml +0 -15
  217. package/dist/src/vocab/follow.yaml +0 -19
  218. package/dist/src/vocab/group.yaml +0 -324
  219. package/dist/src/vocab/hashtag.yaml +0 -14
  220. package/dist/src/vocab/ignore.yaml +0 -14
  221. package/dist/src/vocab/image.yaml +0 -9
  222. package/dist/src/vocab/intransitiveactivity.yaml +0 -15
  223. package/dist/src/vocab/invite.yaml +0 -14
  224. package/dist/src/vocab/join.yaml +0 -14
  225. package/dist/src/vocab/key.yaml +0 -28
  226. package/dist/src/vocab/leave.yaml +0 -14
  227. package/dist/src/vocab/like.yaml +0 -16
  228. package/dist/src/vocab/link.yaml +0 -101
  229. package/dist/src/vocab/listen.yaml +0 -12
  230. package/dist/src/vocab/mention.yaml +0 -9
  231. package/dist/src/vocab/move.yaml +0 -15
  232. package/dist/src/vocab/multikey.yaml +0 -36
  233. package/dist/src/vocab/note.yaml +0 -48
  234. package/dist/src/vocab/object.yaml +0 -404
  235. package/dist/src/vocab/offer.yaml +0 -15
  236. package/dist/src/vocab/orderedcollection.yaml +0 -39
  237. package/dist/src/vocab/orderedcollectionpage.yaml +0 -50
  238. package/dist/src/vocab/organization.yaml +0 -324
  239. package/dist/src/vocab/page.yaml +0 -11
  240. package/dist/src/vocab/person.yaml +0 -324
  241. package/dist/src/vocab/place.yaml +0 -75
  242. package/dist/src/vocab/profile.yaml +0 -26
  243. package/dist/src/vocab/propertyvalue.yaml +0 -32
  244. package/dist/src/vocab/question.yaml +0 -103
  245. package/dist/src/vocab/read.yaml +0 -13
  246. package/dist/src/vocab/reject.yaml +0 -14
  247. package/dist/src/vocab/relationship.yaml +0 -52
  248. package/dist/src/vocab/remove.yaml +0 -14
  249. package/dist/src/vocab/service.yaml +0 -324
  250. package/dist/src/vocab/source.yaml +0 -26
  251. package/dist/src/vocab/tentativeaccept.yaml +0 -14
  252. package/dist/src/vocab/tentativereject.yaml +0 -14
  253. package/dist/src/vocab/tombstone.yaml +0 -24
  254. package/dist/src/vocab/travel.yaml +0 -16
  255. package/dist/src/vocab/undo.yaml +0 -26
  256. package/dist/src/vocab/update.yaml +0 -58
  257. package/dist/src/vocab/video.yaml +0 -11
  258. package/dist/src/vocab/view.yaml +0 -13
  259. package/dist/testing/docloader.test.js +0 -24
  260. package/dist/type-BMGxK0zE.js +0 -42006
  261. package/dist/vocab/actor.test.d.ts +0 -3
  262. package/dist/vocab/actor.test.js +0 -5965
  263. package/dist/vocab/lookup.test.d.ts +0 -3
  264. package/dist/vocab/lookup.test.js +0 -206
  265. package/dist/vocab/mod.d.ts +0 -8
  266. package/dist/vocab/mod.js +0 -10
  267. package/dist/vocab/schema.yaml +0 -247
  268. package/dist/vocab/type.test.d.ts +0 -3
  269. package/dist/vocab/type.test.js +0 -25
  270. package/dist/vocab/vocab.test.d.ts +0 -3
  271. package/dist/vocab/vocab.test.js +0 -3363
  272. package/dist/vocab-CXuKLJjd.js +0 -246
  273. package/dist/vocab-SOE1ifCr.d.ts +0 -14634
  274. package/dist/webfinger/handler.test.d.ts +0 -3
  275. package/dist/webfinger/lookup.test.d.ts +0 -3
  276. package/dist/webfinger/lookup.test.js +0 -195
  277. package/dist/webfinger/mod.d.ts +0 -6
  278. package/dist/webfinger/mod.js +0 -9
  279. package/dist/webfinger-C3GIyXIg.js +0 -4
  280. package/dist/x/cfworkers.d.ts +0 -61
  281. package/dist/x/cfworkers.js +0 -98
  282. package/dist/x/cfworkers.test.d.ts +0 -3
  283. package/dist/x/cfworkers.test.js +0 -179
  284. package/dist/x/hono.d.ts +0 -56
  285. package/dist/x/hono.js +0 -60
  286. package/dist/x/sveltekit.d.ts +0 -48
  287. package/dist/x/sveltekit.js +0 -68
  288. /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
  289. /package/dist/{collection-CSzG2j1P.js → collection-CcnIw1qY.js} +0 -0
  290. /package/dist/{nodeinfo/semver.test.d.ts → federation/idempotency.test.d.ts} +0 -0
  291. /package/dist/{runtime/authdocloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
  292. /package/dist/{runtime/docloader.test.d.ts → federation/webfinger.test.d.ts} +0 -0
  293. /package/dist/{mod-1pDWKvUL.d.ts → mod-1E3W847c.d.ts} +0 -0
  294. /package/dist/{runtime/key.test.d.ts → otel/exporter.test.d.ts} +0 -0
  295. /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
  296. /package/dist/{testing → utils}/docloader.test.d.ts +0 -0
  297. /package/dist/{runtime/langstr.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
@@ -1,16 +1,13 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { KvKey, KvStore } from "./kv-C7sopW2E.js";
4
- import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "./docloader-CxWcuWqQ.js";
5
- import { GetNodeInfoOptions, JsonValue, NodeInfo } from "./client-DF8anIB5.js";
6
- import { Activity, Collection, CryptographicKey, Hashtag, Link, Multikey, Object as Object$1 } from "./vocab-SOE1ifCr.js";
7
- import { Actor, Recipient } from "./actor-C22bXuuC.js";
8
- import { HttpMessageSignaturesSpec } from "./http-DqSNLFNY.js";
9
- import { GetKeyOwnerOptions } from "./owner-CQPnQVtf.js";
10
- import { LookupObjectOptions, TraverseCollectionOptions } from "./mod-Cxt4Kpf6.js";
11
- import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "./mod-DBzN0aCM.js";
12
- import { MessageQueue } from "./mq-CRGm1e_F.js";
13
- import { Span, TracerProvider } from "@opentelemetry/api";
3
+ import { GetNodeInfoOptions, JsonValue, NodeInfo } from "./client-BivSNrEg.js";
4
+ import { HttpMessageSignaturesSpec } from "./http-DLBDPal9.js";
5
+ import { GetKeyOwnerOptions } from "./owner-BgI8C-VY.js";
6
+ import { KvKey, KvStore } from "./kv-CtOmTRNc.js";
7
+ import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, TraverseCollectionOptions } from "@fedify/vocab";
8
+ import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
9
+ import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
10
+ import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
14
11
 
15
12
  //#region src/compat/types.d.ts
16
13
  /**
@@ -283,7 +280,7 @@ type ObjectAuthorizePredicate<TContextData, TParam extends string> = (context: R
283
280
  * the entire collection without pagination.
284
281
  * @since 1.8.0
285
282
  */
286
- type CustomCollectionDispatcher<TItem, TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: TParams, cursor: string | null) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>;
283
+ type CustomCollectionDispatcher<TItem, TParam extends string, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: Record<TParam, string>, cursor: string | null) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>;
287
284
  /**
288
285
  * A callback that counts the number of items in a custom collection.
289
286
  *
@@ -293,7 +290,7 @@ type CustomCollectionDispatcher<TItem, TParams extends Record<string, string>, T
293
290
  * @param values The parameters of the requested URL.
294
291
  * @since 1.8.0
295
292
  */
296
- type CustomCollectionCounter<TParams extends Record<string, string>, TContextData> = (context: RequestContext<TContextData>, values: TParams) => number | bigint | null | Promise<number | bigint | null>;
293
+ type CustomCollectionCounter<TParam extends string, TContextData> = (context: RequestContext<TContextData>, values: Record<TParam, string>) => number | bigint | null | Promise<number | bigint | null>;
297
294
  /**
298
295
  * A callback that returns a cursor for a custom collection.
299
296
  *
@@ -306,10 +303,148 @@ type CustomCollectionCounter<TParams extends Record<string, string>, TContextDat
306
303
  * @param values The parameters of the requested URL.
307
304
  * @since 1.8.0
308
305
  */
309
- type CustomCollectionCursor<TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: TParams) => string | null | Promise<string | null>;
306
+ type CustomCollectionCursor<TParam extends string, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: Record<TParam, string>) => string | null | Promise<string | null>;
307
+ //#endregion
308
+ //#region src/federation/mq.d.ts
309
+ /**
310
+ * Additional options for enqueuing a message in a queue.
311
+ *
312
+ * @since 0.5.0
313
+ */
314
+ interface MessageQueueEnqueueOptions {
315
+ /**
316
+ * The delay before the message is enqueued. No delay by default.
317
+ *
318
+ * It must not be negative.
319
+ */
320
+ delay?: Temporal.Duration;
321
+ }
322
+ /**
323
+ * Additional options for listening to a message queue.
324
+ *
325
+ * @since 1.0.0
326
+ */
327
+ interface MessageQueueListenOptions {
328
+ /**
329
+ * The signal to abort listening to the message queue.
330
+ */
331
+ signal?: AbortSignal;
332
+ }
333
+ /**
334
+ * An abstract interface for a message queue.
335
+ *
336
+ * @since 0.5.0
337
+ */
338
+ interface MessageQueue {
339
+ /**
340
+ * Whether the message queue backend provides native retry mechanisms.
341
+ * When `true`, Fedify will skip its own retry logic and rely on the backend
342
+ * to handle retries. When `false` or omitted, Fedify will handle retries
343
+ * using its own retry policies.
344
+ *
345
+ * @default `false`
346
+ * @since 1.7.0
347
+ */
348
+ readonly nativeRetrial?: boolean;
349
+ /**
350
+ * Enqueues a message in the queue.
351
+ * @param message The message to enqueue.
352
+ * @param options Additional options for enqueuing the message.
353
+ */
354
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
355
+ /**
356
+ * Enqueues multiple messages in the queue. This operation is optional,
357
+ * and may not be supported by all implementations. If not supported,
358
+ * Fedify will invoke {@link enqueue} for each message.
359
+ *
360
+ * @param messages The messages to enqueue.
361
+ * @param options Additional options for enqueuing the messages.
362
+ */
363
+ enqueueMany?: (messages: any[], options?: MessageQueueEnqueueOptions) => Promise<void>;
364
+ /**
365
+ * Listens for messages in the queue.
366
+ * @param handler The handler for messages in the queue.
367
+ * @param options Additional options for listening to the message queue.
368
+ * @returns A promise that resolves when the listening is done. It never
369
+ * rejects, and is resolved when the signal is aborted. If no
370
+ * signal is provided, it never resolves.
371
+ */
372
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
373
+ }
374
+ /**
375
+ * Additional options for {@link InProcessMessageQueue}.
376
+ * @since 1.0.0
377
+ */
378
+ interface InProcessMessageQueueOptions {
379
+ /**
380
+ * The interval to poll for messages in the queue. 5 seconds by default.
381
+ * @default `{ seconds: 5 }`
382
+ */
383
+ pollInterval?: Temporal.Duration | Temporal.DurationLike;
384
+ }
385
+ /**
386
+ * A message queue that processes messages in the same process.
387
+ * Do not use this in production as it does neither persist messages nor
388
+ * distribute them across multiple processes.
389
+ *
390
+ * @since 0.5.0
391
+ */
392
+ declare class InProcessMessageQueue implements MessageQueue {
393
+ #private;
394
+ /**
395
+ * In-process message queue does not provide native retry mechanisms.
396
+ * @since 1.7.0
397
+ */
398
+ readonly nativeRetrial = false;
399
+ /**
400
+ * Constructs a new {@link InProcessMessageQueue} with the given options.
401
+ * @param options Additional options for the in-process message queue.
402
+ */
403
+ constructor(options?: InProcessMessageQueueOptions);
404
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
405
+ enqueueMany(messages: any[], options?: MessageQueueEnqueueOptions): Promise<void>;
406
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
407
+ }
408
+ /**
409
+ * A message queue that processes messages in parallel. It takes another
410
+ * {@link MessageQueue}, and processes messages in parallel up to a certain
411
+ * number of workers.
412
+ *
413
+ * Actually, it's rather a decorator than a queue itself.
414
+ *
415
+ * Note that the workers do not run in truly parallel, in the sense that they
416
+ * are not running in separate threads or processes. They are running in the
417
+ * same process, but are scheduled to run in parallel. Hence, this is useful
418
+ * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
419
+ * workloads.
420
+ *
421
+ * @since 1.0.0
422
+ */
423
+ declare class ParallelMessageQueue implements MessageQueue {
424
+ #private;
425
+ readonly queue: MessageQueue;
426
+ readonly workers: number;
427
+ /**
428
+ * Inherits the native retry capability from the wrapped queue.
429
+ * @since 1.7.0
430
+ */
431
+ readonly nativeRetrial?: boolean;
432
+ /**
433
+ * Constructs a new {@link ParallelMessageQueue} with the given queue and
434
+ * number of workers.
435
+ * @param queue The message queue to use under the hood. Note that
436
+ * {@link ParallelMessageQueue} cannot be nested.
437
+ * @param workers The number of workers to process messages in parallel.
438
+ * @throws {TypeError} If the given queue is an instance of
439
+ * {@link ParallelMessageQueue}.
440
+ */
441
+ constructor(queue: MessageQueue, workers: number);
442
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
443
+ enqueueMany(messages: any[], options?: MessageQueueEnqueueOptions): Promise<void>;
444
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
445
+ }
310
446
  //#endregion
311
447
  //#region src/federation/handler.d.ts
312
-
313
448
  /**
314
449
  * Options for the {@link respondWithObject} and
315
450
  * {@link respondWithObjectIfAcceptable} functions.
@@ -704,7 +839,7 @@ interface Federatable<TContextData> {
704
839
  * @returns An object with methods to set other actor dispatcher callbacks.
705
840
  * @throws {RouterError} Thrown if the path pattern is invalid.
706
841
  */
707
- setActorDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: ActorDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
842
+ setActorDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}` | `${string}${Rfc6570Expression<"handle">}${string}`, dispatcher: ActorDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
708
843
  /**
709
844
  * Registers an object dispatcher.
710
845
  *
@@ -718,9 +853,7 @@ interface Federatable<TContextData> {
718
853
  * must have one or more variables.
719
854
  * @param dispatcher An object dispatcher callback to register.
720
855
  */
721
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
722
- typeId: URL;
723
- }, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
856
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
724
857
  /**
725
858
  * Registers an object dispatcher.
726
859
  *
@@ -734,9 +867,7 @@ interface Federatable<TContextData> {
734
867
  * must have one or more variables.
735
868
  * @param dispatcher An object dispatcher callback to register.
736
869
  */
737
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
738
- typeId: URL;
739
- }, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
870
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
740
871
  /**
741
872
  * Registers an object dispatcher.
742
873
  *
@@ -750,9 +881,7 @@ interface Federatable<TContextData> {
750
881
  * must have one or more variables.
751
882
  * @param dispatcher An object dispatcher callback to register.
752
883
  */
753
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
754
- typeId: URL;
755
- }, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
884
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
756
885
  /**
757
886
  * Registers an object dispatcher.
758
887
  *
@@ -766,9 +895,7 @@ interface Federatable<TContextData> {
766
895
  * must have one or more variables.
767
896
  * @param dispatcher An object dispatcher callback to register.
768
897
  */
769
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
770
- typeId: URL;
771
- }, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
898
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
772
899
  /**
773
900
  * Registers an object dispatcher.
774
901
  *
@@ -782,9 +909,7 @@ interface Federatable<TContextData> {
782
909
  * must have one or more variables.
783
910
  * @param dispatcher An object dispatcher callback to register.
784
911
  */
785
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
786
- typeId: URL;
787
- }, path: `${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
912
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
788
913
  /**
789
914
  * Registers an object dispatcher.
790
915
  *
@@ -798,9 +923,7 @@ interface Federatable<TContextData> {
798
923
  * must have one or more variables.
799
924
  * @param dispatcher An object dispatcher callback to register.
800
925
  */
801
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
802
- typeId: URL;
803
- }, path: `${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
926
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
804
927
  /**
805
928
  * Registers an inbox dispatcher.
806
929
  *
@@ -812,7 +935,7 @@ interface Federatable<TContextData> {
812
935
  * @param dispatcher An inbox dispatcher callback to register.
813
936
  * @throws {@link RouterError} Thrown if the path pattern is invalid.
814
937
  */
815
- setInboxDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
938
+ setInboxDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}` | `${string}${Rfc6570Expression<"handle">}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
816
939
  /**
817
940
  * Registers an outbox dispatcher.
818
941
  *
@@ -836,7 +959,7 @@ interface Federatable<TContextData> {
836
959
  * @param dispatcher An outbox dispatcher callback to register.
837
960
  * @throws {@link RouterError} Thrown if the path pattern is invalid.
838
961
  */
839
- setOutboxDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
962
+ setOutboxDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}` | `${string}${Rfc6570Expression<"handle">}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
840
963
  /**
841
964
  * Registers a following collection dispatcher.
842
965
  * @param path The URI path pattern for the following collection. The syntax
@@ -848,7 +971,7 @@ interface Federatable<TContextData> {
848
971
  * callbacks.
849
972
  * @throws {RouterError} Thrown if the path pattern is invalid.
850
973
  */
851
- setFollowingDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Actor | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
974
+ setFollowingDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}` | `${string}${Rfc6570Expression<"handle">}${string}`, dispatcher: CollectionDispatcher<Actor | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
852
975
  /**
853
976
  * Registers a followers collection dispatcher.
854
977
  * @param path The URI path pattern for the followers collection. The syntax
@@ -860,7 +983,7 @@ interface Federatable<TContextData> {
860
983
  * callbacks.
861
984
  * @throws {@link RouterError} Thrown if the path pattern is invalid.
862
985
  */
863
- setFollowersDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Recipient, Context<TContextData>, TContextData, URL>): CollectionCallbackSetters<Context<TContextData>, TContextData, URL>;
986
+ setFollowersDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}` | `${string}${Rfc6570Expression<"handle">}${string}`, dispatcher: CollectionDispatcher<Recipient, Context<TContextData>, TContextData, URL>): CollectionCallbackSetters<Context<TContextData>, TContextData, URL>;
864
987
  /**
865
988
  * Registers a liked collection dispatcher.
866
989
  * @param path The URI path pattern for the liked collection. The syntax
@@ -872,7 +995,7 @@ interface Federatable<TContextData> {
872
995
  * callbacks.
873
996
  * @throws {@link RouterError} Thrown if the path pattern is invalid.
874
997
  */
875
- setLikedDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Object$1 | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
998
+ setLikedDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}` | `${string}${Rfc6570Expression<"handle">}${string}`, dispatcher: CollectionDispatcher<Object$1 | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
876
999
  /**
877
1000
  * Registers a featured collection dispatcher.
878
1001
  * @param path The URI path pattern for the featured collection. The syntax
@@ -884,7 +1007,7 @@ interface Federatable<TContextData> {
884
1007
  * callbacks.
885
1008
  * @throws {@link RouterError} Thrown if the path pattern is invalid.
886
1009
  */
887
- setFeaturedDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Object$1, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
1010
+ setFeaturedDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}` | `${string}${Rfc6570Expression<"handle">}${string}`, dispatcher: CollectionDispatcher<Object$1, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
888
1011
  /**
889
1012
  * Registers a featured tags collection dispatcher.
890
1013
  * @param path The URI path pattern for the featured tags collection.
@@ -896,7 +1019,7 @@ interface Federatable<TContextData> {
896
1019
  * callbacks.
897
1020
  * @throws {@link RouterError} Thrown if the path pattern is invalid.
898
1021
  */
899
- setFeaturedTagsDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Hashtag, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
1022
+ setFeaturedTagsDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}` | `${string}${Rfc6570Expression<"handle">}${string}`, dispatcher: CollectionDispatcher<Hashtag, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
900
1023
  /**
901
1024
  * Assigns the URL path for the inbox and starts setting inbox listeners.
902
1025
  *
@@ -926,7 +1049,37 @@ interface Federatable<TContextData> {
926
1049
  * @returns An object to register inbox listeners.
927
1050
  * @throws {RouteError} Thrown if the path pattern is invalid.
928
1051
  */
929
- setInboxListeners(inboxPath: `${string}{identifier}${string}` | `${string}{handle}${string}`, sharedInboxPath?: string): InboxListenerSetters<TContextData>;
1052
+ setInboxListeners(inboxPath: `${string}${Rfc6570Expression<"identifier">}${string}` | `${string}${Rfc6570Expression<"handle">}${string}`, sharedInboxPath?: string): InboxListenerSetters<TContextData>;
1053
+ /**
1054
+ * Registers a collection of objects dispatcher.
1055
+ *
1056
+ * @template TContextData The context data to pass to the {@link Context}.
1057
+ * @template TObject The type of objects to dispatch.
1058
+ * @template TParam The parameter names of the requested URL.
1059
+ * @param name A unique name for the collection dispatcher.
1060
+ * @param itemType The Activity Vocabulary class of the object to dispatch.
1061
+ * @param path The URI path pattern for the collection dispatcher.
1062
+ * The syntax is based on URI Template
1063
+ * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1064
+ * The path must have one or more variables.
1065
+ * @param dispatcher A collection dispatcher callback to register.
1066
+ */
1067
+ setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
1068
+ /**
1069
+ * Registers a collection of objects dispatcher.
1070
+ *
1071
+ * @template TContextData The context data to pass to the {@link Context}.
1072
+ * @template TObject The type of objects to dispatch.
1073
+ * @template TParam The parameter names of the requested URL.
1074
+ * @param name A unique name for the collection dispatcher.
1075
+ * @param itemType The Activity Vocabulary class of the object to dispatch.
1076
+ * @param path The URI path pattern for the collection dispatcher.
1077
+ * The syntax is based on URI Template
1078
+ * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1079
+ * The path must have one or more variables.
1080
+ * @param dispatcher A collection dispatcher callback to register.
1081
+ */
1082
+ setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
930
1083
  /**
931
1084
  * Registers a collection of objects dispatcher.
932
1085
  *
@@ -941,7 +1094,37 @@ interface Federatable<TContextData> {
941
1094
  * The path must have one or more variables.
942
1095
  * @param dispatcher A collection dispatcher callback to register.
943
1096
  */
944
- setCollectionDispatcher<TObject extends Object$1, TParams extends Record<string, string>>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: ParamsKeyPath<TParams>, dispatcher: CustomCollectionDispatcher<TObject, TParams, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParams, RequestContext<TContextData>, TContextData>;
1097
+ setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
1098
+ /**
1099
+ * Registers an ordered collection of objects dispatcher.
1100
+ *
1101
+ * @template TContextData The context data to pass to the {@link Context}.
1102
+ * @template TObject The type of objects to dispatch.
1103
+ * @template TParam The parameter names of the requested URL.
1104
+ * @param name A unique name for the collection dispatcher.
1105
+ * @param itemType The Activity Vocabulary class of the object to dispatch.
1106
+ * @param path The URI path pattern for the collection dispatcher.
1107
+ * The syntax is based on URI Template
1108
+ * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1109
+ * The path must have one or more variables.
1110
+ * @param dispatcher A collection dispatcher callback to register.
1111
+ */
1112
+ setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
1113
+ /**
1114
+ * Registers an ordered collection of objects dispatcher.
1115
+ *
1116
+ * @template TContextData The context data to pass to the {@link Context}.
1117
+ * @template TObject The type of objects to dispatch.
1118
+ * @template TParam The parameter names of the requested URL.
1119
+ * @param name A unique name for the collection dispatcher.
1120
+ * @param itemType The Activity Vocabulary class of the object to dispatch.
1121
+ * @param path The URI path pattern for the collection dispatcher.
1122
+ * The syntax is based on URI Template
1123
+ * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1124
+ * The path must have one or more variables.
1125
+ * @param dispatcher A collection dispatcher callback to register.
1126
+ */
1127
+ setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
945
1128
  /**
946
1129
  * Registers an ordered collection of objects dispatcher.
947
1130
  *
@@ -956,7 +1139,7 @@ interface Federatable<TContextData> {
956
1139
  * The path must have one or more variables.
957
1140
  * @param dispatcher A collection dispatcher callback to register.
958
1141
  */
959
- setOrderedCollectionDispatcher<TObject extends Object$1, TParams extends Record<string, string>>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: ParamsKeyPath<TParams>, dispatcher: CustomCollectionDispatcher<TObject, TParams, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParams, RequestContext<TContextData>, TContextData>;
1142
+ setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
960
1143
  }
961
1144
  /**
962
1145
  * An object that registers federation-related business logic and dispatches
@@ -1092,12 +1275,6 @@ interface FederationOptions<TContextData> {
1092
1275
  * @since 1.4.0
1093
1276
  */
1094
1277
  contextLoaderFactory?: DocumentLoaderFactory;
1095
- /**
1096
- * A custom JSON-LD context loader. By default, this uses the same loader
1097
- * as the document loader.
1098
- * @deprecated Use {@link contextLoaderFactory} instead.
1099
- */
1100
- contextLoader?: DocumentLoader;
1101
1278
  /**
1102
1279
  * A factory function that creates an authenticated document loader for a
1103
1280
  * given identity. This is used for fetching documents that require
@@ -1306,6 +1483,36 @@ interface CollectionCallbackSetters<TContext extends Context<TContextData>, TCon
1306
1483
  */
1307
1484
  authorize(predicate: AuthorizePredicate<TContextData>): CollectionCallbackSetters<TContext, TContextData, TFilter>;
1308
1485
  }
1486
+ /**
1487
+ * The strategy for handling activity idempotency in inbox processing.
1488
+ *
1489
+ * - `"global"`: Activities are deduplicated globally across all inboxes and
1490
+ * origins. The same activity ID will be processed only once, regardless
1491
+ * of which inbox receives it or which server sent it.
1492
+ *
1493
+ * - `"per-origin"`: Activities are deduplicated per receiving server's origin.
1494
+ * The same activity ID will be processed only once on each receiving server,
1495
+ * but can be processed separately on different receiving servers. This had
1496
+ * been the default behavior in Fedify 1.x versions.
1497
+ *
1498
+ * - `"per-inbox"`: Activities are deduplicated per inbox. The same activity
1499
+ * ID can be processed once per inbox, allowing the same activity to be
1500
+ * delivered to multiple inboxes independently. This follows standard
1501
+ * ActivityPub behavior and is the default strategy since Fedify 2.0.0.
1502
+ *
1503
+ * @since 1.9.0
1504
+ */
1505
+ type IdempotencyStrategy = "global" | "per-origin" | "per-inbox";
1506
+ /**
1507
+ * A callback to generate a custom idempotency key for an activity.
1508
+ * Returns the cache key to use, or null to skip idempotency checking.
1509
+ * @template TContextData The context data to pass to the {@link InboxContext}.
1510
+ * @param ctx The inbox context.
1511
+ * @param activity The activity being processed.
1512
+ * @returns The idempotency key to use for caching, or null to skip caching.
1513
+ * @since 1.9.0
1514
+ */
1515
+ type IdempotencyKeyCallback<TContextData> = (ctx: InboxContext<TContextData>, activity: Activity) => string | null | Promise<string | null>;
1309
1516
  /**
1310
1517
  * Registry for inbox listeners for different activity types.
1311
1518
  */
@@ -1336,6 +1543,36 @@ interface InboxListenerSetters<TContextData> {
1336
1543
  * @since 0.11.0
1337
1544
  */
1338
1545
  setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
1546
+ /**
1547
+ * Configures the strategy for handling activity idempotency in inbox processing.
1548
+ *
1549
+ * @example
1550
+ * Use per-inbox strategy (standard ActivityPub behavior):
1551
+ * ```
1552
+ * federation
1553
+ * .setInboxListeners("/users/{identifier}/inbox", "/inbox")
1554
+ * .withIdempotency("per-inbox");
1555
+ * ```
1556
+ *
1557
+ * Use custom strategy:
1558
+ * ```
1559
+ * federation
1560
+ * .setInboxListeners("/users/{identifier}/inbox", "/inbox")
1561
+ * .withIdempotency((ctx, activity) => {
1562
+ * // Return null to skip idempotency
1563
+ * return `${ctx.origin}:${activity.id?.href}:${ctx.recipient}`;
1564
+ * });
1565
+ * ```
1566
+ *
1567
+ * @param strategy The idempotency strategy to use. Can be:
1568
+ * - `"global"`: Activities are deduplicated across all inboxes and origins
1569
+ * - `"per-origin"`: Activities are deduplicated per inbox origin
1570
+ * - `"per-inbox"`: Activities are deduplicated per inbox
1571
+ * - A custom callback function that returns the cache key to use
1572
+ * @returns The setters object so that settings can be chained.
1573
+ * @since 1.9.0
1574
+ */
1575
+ withIdempotency(strategy: IdempotencyStrategy | IdempotencyKeyCallback<TContextData>): InboxListenerSetters<TContextData>;
1339
1576
  }
1340
1577
  /**
1341
1578
  * Parameters of {@link Federation.fetch} method.
@@ -1374,38 +1611,38 @@ interface FederationFetchOptions<TContextData> {
1374
1611
  /**
1375
1612
  * Additional settings for a custom collection dispatcher.
1376
1613
  *
1377
- * @template TParams The type of the parameters in the URL path.
1614
+ * @template TParam The type of the parameters in the URL path.
1378
1615
  * @template TContext The type of the context. {@link Context} or
1379
1616
  * {@link RequestContext}.
1380
1617
  * @template TContextData The context data to pass to the {@link Context}.
1381
1618
  * @template TFilter The type of filter for the collection.
1382
1619
  */
1383
- interface CustomCollectionCallbackSetters<TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData> {
1620
+ interface CustomCollectionCallbackSetters<TParam extends string, TContext extends Context<TContextData>, TContextData> {
1384
1621
  /**
1385
1622
  * Sets the counter for the custom collection.
1386
1623
  * @param counter A callback that returns the number of items in the custom collection.
1387
1624
  * @returns The setters object so that settings can be chained.
1388
1625
  */
1389
- setCounter(counter: CustomCollectionCounter<TParams, TContextData>): CustomCollectionCallbackSetters<TParams, TContext, TContextData>;
1626
+ setCounter(counter: CustomCollectionCounter<TParam, TContextData>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
1390
1627
  /**
1391
1628
  * Sets the first cursor for the custom collection.
1392
1629
  * @param cursor The cursor for the first item in the custom collection.
1393
1630
  * @returns The setters object so that settings can be chained.
1394
1631
  */
1395
- setFirstCursor(cursor: CustomCollectionCursor<TParams, TContext, TContextData>): CustomCollectionCallbackSetters<TParams, TContext, TContextData>;
1632
+ setFirstCursor(cursor: CustomCollectionCursor<TParam, TContext, TContextData>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
1396
1633
  /**
1397
1634
  * Sets the last cursor for the custom collection.
1398
1635
  * @param cursor The cursor for the last item in the custom collection.
1399
1636
  * @returns The setters object so that settings can be chained.
1400
1637
  */
1401
- setLastCursor(cursor: CustomCollectionCursor<TParams, TContext, TContextData>): CustomCollectionCallbackSetters<TParams, TContext, TContextData>;
1638
+ setLastCursor(cursor: CustomCollectionCursor<TParam, TContext, TContextData>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
1402
1639
  /**
1403
1640
  * Specifies the conditions under which requests are authorized.
1404
1641
  * @param predicate A callback that returns whether a request is authorized.
1405
1642
  * @returns The setters object so that settings can be chained.
1406
1643
  * @since 0.7.0
1407
1644
  */
1408
- authorize(predicate: ObjectAuthorizePredicate<TContextData, string>): CustomCollectionCallbackSetters<TParams, TContext, TContextData>;
1645
+ authorize(predicate: ObjectAuthorizePredicate<TContextData, string>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
1409
1646
  }
1410
1647
  /**
1411
1648
  * Represents an object with a type ID, which is either a constructor or an
@@ -1417,73 +1654,34 @@ type ConstructorWithTypeId<TObject extends Object$1> = (new (...args: any[]) =>
1417
1654
  typeId: URL;
1418
1655
  };
1419
1656
  /**
1420
- * Represents a path from the key of parameter objects.
1421
- * @param Params - A record of parameters where keys are parameter names and
1422
- * values are their string representations.
1423
- * @returns A string representing the path with all parameters.
1424
- * @example
1425
- * ```ts
1426
- * type UserPostPath = ParamsKeyPath<{ userId: string; postId: string }>;
1427
- * let userPostPath: UserPostPath;
1428
- * // userPostPath = "/posts/{postId}"; // invalid - does not contain `{userId}`
1429
- * // userPostPath = "/users/{userId}"; // invalid - does not contain `{postId}`
1430
- * userPostPath = "/users/{userId}/posts/{postId}"; // valid
1431
- * userPostPath = "/posts/{postId}/users/{userId}"; // valid
1432
- * ```
1433
- */
1434
- type ParamsKeyPath<Params extends Record<string, string>> = ParamsPath<Extract<keyof Params, string>> & string;
1435
- /**
1436
- * Represents a path with multiple parameters.
1437
- * All permutations of the parameters are included in the union type.
1438
- * The path must have all parameters in the form of `{paramName}`.
1439
- * @param Params - A union of parameter names.
1440
- * @returns A string representing the path with all parameters.
1441
- * @example
1442
- * ```ts
1443
- * type UserPostPath = ParamsPath<"userId" | "postId">;
1444
- * // = `${string}{userId}${string}` & `${string}{postId}${string}`
1445
- * // =
1446
- * // | `${string}{userId}${string}{postId}${string}`
1447
- * // | `${string}{postId}${string}{userId}${string}`
1448
- * let userPostPath: UserPostPath;
1449
- * userPostPath = "/users/posts"; // ❌ invalid
1450
- * userPostPath = "/users/{userId}"; // ❌ invalid
1451
- * userPostPath = "/posts/{postId}"; // ❌ invalid
1452
- * userPostPath = "/users/{userId}/posts/{postId}"; // ✅ valid
1453
- * userPostPath = "/posts/{postId}/users/{userId}"; // ✅ valid
1454
- */
1455
- type ParamsPath<Params extends string> = UnionToIntersection<ParamPath<Params>>;
1456
- /**
1457
- * Represents a path with a single parameter.
1458
- * The path must have at least one of the parameters in the form of `{paramName}`.
1459
- * @param Param - The name of the parameter.
1460
- * @returns A string representing the path with the parameter.
1461
- * @example
1462
- * ```ts
1463
- * type UserPostPath = ParamPath<"userId" | "postId">;
1464
- * // = `${string}{userId}${string}` | `${string}{postId}${string}`
1465
- * let userPostPath: UserPostPath;
1466
- * userPostPath = "/users/posts"; // ❌ invalid
1467
- * userPostPath = "/users/{userId}"; // ✅ valid
1468
- * userPostPath = "/posts/{postId}"; // ✅ valid
1469
- * userPostPath = "/users/{userId}/posts/{postId}"; // ✅ valid
1470
- * userPostPath = "/posts/{postId}/users/{userId}"; // ✅ valid
1471
- */
1472
- type ParamPath<Param extends string> = `${string}{${Param}}${string}`;
1473
- /**
1474
- * Converts union types to intersection types.
1657
+ * Defines a union of all valid RFC 6570 URI Template expressions for a given
1658
+ * parameter name.
1659
+ *
1660
+ * RFC 6570 specifies a syntax for URI templates, allowing for variable
1661
+ * expansion. This type captures all Level 1-4 operator expressions for a
1662
+ * single, named variable.
1475
1663
  *
1476
- * @template U - The union type to convert.
1477
- * @returns The intersection type of the union.
1664
+ * The supported expression types are:
1665
+ * - `{Param}`: Simple string expansion
1666
+ * - `+{Param}`: Reserved string expansion
1667
+ * - `#{Param}`: Fragment expansion
1668
+ * - `{.Param}`: Label expansion with a dot-prefix
1669
+ * - `{/Param}`: Path segment expansion
1670
+ * - `{;Param}`: Path-style parameter expansion
1671
+ * - `{?Param}`: Query component expansion
1672
+ * - `{&Param}`: Query continuation expansion
1673
+ *
1674
+ * @template Param The name of the parameter to be used in the expressions.
1478
1675
  * @example
1479
1676
  * ```ts
1480
- * type A = { a: string };
1481
- * type B = { b: number };
1482
- * type AorB = A | B;
1483
- * type AandB = UnionToIntersection<AorB>;
1484
- * // AandB = { a: string; b: number }
1677
+ * type UserIdExpression = Rfc6570Expression<"userId">;
1678
+ *
1679
+ * // The variable `userPath` can be assigned any of the valid expressions.
1680
+ * const userPath: UserIdExpression = "{/userId}";
1681
+ * ```
1682
+ * @see {@link https://tools.ietf.org/html/rfc6570} for the full specification.
1485
1683
  */
1486
- type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never;
1684
+ type Rfc6570Expression<Param extends string> = `{${Param}}` | `{+${Param}}` | `{#${Param}}` | `{.${Param}}` | `{/${Param}}` | `{;${Param}}` | `{?${Param}}` | `{&${Param}}`;
1487
1685
  //#endregion
1488
1686
  //#region src/federation/context.d.ts
1489
1687
  /**
@@ -1572,9 +1770,7 @@ interface Context<TContextData> {
1572
1770
  * @throws {TypeError} If values are invalid.
1573
1771
  * @since 0.7.0
1574
1772
  */
1575
- getObjectUri<TObject extends Object$1>(cls: (new (...args: any[]) => TObject) & {
1576
- typeId: URL;
1577
- }, values: Record<string, string>): URL;
1773
+ getObjectUri<TObject extends Object$1>(cls: ConstructorWithTypeId<TObject>, values: Record<string, string>): URL;
1578
1774
  /**
1579
1775
  * Builds the URI of an actor's outbox with the given identifier.
1580
1776
  * @param identifier The actor's identifier.
@@ -1888,9 +2084,7 @@ interface RequestContext<TContextData> extends Context<TContextData> {
1888
2084
  * @throws {TypeError} If values are invalid.
1889
2085
  * @since 0.7.0
1890
2086
  */
1891
- getObject<TObject extends Object$1>(cls: (new (...args: any[]) => TObject) & {
1892
- typeId: URL;
1893
- }, values: Record<string, string>): Promise<TObject | null>;
2087
+ getObject<TObject extends Object$1>(cls: ConstructorWithTypeId<TObject>, values: Record<string, string>): Promise<TObject | null>;
1894
2088
  /**
1895
2089
  * Gets the public key of the sender, if any exists and it is verified.
1896
2090
  * Otherwise, `null` is returned.
@@ -2034,9 +2228,7 @@ type ParseUriResult =
2034
2228
  * The case of an object URI.
2035
2229
  */ | {
2036
2230
  readonly type: "object";
2037
- readonly class: (new (...args: any[]) => Object$1) & {
2038
- typeId: URL;
2039
- };
2231
+ readonly class: ConstructorWithTypeId<Object$1>;
2040
2232
  readonly typeId: URL;
2041
2233
  readonly values: Record<string, string>;
2042
2234
  }
@@ -2254,4 +2446,4 @@ interface ActorKeyPair extends CryptoKeyPair {
2254
2446
  multikey: Multikey;
2255
2447
  }
2256
2448
  //#endregion
2257
- export { ActivityTransformer, ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, Message, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParamsKeyPath, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
2449
+ export { ActivityTransformer, ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };