@fedify/testing 2.5.0-dev.2609 → 2.5.0-dev.2618
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/README.md +6 -0
- package/dist/mod.cjs +7 -1
- package/dist/mod.d.cts +3 -0
- package/dist/mod.d.ts +3 -0
- package/dist/mod.js +7 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -87,6 +87,12 @@ const sent = context.getSentActivities();
|
|
|
87
87
|
console.log(sent[0].activity);
|
|
88
88
|
~~~~
|
|
89
89
|
|
|
90
|
+
Both `context.getSentActivities()` and `federation.sentActivities` retain the
|
|
91
|
+
optional `dispatchId` supplied to `sendActivity()`. Reusing a dispatch ID
|
|
92
|
+
records another send, so tests can check correlation across application-managed
|
|
93
|
+
retries. Mock federations also accept `setOutboundObservers()` registration,
|
|
94
|
+
but mock sends do not invoke those callbacks.
|
|
95
|
+
|
|
90
96
|
### Helper functions
|
|
91
97
|
|
|
92
98
|
The package also exports helper functions for creating various context types:
|
package/dist/mod.cjs
CHANGED
|
@@ -571,6 +571,7 @@ var MockFederation = class {
|
|
|
571
571
|
};
|
|
572
572
|
return setters;
|
|
573
573
|
}
|
|
574
|
+
setOutboundObservers(_observers) {}
|
|
574
575
|
setInboxListeners(inboxPath, sharedInboxPath) {
|
|
575
576
|
this.inboxPath = inboxPath;
|
|
576
577
|
this.sharedInboxPath = sharedInboxPath;
|
|
@@ -1229,11 +1230,15 @@ var MockContext = class MockContext {
|
|
|
1229
1230
|
return Promise.resolve(null);
|
|
1230
1231
|
}
|
|
1231
1232
|
sendActivity(sender, recipients, activity, options) {
|
|
1233
|
+
const dispatchId = options?.dispatchId;
|
|
1234
|
+
if (dispatchId !== void 0 && typeof dispatchId !== "string") return Promise.reject(/* @__PURE__ */ new TypeError("dispatchId must be a string."));
|
|
1235
|
+
if (dispatchId !== void 0 && (dispatchId.length > 1024 || new TextEncoder().encode(dispatchId).byteLength > 1024)) return Promise.reject(/* @__PURE__ */ new RangeError("dispatchId must not exceed 1,024 UTF-8 bytes."));
|
|
1232
1236
|
this.sentActivities.push({
|
|
1233
1237
|
sender,
|
|
1234
1238
|
recipients,
|
|
1235
1239
|
activity,
|
|
1236
|
-
rawActivity: options?.rawActivity
|
|
1240
|
+
rawActivity: options?.rawActivity,
|
|
1241
|
+
...dispatchId === void 0 ? {} : { dispatchId }
|
|
1237
1242
|
});
|
|
1238
1243
|
if (this.federation instanceof MockFederation) {
|
|
1239
1244
|
const queued = this.federation.queueStarted;
|
|
@@ -1242,6 +1247,7 @@ var MockContext = class MockContext {
|
|
|
1242
1247
|
queue: queued ? "outbox" : void 0,
|
|
1243
1248
|
activity,
|
|
1244
1249
|
rawActivity: options?.rawActivity,
|
|
1250
|
+
...dispatchId === void 0 ? {} : { dispatchId },
|
|
1245
1251
|
sentOrder: ++this.federation.sentCounter
|
|
1246
1252
|
});
|
|
1247
1253
|
}
|
package/dist/mod.d.cts
CHANGED
|
@@ -79,6 +79,8 @@ interface SentActivity {
|
|
|
79
79
|
activity: Activity;
|
|
80
80
|
/** The raw forwarded payload, if preserved by the caller. */
|
|
81
81
|
rawActivity?: unknown;
|
|
82
|
+
/** Application-provided correlation identifier, if present. */
|
|
83
|
+
dispatchId?: string;
|
|
82
84
|
/** The order in which the activity was sent (auto-incrementing counter). */
|
|
83
85
|
sentOrder: number;
|
|
84
86
|
}
|
|
@@ -94,6 +96,7 @@ interface TestContext<TContextData> extends Omit<Context<TContextData>, "clone">
|
|
|
94
96
|
recipients: any;
|
|
95
97
|
activity: Activity;
|
|
96
98
|
rawActivity?: unknown;
|
|
99
|
+
dispatchId?: string;
|
|
97
100
|
}>;
|
|
98
101
|
reset(): void;
|
|
99
102
|
}
|
package/dist/mod.d.ts
CHANGED
|
@@ -79,6 +79,8 @@ interface SentActivity {
|
|
|
79
79
|
activity: Activity;
|
|
80
80
|
/** The raw forwarded payload, if preserved by the caller. */
|
|
81
81
|
rawActivity?: unknown;
|
|
82
|
+
/** Application-provided correlation identifier, if present. */
|
|
83
|
+
dispatchId?: string;
|
|
82
84
|
/** The order in which the activity was sent (auto-incrementing counter). */
|
|
83
85
|
sentOrder: number;
|
|
84
86
|
}
|
|
@@ -94,6 +96,7 @@ interface TestContext<TContextData> extends Omit<Context<TContextData>, "clone">
|
|
|
94
96
|
recipients: any;
|
|
95
97
|
activity: Activity;
|
|
96
98
|
rawActivity?: unknown;
|
|
99
|
+
dispatchId?: string;
|
|
97
100
|
}>;
|
|
98
101
|
reset(): void;
|
|
99
102
|
}
|
package/dist/mod.js
CHANGED
|
@@ -570,6 +570,7 @@ var MockFederation = class {
|
|
|
570
570
|
};
|
|
571
571
|
return setters;
|
|
572
572
|
}
|
|
573
|
+
setOutboundObservers(_observers) {}
|
|
573
574
|
setInboxListeners(inboxPath, sharedInboxPath) {
|
|
574
575
|
this.inboxPath = inboxPath;
|
|
575
576
|
this.sharedInboxPath = sharedInboxPath;
|
|
@@ -1228,11 +1229,15 @@ var MockContext = class MockContext {
|
|
|
1228
1229
|
return Promise.resolve(null);
|
|
1229
1230
|
}
|
|
1230
1231
|
sendActivity(sender, recipients, activity, options) {
|
|
1232
|
+
const dispatchId = options?.dispatchId;
|
|
1233
|
+
if (dispatchId !== void 0 && typeof dispatchId !== "string") return Promise.reject(/* @__PURE__ */ new TypeError("dispatchId must be a string."));
|
|
1234
|
+
if (dispatchId !== void 0 && (dispatchId.length > 1024 || new TextEncoder().encode(dispatchId).byteLength > 1024)) return Promise.reject(/* @__PURE__ */ new RangeError("dispatchId must not exceed 1,024 UTF-8 bytes."));
|
|
1231
1235
|
this.sentActivities.push({
|
|
1232
1236
|
sender,
|
|
1233
1237
|
recipients,
|
|
1234
1238
|
activity,
|
|
1235
|
-
rawActivity: options?.rawActivity
|
|
1239
|
+
rawActivity: options?.rawActivity,
|
|
1240
|
+
...dispatchId === void 0 ? {} : { dispatchId }
|
|
1236
1241
|
});
|
|
1237
1242
|
if (this.federation instanceof MockFederation) {
|
|
1238
1243
|
const queued = this.federation.queueStarted;
|
|
@@ -1241,6 +1246,7 @@ var MockContext = class MockContext {
|
|
|
1241
1246
|
queue: queued ? "outbox" : void 0,
|
|
1242
1247
|
activity,
|
|
1243
1248
|
rawActivity: options?.rawActivity,
|
|
1249
|
+
...dispatchId === void 0 ? {} : { dispatchId },
|
|
1244
1250
|
sentOrder: ++this.federation.sentCounter
|
|
1245
1251
|
});
|
|
1246
1252
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/testing",
|
|
3
|
-
"version": "2.5.0-dev.
|
|
3
|
+
"version": "2.5.0-dev.2618+6a7cb6bb",
|
|
4
4
|
"description": "Testing utilities for Fedify applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"package.json"
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@fedify/fedify": "^2.5.0-dev.
|
|
50
|
+
"@fedify/fedify": "^2.5.0-dev.2618+6a7cb6bb"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@opentelemetry/api": "~1.9.1",
|
|
54
54
|
"es-toolkit": "1.46.1",
|
|
55
55
|
"temporal-polyfill": "^1.0.1",
|
|
56
|
-
"@fedify/vocab": "2.5.0-dev.
|
|
57
|
-
"@fedify/vocab-runtime": "^2.5.0-dev.
|
|
56
|
+
"@fedify/vocab": "2.5.0-dev.2618+6a7cb6bb",
|
|
57
|
+
"@fedify/vocab-runtime": "^2.5.0-dev.2618+6a7cb6bb"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@standard-schema/spec": "^1.1.0",
|