@fedify/fedify 2.0.0-dev.241 → 2.0.0-dev.323
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{builder-CR-ZQZJR.js → builder-CvKuNW7P.js} +3 -3
- package/dist/{chunk-DqRYRqnO.cjs → chunk-CGaQZ11T.cjs} +19 -0
- package/dist/chunk-DJNbSFdH.js +29 -0
- package/dist/compat/mod.cjs +1 -1
- package/dist/compat/mod.d.cts +6 -6
- package/dist/compat/mod.d.ts +6 -6
- package/dist/compat/mod.js +2 -2
- package/dist/compat/transformers.test.js +11 -11
- package/dist/{context-C7vzWilY.d.ts → context-CJO1oqSa.d.ts} +55 -12
- package/dist/{context-Bns6uTJq.js → context-CZ5llAss.js} +12 -12
- package/dist/{context-CrB9RFy5.d.cts → context-Zqld1re2.d.cts} +55 -12
- package/dist/{deno-DOeSTfhz.js → deno-BTAi5-ur.js} +11 -3
- package/dist/{docloader-C1AGOQQm.js → docloader-D8dzb6AT.js} +2 -2
- package/dist/federation/builder.test.js +3 -3
- package/dist/federation/handler.test.js +12 -12
- package/dist/federation/idempotency.test.js +47 -11
- package/dist/federation/inbox.test.js +2 -2
- package/dist/federation/middleware.test.js +63 -11
- package/dist/federation/mod.cjs +7 -7
- package/dist/federation/mod.d.cts +6 -6
- package/dist/federation/mod.d.ts +6 -6
- package/dist/federation/mod.js +7 -7
- package/dist/federation/mq.test.js +162 -10
- package/dist/federation/send.test.js +5 -5
- package/dist/federation/webfinger.test.js +12 -12
- package/dist/{federation-B431K2gm.cjs → federation-Bp3HI26G.cjs} +95 -11
- package/dist/{federation-BbZwNNWj.js → federation-DaMfqRm4.js} +94 -10
- package/dist/{http-C1LrW2D3.cjs → http-BCfCt7nq.cjs} +12 -4
- package/dist/{http-i8VdY2df.js → http-C02fQ5SX.js} +11 -3
- package/dist/{http-DGkEl4mw.js → http-C4WANccp.js} +2 -2
- package/dist/{inbox-Cp87HRVs.js → inbox-CdBcxHA7.js} +1 -1
- package/dist/{key-3_vbTfr8.js → key-BI6sqU5u.js} +1 -1
- package/dist/{kv-cache-B4CFgxYq.js → kv-cache-BLxaWwPk.js} +1 -1
- package/dist/{kv-cache-DOgKf8lH.cjs → kv-cache-Dk9UX_M2.cjs} +2 -2
- package/dist/{ld-BQxhMgOJ.js → ld-qTcTL2A4.js} +2 -2
- package/dist/middleware-BhYGJwH9.js +12 -0
- package/dist/{middleware-DZ-OdkE6.js → middleware-DG4UsFBP.js} +11 -11
- package/dist/{middleware-DbwwSEOr.js → middleware-DaOdxVOc.js} +65 -22
- package/dist/middleware-Dsrm1uhx.cjs +12 -0
- package/dist/{middleware-ixha9m0b.js → middleware-LQKxYF7X.js} +61 -18
- package/dist/{middleware-D4Eexdig.cjs → middleware-nW8ONmt3.cjs} +62 -19
- package/dist/mod-Bh8mqlYw.d.cts +9 -0
- package/dist/{mod-waqu-BL_.d.ts → mod-Bpuc-q64.d.ts} +1 -1
- package/dist/{mod-C3SOvTD1.d.ts → mod-C92O3FpJ.d.ts} +1 -1
- package/dist/{mod-0qnPv4EC.d.cts → mod-CKtAEVny.d.cts} +1 -1
- package/dist/{mod-BrS8tiad.d.cts → mod-COO7VMcm.d.cts} +1 -1
- package/dist/{mod-DZmuPaKv.d.ts → mod-CvhyLrjX.d.ts} +2 -2
- package/dist/mod-D6HodEq7.d.ts +7 -0
- package/dist/{mod-D6pS5_xJ.d.cts → mod-DFWeUq2q.d.cts} +1 -1
- package/dist/{mod-BHXq4Q3x.d.cts → mod-DWaA45ef.d.cts} +2 -2
- package/dist/{mod-jOa7W503.d.ts → mod-q2IR8UiH.d.ts} +1 -1
- package/dist/mod.cjs +57 -9
- package/dist/mod.d.cts +19 -10
- package/dist/mod.d.ts +20 -10
- package/dist/mod.js +59 -11
- package/dist/nodeinfo/handler.test.js +12 -12
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.d.cts +2 -2
- package/dist/nodeinfo/mod.d.ts +2 -2
- package/dist/nodeinfo/mod.js +2 -2
- package/dist/otel/mod.cjs +1 -1
- package/dist/otel/mod.d.cts +1 -1
- package/dist/otel/mod.d.ts +1 -1
- package/dist/{owner-Bod8mCab.js → owner-Cfmtlwoe.js} +1 -1
- package/dist/{proof--60Adidu.js → proof-Bc8ULrzP.js} +2 -2
- package/dist/{proof-C8MAHWxQ.cjs → proof-BoqEqbih.cjs} +2 -2
- package/dist/{proof-vG4ePLF2.js → proof-OjMPhNWs.js} +1 -1
- package/dist/runtime/mod.cjs +14 -0
- package/dist/runtime/mod.d.cts +2 -0
- package/dist/runtime/mod.d.ts +4 -0
- package/dist/runtime/mod.js +7 -0
- package/dist/runtime-c2Njxsry.cjs +17 -0
- package/dist/runtime-poamPCMb.js +13 -0
- package/dist/{send-B3fWpYN9.js → send-BKW3wSXo.js} +2 -2
- package/dist/sig/http.test.js +3 -3
- package/dist/sig/key.test.js +2 -2
- package/dist/sig/ld.test.js +3 -3
- package/dist/sig/mod.cjs +3 -3
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +3 -3
- package/dist/sig/owner.test.js +3 -3
- package/dist/sig/proof.test.js +3 -3
- package/dist/testing/mod.d.ts +23 -7
- package/dist/testing/mod.js +1 -1
- package/dist/{transformers-BjBg6Lag.cjs → transformers-3g8GZwkZ.cjs} +1 -1
- package/dist/{types-B6z6CqIz.cjs → types-Cd_hszr_.cjs} +1 -1
- package/dist/utils/docloader.test.js +4 -4
- package/dist/utils/mod.cjs +3 -3
- package/dist/utils/mod.d.cts +3 -3
- package/dist/utils/mod.d.ts +3 -3
- package/dist/utils/mod.js +3 -3
- package/dist/vocab/mod.cjs +13 -0
- package/dist/vocab/mod.d.cts +1 -0
- package/dist/vocab/mod.d.ts +3 -0
- package/dist/vocab/mod.js +5 -0
- package/package.json +30 -8
- package/dist/middleware-C52jAnyA.js +0 -12
- package/dist/middleware-XsmW-sAa.cjs +0 -12
- /package/dist/{client-by-PEGAJ.d.cts → client-CwkOPN13.d.cts} +0 -0
- /package/dist/{client-CUTUGgvJ.d.ts → client-a7NwzhA2.d.ts} +0 -0
- /package/dist/{compat-nxUqe4Z-.js → compat-Bb4NuTUO.js} +0 -0
- /package/dist/{http-ClB3pLcL.d.cts → http-CCEu-x1_.d.cts} +0 -0
- /package/dist/{http-DLBDPal9.d.ts → http-CODSJcKx.d.ts} +0 -0
- /package/dist/{kv-B4vFhIYL.d.cts → kv-g9jFc34-.d.cts} +0 -0
- /package/dist/{kv-CYySNrsn.d.ts → kv-jg_8SMc1.d.ts} +0 -0
- /package/dist/{mod-1E3W847c.d.ts → mod-AGjRfPjT.d.ts} +0 -0
- /package/dist/{mod-C81L6_lQ.d.cts → mod-gq_Xfdz8.d.cts} +0 -0
- /package/dist/{nodeinfo-BlLsRSiT.js → nodeinfo-DoESQxq5.js} +0 -0
- /package/dist/{owner-C-zfmVAD.d.cts → owner-9yZ5Ibsb.d.cts} +0 -0
- /package/dist/{owner-BgI8C-VY.d.ts → owner-DQYAbVmX.d.ts} +0 -0
- /package/dist/{sig-CwuONEzF.js → sig-BNhspNOf.js} +0 -0
- /package/dist/{sig-DeXX2xnj.cjs → sig-vX39WyWI.cjs} +0 -0
- /package/dist/{transformers-N_ip_y4P.js → transformers-C3FLHUd6.js} +0 -0
- /package/dist/{types-8l28uC8o.js → types-C93Ob9cU.js} +0 -0
- /package/dist/{utils-Db0ZmjcD.cjs → utils-BQ9KqEK9.cjs} +0 -0
- /package/dist/{utils-Wranxuoe.js → utils-Dn5OPdSW.js} +0 -0
|
@@ -8,25 +8,25 @@ import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
|
|
8
8
|
import "../assert-MZs1qjMx.js";
|
|
9
9
|
import "../assert_instance_of-DHz7EHNU.js";
|
|
10
10
|
import { MemoryKvStore } from "../kv-QzKcOQgP.js";
|
|
11
|
-
import "../deno-
|
|
12
|
-
import { createFederation } from "../middleware-
|
|
11
|
+
import "../deno-BTAi5-ur.js";
|
|
12
|
+
import { createFederation } from "../middleware-DaOdxVOc.js";
|
|
13
13
|
import "../client-Dg7OfUDA.js";
|
|
14
14
|
import "../router-D9eI0s4b.js";
|
|
15
15
|
import "../types-CPz01LGH.js";
|
|
16
|
-
import "../key-
|
|
17
|
-
import "../http-
|
|
18
|
-
import "../ld-
|
|
19
|
-
import "../owner-
|
|
20
|
-
import { signObject } from "../proof
|
|
21
|
-
import "../docloader-
|
|
16
|
+
import "../key-BI6sqU5u.js";
|
|
17
|
+
import "../http-C4WANccp.js";
|
|
18
|
+
import "../ld-qTcTL2A4.js";
|
|
19
|
+
import "../owner-Cfmtlwoe.js";
|
|
20
|
+
import { signObject } from "../proof-Bc8ULrzP.js";
|
|
21
|
+
import "../docloader-D8dzb6AT.js";
|
|
22
22
|
import "../kv-cache-B__dHl7g.js";
|
|
23
|
-
import "../inbox-
|
|
24
|
-
import "../builder-
|
|
23
|
+
import "../inbox-CdBcxHA7.js";
|
|
24
|
+
import "../builder-CvKuNW7P.js";
|
|
25
25
|
import "../collection-CcnIw1qY.js";
|
|
26
26
|
import "../keycache-DRxpZ5r9.js";
|
|
27
27
|
import "../negotiation-5NPJL6zp.js";
|
|
28
28
|
import "../retry-D4GJ670a.js";
|
|
29
|
-
import "../send-
|
|
29
|
+
import "../send-BKW3wSXo.js";
|
|
30
30
|
import "../std__assert-DWivtrGR.js";
|
|
31
31
|
import "../assert_rejects-Ce45JcFg.js";
|
|
32
32
|
import "../assert_throws-BNXdRGWP.js";
|
|
@@ -198,5 +198,41 @@ test("Federation.setInboxListeners().withIdempotency() - custom callback", async
|
|
|
198
198
|
assertEquals(response.status, 202);
|
|
199
199
|
assertEquals(processedActivities.length, 3);
|
|
200
200
|
});
|
|
201
|
+
test("Federation.setInboxListeners() - default strategy is per-inbox", async () => {
|
|
202
|
+
const federation = createTestFederation();
|
|
203
|
+
const processedActivities = [];
|
|
204
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (ctx, activity$1) => {
|
|
205
|
+
processedActivities.push([ctx.recipient, activity$1]);
|
|
206
|
+
});
|
|
207
|
+
const activity = new Create({
|
|
208
|
+
id: new URL("https://example.com/activities/6"),
|
|
209
|
+
actor: new URL("https://example.com/person2")
|
|
210
|
+
});
|
|
211
|
+
const signedActivity = await signObject(activity, ed25519PrivateKey, ed25519Multikey.id);
|
|
212
|
+
const body = JSON.stringify(await signedActivity.toJsonLd({ contextLoader: mockDocumentLoader }));
|
|
213
|
+
let response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
|
214
|
+
method: "POST",
|
|
215
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
216
|
+
body
|
|
217
|
+
}), { contextData: void 0 });
|
|
218
|
+
assertEquals(response.status, 202);
|
|
219
|
+
assertEquals(processedActivities.length, 1);
|
|
220
|
+
assertEquals(processedActivities[0][0], "john");
|
|
221
|
+
response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
222
|
+
method: "POST",
|
|
223
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
224
|
+
body
|
|
225
|
+
}), { contextData: void 0 });
|
|
226
|
+
assertEquals(response.status, 202);
|
|
227
|
+
assertEquals(processedActivities.length, 2);
|
|
228
|
+
assertEquals(processedActivities[1][0], null);
|
|
229
|
+
response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
|
230
|
+
method: "POST",
|
|
231
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
232
|
+
body
|
|
233
|
+
}), { contextData: void 0 });
|
|
234
|
+
assertEquals(response.status, 202);
|
|
235
|
+
assertEquals(processedActivities.length, 2);
|
|
236
|
+
});
|
|
201
237
|
|
|
202
238
|
//#endregion
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import { test } from "../dist-B5f6a8Tt.js";
|
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
|
8
|
-
import "../deno-
|
|
9
|
-
import { InboxListenerSet } from "../inbox-
|
|
8
|
+
import "../deno-BTAi5-ur.js";
|
|
9
|
+
import { InboxListenerSet } from "../inbox-CdBcxHA7.js";
|
|
10
10
|
import { assertThrows } from "../assert_throws-BNXdRGWP.js";
|
|
11
11
|
import { Activity, Create, Invite, Offer, Update } from "@fedify/vocab";
|
|
12
12
|
|
|
@@ -8,25 +8,25 @@ import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
|
|
8
8
|
import { assert } from "../assert-MZs1qjMx.js";
|
|
9
9
|
import { assertInstanceOf } from "../assert_instance_of-DHz7EHNU.js";
|
|
10
10
|
import { MemoryKvStore } from "../kv-QzKcOQgP.js";
|
|
11
|
-
import "../deno-
|
|
12
|
-
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "../middleware-
|
|
11
|
+
import "../deno-BTAi5-ur.js";
|
|
12
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "../middleware-DaOdxVOc.js";
|
|
13
13
|
import "../client-Dg7OfUDA.js";
|
|
14
14
|
import { RouterError } from "../router-D9eI0s4b.js";
|
|
15
15
|
import "../types-CPz01LGH.js";
|
|
16
|
-
import "../key-
|
|
17
|
-
import { signRequest, verifyRequest } from "../http-
|
|
18
|
-
import { detachSignature, signJsonLd, verifyJsonLd } from "../ld-
|
|
19
|
-
import { doesActorOwnKey } from "../owner-
|
|
20
|
-
import { signObject, verifyObject } from "../proof
|
|
21
|
-
import { fetchDocumentLoader, getAuthenticatedDocumentLoader } from "../docloader-
|
|
16
|
+
import "../key-BI6sqU5u.js";
|
|
17
|
+
import { signRequest, verifyRequest } from "../http-C4WANccp.js";
|
|
18
|
+
import { detachSignature, signJsonLd, verifyJsonLd } from "../ld-qTcTL2A4.js";
|
|
19
|
+
import { doesActorOwnKey } from "../owner-Cfmtlwoe.js";
|
|
20
|
+
import { signObject, verifyObject } from "../proof-Bc8ULrzP.js";
|
|
21
|
+
import { fetchDocumentLoader, getAuthenticatedDocumentLoader } from "../docloader-D8dzb6AT.js";
|
|
22
22
|
import "../kv-cache-B__dHl7g.js";
|
|
23
|
-
import "../inbox-
|
|
24
|
-
import "../builder-
|
|
23
|
+
import "../inbox-CdBcxHA7.js";
|
|
24
|
+
import "../builder-CvKuNW7P.js";
|
|
25
25
|
import "../collection-CcnIw1qY.js";
|
|
26
26
|
import "../keycache-DRxpZ5r9.js";
|
|
27
27
|
import "../negotiation-5NPJL6zp.js";
|
|
28
28
|
import "../retry-D4GJ670a.js";
|
|
29
|
-
import "../send-
|
|
29
|
+
import "../send-BKW3wSXo.js";
|
|
30
30
|
import { assertStrictEquals } from "../std__assert-DWivtrGR.js";
|
|
31
31
|
import { assertFalse, assertRejects } from "../assert_rejects-Ce45JcFg.js";
|
|
32
32
|
import { assertThrows } from "../assert_throws-BNXdRGWP.js";
|
|
@@ -1635,6 +1635,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1635
1635
|
sharedInbox: false
|
|
1636
1636
|
} },
|
|
1637
1637
|
keys: queue.messages[0].type === "fanout" ? queue.messages[0].keys : [],
|
|
1638
|
+
orderingKey: void 0,
|
|
1638
1639
|
traceContext: {}
|
|
1639
1640
|
}]);
|
|
1640
1641
|
});
|
|
@@ -1732,6 +1733,57 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1732
1733
|
});
|
|
1733
1734
|
assertNotEquals(collectionSyncHeader, null);
|
|
1734
1735
|
});
|
|
1736
|
+
queue.clear();
|
|
1737
|
+
await t.step("orderingKey with fanout: \"force\"", async () => {
|
|
1738
|
+
const activity = new vocab.Create({
|
|
1739
|
+
id: new URL("https://example.com/activity/ordering-1"),
|
|
1740
|
+
actor: new URL("https://example.com/person")
|
|
1741
|
+
});
|
|
1742
|
+
await ctx2.sendActivity({ username: "john" }, {
|
|
1743
|
+
id: new URL("https://example.com/recipient"),
|
|
1744
|
+
inboxId: new URL("https://example.com/inbox")
|
|
1745
|
+
}, activity, {
|
|
1746
|
+
fanout: "force",
|
|
1747
|
+
orderingKey: "https://example.com/note/1"
|
|
1748
|
+
});
|
|
1749
|
+
assertEquals(queue.messages.length, 1);
|
|
1750
|
+
const fanoutMessage = queue.messages[0];
|
|
1751
|
+
assertEquals(fanoutMessage.type, "fanout");
|
|
1752
|
+
if (fanoutMessage.type === "fanout") assertEquals(fanoutMessage.orderingKey, "https://example.com/note/1");
|
|
1753
|
+
});
|
|
1754
|
+
queue.clear();
|
|
1755
|
+
await t.step("orderingKey with fanout: \"skip\"", async () => {
|
|
1756
|
+
const activity = new vocab.Create({
|
|
1757
|
+
id: new URL("https://example.com/activity/ordering-2"),
|
|
1758
|
+
actor: new URL("https://example.com/person")
|
|
1759
|
+
});
|
|
1760
|
+
await ctx2.sendActivity({ username: "john" }, {
|
|
1761
|
+
id: new URL("https://example.com/recipient"),
|
|
1762
|
+
inboxId: new URL("https://example.com/inbox")
|
|
1763
|
+
}, activity, {
|
|
1764
|
+
fanout: "skip",
|
|
1765
|
+
orderingKey: "https://example.com/note/2"
|
|
1766
|
+
});
|
|
1767
|
+
assertEquals(queue.messages.length, 1);
|
|
1768
|
+
const outboxMessage = queue.messages[0];
|
|
1769
|
+
assertEquals(outboxMessage.type, "outbox");
|
|
1770
|
+
if (outboxMessage.type === "outbox") assertEquals(outboxMessage.orderingKey, "https://example.com/note/2\nhttps://example.com");
|
|
1771
|
+
});
|
|
1772
|
+
queue.clear();
|
|
1773
|
+
await t.step("orderingKey not specified", async () => {
|
|
1774
|
+
const activity = new vocab.Create({
|
|
1775
|
+
id: new URL("https://example.com/activity/ordering-3"),
|
|
1776
|
+
actor: new URL("https://example.com/person")
|
|
1777
|
+
});
|
|
1778
|
+
await ctx2.sendActivity({ username: "john" }, {
|
|
1779
|
+
id: new URL("https://example.com/recipient"),
|
|
1780
|
+
inboxId: new URL("https://example.com/inbox")
|
|
1781
|
+
}, activity, { fanout: "force" });
|
|
1782
|
+
assertEquals(queue.messages.length, 1);
|
|
1783
|
+
const fanoutMessage2 = queue.messages[0];
|
|
1784
|
+
assertEquals(fanoutMessage2.type, "fanout");
|
|
1785
|
+
if (fanoutMessage2.type === "fanout") assertEquals(fanoutMessage2.orderingKey, void 0);
|
|
1786
|
+
});
|
|
1735
1787
|
esm_default.hardReset();
|
|
1736
1788
|
});
|
|
1737
1789
|
test({
|
package/dist/federation/mod.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
3
3
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
4
4
|
|
|
5
|
-
require('../transformers-
|
|
6
|
-
require('../http-
|
|
7
|
-
const require_middleware = require('../middleware-
|
|
8
|
-
require('../proof-
|
|
9
|
-
const require_federation = require('../federation-
|
|
10
|
-
require('../types-
|
|
11
|
-
require('../kv-cache-
|
|
5
|
+
require('../transformers-3g8GZwkZ.cjs');
|
|
6
|
+
require('../http-BCfCt7nq.cjs');
|
|
7
|
+
const require_middleware = require('../middleware-nW8ONmt3.cjs');
|
|
8
|
+
require('../proof-BoqEqbih.cjs');
|
|
9
|
+
const require_federation = require('../federation-Bp3HI26G.cjs');
|
|
10
|
+
require('../types-Cd_hszr_.cjs');
|
|
11
|
+
require('../kv-cache-Dk9UX_M2.cjs');
|
|
12
12
|
|
|
13
13
|
exports.InProcessMessageQueue = require_federation.InProcessMessageQueue;
|
|
14
14
|
exports.MemoryKvStore = require_federation.MemoryKvStore;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../client-
|
|
2
|
-
import "../http-
|
|
3
|
-
import "../owner-
|
|
4
|
-
import { 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 } from "../context-
|
|
5
|
-
import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore } from "../kv-
|
|
6
|
-
import { WebFingerHandlerParameters, handleWebFinger } from "../mod-
|
|
1
|
+
import "../client-CwkOPN13.cjs";
|
|
2
|
+
import "../http-CCEu-x1_.cjs";
|
|
3
|
+
import "../owner-9yZ5Ibsb.cjs";
|
|
4
|
+
import { 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 } from "../context-Zqld1re2.cjs";
|
|
5
|
+
import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore } from "../kv-g9jFc34-.cjs";
|
|
6
|
+
import { WebFingerHandlerParameters, handleWebFinger } from "../mod-CKtAEVny.cjs";
|
|
7
7
|
export { 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, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, 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, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|
package/dist/federation/mod.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import "../client-
|
|
4
|
-
import "../http-
|
|
5
|
-
import "../owner-
|
|
6
|
-
import { 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 } from "../context-
|
|
7
|
-
import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore } from "../kv-
|
|
8
|
-
import { WebFingerHandlerParameters, handleWebFinger } from "../mod-
|
|
3
|
+
import "../client-a7NwzhA2.js";
|
|
4
|
+
import "../http-CODSJcKx.js";
|
|
5
|
+
import "../owner-DQYAbVmX.js";
|
|
6
|
+
import { 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 } from "../context-CJO1oqSa.js";
|
|
7
|
+
import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore } from "../kv-jg_8SMc1.js";
|
|
8
|
+
import { WebFingerHandlerParameters, handleWebFinger } from "../mod-C92O3FpJ.js";
|
|
9
9
|
export { 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, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, 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, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|
package/dist/federation/mod.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import "../transformers-
|
|
6
|
-
import "../http-
|
|
7
|
-
import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-
|
|
8
|
-
import "../proof-
|
|
9
|
-
import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "../federation-
|
|
10
|
-
import "../types-
|
|
11
|
-
import "../kv-cache-
|
|
5
|
+
import "../transformers-C3FLHUd6.js";
|
|
6
|
+
import "../http-C02fQ5SX.js";
|
|
7
|
+
import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-LQKxYF7X.js";
|
|
8
|
+
import "../proof-OjMPhNWs.js";
|
|
9
|
+
import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "../federation-DaMfqRm4.js";
|
|
10
|
+
import "../types-C93Ob9cU.js";
|
|
11
|
+
import "../kv-cache-BLxaWwPk.js";
|
|
12
12
|
|
|
13
13
|
export { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue, Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|
|
@@ -26,6 +26,11 @@ var InProcessMessageQueue = class {
|
|
|
26
26
|
#monitors;
|
|
27
27
|
#pollIntervalMs;
|
|
28
28
|
/**
|
|
29
|
+
* Tracks which ordering keys are currently being processed to ensure
|
|
30
|
+
* sequential processing for messages with the same key.
|
|
31
|
+
*/
|
|
32
|
+
#processingKeys;
|
|
33
|
+
/**
|
|
29
34
|
* In-process message queue does not provide native retry mechanisms.
|
|
30
35
|
* @since 1.7.0
|
|
31
36
|
*/
|
|
@@ -38,6 +43,7 @@ var InProcessMessageQueue = class {
|
|
|
38
43
|
this.#messages = [];
|
|
39
44
|
this.#monitors = {};
|
|
40
45
|
this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
|
|
46
|
+
this.#processingKeys = /* @__PURE__ */ new Set();
|
|
41
47
|
}
|
|
42
48
|
enqueue(message, options) {
|
|
43
49
|
const delay$1 = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
@@ -48,7 +54,11 @@ var InProcessMessageQueue = class {
|
|
|
48
54
|
}), delay$1);
|
|
49
55
|
return Promise.resolve();
|
|
50
56
|
}
|
|
51
|
-
|
|
57
|
+
const orderingKey = options?.orderingKey ?? null;
|
|
58
|
+
this.#messages.push({
|
|
59
|
+
message,
|
|
60
|
+
orderingKey
|
|
61
|
+
});
|
|
52
62
|
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
|
53
63
|
return Promise.resolve();
|
|
54
64
|
}
|
|
@@ -62,18 +72,29 @@ var InProcessMessageQueue = class {
|
|
|
62
72
|
}), delay$1);
|
|
63
73
|
return Promise.resolve();
|
|
64
74
|
}
|
|
65
|
-
|
|
75
|
+
const orderingKey = options?.orderingKey ?? null;
|
|
76
|
+
for (const message of messages) this.#messages.push({
|
|
77
|
+
message,
|
|
78
|
+
orderingKey
|
|
79
|
+
});
|
|
66
80
|
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
|
67
81
|
return Promise.resolve();
|
|
68
82
|
}
|
|
69
83
|
async listen(handler, options = {}) {
|
|
70
84
|
const signal = options.signal;
|
|
71
85
|
while (signal == null || !signal.aborted) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
const idx = this.#messages.findIndex((m) => m.orderingKey == null || !this.#processingKeys.has(m.orderingKey));
|
|
87
|
+
if (idx >= 0) {
|
|
88
|
+
const queued = this.#messages.splice(idx, 1)[0];
|
|
89
|
+
const { message, orderingKey } = queued;
|
|
90
|
+
if (orderingKey != null) this.#processingKeys.add(orderingKey);
|
|
91
|
+
try {
|
|
92
|
+
await handler(message);
|
|
93
|
+
} finally {
|
|
94
|
+
if (orderingKey != null) this.#processingKeys.delete(orderingKey);
|
|
95
|
+
}
|
|
96
|
+
} else if (this.#messages.length === 0) await this.#wait(this.#pollIntervalMs, signal);
|
|
97
|
+
else await this.#wait(10, signal);
|
|
77
98
|
}
|
|
78
99
|
}
|
|
79
100
|
#wait(ms, signal) {
|
|
@@ -105,6 +126,21 @@ var InProcessMessageQueue = class {
|
|
|
105
126
|
* for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
|
|
106
127
|
* workloads.
|
|
107
128
|
*
|
|
129
|
+
* When using `ParallelMessageQueue`, the ordering guarantee is preserved
|
|
130
|
+
* *only if* the underlying queue implementation delivers messages in a wrapper
|
|
131
|
+
* format that includes the `__fedify_ordering_key__` property. Currently,
|
|
132
|
+
* only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
|
|
133
|
+
* For other queue implementations (e.g., `InProcessMessageQueue`,
|
|
134
|
+
* `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
|
|
135
|
+
* `AmqpMessageQueue`), the ordering key cannot be detected by
|
|
136
|
+
* `ParallelMessageQueue`, so ordering guarantees are handled by those
|
|
137
|
+
* implementations directly rather than at the `ParallelMessageQueue` level.
|
|
138
|
+
*
|
|
139
|
+
* Messages with the same ordering key will never be processed concurrently
|
|
140
|
+
* by different workers, ensuring sequential processing within each key.
|
|
141
|
+
* Messages with different ordering keys (or no ordering key) can still be
|
|
142
|
+
* processed in parallel.
|
|
143
|
+
*
|
|
108
144
|
* @since 1.0.0
|
|
109
145
|
*/
|
|
110
146
|
var ParallelMessageQueue = class ParallelMessageQueue {
|
|
@@ -116,6 +152,15 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
116
152
|
*/
|
|
117
153
|
nativeRetrial;
|
|
118
154
|
/**
|
|
155
|
+
* Tracks which ordering keys are currently being processed to ensure
|
|
156
|
+
* sequential processing for messages with the same key.
|
|
157
|
+
*/
|
|
158
|
+
#processingKeys = /* @__PURE__ */ new Set();
|
|
159
|
+
/**
|
|
160
|
+
* Pending messages waiting for their ordering key to become available.
|
|
161
|
+
*/
|
|
162
|
+
#pendingMessages = [];
|
|
163
|
+
/**
|
|
119
164
|
* Constructs a new {@link ParallelMessageQueue} with the given queue and
|
|
120
165
|
* number of workers.
|
|
121
166
|
* @param queue The message queue to use under the hood. Note that
|
|
@@ -143,6 +188,25 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
143
188
|
}
|
|
144
189
|
await this.queue.enqueueMany(messages, options);
|
|
145
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Extracts ordering key from a message if present.
|
|
193
|
+
*
|
|
194
|
+
* This method only works for queue implementations that deliver messages
|
|
195
|
+
* in the wrapper format with `__fedify_ordering_key__` property. Currently,
|
|
196
|
+
* only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
|
|
197
|
+
*
|
|
198
|
+
* For other queue implementations (`InProcessMessageQueue`,
|
|
199
|
+
* `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
|
|
200
|
+
* `AmqpMessageQueue`), messages are delivered as raw payloads without the
|
|
201
|
+
* wrapper, so the ordering key cannot be detected here. Those
|
|
202
|
+
* implementations handle ordering guarantees internally.
|
|
203
|
+
*/
|
|
204
|
+
#extractOrderingKey(message) {
|
|
205
|
+
if (message != null && typeof message === "object") {
|
|
206
|
+
if ("__fedify_ordering_key__" in message) return message.__fedify_ordering_key__;
|
|
207
|
+
}
|
|
208
|
+
return void 0;
|
|
209
|
+
}
|
|
146
210
|
listen(handler, options = {}) {
|
|
147
211
|
const workers = /* @__PURE__ */ new Map();
|
|
148
212
|
return this.queue.listen(async (message) => {
|
|
@@ -151,13 +215,33 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
151
215
|
workers.delete(consumedId);
|
|
152
216
|
}
|
|
153
217
|
const workerId = crypto.randomUUID();
|
|
154
|
-
const
|
|
218
|
+
const orderingKey = this.#extractOrderingKey(message);
|
|
219
|
+
if (orderingKey != null && this.#processingKeys.has(orderingKey)) await new Promise((resolve) => {
|
|
220
|
+
this.#pendingMessages.push({
|
|
221
|
+
message,
|
|
222
|
+
orderingKey,
|
|
223
|
+
resolve
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
if (orderingKey != null) this.#processingKeys.add(orderingKey);
|
|
227
|
+
const promise = this.#work(workerId, handler, message, orderingKey);
|
|
155
228
|
workers.set(workerId, promise);
|
|
156
229
|
}, options);
|
|
157
230
|
}
|
|
158
|
-
async #work(workerId, handler, message) {
|
|
231
|
+
async #work(workerId, handler, message, orderingKey) {
|
|
159
232
|
await this.#sleep(0);
|
|
160
|
-
|
|
233
|
+
try {
|
|
234
|
+
await handler(message);
|
|
235
|
+
} finally {
|
|
236
|
+
if (orderingKey != null) {
|
|
237
|
+
this.#processingKeys.delete(orderingKey);
|
|
238
|
+
const pendingIdx = this.#pendingMessages.findIndex((p) => p.orderingKey === orderingKey);
|
|
239
|
+
if (pendingIdx >= 0) {
|
|
240
|
+
const pending = this.#pendingMessages.splice(pendingIdx, 1)[0];
|
|
241
|
+
pending.resolve();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
161
245
|
return workerId;
|
|
162
246
|
}
|
|
163
247
|
#sleep(ms) {
|
|
@@ -222,6 +306,74 @@ test("InProcessMessageQueue", async (t) => {
|
|
|
222
306
|
controller.abort();
|
|
223
307
|
await listening;
|
|
224
308
|
});
|
|
309
|
+
test("InProcessMessageQueue orderingKey", async (t) => {
|
|
310
|
+
const mq = new InProcessMessageQueue();
|
|
311
|
+
const orderTracker = {
|
|
312
|
+
keyA: [],
|
|
313
|
+
keyB: [],
|
|
314
|
+
noKey: []
|
|
315
|
+
};
|
|
316
|
+
const allMessages = [];
|
|
317
|
+
const controller = new AbortController();
|
|
318
|
+
const listening = mq.listen((message) => {
|
|
319
|
+
allMessages.push(message);
|
|
320
|
+
const trackKey = message.key ?? "noKey";
|
|
321
|
+
if (trackKey in orderTracker) orderTracker[trackKey].push(message.value);
|
|
322
|
+
}, controller);
|
|
323
|
+
await t.step("enqueue with ordering key", async () => {
|
|
324
|
+
await mq.enqueue({
|
|
325
|
+
key: "keyA",
|
|
326
|
+
value: 1
|
|
327
|
+
}, { orderingKey: "keyA" });
|
|
328
|
+
await mq.enqueue({
|
|
329
|
+
key: "keyB",
|
|
330
|
+
value: 1
|
|
331
|
+
}, { orderingKey: "keyB" });
|
|
332
|
+
await mq.enqueue({
|
|
333
|
+
key: "keyA",
|
|
334
|
+
value: 2
|
|
335
|
+
}, { orderingKey: "keyA" });
|
|
336
|
+
await mq.enqueue({
|
|
337
|
+
key: "keyB",
|
|
338
|
+
value: 2
|
|
339
|
+
}, { orderingKey: "keyB" });
|
|
340
|
+
await mq.enqueue({
|
|
341
|
+
key: "keyA",
|
|
342
|
+
value: 3
|
|
343
|
+
}, { orderingKey: "keyA" });
|
|
344
|
+
await mq.enqueue({
|
|
345
|
+
key: "keyB",
|
|
346
|
+
value: 3
|
|
347
|
+
}, { orderingKey: "keyB" });
|
|
348
|
+
await mq.enqueue({
|
|
349
|
+
key: null,
|
|
350
|
+
value: 1
|
|
351
|
+
});
|
|
352
|
+
await mq.enqueue({
|
|
353
|
+
key: null,
|
|
354
|
+
value: 2
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
await waitFor(() => allMessages.length >= 8, 3e4);
|
|
358
|
+
await t.step("verify ordering key order", () => {
|
|
359
|
+
assertEquals(orderTracker.keyA, [
|
|
360
|
+
1,
|
|
361
|
+
2,
|
|
362
|
+
3
|
|
363
|
+
], "Messages with orderingKey 'keyA' should be processed in order");
|
|
364
|
+
assertEquals(orderTracker.keyB, [
|
|
365
|
+
1,
|
|
366
|
+
2,
|
|
367
|
+
3
|
|
368
|
+
], "Messages with orderingKey 'keyB' should be processed in order");
|
|
369
|
+
});
|
|
370
|
+
await t.step("verify messages without ordering key", () => {
|
|
371
|
+
assertEquals(orderTracker.noKey.length, 2, "Messages without ordering key should all be received");
|
|
372
|
+
assert(orderTracker.noKey.includes(1) && orderTracker.noKey.includes(2), "Messages without ordering key should contain values 1 and 2");
|
|
373
|
+
});
|
|
374
|
+
controller.abort();
|
|
375
|
+
await listening;
|
|
376
|
+
});
|
|
225
377
|
test("MessageQueue.nativeRetrial", async (t) => {
|
|
226
378
|
if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") await t.step("DenoKvMessageQueue", async () => {
|
|
227
379
|
const packageName = () => "@fedify/denokv";
|
|
@@ -7,11 +7,11 @@ import { createTestTracerProvider, mockDocumentLoader, test } from "../dist-B5f6
|
|
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
|
8
8
|
import { assert } from "../assert-MZs1qjMx.js";
|
|
9
9
|
import "../assert_instance_of-DHz7EHNU.js";
|
|
10
|
-
import "../deno-
|
|
11
|
-
import "../key-
|
|
12
|
-
import { verifyRequest } from "../http-
|
|
13
|
-
import { doesActorOwnKey } from "../owner-
|
|
14
|
-
import { extractInboxes, sendActivity } from "../send-
|
|
10
|
+
import "../deno-BTAi5-ur.js";
|
|
11
|
+
import "../key-BI6sqU5u.js";
|
|
12
|
+
import { verifyRequest } from "../http-C4WANccp.js";
|
|
13
|
+
import { doesActorOwnKey } from "../owner-Cfmtlwoe.js";
|
|
14
|
+
import { extractInboxes, sendActivity } from "../send-BKW3wSXo.js";
|
|
15
15
|
import "../std__assert-DWivtrGR.js";
|
|
16
16
|
import { assertFalse, assertRejects } from "../assert_rejects-Ce45JcFg.js";
|
|
17
17
|
import "../assert_throws-BNXdRGWP.js";
|
|
@@ -8,30 +8,30 @@ import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
|
|
8
8
|
import "../assert-MZs1qjMx.js";
|
|
9
9
|
import "../assert_instance_of-DHz7EHNU.js";
|
|
10
10
|
import { MemoryKvStore } from "../kv-QzKcOQgP.js";
|
|
11
|
-
import "../deno-
|
|
12
|
-
import { createFederation, handleWebFinger } from "../middleware-
|
|
11
|
+
import "../deno-BTAi5-ur.js";
|
|
12
|
+
import { createFederation, handleWebFinger } from "../middleware-DaOdxVOc.js";
|
|
13
13
|
import "../client-Dg7OfUDA.js";
|
|
14
14
|
import "../router-D9eI0s4b.js";
|
|
15
15
|
import "../types-CPz01LGH.js";
|
|
16
|
-
import "../key-
|
|
17
|
-
import "../http-
|
|
18
|
-
import "../ld-
|
|
19
|
-
import "../owner-
|
|
20
|
-
import "../proof
|
|
21
|
-
import "../docloader-
|
|
16
|
+
import "../key-BI6sqU5u.js";
|
|
17
|
+
import "../http-C4WANccp.js";
|
|
18
|
+
import "../ld-qTcTL2A4.js";
|
|
19
|
+
import "../owner-Cfmtlwoe.js";
|
|
20
|
+
import "../proof-Bc8ULrzP.js";
|
|
21
|
+
import "../docloader-D8dzb6AT.js";
|
|
22
22
|
import "../kv-cache-B__dHl7g.js";
|
|
23
|
-
import "../inbox-
|
|
24
|
-
import "../builder-
|
|
23
|
+
import "../inbox-CdBcxHA7.js";
|
|
24
|
+
import "../builder-CvKuNW7P.js";
|
|
25
25
|
import "../collection-CcnIw1qY.js";
|
|
26
26
|
import "../keycache-DRxpZ5r9.js";
|
|
27
27
|
import "../negotiation-5NPJL6zp.js";
|
|
28
28
|
import "../retry-D4GJ670a.js";
|
|
29
|
-
import "../send-
|
|
29
|
+
import "../send-BKW3wSXo.js";
|
|
30
30
|
import "../std__assert-DWivtrGR.js";
|
|
31
31
|
import "../assert_rejects-Ce45JcFg.js";
|
|
32
32
|
import "../assert_throws-BNXdRGWP.js";
|
|
33
33
|
import "../assert_not_equals-C80BG-_5.js";
|
|
34
|
-
import { createRequestContext } from "../context-
|
|
34
|
+
import { createRequestContext } from "../context-CZ5llAss.js";
|
|
35
35
|
import { Image, Link, Person } from "@fedify/vocab";
|
|
36
36
|
|
|
37
37
|
//#region src/federation/webfinger.test.ts
|