@fedify/testing 2.3.0-dev.1361 → 2.3.0-dev.1371
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 +1 -42
- package/dist/mod.js +1 -42
- package/package.json +2 -3
package/dist/mod.cjs
CHANGED
|
@@ -38,7 +38,7 @@ const noopMeterProvider$1 = { getMeter: () => ({
|
|
|
38
38
|
removeBatchObservableCallback: () => void 0
|
|
39
39
|
}) };
|
|
40
40
|
function createContext(values) {
|
|
41
|
-
const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, meterProvider, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getCollectionUri, getOutboxUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject, traverseCollection, lookupNodeInfo, lookupWebFinger, sendActivity, routeActivity
|
|
41
|
+
const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, meterProvider, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getCollectionUri, getOutboxUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject, traverseCollection, lookupNodeInfo, lookupWebFinger, sendActivity, routeActivity } = values;
|
|
42
42
|
function throwRouterError() {
|
|
43
43
|
throw new _fedify_fedify_federation.RouterError("Not implemented");
|
|
44
44
|
}
|
|
@@ -98,12 +98,6 @@ function createContext(values) {
|
|
|
98
98
|
}),
|
|
99
99
|
routeActivity: routeActivity ?? ((_params) => {
|
|
100
100
|
throw new Error("Not implemented");
|
|
101
|
-
}),
|
|
102
|
-
enqueueTask: enqueueTask ?? ((_task, _data, _options) => {
|
|
103
|
-
throw new Error("Not implemented");
|
|
104
|
-
}),
|
|
105
|
-
enqueueTaskMany: enqueueTaskMany ?? ((_task, _payloads, _options) => {
|
|
106
|
-
throw new Error("Not implemented");
|
|
107
101
|
})
|
|
108
102
|
};
|
|
109
103
|
}
|
|
@@ -292,7 +286,6 @@ var MockFederation = class {
|
|
|
292
286
|
sharedInboxPath;
|
|
293
287
|
objectPaths = /* @__PURE__ */ new Map();
|
|
294
288
|
objectDispatchers = /* @__PURE__ */ new Map();
|
|
295
|
-
taskDefinitions = /* @__PURE__ */ new Map();
|
|
296
289
|
inboxDispatcher;
|
|
297
290
|
outboxDispatcher;
|
|
298
291
|
outboxAuthorizePredicate;
|
|
@@ -316,19 +309,6 @@ var MockFederation = class {
|
|
|
316
309
|
this.nodeInfoDispatcher = dispatcher;
|
|
317
310
|
this.nodeInfoPath = path;
|
|
318
311
|
}
|
|
319
|
-
defineTask(name, options) {
|
|
320
|
-
if (this.taskDefinitions.has(name)) throw new TypeError(`Task ${JSON.stringify(name)} is already defined.`);
|
|
321
|
-
const handle = {
|
|
322
|
-
name,
|
|
323
|
-
schema: options.schema
|
|
324
|
-
};
|
|
325
|
-
this.taskDefinitions.set(name, {
|
|
326
|
-
name,
|
|
327
|
-
...options,
|
|
328
|
-
handle
|
|
329
|
-
});
|
|
330
|
-
return handle;
|
|
331
|
-
}
|
|
332
312
|
setWebFingerLinksDispatcher(dispatcher) {
|
|
333
313
|
this.webFingerDispatcher = dispatcher;
|
|
334
314
|
}
|
|
@@ -479,7 +459,6 @@ var MockFederation = class {
|
|
|
479
459
|
this.activeQueues.add("inbox");
|
|
480
460
|
this.activeQueues.add("outbox");
|
|
481
461
|
this.activeQueues.add("fanout");
|
|
482
|
-
this.activeQueues.add("task");
|
|
483
462
|
}
|
|
484
463
|
}
|
|
485
464
|
async processQueuedTask(contextData, _message) {
|
|
@@ -759,26 +738,6 @@ var MockContext = class MockContext {
|
|
|
759
738
|
getSignedKeyOwner() {
|
|
760
739
|
return Promise.resolve(null);
|
|
761
740
|
}
|
|
762
|
-
#resolveTaskDefinition(task) {
|
|
763
|
-
if (!(this.federation instanceof MockFederation)) throw new TypeError("No task definitions are available.");
|
|
764
|
-
const def = this.federation.taskDefinitions.get(task.name);
|
|
765
|
-
if (def == null || def.handle !== task) throw new TypeError(`Task ${JSON.stringify(task.name)} is not defined on this federation; pass a handle returned by its defineTask().`);
|
|
766
|
-
return def;
|
|
767
|
-
}
|
|
768
|
-
async #validateTaskPayload(def, data) {
|
|
769
|
-
const result = await def.schema["~standard"].validate(data);
|
|
770
|
-
if (result.issues != null && result.issues.length > 0) throw new TypeError(`Task data failed schema validation: ${JSON.stringify(result.issues)}`);
|
|
771
|
-
return result.value;
|
|
772
|
-
}
|
|
773
|
-
async enqueueTask(task, data, _options) {
|
|
774
|
-
const def = this.#resolveTaskDefinition(task);
|
|
775
|
-
await def.handler(this, await this.#validateTaskPayload(def, data));
|
|
776
|
-
}
|
|
777
|
-
async enqueueTaskMany(task, payloads, _options) {
|
|
778
|
-
const def = this.#resolveTaskDefinition(task);
|
|
779
|
-
const values = await Promise.all(payloads.map((data) => this.#validateTaskPayload(def, data)));
|
|
780
|
-
for (const value of values) await def.handler(this, value);
|
|
781
|
-
}
|
|
782
741
|
clone(data) {
|
|
783
742
|
return new MockContext({
|
|
784
743
|
url: this.url,
|
package/dist/mod.js
CHANGED
|
@@ -37,7 +37,7 @@ const noopMeterProvider$1 = { getMeter: () => ({
|
|
|
37
37
|
removeBatchObservableCallback: () => void 0
|
|
38
38
|
}) };
|
|
39
39
|
function createContext(values) {
|
|
40
|
-
const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, meterProvider, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getCollectionUri, getOutboxUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject: lookupObject$1, traverseCollection: traverseCollection$1, lookupNodeInfo, lookupWebFinger, sendActivity, routeActivity
|
|
40
|
+
const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, meterProvider, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getCollectionUri, getOutboxUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject: lookupObject$1, traverseCollection: traverseCollection$1, lookupNodeInfo, lookupWebFinger, sendActivity, routeActivity } = values;
|
|
41
41
|
function throwRouterError() {
|
|
42
42
|
throw new RouterError("Not implemented");
|
|
43
43
|
}
|
|
@@ -97,12 +97,6 @@ function createContext(values) {
|
|
|
97
97
|
}),
|
|
98
98
|
routeActivity: routeActivity ?? ((_params) => {
|
|
99
99
|
throw new Error("Not implemented");
|
|
100
|
-
}),
|
|
101
|
-
enqueueTask: enqueueTask ?? ((_task, _data, _options) => {
|
|
102
|
-
throw new Error("Not implemented");
|
|
103
|
-
}),
|
|
104
|
-
enqueueTaskMany: enqueueTaskMany ?? ((_task, _payloads, _options) => {
|
|
105
|
-
throw new Error("Not implemented");
|
|
106
100
|
})
|
|
107
101
|
};
|
|
108
102
|
}
|
|
@@ -291,7 +285,6 @@ var MockFederation = class {
|
|
|
291
285
|
sharedInboxPath;
|
|
292
286
|
objectPaths = /* @__PURE__ */ new Map();
|
|
293
287
|
objectDispatchers = /* @__PURE__ */ new Map();
|
|
294
|
-
taskDefinitions = /* @__PURE__ */ new Map();
|
|
295
288
|
inboxDispatcher;
|
|
296
289
|
outboxDispatcher;
|
|
297
290
|
outboxAuthorizePredicate;
|
|
@@ -315,19 +308,6 @@ var MockFederation = class {
|
|
|
315
308
|
this.nodeInfoDispatcher = dispatcher;
|
|
316
309
|
this.nodeInfoPath = path;
|
|
317
310
|
}
|
|
318
|
-
defineTask(name, options) {
|
|
319
|
-
if (this.taskDefinitions.has(name)) throw new TypeError(`Task ${JSON.stringify(name)} is already defined.`);
|
|
320
|
-
const handle = {
|
|
321
|
-
name,
|
|
322
|
-
schema: options.schema
|
|
323
|
-
};
|
|
324
|
-
this.taskDefinitions.set(name, {
|
|
325
|
-
name,
|
|
326
|
-
...options,
|
|
327
|
-
handle
|
|
328
|
-
});
|
|
329
|
-
return handle;
|
|
330
|
-
}
|
|
331
311
|
setWebFingerLinksDispatcher(dispatcher) {
|
|
332
312
|
this.webFingerDispatcher = dispatcher;
|
|
333
313
|
}
|
|
@@ -478,7 +458,6 @@ var MockFederation = class {
|
|
|
478
458
|
this.activeQueues.add("inbox");
|
|
479
459
|
this.activeQueues.add("outbox");
|
|
480
460
|
this.activeQueues.add("fanout");
|
|
481
|
-
this.activeQueues.add("task");
|
|
482
461
|
}
|
|
483
462
|
}
|
|
484
463
|
async processQueuedTask(contextData, _message) {
|
|
@@ -758,26 +737,6 @@ var MockContext = class MockContext {
|
|
|
758
737
|
getSignedKeyOwner() {
|
|
759
738
|
return Promise.resolve(null);
|
|
760
739
|
}
|
|
761
|
-
#resolveTaskDefinition(task) {
|
|
762
|
-
if (!(this.federation instanceof MockFederation)) throw new TypeError("No task definitions are available.");
|
|
763
|
-
const def = this.federation.taskDefinitions.get(task.name);
|
|
764
|
-
if (def == null || def.handle !== task) throw new TypeError(`Task ${JSON.stringify(task.name)} is not defined on this federation; pass a handle returned by its defineTask().`);
|
|
765
|
-
return def;
|
|
766
|
-
}
|
|
767
|
-
async #validateTaskPayload(def, data) {
|
|
768
|
-
const result = await def.schema["~standard"].validate(data);
|
|
769
|
-
if (result.issues != null && result.issues.length > 0) throw new TypeError(`Task data failed schema validation: ${JSON.stringify(result.issues)}`);
|
|
770
|
-
return result.value;
|
|
771
|
-
}
|
|
772
|
-
async enqueueTask(task, data, _options) {
|
|
773
|
-
const def = this.#resolveTaskDefinition(task);
|
|
774
|
-
await def.handler(this, await this.#validateTaskPayload(def, data));
|
|
775
|
-
}
|
|
776
|
-
async enqueueTaskMany(task, payloads, _options) {
|
|
777
|
-
const def = this.#resolveTaskDefinition(task);
|
|
778
|
-
const values = await Promise.all(payloads.map((data) => this.#validateTaskPayload(def, data)));
|
|
779
|
-
for (const value of values) await def.handler(this, value);
|
|
780
|
-
}
|
|
781
740
|
clone(data) {
|
|
782
741
|
return new MockContext({
|
|
783
742
|
url: this.url,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/testing",
|
|
3
|
-
"version": "2.3.0-dev.
|
|
3
|
+
"version": "2.3.0-dev.1371+09f768c2",
|
|
4
4
|
"description": "Testing utilities for Fedify applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -50,14 +50,13 @@
|
|
|
50
50
|
"package.json"
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@fedify/fedify": "^2.3.0-dev.
|
|
53
|
+
"@fedify/fedify": "^2.3.0-dev.1371+09f768c2"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"es-toolkit": "1.46.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@js-temporal/polyfill": "^0.5.1",
|
|
60
|
-
"@standard-schema/spec": "^1.1.0",
|
|
61
60
|
"@std/assert": "npm:@jsr/std__assert@^1.0.13",
|
|
62
61
|
"@std/async": "npm:@jsr/std__async@^1.0.13",
|
|
63
62
|
"tsdown": "^0.22.0",
|