@zimic/interceptor 0.19.1-canary.2 → 0.19.1-canary.4

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 (42) hide show
  1. package/dist/{chunk-6PRFBMY7.mjs → chunk-7BR57OM2.mjs} +3 -3
  2. package/dist/chunk-7BR57OM2.mjs.map +1 -0
  3. package/dist/{chunk-3NJLJSD6.js → chunk-QB2A2272.js} +3 -3
  4. package/dist/chunk-QB2A2272.js.map +1 -0
  5. package/dist/cli.js +20 -20
  6. package/dist/cli.js.map +1 -1
  7. package/dist/cli.mjs +4 -4
  8. package/dist/cli.mjs.map +1 -1
  9. package/dist/http.d.ts +268 -479
  10. package/dist/http.js +5 -5
  11. package/dist/http.js.map +1 -1
  12. package/dist/http.mjs +5 -5
  13. package/dist/http.mjs.map +1 -1
  14. package/dist/server.d.ts +14 -15
  15. package/dist/server.js +6 -6
  16. package/dist/server.mjs +1 -1
  17. package/package.json +3 -3
  18. package/src/cli/server/start.ts +1 -1
  19. package/src/cli/server/token/create.ts +1 -1
  20. package/src/http/interceptor/errors/NotRunningHttpInterceptorError.ts +3 -3
  21. package/src/http/interceptor/errors/RequestSavingSafeLimitExceededError.ts +2 -2
  22. package/src/http/interceptor/errors/RunningHttpInterceptorError.ts +3 -3
  23. package/src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts +1 -1
  24. package/src/http/interceptor/factory.ts +1 -9
  25. package/src/http/interceptor/types/options.ts +32 -132
  26. package/src/http/interceptor/types/public.ts +160 -248
  27. package/src/http/interceptor/types/schema.ts +2 -3
  28. package/src/http/interceptorWorker/HttpInterceptorWorker.ts +1 -1
  29. package/src/http/interceptorWorker/errors/UnregisteredBrowserServiceWorkerError.ts +2 -2
  30. package/src/http/requestHandler/errors/DisabledRequestSavingError.ts +2 -2
  31. package/src/http/requestHandler/errors/TimesCheckError.ts +1 -1
  32. package/src/http/requestHandler/types/public.ts +60 -73
  33. package/src/http/requestHandler/types/restrictions.ts +6 -6
  34. package/src/server/errors/InvalidInterceptorTokenError.ts +1 -1
  35. package/src/server/errors/InvalidInterceptorTokenFileError.ts +1 -1
  36. package/src/server/errors/InvalidInterceptorTokenValueError.ts +1 -1
  37. package/src/server/errors/RunningInterceptorServerError.ts +1 -1
  38. package/src/server/factory.ts +3 -3
  39. package/src/server/types/options.ts +2 -3
  40. package/src/server/types/public.ts +8 -8
  41. package/dist/chunk-3NJLJSD6.js.map +0 -1
  42. package/dist/chunk-6PRFBMY7.mjs.map +0 -1
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * An error thrown when the interceptor server is running and some operation requires it to be stopped first.
3
3
  *
4
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptorserver `@zimic/interceptor/server` - API reference}
4
+ * @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `@zimic/interceptor/server` API reference}
5
5
  */
6
6
  declare class RunningInterceptorServerError extends Error {
7
7
  constructor(additionalMessage: string);
@@ -13,10 +13,9 @@ declare class NotRunningInterceptorServerError extends Error {
13
13
  }
14
14
 
15
15
  /**
16
- * The options to create an
17
- * {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server interceptor server}.
16
+ * The options to create an {@link https://zimic.dev/docs/interceptor/cli/server interceptor server}.
18
17
  *
19
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
18
+ * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
20
19
  */
21
20
  interface InterceptorServerOptions {
22
21
  /**
@@ -45,30 +44,30 @@ interface InterceptorServerOptions {
45
44
 
46
45
  /**
47
46
  * A server to intercept and handle requests. It is used in combination with
48
- * {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors remote interceptors}.
47
+ * {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptors}.
49
48
  *
50
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
49
+ * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
51
50
  */
52
51
  interface InterceptorServer {
53
52
  /**
54
53
  * The hostname of the server. It can be reassigned to a new value if the server is not running.
55
54
  *
56
55
  * @throws {RunningInterceptorServerError} When trying to reassign a new hostname with the server still running.
57
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
56
+ * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
58
57
  */
59
58
  hostname: string;
60
59
  /**
61
60
  * The port of the server. It can be reassigned to a new value if the server is not running.
62
61
  *
63
62
  * @throws {RunningInterceptorServerError} When trying to reassign a new port with the server still running.
64
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
63
+ * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
65
64
  */
66
65
  port: number | undefined;
67
66
  /**
68
67
  * Whether to log warnings about unhandled requests to the console.
69
68
  *
70
69
  * @default true
71
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
70
+ * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
72
71
  */
73
72
  logUnhandledRequests: boolean;
74
73
  /**
@@ -83,7 +82,7 @@ interface InterceptorServer {
83
82
  * Whether the server is running.
84
83
  *
85
84
  * @readonly
86
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
85
+ * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
87
86
  */
88
87
  get isRunning(): boolean;
89
88
  /**
@@ -92,13 +91,13 @@ interface InterceptorServer {
92
91
  * The server is automatically stopped if a process exit event is detected, such as SIGINT, SIGTERM, or an uncaught
93
92
  * exception.
94
93
  *
95
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
94
+ * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
96
95
  */
97
96
  start: () => Promise<void>;
98
97
  /**
99
98
  * Stops the server.
100
99
  *
101
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server `zimic-interceptor server` API reference}
100
+ * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
102
101
  */
103
102
  stop: () => Promise<void>;
104
103
  }
@@ -115,12 +114,12 @@ declare const DEFAULT_ACCESS_CONTROL_HEADERS: Readonly<{
115
114
  declare const DEFAULT_PREFLIGHT_STATUS_CODE = 204;
116
115
 
117
116
  /**
118
- * Creates an {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server interceptor server}.
117
+ * Creates an {@link https://zimic.dev/docs/interceptor/cli/server interceptor server}.
119
118
  *
120
119
  * @param options The options to create the server.
121
120
  * @returns The created server.
122
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server-programmatic-usage `zimic-interceptor server` programmatic usage}
123
- * @see {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors Remote HTTP Interceptors} .
121
+ * @see {@link https://zimic.dev/docs/interceptor/cli/server-programmatic-usage `zimic-interceptor server` programmatic usage}
122
+ * @see {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors Remote HTTP Interceptors} .
124
123
  */
125
124
  declare function createInterceptorServer(options?: InterceptorServerOptions): InterceptorServer;
126
125
 
package/dist/server.js CHANGED
@@ -1,29 +1,29 @@
1
1
  'use strict';
2
2
 
3
- var chunk3NJLJSD6_js = require('./chunk-3NJLJSD6.js');
3
+ var chunkQB2A2272_js = require('./chunk-QB2A2272.js');
4
4
  require('./chunk-WCQVDF3K.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "DEFAULT_ACCESS_CONTROL_HEADERS", {
9
9
  enumerable: true,
10
- get: function () { return chunk3NJLJSD6_js.DEFAULT_ACCESS_CONTROL_HEADERS; }
10
+ get: function () { return chunkQB2A2272_js.DEFAULT_ACCESS_CONTROL_HEADERS; }
11
11
  });
12
12
  Object.defineProperty(exports, "DEFAULT_PREFLIGHT_STATUS_CODE", {
13
13
  enumerable: true,
14
- get: function () { return chunk3NJLJSD6_js.DEFAULT_PREFLIGHT_STATUS_CODE; }
14
+ get: function () { return chunkQB2A2272_js.DEFAULT_PREFLIGHT_STATUS_CODE; }
15
15
  });
16
16
  Object.defineProperty(exports, "NotRunningInterceptorServerError", {
17
17
  enumerable: true,
18
- get: function () { return chunk3NJLJSD6_js.NotRunningInterceptorServerError_default; }
18
+ get: function () { return chunkQB2A2272_js.NotRunningInterceptorServerError_default; }
19
19
  });
20
20
  Object.defineProperty(exports, "RunningInterceptorServerError", {
21
21
  enumerable: true,
22
- get: function () { return chunk3NJLJSD6_js.RunningInterceptorServerError_default; }
22
+ get: function () { return chunkQB2A2272_js.RunningInterceptorServerError_default; }
23
23
  });
24
24
  Object.defineProperty(exports, "createInterceptorServer", {
25
25
  enumerable: true,
26
- get: function () { return chunk3NJLJSD6_js.createInterceptorServer; }
26
+ get: function () { return chunkQB2A2272_js.createInterceptorServer; }
27
27
  });
28
28
  //# sourceMappingURL=server.js.map
29
29
  //# sourceMappingURL=server.js.map
package/dist/server.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { DEFAULT_ACCESS_CONTROL_HEADERS, DEFAULT_PREFLIGHT_STATUS_CODE, NotRunningInterceptorServerError_default as NotRunningInterceptorServerError, RunningInterceptorServerError_default as RunningInterceptorServerError, createInterceptorServer } from './chunk-6PRFBMY7.mjs';
1
+ export { DEFAULT_ACCESS_CONTROL_HEADERS, DEFAULT_PREFLIGHT_STATUS_CODE, NotRunningInterceptorServerError_default as NotRunningInterceptorServerError, RunningInterceptorServerError_default as RunningInterceptorServerError, createInterceptorServer } from './chunk-7BR57OM2.mjs';
2
2
  import './chunk-CGILA3WO.mjs';
3
3
  //# sourceMappingURL=server.mjs.map
4
4
  //# sourceMappingURL=server.mjs.map
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "api",
15
15
  "static"
16
16
  ],
17
- "version": "0.19.1-canary.2",
17
+ "version": "0.19.1-canary.4",
18
18
  "repository": {
19
19
  "type": "git",
20
20
  "url": "https://github.com/zimicjs/zimic.git",
@@ -100,9 +100,9 @@
100
100
  "typescript": "^5.8.3",
101
101
  "vitest": "^3.2.1",
102
102
  "@zimic/eslint-config-node": "0.0.0",
103
+ "@zimic/tsconfig": "0.0.0",
103
104
  "@zimic/lint-staged-config": "0.0.0",
104
- "@zimic/utils": "0.0.0",
105
- "@zimic/tsconfig": "0.0.0"
105
+ "@zimic/utils": "0.0.0"
106
106
  },
107
107
  "peerDependencies": {
108
108
  "typescript": ">=5.0.0",
@@ -71,7 +71,7 @@ async function startInterceptorServer({
71
71
  [
72
72
  `Attention: this interceptor server is ${color.bold(color.red('unprotected'))}. Do not expose it publicly without authentication.`,
73
73
  '',
74
- 'Learn more: https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#authentication',
74
+ 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',
75
75
  ].join('\n'),
76
76
  );
77
77
  }
@@ -27,7 +27,7 @@ export async function createInterceptorServerToken({
27
27
  '',
28
28
  `${color.dim('$')} zimic-interceptor server start ${color.cyan('--tokens-dir')} ${color.magenta(tokensDirectory)}`,
29
29
  '',
30
- 'Learn more: https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#authentication',
30
+ 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',
31
31
  ].join('\n'),
32
32
  );
33
33
  }
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * An error thrown when the interceptor is not running and it's not possible to use the mocking utilities.
3
3
  *
4
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorstart `interceptor.start()` API reference}
5
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorstop `interceptor.stop()` API reference}
6
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorisrunning `interceptor.isRunning` API reference}
4
+ * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstart `interceptor.start()` API reference}
5
+ * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstop `interceptor.stop()` API reference}
6
+ * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorisrunning `interceptor.isRunning` API reference}
7
7
  */
8
8
  class NotRunningHttpInterceptorError extends Error {
9
9
  constructor() {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Error thrown when the safe limit of saved intercepted requests is exceeded.
3
3
  *
4
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#saving-requests Saving intercepted requests}
4
+ * @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor` API reference}
5
5
  */
6
6
  class RequestSavingSafeLimitExceededError extends TypeError {
7
7
  constructor(numberOfSavedRequests: number, safeLimit: number) {
@@ -13,7 +13,7 @@ class RequestSavingSafeLimitExceededError extends TypeError {
13
13
  'requests in memory can lead to performance issues.\n\n' +
14
14
  'If you do not need to save requests, consider setting `requestSaving.enabled: false` in your ' +
15
15
  'interceptor.\n\n' +
16
- 'Learn more: https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#saving-requests',
16
+ 'Learn more: https://zimic.dev/docs/interceptor/api/create-http-interceptor',
17
17
  );
18
18
  this.name = 'RequestSavingSafeLimitExceededError';
19
19
  }
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * An error thrown when the interceptor is running and some operation requires it to be stopped first.
3
3
  *
4
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorstart `interceptor.start()` API reference}
5
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorstop `interceptor.stop()` API reference}
6
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorisrunning `interceptor.isRunning` API reference}
4
+ * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstart `interceptor.start()` API reference}
5
+ * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstop `interceptor.stop()` API reference}
6
+ * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorisrunning `interceptor.isRunning` API reference}
7
7
  */
8
8
  class RunningHttpInterceptorError extends Error {
9
9
  constructor(additionalMessage: string) {
@@ -2,7 +2,7 @@
2
2
  * An error thrown when an unknown interceptor platform is detected. Currently, the platforms `node` and `browser` are
3
3
  * supported.
4
4
  *
5
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorplatform `interceptor.platform` API reference}
5
+ * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorplatform `interceptor.platform` API reference}
6
6
  */
7
7
  class UnknownHttpInterceptorPlatformError extends Error {
8
8
  /* istanbul ignore next -- @preserve
@@ -17,15 +17,7 @@ function isRemoteHttpInterceptorOptions(options: HttpInterceptorOptions): option
17
17
  return options.type === 'remote';
18
18
  }
19
19
 
20
- /**
21
- * Creates an HTTP interceptor.
22
- *
23
- * @param options The options for the interceptor.
24
- * @returns The created HTTP interceptor.
25
- * @throws {InvalidURLError} If the base URL is invalid.
26
- * @throws {UnsupportedURLProtocolError} If the base URL protocol is not either `http` or `https`.
27
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#createhttpinterceptoroptions `createHttpInterceptor(options)` API reference}
28
- */
20
+ /** @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor()` API reference} */
29
21
  export function createHttpInterceptor<Schema extends HttpSchema>(
30
22
  options: LocalHttpInterceptorOptions,
31
23
  ): PublicLocalHttpInterceptor<Schema>;
@@ -3,192 +3,92 @@ import { PossiblePromise } from '@zimic/utils/types';
3
3
  import { HttpInterceptorRequestSaving } from './public';
4
4
  import { UnhandledHttpInterceptorRequest } from './requests';
5
5
 
6
- /**
7
- * An type of an HTTP interceptor.
8
- *
9
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#httpinterceptor `HttpInterceptor` API reference}
10
- */
6
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptortype `interceptor.type` API reference} */
11
7
  export type HttpInterceptorType = 'local' | 'remote';
12
8
 
13
- /**
14
- * The platform where an HTTP interceptor is running.
15
- *
16
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#http-interceptorplatform `interceptor.platform` API reference}
17
- */
9
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorplatform `interceptor.platform` API reference} */
18
10
  export type HttpInterceptorPlatform = 'node' | 'browser';
19
11
 
20
- /**
21
- * The strategy to treat unhandled requests.
22
- *
23
- * When `log` is `true` or `undefined`, warnings about unhandled requests are logged to the console. If provided a
24
- * factory, unhandled request warnings will be logged if the function returns a
25
- * {@link UnhandledRequestStrategy.Declaration strategy declaration} containing `log` as `true` or `undefined`.
26
- *
27
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
28
- */
12
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
29
13
  export namespace UnhandledRequestStrategy {
30
- /**
31
- * The action to take when an unhandled request is intercepted.
32
- *
33
- * In a {@link https://github.com/zimicjs/zimic/wiki/getting‐started#local-http-interceptors local interceptor}, the
34
- * action is always `bypass`, meaning that unhandled requests pass through the interceptor and reach the real network.
35
- * {@link https://github.com/zimicjs/zimic/wiki/getting‐started#local-http-interceptors Remote interceptors} always use
36
- * `reject`, since unhandled requests that react an
37
- * {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server interceptor server} cannot be bypassed.
38
- *
39
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
40
- */
14
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
41
15
  export type Action = 'bypass' | 'reject';
42
16
 
43
- /**
44
- * A static declaration of the strategy to use for unhandled requests.
45
- *
46
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
47
- */
17
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
48
18
  export interface Declaration<DeclarationAction extends Action = Action> {
49
- /** The action to take when an unhandled request is intercepted. */
19
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
50
20
  action: DeclarationAction;
51
21
 
52
- /**
53
- * Whether to log unhandled requests to the console.
54
- *
55
- * @default true
56
- */
22
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
57
23
  log?: boolean;
58
24
  }
59
25
 
60
- /**
61
- * A factory to create dynamic unhandled request strategies based on the intercepted request.
62
- *
63
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
64
- */
26
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
65
27
  export type DeclarationFactory<DeclarationAction extends Action = Action> = (
66
28
  request: UnhandledHttpInterceptorRequest,
67
29
  ) => PossiblePromise<Declaration<DeclarationAction>>;
68
30
 
69
- /**
70
- * A static declaration of the strategy to use for unhandled requests in local interceptors.
71
- *
72
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
73
- */
31
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
74
32
  export type LocalDeclaration = Declaration;
75
33
 
76
- /**
77
- * A factory to create dynamic unhandled request strategies based on the intercepted request in local interceptors.
78
- *
79
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
80
- */
34
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
81
35
  export type LocalDeclarationFactory = DeclarationFactory;
82
36
 
83
- /**
84
- * A static declaration of the strategy to use for unhandled requests in remote interceptors.
85
- *
86
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
87
- */
37
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
88
38
  export type RemoteDeclaration = Declaration<'reject'>;
89
39
 
90
- /**
91
- * A factory to create dynamic unhandled request strategies based on the intercepted request in remote interceptors.
92
- *
93
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
94
- */
40
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
95
41
  export type RemoteDeclarationFactory = DeclarationFactory<'reject'>;
96
42
 
97
- /** The static declaration or a factory of the strategy to use for unhandled requests in local interceptors. */
43
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
98
44
  export type Local = LocalDeclaration | LocalDeclarationFactory;
99
45
 
100
- /** The static declaration or a factory of the strategy to use for unhandled requests in remote interceptors. */
46
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
101
47
  export type Remote = RemoteDeclaration | RemoteDeclarationFactory;
102
48
  }
103
49
 
104
50
  export type UnhandledRequestStrategy = UnhandledRequestStrategy.Local | UnhandledRequestStrategy.Remote;
105
51
 
106
52
  export interface SharedHttpInterceptorOptions {
107
- /**
108
- * The type of the HTTP interceptor.
109
- *
110
- * @default 'local'
111
- */
53
+ /** @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor()` API reference} */
112
54
  type?: HttpInterceptorType;
113
55
 
114
- /**
115
- * Represents the URL that should be matched by the interceptor. Any request starting with this base URL will be
116
- * intercepted if a matching
117
- * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#httprequesthandler handler} exists.
118
- *
119
- * For {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors remote interceptors}, this
120
- * base URL should point to an
121
- * {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server interceptor server}. It may include
122
- * additional paths to differentiate between conflicting mocks.
123
- */
56
+ /** @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor()` API reference} */
124
57
  baseURL: string;
125
58
 
126
- /**
127
- * Configures if the intercepted requests are saved and how they are handled.
128
- *
129
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#saving-requests Saving intercepted requests}
130
- * @see {@link https://github.com/zimicjs/zimic/wiki/guides‐testing‐interceptor Testing}
131
- */
59
+ /** @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor()` API reference} */
132
60
  requestSaving?: Partial<HttpInterceptorRequestSaving>;
133
61
  }
134
62
 
135
63
  /**
136
- * The options to create a
137
- * {@link https://github.com/zimicjs/zimic/wiki/getting‐started#local-http-interceptors local HTTP interceptor}.
138
- *
139
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#creating-a-local-http-interceptor Creating a local HTTP interceptor}
64
+ * @see {@link https://zimic.dev/docs/interceptor/guides/http/local-interceptors#creating-a-local-http-interceptor Creating a local HTTP interceptor}
65
+ * @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor()` API reference}
140
66
  */
141
67
  export interface LocalHttpInterceptorOptions extends SharedHttpInterceptorOptions {
142
68
  type?: 'local';
143
69
 
144
- /**
145
- * The strategy to use for unhandled requests. If a request starts with the base URL of the interceptor, but no
146
- * matching handler exists, this strategy will be used. If a function is provided, it will be called with the
147
- * unhandled request.
148
- *
149
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
150
- */
70
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
151
71
  onUnhandledRequest?: UnhandledRequestStrategy.Local;
152
72
  }
153
73
 
74
+ interface HttpInterceptorAuthOptions {
75
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication Interceptor server authentication} */
76
+ token: string;
77
+ }
78
+
154
79
  /**
155
- * The options to create a
156
- * {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors remote HTTP interceptor}.
157
- *
158
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#creating-a-remote-http-interceptor Creating a remote HTTP interceptor}
80
+ * @see {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#creating-a-remote-http-interceptor Creating a remote HTTP interceptor}
81
+ * @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor()` API reference}
159
82
  */
160
83
  export interface RemoteHttpInterceptorOptions extends SharedHttpInterceptorOptions {
161
84
  type: 'remote';
162
85
 
163
- /**
164
- * Options to authenticate the interceptor when connecting to an interceptor server. This is required if the
165
- * interceptor server was started with the `--tokens-dir` option.
166
- *
167
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#authentication Interceptor server authentication}
168
- */
169
- auth?: {
170
- /**
171
- * The authentication token to use.
172
- *
173
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#authentication Interceptor server authentication}
174
- */
175
- token: string;
176
- };
177
-
178
- /**
179
- * The strategy to use for unhandled requests. If a request starts with the base URL of the interceptor, but no
180
- * matching handler exists, this strategy will be used. If a function is provided, it will be called with the
181
- * unhandled request.
182
- *
183
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
184
- */
86
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication Interceptor server authentication} */
87
+ auth?: HttpInterceptorAuthOptions;
88
+
89
+ /** @see {@link https://zimic.dev/docs/interceptor/guides/http/unhandled-requests Unhandled requests} */
185
90
  onUnhandledRequest?: UnhandledRequestStrategy.Remote;
186
91
  }
187
92
 
188
- /**
189
- * The options to create an
190
- * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#httpinterceptor HTTP interceptor}.
191
- *
192
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#createhttpinterceptoroptions `createHttpInterceptor(options)` API reference}
193
- */
93
+ /** @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor()` API reference} */
194
94
  export type HttpInterceptorOptions = LocalHttpInterceptorOptions | RemoteHttpInterceptorOptions;