@zimic/interceptor 1.2.4-canary.0 → 1.2.4-canary.2

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/server.js CHANGED
@@ -1,29 +1,29 @@
1
1
  'use strict';
2
2
 
3
- var chunkIPL73BDI_js = require('./chunk-IPL73BDI.js');
3
+ var chunkMYIYYX4K_js = require('./chunk-MYIYYX4K.js');
4
4
  require('./chunk-DGUM43GV.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "DEFAULT_ACCESS_CONTROL_HEADERS", {
9
9
  enumerable: true,
10
- get: function () { return chunkIPL73BDI_js.DEFAULT_ACCESS_CONTROL_HEADERS; }
10
+ get: function () { return chunkMYIYYX4K_js.DEFAULT_ACCESS_CONTROL_HEADERS; }
11
11
  });
12
12
  Object.defineProperty(exports, "DEFAULT_PREFLIGHT_STATUS_CODE", {
13
13
  enumerable: true,
14
- get: function () { return chunkIPL73BDI_js.DEFAULT_PREFLIGHT_STATUS_CODE; }
14
+ get: function () { return chunkMYIYYX4K_js.DEFAULT_PREFLIGHT_STATUS_CODE; }
15
15
  });
16
16
  Object.defineProperty(exports, "NotRunningInterceptorServerError", {
17
17
  enumerable: true,
18
- get: function () { return chunkIPL73BDI_js.NotRunningInterceptorServerError_default; }
18
+ get: function () { return chunkMYIYYX4K_js.NotRunningInterceptorServerError_default; }
19
19
  });
20
20
  Object.defineProperty(exports, "RunningInterceptorServerError", {
21
21
  enumerable: true,
22
- get: function () { return chunkIPL73BDI_js.RunningInterceptorServerError_default; }
22
+ get: function () { return chunkMYIYYX4K_js.RunningInterceptorServerError_default; }
23
23
  });
24
24
  Object.defineProperty(exports, "createInterceptorServer", {
25
25
  enumerable: true,
26
- get: function () { return chunkIPL73BDI_js.createInterceptorServer; }
26
+ get: function () { return chunkMYIYYX4K_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-OTZ5Z633.mjs';
1
+ export { DEFAULT_ACCESS_CONTROL_HEADERS, DEFAULT_PREFLIGHT_STATUS_CODE, NotRunningInterceptorServerError_default as NotRunningInterceptorServerError, RunningInterceptorServerError_default as RunningInterceptorServerError, createInterceptorServer } from './chunk-YSPTSRWX.mjs';
2
2
  import './chunk-BJTO5JO5.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": "1.2.4-canary.0",
17
+ "version": "1.2.4-canary.2",
18
18
  "homepage": "https://zimic.dev/docs/interceptor",
19
19
  "repository": {
20
20
  "type": "git",
@@ -96,21 +96,21 @@
96
96
  },
97
97
  "dependencies": {
98
98
  "@whatwg-node/server": "0.10.17",
99
- "execa": "9.6.0",
99
+ "execa": "9.6.1",
100
100
  "isomorphic-ws": "5.0.0",
101
101
  "msw": "2.11.1",
102
102
  "picocolors": "^1.1.1",
103
103
  "ws": "8.18.3",
104
104
  "yargs": "18.0.0",
105
- "zod": "^4.1.12"
105
+ "zod": "^4.1.13"
106
106
  },
107
107
  "devDependencies": {
108
108
  "@types/node": "^24.10.1",
109
109
  "@types/ws": "^8.18.1",
110
110
  "@types/yargs": "^17.0.35",
111
- "@vitest/browser": "^4.0.13",
112
- "@vitest/browser-playwright": "^4.0.13",
113
- "@vitest/coverage-istanbul": "^4.0.13",
111
+ "@vitest/browser": "^4.0.14",
112
+ "@vitest/browser-playwright": "^4.0.14",
113
+ "@vitest/coverage-istanbul": "^4.0.14",
114
114
  "@zimic/eslint-config-node": "workspace:*",
115
115
  "@zimic/lint-staged-config": "workspace:*",
116
116
  "@zimic/tsconfig": "workspace:*",
@@ -118,10 +118,10 @@
118
118
  "concurrently": "^9.2.1",
119
119
  "dotenv-cli": "^11.0.0",
120
120
  "eslint": "^9.39.1",
121
- "playwright": "^1.56.1",
121
+ "playwright": "^1.57.0",
122
122
  "tsup": "^8.5.1",
123
123
  "typescript": "^5.9.3",
124
- "vitest": "^4.0.13"
124
+ "vitest": "^4.0.14"
125
125
  },
126
126
  "peerDependencies": {
127
127
  "@zimic/http": "^1.2.0 || workspace:*",
@@ -9,7 +9,7 @@ class UnknownHttpInterceptorPlatformError extends Error {
9
9
  * Ignoring because checking unknown platforms is currently not possible in our Vitest setup. */
10
10
  constructor() {
11
11
  super('Unknown interceptor platform.');
12
- this.name = 'UnknownHttpInterceptorPlatform';
12
+ this.name = 'UnknownHttpInterceptorPlatformError';
13
13
  }
14
14
  }
15
15
 
@@ -19,8 +19,7 @@ class LocalHttpRequestHandler<
19
19
  Method extends HttpSchemaMethod<Schema>,
20
20
  Path extends HttpSchemaPath<Schema, Method>,
21
21
  StatusCode extends HttpStatusCode = never,
22
- > implements InternalHttpRequestHandler<Schema, Method, Path, StatusCode>
23
- {
22
+ > implements InternalHttpRequestHandler<Schema, Method, Path, StatusCode> {
24
23
  readonly type = 'local';
25
24
 
26
25
  client: HttpRequestHandlerClient<Schema, Method, Path, StatusCode>;
@@ -24,8 +24,7 @@ class RemoteHttpRequestHandler<
24
24
  Method extends HttpSchemaMethod<Schema>,
25
25
  Path extends HttpSchemaPath<Schema, Method>,
26
26
  StatusCode extends HttpStatusCode = never,
27
- > implements InternalHttpRequestHandler<Schema, Method, Path, StatusCode>
28
- {
27
+ > implements InternalHttpRequestHandler<Schema, Method, Path, StatusCode> {
29
28
  readonly type = 'remote';
30
29
 
31
30
  client: HttpRequestHandlerClient<Schema, Method, Path, StatusCode>;
@@ -68,8 +68,10 @@ export type HttpRequestHandlerResponseDelayFactory<Path extends string, MethodSc
68
68
  ) => PossiblePromise<number>;
69
69
 
70
70
  /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */
71
- export interface HttpInterceptorRequest<Path extends string, MethodSchema extends HttpMethodSchema>
72
- extends Omit<HttpRequest, keyof Body | 'headers' | 'clone'> {
71
+ export interface HttpInterceptorRequest<Path extends string, MethodSchema extends HttpMethodSchema> extends Omit<
72
+ HttpRequest,
73
+ keyof Body | 'headers' | 'clone'
74
+ > {
73
75
  /**
74
76
  * The headers of the request.
75
77
  *
@@ -104,8 +106,10 @@ export interface HttpInterceptorRequest<Path extends string, MethodSchema extend
104
106
  }
105
107
 
106
108
  /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */
107
- export interface HttpInterceptorResponse<MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode>
108
- extends Omit<HttpResponse, keyof Body | 'headers' | 'clone'> {
109
+ export interface HttpInterceptorResponse<
110
+ MethodSchema extends HttpMethodSchema,
111
+ StatusCode extends HttpStatusCode,
112
+ > extends Omit<HttpResponse, keyof Body | 'headers' | 'clone'> {
109
113
  /**
110
114
  * The headers of the response.
111
115
  *
package/src/utils/http.ts CHANGED
@@ -6,14 +6,14 @@ class HttpServerTimeoutError extends Error {}
6
6
  export class HttpServerStartTimeoutError extends HttpServerTimeoutError {
7
7
  constructor(reachedTimeout: number) {
8
8
  super(`HTTP server start timed out after ${reachedTimeout}ms.`);
9
- this.name = 'HttpServerStartTimeout';
9
+ this.name = 'HttpServerStartTimeoutError';
10
10
  }
11
11
  }
12
12
 
13
13
  export class HttpServerStopTimeoutError extends HttpServerTimeoutError {
14
14
  constructor(reachedTimeout: number) {
15
15
  super(`HTTP server stop timed out after ${reachedTimeout}ms.`);
16
- this.name = 'HttpServerStopTimeout';
16
+ this.name = 'HttpServerStopTimeoutError';
17
17
  }
18
18
  }
19
19
 
@@ -8,14 +8,14 @@ class WebSocketTimeoutError extends Error {}
8
8
  export class WebSocketOpenTimeoutError extends WebSocketTimeoutError {
9
9
  constructor(reachedTimeout: number) {
10
10
  super(`Web socket open timed out after ${reachedTimeout}ms.`);
11
- this.name = 'WebSocketOpenTimeout';
11
+ this.name = 'WebSocketOpenTimeoutError';
12
12
  }
13
13
  }
14
14
 
15
15
  export class WebSocketMessageTimeoutError extends WebSocketTimeoutError {
16
16
  constructor(reachedTimeout: number) {
17
17
  super(`Web socket message timed out after ${reachedTimeout}ms.`);
18
- this.name = 'WebSocketMessageTimeout';
18
+ this.name = 'WebSocketMessageTimeoutError';
19
19
  }
20
20
  }
21
21
 
@@ -29,7 +29,7 @@ export class WebSocketMessageAbortError extends WebSocketTimeoutError {
29
29
  export class WebSocketCloseTimeoutError extends WebSocketTimeoutError {
30
30
  constructor(reachedTimeout: number) {
31
31
  super(`Web socket close timed out after ${reachedTimeout}ms.`);
32
- this.name = 'WebSocketCloseTimeout';
32
+ this.name = 'WebSocketCloseTimeoutError';
33
33
  }
34
34
  }
35
35
 
@@ -12,7 +12,7 @@ import {
12
12
  } from '@/utils/webSocket';
13
13
 
14
14
  import { WEB_SOCKET_CONTROL_MESSAGES, WebSocketControlMessage } from './constants';
15
- import InvalidWebSocketMessage from './errors/InvalidWebSocketMessage';
15
+ import InvalidWebSocketMessageError from './errors/InvalidWebSocketMessageError';
16
16
  import NotRunningWebSocketHandlerError from './errors/NotRunningWebSocketHandlerError';
17
17
  import {
18
18
  WebSocketEventMessageListener,
@@ -116,7 +116,7 @@ abstract class WebSocketHandler<Schema extends WebSocketSchema> {
116
116
  if (typeof data === 'string') {
117
117
  return data;
118
118
  } else {
119
- throw new InvalidWebSocketMessage(data);
119
+ throw new InvalidWebSocketMessageError(data);
120
120
  }
121
121
  }
122
122
 
@@ -126,11 +126,11 @@ abstract class WebSocketHandler<Schema extends WebSocketSchema> {
126
126
  try {
127
127
  parsedMessage = JSON.parse(stringifiedMessage) as unknown;
128
128
  } catch {
129
- throw new InvalidWebSocketMessage(stringifiedMessage);
129
+ throw new InvalidWebSocketMessageError(stringifiedMessage);
130
130
  }
131
131
 
132
132
  if (!this.isMessage(parsedMessage)) {
133
- throw new InvalidWebSocketMessage(stringifiedMessage);
133
+ throw new InvalidWebSocketMessageError(stringifiedMessage);
134
134
  }
135
135
 
136
136
  if (this.isReplyMessage(parsedMessage)) {
@@ -0,0 +1,8 @@
1
+ class InvalidWebSocketMessageError extends Error {
2
+ constructor(message: unknown) {
3
+ super(`Web socket message is invalid and could not be parsed: ${message}`);
4
+ this.name = 'InvalidWebSocketMessageError';
5
+ }
6
+ }
7
+
8
+ export default InvalidWebSocketMessageError;