@fedify/testing 2.0.35-dev.2468 → 2.0.35-dev.2470
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.cjs +18 -3
- package/dist/mod.d.cts +8 -0
- package/dist/mod.d.ts +8 -0
- package/dist/mod.js +18 -3
- package/package.json +6 -5
package/dist/mod.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
let _fedify_vocab = require("@fedify/vocab");
|
|
4
|
+
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
5
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
4
6
|
let _fedify_fedify_federation = require("@fedify/fedify/federation");
|
|
5
7
|
let es_toolkit = require("es-toolkit");
|
|
6
8
|
let node_assert_strict = require("node:assert/strict");
|
|
@@ -206,9 +208,11 @@ var MockFederation = class {
|
|
|
206
208
|
inboxListeners = /* @__PURE__ */ new Map();
|
|
207
209
|
contextData;
|
|
208
210
|
receivedActivities = [];
|
|
211
|
+
documentLoader;
|
|
209
212
|
constructor(options = {}) {
|
|
210
213
|
this.options = options;
|
|
211
214
|
this.contextData = options.contextData;
|
|
215
|
+
if (options.allowPrivateAddress === true) this.documentLoader = (0, _fedify_vocab_runtime.getDocumentLoader)({ allowPrivateAddress: true });
|
|
212
216
|
}
|
|
213
217
|
setNodeInfoDispatcher(path, dispatcher) {
|
|
214
218
|
this.nodeInfoDispatcher = dispatcher;
|
|
@@ -354,7 +358,10 @@ var MockFederation = class {
|
|
|
354
358
|
return new MockContext({
|
|
355
359
|
url: baseUrlOrRequest instanceof Request ? new URL(baseUrlOrRequest.url) : baseUrlOrRequest,
|
|
356
360
|
data: contextData,
|
|
357
|
-
federation: mockFederation
|
|
361
|
+
federation: mockFederation,
|
|
362
|
+
documentLoader: this.documentLoader,
|
|
363
|
+
contextLoader: this.documentLoader,
|
|
364
|
+
tracerProvider: this.documentLoader == null ? void 0 : this.options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()
|
|
358
365
|
});
|
|
359
366
|
}
|
|
360
367
|
async fetch(request, options) {
|
|
@@ -374,10 +381,18 @@ var MockFederation = class {
|
|
|
374
381
|
const typeName = activity.constructor.name;
|
|
375
382
|
const listeners = this.inboxListeners.get(typeName) || [];
|
|
376
383
|
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.");
|
|
384
|
+
const receivedActivity = listeners.length > 0 && this.documentLoader != null ? activity.clone({}, {
|
|
385
|
+
documentLoader: this.documentLoader,
|
|
386
|
+
contextLoader: this.documentLoader
|
|
387
|
+
}) : activity;
|
|
388
|
+
if (receivedActivity !== activity) Reflect.set(receivedActivity, "_cachedJsonLd", Reflect.get(activity, "_cachedJsonLd"));
|
|
377
389
|
for (const listener of listeners) await listener(createInboxContext({
|
|
378
390
|
data: this.contextData,
|
|
379
|
-
federation: this
|
|
380
|
-
|
|
391
|
+
federation: this,
|
|
392
|
+
documentLoader: this.documentLoader,
|
|
393
|
+
contextLoader: this.documentLoader,
|
|
394
|
+
tracerProvider: this.documentLoader == null ? void 0 : this.options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()
|
|
395
|
+
}), receivedActivity);
|
|
381
396
|
}
|
|
382
397
|
/**
|
|
383
398
|
* Clears all sent activities from the mock federation.
|
package/dist/mod.d.cts
CHANGED
|
@@ -122,6 +122,14 @@ interface TestFederation<TContextData> extends Omit<Federation<TContextData>, "c
|
|
|
122
122
|
declare function createFederation<TContextData>(options?: {
|
|
123
123
|
contextData?: TContextData;
|
|
124
124
|
origin?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Use HTTP document loading for received activities and contexts created by
|
|
127
|
+
* this federation, allowing private addresses such as localhost.
|
|
128
|
+
* If false or omitted, contexts retain their no-op mock loaders and
|
|
129
|
+
* received activities retain their own loaders.
|
|
130
|
+
* @since 2.0.35
|
|
131
|
+
*/
|
|
132
|
+
allowPrivateAddress?: boolean;
|
|
125
133
|
tracerProvider?: any;
|
|
126
134
|
}): TestFederation<TContextData>;
|
|
127
135
|
//#endregion
|
package/dist/mod.d.ts
CHANGED
|
@@ -122,6 +122,14 @@ interface TestFederation<TContextData> extends Omit<Federation<TContextData>, "c
|
|
|
122
122
|
declare function createFederation<TContextData>(options?: {
|
|
123
123
|
contextData?: TContextData;
|
|
124
124
|
origin?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Use HTTP document loading for received activities and contexts created by
|
|
127
|
+
* this federation, allowing private addresses such as localhost.
|
|
128
|
+
* If false or omitted, contexts retain their no-op mock loaders and
|
|
129
|
+
* received activities retain their own loaders.
|
|
130
|
+
* @since 2.0.35
|
|
131
|
+
*/
|
|
132
|
+
allowPrivateAddress?: boolean;
|
|
125
133
|
tracerProvider?: any;
|
|
126
134
|
}): TestFederation<TContextData>;
|
|
127
135
|
//#endregion
|
package/dist/mod.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { CryptographicKey, Multikey, lookupObject, traverseCollection } from "@fedify/vocab";
|
|
3
|
+
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
4
|
+
import { trace } from "@opentelemetry/api";
|
|
3
5
|
import { RouterError } from "@fedify/fedify/federation";
|
|
4
6
|
import { delay } from "es-toolkit";
|
|
5
7
|
import { deepStrictEqual, ok, strictEqual } from "node:assert/strict";
|
|
@@ -205,9 +207,11 @@ var MockFederation = class {
|
|
|
205
207
|
inboxListeners = /* @__PURE__ */ new Map();
|
|
206
208
|
contextData;
|
|
207
209
|
receivedActivities = [];
|
|
210
|
+
documentLoader;
|
|
208
211
|
constructor(options = {}) {
|
|
209
212
|
this.options = options;
|
|
210
213
|
this.contextData = options.contextData;
|
|
214
|
+
if (options.allowPrivateAddress === true) this.documentLoader = getDocumentLoader({ allowPrivateAddress: true });
|
|
211
215
|
}
|
|
212
216
|
setNodeInfoDispatcher(path, dispatcher) {
|
|
213
217
|
this.nodeInfoDispatcher = dispatcher;
|
|
@@ -353,7 +357,10 @@ var MockFederation = class {
|
|
|
353
357
|
return new MockContext({
|
|
354
358
|
url: baseUrlOrRequest instanceof Request ? new URL(baseUrlOrRequest.url) : baseUrlOrRequest,
|
|
355
359
|
data: contextData,
|
|
356
|
-
federation: mockFederation
|
|
360
|
+
federation: mockFederation,
|
|
361
|
+
documentLoader: this.documentLoader,
|
|
362
|
+
contextLoader: this.documentLoader,
|
|
363
|
+
tracerProvider: this.documentLoader == null ? void 0 : this.options.tracerProvider ?? trace.getTracerProvider()
|
|
357
364
|
});
|
|
358
365
|
}
|
|
359
366
|
async fetch(request, options) {
|
|
@@ -373,10 +380,18 @@ var MockFederation = class {
|
|
|
373
380
|
const typeName = activity.constructor.name;
|
|
374
381
|
const listeners = this.inboxListeners.get(typeName) || [];
|
|
375
382
|
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.");
|
|
383
|
+
const receivedActivity = listeners.length > 0 && this.documentLoader != null ? activity.clone({}, {
|
|
384
|
+
documentLoader: this.documentLoader,
|
|
385
|
+
contextLoader: this.documentLoader
|
|
386
|
+
}) : activity;
|
|
387
|
+
if (receivedActivity !== activity) Reflect.set(receivedActivity, "_cachedJsonLd", Reflect.get(activity, "_cachedJsonLd"));
|
|
376
388
|
for (const listener of listeners) await listener(createInboxContext({
|
|
377
389
|
data: this.contextData,
|
|
378
|
-
federation: this
|
|
379
|
-
|
|
390
|
+
federation: this,
|
|
391
|
+
documentLoader: this.documentLoader,
|
|
392
|
+
contextLoader: this.documentLoader,
|
|
393
|
+
tracerProvider: this.documentLoader == null ? void 0 : this.options.tracerProvider ?? trace.getTracerProvider()
|
|
394
|
+
}), receivedActivity);
|
|
380
395
|
}
|
|
381
396
|
/**
|
|
382
397
|
* Clears all sent activities from the mock federation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/testing",
|
|
3
|
-
"version": "2.0.35-dev.
|
|
3
|
+
"version": "2.0.35-dev.2470+891ba128",
|
|
4
4
|
"description": "Testing utilities for Fedify applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -50,20 +50,21 @@
|
|
|
50
50
|
"package.json"
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@fedify/fedify": "^2.0.35-dev.
|
|
53
|
+
"@fedify/fedify": "^2.0.35-dev.2470+891ba128"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@js-temporal/polyfill": "^0.5.1",
|
|
57
|
+
"@opentelemetry/api": "^1.9.0",
|
|
57
58
|
"es-toolkit": "1.43.0",
|
|
58
|
-
"@fedify/vocab": "^2.0.35-dev.
|
|
59
|
+
"@fedify/vocab-runtime": "^2.0.35-dev.2470+891ba128",
|
|
60
|
+
"@fedify/vocab": "^2.0.35-dev.2470+891ba128"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@std/assert": "npm:@jsr/std__assert@^1.0.13",
|
|
62
64
|
"@std/async": "npm:@jsr/std__async@^1.0.13",
|
|
63
65
|
"tsdown": "^0.21.6",
|
|
64
66
|
"typescript": "^6.0.0",
|
|
65
|
-
"@fedify/fixture": "^2.0.0"
|
|
66
|
-
"@fedify/vocab-runtime": "^2.0.35-dev.2468+595e3cce"
|
|
67
|
+
"@fedify/fixture": "^2.0.0"
|
|
67
68
|
},
|
|
68
69
|
"scripts": {
|
|
69
70
|
"build:self": "tsdown",
|