@fedify/fedify 1.6.1-dev.851 → 1.6.1-dev.856
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/_virtual/rolldown_runtime.js +26 -1
- package/dist/codegen/schema.js +5 -4
- package/dist/deno.js +15 -2
- package/dist/federation/middleware.test.js +62 -53
- package/dist/federation/send.test.js +8 -10
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/constants.js +1 -7
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/dirname.js +1 -1
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/normalize.js +1 -1
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/dirname.js +1 -32
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/join.js +1 -32
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/mod.js +0 -2
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/_util.js +1 -1
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/dirname.js +2 -2
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/normalize.js +2 -2
- package/dist/node_modules/.pnpm/@jsr_std__url@1.0.0-rc.3/node_modules/@jsr/std__url/dirname.js +1 -1
- package/dist/node_modules/.pnpm/@jsr_std__url@1.0.0-rc.3/node_modules/@jsr/std__url/join.js +1 -1
- package/dist/node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.js +68 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/CallHistory.js +94 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/FetchMock.js +143 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/IsSubsetOf.js +103 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Matchers.js +195 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/RequestUtils.js +83 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Route.js +137 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Router.js +181 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/StatusTextMap.js +73 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/TypeDescriptor.js +97 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/index.js +11 -0
- package/dist/node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js +87 -0
- package/dist/node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.js +37 -0
- package/dist/runtime/authdocloader.test.js +5 -5
- package/dist/runtime/docloader.js +1 -1
- package/dist/runtime/docloader.test.js +8 -0
- package/dist/sig/key.js +7 -2
- package/dist/testing/docloader.js +34 -15
- package/dist/testing/fixtures/example.com/{hong-gildong → hong-gildong.json} +1 -1
- package/dist/testing/fixtures/example.com/{object → object.json} +1 -1
- package/dist/testing/fixtures/example.com/person.js +29 -0
- package/dist/testing/fixtures/example.com/person2.js +48 -0
- package/dist/testing/fixtures/example.com/{test → test.json} +1 -1
- package/dist/testing/fixtures/w3id.org/security/data-integrity/{v1 → v1.json} +1 -1
- package/dist/testing/fixtures/w3id.org/security/{v1 → v1.json} +9 -9
- package/dist/testing/mod.d.ts +11 -0
- package/dist/testing/mod.js +44 -38
- package/dist/vocab/lookup.test.js +30 -35
- package/dist/vocab/vocab.js +176 -176
- package/dist/vocab/vocab.test.js +2 -2
- package/package.json +8 -3
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/_util.js +0 -19
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/dirname.js +0 -75
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/join.js +0 -54
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/normalize.js +0 -87
- /package/dist/testing/fixtures/activitypub.academy/users/{brauca_darradiul → brauca_darradiul.json} +0 -0
- /package/dist/testing/fixtures/example.com/{announce → announce.json} +0 -0
- /package/dist/testing/fixtures/example.com/{collection → collection.json} +0 -0
- /package/dist/testing/fixtures/example.com/{create → create.json} +0 -0
- /package/dist/testing/fixtures/example.com/{cross-origin-actor → cross-origin-actor.json} +0 -0
- /package/dist/testing/fixtures/example.com/{invite → invite.json} +0 -0
- /package/dist/testing/fixtures/example.com/{key → key.json} +0 -0
- /package/dist/testing/fixtures/example.com/{key2 → key2.json} +0 -0
- /package/dist/testing/fixtures/example.com/{orderedcollectionpage → orderedcollectionpage.json} +0 -0
- /package/dist/testing/fixtures/example.com/paged/{a → a.json} +0 -0
- /package/dist/testing/fixtures/example.com/paged/{b → b.json} +0 -0
- /package/dist/testing/fixtures/example.com/{paged-collection → paged-collection.json} +0 -0
- /package/dist/testing/fixtures/example.com/{person → person.json} +0 -0
- /package/dist/testing/fixtures/example.com/{person2 → person2.json} +0 -0
- /package/dist/testing/fixtures/example.com/users/{handle → handle.json} +0 -0
- /package/dist/testing/fixtures/example.com/{wrong-type → wrong-type.json} +0 -0
- /package/dist/testing/fixtures/remote.domain/users/{bob → bob.json} +0 -0
- /package/dist/testing/fixtures/server.example/users/{alice → alice.json} +0 -0
- /package/dist/testing/fixtures/w3id.org/identity/{v1 → v1.json} +0 -0
- /package/dist/testing/fixtures/w3id.org/security/multikey/{v1 → v1.json} +0 -0
- /package/dist/testing/fixtures/wizard.casa/users/{hongminhee → hongminhee.json} +0 -0
- /package/dist/testing/fixtures/www.w3.org/ns/{activitystreams → activitystreams.json} +0 -0
- /package/dist/testing/fixtures/www.w3.org/ns/did/{v1 → v1.json} +0 -0
package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/CallHistory.js
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import { createCallLogFromUrlAndOptions } from "./RequestUtils.js";
|
6
|
+
import { isUrlMatcher } from "./Matchers.js";
|
7
|
+
import { Route_default } from "./Route.js";
|
8
|
+
|
9
|
+
//#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/CallHistory.js
|
10
|
+
const isName = (filter) => typeof filter === "string" && /^[\da-zA-Z-]+$/.test(filter) && !["matched", "unmatched"].includes(filter);
|
11
|
+
const isMatchedOrUnmatched = (filter) => typeof filter === "boolean" || ["matched", "unmatched"].includes(filter);
|
12
|
+
var CallHistory = class {
|
13
|
+
constructor(config, router) {
|
14
|
+
this.callLogs = [];
|
15
|
+
this.config = config;
|
16
|
+
this.router = router;
|
17
|
+
}
|
18
|
+
recordCall(callLog) {
|
19
|
+
this.callLogs.push(callLog);
|
20
|
+
}
|
21
|
+
clear() {
|
22
|
+
this.callLogs.forEach(({ route }) => {
|
23
|
+
if (route) route.reset();
|
24
|
+
});
|
25
|
+
this.callLogs = [];
|
26
|
+
}
|
27
|
+
async flush(waitForResponseMethods) {
|
28
|
+
const queuedPromises = this.callLogs.flatMap((call) => call.pendingPromises);
|
29
|
+
await Promise.allSettled(queuedPromises);
|
30
|
+
if (waitForResponseMethods) {
|
31
|
+
await Promise.resolve();
|
32
|
+
await this.flush();
|
33
|
+
}
|
34
|
+
}
|
35
|
+
calls(filter, options) {
|
36
|
+
let calls = [...this.callLogs];
|
37
|
+
if (typeof filter === "undefined" && !options) return calls;
|
38
|
+
if (isMatchedOrUnmatched(filter)) {
|
39
|
+
if ([true, "matched"].includes(filter)) calls = calls.filter(({ route }) => !route.config.isFallback);
|
40
|
+
else if ([false, "unmatched"].includes(filter)) calls = calls.filter(({ route }) => Boolean(route.config.isFallback));
|
41
|
+
if (!options) return calls;
|
42
|
+
} else if (isName(filter)) {
|
43
|
+
calls = calls.filter(({ route: { config: { name } } }) => name === filter);
|
44
|
+
if (!options) return calls;
|
45
|
+
} else if (isUrlMatcher(filter)) options = {
|
46
|
+
url: filter,
|
47
|
+
...options || {}
|
48
|
+
};
|
49
|
+
else options = {
|
50
|
+
...filter,
|
51
|
+
...options || {}
|
52
|
+
};
|
53
|
+
const { matcher } = new Route_default({
|
54
|
+
response: "ok",
|
55
|
+
...options
|
56
|
+
});
|
57
|
+
calls = calls.filter(({ url, options: options$1 }) => {
|
58
|
+
return matcher(createCallLogFromUrlAndOptions(url, options$1));
|
59
|
+
});
|
60
|
+
return calls;
|
61
|
+
}
|
62
|
+
called(filter, options) {
|
63
|
+
return Boolean(this.calls(filter, options).length);
|
64
|
+
}
|
65
|
+
lastCall(filter, options) {
|
66
|
+
return this.calls(filter, options).pop();
|
67
|
+
}
|
68
|
+
done(routeNames) {
|
69
|
+
let routesToCheck = this.router.routes;
|
70
|
+
if (routeNames) {
|
71
|
+
routeNames = Array.isArray(routeNames) ? routeNames : [routeNames];
|
72
|
+
routesToCheck = this.router.routes.filter(({ config: { name } }) => routeNames.includes(name));
|
73
|
+
}
|
74
|
+
return routesToCheck.map((route) => {
|
75
|
+
const calls = this.callLogs.filter(({ route: routeApplied }) => routeApplied === route);
|
76
|
+
if (!calls.length) {
|
77
|
+
console.warn(`Warning: ${route.config.name} not called`);
|
78
|
+
return false;
|
79
|
+
}
|
80
|
+
const expectedTimes = route.config.repeat;
|
81
|
+
if (!expectedTimes) return true;
|
82
|
+
const actualTimes = calls.length;
|
83
|
+
if (expectedTimes > actualTimes) {
|
84
|
+
console.warn(`Warning: ${route.config.name} only called ${actualTimes} times, but ${expectedTimes} expected`);
|
85
|
+
return false;
|
86
|
+
}
|
87
|
+
return true;
|
88
|
+
}).every((isDone) => isDone);
|
89
|
+
}
|
90
|
+
};
|
91
|
+
var CallHistory_default = CallHistory;
|
92
|
+
|
93
|
+
//#endregion
|
94
|
+
export { CallHistory_default };
|
package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/FetchMock.js
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import { createCallLogFromRequest, createCallLogFromUrlAndOptions } from "./RequestUtils.js";
|
6
|
+
import { Route_default } from "./Route.js";
|
7
|
+
import { Router$2 as Router } from "./Router.js";
|
8
|
+
import { CallHistory_default } from "./CallHistory.js";
|
9
|
+
|
10
|
+
//#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/FetchMock.js
|
11
|
+
const defaultFetchMockConfig = {
|
12
|
+
includeContentLength: true,
|
13
|
+
matchPartialBody: false,
|
14
|
+
Request: globalThis.Request,
|
15
|
+
Response: globalThis.Response,
|
16
|
+
Headers: globalThis.Headers,
|
17
|
+
fetch: globalThis.fetch
|
18
|
+
};
|
19
|
+
const defineShorthand = (shorthandOptions) => {
|
20
|
+
function shorthand(matcher, response, options) {
|
21
|
+
return this.route(matcher, response, Object.assign(options || {}, shorthandOptions));
|
22
|
+
}
|
23
|
+
return shorthand;
|
24
|
+
};
|
25
|
+
const defineGreedyShorthand = (shorthandOptions) => {
|
26
|
+
return function(response, options) {
|
27
|
+
return this.route("*", response, Object.assign(options || {}, shorthandOptions));
|
28
|
+
};
|
29
|
+
};
|
30
|
+
var FetchMock = class FetchMock {
|
31
|
+
constructor(config, router) {
|
32
|
+
this.sticky = defineShorthand({ sticky: true });
|
33
|
+
this.once = defineShorthand({ repeat: 1 });
|
34
|
+
this.any = defineGreedyShorthand({});
|
35
|
+
this.anyOnce = defineGreedyShorthand({ repeat: 1 });
|
36
|
+
this.get = defineShorthand({ method: "get" });
|
37
|
+
this.getOnce = defineShorthand({
|
38
|
+
method: "get",
|
39
|
+
repeat: 1
|
40
|
+
});
|
41
|
+
this.post = defineShorthand({ method: "post" });
|
42
|
+
this.postOnce = defineShorthand({
|
43
|
+
method: "post",
|
44
|
+
repeat: 1
|
45
|
+
});
|
46
|
+
this.put = defineShorthand({ method: "put" });
|
47
|
+
this.putOnce = defineShorthand({
|
48
|
+
method: "put",
|
49
|
+
repeat: 1
|
50
|
+
});
|
51
|
+
this.delete = defineShorthand({ method: "delete" });
|
52
|
+
this.deleteOnce = defineShorthand({
|
53
|
+
method: "delete",
|
54
|
+
repeat: 1
|
55
|
+
});
|
56
|
+
this.head = defineShorthand({ method: "head" });
|
57
|
+
this.headOnce = defineShorthand({
|
58
|
+
method: "head",
|
59
|
+
repeat: 1
|
60
|
+
});
|
61
|
+
this.patch = defineShorthand({ method: "patch" });
|
62
|
+
this.patchOnce = defineShorthand({
|
63
|
+
method: "patch",
|
64
|
+
repeat: 1
|
65
|
+
});
|
66
|
+
this.config = config;
|
67
|
+
this.router = new Router(this.config, {
|
68
|
+
routes: router ? [...router.routes] : [],
|
69
|
+
fallbackRoute: router ? router.fallbackRoute : null
|
70
|
+
});
|
71
|
+
this.callHistory = new CallHistory_default(this.config, this.router);
|
72
|
+
this.fetchHandler = this.fetchHandler.bind(this);
|
73
|
+
Object.assign(this.fetchHandler, { fetchMock: this });
|
74
|
+
}
|
75
|
+
createInstance() {
|
76
|
+
return new FetchMock({ ...this.config }, this.router);
|
77
|
+
}
|
78
|
+
async fetchHandler(requestInput, requestInit) {
|
79
|
+
let callLog;
|
80
|
+
if (requestInput instanceof this.config.Request) callLog = await createCallLogFromRequest(requestInput, requestInit);
|
81
|
+
else callLog = createCallLogFromUrlAndOptions(requestInput, requestInit);
|
82
|
+
this.callHistory.recordCall(callLog);
|
83
|
+
const responsePromise = this.router.execute(callLog);
|
84
|
+
callLog.pendingPromises.push(responsePromise);
|
85
|
+
return responsePromise;
|
86
|
+
}
|
87
|
+
route(matcher, response, options) {
|
88
|
+
this.router.addRoute(matcher, response, options);
|
89
|
+
return this;
|
90
|
+
}
|
91
|
+
catch(response) {
|
92
|
+
this.router.setFallback(response);
|
93
|
+
return this;
|
94
|
+
}
|
95
|
+
defineMatcher(matcher) {
|
96
|
+
Route_default.defineMatcher(matcher);
|
97
|
+
}
|
98
|
+
removeRoutes(options) {
|
99
|
+
this.router.removeRoutes(options);
|
100
|
+
return this;
|
101
|
+
}
|
102
|
+
removeRoute(routeName) {
|
103
|
+
this.router.removeRoutes({ names: [routeName] });
|
104
|
+
return this;
|
105
|
+
}
|
106
|
+
modifyRoute(routeName, options) {
|
107
|
+
this.router.modifyRoute(routeName, options);
|
108
|
+
return this;
|
109
|
+
}
|
110
|
+
clearHistory() {
|
111
|
+
this.callHistory.clear();
|
112
|
+
return this;
|
113
|
+
}
|
114
|
+
mockGlobal() {
|
115
|
+
globalThis.fetch = this.fetchHandler;
|
116
|
+
return this;
|
117
|
+
}
|
118
|
+
unmockGlobal() {
|
119
|
+
globalThis.fetch = this.config.fetch;
|
120
|
+
return this;
|
121
|
+
}
|
122
|
+
hardReset(options) {
|
123
|
+
this.clearHistory();
|
124
|
+
this.removeRoutes(options);
|
125
|
+
this.unmockGlobal();
|
126
|
+
return this;
|
127
|
+
}
|
128
|
+
spy(matcher, name) {
|
129
|
+
const boundFetch = this.config.fetch.bind(globalThis);
|
130
|
+
if (matcher) this.route(matcher, ({ args }) => boundFetch(...args), name);
|
131
|
+
else this.catch(({ args }) => boundFetch(...args));
|
132
|
+
return this;
|
133
|
+
}
|
134
|
+
spyGlobal() {
|
135
|
+
this.mockGlobal();
|
136
|
+
return this.spy();
|
137
|
+
}
|
138
|
+
};
|
139
|
+
const fetchMock = new FetchMock({ ...defaultFetchMockConfig });
|
140
|
+
var FetchMock_default = fetchMock;
|
141
|
+
|
142
|
+
//#endregion
|
143
|
+
export { FetchMock, FetchMock_default, defaultFetchMockConfig };
|
package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/IsSubsetOf.js
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import { TypeDescriptor } from "./TypeDescriptor.js";
|
6
|
+
|
7
|
+
//#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/IsSubsetOf.js
|
8
|
+
const allowedTypes = new Set([
|
9
|
+
"array",
|
10
|
+
"object",
|
11
|
+
"function",
|
12
|
+
"null"
|
13
|
+
]);
|
14
|
+
const isSubsetOf = function(subset, superset, visited = []) {
|
15
|
+
const subsetType = TypeDescriptor.of(subset);
|
16
|
+
const supersetType = TypeDescriptor.of(superset);
|
17
|
+
if (!allowedTypes.has(subsetType)) throw new Error(`Type '${subsetType}' is not supported.`);
|
18
|
+
if (!allowedTypes.has(supersetType)) throw new Error(`Type '${supersetType}' is not supported.`);
|
19
|
+
if (TypeDescriptor.isFunction(subset)) {
|
20
|
+
if (!TypeDescriptor.isFunction(superset)) throw new Error(`Types '${subsetType}' and '${supersetType}' do not match.`);
|
21
|
+
return subset.toString() === superset.toString();
|
22
|
+
}
|
23
|
+
if (TypeDescriptor.isArray(subset)) {
|
24
|
+
if (!TypeDescriptor.isArray(superset)) throw new Error(`Types '${subsetType}' and '${supersetType}' do not match.`);
|
25
|
+
if (subset.length > superset.length) return false;
|
26
|
+
for (const subsetItem of subset) {
|
27
|
+
const subsetItemType = TypeDescriptor.of(subsetItem);
|
28
|
+
let isItemInSuperset;
|
29
|
+
switch (subsetItemType) {
|
30
|
+
case "array":
|
31
|
+
case "object":
|
32
|
+
case "function": {
|
33
|
+
if (visited.includes(subsetItem)) continue;
|
34
|
+
visited.push(subsetItem);
|
35
|
+
isItemInSuperset = superset.some((supersetItem) => {
|
36
|
+
try {
|
37
|
+
return isSubsetOf(subsetItem, supersetItem, visited);
|
38
|
+
} catch {
|
39
|
+
return false;
|
40
|
+
}
|
41
|
+
});
|
42
|
+
break;
|
43
|
+
}
|
44
|
+
default: isItemInSuperset = superset.includes(subsetItem);
|
45
|
+
}
|
46
|
+
if (!isItemInSuperset) return false;
|
47
|
+
}
|
48
|
+
return true;
|
49
|
+
}
|
50
|
+
if (TypeDescriptor.isObject(subset)) {
|
51
|
+
if (!TypeDescriptor.isObject(superset) || TypeDescriptor.isArray(superset)) throw new Error(`Types '${subsetType}' and '${supersetType}' do not match.`);
|
52
|
+
if (Object.keys(subset).length > Object.keys(superset).length) return false;
|
53
|
+
for (const [subsetKey, subsetValue] of Object.entries(subset)) {
|
54
|
+
const supersetValue = superset[subsetKey];
|
55
|
+
const subsetValueType = TypeDescriptor.of(subsetValue);
|
56
|
+
switch (subsetValueType) {
|
57
|
+
case "array":
|
58
|
+
case "object":
|
59
|
+
case "function": {
|
60
|
+
if (visited.includes(subsetValue)) continue;
|
61
|
+
visited.push(subsetValue);
|
62
|
+
try {
|
63
|
+
const isInSuperset = isSubsetOf(subsetValue, supersetValue, visited);
|
64
|
+
if (!isInSuperset) return false;
|
65
|
+
} catch {
|
66
|
+
return false;
|
67
|
+
}
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
default: if (subsetValue !== supersetValue) return false;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
if (TypeDescriptor.isNull(subset)) {
|
76
|
+
if (!TypeDescriptor.isNull(superset)) throw new Error(`Types '${subsetType}' and '${supersetType}' do not match.`);
|
77
|
+
return true;
|
78
|
+
}
|
79
|
+
throw new Error("Invalid operation.");
|
80
|
+
};
|
81
|
+
isSubsetOf.structural = function(subset, superset, visited = []) {
|
82
|
+
if (!TypeDescriptor.isObject(subset)) throw new Error(`Type '${TypeDescriptor.of(subset)}' is not supported.`);
|
83
|
+
if (!TypeDescriptor.isObject(superset)) throw new Error(`Type '${TypeDescriptor.of(superset)}' is not supported.`);
|
84
|
+
for (const [subsetKey, subsetValue] of Object.entries(subset)) {
|
85
|
+
if (superset[subsetKey] === void 0) return false;
|
86
|
+
const subsetValueType = TypeDescriptor.of(subsetValue);
|
87
|
+
const supersetValue = superset[subsetKey];
|
88
|
+
if (subsetValueType === "object") {
|
89
|
+
if (visited.includes(subsetValue)) continue;
|
90
|
+
visited.push(subsetValue);
|
91
|
+
try {
|
92
|
+
const isInSuperset = isSubsetOf.structural(subsetValue, supersetValue, visited);
|
93
|
+
if (!isInSuperset) return false;
|
94
|
+
} catch {
|
95
|
+
return false;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
return true;
|
100
|
+
};
|
101
|
+
|
102
|
+
//#endregion
|
103
|
+
export { isSubsetOf };
|
package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Matchers.js
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import { __toESM } from "../../../../../../../_virtual/rolldown_runtime.js";
|
6
|
+
import { require_glob_to_regexp } from "../../../../../glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js";
|
7
|
+
import { parse$1 as parse } from "../../../../../regexparam@3.0.0/node_modules/regexparam/dist/index.js";
|
8
|
+
import { isSubsetOf } from "./IsSubsetOf.js";
|
9
|
+
import { dequal } from "../../../../../dequal@2.0.3/node_modules/dequal/dist/index.js";
|
10
|
+
import { getPath, normalizeHeaders, normalizeUrl } from "./RequestUtils.js";
|
11
|
+
|
12
|
+
//#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Matchers.js
|
13
|
+
var import_glob_to_regexp = __toESM(require_glob_to_regexp(), 1);
|
14
|
+
const isUrlMatcher = (matcher) => matcher instanceof RegExp || typeof matcher === "string" || typeof matcher === "object" && "href" in matcher;
|
15
|
+
const isFunctionMatcher = (matcher) => typeof matcher === "function";
|
16
|
+
const stringMatchers = {
|
17
|
+
begin: (targetString) => ({ url }) => url.startsWith(targetString),
|
18
|
+
end: (targetString) => ({ url }) => url.endsWith(targetString),
|
19
|
+
include: (targetString) => ({ url }) => url.includes(targetString),
|
20
|
+
glob: (targetString) => {
|
21
|
+
const urlRX = (0, import_glob_to_regexp.default)(targetString);
|
22
|
+
return ({ url }) => urlRX.test(url);
|
23
|
+
},
|
24
|
+
express: (targetString) => {
|
25
|
+
const urlRX = parse(targetString);
|
26
|
+
return (callLog) => {
|
27
|
+
const vals = urlRX.pattern.exec(getPath(callLog.url));
|
28
|
+
if (!vals) {
|
29
|
+
callLog.expressParams = {};
|
30
|
+
return false;
|
31
|
+
}
|
32
|
+
vals.shift();
|
33
|
+
callLog.expressParams = urlRX.keys.reduce((map, paramName, i) => vals[i] ? Object.assign(map, { [paramName]: vals[i] }) : map, {});
|
34
|
+
return true;
|
35
|
+
};
|
36
|
+
},
|
37
|
+
path: (targetString) => {
|
38
|
+
const dotlessTargetString = getPath(targetString);
|
39
|
+
return ({ url }) => {
|
40
|
+
const path = getPath(url);
|
41
|
+
return path === targetString || path === dotlessTargetString;
|
42
|
+
};
|
43
|
+
}
|
44
|
+
};
|
45
|
+
const getHeaderMatcher = ({ headers: expectedHeaders }) => {
|
46
|
+
if (!expectedHeaders) return;
|
47
|
+
const expectation = normalizeHeaders(expectedHeaders);
|
48
|
+
return ({ options: { headers = {} } }) => {
|
49
|
+
const lowerCaseHeaders = normalizeHeaders(headers);
|
50
|
+
return Object.keys(expectation).every((headerName) => lowerCaseHeaders[headerName] === expectation[headerName]);
|
51
|
+
};
|
52
|
+
};
|
53
|
+
const getMissingHeaderMatcher = ({ missingHeaders: expectedMissingHeaders }) => {
|
54
|
+
if (!expectedMissingHeaders) return;
|
55
|
+
const expectation = expectedMissingHeaders.map((header) => header.toLowerCase());
|
56
|
+
return ({ options: { headers = {} } }) => {
|
57
|
+
const lowerCaseHeaders = normalizeHeaders(headers);
|
58
|
+
return expectation.every((headerName) => !(headerName in lowerCaseHeaders));
|
59
|
+
};
|
60
|
+
};
|
61
|
+
const getMethodMatcher = ({ method: expectedMethod }) => {
|
62
|
+
if (!expectedMethod) return;
|
63
|
+
return ({ options: { method } = {} }) => {
|
64
|
+
const actualMethod = method ? method.toLowerCase() : "get";
|
65
|
+
return expectedMethod === actualMethod;
|
66
|
+
};
|
67
|
+
};
|
68
|
+
const getQueryParamsMatcher = ({ query: passedQuery }) => {
|
69
|
+
if (!passedQuery) return;
|
70
|
+
const expectedQuery = new URLSearchParams();
|
71
|
+
for (const [key, value] of Object.entries(passedQuery)) if (Array.isArray(value)) for (const item of value) expectedQuery.append(key, typeof item === "object" || typeof item === "undefined" ? "" : item.toString());
|
72
|
+
else expectedQuery.append(key, typeof value === "object" || typeof value === "undefined" ? "" : value.toString());
|
73
|
+
const keys = Array.from(expectedQuery.keys());
|
74
|
+
return ({ queryParams }) => {
|
75
|
+
return keys.every((key) => {
|
76
|
+
const expectedValues = expectedQuery.getAll(key).sort();
|
77
|
+
const actualValues = queryParams.getAll(key).sort();
|
78
|
+
if (expectedValues.length !== actualValues.length) return false;
|
79
|
+
if (Array.isArray(passedQuery[key])) return expectedValues.every((expected, index) => expected === actualValues[index]);
|
80
|
+
return dequal(actualValues, expectedValues);
|
81
|
+
});
|
82
|
+
};
|
83
|
+
};
|
84
|
+
const getExpressParamsMatcher = ({ params: expectedParams, url }) => {
|
85
|
+
if (!expectedParams) return;
|
86
|
+
if (!(typeof url === "string" && /express:/.test(url))) throw new Error("fetch-mock: matching on params is only possible when using an express: matcher");
|
87
|
+
const expectedKeys = Object.keys(expectedParams);
|
88
|
+
return ({ expressParams = {} }) => {
|
89
|
+
return expectedKeys.every((key) => expressParams[key] === expectedParams[key]);
|
90
|
+
};
|
91
|
+
};
|
92
|
+
const formDataToObject = (formData) => {
|
93
|
+
const fields = [...formData];
|
94
|
+
const result = {};
|
95
|
+
fields.forEach(([key, value]) => {
|
96
|
+
result[key] = result[key] || [];
|
97
|
+
result[key].push(value);
|
98
|
+
});
|
99
|
+
return result;
|
100
|
+
};
|
101
|
+
const getBodyMatcher = (route) => {
|
102
|
+
let { body: expectedBody } = route;
|
103
|
+
let expectedBodyType = "json";
|
104
|
+
if (!expectedBody) return;
|
105
|
+
if (expectedBody instanceof FormData) {
|
106
|
+
expectedBodyType = "formData";
|
107
|
+
expectedBody = formDataToObject(expectedBody);
|
108
|
+
}
|
109
|
+
return ({ options: { body, method = "get" } }) => {
|
110
|
+
if (["get", "head"].includes(method.toLowerCase())) return false;
|
111
|
+
let sentBody;
|
112
|
+
try {
|
113
|
+
if (typeof body === "string") {
|
114
|
+
sentBody = JSON.parse(body);
|
115
|
+
if (expectedBodyType !== "json") return false;
|
116
|
+
}
|
117
|
+
} catch {}
|
118
|
+
if (body instanceof FormData) {
|
119
|
+
if (expectedBodyType !== "formData") return false;
|
120
|
+
sentBody = formDataToObject(body);
|
121
|
+
}
|
122
|
+
return sentBody && (route.matchPartialBody ? isSubsetOf(expectedBody, sentBody) : dequal(expectedBody, sentBody));
|
123
|
+
};
|
124
|
+
};
|
125
|
+
const getFunctionMatcher = ({ matcherFunction }) => matcherFunction;
|
126
|
+
const getRegexpMatcher = (regexp) => ({ url }) => regexp.test(url);
|
127
|
+
const getFullUrlMatcher = (route, matcherUrl, query) => {
|
128
|
+
const expectedUrl = normalizeUrl(matcherUrl, route.allowRelativeUrls);
|
129
|
+
if (route.url === matcherUrl) route.url = expectedUrl;
|
130
|
+
return ({ url }) => {
|
131
|
+
if (query && expectedUrl.indexOf("?")) return getPath(url) === getPath(expectedUrl);
|
132
|
+
return normalizeUrl(url, true) === expectedUrl;
|
133
|
+
};
|
134
|
+
};
|
135
|
+
const getUrlMatcher = (route) => {
|
136
|
+
const { url: matcherUrl, query } = route;
|
137
|
+
if (matcherUrl === "*") return () => true;
|
138
|
+
if (matcherUrl instanceof RegExp) return getRegexpMatcher(matcherUrl);
|
139
|
+
if (matcherUrl instanceof URL) {
|
140
|
+
if (matcherUrl.href) return getFullUrlMatcher(route, matcherUrl.href, query);
|
141
|
+
}
|
142
|
+
if (typeof matcherUrl === "string") {
|
143
|
+
for (const shorthand in stringMatchers) if (matcherUrl.indexOf(`${shorthand}:`) === 0) {
|
144
|
+
const urlFragment = matcherUrl.replace(new RegExp(`^${shorthand}:`), "");
|
145
|
+
return stringMatchers[shorthand](urlFragment);
|
146
|
+
}
|
147
|
+
return getFullUrlMatcher(route, matcherUrl, query);
|
148
|
+
}
|
149
|
+
if (typeof matcherUrl === "object") {
|
150
|
+
const matchers = Object.entries(matcherUrl).map(([key, pattern]) => {
|
151
|
+
if (key === "regexp") return getRegexpMatcher(pattern);
|
152
|
+
else if (key in stringMatchers) return stringMatchers[key](pattern);
|
153
|
+
else throw new Error(`unrecognised url matching pattern: ${key}`);
|
154
|
+
});
|
155
|
+
return (route$1) => matchers.every((matcher) => matcher(route$1));
|
156
|
+
}
|
157
|
+
};
|
158
|
+
const builtInMatchers = [
|
159
|
+
{
|
160
|
+
name: "url",
|
161
|
+
matcher: getUrlMatcher
|
162
|
+
},
|
163
|
+
{
|
164
|
+
name: "query",
|
165
|
+
matcher: getQueryParamsMatcher
|
166
|
+
},
|
167
|
+
{
|
168
|
+
name: "method",
|
169
|
+
matcher: getMethodMatcher
|
170
|
+
},
|
171
|
+
{
|
172
|
+
name: "headers",
|
173
|
+
matcher: getHeaderMatcher
|
174
|
+
},
|
175
|
+
{
|
176
|
+
name: "missingHeaders",
|
177
|
+
matcher: getMissingHeaderMatcher
|
178
|
+
},
|
179
|
+
{
|
180
|
+
name: "params",
|
181
|
+
matcher: getExpressParamsMatcher
|
182
|
+
},
|
183
|
+
{
|
184
|
+
name: "body",
|
185
|
+
matcher: getBodyMatcher,
|
186
|
+
usesBody: true
|
187
|
+
},
|
188
|
+
{
|
189
|
+
name: "matcherFunction",
|
190
|
+
matcher: getFunctionMatcher
|
191
|
+
}
|
192
|
+
];
|
193
|
+
|
194
|
+
//#endregion
|
195
|
+
export { builtInMatchers, isFunctionMatcher, isUrlMatcher };
|
package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/RequestUtils.js
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
//#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/RequestUtils.js
|
6
|
+
const absoluteUrlRX = new RegExp("^[a-z]+://|^data:", "i");
|
7
|
+
const protocolRelativeUrlRX = new RegExp("^//", "i");
|
8
|
+
function hasCredentialsInUrl(url) {
|
9
|
+
const urlObject = new URL(url, !absoluteUrlRX.test(url) ? "http://dummy" : void 0);
|
10
|
+
return Boolean(urlObject.username || urlObject.password);
|
11
|
+
}
|
12
|
+
function normalizeUrl(url, allowRelativeUrls) {
|
13
|
+
if (url instanceof URL) return url.href;
|
14
|
+
const primitiveUrl = String(url).valueOf();
|
15
|
+
if (absoluteUrlRX.test(primitiveUrl)) return new URL(primitiveUrl).href;
|
16
|
+
if (protocolRelativeUrlRX.test(primitiveUrl)) return new URL(primitiveUrl, "http://dummy").href.replace(/^[a-z]+:/, "");
|
17
|
+
if ("location" in globalThis) if (primitiveUrl.startsWith("/")) return `${globalThis.location.origin}${primitiveUrl}`;
|
18
|
+
else return `${globalThis.location.href}/${primitiveUrl}`;
|
19
|
+
else if (allowRelativeUrls) {
|
20
|
+
const urlInstance = new URL(primitiveUrl, "http://dummy");
|
21
|
+
return urlInstance.pathname + urlInstance.search;
|
22
|
+
} else throw new Error("Relative urls are not support by default in node.js tests. Either use a utility such as jsdom to define globalThis.location or set `fetchMock.config.allowRelativeUrls = true`");
|
23
|
+
}
|
24
|
+
function createCallLogFromUrlAndOptions(url, options) {
|
25
|
+
const pendingPromises = [];
|
26
|
+
if (typeof url === "string" || url instanceof String || url instanceof URL) {
|
27
|
+
const normalizedUrl = normalizeUrl(url, true);
|
28
|
+
const derivedOptions = options ? { ...options } : {};
|
29
|
+
if (derivedOptions.headers) derivedOptions.headers = normalizeHeaders(derivedOptions.headers);
|
30
|
+
derivedOptions.method = derivedOptions.method ? derivedOptions.method.toLowerCase() : "get";
|
31
|
+
return {
|
32
|
+
args: [url, options],
|
33
|
+
url: normalizedUrl,
|
34
|
+
queryParams: new URLSearchParams(getQuery(normalizedUrl)),
|
35
|
+
options: derivedOptions,
|
36
|
+
signal: derivedOptions.signal,
|
37
|
+
pendingPromises
|
38
|
+
};
|
39
|
+
}
|
40
|
+
if (typeof url === "object") throw new TypeError("fetch-mock: Unrecognised Request object. Read the Config and Installation sections of the docs");
|
41
|
+
else throw new TypeError("fetch-mock: Invalid arguments passed to fetch");
|
42
|
+
}
|
43
|
+
async function createCallLogFromRequest(request, options) {
|
44
|
+
const pendingPromises = [];
|
45
|
+
const derivedOptions = { method: request.method };
|
46
|
+
try {
|
47
|
+
try {
|
48
|
+
derivedOptions.body = await request.clone().formData();
|
49
|
+
} catch {
|
50
|
+
derivedOptions.body = await request.clone().text();
|
51
|
+
}
|
52
|
+
} catch {}
|
53
|
+
if (request.headers) derivedOptions.headers = normalizeHeaders(request.headers);
|
54
|
+
const url = normalizeUrl(request.url, true);
|
55
|
+
const callLog = {
|
56
|
+
args: [request, options],
|
57
|
+
url,
|
58
|
+
queryParams: new URLSearchParams(getQuery(url)),
|
59
|
+
options: Object.assign(derivedOptions, options || {}),
|
60
|
+
request,
|
61
|
+
signal: options && options.signal || request.signal,
|
62
|
+
pendingPromises
|
63
|
+
};
|
64
|
+
return callLog;
|
65
|
+
}
|
66
|
+
function getPath(url) {
|
67
|
+
const u = absoluteUrlRX.test(url) ? new URL(url) : new URL(url, "http://dummy");
|
68
|
+
return u.pathname;
|
69
|
+
}
|
70
|
+
function getQuery(url) {
|
71
|
+
const u = absoluteUrlRX.test(url) ? new URL(url) : new URL(url, "http://dummy");
|
72
|
+
return u.search ? u.search.substr(1) : "";
|
73
|
+
}
|
74
|
+
function normalizeHeaders(headers) {
|
75
|
+
let entries;
|
76
|
+
if (headers instanceof Headers) entries = [...headers.entries()];
|
77
|
+
else if (Array.isArray(headers)) entries = headers;
|
78
|
+
else entries = Object.entries(headers);
|
79
|
+
return Object.fromEntries(entries.map(([key, val]) => [key.toLowerCase(), String(val).valueOf()]));
|
80
|
+
}
|
81
|
+
|
82
|
+
//#endregion
|
83
|
+
export { createCallLogFromRequest, createCallLogFromUrlAndOptions, getPath, hasCredentialsInUrl, normalizeHeaders, normalizeUrl };
|