@zimic/interceptor 0.18.1 → 0.18.2-canary.1

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 chunk3GG7AT63_js = require('./chunk-3GG7AT63.js');
3
+ var chunkKBWRANAF_js = require('./chunk-KBWRANAF.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 chunk3GG7AT63_js.DEFAULT_ACCESS_CONTROL_HEADERS; }
10
+ get: function () { return chunkKBWRANAF_js.DEFAULT_ACCESS_CONTROL_HEADERS; }
11
11
  });
12
12
  Object.defineProperty(exports, "DEFAULT_PREFLIGHT_STATUS_CODE", {
13
13
  enumerable: true,
14
- get: function () { return chunk3GG7AT63_js.DEFAULT_PREFLIGHT_STATUS_CODE; }
14
+ get: function () { return chunkKBWRANAF_js.DEFAULT_PREFLIGHT_STATUS_CODE; }
15
15
  });
16
16
  Object.defineProperty(exports, "NotRunningInterceptorServerError", {
17
17
  enumerable: true,
18
- get: function () { return chunk3GG7AT63_js.NotRunningInterceptorServerError_default; }
18
+ get: function () { return chunkKBWRANAF_js.NotRunningInterceptorServerError_default; }
19
19
  });
20
20
  Object.defineProperty(exports, "RunningInterceptorServerError", {
21
21
  enumerable: true,
22
- get: function () { return chunk3GG7AT63_js.RunningInterceptorServerError_default; }
22
+ get: function () { return chunkKBWRANAF_js.RunningInterceptorServerError_default; }
23
23
  });
24
24
  Object.defineProperty(exports, "createInterceptorServer", {
25
25
  enumerable: true,
26
- get: function () { return chunk3GG7AT63_js.createInterceptorServer; }
26
+ get: function () { return chunkKBWRANAF_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-NYY2KKWB.mjs';
1
+ export { DEFAULT_ACCESS_CONTROL_HEADERS, DEFAULT_PREFLIGHT_STATUS_CODE, NotRunningInterceptorServerError_default as NotRunningInterceptorServerError, RunningInterceptorServerError_default as RunningInterceptorServerError, createInterceptorServer } from './chunk-XRFIPHQZ.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.18.1",
17
+ "version": "0.18.2-canary.1",
18
18
  "repository": {
19
19
  "type": "git",
20
20
  "url": "https://github.com/zimicjs/zimic.git",
@@ -75,10 +75,10 @@
75
75
  "./package.json": "./package.json"
76
76
  },
77
77
  "dependencies": {
78
- "@whatwg-node/server": "0.10.6",
78
+ "@whatwg-node/server": "0.10.8",
79
79
  "execa": "9.5.3",
80
80
  "isomorphic-ws": "5.0.0",
81
- "msw": "2.7.6",
81
+ "msw": "2.8.3",
82
82
  "picocolors": "^1.1.1",
83
83
  "ws": "8.18.2",
84
84
  "yargs": "17.7.2",
@@ -94,19 +94,19 @@
94
94
  "@vitest/browser": "^3.1.2",
95
95
  "@vitest/coverage-istanbul": "^3.1.2",
96
96
  "dotenv-cli": "^8.0.0",
97
- "eslint": "^9.26.0",
97
+ "eslint": "^9.27.0",
98
98
  "playwright": "^1.52.0",
99
99
  "tsup": "^8.4.0",
100
100
  "typescript": "^5.8.3",
101
101
  "vitest": "^3.1.2",
102
102
  "@zimic/eslint-config-node": "0.0.0",
103
103
  "@zimic/lint-staged-config": "0.0.0",
104
- "@zimic/tsconfig": "0.0.0",
105
- "@zimic/utils": "0.0.0"
104
+ "@zimic/utils": "0.0.0",
105
+ "@zimic/tsconfig": "0.0.0"
106
106
  },
107
107
  "peerDependencies": {
108
108
  "typescript": ">=4.8.0",
109
- "@zimic/http": "^0.4.0 || 0.4.1-canary.0"
109
+ "@zimic/http": "^0.4.0 || 0.4.2-canary.0"
110
110
  },
111
111
  "peerDependenciesMeta": {
112
112
  "typescript": {
@@ -1,14 +1,14 @@
1
1
  import { HttpBody, HttpSchema, HttpSchemaMethod, HttpSchemaPath } from '@zimic/http';
2
2
  import { Default } from '@zimic/utils/types';
3
3
 
4
- import { HttpResponseFactoryContext } from '../../interceptorWorker/types/requests';
4
+ import { MSWHttpResponseFactoryContext } from '../../interceptorWorker/types/msw';
5
5
  import { HttpInterceptorRequest } from '../../requestHandler/types/requests';
6
6
 
7
7
  export type HttpInterceptorRequestContext<
8
8
  Schema extends HttpSchema,
9
9
  Method extends HttpSchemaMethod<Schema>,
10
10
  Path extends HttpSchemaPath<Schema, Method>,
11
- > = HttpResponseFactoryContext<Default<Default<Schema[Path][Method]>['request']>['body']>;
11
+ > = MSWHttpResponseFactoryContext<Default<Default<Schema[Path][Method]>['request']>['body']>;
12
12
 
13
13
  export type UnhandledHttpInterceptorRequestPath = string;
14
14
 
@@ -35,8 +35,8 @@ import {
35
35
  import { DEFAULT_UNHANDLED_REQUEST_STRATEGY } from './constants';
36
36
  import InvalidFormDataError from './errors/InvalidFormDataError';
37
37
  import InvalidJSONError from './errors/InvalidJSONError';
38
+ import { MSWHttpResponseFactory } from './types/msw';
38
39
  import { HttpInterceptorWorkerType } from './types/options';
39
- import { HttpResponseFactory } from './types/requests';
40
40
 
41
41
  abstract class HttpInterceptorWorker {
42
42
  abstract get type(): HttpInterceptorWorkerType;
@@ -102,7 +102,7 @@ abstract class HttpInterceptorWorker {
102
102
  interceptor: HttpInterceptorClient<Schema>,
103
103
  method: HttpMethod,
104
104
  url: string,
105
- createResponse: HttpResponseFactory,
105
+ createResponse: MSWHttpResponseFactory,
106
106
  ): PossiblePromise<void>;
107
107
 
108
108
  protected async logUnhandledRequestIfNecessary(
@@ -1,7 +1,7 @@
1
1
  import { HttpRequest, HttpResponse, HttpMethod, HttpSchema } from '@zimic/http';
2
2
  import excludeURLParams from '@zimic/utils/url/excludeURLParams';
3
3
  import validateURLPathParams from '@zimic/utils/url/validateURLPathParams';
4
- import { HttpHandler as MSWHttpHandler, SharedOptions as MSWWorkerSharedOptions, http, passthrough } from 'msw';
4
+ import { SharedOptions as MSWWorkerSharedOptions, http, passthrough } from 'msw';
5
5
  import * as mswBrowser from 'msw/browser';
6
6
  import * as mswNode from 'msw/node';
7
7
 
@@ -13,17 +13,17 @@ import UnknownHttpInterceptorPlatformError from '../interceptor/errors/UnknownHt
13
13
  import HttpInterceptorClient from '../interceptor/HttpInterceptorClient';
14
14
  import UnregisteredBrowserServiceWorkerError from './errors/UnregisteredBrowserServiceWorkerError';
15
15
  import HttpInterceptorWorker from './HttpInterceptorWorker';
16
+ import { BrowserMSWWorker, MSWHandler, MSWHttpResponseFactory, MSWWorker, NodeMSWWorker } from './types/msw';
16
17
  import { LocalHttpInterceptorWorkerOptions } from './types/options';
17
- import { BrowserHttpWorker, HttpResponseFactory, HttpWorker, NodeHttpWorker } from './types/requests';
18
18
 
19
19
  class LocalHttpInterceptorWorker extends HttpInterceptorWorker {
20
- private internalWorker?: HttpWorker;
20
+ private internalWorker?: MSWWorker;
21
21
 
22
- private defaultHttpHandler: MSWHttpHandler;
22
+ private defaultHttpHandler: MSWHandler;
23
23
 
24
24
  private httpHandlerGroups: {
25
25
  interceptor: HttpInterceptorClient<any>; // eslint-disable-line @typescript-eslint/no-explicit-any
26
- httpHandler: MSWHttpHandler;
26
+ httpHandler: MSWHandler;
27
27
  }[] = [];
28
28
 
29
29
  constructor(_options: LocalHttpInterceptorWorkerOptions) {
@@ -84,7 +84,7 @@ class LocalHttpInterceptorWorker extends HttpInterceptorWorker {
84
84
  });
85
85
  }
86
86
 
87
- private async startInBrowser(internalWorker: BrowserHttpWorker, sharedOptions: MSWWorkerSharedOptions) {
87
+ private async startInBrowser(internalWorker: BrowserMSWWorker, sharedOptions: MSWWorkerSharedOptions) {
88
88
  try {
89
89
  await internalWorker.start({ ...sharedOptions, quiet: true });
90
90
  } catch (error) {
@@ -99,7 +99,7 @@ class LocalHttpInterceptorWorker extends HttpInterceptorWorker {
99
99
  throw error;
100
100
  }
101
101
 
102
- private startInNode(internalWorker: NodeHttpWorker, sharedOptions: MSWWorkerSharedOptions) {
102
+ private startInNode(internalWorker: NodeMSWWorker, sharedOptions: MSWWorkerSharedOptions) {
103
103
  internalWorker.listen(sharedOptions);
104
104
  }
105
105
 
@@ -119,15 +119,15 @@ class LocalHttpInterceptorWorker extends HttpInterceptorWorker {
119
119
  });
120
120
  }
121
121
 
122
- private stopInBrowser(internalWorker: BrowserHttpWorker) {
122
+ private stopInBrowser(internalWorker: BrowserMSWWorker) {
123
123
  internalWorker.stop();
124
124
  }
125
125
 
126
- private stopInNode(internalWorker: NodeHttpWorker) {
126
+ private stopInNode(internalWorker: NodeMSWWorker) {
127
127
  internalWorker.close();
128
128
  }
129
129
 
130
- private isInternalBrowserWorker(worker: HttpWorker) {
130
+ private isInternalBrowserWorker(worker: MSWWorker) {
131
131
  return 'start' in worker && 'stop' in worker;
132
132
  }
133
133
 
@@ -143,7 +143,7 @@ class LocalHttpInterceptorWorker extends HttpInterceptorWorker {
143
143
  interceptor: HttpInterceptorClient<Schema>,
144
144
  method: HttpMethod,
145
145
  rawURL: string | URL,
146
- createResponse: HttpResponseFactory,
146
+ createResponse: MSWHttpResponseFactory,
147
147
  ) {
148
148
  const lowercaseMethod = method.toLowerCase<typeof method>();
149
149
 
@@ -14,15 +14,15 @@ import UnknownHttpInterceptorPlatformError from '../interceptor/errors/UnknownHt
14
14
  import HttpInterceptorClient, { AnyHttpInterceptorClient } from '../interceptor/HttpInterceptorClient';
15
15
  import { HttpInterceptorPlatform } from '../interceptor/types/options';
16
16
  import HttpInterceptorWorker from './HttpInterceptorWorker';
17
+ import { MSWHttpResponseFactory, MSWHttpResponseFactoryContext } from './types/msw';
17
18
  import { RemoteHttpInterceptorWorkerOptions } from './types/options';
18
- import { HttpResponseFactory, HttpResponseFactoryContext } from './types/requests';
19
19
 
20
20
  interface HttpHandler {
21
21
  id: string;
22
22
  url: { base: string; full: string };
23
23
  method: HttpMethod;
24
24
  interceptor: AnyHttpInterceptorClient;
25
- createResponse: (context: HttpResponseFactoryContext) => Promise<HttpResponse | null>;
25
+ createResponse: (context: MSWHttpResponseFactoryContext) => Promise<HttpResponse | null>;
26
26
  }
27
27
 
28
28
  class RemoteHttpInterceptorWorker extends HttpInterceptorWorker {
@@ -133,7 +133,7 @@ class RemoteHttpInterceptorWorker extends HttpInterceptorWorker {
133
133
  interceptor: HttpInterceptorClient<Schema>,
134
134
  method: HttpMethod,
135
135
  rawURL: string | URL,
136
- createResponse: HttpResponseFactory,
136
+ createResponse: MSWHttpResponseFactory,
137
137
  ) {
138
138
  if (!this.isRunning) {
139
139
  throw new NotRunningHttpInterceptorError();
@@ -0,0 +1,18 @@
1
+ import { HttpResponse, HttpBody, HttpRequest } from '@zimic/http';
2
+ import { PossiblePromise } from '@zimic/utils/types';
3
+ import type { HttpHandler as MSWHandler } from 'msw';
4
+ import type { SetupWorker as BrowserMSWWorker } from 'msw/browser';
5
+ import type { SetupServer as NodeMSWWorker } from 'msw/node';
6
+
7
+ export type { MSWHandler, NodeMSWWorker, BrowserMSWWorker };
8
+
9
+ export type MSWWorker = NodeMSWWorker | BrowserMSWWorker;
10
+
11
+ export interface MSWHttpResponseFactoryContext<Body extends HttpBody = HttpBody> {
12
+ request: HttpRequest<Body>;
13
+ }
14
+
15
+ export type MSWHttpResponseFactory<
16
+ RequestBody extends HttpBody = HttpBody,
17
+ ResponseBody extends HttpBody = HttpBody,
18
+ > = (context: MSWHttpResponseFactoryContext<RequestBody>) => PossiblePromise<HttpResponse<ResponseBody> | null>;
@@ -1,15 +0,0 @@
1
- import { HttpResponse, HttpBody, HttpRequest } from '@zimic/http';
2
- import { PossiblePromise } from '@zimic/utils/types';
3
- import type { SetupWorker as BrowserMSWWorker } from 'msw/browser';
4
- import type { SetupServer as NodeMSWWorker } from 'msw/node';
5
-
6
- export type HttpWorker = BrowserMSWWorker | NodeMSWWorker;
7
- export { BrowserMSWWorker as BrowserHttpWorker, NodeMSWWorker as NodeHttpWorker };
8
-
9
- export interface HttpResponseFactoryContext<Body extends HttpBody = HttpBody> {
10
- request: HttpRequest<Body>;
11
- }
12
-
13
- export type HttpResponseFactory<RequestBody extends HttpBody = HttpBody, ResponseBody extends HttpBody = HttpBody> = (
14
- context: HttpResponseFactoryContext<RequestBody>,
15
- ) => PossiblePromise<HttpResponse<ResponseBody> | null>;