@zimic/interceptor 0.19.1-canary.4 → 0.19.1-canary.5
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/{chunk-QB2A2272.js → chunk-PKURIUS2.js} +2 -2
- package/dist/{chunk-QB2A2272.js.map → chunk-PKURIUS2.js.map} +1 -1
- package/dist/{chunk-7BR57OM2.mjs → chunk-XBLRKSEM.mjs} +2 -2
- package/dist/{chunk-7BR57OM2.mjs.map → chunk-XBLRKSEM.mjs.map} +1 -1
- package/dist/cli.js +22 -22
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/server.d.ts +14 -78
- package/dist/server.js +6 -6
- package/dist/server.mjs +1 -1
- package/package.json +2 -2
- package/src/server/factory.ts +1 -8
- package/src/server/types/options.ts +5 -23
- package/src/server/types/public.ts +8 -47
- package/src/utils/processes.ts +4 -4
package/dist/server.d.ts
CHANGED
|
@@ -12,93 +12,36 @@ declare class NotRunningInterceptorServerError extends Error {
|
|
|
12
12
|
constructor();
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* The options to create an {@link https://zimic.dev/docs/interceptor/cli/server interceptor server}.
|
|
17
|
-
*
|
|
18
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
19
|
-
*/
|
|
15
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
20
16
|
interface InterceptorServerOptions {
|
|
21
|
-
/**
|
|
22
|
-
* The hostname to start the server on.
|
|
23
|
-
*
|
|
24
|
-
* @default localhost
|
|
25
|
-
*/
|
|
17
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
26
18
|
hostname?: string;
|
|
27
|
-
/**
|
|
19
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
28
20
|
port?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Whether to log warnings about unhandled requests to the console.
|
|
31
|
-
*
|
|
32
|
-
* @default true
|
|
33
|
-
*/
|
|
21
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
34
22
|
logUnhandledRequests?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* The directory where the authorized interceptor authentication tokens are saved. If provided, only remote
|
|
37
|
-
* interceptors bearing a valid token will be accepted. This option is essential if you are exposing your interceptor
|
|
38
|
-
* server publicly. For local development and testing, though, `--tokens-dir` is optional.
|
|
39
|
-
*
|
|
40
|
-
* @default undefined
|
|
41
|
-
*/
|
|
23
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
42
24
|
tokensDirectory?: string;
|
|
43
25
|
}
|
|
44
26
|
|
|
45
|
-
/**
|
|
46
|
-
* A server to intercept and handle requests. It is used in combination with
|
|
47
|
-
* {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptors}.
|
|
48
|
-
*
|
|
49
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
50
|
-
*/
|
|
27
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
51
28
|
interface InterceptorServer {
|
|
52
|
-
/**
|
|
53
|
-
* The hostname of the server. It can be reassigned to a new value if the server is not running.
|
|
54
|
-
*
|
|
55
|
-
* @throws {RunningInterceptorServerError} When trying to reassign a new hostname with the server still running.
|
|
56
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
57
|
-
*/
|
|
29
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
58
30
|
hostname: string;
|
|
59
|
-
/**
|
|
60
|
-
* The port of the server. It can be reassigned to a new value if the server is not running.
|
|
61
|
-
*
|
|
62
|
-
* @throws {RunningInterceptorServerError} When trying to reassign a new port with the server still running.
|
|
63
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
64
|
-
*/
|
|
31
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
65
32
|
port: number | undefined;
|
|
66
|
-
/**
|
|
67
|
-
* Whether to log warnings about unhandled requests to the console.
|
|
68
|
-
*
|
|
69
|
-
* @default true
|
|
70
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
71
|
-
*/
|
|
33
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
72
34
|
logUnhandledRequests: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* The directory where the authorized interceptor authentication tokens are saved. If provided, only remote
|
|
75
|
-
* interceptors bearing a valid token will be accepted. This option is essential if you are exposing your interceptor
|
|
76
|
-
* server publicly. For local development and testing, though, `--tokens-dir` is optional.
|
|
77
|
-
*
|
|
78
|
-
* @default undefined
|
|
79
|
-
*/
|
|
35
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
80
36
|
tokensDirectory?: string;
|
|
81
37
|
/**
|
|
82
|
-
* Whether the server is running.
|
|
83
|
-
*
|
|
84
38
|
* @readonly
|
|
85
|
-
* @see {@link https://zimic.dev/docs/interceptor/
|
|
39
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference}
|
|
86
40
|
*/
|
|
87
41
|
get isRunning(): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Starts the server.
|
|
90
|
-
*
|
|
91
|
-
* The server is automatically stopped if a process exit event is detected, such as SIGINT, SIGTERM, or an uncaught
|
|
92
|
-
* exception.
|
|
93
|
-
*
|
|
94
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
95
|
-
*/
|
|
42
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
96
43
|
start: () => Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Stops the server.
|
|
99
|
-
*
|
|
100
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
101
|
-
*/
|
|
44
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
102
45
|
stop: () => Promise<void>;
|
|
103
46
|
}
|
|
104
47
|
|
|
@@ -113,14 +56,7 @@ declare const DEFAULT_ACCESS_CONTROL_HEADERS: Readonly<{
|
|
|
113
56
|
/** The default status code for the preflight request. */
|
|
114
57
|
declare const DEFAULT_PREFLIGHT_STATUS_CODE = 204;
|
|
115
58
|
|
|
116
|
-
/**
|
|
117
|
-
* Creates an {@link https://zimic.dev/docs/interceptor/cli/server interceptor server}.
|
|
118
|
-
*
|
|
119
|
-
* @param options The options to create the server.
|
|
120
|
-
* @returns The created server.
|
|
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} .
|
|
123
|
-
*/
|
|
59
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
124
60
|
declare function createInterceptorServer(options?: InterceptorServerOptions): InterceptorServer;
|
|
125
61
|
|
|
126
62
|
export { DEFAULT_ACCESS_CONTROL_HEADERS, DEFAULT_PREFLIGHT_STATUS_CODE, type InterceptorServer, type InterceptorServerOptions, NotRunningInterceptorServerError, RunningInterceptorServerError, createInterceptorServer };
|
package/dist/server.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkPKURIUS2_js = require('./chunk-PKURIUS2.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
|
|
10
|
+
get: function () { return chunkPKURIUS2_js.DEFAULT_ACCESS_CONTROL_HEADERS; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "DEFAULT_PREFLIGHT_STATUS_CODE", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkPKURIUS2_js.DEFAULT_PREFLIGHT_STATUS_CODE; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "NotRunningInterceptorServerError", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkPKURIUS2_js.NotRunningInterceptorServerError_default; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "RunningInterceptorServerError", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkPKURIUS2_js.RunningInterceptorServerError_default; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "createInterceptorServer", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkPKURIUS2_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-
|
|
1
|
+
export { DEFAULT_ACCESS_CONTROL_HEADERS, DEFAULT_PREFLIGHT_STATUS_CODE, NotRunningInterceptorServerError_default as NotRunningInterceptorServerError, RunningInterceptorServerError_default as RunningInterceptorServerError, createInterceptorServer } from './chunk-XBLRKSEM.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.
|
|
17
|
+
"version": "0.19.1-canary.5",
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
20
|
"url": "https://github.com/zimicjs/zimic.git",
|
|
@@ -100,8 +100,8 @@
|
|
|
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",
|
|
104
103
|
"@zimic/lint-staged-config": "0.0.0",
|
|
104
|
+
"@zimic/tsconfig": "0.0.0",
|
|
105
105
|
"@zimic/utils": "0.0.0"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
package/src/server/factory.ts
CHANGED
|
@@ -2,14 +2,7 @@ import InterceptorServer from './InterceptorServer';
|
|
|
2
2
|
import { InterceptorServerOptions } from './types/options';
|
|
3
3
|
import { InterceptorServer as PublicInterceptorServer } from './types/public';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Creates an {@link https://zimic.dev/docs/interceptor/cli/server interceptor server}.
|
|
7
|
-
*
|
|
8
|
-
* @param options The options to create the server.
|
|
9
|
-
* @returns The created server.
|
|
10
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server-programmatic-usage `zimic-interceptor server` programmatic usage}
|
|
11
|
-
* @see {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors Remote HTTP Interceptors} .
|
|
12
|
-
*/
|
|
5
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
13
6
|
export function createInterceptorServer(options: InterceptorServerOptions = {}): PublicInterceptorServer {
|
|
14
7
|
return new InterceptorServer(options);
|
|
15
8
|
}
|
|
@@ -1,32 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The options to create an {@link https://zimic.dev/docs/interceptor/cli/server interceptor server}.
|
|
3
|
-
*
|
|
4
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
5
|
-
*/
|
|
1
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
6
2
|
export interface InterceptorServerOptions {
|
|
7
|
-
/**
|
|
8
|
-
* The hostname to start the server on.
|
|
9
|
-
*
|
|
10
|
-
* @default localhost
|
|
11
|
-
*/
|
|
3
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
12
4
|
hostname?: string;
|
|
13
5
|
|
|
14
|
-
/**
|
|
6
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
15
7
|
port?: number;
|
|
16
8
|
|
|
17
|
-
/**
|
|
18
|
-
* Whether to log warnings about unhandled requests to the console.
|
|
19
|
-
*
|
|
20
|
-
* @default true
|
|
21
|
-
*/
|
|
9
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
22
10
|
logUnhandledRequests?: boolean;
|
|
23
11
|
|
|
24
|
-
/**
|
|
25
|
-
* The directory where the authorized interceptor authentication tokens are saved. If provided, only remote
|
|
26
|
-
* interceptors bearing a valid token will be accepted. This option is essential if you are exposing your interceptor
|
|
27
|
-
* server publicly. For local development and testing, though, `--tokens-dir` is optional.
|
|
28
|
-
*
|
|
29
|
-
* @default undefined
|
|
30
|
-
*/
|
|
12
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
|
|
31
13
|
tokensDirectory?: string;
|
|
32
14
|
}
|
|
@@ -1,65 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A server to intercept and handle requests. It is used in combination with
|
|
3
|
-
* {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptors}.
|
|
4
|
-
*
|
|
5
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
6
|
-
*/
|
|
1
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
7
2
|
export interface InterceptorServer {
|
|
8
|
-
/**
|
|
9
|
-
* The hostname of the server. It can be reassigned to a new value if the server is not running.
|
|
10
|
-
*
|
|
11
|
-
* @throws {RunningInterceptorServerError} When trying to reassign a new hostname with the server still running.
|
|
12
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
13
|
-
*/
|
|
3
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
14
4
|
hostname: string;
|
|
15
5
|
|
|
16
|
-
/**
|
|
17
|
-
* The port of the server. It can be reassigned to a new value if the server is not running.
|
|
18
|
-
*
|
|
19
|
-
* @throws {RunningInterceptorServerError} When trying to reassign a new port with the server still running.
|
|
20
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
21
|
-
*/
|
|
6
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
22
7
|
port: number | undefined;
|
|
23
8
|
|
|
24
|
-
/**
|
|
25
|
-
* Whether to log warnings about unhandled requests to the console.
|
|
26
|
-
*
|
|
27
|
-
* @default true
|
|
28
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
29
|
-
*/
|
|
9
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
30
10
|
logUnhandledRequests: boolean;
|
|
31
11
|
|
|
32
|
-
/**
|
|
33
|
-
* The directory where the authorized interceptor authentication tokens are saved. If provided, only remote
|
|
34
|
-
* interceptors bearing a valid token will be accepted. This option is essential if you are exposing your interceptor
|
|
35
|
-
* server publicly. For local development and testing, though, `--tokens-dir` is optional.
|
|
36
|
-
*
|
|
37
|
-
* @default undefined
|
|
38
|
-
*/
|
|
12
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
39
13
|
tokensDirectory?: string;
|
|
40
14
|
|
|
41
15
|
/**
|
|
42
|
-
* Whether the server is running.
|
|
43
|
-
*
|
|
44
16
|
* @readonly
|
|
45
|
-
* @see {@link https://zimic.dev/docs/interceptor/
|
|
17
|
+
* @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference}
|
|
46
18
|
*/
|
|
47
19
|
get isRunning(): boolean;
|
|
48
20
|
|
|
49
|
-
/**
|
|
50
|
-
* Starts the server.
|
|
51
|
-
*
|
|
52
|
-
* The server is automatically stopped if a process exit event is detected, such as SIGINT, SIGTERM, or an uncaught
|
|
53
|
-
* exception.
|
|
54
|
-
*
|
|
55
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
56
|
-
*/
|
|
21
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
57
22
|
start: () => Promise<void>;
|
|
58
23
|
|
|
59
|
-
/**
|
|
60
|
-
* Stops the server.
|
|
61
|
-
*
|
|
62
|
-
* @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
|
|
63
|
-
*/
|
|
24
|
+
/** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
|
|
64
25
|
stop: () => Promise<void>;
|
|
65
26
|
}
|
package/src/utils/processes.ts
CHANGED
|
@@ -69,11 +69,11 @@ export class CommandError extends Error {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export async function runCommand(
|
|
72
|
+
export async function runCommand(commandEntry: string, commandArguments: string[]) {
|
|
73
73
|
const { execa: $, ExecaError } = await importExeca();
|
|
74
74
|
|
|
75
75
|
try {
|
|
76
|
-
await $(
|
|
76
|
+
await $(commandEntry, commandArguments, { stdio: 'inherit' });
|
|
77
77
|
} catch (error) {
|
|
78
78
|
/* istanbul ignore if -- @preserve
|
|
79
79
|
* This is a safeguard if the error is not an ExecaError. It is not expected to run. */
|
|
@@ -81,8 +81,8 @@ export async function runCommand(command: string, commandArguments: string[]) {
|
|
|
81
81
|
throw error;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
const commandError = new CommandError(
|
|
85
|
-
command: [
|
|
84
|
+
const commandError = new CommandError(commandEntry, {
|
|
85
|
+
command: [commandEntry, ...commandArguments],
|
|
86
86
|
exitCode: error.exitCode,
|
|
87
87
|
signal: error.signal,
|
|
88
88
|
originalMessage: error.originalMessage,
|