@fedify/fedify 1.8.1-pr.315.1090 → 1.8.1-pr.315.1275

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 (203) hide show
  1. package/README.md +16 -10
  2. package/dist/{actor-BX-pKSuT.js → actor-B9oI1pGu.js} +2 -5
  3. package/dist/{actor-1rvS-py8.d.ts → actor-CYyhXZHp.d.ts} +3 -3
  4. package/dist/{actor-C02Getjh.js → actor-Cg2FBINf.js} +189 -189
  5. package/dist/{assert-DwEa6glZ.js → assert-MZs1qjMx.js} +2 -2
  6. package/dist/{assert_equals-C5gKCm6A.js → assert_equals-DSbWqCm3.js} +9 -9
  7. package/dist/{assert_instance_of-C9QtN-X9.js → assert_instance_of-DHz7EHNU.js} +2 -2
  8. package/dist/{assert_is_error-DQdKoRgb.js → assert_is_error-BPGph1Jx.js} +2 -2
  9. package/dist/{assert_not_equals-7pyUM3Ib.js → assert_not_equals-f3m3epl3.js} +2 -2
  10. package/dist/{assert_rejects-DceVjUlD.js → assert_rejects-DiIiJbZn.js} +4 -4
  11. package/dist/{assert_throws-DTDC_gwN.js → assert_throws-BOO88avQ.js} +3 -3
  12. package/dist/{authdocloader-BbVFhkcz.js → authdocloader-0urt38S6.js} +4 -4
  13. package/dist/{authdocloader-BZs3nvC8.js → authdocloader-BkwhwBf_.js} +4 -5
  14. package/dist/{builder-DuW8p2S3.js → builder-B-wZuoFJ.js} +75 -6
  15. package/dist/{client-DK4qnXK0.d.ts → client-B_KFjN3D.d.ts} +4 -4
  16. package/dist/{client-BD0mI7gk.js → client-Cr3DvU-q.js} +3 -3
  17. package/dist/{collection-Dfb0TPno.js → collection-CSzG2j1P.js} +1 -1
  18. package/dist/compat/mod.d.ts +12 -12
  19. package/dist/compat/mod.js +1 -1
  20. package/dist/compat/transformers.test.js +25 -32
  21. package/dist/{context-BhO5LP_t.d.ts → context-BRl3Ndz3.d.ts} +286 -73
  22. package/dist/{denokv-QWKsIqML.js → denokv-2x6-IpXO.js} +1 -1
  23. package/dist/{docloader-umQd797n.js → docloader-BLgRerm3.js} +41 -40
  24. package/dist/{docloader-DtGccyuM.d.ts → docloader-DJT1UZH4.d.ts} +5 -2
  25. package/dist/{esm-d-9EVGaP.js → esm-CRotYXVH.js} +15 -15
  26. package/dist/federation/builder.test.js +35 -21
  27. package/dist/federation/collection.test.js +13 -11
  28. package/dist/federation/handler.test.js +341 -40
  29. package/dist/federation/inbox.test.js +8 -12
  30. package/dist/federation/keycache.test.js +9 -12
  31. package/dist/federation/kv.test.js +13 -11
  32. package/dist/federation/middleware.test.js +65 -42
  33. package/dist/federation/mod.d.ts +12 -12
  34. package/dist/federation/mod.js +12 -12
  35. package/dist/federation/mq.test.js +15 -13
  36. package/dist/federation/retry.test.js +7 -5
  37. package/dist/federation/router.test.js +12 -11
  38. package/dist/federation/send.test.js +19 -25
  39. package/dist/{federation-C44ekWNP.js → federation-CMX7WzeL.js} +2 -2
  40. package/dist/{http-D59x3pzl.js → http-BkzChfDi.js} +5 -5
  41. package/dist/{http-Cp-0z2Ja.d.ts → http-CMfQwn0N.d.ts} +6 -6
  42. package/dist/{http-CkS9JLmm.js → http-g01-ecph.js} +6 -5
  43. package/dist/{inbox-BjyNe-HL.js → inbox-CpONbSbQ.js} +2 -4
  44. package/dist/{key-jxin-rRq.js → key-B9Yg9Nqz.js} +4 -5
  45. package/dist/{key-Btkh3AwY.js → key-C3aLobhY.js} +4 -4
  46. package/dist/{key-Cf8lNopw.js → key-DdT7xoLD.js} +4 -4
  47. package/dist/key-RnJPgo1m.js +10 -0
  48. package/dist/{keycache-BC5bL06g.js → keycache-BvyhLLHV.js} +2 -2
  49. package/dist/{keys-Dfntfi5m.js → keys-BRSTnUlp.js} +2 -2
  50. package/dist/{kv-DDdb1hMa.d.ts → kv-C7sopW2E.d.ts} +2 -2
  51. package/dist/{kv-D7Yt6pnB.js → kv-CRZrzyXm.js} +1 -1
  52. package/dist/{ld-DwoZFwEd.js → ld-i6KANj32.js} +3 -5
  53. package/dist/{lookup-CAXRxPZ3.js → lookup-BGA_VdZm.js} +115 -8
  54. package/dist/{lookup-gQIU9tXW.js → lookup-D5NvwwsS.js} +2 -2
  55. package/dist/{lookup-m3U6KA0u.d.ts → lookup-DXPWo3Hz.d.ts} +3 -3
  56. package/dist/{middleware-BOHju0mN.js → middleware-BdFHk7bB.js} +629 -24
  57. package/dist/{middleware-cN6r9o1m.js → middleware-Chh21-S_.js} +563 -32
  58. package/dist/middleware-DEwSbDYQ.js +26 -0
  59. package/dist/middleware-DyY-_2Np.js +17 -0
  60. package/dist/{mod-c1I-Ydch.d.ts → mod-Cozftwmt.d.ts} +4 -4
  61. package/dist/{mod-yPzXIjJX.d.ts → mod-DHoWcUrW.d.ts} +6 -6
  62. package/dist/{mod-nlVEnYuj.d.ts → mod-DyY7EVjn.d.ts} +6 -6
  63. package/dist/{mod-BqCBztub.d.ts → mod-DyvbAsBu.d.ts} +6 -6
  64. package/dist/mod.d.ts +15 -15
  65. package/dist/mod.js +12 -12
  66. package/dist/{mq-DYKDDJmp.d.ts → mq-CRGm1e_F.d.ts} +1 -1
  67. package/dist/nodeinfo/client.test.js +15 -15
  68. package/dist/nodeinfo/handler.test.js +30 -39
  69. package/dist/nodeinfo/mod.d.ts +3 -3
  70. package/dist/nodeinfo/mod.js +2 -2
  71. package/dist/nodeinfo/semver.test.js +13 -11
  72. package/dist/nodeinfo/types.test.js +14 -12
  73. package/dist/{owner-BK4eWKBp.d.ts → owner-CfnEgfAc.d.ts} +4 -4
  74. package/dist/{owner-BrSLT3By.js → owner-DSr0c3Yp.js} +3 -4
  75. package/dist/{proof-u4rhYX_R.js → proof-B83O-qBN.js} +4 -6
  76. package/dist/{proof-BDYegzwN.js → proof-a4fXDkG3.js} +7 -7
  77. package/dist/{retry-BiIhZWgD.js → retry-D4GJ670a.js} +1 -1
  78. package/dist/runtime/authdocloader.test.js +18 -24
  79. package/dist/runtime/docloader.test.js +14 -15
  80. package/dist/runtime/key.test.js +14 -19
  81. package/dist/runtime/langstr.test.js +12 -11
  82. package/dist/runtime/mod.d.ts +5 -5
  83. package/dist/runtime/mod.js +6 -6
  84. package/dist/runtime/multibase/multibase.test.js +12 -11
  85. package/dist/runtime/url.test.js +8 -7
  86. package/dist/{semver-DWClQt_5.js → semver-dArNLkR9.js} +1 -1
  87. package/dist/{send-DRDKgORs.js → send-QRloWueE.js} +3 -3
  88. package/dist/sig/http.test.js +40 -23
  89. package/dist/sig/key.test.js +15 -21
  90. package/dist/sig/ld.test.js +13 -19
  91. package/dist/sig/mod.d.ts +7 -7
  92. package/dist/sig/mod.js +6 -6
  93. package/dist/sig/owner.test.js +16 -23
  94. package/dist/sig/proof.test.js +16 -22
  95. package/dist/{std__assert-B3iAixc-.js → std__assert-X-_kMxKM.js} +6 -6
  96. package/dist/testing/docloader.test.js +12 -11
  97. package/dist/testing/mod.d.ts +8622 -2
  98. package/dist/testing/mod.js +4 -2
  99. package/dist/testing-A4u9tSVX.js +302 -0
  100. package/dist/{transformers-ghwJuzGY.js → transformers-Dna8Fg7k.js} +4 -4
  101. package/dist/{vocab-C4cyrUaT.js → type-DHDlfpLg.js} +5246 -185
  102. package/dist/{types-C7C_l-jz.js → types-BIgY6c-l.js} +2 -2
  103. package/dist/{types-D1lhruqy.js → types-DbFIDnXK.js} +4 -4
  104. package/dist/vocab/actor.test.js +143 -149
  105. package/dist/vocab/lookup.test.js +37 -20
  106. package/dist/vocab/mod.d.ts +5 -5
  107. package/dist/vocab/mod.js +4 -4
  108. package/dist/vocab/type.test.js +5 -9
  109. package/dist/vocab/vocab.test.js +54 -58
  110. package/dist/{vocab-BaWeqg9y.js → vocab-DN6Plgg2.js} +6 -6
  111. package/dist/{vocab-B52eQhpN.d.ts → vocab-KgaI50mH.d.ts} +3 -3
  112. package/dist/webfinger/handler.test.js +30 -39
  113. package/dist/webfinger/lookup.test.js +13 -14
  114. package/dist/webfinger/mod.d.ts +3 -3
  115. package/dist/webfinger/mod.js +2 -2
  116. package/dist/x/cfworkers.d.ts +3 -3
  117. package/dist/x/cfworkers.js +1 -1
  118. package/dist/x/cfworkers.test.js +13 -11
  119. package/dist/x/hono.d.ts +16 -16
  120. package/dist/x/hono.js +3 -3
  121. package/dist/x/sveltekit.d.ts +13 -13
  122. package/dist/x/sveltekit.js +2 -2
  123. package/package.json +3 -3
  124. package/dist/chunk-HsBuZ-b2.js +0 -41
  125. package/dist/context-V7yd31ov.js +0 -108
  126. package/dist/docloader-Bh-sDknx.js +0 -68
  127. package/dist/docloader-D5BOqs-9.js +0 -4514
  128. package/dist/key-DqZKjPjH.js +0 -16
  129. package/dist/langstr-DbWheeIS.js +0 -33
  130. package/dist/lookup-DvfZUKur.js +0 -133
  131. package/dist/middleware-31SyXabg.js +0 -33
  132. package/dist/middleware-CGl-YyTa.js +0 -17
  133. package/dist/multibase-DeCHcK8L.js +0 -316
  134. package/dist/router-D3UybECj.js +0 -118
  135. package/dist/testing-BZ0dJ4qn.js +0 -143
  136. package/dist/type-D2s5lmbZ.js +0 -14
  137. package/dist/url-kTAI6_KP.js +0 -68
  138. /package/dist/{vocab → src/vocab}/accept.yaml +0 -0
  139. /package/dist/{vocab → src/vocab}/activity.yaml +0 -0
  140. /package/dist/{vocab → src/vocab}/add.yaml +0 -0
  141. /package/dist/{vocab → src/vocab}/announce.yaml +0 -0
  142. /package/dist/{vocab → src/vocab}/application.yaml +0 -0
  143. /package/dist/{vocab → src/vocab}/arrive.yaml +0 -0
  144. /package/dist/{vocab → src/vocab}/article.yaml +0 -0
  145. /package/dist/{vocab → src/vocab}/audio.yaml +0 -0
  146. /package/dist/{vocab → src/vocab}/block.yaml +0 -0
  147. /package/dist/{vocab → src/vocab}/chatmessage.yaml +0 -0
  148. /package/dist/{vocab → src/vocab}/collection.yaml +0 -0
  149. /package/dist/{vocab → src/vocab}/collectionpage.yaml +0 -0
  150. /package/dist/{vocab → src/vocab}/create.yaml +0 -0
  151. /package/dist/{vocab → src/vocab}/dataintegrityproof.yaml +0 -0
  152. /package/dist/{vocab → src/vocab}/delete.yaml +0 -0
  153. /package/dist/{vocab → src/vocab}/didservice.yaml +0 -0
  154. /package/dist/{vocab → src/vocab}/dislike.yaml +0 -0
  155. /package/dist/{vocab → src/vocab}/document.yaml +0 -0
  156. /package/dist/{vocab → src/vocab}/emoji.yaml +0 -0
  157. /package/dist/{vocab → src/vocab}/emojireact.yaml +0 -0
  158. /package/dist/{vocab → src/vocab}/endpoints.yaml +0 -0
  159. /package/dist/{vocab → src/vocab}/event.yaml +0 -0
  160. /package/dist/{vocab → src/vocab}/export.yaml +0 -0
  161. /package/dist/{vocab → src/vocab}/flag.yaml +0 -0
  162. /package/dist/{vocab → src/vocab}/follow.yaml +0 -0
  163. /package/dist/{vocab → src/vocab}/group.yaml +0 -0
  164. /package/dist/{vocab → src/vocab}/hashtag.yaml +0 -0
  165. /package/dist/{vocab → src/vocab}/ignore.yaml +0 -0
  166. /package/dist/{vocab → src/vocab}/image.yaml +0 -0
  167. /package/dist/{vocab → src/vocab}/intransitiveactivity.yaml +0 -0
  168. /package/dist/{vocab → src/vocab}/invite.yaml +0 -0
  169. /package/dist/{vocab → src/vocab}/join.yaml +0 -0
  170. /package/dist/{vocab → src/vocab}/key.yaml +0 -0
  171. /package/dist/{vocab → src/vocab}/leave.yaml +0 -0
  172. /package/dist/{vocab → src/vocab}/like.yaml +0 -0
  173. /package/dist/{vocab → src/vocab}/link.yaml +0 -0
  174. /package/dist/{vocab → src/vocab}/listen.yaml +0 -0
  175. /package/dist/{vocab → src/vocab}/mention.yaml +0 -0
  176. /package/dist/{vocab → src/vocab}/move.yaml +0 -0
  177. /package/dist/{vocab → src/vocab}/multikey.yaml +0 -0
  178. /package/dist/{vocab → src/vocab}/note.yaml +0 -0
  179. /package/dist/{vocab → src/vocab}/object.yaml +0 -0
  180. /package/dist/{vocab → src/vocab}/offer.yaml +0 -0
  181. /package/dist/{vocab → src/vocab}/orderedcollection.yaml +0 -0
  182. /package/dist/{vocab → src/vocab}/orderedcollectionpage.yaml +0 -0
  183. /package/dist/{vocab → src/vocab}/organization.yaml +0 -0
  184. /package/dist/{vocab → src/vocab}/page.yaml +0 -0
  185. /package/dist/{vocab → src/vocab}/person.yaml +0 -0
  186. /package/dist/{vocab → src/vocab}/place.yaml +0 -0
  187. /package/dist/{vocab → src/vocab}/profile.yaml +0 -0
  188. /package/dist/{vocab → src/vocab}/propertyvalue.yaml +0 -0
  189. /package/dist/{vocab → src/vocab}/question.yaml +0 -0
  190. /package/dist/{vocab → src/vocab}/read.yaml +0 -0
  191. /package/dist/{vocab → src/vocab}/reject.yaml +0 -0
  192. /package/dist/{vocab → src/vocab}/relationship.yaml +0 -0
  193. /package/dist/{vocab → src/vocab}/remove.yaml +0 -0
  194. /package/dist/{vocab → src/vocab}/service.yaml +0 -0
  195. /package/dist/{vocab → src/vocab}/source.yaml +0 -0
  196. /package/dist/{vocab → src/vocab}/tentativeaccept.yaml +0 -0
  197. /package/dist/{vocab → src/vocab}/tentativereject.yaml +0 -0
  198. /package/dist/{vocab → src/vocab}/tombstone.yaml +0 -0
  199. /package/dist/{vocab → src/vocab}/travel.yaml +0 -0
  200. /package/dist/{vocab → src/vocab}/undo.yaml +0 -0
  201. /package/dist/{vocab → src/vocab}/update.yaml +0 -0
  202. /package/dist/{vocab → src/vocab}/video.yaml +0 -0
  203. /package/dist/{vocab → src/vocab}/view.yaml +0 -0
@@ -3,6 +3,8 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { test, testDefinitions } from "../testing-BZ0dJ4qn.js";
6
+ import "../type-DHDlfpLg.js";
7
+ import "../lookup-BGA_VdZm.js";
8
+ import { createInboxContext, createRequestContext, test, testDefinitions } from "../testing-A4u9tSVX.js";
7
9
 
8
- export { test, testDefinitions };
10
+ export { createInboxContext, createRequestContext, test, testDefinitions };
@@ -0,0 +1,302 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+ globalThis.addEventListener = () => {};
5
+
6
+ import { __require, lookupWebFinger } from "./type-DHDlfpLg.js";
7
+ import { RouterError, lookupObject, traverseCollection } from "./lookup-BGA_VdZm.js";
8
+ import { configure, getConsoleSink, getLogger, reset } from "@logtape/logtape";
9
+ import { trace } from "@opentelemetry/api";
10
+
11
+ //#region src/testing/docloader.ts
12
+ const logger = getLogger([
13
+ "fedify",
14
+ "testing",
15
+ "docloader"
16
+ ]);
17
+ /**
18
+ * A mock of the document loader. This does not make any actual HTTP requests
19
+ * towards the remote server, but looks up the local fixture files instead.
20
+ *
21
+ * For instance, `mockDocumentLoader("http://example.com/foo/bar")` will look up
22
+ * the file `testing/fixtures/http/example.com/foo/bar` (no suffix) and return
23
+ * its content as the response.
24
+ */
25
+ async function mockDocumentLoader(resource, _options) {
26
+ const url = new URL(resource);
27
+ if ("navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers") {
28
+ const testUrl = new URL(url);
29
+ testUrl.hostname += ".test";
30
+ const resp = await fetch(testUrl);
31
+ if (resp.ok) {
32
+ const document$1 = await resp.json();
33
+ logger.debug("Successfully fetched fixture {resource}: {status} {statusText}\n{body}", {
34
+ resource,
35
+ status: resp.status,
36
+ statusText: resp.statusText,
37
+ body: document$1
38
+ });
39
+ return {
40
+ contextUrl: null,
41
+ document: document$1,
42
+ documentUrl: resource
43
+ };
44
+ }
45
+ const error = await resp.text();
46
+ logger.error("Failed to fetch fixture {resource}: {error}", {
47
+ resource,
48
+ error
49
+ });
50
+ throw new Error(error);
51
+ }
52
+ const path = `./fixtures/${url.host}${url.pathname}.json`;
53
+ let document;
54
+ try {
55
+ document = (await import(path, { with: { type: "json" } })).default;
56
+ } catch (error) {
57
+ logger.error("Failed to read fixture file {path}: {error}", {
58
+ path,
59
+ error
60
+ });
61
+ throw error;
62
+ }
63
+ return {
64
+ contextUrl: null,
65
+ document,
66
+ documentUrl: resource
67
+ };
68
+ }
69
+
70
+ //#endregion
71
+ //#region src/testing/context.ts
72
+ function createContext(values) {
73
+ const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getCollectionUri, getOutboxUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject: lookupObject$1, traverseCollection: traverseCollection$1, lookupNodeInfo, lookupWebFinger: lookupWebFinger$1, sendActivity, routeActivity } = values;
74
+ function throwRouteError() {
75
+ throw new RouterError("Not implemented");
76
+ }
77
+ return {
78
+ federation,
79
+ data,
80
+ origin: url.origin,
81
+ canonicalOrigin: canonicalOrigin ?? url.origin,
82
+ host: url.host,
83
+ hostname: url.hostname,
84
+ documentLoader: documentLoader ?? mockDocumentLoader,
85
+ contextLoader: contextLoader ?? mockDocumentLoader,
86
+ tracerProvider: tracerProvider ?? trace.getTracerProvider(),
87
+ clone: clone ?? ((data$1) => createContext({
88
+ ...values,
89
+ data: data$1
90
+ })),
91
+ getNodeInfoUri: getNodeInfoUri ?? throwRouteError,
92
+ getActorUri: getActorUri ?? throwRouteError,
93
+ getObjectUri: getObjectUri ?? throwRouteError,
94
+ getCollectionUri: getCollectionUri ?? throwRouteError,
95
+ getOutboxUri: getOutboxUri ?? throwRouteError,
96
+ getInboxUri: getInboxUri ?? throwRouteError,
97
+ getFollowingUri: getFollowingUri ?? throwRouteError,
98
+ getFollowersUri: getFollowersUri ?? throwRouteError,
99
+ getLikedUri: getLikedUri ?? throwRouteError,
100
+ getFeaturedUri: getFeaturedUri ?? throwRouteError,
101
+ getFeaturedTagsUri: getFeaturedTagsUri ?? throwRouteError,
102
+ parseUri: parseUri ?? ((_uri) => {
103
+ throw new Error("Not implemented");
104
+ }),
105
+ getDocumentLoader: getDocumentLoader ?? ((_params) => {
106
+ throw new Error("Not implemented");
107
+ }),
108
+ getActorKeyPairs: getActorKeyPairs ?? ((_handle) => Promise.resolve([])),
109
+ lookupObject: lookupObject$1 ?? ((uri, options = {}) => {
110
+ return lookupObject(uri, {
111
+ documentLoader: options.documentLoader ?? documentLoader ?? mockDocumentLoader,
112
+ contextLoader: options.contextLoader ?? contextLoader ?? mockDocumentLoader
113
+ });
114
+ }),
115
+ traverseCollection: traverseCollection$1 ?? ((collection, options = {}) => {
116
+ return traverseCollection(collection, {
117
+ documentLoader: options.documentLoader ?? documentLoader ?? mockDocumentLoader,
118
+ contextLoader: options.contextLoader ?? contextLoader ?? mockDocumentLoader
119
+ });
120
+ }),
121
+ lookupNodeInfo: lookupNodeInfo ?? ((_params) => {
122
+ throw new Error("Not implemented");
123
+ }),
124
+ lookupWebFinger: lookupWebFinger$1 ?? ((resource, options = {}) => {
125
+ return lookupWebFinger(resource, options);
126
+ }),
127
+ sendActivity: sendActivity ?? ((_params) => {
128
+ throw new Error("Not implemented");
129
+ }),
130
+ routeActivity: routeActivity ?? ((_params) => {
131
+ throw new Error("Not implemented");
132
+ })
133
+ };
134
+ }
135
+ function createRequestContext(args) {
136
+ return {
137
+ ...createContext(args),
138
+ clone: args.clone ?? ((data) => createRequestContext({
139
+ ...args,
140
+ data
141
+ })),
142
+ request: args.request ?? new Request(args.url),
143
+ url: args.url,
144
+ getActor: args.getActor ?? (() => Promise.resolve(null)),
145
+ getObject: args.getObject ?? (() => Promise.resolve(null)),
146
+ getSignedKey: args.getSignedKey ?? (() => Promise.resolve(null)),
147
+ getSignedKeyOwner: args.getSignedKeyOwner ?? (() => Promise.resolve(null)),
148
+ sendActivity: args.sendActivity ?? ((_params) => {
149
+ throw new Error("Not implemented");
150
+ })
151
+ };
152
+ }
153
+ function createInboxContext(args) {
154
+ return {
155
+ ...createContext(args),
156
+ clone: args.clone ?? ((data) => createInboxContext({
157
+ ...args,
158
+ data
159
+ })),
160
+ recipient: args.recipient ?? null,
161
+ forwardActivity: args.forwardActivity ?? ((_params) => {
162
+ throw new Error("Not implemented");
163
+ })
164
+ };
165
+ }
166
+
167
+ //#endregion
168
+ //#region src/testing/mod.ts
169
+ const testDefinitions = [];
170
+ function test(name, options, fn) {
171
+ const def = typeof name === "string" ? typeof options === "function" ? {
172
+ name,
173
+ fn: options
174
+ } : {
175
+ name,
176
+ ...options,
177
+ fn
178
+ } : name;
179
+ testDefinitions.push(def);
180
+ if ("Deno" in globalThis) {
181
+ const func = def.fn;
182
+ Deno.test({
183
+ ...def,
184
+ async fn(t) {
185
+ const records = [];
186
+ await configure({
187
+ sinks: {
188
+ buffer(record) {
189
+ if (record.category.length > 1 && record.category[0] === "logtape" && record.category[1] === "meta") return;
190
+ records.push(record);
191
+ },
192
+ console: getConsoleSink()
193
+ },
194
+ filters: {},
195
+ loggers: [{
196
+ category: [],
197
+ sinks: [Deno.env.get("LOG") === "always" ? "console" : "buffer"]
198
+ }]
199
+ });
200
+ try {
201
+ await func(t);
202
+ } catch (e) {
203
+ const consoleSink = getConsoleSink();
204
+ for (const record of records) consoleSink(record);
205
+ throw e;
206
+ } finally {
207
+ await reset();
208
+ }
209
+ }
210
+ });
211
+ } else if ("Bun" in globalThis) {
212
+ let failed = void 0;
213
+ async function step(defOrNameOrFn, fn$2) {
214
+ let def$1;
215
+ if (typeof defOrNameOrFn === "string") def$1 = {
216
+ name: defOrNameOrFn,
217
+ fn: fn$2
218
+ };
219
+ else if (typeof defOrNameOrFn === "function") def$1 = {
220
+ name: defOrNameOrFn.name,
221
+ fn: defOrNameOrFn
222
+ };
223
+ else def$1 = defOrNameOrFn;
224
+ if (def$1.ignore) return true;
225
+ try {
226
+ await def$1.fn({
227
+ name: def$1.name,
228
+ origin: "",
229
+ step
230
+ });
231
+ } catch (e) {
232
+ failed ??= e;
233
+ return false;
234
+ }
235
+ return true;
236
+ }
237
+ const ctx = {
238
+ name: def.name,
239
+ origin: "",
240
+ step
241
+ };
242
+ async function fn$1() {
243
+ await def.fn(ctx);
244
+ if (failed) throw failed;
245
+ }
246
+ const bunTest = Bun.jest(caller()).test;
247
+ if (def.ignore) bunTest.skip(def.name, fn$1);
248
+ else if (def.only) bunTest.only(def.name, fn$1);
249
+ else bunTest(def.name, fn$1);
250
+ } else try {
251
+ const { test: nodeTest } = __require("node:test");
252
+ nodeTest(def.name, {
253
+ only: def.only,
254
+ skip: def.ignore
255
+ }, async (t) => {
256
+ await def.fn(intoDenoTestContext(def.name, t));
257
+ });
258
+ } catch {}
259
+ }
260
+ function intoDenoTestContext(name, ctx) {
261
+ async function step(defOrNameOrFn, fn) {
262
+ let def;
263
+ if (typeof defOrNameOrFn === "string") def = {
264
+ name: defOrNameOrFn,
265
+ fn
266
+ };
267
+ else if (typeof defOrNameOrFn === "function") def = {
268
+ name: defOrNameOrFn.name,
269
+ fn: defOrNameOrFn
270
+ };
271
+ else def = defOrNameOrFn;
272
+ let failed = false;
273
+ await ctx.test(def.name, async (ctx2) => {
274
+ try {
275
+ await def.fn(intoDenoTestContext(def.name, ctx2));
276
+ } catch (e) {
277
+ failed = true;
278
+ throw e;
279
+ }
280
+ });
281
+ return failed;
282
+ }
283
+ const denoCtx = {
284
+ name,
285
+ origin: ctx.filePath ?? "",
286
+ step
287
+ };
288
+ return denoCtx;
289
+ }
290
+ /** Retrieve caller test file. */
291
+ function caller() {
292
+ const Trace = Error;
293
+ const _ = Trace.prepareStackTrace;
294
+ Trace.prepareStackTrace = (_$1, stack$1) => stack$1;
295
+ const { stack } = /* @__PURE__ */ new Error();
296
+ Trace.prepareStackTrace = _;
297
+ const caller$1 = stack[2];
298
+ return caller$1.getFileName().replaceAll("\\", "/");
299
+ }
300
+
301
+ //#endregion
302
+ export { createInboxContext, createRequestContext, mockDocumentLoader, test, testDefinitions };
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { getLogger } from "@logtape/logtape";
6
6
 
7
- //#region compat/transformers.ts
7
+ //#region src/compat/transformers.ts
8
8
  const logger = getLogger([
9
9
  "fedify",
10
10
  "compat",
@@ -22,7 +22,7 @@ const logger = getLogger([
22
22
  * https://example.com/#Follow/12345678-1234-5678-1234-567812345678
23
23
  * ```
24
24
  *
25
- * @typeParam TContextData The type of the context data.
25
+ * @template TContextData The type of the context data.
26
26
  * @param activity The activity to assign an ID to.
27
27
  * @param context The context of the activity.
28
28
  * @return The activity with an ID assigned.
@@ -73,7 +73,7 @@ function autoIdAssigner(activity, context) {
73
73
  *
74
74
  * As some ActivityPub implementations like Threads fail to deal with inlined
75
75
  * actor objects, this transformer can be used to work around this issue.
76
- * @typeParam TContextData The type of the context data.
76
+ * @template TContextData The type of the context data.
77
77
  * @param activity The activity to dehydrate the actor property of.
78
78
  * @param context The context of the activity.
79
79
  * @returns The dehydrated activity.
@@ -86,7 +86,7 @@ function actorDehydrator(activity, _context) {
86
86
  /**
87
87
  * Gets the default activity transformers that are applied to all outgoing
88
88
  * activities.
89
- * @typeParam TContextData The type of the context data.
89
+ * @template TContextData The type of the context data.
90
90
  * @returns The default activity transformers.
91
91
  * @since 1.4.0
92
92
  */