@fedify/fedify 1.6.1-dev.851 → 1.6.1-dev.869

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.
Files changed (83) hide show
  1. package/dist/_virtual/rolldown_runtime.js +26 -1
  2. package/dist/codegen/schema.js +5 -4
  3. package/dist/deno.js +15 -2
  4. package/dist/federation/builder.js +12 -12
  5. package/dist/federation/builder.test.js +1 -0
  6. package/dist/federation/inbox.js +6 -1
  7. package/dist/federation/middleware.test.js +62 -53
  8. package/dist/federation/router.d.ts +1 -0
  9. package/dist/federation/router.js +19 -1
  10. package/dist/federation/router.test.js +15 -0
  11. package/dist/federation/send.test.js +8 -10
  12. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/constants.js +1 -7
  13. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/dirname.js +1 -1
  14. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/from_file_url.js +1 -1
  15. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/normalize.js +1 -1
  16. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/dirname.js +1 -32
  17. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/join.js +1 -32
  18. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/mod.js +0 -2
  19. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/_util.js +1 -1
  20. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/dirname.js +2 -2
  21. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/from_file_url.js +1 -1
  22. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/normalize.js +2 -2
  23. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/from_file_url.js +1 -1
  24. package/dist/node_modules/.pnpm/@jsr_std__url@1.0.0-rc.3/node_modules/@jsr/std__url/dirname.js +1 -1
  25. package/dist/node_modules/.pnpm/@jsr_std__url@1.0.0-rc.3/node_modules/@jsr/std__url/join.js +1 -1
  26. package/dist/node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.js +68 -0
  27. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/CallHistory.js +94 -0
  28. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/FetchMock.js +143 -0
  29. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/IsSubsetOf.js +103 -0
  30. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Matchers.js +195 -0
  31. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/RequestUtils.js +83 -0
  32. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Route.js +137 -0
  33. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Router.js +181 -0
  34. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/StatusTextMap.js +73 -0
  35. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/TypeDescriptor.js +97 -0
  36. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/index.js +11 -0
  37. package/dist/node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js +87 -0
  38. package/dist/node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.js +37 -0
  39. package/dist/runtime/authdocloader.test.js +5 -5
  40. package/dist/runtime/docloader.js +1 -1
  41. package/dist/runtime/docloader.test.js +8 -0
  42. package/dist/sig/key.js +7 -2
  43. package/dist/testing/docloader.js +34 -15
  44. package/dist/testing/fixtures/example.com/{hong-gildong → hong-gildong.json} +1 -1
  45. package/dist/testing/fixtures/example.com/{object → object.json} +1 -1
  46. package/dist/testing/fixtures/example.com/person.js +29 -0
  47. package/dist/testing/fixtures/example.com/person2.js +48 -0
  48. package/dist/testing/fixtures/example.com/{test → test.json} +1 -1
  49. package/dist/testing/fixtures/w3id.org/security/data-integrity/{v1 → v1.json} +1 -1
  50. package/dist/testing/fixtures/w3id.org/security/{v1 → v1.json} +9 -9
  51. package/dist/testing/mod.d.ts +11 -0
  52. package/dist/testing/mod.js +44 -38
  53. package/dist/vocab/lookup.test.js +30 -35
  54. package/dist/vocab/vocab.js +176 -176
  55. package/dist/vocab/vocab.test.js +2 -2
  56. package/package.json +8 -3
  57. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/_util.js +0 -19
  58. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/dirname.js +0 -75
  59. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/join.js +0 -54
  60. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/normalize.js +0 -87
  61. /package/dist/testing/fixtures/activitypub.academy/users/{brauca_darradiul → brauca_darradiul.json} +0 -0
  62. /package/dist/testing/fixtures/example.com/{announce → announce.json} +0 -0
  63. /package/dist/testing/fixtures/example.com/{collection → collection.json} +0 -0
  64. /package/dist/testing/fixtures/example.com/{create → create.json} +0 -0
  65. /package/dist/testing/fixtures/example.com/{cross-origin-actor → cross-origin-actor.json} +0 -0
  66. /package/dist/testing/fixtures/example.com/{invite → invite.json} +0 -0
  67. /package/dist/testing/fixtures/example.com/{key → key.json} +0 -0
  68. /package/dist/testing/fixtures/example.com/{key2 → key2.json} +0 -0
  69. /package/dist/testing/fixtures/example.com/{orderedcollectionpage → orderedcollectionpage.json} +0 -0
  70. /package/dist/testing/fixtures/example.com/paged/{a → a.json} +0 -0
  71. /package/dist/testing/fixtures/example.com/paged/{b → b.json} +0 -0
  72. /package/dist/testing/fixtures/example.com/{paged-collection → paged-collection.json} +0 -0
  73. /package/dist/testing/fixtures/example.com/{person → person.json} +0 -0
  74. /package/dist/testing/fixtures/example.com/{person2 → person2.json} +0 -0
  75. /package/dist/testing/fixtures/example.com/users/{handle → handle.json} +0 -0
  76. /package/dist/testing/fixtures/example.com/{wrong-type → wrong-type.json} +0 -0
  77. /package/dist/testing/fixtures/remote.domain/users/{bob → bob.json} +0 -0
  78. /package/dist/testing/fixtures/server.example/users/{alice → alice.json} +0 -0
  79. /package/dist/testing/fixtures/w3id.org/identity/{v1 → v1.json} +0 -0
  80. /package/dist/testing/fixtures/w3id.org/security/multikey/{v1 → v1.json} +0 -0
  81. /package/dist/testing/fixtures/wizard.casa/users/{hongminhee → hongminhee.json} +0 -0
  82. /package/dist/testing/fixtures/www.w3.org/ns/{activitystreams → activitystreams.json} +0 -0
  83. /package/dist/testing/fixtures/www.w3.org/ns/did/{v1 → v1.json} +0 -0
@@ -1,35 +1,4 @@
1
1
 
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import { isWindows } from "./_os.js";
6
- import { join$1 as join } from "./posix/join.js";
7
- import { join$2 as join$1 } from "./windows/join.js";
8
-
9
- //#region node_modules/.pnpm/@jsr+std__path@1.0.9/node_modules/@jsr/std__path/join.js
10
- /**
11
- * Joins a sequence of paths, then normalizes the resulting path.
12
- *
13
- * @example Usage
14
- * ```ts
15
- * import { join } from "@std/path/join";
16
- * import { assertEquals } from "@std/assert";
17
- *
18
- * if (Deno.build.os === "windows") {
19
- * assertEquals(join("C:\\foo", "bar", "baz\\quux", "garply", ".."), "C:\\foo\\bar\\baz\\quux");
20
- * } else {
21
- * assertEquals(join("/foo", "bar", "baz/quux", "garply", ".."), "/foo/bar/baz/quux");
22
- * }
23
- * ```
24
- *
25
- * Note: If you are working with file URLs,
26
- * use the new version of `join` from `@std/path/unstable-join`.
27
- *
28
- * @param paths Paths to be joined and normalized.
29
- * @returns The joined and normalized path.
30
- */ function join$2(...paths) {
31
- return isWindows ? join$1(...paths) : join(...paths);
32
- }
33
-
34
- //#endregion
35
- export { join$2 as join };
4
+
@@ -2,6 +2,4 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { dirname } from "./dirname.js";
6
5
  import { fromFileUrl } from "./from_file_url.js";
7
- import { join } from "./join.js";
@@ -10,4 +10,4 @@ function isPosixPathSeparator(code) {
10
10
  }
11
11
 
12
12
  //#endregion
13
- export { isPosixPathSeparator as isPosixPathSeparator$1 };
13
+ export { isPosixPathSeparator };
@@ -3,8 +3,8 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
5
  import { stripTrailingSeparators } from "../_common/strip_trailing_separators.js";
6
- import { isPosixPathSeparator$1 as isPosixPathSeparator } from "./_util.js";
7
- import { assertArg$1 as assertArg } from "../_common/dirname.js";
6
+ import { isPosixPathSeparator } from "./_util.js";
7
+ import { assertArg } from "../_common/dirname.js";
8
8
 
9
9
  //#region node_modules/.pnpm/@jsr+std__path@1.0.9/node_modules/@jsr/std__path/posix/dirname.js
10
10
  /**
@@ -2,7 +2,7 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { assertArg } from "../_common/from_file_url.js";
5
+ import { assertArg$2 as assertArg } from "../_common/from_file_url.js";
6
6
 
7
7
  //#region node_modules/.pnpm/@jsr+std__path@1.0.9/node_modules/@jsr/std__path/posix/from_file_url.js
8
8
  /**
@@ -2,8 +2,8 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { isPosixPathSeparator$1 as isPosixPathSeparator } from "./_util.js";
6
- import { assertArg$2 as assertArg } from "../_common/normalize.js";
5
+ import { isPosixPathSeparator } from "./_util.js";
6
+ import { assertArg$1 as assertArg } from "../_common/normalize.js";
7
7
  import { normalizeString } from "../_common/normalize_string.js";
8
8
 
9
9
  //#region node_modules/.pnpm/@jsr+std__path@1.0.9/node_modules/@jsr/std__path/posix/normalize.js
@@ -2,7 +2,7 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { assertArg } from "../_common/from_file_url.js";
5
+ import { assertArg$2 as assertArg } from "../_common/from_file_url.js";
6
6
 
7
7
  //#region node_modules/.pnpm/@jsr+std__path@1.0.9/node_modules/@jsr/std__path/windows/from_file_url.js
8
8
  /**
@@ -35,4 +35,4 @@ import { strip } from "./_strip.js";
35
35
  }
36
36
 
37
37
  //#endregion
38
- export { dirname$1 as dirname$3 };
38
+ export { dirname$1 as dirname };
@@ -33,4 +33,4 @@ import { join$1 as join } from "../../../../@jsr_std__path@1.0.9/node_modules/@j
33
33
  }
34
34
 
35
35
  //#endregion
36
- export { join$1 as join$3 };
36
+ export { join$1 as join };
@@ -0,0 +1,68 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ //#region node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.mjs
6
+ var has = Object.prototype.hasOwnProperty;
7
+ function find(iter, tar, key) {
8
+ for (key of iter.keys()) if (dequal(key, tar)) return key;
9
+ }
10
+ function dequal(foo, bar) {
11
+ var ctor, len, tmp;
12
+ if (foo === bar) return true;
13
+ if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
14
+ if (ctor === Date) return foo.getTime() === bar.getTime();
15
+ if (ctor === RegExp) return foo.toString() === bar.toString();
16
+ if (ctor === Array) {
17
+ if ((len = foo.length) === bar.length) while (len-- && dequal(foo[len], bar[len]));
18
+ return len === -1;
19
+ }
20
+ if (ctor === Set) {
21
+ if (foo.size !== bar.size) return false;
22
+ for (len of foo) {
23
+ tmp = len;
24
+ if (tmp && typeof tmp === "object") {
25
+ tmp = find(bar, tmp);
26
+ if (!tmp) return false;
27
+ }
28
+ if (!bar.has(tmp)) return false;
29
+ }
30
+ return true;
31
+ }
32
+ if (ctor === Map) {
33
+ if (foo.size !== bar.size) return false;
34
+ for (len of foo) {
35
+ tmp = len[0];
36
+ if (tmp && typeof tmp === "object") {
37
+ tmp = find(bar, tmp);
38
+ if (!tmp) return false;
39
+ }
40
+ if (!dequal(len[1], bar.get(tmp))) return false;
41
+ }
42
+ return true;
43
+ }
44
+ if (ctor === ArrayBuffer) {
45
+ foo = new Uint8Array(foo);
46
+ bar = new Uint8Array(bar);
47
+ } else if (ctor === DataView) {
48
+ if ((len = foo.byteLength) === bar.byteLength) while (len-- && foo.getInt8(len) === bar.getInt8(len));
49
+ return len === -1;
50
+ }
51
+ if (ArrayBuffer.isView(foo)) {
52
+ if ((len = foo.byteLength) === bar.byteLength) while (len-- && foo[len] === bar[len]);
53
+ return len === -1;
54
+ }
55
+ if (!ctor || typeof foo === "object") {
56
+ len = 0;
57
+ for (ctor in foo) {
58
+ if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
59
+ if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
60
+ }
61
+ return Object.keys(bar).length === len;
62
+ }
63
+ }
64
+ return foo !== foo && bar !== bar;
65
+ }
66
+
67
+ //#endregion
68
+ export { dequal };
@@ -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 };
@@ -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 };
@@ -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 };