@zimic/interceptor 0.16.0-canary.1 → 0.16.0-canary.10

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 (41) hide show
  1. package/README.md +4 -5
  2. package/dist/{chunk-6TSSHQW5.mjs → chunk-NTRC2S4I.mjs} +253 -312
  3. package/dist/chunk-NTRC2S4I.mjs.map +1 -0
  4. package/dist/{chunk-R2ROSKU4.js → chunk-O6ZIPCUJ.js} +254 -313
  5. package/dist/chunk-O6ZIPCUJ.js.map +1 -0
  6. package/dist/cli.js +9 -9
  7. package/dist/cli.js.map +1 -1
  8. package/dist/cli.mjs +5 -5
  9. package/dist/cli.mjs.map +1 -1
  10. package/dist/http.d.ts +156 -176
  11. package/dist/http.js +265 -324
  12. package/dist/http.js.map +1 -1
  13. package/dist/http.mjs +263 -323
  14. package/dist/http.mjs.map +1 -1
  15. package/dist/server.d.ts +20 -46
  16. package/dist/server.js +7 -7
  17. package/dist/server.mjs +1 -1
  18. package/package.json +5 -5
  19. package/src/cli/browser/init.ts +2 -2
  20. package/src/cli/server/start.ts +2 -2
  21. package/src/http/index.ts +6 -13
  22. package/src/http/interceptor/HttpInterceptorClient.ts +30 -15
  23. package/src/http/interceptor/LocalHttpInterceptor.ts +8 -8
  24. package/src/http/interceptor/RemoteHttpInterceptor.ts +8 -8
  25. package/src/http/interceptor/errors/RequestSavingSafeLimitExceededError.ts +22 -0
  26. package/src/http/interceptor/factory.ts +1 -1
  27. package/src/http/interceptor/types/options.ts +4 -11
  28. package/src/http/interceptor/types/public.ts +44 -12
  29. package/src/http/interceptor/types/schema.ts +2 -2
  30. package/src/http/interceptorWorker/HttpInterceptorWorker.ts +6 -31
  31. package/src/http/requestHandler/HttpRequestHandlerClient.ts +15 -5
  32. package/src/http/requestHandler/errors/DisabledRequestSavingError.ts +2 -2
  33. package/src/http/requestHandler/errors/TimesCheckError.ts +15 -14
  34. package/src/http/requestHandler/types/public.ts +16 -8
  35. package/src/server/index.ts +1 -11
  36. package/src/utils/console.ts +2 -2
  37. package/dist/chunk-6TSSHQW5.mjs.map +0 -1
  38. package/dist/chunk-R2ROSKU4.js.map +0 -1
  39. package/src/http/interceptorWorker/HttpInterceptorWorkerStore.ts +0 -34
  40. package/src/http/namespace/HttpInterceptorNamespace.ts +0 -81
  41. package/src/server/namespace/InterceptorServerNamespace.ts +0 -21
@@ -1,34 +0,0 @@
1
- import { HttpInterceptorType, UnhandledRequestStrategy } from '../interceptor/types/options';
2
- import { DEFAULT_UNHANDLED_REQUEST_STRATEGY } from './constants';
3
-
4
- class HttpInterceptorWorkerStore {
5
- private static _defaultOnUnhandledRequest: {
6
- local: UnhandledRequestStrategy.Local;
7
- remote: UnhandledRequestStrategy.Remote;
8
- } = {
9
- local: { ...DEFAULT_UNHANDLED_REQUEST_STRATEGY.local },
10
- remote: { ...DEFAULT_UNHANDLED_REQUEST_STRATEGY.remote },
11
- };
12
-
13
- private class = HttpInterceptorWorkerStore;
14
-
15
- defaultOnUnhandledRequest(interceptorType: 'local'): UnhandledRequestStrategy.Local;
16
- defaultOnUnhandledRequest(interceptorType: 'remote'): UnhandledRequestStrategy.Remote;
17
- defaultOnUnhandledRequest(interceptorType: HttpInterceptorType): UnhandledRequestStrategy;
18
- defaultOnUnhandledRequest(interceptorType: HttpInterceptorType) {
19
- return this.class._defaultOnUnhandledRequest[interceptorType];
20
- }
21
-
22
- setDefaultOnUnhandledRequest(interceptorType: 'local', strategy: UnhandledRequestStrategy.Local): void;
23
- setDefaultOnUnhandledRequest(interceptorType: 'remote', strategy: UnhandledRequestStrategy.Remote): void;
24
- setDefaultOnUnhandledRequest(interceptorType: HttpInterceptorType, strategy: UnhandledRequestStrategy): void;
25
- setDefaultOnUnhandledRequest(interceptorType: HttpInterceptorType, strategy: UnhandledRequestStrategy) {
26
- if (interceptorType === 'local') {
27
- this.class._defaultOnUnhandledRequest[interceptorType] = strategy as UnhandledRequestStrategy.Local;
28
- } else {
29
- this.class._defaultOnUnhandledRequest[interceptorType] = strategy as UnhandledRequestStrategy.Remote;
30
- }
31
- }
32
- }
33
-
34
- export default HttpInterceptorWorkerStore;
@@ -1,81 +0,0 @@
1
- import { createHttpInterceptor } from '../interceptor/factory';
2
- import { UnhandledRequestStrategy } from '../interceptor/types/options';
3
- import HttpInterceptorWorkerStore from '../interceptorWorker/HttpInterceptorWorkerStore';
4
-
5
- /** Default HTTP interceptor settings. */
6
- export class HttpInterceptorNamespaceDefault {
7
- local: {
8
- /**
9
- * Gets or sets the default strategy for local unhandled requests. If a request does not start with the base URL of
10
- * any local interceptors, this strategy will be used. If a function is provided, it will be called with the
11
- * unhandled request.
12
- *
13
- * You can override this default for specific interceptors by using `onUnhandledRequest` in
14
- * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#httpinterceptorcreateoptions `httpInterceptor.create(options)`}.
15
- *
16
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
17
- */
18
- get onUnhandledRequest(): UnhandledRequestStrategy.Local;
19
- set onUnhandledRequest(strategy: UnhandledRequestStrategy.Local);
20
- };
21
-
22
- remote: {
23
- /**
24
- * Gets or sets the default strategy for remote unhandled requests. If a request does not start with the base URL of
25
- * any remote interceptors, this strategy will be used. If a function is provided, it will be called with the
26
- * unhandled request.
27
- *
28
- * You can override this default for specific interceptors by using `onUnhandledRequest` in
29
- * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#httpinterceptorcreateoptions `httpInterceptor.create(options)`}.
30
- *
31
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#unhandled-requests Unhandled requests}
32
- */
33
- get onUnhandledRequest(): UnhandledRequestStrategy.Remote;
34
- set onUnhandledRequest(strategy: UnhandledRequestStrategy.Remote);
35
- };
36
-
37
- constructor() {
38
- const workerStore = new HttpInterceptorWorkerStore();
39
-
40
- this.local = {
41
- get onUnhandledRequest() {
42
- return workerStore.defaultOnUnhandledRequest('local');
43
- },
44
- set onUnhandledRequest(strategy: UnhandledRequestStrategy.Local) {
45
- workerStore.setDefaultOnUnhandledRequest('local', strategy);
46
- },
47
- };
48
-
49
- this.remote = {
50
- get onUnhandledRequest() {
51
- return workerStore.defaultOnUnhandledRequest('remote');
52
- },
53
- set onUnhandledRequest(strategy: UnhandledRequestStrategy.Remote) {
54
- workerStore.setDefaultOnUnhandledRequest('remote', strategy);
55
- },
56
- };
57
- }
58
- }
59
-
60
- /**
61
- * A namespace of interceptor resources for mocking HTTP requests.
62
- *
63
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#httpinterceptor `HttpInterceptor` API reference}
64
- */
65
- class HttpInterceptorNamespace {
66
- /**
67
- * Creates an HTTP interceptor.
68
- *
69
- * @param options The options for the interceptor.
70
- * @returns The created HTTP interceptor.
71
- * @throws {InvalidURLError} If the base URL is invalid.
72
- * @throws {UnsupportedURLProtocolError} If the base URL protocol is not either `http` or `https`.
73
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#httpinterceptorcreateoptions `httpInterceptor.create(options)` API reference}
74
- */
75
- create = createHttpInterceptor;
76
-
77
- /** Default HTTP interceptor settings. */
78
- default = Object.freeze(new HttpInterceptorNamespaceDefault());
79
- }
80
-
81
- export default HttpInterceptorNamespace;
@@ -1,21 +0,0 @@
1
- import { createInterceptorServer } from '../factory';
2
-
3
- /**
4
- * A namespace of interceptor server resources for handling HTTP requests.
5
- *
6
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server-programmatic-usage `zimic-interceptor server` programmatic usage}
7
- * @see {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors Remote HTTP Interceptors} .
8
- */
9
- class InterceptorServerNamespace {
10
- /**
11
- * Creates an {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server interceptor server}.
12
- *
13
- * @param options The options to create the server.
14
- * @returns The created server.
15
- * @see {@link https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server#zimic-server-programmatic-usage `zimic-interceptor server` programmatic usage}
16
- * @see {@link https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors Remote HTTP Interceptors} .
17
- */
18
- create = createInterceptorServer;
19
- }
20
-
21
- export default InterceptorServerNamespace;