@zimic/interceptor 0.20.2 → 0.21.0-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/{chunk-TLZZ3DX6.mjs → chunk-FQH2EMUC.mjs} +4 -4
- package/dist/chunk-FQH2EMUC.mjs.map +1 -0
- package/dist/{chunk-IUNCQOCT.js → chunk-VN36ZR3C.js} +4 -4
- package/dist/chunk-VN36ZR3C.js.map +1 -0
- package/dist/cli.js +18 -18
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/http.d.ts +36 -9
- package/dist/http.js +58 -31
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +58 -31
- package/dist/http.mjs.map +1 -1
- package/dist/server.js +6 -6
- package/dist/server.mjs +1 -1
- package/package.json +3 -3
- package/src/http/interceptorWorker/HttpInterceptorWorker.ts +3 -2
- package/src/http/requestHandler/HttpRequestHandlerClient.ts +18 -2
- package/src/http/requestHandler/types/requests.ts +42 -9
- package/src/http/requestHandler/types/restrictions.ts +5 -1
- package/src/utils/data.ts +23 -0
- package/dist/chunk-IUNCQOCT.js.map +0 -1
- package/dist/chunk-TLZZ3DX6.mjs.map +0 -1
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/cli/browser/shared/constants.ts","../src/cli/browser/init.ts","../src/utils/processes.ts","../src/cli/server/start.ts","../src/cli/server/token/create.ts","../src/cli/server/token/list.ts","../src/cli/server/token/remove.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["path","__require","fs","logger","color","__name","createCachedDynamicImport_default","createInterceptorServer","exitEvent","createInterceptorToken","listInterceptorTokens","readInterceptorTokenFromFile","removeInterceptorToken","yargs","hideBin","DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBE,IAAA,OAAA,GAAW,QAAA;;;AChBN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,EAAc;AAAA,UACzB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,uDAAA;AAAA,UACb,KAAA,EAAO,GAAA;AAAA,UACP,OAAA,EAASE;AAAA,SACV,CAAA;AAAA,QACH,OAAO,YAAA,KAAiB;AACtB,UAAA,MAAM,2BAAA,CAA4B;AAAA,YAChC,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH,OACF,CAEC,OAAA;AAAA,QACC,CAAC,gBAAgB,kBAAkB,CAAA;AAAA,QACnC,8JAAA;AAAA,QAEA,CAACF,MAAAA,KACCA,MAAAA,CACG,UAAA,CAAW,SAAA,EAAW;AAAA,UACrB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,wCAAA;AAAA,UACb,YAAA,EAAc;AAAA,SACf,CAAA,CACA,MAAA,CAAO,YAAA,EAAc;AAAA,UACpB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,uDAAA;AAAA,UACb,KAAA,EAAO,GAAA;AAAA,UACP,OAAA,EAASE;AAAA,SACV,CAAA;AAAA,QACL,OAAO,YAAA,KAAiB;AACtB,UAAA,MAAM,4BAAA,CAA6B;AAAA,YACjC,SAAS,YAAA,CAAa,OAAA;AAAA,YACtB,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH;AACF;AACJ,IAGH,KAAA,EAAM;AACX;AAtKeV,uBAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAwKf,IAAO,WAAA,GAAQ,MAAA;;;ACjLf,KAAK,WAAA,EAAO","file":"cli.js","sourcesContent":["{\n \"name\": \"@zimic/interceptor\",\n \"description\": \"Next-gen TypeScript-first HTTP intercepting and mocking\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"interceptor\",\n \"mock\",\n \"api\",\n \"static\"\n ],\n \"version\": \"0.20.2\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-interceptor\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"http.d.ts\",\n \"server.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-interceptor\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./http\": {\n \"types\": \"./http.d.ts\",\n \"import\": \"./dist/http.mjs\",\n \"require\": \"./dist/http.js\",\n \"default\": \"./dist/http.js\"\n },\n \"./server\": {\n \"types\": \"./server.d.ts\",\n \"import\": \"./dist/server.mjs\",\n \"require\": \"./dist/server.js\",\n \"default\": \"./dist/server.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"deps:install-playwright\": \"playwright install chromium\",\n \"deps:init-msw\": \"msw init ./public --no-save\",\n \"deps:prepare\": \"pnpm deps:install-playwright && pnpm deps:init-msw\",\n \"postinstall\": \"node --enable-source-maps -e \\\"try{require('./dist/scripts/postinstall')}catch(error){console.error(error)}\\\"\"\n },\n \"dependencies\": {\n \"@whatwg-node/server\": \"0.10.10\",\n \"execa\": \"9.6.0\",\n \"isomorphic-ws\": \"5.0.0\",\n \"msw\": \"2.10.2\",\n \"picocolors\": \"^1.1.1\",\n \"ws\": \"8.18.3\",\n \"yargs\": \"18.0.0\",\n \"zod\": \"^3.25.67\"\n },\n \"optionalDependencies\": {\n \"bufferutil\": \"4.0.9\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.0.7\",\n \"@types/ws\": \"^8.18.1\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^8.0.0\",\n \"eslint\": \"^9.30.0\",\n \"playwright\": \"^1.53.1\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"@zimic/http\": \"^0.6.0 || workspace:*\",\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","export const SERVICE_WORKER_FILE_NAME = 'mockServiceWorker.js';\n","import fs from 'fs';\nimport path from 'path';\nimport color from 'picocolors';\n\nimport { logger } from '@/utils/logging';\n\nimport { SERVICE_WORKER_FILE_NAME } from './shared/constants';\n\nconst MSW_ROOT_PATH = path.join(require.resolve('msw'), '..', '..', '..');\nexport const MOCK_SERVICE_WORKER_PATH = path.join(MSW_ROOT_PATH, 'lib', SERVICE_WORKER_FILE_NAME);\n\ninterface BrowserServiceWorkerInitOptions {\n publicDirectory: string;\n}\n\nasync function initializeBrowserServiceWorker({ publicDirectory }: BrowserServiceWorkerInitOptions) {\n await fs.promises.mkdir(publicDirectory, { recursive: true });\n\n const destinationPath = path.join(publicDirectory, SERVICE_WORKER_FILE_NAME);\n await fs.promises.copyFile(MOCK_SERVICE_WORKER_PATH, destinationPath);\n\n logger.info(`Service worker script saved to ${color.magenta(destinationPath)}.`);\n}\n\nexport default initializeBrowserServiceWorker;\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\n\nexport const PROCESS_EXIT_EVENTS = Object.freeze([\n 'beforeExit',\n 'uncaughtExceptionMonitor',\n 'SIGINT',\n 'SIGTERM',\n 'SIGHUP',\n 'SIGBREAK',\n] as const);\n\nexport type ProcessExitEvent = (typeof PROCESS_EXIT_EVENTS)[number];\n\n// Having an undefined exit code means that the process will already exit with the default exit code.\nexport const PROCESS_EXIT_CODE_BY_EXIT_EVENT: Record<string, number | undefined> = {\n beforeExit: undefined,\n uncaughtExceptionMonitor: undefined,\n SIGINT: 130,\n SIGTERM: 143,\n SIGHUP: 129,\n SIGBREAK: 131,\n} satisfies Record<ProcessExitEvent, number | undefined>;\n\nexport const importExeca = createCachedDynamicImport(() => import('execa'));\n\ninterface CommandErrorOptions {\n command?: string[];\n exitCode?: number;\n signal?: NodeJS.Signals;\n originalMessage?: string;\n}\n\nexport class CommandError extends Error {\n static readonly DEFAULT_EXIT_CODE = 1;\n\n readonly command: string[];\n readonly exitCode: number;\n readonly signal?: NodeJS.Signals;\n\n constructor(executable: string, options: CommandErrorOptions) {\n const message = CommandError.createMessage(executable, options);\n super(message);\n\n this.name = 'CommandError';\n this.command = options.command ?? [executable];\n this.exitCode = this.getExitCode(options);\n this.signal = options.signal;\n }\n\n private getExitCode(options: CommandErrorOptions): number {\n const existingExitCode = options.exitCode;\n const exitCodeInferredFromSignal =\n options.signal === undefined ? undefined : PROCESS_EXIT_CODE_BY_EXIT_EVENT[options.signal];\n\n return existingExitCode ?? exitCodeInferredFromSignal ?? CommandError.DEFAULT_EXIT_CODE;\n }\n\n private static createMessage(command: string, options: CommandErrorOptions) {\n const suffix = options.originalMessage ? `: ${options.originalMessage}` : '';\n\n if (options.exitCode === undefined && options.signal === undefined) {\n return `Command '${command}' failed${suffix}`;\n }\n\n const prefix = `Command '${command}' exited `;\n const infix = options.exitCode === undefined ? `after signal ${options.signal}` : `with code ${options.exitCode}`;\n\n return `${prefix}${infix}${suffix}`;\n }\n}\n\nexport async function runCommand(commandEntry: string, commandArguments: string[]) {\n const { execa: $, ExecaError } = await importExeca();\n\n try {\n await $(commandEntry, commandArguments, { stdio: 'inherit' });\n } catch (error) {\n /* istanbul ignore if -- @preserve\n * This is a safeguard if the error is not an ExecaError. It is not expected to run. */\n if (!(error instanceof ExecaError)) {\n throw error;\n }\n\n const commandError = new CommandError(commandEntry, {\n command: [commandEntry, ...commandArguments],\n exitCode: error.exitCode,\n signal: error.signal,\n originalMessage: error.originalMessage,\n });\n\n throw commandError;\n }\n}\n","import color from 'picocolors';\n\nimport { InterceptorServer, createInterceptorServer } from '@/server';\nimport { InterceptorServerOptions } from '@/server/types/options';\nimport { logger } from '@/utils/logging';\nimport {\n CommandError,\n PROCESS_EXIT_CODE_BY_EXIT_EVENT,\n PROCESS_EXIT_EVENTS,\n ProcessExitEvent,\n runCommand,\n} from '@/utils/processes';\n\ninterface InterceptorServerStartOptions extends InterceptorServerOptions {\n ephemeral: boolean;\n onReady?: { command: string; arguments: string[] };\n}\n\nexport let serverSingleton: InterceptorServer | undefined;\n\nasync function startInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n ephemeral,\n onReady,\n}: InterceptorServerStartOptions) {\n const server = createInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n });\n\n async function handleExitEvent(exitEvent: ProcessExitEvent | undefined) {\n await server.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.off(exitEvent, exitHandler);\n }\n\n const exitCode = exitEvent ? PROCESS_EXIT_CODE_BY_EXIT_EVENT[exitEvent] : undefined;\n if (exitCode !== undefined) {\n process.exit(exitCode);\n }\n }\n\n const exitHandlerGroups = PROCESS_EXIT_EVENTS.map((exitEvent) => ({\n exitEvent,\n exitHandler: handleExitEvent.bind(null, exitEvent),\n }));\n\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.on(exitEvent, exitHandler);\n }\n\n serverSingleton = server;\n\n await server.start();\n\n logger.info(\n `${ephemeral ? 'Ephemeral s' : 'S'}erver is running on ${color.yellow(`${server.hostname}:${server.port}`)}`,\n );\n\n const isDangerouslyUnprotected = !tokensDirectory && process.env.NODE_ENV === 'production';\n\n if (isDangerouslyUnprotected) {\n logger.warn(\n [\n `Attention: this interceptor server is ${color.bold(color.red('unprotected'))}. Do not expose it publicly without authentication.`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n }\n\n if (onReady) {\n try {\n await runCommand(onReady.command, onReady.arguments);\n } catch (error) {\n console.error(error);\n\n /* istanbul ignore if -- @preserve\n * A CommandError is always expected here. */\n if (!(error instanceof CommandError)) {\n throw error;\n }\n\n process.exit(error.exitCode);\n }\n }\n\n if (ephemeral) {\n await handleExitEvent(undefined);\n process.exit(0);\n }\n}\n\nexport default startInterceptorServer;\n","import color from 'picocolors';\n\nimport { createInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenName?: string;\n tokensDirectory: string;\n}\n\nexport async function createInterceptorServerToken({\n tokenName,\n tokensDirectory,\n}: InterceptorServerCreateTokenOptions) {\n const token = await createInterceptorToken({ name: tokenName, tokensDirectory });\n\n logger.info(\n [\n `${color.green(color.bold('✔'))} Token${tokenName ? ` ${color.green(tokenName)}` : ''} created:`,\n '',\n color.yellow(token.value),\n '',\n 'Store this token securely. It cannot be retrieved later.',\n '',\n `To enable authentication in your interceptor server, use the ${color.cyan('--tokens-dir')} option. Only ` +\n 'remote interceptors bearing a valid token will be allowed to connect.',\n '',\n `${color.dim('$')} zimic-interceptor server start ${color.cyan('--tokens-dir')} ${color.magenta(tokensDirectory)}`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n}\n","import { listInterceptorTokens } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerListTokensOptions {\n tokensDirectory: string;\n}\n\nexport async function listInterceptorServerTokens({ tokensDirectory }: InterceptorServerListTokensOptions) {\n const tokens = await listInterceptorTokens({ tokensDirectory });\n\n logger.raw.table(\n [\n { title: 'ID', property: 'id' },\n { title: 'NAME', property: 'name' },\n { title: 'CREATED AT', property: 'createdAt' },\n ],\n tokens.map((token) => ({\n id: token.id,\n name: token.name ?? '',\n createdAt: token.createdAt.toISOString(),\n })),\n );\n}\n","import color from 'picocolors';\n\nimport { readInterceptorTokenFromFile, removeInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenId: string;\n tokensDirectory: string;\n}\n\nexport async function removeInterceptorServerToken({ tokenId, tokensDirectory }: InterceptorServerCreateTokenOptions) {\n const token = await readInterceptorTokenFromFile(tokenId, { tokensDirectory });\n\n if (!token) {\n logger.error(`${color.red(color.bold('✘'))} Token ${color.red(tokenId)} not found.`);\n process.exit(1);\n }\n\n await removeInterceptorToken(token.id, { tokensDirectory });\n\n logger.info(`${color.green(color.bold('✔'))} Token ${color.green(token.name ?? token.id)} removed.`);\n}\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY } from '../server/utils/auth';\nimport initializeBrowserServiceWorker from './browser/init';\nimport startInterceptorServer from './server/start';\nimport { createInterceptorServerToken } from './server/token/create';\nimport { listInterceptorServerTokens } from './server/token/list';\nimport { removeInterceptorServerToken } from './server/token/remove';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-interceptor')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('browser', 'Manage your browser mock configuration.', (yargs) =>\n yargs.demandCommand().command(\n 'init <publicDirectory>',\n 'Initialize the browser service worker configuration.',\n (yargs) =>\n yargs.positional('publicDirectory', {\n type: 'string',\n description: 'The path to the public directory of your application.',\n demandOption: true,\n }),\n async (cliArguments) => {\n await initializeBrowserServiceWorker({\n publicDirectory: cliArguments.publicDirectory,\n });\n },\n ),\n )\n\n .command('server', 'Manage interceptor servers.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'start [-- onReady]',\n 'Start an interceptor server.',\n (yargs) =>\n yargs\n .positional('onReady', {\n description: 'A command to run when the server is ready to accept connections.',\n type: 'string',\n })\n .option('hostname', {\n type: 'string',\n description: 'The hostname to start the server on.',\n alias: 'h',\n default: 'localhost',\n })\n .option('port', {\n type: 'number',\n description: 'The port to start the server on.',\n alias: 'p',\n })\n .option('ephemeral', {\n type: 'boolean',\n description:\n 'Whether the server should stop automatically after the on-ready command finishes. ' +\n 'If no on-ready command is provided and ephemeral is true, the server will stop immediately after ' +\n 'starting.',\n alias: 'e',\n default: false,\n })\n .option('log-unhandled-requests', {\n type: 'boolean',\n description:\n 'Whether to log a warning when no interceptors were found for the base URL of a request. ' +\n 'If an interceptor was matched, the logging behavior for that base URL is configured in the ' +\n 'interceptor itself.',\n alias: 'l',\n })\n .option('tokens-dir', {\n type: 'string',\n description:\n 'The directory where the authorized interceptor authentication tokens are saved. If provided, only ' +\n 'remote interceptors bearing a valid token will be accepted. This option is essential if you are ' +\n 'exposing your interceptor server publicly. For local development and testing, though, ' +\n '`--tokens-dir` is optional.',\n alias: 't',\n }),\n async (cliArguments) => {\n const onReadyCommand = cliArguments._.at(2)?.toString();\n const onReadyCommandArguments = cliArguments._.slice(3).map((argument) => argument.toString());\n\n await startInterceptorServer({\n hostname: cliArguments.hostname,\n port: cliArguments.port,\n ephemeral: cliArguments.ephemeral,\n logUnhandledRequests: cliArguments.logUnhandledRequests,\n tokensDirectory: cliArguments.tokensDir,\n onReady: onReadyCommand\n ? {\n command: onReadyCommand.toString(),\n arguments: onReadyCommandArguments,\n }\n : undefined,\n });\n },\n )\n\n .command('token', 'Manage remote interceptor authentication tokens.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'create',\n 'Create an interceptor token.',\n (yargs) =>\n yargs\n .option('name', {\n type: 'string',\n description: 'The name of the token to create.',\n alias: 'n',\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the created interceptor token will be saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await createInterceptorServerToken({\n tokenName: cliArguments.name,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['ls', 'list'],\n 'List the authorized interceptor tokens.',\n (yargs) =>\n yargs.option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await listInterceptorServerTokens({\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['rm <tokenId>', 'remove <tokenId>'],\n 'Remove (invalidate) an interceptor token. Existing connections will not be affected, so restarting the ' +\n 'server is recommended to disconnect all interceptors.',\n (yargs) =>\n yargs\n .positional('tokenId', {\n type: 'string',\n description: 'The identifier of the token to remove.',\n demandOption: true,\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await removeInterceptorServerToken({\n tokenId: cliArguments.tokenId,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n ),\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli/browser/shared/constants.ts","../src/cli/browser/init.ts","../src/utils/processes.ts","../src/cli/server/start.ts","../src/cli/server/token/create.ts","../src/cli/server/token/list.ts","../src/cli/server/token/remove.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["path","__require","fs","logger","color","__name","createCachedDynamicImport_default","createInterceptorServer","exitEvent","createInterceptorToken","listInterceptorTokens","readInterceptorTokenFromFile","removeInterceptorToken","yargs","hideBin","DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBE,IAAA,OAAA,GAAW,iBAAA;;;AChBN,IAAM,wBAAA,GAA2B,sBAAA;;;ACQxC,IAAM,aAAA,GAAgBA,sBAAK,IAAA,CAAKC,0BAAA,CAAQ,QAAQ,KAAK,CAAA,EAAG,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA;AACjE,IAAM,wBAAA,GAA2BD,qBAAA,CAAK,IAAA,CAAK,aAAA,EAAe,OAAO,wBAAwB,CAAA;AAMhG,eAAe,8BAAA,CAA+B,EAAE,eAAA,EAAgB,EAAoC;AAClG,EAAA,MAAME,oBAAG,QAAA,CAAS,KAAA,CAAM,iBAAiB,EAAE,SAAA,EAAW,MAAM,CAAA;AAE5D,EAAA,MAAM,eAAA,GAAkBF,qBAAA,CAAK,IAAA,CAAK,eAAA,EAAiB,wBAAwB,CAAA;AAC3E,EAAA,MAAME,mBAAA,CAAG,QAAA,CAAS,QAAA,CAAS,wBAAA,EAA0B,eAAe,CAAA;AAEpE,EAAAC,uBAAA,CAAO,KAAK,CAA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AA;AAAA,UACb,KAAA,EAAO,GAAA;AAAA,UACP,OAAA,EAASE;AAAA,SACV,CAAA;AAAA,QACL,OAAO,YAAA,KAAiB;AACtB,UAAA,MAAM,4BAAA,CAA6B;AAAA,YACjC,SAAS,YAAA,CAAa,OAAA;AAAA,YACtB,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH;AACF;AACJ,IAGH,KAAA,EAAM;AACX;AAtKeV,uBAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAwKf,IAAO,WAAA,GAAQ,MAAA;;;ACjLf,KAAK,WAAA,EAAO","file":"cli.js","sourcesContent":["{\n \"name\": \"@zimic/interceptor\",\n \"description\": \"Next-gen TypeScript-first HTTP intercepting and mocking\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"interceptor\",\n \"mock\",\n \"api\",\n \"static\"\n ],\n \"version\": \"0.21.0-canary.1\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-interceptor\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"http.d.ts\",\n \"server.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-interceptor\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./http\": {\n \"types\": \"./http.d.ts\",\n \"import\": \"./dist/http.mjs\",\n \"require\": \"./dist/http.js\",\n \"default\": \"./dist/http.js\"\n },\n \"./server\": {\n \"types\": \"./server.d.ts\",\n \"import\": \"./dist/server.mjs\",\n \"require\": \"./dist/server.js\",\n \"default\": \"./dist/server.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"deps:install-playwright\": \"playwright install chromium\",\n \"deps:init-msw\": \"msw init ./public --no-save\",\n \"deps:prepare\": \"pnpm deps:install-playwright && pnpm deps:init-msw\",\n \"postinstall\": \"node --enable-source-maps -e \\\"try{require('./dist/scripts/postinstall')}catch(error){console.error(error)}\\\"\"\n },\n \"dependencies\": {\n \"@whatwg-node/server\": \"0.10.10\",\n \"execa\": \"9.6.0\",\n \"isomorphic-ws\": \"5.0.0\",\n \"msw\": \"2.10.2\",\n \"picocolors\": \"^1.1.1\",\n \"ws\": \"8.18.3\",\n \"yargs\": \"18.0.0\",\n \"zod\": \"^3.25.67\"\n },\n \"optionalDependencies\": {\n \"bufferutil\": \"4.0.9\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.0.7\",\n \"@types/ws\": \"^8.18.1\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^8.0.0\",\n \"eslint\": \"^9.30.0\",\n \"playwright\": \"^1.53.1\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"@zimic/http\": \"^0.7.0 || workspace:*\",\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","export const SERVICE_WORKER_FILE_NAME = 'mockServiceWorker.js';\n","import fs from 'fs';\nimport path from 'path';\nimport color from 'picocolors';\n\nimport { logger } from '@/utils/logging';\n\nimport { SERVICE_WORKER_FILE_NAME } from './shared/constants';\n\nconst MSW_ROOT_PATH = path.join(require.resolve('msw'), '..', '..', '..');\nexport const MOCK_SERVICE_WORKER_PATH = path.join(MSW_ROOT_PATH, 'lib', SERVICE_WORKER_FILE_NAME);\n\ninterface BrowserServiceWorkerInitOptions {\n publicDirectory: string;\n}\n\nasync function initializeBrowserServiceWorker({ publicDirectory }: BrowserServiceWorkerInitOptions) {\n await fs.promises.mkdir(publicDirectory, { recursive: true });\n\n const destinationPath = path.join(publicDirectory, SERVICE_WORKER_FILE_NAME);\n await fs.promises.copyFile(MOCK_SERVICE_WORKER_PATH, destinationPath);\n\n logger.info(`Service worker script saved to ${color.magenta(destinationPath)}.`);\n}\n\nexport default initializeBrowserServiceWorker;\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\n\nexport const PROCESS_EXIT_EVENTS = Object.freeze([\n 'beforeExit',\n 'uncaughtExceptionMonitor',\n 'SIGINT',\n 'SIGTERM',\n 'SIGHUP',\n 'SIGBREAK',\n] as const);\n\nexport type ProcessExitEvent = (typeof PROCESS_EXIT_EVENTS)[number];\n\n// Having an undefined exit code means that the process will already exit with the default exit code.\nexport const PROCESS_EXIT_CODE_BY_EXIT_EVENT: Record<string, number | undefined> = {\n beforeExit: undefined,\n uncaughtExceptionMonitor: undefined,\n SIGINT: 130,\n SIGTERM: 143,\n SIGHUP: 129,\n SIGBREAK: 131,\n} satisfies Record<ProcessExitEvent, number | undefined>;\n\nexport const importExeca = createCachedDynamicImport(() => import('execa'));\n\ninterface CommandErrorOptions {\n command?: string[];\n exitCode?: number;\n signal?: NodeJS.Signals;\n originalMessage?: string;\n}\n\nexport class CommandError extends Error {\n static readonly DEFAULT_EXIT_CODE = 1;\n\n readonly command: string[];\n readonly exitCode: number;\n readonly signal?: NodeJS.Signals;\n\n constructor(executable: string, options: CommandErrorOptions) {\n const message = CommandError.createMessage(executable, options);\n super(message);\n\n this.name = 'CommandError';\n this.command = options.command ?? [executable];\n this.exitCode = this.getExitCode(options);\n this.signal = options.signal;\n }\n\n private getExitCode(options: CommandErrorOptions): number {\n const existingExitCode = options.exitCode;\n const exitCodeInferredFromSignal =\n options.signal === undefined ? undefined : PROCESS_EXIT_CODE_BY_EXIT_EVENT[options.signal];\n\n return existingExitCode ?? exitCodeInferredFromSignal ?? CommandError.DEFAULT_EXIT_CODE;\n }\n\n private static createMessage(command: string, options: CommandErrorOptions) {\n const suffix = options.originalMessage ? `: ${options.originalMessage}` : '';\n\n if (options.exitCode === undefined && options.signal === undefined) {\n return `Command '${command}' failed${suffix}`;\n }\n\n const prefix = `Command '${command}' exited `;\n const infix = options.exitCode === undefined ? `after signal ${options.signal}` : `with code ${options.exitCode}`;\n\n return `${prefix}${infix}${suffix}`;\n }\n}\n\nexport async function runCommand(commandEntry: string, commandArguments: string[]) {\n const { execa: $, ExecaError } = await importExeca();\n\n try {\n await $(commandEntry, commandArguments, { stdio: 'inherit' });\n } catch (error) {\n /* istanbul ignore if -- @preserve\n * This is a safeguard if the error is not an ExecaError. It is not expected to run. */\n if (!(error instanceof ExecaError)) {\n throw error;\n }\n\n const commandError = new CommandError(commandEntry, {\n command: [commandEntry, ...commandArguments],\n exitCode: error.exitCode,\n signal: error.signal,\n originalMessage: error.originalMessage,\n });\n\n throw commandError;\n }\n}\n","import color from 'picocolors';\n\nimport { InterceptorServer, createInterceptorServer } from '@/server';\nimport { InterceptorServerOptions } from '@/server/types/options';\nimport { logger } from '@/utils/logging';\nimport {\n CommandError,\n PROCESS_EXIT_CODE_BY_EXIT_EVENT,\n PROCESS_EXIT_EVENTS,\n ProcessExitEvent,\n runCommand,\n} from '@/utils/processes';\n\ninterface InterceptorServerStartOptions extends InterceptorServerOptions {\n ephemeral: boolean;\n onReady?: { command: string; arguments: string[] };\n}\n\nexport let serverSingleton: InterceptorServer | undefined;\n\nasync function startInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n ephemeral,\n onReady,\n}: InterceptorServerStartOptions) {\n const server = createInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n });\n\n async function handleExitEvent(exitEvent: ProcessExitEvent | undefined) {\n await server.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.off(exitEvent, exitHandler);\n }\n\n const exitCode = exitEvent ? PROCESS_EXIT_CODE_BY_EXIT_EVENT[exitEvent] : undefined;\n if (exitCode !== undefined) {\n process.exit(exitCode);\n }\n }\n\n const exitHandlerGroups = PROCESS_EXIT_EVENTS.map((exitEvent) => ({\n exitEvent,\n exitHandler: handleExitEvent.bind(null, exitEvent),\n }));\n\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.on(exitEvent, exitHandler);\n }\n\n serverSingleton = server;\n\n await server.start();\n\n logger.info(\n `${ephemeral ? 'Ephemeral s' : 'S'}erver is running on ${color.yellow(`${server.hostname}:${server.port}`)}`,\n );\n\n const isDangerouslyUnprotected = !tokensDirectory && process.env.NODE_ENV === 'production';\n\n if (isDangerouslyUnprotected) {\n logger.warn(\n [\n `Attention: this interceptor server is ${color.bold(color.red('unprotected'))}. Do not expose it publicly without authentication.`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n }\n\n if (onReady) {\n try {\n await runCommand(onReady.command, onReady.arguments);\n } catch (error) {\n console.error(error);\n\n /* istanbul ignore if -- @preserve\n * A CommandError is always expected here. */\n if (!(error instanceof CommandError)) {\n throw error;\n }\n\n process.exit(error.exitCode);\n }\n }\n\n if (ephemeral) {\n await handleExitEvent(undefined);\n process.exit(0);\n }\n}\n\nexport default startInterceptorServer;\n","import color from 'picocolors';\n\nimport { createInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenName?: string;\n tokensDirectory: string;\n}\n\nexport async function createInterceptorServerToken({\n tokenName,\n tokensDirectory,\n}: InterceptorServerCreateTokenOptions) {\n const token = await createInterceptorToken({ name: tokenName, tokensDirectory });\n\n logger.info(\n [\n `${color.green(color.bold('✔'))} Token${tokenName ? ` ${color.green(tokenName)}` : ''} created:`,\n '',\n color.yellow(token.value),\n '',\n 'Store this token securely. It cannot be retrieved later.',\n '',\n `To enable authentication in your interceptor server, use the ${color.cyan('--tokens-dir')} option. Only ` +\n 'remote interceptors bearing a valid token will be allowed to connect.',\n '',\n `${color.dim('$')} zimic-interceptor server start ${color.cyan('--tokens-dir')} ${color.magenta(tokensDirectory)}`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n}\n","import { listInterceptorTokens } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerListTokensOptions {\n tokensDirectory: string;\n}\n\nexport async function listInterceptorServerTokens({ tokensDirectory }: InterceptorServerListTokensOptions) {\n const tokens = await listInterceptorTokens({ tokensDirectory });\n\n logger.raw.table(\n [\n { title: 'ID', property: 'id' },\n { title: 'NAME', property: 'name' },\n { title: 'CREATED AT', property: 'createdAt' },\n ],\n tokens.map((token) => ({\n id: token.id,\n name: token.name ?? '',\n createdAt: token.createdAt.toISOString(),\n })),\n );\n}\n","import color from 'picocolors';\n\nimport { readInterceptorTokenFromFile, removeInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenId: string;\n tokensDirectory: string;\n}\n\nexport async function removeInterceptorServerToken({ tokenId, tokensDirectory }: InterceptorServerCreateTokenOptions) {\n const token = await readInterceptorTokenFromFile(tokenId, { tokensDirectory });\n\n if (!token) {\n logger.error(`${color.red(color.bold('✘'))} Token ${color.red(tokenId)} not found.`);\n process.exit(1);\n }\n\n await removeInterceptorToken(token.id, { tokensDirectory });\n\n logger.info(`${color.green(color.bold('✔'))} Token ${color.green(token.name ?? token.id)} removed.`);\n}\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY } from '../server/utils/auth';\nimport initializeBrowserServiceWorker from './browser/init';\nimport startInterceptorServer from './server/start';\nimport { createInterceptorServerToken } from './server/token/create';\nimport { listInterceptorServerTokens } from './server/token/list';\nimport { removeInterceptorServerToken } from './server/token/remove';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-interceptor')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('browser', 'Manage your browser mock configuration.', (yargs) =>\n yargs.demandCommand().command(\n 'init <publicDirectory>',\n 'Initialize the browser service worker configuration.',\n (yargs) =>\n yargs.positional('publicDirectory', {\n type: 'string',\n description: 'The path to the public directory of your application.',\n demandOption: true,\n }),\n async (cliArguments) => {\n await initializeBrowserServiceWorker({\n publicDirectory: cliArguments.publicDirectory,\n });\n },\n ),\n )\n\n .command('server', 'Manage interceptor servers.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'start [-- onReady]',\n 'Start an interceptor server.',\n (yargs) =>\n yargs\n .positional('onReady', {\n description: 'A command to run when the server is ready to accept connections.',\n type: 'string',\n })\n .option('hostname', {\n type: 'string',\n description: 'The hostname to start the server on.',\n alias: 'h',\n default: 'localhost',\n })\n .option('port', {\n type: 'number',\n description: 'The port to start the server on.',\n alias: 'p',\n })\n .option('ephemeral', {\n type: 'boolean',\n description:\n 'Whether the server should stop automatically after the on-ready command finishes. ' +\n 'If no on-ready command is provided and ephemeral is true, the server will stop immediately after ' +\n 'starting.',\n alias: 'e',\n default: false,\n })\n .option('log-unhandled-requests', {\n type: 'boolean',\n description:\n 'Whether to log a warning when no interceptors were found for the base URL of a request. ' +\n 'If an interceptor was matched, the logging behavior for that base URL is configured in the ' +\n 'interceptor itself.',\n alias: 'l',\n })\n .option('tokens-dir', {\n type: 'string',\n description:\n 'The directory where the authorized interceptor authentication tokens are saved. If provided, only ' +\n 'remote interceptors bearing a valid token will be accepted. This option is essential if you are ' +\n 'exposing your interceptor server publicly. For local development and testing, though, ' +\n '`--tokens-dir` is optional.',\n alias: 't',\n }),\n async (cliArguments) => {\n const onReadyCommand = cliArguments._.at(2)?.toString();\n const onReadyCommandArguments = cliArguments._.slice(3).map((argument) => argument.toString());\n\n await startInterceptorServer({\n hostname: cliArguments.hostname,\n port: cliArguments.port,\n ephemeral: cliArguments.ephemeral,\n logUnhandledRequests: cliArguments.logUnhandledRequests,\n tokensDirectory: cliArguments.tokensDir,\n onReady: onReadyCommand\n ? {\n command: onReadyCommand.toString(),\n arguments: onReadyCommandArguments,\n }\n : undefined,\n });\n },\n )\n\n .command('token', 'Manage remote interceptor authentication tokens.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'create',\n 'Create an interceptor token.',\n (yargs) =>\n yargs\n .option('name', {\n type: 'string',\n description: 'The name of the token to create.',\n alias: 'n',\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the created interceptor token will be saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await createInterceptorServerToken({\n tokenName: cliArguments.name,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['ls', 'list'],\n 'List the authorized interceptor tokens.',\n (yargs) =>\n yargs.option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await listInterceptorServerTokens({\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['rm <tokenId>', 'remove <tokenId>'],\n 'Remove (invalidate) an interceptor token. Existing connections will not be affected, so restarting the ' +\n 'server is recommended to disconnect all interceptors.',\n (yargs) =>\n yargs\n .positional('tokenId', {\n type: 'string',\n description: 'The identifier of the token to remove.',\n demandOption: true,\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await removeInterceptorServerToken({\n tokenId: cliArguments.tokenId,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n ),\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createCachedDynamicImport_default, logger, createInterceptorServer, createInterceptorToken, listInterceptorTokens, readInterceptorTokenFromFile, removeInterceptorToken, DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY } from './chunk-
|
|
2
|
+
import { createCachedDynamicImport_default, logger, createInterceptorServer, createInterceptorToken, listInterceptorTokens, readInterceptorTokenFromFile, removeInterceptorToken, DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY } from './chunk-FQH2EMUC.mjs';
|
|
3
3
|
import { __require, __name } from './chunk-CGILA3WO.mjs';
|
|
4
4
|
import yargs from 'yargs';
|
|
5
5
|
import { hideBin } from 'yargs/helpers';
|
|
@@ -8,7 +8,7 @@ import path from 'path';
|
|
|
8
8
|
import color3 from 'picocolors';
|
|
9
9
|
|
|
10
10
|
// package.json
|
|
11
|
-
var version = "0.
|
|
11
|
+
var version = "0.21.0-canary.1";
|
|
12
12
|
|
|
13
13
|
// src/cli/browser/shared/constants.ts
|
|
14
14
|
var SERVICE_WORKER_FILE_NAME = "mockServiceWorker.js";
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/cli/browser/shared/constants.ts","../src/cli/browser/init.ts","../src/utils/processes.ts","../src/cli/server/start.ts","../src/cli/server/token/create.ts","../src/cli/server/token/list.ts","../src/cli/server/token/remove.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["color","exitEvent","yargs"],"mappings":";;;;;;;;;;AAgBE,IAAA,OAAA,GAAW,QAAA;;;AChBN,IAAM,wBAAA,GAA2B,sBAAA;;;ACQxC,IAAM,aAAA,GAAgB,KAAK,IAAA,CAAK,SAAA,CAAQ,QAAQ,KAAK,CAAA,EAAG,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA;AACjE,IAAM,wBAAA,GAA2B,IAAA,CAAK,IAAA,CAAK,aAAA,EAAe,OAAO,wBAAwB,CAAA;AAMhG,eAAe,8BAAA,CAA+B,EAAE,eAAA,EAAgB,EAAoC;AAClG,EAAA,MAAM,GAAG,QAAA,CAAS,KAAA,CAAM,iBAAiB,EAAE,SAAA,EAAW,MAAM,CAAA;AAE5D,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,IAAA,CAAK,eAAA,EAAiB,wBAAwB,CAAA;AAC3E,EAAA,MAAM,EAAA,CAAG,QAAA,CAAS,QAAA,CAAS,wBAAA,EAA0B,eAAe,CAAA;AAEpE,EAAA,M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AA,EAAS;AAAA,SACV,CAAA;AAAA,QACL,OAAO,YAAA,KAAiB;AACtB,UAAA,MAAM,4BAAA,CAA6B;AAAA,YACjC,SAAS,YAAA,CAAa,OAAA;AAAA,YACtB,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH;AACF;AACJ,IAGH,KAAA,EAAM;AACX;AAtKe,MAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAwKf,IAAO,WAAA,GAAQ,MAAA;;;ACjLf,KAAK,WAAA,EAAO","file":"cli.mjs","sourcesContent":["{\n \"name\": \"@zimic/interceptor\",\n \"description\": \"Next-gen TypeScript-first HTTP intercepting and mocking\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"interceptor\",\n \"mock\",\n \"api\",\n \"static\"\n ],\n \"version\": \"0.20.2\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-interceptor\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"http.d.ts\",\n \"server.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-interceptor\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./http\": {\n \"types\": \"./http.d.ts\",\n \"import\": \"./dist/http.mjs\",\n \"require\": \"./dist/http.js\",\n \"default\": \"./dist/http.js\"\n },\n \"./server\": {\n \"types\": \"./server.d.ts\",\n \"import\": \"./dist/server.mjs\",\n \"require\": \"./dist/server.js\",\n \"default\": \"./dist/server.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"deps:install-playwright\": \"playwright install chromium\",\n \"deps:init-msw\": \"msw init ./public --no-save\",\n \"deps:prepare\": \"pnpm deps:install-playwright && pnpm deps:init-msw\",\n \"postinstall\": \"node --enable-source-maps -e \\\"try{require('./dist/scripts/postinstall')}catch(error){console.error(error)}\\\"\"\n },\n \"dependencies\": {\n \"@whatwg-node/server\": \"0.10.10\",\n \"execa\": \"9.6.0\",\n \"isomorphic-ws\": \"5.0.0\",\n \"msw\": \"2.10.2\",\n \"picocolors\": \"^1.1.1\",\n \"ws\": \"8.18.3\",\n \"yargs\": \"18.0.0\",\n \"zod\": \"^3.25.67\"\n },\n \"optionalDependencies\": {\n \"bufferutil\": \"4.0.9\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.0.7\",\n \"@types/ws\": \"^8.18.1\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^8.0.0\",\n \"eslint\": \"^9.30.0\",\n \"playwright\": \"^1.53.1\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"@zimic/http\": \"^0.6.0 || workspace:*\",\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","export const SERVICE_WORKER_FILE_NAME = 'mockServiceWorker.js';\n","import fs from 'fs';\nimport path from 'path';\nimport color from 'picocolors';\n\nimport { logger } from '@/utils/logging';\n\nimport { SERVICE_WORKER_FILE_NAME } from './shared/constants';\n\nconst MSW_ROOT_PATH = path.join(require.resolve('msw'), '..', '..', '..');\nexport const MOCK_SERVICE_WORKER_PATH = path.join(MSW_ROOT_PATH, 'lib', SERVICE_WORKER_FILE_NAME);\n\ninterface BrowserServiceWorkerInitOptions {\n publicDirectory: string;\n}\n\nasync function initializeBrowserServiceWorker({ publicDirectory }: BrowserServiceWorkerInitOptions) {\n await fs.promises.mkdir(publicDirectory, { recursive: true });\n\n const destinationPath = path.join(publicDirectory, SERVICE_WORKER_FILE_NAME);\n await fs.promises.copyFile(MOCK_SERVICE_WORKER_PATH, destinationPath);\n\n logger.info(`Service worker script saved to ${color.magenta(destinationPath)}.`);\n}\n\nexport default initializeBrowserServiceWorker;\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\n\nexport const PROCESS_EXIT_EVENTS = Object.freeze([\n 'beforeExit',\n 'uncaughtExceptionMonitor',\n 'SIGINT',\n 'SIGTERM',\n 'SIGHUP',\n 'SIGBREAK',\n] as const);\n\nexport type ProcessExitEvent = (typeof PROCESS_EXIT_EVENTS)[number];\n\n// Having an undefined exit code means that the process will already exit with the default exit code.\nexport const PROCESS_EXIT_CODE_BY_EXIT_EVENT: Record<string, number | undefined> = {\n beforeExit: undefined,\n uncaughtExceptionMonitor: undefined,\n SIGINT: 130,\n SIGTERM: 143,\n SIGHUP: 129,\n SIGBREAK: 131,\n} satisfies Record<ProcessExitEvent, number | undefined>;\n\nexport const importExeca = createCachedDynamicImport(() => import('execa'));\n\ninterface CommandErrorOptions {\n command?: string[];\n exitCode?: number;\n signal?: NodeJS.Signals;\n originalMessage?: string;\n}\n\nexport class CommandError extends Error {\n static readonly DEFAULT_EXIT_CODE = 1;\n\n readonly command: string[];\n readonly exitCode: number;\n readonly signal?: NodeJS.Signals;\n\n constructor(executable: string, options: CommandErrorOptions) {\n const message = CommandError.createMessage(executable, options);\n super(message);\n\n this.name = 'CommandError';\n this.command = options.command ?? [executable];\n this.exitCode = this.getExitCode(options);\n this.signal = options.signal;\n }\n\n private getExitCode(options: CommandErrorOptions): number {\n const existingExitCode = options.exitCode;\n const exitCodeInferredFromSignal =\n options.signal === undefined ? undefined : PROCESS_EXIT_CODE_BY_EXIT_EVENT[options.signal];\n\n return existingExitCode ?? exitCodeInferredFromSignal ?? CommandError.DEFAULT_EXIT_CODE;\n }\n\n private static createMessage(command: string, options: CommandErrorOptions) {\n const suffix = options.originalMessage ? `: ${options.originalMessage}` : '';\n\n if (options.exitCode === undefined && options.signal === undefined) {\n return `Command '${command}' failed${suffix}`;\n }\n\n const prefix = `Command '${command}' exited `;\n const infix = options.exitCode === undefined ? `after signal ${options.signal}` : `with code ${options.exitCode}`;\n\n return `${prefix}${infix}${suffix}`;\n }\n}\n\nexport async function runCommand(commandEntry: string, commandArguments: string[]) {\n const { execa: $, ExecaError } = await importExeca();\n\n try {\n await $(commandEntry, commandArguments, { stdio: 'inherit' });\n } catch (error) {\n /* istanbul ignore if -- @preserve\n * This is a safeguard if the error is not an ExecaError. It is not expected to run. */\n if (!(error instanceof ExecaError)) {\n throw error;\n }\n\n const commandError = new CommandError(commandEntry, {\n command: [commandEntry, ...commandArguments],\n exitCode: error.exitCode,\n signal: error.signal,\n originalMessage: error.originalMessage,\n });\n\n throw commandError;\n }\n}\n","import color from 'picocolors';\n\nimport { InterceptorServer, createInterceptorServer } from '@/server';\nimport { InterceptorServerOptions } from '@/server/types/options';\nimport { logger } from '@/utils/logging';\nimport {\n CommandError,\n PROCESS_EXIT_CODE_BY_EXIT_EVENT,\n PROCESS_EXIT_EVENTS,\n ProcessExitEvent,\n runCommand,\n} from '@/utils/processes';\n\ninterface InterceptorServerStartOptions extends InterceptorServerOptions {\n ephemeral: boolean;\n onReady?: { command: string; arguments: string[] };\n}\n\nexport let serverSingleton: InterceptorServer | undefined;\n\nasync function startInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n ephemeral,\n onReady,\n}: InterceptorServerStartOptions) {\n const server = createInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n });\n\n async function handleExitEvent(exitEvent: ProcessExitEvent | undefined) {\n await server.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.off(exitEvent, exitHandler);\n }\n\n const exitCode = exitEvent ? PROCESS_EXIT_CODE_BY_EXIT_EVENT[exitEvent] : undefined;\n if (exitCode !== undefined) {\n process.exit(exitCode);\n }\n }\n\n const exitHandlerGroups = PROCESS_EXIT_EVENTS.map((exitEvent) => ({\n exitEvent,\n exitHandler: handleExitEvent.bind(null, exitEvent),\n }));\n\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.on(exitEvent, exitHandler);\n }\n\n serverSingleton = server;\n\n await server.start();\n\n logger.info(\n `${ephemeral ? 'Ephemeral s' : 'S'}erver is running on ${color.yellow(`${server.hostname}:${server.port}`)}`,\n );\n\n const isDangerouslyUnprotected = !tokensDirectory && process.env.NODE_ENV === 'production';\n\n if (isDangerouslyUnprotected) {\n logger.warn(\n [\n `Attention: this interceptor server is ${color.bold(color.red('unprotected'))}. Do not expose it publicly without authentication.`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n }\n\n if (onReady) {\n try {\n await runCommand(onReady.command, onReady.arguments);\n } catch (error) {\n console.error(error);\n\n /* istanbul ignore if -- @preserve\n * A CommandError is always expected here. */\n if (!(error instanceof CommandError)) {\n throw error;\n }\n\n process.exit(error.exitCode);\n }\n }\n\n if (ephemeral) {\n await handleExitEvent(undefined);\n process.exit(0);\n }\n}\n\nexport default startInterceptorServer;\n","import color from 'picocolors';\n\nimport { createInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenName?: string;\n tokensDirectory: string;\n}\n\nexport async function createInterceptorServerToken({\n tokenName,\n tokensDirectory,\n}: InterceptorServerCreateTokenOptions) {\n const token = await createInterceptorToken({ name: tokenName, tokensDirectory });\n\n logger.info(\n [\n `${color.green(color.bold('✔'))} Token${tokenName ? ` ${color.green(tokenName)}` : ''} created:`,\n '',\n color.yellow(token.value),\n '',\n 'Store this token securely. It cannot be retrieved later.',\n '',\n `To enable authentication in your interceptor server, use the ${color.cyan('--tokens-dir')} option. Only ` +\n 'remote interceptors bearing a valid token will be allowed to connect.',\n '',\n `${color.dim('$')} zimic-interceptor server start ${color.cyan('--tokens-dir')} ${color.magenta(tokensDirectory)}`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n}\n","import { listInterceptorTokens } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerListTokensOptions {\n tokensDirectory: string;\n}\n\nexport async function listInterceptorServerTokens({ tokensDirectory }: InterceptorServerListTokensOptions) {\n const tokens = await listInterceptorTokens({ tokensDirectory });\n\n logger.raw.table(\n [\n { title: 'ID', property: 'id' },\n { title: 'NAME', property: 'name' },\n { title: 'CREATED AT', property: 'createdAt' },\n ],\n tokens.map((token) => ({\n id: token.id,\n name: token.name ?? '',\n createdAt: token.createdAt.toISOString(),\n })),\n );\n}\n","import color from 'picocolors';\n\nimport { readInterceptorTokenFromFile, removeInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenId: string;\n tokensDirectory: string;\n}\n\nexport async function removeInterceptorServerToken({ tokenId, tokensDirectory }: InterceptorServerCreateTokenOptions) {\n const token = await readInterceptorTokenFromFile(tokenId, { tokensDirectory });\n\n if (!token) {\n logger.error(`${color.red(color.bold('✘'))} Token ${color.red(tokenId)} not found.`);\n process.exit(1);\n }\n\n await removeInterceptorToken(token.id, { tokensDirectory });\n\n logger.info(`${color.green(color.bold('✔'))} Token ${color.green(token.name ?? token.id)} removed.`);\n}\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY } from '../server/utils/auth';\nimport initializeBrowserServiceWorker from './browser/init';\nimport startInterceptorServer from './server/start';\nimport { createInterceptorServerToken } from './server/token/create';\nimport { listInterceptorServerTokens } from './server/token/list';\nimport { removeInterceptorServerToken } from './server/token/remove';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-interceptor')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('browser', 'Manage your browser mock configuration.', (yargs) =>\n yargs.demandCommand().command(\n 'init <publicDirectory>',\n 'Initialize the browser service worker configuration.',\n (yargs) =>\n yargs.positional('publicDirectory', {\n type: 'string',\n description: 'The path to the public directory of your application.',\n demandOption: true,\n }),\n async (cliArguments) => {\n await initializeBrowserServiceWorker({\n publicDirectory: cliArguments.publicDirectory,\n });\n },\n ),\n )\n\n .command('server', 'Manage interceptor servers.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'start [-- onReady]',\n 'Start an interceptor server.',\n (yargs) =>\n yargs\n .positional('onReady', {\n description: 'A command to run when the server is ready to accept connections.',\n type: 'string',\n })\n .option('hostname', {\n type: 'string',\n description: 'The hostname to start the server on.',\n alias: 'h',\n default: 'localhost',\n })\n .option('port', {\n type: 'number',\n description: 'The port to start the server on.',\n alias: 'p',\n })\n .option('ephemeral', {\n type: 'boolean',\n description:\n 'Whether the server should stop automatically after the on-ready command finishes. ' +\n 'If no on-ready command is provided and ephemeral is true, the server will stop immediately after ' +\n 'starting.',\n alias: 'e',\n default: false,\n })\n .option('log-unhandled-requests', {\n type: 'boolean',\n description:\n 'Whether to log a warning when no interceptors were found for the base URL of a request. ' +\n 'If an interceptor was matched, the logging behavior for that base URL is configured in the ' +\n 'interceptor itself.',\n alias: 'l',\n })\n .option('tokens-dir', {\n type: 'string',\n description:\n 'The directory where the authorized interceptor authentication tokens are saved. If provided, only ' +\n 'remote interceptors bearing a valid token will be accepted. This option is essential if you are ' +\n 'exposing your interceptor server publicly. For local development and testing, though, ' +\n '`--tokens-dir` is optional.',\n alias: 't',\n }),\n async (cliArguments) => {\n const onReadyCommand = cliArguments._.at(2)?.toString();\n const onReadyCommandArguments = cliArguments._.slice(3).map((argument) => argument.toString());\n\n await startInterceptorServer({\n hostname: cliArguments.hostname,\n port: cliArguments.port,\n ephemeral: cliArguments.ephemeral,\n logUnhandledRequests: cliArguments.logUnhandledRequests,\n tokensDirectory: cliArguments.tokensDir,\n onReady: onReadyCommand\n ? {\n command: onReadyCommand.toString(),\n arguments: onReadyCommandArguments,\n }\n : undefined,\n });\n },\n )\n\n .command('token', 'Manage remote interceptor authentication tokens.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'create',\n 'Create an interceptor token.',\n (yargs) =>\n yargs\n .option('name', {\n type: 'string',\n description: 'The name of the token to create.',\n alias: 'n',\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the created interceptor token will be saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await createInterceptorServerToken({\n tokenName: cliArguments.name,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['ls', 'list'],\n 'List the authorized interceptor tokens.',\n (yargs) =>\n yargs.option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await listInterceptorServerTokens({\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['rm <tokenId>', 'remove <tokenId>'],\n 'Remove (invalidate) an interceptor token. Existing connections will not be affected, so restarting the ' +\n 'server is recommended to disconnect all interceptors.',\n (yargs) =>\n yargs\n .positional('tokenId', {\n type: 'string',\n description: 'The identifier of the token to remove.',\n demandOption: true,\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await removeInterceptorServerToken({\n tokenId: cliArguments.tokenId,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n ),\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli/browser/shared/constants.ts","../src/cli/browser/init.ts","../src/utils/processes.ts","../src/cli/server/start.ts","../src/cli/server/token/create.ts","../src/cli/server/token/list.ts","../src/cli/server/token/remove.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["color","exitEvent","yargs"],"mappings":";;;;;;;;;;AAgBE,IAAA,OAAA,GAAW,iBAAA;;;AChBN,IAAM,wBAAA,GAA2B,sBAAA;;;ACQxC,IAAM,aAAA,GAAgB,KAAK,IAAA,CAAK,SAAA,CAAQ,QAAQ,KAAK,CAAA,EAAG,IAAA,EAAM,IAAA,EAAM,IAA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A,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH,OACF,CAEC,OAAA;AAAA,QACC,CAAC,gBAAgB,kBAAkB,CAAA;AAAA,QACnC,8JAAA;AAAA,QAEA,CAACA,MAAAA,KACCA,MAAAA,CACG,UAAA,CAAW,SAAA,EAAW;AAAA,UACrB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,wCAAA;AAAA,UACb,YAAA,EAAc;AAAA,SACf,CAAA,CACA,MAAA,CAAO,YAAA,EAAc;AAAA,UACpB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,uDAAA;AAAA,UACb,KAAA,EAAO,GAAA;AAAA,UACP,OAAA,EAAS;AAAA,SACV,CAAA;AAAA,QACL,OAAO,YAAA,KAAiB;AACtB,UAAA,MAAM,4BAAA,CAA6B;AAAA,YACjC,SAAS,YAAA,CAAa,OAAA;AAAA,YACtB,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH;AACF;AACJ,IAGH,KAAA,EAAM;AACX;AAtKe,MAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAwKf,IAAO,WAAA,GAAQ,MAAA;;;ACjLf,KAAK,WAAA,EAAO","file":"cli.mjs","sourcesContent":["{\n \"name\": \"@zimic/interceptor\",\n \"description\": \"Next-gen TypeScript-first HTTP intercepting and mocking\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"interceptor\",\n \"mock\",\n \"api\",\n \"static\"\n ],\n \"version\": \"0.21.0-canary.1\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-interceptor\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"http.d.ts\",\n \"server.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-interceptor\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./http\": {\n \"types\": \"./http.d.ts\",\n \"import\": \"./dist/http.mjs\",\n \"require\": \"./dist/http.js\",\n \"default\": \"./dist/http.js\"\n },\n \"./server\": {\n \"types\": \"./server.d.ts\",\n \"import\": \"./dist/server.mjs\",\n \"require\": \"./dist/server.js\",\n \"default\": \"./dist/server.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"deps:install-playwright\": \"playwright install chromium\",\n \"deps:init-msw\": \"msw init ./public --no-save\",\n \"deps:prepare\": \"pnpm deps:install-playwright && pnpm deps:init-msw\",\n \"postinstall\": \"node --enable-source-maps -e \\\"try{require('./dist/scripts/postinstall')}catch(error){console.error(error)}\\\"\"\n },\n \"dependencies\": {\n \"@whatwg-node/server\": \"0.10.10\",\n \"execa\": \"9.6.0\",\n \"isomorphic-ws\": \"5.0.0\",\n \"msw\": \"2.10.2\",\n \"picocolors\": \"^1.1.1\",\n \"ws\": \"8.18.3\",\n \"yargs\": \"18.0.0\",\n \"zod\": \"^3.25.67\"\n },\n \"optionalDependencies\": {\n \"bufferutil\": \"4.0.9\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.0.7\",\n \"@types/ws\": \"^8.18.1\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^8.0.0\",\n \"eslint\": \"^9.30.0\",\n \"playwright\": \"^1.53.1\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"@zimic/http\": \"^0.7.0 || workspace:*\",\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","export const SERVICE_WORKER_FILE_NAME = 'mockServiceWorker.js';\n","import fs from 'fs';\nimport path from 'path';\nimport color from 'picocolors';\n\nimport { logger } from '@/utils/logging';\n\nimport { SERVICE_WORKER_FILE_NAME } from './shared/constants';\n\nconst MSW_ROOT_PATH = path.join(require.resolve('msw'), '..', '..', '..');\nexport const MOCK_SERVICE_WORKER_PATH = path.join(MSW_ROOT_PATH, 'lib', SERVICE_WORKER_FILE_NAME);\n\ninterface BrowserServiceWorkerInitOptions {\n publicDirectory: string;\n}\n\nasync function initializeBrowserServiceWorker({ publicDirectory }: BrowserServiceWorkerInitOptions) {\n await fs.promises.mkdir(publicDirectory, { recursive: true });\n\n const destinationPath = path.join(publicDirectory, SERVICE_WORKER_FILE_NAME);\n await fs.promises.copyFile(MOCK_SERVICE_WORKER_PATH, destinationPath);\n\n logger.info(`Service worker script saved to ${color.magenta(destinationPath)}.`);\n}\n\nexport default initializeBrowserServiceWorker;\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\n\nexport const PROCESS_EXIT_EVENTS = Object.freeze([\n 'beforeExit',\n 'uncaughtExceptionMonitor',\n 'SIGINT',\n 'SIGTERM',\n 'SIGHUP',\n 'SIGBREAK',\n] as const);\n\nexport type ProcessExitEvent = (typeof PROCESS_EXIT_EVENTS)[number];\n\n// Having an undefined exit code means that the process will already exit with the default exit code.\nexport const PROCESS_EXIT_CODE_BY_EXIT_EVENT: Record<string, number | undefined> = {\n beforeExit: undefined,\n uncaughtExceptionMonitor: undefined,\n SIGINT: 130,\n SIGTERM: 143,\n SIGHUP: 129,\n SIGBREAK: 131,\n} satisfies Record<ProcessExitEvent, number | undefined>;\n\nexport const importExeca = createCachedDynamicImport(() => import('execa'));\n\ninterface CommandErrorOptions {\n command?: string[];\n exitCode?: number;\n signal?: NodeJS.Signals;\n originalMessage?: string;\n}\n\nexport class CommandError extends Error {\n static readonly DEFAULT_EXIT_CODE = 1;\n\n readonly command: string[];\n readonly exitCode: number;\n readonly signal?: NodeJS.Signals;\n\n constructor(executable: string, options: CommandErrorOptions) {\n const message = CommandError.createMessage(executable, options);\n super(message);\n\n this.name = 'CommandError';\n this.command = options.command ?? [executable];\n this.exitCode = this.getExitCode(options);\n this.signal = options.signal;\n }\n\n private getExitCode(options: CommandErrorOptions): number {\n const existingExitCode = options.exitCode;\n const exitCodeInferredFromSignal =\n options.signal === undefined ? undefined : PROCESS_EXIT_CODE_BY_EXIT_EVENT[options.signal];\n\n return existingExitCode ?? exitCodeInferredFromSignal ?? CommandError.DEFAULT_EXIT_CODE;\n }\n\n private static createMessage(command: string, options: CommandErrorOptions) {\n const suffix = options.originalMessage ? `: ${options.originalMessage}` : '';\n\n if (options.exitCode === undefined && options.signal === undefined) {\n return `Command '${command}' failed${suffix}`;\n }\n\n const prefix = `Command '${command}' exited `;\n const infix = options.exitCode === undefined ? `after signal ${options.signal}` : `with code ${options.exitCode}`;\n\n return `${prefix}${infix}${suffix}`;\n }\n}\n\nexport async function runCommand(commandEntry: string, commandArguments: string[]) {\n const { execa: $, ExecaError } = await importExeca();\n\n try {\n await $(commandEntry, commandArguments, { stdio: 'inherit' });\n } catch (error) {\n /* istanbul ignore if -- @preserve\n * This is a safeguard if the error is not an ExecaError. It is not expected to run. */\n if (!(error instanceof ExecaError)) {\n throw error;\n }\n\n const commandError = new CommandError(commandEntry, {\n command: [commandEntry, ...commandArguments],\n exitCode: error.exitCode,\n signal: error.signal,\n originalMessage: error.originalMessage,\n });\n\n throw commandError;\n }\n}\n","import color from 'picocolors';\n\nimport { InterceptorServer, createInterceptorServer } from '@/server';\nimport { InterceptorServerOptions } from '@/server/types/options';\nimport { logger } from '@/utils/logging';\nimport {\n CommandError,\n PROCESS_EXIT_CODE_BY_EXIT_EVENT,\n PROCESS_EXIT_EVENTS,\n ProcessExitEvent,\n runCommand,\n} from '@/utils/processes';\n\ninterface InterceptorServerStartOptions extends InterceptorServerOptions {\n ephemeral: boolean;\n onReady?: { command: string; arguments: string[] };\n}\n\nexport let serverSingleton: InterceptorServer | undefined;\n\nasync function startInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n ephemeral,\n onReady,\n}: InterceptorServerStartOptions) {\n const server = createInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n });\n\n async function handleExitEvent(exitEvent: ProcessExitEvent | undefined) {\n await server.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.off(exitEvent, exitHandler);\n }\n\n const exitCode = exitEvent ? PROCESS_EXIT_CODE_BY_EXIT_EVENT[exitEvent] : undefined;\n if (exitCode !== undefined) {\n process.exit(exitCode);\n }\n }\n\n const exitHandlerGroups = PROCESS_EXIT_EVENTS.map((exitEvent) => ({\n exitEvent,\n exitHandler: handleExitEvent.bind(null, exitEvent),\n }));\n\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.on(exitEvent, exitHandler);\n }\n\n serverSingleton = server;\n\n await server.start();\n\n logger.info(\n `${ephemeral ? 'Ephemeral s' : 'S'}erver is running on ${color.yellow(`${server.hostname}:${server.port}`)}`,\n );\n\n const isDangerouslyUnprotected = !tokensDirectory && process.env.NODE_ENV === 'production';\n\n if (isDangerouslyUnprotected) {\n logger.warn(\n [\n `Attention: this interceptor server is ${color.bold(color.red('unprotected'))}. Do not expose it publicly without authentication.`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n }\n\n if (onReady) {\n try {\n await runCommand(onReady.command, onReady.arguments);\n } catch (error) {\n console.error(error);\n\n /* istanbul ignore if -- @preserve\n * A CommandError is always expected here. */\n if (!(error instanceof CommandError)) {\n throw error;\n }\n\n process.exit(error.exitCode);\n }\n }\n\n if (ephemeral) {\n await handleExitEvent(undefined);\n process.exit(0);\n }\n}\n\nexport default startInterceptorServer;\n","import color from 'picocolors';\n\nimport { createInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenName?: string;\n tokensDirectory: string;\n}\n\nexport async function createInterceptorServerToken({\n tokenName,\n tokensDirectory,\n}: InterceptorServerCreateTokenOptions) {\n const token = await createInterceptorToken({ name: tokenName, tokensDirectory });\n\n logger.info(\n [\n `${color.green(color.bold('✔'))} Token${tokenName ? ` ${color.green(tokenName)}` : ''} created:`,\n '',\n color.yellow(token.value),\n '',\n 'Store this token securely. It cannot be retrieved later.',\n '',\n `To enable authentication in your interceptor server, use the ${color.cyan('--tokens-dir')} option. Only ` +\n 'remote interceptors bearing a valid token will be allowed to connect.',\n '',\n `${color.dim('$')} zimic-interceptor server start ${color.cyan('--tokens-dir')} ${color.magenta(tokensDirectory)}`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n}\n","import { listInterceptorTokens } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerListTokensOptions {\n tokensDirectory: string;\n}\n\nexport async function listInterceptorServerTokens({ tokensDirectory }: InterceptorServerListTokensOptions) {\n const tokens = await listInterceptorTokens({ tokensDirectory });\n\n logger.raw.table(\n [\n { title: 'ID', property: 'id' },\n { title: 'NAME', property: 'name' },\n { title: 'CREATED AT', property: 'createdAt' },\n ],\n tokens.map((token) => ({\n id: token.id,\n name: token.name ?? '',\n createdAt: token.createdAt.toISOString(),\n })),\n );\n}\n","import color from 'picocolors';\n\nimport { readInterceptorTokenFromFile, removeInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenId: string;\n tokensDirectory: string;\n}\n\nexport async function removeInterceptorServerToken({ tokenId, tokensDirectory }: InterceptorServerCreateTokenOptions) {\n const token = await readInterceptorTokenFromFile(tokenId, { tokensDirectory });\n\n if (!token) {\n logger.error(`${color.red(color.bold('✘'))} Token ${color.red(tokenId)} not found.`);\n process.exit(1);\n }\n\n await removeInterceptorToken(token.id, { tokensDirectory });\n\n logger.info(`${color.green(color.bold('✔'))} Token ${color.green(token.name ?? token.id)} removed.`);\n}\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY } from '../server/utils/auth';\nimport initializeBrowserServiceWorker from './browser/init';\nimport startInterceptorServer from './server/start';\nimport { createInterceptorServerToken } from './server/token/create';\nimport { listInterceptorServerTokens } from './server/token/list';\nimport { removeInterceptorServerToken } from './server/token/remove';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-interceptor')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('browser', 'Manage your browser mock configuration.', (yargs) =>\n yargs.demandCommand().command(\n 'init <publicDirectory>',\n 'Initialize the browser service worker configuration.',\n (yargs) =>\n yargs.positional('publicDirectory', {\n type: 'string',\n description: 'The path to the public directory of your application.',\n demandOption: true,\n }),\n async (cliArguments) => {\n await initializeBrowserServiceWorker({\n publicDirectory: cliArguments.publicDirectory,\n });\n },\n ),\n )\n\n .command('server', 'Manage interceptor servers.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'start [-- onReady]',\n 'Start an interceptor server.',\n (yargs) =>\n yargs\n .positional('onReady', {\n description: 'A command to run when the server is ready to accept connections.',\n type: 'string',\n })\n .option('hostname', {\n type: 'string',\n description: 'The hostname to start the server on.',\n alias: 'h',\n default: 'localhost',\n })\n .option('port', {\n type: 'number',\n description: 'The port to start the server on.',\n alias: 'p',\n })\n .option('ephemeral', {\n type: 'boolean',\n description:\n 'Whether the server should stop automatically after the on-ready command finishes. ' +\n 'If no on-ready command is provided and ephemeral is true, the server will stop immediately after ' +\n 'starting.',\n alias: 'e',\n default: false,\n })\n .option('log-unhandled-requests', {\n type: 'boolean',\n description:\n 'Whether to log a warning when no interceptors were found for the base URL of a request. ' +\n 'If an interceptor was matched, the logging behavior for that base URL is configured in the ' +\n 'interceptor itself.',\n alias: 'l',\n })\n .option('tokens-dir', {\n type: 'string',\n description:\n 'The directory where the authorized interceptor authentication tokens are saved. If provided, only ' +\n 'remote interceptors bearing a valid token will be accepted. This option is essential if you are ' +\n 'exposing your interceptor server publicly. For local development and testing, though, ' +\n '`--tokens-dir` is optional.',\n alias: 't',\n }),\n async (cliArguments) => {\n const onReadyCommand = cliArguments._.at(2)?.toString();\n const onReadyCommandArguments = cliArguments._.slice(3).map((argument) => argument.toString());\n\n await startInterceptorServer({\n hostname: cliArguments.hostname,\n port: cliArguments.port,\n ephemeral: cliArguments.ephemeral,\n logUnhandledRequests: cliArguments.logUnhandledRequests,\n tokensDirectory: cliArguments.tokensDir,\n onReady: onReadyCommand\n ? {\n command: onReadyCommand.toString(),\n arguments: onReadyCommandArguments,\n }\n : undefined,\n });\n },\n )\n\n .command('token', 'Manage remote interceptor authentication tokens.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'create',\n 'Create an interceptor token.',\n (yargs) =>\n yargs\n .option('name', {\n type: 'string',\n description: 'The name of the token to create.',\n alias: 'n',\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the created interceptor token will be saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await createInterceptorServerToken({\n tokenName: cliArguments.name,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['ls', 'list'],\n 'List the authorized interceptor tokens.',\n (yargs) =>\n yargs.option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await listInterceptorServerTokens({\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['rm <tokenId>', 'remove <tokenId>'],\n 'Remove (invalidate) an interceptor token. Existing connections will not be affected, so restarting the ' +\n 'server is recommended to disconnect all interceptors.',\n (yargs) =>\n yargs\n .positional('tokenId', {\n type: 'string',\n description: 'The identifier of the token to remove.',\n demandOption: true,\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await removeInterceptorServerToken({\n tokenId: cliArguments.tokenId,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n ),\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
|
package/dist/http.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ declare class DisabledRequestSavingError extends TypeError {
|
|
|
85
85
|
type Default<Type, IfEmpty = never> = [undefined | void] extends [Type] ? IfEmpty : Exclude<Type, undefined | void>;
|
|
86
86
|
type IfNever<Type, Yes, No = Type> = [Type] extends [never] ? Yes : No;
|
|
87
87
|
type PossiblePromise<Type> = Type | PromiseLike<Type>;
|
|
88
|
+
type ReplaceBy<Type, Source, Target> = Type extends Source ? Target : Type;
|
|
88
89
|
type PartialByKey<Type, Key extends keyof Type> = Omit<Type, Key> & Partial<Pick<Type, Key>>;
|
|
89
90
|
type DeepPartial<Type> = Type extends (...parameters: never[]) => unknown ? Type : Type extends (infer ArrayItem)[] ? DeepPartial<ArrayItem>[] : Type extends object ? {
|
|
90
91
|
[Key in keyof Type]?: DeepPartial<Type[Key]>;
|
|
@@ -122,25 +123,51 @@ type HttpRequestHandlerResponseDeclaration<MethodSchema extends HttpMethodSchema
|
|
|
122
123
|
type HttpRequestHandlerResponseDeclarationFactory<Path extends string, MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode = HttpStatusCode> = (request: Omit<HttpInterceptorRequest<Path, MethodSchema>, 'response'>) => PossiblePromise<HttpRequestHandlerResponseDeclaration<MethodSchema, StatusCode>>;
|
|
123
124
|
/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */
|
|
124
125
|
interface HttpInterceptorRequest<Path extends string, MethodSchema extends HttpMethodSchema> extends Omit<HttpRequest, keyof Body | 'headers' | 'clone'> {
|
|
125
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* The headers of the request.
|
|
128
|
+
*
|
|
129
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/headers#using-request-headers Using request headers}
|
|
130
|
+
*/
|
|
126
131
|
headers: HttpHeaders<Default<HttpRequestHeadersSchema<MethodSchema>>>;
|
|
127
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* The path parameters of the request. They are parsed from the path string when using dynamic paths.
|
|
134
|
+
*
|
|
135
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/path-params#using-request-path-params Using request path parameters}
|
|
136
|
+
*/
|
|
128
137
|
pathParams: InferPathParams<Path>;
|
|
129
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* The search parameters of the request.
|
|
140
|
+
*
|
|
141
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/search-params#using-request-search-params Using request search parameters}
|
|
142
|
+
*/
|
|
130
143
|
searchParams: HttpSearchParams<Default<HttpRequestSearchParamsSchema<MethodSchema>>>;
|
|
131
|
-
/**
|
|
132
|
-
|
|
144
|
+
/**
|
|
145
|
+
* The body of the request. It is already parsed by default as detailed in
|
|
146
|
+
* {@link https://zimic.dev/docs/interceptor/guides/http/bodies#default-body-parsing Default body parsing}.
|
|
147
|
+
*
|
|
148
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/bodies#using-request-bodies Using request bodies}
|
|
149
|
+
*/
|
|
150
|
+
body: ReplaceBy<HttpRequestBodySchema<MethodSchema>, ArrayBuffer | ReadableStream, Blob>;
|
|
133
151
|
/** The raw request object. */
|
|
134
152
|
raw: HttpRequest<HttpRequestBodySchema<MethodSchema>, Default<HttpRequestHeadersSchema<MethodSchema>>>;
|
|
135
153
|
}
|
|
136
154
|
/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */
|
|
137
155
|
interface HttpInterceptorResponse<MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode> extends Omit<HttpResponse, keyof Body | 'headers' | 'clone'> {
|
|
138
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* The headers of the response.
|
|
158
|
+
*
|
|
159
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/headers#using-response-headers Using response headers}
|
|
160
|
+
*/
|
|
139
161
|
headers: HttpHeaders<Default<HttpResponseHeadersSchema<MethodSchema, StatusCode>>>;
|
|
140
162
|
/** The status code of the response. */
|
|
141
163
|
status: StatusCode;
|
|
142
|
-
/**
|
|
143
|
-
|
|
164
|
+
/**
|
|
165
|
+
* The body of the response. It is already parsed by default as detailed in
|
|
166
|
+
* {@link https://zimic.dev/docs/interceptor/guides/http/bodies#default-body-parsing Default body parsing}.
|
|
167
|
+
*
|
|
168
|
+
* @see {@link https://zimic.dev/docs/interceptor/guides/http/bodies#using-response-bodies Using response bodies}
|
|
169
|
+
*/
|
|
170
|
+
body: ReplaceBy<HttpResponseBodySchema<MethodSchema, StatusCode>, ArrayBuffer | ReadableStream, Blob>;
|
|
144
171
|
/** The raw response object. */
|
|
145
172
|
raw: HttpResponse<HttpResponseBodySchema<MethodSchema, StatusCode>, Default<HttpResponseHeadersSchema<MethodSchema, StatusCode>>, StatusCode>;
|
|
146
173
|
}
|
|
@@ -231,7 +258,7 @@ type HttpRequestHandlerHeadersStaticRestriction<Schema extends HttpSchema, Metho
|
|
|
231
258
|
type PartialHttpSearchParamsOrSchema<Schema extends HttpSearchParamsSchema.Loose> = IfNever<Schema, never, Partial<Schema> | HttpSearchParams<Partial<Schema>> | HttpSearchParams<Schema>>;
|
|
232
259
|
/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
|
|
233
260
|
type HttpRequestHandlerSearchParamsStaticRestriction<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>> = PartialHttpSearchParamsOrSchema<Default<HttpRequestSearchParamsSchema<Default<Schema[Path][Method]>>>>;
|
|
234
|
-
type PartialBodyOrSchema<Body extends HttpBody> = Body extends HttpFormData<infer Schema> ? HttpFormData<Partial<Schema>> | HttpFormData<Schema> : Body extends HttpSearchParams<infer Schema> ? HttpSearchParams<Partial<Schema>> | HttpSearchParams<Schema> : Body extends Blob ? Body : DeepPartial<Body>;
|
|
261
|
+
type PartialBodyOrSchema<Body extends HttpBody> = Body extends HttpFormData<infer Schema> ? HttpFormData<Partial<Schema>> | HttpFormData<Schema> : Body extends HttpSearchParams<infer Schema> ? HttpSearchParams<Partial<Schema>> | HttpSearchParams<Schema> : Body extends Blob ? Body : Body extends ArrayBuffer ? Body : Body extends ReadableStream ? Body : DeepPartial<Body>;
|
|
235
262
|
/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
|
|
236
263
|
type HttpRequestHandlerBodyStaticRestriction<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>> = PartialBodyOrSchema<HttpRequestBodySchema<Default<Schema[Path][Method]>>>;
|
|
237
264
|
/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
|
package/dist/http.js
CHANGED
|
@@ -585,6 +585,52 @@ __name(jsonEquals, "jsonEquals");
|
|
|
585
585
|
__name2(jsonEquals, "jsonEquals");
|
|
586
586
|
var jsonEquals_default = jsonEquals;
|
|
587
587
|
|
|
588
|
+
// src/utils/data.ts
|
|
589
|
+
async function convertReadableStreamToBlob(stream, options) {
|
|
590
|
+
const chunks = [];
|
|
591
|
+
const reader = stream.getReader();
|
|
592
|
+
while (true) {
|
|
593
|
+
const readResult = await reader.read();
|
|
594
|
+
if (readResult.value) {
|
|
595
|
+
chunks.push(readResult.value);
|
|
596
|
+
}
|
|
597
|
+
if (readResult.done) {
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return new Blob(chunks, options);
|
|
602
|
+
}
|
|
603
|
+
__name(convertReadableStreamToBlob, "convertReadableStreamToBlob");
|
|
604
|
+
function convertArrayBufferToBlob(buffer, options) {
|
|
605
|
+
return new Blob([buffer], options);
|
|
606
|
+
}
|
|
607
|
+
__name(convertArrayBufferToBlob, "convertArrayBufferToBlob");
|
|
608
|
+
function convertArrayBufferToBase64(buffer) {
|
|
609
|
+
if (isClientSide()) {
|
|
610
|
+
const bufferBytes = new Uint8Array(buffer);
|
|
611
|
+
const bufferAsStringArray = [];
|
|
612
|
+
for (const byte of bufferBytes) {
|
|
613
|
+
const byteCode = String.fromCharCode(byte);
|
|
614
|
+
bufferAsStringArray.push(byteCode);
|
|
615
|
+
}
|
|
616
|
+
const bufferAsString = bufferAsStringArray.join("");
|
|
617
|
+
return btoa(bufferAsString);
|
|
618
|
+
} else {
|
|
619
|
+
return Buffer.from(buffer).toString("base64");
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
__name(convertArrayBufferToBase64, "convertArrayBufferToBase64");
|
|
623
|
+
function convertBase64ToArrayBuffer(base64Value) {
|
|
624
|
+
if (isClientSide()) {
|
|
625
|
+
const bufferAsString = atob(base64Value);
|
|
626
|
+
const array = Uint8Array.from(bufferAsString, (character) => character.charCodeAt(0));
|
|
627
|
+
return array.buffer;
|
|
628
|
+
} else {
|
|
629
|
+
return Buffer.from(base64Value, "base64");
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
__name(convertBase64ToArrayBuffer, "convertBase64ToArrayBuffer");
|
|
633
|
+
|
|
588
634
|
// src/http/requestHandler/errors/NoResponseDefinitionError.ts
|
|
589
635
|
var NoResponseDefinitionError = class extends TypeError {
|
|
590
636
|
static {
|
|
@@ -793,14 +839,22 @@ var HttpRequestHandlerClient = class {
|
|
|
793
839
|
diff: { expected: restrictionBody, received: body }
|
|
794
840
|
};
|
|
795
841
|
}
|
|
796
|
-
if (restrictionBody instanceof Blob) {
|
|
842
|
+
if (restrictionBody instanceof Blob || restrictionBody instanceof ArrayBuffer || restrictionBody instanceof ReadableStream) {
|
|
797
843
|
if (!(body instanceof Blob)) {
|
|
798
844
|
return {
|
|
799
845
|
value: false,
|
|
800
846
|
diff: { expected: restrictionBody, received: body }
|
|
801
847
|
};
|
|
802
848
|
}
|
|
803
|
-
|
|
849
|
+
let restrictionBodyAsBlob;
|
|
850
|
+
if (restrictionBody instanceof ArrayBuffer) {
|
|
851
|
+
restrictionBodyAsBlob = convertArrayBufferToBlob(restrictionBody, { type: body.type });
|
|
852
|
+
} else if (restrictionBody instanceof ReadableStream) {
|
|
853
|
+
restrictionBodyAsBlob = await convertReadableStreamToBlob(restrictionBody, { type: body.type });
|
|
854
|
+
} else {
|
|
855
|
+
restrictionBodyAsBlob = restrictionBody;
|
|
856
|
+
}
|
|
857
|
+
const matchesRestriction2 = await blobEquals_default(body, restrictionBodyAsBlob);
|
|
804
858
|
return matchesRestriction2 ? { value: true } : {
|
|
805
859
|
value: false,
|
|
806
860
|
diff: { expected: restrictionBody, received: body }
|
|
@@ -1131,7 +1185,7 @@ var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
|
1131
1185
|
if (!canHaveBody) {
|
|
1132
1186
|
return new Response(null, { headers, status });
|
|
1133
1187
|
}
|
|
1134
|
-
if (typeof declaration.body === "string" || declaration.body === void 0 || declaration.body instanceof FormData || declaration.body instanceof URLSearchParams || declaration.body instanceof Blob || declaration.body instanceof ArrayBuffer) {
|
|
1188
|
+
if (typeof declaration.body === "string" || declaration.body === void 0 || declaration.body instanceof FormData || declaration.body instanceof URLSearchParams || declaration.body instanceof Blob || declaration.body instanceof ArrayBuffer || declaration.body instanceof ReadableStream) {
|
|
1135
1189
|
return new Response(declaration.body ?? null, { headers, status });
|
|
1136
1190
|
}
|
|
1137
1191
|
return Response.json(declaration.body, { headers, status });
|
|
@@ -1269,7 +1323,7 @@ var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
|
1269
1323
|
try {
|
|
1270
1324
|
return await this.parseRawBodyAsJSON(resource);
|
|
1271
1325
|
} catch {
|
|
1272
|
-
return await this.
|
|
1326
|
+
return await this.parseRawBodyAsBlob(resourceClone);
|
|
1273
1327
|
}
|
|
1274
1328
|
} catch (error) {
|
|
1275
1329
|
console.error(error);
|
|
@@ -1874,33 +1928,6 @@ var importCrypto = createCachedDynamicImport_default(async () => {
|
|
|
1874
1928
|
return globalCrypto ?? await import('crypto');
|
|
1875
1929
|
});
|
|
1876
1930
|
|
|
1877
|
-
// src/utils/data.ts
|
|
1878
|
-
function convertArrayBufferToBase64(buffer) {
|
|
1879
|
-
if (isClientSide()) {
|
|
1880
|
-
const bufferBytes = new Uint8Array(buffer);
|
|
1881
|
-
const bufferAsStringArray = [];
|
|
1882
|
-
for (const byte of bufferBytes) {
|
|
1883
|
-
const byteCode = String.fromCharCode(byte);
|
|
1884
|
-
bufferAsStringArray.push(byteCode);
|
|
1885
|
-
}
|
|
1886
|
-
const bufferAsString = bufferAsStringArray.join("");
|
|
1887
|
-
return btoa(bufferAsString);
|
|
1888
|
-
} else {
|
|
1889
|
-
return Buffer.from(buffer).toString("base64");
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
__name(convertArrayBufferToBase64, "convertArrayBufferToBase64");
|
|
1893
|
-
function convertBase64ToArrayBuffer(base64Value) {
|
|
1894
|
-
if (isClientSide()) {
|
|
1895
|
-
const bufferAsString = atob(base64Value);
|
|
1896
|
-
const array = Uint8Array.from(bufferAsString, (character) => character.charCodeAt(0));
|
|
1897
|
-
return array.buffer;
|
|
1898
|
-
} else {
|
|
1899
|
-
return Buffer.from(base64Value, "base64");
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
__name(convertBase64ToArrayBuffer, "convertBase64ToArrayBuffer");
|
|
1903
|
-
|
|
1904
1931
|
// src/utils/fetch.ts
|
|
1905
1932
|
function deserializeRequest(serializedRequest) {
|
|
1906
1933
|
const deserializedBody = serializedRequest.body ? convertBase64ToArrayBuffer(serializedRequest.body) : null;
|