@fedify/fedify 1.8.1-pr.334.1193 → 1.8.1-pr.340.1214

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 (107) hide show
  1. package/dist/{actor-CeBMq8qR.js → actor-0406z0yr.js} +1 -1
  2. package/dist/{actor-BxYrc06V.js → actor-BaC4dvrg.js} +179 -179
  3. package/dist/{actor-B4TBtqRP.d.ts → actor-CWNAGvnO.d.ts} +2 -2
  4. package/dist/{authdocloader-D64rqKxU.js → authdocloader-CEsK8iV_.js} +3 -3
  5. package/dist/{authdocloader-mGQvrIQ2.js → authdocloader-CtMSv_Pw.js} +3 -3
  6. package/dist/{builder-BMWyrhEH.js → builder-BMJsk4Fm.js} +74 -4
  7. package/dist/{client-BQ4AQGKo.d.ts → client-B0IOer6B.d.ts} +1 -1
  8. package/dist/{client-CTC5x_Sz.js → client-BKDCmXzu.js} +1 -1
  9. package/dist/compat/mod.d.ts +11 -11
  10. package/dist/compat/mod.js +1 -1
  11. package/dist/compat/transformers.test.js +16 -16
  12. package/dist/{context-B6mUZhs_.d.ts → context-BNA3vzcr.d.ts} +273 -60
  13. package/dist/{docloader-BeCtcTOJ.d.ts → docloader-CLolPVL_.d.ts} +1 -1
  14. package/dist/{docloader-BU0Mbf3M.js → docloader-DWk5FlEW.js} +1 -1
  15. package/dist/{esm-LMB9p-G5.js → esm-CXrO8Uio.js} +1 -1
  16. package/dist/federation/builder.test.js +25 -6
  17. package/dist/federation/collection.test.js +3 -3
  18. package/dist/federation/handler.test.js +327 -17
  19. package/dist/federation/inbox.test.js +4 -4
  20. package/dist/federation/keycache.test.js +4 -4
  21. package/dist/federation/kv.test.js +3 -3
  22. package/dist/federation/middleware.test.js +49 -18
  23. package/dist/federation/mod.d.ts +11 -11
  24. package/dist/federation/mod.js +11 -11
  25. package/dist/federation/mq.test.js +3 -3
  26. package/dist/federation/retry.test.js +3 -3
  27. package/dist/federation/router.test.js +3 -3
  28. package/dist/federation/send.test.js +10 -10
  29. package/dist/{http-D3g0NXG1.js → http-CO1FrcSi.js} +2 -2
  30. package/dist/{http-D1uoUH4N.d.ts → http-COez3YdK.d.ts} +4 -4
  31. package/dist/{http-CYR3mIVn.js → http-DhcY_6sW.js} +3 -3
  32. package/dist/{inbox-CKssCQNk.js → inbox-BU_xB7k0.js} +1 -1
  33. package/dist/{key-BBZcKCrH.js → key-B09hs4s0.js} +3 -3
  34. package/dist/{key-CmOXs0Mq.js → key-BdLJwUgz.js} +3 -3
  35. package/dist/{key-YOEsvep6.js → key-CnJoBmuO.js} +3 -3
  36. package/dist/{key-CuNvhgVd.js → key-DOtg5R6v.js} +4 -4
  37. package/dist/{keycache-DGObidvq.js → keycache-lSDCpE3z.js} +1 -1
  38. package/dist/{keys-CPhbsrsX.js → keys-DAWEhOVZ.js} +1 -1
  39. package/dist/{kv-DDdb1hMa.d.ts → kv-BqOK6zss.d.ts} +1 -1
  40. package/dist/{ld-D8ugSU-x.js → ld-wWks9TWo.js} +2 -2
  41. package/dist/{lookup-rBByGTyy.js → lookup-B7MyB44I.js} +1 -1
  42. package/dist/{lookup-B0_qPExk.js → lookup-Cph3FzCE.js} +1 -1
  43. package/dist/{lookup-J_m4YZg0.d.ts → lookup-tSXYzgYs.d.ts} +1 -1
  44. package/dist/middleware-B3Vppi4s.js +26 -0
  45. package/dist/{middleware-u2WBeCjB.js → middleware-B93u9XJg.js} +552 -17
  46. package/dist/middleware-B_dKx4Hf.js +17 -0
  47. package/dist/{middleware-B_To0NZ3.js → middleware-BrIs_Xfo.js} +616 -11
  48. package/dist/{mod-BCl7t-Ka.d.ts → mod-Bf-mThHd.d.ts} +4 -4
  49. package/dist/{mod-BFwgZ7_K.d.ts → mod-C2jQirfr.d.ts} +2 -2
  50. package/dist/{mod-D9qE4iHP.d.ts → mod-CxD6XXBN.d.ts} +5 -5
  51. package/dist/{mod-0L5jhGYM.d.ts → mod-UTC30uNC.d.ts} +2 -2
  52. package/dist/mod.d.ts +14 -14
  53. package/dist/mod.js +11 -11
  54. package/dist/nodeinfo/client.test.js +5 -5
  55. package/dist/nodeinfo/handler.test.js +16 -16
  56. package/dist/nodeinfo/mod.d.ts +3 -3
  57. package/dist/nodeinfo/mod.js +2 -2
  58. package/dist/nodeinfo/semver.test.js +3 -3
  59. package/dist/nodeinfo/types.test.js +3 -3
  60. package/dist/{owner-CEv_PfyK.d.ts → owner-BlxMNrL4.d.ts} +3 -3
  61. package/dist/{owner-D1TBvEbO.js → owner-D5LGiRcJ.js} +2 -2
  62. package/dist/{proof-CUsFh6B-.js → proof-B2bSQ9mB.js} +4 -4
  63. package/dist/{proof-CyWfFsKS.js → proof-DMbQihAa.js} +3 -3
  64. package/dist/runtime/authdocloader.test.js +9 -9
  65. package/dist/runtime/docloader.test.js +4 -4
  66. package/dist/runtime/key.test.js +5 -5
  67. package/dist/runtime/langstr.test.js +3 -3
  68. package/dist/runtime/mod.d.ts +5 -5
  69. package/dist/runtime/mod.js +6 -6
  70. package/dist/runtime/multibase/multibase.test.js +3 -3
  71. package/dist/runtime/url.test.js +3 -3
  72. package/dist/{send-CrjrTnXW.js → send-CHfFIhLs.js} +2 -2
  73. package/dist/sig/http.test.js +8 -8
  74. package/dist/sig/key.test.js +6 -6
  75. package/dist/sig/ld.test.js +7 -7
  76. package/dist/sig/mod.d.ts +7 -7
  77. package/dist/sig/mod.js +6 -6
  78. package/dist/sig/owner.test.js +7 -7
  79. package/dist/sig/proof.test.js +7 -7
  80. package/dist/testing/docloader.test.js +3 -3
  81. package/dist/testing/mod.d.ts +260 -48
  82. package/dist/testing/mod.js +3 -3
  83. package/dist/{testing-CROcCUCq.js → testing-B1f6X3bJ.js} +4 -3
  84. package/dist/{transformers-ghwJuzGY.js → transformers-DJRB0yFF.js} +3 -3
  85. package/dist/{type-DGlR8Urb.js → type-DDS4cl1h.js} +179 -179
  86. package/dist/{types-DZdBK266.js → types-DqEgOZ7x.js} +1 -1
  87. package/dist/vocab/actor.test.js +5 -5
  88. package/dist/vocab/lookup.test.js +4 -4
  89. package/dist/vocab/mod.d.ts +5 -5
  90. package/dist/vocab/mod.js +4 -4
  91. package/dist/vocab/type.test.js +3 -3
  92. package/dist/vocab/vocab.test.js +4 -4
  93. package/dist/{vocab-BLQ-_oLb.js → vocab-4bE35CsS.js} +3 -3
  94. package/dist/{vocab-By6mpzr-.d.ts → vocab-Cyrb7_co.d.ts} +1 -1
  95. package/dist/webfinger/handler.test.js +16 -16
  96. package/dist/webfinger/lookup.test.js +4 -4
  97. package/dist/webfinger/mod.d.ts +3 -3
  98. package/dist/webfinger/mod.js +2 -2
  99. package/dist/x/cfworkers.d.ts +1 -1
  100. package/dist/x/cfworkers.test.js +3 -3
  101. package/dist/x/hono.d.ts +14 -14
  102. package/dist/x/hono.js +2 -2
  103. package/dist/x/sveltekit.d.ts +11 -11
  104. package/dist/x/sveltekit.js +1 -1
  105. package/package.json +1 -1
  106. package/dist/middleware-DbDzHrt7.js +0 -17
  107. package/dist/middleware-JUbAKlS5.js +0 -26
@@ -1,14 +1,14 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { KvKey, KvStore } from "./kv-DDdb1hMa.js";
4
- import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "./docloader-BeCtcTOJ.js";
5
- import { GetNodeInfoOptions, JsonValue, NodeInfo } from "./client-BQ4AQGKo.js";
6
- import { Activity, Collection, CryptographicKey, Hashtag, Link, Multikey, Object as Object$1 } from "./vocab-By6mpzr-.js";
7
- import { Actor, Recipient } from "./actor-B4TBtqRP.js";
8
- import { HttpMessageSignaturesSpec } from "./http-D1uoUH4N.js";
9
- import { GetKeyOwnerOptions } from "./owner-CEv_PfyK.js";
10
- import { LookupObjectOptions, TraverseCollectionOptions } from "./mod-BFwgZ7_K.js";
11
- import { LookupWebFingerOptions, ResourceDescriptor } from "./lookup-J_m4YZg0.js";
3
+ import { KvKey, KvStore } from "./kv-BqOK6zss.js";
4
+ import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "./docloader-CLolPVL_.js";
5
+ import { GetNodeInfoOptions, JsonValue, NodeInfo } from "./client-B0IOer6B.js";
6
+ import { Activity, Collection, CryptographicKey, Hashtag, Link, Multikey, Object as Object$1 } from "./vocab-Cyrb7_co.js";
7
+ import { Actor, Recipient } from "./actor-CWNAGvnO.js";
8
+ import { HttpMessageSignaturesSpec } from "./http-COez3YdK.js";
9
+ import { GetKeyOwnerOptions } from "./owner-BlxMNrL4.js";
10
+ import { LookupObjectOptions, TraverseCollectionOptions } from "./mod-C2jQirfr.js";
11
+ import { LookupWebFingerOptions, ResourceDescriptor } from "./lookup-tSXYzgYs.js";
12
12
  import { MessageQueue } from "./mq-DYKDDJmp.js";
13
13
  import { Span, TracerProvider } from "@opentelemetry/api";
14
14
 
@@ -70,13 +70,13 @@ interface SenderKeyPair {
70
70
  /**
71
71
  * A callback that dispatches a {@link NodeInfo} object.
72
72
  *
73
- * @typeParam TContextData The context data to pass to the {@link Context}.
73
+ * @template TContextData The context data to pass to the {@link Context}.
74
74
  */
75
75
  type NodeInfoDispatcher<TContextData> = (context: RequestContext<TContextData>) => NodeInfo | Promise<NodeInfo>;
76
76
  /**
77
77
  * A callback that dispatches an {@link Actor} object.
78
78
  *
79
- * @typeParam TContextData The context data to pass to the {@link Context}.
79
+ * @template TContextData The context data to pass to the {@link Context}.
80
80
  * @param context The request context.
81
81
  * @param identifier The actor's internal identifier or username.
82
82
  */
@@ -84,7 +84,7 @@ type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, ide
84
84
  /**
85
85
  * A callback that dispatches key pairs for an actor.
86
86
  *
87
- * @typeParam TContextData The context data to pass to the {@link Context}.
87
+ * @template TContextData The context data to pass to the {@link Context}.
88
88
  * @param context The context.
89
89
  * @param identifier The actor's internal identifier or username.
90
90
  * @returns The key pairs.
@@ -94,7 +94,7 @@ type ActorKeyPairsDispatcher<TContextData> = (context: Context<TContextData>, id
94
94
  /**
95
95
  * A callback that maps a WebFinger username to the corresponding actor's
96
96
  * internal identifier, or `null` if the username is not found.
97
- * @typeParam TContextData The context data to pass to the {@link Context}.
97
+ * @template TContextData The context data to pass to the {@link Context}.
98
98
  * @param context The context.
99
99
  * @param username The WebFinger username.
100
100
  * @returns The actor's internal identifier, or `null` if the username is not
@@ -105,7 +105,7 @@ type ActorHandleMapper<TContextData> = (context: Context<TContextData>, username
105
105
  /**
106
106
  * A callback that maps a WebFinger query to the corresponding actor's
107
107
  * internal identifier or username, or `null` if the query is not found.
108
- * @typeParam TContextData The context data to pass to the {@link Context}.
108
+ * @template TContextData The context data to pass to the {@link Context}.
109
109
  * @param context The request context.
110
110
  * @param resource The URL that was queried through WebFinger.
111
111
  * @returns The actor's internal identifier or username, or `null` if the query
@@ -124,20 +124,20 @@ type ActorAliasMapper<TContextData> = (context: RequestContext<TContextData>, re
124
124
  /**
125
125
  * A callback that dispatches an object.
126
126
  *
127
- * @typeParam TContextData The context data to pass to the {@link Context}.
128
- * @typeParam TObject The type of object to dispatch.
129
- * @typeParam TParam The parameter names of the requested URL.
127
+ * @template TContextData The context data to pass to the {@link Context}.
128
+ * @template TObject The type of object to dispatch.
129
+ * @template TParam The parameter names of the requested URL.
130
130
  * @since 0.7.0
131
131
  */
132
132
  type ObjectDispatcher<TContextData, TObject extends Object$1, TParam extends string> = (context: RequestContext<TContextData>, values: Record<TParam, string>) => TObject | null | Promise<TObject | null>;
133
133
  /**
134
134
  * A callback that dispatches a collection.
135
135
  *
136
- * @typeParam TItem The type of items in the collection.
137
- * @typeParam TContext The type of the context. {@link Context} or
136
+ * @template TItem The type of items in the collection.
137
+ * @template TContext The type of the context. {@link Context} or
138
138
  * {@link RequestContext}.
139
- * @typeParam TContextData The context data to pass to the `TContext`.
140
- * @typeParam TFilter The type of the filter, if any.
139
+ * @template TContextData The context data to pass to the `TContext`.
140
+ * @template TFilter The type of the filter, if any.
141
141
  * @param context The context.
142
142
  * @param identifier The internal identifier or the username of the collection
143
143
  * owner.
@@ -149,7 +149,7 @@ type CollectionDispatcher<TItem, TContext extends Context<TContextData>, TContex
149
149
  /**
150
150
  * A callback that counts the number of items in a collection.
151
151
  *
152
- * @typeParam TContextData The context data to pass to the {@link Context}.
152
+ * @template TContextData The context data to pass to the {@link Context}.
153
153
  * @param context The context.
154
154
  * @param identifier The internal identifier or the username of the collection
155
155
  * owner.
@@ -159,10 +159,10 @@ type CollectionCounter<TContextData, TFilter> = (context: RequestContext<TContex
159
159
  /**
160
160
  * A callback that returns a cursor for a collection.
161
161
  *
162
- * @typeParam TContext The type of the context. {@link Context} or
162
+ * @template TContext The type of the context. {@link Context} or
163
163
  * {@link RequestContext}.
164
- * @typeParam TContextData The context data to pass to the {@link Context}.
165
- * @typeParam TFilter The type of the filter, if any.
164
+ * @template TContextData The context data to pass to the {@link Context}.
165
+ * @template TFilter The type of the filter, if any.
166
166
  * @param context The context.
167
167
  * @param identifier The internal identifier or the username of the collection
168
168
  * owner.
@@ -172,8 +172,8 @@ type CollectionCursor<TContext extends Context<TContextData>, TContextData, TFil
172
172
  /**
173
173
  * A callback that listens for activities in an inbox.
174
174
  *
175
- * @typeParam TContextData The context data to pass to the {@link Context}.
176
- * @typeParam TActivity The type of activity to listen for.
175
+ * @template TContextData The context data to pass to the {@link Context}.
176
+ * @template TActivity The type of activity to listen for.
177
177
  * @param context The inbox context.
178
178
  * @param activity The activity that was received.
179
179
  */
@@ -181,7 +181,7 @@ type InboxListener<TContextData, TActivity extends Activity> = (context: InboxCo
181
181
  /**
182
182
  * A callback that handles errors in an inbox.
183
183
  *
184
- * @typeParam TContextData The context data to pass to the {@link Context}.
184
+ * @template TContextData The context data to pass to the {@link Context}.
185
185
  * @param context The inbox context.
186
186
  */
187
187
  type InboxErrorHandler<TContextData> = (context: Context<TContextData>, error: Error) => void | Promise<void>;
@@ -189,7 +189,7 @@ type InboxErrorHandler<TContextData> = (context: Context<TContextData>, error: E
189
189
  * A callback that dispatches the key pair for the authenticated document loader
190
190
  * of the {@link Context} passed to the shared inbox listener.
191
191
  *
192
- * @typeParam TContextData The context data to pass to the {@link Context}.
192
+ * @template TContextData The context data to pass to the {@link Context}.
193
193
  * @param context The context.
194
194
  * @returns The username or the internal identifier of the actor or the key pair
195
195
  * for the authenticated document loader of the {@link Context} passed
@@ -222,7 +222,7 @@ type OutboxErrorHandler = (error: Error, activity: Activity | null) => void | Pr
222
222
  /**
223
223
  * A callback that determines if a request is authorized or not.
224
224
  *
225
- * @typeParam TContextData The context data to pass to the {@link Context}.
225
+ * @template TContextData The context data to pass to the {@link Context}.
226
226
  * @param context The request context.
227
227
  * @param identifier The internal identifier of the actor that is being requested.
228
228
  * @param signedKey *Deprecated in Fedify 1.5.0 in favor of
@@ -242,8 +242,8 @@ type AuthorizePredicate<TContextData> = (context: RequestContext<TContextData>,
242
242
  /**
243
243
  * A callback that determines if a request is authorized or not.
244
244
  *
245
- * @typeParam TContextData The context data to pass to the {@link Context}.
246
- * @typeParam TParam The parameter names of the requested URL.
245
+ * @template TContextData The context data to pass to the {@link Context}.
246
+ * @template TParam The parameter names of the requested URL.
247
247
  * @param context The request context.
248
248
  * @param values The parameters of the requested URL.
249
249
  * @param signedKey *Deprecated in Fedify 1.5.0 in favor of
@@ -260,8 +260,48 @@ type AuthorizePredicate<TContextData> = (context: RequestContext<TContextData>,
260
260
  * @since 0.7.0
261
261
  */
262
262
  type ObjectAuthorizePredicate<TContextData, TParam extends string> = (context: RequestContext<TContextData>, values: Record<TParam, string>, signedKey: CryptographicKey | null, signedKeyOwner: Actor | null) => boolean | Promise<boolean>;
263
+ /**
264
+ * A callback that dispatches a custom collection.
265
+ *
266
+ * @template TItem The type of items in the collection.
267
+ * @template TParams The parameter names of the requested URL.
268
+ * @template TContext The type of the context. {@link Context} or
269
+ * {@link RequestContext}.
270
+ * @template TContextData The context data to pass to the `TContext`.
271
+ * @template TFilter The type of the filter, if any.
272
+ * @param context The context.
273
+ * @param values The parameters of the requested URL.
274
+ * @param cursor The cursor to start the collection from, or `null` to dispatch
275
+ * the entire collection without pagination.
276
+ * @since 1.8.0
277
+ */
278
+ type CustomCollectionDispatcher<TItem, TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: TParams, cursor: string | null) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>;
279
+ /**
280
+ * A callback that counts the number of items in a custom collection.
281
+ *
282
+ * @template TParams The parameter names of the requested URL.
283
+ * @template TContextData The context data to pass to the {@link Context}.
284
+ * @param context The context.
285
+ * @param values The parameters of the requested URL.
286
+ * @since 1.8.0
287
+ */
288
+ type CustomCollectionCounter<TParams extends Record<string, string>, TContextData> = (context: RequestContext<TContextData>, values: TParams) => number | bigint | null | Promise<number | bigint | null>;
289
+ /**
290
+ * A callback that returns a cursor for a custom collection.
291
+ *
292
+ * @template TParams The parameter names of the requested URL.
293
+ * @template TContext The type of the context. {@link Context} or
294
+ * {@link RequestContext}.
295
+ * @template TContextData The context data to pass to the {@link Context}.
296
+ * @template TFilter The type of the filter, if any.
297
+ * @param context The context.
298
+ * @param values The parameters of the requested URL.
299
+ * @since 1.8.0
300
+ */
301
+ type CustomCollectionCursor<TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: TParams) => string | null | Promise<string | null>;
263
302
  //#endregion
264
303
  //#region federation/handler.d.ts
304
+
265
305
  /**
266
306
  * Options for the {@link respondWithObject} and
267
307
  * {@link respondWithObjectIfAcceptable} functions.
@@ -509,7 +549,7 @@ declare function createExponentialBackoffPolicy(options?: CreateExponentialBacko
509
549
  //#region federation/middleware.d.ts
510
550
  /**
511
551
  * Options for {@link createFederation} function.
512
- * @typeParam TContextData The type of the context data.
552
+ * @template TContextData The type of the context data.
513
553
  * @since 0.10.0
514
554
  * @deprecated Use {@link FederationOptions} instead.
515
555
  */
@@ -613,7 +653,7 @@ interface FederationStartQueueOptions {
613
653
  }
614
654
  /**
615
655
  * A common interface between {@link Federation} and {@link FederationBuilder}.
616
- * @typeParam TContextData The context data to pass to the {@link Context}.
656
+ * @template TContextData The context data to pass to the {@link Context}.
617
657
  * @since 1.6.0
618
658
  */
619
659
  interface Federatable<TContextData> {
@@ -655,9 +695,9 @@ interface Federatable<TContextData> {
655
695
  /**
656
696
  * Registers an object dispatcher.
657
697
  *
658
- * @typeParam TContextData The context data to pass to the {@link Context}.
659
- * @typeParam TObject The type of object to dispatch.
660
- * @typeParam TParam The parameter names of the requested URL.
698
+ * @template TContextData The context data to pass to the {@link Context}.
699
+ * @template TObject The type of object to dispatch.
700
+ * @template TParam The parameter names of the requested URL.
661
701
  * @param cls The Activity Vocabulary class of the object to dispatch.
662
702
  * @param path The URI path pattern for the object dispatcher. The syntax is
663
703
  * based on URI Template
@@ -671,9 +711,9 @@ interface Federatable<TContextData> {
671
711
  /**
672
712
  * Registers an object dispatcher.
673
713
  *
674
- * @typeParam TContextData The context data to pass to the {@link Context}.
675
- * @typeParam TObject The type of object to dispatch.
676
- * @typeParam TParam The parameter names of the requested URL.
714
+ * @template TContextData The context data to pass to the {@link Context}.
715
+ * @template TObject The type of object to dispatch.
716
+ * @template TParam The parameter names of the requested URL.
677
717
  * @param cls The Activity Vocabulary class of the object to dispatch.
678
718
  * @param path The URI path pattern for the object dispatcher. The syntax is
679
719
  * based on URI Template
@@ -687,9 +727,9 @@ interface Federatable<TContextData> {
687
727
  /**
688
728
  * Registers an object dispatcher.
689
729
  *
690
- * @typeParam TContextData The context data to pass to the {@link Context}.
691
- * @typeParam TObject The type of object to dispatch.
692
- * @typeParam TParam The parameter names of the requested URL.
730
+ * @template TContextData The context data to pass to the {@link Context}.
731
+ * @template TObject The type of object to dispatch.
732
+ * @template TParam The parameter names of the requested URL.
693
733
  * @param cls The Activity Vocabulary class of the object to dispatch.
694
734
  * @param path The URI path pattern for the object dispatcher. The syntax is
695
735
  * based on URI Template
@@ -703,9 +743,9 @@ interface Federatable<TContextData> {
703
743
  /**
704
744
  * Registers an object dispatcher.
705
745
  *
706
- * @typeParam TContextData The context data to pass to the {@link Context}.
707
- * @typeParam TObject The type of object to dispatch.
708
- * @typeParam TParam The parameter names of the requested URL.
746
+ * @template TContextData The context data to pass to the {@link Context}.
747
+ * @template TObject The type of object to dispatch.
748
+ * @template TParam The parameter names of the requested URL.
709
749
  * @param cls The Activity Vocabulary class of the object to dispatch.
710
750
  * @param path The URI path pattern for the object dispatcher. The syntax is
711
751
  * based on URI Template
@@ -719,9 +759,9 @@ interface Federatable<TContextData> {
719
759
  /**
720
760
  * Registers an object dispatcher.
721
761
  *
722
- * @typeParam TContextData The context data to pass to the {@link Context}.
723
- * @typeParam TObject The type of object to dispatch.
724
- * @typeParam TParam The parameter names of the requested URL.
762
+ * @template TContextData The context data to pass to the {@link Context}.
763
+ * @template TObject The type of object to dispatch.
764
+ * @template TParam The parameter names of the requested URL.
725
765
  * @param cls The Activity Vocabulary class of the object to dispatch.
726
766
  * @param path The URI path pattern for the object dispatcher. The syntax is
727
767
  * based on URI Template
@@ -735,9 +775,9 @@ interface Federatable<TContextData> {
735
775
  /**
736
776
  * Registers an object dispatcher.
737
777
  *
738
- * @typeParam TContextData The context data to pass to the {@link Context}.
739
- * @typeParam TObject The type of object to dispatch.
740
- * @typeParam TParam The parameter names of the requested URL.
778
+ * @template TContextData The context data to pass to the {@link Context}.
779
+ * @template TObject The type of object to dispatch.
780
+ * @template TParam The parameter names of the requested URL.
741
781
  * @param cls The Activity Vocabulary class of the object to dispatch.
742
782
  * @param path The URI path pattern for the object dispatcher. The syntax is
743
783
  * based on URI Template
@@ -874,6 +914,36 @@ interface Federatable<TContextData> {
874
914
  * @throws {RouteError} Thrown if the path pattern is invalid.
875
915
  */
876
916
  setInboxListeners(inboxPath: `${string}{identifier}${string}` | `${string}{handle}${string}`, sharedInboxPath?: string): InboxListenerSetters<TContextData>;
917
+ /**
918
+ * Registers a collection of objects dispatcher.
919
+ *
920
+ * @template TContextData The context data to pass to the {@link Context}.
921
+ * @template TObject The type of objects to dispatch.
922
+ * @template TParam The parameter names of the requested URL.
923
+ * @param name A unique name for the collection dispatcher.
924
+ * @param itemType The Activity Vocabulary class of the object to dispatch.
925
+ * @param path The URI path pattern for the collection dispatcher.
926
+ * The syntax is based on URI Template
927
+ * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
928
+ * The path must have one or more variables.
929
+ * @param dispatcher A collection dispatcher callback to register.
930
+ */
931
+ setCollectionDispatcher<TObject extends Object$1, TParams extends Record<string, string>>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: ParamsKeyPath<TParams>, dispatcher: CustomCollectionDispatcher<TObject, TParams, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParams, RequestContext<TContextData>, TContextData>;
932
+ /**
933
+ * Registers an ordered collection of objects dispatcher.
934
+ *
935
+ * @template TContextData The context data to pass to the {@link Context}.
936
+ * @template TObject The type of objects to dispatch.
937
+ * @template TParam The parameter names of the requested URL.
938
+ * @param name A unique name for the collection dispatcher.
939
+ * @param itemType The Activity Vocabulary class of the object to dispatch.
940
+ * @param path The URI path pattern for the collection dispatcher.
941
+ * The syntax is based on URI Template
942
+ * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
943
+ * The path must have one or more variables.
944
+ * @param dispatcher A collection dispatcher callback to register.
945
+ */
946
+ setOrderedCollectionDispatcher<TObject extends Object$1, TParams extends Record<string, string>>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: ParamsKeyPath<TParams>, dispatcher: CustomCollectionDispatcher<TObject, TParams, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParams, RequestContext<TContextData>, TContextData>;
877
947
  }
878
948
  /**
879
949
  * An object that registers federation-related business logic and dispatches
@@ -881,7 +951,7 @@ interface Federatable<TContextData> {
881
951
  *
882
952
  * It also provides a middleware interface for handling requests before your
883
953
  * web framework's router; see {@link Federation.fetch}.
884
- * @typeParam TContextData The context data to pass to the {@link Context}.
954
+ * @template TContextData The context data to pass to the {@link Context}.
885
955
  * @since 0.13.0
886
956
  */
887
957
  interface Federation<TContextData> extends Federatable<TContextData> {
@@ -940,7 +1010,7 @@ interface Federation<TContextData> extends Federatable<TContextData> {
940
1010
  * instantiation of the {@link Federation} object until the {@link build}
941
1011
  * method is called so that dispatchers and listeners can be registered
942
1012
  * before the {@link Federation} object is instantiated.
943
- * @typeParam TContextData The context data to pass to the {@link Context}.
1013
+ * @template TContextData The context data to pass to the {@link Context}.
944
1014
  * @since 1.6.0
945
1015
  */
946
1016
  interface FederationBuilder<TContextData> extends Federatable<TContextData> {
@@ -952,7 +1022,7 @@ interface FederationBuilder<TContextData> extends Federatable<TContextData> {
952
1022
  }
953
1023
  /**
954
1024
  * Options for creating a {@link Federation} object.
955
- * @typeParam TContextData The context data to pass to the {@link Context}.
1025
+ * @template TContextData The context data to pass to the {@link Context}.
956
1026
  * @since 1.6.0
957
1027
  */
958
1028
  interface FederationOptions<TContextData> {
@@ -1197,10 +1267,10 @@ interface ObjectCallbackSetters<TContextData, TObject extends Object$1, TParam e
1197
1267
  /**
1198
1268
  * Additional settings for a collection dispatcher.
1199
1269
  *
1200
- * @typeParam TContext The type of the context. {@link Context} or
1270
+ * @template TContext The type of the context. {@link Context} or
1201
1271
  * {@link RequestContext}.
1202
- * @typeParam TContextData The context data to pass to the {@link Context}.
1203
- * @typeParam TFilter The type of filter for the collection.
1272
+ * @template TContextData The context data to pass to the {@link Context}.
1273
+ * @template TFilter The type of filter for the collection.
1204
1274
  */
1205
1275
  interface CollectionCallbackSetters<TContext extends Context<TContextData>, TContextData, TFilter> {
1206
1276
  /**
@@ -1263,7 +1333,7 @@ interface InboxListenerSetters<TContextData> {
1263
1333
  /**
1264
1334
  * Parameters of {@link Federation.fetch} method.
1265
1335
  *
1266
- * @typeParam TContextData The context data to pass to the {@link Context}.
1336
+ * @template TContextData The context data to pass to the {@link Context}.
1267
1337
  * @since 0.6.0
1268
1338
  */
1269
1339
  interface FederationFetchOptions<TContextData> {
@@ -1294,6 +1364,119 @@ interface FederationFetchOptions<TContextData> {
1294
1364
  */
1295
1365
  onUnauthorized?: (request: Request) => Response | Promise<Response>;
1296
1366
  }
1367
+ /**
1368
+ * Additional settings for a custom collection dispatcher.
1369
+ *
1370
+ * @template TParams The type of the parameters in the URL path.
1371
+ * @template TContext The type of the context. {@link Context} or
1372
+ * {@link RequestContext}.
1373
+ * @template TContextData The context data to pass to the {@link Context}.
1374
+ * @template TFilter The type of filter for the collection.
1375
+ */
1376
+ interface CustomCollectionCallbackSetters<TParams extends Record<string, string>, TContext extends Context<TContextData>, TContextData> {
1377
+ /**
1378
+ * Sets the counter for the custom collection.
1379
+ * @param counter A callback that returns the number of items in the custom collection.
1380
+ * @returns The setters object so that settings can be chained.
1381
+ */
1382
+ setCounter(counter: CustomCollectionCounter<TParams, TContextData>): CustomCollectionCallbackSetters<TParams, TContext, TContextData>;
1383
+ /**
1384
+ * Sets the first cursor for the custom collection.
1385
+ * @param cursor The cursor for the first item in the custom collection.
1386
+ * @returns The setters object so that settings can be chained.
1387
+ */
1388
+ setFirstCursor(cursor: CustomCollectionCursor<TParams, TContext, TContextData>): CustomCollectionCallbackSetters<TParams, TContext, TContextData>;
1389
+ /**
1390
+ * Sets the last cursor for the custom collection.
1391
+ * @param cursor The cursor for the last item in the custom collection.
1392
+ * @returns The setters object so that settings can be chained.
1393
+ */
1394
+ setLastCursor(cursor: CustomCollectionCursor<TParams, TContext, TContextData>): CustomCollectionCallbackSetters<TParams, TContext, TContextData>;
1395
+ /**
1396
+ * Specifies the conditions under which requests are authorized.
1397
+ * @param predicate A callback that returns whether a request is authorized.
1398
+ * @returns The setters object so that settings can be chained.
1399
+ * @since 0.7.0
1400
+ */
1401
+ authorize(predicate: ObjectAuthorizePredicate<TContextData, string>): CustomCollectionCallbackSetters<TParams, TContext, TContextData>;
1402
+ }
1403
+ /**
1404
+ * Represents an object with a type ID, which is either a constructor or an
1405
+ * instance of the object.
1406
+ *
1407
+ * @template TObject The type of the object.
1408
+ */
1409
+ type ConstructorWithTypeId<TObject extends Object$1> = (new (...args: any[]) => TObject) & {
1410
+ typeId: URL;
1411
+ };
1412
+ /**
1413
+ * Represents a path from the key of parameter objects.
1414
+ * @param Params - A record of parameters where keys are parameter names and
1415
+ * values are their string representations.
1416
+ * @returns A string representing the path with all parameters.
1417
+ * @example
1418
+ * ```ts
1419
+ * type UserPostPath = ParamsKeyPath<{ userId: string; postId: string }>;
1420
+ * let userPostPath: UserPostPath;
1421
+ * // userPostPath = "/posts/{postId}"; // invalid - does not contain `{userId}`
1422
+ * // userPostPath = "/users/{userId}"; // invalid - does not contain `{postId}`
1423
+ * userPostPath = "/users/{userId}/posts/{postId}"; // valid
1424
+ * userPostPath = "/posts/{postId}/users/{userId}"; // valid
1425
+ * ```
1426
+ */
1427
+ type ParamsKeyPath<Params extends Record<string, string>> = ParamsPath<Extract<keyof Params, string>> & string;
1428
+ /**
1429
+ * Represents a path with multiple parameters.
1430
+ * All permutations of the parameters are included in the union type.
1431
+ * The path must have all parameters in the form of `{paramName}`.
1432
+ * @param Params - A union of parameter names.
1433
+ * @returns A string representing the path with all parameters.
1434
+ * @example
1435
+ * ```ts
1436
+ * type UserPostPath = ParamsPath<"userId" | "postId">;
1437
+ * // = `${string}{userId}${string}` & `${string}{postId}${string}`
1438
+ * // =
1439
+ * // | `${string}{userId}${string}{postId}${string}`
1440
+ * // | `${string}{postId}${string}{userId}${string}`
1441
+ * let userPostPath: UserPostPath;
1442
+ * userPostPath = "/users/posts"; // ❌ invalid
1443
+ * userPostPath = "/users/{userId}"; // ❌ invalid
1444
+ * userPostPath = "/posts/{postId}"; // ❌ invalid
1445
+ * userPostPath = "/users/{userId}/posts/{postId}"; // ✅ valid
1446
+ * userPostPath = "/posts/{postId}/users/{userId}"; // ✅ valid
1447
+ */
1448
+ type ParamsPath<Params extends string> = UnionToIntersection<ParamPath<Params>>;
1449
+ /**
1450
+ * Represents a path with a single parameter.
1451
+ * The path must have at least one of the parameters in the form of `{paramName}`.
1452
+ * @param Param - The name of the parameter.
1453
+ * @returns A string representing the path with the parameter.
1454
+ * @example
1455
+ * ```ts
1456
+ * type UserPostPath = ParamPath<"userId" | "postId">;
1457
+ * // = `${string}{userId}${string}` | `${string}{postId}${string}`
1458
+ * let userPostPath: UserPostPath;
1459
+ * userPostPath = "/users/posts"; // ❌ invalid
1460
+ * userPostPath = "/users/{userId}"; // ✅ valid
1461
+ * userPostPath = "/posts/{postId}"; // ✅ valid
1462
+ * userPostPath = "/users/{userId}/posts/{postId}"; // ✅ valid
1463
+ * userPostPath = "/posts/{postId}/users/{userId}"; // ✅ valid
1464
+ */
1465
+ type ParamPath<Param extends string> = `${string}{${Param}}${string}`;
1466
+ /**
1467
+ * Converts union types to intersection types.
1468
+ *
1469
+ * @template U - The union type to convert.
1470
+ * @returns The intersection type of the union.
1471
+ * @example
1472
+ * ```ts
1473
+ * type A = { a: string };
1474
+ * type B = { b: number };
1475
+ * type AorB = A | B;
1476
+ * type AandB = UnionToIntersection<AorB>;
1477
+ * // AandB = { a: string; b: number }
1478
+ */
1479
+ type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never;
1297
1480
  //#endregion
1298
1481
  //#region federation/context.d.ts
1299
1482
  /**
@@ -1648,6 +1831,16 @@ interface Context<TContextData> {
1648
1831
  * @since 1.3.0
1649
1832
  */
1650
1833
  routeActivity(recipient: string | null, activity: Activity, options?: RouteActivityOptions): Promise<boolean>;
1834
+ /**
1835
+ * Builds the URI of a collection of objects with the given name and values.
1836
+ * @param name The name of the collection, which can be a string or a symbol.
1837
+ * @param values The values of the URI parameters.
1838
+ * @return The URI of the collection.
1839
+ * @throws {RouteError} If no object dispatcher is available for the name.
1840
+ * @throws {TypeError} If values are invalid.
1841
+ * @since 1.8.0
1842
+ */
1843
+ getCollectionUri<TParam extends Record<string, string>>(name: string | symbol, values: TParam): URL;
1651
1844
  }
1652
1845
  /**
1653
1846
  * A context for a request.
@@ -1898,6 +2091,26 @@ type ParseUriResult =
1898
2091
  readonly type: "featuredTags";
1899
2092
  readonly identifier: string;
1900
2093
  readonly handle: string;
2094
+ }
2095
+ /**
2096
+ * The case of a custom collection URI.
2097
+ * @since 1.8.0
2098
+ */ | {
2099
+ readonly type: "collection";
2100
+ readonly name: string | symbol;
2101
+ readonly class: ConstructorWithTypeId<Object$1>;
2102
+ readonly typeId: URL;
2103
+ readonly values: Record<string, string>;
2104
+ }
2105
+ /**
2106
+ * The case of a custom ordered collection URI.
2107
+ * @since 1.8.0
2108
+ */ | {
2109
+ readonly type: "orderedCollection";
2110
+ readonly name: string | symbol;
2111
+ readonly class: ConstructorWithTypeId<Object$1>;
2112
+ readonly typeId: URL;
2113
+ readonly values: Record<string, string>;
1901
2114
  };
1902
2115
  /**
1903
2116
  * Options for {@link Context.sendActivity} method.
@@ -2034,4 +2247,4 @@ interface ActorKeyPair extends CryptoKeyPair {
2034
2247
  multikey: Multikey;
2035
2248
  }
2036
2249
  //#endregion
2037
- export { ActivityTransformer, ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, Context, CreateExponentialBackoffPolicyOptions, CreateFederationOptions, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, Message, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
2250
+ export { ActivityTransformer, 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, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { KvKey, KvStore } from "./kv-DDdb1hMa.js";
3
+ import { KvKey, KvStore } from "./kv-BqOK6zss.js";
4
4
 
5
5
  //#region runtime/docloader.d.ts
6
6
  /**
@@ -10,7 +10,7 @@ import { isIP } from "node:net";
10
10
 
11
11
  //#region deno.json
12
12
  var name = "@fedify/fedify";
13
- var version = "1.8.1-pr.334.1193+17e63d2f";
13
+ var version = "1.8.1-pr.340.1214+314e295d";
14
14
  var license = "MIT";
15
15
  var exports = {
16
16
  ".": "./mod.ts",
@@ -3,7 +3,7 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { __commonJS, __toESM } from "./type-DGlR8Urb.js";
6
+ import { __commonJS, __toESM } from "./type-DDS4cl1h.js";
7
7
 
8
8
  //#region ../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
9
9
  var require_glob_to_regexp = __commonJS({ "../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js"(exports, module) {
@@ -3,21 +3,21 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Activity, Note, Person } from "../type-DGlR8Urb.js";
6
+ import { Activity, Note, Person } from "../type-DDS4cl1h.js";
7
7
  import { assertEquals } from "../assert_equals-C5gKCm6A.js";
8
8
  import "../assert-DwEa6glZ.js";
9
9
  import "../assert_instance_of-C9QtN-X9.js";
10
10
  import { MemoryKvStore } from "../kv-D7Yt6pnB.js";
11
11
  import { parseSemVer } from "../semver-DCqorrj5.js";
12
- import "../lookup-B0_qPExk.js";
13
- import "../inbox-CKssCQNk.js";
14
- import { createFederationBuilder } from "../builder-BMWyrhEH.js";
15
- import { test } from "../testing-CROcCUCq.js";
12
+ import "../lookup-Cph3FzCE.js";
13
+ import "../inbox-BU_xB7k0.js";
14
+ import { createFederationBuilder } from "../builder-BMJsk4Fm.js";
15
+ import { test } from "../testing-B1f6X3bJ.js";
16
16
  import { assertExists } from "../std__assert-BQdmxyzF.js";
17
17
  import "../assert_rejects-AjlKk-Vo.js";
18
18
  import "../assert_is_error-CeVBLPsZ.js";
19
19
  import "../assert_not_equals-D2R2nl5h.js";
20
- import "../assert_throws-CqMKbTh_.js";
20
+ import { assertThrows } from "../assert_throws-CqMKbTh_.js";
21
21
 
22
22
  //#region federation/builder.test.ts
23
23
  test("FederationBuilder", async (t) => {
@@ -150,6 +150,25 @@ test("FederationBuilder", async (t) => {
150
150
  assertEquals(personRoute?.name, `object:${Person.typeId.href}`);
151
151
  assertEquals(personRoute?.values.id, "abc");
152
152
  });
153
+ await t.step("should handle symbol names uniquely in custom collection dispatchers", () => {
154
+ const builder = createFederationBuilder();
155
+ const unnamedSymbol1 = Symbol();
156
+ const unnamedSymbol2 = Symbol();
157
+ const namedSymbol1 = Symbol.for("");
158
+ const namedSymbol2 = Symbol.for("");
159
+ const strId = String(unnamedSymbol1);
160
+ const dispatcher = (_ctx, _params) => ({ items: [] });
161
+ builder.setCollectionDispatcher(unnamedSymbol1, Note, "/unnamed-symbol1/{id}", dispatcher);
162
+ assertThrows(() => {
163
+ builder.setCollectionDispatcher(unnamedSymbol1, Note, "/unnamed-symbol1-duplicate/{id}", dispatcher);
164
+ }, Error, "Collection dispatcher for Symbol() already set.");
165
+ builder.setCollectionDispatcher(unnamedSymbol2, Note, "/unnamed-symbol2/{id}", dispatcher);
166
+ builder.setCollectionDispatcher(namedSymbol1, Note, "/named-symbol/{id}", dispatcher);
167
+ assertThrows(() => {
168
+ builder.setCollectionDispatcher(namedSymbol2, Note, "/named-symbol/{id}", dispatcher);
169
+ });
170
+ builder.setCollectionDispatcher(strId, Note, "/string-id/{id}", dispatcher);
171
+ });
153
172
  });
154
173
 
155
174
  //#endregion