@fedify/testing 1.8.12 → 1.8.14-pr.470.1821
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/dist/mod.d.ts +1 -3
- package/dist/mod.js +95 -98
- package/package.json +2 -2
package/dist/mod.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TracerProvider } from "@opentelemetry/api";
|
|
2
1
|
import { ActorCallbackSetters, ActorDispatcher, ActorKeyPair, CollectionCallbackSetters, CollectionDispatcher, Context, Federation, FederationFetchOptions, FederationStartQueueOptions, InboxContext, InboxListenerSetters, Message, NodeInfoDispatcher, ObjectCallbackSetters, ObjectDispatcher, ParseUriResult, RequestContext, RouteActivityOptions, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair } from "@fedify/fedify/federation";
|
|
3
2
|
import { Activity, Actor, Collection, Hashtag, LookupObjectOptions, Object as Object$1, Recipient, TraverseCollectionOptions } from "@fedify/fedify/vocab";
|
|
4
3
|
import { ResourceDescriptor } from "@fedify/fedify/webfinger";
|
|
4
|
+
import { TracerProvider } from "@opentelemetry/api";
|
|
5
5
|
import { JsonValue, NodeInfo } from "@fedify/fedify/nodeinfo";
|
|
6
6
|
import { DocumentLoader } from "@fedify/fedify/runtime";
|
|
7
7
|
|
|
@@ -273,8 +273,6 @@ declare class MockContext<TContextData> implements Context<TContextData> {
|
|
|
273
273
|
*/
|
|
274
274
|
reset(): void;
|
|
275
275
|
}
|
|
276
|
-
//#endregion
|
|
277
|
-
//#region src/context.d.ts
|
|
278
276
|
declare function createContext<TContextData>(values: Partial<Context<TContextData>> & {
|
|
279
277
|
url?: URL;
|
|
280
278
|
data: TContextData;
|
package/dist/mod.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { trace } from "@opentelemetry/api";
|
|
2
1
|
import { RouterError } from "@fedify/fedify/federation";
|
|
3
2
|
import { lookupObject, traverseCollection } from "@fedify/fedify/vocab";
|
|
4
3
|
import { lookupWebFinger } from "@fedify/fedify/webfinger";
|
|
4
|
+
import { trace } from "@opentelemetry/api";
|
|
5
5
|
|
|
6
6
|
//#region src/docloader.ts
|
|
7
7
|
const mockDocumentLoader = async (url) => ({
|
|
@@ -10,103 +10,6 @@ const mockDocumentLoader = async (url) => ({
|
|
|
10
10
|
documentUrl: url
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/context.ts
|
|
15
|
-
function createContext(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
|
-
function throwRouteError() {
|
|
18
|
-
throw new RouterError("Not implemented");
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
federation,
|
|
22
|
-
data,
|
|
23
|
-
origin: url.origin,
|
|
24
|
-
canonicalOrigin: canonicalOrigin ?? url.origin,
|
|
25
|
-
host: url.host,
|
|
26
|
-
hostname: url.hostname,
|
|
27
|
-
documentLoader: documentLoader ?? mockDocumentLoader,
|
|
28
|
-
contextLoader: contextLoader ?? mockDocumentLoader,
|
|
29
|
-
tracerProvider: tracerProvider ?? trace.getTracerProvider(),
|
|
30
|
-
clone: clone ?? ((data$1) => createContext({
|
|
31
|
-
...values,
|
|
32
|
-
data: data$1
|
|
33
|
-
})),
|
|
34
|
-
getNodeInfoUri: getNodeInfoUri ?? throwRouteError,
|
|
35
|
-
getActorUri: getActorUri ?? throwRouteError,
|
|
36
|
-
getObjectUri: getObjectUri ?? throwRouteError,
|
|
37
|
-
getCollectionUri: getCollectionUri ?? throwRouteError,
|
|
38
|
-
getOutboxUri: getOutboxUri ?? throwRouteError,
|
|
39
|
-
getInboxUri: getInboxUri ?? throwRouteError,
|
|
40
|
-
getFollowingUri: getFollowingUri ?? throwRouteError,
|
|
41
|
-
getFollowersUri: getFollowersUri ?? throwRouteError,
|
|
42
|
-
getLikedUri: getLikedUri ?? throwRouteError,
|
|
43
|
-
getFeaturedUri: getFeaturedUri ?? throwRouteError,
|
|
44
|
-
getFeaturedTagsUri: getFeaturedTagsUri ?? throwRouteError,
|
|
45
|
-
parseUri: parseUri ?? ((_uri) => {
|
|
46
|
-
throw new Error("Not implemented");
|
|
47
|
-
}),
|
|
48
|
-
getDocumentLoader: getDocumentLoader ?? ((_params) => {
|
|
49
|
-
throw new Error("Not implemented");
|
|
50
|
-
}),
|
|
51
|
-
getActorKeyPairs: getActorKeyPairs ?? ((_handle) => Promise.resolve([])),
|
|
52
|
-
lookupObject: lookupObject$1 ?? ((uri, options = {}) => {
|
|
53
|
-
return lookupObject(uri, {
|
|
54
|
-
documentLoader: options.documentLoader ?? documentLoader ?? mockDocumentLoader,
|
|
55
|
-
contextLoader: options.contextLoader ?? contextLoader ?? mockDocumentLoader
|
|
56
|
-
});
|
|
57
|
-
}),
|
|
58
|
-
traverseCollection: traverseCollection$1 ?? ((collection, options = {}) => {
|
|
59
|
-
return traverseCollection(collection, {
|
|
60
|
-
documentLoader: options.documentLoader ?? documentLoader ?? mockDocumentLoader,
|
|
61
|
-
contextLoader: options.contextLoader ?? contextLoader ?? mockDocumentLoader
|
|
62
|
-
});
|
|
63
|
-
}),
|
|
64
|
-
lookupNodeInfo: lookupNodeInfo ?? ((_params) => {
|
|
65
|
-
throw new Error("Not implemented");
|
|
66
|
-
}),
|
|
67
|
-
lookupWebFinger: lookupWebFinger$1 ?? ((resource, options = {}) => {
|
|
68
|
-
return lookupWebFinger(resource, options);
|
|
69
|
-
}),
|
|
70
|
-
sendActivity: sendActivity ?? ((_params) => {
|
|
71
|
-
throw new Error("Not implemented");
|
|
72
|
-
}),
|
|
73
|
-
routeActivity: routeActivity ?? ((_params) => {
|
|
74
|
-
throw new Error("Not implemented");
|
|
75
|
-
})
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function createRequestContext(args) {
|
|
79
|
-
return {
|
|
80
|
-
...createContext(args),
|
|
81
|
-
clone: args.clone ?? ((data) => createRequestContext({
|
|
82
|
-
...args,
|
|
83
|
-
data
|
|
84
|
-
})),
|
|
85
|
-
request: args.request ?? new Request(args.url),
|
|
86
|
-
url: args.url,
|
|
87
|
-
getActor: args.getActor ?? (() => Promise.resolve(null)),
|
|
88
|
-
getObject: args.getObject ?? (() => Promise.resolve(null)),
|
|
89
|
-
getSignedKey: args.getSignedKey ?? (() => Promise.resolve(null)),
|
|
90
|
-
getSignedKeyOwner: args.getSignedKeyOwner ?? (() => Promise.resolve(null)),
|
|
91
|
-
sendActivity: args.sendActivity ?? ((_params) => {
|
|
92
|
-
throw new Error("Not implemented");
|
|
93
|
-
})
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function createInboxContext(args) {
|
|
97
|
-
return {
|
|
98
|
-
...createContext(args),
|
|
99
|
-
clone: args.clone ?? ((data) => createInboxContext({
|
|
100
|
-
...args,
|
|
101
|
-
data
|
|
102
|
-
})),
|
|
103
|
-
recipient: args.recipient ?? null,
|
|
104
|
-
forwardActivity: args.forwardActivity ?? ((_params) => {
|
|
105
|
-
throw new Error("Not implemented");
|
|
106
|
-
})
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
13
|
//#endregion
|
|
111
14
|
//#region src/mock.ts
|
|
112
15
|
/**
|
|
@@ -628,6 +531,100 @@ var MockContext = class MockContext {
|
|
|
628
531
|
this.sentActivities = [];
|
|
629
532
|
}
|
|
630
533
|
};
|
|
534
|
+
function createContext(values) {
|
|
535
|
+
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;
|
|
536
|
+
function throwRouteError() {
|
|
537
|
+
throw new RouterError("Not implemented");
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
federation,
|
|
541
|
+
data,
|
|
542
|
+
origin: url.origin,
|
|
543
|
+
canonicalOrigin: canonicalOrigin ?? url.origin,
|
|
544
|
+
host: url.host,
|
|
545
|
+
hostname: url.hostname,
|
|
546
|
+
documentLoader: documentLoader ?? mockDocumentLoader,
|
|
547
|
+
contextLoader: contextLoader ?? mockDocumentLoader,
|
|
548
|
+
tracerProvider: tracerProvider ?? trace.getTracerProvider(),
|
|
549
|
+
clone: clone ?? ((data$1) => createContext({
|
|
550
|
+
...values,
|
|
551
|
+
data: data$1
|
|
552
|
+
})),
|
|
553
|
+
getNodeInfoUri: getNodeInfoUri ?? throwRouteError,
|
|
554
|
+
getActorUri: getActorUri ?? throwRouteError,
|
|
555
|
+
getObjectUri: getObjectUri ?? throwRouteError,
|
|
556
|
+
getCollectionUri: getCollectionUri ?? throwRouteError,
|
|
557
|
+
getOutboxUri: getOutboxUri ?? throwRouteError,
|
|
558
|
+
getInboxUri: getInboxUri ?? throwRouteError,
|
|
559
|
+
getFollowingUri: getFollowingUri ?? throwRouteError,
|
|
560
|
+
getFollowersUri: getFollowersUri ?? throwRouteError,
|
|
561
|
+
getLikedUri: getLikedUri ?? throwRouteError,
|
|
562
|
+
getFeaturedUri: getFeaturedUri ?? throwRouteError,
|
|
563
|
+
getFeaturedTagsUri: getFeaturedTagsUri ?? throwRouteError,
|
|
564
|
+
parseUri: parseUri ?? ((_uri) => {
|
|
565
|
+
throw new Error("Not implemented");
|
|
566
|
+
}),
|
|
567
|
+
getDocumentLoader: getDocumentLoader ?? ((_params) => {
|
|
568
|
+
throw new Error("Not implemented");
|
|
569
|
+
}),
|
|
570
|
+
getActorKeyPairs: getActorKeyPairs ?? ((_handle) => Promise.resolve([])),
|
|
571
|
+
lookupObject: lookupObject$1 ?? ((uri, options = {}) => {
|
|
572
|
+
return lookupObject(uri, {
|
|
573
|
+
documentLoader: options.documentLoader ?? documentLoader ?? mockDocumentLoader,
|
|
574
|
+
contextLoader: options.contextLoader ?? contextLoader ?? mockDocumentLoader
|
|
575
|
+
});
|
|
576
|
+
}),
|
|
577
|
+
traverseCollection: traverseCollection$1 ?? ((collection, options = {}) => {
|
|
578
|
+
return traverseCollection(collection, {
|
|
579
|
+
documentLoader: options.documentLoader ?? documentLoader ?? mockDocumentLoader,
|
|
580
|
+
contextLoader: options.contextLoader ?? contextLoader ?? mockDocumentLoader
|
|
581
|
+
});
|
|
582
|
+
}),
|
|
583
|
+
lookupNodeInfo: lookupNodeInfo ?? ((_params) => {
|
|
584
|
+
throw new Error("Not implemented");
|
|
585
|
+
}),
|
|
586
|
+
lookupWebFinger: lookupWebFinger$1 ?? ((resource, options = {}) => {
|
|
587
|
+
return lookupWebFinger(resource, options);
|
|
588
|
+
}),
|
|
589
|
+
sendActivity: sendActivity ?? ((_params) => {
|
|
590
|
+
throw new Error("Not implemented");
|
|
591
|
+
}),
|
|
592
|
+
routeActivity: routeActivity ?? ((_params) => {
|
|
593
|
+
throw new Error("Not implemented");
|
|
594
|
+
})
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function createRequestContext(args) {
|
|
598
|
+
return {
|
|
599
|
+
...createContext(args),
|
|
600
|
+
clone: args.clone ?? ((data) => createRequestContext({
|
|
601
|
+
...args,
|
|
602
|
+
data
|
|
603
|
+
})),
|
|
604
|
+
request: args.request ?? new Request(args.url),
|
|
605
|
+
url: args.url,
|
|
606
|
+
getActor: args.getActor ?? (() => Promise.resolve(null)),
|
|
607
|
+
getObject: args.getObject ?? (() => Promise.resolve(null)),
|
|
608
|
+
getSignedKey: args.getSignedKey ?? (() => Promise.resolve(null)),
|
|
609
|
+
getSignedKeyOwner: args.getSignedKeyOwner ?? (() => Promise.resolve(null)),
|
|
610
|
+
sendActivity: args.sendActivity ?? ((_params) => {
|
|
611
|
+
throw new Error("Not implemented");
|
|
612
|
+
})
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
function createInboxContext(args) {
|
|
616
|
+
return {
|
|
617
|
+
...createContext(args),
|
|
618
|
+
clone: args.clone ?? ((data) => createInboxContext({
|
|
619
|
+
...args,
|
|
620
|
+
data
|
|
621
|
+
})),
|
|
622
|
+
recipient: args.recipient ?? null,
|
|
623
|
+
forwardActivity: args.forwardActivity ?? ((_params) => {
|
|
624
|
+
throw new Error("Not implemented");
|
|
625
|
+
})
|
|
626
|
+
};
|
|
627
|
+
}
|
|
631
628
|
|
|
632
629
|
//#endregion
|
|
633
630
|
export { MockContext, MockFederation, createContext, createInboxContext, createRequestContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/testing",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.14-pr.470.1821+d8391b57",
|
|
4
4
|
"description": "Testing utilities for Fedify applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"package.json"
|
|
46
46
|
],
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@fedify/fedify": "^1.8.
|
|
48
|
+
"@fedify/fedify": "^1.8.14-pr.470.1821+d8391b57"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@opentelemetry/api": "^1.9.0"
|