@fedify/fedify 2.0.0-dev.1726 → 2.0.0-dev.1750

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 (194) hide show
  1. package/README.md +3 -0
  2. package/dist/{actor-menZmmiI.js → actor-CMgHXjhs.js} +189 -677
  3. package/dist/{actor-dO7jHa6A.js → actor-CRS7Dbo1.js} +1 -1
  4. package/dist/{actor-T6RyhRgk.d.ts → actor-DqFajh9s.d.ts} +2 -2
  5. package/dist/{actor-Bn2RCpws.cjs → actor-JG822JBi.cjs} +921 -1451
  6. package/dist/{actor-D6K058Tb.d.cts → actor-f2NtjyCg.d.cts} +2 -2
  7. package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
  8. package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
  9. package/dist/{builder-CGF1vv7G.js → builder-D44QzfuD.js} +3 -4
  10. package/dist/{client-CegPX0Rn.d.cts → client-94iWEfQa.d.cts} +1 -1
  11. package/dist/{client-bgSdkFa2.d.ts → client-BsGzbnV-.d.ts} +1 -1
  12. package/dist/{client-BfzV3u96.js → client-pY7-3icS.js} +1 -1
  13. package/dist/compat/mod.d.cts +11 -12
  14. package/dist/compat/mod.d.ts +11 -12
  15. package/dist/compat/transformers.test.js +20 -20
  16. package/dist/{context-B1X8-X33.d.ts → context-DG0huGW-.d.ts} +25 -55
  17. package/dist/{context-DYCJXr7J.d.cts → context-DJ8aSy2Q.d.cts} +25 -55
  18. package/dist/{authdocloader-DevmXsTo.js → docloader-BvlqkI1M.js} +17 -8
  19. package/dist/{esm-BODOj_Oi.js → esm-BZMLn6gu.js} +11 -11
  20. package/dist/federation/builder.test.js +8 -10
  21. package/dist/federation/collection.test.js +7 -9
  22. package/dist/federation/handler.test.js +25 -26
  23. package/dist/federation/idempotency.test.js +25 -26
  24. package/dist/federation/inbox.test.js +4 -6
  25. package/dist/federation/keycache.test.js +3 -4
  26. package/dist/federation/kv.test.js +6 -8
  27. package/dist/federation/middleware.test.js +26 -27
  28. package/dist/federation/mod.cjs +9 -11
  29. package/dist/federation/mod.d.cts +11 -12
  30. package/dist/federation/mod.d.ts +11 -12
  31. package/dist/federation/mod.js +9 -11
  32. package/dist/federation/mq.test.js +8 -10
  33. package/dist/federation/negotiation.test.js +7 -9
  34. package/dist/federation/retry.test.js +4 -5
  35. package/dist/federation/router.test.js +6 -8
  36. package/dist/federation/send.test.js +13 -15
  37. package/dist/{http-gHyCrTrX.js → http-BPsXiq3Y.js} +256 -6
  38. package/dist/{http-D6Uj2x2y.d.ts → http-BbO0ejuk.d.ts} +2 -2
  39. package/dist/{http-BmbMWfmh.cjs → http-CPqfuthT.cjs} +289 -9
  40. package/dist/{http-Danw_xTY.js → http-DIsJckI7.js} +2 -2
  41. package/dist/{http-D-e6AFwR.d.cts → http-M8k5mKc0.d.cts} +2 -2
  42. package/dist/{inbox-Blp5F74G.js → inbox-24__vIeD.js} +1 -1
  43. package/dist/{key-CIIkeide.js → key-CcqQC_vj.js} +3 -2
  44. package/dist/{keycache-Covv8lvK.js → keycache-BUF-P0-V.js} +1 -1
  45. package/dist/{keys-DZ1bqhJz.js → keys-DSikT9wk.js} +2 -1
  46. package/dist/kv-cache-CBOkGH5t.js +121 -0
  47. package/dist/kv-cache-gyMh96Y-.cjs +133 -0
  48. package/dist/kv-cache-z0lgwFi_.js +93 -0
  49. package/dist/{ld-C7KL1MK2.js → ld-C5wht8V2.js} +3 -2
  50. package/dist/lookup-BE8ZMmug.js +261 -0
  51. package/dist/{type-D_8QzkEn.js → lookup-CxJLpHHf.js} +503 -5327
  52. package/dist/lookup-Doq5XdGY.cjs +273 -0
  53. package/dist/{middleware-HKKY6sAX.js → middleware-BImvTjdU.js} +18 -17
  54. package/dist/middleware-BsLmqSNx.cjs +15 -0
  55. package/dist/middleware-CdFqipch.js +15 -0
  56. package/dist/{middleware-C60xXvWx.cjs → middleware-ClcQM1de.cjs} +30 -31
  57. package/dist/{middleware-DXOZ6_ST.js → middleware-D5NFjhOL.js} +10 -11
  58. package/dist/middleware-ZZJaIUDZ.js +26 -0
  59. package/dist/{mod-BhUKmBJD.d.ts → mod-B2iOw50L.d.ts} +3 -3
  60. package/dist/mod-BYynOiJG.d.ts +109 -0
  61. package/dist/{mod-DlU8ISoa.d.ts → mod-BlVovdcy.d.ts} +2 -2
  62. package/dist/{mod-DcKxhFQ8.d.ts → mod-BoHnwOCs.d.ts} +2 -2
  63. package/dist/{mod-CxkWO3Mg.d.cts → mod-BxRCHTz-.d.cts} +2 -2
  64. package/dist/{mod-jQ4OODsl.d.cts → mod-C58MZ7Wx.d.cts} +1 -1
  65. package/dist/{mod-twdvV2hR.d.cts → mod-DJcZDvjA.d.cts} +2 -2
  66. package/dist/{mod-Djzcw2ry.d.cts → mod-DgdBYYa0.d.cts} +3 -3
  67. package/dist/{mod-DBzN0aCM.d.ts → mod-Ds0mpFZU.d.ts} +1 -1
  68. package/dist/mod-VastcQsk.d.cts +107 -0
  69. package/dist/mod.cjs +19 -32
  70. package/dist/mod.d.cts +15 -16
  71. package/dist/mod.d.ts +16 -17
  72. package/dist/mod.js +14 -16
  73. package/dist/nodeinfo/client.test.js +8 -10
  74. package/dist/nodeinfo/handler.test.js +24 -25
  75. package/dist/nodeinfo/mod.cjs +2 -3
  76. package/dist/nodeinfo/mod.d.cts +2 -4
  77. package/dist/nodeinfo/mod.d.ts +2 -4
  78. package/dist/nodeinfo/mod.js +2 -3
  79. package/dist/nodeinfo/types.test.js +7 -9
  80. package/dist/{owner-BN_tO3cY.d.cts → owner-B4HbyP8s.d.cts} +3 -3
  81. package/dist/{owner-COcyel6J.js → owner-DIa5WpbP.js} +3 -2
  82. package/dist/{owner-hd9lvQcP.d.ts → owner-kQRGVXG1.d.ts} +3 -3
  83. package/dist/{proof-Cpk853lc.js → proof-CCzhKDDB.js} +2 -2
  84. package/dist/{proof-D6pbnNx2.js → proof-D0ak0hhc.js} +5 -4
  85. package/dist/{proof-CMJcrQoM.cjs → proof-DTKtjEh_.cjs} +17 -16
  86. package/dist/{send-C7A7_big.js → send-BWfkS2zO.js} +2 -2
  87. package/dist/sig/http.test.js +12 -13
  88. package/dist/sig/key.test.js +9 -11
  89. package/dist/sig/ld.test.js +8 -10
  90. package/dist/sig/mod.cjs +9 -11
  91. package/dist/sig/mod.d.cts +5 -7
  92. package/dist/sig/mod.d.ts +5 -7
  93. package/dist/sig/mod.js +5 -7
  94. package/dist/sig/owner.test.js +10 -12
  95. package/dist/sig/proof.test.js +13 -14
  96. package/dist/testing/docloader.test.js +6 -8
  97. package/dist/testing/mod.d.ts +16 -131
  98. package/dist/testing/mod.js +2 -3
  99. package/dist/{testing-e8Kpb1uV.js → testing-BHLtJbQx.js} +1 -2
  100. package/dist/{types-Db4ukgX8.js → types-BtUjyi5y.js} +1 -1
  101. package/dist/{types-LjTL4QMx.cjs → types-CWgzGaqk.cjs} +3 -3
  102. package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +14 -15
  103. package/dist/utils/kv-cache.test.js +209 -0
  104. package/dist/utils/mod.cjs +12 -0
  105. package/dist/utils/mod.d.cts +5 -0
  106. package/dist/utils/mod.d.ts +7 -0
  107. package/dist/utils/mod.js +11 -0
  108. package/dist/vocab/actor.test.js +8 -10
  109. package/dist/vocab/lookup.test.js +7 -9
  110. package/dist/vocab/mod.cjs +3 -4
  111. package/dist/vocab/mod.d.cts +3 -5
  112. package/dist/vocab/mod.d.ts +3 -5
  113. package/dist/vocab/mod.js +3 -4
  114. package/dist/vocab/type.test.js +2 -3
  115. package/dist/vocab/vocab.test.js +9 -10
  116. package/dist/{vocab-BI0Ak5lL.d.ts → vocab-BCWe1Ih5.d.ts} +2 -21
  117. package/dist/{vocab-DLHpZwOW.cjs → vocab-C3ZbIV8S.cjs} +5 -5
  118. package/dist/{vocab-Dw1-yVGg.d.cts → vocab-CeDBzu-f.d.cts} +2 -21
  119. package/dist/{vocab-CJHF7Q71.js → vocab-CjheaIIe.js} +3 -3
  120. package/dist/webfinger/handler.test.js +24 -25
  121. package/dist/webfinger/lookup.test.js +7 -9
  122. package/dist/webfinger/mod.cjs +2 -3
  123. package/dist/webfinger/mod.d.cts +1 -3
  124. package/dist/webfinger/mod.d.ts +1 -3
  125. package/dist/webfinger/mod.js +2 -3
  126. package/dist/x/cfworkers.d.cts +2 -2
  127. package/dist/x/cfworkers.d.ts +2 -2
  128. package/dist/x/cfworkers.test.js +6 -8
  129. package/dist/x/hono.d.cts +10 -11
  130. package/dist/x/hono.d.ts +10 -11
  131. package/dist/x/sveltekit.d.cts +10 -11
  132. package/dist/x/sveltekit.d.ts +10 -11
  133. package/package.json +15 -14
  134. package/dist/assert_throws-BOO88avQ.js +0 -39
  135. package/dist/authdocloader-CEqdZdT7.cjs +0 -58
  136. package/dist/authdocloader-CZsCIRLV.js +0 -52
  137. package/dist/docloader-Buh0Ah9G.cjs +0 -4861
  138. package/dist/docloader-CxWcuWqQ.d.ts +0 -221
  139. package/dist/docloader-D-MrRyHl.d.cts +0 -219
  140. package/dist/docloader-DOmINJ1U.js +0 -4795
  141. package/dist/key-B2cp5-JF.js +0 -10
  142. package/dist/key-BR1W25rw.cjs +0 -290
  143. package/dist/key-BnjofJ4e.js +0 -260
  144. package/dist/key-DhflzsBJ.cjs +0 -10
  145. package/dist/key-WES6wszI.js +0 -10
  146. package/dist/lookup-CDOxr8vw.cjs +0 -137
  147. package/dist/lookup-D8tCnUj2.js +0 -131
  148. package/dist/lookup-VSVPBU3J.js +0 -331
  149. package/dist/middleware-9KSLASn7.js +0 -17
  150. package/dist/middleware-CH0PNtaj.cjs +0 -17
  151. package/dist/middleware-CrzCnpdt.js +0 -26
  152. package/dist/mod-CerN_Sza.d.ts +0 -104
  153. package/dist/mod-Cj1tHXBR.d.cts +0 -102
  154. package/dist/runtime/docloader.test.js +0 -522
  155. package/dist/runtime/key.test.d.ts +0 -3
  156. package/dist/runtime/key.test.js +0 -103
  157. package/dist/runtime/langstr.test.d.ts +0 -3
  158. package/dist/runtime/langstr.test.js +0 -39
  159. package/dist/runtime/link.test.d.ts +0 -3
  160. package/dist/runtime/link.test.js +0 -61
  161. package/dist/runtime/mod.cjs +0 -25
  162. package/dist/runtime/mod.d.cts +0 -6
  163. package/dist/runtime/mod.d.ts +0 -8
  164. package/dist/runtime/mod.js +0 -13
  165. package/dist/runtime/multibase/multibase.test.d.ts +0 -3
  166. package/dist/runtime/multibase/multibase.test.js +0 -358
  167. package/dist/runtime/url.test.d.ts +0 -3
  168. package/dist/runtime/url.test.js +0 -45
  169. /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
  170. /package/dist/{collection-CcnIw1qY.js → collection-BzWsN9pB.js} +0 -0
  171. /package/dist/{denokv-Bv33Xxea.js → denokv-CCssOzMJ.js} +0 -0
  172. /package/dist/{federation-H2_En3j5.cjs → federation-CRpdnOMS.cjs} +0 -0
  173. /package/dist/{federation-D1U8YY9t.js → federation-jcR8-ZxP.js} +0 -0
  174. /package/dist/{kv-C7sopW2E.d.ts → kv-BKNZ-Tb-.d.ts} +0 -0
  175. /package/dist/{kv-63Cil1MD.d.cts → kv-Bxr0Q87_.d.cts} +0 -0
  176. /package/dist/{mod-FZd39qVq.d.cts → mod-B-hUPT2N.d.cts} +0 -0
  177. /package/dist/{mod-1pDWKvUL.d.ts → mod-CVgZgliM.d.ts} +0 -0
  178. /package/dist/{mod-g0xFzAP9.d.ts → mod-xIj-IT58.d.ts} +0 -0
  179. /package/dist/{mq-CRGm1e_F.d.ts → mq-CUKlBw08.d.ts} +0 -0
  180. /package/dist/{mq-B7R1Q-M5.d.cts → mq-DcJPkXD5.d.cts} +0 -0
  181. /package/dist/{negotiation-5NPJL6zp.js → negotiation-C4nFufNk.js} +0 -0
  182. /package/dist/{nodeinfo-DfycQ8Wf.js → nodeinfo-BnthBobC.js} +0 -0
  183. /package/dist/{nodeinfo-Co9lJrWl.cjs → nodeinfo-CdN0rEnZ.cjs} +0 -0
  184. /package/dist/{retry-D4GJ670a.js → retry-CfF8Gn4d.js} +0 -0
  185. /package/dist/{runtime-DPYEDf-o.js → sig-C34-oHBl.js} +0 -0
  186. /package/dist/{runtime-C58AJWSv.cjs → sig-YYj5tCnr.cjs} +0 -0
  187. /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
  188. /package/dist/{types-BSuWJsOm.js → types-C2XVl6gj.js} +0 -0
  189. /package/dist/{runtime → utils}/docloader.test.d.ts +0 -0
  190. /package/dist/{runtime/authdocloader.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
  191. /package/dist/{sig-Cj3tk-ig.js → utils-D-Va7aXC.js} +0 -0
  192. /package/dist/{sig-ByHXzqUi.cjs → utils-DyRU1gdZ.cjs} +0 -0
  193. /package/dist/{webfinger-De_bU0iE.js → webfinger-C72Y8lrh.js} +0 -0
  194. /package/dist/{webfinger-BjOEdFPs.cjs → webfinger-vAtLmxOF.cjs} +0 -0
@@ -3,17 +3,15 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import "../type-D_8QzkEn.js";
6
+ import "../lookup-CxJLpHHf.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
- import "../lookup-VSVPBU3J.js";
11
- import { mockDocumentLoader, test } from "../testing-e8Kpb1uV.js";
12
- import "../std__assert-X-_kMxKM.js";
13
- import "../assert_rejects-DiIiJbZn.js";
14
- import "../assert_is_error-BPGph1Jx.js";
15
- import "../assert_not_equals-f3m3epl3.js";
16
- import "../assert_throws-BOO88avQ.js";
10
+ import { mockDocumentLoader, test } from "../testing-BHLtJbQx.js";
11
+ import "../std__assert-DWivtrGR.js";
12
+ import "../assert_rejects-Ce45JcFg.js";
13
+ import "../assert_throws-BNXdRGWP.js";
14
+ import "../assert_not_equals-C80BG-_5.js";
17
15
 
18
16
  //#region src/testing/docloader.test.ts
19
17
  test("mockDocumentLoader()", async () => {
@@ -1,75 +1,9 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
+ import { DocumentLoader, GetUserAgentOptions, LanguageString } from "@fedify/vocab-runtime";
4
5
  import { Span, TracerProvider } from "@opentelemetry/api";
5
6
 
6
- //#region src/runtime/docloader.d.ts
7
- /**
8
- * A remote JSON-LD document and its context fetched by
9
- * a {@link DocumentLoader}.
10
- */
11
- interface RemoteDocument {
12
- /**
13
- * The URL of the context document.
14
- */
15
- contextUrl: string | null;
16
- /**
17
- * The fetched JSON-LD document.
18
- */
19
- document: unknown;
20
- /**
21
- * The URL of the fetched document.
22
- */
23
- documentUrl: string;
24
- }
25
- /**
26
- * Options for {@link DocumentLoader}.
27
- * @since 1.8.0
28
- */
29
- interface DocumentLoaderOptions {
30
- /**
31
- * An `AbortSignal` for cancellation.
32
- * @since 1.8.0
33
- */
34
- signal?: AbortSignal;
35
- }
36
- /**
37
- * A JSON-LD document loader that fetches documents from the Web.
38
- * @param url The URL of the document to load.
39
- * @param options The options for the document loader.
40
- * @returns The loaded remote document.
41
- */
42
- type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>;
43
- /**
44
- * A factory function that creates a {@link DocumentLoader} with options.
45
- * @param options The options for the document loader.
46
- * @returns The document loader.
47
- * @since 1.4.0
48
- */
49
-
50
- /**
51
- * Options for making `User-Agent` string.
52
- * @see {@link getUserAgent}
53
- * @since 1.3.0
54
- */
55
- interface GetUserAgentOptions {
56
- /**
57
- * An optional software name and version, e.g., `"Hollo/1.0.0"`.
58
- */
59
- software?: string | null;
60
- /**
61
- * An optional URL to append to the user agent string.
62
- * Usually the URL of the ActivityPub instance.
63
- */
64
- url?: string | URL | null;
65
- }
66
- /**
67
- * Gets the user agent string for the given application and URL.
68
- * @param options The options for making the user agent string.
69
- * @returns The user agent string.
70
- * @since 1.3.0
71
- */
72
- //#endregion
73
7
  //#region src/nodeinfo/types.d.ts
74
8
  /**
75
9
  * The type of the result of parsing JSON.
@@ -248,25 +182,6 @@ interface GetNodeInfoOptions {
248
182
  * @since 1.2.0
249
183
  */
250
184
  //#endregion
251
- //#region src/runtime/langstr.d.ts
252
- /**
253
- * A language-tagged string which corresponds to the `rdf:langString` type.
254
- */
255
- declare class LanguageString extends String {
256
- /**
257
- * The locale of the string.
258
- * @since 2.0.0
259
- */
260
- readonly locale: Intl.Locale;
261
- /**
262
- * Constructs a new `LanguageString`.
263
- * @param value A string value written in the given language.
264
- * @param locale The language of the string. If a string is given, it will
265
- * be parsed as a `Intl.Locale` object.
266
- */
267
- constructor(value: string, language: Intl.Locale | string);
268
- }
269
- //#endregion
270
185
  //#region src/vocab/vocab.d.ts
271
186
  /** Describes an object of any kind. The Object type serves as the base type for
272
187
  * most of the other kinds of objects defined in the Activity Vocabulary,
@@ -7637,9 +7552,7 @@ interface Federatable<TContextData> {
7637
7552
  * must have one or more variables.
7638
7553
  * @param dispatcher An object dispatcher callback to register.
7639
7554
  */
7640
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
7641
- typeId: URL;
7642
- }, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7555
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7643
7556
  /**
7644
7557
  * Registers an object dispatcher.
7645
7558
  *
@@ -7653,9 +7566,7 @@ interface Federatable<TContextData> {
7653
7566
  * must have one or more variables.
7654
7567
  * @param dispatcher An object dispatcher callback to register.
7655
7568
  */
7656
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
7657
- typeId: URL;
7658
- }, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7569
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7659
7570
  /**
7660
7571
  * Registers an object dispatcher.
7661
7572
  *
@@ -7669,9 +7580,7 @@ interface Federatable<TContextData> {
7669
7580
  * must have one or more variables.
7670
7581
  * @param dispatcher An object dispatcher callback to register.
7671
7582
  */
7672
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
7673
- typeId: URL;
7674
- }, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7583
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7675
7584
  /**
7676
7585
  * Registers an object dispatcher.
7677
7586
  *
@@ -7685,9 +7594,7 @@ interface Federatable<TContextData> {
7685
7594
  * must have one or more variables.
7686
7595
  * @param dispatcher An object dispatcher callback to register.
7687
7596
  */
7688
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
7689
- typeId: URL;
7690
- }, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7597
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7691
7598
  /**
7692
7599
  * Registers an object dispatcher.
7693
7600
  *
@@ -7701,9 +7608,7 @@ interface Federatable<TContextData> {
7701
7608
  * must have one or more variables.
7702
7609
  * @param dispatcher An object dispatcher callback to register.
7703
7610
  */
7704
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
7705
- typeId: URL;
7706
- }, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7611
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7707
7612
  /**
7708
7613
  * Registers an object dispatcher.
7709
7614
  *
@@ -7717,9 +7622,7 @@ interface Federatable<TContextData> {
7717
7622
  * must have one or more variables.
7718
7623
  * @param dispatcher An object dispatcher callback to register.
7719
7624
  */
7720
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
7721
- typeId: URL;
7722
- }, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7625
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
7723
7626
  /**
7724
7627
  * Registers an inbox dispatcher.
7725
7628
  *
@@ -7860,9 +7763,7 @@ interface Federatable<TContextData> {
7860
7763
  * The path must have one or more variables.
7861
7764
  * @param dispatcher A collection dispatcher callback to register.
7862
7765
  */
7863
- setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: (new (...args: any[]) => TObject) & {
7864
- typeId: URL;
7865
- }, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7766
+ setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7866
7767
  /**
7867
7768
  * Registers a collection of objects dispatcher.
7868
7769
  *
@@ -7877,9 +7778,7 @@ interface Federatable<TContextData> {
7877
7778
  * The path must have one or more variables.
7878
7779
  * @param dispatcher A collection dispatcher callback to register.
7879
7780
  */
7880
- setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: (new (...args: any[]) => TObject) & {
7881
- typeId: URL;
7882
- }, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7781
+ setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7883
7782
  /**
7884
7783
  * Registers a collection of objects dispatcher.
7885
7784
  *
@@ -7894,9 +7793,7 @@ interface Federatable<TContextData> {
7894
7793
  * The path must have one or more variables.
7895
7794
  * @param dispatcher A collection dispatcher callback to register.
7896
7795
  */
7897
- setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: (new (...args: any[]) => TObject) & {
7898
- typeId: URL;
7899
- }, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7796
+ setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7900
7797
  /**
7901
7798
  * Registers an ordered collection of objects dispatcher.
7902
7799
  *
@@ -7911,9 +7808,7 @@ interface Federatable<TContextData> {
7911
7808
  * The path must have one or more variables.
7912
7809
  * @param dispatcher A collection dispatcher callback to register.
7913
7810
  */
7914
- setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: (new (...args: any[]) => TObject) & {
7915
- typeId: URL;
7916
- }, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7811
+ setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7917
7812
  /**
7918
7813
  * Registers an ordered collection of objects dispatcher.
7919
7814
  *
@@ -7928,9 +7823,7 @@ interface Federatable<TContextData> {
7928
7823
  * The path must have one or more variables.
7929
7824
  * @param dispatcher A collection dispatcher callback to register.
7930
7825
  */
7931
- setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: (new (...args: any[]) => TObject) & {
7932
- typeId: URL;
7933
- }, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7826
+ setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7934
7827
  /**
7935
7828
  * Registers an ordered collection of objects dispatcher.
7936
7829
  *
@@ -7945,9 +7838,7 @@ interface Federatable<TContextData> {
7945
7838
  * The path must have one or more variables.
7946
7839
  * @param dispatcher A collection dispatcher callback to register.
7947
7840
  */
7948
- setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: (new (...args: any[]) => TObject) & {
7949
- typeId: URL;
7950
- }, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7841
+ setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
7951
7842
  }
7952
7843
  /**
7953
7844
  * An object that registers federation-related business logic and dispatches
@@ -8405,9 +8296,7 @@ interface Context<TContextData> {
8405
8296
  * @throws {TypeError} If values are invalid.
8406
8297
  * @since 0.7.0
8407
8298
  */
8408
- getObjectUri<TObject extends Object$1>(cls: (new (...args: any[]) => TObject) & {
8409
- typeId: URL;
8410
- }, values: Record<string, string>): URL;
8299
+ getObjectUri<TObject extends Object$1>(cls: ConstructorWithTypeId<TObject>, values: Record<string, string>): URL;
8411
8300
  /**
8412
8301
  * Builds the URI of an actor's outbox with the given identifier.
8413
8302
  * @param identifier The actor's identifier.
@@ -8721,9 +8610,7 @@ interface RequestContext<TContextData> extends Context<TContextData> {
8721
8610
  * @throws {TypeError} If values are invalid.
8722
8611
  * @since 0.7.0
8723
8612
  */
8724
- getObject<TObject extends Object$1>(cls: (new (...args: any[]) => TObject) & {
8725
- typeId: URL;
8726
- }, values: Record<string, string>): Promise<TObject | null>;
8613
+ getObject<TObject extends Object$1>(cls: ConstructorWithTypeId<TObject>, values: Record<string, string>): Promise<TObject | null>;
8727
8614
  /**
8728
8615
  * Gets the public key of the sender, if any exists and it is verified.
8729
8616
  * Otherwise, `null` is returned.
@@ -8867,9 +8754,7 @@ type ParseUriResult =
8867
8754
  * The case of an object URI.
8868
8755
  */ | {
8869
8756
  readonly type: "object";
8870
- readonly class: (new (...args: any[]) => Object$1) & {
8871
- typeId: URL;
8872
- };
8757
+ readonly class: ConstructorWithTypeId<Object$1>;
8873
8758
  readonly typeId: URL;
8874
8759
  readonly values: Record<string, string>;
8875
8760
  }
@@ -3,8 +3,7 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import "../type-D_8QzkEn.js";
7
- import "../lookup-VSVPBU3J.js";
8
- import { createInboxContext, createRequestContext, test, testDefinitions } from "../testing-e8Kpb1uV.js";
6
+ import "../lookup-CxJLpHHf.js";
7
+ import { createInboxContext, createRequestContext, test, testDefinitions } from "../testing-BHLtJbQx.js";
9
8
 
10
9
  export { createInboxContext, createRequestContext, test, testDefinitions };
@@ -3,8 +3,7 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { __require, lookupWebFinger } from "./type-D_8QzkEn.js";
7
- import { RouterError, lookupObject, traverseCollection } from "./lookup-VSVPBU3J.js";
6
+ import { RouterError, __require, lookupObject, lookupWebFinger, traverseCollection } from "./lookup-CxJLpHHf.js";
8
7
  import { configure, getConsoleSink, getLogger, reset } from "@logtape/logtape";
9
8
  import { trace } from "@opentelemetry/api";
10
9
 
@@ -2,8 +2,8 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { getUserAgent } from "./docloader-DOmINJ1U.js";
6
5
  import { getLogger } from "@logtape/logtape";
6
+ import { getUserAgent } from "@fedify/vocab-runtime";
7
7
 
8
8
  //#region src/nodeinfo/client.ts
9
9
  const logger = getLogger([
@@ -3,8 +3,8 @@
3
3
  const { URLPattern } = require("urlpattern-polyfill");
4
4
 
5
5
  const require_chunk = require('./chunk-DqRYRqnO.cjs');
6
- const require_docloader = require('./docloader-Buh0Ah9G.cjs');
7
6
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
7
+ const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
8
8
 
9
9
  //#region src/nodeinfo/client.ts
10
10
  const logger = (0, __logtape_logtape.getLogger)([
@@ -19,7 +19,7 @@ async function getNodeInfo(url, options = {}) {
19
19
  const wellKnownUrl = new URL("/.well-known/nodeinfo", url);
20
20
  const wellKnownResponse = await fetch(wellKnownUrl, { headers: {
21
21
  Accept: "application/json",
22
- "User-Agent": typeof options.userAgent === "string" ? options.userAgent : require_docloader.getUserAgent(options.userAgent)
22
+ "User-Agent": typeof options.userAgent === "string" ? options.userAgent : (0, __fedify_vocab_runtime.getUserAgent)(options.userAgent)
23
23
  } });
24
24
  if (!wellKnownResponse.ok) {
25
25
  logger.error("Failed to fetch {url}: {status} {statusText}", {
@@ -42,7 +42,7 @@ async function getNodeInfo(url, options = {}) {
42
42
  }
43
43
  const response = await fetch(nodeInfoUrl, { headers: {
44
44
  Accept: "application/json",
45
- "User-Agent": typeof options.userAgent === "string" ? options.userAgent : require_docloader.getUserAgent(options.userAgent)
45
+ "User-Agent": typeof options.userAgent === "string" ? options.userAgent : (0, __fedify_vocab_runtime.getUserAgent)(options.userAgent)
46
46
  } });
47
47
  if (!response.ok) {
48
48
  logger.error("Failed to fetch NodeInfo document from {url}: {status} {statusText}", {
@@ -3,25 +3,24 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { UrlError } from "../type-D_8QzkEn.js";
6
+ import "../lookup-CxJLpHHf.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
- import "../lookup-VSVPBU3J.js";
11
- import "../actor-dO7jHa6A.js";
12
- import "../key-CIIkeide.js";
13
- import { verifyRequest } from "../http-Danw_xTY.js";
14
- import { getAuthenticatedDocumentLoader } from "../authdocloader-DevmXsTo.js";
15
- import { mockDocumentLoader, test } from "../testing-e8Kpb1uV.js";
16
- import "../std__assert-X-_kMxKM.js";
17
- import { assertRejects } from "../assert_rejects-DiIiJbZn.js";
18
- import "../assert_is_error-BPGph1Jx.js";
19
- import "../assert_not_equals-f3m3epl3.js";
20
- import "../assert_throws-BOO88avQ.js";
21
- import { rsaPrivateKey2 } from "../keys-DZ1bqhJz.js";
22
- import { esm_default } from "../esm-BODOj_Oi.js";
10
+ import "../actor-CRS7Dbo1.js";
11
+ import "../key-CcqQC_vj.js";
12
+ import { verifyRequest } from "../http-DIsJckI7.js";
13
+ import { getAuthenticatedDocumentLoader } from "../docloader-BvlqkI1M.js";
14
+ import { mockDocumentLoader, test } from "../testing-BHLtJbQx.js";
15
+ import "../std__assert-DWivtrGR.js";
16
+ import { assertRejects } from "../assert_rejects-Ce45JcFg.js";
17
+ import "../assert_throws-BNXdRGWP.js";
18
+ import "../assert_not_equals-C80BG-_5.js";
19
+ import { rsaPrivateKey2 } from "../keys-DSikT9wk.js";
20
+ import { esm_default } from "../esm-BZMLn6gu.js";
21
+ import { UrlError } from "@fedify/vocab-runtime";
23
22
 
24
- //#region src/runtime/authdocloader.test.ts
23
+ //#region src/utils/docloader.test.ts
25
24
  test("getAuthenticatedDocumentLoader()", async (t) => {
26
25
  esm_default.spyGlobal();
27
26
  esm_default.get("begin:https://example.com/object", async (cl) => {
@@ -0,0 +1,209 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+ globalThis.addEventListener = () => {};
5
+
6
+ import "../lookup-CxJLpHHf.js";
7
+ import { MockKvStore, kvCache } from "../kv-cache-z0lgwFi_.js";
8
+ import { mockDocumentLoader, test } from "../testing-BHLtJbQx.js";
9
+ import { preloadedContexts } from "@fedify/vocab-runtime";
10
+ import { deepStrictEqual, throws } from "node:assert";
11
+
12
+ //#region src/utils/kv-cache.test.ts
13
+ test("kvCache()", async (t) => {
14
+ const kv = new MockKvStore();
15
+ await t.step("cached", async () => {
16
+ const loader = kvCache({
17
+ kv,
18
+ loader: mockDocumentLoader,
19
+ rules: [
20
+ ["https://example.org/", Temporal.Duration.from({ days: 1 })],
21
+ [new URL("https://example.net/"), Temporal.Duration.from({ days: 1 })],
22
+ [new URLPattern("https://example.com/*"), Temporal.Duration.from({ days: 30 })]
23
+ ],
24
+ prefix: ["_test", "cached"]
25
+ });
26
+ const result = await loader("https://example.com/object");
27
+ deepStrictEqual(result, {
28
+ contextUrl: null,
29
+ documentUrl: "https://example.com/object",
30
+ document: {
31
+ "@context": "https://www.w3.org/ns/activitystreams",
32
+ id: "https://example.com/object",
33
+ name: "Fetched object",
34
+ type: "Object"
35
+ }
36
+ });
37
+ const cache = await kv.get([
38
+ "_test",
39
+ "cached",
40
+ "https://example.com/object"
41
+ ]);
42
+ deepStrictEqual(cache, result);
43
+ await kv.set([
44
+ "_test",
45
+ "cached",
46
+ "https://example.org/"
47
+ ], {
48
+ contextUrl: null,
49
+ documentUrl: "https://example.org/",
50
+ document: { "id": "https://example.org/" }
51
+ });
52
+ const result2 = await loader("https://example.org/");
53
+ deepStrictEqual(result2, {
54
+ contextUrl: null,
55
+ documentUrl: "https://example.org/",
56
+ document: { "id": "https://example.org/" }
57
+ });
58
+ await kv.set([
59
+ "_test",
60
+ "cached",
61
+ "https://example.net/"
62
+ ], {
63
+ contextUrl: null,
64
+ documentUrl: "https://example.net/",
65
+ document: { "id": "https://example.net/" }
66
+ });
67
+ const result3 = await loader("https://example.net/");
68
+ deepStrictEqual(result3, {
69
+ contextUrl: null,
70
+ documentUrl: "https://example.net/",
71
+ document: { "id": "https://example.net/" }
72
+ });
73
+ });
74
+ await t.step("not cached", async () => {
75
+ const loader = kvCache({
76
+ kv,
77
+ loader: mockDocumentLoader,
78
+ rules: [],
79
+ prefix: ["_test", "not cached"]
80
+ });
81
+ const result = await loader("https://example.com/object");
82
+ deepStrictEqual(result, {
83
+ contextUrl: null,
84
+ documentUrl: "https://example.com/object",
85
+ document: {
86
+ "@context": "https://www.w3.org/ns/activitystreams",
87
+ id: "https://example.com/object",
88
+ name: "Fetched object",
89
+ type: "Object"
90
+ }
91
+ });
92
+ const cache = await kv.get([
93
+ "test2",
94
+ "not cached",
95
+ "https://example.com/object"
96
+ ]);
97
+ deepStrictEqual(cache, void 0);
98
+ });
99
+ await t.step("maximum cache duration", () => {
100
+ throws(() => kvCache({
101
+ kv,
102
+ loader: mockDocumentLoader,
103
+ rules: [["https://example.com/", Temporal.Duration.from({
104
+ days: 30,
105
+ seconds: 1
106
+ })]]
107
+ }), TypeError, "The maximum cache duration is 30 days");
108
+ throws(() => kvCache({
109
+ kv,
110
+ loader: mockDocumentLoader,
111
+ rules: [[new URLPattern("https://example.com/*"), Temporal.Duration.from({
112
+ days: 30,
113
+ seconds: 1
114
+ })]]
115
+ }), TypeError, "The maximum cache duration is 30 days");
116
+ });
117
+ await t.step("on kv store exception", async () => {
118
+ class KvStoreThrowsException {
119
+ get(_key) {
120
+ throw new Error("Failed to get key");
121
+ }
122
+ set(_key, _value, _options) {
123
+ throw new Error("Failed to set key");
124
+ }
125
+ delete(_key) {
126
+ throw new Error("Failed to delete key");
127
+ }
128
+ }
129
+ const loader = kvCache({
130
+ kv: new KvStoreThrowsException(),
131
+ loader: mockDocumentLoader,
132
+ rules: [
133
+ ["https://example.org/", Temporal.Duration.from({ days: 1 })],
134
+ [new URL("https://example.net/"), Temporal.Duration.from({ days: 1 })],
135
+ [new URLPattern("https://example.com/*"), Temporal.Duration.from({ days: 30 })]
136
+ ],
137
+ prefix: ["_test", "not cached"]
138
+ });
139
+ const result = await loader("https://example.com/object");
140
+ deepStrictEqual(result, {
141
+ contextUrl: null,
142
+ documentUrl: "https://example.com/object",
143
+ document: {
144
+ "@context": "https://www.w3.org/ns/activitystreams",
145
+ id: "https://example.com/object",
146
+ name: "Fetched object",
147
+ type: "Object"
148
+ }
149
+ });
150
+ });
151
+ await t.step("preloaded contexts bypass cache", async () => {
152
+ const kv$1 = new MockKvStore();
153
+ let loaderCalled = false;
154
+ const mockLoader = (url) => {
155
+ loaderCalled = true;
156
+ return Promise.resolve({
157
+ contextUrl: null,
158
+ documentUrl: url,
159
+ document: { "mock": "document" }
160
+ });
161
+ };
162
+ const loader = kvCache({
163
+ kv: kv$1,
164
+ loader: mockLoader,
165
+ prefix: ["_test", "preloaded"]
166
+ });
167
+ const activityStreamsUrl = "https://www.w3.org/ns/activitystreams";
168
+ loaderCalled = false;
169
+ const result = await loader(activityStreamsUrl);
170
+ deepStrictEqual(result, {
171
+ contextUrl: null,
172
+ documentUrl: activityStreamsUrl,
173
+ document: preloadedContexts[activityStreamsUrl]
174
+ });
175
+ deepStrictEqual(loaderCalled, false, "Loader should not be called for preloaded contexts");
176
+ const cachedValue = await kv$1.get([
177
+ "_test",
178
+ "preloaded",
179
+ activityStreamsUrl
180
+ ]);
181
+ deepStrictEqual(cachedValue, void 0, "Preloaded contexts should not be cached in KV store");
182
+ const securityUrl = "https://w3id.org/security/v1";
183
+ loaderCalled = false;
184
+ const result2 = await loader(securityUrl);
185
+ deepStrictEqual(result2, {
186
+ contextUrl: null,
187
+ documentUrl: securityUrl,
188
+ document: preloadedContexts[securityUrl]
189
+ });
190
+ deepStrictEqual(loaderCalled, false, "Loader should not be called for preloaded contexts");
191
+ const nonPreloadedUrl = "https://example.com/not-preloaded";
192
+ loaderCalled = false;
193
+ const result3 = await loader(nonPreloadedUrl);
194
+ deepStrictEqual(result3, {
195
+ contextUrl: null,
196
+ documentUrl: nonPreloadedUrl,
197
+ document: { "mock": "document" }
198
+ });
199
+ deepStrictEqual(loaderCalled, true, "Loader should be called for non-preloaded URLs");
200
+ const cachedValue2 = await kv$1.get([
201
+ "_test",
202
+ "preloaded",
203
+ nonPreloadedUrl
204
+ ]);
205
+ deepStrictEqual(cachedValue2, result3, "Non-preloaded URLs should be cached");
206
+ });
207
+ });
208
+
209
+ //#endregion
@@ -0,0 +1,12 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ require('../lookup-Doq5XdGY.cjs');
6
+ require('../actor-JG822JBi.cjs');
7
+ require('../http-CPqfuthT.cjs');
8
+ const require_kv_cache = require('../kv-cache-gyMh96Y-.cjs');
9
+ require('../utils-DyRU1gdZ.cjs');
10
+
11
+ exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
12
+ exports.kvCache = require_kv_cache.kvCache;
@@ -0,0 +1,5 @@
1
+ import "../vocab-CeDBzu-f.cjs";
2
+ import "../http-M8k5mKc0.cjs";
3
+ import "../kv-Bxr0Q87_.cjs";
4
+ import { getAuthenticatedDocumentLoader, kvCache } from "../mod-VastcQsk.cjs";
5
+ export { getAuthenticatedDocumentLoader, kvCache };
@@ -0,0 +1,7 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
+ import "../vocab-BCWe1Ih5.js";
4
+ import "../http-BbO0ejuk.js";
5
+ import "../kv-BKNZ-Tb-.js";
6
+ import { getAuthenticatedDocumentLoader, kvCache } from "../mod-BYynOiJG.js";
7
+ export { getAuthenticatedDocumentLoader, kvCache };
@@ -0,0 +1,11 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import "../lookup-BE8ZMmug.js";
6
+ import "../actor-CMgHXjhs.js";
7
+ import "../http-BPsXiq3Y.js";
8
+ import { getAuthenticatedDocumentLoader, kvCache } from "../kv-cache-CBOkGH5t.js";
9
+ import "../utils-D-Va7aXC.js";
10
+
11
+ export { getAuthenticatedDocumentLoader, kvCache };