@fedify/fedify 2.0.0-dev.1604 → 2.0.0-dev.1690
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/actor-Be0ThtXy.cjs +42609 -0
- package/dist/{actor-BC3XtGTj.js → actor-ChbPLm6n.js} +7266 -2443
- package/dist/actor-D6K058Tb.d.cts +128 -0
- package/dist/{actor-CmRlosMl.js → actor-DuCeRiNh.js} +1 -1
- package/dist/{actor-C22bXuuC.d.ts → actor-T6RyhRgk.d.ts} +1 -1
- package/dist/{assert_rejects-7UF4R_Qs.js → assert_rejects-DiIiJbZn.js} +1 -1
- package/dist/{assert_throws-53_pKeP3.js → assert_throws-BOO88avQ.js} +1 -1
- package/dist/{authdocloader-CzpPQC01.js → authdocloader-Brax1A32.js} +3 -3
- package/dist/{authdocloader-D-DICGXT.js → authdocloader-CrxhFL8e.js} +6 -6
- package/dist/authdocloader-OSn_teLV.cjs +58 -0
- package/dist/{builder-D9zidAqR.js → builder-CYOcDUkj.js} +10 -4
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/client-CegPX0Rn.d.cts +222 -0
- package/dist/{client-Bsj0vQPr.js → client-CnOdwLLN.js} +1 -1
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +13 -0
- package/dist/compat/mod.d.ts +7 -7
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +18 -17
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/{context-CDSZdQHD.d.ts → context-ByZprN0S.d.ts} +66 -6
- package/dist/context-C5BsZkDr.d.cts +2315 -0
- package/dist/docloader-CCqXeagZ.cjs +4861 -0
- package/dist/docloader-D-MrRyHl.d.cts +219 -0
- package/dist/{docloader-CkASOfZ5.js → docloader-XK3y2jn5.js} +189 -9
- package/dist/{esm-CXF1VoeR.js → esm-DnIzfEj0.js} +1 -1
- package/dist/federation/builder.test.js +10 -10
- package/dist/federation/collection.test.js +8 -8
- package/dist/federation/handler.test.js +26 -145
- package/dist/federation/idempotency.test.d.ts +3 -0
- package/dist/federation/idempotency.test.js +202 -0
- package/dist/federation/inbox.test.js +6 -6
- package/dist/federation/keycache.test.js +4 -4
- package/dist/federation/kv.test.js +9 -8
- package/dist/federation/middleware.test.js +232 -38
- package/dist/federation/mod.cjs +29 -0
- package/dist/federation/mod.d.cts +13 -0
- package/dist/federation/mod.d.ts +7 -7
- package/dist/federation/mod.js +15 -15
- package/dist/federation/mq.test.js +10 -10
- package/dist/federation/negotiation.test.d.ts +3 -0
- package/dist/federation/negotiation.test.js +28 -0
- package/dist/federation/retry.test.js +5 -5
- package/dist/federation/router.test.js +8 -8
- package/dist/federation/send.test.js +15 -15
- package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
- package/dist/federation-H2_En3j5.cjs +244 -0
- package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
- package/dist/{http-CSYNybkH.js → http-BNOYnVsU.js} +2 -2
- package/dist/{http-B_pxY5of.js → http-BxbM8sEy.js} +6 -6
- package/dist/http-C7vbQwbz.cjs +826 -0
- package/dist/http-D-e6AFwR.d.cts +253 -0
- package/dist/{http-DqSNLFNY.d.ts → http-D6Uj2x2y.d.ts} +1 -1
- package/dist/{inbox-DoJlwIE4.js → inbox-BRru9pX3.js} +24 -7
- package/dist/{key-BOzqiGbl.js → key-1KXru8Ug.js} +2 -2
- package/dist/key-B3uag-rz.js +10 -0
- package/dist/key-BiBmb1Yy.cjs +10 -0
- package/dist/{key-DWWqeyaq.js → key-DK_nfU4I.js} +3 -3
- package/dist/key-Z6ceKnZC.cjs +290 -0
- package/dist/{key-Bif4eMj7.js → key-jyNTxCvK.js} +5 -5
- package/dist/{keycache--NYDYifd.js → keycache-CN61iGVj.js} +1 -1
- package/dist/{keys-MacD9GP6.js → keys-BPdFKgiy.js} +1 -1
- package/dist/kv-63Cil1MD.d.cts +81 -0
- package/dist/{ld-D9oTBLrs.js → ld-Dv8DNNAT.js} +2 -2
- package/dist/{lookup-Cz9VSYxw.js → lookup-BPviO8ij.js} +4 -4
- package/dist/lookup-hnMAAU5r.cjs +137 -0
- package/dist/{lookup-DuzrBbTj.js → lookup-pV0JOsuV.js} +21 -12
- package/dist/middleware-BmoOlgc1.cjs +4231 -0
- package/dist/{middleware-C0w2M0tb.js → middleware-Bz_A2jeJ.js} +87 -91
- package/dist/middleware-CI0-zw4U.js +26 -0
- package/dist/{middleware-CgNm3XOJ.js → middleware-DY9B2lL8.js} +57 -148
- package/dist/middleware-QNK-W-jE.cjs +17 -0
- package/dist/middleware-_vjt6FWU.js +17 -0
- package/dist/mod-8DMWKtQE.d.cts +80 -0
- package/dist/{mod-Drmz72EK.d.ts → mod-BhUKmBJD.d.ts} +2 -2
- package/dist/mod-C2tOeRkN.d.cts +1 -0
- package/dist/{mod-TFoH2Ql8.d.ts → mod-CerN_Sza.d.ts} +1 -1
- package/dist/mod-Cj1tHXBR.d.cts +102 -0
- package/dist/mod-CxkWO3Mg.d.cts +307 -0
- package/dist/{mod-RI3-KvUI.d.ts → mod-D6hQoxC5.d.ts} +2 -2
- package/dist/mod-Djzcw2ry.d.cts +266 -0
- package/dist/{mod-Cxt4Kpf6.d.ts → mod-DlU8ISoa.d.ts} +19 -1
- package/dist/mod-FZd39qVq.d.cts +1 -0
- package/dist/mod-jQ4OODsl.d.cts +113 -0
- package/dist/mod.cjs +150 -0
- package/dist/mod.d.cts +17 -0
- package/dist/mod.d.ts +10 -10
- package/dist/mod.js +20 -20
- package/dist/mq-B7R1Q-M5.d.cts +140 -0
- package/dist/negotiation-5NPJL6zp.js +71 -0
- package/dist/nodeinfo/client.test.js +10 -10
- package/dist/nodeinfo/handler.test.js +23 -22
- package/dist/nodeinfo/mod.cjs +11 -0
- package/dist/nodeinfo/mod.d.cts +5 -0
- package/dist/nodeinfo/mod.js +6 -6
- package/dist/nodeinfo/types.test.js +8 -8
- package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
- package/dist/nodeinfo-DfycQ8Wf.js +4 -0
- package/dist/owner-BN_tO3cY.d.cts +67 -0
- package/dist/{owner-gB-pDKA-.js → owner-e3FYDhsk.js} +2 -2
- package/dist/{owner-CQPnQVtf.d.ts → owner-hd9lvQcP.d.ts} +2 -2
- package/dist/{proof-CScVkkIT.js → proof-6gFMwMNJ.js} +2 -2
- package/dist/proof-B-eqv0Ug.cjs +673 -0
- package/dist/{proof-VPikK_0V.js → proof-DfgvA3al.js} +6 -6
- package/dist/runtime/authdocloader.test.js +14 -14
- package/dist/runtime/docloader.test.js +9 -9
- package/dist/runtime/key.test.js +10 -10
- package/dist/runtime/langstr.test.js +8 -8
- package/dist/runtime/link.test.d.ts +3 -0
- package/dist/runtime/link.test.js +61 -0
- package/dist/runtime/mod.cjs +25 -0
- package/dist/runtime/mod.d.cts +6 -0
- package/dist/runtime/mod.d.ts +3 -3
- package/dist/runtime/mod.js +10 -10
- package/dist/runtime/multibase/multibase.test.js +8 -8
- package/dist/runtime/url.test.js +5 -5
- package/dist/runtime-C58AJWSv.cjs +4 -0
- package/dist/runtime-DPYEDf-o.js +4 -0
- package/dist/{send-flZ7H10-.js → send-Tl9NOnmO.js} +2 -2
- package/dist/sig/http.test.js +13 -13
- package/dist/sig/key.test.js +11 -11
- package/dist/sig/ld.test.js +10 -10
- package/dist/sig/mod.cjs +30 -0
- package/dist/sig/mod.d.cts +8 -0
- package/dist/sig/mod.d.ts +5 -5
- package/dist/sig/mod.js +10 -10
- package/dist/sig/owner.test.js +12 -12
- package/dist/sig/proof.test.js +12 -12
- package/dist/sig-ByHXzqUi.cjs +4 -0
- package/dist/sig-Cj3tk-ig.js +4 -0
- package/dist/testing/docloader.test.js +8 -8
- package/dist/testing/mod.d.ts +272 -0
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-CdBSI4xF.js → testing-BWNCAbL-.js} +2 -2
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/{type-CAteiET0.js → type-C69ZBu7f.js} +7258 -2255
- package/dist/{types-Vo0qKhN7.js → types-DqxyTxOf.js} +4 -4
- package/dist/types-zqdWZh4O.cjs +315 -0
- package/dist/vocab/actor.test.js +10 -10
- package/dist/vocab/lookup.test.js +259 -9
- package/dist/vocab/mod.cjs +87 -0
- package/dist/vocab/mod.d.cts +6 -0
- package/dist/vocab/mod.d.ts +3 -3
- package/dist/vocab/mod.js +7 -7
- package/dist/vocab/type.test.js +3 -3
- package/dist/vocab/vocab.test.js +438 -14
- package/dist/vocab-B39-pFl9.cjs +291 -0
- package/dist/{vocab-SOE1ifCr.d.ts → vocab-BI0Ak5lL.d.ts} +290 -0
- package/dist/{vocab-89qErSc9.js → vocab-BWoeZsME.js} +26 -17
- package/dist/vocab-Dw1-yVGg.d.cts +14922 -0
- package/dist/webfinger/handler.test.js +23 -22
- package/dist/webfinger/lookup.test.js +9 -9
- package/dist/webfinger/mod.cjs +9 -0
- package/dist/webfinger/mod.d.cts +4 -0
- package/dist/webfinger/mod.js +6 -6
- package/dist/webfinger-BjOEdFPs.cjs +4 -0
- package/dist/webfinger-De_bU0iE.js +4 -0
- package/dist/x/cfworkers.cjs +100 -0
- package/dist/x/cfworkers.d.cts +59 -0
- package/dist/x/cfworkers.js +3 -3
- package/dist/x/cfworkers.test.js +8 -8
- package/dist/x/hono.cjs +61 -0
- package/dist/x/hono.d.cts +54 -0
- package/dist/x/hono.d.ts +6 -6
- package/dist/x/hono.js +3 -3
- package/dist/x/sveltekit.cjs +69 -0
- package/dist/x/sveltekit.d.cts +46 -0
- package/dist/x/sveltekit.d.ts +6 -6
- package/dist/x/sveltekit.js +3 -3
- package/package.json +68 -13
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/key-BteSu1lX.js +0 -10
- package/dist/middleware-CNfiKLIZ.js +0 -25
- package/dist/middleware-CnvU63kV.js +0 -17
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/webfinger-C3GIyXIg.js +0 -4
- /package/dist/{assert_is_error-B035L3om.js → assert_is_error-BPGph1Jx.js} +0 -0
- /package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals-f3m3epl3.js} +0 -0
- /package/dist/{denokv-jZ0Z2h0M.js → denokv-Bv33Xxea.js} +0 -0
- /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
- /package/dist/{std__assert-DWivtrGR.js → std__assert-X-_kMxKM.js} +0 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
require('../transformers-CoBS-oFG.cjs');
|
6
|
+
require('../docloader-CCqXeagZ.cjs');
|
7
|
+
require('../actor-Be0ThtXy.cjs');
|
8
|
+
const require_middleware = require('../middleware-BmoOlgc1.cjs');
|
9
|
+
require('../lookup-hnMAAU5r.cjs');
|
10
|
+
require('../key-Z6ceKnZC.cjs');
|
11
|
+
require('../http-C7vbQwbz.cjs');
|
12
|
+
require('../proof-B-eqv0Ug.cjs');
|
13
|
+
const require_federation = require('../federation-H2_En3j5.cjs');
|
14
|
+
require('../types-zqdWZh4O.cjs');
|
15
|
+
require('../authdocloader-OSn_teLV.cjs');
|
16
|
+
require('../vocab-B39-pFl9.cjs');
|
17
|
+
|
18
|
+
exports.InProcessMessageQueue = require_federation.InProcessMessageQueue;
|
19
|
+
exports.MemoryKvStore = require_federation.MemoryKvStore;
|
20
|
+
exports.ParallelMessageQueue = require_federation.ParallelMessageQueue;
|
21
|
+
exports.Router = require_middleware.Router;
|
22
|
+
exports.RouterError = require_middleware.RouterError;
|
23
|
+
exports.buildCollectionSynchronizationHeader = require_middleware.buildCollectionSynchronizationHeader;
|
24
|
+
exports.createExponentialBackoffPolicy = require_middleware.createExponentialBackoffPolicy;
|
25
|
+
exports.createFederation = require_middleware.createFederation;
|
26
|
+
exports.createFederationBuilder = require_middleware.createFederationBuilder;
|
27
|
+
exports.digest = require_middleware.digest;
|
28
|
+
exports.respondWithObject = require_middleware.respondWithObject;
|
29
|
+
exports.respondWithObjectIfAcceptable = require_middleware.respondWithObjectIfAcceptable;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { KvKey, KvStore, KvStoreSetOptions, MemoryKvStore } from "../kv-63Cil1MD.cjs";
|
2
|
+
import "../docloader-D-MrRyHl.cjs";
|
3
|
+
import "../client-CegPX0Rn.cjs";
|
4
|
+
import "../vocab-Dw1-yVGg.cjs";
|
5
|
+
import "../actor-D6K058Tb.cjs";
|
6
|
+
import "../http-D-e6AFwR.cjs";
|
7
|
+
import "../owner-BN_tO3cY.cjs";
|
8
|
+
import "../mod-CxkWO3Mg.cjs";
|
9
|
+
import "../mod-jQ4OODsl.cjs";
|
10
|
+
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, 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 } from "../context-C5BsZkDr.cjs";
|
11
|
+
import { InProcessMessageQueue, InProcessMessageQueueOptions, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, ParallelMessageQueue } from "../mq-B7R1Q-M5.cjs";
|
12
|
+
import "../mod-C2tOeRkN.cjs";
|
13
|
+
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, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParamsKeyPath, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
|
package/dist/federation/mod.d.ts
CHANGED
@@ -3,13 +3,13 @@ import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
import { KvKey, KvStore, KvStoreSetOptions, MemoryKvStore } from "../kv-C7sopW2E.js";
|
4
4
|
import "../docloader-CxWcuWqQ.js";
|
5
5
|
import "../client-bgSdkFa2.js";
|
6
|
-
import "../vocab-
|
7
|
-
import "../actor-
|
8
|
-
import "../http-
|
9
|
-
import "../owner-
|
10
|
-
import "../mod-
|
6
|
+
import "../vocab-BI0Ak5lL.js";
|
7
|
+
import "../actor-T6RyhRgk.js";
|
8
|
+
import "../http-D6Uj2x2y.js";
|
9
|
+
import "../owner-hd9lvQcP.js";
|
10
|
+
import "../mod-DlU8ISoa.js";
|
11
11
|
import "../mod-DBzN0aCM.js";
|
12
|
-
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, 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 } from "../context-
|
12
|
+
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, 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 } from "../context-ByZprN0S.js";
|
13
13
|
import { InProcessMessageQueue, InProcessMessageQueueOptions, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, ParallelMessageQueue } from "../mq-CRGm1e_F.js";
|
14
14
|
import "../mod-g0xFzAP9.js";
|
15
|
-
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, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParamsKeyPath, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
|
15
|
+
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, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParamsKeyPath, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
|
package/dist/federation/mod.js
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import "../transformers-
|
6
|
-
import "../docloader-
|
7
|
-
import "../actor-
|
8
|
-
import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-
|
9
|
-
import "../lookup-
|
10
|
-
import "../key-
|
11
|
-
import "../http-
|
12
|
-
import "../proof-
|
13
|
-
import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "../federation-
|
14
|
-
import "../types-
|
15
|
-
import "../authdocloader-
|
16
|
-
import "../vocab-
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import "../transformers-BFT6d7J5.js";
|
6
|
+
import "../docloader-XK3y2jn5.js";
|
7
|
+
import "../actor-ChbPLm6n.js";
|
8
|
+
import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-Bz_A2jeJ.js";
|
9
|
+
import "../lookup-BPviO8ij.js";
|
10
|
+
import "../key-jyNTxCvK.js";
|
11
|
+
import "../http-BxbM8sEy.js";
|
12
|
+
import "../proof-DfgvA3al.js";
|
13
|
+
import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "../federation-D1U8YY9t.js";
|
14
|
+
import "../types-DqxyTxOf.js";
|
15
|
+
import "../authdocloader-CrxhFL8e.js";
|
16
|
+
import "../vocab-BWoeZsME.js";
|
17
17
|
|
18
18
|
export { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue, Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
|
@@ -3,17 +3,17 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import "../type-
|
6
|
+
import "../type-C69ZBu7f.js";
|
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 "../lookup-
|
11
|
-
import { test } from "../testing-
|
12
|
-
import { assertGreater, assertGreaterOrEqual } from "../std__assert-
|
13
|
-
import { assertFalse } from "../assert_rejects-
|
14
|
-
import "../assert_is_error-
|
15
|
-
import "../assert_not_equals-
|
16
|
-
import "../assert_throws-
|
10
|
+
import "../lookup-pV0JOsuV.js";
|
11
|
+
import { test } from "../testing-BWNCAbL-.js";
|
12
|
+
import { assertGreater, assertGreaterOrEqual } from "../std__assert-X-_kMxKM.js";
|
13
|
+
import { assertFalse } from "../assert_rejects-DiIiJbZn.js";
|
14
|
+
import "../assert_is_error-BPGph1Jx.js";
|
15
|
+
import "../assert_not_equals-f3m3epl3.js";
|
16
|
+
import "../assert_throws-BOO88avQ.js";
|
17
17
|
import { delay } from "es-toolkit";
|
18
18
|
|
19
19
|
//#region src/federation/mq.ts
|
@@ -227,7 +227,7 @@ test("InProcessMessageQueue", async (t) => {
|
|
227
227
|
});
|
228
228
|
test("MessageQueue.nativeRetrial", async (t) => {
|
229
229
|
if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") await t.step("DenoKvMessageQueue", async () => {
|
230
|
-
const { DenoKvMessageQueue } = await import("../denokv-
|
230
|
+
const { DenoKvMessageQueue } = await import("../denokv-Bv33Xxea.js");
|
231
231
|
const mq = new DenoKvMessageQueue(await globalThis.Deno.openKv(":memory:"));
|
232
232
|
assert(mq.nativeRetrial);
|
233
233
|
if (Symbol.dispose in mq) {
|
@@ -266,7 +266,7 @@ test("MessageQueue.nativeRetrial", async (t) => {
|
|
266
266
|
});
|
267
267
|
const queues = { InProcessMessageQueue: () => Promise.resolve(new InProcessMessageQueue()) };
|
268
268
|
if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") {
|
269
|
-
const { DenoKvMessageQueue } = await import("../denokv-
|
269
|
+
const { DenoKvMessageQueue } = await import("../denokv-Bv33Xxea.js");
|
270
270
|
queues.DenoKvMessageQueue = async () => new DenoKvMessageQueue(await globalThis.Deno.openKv(":memory:"));
|
271
271
|
}
|
272
272
|
for (const mqName in queues) test({
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
globalThis.addEventListener = () => {};
|
5
|
+
|
6
|
+
import "../type-C69ZBu7f.js";
|
7
|
+
import "../assert_equals-DSbWqCm3.js";
|
8
|
+
import { assert } from "../assert-MZs1qjMx.js";
|
9
|
+
import "../assert_instance_of-DHz7EHNU.js";
|
10
|
+
import "../lookup-pV0JOsuV.js";
|
11
|
+
import { acceptsJsonLd } from "../negotiation-5NPJL6zp.js";
|
12
|
+
import { test } from "../testing-BWNCAbL-.js";
|
13
|
+
import "../std__assert-X-_kMxKM.js";
|
14
|
+
import { assertFalse } from "../assert_rejects-DiIiJbZn.js";
|
15
|
+
import "../assert_is_error-BPGph1Jx.js";
|
16
|
+
import "../assert_not_equals-f3m3epl3.js";
|
17
|
+
import "../assert_throws-BOO88avQ.js";
|
18
|
+
|
19
|
+
//#region src/federation/negotiation.test.ts
|
20
|
+
test("acceptsJsonLd()", () => {
|
21
|
+
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/activity+json" } })));
|
22
|
+
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json" } })));
|
23
|
+
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/json" } })));
|
24
|
+
assertFalse(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json; q=0.5, text/html; q=0.8" } })));
|
25
|
+
assertFalse(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json; q=0.4, application/xhtml+xml; q=0.9" } })));
|
26
|
+
});
|
27
|
+
|
28
|
+
//#endregion
|
@@ -3,12 +3,12 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import "../type-
|
6
|
+
import "../type-C69ZBu7f.js";
|
7
7
|
import { AssertionError, assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
|
-
import "../lookup-
|
9
|
-
import { createExponentialBackoffPolicy } from "../retry-
|
10
|
-
import { test } from "../testing-
|
11
|
-
import { assertNotEquals } from "../assert_not_equals-
|
8
|
+
import "../lookup-pV0JOsuV.js";
|
9
|
+
import { createExponentialBackoffPolicy } from "../retry-D4GJ670a.js";
|
10
|
+
import { test } from "../testing-BWNCAbL-.js";
|
11
|
+
import { assertNotEquals } from "../assert_not_equals-f3m3epl3.js";
|
12
12
|
|
13
13
|
//#region src/federation/retry.test.ts
|
14
14
|
test("createExponentialBackoffPolicy()", () => {
|
@@ -3,17 +3,17 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import "../type-
|
6
|
+
import "../type-C69ZBu7f.js";
|
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 { Router, RouterError } from "../lookup-
|
11
|
-
import { test } from "../testing-
|
12
|
-
import "../std__assert-
|
13
|
-
import { assertFalse } from "../assert_rejects-
|
14
|
-
import "../assert_is_error-
|
15
|
-
import "../assert_not_equals-
|
16
|
-
import { assertThrows } from "../assert_throws-
|
10
|
+
import { Router, RouterError } from "../lookup-pV0JOsuV.js";
|
11
|
+
import { test } from "../testing-BWNCAbL-.js";
|
12
|
+
import "../std__assert-X-_kMxKM.js";
|
13
|
+
import { assertFalse } from "../assert_rejects-DiIiJbZn.js";
|
14
|
+
import "../assert_is_error-BPGph1Jx.js";
|
15
|
+
import "../assert_not_equals-f3m3epl3.js";
|
16
|
+
import { assertThrows } from "../assert_throws-BOO88avQ.js";
|
17
17
|
|
18
18
|
//#region src/federation/router.test.ts
|
19
19
|
function setUp(options = {}) {
|
@@ -3,24 +3,24 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Activity, Application, Endpoints, Group, Person, Service } from "../type-
|
6
|
+
import { Activity, Application, Endpoints, Group, Person, Service } from "../type-C69ZBu7f.js";
|
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 "../lookup-
|
11
|
-
import "../actor-
|
12
|
-
import "../key-
|
13
|
-
import { verifyRequest } from "../http-
|
14
|
-
import { doesActorOwnKey } from "../owner-
|
15
|
-
import { extractInboxes, sendActivity } from "../send-
|
16
|
-
import { mockDocumentLoader, test } from "../testing-
|
17
|
-
import "../std__assert-
|
18
|
-
import { assertFalse, assertRejects } from "../assert_rejects-
|
19
|
-
import "../assert_is_error-
|
20
|
-
import { assertNotEquals } from "../assert_not_equals-
|
21
|
-
import "../assert_throws-
|
22
|
-
import { ed25519Multikey, ed25519PrivateKey, rsaPrivateKey2, rsaPublicKey2 } from "../keys-
|
23
|
-
import { esm_default } from "../esm-
|
10
|
+
import "../lookup-pV0JOsuV.js";
|
11
|
+
import "../actor-DuCeRiNh.js";
|
12
|
+
import "../key-1KXru8Ug.js";
|
13
|
+
import { verifyRequest } from "../http-BNOYnVsU.js";
|
14
|
+
import { doesActorOwnKey } from "../owner-e3FYDhsk.js";
|
15
|
+
import { extractInboxes, sendActivity } from "../send-Tl9NOnmO.js";
|
16
|
+
import { mockDocumentLoader, test } from "../testing-BWNCAbL-.js";
|
17
|
+
import "../std__assert-X-_kMxKM.js";
|
18
|
+
import { assertFalse, assertRejects } from "../assert_rejects-DiIiJbZn.js";
|
19
|
+
import "../assert_is_error-BPGph1Jx.js";
|
20
|
+
import { assertNotEquals } from "../assert_not_equals-f3m3epl3.js";
|
21
|
+
import "../assert_throws-BOO88avQ.js";
|
22
|
+
import { ed25519Multikey, ed25519PrivateKey, rsaPrivateKey2, rsaPublicKey2 } from "../keys-BPdFKgiy.js";
|
23
|
+
import { esm_default } from "../esm-DnIzfEj0.js";
|
24
24
|
|
25
25
|
//#region src/federation/send.test.ts
|
26
26
|
test("extractInboxes()", () => {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
5
|
import { isEqual } from "es-toolkit";
|
6
6
|
|
7
7
|
//#region src/federation/kv.ts
|
@@ -0,0 +1,244 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
const require_chunk = require('./chunk-DqRYRqnO.cjs');
|
6
|
+
const es_toolkit = require_chunk.__toESM(require("es-toolkit"));
|
7
|
+
|
8
|
+
//#region src/federation/kv.ts
|
9
|
+
/**
|
10
|
+
* A key–value store that stores values in memory.
|
11
|
+
* Do not use this in production as it does not persist values.
|
12
|
+
*
|
13
|
+
* @since 0.5.0
|
14
|
+
*/
|
15
|
+
var MemoryKvStore = class {
|
16
|
+
#values = {};
|
17
|
+
#encodeKey(key) {
|
18
|
+
return JSON.stringify(key);
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* {@inheritDoc KvStore.get}
|
22
|
+
*/
|
23
|
+
get(key) {
|
24
|
+
const encodedKey = this.#encodeKey(key);
|
25
|
+
const entry = this.#values[encodedKey];
|
26
|
+
if (entry == null) return Promise.resolve(void 0);
|
27
|
+
const [value, expiration] = entry;
|
28
|
+
if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
|
29
|
+
delete this.#values[encodedKey];
|
30
|
+
return Promise.resolve(void 0);
|
31
|
+
}
|
32
|
+
return Promise.resolve(value);
|
33
|
+
}
|
34
|
+
/**
|
35
|
+
* {@inheritDoc KvStore.set}
|
36
|
+
*/
|
37
|
+
set(key, value, options) {
|
38
|
+
const encodedKey = this.#encodeKey(key);
|
39
|
+
const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
|
40
|
+
this.#values[encodedKey] = [value, expiration];
|
41
|
+
return Promise.resolve();
|
42
|
+
}
|
43
|
+
/**
|
44
|
+
* {@inheritDoc KvStore.delete}
|
45
|
+
*/
|
46
|
+
delete(key) {
|
47
|
+
const encodedKey = this.#encodeKey(key);
|
48
|
+
delete this.#values[encodedKey];
|
49
|
+
return Promise.resolve();
|
50
|
+
}
|
51
|
+
/**
|
52
|
+
* {@inheritDoc KvStore.cas}
|
53
|
+
*/
|
54
|
+
cas(key, expectedValue, newValue, options) {
|
55
|
+
const encodedKey = this.#encodeKey(key);
|
56
|
+
const entry = this.#values[encodedKey];
|
57
|
+
let currentValue;
|
58
|
+
if (entry == null) currentValue = void 0;
|
59
|
+
else {
|
60
|
+
const [value, expiration$1] = entry;
|
61
|
+
if (expiration$1 != null && Temporal.Now.instant().until(expiration$1).sign < 0) {
|
62
|
+
delete this.#values[encodedKey];
|
63
|
+
currentValue = void 0;
|
64
|
+
} else currentValue = value;
|
65
|
+
}
|
66
|
+
if (!(0, es_toolkit.isEqual)(currentValue, expectedValue)) return Promise.resolve(false);
|
67
|
+
const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
|
68
|
+
this.#values[encodedKey] = [newValue, expiration];
|
69
|
+
return Promise.resolve(true);
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
//#endregion
|
74
|
+
//#region src/federation/mq.ts
|
75
|
+
/**
|
76
|
+
* A message queue that processes messages in the same process.
|
77
|
+
* Do not use this in production as it does neither persist messages nor
|
78
|
+
* distribute them across multiple processes.
|
79
|
+
*
|
80
|
+
* @since 0.5.0
|
81
|
+
*/
|
82
|
+
var InProcessMessageQueue = class {
|
83
|
+
#messages;
|
84
|
+
#monitors;
|
85
|
+
#pollIntervalMs;
|
86
|
+
/**
|
87
|
+
* In-process message queue does not provide native retry mechanisms.
|
88
|
+
* @since 1.7.0
|
89
|
+
*/
|
90
|
+
nativeRetrial = false;
|
91
|
+
/**
|
92
|
+
* Constructs a new {@link InProcessMessageQueue} with the given options.
|
93
|
+
* @param options Additional options for the in-process message queue.
|
94
|
+
*/
|
95
|
+
constructor(options = {}) {
|
96
|
+
this.#messages = [];
|
97
|
+
this.#monitors = {};
|
98
|
+
this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
|
99
|
+
}
|
100
|
+
enqueue(message, options) {
|
101
|
+
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
102
|
+
if (delay > 0) {
|
103
|
+
setTimeout(() => this.enqueue(message, {
|
104
|
+
...options,
|
105
|
+
delay: void 0
|
106
|
+
}), delay);
|
107
|
+
return Promise.resolve();
|
108
|
+
}
|
109
|
+
this.#messages.push(message);
|
110
|
+
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
111
|
+
return Promise.resolve();
|
112
|
+
}
|
113
|
+
enqueueMany(messages, options) {
|
114
|
+
if (messages.length === 0) return Promise.resolve();
|
115
|
+
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
116
|
+
if (delay > 0) {
|
117
|
+
setTimeout(() => this.enqueueMany(messages, {
|
118
|
+
...options,
|
119
|
+
delay: void 0
|
120
|
+
}), delay);
|
121
|
+
return Promise.resolve();
|
122
|
+
}
|
123
|
+
this.#messages.push(...messages);
|
124
|
+
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
125
|
+
return Promise.resolve();
|
126
|
+
}
|
127
|
+
async listen(handler, options = {}) {
|
128
|
+
const signal = options.signal;
|
129
|
+
while (signal == null || !signal.aborted) {
|
130
|
+
while (this.#messages.length > 0) {
|
131
|
+
const message = this.#messages.shift();
|
132
|
+
await handler(message);
|
133
|
+
}
|
134
|
+
await this.#wait(this.#pollIntervalMs, signal);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
#wait(ms, signal) {
|
138
|
+
let timer = null;
|
139
|
+
return Promise.any([new Promise((resolve) => {
|
140
|
+
signal?.addEventListener("abort", () => {
|
141
|
+
if (timer != null) clearTimeout(timer);
|
142
|
+
resolve();
|
143
|
+
}, { once: true });
|
144
|
+
const monitorId = crypto.randomUUID();
|
145
|
+
this.#monitors[monitorId] = () => {
|
146
|
+
delete this.#monitors[monitorId];
|
147
|
+
if (timer != null) clearTimeout(timer);
|
148
|
+
resolve();
|
149
|
+
};
|
150
|
+
}), new Promise((resolve) => timer = setTimeout(resolve, ms))]);
|
151
|
+
}
|
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
|
+
* @since 1.0.0
|
167
|
+
*/
|
168
|
+
var ParallelMessageQueue = class ParallelMessageQueue {
|
169
|
+
queue;
|
170
|
+
workers;
|
171
|
+
/**
|
172
|
+
* Inherits the native retry capability from the wrapped queue.
|
173
|
+
* @since 1.7.0
|
174
|
+
*/
|
175
|
+
nativeRetrial;
|
176
|
+
/**
|
177
|
+
* Constructs a new {@link ParallelMessageQueue} with the given queue and
|
178
|
+
* number of workers.
|
179
|
+
* @param queue The message queue to use under the hood. Note that
|
180
|
+
* {@link ParallelMessageQueue} cannot be nested.
|
181
|
+
* @param workers The number of workers to process messages in parallel.
|
182
|
+
* @throws {TypeError} If the given queue is an instance of
|
183
|
+
* {@link ParallelMessageQueue}.
|
184
|
+
*/
|
185
|
+
constructor(queue, workers) {
|
186
|
+
if (queue instanceof ParallelMessageQueue) throw new TypeError("Cannot nest ParallelMessageQueue.");
|
187
|
+
this.queue = queue;
|
188
|
+
this.workers = workers;
|
189
|
+
this.nativeRetrial = queue.nativeRetrial;
|
190
|
+
}
|
191
|
+
enqueue(message, options) {
|
192
|
+
return this.queue.enqueue(message, options);
|
193
|
+
}
|
194
|
+
async enqueueMany(messages, options) {
|
195
|
+
if (this.queue.enqueueMany == null) {
|
196
|
+
const results = await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)));
|
197
|
+
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
198
|
+
if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
|
199
|
+
else if (errors.length === 1) throw errors[0];
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
await this.queue.enqueueMany(messages, options);
|
203
|
+
}
|
204
|
+
listen(handler, options = {}) {
|
205
|
+
const workers = /* @__PURE__ */ new Map();
|
206
|
+
return this.queue.listen(async (message) => {
|
207
|
+
while (workers.size >= this.workers) {
|
208
|
+
const consumedId = await Promise.any(workers.values());
|
209
|
+
workers.delete(consumedId);
|
210
|
+
}
|
211
|
+
const workerId = crypto.randomUUID();
|
212
|
+
const promise = this.#work(workerId, handler, message);
|
213
|
+
workers.set(workerId, promise);
|
214
|
+
}, options);
|
215
|
+
}
|
216
|
+
async #work(workerId, handler, message) {
|
217
|
+
await this.#sleep(0);
|
218
|
+
await handler(message);
|
219
|
+
return workerId;
|
220
|
+
}
|
221
|
+
#sleep(ms) {
|
222
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
223
|
+
}
|
224
|
+
};
|
225
|
+
|
226
|
+
//#endregion
|
227
|
+
Object.defineProperty(exports, 'InProcessMessageQueue', {
|
228
|
+
enumerable: true,
|
229
|
+
get: function () {
|
230
|
+
return InProcessMessageQueue;
|
231
|
+
}
|
232
|
+
});
|
233
|
+
Object.defineProperty(exports, 'MemoryKvStore', {
|
234
|
+
enumerable: true,
|
235
|
+
get: function () {
|
236
|
+
return MemoryKvStore;
|
237
|
+
}
|
238
|
+
});
|
239
|
+
Object.defineProperty(exports, 'ParallelMessageQueue', {
|
240
|
+
enumerable: true,
|
241
|
+
get: function () {
|
242
|
+
return ParallelMessageQueue;
|
243
|
+
}
|
244
|
+
});
|
@@ -3,8 +3,8 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { CryptographicKey, deno_default } from "./type-
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-
|
6
|
+
import { CryptographicKey, deno_default } from "./type-C69ZBu7f.js";
|
7
|
+
import { fetchKey, validateCryptoKey } from "./key-1KXru8Ug.js";
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
10
10
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
@@ -1,10 +1,10 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import { deno_default } from "./docloader-
|
6
|
-
import { CryptographicKey } from "./actor-
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import { deno_default } from "./docloader-XK3y2jn5.js";
|
6
|
+
import { CryptographicKey } from "./actor-ChbPLm6n.js";
|
7
|
+
import { fetchKey, validateCryptoKey } from "./key-jyNTxCvK.js";
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
10
10
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|