@fedify/fedify 2.3.0-dev.1119 → 2.3.0-dev.1137

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 (116) hide show
  1. package/README.md +3 -0
  2. package/dist/{assert-DikXweDx.mjs → assert-OguE97r2.mjs} +1 -1
  3. package/dist/{assert_instance_of-C4Ri6VuN.mjs → assert_instance_of-DBC5X09g.mjs} +1 -1
  4. package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-DkVK8oqV.mjs} +1 -1
  5. package/dist/{assert_rejects-DQP-q39h.mjs → assert_rejects-DN60FHPX.mjs} +2 -2
  6. package/dist/{assert_strict_equals-Dmjbg-bA.mjs → assert_strict_equals-XEgZAlrj.mjs} +1 -1
  7. package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-BOkhLGYc.mjs} +1 -1
  8. package/dist/{builder-Ond_h57y.mjs → builder-BCkBXxky.mjs} +60 -41
  9. package/dist/compat/mod.d.cts +1 -1
  10. package/dist/compat/mod.d.ts +1 -1
  11. package/dist/compat/outgoing-jsonld.test.mjs +3 -3
  12. package/dist/compat/public-audience.test.mjs +3 -3
  13. package/dist/compat/transformers.test.mjs +5 -5
  14. package/dist/{context-cSUMk2da.d.ts → context-DCtsSHDv.d.ts} +4 -293
  15. package/dist/{context-Ch-ZLyTQ.d.cts → context-DI2gRbyN.d.cts} +3 -294
  16. package/dist/{context-BAE7AKLA.mjs → context-DVoTs_wM.mjs} +1 -1
  17. package/dist/{deno-DVsHS7rA.mjs → deno-B_9yJW3w.mjs} +1 -1
  18. package/dist/{docloader-WsWfKaE5.mjs → docloader-BT89tyFr.mjs} +3 -3
  19. package/dist/federation/builder.test.mjs +138 -10
  20. package/dist/federation/collection.test.mjs +3 -3
  21. package/dist/federation/handler.test.mjs +12 -12
  22. package/dist/federation/idempotency.test.mjs +6 -6
  23. package/dist/federation/inbox.test.mjs +3 -3
  24. package/dist/federation/keycache.test.mjs +5 -5
  25. package/dist/federation/kv.test.mjs +3 -3
  26. package/dist/federation/metrics.test.mjs +231 -3
  27. package/dist/federation/middleware.test.mjs +88 -18
  28. package/dist/federation/mod.cjs +155 -3
  29. package/dist/federation/mod.d.cts +3 -2
  30. package/dist/federation/mod.d.ts +3 -2
  31. package/dist/federation/mod.js +153 -1
  32. package/dist/federation/mq.test.mjs +5 -5
  33. package/dist/federation/negotiation.test.mjs +4 -4
  34. package/dist/federation/retry.test.mjs +3 -3
  35. package/dist/federation/router.test.mjs +190 -9
  36. package/dist/federation/send.test.mjs +16 -16
  37. package/dist/federation/webfinger.test.mjs +5 -5
  38. package/dist/{getMachineId-bsd-BY01PL1n.mjs → getMachineId-bsd-etIyxDet.mjs} +1 -1
  39. package/dist/{getMachineId-darwin-Dr1gkBkp.mjs → getMachineId-darwin-D23zTf4g.mjs} +1 -1
  40. package/dist/{getMachineId-win-QEYwcJiy.mjs → getMachineId-win-Dpap6v5i.mjs} +1 -1
  41. package/dist/{http-CouJSFVK.js → http-CToqG5ap.js} +252 -20
  42. package/dist/{http-CubOB9wq.cjs → http-CWoeyogl.cjs} +263 -19
  43. package/dist/{http-DUV8ysti.mjs → http-Cyx5SNuu.mjs} +8 -6
  44. package/dist/{http-D6LP89UO.d.ts → http-VyDTd4G3.d.cts} +8 -1
  45. package/dist/{http-D6aw3j2U.d.cts → http-lf8Hsd91.d.ts} +8 -1
  46. package/dist/{key-BoWaYRHm.mjs → key-CkkMJBjF.mjs} +42 -17
  47. package/dist/{kv-cache-DBNpsneh.js → kv-cache-CuCn2xvM.js} +19 -2
  48. package/dist/{kv-cache-Dz31ATUT.cjs → kv-cache-DuEwFYcN.cjs} +19 -2
  49. package/dist/{kv-cache-DihufyAQ.mjs → kv-cache-VHFP42vY.mjs} +19 -1
  50. package/dist/{ld-B5K1mSuG.mjs → ld-k8yqD2a-.mjs} +3 -3
  51. package/dist/{metrics-C4attqv0.mjs → metrics-iRBg8jTk.mjs} +209 -2
  52. package/dist/{middleware-CmsDtIHI.cjs → middleware-BWLUrbS9.cjs} +137 -210
  53. package/dist/{middleware-BDKFRjue.mjs → middleware-CztxpARM.mjs} +1 -1
  54. package/dist/{middleware-Dtjz-hSk.js → middleware-D7FrhN9q.js} +101 -162
  55. package/dist/{middleware-t0jC8I99.mjs → middleware-DQEgdr83.mjs} +64 -36
  56. package/dist/{mod-BDhgfjP7.d.cts → mod-B0hW12_O.d.cts} +1 -1
  57. package/dist/mod-C504qevA.d.cts +173 -0
  58. package/dist/{mod-B-Lin9Sy.d.ts → mod-COIAjwRS.d.ts} +1 -1
  59. package/dist/{mod-DLrRb0dx.d.ts → mod-DFvNJcNb.d.ts} +54 -3
  60. package/dist/mod-wYfuXeDE.d.ts +173 -0
  61. package/dist/{mod-BR_BB0bh.d.cts → mod-yvIXFAEi.d.cts} +54 -3
  62. package/dist/mod.cjs +6 -6
  63. package/dist/mod.d.cts +6 -5
  64. package/dist/mod.d.ts +6 -5
  65. package/dist/mod.js +5 -5
  66. package/dist/mq-D-nlpY04.d.ts +208 -0
  67. package/dist/mq-D8uSFzxe.d.cts +208 -0
  68. package/dist/nodeinfo/client.test.mjs +4 -4
  69. package/dist/nodeinfo/handler.test.mjs +5 -5
  70. package/dist/nodeinfo/types.test.mjs +4 -4
  71. package/dist/otel/exporter.test.mjs +3 -3
  72. package/dist/{outgoing-jsonld-BNL8AC14.mjs → outgoing-jsonld-BgFLCJQ_.mjs} +1 -1
  73. package/dist/{owner-hDxI0ufu.mjs → owner-nmXdvXpc.mjs} +2 -2
  74. package/dist/{proof-BUWfVr6Q.cjs → proof-CcsIJLTn.cjs} +1 -1
  75. package/dist/{proof-DhVuz4bc.mjs → proof-DpwO1T4S.mjs} +5 -5
  76. package/dist/{proof-n60t8o9P.js → proof-NRmtrTDu.js} +1 -1
  77. package/dist/{send-BPhyR5Oo.mjs → send-DvX2tYyZ.mjs} +3 -3
  78. package/dist/sig/accept.test.mjs +1 -1
  79. package/dist/sig/http.test.mjs +13 -9
  80. package/dist/sig/key.test.mjs +104 -7
  81. package/dist/sig/ld.test.mjs +7 -7
  82. package/dist/sig/mod.cjs +2 -2
  83. package/dist/sig/mod.d.cts +2 -2
  84. package/dist/sig/mod.d.ts +2 -2
  85. package/dist/sig/mod.js +2 -2
  86. package/dist/sig/owner.test.mjs +6 -6
  87. package/dist/sig/proof.test.mjs +8 -8
  88. package/dist/{std__assert-BTEgfoJo.mjs → std__assert-BBjXFNOb.mjs} +4 -4
  89. package/dist/testing/mod.d.mts +1 -0
  90. package/dist/testing/mod.mjs +1 -1
  91. package/dist/utils/docloader.test.mjs +7 -7
  92. package/dist/utils/kv-cache.test.mjs +67 -2
  93. package/dist/utils/mod.cjs +1 -1
  94. package/dist/utils/mod.d.cts +1 -1
  95. package/dist/utils/mod.d.ts +1 -1
  96. package/dist/utils/mod.js +1 -1
  97. package/package.json +6 -7
  98. package/dist/mod-C6E8rkcz.d.ts +0 -63
  99. package/dist/mod-P9tE2WmM.d.cts +0 -63
  100. package/dist/router-BT_F5748.mjs +0 -114
  101. /package/dist/{accept-CgDcxvjV.mjs → accept-CceiKpCy.mjs} +0 -0
  102. /package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-tztVvlNb.mjs} +0 -0
  103. /package/dist/{assert_equals-Ew3jOFa3.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
  104. /package/dist/{client-Bneh_DYR.mjs → client-B_A6mfn3.mjs} +0 -0
  105. /package/dist/{collection-Cc3DVAhE.mjs → collection-CA3V5zyK.mjs} +0 -0
  106. /package/dist/{esm-sdtqOUPu.mjs → esm-BQRw925N.mjs} +0 -0
  107. /package/dist/{execAsync-Dxb7rNf3.mjs → execAsync-DCBrgFiV.mjs} +0 -0
  108. /package/dist/{getMachineId-linux-Bbhofx-s.mjs → getMachineId-linux-ObI47Hql.mjs} +0 -0
  109. /package/dist/{getMachineId-unsupported-dIOte2Ct.mjs → getMachineId-unsupported-Ddu-PFeh.mjs} +0 -0
  110. /package/dist/{keycache-BeU0LCII.mjs → keycache-BYMd8q7F.mjs} +0 -0
  111. /package/dist/{keys-CSYsOMFG.mjs → keys-C3kae-6B.mjs} +0 -0
  112. /package/dist/{kv-QHE0oeM3.mjs → kv-x2IvBUyq.mjs} +0 -0
  113. /package/dist/{negotiation-DDstyBvc.mjs → negotiation-CDW-_gUU.mjs} +0 -0
  114. /package/dist/{public-audience-c9zmYKgA.mjs → public-audience-N3pyOx2p.mjs} +0 -0
  115. /package/dist/{retry-_VvV0h9f.mjs → retry-v_sGLH1d.mjs} +0 -0
  116. /package/dist/{types-D09GN0uZ.mjs → types-BFowWFTT.mjs} +0 -0
@@ -0,0 +1,208 @@
1
+ /// <reference lib="esnext.temporal" />
2
+ //#region src/federation/mq.d.ts
3
+ /**
4
+ * Additional options for enqueuing a message in a queue.
5
+ *
6
+ * @since 0.5.0
7
+ */
8
+ interface MessageQueueEnqueueOptions {
9
+ /**
10
+ * The delay before the message is enqueued. No delay by default.
11
+ *
12
+ * It must not be negative.
13
+ */
14
+ readonly delay?: Temporal.Duration;
15
+ /**
16
+ * An optional key that ensures messages with the same ordering key are
17
+ * processed sequentially (one at a time). Messages with different ordering
18
+ * keys (or no ordering key) may be processed in parallel.
19
+ *
20
+ * This is useful for ensuring that related messages are processed in order,
21
+ * such as ensuring that a `Delete` activity is processed after a `Create`
22
+ * activity for the same object.
23
+ *
24
+ * @since 2.0.0
25
+ */
26
+ readonly orderingKey?: string;
27
+ }
28
+ /**
29
+ * Additional options for listening to a message queue.
30
+ *
31
+ * @since 1.0.0
32
+ */
33
+ interface MessageQueueListenOptions {
34
+ /**
35
+ * The signal to abort listening to the message queue.
36
+ */
37
+ signal?: AbortSignal;
38
+ }
39
+ /**
40
+ * The number of messages waiting in a message queue.
41
+ *
42
+ * @since 2.3.0
43
+ */
44
+ interface MessageQueueDepth {
45
+ /**
46
+ * The total number of messages still waiting in the backend queue.
47
+ *
48
+ * This does not include messages that have already been handed to a worker
49
+ * for processing.
50
+ */
51
+ readonly queued: number;
52
+ /**
53
+ * The number of queued messages eligible for immediate processing.
54
+ *
55
+ * Queue backends that cannot cheaply distinguish ready and delayed messages
56
+ * may omit this field.
57
+ */
58
+ readonly ready?: number;
59
+ /**
60
+ * The number of queued messages scheduled for later delivery.
61
+ *
62
+ * Queue backends that cannot cheaply distinguish ready and delayed messages
63
+ * may omit this field.
64
+ */
65
+ readonly delayed?: number;
66
+ }
67
+ /**
68
+ * An abstract interface for a message queue.
69
+ *
70
+ * @since 0.5.0
71
+ */
72
+ interface MessageQueue {
73
+ /**
74
+ * Whether the message queue backend provides native retry mechanisms.
75
+ * When `true`, Fedify will skip its own retry logic and rely on the backend
76
+ * to handle retries. When `false` or omitted, Fedify will handle retries
77
+ * using its own retry policies.
78
+ *
79
+ * @default `false`
80
+ * @since 1.7.0
81
+ */
82
+ readonly nativeRetrial?: boolean;
83
+ /**
84
+ * Enqueues a message in the queue.
85
+ * @param message The message to enqueue.
86
+ * @param options Additional options for enqueuing the message.
87
+ */
88
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
89
+ /**
90
+ * Enqueues multiple messages in the queue. This operation is optional,
91
+ * and may not be supported by all implementations. If not supported,
92
+ * Fedify will invoke {@link enqueue} for each message.
93
+ *
94
+ * @param messages The messages to enqueue.
95
+ * @param options Additional options for enqueuing the messages.
96
+ */
97
+ enqueueMany?: (messages: readonly any[], options?: MessageQueueEnqueueOptions) => Promise<void>;
98
+ /**
99
+ * Listens for messages in the queue.
100
+ * @param handler The handler for messages in the queue.
101
+ * @param options Additional options for listening to the message queue.
102
+ * @returns A promise that resolves when the listening is done. It never
103
+ * rejects, and is resolved when the signal is aborted. If no
104
+ * signal is provided, it never resolves.
105
+ */
106
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
107
+ /**
108
+ * Gets the number of messages waiting in the queue.
109
+ *
110
+ * This operation is optional, and may not be supported by all
111
+ * implementations. The returned counts exclude messages currently being
112
+ * handled by a worker.
113
+ *
114
+ * @since 2.3.0
115
+ */
116
+ getDepth?(): Promise<MessageQueueDepth>;
117
+ }
118
+ /**
119
+ * Additional options for {@link InProcessMessageQueue}.
120
+ * @since 1.0.0
121
+ */
122
+ interface InProcessMessageQueueOptions {
123
+ /**
124
+ * The interval to poll for messages in the queue. 5 seconds by default.
125
+ * @default `{ seconds: 5 }`
126
+ */
127
+ pollInterval?: Temporal.Duration | Temporal.DurationLike;
128
+ }
129
+ /**
130
+ * A message queue that processes messages in the same process.
131
+ * Do not use this in production as it does neither persist messages nor
132
+ * distribute them across multiple processes.
133
+ *
134
+ * @since 0.5.0
135
+ */
136
+ declare class InProcessMessageQueue implements MessageQueue {
137
+ #private;
138
+ /**
139
+ * In-process message queue does not provide native retry mechanisms.
140
+ * @since 1.7.0
141
+ */
142
+ readonly nativeRetrial = false;
143
+ /**
144
+ * Constructs a new {@link InProcessMessageQueue} with the given options.
145
+ * @param options Additional options for the in-process message queue.
146
+ */
147
+ constructor(options?: InProcessMessageQueueOptions);
148
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
149
+ enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
150
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
151
+ getDepth(): Promise<MessageQueueDepth>;
152
+ }
153
+ /**
154
+ * A message queue that processes messages in parallel. It takes another
155
+ * {@link MessageQueue}, and processes messages in parallel up to a certain
156
+ * number of workers.
157
+ *
158
+ * Actually, it's rather a decorator than a queue itself.
159
+ *
160
+ * Note that the workers do not run in truly parallel, in the sense that they
161
+ * are not running in separate threads or processes. They are running in the
162
+ * same process, but are scheduled to run in parallel. Hence, this is useful
163
+ * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
164
+ * workloads.
165
+ *
166
+ * When using `ParallelMessageQueue`, the ordering guarantee is preserved
167
+ * *only if* the underlying queue implementation delivers messages in a wrapper
168
+ * format that includes the `__fedify_ordering_key__` property. Currently,
169
+ * only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
170
+ * For other queue implementations (e.g., `InProcessMessageQueue`,
171
+ * `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
172
+ * `AmqpMessageQueue`), the ordering key cannot be detected by
173
+ * `ParallelMessageQueue`, so ordering guarantees are handled by those
174
+ * implementations directly rather than at the `ParallelMessageQueue` level.
175
+ *
176
+ * Messages with the same ordering key will never be processed concurrently
177
+ * by different workers, ensuring sequential processing within each key.
178
+ * Messages with different ordering keys (or no ordering key) can still be
179
+ * processed in parallel.
180
+ *
181
+ * @since 1.0.0
182
+ */
183
+ declare class ParallelMessageQueue implements MessageQueue {
184
+ #private;
185
+ readonly queue: MessageQueue;
186
+ readonly workers: number;
187
+ /**
188
+ * Inherits the native retry capability from the wrapped queue.
189
+ * @since 1.7.0
190
+ */
191
+ readonly nativeRetrial?: boolean;
192
+ readonly getDepth?: () => Promise<MessageQueueDepth>;
193
+ /**
194
+ * Constructs a new {@link ParallelMessageQueue} with the given queue and
195
+ * number of workers.
196
+ * @param queue The message queue to use under the hood. Note that
197
+ * {@link ParallelMessageQueue} cannot be nested.
198
+ * @param workers The number of workers to process messages in parallel.
199
+ * @throws {TypeError} If the given queue is an instance of
200
+ * {@link ParallelMessageQueue}.
201
+ */
202
+ constructor(queue: MessageQueue, workers: number);
203
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
204
+ enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
205
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
206
+ }
207
+ //#endregion
208
+ export { MessageQueueEnqueueOptions as a, MessageQueueDepth as i, InProcessMessageQueueOptions as n, MessageQueueListenOptions as o, MessageQueue as r, ParallelMessageQueue as s, InProcessMessageQueue as t };
@@ -0,0 +1,208 @@
1
+ /// <reference lib="esnext.temporal" />
2
+ //#region src/federation/mq.d.ts
3
+ /**
4
+ * Additional options for enqueuing a message in a queue.
5
+ *
6
+ * @since 0.5.0
7
+ */
8
+ interface MessageQueueEnqueueOptions {
9
+ /**
10
+ * The delay before the message is enqueued. No delay by default.
11
+ *
12
+ * It must not be negative.
13
+ */
14
+ readonly delay?: Temporal.Duration;
15
+ /**
16
+ * An optional key that ensures messages with the same ordering key are
17
+ * processed sequentially (one at a time). Messages with different ordering
18
+ * keys (or no ordering key) may be processed in parallel.
19
+ *
20
+ * This is useful for ensuring that related messages are processed in order,
21
+ * such as ensuring that a `Delete` activity is processed after a `Create`
22
+ * activity for the same object.
23
+ *
24
+ * @since 2.0.0
25
+ */
26
+ readonly orderingKey?: string;
27
+ }
28
+ /**
29
+ * Additional options for listening to a message queue.
30
+ *
31
+ * @since 1.0.0
32
+ */
33
+ interface MessageQueueListenOptions {
34
+ /**
35
+ * The signal to abort listening to the message queue.
36
+ */
37
+ signal?: AbortSignal;
38
+ }
39
+ /**
40
+ * The number of messages waiting in a message queue.
41
+ *
42
+ * @since 2.3.0
43
+ */
44
+ interface MessageQueueDepth {
45
+ /**
46
+ * The total number of messages still waiting in the backend queue.
47
+ *
48
+ * This does not include messages that have already been handed to a worker
49
+ * for processing.
50
+ */
51
+ readonly queued: number;
52
+ /**
53
+ * The number of queued messages eligible for immediate processing.
54
+ *
55
+ * Queue backends that cannot cheaply distinguish ready and delayed messages
56
+ * may omit this field.
57
+ */
58
+ readonly ready?: number;
59
+ /**
60
+ * The number of queued messages scheduled for later delivery.
61
+ *
62
+ * Queue backends that cannot cheaply distinguish ready and delayed messages
63
+ * may omit this field.
64
+ */
65
+ readonly delayed?: number;
66
+ }
67
+ /**
68
+ * An abstract interface for a message queue.
69
+ *
70
+ * @since 0.5.0
71
+ */
72
+ interface MessageQueue {
73
+ /**
74
+ * Whether the message queue backend provides native retry mechanisms.
75
+ * When `true`, Fedify will skip its own retry logic and rely on the backend
76
+ * to handle retries. When `false` or omitted, Fedify will handle retries
77
+ * using its own retry policies.
78
+ *
79
+ * @default `false`
80
+ * @since 1.7.0
81
+ */
82
+ readonly nativeRetrial?: boolean;
83
+ /**
84
+ * Enqueues a message in the queue.
85
+ * @param message The message to enqueue.
86
+ * @param options Additional options for enqueuing the message.
87
+ */
88
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
89
+ /**
90
+ * Enqueues multiple messages in the queue. This operation is optional,
91
+ * and may not be supported by all implementations. If not supported,
92
+ * Fedify will invoke {@link enqueue} for each message.
93
+ *
94
+ * @param messages The messages to enqueue.
95
+ * @param options Additional options for enqueuing the messages.
96
+ */
97
+ enqueueMany?: (messages: readonly any[], options?: MessageQueueEnqueueOptions) => Promise<void>;
98
+ /**
99
+ * Listens for messages in the queue.
100
+ * @param handler The handler for messages in the queue.
101
+ * @param options Additional options for listening to the message queue.
102
+ * @returns A promise that resolves when the listening is done. It never
103
+ * rejects, and is resolved when the signal is aborted. If no
104
+ * signal is provided, it never resolves.
105
+ */
106
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
107
+ /**
108
+ * Gets the number of messages waiting in the queue.
109
+ *
110
+ * This operation is optional, and may not be supported by all
111
+ * implementations. The returned counts exclude messages currently being
112
+ * handled by a worker.
113
+ *
114
+ * @since 2.3.0
115
+ */
116
+ getDepth?(): Promise<MessageQueueDepth>;
117
+ }
118
+ /**
119
+ * Additional options for {@link InProcessMessageQueue}.
120
+ * @since 1.0.0
121
+ */
122
+ interface InProcessMessageQueueOptions {
123
+ /**
124
+ * The interval to poll for messages in the queue. 5 seconds by default.
125
+ * @default `{ seconds: 5 }`
126
+ */
127
+ pollInterval?: Temporal.Duration | Temporal.DurationLike;
128
+ }
129
+ /**
130
+ * A message queue that processes messages in the same process.
131
+ * Do not use this in production as it does neither persist messages nor
132
+ * distribute them across multiple processes.
133
+ *
134
+ * @since 0.5.0
135
+ */
136
+ declare class InProcessMessageQueue implements MessageQueue {
137
+ #private;
138
+ /**
139
+ * In-process message queue does not provide native retry mechanisms.
140
+ * @since 1.7.0
141
+ */
142
+ readonly nativeRetrial = false;
143
+ /**
144
+ * Constructs a new {@link InProcessMessageQueue} with the given options.
145
+ * @param options Additional options for the in-process message queue.
146
+ */
147
+ constructor(options?: InProcessMessageQueueOptions);
148
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
149
+ enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
150
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
151
+ getDepth(): Promise<MessageQueueDepth>;
152
+ }
153
+ /**
154
+ * A message queue that processes messages in parallel. It takes another
155
+ * {@link MessageQueue}, and processes messages in parallel up to a certain
156
+ * number of workers.
157
+ *
158
+ * Actually, it's rather a decorator than a queue itself.
159
+ *
160
+ * Note that the workers do not run in truly parallel, in the sense that they
161
+ * are not running in separate threads or processes. They are running in the
162
+ * same process, but are scheduled to run in parallel. Hence, this is useful
163
+ * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
164
+ * workloads.
165
+ *
166
+ * When using `ParallelMessageQueue`, the ordering guarantee is preserved
167
+ * *only if* the underlying queue implementation delivers messages in a wrapper
168
+ * format that includes the `__fedify_ordering_key__` property. Currently,
169
+ * only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
170
+ * For other queue implementations (e.g., `InProcessMessageQueue`,
171
+ * `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
172
+ * `AmqpMessageQueue`), the ordering key cannot be detected by
173
+ * `ParallelMessageQueue`, so ordering guarantees are handled by those
174
+ * implementations directly rather than at the `ParallelMessageQueue` level.
175
+ *
176
+ * Messages with the same ordering key will never be processed concurrently
177
+ * by different workers, ensuring sequential processing within each key.
178
+ * Messages with different ordering keys (or no ordering key) can still be
179
+ * processed in parallel.
180
+ *
181
+ * @since 1.0.0
182
+ */
183
+ declare class ParallelMessageQueue implements MessageQueue {
184
+ #private;
185
+ readonly queue: MessageQueue;
186
+ readonly workers: number;
187
+ /**
188
+ * Inherits the native retry capability from the wrapped queue.
189
+ * @since 1.7.0
190
+ */
191
+ readonly nativeRetrial?: boolean;
192
+ readonly getDepth?: () => Promise<MessageQueueDepth>;
193
+ /**
194
+ * Constructs a new {@link ParallelMessageQueue} with the given queue and
195
+ * number of workers.
196
+ * @param queue The message queue to use under the hood. Note that
197
+ * {@link ParallelMessageQueue} cannot be nested.
198
+ * @param workers The number of workers to process messages in parallel.
199
+ * @throws {TypeError} If the given queue is an instance of
200
+ * {@link ParallelMessageQueue}.
201
+ */
202
+ constructor(queue: MessageQueue, workers: number);
203
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
204
+ enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
205
+ listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
206
+ }
207
+ //#endregion
208
+ export { MessageQueueEnqueueOptions as a, MessageQueueDepth as i, InProcessMessageQueueOptions as n, MessageQueueListenOptions as o, MessageQueue as r, ParallelMessageQueue as s, InProcessMessageQueue as t };
@@ -1,10 +1,10 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
- import "../std__assert-BTEgfoJo.mjs";
6
- import { t as esm_default } from "../esm-sdtqOUPu.mjs";
7
- import { a as parseProtocol, c as parseUsage, i as parseOutboundService, n as parseInboundService, o as parseServices, r as parseNodeInfo, s as parseSoftware, t as getNodeInfo } from "../client-Bneh_DYR.mjs";
4
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
+ import "../std__assert-BBjXFNOb.mjs";
6
+ import { t as esm_default } from "../esm-BQRw925N.mjs";
7
+ import { a as parseProtocol, c as parseUsage, i as parseOutboundService, n as parseInboundService, o as parseServices, r as parseNodeInfo, s as parseSoftware, t as getNodeInfo } from "../client-B_A6mfn3.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/nodeinfo/client.test.ts
10
10
  test("getNodeInfo()", async (t) => {
@@ -1,11 +1,11 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { r as createRequestContext } from "../context-BAE7AKLA.mjs";
5
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-BTEgfoJo.mjs";
7
- import { t as MemoryKvStore } from "../kv-QHE0oeM3.mjs";
8
- import { _ as handleNodeInfoJrd, g as handleNodeInfo, o as createFederation } from "../middleware-t0jC8I99.mjs";
4
+ import { r as createRequestContext } from "../context-DVoTs_wM.mjs";
5
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
6
+ import "../std__assert-BBjXFNOb.mjs";
7
+ import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
8
+ import { _ as handleNodeInfoJrd, g as handleNodeInfo, o as createFederation } from "../middleware-DQEgdr83.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  //#region src/nodeinfo/handler.test.ts
11
11
  test("handleNodeInfo()", async () => {
@@ -1,10 +1,10 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
- import "../std__assert-BTEgfoJo.mjs";
6
- import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
7
- import { t as nodeInfoToJson } from "../types-D09GN0uZ.mjs";
4
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
+ import "../std__assert-BBjXFNOb.mjs";
6
+ import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
7
+ import { t as nodeInfoToJson } from "../types-BFowWFTT.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/nodeinfo/types.test.ts
10
10
  test("nodeInfoToJson()", () => {
@@ -1,9 +1,9 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
- import "../std__assert-BTEgfoJo.mjs";
6
- import { t as MemoryKvStore } from "../kv-QHE0oeM3.mjs";
4
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
+ import "../std__assert-BBjXFNOb.mjs";
6
+ import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { ExportResultCode } from "@opentelemetry/core";
9
9
  import { SpanKind, SpanStatusCode, TraceFlags } from "@opentelemetry/api";
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as preloadedOnlyDocumentLoader, t as normalizePublicAudience } from "./public-audience-c9zmYKgA.mjs";
4
+ import { n as preloadedOnlyDocumentLoader, t as normalizePublicAudience } from "./public-audience-N3pyOx2p.mjs";
5
5
  import { getLogger } from "@logtape/logtape";
6
6
  import { preloadedContexts } from "@fedify/vocab-runtime";
7
7
  import jsonld from "@fedify/vocab-runtime/jsonld";
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-DVsHS7rA.mjs";
5
- import "./key-BoWaYRHm.mjs";
4
+ import { n as version, t as name } from "./deno-B_9yJW3w.mjs";
5
+ import "./key-CkkMJBjF.mjs";
6
6
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
7
7
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
8
8
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -1,7 +1,7 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  const require_chunk = require("./chunk-DDcVe30Y.cjs");
4
- const require_http = require("./http-CubOB9wq.cjs");
4
+ const require_http = require("./http-CWoeyogl.cjs");
5
5
  let _logtape_logtape = require("@logtape/logtape");
6
6
  let _fedify_vocab = require("@fedify/vocab");
7
7
  let _opentelemetry_api = require("@opentelemetry/api");
@@ -1,11 +1,11 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-DVsHS7rA.mjs";
5
- import { a as measureSignatureKeyFetch, n as getFederationMetrics, t as getDurationMs } from "./metrics-C4attqv0.mjs";
6
- import { n as fetchKey, o as validateCryptoKey } from "./key-BoWaYRHm.mjs";
7
- import { n as preloadedOnlyDocumentLoader } from "./public-audience-c9zmYKgA.mjs";
8
- import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-BNL8AC14.mjs";
4
+ import { n as version, t as name } from "./deno-B_9yJW3w.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-iRBg8jTk.mjs";
6
+ import { n as fetchKey, o as validateCryptoKey } from "./key-CkkMJBjF.mjs";
7
+ import { n as preloadedOnlyDocumentLoader } from "./public-audience-N3pyOx2p.mjs";
8
+ import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-BgFLCJQ_.mjs";
9
9
  import { getLogger } from "@logtape/logtape";
10
10
  import { Activity, DataIntegrityProof, Multikey, getTypeId } from "@fedify/vocab";
11
11
  import { SpanStatusCode, trace } from "@opentelemetry/api";
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { E as version, T as name, d as validateCryptoKey, f as getDurationMs, g as measureSignatureKeyFetch, p as getFederationMetrics, s as fetchKey } from "./http-CouJSFVK.js";
3
+ import { D as name, O as version, _ as measureSignatureKeyFetch, d as validateCryptoKey, f as getDurationMs, p as getFederationMetrics, s as fetchKey } from "./http-CToqG5ap.js";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, PUBLIC_COLLECTION, getTypeId, isActor } from "@fedify/vocab";
6
6
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -1,9 +1,9 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-DVsHS7rA.mjs";
5
- import { n as getFederationMetrics, t as getDurationMs } from "./metrics-C4attqv0.mjs";
6
- import { n as doubleKnock } from "./http-DUV8ysti.mjs";
4
+ import { n as version, t as name } from "./deno-B_9yJW3w.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics } from "./metrics-iRBg8jTk.mjs";
6
+ import { n as doubleKnock } from "./http-Cyx5SNuu.mjs";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
9
9
  //#region src/federation/send.ts
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature, t as formatAcceptSignature } from "../accept-CgDcxvjV.mjs";
4
+ import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature, t as formatAcceptSignature } from "../accept-CceiKpCy.mjs";
5
5
  import { test } from "@fedify/fixture";
6
6
  import { deepStrictEqual, strictEqual } from "node:assert/strict";
7
7
  //#region src/sig/accept.test.ts
@@ -1,15 +1,15 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
- import { r as assertExists, t as assertStringIncludes } from "../std__assert-BTEgfoJo.mjs";
6
- import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DQP-q39h.mjs";
7
- import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
8
- import { t as assert } from "../assert-DikXweDx.mjs";
9
- import { t as esm_default } from "../esm-sdtqOUPu.mjs";
10
- import { t as exportJwk } from "../key-BoWaYRHm.mjs";
11
- import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-DUV8ysti.mjs";
12
- import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-CSYsOMFG.mjs";
4
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
+ import { r as assertExists, t as assertStringIncludes } from "../std__assert-BBjXFNOb.mjs";
6
+ import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
7
+ import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
8
+ import { t as assert } from "../assert-OguE97r2.mjs";
9
+ import { t as esm_default } from "../esm-BQRw925N.mjs";
10
+ import { t as exportJwk } from "../key-CkkMJBjF.mjs";
11
+ import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-Cyx5SNuu.mjs";
12
+ import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-C3kae-6B.mjs";
13
13
  import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
14
14
  import { FetchError, exportSpki } from "@fedify/vocab-runtime";
15
15
  import { encodeBase64 } from "byte-encodings/base64";
@@ -259,6 +259,10 @@ test("verifyRequestDetailed() records verification duration metric", async (t) =
259
259
  assertEquals(measurement.attributes["activitypub.signature.result"], "verified");
260
260
  assertEquals(measurement.attributes["http_signatures.algorithm"], "rsa-sha256");
261
261
  assertFalse("http_signatures.failure_reason" in measurement.attributes);
262
+ const keyLookups = recorder.getMeasurements("activitypub.key.lookup");
263
+ assertEquals(keyLookups.length, 1);
264
+ assertEquals(keyLookups[0].attributes["activitypub.lookup.kind"], "public_key");
265
+ assertEquals(keyLookups[0].attributes["activitypub.lookup.result"], "fetched");
262
266
  });
263
267
  await t.step("missing signature is recorded as result=missing", async () => {
264
268
  const [meterProvider, recorder] = createTestMeterProvider();