@fedify/testing 1.8.14-pr.470.1823 → 1.8.14-pr.470.1835
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 +55 -28
- package/dist/mod.js +94 -94
- package/package.json +2 -2
package/dist/mod.d.ts
CHANGED
|
@@ -1,12 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import * as _fedify_fedify_federation0 from "@fedify/fedify/federation";
|
|
2
|
+
import * as _fedify_fedify_vocab24 from "@fedify/fedify/vocab";
|
|
3
|
+
import * as _fedify_fedify_webfinger32 from "@fedify/fedify/webfinger";
|
|
4
4
|
import { TracerProvider } from "@opentelemetry/api";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as _fedify_fedify_nodeinfo21 from "@fedify/fedify/nodeinfo";
|
|
6
|
+
import * as _fedify_fedify_runtime23 from "@fedify/fedify/runtime";
|
|
7
7
|
|
|
8
8
|
//#region src/mock.d.ts
|
|
9
|
-
|
|
9
|
+
type ActorCallbackSetters<TContextData> = _fedify_fedify_federation0.ActorCallbackSetters<TContextData>;
|
|
10
|
+
type ActorDispatcher<TContextData> = _fedify_fedify_federation0.ActorDispatcher<TContextData>;
|
|
11
|
+
type ActorKeyPair = _fedify_fedify_federation0.ActorKeyPair;
|
|
12
|
+
type CollectionCallbackSetters<TContext extends Context<TContextData>, TContextData, TCursor> = _fedify_fedify_federation0.CollectionCallbackSetters<TContext, TContextData, TCursor>;
|
|
13
|
+
type CollectionDispatcher<TItem, TContext extends Context<TContextData>, TContextData, TCursor> = _fedify_fedify_federation0.CollectionDispatcher<TItem, TContext, TContextData, TCursor>;
|
|
14
|
+
type Context<TContextData> = _fedify_fedify_federation0.Context<TContextData>;
|
|
15
|
+
type Federation<TContextData> = _fedify_fedify_federation0.Federation<TContextData>;
|
|
16
|
+
type FederationFetchOptions<TContextData> = _fedify_fedify_federation0.FederationFetchOptions<TContextData>;
|
|
17
|
+
type FederationStartQueueOptions = _fedify_fedify_federation0.FederationStartQueueOptions;
|
|
18
|
+
type InboxContext<TContextData> = _fedify_fedify_federation0.InboxContext<TContextData>;
|
|
19
|
+
type InboxListenerSetters<TContextData> = _fedify_fedify_federation0.InboxListenerSetters<TContextData>;
|
|
20
|
+
type Message = _fedify_fedify_federation0.Message;
|
|
21
|
+
type NodeInfoDispatcher<TContextData> = _fedify_fedify_federation0.NodeInfoDispatcher<TContextData>;
|
|
22
|
+
type ObjectCallbackSetters<TContextData, TObject extends Object$1, TParam extends string> = _fedify_fedify_federation0.ObjectCallbackSetters<TContextData, TObject, TParam>;
|
|
23
|
+
type ObjectDispatcher<TContextData, TObject extends Object$1, TParam extends string> = _fedify_fedify_federation0.ObjectDispatcher<TContextData, TObject, TParam>;
|
|
24
|
+
type ParseUriResult = _fedify_fedify_federation0.ParseUriResult;
|
|
25
|
+
type RequestContext<TContextData> = _fedify_fedify_federation0.RequestContext<TContextData>;
|
|
26
|
+
type RouteActivityOptions = _fedify_fedify_federation0.RouteActivityOptions;
|
|
27
|
+
type SendActivityOptions = _fedify_fedify_federation0.SendActivityOptions;
|
|
28
|
+
type SendActivityOptionsForCollection = _fedify_fedify_federation0.SendActivityOptionsForCollection;
|
|
29
|
+
type SenderKeyPair = _fedify_fedify_federation0.SenderKeyPair;
|
|
30
|
+
type JsonValue = _fedify_fedify_nodeinfo21.JsonValue;
|
|
31
|
+
type NodeInfo = _fedify_fedify_nodeinfo21.NodeInfo;
|
|
32
|
+
type DocumentLoader = _fedify_fedify_runtime23.DocumentLoader;
|
|
33
|
+
type Activity = _fedify_fedify_vocab24.Activity;
|
|
34
|
+
type Actor = _fedify_fedify_vocab24.Actor;
|
|
35
|
+
type Collection = _fedify_fedify_vocab24.Collection;
|
|
36
|
+
type Hashtag = _fedify_fedify_vocab24.Hashtag;
|
|
37
|
+
type LookupObjectOptions = _fedify_fedify_vocab24.LookupObjectOptions;
|
|
38
|
+
type Object$1 = _fedify_fedify_vocab24.Object;
|
|
39
|
+
type Recipient = _fedify_fedify_vocab24.Recipient;
|
|
40
|
+
type TraverseCollectionOptions = _fedify_fedify_vocab24.TraverseCollectionOptions;
|
|
41
|
+
type ResourceDescriptor = _fedify_fedify_webfinger32.ResourceDescriptor;
|
|
42
|
+
declare function createContext<TContextData>(values: Partial<Context<TContextData>> & {
|
|
43
|
+
url?: URL;
|
|
44
|
+
data: TContextData;
|
|
45
|
+
federation: Federation<TContextData>;
|
|
46
|
+
}): Context<TContextData>;
|
|
47
|
+
declare function createRequestContext<TContextData>(args: Partial<RequestContext<TContextData>> & {
|
|
48
|
+
url: URL;
|
|
49
|
+
data: TContextData;
|
|
50
|
+
federation: Federation<TContextData>;
|
|
51
|
+
}): RequestContext<TContextData>;
|
|
52
|
+
declare function createInboxContext<TContextData>(args: Partial<InboxContext<TContextData>> & {
|
|
53
|
+
url?: URL;
|
|
54
|
+
data: TContextData;
|
|
55
|
+
recipient?: string | null;
|
|
56
|
+
federation: Federation<TContextData>;
|
|
57
|
+
}): InboxContext<TContextData>;
|
|
10
58
|
/**
|
|
11
59
|
* Represents a sent activity with metadata about how it was sent.
|
|
12
60
|
* @since 1.8.0
|
|
@@ -273,26 +321,5 @@ declare class MockContext<TContextData> implements Context<TContextData> {
|
|
|
273
321
|
*/
|
|
274
322
|
reset(): void;
|
|
275
323
|
}
|
|
276
|
-
declare function createContext<TContextData>(values: Partial<Context<TContextData>> & {
|
|
277
|
-
url?: URL;
|
|
278
|
-
data: TContextData;
|
|
279
|
-
federation: Federation<TContextData>;
|
|
280
|
-
}): Context<TContextData>;
|
|
281
|
-
declare function createRequestContext<TContextData>(args: Partial<RequestContext<TContextData>> & {
|
|
282
|
-
url: URL;
|
|
283
|
-
data: TContextData;
|
|
284
|
-
federation: Federation<TContextData>;
|
|
285
|
-
}): RequestContext<TContextData>;
|
|
286
|
-
declare function createInboxContext<TContextData>(args: Partial<InboxContext<TContextData>> & {
|
|
287
|
-
url?: URL;
|
|
288
|
-
data: TContextData;
|
|
289
|
-
recipient?: string | null;
|
|
290
|
-
federation: Federation<TContextData>;
|
|
291
|
-
}): InboxContext<TContextData>;
|
|
292
|
-
//#endregion
|
|
293
|
-
//#region src/types.d.ts
|
|
294
|
-
interface InboxListener<TContextData, TActivity extends Activity> {
|
|
295
|
-
(context: InboxContext<TContextData>, activity: TActivity): void | Promise<void>;
|
|
296
|
-
}
|
|
297
324
|
//#endregion
|
|
298
|
-
export {
|
|
325
|
+
export { MockContext, MockFederation, SentActivity, createContext, createInboxContext, createRequestContext };
|
package/dist/mod.js
CHANGED
|
@@ -12,6 +12,100 @@ const mockDocumentLoader = async (url) => ({
|
|
|
12
12
|
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/mock.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
|
+
}
|
|
15
109
|
/**
|
|
16
110
|
* Helper function to expand URI templates with values.
|
|
17
111
|
* Supports simple placeholders like {identifier}, {handle}, etc.
|
|
@@ -531,100 +625,6 @@ var MockContext = class MockContext {
|
|
|
531
625
|
this.sentActivities = [];
|
|
532
626
|
}
|
|
533
627
|
};
|
|
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
|
-
}
|
|
628
628
|
|
|
629
629
|
//#endregion
|
|
630
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.14-pr.470.
|
|
3
|
+
"version": "1.8.14-pr.470.1835+535dbebe",
|
|
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.14-pr.470.
|
|
48
|
+
"@fedify/fedify": "^1.8.14-pr.470.1835+535dbebe"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@opentelemetry/api": "^1.9.0"
|