@fedify/testing 1.8.1-pr.331.1178 → 1.8.1-pr.332.1179

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.
package/context.ts CHANGED
@@ -1,16 +1,16 @@
1
- import { trace } from "@opentelemetry/api";
2
1
  import type {
3
2
  Context,
3
+ Federation,
4
4
  InboxContext,
5
5
  RequestContext,
6
6
  } from "@fedify/fedify/federation";
7
- import type { Federation } from "@fedify/fedify/federation";
8
7
  import { RouterError } from "@fedify/fedify/federation";
9
8
  import {
10
9
  lookupObject as globalLookupObject,
11
10
  traverseCollection as globalTraverseCollection,
12
11
  } from "@fedify/fedify/vocab";
13
12
  import { lookupWebFinger as globalLookupWebFinger } from "@fedify/fedify/webfinger";
13
+ import { trace } from "@opentelemetry/api";
14
14
  import { mockDocumentLoader } from "./docloader.ts";
15
15
 
16
16
  // NOTE: Copied from @fedify/fedify/testing/context.ts
@@ -34,6 +34,7 @@ export function createContext<TContextData>(
34
34
  getNodeInfoUri,
35
35
  getActorUri,
36
36
  getObjectUri,
37
+ getCollectionUri,
37
38
  getOutboxUri,
38
39
  getInboxUri,
39
40
  getFollowingUri,
@@ -68,6 +69,7 @@ export function createContext<TContextData>(
68
69
  getNodeInfoUri: getNodeInfoUri ?? throwRouteError,
69
70
  getActorUri: getActorUri ?? throwRouteError,
70
71
  getObjectUri: getObjectUri ?? throwRouteError,
72
+ getCollectionUri: getCollectionUri ?? throwRouteError,
71
73
  getOutboxUri: getOutboxUri ?? throwRouteError,
72
74
  getInboxUri: getInboxUri ?? throwRouteError,
73
75
  getFollowingUri: getFollowingUri ?? throwRouteError,
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/testing",
3
- "version": "1.8.1-pr.331.1178+a338511b",
3
+ "version": "1.8.1-pr.332.1179+0d71f17e",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./mod.ts"
package/dist/mod.d.ts CHANGED
@@ -124,6 +124,8 @@ declare class MockFederation<TContextData> implements Federation<TContextData> {
124
124
  * @since 1.8.0
125
125
  */
126
126
  reset(): void;
127
+ setCollectionDispatcher<TObject extends Object$1, TParams extends Record<string, string>>(_name: string | symbol, _itemType: any, _path: any, _dispatcher: any): any;
128
+ setOrderedCollectionDispatcher<TObject extends Object$1, TParams extends Record<string, string>>(_name: string | symbol, _itemType: any, _path: any, _dispatcher: any): any;
127
129
  }
128
130
  /**
129
131
  * A mock implementation of the {@link Context} interface for unit testing.
@@ -196,6 +198,7 @@ declare class MockContext<TContextData> implements Context<TContextData> {
196
198
  getLikedUri(identifier: string): URL;
197
199
  getFeaturedUri(identifier: string): URL;
198
200
  getFeaturedTagsUri(identifier: string): URL;
201
+ getCollectionUri<TParam extends Record<string, string>>(_name: string | symbol, values: TParam): URL;
199
202
  parseUri(uri: URL): ParseUriResult | null;
200
203
  getActorKeyPairs(_identifier: string): Promise<ActorKeyPair[]>;
201
204
  getDocumentLoader(params: {
package/dist/mod.js CHANGED
@@ -13,7 +13,7 @@ const mockDocumentLoader = async (url) => ({
13
13
  //#endregion
14
14
  //#region context.ts
15
15
  function createContext(values) {
16
- const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getOutboxUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject: lookupObject$1, traverseCollection: traverseCollection$1, lookupNodeInfo, lookupWebFinger: lookupWebFinger$1, sendActivity, routeActivity } = values;
16
+ 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;
17
17
  function throwRouteError() {
18
18
  throw new RouterError("Not implemented");
19
19
  }
@@ -34,6 +34,7 @@ function createContext(values) {
34
34
  getNodeInfoUri: getNodeInfoUri ?? throwRouteError,
35
35
  getActorUri: getActorUri ?? throwRouteError,
36
36
  getObjectUri: getObjectUri ?? throwRouteError,
37
+ getCollectionUri: getCollectionUri ?? throwRouteError,
37
38
  getOutboxUri: getOutboxUri ?? throwRouteError,
38
39
  getInboxUri: getInboxUri ?? throwRouteError,
39
40
  getFollowingUri: getFollowingUri ?? throwRouteError,
@@ -363,6 +364,22 @@ var MockFederation = class {
363
364
  reset() {
364
365
  this.sentActivities = [];
365
366
  }
367
+ setCollectionDispatcher(_name, _itemType, _path, _dispatcher) {
368
+ return {
369
+ setCounter: () => this,
370
+ setFirstCursor: () => this,
371
+ setLastCursor: () => this,
372
+ authorize: () => this
373
+ };
374
+ }
375
+ setOrderedCollectionDispatcher(_name, _itemType, _path, _dispatcher) {
376
+ return {
377
+ setCounter: () => this,
378
+ setFirstCursor: () => this,
379
+ setLastCursor: () => this,
380
+ authorize: () => this
381
+ };
382
+ }
366
383
  };
367
384
  /**
368
385
  * A mock implementation of the {@link Context} interface for unit testing.
@@ -538,6 +555,10 @@ var MockContext = class MockContext {
538
555
  }
539
556
  return new URL(`/users/${identifier}/tags`, this.origin);
540
557
  }
558
+ getCollectionUri(_name, values) {
559
+ const path = globalThis.Object.entries(values).map(([key, value]) => `${key}/${value}`).join("/");
560
+ return new URL(`/collections/${String(_name)}/${path}`, this.origin);
561
+ }
541
562
  parseUri(uri) {
542
563
  if (uri.pathname.startsWith("/users/")) {
543
564
  const parts = uri.pathname.split("/");
package/mock.ts CHANGED
@@ -535,6 +535,42 @@ export class MockFederation<TContextData> implements Federation<TContextData> {
535
535
  reset(): void {
536
536
  this.sentActivities = [];
537
537
  }
538
+
539
+ setCollectionDispatcher<
540
+ TObject extends Object,
541
+ TParams extends Record<string, string>,
542
+ >(
543
+ _name: string | symbol,
544
+ _itemType: any,
545
+ _path: any,
546
+ _dispatcher: any,
547
+ ): any {
548
+ // Mock implementation - just return a mock callback setters object
549
+ return {
550
+ setCounter: () => this as any,
551
+ setFirstCursor: () => this as any,
552
+ setLastCursor: () => this as any,
553
+ authorize: () => this as any,
554
+ };
555
+ }
556
+
557
+ setOrderedCollectionDispatcher<
558
+ TObject extends Object,
559
+ TParams extends Record<string, string>,
560
+ >(
561
+ _name: string | symbol,
562
+ _itemType: any,
563
+ _path: any,
564
+ _dispatcher: any,
565
+ ): any {
566
+ // Mock implementation - just return a mock callback setters object
567
+ return {
568
+ setCounter: () => this as any,
569
+ setFirstCursor: () => this as any,
570
+ setLastCursor: () => this as any,
571
+ authorize: () => this as any,
572
+ };
573
+ }
538
574
  }
539
575
 
540
576
  // Type definitions for inbox listeners
@@ -780,6 +816,17 @@ export class MockContext<TContextData> implements Context<TContextData> {
780
816
  return new URL(`/users/${identifier}/tags`, this.origin);
781
817
  }
782
818
 
819
+ getCollectionUri<TParam extends Record<string, string>>(
820
+ _name: string | symbol,
821
+ values: TParam,
822
+ ): URL {
823
+ // Mock implementation - construct a generic collection URI
824
+ const path = globalThis.Object.entries(values)
825
+ .map(([key, value]) => `${key}/${value}`)
826
+ .join("/");
827
+ return new URL(`/collections/${String(_name)}/${path}`, this.origin);
828
+ }
829
+
783
830
  parseUri(uri: URL): ParseUriResult | null {
784
831
  if (uri.pathname.startsWith("/users/")) {
785
832
  const parts = uri.pathname.split("/");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/testing",
3
- "version": "1.8.1-pr.331.1178+a338511b",
3
+ "version": "1.8.1-pr.332.1179+0d71f17e",
4
4
  "description": "Testing utilities for Fedify applications",
5
5
  "keywords": [
6
6
  "fedify",
@@ -41,7 +41,7 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "peerDependencies": {
44
- "@fedify/fedify": "1.8.1-pr.331.1178+a338511b"
44
+ "@fedify/fedify": "1.8.1-pr.332.1179+0d71f17e"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@js-temporal/polyfill": "^0.5.1",