@mswjs/interceptors 0.22.10 → 0.22.11

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 (72) hide show
  1. package/lib/browser/{Interceptor-c794917d.d.ts → Interceptor-c8fc448a.d.ts} +3 -3
  2. package/lib/browser/{chunk-KX4GZMPY.mjs → chunk-4W72RMFC.mjs} +15 -11
  3. package/lib/browser/{chunk-OK5YCL7L.js → chunk-ECRLBCQN.js} +55 -55
  4. package/lib/browser/{chunk-KQGVZIDK.js → chunk-EGQUVEJ3.js} +19 -15
  5. package/lib/browser/{chunk-2EIH6L6D.js → chunk-KCAWLR7J.js} +25 -25
  6. package/lib/browser/{chunk-CKVJ2NZB.mjs → chunk-MJZRQFUP.mjs} +67 -54
  7. package/lib/browser/{chunk-H4SFMU2L.js → chunk-NHFEA72Q.js} +74 -61
  8. package/lib/browser/{chunk-2GVXYEMC.mjs → chunk-O7B67YBY.mjs} +54 -54
  9. package/lib/browser/{chunk-65HGG3CV.mjs → chunk-UYUNRMLU.mjs} +1 -1
  10. package/lib/browser/index.d.ts +3 -3
  11. package/lib/browser/index.js +8 -8
  12. package/lib/browser/index.mjs +6 -6
  13. package/lib/browser/interceptors/XMLHttpRequest/index.d.ts +2 -2
  14. package/lib/browser/interceptors/XMLHttpRequest/index.js +4 -4
  15. package/lib/browser/interceptors/XMLHttpRequest/index.mjs +3 -3
  16. package/lib/browser/interceptors/fetch/index.d.ts +2 -2
  17. package/lib/browser/interceptors/fetch/index.js +3 -3
  18. package/lib/browser/interceptors/fetch/index.mjs +2 -2
  19. package/lib/browser/presets/browser.d.ts +2 -2
  20. package/lib/browser/presets/browser.js +6 -6
  21. package/lib/browser/presets/browser.mjs +4 -4
  22. package/lib/node/{BatchInterceptor-5c1e5de3.d.ts → BatchInterceptor-fe69020d.d.ts} +1 -1
  23. package/lib/node/{Interceptor-b3a4098c.d.ts → Interceptor-f9dfe016.d.ts} +3 -3
  24. package/lib/node/RemoteHttpInterceptor.d.ts +3 -3
  25. package/lib/node/RemoteHttpInterceptor.js +25 -19
  26. package/lib/node/RemoteHttpInterceptor.mjs +21 -15
  27. package/lib/node/{chunk-VTP5KY7W.js → chunk-2OJRZCGS.js} +71 -58
  28. package/lib/node/{chunk-6CRMKMDL.mjs → chunk-3V5OWTY7.mjs} +54 -55
  29. package/lib/node/{chunk-62KFIM4W.js → chunk-6KJ5M2VR.js} +56 -57
  30. package/lib/node/{chunk-A3X67VOL.js → chunk-7XU7Q63W.js} +111 -94
  31. package/lib/node/{chunk-MUUQLKVJ.js → chunk-PKB2CXQV.js} +3 -3
  32. package/lib/node/{chunk-SFLY7F52.js → chunk-RJMXHEGJ.js} +6 -6
  33. package/lib/node/{chunk-EHQJSMSD.mjs → chunk-RL5IV5PL.mjs} +67 -54
  34. package/lib/node/{chunk-RFVEKRYP.mjs → chunk-S5A4P4BZ.mjs} +1 -1
  35. package/lib/node/{chunk-IC6Y7RGW.mjs → chunk-SBAVVQIW.mjs} +5 -5
  36. package/lib/node/{chunk-W27FTX2A.mjs → chunk-XVHIXGXD.mjs} +111 -94
  37. package/lib/node/index.d.ts +3 -3
  38. package/lib/node/index.js +4 -4
  39. package/lib/node/index.mjs +3 -3
  40. package/lib/node/interceptors/ClientRequest/index.d.ts +2 -2
  41. package/lib/node/interceptors/ClientRequest/index.js +3 -3
  42. package/lib/node/interceptors/ClientRequest/index.mjs +2 -2
  43. package/lib/node/interceptors/XMLHttpRequest/index.d.ts +2 -2
  44. package/lib/node/interceptors/XMLHttpRequest/index.js +4 -4
  45. package/lib/node/interceptors/XMLHttpRequest/index.mjs +3 -3
  46. package/lib/node/interceptors/fetch/index.d.ts +2 -2
  47. package/lib/node/interceptors/fetch/index.js +16 -12
  48. package/lib/node/interceptors/fetch/index.mjs +15 -11
  49. package/lib/node/presets/node.d.ts +2 -2
  50. package/lib/node/presets/node.js +6 -6
  51. package/lib/node/presets/node.mjs +4 -4
  52. package/package.json +2 -3
  53. package/src/BatchInterceptor.ts +4 -4
  54. package/src/Interceptor.ts +27 -27
  55. package/src/RemoteHttpInterceptor.ts +16 -10
  56. package/src/interceptors/ClientRequest/NodeClientRequest.test.ts +11 -11
  57. package/src/interceptors/ClientRequest/NodeClientRequest.ts +47 -38
  58. package/src/interceptors/ClientRequest/http.request.ts +3 -3
  59. package/src/interceptors/ClientRequest/index.ts +4 -4
  60. package/src/interceptors/ClientRequest/utils/createRequest.test.ts +5 -5
  61. package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.ts +7 -7
  62. package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts +27 -27
  63. package/src/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.ts +4 -4
  64. package/src/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.ts +7 -4
  65. package/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts +47 -36
  66. package/src/interceptors/XMLHttpRequest/XMLHttpRequestProxy.ts +15 -13
  67. package/src/interceptors/XMLHttpRequest/index.ts +5 -5
  68. package/src/interceptors/fetch/index.ts +14 -11
  69. package/src/utils/AsyncEventEmitter.ts +27 -27
  70. package/src/utils/cloneObject.ts +7 -7
  71. package/src/utils/getUrlByRequestOptions.ts +13 -13
  72. package/src/utils/debug.ts +0 -4
@@ -1,27 +1,27 @@
1
- import { debug } from './debug'
1
+ import { Logger } from '@open-draft/logger'
2
2
 
3
- const log = debug('cloneObject')
3
+ const logger = new Logger('cloneObject')
4
4
 
5
5
  function isPlainObject(obj?: Record<string, any>): boolean {
6
- log('is plain object?', obj)
6
+ logger.info('is plain object?', obj)
7
7
 
8
8
  if (obj == null || !obj.constructor?.name) {
9
- log('given object is undefined, not a plain object...')
9
+ logger.info('given object is undefined, not a plain object...')
10
10
  return false
11
11
  }
12
12
 
13
- log('checking the object constructor:', obj.constructor.name)
13
+ logger.info('checking the object constructor:', obj.constructor.name)
14
14
  return obj.constructor.name === 'Object'
15
15
  }
16
16
 
17
17
  export function cloneObject<ObjectType extends Record<string, any>>(
18
18
  obj: ObjectType
19
19
  ): ObjectType {
20
- log('cloning object:', obj)
20
+ logger.info('cloning object:', obj)
21
21
 
22
22
  const enumerableProperties = Object.entries(obj).reduce<Record<string, any>>(
23
23
  (acc, [key, value]) => {
24
- log('analyzing key-value pair:', key, value)
24
+ logger.info('analyzing key-value pair:', key, value)
25
25
 
26
26
  // Recursively clone only plain objects, omitting class instances.
27
27
  acc[key] = isPlainObject(value) ? cloneObject(value) : value
@@ -1,8 +1,8 @@
1
1
  import { Agent } from 'http'
2
2
  import { RequestOptions, Agent as HttpsAgent } from 'https'
3
- import { debug } from './debug'
3
+ import { Logger } from '@open-draft/logger'
4
4
 
5
- const log = debug('utils getUrlByRequestOptions')
5
+ const logger = new Logger('utils getUrlByRequestOptions')
6
6
 
7
7
  // Request instance constructed by the "request" library
8
8
  // has a "self" property that has a "uri" field. This is
@@ -124,43 +124,43 @@ function getHostname(host: string, port?: number): string {
124
124
  * Creates a `URL` instance from a given `RequestOptions` object.
125
125
  */
126
126
  export function getUrlByRequestOptions(options: ResolvedRequestOptions): URL {
127
- log('request options', options)
127
+ logger.info('request options', options)
128
128
 
129
129
  if (options.uri) {
130
- log(
130
+ logger.info(
131
131
  'constructing url from explicitly provided "options.uri": %s',
132
132
  options.uri
133
133
  )
134
134
  return new URL(options.uri.href)
135
135
  }
136
136
 
137
- log('figuring out url from request options...')
137
+ logger.info('figuring out url from request options...')
138
138
 
139
139
  const protocol = getProtocolByRequestOptions(options)
140
- log('protocol', protocol)
140
+ logger.info('protocol', protocol)
141
141
 
142
142
  const host = getHostByRequestOptions(options)
143
- log('host', host)
143
+ logger.info('host', host)
144
144
 
145
145
  const port = getPortByRequestOptions(options)
146
- log('port', port)
146
+ logger.info('port', port)
147
147
 
148
148
  const hostname = getHostname(host, port)
149
- log('hostname', hostname)
149
+ logger.info('hostname', hostname)
150
150
 
151
151
  const path = options.path || DEFAULT_PATH
152
- log('path', path)
152
+ logger.info('path', path)
153
153
 
154
154
  const credentials = getAuthByRequestOptions(options)
155
- log('credentials', credentials)
155
+ logger.info('credentials', credentials)
156
156
 
157
157
  const authString = credentials
158
158
  ? `${credentials.username}:${credentials.password}@`
159
159
  : ''
160
- log('auth string:', authString)
160
+ logger.info('auth string:', authString)
161
161
 
162
162
  const url = new URL(`${protocol}//${authString}${hostname}${path}`)
163
- log('created url:', url)
163
+ logger.info('created url:', url)
164
164
 
165
165
  return url
166
166
  }
@@ -1,4 +0,0 @@
1
- export type { Debugger } from 'debug'
2
- import debugCjsImport from 'debug'
3
-
4
- export const debug = debugCjsImport