@fedify/fedify 2.3.0-dev.1361 → 2.3.0-dev.1367

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/{assert-DikXweDx.mjs → assert-OguE97r2.mjs} +1 -1
  2. package/dist/{assert_instance_of-C4Ri6VuN.mjs → assert_instance_of-DBC5X09g.mjs} +1 -1
  3. package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-DkVK8oqV.mjs} +1 -1
  4. package/dist/{assert_rejects-DQP-q39h.mjs → assert_rejects-DN60FHPX.mjs} +2 -2
  5. package/dist/{assert_strict_equals-Dmjbg-bA.mjs → assert_strict_equals-XEgZAlrj.mjs} +1 -1
  6. package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-BOkhLGYc.mjs} +1 -1
  7. package/dist/{builder-Ec1dUgEm.mjs → builder-CsrxMBlC.mjs} +3 -23
  8. package/dist/compat/mod.d.cts +1 -1
  9. package/dist/compat/mod.d.ts +1 -1
  10. package/dist/compat/outgoing-jsonld.test.mjs +3 -3
  11. package/dist/compat/public-audience.test.mjs +3 -3
  12. package/dist/compat/transformers.test.mjs +5 -5
  13. package/dist/{context-BuGH_Vft.d.cts → context-BBVLF7lx.d.cts} +70 -286
  14. package/dist/{context-CLtZxCu6.d.ts → context-BU6jSQdo.d.ts} +70 -285
  15. package/dist/{context-BrIOaBSs.mjs → context-DVoTs_wM.mjs} +1 -7
  16. package/dist/{deno-C1j4CMgo.mjs → deno-BiUfdE9z.mjs} +1 -1
  17. package/dist/{docloader-DLb-Mj7i.mjs → docloader-BBJhBveN.mjs} +2 -2
  18. package/dist/federation/builder.test.mjs +5 -5
  19. package/dist/federation/circuit-breaker.test.mjs +5 -5
  20. package/dist/federation/collection.test.mjs +3 -3
  21. package/dist/federation/handler.test.mjs +13 -13
  22. package/dist/federation/idempotency.test.mjs +6 -6
  23. package/dist/federation/inbox.test.mjs +3 -3
  24. package/dist/federation/keycache.test.mjs +5 -5
  25. package/dist/federation/kv.test.mjs +3 -3
  26. package/dist/federation/metrics.test.mjs +4 -4
  27. package/dist/federation/middleware.test.mjs +19 -200
  28. package/dist/federation/mod.cjs +1 -1
  29. package/dist/federation/mod.d.cts +3 -3
  30. package/dist/federation/mod.d.ts +3 -3
  31. package/dist/federation/mod.js +1 -1
  32. package/dist/federation/mq.test.mjs +260 -5
  33. package/dist/federation/negotiation.test.mjs +4 -4
  34. package/dist/federation/retry.test.mjs +3 -3
  35. package/dist/federation/router.test.mjs +5 -5
  36. package/dist/federation/send.test.mjs +10 -10
  37. package/dist/federation/temporal.test.mjs +4 -4
  38. package/dist/federation/webfinger.test.mjs +6 -6
  39. package/dist/{http-pFZqYnR0.mjs → http-B57xhg1w.mjs} +4 -4
  40. package/dist/{http-1oEzWsNL.js → http-BceZYwwH.js} +1 -1
  41. package/dist/{http-DwM39C9Q.cjs → http-CbSNQzUp.cjs} +1 -1
  42. package/dist/{key-E-05ikaC.mjs → key-DjYpTdy6.mjs} +2 -2
  43. package/dist/{kv-cache-CgchQxpw.js → kv-cache-5QIPMDoZ.js} +1 -1
  44. package/dist/{kv-cache-enboxEhN.cjs → kv-cache-B_Q8LGYW.cjs} +1 -1
  45. package/dist/{kv-cache-D-OZCnQz.mjs → kv-cache-KKf6uhtv.mjs} +1 -1
  46. package/dist/{ld-Bi8DPgxi.mjs → ld-OdHhWHdK.mjs} +3 -3
  47. package/dist/{metrics-BC8TM85p.mjs → metrics-BNeDNuTR.mjs} +1 -1
  48. package/dist/{middleware-TZyBWL4B.cjs → middleware-7mEPRH-T.cjs} +10 -277
  49. package/dist/{middleware-B81UTyWc.mjs → middleware-CH8EAw7G.mjs} +1 -1
  50. package/dist/{middleware-6R3zHHW0.mjs → middleware-CR1Ux5W8.mjs} +23 -182
  51. package/dist/{middleware-bEYsEa2y.js → middleware-x0QQLtuD.js} +10 -277
  52. package/dist/{mod-DRokcHeU.d.cts → mod-C0F6kvgS.d.cts} +1 -1
  53. package/dist/{mod-r-1xOW_C.d.ts → mod-vPYVoa5n.d.ts} +1 -1
  54. package/dist/mod.cjs +4 -4
  55. package/dist/mod.d.cts +4 -4
  56. package/dist/mod.d.ts +4 -4
  57. package/dist/mod.js +4 -4
  58. package/dist/nodeinfo/client.test.mjs +3 -3
  59. package/dist/nodeinfo/handler.test.mjs +5 -5
  60. package/dist/nodeinfo/types.test.mjs +4 -4
  61. package/dist/otel/exporter.test.mjs +3 -3
  62. package/dist/{outgoing-jsonld-BgFLCJQ_.mjs → outgoing-jsonld-L_DbOaFe.mjs} +1 -1
  63. package/dist/{owner-9bbtWYCS.mjs → owner-UhADnZlT.mjs} +2 -2
  64. package/dist/{proof-DS0QOtP2.mjs → proof-B5uQgIa7.mjs} +5 -5
  65. package/dist/{proof-B45zHTY3.cjs → proof-D7K9-olI.cjs} +1 -1
  66. package/dist/{proof-CA5R6h5L.js → proof-O2kSrwei.js} +1 -1
  67. package/dist/{send-CyGRAWkX.mjs → send-Bd2V-sji.mjs} +3 -3
  68. package/dist/sig/accept.test.mjs +1 -1
  69. package/dist/sig/http.test.mjs +8 -8
  70. package/dist/sig/key.test.mjs +6 -6
  71. package/dist/sig/ld.test.mjs +7 -7
  72. package/dist/sig/mod.cjs +2 -2
  73. package/dist/sig/mod.js +2 -2
  74. package/dist/sig/owner.test.mjs +6 -6
  75. package/dist/sig/proof.test.mjs +8 -8
  76. package/dist/{std__assert-BTEgfoJo.mjs → std__assert-BBjXFNOb.mjs} +4 -4
  77. package/dist/{temporal-B82PdoA8.mjs → temporal-BXLwWpMY.mjs} +1 -1
  78. package/dist/testing/mod.d.mts +7 -378
  79. package/dist/testing/mod.mjs +2 -3
  80. package/dist/utils/docloader.test.mjs +6 -6
  81. package/dist/utils/kv-cache.test.mjs +1 -1
  82. package/dist/utils/mod.cjs +1 -1
  83. package/dist/utils/mod.js +1 -1
  84. package/package.json +8 -10
  85. package/dist/codec-Bf-rTqks.mjs +0 -94
  86. package/dist/federation/tasks/codec.test.d.mts +0 -2
  87. package/dist/federation/tasks/codec.test.mjs +0 -292
  88. package/dist/federation/tasks/tasks.test.d.mts +0 -2
  89. package/dist/federation/tasks/tasks.test.mjs +0 -651
  90. package/dist/mq-CvJAzRz5.mjs +0 -260
  91. package/dist/testing-CjYPStvE.mjs +0 -55
  92. /package/dist/{accept-CceiKpCy.mjs → accept-CPkZzmGN.mjs} +0 -0
  93. /package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-tztVvlNb.mjs} +0 -0
  94. /package/dist/{assert_equals-Ew3jOFa3.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
  95. /package/dist/{circuit-breaker-hJBB6jwA.mjs → circuit-breaker-CSWsyoef.mjs} +0 -0
  96. /package/dist/{client-B_A6mfn3.mjs → client-ByXmQhYD.mjs} +0 -0
  97. /package/dist/{collection-Dp5ky45w.mjs → collection-Cc3DVAhE.mjs} +0 -0
  98. /package/dist/{keycache-CaOR6NYg.mjs → keycache-BeU0LCII.mjs} +0 -0
  99. /package/dist/{keys-C3kae-6B.mjs → keys-DGu1NFwu.mjs} +0 -0
  100. /package/dist/{kv-x2IvBUyq.mjs → kv-rV3vodCc.mjs} +0 -0
  101. /package/dist/{negotiation-m_L2nyS3.mjs → negotiation-DDstyBvc.mjs} +0 -0
  102. /package/dist/{public-audience-N3pyOx2p.mjs → public-audience-Cvbr2Gzt.mjs} +0 -0
  103. /package/dist/{retry-DI4O-zYl.mjs → retry-CXg_MBI-.mjs} +0 -0
  104. /package/dist/{types-BFowWFTT.mjs → types-J53Kw7so.mjs} +0 -0
@@ -1,28 +1,27 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-C1j4CMgo.mjs";
5
- import { a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, n as getDurationMs, o as isAbortError, r as getFederationMetrics, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "./metrics-BC8TM85p.mjs";
6
- import { t as formatAcceptSignature } from "./accept-CceiKpCy.mjs";
7
- import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-E-05ikaC.mjs";
8
- import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-pFZqYnR0.mjs";
9
- import { t as getAuthenticatedDocumentLoader } from "./docloader-DLb-Mj7i.mjs";
10
- import { n as kvCache } from "./kv-cache-D-OZCnQz.mjs";
11
- import { _ as wrapContextLoaderForJsonLd, a as compactJsonLd, c as getNormalizationContextLoader, d as isClearlyMalformedContextReference, f as isInvalidUrlTypeError, l as hasSignature, m as verifyCompactJsonLd, p as signJsonLd, r as assertSafeJsonLd, s as detachSignature, t as InvalidContextReferenceError, u as hasSignatureLike } from "./ld-Bi8DPgxi.mjs";
12
- import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-9bbtWYCS.mjs";
13
- import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-BgFLCJQ_.mjs";
14
- import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-DS0QOtP2.mjs";
15
- import { t as getNodeInfo } from "./client-B_A6mfn3.mjs";
16
- import { t as nodeInfoToJson } from "./types-BFowWFTT.mjs";
17
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-CyGRAWkX.mjs";
18
- import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-Ec1dUgEm.mjs";
19
- import { t as CircuitBreaker } from "./circuit-breaker-hJBB6jwA.mjs";
20
- import { t as buildCollectionSynchronizationHeader } from "./collection-Dp5ky45w.mjs";
21
- import { t as KvKeyCache } from "./keycache-CaOR6NYg.mjs";
22
- import { t as acceptsJsonLd } from "./negotiation-m_L2nyS3.mjs";
23
- import { t as hasMalformedKnownTemporalLiteral } from "./temporal-B82PdoA8.mjs";
24
- import { t as createExponentialBackoffPolicy } from "./retry-DI4O-zYl.mjs";
25
- import { t as TaskCodec } from "./codec-Bf-rTqks.mjs";
4
+ import { n as version, t as name } from "./deno-BiUfdE9z.mjs";
5
+ import { a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, n as getDurationMs, o as isAbortError, r as getFederationMetrics, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "./metrics-BNeDNuTR.mjs";
6
+ import { t as formatAcceptSignature } from "./accept-CPkZzmGN.mjs";
7
+ import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-DjYpTdy6.mjs";
8
+ import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-B57xhg1w.mjs";
9
+ import { t as getAuthenticatedDocumentLoader } from "./docloader-BBJhBveN.mjs";
10
+ import { n as kvCache } from "./kv-cache-KKf6uhtv.mjs";
11
+ import { _ as wrapContextLoaderForJsonLd, a as compactJsonLd, c as getNormalizationContextLoader, d as isClearlyMalformedContextReference, f as isInvalidUrlTypeError, l as hasSignature, m as verifyCompactJsonLd, p as signJsonLd, r as assertSafeJsonLd, s as detachSignature, t as InvalidContextReferenceError, u as hasSignatureLike } from "./ld-OdHhWHdK.mjs";
12
+ import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-UhADnZlT.mjs";
13
+ import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-L_DbOaFe.mjs";
14
+ import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-B5uQgIa7.mjs";
15
+ import { t as getNodeInfo } from "./client-ByXmQhYD.mjs";
16
+ import { t as nodeInfoToJson } from "./types-J53Kw7so.mjs";
17
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-Bd2V-sji.mjs";
18
+ import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-CsrxMBlC.mjs";
19
+ import { t as CircuitBreaker } from "./circuit-breaker-CSWsyoef.mjs";
20
+ import { t as buildCollectionSynchronizationHeader } from "./collection-Cc3DVAhE.mjs";
21
+ import { t as KvKeyCache } from "./keycache-BeU0LCII.mjs";
22
+ import { t as acceptsJsonLd } from "./negotiation-DDstyBvc.mjs";
23
+ import { t as hasMalformedKnownTemporalLiteral } from "./temporal-BXLwWpMY.mjs";
24
+ import { t as createExponentialBackoffPolicy } from "./retry-CXg_MBI-.mjs";
26
25
  import { getLogger, withContext } from "@logtape/logtape";
27
26
  import { RouterError } from "@fedify/uri-template";
28
27
  import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
@@ -2410,12 +2409,9 @@ var FederationImpl = class extends FederationBuilderImpl {
2410
2409
  inboxQueue;
2411
2410
  outboxQueue;
2412
2411
  fanoutQueue;
2413
- taskQueue;
2414
2412
  inboxQueueStarted;
2415
2413
  outboxQueueStarted;
2416
2414
  fanoutQueueStarted;
2417
- taskQueueStarted;
2418
- startedTaskQueues;
2419
2415
  manuallyStartQueue;
2420
2416
  origin;
2421
2417
  documentLoaderFactory;
@@ -2429,8 +2425,6 @@ var FederationImpl = class extends FederationBuilderImpl {
2429
2425
  skipSignatureVerification;
2430
2426
  outboxRetryPolicy;
2431
2427
  inboxRetryPolicy;
2432
- taskRetryPolicy;
2433
- taskQueueResolution;
2434
2428
  circuitBreaker;
2435
2429
  activityTransformers;
2436
2430
  _tracerProvider;
@@ -2476,17 +2470,14 @@ var FederationImpl = class extends FederationBuilderImpl {
2476
2470
  this.inboxQueue = void 0;
2477
2471
  this.outboxQueue = void 0;
2478
2472
  this.fanoutQueue = void 0;
2479
- this.taskQueue = void 0;
2480
2473
  } else if ("enqueue" in options.queue && "listen" in options.queue) {
2481
2474
  this.inboxQueue = options.queue;
2482
2475
  this.outboxQueue = options.queue;
2483
2476
  this.fanoutQueue = options.queue;
2484
- this.taskQueue = void 0;
2485
2477
  } else {
2486
2478
  this.inboxQueue = options.queue.inbox;
2487
2479
  this.outboxQueue = options.queue.outbox;
2488
2480
  this.fanoutQueue = options.queue.fanout;
2489
- this.taskQueue = options.queue.task;
2490
2481
  }
2491
2482
  if (options.circuitBreaker !== false && this.outboxQueue != null) {
2492
2483
  this.circuitBreaker = new CircuitBreaker({
@@ -2510,8 +2501,6 @@ var FederationImpl = class extends FederationBuilderImpl {
2510
2501
  this.inboxQueueStarted = false;
2511
2502
  this.outboxQueueStarted = false;
2512
2503
  this.fanoutQueueStarted = false;
2513
- this.taskQueueStarted = false;
2514
- this.startedTaskQueues = /* @__PURE__ */ new Set();
2515
2504
  this.manuallyStartQueue = options.manuallyStartQueue ?? false;
2516
2505
  if (options.origin != null) if (typeof options.origin === "string") {
2517
2506
  if (!URL.canParse(options.origin) || !options.origin.match(/^https?:\/\//)) throw new TypeError(`Invalid origin: ${JSON.stringify(options.origin)}`);
@@ -2593,8 +2582,6 @@ var FederationImpl = class extends FederationBuilderImpl {
2593
2582
  this.inboxChallengePolicy = options.inboxChallengePolicy;
2594
2583
  this.outboxRetryPolicy = options.outboxRetryPolicy ?? createExponentialBackoffPolicy();
2595
2584
  this.inboxRetryPolicy = options.inboxRetryPolicy ?? createExponentialBackoffPolicy();
2596
- this.taskRetryPolicy = options.taskRetryPolicy ?? createExponentialBackoffPolicy();
2597
- this.taskQueueResolution = options.taskQueueResolution ?? "fallback";
2598
2585
  this.activityTransformers = options.activityTransformers ?? getDefaultActivityTransformers();
2599
2586
  this._tracerProvider = options.tracerProvider;
2600
2587
  if (benchmarkMode) {
@@ -2643,14 +2630,8 @@ var FederationImpl = class extends FederationBuilderImpl {
2643
2630
  _getTracer() {
2644
2631
  return this.tracerProvider.getTracer(name, version);
2645
2632
  }
2646
- resolveTaskQueue(taskName) {
2647
- const resolved = this.taskDefinitions.get(taskName)?.queue ?? this.taskQueue;
2648
- if (resolved != null) return resolved;
2649
- return this.taskQueueResolution === "strict" ? void 0 : this.outboxQueue;
2650
- }
2651
2633
  async _startQueueInternal(ctxData, signal, queue) {
2652
- const hasDedicatedTaskQueue = [...this.taskDefinitions.values()].some((def) => def.queue != null);
2653
- if (this.inboxQueue == null && this.outboxQueue == null && this.fanoutQueue == null && this.taskQueue == null && !hasDedicatedTaskQueue) return;
2634
+ if (this.inboxQueue == null && this.outboxQueue == null) return;
2654
2635
  const logger = getLogger([
2655
2636
  "fedify",
2656
2637
  "federation",
@@ -2672,26 +2653,6 @@ var FederationImpl = class extends FederationBuilderImpl {
2672
2653
  this.fanoutQueueStarted = true;
2673
2654
  promises.push(this.fanoutQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
2674
2655
  }
2675
- if (this.taskQueue != null && this.taskQueue !== this.inboxQueue && this.taskQueue !== this.outboxQueue && this.taskQueue !== this.fanoutQueue && (queue == null || queue === "task") && !this.taskQueueStarted) {
2676
- logger.debug("Starting a task worker.");
2677
- this.taskQueueStarted = true;
2678
- promises.push(this.taskQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
2679
- }
2680
- if (queue == null || queue === "task") {
2681
- const standardQueues = new Set([
2682
- this.inboxQueue,
2683
- this.outboxQueue,
2684
- this.fanoutQueue,
2685
- this.taskQueue
2686
- ].filter((q) => q != null));
2687
- for (const def of this.taskDefinitions.values()) {
2688
- const taskQueue = def.queue;
2689
- if (taskQueue == null || standardQueues.has(taskQueue) || this.startedTaskQueues.has(taskQueue)) continue;
2690
- logger.debug("Starting a worker for a dedicated per-task queue.");
2691
- this.startedTaskQueues.add(taskQueue);
2692
- promises.push(taskQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
2693
- }
2694
- }
2695
2656
  await Promise.all(promises);
2696
2657
  }
2697
2658
  processQueuedTask(contextData, message) {
@@ -2813,7 +2774,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2813
2774
  }
2814
2775
  });
2815
2776
  });
2816
- } else if (message.type === "task") await this.#listenTaskMessage(contextData, message);
2777
+ }
2817
2778
  });
2818
2779
  }
2819
2780
  async #listenFanoutMessage(data, message) {
@@ -3377,77 +3338,6 @@ var FederationImpl = class extends FederationBuilderImpl {
3377
3338
  listenerSpan.end();
3378
3339
  });
3379
3340
  }
3380
- async #listenTaskMessage(contextData, message) {
3381
- const logger = getLogger([
3382
- "fedify",
3383
- "federation",
3384
- "task"
3385
- ]);
3386
- const def = this.taskDefinitions.get(message.taskName);
3387
- if (def == null) {
3388
- logger.warn("Received a custom task {taskName} with no registered handler; dropping.", { taskName: message.taskName });
3389
- return;
3390
- }
3391
- const context = this.#createContext(new URL(message.baseUrl), contextData);
3392
- let data;
3393
- try {
3394
- data = await context.codec.decode(def.schema, message.data);
3395
- } catch (error) {
3396
- logger.error("Custom task {taskName} payload could not be decoded or validated; dropping:\n{error}", {
3397
- taskName: message.taskName,
3398
- error
3399
- });
3400
- return;
3401
- }
3402
- try {
3403
- await def.handler(context, data);
3404
- } catch (error) {
3405
- if (def.onError != null) try {
3406
- await def.onError(context, error, data);
3407
- } catch (onErrorError) {
3408
- logger.error("onError for custom task {taskName} threw:\n{error}", {
3409
- taskName: message.taskName,
3410
- error: onErrorError
3411
- });
3412
- }
3413
- const queue = this.resolveTaskQueue(def.name);
3414
- if (queue?.nativeRetrial) throw error;
3415
- const retryPolicy = def.retryPolicy ?? this.taskRetryPolicy;
3416
- let elapsedTime = Temporal.Duration.from({ seconds: 0 });
3417
- try {
3418
- elapsedTime = Temporal.Instant.from(message.started).until(Temporal.Now.instant());
3419
- } catch (parseError) {
3420
- logger.error("Custom task {taskName} has an unparsable started time {started}; treating elapsedTime as zero:\n{error}", {
3421
- taskName: message.taskName,
3422
- started: message.started,
3423
- error: parseError
3424
- });
3425
- }
3426
- const delay = retryPolicy({
3427
- elapsedTime,
3428
- attempts: message.attempt
3429
- });
3430
- if (delay != null && queue != null) {
3431
- logger.error("Custom task {taskName} failed (attempt #{attempt}); retry...:\n{error}", {
3432
- taskName: message.taskName,
3433
- attempt: message.attempt,
3434
- error
3435
- });
3436
- const retryMessage = {
3437
- ...message,
3438
- attempt: message.attempt + 1
3439
- };
3440
- await queue.enqueue(retryMessage, {
3441
- delay: clampNegativeDelay(delay),
3442
- orderingKey: message.orderingKey
3443
- });
3444
- } else logger.error("Custom task {taskName} failed after {attempt} attempts; giving up:\n{error}", {
3445
- taskName: message.taskName,
3446
- attempt: message.attempt,
3447
- error
3448
- });
3449
- }
3450
- }
3451
3341
  startQueue(contextData, options = {}) {
3452
3342
  return this._startQueueInternal(contextData, options.signal, options.queue);
3453
3343
  }
@@ -4024,7 +3914,6 @@ var ContextImpl = class ContextImpl {
4024
3914
  documentLoader;
4025
3915
  contextLoader;
4026
3916
  invokedFromActorKeyPairsDispatcher;
4027
- #codec;
4028
3917
  constructor({ url, federation, data, documentLoader, contextLoader, invokedFromActorKeyPairsDispatcher }) {
4029
3918
  this.url = url;
4030
3919
  this.federation = federation;
@@ -4033,15 +3922,6 @@ var ContextImpl = class ContextImpl {
4033
3922
  this.contextLoader = contextLoader;
4034
3923
  this.invokedFromActorKeyPairsDispatcher = invokedFromActorKeyPairsDispatcher;
4035
3924
  }
4036
- /**
4037
- * A {@link TaskCodec} bound to this context's loaders, used to encode
4038
- * and decode custom task payloads. Lazily created and cached so a context
4039
- * that never enqueues or dispatches a task pays nothing.
4040
- * @internal
4041
- */
4042
- get codec() {
4043
- return this.#codec ??= new TaskCodec(this);
4044
- }
4045
3925
  clone(data) {
4046
3926
  return new ContextImpl({
4047
3927
  url: this.url,
@@ -4360,45 +4240,6 @@ var ContextImpl = class ContextImpl {
4360
4240
  allowPrivateAddress: this.federation.allowPrivateAddress
4361
4241
  });
4362
4242
  }
4363
- async enqueueTask(task, data, options = {}) {
4364
- await this.#enqueueTasks(task, [data], options);
4365
- }
4366
- async enqueueTaskMany(task, payloads, options = {}) {
4367
- await this.#enqueueTasks(task, payloads, options);
4368
- }
4369
- async #enqueueTasks(task, items, options) {
4370
- const def = this.federation.taskDefinitions.get(task.name);
4371
- if (def == null || def.handle !== task) throw new TypeError(`Task ${JSON.stringify(task.name)} is not defined on this federation; pass a handle returned by its defineTask().`);
4372
- const queue = this.federation.resolveTaskQueue(task.name);
4373
- if (queue == null) throw new TypeError("No message queue is configured for tasks; pass `queue` to createFederation() or to defineTask().");
4374
- if (items.length < 1) return;
4375
- const delay = options.delay == null ? void 0 : Temporal.Duration.from(options.delay);
4376
- const messages = await Promise.all(items.map(this.#encodeTaskMessage(task, options)));
4377
- if (!this.federation.manuallyStartQueue) this.federation._startQueueInternal(this.data);
4378
- const enqueueOptions = {
4379
- delay,
4380
- orderingKey: options.orderingKey
4381
- };
4382
- if (messages.length === 1) await queue.enqueue(messages[0], enqueueOptions);
4383
- else if (queue.enqueueMany != null) await queue.enqueueMany(messages, enqueueOptions);
4384
- else await Promise.all(messages.map((m) => queue.enqueue(m, enqueueOptions)));
4385
- }
4386
- #encodeTaskMessage = (task, options) => async (data) => {
4387
- const encoded = await this.codec.encode(task.schema, data);
4388
- const carrier = {};
4389
- propagation.inject(context.active(), carrier);
4390
- return {
4391
- type: "task",
4392
- id: crypto.randomUUID(),
4393
- baseUrl: this.origin,
4394
- taskName: task.name,
4395
- data: encoded,
4396
- started: Temporal.Now.instant().toString(),
4397
- attempt: 0,
4398
- orderingKey: options.orderingKey,
4399
- traceContext: carrier
4400
- };
4401
- };
4402
4243
  sendActivity(sender, recipients, activity, options = {}) {
4403
4244
  return this.tracerProvider.getTracer(name, version).startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
4404
4245
  kind: this.federation.outboxQueue == null || options.immediate ? SpanKind.CLIENT : SpanKind.PRODUCER,