@fedify/fedify 2.4.0-dev.1422 → 2.4.0-dev.1431
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/{assert-DikXweDx.mjs → assert-OguE97r2.mjs} +1 -1
- package/dist/{assert_instance_of-C4Ri6VuN.mjs → assert_instance_of-DBC5X09g.mjs} +1 -1
- package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-DkVK8oqV.mjs} +1 -1
- package/dist/{assert_rejects-DQP-q39h.mjs → assert_rejects-DN60FHPX.mjs} +2 -2
- package/dist/{assert_strict_equals-Dmjbg-bA.mjs → assert_strict_equals-XEgZAlrj.mjs} +1 -1
- package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-BOkhLGYc.mjs} +1 -1
- package/dist/{builder-Gef_ZeDE.mjs → builder-CZR-efLj.mjs} +3 -23
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +3 -3
- package/dist/compat/public-audience.test.mjs +3 -3
- package/dist/compat/transformers.test.mjs +5 -5
- package/dist/{context-BuGH_Vft.d.cts → context-BBVLF7lx.d.cts} +70 -286
- package/dist/{context-CLtZxCu6.d.ts → context-BU6jSQdo.d.ts} +70 -285
- package/dist/{context-BrIOaBSs.mjs → context-DVoTs_wM.mjs} +1 -7
- package/dist/{deno-BmD7XRaO.mjs → deno-DTMxScEV.mjs} +1 -1
- package/dist/{docloader-B8AJowCx.mjs → docloader-BfWi9rXZ.mjs} +2 -2
- package/dist/federation/builder.test.mjs +5 -5
- package/dist/federation/circuit-breaker.test.mjs +5 -5
- package/dist/federation/collection.test.mjs +3 -3
- package/dist/federation/handler.test.mjs +13 -13
- package/dist/federation/idempotency.test.mjs +6 -6
- package/dist/federation/inbox.test.mjs +3 -3
- package/dist/federation/keycache.test.mjs +5 -5
- package/dist/federation/kv.test.mjs +3 -3
- package/dist/federation/metrics.test.mjs +4 -4
- package/dist/federation/middleware.test.mjs +19 -200
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +260 -5
- package/dist/federation/negotiation.test.mjs +4 -4
- package/dist/federation/retry.test.mjs +3 -3
- package/dist/federation/router.test.mjs +5 -5
- package/dist/federation/send.test.mjs +10 -10
- package/dist/federation/temporal.test.mjs +4 -4
- package/dist/federation/webfinger.test.mjs +6 -6
- package/dist/{http-GQoPA_YT.mjs → http-BCpKHsqy.mjs} +4 -4
- package/dist/{http-BCSQJ_gv.cjs → http-CIwbPzeL.cjs} +17 -7
- package/dist/{http-CJ0WNyqA.js → http-D07vE9PZ.js} +17 -7
- package/dist/{key-BLy_TeTg.mjs → key-BjyR4b3H.mjs} +18 -8
- package/dist/{kv-cache-DXwu7BtY.cjs → kv-cache-CXj8cbEx.cjs} +1 -1
- package/dist/{kv-cache-pw-kBdVz.mjs → kv-cache-IEJVfSBn.mjs} +1 -1
- package/dist/{kv-cache-CjEcb9qH.js → kv-cache-LdHRMYlC.js} +1 -1
- package/dist/{ld-CWgxPlZq.mjs → ld-xrOJDs7P.mjs} +3 -3
- package/dist/{metrics-DUKoLd_E.mjs → metrics-BAQhI4a7.mjs} +1 -1
- package/dist/{middleware-BiCk4wGY.cjs → middleware-B1l3sgj_.cjs} +31 -281
- package/dist/{middleware-Dq-HhJHd.mjs → middleware-BQ8dje7a.mjs} +1 -1
- package/dist/{middleware-2Us0G3Iy.js → middleware-BgK5j6TR.js} +31 -281
- package/dist/{middleware-PZaroDUk.mjs → middleware-CvPc_n0b.mjs} +44 -186
- package/dist/{mod-DRokcHeU.d.cts → mod-C0F6kvgS.d.cts} +1 -1
- package/dist/{mod-r-1xOW_C.d.ts → mod-vPYVoa5n.d.ts} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.d.cts +4 -4
- package/dist/mod.d.ts +4 -4
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/client.test.mjs +3 -3
- package/dist/nodeinfo/handler.test.mjs +5 -5
- package/dist/nodeinfo/types.test.mjs +4 -4
- package/dist/otel/exporter.test.mjs +3 -3
- package/dist/{outgoing-jsonld-BgFLCJQ_.mjs → outgoing-jsonld-L_DbOaFe.mjs} +1 -1
- package/dist/{owner-U0Z8Ex6i.mjs → owner-CHvv4iAW.mjs} +2 -2
- package/dist/{proof-f7K32nz7.js → proof-C9nqy_mp.js} +1 -1
- package/dist/{proof-nb5tfciW.mjs → proof-DOIrkqW_.mjs} +5 -5
- package/dist/{proof-DA3hLGSO.cjs → proof-pmMnJMQe.cjs} +1 -1
- package/dist/{send-CLfW5Fdf.mjs → send-CC8034Mb.mjs} +3 -3
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +8 -8
- package/dist/sig/key.test.mjs +56 -6
- package/dist/sig/ld.test.mjs +7 -7
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +6 -6
- package/dist/sig/proof.test.mjs +8 -8
- package/dist/{std__assert-BTEgfoJo.mjs → std__assert-BBjXFNOb.mjs} +4 -4
- package/dist/{temporal-2ry_jdCK.mjs → temporal-CJdpFg8A.mjs} +1 -1
- package/dist/testing/mod.d.mts +7 -378
- package/dist/testing/mod.mjs +2 -3
- package/dist/utils/docloader.test.mjs +6 -6
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -8
- package/dist/codec-Bf-rTqks.mjs +0 -94
- package/dist/federation/tasks/codec.test.d.mts +0 -2
- package/dist/federation/tasks/codec.test.mjs +0 -292
- package/dist/federation/tasks/tasks.test.d.mts +0 -2
- package/dist/federation/tasks/tasks.test.mjs +0 -651
- package/dist/mq-CvJAzRz5.mjs +0 -260
- package/dist/testing-CjYPStvE.mjs +0 -55
- /package/dist/{accept-CceiKpCy.mjs → accept-CPkZzmGN.mjs} +0 -0
- /package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-tztVvlNb.mjs} +0 -0
- /package/dist/{assert_equals-Ew3jOFa3.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
- /package/dist/{circuit-breaker-hJBB6jwA.mjs → circuit-breaker-CSWsyoef.mjs} +0 -0
- /package/dist/{client-B_A6mfn3.mjs → client-ByXmQhYD.mjs} +0 -0
- /package/dist/{collection-Dp5ky45w.mjs → collection-Cc3DVAhE.mjs} +0 -0
- /package/dist/{keycache-CaOR6NYg.mjs → keycache-BeU0LCII.mjs} +0 -0
- /package/dist/{keys-C3kae-6B.mjs → keys-DGu1NFwu.mjs} +0 -0
- /package/dist/{kv-x2IvBUyq.mjs → kv-rV3vodCc.mjs} +0 -0
- /package/dist/{negotiation-m_L2nyS3.mjs → negotiation-DDstyBvc.mjs} +0 -0
- /package/dist/{public-audience-N3pyOx2p.mjs → public-audience-Cvbr2Gzt.mjs} +0 -0
- /package/dist/{retry-DI4O-zYl.mjs → retry-CXg_MBI-.mjs} +0 -0
- /package/dist/{types-BFowWFTT.mjs → types-J53Kw7so.mjs} +0 -0
package/dist/testing/mod.d.mts
CHANGED
|
@@ -2,12 +2,11 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
import { ExportResultCode } from "@opentelemetry/core";
|
|
4
4
|
import { Router } from "@fedify/uri-template";
|
|
5
|
-
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey,
|
|
5
|
+
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
|
|
6
6
|
import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
|
|
7
7
|
import { MeterProvider, TracerProvider } from "@opentelemetry/api";
|
|
8
8
|
import { DocumentLoader, GetUserAgentOptions } from "@fedify/vocab-runtime";
|
|
9
9
|
import { MeterProvider as MeterProvider$1, MetricReader } from "@opentelemetry/sdk-metrics";
|
|
10
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
11
10
|
|
|
12
11
|
//#region src/nodeinfo/types.d.ts
|
|
13
12
|
/**
|
|
@@ -581,278 +580,6 @@ type CustomCollectionCounter<TParam extends string, TContextData> = (context: Re
|
|
|
581
580
|
*/
|
|
582
581
|
type CustomCollectionCursor<TParam extends string, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: Record<TParam, string>) => string | null | Promise<string | null>;
|
|
583
582
|
//#endregion
|
|
584
|
-
//#region src/federation/mq.d.ts
|
|
585
|
-
/**
|
|
586
|
-
* Additional options for enqueuing a message in a queue.
|
|
587
|
-
*
|
|
588
|
-
* @since 0.5.0
|
|
589
|
-
*/
|
|
590
|
-
interface MessageQueueEnqueueOptions {
|
|
591
|
-
/**
|
|
592
|
-
* The delay before the message is enqueued. No delay by default.
|
|
593
|
-
*
|
|
594
|
-
* It must not be negative.
|
|
595
|
-
*/
|
|
596
|
-
readonly delay?: Temporal.Duration;
|
|
597
|
-
/**
|
|
598
|
-
* An optional key that ensures messages with the same ordering key are
|
|
599
|
-
* processed sequentially (one at a time). Messages with different ordering
|
|
600
|
-
* keys (or no ordering key) may be processed in parallel.
|
|
601
|
-
*
|
|
602
|
-
* This is useful for ensuring that related messages are processed in order,
|
|
603
|
-
* such as ensuring that a `Delete` activity is processed after a `Create`
|
|
604
|
-
* activity for the same object.
|
|
605
|
-
*
|
|
606
|
-
* @since 2.0.0
|
|
607
|
-
*/
|
|
608
|
-
readonly orderingKey?: string;
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* Additional options for listening to a message queue.
|
|
612
|
-
*
|
|
613
|
-
* @since 1.0.0
|
|
614
|
-
*/
|
|
615
|
-
interface MessageQueueListenOptions {
|
|
616
|
-
/**
|
|
617
|
-
* The signal to abort listening to the message queue.
|
|
618
|
-
*/
|
|
619
|
-
signal?: AbortSignal;
|
|
620
|
-
}
|
|
621
|
-
/**
|
|
622
|
-
* The number of messages waiting in a message queue.
|
|
623
|
-
*
|
|
624
|
-
* @since 2.3.0
|
|
625
|
-
*/
|
|
626
|
-
interface MessageQueueDepth {
|
|
627
|
-
/**
|
|
628
|
-
* The total number of messages still waiting in the backend queue.
|
|
629
|
-
*
|
|
630
|
-
* This does not include messages that have already been handed to a worker
|
|
631
|
-
* for processing.
|
|
632
|
-
*/
|
|
633
|
-
readonly queued: number;
|
|
634
|
-
/**
|
|
635
|
-
* The number of queued messages eligible for immediate processing.
|
|
636
|
-
*
|
|
637
|
-
* Queue backends that cannot cheaply distinguish ready and delayed messages
|
|
638
|
-
* may omit this field.
|
|
639
|
-
*/
|
|
640
|
-
readonly ready?: number;
|
|
641
|
-
/**
|
|
642
|
-
* The number of queued messages scheduled for later delivery.
|
|
643
|
-
*
|
|
644
|
-
* Queue backends that cannot cheaply distinguish ready and delayed messages
|
|
645
|
-
* may omit this field.
|
|
646
|
-
*/
|
|
647
|
-
readonly delayed?: number;
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* An abstract interface for a message queue.
|
|
651
|
-
*
|
|
652
|
-
* @since 0.5.0
|
|
653
|
-
*/
|
|
654
|
-
interface MessageQueue {
|
|
655
|
-
/**
|
|
656
|
-
* Whether the message queue backend provides native retry mechanisms.
|
|
657
|
-
* When `true`, Fedify will skip its own retry logic and rely on the backend
|
|
658
|
-
* to handle retries. When `false` or omitted, Fedify will handle retries
|
|
659
|
-
* using its own retry policies.
|
|
660
|
-
*
|
|
661
|
-
* @default `false`
|
|
662
|
-
* @since 1.7.0
|
|
663
|
-
*/
|
|
664
|
-
readonly nativeRetrial?: boolean;
|
|
665
|
-
/**
|
|
666
|
-
* Enqueues a message in the queue.
|
|
667
|
-
* @param message The message to enqueue.
|
|
668
|
-
* @param options Additional options for enqueuing the message.
|
|
669
|
-
*/
|
|
670
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
671
|
-
/**
|
|
672
|
-
* Enqueues multiple messages in the queue. This operation is optional,
|
|
673
|
-
* and may not be supported by all implementations. If not supported,
|
|
674
|
-
* Fedify will invoke {@link enqueue} for each message.
|
|
675
|
-
*
|
|
676
|
-
* @param messages The messages to enqueue.
|
|
677
|
-
* @param options Additional options for enqueuing the messages.
|
|
678
|
-
*/
|
|
679
|
-
enqueueMany?: (messages: readonly any[], options?: MessageQueueEnqueueOptions) => Promise<void>;
|
|
680
|
-
/**
|
|
681
|
-
* Listens for messages in the queue.
|
|
682
|
-
* @param handler The handler for messages in the queue.
|
|
683
|
-
* @param options Additional options for listening to the message queue.
|
|
684
|
-
* @returns A promise that resolves when the listening is done. It never
|
|
685
|
-
* rejects, and is resolved when the signal is aborted. If no
|
|
686
|
-
* signal is provided, it never resolves.
|
|
687
|
-
*/
|
|
688
|
-
listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
689
|
-
/**
|
|
690
|
-
* Gets the number of messages waiting in the queue.
|
|
691
|
-
*
|
|
692
|
-
* This operation is optional, and may not be supported by all
|
|
693
|
-
* implementations. The returned counts exclude messages currently being
|
|
694
|
-
* handled by a worker.
|
|
695
|
-
*
|
|
696
|
-
* @since 2.3.0
|
|
697
|
-
*/
|
|
698
|
-
getDepth?(): Promise<MessageQueueDepth>;
|
|
699
|
-
}
|
|
700
|
-
//#endregion
|
|
701
|
-
//#region src/federation/retry.d.ts
|
|
702
|
-
/**
|
|
703
|
-
* The context passed to a {@link RetryPolicy} callback.
|
|
704
|
-
* @since 0.12.0
|
|
705
|
-
*/
|
|
706
|
-
interface RetryContext {
|
|
707
|
-
/**
|
|
708
|
-
* The elapsed time since the first attempt.
|
|
709
|
-
*/
|
|
710
|
-
readonly elapsedTime: Temporal.Duration;
|
|
711
|
-
/**
|
|
712
|
-
* The number of attempts so far.
|
|
713
|
-
*/
|
|
714
|
-
readonly attempts: number;
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* A policy that determines the delay before the next retry.
|
|
718
|
-
* @param context The retry context.
|
|
719
|
-
* @returns The delay before the next retry, or `null` to stop retrying.
|
|
720
|
-
* It must not negative.
|
|
721
|
-
* @since 0.12.0
|
|
722
|
-
*/
|
|
723
|
-
type RetryPolicy = (context: RetryContext) => Temporal.Duration | null;
|
|
724
|
-
//#endregion
|
|
725
|
-
//#region src/federation/tasks/task.d.ts
|
|
726
|
-
/**
|
|
727
|
-
* A callback that processes a custom background task.
|
|
728
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
729
|
-
* @template TData The type of the task payload, inferred from the task's
|
|
730
|
-
* schema.
|
|
731
|
-
* @param ctx The context for the worker processing the task.
|
|
732
|
-
* @param data The decoded and validated task payload.
|
|
733
|
-
* @since 2.x.x
|
|
734
|
-
*/
|
|
735
|
-
type TaskHandler<TContextData, TData> = (ctx: Context<TContextData>, data: TData) => Promise<void> | void;
|
|
736
|
-
/**
|
|
737
|
-
* Options for {@link TaskRegistry.defineTask}.
|
|
738
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
739
|
-
* @template TSchema The [Standard Schema](https://standardschema.dev/) that
|
|
740
|
-
* validates the task payload.
|
|
741
|
-
* @since 2.x.x
|
|
742
|
-
*/
|
|
743
|
-
interface TaskDefinitionOptions<TContextData, TSchema extends StandardSchemaV1> {
|
|
744
|
-
/**
|
|
745
|
-
* The [Standard Schema](https://standardschema.dev/) that validates the
|
|
746
|
-
* task payload. The payload type is inferred from this schema.
|
|
747
|
-
*
|
|
748
|
-
* The payload is validated twice: once at enqueue time (fail fast) and
|
|
749
|
-
* once at dequeue time (drift protection against payloads enqueued by an
|
|
750
|
-
* older deployment). Because the same schema runs on both sides, its
|
|
751
|
-
* validation must be idempotent: the validated output must itself be
|
|
752
|
-
* a valid input. Transforming schemas (e.g., Zod's `.transform()`) whose
|
|
753
|
-
* output differs in shape from their input are not supported.
|
|
754
|
-
*/
|
|
755
|
-
readonly schema: TSchema;
|
|
756
|
-
/**
|
|
757
|
-
* The callback that processes the task on a background worker.
|
|
758
|
-
*/
|
|
759
|
-
readonly handler: TaskHandler<TContextData, StandardSchemaV1.InferOutput<TSchema>>;
|
|
760
|
-
/**
|
|
761
|
-
* The retry policy for this task. If omitted, the federation-wide
|
|
762
|
-
* task retry policy is used, which defaults to an exponential backoff
|
|
763
|
-
* policy.
|
|
764
|
-
*/
|
|
765
|
-
readonly retryPolicy?: RetryPolicy;
|
|
766
|
-
/**
|
|
767
|
-
* A callback invoked when the {@link handler} throws an error, before
|
|
768
|
-
* a retry is scheduled.
|
|
769
|
-
* @param ctx The context for the worker processing the task.
|
|
770
|
-
* @param error The error thrown by the handler.
|
|
771
|
-
* @param data The decoded and validated task payload.
|
|
772
|
-
*/
|
|
773
|
-
readonly onError?: (ctx: Context<TContextData>, error: unknown, data: StandardSchemaV1.InferOutput<TSchema>) => Promise<void> | void;
|
|
774
|
-
/**
|
|
775
|
-
* The message queue dedicated to this task. If omitted, the task is
|
|
776
|
-
* routed to the federation-wide task queue, falling back to the outbox
|
|
777
|
-
* queue (unless `taskQueueResolution: "strict"` is configured).
|
|
778
|
-
*/
|
|
779
|
-
readonly queue?: MessageQueue;
|
|
780
|
-
}
|
|
781
|
-
/**
|
|
782
|
-
* Phantom key binding a {@link TaskDefinition} to its federation's context
|
|
783
|
-
* data type. Declared only—no value exists at runtime, and the symbol is
|
|
784
|
-
* not exported, so the marker stays out of user-facing completions.
|
|
785
|
-
*/
|
|
786
|
-
declare const contextDataBrand: unique symbol;
|
|
787
|
-
/**
|
|
788
|
-
* The handle returned by {@link TaskRegistry.defineTask}. It carries the
|
|
789
|
-
* task name and schema so that {@link Context.enqueueTask} can validate the
|
|
790
|
-
* payload and infer its type at every call site.
|
|
791
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
792
|
-
* @template TData The type of the task payload, inferred from the task's
|
|
793
|
-
* schema.
|
|
794
|
-
* @since 2.x.x
|
|
795
|
-
*/
|
|
796
|
-
interface TaskDefinition<TContextData, TData> {
|
|
797
|
-
/**
|
|
798
|
-
* The unique name of the task.
|
|
799
|
-
*/
|
|
800
|
-
readonly name: string;
|
|
801
|
-
/**
|
|
802
|
-
* The [Standard Schema](https://standardschema.dev/) that validates the
|
|
803
|
-
* task payload.
|
|
804
|
-
*/
|
|
805
|
-
readonly schema: StandardSchemaV1<unknown, TData>;
|
|
806
|
-
/**
|
|
807
|
-
* @internal Phantom marker binding the handle to its federation.
|
|
808
|
-
*/
|
|
809
|
-
readonly [contextDataBrand]?: TContextData;
|
|
810
|
-
}
|
|
811
|
-
/**
|
|
812
|
-
* Registration of custom background tasks. Both {@link Federation} and
|
|
813
|
-
* {@link FederationBuilder} implement this interface.
|
|
814
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
815
|
-
* @since 2.x.x
|
|
816
|
-
*/
|
|
817
|
-
interface TaskRegistry<TContextData> {
|
|
818
|
-
/**
|
|
819
|
-
* Defines a custom background task. The returned handle is passed to
|
|
820
|
-
* {@link Context.enqueueTask} to enqueue the task.
|
|
821
|
-
*
|
|
822
|
-
* @example
|
|
823
|
-
* ``` typescript
|
|
824
|
-
* const sendDigest = federation.defineTask("sendDigest", {
|
|
825
|
-
* schema: digestSchema,
|
|
826
|
-
* handler: async (ctx, data) => {
|
|
827
|
-
* // …process the payload on a background worker…
|
|
828
|
-
* },
|
|
829
|
-
* });
|
|
830
|
-
* ```
|
|
831
|
-
*
|
|
832
|
-
* @param name The unique name of the task.
|
|
833
|
-
* @param options The task definition options. The payload type is
|
|
834
|
-
* inferred from `options.schema`.
|
|
835
|
-
* @returns The handle to pass to {@link Context.enqueueTask}.
|
|
836
|
-
* @throws {TypeError} If a task with the same name is already defined.
|
|
837
|
-
*/
|
|
838
|
-
defineTask<TSchema extends StandardSchemaV1>(name: string, options: TaskDefinitionOptions<TContextData, TSchema>): TaskDefinition<TContextData, StandardSchemaV1.InferOutput<TSchema>>;
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Options for {@link Context.enqueueTask} and {@link Context.enqueueTaskMany}.
|
|
842
|
-
* @since 2.x.x
|
|
843
|
-
*/
|
|
844
|
-
interface TaskEnqueueOptions {
|
|
845
|
-
/**
|
|
846
|
-
* The delay before the task is processed. No delay by default.
|
|
847
|
-
*/
|
|
848
|
-
readonly delay?: Temporal.DurationLike;
|
|
849
|
-
/**
|
|
850
|
-
* An optional key that ensures tasks with the same ordering key are
|
|
851
|
-
* processed sequentially (one at a time).
|
|
852
|
-
*/
|
|
853
|
-
readonly orderingKey?: string;
|
|
854
|
-
}
|
|
855
|
-
//#endregion
|
|
856
583
|
//#region src/federation/queue.d.ts
|
|
857
584
|
interface SenderKeyJwkPair {
|
|
858
585
|
readonly keyId: string;
|
|
@@ -867,7 +594,7 @@ interface SenderKeyJwkPair {
|
|
|
867
594
|
* type.
|
|
868
595
|
* @since 1.6.0
|
|
869
596
|
*/
|
|
870
|
-
type Message = FanoutMessage | OutboxMessage | InboxMessage
|
|
597
|
+
type Message = FanoutMessage | OutboxMessage | InboxMessage;
|
|
871
598
|
interface FanoutMessage {
|
|
872
599
|
readonly type: "fanout";
|
|
873
600
|
readonly id: ReturnType<typeof crypto.randomUUID>;
|
|
@@ -921,24 +648,6 @@ interface OutboxMessage {
|
|
|
921
648
|
readonly circuitHeldSince?: string;
|
|
922
649
|
readonly traceContext: Readonly<Record<string, string>>;
|
|
923
650
|
}
|
|
924
|
-
/**
|
|
925
|
-
* A message that carries a custom background task. Every field is
|
|
926
|
-
* a string, number, or plain record so that the message survives both
|
|
927
|
-
* JSON serialization and structured clone on every queue backend.
|
|
928
|
-
* @since 2.x.x
|
|
929
|
-
*/
|
|
930
|
-
interface TaskMessage {
|
|
931
|
-
readonly type: "task";
|
|
932
|
-
readonly id: ReturnType<typeof crypto.randomUUID>;
|
|
933
|
-
readonly baseUrl: string;
|
|
934
|
-
readonly taskName: string;
|
|
935
|
-
/** devalue-encoded task data; vocab objects bridged to expanded JSON-LD. */
|
|
936
|
-
readonly data: string;
|
|
937
|
-
readonly started: string;
|
|
938
|
-
readonly attempt: number;
|
|
939
|
-
readonly orderingKey?: string;
|
|
940
|
-
readonly traceContext: Readonly<Record<string, string>>;
|
|
941
|
-
}
|
|
942
651
|
interface InboxMessage {
|
|
943
652
|
readonly type: "inbox";
|
|
944
653
|
readonly id: ReturnType<typeof crypto.randomUUID>;
|
|
@@ -998,18 +707,18 @@ interface FederationStartQueueOptions {
|
|
|
998
707
|
signal?: AbortSignal;
|
|
999
708
|
/**
|
|
1000
709
|
* Starts the task worker only for the specified queue. If unspecified,
|
|
1001
|
-
* which is the default, the task worker starts for all
|
|
1002
|
-
* inbox, outbox,
|
|
710
|
+
* which is the default, the task worker starts for all three queues:
|
|
711
|
+
* inbox, outbox, and fanout.
|
|
1003
712
|
* @since 1.3.0
|
|
1004
713
|
*/
|
|
1005
|
-
queue?: "inbox" | "outbox" | "fanout"
|
|
714
|
+
queue?: "inbox" | "outbox" | "fanout";
|
|
1006
715
|
}
|
|
1007
716
|
/**
|
|
1008
717
|
* A common interface between {@link Federation} and {@link FederationBuilder}.
|
|
1009
718
|
* @template TContextData The context data to pass to the {@link Context}.
|
|
1010
719
|
* @since 1.6.0
|
|
1011
720
|
*/
|
|
1012
|
-
interface Federatable<TContextData>
|
|
721
|
+
interface Federatable<TContextData> {
|
|
1013
722
|
/**
|
|
1014
723
|
* Registers a NodeInfo dispatcher.
|
|
1015
724
|
* @param path The URI path pattern for the NodeInfo dispatcher. The syntax
|
|
@@ -2178,44 +1887,6 @@ interface Context<TContextData> {
|
|
|
2178
1887
|
* @since 1.3.0
|
|
2179
1888
|
*/
|
|
2180
1889
|
routeActivity(recipient: string | null, activity: Activity, options?: RouteActivityOptions): Promise<boolean>;
|
|
2181
|
-
/**
|
|
2182
|
-
* Enqueues a custom background task. The payload is validated against
|
|
2183
|
-
* the task's schema, serialized, and processed by the task's handler on
|
|
2184
|
-
* a background worker.
|
|
2185
|
-
*
|
|
2186
|
-
* @example
|
|
2187
|
-
* ``` typescript
|
|
2188
|
-
* await ctx.enqueueTask(sendDigest, { userId: "alice" });
|
|
2189
|
-
* ```
|
|
2190
|
-
*
|
|
2191
|
-
* @template TData The type of the task payload, inferred from the task's
|
|
2192
|
-
* schema.
|
|
2193
|
-
* @param task The handle returned by {@link TaskRegistry.defineTask}.
|
|
2194
|
-
* @param data The task payload. It is validated against the task's
|
|
2195
|
-
* schema before being enqueued.
|
|
2196
|
-
* @param options Options for enqueuing the task.
|
|
2197
|
-
* @throws {TypeError} If the task is not defined on this federation,
|
|
2198
|
-
* if no message queue is configured for tasks, or if
|
|
2199
|
-
* the payload fails schema validation.
|
|
2200
|
-
* @since 2.x.x
|
|
2201
|
-
*/
|
|
2202
|
-
enqueueTask<TData>(task: TaskDefinition<TContextData, TData>, data: TData, options?: TaskEnqueueOptions): Promise<void>;
|
|
2203
|
-
/**
|
|
2204
|
-
* Enqueues multiple payloads for a custom background task at once.
|
|
2205
|
-
* Uses the queue's bulk enqueue operation when available, falling back
|
|
2206
|
-
* to parallel single enqueues.
|
|
2207
|
-
* @template TData The type of the task payload, inferred from the task's
|
|
2208
|
-
* schema.
|
|
2209
|
-
* @param task The handle returned by {@link TaskRegistry.defineTask}.
|
|
2210
|
-
* @param payloads The task payloads. Each is validated against the
|
|
2211
|
-
* task's schema before being enqueued.
|
|
2212
|
-
* @param options Options for enqueuing the tasks.
|
|
2213
|
-
* @throws {TypeError} If the task is not defined on this federation,
|
|
2214
|
-
* if no message queue is configured for tasks, or if
|
|
2215
|
-
* a payload fails schema validation.
|
|
2216
|
-
* @since 2.x.x
|
|
2217
|
-
*/
|
|
2218
|
-
enqueueTaskMany<TData>(task: TaskDefinition<TContextData, TData>, payloads: readonly TData[], options?: TaskEnqueueOptions): Promise<void>;
|
|
2219
1890
|
/**
|
|
2220
1891
|
* Builds the URI of a collection of objects with the given name and values.
|
|
2221
1892
|
* @param name The name of the collection, which can be a string or a symbol.
|
|
@@ -2799,51 +2470,9 @@ declare function createOutboxContext<TContextData>(args: Partial<OutboxContext<T
|
|
|
2799
2470
|
federation: Federation<TContextData>;
|
|
2800
2471
|
}): OutboxContext<TContextData>;
|
|
2801
2472
|
//#endregion
|
|
2802
|
-
//#region src/testing/tasks.d.ts
|
|
2803
|
-
/**
|
|
2804
|
-
* Builds a minimal [Standard Schema](https://standardschema.dev/) from a type
|
|
2805
|
-
* guard, for use as a task payload schema in tests.
|
|
2806
|
-
*/
|
|
2807
|
-
declare const makeSchema: <T>(check: (data: unknown) => data is T) => StandardSchemaV1<unknown, T>;
|
|
2808
|
-
declare const stringSchema: StandardSchemaV1<unknown, string>;
|
|
2809
|
-
declare const numberSchema: StandardSchemaV1<unknown, number>;
|
|
2810
|
-
/** A task payload that carries a vocabulary object, to exercise the codec's
|
|
2811
|
-
* vocab-to-JSON-LD bridging. */
|
|
2812
|
-
interface Envelope {
|
|
2813
|
-
note: Note;
|
|
2814
|
-
title: string;
|
|
2815
|
-
}
|
|
2816
|
-
declare const envelopeSchema: StandardSchemaV1<unknown, Envelope>;
|
|
2817
|
-
/** Options for {@link MockQueue}. */
|
|
2818
|
-
interface MockQueueOptions {
|
|
2819
|
-
readonly nativeRetrial?: boolean;
|
|
2820
|
-
readonly supportsEnqueueMany?: boolean;
|
|
2821
|
-
}
|
|
2822
|
-
/**
|
|
2823
|
-
* A {@link MessageQueue} that records what it was asked to enqueue and resolves
|
|
2824
|
-
* its `listen()` when the abort signal fires, so tests can inspect dispatch
|
|
2825
|
-
* without a real backend.
|
|
2826
|
-
*/
|
|
2827
|
-
declare class MockQueue implements MessageQueue {
|
|
2828
|
-
readonly nativeRetrial: boolean;
|
|
2829
|
-
readonly enqueued: {
|
|
2830
|
-
message: TaskMessage;
|
|
2831
|
-
options?: MessageQueueEnqueueOptions;
|
|
2832
|
-
}[];
|
|
2833
|
-
readonly enqueuedMany: {
|
|
2834
|
-
messages: readonly TaskMessage[];
|
|
2835
|
-
options?: MessageQueueEnqueueOptions;
|
|
2836
|
-
}[];
|
|
2837
|
-
listenCount: number;
|
|
2838
|
-
enqueueMany?: (messages: readonly TaskMessage[], options?: MessageQueueEnqueueOptions) => Promise<void>;
|
|
2839
|
-
constructor(options?: MockQueueOptions);
|
|
2840
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
2841
|
-
listen(_handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
|
|
2842
|
-
}
|
|
2843
|
-
//#endregion
|
|
2844
2473
|
//#region ../fixture/dist/mod.d.ts
|
|
2845
2474
|
//#endregion
|
|
2846
2475
|
//#region src/test.d.ts
|
|
2847
2476
|
declare const testDefinitions: Deno.TestDefinition[];
|
|
2848
2477
|
//#endregion
|
|
2849
|
-
export {
|
|
2478
|
+
export { createInboxContext, createOutboxContext, createRequestContext, testDefinitions };
|
package/dist/testing/mod.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { i as testDefinitions, n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-
|
|
5
|
-
|
|
6
|
-
export { MockQueue, createInboxContext, createOutboxContext, createRequestContext, envelopeSchema, makeSchema, numberSchema, stringSchema, testDefinitions };
|
|
4
|
+
import { i as testDefinitions, n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-DVoTs_wM.mjs";
|
|
5
|
+
export { createInboxContext, createOutboxContext, createRequestContext, testDefinitions };
|
|
@@ -2,12 +2,12 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as esm_default } from "../esm-vrlUxr60.mjs";
|
|
5
|
-
import { t as assertEquals } from "../assert_equals-
|
|
6
|
-
import "../std__assert-
|
|
7
|
-
import { t as assertRejects } from "../assert_rejects-
|
|
8
|
-
import { l as verifyRequest } from "../http-
|
|
9
|
-
import { i as rsaPrivateKey2 } from "../keys-
|
|
10
|
-
import { t as getAuthenticatedDocumentLoader } from "../docloader-
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
7
|
+
import { t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
8
|
+
import { l as verifyRequest } from "../http-BCpKHsqy.mjs";
|
|
9
|
+
import { i as rsaPrivateKey2 } from "../keys-DGu1NFwu.mjs";
|
|
10
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-BfWi9rXZ.mjs";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
import { UrlError } from "@fedify/vocab-runtime";
|
|
13
13
|
//#region src/utils/docloader.test.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as kvCache, t as MockKvStore } from "../kv-cache-
|
|
4
|
+
import { n as kvCache, t as MockKvStore } from "../kv-cache-IEJVfSBn.mjs";
|
|
5
5
|
import { deepStrictEqual, throws } from "node:assert";
|
|
6
6
|
import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
7
7
|
import { preloadedContexts } from "@fedify/vocab-runtime";
|
package/dist/utils/mod.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const require_kv_cache = require("../kv-cache-
|
|
4
|
+
const require_kv_cache = require("../kv-cache-CXj8cbEx.cjs");
|
|
5
5
|
exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
|
|
6
6
|
exports.kvCache = require_kv_cache.kvCache;
|
package/dist/utils/mod.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-
|
|
3
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-LdHRMYlC.js";
|
|
4
4
|
export { getAuthenticatedDocumentLoader, kvCache };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/fedify",
|
|
3
|
-
"version": "2.4.0-dev.
|
|
3
|
+
"version": "2.4.0-dev.1431+9ef6f5e8",
|
|
4
4
|
"description": "An ActivityPub server framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ActivityPub",
|
|
@@ -146,18 +146,16 @@
|
|
|
146
146
|
"@opentelemetry/sdk-metrics": "2.7.1",
|
|
147
147
|
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
148
148
|
"@opentelemetry/semantic-conventions": "^1.40.0",
|
|
149
|
-
"@standard-schema/spec": "^1.1.0",
|
|
150
149
|
"byte-encodings": "^1.0.11",
|
|
151
|
-
"devalue": "^5.8.1",
|
|
152
150
|
"es-toolkit": "1.46.1",
|
|
153
151
|
"json-canon": "^1.0.1",
|
|
154
152
|
"jsonld": "^9.0.0",
|
|
155
153
|
"structured-field-values": "^2.0.4",
|
|
156
154
|
"urlpattern-polyfill": "^10.1.0",
|
|
157
|
-
"@fedify/uri-template": "2.4.0-dev.
|
|
158
|
-
"@fedify/vocab-runtime": "2.4.0-dev.
|
|
159
|
-
"@fedify/vocab": "2.4.0-dev.
|
|
160
|
-
"@fedify/webfinger": "2.4.0-dev.
|
|
155
|
+
"@fedify/uri-template": "2.4.0-dev.1431+9ef6f5e8",
|
|
156
|
+
"@fedify/vocab-runtime": "2.4.0-dev.1431+9ef6f5e8",
|
|
157
|
+
"@fedify/vocab": "2.4.0-dev.1431+9ef6f5e8",
|
|
158
|
+
"@fedify/webfinger": "2.4.0-dev.1431+9ef6f5e8"
|
|
161
159
|
},
|
|
162
160
|
"devDependencies": {
|
|
163
161
|
"@std/assert": "npm:@jsr/std__assert@^0.226.0",
|
|
@@ -170,7 +168,7 @@
|
|
|
170
168
|
"typescript": "^6.0.0",
|
|
171
169
|
"wrangler": "^4.17.0",
|
|
172
170
|
"@fedify/fixture": "2.0.0",
|
|
173
|
-
"@fedify/vocab-tools": "^2.4.0-dev.
|
|
171
|
+
"@fedify/vocab-tools": "^2.4.0-dev.1431+9ef6f5e8"
|
|
174
172
|
},
|
|
175
173
|
"scripts": {
|
|
176
174
|
"build:self": "tsdown",
|
package/dist/codec-Bf-rTqks.mjs
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import "@js-temporal/polyfill";
|
|
2
|
-
import "urlpattern-polyfill";
|
|
3
|
-
globalThis.addEventListener = () => {};
|
|
4
|
-
import { Link, Object as Object$1 } from "@fedify/vocab";
|
|
5
|
-
import { parse, stringifyAsync } from "devalue";
|
|
6
|
-
//#region src/federation/tasks/codec.ts
|
|
7
|
-
var TaskCodec = class TaskCodec {
|
|
8
|
-
options;
|
|
9
|
-
constructor(options) {
|
|
10
|
-
this.options = options;
|
|
11
|
-
}
|
|
12
|
-
serialize = (data) => stringifyAsync(data, { Vocab: this.#stringifyVocab });
|
|
13
|
-
deserialize = (raw) => this.#revive(/* @__PURE__ */ new Map())(parse(raw, { Vocab: VocabHolder.from }));
|
|
14
|
-
/** Validates `data` against `schema`, then serializes it. */
|
|
15
|
-
encode = async (schema, data) => this.serialize(await TaskCodec.validate(schema, data));
|
|
16
|
-
/** Deserializes `raw`, then validates the result against `schema`. */
|
|
17
|
-
decode = async (schema, raw) => TaskCodec.validate(schema, await this.deserialize(raw));
|
|
18
|
-
static validate = async (schema, data) => getValueIfSchema(await schema["~standard"].validate(data));
|
|
19
|
-
#stringifyVocab = (value) => isVocab(value) && this.#toWire(value);
|
|
20
|
-
#toWire = async (value) => ({
|
|
21
|
-
kind: value instanceof Link ? "link" : "object",
|
|
22
|
-
jsonLd: await value.toJsonLd({
|
|
23
|
-
format: "expand",
|
|
24
|
-
...this.options
|
|
25
|
-
})
|
|
26
|
-
});
|
|
27
|
-
#revive = (seen) => {
|
|
28
|
-
const inner = async (node) => {
|
|
29
|
-
if (node === null || typeof node !== "object") return node;
|
|
30
|
-
if (seen.has(node)) return seen.get(node);
|
|
31
|
-
for (const reviver of this.#classRevivers) {
|
|
32
|
-
const out = reviver(seen, inner, node);
|
|
33
|
-
if (out !== void 0) return await out;
|
|
34
|
-
}
|
|
35
|
-
return node;
|
|
36
|
-
};
|
|
37
|
-
return inner;
|
|
38
|
-
};
|
|
39
|
-
#classRevivers = [
|
|
40
|
-
classReviver(isInstanceOf(VocabHolder), ({ kind, jsonLd }) => kind === "link" ? Link.fromJsonLd(jsonLd, this.options) : Object$1.fromJsonLd(jsonLd, this.options), () => {}),
|
|
41
|
-
classReviver(isInstanceOf(Array), () => [], async (revive, node, arr) => {
|
|
42
|
-
for (const item of await Array.fromAsync(node, revive)) arr.push(item);
|
|
43
|
-
}),
|
|
44
|
-
classReviver(isInstanceOf(Map), () => /* @__PURE__ */ new Map(), async (revive, node, map) => {
|
|
45
|
-
for (const [k, v] of node) map.set(await revive(k), await revive(v));
|
|
46
|
-
}),
|
|
47
|
-
classReviver(isInstanceOf(Set), () => /* @__PURE__ */ new Set(), async (revive, node, set) => {
|
|
48
|
-
for (const v of await Array.fromAsync(node, revive)) set.add(v);
|
|
49
|
-
}),
|
|
50
|
-
classReviver(isPlainObject, () => ({}), async (revive, node, obj) => {
|
|
51
|
-
for (const [k, v] of globalThis.Object.entries(node)) obj[k] = await revive(v);
|
|
52
|
-
})
|
|
53
|
-
];
|
|
54
|
-
};
|
|
55
|
-
const isVocab = (value) => value instanceof Object$1 || value instanceof Link;
|
|
56
|
-
const isPlainObject = (value) => value === null || typeof value !== "object" ? false : isObjectPrototype(globalThis.Object.getPrototypeOf(value));
|
|
57
|
-
const isObjectPrototype = (proto) => proto === null || proto === globalThis.Object.prototype;
|
|
58
|
-
const isInstanceOf = (cls) => (v) => v instanceof cls;
|
|
59
|
-
function getValueIfSchema(result) {
|
|
60
|
-
assertSchema(result);
|
|
61
|
-
return result.value;
|
|
62
|
-
}
|
|
63
|
-
function assertSchema(result) {
|
|
64
|
-
if (result.issues && result.issues.length > 0) throw new TypeError(`Task data failed schema validation: ${JSON.stringify(result.issues)}`);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* A vocabulary object parked by the synchronous decode reviver, held until
|
|
68
|
-
* the async revive pass can `fromJsonLd()` it back into an instance.
|
|
69
|
-
*/
|
|
70
|
-
var VocabHolder = class VocabHolder {
|
|
71
|
-
kind;
|
|
72
|
-
jsonLd;
|
|
73
|
-
constructor(kind, jsonLd) {
|
|
74
|
-
this.kind = kind;
|
|
75
|
-
this.jsonLd = jsonLd;
|
|
76
|
-
}
|
|
77
|
-
static from = ({ kind, jsonLd }) => new VocabHolder(kind, jsonLd);
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Ties a container filter to its empty-shell `init` and child-filling `set`
|
|
81
|
-
* through one type parameter—a correlation the heterogeneous reviver list
|
|
82
|
-
* cannot carry, which previously forced `@ts-ignore` at the dispatch site.
|
|
83
|
-
*/
|
|
84
|
-
const classReviver = (filter, init, set) => (seen, revive, node) => {
|
|
85
|
-
if (!filter(node)) return void 0;
|
|
86
|
-
return (async () => {
|
|
87
|
-
const out = await init(node);
|
|
88
|
-
seen.set(node, out);
|
|
89
|
-
await set(revive, node, out);
|
|
90
|
-
return out;
|
|
91
|
-
})();
|
|
92
|
-
};
|
|
93
|
-
//#endregion
|
|
94
|
-
export { TaskCodec as t };
|