@fedify/testing 1.8.14-pr.470.1832 → 1.8.14-pr.470.1850

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 (3) hide show
  1. package/dist/mod.d.ts +55 -177
  2. package/dist/mod.js +58 -36
  3. package/package.json +2 -5
package/dist/mod.d.ts CHANGED
@@ -1,31 +1,38 @@
1
- import { TracerProvider } from "@opentelemetry/api";
2
- import { Activity, Actor, Collection, Hashtag, LookupObjectOptions, Object as Object$1, Recipient, TraverseCollectionOptions } from "@fedify/fedify/vocab";
3
- import { ResourceDescriptor } from "@fedify/fedify/webfinger";
4
- import * as _fedify_fedify_federation4 from "@fedify/fedify/federation";
5
- import { JsonValue, NodeInfo } from "@fedify/fedify/nodeinfo";
6
- import { DocumentLoader } from "@fedify/fedify/runtime";
1
+ import { ActorCallbackSetters, ActorDispatcher, CollectionCallbackSetters, CollectionDispatcher, Context, Federation, FederationFetchOptions, FederationStartQueueOptions, InboxContext, InboxListenerSetters, Message, NodeInfoDispatcher, ObjectCallbackSetters, ObjectDispatcher, RequestContext } from "@fedify/fedify/federation";
2
+ import { Activity, Actor, Hashtag, Object as Object$1, Recipient } from "@fedify/fedify/vocab";
3
+ import "@fedify/fedify/runtime";
7
4
 
5
+ //#region src/context.d.ts
6
+ declare function createContext<TContextData>(values: Partial<Context<TContextData>> & {
7
+ url?: URL;
8
+ data: TContextData;
9
+ federation: Federation<TContextData>;
10
+ }): Context<TContextData>;
11
+ /**
12
+ * Creates a RequestContext for testing purposes.
13
+ * @param args Partial RequestContext properties
14
+ * @returns A RequestContext instance
15
+ * @since 1.8.0
16
+ */
17
+ declare function createRequestContext<TContextData>(args: Partial<RequestContext<TContextData>> & {
18
+ url: URL;
19
+ data: TContextData;
20
+ federation: Federation<TContextData>;
21
+ }): RequestContext<TContextData>;
22
+ /**
23
+ * Creates an InboxContext for testing purposes.
24
+ * @param args Partial InboxContext properties
25
+ * @returns An InboxContext instance
26
+ * @since 1.8.0
27
+ */
28
+ declare function createInboxContext<TContextData>(args: Partial<InboxContext<TContextData>> & {
29
+ url?: URL;
30
+ data: TContextData;
31
+ recipient?: string | null;
32
+ federation: Federation<TContextData>;
33
+ }): InboxContext<TContextData>;
34
+ //#endregion
8
35
  //#region src/mock.d.ts
9
- type ActorCallbackSetters<TContextData> = _fedify_fedify_federation4.ActorCallbackSetters<TContextData>;
10
- type ActorDispatcher<TContextData> = _fedify_fedify_federation4.ActorDispatcher<TContextData>;
11
- type ActorKeyPair = _fedify_fedify_federation4.ActorKeyPair;
12
- type Context$1<TContextData> = _fedify_fedify_federation4.Context<TContextData>;
13
- type CollectionCallbackSetters<TContext extends Context$1<TContextData>, TContextData, TFilter> = _fedify_fedify_federation4.CollectionCallbackSetters<TContext, TContextData, TFilter>;
14
- type CollectionDispatcher<TItem, TContext extends Context$1<TContextData>, TContextData, TFilter> = _fedify_fedify_federation4.CollectionDispatcher<TItem, TContext, TContextData, TFilter>;
15
- type Federation$1<TContextData> = _fedify_fedify_federation4.Federation<TContextData>;
16
- type FederationFetchOptions<TContextData> = _fedify_fedify_federation4.FederationFetchOptions<TContextData>;
17
- type FederationStartQueueOptions = _fedify_fedify_federation4.FederationStartQueueOptions;
18
- type InboxListenerSetters<TContextData> = _fedify_fedify_federation4.InboxListenerSetters<TContextData>;
19
- type Message = _fedify_fedify_federation4.Message;
20
- type NodeInfoDispatcher<TContextData> = _fedify_fedify_federation4.NodeInfoDispatcher<TContextData>;
21
- type ObjectCallbackSetters<TContextData, TObject extends Object$1, TParam extends string> = _fedify_fedify_federation4.ObjectCallbackSetters<TContextData, TObject, TParam>;
22
- type ObjectDispatcher<TContextData, TObject extends Object$1, TParam extends string> = _fedify_fedify_federation4.ObjectDispatcher<TContextData, TObject, TParam>;
23
- type ParseUriResult = _fedify_fedify_federation4.ParseUriResult;
24
- type RequestContext$1<TContextData> = _fedify_fedify_federation4.RequestContext<TContextData>;
25
- type RouteActivityOptions = _fedify_fedify_federation4.RouteActivityOptions;
26
- type SendActivityOptions = _fedify_fedify_federation4.SendActivityOptions;
27
- type SendActivityOptionsForCollection = _fedify_fedify_federation4.SendActivityOptionsForCollection;
28
- type SenderKeyPair = _fedify_fedify_federation4.SenderKeyPair;
29
36
  /**
30
37
  * Represents a sent activity with metadata about how it was sent.
31
38
  * @since 1.8.0
@@ -73,7 +80,7 @@ interface SentActivity {
73
80
  * @template TContextData The context data to pass to the {@link Context}.
74
81
  * @since 1.8.0
75
82
  */
76
- declare class MockFederation<TContextData> implements Federation$1<TContextData> {
83
+ declare class MockFederation<TContextData> implements Federation<TContextData> {
77
84
  private options;
78
85
  sentActivities: SentActivity[];
79
86
  queueStarted: boolean;
@@ -106,25 +113,24 @@ declare class MockFederation<TContextData> implements Federation$1<TContextData>
106
113
  constructor(options?: {
107
114
  contextData?: TContextData;
108
115
  origin?: string;
109
- tracerProvider?: TracerProvider;
116
+ tracerProvider?: any;
110
117
  });
111
118
  setNodeInfoDispatcher(path: string, dispatcher: NodeInfoDispatcher<TContextData>): void;
112
119
  setActorDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: ActorDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
113
120
  setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
114
121
  typeId: URL;
115
122
  }, path: string, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
116
- setInboxDispatcher(_path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext$1<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext$1<TContextData>, TContextData, void>;
117
- setOutboxDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext$1<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext$1<TContextData>, TContextData, void>;
118
- setFollowingDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Actor | URL, RequestContext$1<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext$1<TContextData>, TContextData, void>;
119
- setFollowersDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Recipient, Context$1<TContextData>, TContextData, URL>): CollectionCallbackSetters<Context$1<TContextData>, TContextData, URL>;
120
- setLikedDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Object$1 | URL, RequestContext$1<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext$1<TContextData>, TContextData, void>;
121
- setFeaturedDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Object$1, RequestContext$1<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext$1<TContextData>, TContextData, void>;
122
- setFeaturedTagsDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Hashtag, RequestContext$1<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext$1<TContextData>, TContextData, void>;
123
+ setInboxDispatcher(_path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
124
+ setOutboxDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
125
+ setFollowingDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Actor | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
126
+ setFollowersDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Recipient, Context<TContextData>, TContextData, URL>): CollectionCallbackSetters<Context<TContextData>, TContextData, URL>;
127
+ setLikedDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Object$1 | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
128
+ setFeaturedDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Object$1, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
129
+ setFeaturedTagsDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Hashtag, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
123
130
  setInboxListeners(inboxPath: `${string}{identifier}${string}` | `${string}{handle}${string}`, sharedInboxPath?: string): InboxListenerSetters<TContextData>;
124
131
  startQueue(contextData: TContextData, options?: FederationStartQueueOptions): Promise<void>;
125
132
  processQueuedTask(contextData: TContextData, _message: Message): Promise<void>;
126
- createContext(baseUrl: URL, contextData: TContextData): Context$1<TContextData>;
127
- createContext(request: Request, contextData: TContextData): RequestContext$1<TContextData>;
133
+ createContext(baseUrlOrRequest: any, contextData: TContextData): any;
128
134
  fetch(request: Request, options: FederationFetchOptions<TContextData>): Promise<Response>;
129
135
  /**
130
136
  * Simulates receiving an activity. This method is specific to the mock
@@ -151,18 +157,20 @@ declare class MockFederation<TContextData> implements Federation$1<TContextData>
151
157
  * This class provides a way to test Fedify applications without needing
152
158
  * a real federation context.
153
159
  *
160
+ * Note: This class is not exported from the public API. Use
161
+ * {@link MockFederation.createContext} instead.
162
+ *
154
163
  * @example
155
164
  * ```typescript
156
165
  * import { Person, Create } from "@fedify/fedify/vocab";
157
- * import { MockContext, MockFederation } from "@fedify/testing";
166
+ * import { MockFederation } from "@fedify/testing";
158
167
  *
159
- * // Create a mock context
168
+ * // Create a mock federation and context
160
169
  * const mockFederation = new MockFederation<{ userId: string }>();
161
- * const context = new MockContext({
162
- * url: new URL("https://example.com"),
163
- * data: { userId: "test-user" },
164
- * federation: mockFederation
165
- * });
170
+ * const context = mockFederation.createContext(
171
+ * new URL("https://example.com"),
172
+ * { userId: "test-user" }
173
+ * );
166
174
  *
167
175
  * // Send an activity
168
176
  * const recipient = new Person({ id: new URL("https://example.com/users/bob") });
@@ -176,143 +184,13 @@ declare class MockFederation<TContextData> implements Federation$1<TContextData>
176
184
  * activity
177
185
  * );
178
186
  *
179
- * // Check sent activities
180
- * const sent = context.getSentActivities();
187
+ * // Check sent activities from the federation
188
+ * const sent = mockFederation.sentActivities;
181
189
  * console.log(sent[0].activity);
182
190
  * ```
183
191
  *
184
192
  * @template TContextData The context data to pass to the {@link Context}.
185
193
  * @since 1.8.0
186
194
  */
187
- declare class MockContext<TContextData> implements Context$1<TContextData> {
188
- readonly origin: string;
189
- readonly canonicalOrigin: string;
190
- readonly host: string;
191
- readonly hostname: string;
192
- readonly data: TContextData;
193
- readonly federation: Federation$1<TContextData>;
194
- readonly documentLoader: DocumentLoader;
195
- readonly contextLoader: DocumentLoader;
196
- readonly tracerProvider: TracerProvider;
197
- private sentActivities;
198
- constructor(options: {
199
- url?: URL;
200
- data: TContextData;
201
- federation: Federation$1<TContextData>;
202
- documentLoader?: DocumentLoader;
203
- contextLoader?: DocumentLoader;
204
- tracerProvider?: TracerProvider;
205
- });
206
- clone(data: TContextData): Context$1<TContextData>;
207
- getNodeInfoUri(): URL;
208
- getActorUri(identifier: string): URL;
209
- getObjectUri<TObject extends Object$1>(cls: (new (...args: any[]) => TObject) & {
210
- typeId: URL;
211
- }, values: Record<string, string>): URL;
212
- getOutboxUri(identifier: string): URL;
213
- getInboxUri(identifier: string): URL;
214
- getInboxUri(): URL;
215
- getFollowingUri(identifier: string): URL;
216
- getFollowersUri(identifier: string): URL;
217
- getLikedUri(identifier: string): URL;
218
- getFeaturedUri(identifier: string): URL;
219
- getFeaturedTagsUri(identifier: string): URL;
220
- getCollectionUri<TParam extends Record<string, string>>(_name: string | symbol, values: TParam): URL;
221
- parseUri(uri: URL): ParseUriResult | null;
222
- getActorKeyPairs(_identifier: string): Promise<ActorKeyPair[]>;
223
- getDocumentLoader(params: {
224
- handle: string;
225
- } | {
226
- identifier: string;
227
- }): Promise<DocumentLoader>;
228
- getDocumentLoader(params: {
229
- keyId: URL;
230
- privateKey: CryptoKey;
231
- }): DocumentLoader;
232
- lookupObject(_uri: URL | string, _options?: LookupObjectOptions): Promise<Object$1 | null>;
233
- traverseCollection<TItem, TContext extends Context$1<TContextData>>(_collection: Collection | URL | null, _options?: TraverseCollectionOptions): AsyncIterable<TItem>;
234
- lookupNodeInfo(url: URL | string, options?: {
235
- parse?: "strict" | "best-effort";
236
- } & any): Promise<NodeInfo | undefined>;
237
- lookupNodeInfo(url: URL | string, options?: {
238
- parse: "none";
239
- } & any): Promise<JsonValue | undefined>;
240
- lookupWebFinger(_resource: URL | `acct:${string}@${string}` | string, _options?: any): Promise<ResourceDescriptor | null>;
241
- sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
242
- identifier: string;
243
- } | {
244
- username: string;
245
- } | {
246
- handle: string;
247
- }, recipients: Recipient | Recipient[], activity: Activity, options?: SendActivityOptions): Promise<void>;
248
- sendActivity(sender: {
249
- identifier: string;
250
- } | {
251
- username: string;
252
- } | {
253
- handle: string;
254
- }, recipients: "followers", activity: Activity, options?: SendActivityOptionsForCollection): Promise<void>;
255
- sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
256
- identifier: string;
257
- } | {
258
- username: string;
259
- } | {
260
- handle: string;
261
- }, recipients: Recipient | Recipient[], activity: Activity, options?: SendActivityOptions): Promise<void>;
262
- sendActivity(sender: {
263
- identifier: string;
264
- } | {
265
- username: string;
266
- } | {
267
- handle: string;
268
- }, recipients: "followers", activity: Activity, options?: SendActivityOptionsForCollection): Promise<void>;
269
- routeActivity(_recipient: string | null, _activity: Activity, _options?: RouteActivityOptions): Promise<boolean>;
270
- /**
271
- * Gets all activities that have been sent through this mock context.
272
- * This method is specific to the mock implementation and is used for
273
- * testing purposes.
274
- *
275
- * @returns An array of sent activity records.
276
- */
277
- getSentActivities(): Array<{
278
- sender: SenderKeyPair | SenderKeyPair[] | {
279
- identifier: string;
280
- } | {
281
- username: string;
282
- } | {
283
- handle: string;
284
- };
285
- recipients: Recipient | Recipient[] | "followers";
286
- activity: Activity;
287
- }>;
288
- /**
289
- * Clears all sent activities from the mock context.
290
- * This method is specific to the mock implementation and is used for
291
- * testing purposes.
292
- */
293
- reset(): void;
294
- }
295
- //#endregion
296
- //#region src/context.d.ts
297
- type Context<TContextData> = _fedify_fedify_federation4.Context<TContextData>;
298
- type Federation<TContextData> = _fedify_fedify_federation4.Federation<TContextData>;
299
- type InboxContext<TContextData> = _fedify_fedify_federation4.InboxContext<TContextData>;
300
- type RequestContext<TContextData> = _fedify_fedify_federation4.RequestContext<TContextData>;
301
- declare function createContext<TContextData>(values: Partial<Context<TContextData>> & {
302
- url?: URL;
303
- data: TContextData;
304
- federation: Federation<TContextData>;
305
- }): Context<TContextData>;
306
- declare function createRequestContext<TContextData>(args: Partial<RequestContext<TContextData>> & {
307
- url: URL;
308
- data: TContextData;
309
- federation: Federation<TContextData>;
310
- }): RequestContext<TContextData>;
311
- declare function createInboxContext<TContextData>(args: Partial<InboxContext<TContextData>> & {
312
- url?: URL;
313
- data: TContextData;
314
- recipient?: string | null;
315
- federation: Federation<TContextData>;
316
- }): InboxContext<TContextData>;
317
195
  //#endregion
318
- export { MockContext, MockFederation, SentActivity, createContext, createInboxContext, createRequestContext };
196
+ export { MockFederation, SentActivity, createContext, createInboxContext, createRequestContext };
package/dist/mod.js CHANGED
@@ -1,4 +1,4 @@
1
- import { trace } from "@opentelemetry/api";
1
+ import { RouterError } from "@fedify/fedify/federation";
2
2
  import { lookupObject, traverseCollection } from "@fedify/fedify/vocab";
3
3
  import { lookupWebFinger } from "@fedify/fedify/webfinger";
4
4
 
@@ -11,12 +11,10 @@ const mockDocumentLoader = async (url) => ({
11
11
 
12
12
  //#endregion
13
13
  //#region src/context.ts
14
- var RouterError = class extends Error {
15
- constructor(message) {
16
- super(message);
17
- this.name = "RouterError";
18
- }
19
- };
14
+ const noopTracerProvider$1 = { getTracer: () => ({
15
+ startActiveSpan: () => void 0,
16
+ startSpan: () => void 0
17
+ }) };
20
18
  function createContext(values) {
21
19
  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;
22
20
  function throwRouteError() {
@@ -31,7 +29,7 @@ function createContext(values) {
31
29
  hostname: url.hostname,
32
30
  documentLoader: documentLoader ?? mockDocumentLoader,
33
31
  contextLoader: contextLoader ?? mockDocumentLoader,
34
- tracerProvider: tracerProvider ?? trace.getTracerProvider(),
32
+ tracerProvider: tracerProvider ?? noopTracerProvider$1,
35
33
  clone: clone ?? ((data$1) => createContext({
36
34
  ...values,
37
35
  data: data$1
@@ -80,6 +78,12 @@ function createContext(values) {
80
78
  })
81
79
  };
82
80
  }
81
+ /**
82
+ * Creates a RequestContext for testing purposes.
83
+ * @param args Partial RequestContext properties
84
+ * @returns A RequestContext instance
85
+ * @since 1.8.0
86
+ */
83
87
  function createRequestContext(args) {
84
88
  return {
85
89
  ...createContext(args),
@@ -98,6 +102,12 @@ function createRequestContext(args) {
98
102
  })
99
103
  };
100
104
  }
105
+ /**
106
+ * Creates an InboxContext for testing purposes.
107
+ * @param args Partial InboxContext properties
108
+ * @returns An InboxContext instance
109
+ * @since 1.8.0
110
+ */
101
111
  function createInboxContext(args) {
102
112
  return {
103
113
  ...createContext(args),
@@ -114,6 +124,10 @@ function createInboxContext(args) {
114
124
 
115
125
  //#endregion
116
126
  //#region src/mock.ts
127
+ const noopTracerProvider = { getTracer: () => ({
128
+ startActiveSpan: () => void 0,
129
+ startSpan: () => void 0
130
+ }) };
117
131
  /**
118
132
  * Helper function to expand URI templates with values.
119
133
  * Supports simple placeholders like {identifier}, {handle}, etc.
@@ -127,6 +141,25 @@ function expandUriTemplate(template, values) {
127
141
  });
128
142
  }
129
143
  /**
144
+ * Creates an InboxContext for testing purposes.
145
+ * @param args Partial InboxContext properties
146
+ * @returns An InboxContext instance
147
+ * @since 1.8.0
148
+ */
149
+ function createInboxContext$1(args) {
150
+ return {
151
+ ...createContext(args),
152
+ clone: args.clone ?? ((data) => createInboxContext$1({
153
+ ...args,
154
+ data
155
+ })),
156
+ recipient: args.recipient ?? null,
157
+ forwardActivity: args.forwardActivity ?? ((_params) => {
158
+ throw new Error("Not implemented");
159
+ })
160
+ };
161
+ }
162
+ /**
130
163
  * A mock implementation of the {@link Federation} interface for unit testing.
131
164
  * This class provides a way to test Fedify applications without needing
132
165
  * a real federation setup.
@@ -314,22 +347,9 @@ var MockFederation = class {
314
347
  }
315
348
  createContext(baseUrlOrRequest, contextData) {
316
349
  const mockFederation = this;
317
- if (baseUrlOrRequest instanceof Request) return createRequestContext({
318
- url: new URL(baseUrlOrRequest.url),
319
- request: baseUrlOrRequest,
320
- data: contextData,
321
- federation: mockFederation,
322
- sendActivity: async (sender, recipients, activity, options) => {
323
- const tempContext = new MockContext({
324
- url: new URL(baseUrlOrRequest.url),
325
- data: contextData,
326
- federation: mockFederation
327
- });
328
- await tempContext.sendActivity(sender, recipients, activity, options);
329
- }
330
- });
331
- else return new MockContext({
332
- url: baseUrlOrRequest,
350
+ const url = baseUrlOrRequest instanceof Request ? new URL(baseUrlOrRequest.url) : baseUrlOrRequest;
351
+ return new MockContext({
352
+ url,
333
353
  data: contextData,
334
354
  federation: mockFederation
335
355
  });
@@ -352,7 +372,7 @@ var MockFederation = class {
352
372
  const listeners = this.inboxListeners.get(typeName) || [];
353
373
  if (listeners.length > 0 && this.contextData === void 0) throw new Error("MockFederation.receiveActivity(): contextData is not initialized. Please provide contextData through the constructor or call startQueue() before receiving activities.");
354
374
  for (const listener of listeners) {
355
- const context = createInboxContext({
375
+ const context = createInboxContext$1({
356
376
  data: this.contextData,
357
377
  federation: this
358
378
  });
@@ -391,18 +411,20 @@ var MockFederation = class {
391
411
  * This class provides a way to test Fedify applications without needing
392
412
  * a real federation context.
393
413
  *
414
+ * Note: This class is not exported from the public API. Use
415
+ * {@link MockFederation.createContext} instead.
416
+ *
394
417
  * @example
395
418
  * ```typescript
396
419
  * import { Person, Create } from "@fedify/fedify/vocab";
397
- * import { MockContext, MockFederation } from "@fedify/testing";
420
+ * import { MockFederation } from "@fedify/testing";
398
421
  *
399
- * // Create a mock context
422
+ * // Create a mock federation and context
400
423
  * const mockFederation = new MockFederation<{ userId: string }>();
401
- * const context = new MockContext({
402
- * url: new URL("https://example.com"),
403
- * data: { userId: "test-user" },
404
- * federation: mockFederation
405
- * });
424
+ * const context = mockFederation.createContext(
425
+ * new URL("https://example.com"),
426
+ * { userId: "test-user" }
427
+ * );
406
428
  *
407
429
  * // Send an activity
408
430
  * const recipient = new Person({ id: new URL("https://example.com/users/bob") });
@@ -416,8 +438,8 @@ var MockFederation = class {
416
438
  * activity
417
439
  * );
418
440
  *
419
- * // Check sent activities
420
- * const sent = context.getSentActivities();
441
+ * // Check sent activities from the federation
442
+ * const sent = mockFederation.sentActivities;
421
443
  * console.log(sent[0].activity);
422
444
  * ```
423
445
  *
@@ -449,7 +471,7 @@ var MockContext = class MockContext {
449
471
  documentUrl: url$1
450
472
  }));
451
473
  this.contextLoader = options.contextLoader ?? this.documentLoader;
452
- this.tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
474
+ this.tracerProvider = options.tracerProvider ?? noopTracerProvider;
453
475
  }
454
476
  clone(data) {
455
477
  return new MockContext({
@@ -635,4 +657,4 @@ var MockContext = class MockContext {
635
657
  };
636
658
 
637
659
  //#endregion
638
- export { MockContext, MockFederation, createContext, createInboxContext, createRequestContext };
660
+ export { MockFederation, createContext, createInboxContext, createRequestContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/testing",
3
- "version": "1.8.14-pr.470.1832+cbd179b1",
3
+ "version": "1.8.14-pr.470.1850+14faeeb8",
4
4
  "description": "Testing utilities for Fedify applications",
5
5
  "keywords": [
6
6
  "fedify",
@@ -45,10 +45,7 @@
45
45
  "package.json"
46
46
  ],
47
47
  "peerDependencies": {
48
- "@fedify/fedify": "^1.8.14-pr.470.1832+cbd179b1"
49
- },
50
- "dependencies": {
51
- "@opentelemetry/api": "^1.9.0"
48
+ "@fedify/fedify": "^1.8.14-pr.470.1850+14faeeb8"
52
49
  },
53
50
  "devDependencies": {
54
51
  "@js-temporal/polyfill": "^0.5.1",