From 2a176e7e6f861fc968ab30ae125c72ed852e692e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Thu, 1 Feb 2024 10:15:53 +0100 Subject: [PATCH] Update owner from sqren to sorenlouv --- .vscode/settings.json | 2 +- README.md | 6 +- dist/index.js | 13595 +++++----------------------------------- src/run.test.ts | 12 +- 4 files changed, 1539 insertions(+), 12076 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 01b64d0..165e99e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,7 +14,7 @@ }, "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/README.md b/README.md index ae1720f..fba0821 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Backport Action - uses: sqren/backport-github-action@v9.3.0 + uses: sorenlouv/backport-github-action@v9.3.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} auto_backport_label_prefix: backport-to- @@ -36,7 +36,7 @@ Now, to backport a pull request, simply apply the label `backport-to-production` ## Configuration -For more fine grained customization, and for the ability to run the [Backport Tool](https://github.com/sqren/backport) as a CLI tool locally, you should create a `.backportrc.json` file in the root directory: +For more fine grained customization, and for the ability to run the [Backport Tool](https://github.com/sorenlouv/backport) as a CLI tool locally, you should create a `.backportrc.json` file in the root directory: ```js // .backportrc.json @@ -59,5 +59,5 @@ For more fine grained customization, and for the ability to run the [Backport To ``` - See the [Backport Tool documentation](https://github.com/sqren/backport/blob/main/docs/config-file-options.md) for all configuration options. + See the [Backport Tool documentation](https://github.com/sorenlouv/backport/blob/main/docs/config-file-options.md) for all configuration options. diff --git a/dist/index.js b/dist/index.js index 4fc5c98..a5e8d31 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9495,6 +9495,7 @@ async function backportRun({ processArgs, optionsFromModule = {}, exitCodeOnFail }); logger.info('Backporting options', options); spinner.stop(); + (0, logger_1.consoleLog)((0, options_1.getActiveOptionsFormatted)(options)); const commitsSpan = elastic_apm_node_1.default.startSpan(`Get commits`); commits = await (0, getCommits_1.getCommits)(options); commitsSpan?.setLabel('commit_count', commits.length); @@ -9621,7 +9622,7 @@ const backportRun_1 = __nccwpck_require__(47272); const fetchCommitByPullNumber_1 = __nccwpck_require__(45542); const fetchCommitBySha_1 = __nccwpck_require__(83378); const fetchCommitsByAuthor_1 = __nccwpck_require__(40713); -const fetchPullRequestsBySearchQuery_1 = __nccwpck_require__(92121); +const fetchPullRequestsBySearchQuery_1 = __nccwpck_require__(31435); const getOptionsFromGithub_1 = __nccwpck_require__(84274); const logger_1 = __nccwpck_require__(57129); const excludeUndefined_1 = __nccwpck_require__(79023); @@ -9894,7 +9895,11 @@ const getMergeCommit_1 = __nccwpck_require__(14246); const getTargetPRLabels_1 = __nccwpck_require__(35865); const waitForCherrypick_1 = __nccwpck_require__(67821); async function cherrypickAndCreateTargetPullRequest({ options, commits, targetBranch, }) { - const backportBranch = (0, getBackportBranchName_1.getBackportBranchName)(targetBranch, commits); + const backportBranch = (0, getBackportBranchName_1.getBackportBranchName)({ + options, + targetBranch, + commits, + }); const repoForkOwner = (0, git_1.getRepoForkOwner)(options); (0, logger_1.consoleLog)(`\n${chalk_1.default.bold(`Backporting to ${targetBranch}:`)}`); await (0, validateTargetBranch_1.validateTargetBranch)({ ...options, branchName: targetBranch }); @@ -9916,7 +9921,7 @@ async function cherrypickAndCreateTargetPullRequest({ options, commits, targetBr repo: options.repoName, title: (0, createPullRequest_1.getTitle)({ options, commits, targetBranch }), body: (0, createPullRequest_1.getPullRequestBody)({ options, commits, targetBranch }), - head: `${repoForkOwner}:${backportBranch}`, + head: `${repoForkOwner}:${backportBranch}`, // eg. sqren:backport/7.x/pr-75007 base: targetBranch, // eg. 7.x }; const targetPullRequest = await (0, createPullRequest_1.createPullRequest)({ options, prPayload }); @@ -10038,12 +10043,16 @@ exports.copySourcePullRequestReviewersToTargetPullRequest = copySourcePullReques /***/ }), /***/ 64209: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getBackportBranchName = void 0; +const handlebars_1 = __importDefault(__nccwpck_require__(48190)); const commitFormatters_1 = __nccwpck_require__(9206); /* * Returns the name of the backport branch without remote name @@ -10053,14 +10062,20 @@ const commitFormatters_1 = __nccwpck_require__(9206); * For a single commit: `backport/7.x/commit-abcdef` * For multiple: `backport/7.x/pr-1234_commit-abcdef` */ -function getBackportBranchName(targetBranch, commits) { +function getBackportBranchName({ options, targetBranch, commits, }) { const refValues = commits .map((commit) => commit.sourcePullRequest ? `pr-${commit.sourcePullRequest.number}` : `commit-${(0, commitFormatters_1.getShortSha)(commit.sourceCommit.sha)}`) .join('_') .slice(0, 200); - return `backport/${targetBranch}/${refValues}`; + const defaultBackportBranchName = 'backport/{{targetBranch}}/{{refValues}}'; + const template = handlebars_1.default.compile(options.backportBranchName ?? defaultBackportBranchName); + return template({ + sourcePullRequest: commits[0].sourcePullRequest, // assume that all commits are from the same PR + targetBranch, + refValues, + }); } exports.getBackportBranchName = getBackportBranchName; //# sourceMappingURL=getBackportBranchName.js.map @@ -10093,7 +10108,8 @@ conflictingFiles, }) { // commits on the source branch that also touched the conflicting files const commitsInConflictingPaths = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({ ...options, - author: null, + author: null, // retrieve commits across all authors + maxNumber: 50, dateSince: null, dateUntil: commit.sourceCommit.committedDate, commitPaths: conflictingFiles, @@ -10314,12 +10330,21 @@ async function cherrypickAndHandleConflicts({ options, commit, commitAuthor, tar const conflictingFilesRelative = conflictingFiles .map((f) => f.relative) .slice(0, 50); - const commitsWithoutBackports = await (0, getCommitsWithoutBackports_1.getCommitsWithoutBackports)({ - options, - commit, - targetBranch, - conflictingFiles: conflictingFilesRelative, - }); + let commitsWithoutBackports; + try { + commitsWithoutBackports = await (0, getCommitsWithoutBackports_1.getCommitsWithoutBackports)({ + options, + commit, + targetBranch, + conflictingFiles: conflictingFilesRelative, + }); + } + catch (e) { + commitsWithoutBackports = []; + if (e instanceof Error) { + logger_1.logger.warn(`Unable to fetch commits without backports: ${e.message}`); + } + } if (!options.interactive) { throw new entrypoint_api_1.BackportError({ code: 'merge-conflict-exception', @@ -10557,7 +10582,7 @@ const commitFormatters_1 = __nccwpck_require__(9206); const fetchCommitByPullNumber_1 = __nccwpck_require__(45542); const fetchCommitBySha_1 = __nccwpck_require__(83378); const fetchCommitsByAuthor_1 = __nccwpck_require__(40713); -const fetchPullRequestsBySearchQuery_1 = __nccwpck_require__(92121); +const fetchPullRequestsBySearchQuery_1 = __nccwpck_require__(31435); const ora_1 = __nccwpck_require__(82998); const prompts_1 = __nccwpck_require__(51031); function getOraPersistsOption(question, answer) { @@ -11007,7 +11032,7 @@ async function gitCommit({ options, commitAuthor, message, }) { `user.email="${commitAuthor.email}"`, 'commit', ...(message ? [`--message=${message}`] : ['--no-edit']), - ...(options.noVerify ? ['--no-verify'] : []), + ...(options.noVerify ? ['--no-verify'] : []), // bypass pre-commit and commit-msg hooks ...(options.signoff ? ['--signoff'] : []), ], cwd); } @@ -11087,8 +11112,8 @@ exports.getUnstagedFiles = getUnstagedFiles; // master -> backport/7.x/pr-1234 -> 7.x async function createBackportBranch({ options, sourceBranch, backportBranch, targetBranch, }) { const spinner = (0, ora_1.ora)(options.interactive, 'Pulling latest changes').start(); + const cwd = (0, env_1.getRepoPath)(options); try { - const cwd = (0, env_1.getRepoPath)(options); await (0, child_process_promisified_1.spawnPromise)('git', ['reset', '--hard'], cwd); await (0, child_process_promisified_1.spawnPromise)('git', ['clean', '-d', '--force'], cwd); // create tmp branch. This can be necessary when fetching to the currently selected branch @@ -11109,26 +11134,34 @@ async function createBackportBranch({ options, sourceBranch, backportBranch, tar await (0, child_process_promisified_1.spawnPromise)('git', ['branch', '-D', tmpBranchName], cwd); } catch (e) { - // + // swallow error } // fetch commits for source branch await fetchBranch(options, sourceBranch); - spinner.succeed(); } catch (e) { spinner.fail(); if (e instanceof child_process_promisified_1.SpawnError) { - const isBranchInvalid = e.context.stderr.toLowerCase().includes(`couldn't find remote ref`) || - e.context.stderr.toLowerCase().includes(`invalid refspec`) || - e.context.stderr - .toLowerCase() - .includes(`is not a commit and a branch '${backportBranch}' cannot be created from it`); - if (isBranchInvalid) { - throw new BackportError_1.BackportError(`The branch "${targetBranch}" is invalid or doesn't exist`); + const invalidRemoteRef = e.context.stderr + .toLowerCase() + .match(/couldn't find remote ref (.*)/)?.[1]; + const invalidCommit = e.context.stderr + .toLowerCase() + .match(/'(.+) is not a commit and a branch .+ cannot be created from it/)?.[1]; + const invalidBranch = invalidRemoteRef || invalidCommit; + if (invalidBranch) { + throw new BackportError_1.BackportError(`The branch "${invalidBranch}" is invalid or doesn't exist`); + } + const invalidRefSpec = e.context.stderr + .toLowerCase() + .match(/invalid refspec (.*)/)?.[1]; + if (invalidRefSpec) { + throw new BackportError_1.BackportError(`The remote "${invalidRefSpec}" is invalid or doesn't exist`); } } throw e; } + spinner.succeed(); } exports.createBackportBranch = createBackportBranch; async function deleteBackportBranch({ options, backportBranch, }) { @@ -11457,10 +11490,12 @@ function getPullRequestBody({ options, commits, targetBranch, }) { 'Please refer to the [Backport tool documentation](https://github.com/sqren/backport)'; const customPrDescription = options.prDescription ?.replaceAll('{{defaultPrDescription}}', defaultPrDescription) - ?.replaceAll('{{commitsStringified}}', JSON.stringify(commits)); + ?.replaceAll('{defaultPrDescription}', defaultPrDescription) // retain backwards compatibility + ?.replaceAll('{{commitsStringified}}', JSON.stringify(commits)) + ?.replaceAll('{commits}', JSON.stringify(commits)); // retain backwards compatibility const template = handlebars_1.default.compile(customPrDescription ?? defaultPrDescription); return template({ - sourcePullRequest: commits[0].sourcePullRequest, + sourcePullRequest: commits[0].sourcePullRequest, // assume that all commits are from the same PR sourceBranch, targetBranch, commitMessages, @@ -11478,7 +11513,7 @@ function getTitle({ options, commits, targetBranch, }) { const template = handlebars_1.default.compile(options.prTitle ?? defaultPrTitle); commits[0].author.name; return template({ - sourcePullRequest: commits[0].sourcePullRequest, + sourcePullRequest: commits[0].sourcePullRequest, // assume that all commits are from the same PR sourceBranch, targetBranch, commitMessages, @@ -11790,7 +11825,7 @@ async function fetchPullRequestId(options, pullNumber) { pullNumber, }, }); - return prResponse.repository.pullRequest.id; + return prResponse.data.data.repository.pullRequest.id; } exports.fetchPullRequestId = fetchPullRequestId; //# sourceMappingURL=FetchPullRequestId.js.map @@ -11813,8 +11848,6 @@ const printer_1 = __nccwpck_require__(71161); const lodash_1 = __nccwpck_require__(72506); const BackportError_1 = __nccwpck_require__(39996); const logger_1 = __nccwpck_require__(57129); -// Define the implementation -// eslint-disable-next-line async function apiRequestV4(opts) { const { githubApiBaseUrlV4 = 'https://api.github.com/graphql', accessToken, query, variables, } = opts; const gqlQueryName = getQueryName(query); @@ -11838,10 +11871,7 @@ async function apiRequestV4(opts) { githubResponse: response, }); span?.setOutcome('success'); - if (opts.fullResponse) { - return response; - } - return response.data.data; + return response; } catch (e) { span?.setOutcome('failure'); @@ -11938,7 +11968,7 @@ async function enablePullRequestAutoMerge(options, targetPullRequestNumber) { mergeMethod: autoMergeMethod.toUpperCase(), }, }); - return res.enablePullRequestAutoMerge.pullRequest?.number; + return res.data.data.enablePullRequestAutoMerge.pullRequest?.number; } exports.enablePullRequestAutoMerge = enablePullRequestAutoMerge; function parseGithubError(e) { @@ -11981,7 +12011,7 @@ async function fetchAuthorId({ accessToken, author, githubApiBaseUrlV4 = 'https: query, variables: { author }, }); - return res.user.id; + return res.data.data.user.id; } exports.fetchAuthorId = fetchAuthorId; //# sourceMappingURL=fetchAuthorId.js.map @@ -12044,9 +12074,9 @@ async function fetchCommitsByPullNumber(options) { } } `; - let res; + let data; try { - res = await (0, apiRequestV4_1.apiRequestV4)({ + const res = await (0, apiRequestV4_1.apiRequestV4)({ githubApiBaseUrlV4, accessToken, query, @@ -12056,11 +12086,12 @@ async function fetchCommitsByPullNumber(options) { pullNumber, }, }); + data = res.data.data; } catch (e) { - res = (0, remoteConfig_1.swallowMissingConfigFileException)(e); + data = (0, remoteConfig_1.swallowMissingConfigFileException)(e); } - const pullRequestNode = res.repository.pullRequest; + const pullRequestNode = data.repository.pullRequest; if (!pullRequestNode) { throw new BackportError_1.BackportError(`The PR #${pullNumber} does not exist`); } @@ -12115,9 +12146,9 @@ async function fetchCommitBySha(options) { ${parseSourceCommit_1.SourceCommitWithTargetPullRequestFragment} `; - let res; + let data; try { - res = await (0, apiRequestV4_1.apiRequestV4)({ + const res = await (0, apiRequestV4_1.apiRequestV4)({ githubApiBaseUrlV4, accessToken, query, @@ -12127,11 +12158,12 @@ async function fetchCommitBySha(options) { sha, }, }); + data = res.data.data; } catch (e) { - res = (0, remoteConfig_1.swallowMissingConfigFileException)(e); + data = (0, remoteConfig_1.swallowMissingConfigFileException)(e); } - const sourceCommit = res.repository.object; + const sourceCommit = data.repository.object; if (!sourceCommit) { throw new BackportError_1.BackportError(`No commit found on branch "${sourceBranch}" with sha "${sha}"`); } @@ -12210,14 +12242,20 @@ async function fetchByCommitPath({ options, authorId, commitPath, }) { dateUntil, }; try { - return await (0, apiRequestV4_1.apiRequestV4)({ + const res = await (0, apiRequestV4_1.apiRequestV4)({ githubApiBaseUrlV4, accessToken, query, variables, }); + return res.data.data; } catch (e) { + if (e instanceof apiRequestV4_1.GithubV4Exception) { + if (e.githubResponse.status === 502 && maxNumber > 50) { + throw new BackportError_1.BackportError(`The GitHub API returned a 502 error. Try reducing the number of commits to display: "--max-number 20"`); + } + } return (0, remoteConfig_1.swallowMissingConfigFileException)(e); } } @@ -12329,7 +12367,7 @@ async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTotalCount) commitsTotalCount, }, }); - const pullRequestNode = res.repository.pullRequest; + const pullRequestNode = res.data.data.repository.pullRequest; if (!pullRequestNode?.mergeCommit) { throw new Error('Pull request is not merged'); } @@ -12355,7 +12393,7 @@ exports.fetchCommitsForRebaseAndMergeStrategy = fetchCommitsForRebaseAndMergeStr /***/ }), -/***/ 92121: +/***/ 31435: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -12415,19 +12453,20 @@ async function fetchPullRequestsBySearchQuery(options) { query: searchQuery, maxNumber, }; - let res; + let data; try { - res = await (0, apiRequestV4_1.apiRequestV4)({ + const res = await (0, apiRequestV4_1.apiRequestV4)({ githubApiBaseUrlV4, accessToken, query, variables, }); + data = res.data.data; } catch (e) { - res = (0, remoteConfig_1.swallowMissingConfigFileException)(e); + data = (0, remoteConfig_1.swallowMissingConfigFileException)(e); } - const commits = res.search.nodes.map((pullRequestNode) => { + const commits = data.search.nodes.map((pullRequestNode) => { const sourceCommit = pullRequestNode.mergeCommit; return (0, parseSourceCommit_1.parseSourceCommit)({ options, sourceCommit }); }); @@ -12502,7 +12541,7 @@ async function fetchExistingPullRequest({ options, prPayload, }) { head: head, }, }); - const existingPullRequest = res.repository.ref?.associatedPullRequests.edges[0]; + const existingPullRequest = res.data.data.repository.ref?.associatedPullRequests.edges[0]; if (!existingPullRequest) { return; } @@ -12543,7 +12582,6 @@ async function getOptionsFromGithub(options) { accessToken, query: query_1.query, variables: { repoOwner, repoName }, - fullResponse: true, }); throwIfInsufficientPermissions(res); data = res.data.data; @@ -12605,7 +12643,7 @@ async function getRemoteConfigFileOptions(res, cwd, skipRemoteConfig) { } } logger_1.logger.info('Remote config: Parsing.'); - return (0, remoteConfig_1.parseRemoteConfig)(remoteConfig); + return (0, remoteConfig_1.parseRemoteConfigFile)(remoteConfig); } function throwIfInsufficientPermissions(res) { const accessScopesHeader = res.headers['x-oauth-scopes']; @@ -12698,12 +12736,13 @@ async function getRepoOwnerAndNameFromGitRemotes({ accessToken, githubApiBaseUrl repoName: firstRemote.repoName, }, }); + const { data } = res.data; return { - repoName: res.repository.name, + repoName: data.repository.name, // get the original owner (not the fork owner) - repoOwner: res.repository.isFork - ? res.repository.parent.owner.login - : res.repository.owner.login, + repoOwner: data.repository.isFork + ? data.repository.parent.owner.login + : data.repository.owner.login, }; } catch (e) { @@ -12823,7 +12862,7 @@ async function validateTargetBranch({ accessToken, repoName, repoOwner, branchNa query, variables: { repoOwner, repoName, branchName }, }); - if (!res.repository.ref) { + if (!res.data.data.repository.ref) { spinner.fail(`The branch "${branchName}" does not exist`); throw new BackportError_1.BackportError({ code: 'invalid-branch-exception', @@ -13112,7 +13151,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.swallowMissingConfigFileException = exports.parseRemoteConfig = exports.RemoteConfigHistoryFragment = void 0; +exports.swallowMissingConfigFileException = exports.parseRemoteConfigFile = exports.RemoteConfigHistoryFragment = void 0; const graphql_tag_1 = __importDefault(__nccwpck_require__(24037)); const readConfigFile_1 = __nccwpck_require__(67028); const apiRequestV4_1 = __nccwpck_require__(91843); @@ -13137,16 +13176,16 @@ exports.RemoteConfigHistoryFragment = (0, graphql_tag_1.default) ` } } `; -function parseRemoteConfig(remoteConfig) { +function parseRemoteConfigFile(remoteConfig) { try { - return (0, readConfigFile_1.withConfigMigrations)(JSON.parse(remoteConfig.file.object.text)); + return (0, readConfigFile_1.parseConfigFile)(remoteConfig.file.object.text); } catch (e) { logger_1.logger.info('Parsing remote config failed', e); return; } } -exports.parseRemoteConfig = parseRemoteConfig; +exports.parseRemoteConfigFile = parseRemoteConfigFile; function swallowMissingConfigFileException(error) { if (!(error instanceof apiRequestV4_1.GithubV4Exception)) { throw error; @@ -13409,7 +13448,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.SourceCommitWithTargetPullRequestFragment = exports.parseSourceCommit = exports.getSuggestedTargetBranches = void 0; +exports.SourceCommitWithTargetPullRequestFragment = exports.parseSourceCommit = void 0; const graphql_tag_1 = __importDefault(__nccwpck_require__(24037)); const lodash_1 = __nccwpck_require__(72506); const remoteConfig_1 = __nccwpck_require__(64904); @@ -13422,7 +13461,6 @@ function getSuggestedTargetBranches(sourceCommit, targetPullRequestStates, branc const mergedPrs = targetPullRequestStates.filter((pr) => pr.state === 'MERGED'); return (0, lodash_1.differenceBy)(missingPrs, mergedPrs, (pr) => pr.label).map((pr) => pr.branch); } -exports.getSuggestedTargetBranches = getSuggestedTargetBranches; function parseSourceCommit({ sourceCommit, options, }) { const sourcePullRequest = (0, getPullRequestStates_1.getSourcePullRequest)(sourceCommit); const sourceCommitBranchLabelMapping = getSourceCommitBranchLabelMapping(sourceCommit); @@ -13550,7 +13588,7 @@ function getSourceCommitBranchLabelMapping(sourceCommit) { const sourcePullRequest = (0, getPullRequestStates_1.getSourcePullRequest)(sourceCommit); const remoteConfig = sourcePullRequest?.mergeCommit.remoteConfigHistory.edges?.[0]?.remoteConfig; if (remoteConfig) { - return (0, remoteConfig_1.parseRemoteConfig)(remoteConfig)?.branchLabelMapping; + return (0, remoteConfig_1.parseRemoteConfigFile)(remoteConfig)?.branchLabelMapping; } } //# sourceMappingURL=parseSourceCommit.js.map @@ -13902,6 +13940,10 @@ function getOptionsFromCliArgs(processArgs) { alias: ['label', 'l'], type: 'array', string: true, + }) + .option('backportBranchName', { + description: 'Name template to use for the branch name of the backport', + type: 'string', }) // cli-only .option('verify', { @@ -13910,6 +13952,7 @@ function getOptionsFromCliArgs(processArgs) { }) .alias('version', 'v') .help() + .exitProcess(!processArgs.includes('--noExitProcess')) .epilogue('For bugs, feature requests or questions: https://github.com/sqren/backport/issues\nOr contact me directly: https://twitter.com/sorenlouv') // don't kill process upon error // and don't log error to console @@ -14047,7 +14090,7 @@ function ensureCorrectPermissions(globalConfigPath) { async function createGlobalConfigIfNotExist(globalConfigPath, configTemplate) { try { await (0, promises_1.writeFile)(globalConfigPath, configTemplate, { - flag: 'wx', + flag: 'wx', // create and write file. Error if it already exists mode: 0o600, // give the owner read-write privleges, no access for others }); return true; @@ -14116,16 +14159,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.withConfigMigrations = exports.readConfigFile = void 0; +exports.parseConfigFile = exports.readConfigFile = void 0; const promises_1 = __nccwpck_require__(73292); const strip_json_comments_1 = __importDefault(__nccwpck_require__(55852)); const BackportError_1 = __nccwpck_require__(39996); const excludeUndefined_1 = __nccwpck_require__(79023); async function readConfigFile(filepath) { const fileContents = await (0, promises_1.readFile)(filepath, 'utf8'); - const configWithoutComments = (0, strip_json_comments_1.default)(fileContents); try { - return withConfigMigrations(JSON.parse(configWithoutComments)); + return parseConfigFile(fileContents); } catch (e) { throw new BackportError_1.BackportError(`"${filepath}" contains invalid JSON:\n\n${fileContents}`); @@ -14133,7 +14175,9 @@ async function readConfigFile(filepath) { } exports.readConfigFile = readConfigFile; // ensure backwards compatability when config options are renamed -function withConfigMigrations({ upstream, labels, branches, addOriginalReviewers, ...config }) { +function parseConfigFile(fileContents) { + const configWithoutComments = (0, strip_json_comments_1.default)(fileContents); + const { upstream, labels, branches, addOriginalReviewers, ...config } = JSON.parse(configWithoutComments); const { repoName, repoOwner } = parseUpstream(upstream, config); return (0, excludeUndefined_1.excludeUndefined)({ ...config, @@ -14148,7 +14192,7 @@ function withConfigMigrations({ upstream, labels, branches, addOriginalReviewers targetPRLabels: config.targetPRLabels ?? labels, }); } -exports.withConfigMigrations = withConfigMigrations; +exports.parseConfigFile = parseConfigFile; function parseUpstream(upstream, config) { if (upstream) { const [repoOwner, repoName] = upstream.split('/'); @@ -14164,12 +14208,16 @@ function parseUpstream(upstream, config) { /***/ }), /***/ 15162: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getOptions = exports.defaultConfigOptions = void 0; +exports.getActiveOptionsFormatted = exports.getOptions = exports.defaultConfigOptions = void 0; +const chalk_1 = __importDefault(__nccwpck_require__(76437)); const lodash_1 = __nccwpck_require__(72506); const BackportError_1 = __nccwpck_require__(39996); const env_1 = __nccwpck_require__(85146); @@ -14188,6 +14236,8 @@ exports.defaultConfigOptions = { cherrypickRef: true, commitConflicts: false, commitPaths: [], + copySourcePRLabels: false, + copySourcePRReviewers: false, cwd: process.cwd(), dateSince: null, dateUntil: null, @@ -14206,8 +14256,6 @@ exports.defaultConfigOptions = { reviewers: [], signoff: false, sourcePRLabels: [], - copySourcePRLabels: false, - copySourcePRReviewers: false, targetBranchChoices: [], targetBranches: [], targetPRLabels: [], @@ -14246,6 +14294,7 @@ async function getOptions({ optionsFromCliArgs, optionsFromModule, }) { ...optionsFromGithub, // cli args override the above ...optionsFromCliArgs, + editor: optionsFromCliArgs.editor === 'false' ? undefined : combined.editor, // required properties accessToken, repoName, @@ -14293,6 +14342,7 @@ function throwForRequiredOptions(options) { 'author', 'autoMergeMethod', 'backportBinary', + 'backportBranchName', 'dir', 'editor', 'gitHostname', @@ -14325,6 +14375,31 @@ function getMergedOptionsFromConfigAndCli({ optionsFromConfigFiles, optionsFromC ...optionsFromCliArgs, }; } +function getActiveOptionsFormatted(options) { + const customOptions = [['repo', `${options.repoOwner}/${options.repoName}`]]; + if (options.pullNumber) { + customOptions.push(['pullNumber', `${options.pullNumber}`]); + } + if (options.author && options.author !== options.authenticatedUsername) { + customOptions.push(['author', `${options.author}`]); + } + if (options.autoMerge !== exports.defaultConfigOptions.autoMerge) { + customOptions.push(['autoMerge', `${options.autoMerge}`]); + } + if (options.maxNumber !== exports.defaultConfigOptions.maxNumber) { + customOptions.push(['maxNumber', `${options.maxNumber}`]); + } + if (options.dateSince) { + customOptions.push(['since', `${options.dateSince}`]); + } + if (options.dateUntil) { + customOptions.push(['until', `${options.dateUntil}`]); + } + return (customOptions + .map(([key, value]) => `${chalk_1.default.bold(key)}: ${value}`) + .join(' • ') + `\n`); +} +exports.getActiveOptionsFormatted = getActiveOptionsFormatted; //# sourceMappingURL=options.js.map /***/ }), @@ -14492,7 +14567,7 @@ exports.maybe = maybe; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.PACKAGE_VERSION = void 0; -exports.PACKAGE_VERSION = '9.3.0'; +exports.PACKAGE_VERSION = '9.4.3'; //# sourceMappingURL=packageVersion.js.map /***/ }), @@ -15084,7 +15159,7 @@ SOFTWARE. module.exports = function(flag, argv) { - argv = argv || process.argv; + argv = argv || process.argv || []; var terminatorPos = argv.indexOf('--'); var prefix = /^-{1,2}/.test(flag) ? '' : '--'; @@ -15749,6 +15824,14 @@ module.exports = { formatError } +// Likely HTTP request header names that would include a request ID value, +// drawn from Fastify's [`requestIdHeader`](https://fastify.dev/docs/latest/Reference/Server/#requestidheader) +// default, Restify's defaults (https://github.com/restify/node-restify/blob/9f1d249/lib/plugins/pre/reqIdHeaders.js#L5). +const REQUEST_ID_HEADERS = [ + 'request-id', + 'x-request-id' +] + // Write ECS fields for the given HTTP request (expected to be // `http.IncomingMessage`-y) into the `ecs` object. This returns true iff // the given `req` was a request object it could process. @@ -15768,25 +15851,24 @@ function formatHttpRequest (ecs, req) { } const { - id, method, - url, headers, hostname, httpVersion, socket } = req - if (id) { - ecs.event = ecs.event || {} - ecs.event.id = id - } - ecs.http = ecs.http || {} ecs.http.version = httpVersion ecs.http.request = ecs.http.request || {} ecs.http.request.method = method + // Express can strip leading parts of `req.url` during routing, so we must use + // https://expressjs.com/en/4x/api.html#req.originalUrl if available. + // Fastify docs (https://fastify.dev/docs/latest/Reference/Request/) imply + // that it might mutate `req.url` during routing as well. + const url = req.originalUrl || req.url + ecs.url = ecs.url || {} ecs.url.full = (socket && socket.encrypted ? 'https://' : 'http://') + headers.host + url const hasQuery = url.indexOf('?') @@ -15808,6 +15890,7 @@ function formatHttpRequest (ecs, req) { if (hostname) { const [host, port] = hostname.split(':') ecs.url.domain = host + // istanbul ignore next if (port) { ecs.url.port = Number(port) } @@ -15846,6 +15929,39 @@ function formatHttpRequest (ecs, req) { } } + // Attempt to set `http.request.id` field from well-known web framework APIs + // or from some likely headers. + // Note: I'm not sure whether to include Hapi's `request.info.id` generated + // value (https://hapi.dev/api/?v=21.3.2#-requestinfo). IIUC it does NOT + // consider an incoming header. + let id = null + switch (typeof (req.id)) { + case 'string': + // Fastify https://fastify.dev/docs/latest/Reference/Request/, also + // Express if using https://www.npmjs.com/package/express-request-id. + id = req.id + break + case 'number': + id = req.id.toString() + break + case 'function': + // Restify http://restify.com/docs/request-api/#id + id = req.id() + break + } + if (!id && hasHeaders) { + for (let i = 0; i < REQUEST_ID_HEADERS.length; i++) { + const k = REQUEST_ID_HEADERS[i] + if (headers[k]) { + id = headers[k] + break + } + } + } + if (id) { + ecs.http.request.id = id + } + return true } @@ -15915,186 +16031,16 @@ module.exports = { formatHttpRequest, formatHttpResponse } -const stringify = __nccwpck_require__(64946) const errorFormatters = __nccwpck_require__(556) const httpFormatters = __nccwpck_require__(17666) module.exports = { - version: '1.6.0', - stringify, + version: '8.10.0', ...errorFormatters, ...httpFormatters } -/***/ }), - -/***/ 64946: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - - - -const build = __nccwpck_require__(87613) - -const string = { type: 'string' } -const number = { type: 'number' } - -const stringify = build({ - type: 'object', - properties: { - '@timestamp': string, - 'log.level': string, - log: { - type: 'object', - properties: { - logger: string - } - }, - message: string, - ecs: { - type: 'object', - properties: { - version: string - } - }, - // https://www.elastic.co/guide/en/ecs/current/ecs-event.html - event: { - type: 'object', - properties: { - dataset: string, - id: string - }, - additionalProperties: true - }, - // https://www.elastic.co/guide/en/ecs/current/ecs-http.html - http: { - type: 'object', - properties: { - version: string, - request: { - type: 'object', - properties: { - method: string, - headers: { - type: 'object', - additionalProperties: true - }, - body: { - type: 'object', - properties: { - bytes: number - } - } - } - }, - response: { - type: 'object', - properties: { - status_code: number, - headers: { - type: 'object', - additionalProperties: true - }, - body: { - type: 'object', - properties: { - bytes: number - } - } - } - } - } - }, - // https://www.elastic.co/guide/en/ecs/current/ecs-url.html - url: { - type: 'object', - properties: { - path: string, - domain: string, - port: number, - query: string, - fragment: string, - full: string - } - }, - // https://www.elastic.co/guide/en/ecs/current/ecs-client.html - client: { - type: 'object', - properties: { - address: string, - ip: string, - port: number - } - }, - // https://www.elastic.co/guide/en/ecs/current/ecs-user_agent.html - user_agent: { - type: 'object', - properties: { - original: string - } - }, - // https://www.elastic.co/guide/en/ecs/current/ecs-tracing.html - trace: { - type: 'object', - properties: { - id: string - } - }, - transaction: { - type: 'object', - properties: { - id: string - } - }, - span: { - type: 'object', - properties: { - id: string - } - }, - // https://www.elastic.co/guide/en/ecs/current/ecs-service.html - service: { - type: 'object', - properties: { - name: string - }, - additionalProperties: true - }, - // https://www.elastic.co/guide/en/ecs/current/ecs-error.html - error: { - type: 'object', - properties: { - type: string, - message: string, - stack_trace: string - }, - additionalProperties: true - } - }, - additionalProperties: true -}) - -module.exports = stringify - - /***/ }), /***/ 57432: @@ -16127,46 +16073,22 @@ const { formatHttpResponse } = __nccwpck_require__(14954) -const { hasOwnProperty } = Object.prototype let triedElasticApmImport = false let elasticApm = null -// Create options for `pino(...)` that configure it for ecs-logging output. -// -// @param {Object} opts - Optional. -// - {Boolean} opts.convertErr - Whether to convert a logged `err` field -// to ECS error fields. Default true, to match Pino's default of having -// an `err` serializer. -// - {Boolean} opts.convertReqRes - Whether to convert logged `req` and `res` -// HTTP request and response fields to ECS HTTP, User agent, and URL -// fields. Default false. -// - {Boolean} opts.apmIntegration - Whether to automatically integrate with -// Elastic APM (https://github.com/elastic/apm-agent-nodejs). If a started -// APM agent is detected, then log records will include the following -// fields: -// - "service.name" - the configured serviceName in the agent -// - "event.dataset" - set to "$serviceName.log" for correlation in Kibana -// - "trace.id", "transaction.id", and "span.id" - if there is a current -// active trace when the log call is made -// Default true. -function createEcsPinoOptions (opts) { - let convertErr = true - let convertReqRes = false - let apmIntegration = true - if (opts) { - if (hasOwnProperty.call(opts, 'convertErr')) { - convertErr = opts.convertErr - } - if (hasOwnProperty.call(opts, 'convertReqRes')) { - convertReqRes = opts.convertReqRes - } - if (hasOwnProperty.call(opts, 'apmIntegration')) { - apmIntegration = opts.apmIntegration - } - } +/** + * Create options for `pino(...)` that configure it for ecs-logging output. + * + * @param {Config} [opts] - See index.d.ts. + */ +function ecsFormat (opts) { + // istanbul ignore next + opts = opts || {} + const convertErr = opts.convertErr != null ? opts.convertErr : true + const convertReqRes = opts.convertReqRes != null ? opts.convertReqRes : false + const apmIntegration = opts.apmIntegration != null ? opts.apmIntegration : true let apm = null - let apmServiceName = null if (apmIntegration) { // istanbul ignore if if (opts && opts._elasticApm) { @@ -16188,16 +16110,55 @@ function createEcsPinoOptions (opts) { } if (elasticApm && elasticApm.isStarted && elasticApm.isStarted()) { apm = elasticApm - // Elastic APM v3.11.0 added getServiceName(). Fallback to private `apm._conf`. - // istanbul ignore next - apmServiceName = apm.getServiceName - ? apm.getServiceName() - : apm._conf.serviceName } } - let isServiceNameInBindings = false - let isEventDatasetInBindings = false + let serviceName = opts.serviceName + if (serviceName == null && apm) { + // istanbul ignore next + serviceName = (apm.getServiceName + ? apm.getServiceName() // added in elastic-apm-node@3.11.0 + : apm._conf.serviceName) // fallback to private `_conf` + } + + let serviceVersion = opts.serviceVersion + // istanbul ignore next + if (serviceVersion == null && apm) { + serviceVersion = (apm.getServiceVersion + ? apm.getServiceVersion() // added in elastic-apm-node@... + : apm._conf.serviceVersion) // fallback to private `_conf` + } + + let serviceEnvironment = opts.serviceEnvironment + if (serviceEnvironment == null && apm) { + // istanbul ignore next + serviceEnvironment = (apm.getServiceEnvironment + ? apm.getServiceEnvironment() // added in elastic-apm-node@... + : apm._conf.environment) // fallback to private `_conf` + } + + let serviceNodeName = opts.serviceNodeName + if (serviceNodeName == null && apm) { + // istanbul ignore next + serviceNodeName = (apm.getServiceNodeName + ? apm.getServiceNodeName() // added in elastic-apm-node@... + : apm._conf.serviceNodeName) // fallback to private `_conf` + } + + let eventDataset = opts.eventDataset + if (eventDataset == null && serviceName) { + eventDataset = serviceName + } + + let wasBindingsCalled = false + function addStaticEcsBindings (obj) { + obj['ecs.version'] = version + if (serviceName) { obj['service.name'] = serviceName } + if (serviceVersion) { obj['service.version'] = serviceVersion } + if (serviceEnvironment) { obj['service.environment'] = serviceEnvironment } + if (serviceNodeName) { obj['service.node.name'] = serviceNodeName } + if (eventDataset) { obj['event.dataset'] = eventDataset } + } const ecsPinoOptions = { messageKey: 'message', @@ -16215,32 +16176,27 @@ function createEcsPinoOptions (opts) { hostname, // name is defined if `log = pino({name: 'my name', ...})` name, - // Warning: silently drop any "ecs" value from `base`. See - // "ecs.version" comment below. - ecs, ...ecsBindings } = bindings if (pid !== undefined) { // https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-pid - ecsBindings.process = { pid: pid } + ecsBindings['process.pid'] = pid } if (hostname !== undefined) { // https://www.elastic.co/guide/en/ecs/current/ecs-host.html#field-host-hostname - ecsBindings.host = { hostname: hostname } + ecsBindings['host.hostname'] = hostname } if (name !== undefined) { // https://www.elastic.co/guide/en/ecs/current/ecs-log.html#field-log-logger - ecsBindings.log = { logger: name } + ecsBindings['log.logger'] = name } - // Note if service.name & event.dataset are set, to not do so again below. - if (bindings.service && bindings.service.name) { - isServiceNameInBindings = true - } - if (bindings.event && bindings.event.dataset) { - isEventDatasetInBindings = true - } + // With `pino({base: null, ...})` the `formatters.bindings` is *not* + // called. In this case we need to make sure to add our static bindings + // in `log()` below. + wasBindingsCalled = true + addStaticEcsBindings(ecsBindings) return ecsBindings }, @@ -16253,56 +16209,20 @@ function createEcsPinoOptions (opts) { ...ecsObj } = obj - // https://www.elastic.co/guide/en/ecs/current/ecs-ecs.html - // For "ecs.version" we take a heavier-handed approach, because it is - // a require ecs-logging field: overwrite any possible "ecs" value from - // the log statement. This means we don't need to spend the time - // guarding against "ecs" being null, Array, Buffer, Date, etc. - ecsObj.ecs = { version } + if (!wasBindingsCalled) { + addStaticEcsBindings(ecsObj) + } if (apm) { - // A mis-configured APM Agent can be "started" but not have a - // "serviceName". - if (apmServiceName) { - // Per https://github.com/elastic/ecs-logging/blob/master/spec/spec.json - // "service.name" and "event.dataset" should be automatically set - // if not already by the user. - if (!isServiceNameInBindings) { - const service = ecsObj.service - if (service === undefined) { - ecsObj.service = { name: apmServiceName } - } else if (!isVanillaObject(service)) { - // Warning: "service" type conflicts with ECS spec. Overwriting. - ecsObj.service = { name: apmServiceName } - } else if (typeof service.name !== 'string') { - ecsObj.service.name = apmServiceName - } - } - if (!isEventDatasetInBindings) { - const event = ecsObj.event - if (event === undefined) { - ecsObj.event = { dataset: apmServiceName + '.log' } - } else if (!isVanillaObject(event)) { - // Warning: "event" type conflicts with ECS spec. Overwriting. - ecsObj.event = { dataset: apmServiceName + '.log' } - } else if (typeof event.dataset !== 'string') { - ecsObj.event.dataset = apmServiceName + '.log' - } - } - } - // https://www.elastic.co/guide/en/ecs/current/ecs-tracing.html const tx = apm.currentTransaction if (tx) { - ecsObj.trace = ecsObj.trace || {} - ecsObj.trace.id = tx.traceId - ecsObj.transaction = ecsObj.transaction || {} - ecsObj.transaction.id = tx.id + ecsObj['trace.id'] = tx.traceId + ecsObj['transaction.id'] = tx.id const span = apm.currentSpan // istanbul ignore else if (span) { - ecsObj.span = ecsObj.span || {} - ecsObj.span.id = span.id + ecsObj['span.id'] = span.id } } } @@ -16340,22 +16260,21 @@ function createEcsPinoOptions (opts) { return ecsPinoOptions } -// Return true if the given arg is a "vanilla" object. Roughly the intent is -// whether this is basic mapping of string keys to values that will serialize -// as a JSON object. -// -// Currently, it excludes Map. The uses above don't really expect a user to: -// service = new Map([["foo", "bar"]]) -// log.info({ service }, '...') -// -// There are many ways tackle this. See some attempts and benchmarks at: -// https://gist.github.com/trentm/34131a92eede80fd2109f8febaa56f5a -function isVanillaObject (o) { - return (typeof o === 'object' && - (!o.constructor || o.constructor.name === 'Object')) -} - -module.exports = createEcsPinoOptions +// Exports to support the following import-styles from JS and TS code: +// 1. `const { ecsFormat } = require('@elastic/ecs-pino-format)` in JS and TS. +// The preferred import style for JS code using CommonJS. +// 2. `import { ecsFormat } from '@elastic/ecs-pino-format'` in JS and TS. +// ES module (ESM) import style. This is the preferred style for TypeScript +// code and for JS developers using ESM. +// 3. `const ecsFormat = require('@elastic/ecs-pino-format')` in JS. +// The old, deprecated import method. Still supported for backward compat. +// 4. `import ecsFormat from '@elastic/ecs-pino-format'` in JS and TS. +// This works, but is deprecated. Prefer #2 style. +// 5. `import * as EcsPinoFormat from '@elastic/ecs-pino-format'` in TS. +// One must then use `EcsPinoFormat.ecsFormat()`. +module.exports = ecsFormat // Required to support style 3. +module.exports.ecsFormat = ecsFormat +module.exports["default"] = ecsFormat // Required to support style 4. /***/ }), @@ -20931,7 +20850,7 @@ exports.ContextAPI = ContextAPI; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.DiagAPI = void 0; const ComponentLogger_1 = __nccwpck_require__(30507); -const logLevelLogger_1 = __nccwpck_require__(87492); +const logLevelLogger_1 = __nccwpck_require__(77978); const types_1 = __nccwpck_require__(46828); const global_utils_1 = __nccwpck_require__(91069); const API_NAME = 'diag'; @@ -21782,7 +21701,7 @@ exports.DiagConsoleLogger = DiagConsoleLogger; /***/ }), -/***/ 87492: +/***/ 77978: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -23524,7 +23443,7 @@ var TraceFlags; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.VERSION = void 0; // this is autogenerated file, see scripts/version-update.js -exports.VERSION = '1.4.1'; +exports.VERSION = '1.7.0'; //# sourceMappingURL=version.js.map /***/ }), @@ -24287,7 +24206,6 @@ __exportStar(__nccwpck_require__(60134), exports); __exportStar(__nccwpck_require__(88044), exports); __exportStar(__nccwpck_require__(24379), exports); __exportStar(__nccwpck_require__(82322), exports); -__exportStar(__nccwpck_require__(62733), exports); exports.baggageUtils = __nccwpck_require__(19987); __exportStar(__nccwpck_require__(81474), exports); __exportStar(__nccwpck_require__(69751), exports); @@ -26391,7 +26309,7 @@ exports.isWrapped = isWrapped; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.VERSION = void 0; // this is autogenerated file, see scripts/version-update.js -exports.VERSION = '1.15.2'; +exports.VERSION = '1.18.1'; //# sourceMappingURL=version.js.map /***/ }), @@ -27855,8 +27773,9 @@ exports.isPromiseLike = isPromiseLike; * limitations under the License. */ Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isDescriptorCompatibleWith = exports.createInstrumentDescriptorWithView = exports.createInstrumentDescriptor = exports.InstrumentType = void 0; +exports.isValidName = exports.isDescriptorCompatibleWith = exports.createInstrumentDescriptorWithView = exports.createInstrumentDescriptor = exports.InstrumentType = void 0; const api_1 = __nccwpck_require__(39128); +const utils_1 = __nccwpck_require__(66425); /** * Supported types of metric instruments. */ @@ -27870,13 +27789,17 @@ var InstrumentType; InstrumentType["OBSERVABLE_UP_DOWN_COUNTER"] = "OBSERVABLE_UP_DOWN_COUNTER"; })(InstrumentType = exports.InstrumentType || (exports.InstrumentType = {})); function createInstrumentDescriptor(name, type, options) { - var _a, _b, _c; + var _a, _b, _c, _d; + if (!isValidName(name)) { + api_1.diag.warn(`Invalid metric name: "${name}". The metric name should be a ASCII string with a length no greater than 255 characters.`); + } return { name, type, description: (_a = options === null || options === void 0 ? void 0 : options.description) !== null && _a !== void 0 ? _a : '', unit: (_b = options === null || options === void 0 ? void 0 : options.unit) !== null && _b !== void 0 ? _b : '', valueType: (_c = options === null || options === void 0 ? void 0 : options.valueType) !== null && _c !== void 0 ? _c : api_1.ValueType.DOUBLE, + advice: (_d = options === null || options === void 0 ? void 0 : options.advice) !== null && _d !== void 0 ? _d : {}, }; } exports.createInstrumentDescriptor = createInstrumentDescriptor; @@ -27888,16 +27811,25 @@ function createInstrumentDescriptorWithView(view, instrument) { type: instrument.type, unit: instrument.unit, valueType: instrument.valueType, + advice: instrument.advice, }; } exports.createInstrumentDescriptorWithView = createInstrumentDescriptorWithView; function isDescriptorCompatibleWith(descriptor, otherDescriptor) { - return (descriptor.name === otherDescriptor.name && + // Names are case-insensitive strings. + return ((0, utils_1.equalsCaseInsensitive)(descriptor.name, otherDescriptor.name) && descriptor.unit === otherDescriptor.unit && descriptor.type === otherDescriptor.type && descriptor.valueType === otherDescriptor.valueType); } exports.isDescriptorCompatibleWith = isDescriptorCompatibleWith; +// ASCII string with a length no greater than 255 characters. +// NB: the first character counted separately from the rest. +const NAME_REGEXP = /^[a-z][a-z0-9_.\-/]{0,254}$/i; +function isValidName(name) { + return name.match(NAME_REGEXP) != null; +} +exports.isValidName = isValidName; //# sourceMappingURL=InstrumentDescriptor.js.map /***/ }), @@ -28260,8 +28192,9 @@ const Instruments_1 = __nccwpck_require__(78443); * The class implements {@link ObservableResult} interface. */ class ObservableResultImpl { - constructor(_descriptor) { - this._descriptor = _descriptor; + constructor(_instrumentName, _valueType) { + this._instrumentName = _instrumentName; + this._valueType = _valueType; /** * @internal */ @@ -28272,12 +28205,11 @@ class ObservableResultImpl { */ observe(value, attributes = {}) { if (typeof value !== 'number') { - api_1.diag.warn(`non-number value provided to metric ${this._descriptor.name}: ${value}`); + api_1.diag.warn(`non-number value provided to metric ${this._instrumentName}: ${value}`); return; } - if (this._descriptor.valueType === api_1.ValueType.INT && - !Number.isInteger(value)) { - api_1.diag.warn(`INT value type cannot accept a floating-point value for ${this._descriptor.name}, ignoring the fractional digits.`); + if (this._valueType === api_1.ValueType.INT && !Number.isInteger(value)) { + api_1.diag.warn(`INT value type cannot accept a floating-point value for ${this._instrumentName}, ignoring the fractional digits.`); value = Math.trunc(value); // ignore non-finite values. if (!Number.isInteger(value)) { @@ -30321,7 +30253,7 @@ const AggregationSelector_1 = __nccwpck_require__(25984); */ class MetricReader { constructor(options) { - var _a, _b; + var _a, _b, _c; // Tracks the shutdown state. // TODO: use BindOncePromise here once a new version of @opentelemetry/core is available. this._shutdown = false; @@ -30329,17 +30261,23 @@ class MetricReader { (_a = options === null || options === void 0 ? void 0 : options.aggregationSelector) !== null && _a !== void 0 ? _a : AggregationSelector_1.DEFAULT_AGGREGATION_SELECTOR; this._aggregationTemporalitySelector = (_b = options === null || options === void 0 ? void 0 : options.aggregationTemporalitySelector) !== null && _b !== void 0 ? _b : AggregationSelector_1.DEFAULT_AGGREGATION_TEMPORALITY_SELECTOR; + this._metricProducers = (_c = options === null || options === void 0 ? void 0 : options.metricProducers) !== null && _c !== void 0 ? _c : []; } /** - * Set the {@link MetricProducer} used by this instance. + * Set the {@link MetricProducer} used by this instance. **This should only be called by the + * SDK and should be considered internal.** * + * To add additional {@link MetricProducer}s to a {@link MetricReader}, pass them to the + * constructor as {@link MetricReaderOptions.metricProducers}. + * + * @internal * @param metricProducer */ setMetricProducer(metricProducer) { - if (this._metricProducer) { + if (this._sdkMetricProducer) { throw new Error('MetricReader can not be bound to a MeterProvider again.'); } - this._metricProducer = metricProducer; + this._sdkMetricProducer = metricProducer; this.onInitialized(); } /** @@ -30367,16 +30305,32 @@ class MetricReader { * Collect all metrics from the associated {@link MetricProducer} */ async collect(options) { - if (this._metricProducer === undefined) { + if (this._sdkMetricProducer === undefined) { throw new Error('MetricReader is not bound to a MetricProducer'); } // Subsequent invocations to collect are not allowed. SDKs SHOULD return some failure for these calls. if (this._shutdown) { throw new Error('MetricReader is shutdown'); } - return this._metricProducer.collect({ - timeoutMillis: options === null || options === void 0 ? void 0 : options.timeoutMillis, - }); + const [sdkCollectionResults, ...additionalCollectionResults] = await Promise.all([ + this._sdkMetricProducer.collect({ + timeoutMillis: options === null || options === void 0 ? void 0 : options.timeoutMillis, + }), + ...this._metricProducers.map(producer => producer.collect({ + timeoutMillis: options === null || options === void 0 ? void 0 : options.timeoutMillis, + })), + ]); + // Merge the results, keeping the SDK's Resource + const errors = sdkCollectionResults.errors.concat((0, utils_1.FlatMap)(additionalCollectionResults, result => result.errors)); + const resource = sdkCollectionResults.resourceMetrics.resource; + const scopeMetrics = sdkCollectionResults.resourceMetrics.scopeMetrics.concat((0, utils_1.FlatMap)(additionalCollectionResults, result => result.resourceMetrics.scopeMetrics)); + return { + resourceMetrics: { + resource, + scopeMetrics, + }, + errors, + }; } /** * Shuts down the metric reader, the promise will reject after the optional timeout or resolve after completion. @@ -30460,6 +30414,7 @@ class PeriodicExportingMetricReader extends MetricReader_1.MetricReader { super({ aggregationSelector: (_a = options.exporter.selectAggregation) === null || _a === void 0 ? void 0 : _a.bind(options.exporter), aggregationTemporalitySelector: (_b = options.exporter.selectAggregationTemporality) === null || _b === void 0 ? void 0 : _b.bind(options.exporter), + metricProducers: options.metricProducers, }); if (options.exportIntervalMillis !== undefined && options.exportIntervalMillis <= 0) { @@ -30623,11 +30578,11 @@ const HashMap_1 = __nccwpck_require__(19536); * Stores and aggregates {@link MetricData} for asynchronous instruments. */ class AsyncMetricStorage extends MetricStorage_1.MetricStorage { - constructor(_instrumentDescriptor, aggregator, _attributesProcessor) { + constructor(_instrumentDescriptor, aggregator, _attributesProcessor, collectorHandles) { super(_instrumentDescriptor); this._attributesProcessor = _attributesProcessor; this._deltaMetricStorage = new DeltaMetricProcessor_1.DeltaMetricProcessor(aggregator); - this._temporalMetricStorage = new TemporalMetricProcessor_1.TemporalMetricProcessor(aggregator); + this._temporalMetricStorage = new TemporalMetricProcessor_1.TemporalMetricProcessor(aggregator, collectorHandles); } record(measurements, observationTime) { const processed = new HashMap_1.AttributeHashMap(); @@ -30643,9 +30598,9 @@ class AsyncMetricStorage extends MetricStorage_1.MetricStorage { * Note: This is a stateful operation and may reset any interval-related * state for the MetricCollector. */ - collect(collector, collectors, collectionTime) { + collect(collector, collectionTime) { const accumulations = this._deltaMetricStorage.collect(); - return this._temporalMetricStorage.buildMetrics(collector, collectors, this._instrumentDescriptor, accumulations, collectionTime); + return this._temporalMetricStorage.buildMetrics(collector, this._instrumentDescriptor, accumulations, collectionTime); } } exports.AsyncMetricStorage = AsyncMetricStorage; @@ -30945,15 +30900,24 @@ class MeterSharedState { * 2. Collect metric result for the collector. */ const errors = await this.observableRegistry.observe(collectionTime, options === null || options === void 0 ? void 0 : options.timeoutMillis); - const metricDataList = Array.from(this.metricStorageRegistry.getStorages(collector)) + const storages = this.metricStorageRegistry.getStorages(collector); + // prevent more allocations if there are no storages. + if (storages.length === 0) { + return null; + } + const metricDataList = storages .map(metricStorage => { - return metricStorage.collect(collector, this._meterProviderSharedState.metricCollectors, collectionTime); + return metricStorage.collect(collector, collectionTime); }) .filter(utils_1.isNotNullish); + // skip this scope if no data was collected (storage created, but no data observed) + if (metricDataList.length === 0) { + return { errors }; + } return { scopeMetrics: { scope: this._instrumentationScope, - metrics: metricDataList.filter(utils_1.isNotNullish), + metrics: metricDataList, }, errors, }; @@ -30967,7 +30931,7 @@ class MeterSharedState { return compatibleStorage; } const aggregator = view.aggregation.createAggregator(viewDescriptor); - const viewStorage = new MetricStorageType(viewDescriptor, aggregator, view.attributesProcessor); + const viewStorage = new MetricStorageType(viewDescriptor, aggregator, view.attributesProcessor, this._meterProviderSharedState.metricCollectors); this.metricStorageRegistry.register(viewStorage); return viewStorage; }); @@ -30980,7 +30944,7 @@ class MeterSharedState { return compatibleStorage; } const aggregator = aggregation.createAggregator(descriptor); - const storage = new MetricStorageType(descriptor, aggregator, AttributesProcessor_1.AttributesProcessor.Noop()); + const storage = new MetricStorageType(descriptor, aggregator, AttributesProcessor_1.AttributesProcessor.Noop(), [collector]); this.metricStorageRegistry.registerForCollector(collector, storage); return storage; }); @@ -31017,7 +30981,6 @@ exports.MeterSharedState = MeterSharedState; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.MetricCollector = void 0; const core_1 = __nccwpck_require__(53555); -const utils_1 = __nccwpck_require__(66425); /** * An internal opaque interface that the MetricReader receives as * MetricProducer. It acts as the storage key to the internal metric stream @@ -31030,14 +30993,26 @@ class MetricCollector { } async collect(options) { const collectionTime = (0, core_1.millisToHrTime)(Date.now()); - const meterCollectionPromises = Array.from(this._sharedState.meterSharedStates.values()).map(meterSharedState => meterSharedState.collect(this, collectionTime, options)); - const result = await Promise.all(meterCollectionPromises); + const scopeMetrics = []; + const errors = []; + const meterCollectionPromises = Array.from(this._sharedState.meterSharedStates.values()).map(async (meterSharedState) => { + const current = await meterSharedState.collect(this, collectionTime, options); + // only add scope metrics if available + if ((current === null || current === void 0 ? void 0 : current.scopeMetrics) != null) { + scopeMetrics.push(current.scopeMetrics); + } + // only add errors if available + if ((current === null || current === void 0 ? void 0 : current.errors) != null) { + errors.push(...current.errors); + } + }); + await Promise.all(meterCollectionPromises); return { resourceMetrics: { resource: this._sharedState.resource, - scopeMetrics: result.map(it => it.scopeMetrics), + scopeMetrics: scopeMetrics, }, - errors: (0, utils_1.FlatMap)(result, it => it.errors), + errors: errors, }; } /** @@ -31104,6 +31079,7 @@ class MetricStorage { description: description, valueType: this._instrumentDescriptor.valueType, unit: this._instrumentDescriptor.unit, + advice: this._instrumentDescriptor.advice, }); } } @@ -31363,7 +31339,7 @@ class ObservableRegistry { } _observeCallbacks(observationTime, timeoutMillis) { return this._callbacks.map(async ({ callback, instrument }) => { - const observableResult = new ObservableResult_1.ObservableResultImpl(instrument._descriptor); + const observableResult = new ObservableResult_1.ObservableResultImpl(instrument._descriptor.name, instrument._descriptor.valueType); let callPromise = Promise.resolve(callback(observableResult)); if (timeoutMillis != null) { callPromise = (0, utils_1.callWithTimeout)(callPromise, timeoutMillis); @@ -31441,11 +31417,11 @@ const TemporalMetricProcessor_1 = __nccwpck_require__(72067); * Stores and aggregates {@link MetricData} for synchronous instruments. */ class SyncMetricStorage extends MetricStorage_1.MetricStorage { - constructor(instrumentDescriptor, aggregator, _attributesProcessor) { + constructor(instrumentDescriptor, aggregator, _attributesProcessor, collectorHandles) { super(instrumentDescriptor); this._attributesProcessor = _attributesProcessor; this._deltaMetricStorage = new DeltaMetricProcessor_1.DeltaMetricProcessor(aggregator); - this._temporalMetricStorage = new TemporalMetricProcessor_1.TemporalMetricProcessor(aggregator); + this._temporalMetricStorage = new TemporalMetricProcessor_1.TemporalMetricProcessor(aggregator, collectorHandles); } record(value, attributes, context, recordTime) { attributes = this._attributesProcessor.process(attributes, context); @@ -31457,9 +31433,9 @@ class SyncMetricStorage extends MetricStorage_1.MetricStorage { * Note: This is a stateful operation and may reset any interval-related * state for the MetricCollector. */ - collect(collector, collectors, collectionTime) { + collect(collector, collectionTime) { const accumulations = this._deltaMetricStorage.collect(); - return this._temporalMetricStorage.buildMetrics(collector, collectors, this._instrumentDescriptor, accumulations, collectionTime); + return this._temporalMetricStorage.buildMetrics(collector, this._instrumentDescriptor, accumulations, collectionTime); } } exports.SyncMetricStorage = SyncMetricStorage; @@ -31498,10 +31474,13 @@ const HashMap_1 = __nccwpck_require__(19536); * of metrics and reports given temporality values. */ class TemporalMetricProcessor { - constructor(_aggregator) { + constructor(_aggregator, collectorHandles) { this._aggregator = _aggregator; this._unreportedAccumulations = new Map(); this._reportHistory = new Map(); + collectorHandles.forEach(handle => { + this._unreportedAccumulations.set(handle, []); + }); } /** * Builds the {@link MetricData} streams to report against a specific MetricCollector. @@ -31512,8 +31491,8 @@ class TemporalMetricProcessor { * @param collectionTime The current collection timestamp. * @returns The {@link MetricData} points or `null`. */ - buildMetrics(collector, collectors, instrumentDescriptor, currentAccumulations, collectionTime) { - this._stashAccumulations(collectors, currentAccumulations); + buildMetrics(collector, instrumentDescriptor, currentAccumulations, collectionTime) { + this._stashAccumulations(currentAccumulations); const unreportedAccumulations = this._getMergedUnreportedAccumulations(collector); let result = unreportedAccumulations; let aggregationTemporality; @@ -31554,18 +31533,24 @@ class TemporalMetricProcessor { collectionTime, aggregationTemporality, }); - return this._aggregator.toMetricData(instrumentDescriptor, aggregationTemporality, AttributesMapToAccumulationRecords(result), + const accumulationRecords = AttributesMapToAccumulationRecords(result); + // do not convert to metric data if there is nothing to convert. + if (accumulationRecords.length === 0) { + return undefined; + } + return this._aggregator.toMetricData(instrumentDescriptor, aggregationTemporality, accumulationRecords, /* endTime */ collectionTime); } - _stashAccumulations(collectors, currentAccumulation) { - collectors.forEach(it => { - let stash = this._unreportedAccumulations.get(it); + _stashAccumulations(currentAccumulation) { + const registeredCollectors = this._unreportedAccumulations.keys(); + for (const collector of registeredCollectors) { + let stash = this._unreportedAccumulations.get(collector); if (stash === undefined) { stash = []; - this._unreportedAccumulations.set(it, stash); + this._unreportedAccumulations.set(collector, stash); } stash.push(currentAccumulation); - }); + } } _getMergedUnreportedAccumulations(collector) { let result = new HashMap_1.AttributeHashMap(); @@ -31641,7 +31626,7 @@ function AttributesMapToAccumulationRecords(map) { * limitations under the License. */ Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.binarySearchLB = exports.setEquals = exports.FlatMap = exports.isPromiseAllSettledRejectionResult = exports.PromiseAllSettled = exports.callWithTimeout = exports.TimeoutError = exports.instrumentationScopeId = exports.hashAttributes = exports.isNotNullish = void 0; +exports.equalsCaseInsensitive = exports.binarySearchLB = exports.setEquals = exports.FlatMap = exports.isPromiseAllSettledRejectionResult = exports.PromiseAllSettled = exports.callWithTimeout = exports.TimeoutError = exports.instrumentationScopeId = exports.hashAttributes = exports.isNotNullish = void 0; function isNotNullish(item) { return item !== undefined && item !== null; } @@ -31780,6 +31765,10 @@ function binarySearchLB(arr, value) { return -1; } exports.binarySearchLB = binarySearchLB; +function equalsCaseInsensitive(lhs, rhs) { + return lhs.toLowerCase() === rhs.toLowerCase(); +} +exports.equalsCaseInsensitive = equalsCaseInsensitive; //# sourceMappingURL=utils.js.map /***/ }), @@ -31945,6 +31934,9 @@ class DefaultAggregation extends Aggregation { return LAST_VALUE_AGGREGATION; } case InstrumentDescriptor_1.InstrumentType.HISTOGRAM: { + if (instrument.advice.explicitBucketBoundaries) { + return new ExplicitBucketHistogramAggregation(instrument.advice.explicitBucketBoundaries); + } return HISTOGRAM_AGGREGATION; } } @@ -34009,6187 +34001,581 @@ module.exports = function (done) { process.nextTick(function () { if (!called) done(null, results); - }) - - return function (callback) { - called = true; - var index = cbCount++; - return function (err, result) { - if (callback) callback.apply(null, arguments); - if (err && !error) error = err; - results[index] = result; - process.nextTick(function () { - if (!--cbCount) done(error, results); - }); - }; - }; -}; - - -/***/ }), - -/***/ 39381: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -module.exports = __nccwpck_require__(20854); -module.exports.HttpsAgent = __nccwpck_require__(96210); -module.exports.constants = __nccwpck_require__(47151); - - -/***/ }), - -/***/ 20854: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -const OriginalAgent = (__nccwpck_require__(13685).Agent); -const ms = __nccwpck_require__(72462); -const debug = (__nccwpck_require__(73837).debuglog)('agentkeepalive'); -const { - INIT_SOCKET, - CURRENT_ID, - CREATE_ID, - SOCKET_CREATED_TIME, - SOCKET_NAME, - SOCKET_REQUEST_COUNT, - SOCKET_REQUEST_FINISHED_COUNT, -} = __nccwpck_require__(47151); - -// OriginalAgent come from -// - https://github.com/nodejs/node/blob/v8.12.0/lib/_http_agent.js -// - https://github.com/nodejs/node/blob/v10.12.0/lib/_http_agent.js - -// node <= 10 -let defaultTimeoutListenerCount = 1; -const majorVersion = parseInt(process.version.split('.', 1)[0].substring(1)); -if (majorVersion >= 11 && majorVersion <= 12) { - defaultTimeoutListenerCount = 2; -} else if (majorVersion >= 13) { - defaultTimeoutListenerCount = 3; -} - -function deprecate(message) { - console.log('[agentkeepalive:deprecated] %s', message); -} - -class Agent extends OriginalAgent { - constructor(options) { - options = options || {}; - options.keepAlive = options.keepAlive !== false; - // default is keep-alive and 4s free socket timeout - // see https://medium.com/ssense-tech/reduce-networking-errors-in-nodejs-23b4eb9f2d83 - if (options.freeSocketTimeout === undefined) { - options.freeSocketTimeout = 4000; - } - // Legacy API: keepAliveTimeout should be rename to `freeSocketTimeout` - if (options.keepAliveTimeout) { - deprecate('options.keepAliveTimeout is deprecated, please use options.freeSocketTimeout instead'); - options.freeSocketTimeout = options.keepAliveTimeout; - delete options.keepAliveTimeout; - } - // Legacy API: freeSocketKeepAliveTimeout should be rename to `freeSocketTimeout` - if (options.freeSocketKeepAliveTimeout) { - deprecate('options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead'); - options.freeSocketTimeout = options.freeSocketKeepAliveTimeout; - delete options.freeSocketKeepAliveTimeout; - } - - // Sets the socket to timeout after timeout milliseconds of inactivity on the socket. - // By default is double free socket timeout. - if (options.timeout === undefined) { - // make sure socket default inactivity timeout >= 8s - options.timeout = Math.max(options.freeSocketTimeout * 2, 8000); - } - - // support humanize format - options.timeout = ms(options.timeout); - options.freeSocketTimeout = ms(options.freeSocketTimeout); - options.socketActiveTTL = options.socketActiveTTL ? ms(options.socketActiveTTL) : 0; - - super(options); - - this[CURRENT_ID] = 0; - - // create socket success counter - this.createSocketCount = 0; - this.createSocketCountLastCheck = 0; - - this.createSocketErrorCount = 0; - this.createSocketErrorCountLastCheck = 0; - - this.closeSocketCount = 0; - this.closeSocketCountLastCheck = 0; - - // socket error event count - this.errorSocketCount = 0; - this.errorSocketCountLastCheck = 0; - - // request finished counter - this.requestCount = 0; - this.requestCountLastCheck = 0; - - // including free socket timeout counter - this.timeoutSocketCount = 0; - this.timeoutSocketCountLastCheck = 0; - - this.on('free', socket => { - // https://github.com/nodejs/node/pull/32000 - // Node.js native agent will check socket timeout eqs agent.options.timeout. - // Use the ttl or freeSocketTimeout to overwrite. - const timeout = this.calcSocketTimeout(socket); - if (timeout > 0 && socket.timeout !== timeout) { - socket.setTimeout(timeout); - } - }); - } - - get freeSocketKeepAliveTimeout() { - deprecate('agent.freeSocketKeepAliveTimeout is deprecated, please use agent.options.freeSocketTimeout instead'); - return this.options.freeSocketTimeout; - } - - get timeout() { - deprecate('agent.timeout is deprecated, please use agent.options.timeout instead'); - return this.options.timeout; - } - - get socketActiveTTL() { - deprecate('agent.socketActiveTTL is deprecated, please use agent.options.socketActiveTTL instead'); - return this.options.socketActiveTTL; - } - - calcSocketTimeout(socket) { - /** - * return <= 0: should free socket - * return > 0: should update socket timeout - * return undefined: not find custom timeout - */ - let freeSocketTimeout = this.options.freeSocketTimeout; - const socketActiveTTL = this.options.socketActiveTTL; - if (socketActiveTTL) { - // check socketActiveTTL - const aliveTime = Date.now() - socket[SOCKET_CREATED_TIME]; - const diff = socketActiveTTL - aliveTime; - if (diff <= 0) { - return diff; - } - if (freeSocketTimeout && diff < freeSocketTimeout) { - freeSocketTimeout = diff; - } - } - // set freeSocketTimeout - if (freeSocketTimeout) { - // set free keepalive timer - // try to use socket custom freeSocketTimeout first, support headers['keep-alive'] - // https://github.com/node-modules/urllib/blob/b76053020923f4d99a1c93cf2e16e0c5ba10bacf/lib/urllib.js#L498 - const customFreeSocketTimeout = socket.freeSocketTimeout || socket.freeSocketKeepAliveTimeout; - return customFreeSocketTimeout || freeSocketTimeout; - } - } - - keepSocketAlive(socket) { - const result = super.keepSocketAlive(socket); - // should not keepAlive, do nothing - if (!result) return result; - - const customTimeout = this.calcSocketTimeout(socket); - if (typeof customTimeout === 'undefined') { - return true; - } - if (customTimeout <= 0) { - debug('%s(requests: %s, finished: %s) free but need to destroy by TTL, request count %s, diff is %s', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], customTimeout); - return false; - } - if (socket.timeout !== customTimeout) { - socket.setTimeout(customTimeout); - } - return true; - } - - // only call on addRequest - reuseSocket(...args) { - // reuseSocket(socket, req) - super.reuseSocket(...args); - const socket = args[0]; - const req = args[1]; - req.reusedSocket = true; - const agentTimeout = this.options.timeout; - if (getSocketTimeout(socket) !== agentTimeout) { - // reset timeout before use - socket.setTimeout(agentTimeout); - debug('%s reset timeout to %sms', socket[SOCKET_NAME], agentTimeout); - } - socket[SOCKET_REQUEST_COUNT]++; - debug('%s(requests: %s, finished: %s) reuse on addRequest, timeout %sms', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], - getSocketTimeout(socket)); - } - - [CREATE_ID]() { - const id = this[CURRENT_ID]++; - if (this[CURRENT_ID] === Number.MAX_SAFE_INTEGER) this[CURRENT_ID] = 0; - return id; - } - - [INIT_SOCKET](socket, options) { - // bugfix here. - // https on node 8, 10 won't set agent.options.timeout by default - // TODO: need to fix on node itself - if (options.timeout) { - const timeout = getSocketTimeout(socket); - if (!timeout) { - socket.setTimeout(options.timeout); - } - } - - if (this.options.keepAlive) { - // Disable Nagle's algorithm: http://blog.caustik.com/2012/04/08/scaling-node-js-to-100k-concurrent-connections/ - // https://fengmk2.com/benchmark/nagle-algorithm-delayed-ack-mock.html - socket.setNoDelay(true); - } - this.createSocketCount++; - if (this.options.socketActiveTTL) { - socket[SOCKET_CREATED_TIME] = Date.now(); - } - // don't show the hole '-----BEGIN CERTIFICATE----' key string - socket[SOCKET_NAME] = `sock[${this[CREATE_ID]()}#${options._agentKey}]`.split('-----BEGIN', 1)[0]; - socket[SOCKET_REQUEST_COUNT] = 1; - socket[SOCKET_REQUEST_FINISHED_COUNT] = 0; - installListeners(this, socket, options); - } - - createConnection(options, oncreate) { - let called = false; - const onNewCreate = (err, socket) => { - if (called) return; - called = true; - - if (err) { - this.createSocketErrorCount++; - return oncreate(err); - } - this[INIT_SOCKET](socket, options); - oncreate(err, socket); - }; - - const newSocket = super.createConnection(options, onNewCreate); - if (newSocket) onNewCreate(null, newSocket); - return newSocket; - } - - get statusChanged() { - const changed = this.createSocketCount !== this.createSocketCountLastCheck || - this.createSocketErrorCount !== this.createSocketErrorCountLastCheck || - this.closeSocketCount !== this.closeSocketCountLastCheck || - this.errorSocketCount !== this.errorSocketCountLastCheck || - this.timeoutSocketCount !== this.timeoutSocketCountLastCheck || - this.requestCount !== this.requestCountLastCheck; - if (changed) { - this.createSocketCountLastCheck = this.createSocketCount; - this.createSocketErrorCountLastCheck = this.createSocketErrorCount; - this.closeSocketCountLastCheck = this.closeSocketCount; - this.errorSocketCountLastCheck = this.errorSocketCount; - this.timeoutSocketCountLastCheck = this.timeoutSocketCount; - this.requestCountLastCheck = this.requestCount; - } - return changed; - } - - getCurrentStatus() { - return { - createSocketCount: this.createSocketCount, - createSocketErrorCount: this.createSocketErrorCount, - closeSocketCount: this.closeSocketCount, - errorSocketCount: this.errorSocketCount, - timeoutSocketCount: this.timeoutSocketCount, - requestCount: this.requestCount, - freeSockets: inspect(this.freeSockets), - sockets: inspect(this.sockets), - requests: inspect(this.requests), - }; - } -} - -// node 8 don't has timeout attribute on socket -// https://github.com/nodejs/node/pull/21204/files#diff-e6ef024c3775d787c38487a6309e491dR408 -function getSocketTimeout(socket) { - return socket.timeout || socket._idleTimeout; -} - -function installListeners(agent, socket, options) { - debug('%s create, timeout %sms', socket[SOCKET_NAME], getSocketTimeout(socket)); - - // listener socket events: close, timeout, error, free - function onFree() { - // create and socket.emit('free') logic - // https://github.com/nodejs/node/blob/master/lib/_http_agent.js#L311 - // no req on the socket, it should be the new socket - if (!socket._httpMessage && socket[SOCKET_REQUEST_COUNT] === 1) return; - - socket[SOCKET_REQUEST_FINISHED_COUNT]++; - agent.requestCount++; - debug('%s(requests: %s, finished: %s) free', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]); - - // should reuse on pedding requests? - const name = agent.getName(options); - if (socket.writable && agent.requests[name] && agent.requests[name].length) { - // will be reuse on agent free listener - socket[SOCKET_REQUEST_COUNT]++; - debug('%s(requests: %s, finished: %s) will be reuse on agent free event', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]); - } - } - socket.on('free', onFree); - - function onClose(isError) { - debug('%s(requests: %s, finished: %s) close, isError: %s', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], isError); - agent.closeSocketCount++; - } - socket.on('close', onClose); - - // start socket timeout handler - function onTimeout() { - // onTimeout and emitRequestTimeout(_http_client.js) - // https://github.com/nodejs/node/blob/v12.x/lib/_http_client.js#L711 - const listenerCount = socket.listeners('timeout').length; - // node <= 10, default listenerCount is 1, onTimeout - // 11 < node <= 12, default listenerCount is 2, onTimeout and emitRequestTimeout - // node >= 13, default listenerCount is 3, onTimeout, - // onTimeout(https://github.com/nodejs/node/pull/32000/files#diff-5f7fb0850412c6be189faeddea6c5359R333) - // and emitRequestTimeout - const timeout = getSocketTimeout(socket); - const req = socket._httpMessage; - const reqTimeoutListenerCount = req && req.listeners('timeout').length || 0; - debug('%s(requests: %s, finished: %s) timeout after %sms, listeners %s, defaultTimeoutListenerCount %s, hasHttpRequest %s, HttpRequest timeoutListenerCount %s', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], - timeout, listenerCount, defaultTimeoutListenerCount, !!req, reqTimeoutListenerCount); - if (debug.enabled) { - debug('timeout listeners: %s', socket.listeners('timeout').map(f => f.name).join(', ')); - } - agent.timeoutSocketCount++; - const name = agent.getName(options); - if (agent.freeSockets[name] && agent.freeSockets[name].indexOf(socket) !== -1) { - // free socket timeout, destroy quietly - socket.destroy(); - // Remove it from freeSockets list immediately to prevent new requests - // from being sent through this socket. - agent.removeSocket(socket, options); - debug('%s is free, destroy quietly', socket[SOCKET_NAME]); - } else { - // if there is no any request socket timeout handler, - // agent need to handle socket timeout itself. - // - // custom request socket timeout handle logic must follow these rules: - // 1. Destroy socket first - // 2. Must emit socket 'agentRemove' event tell agent remove socket - // from freeSockets list immediately. - // Otherise you may be get 'socket hang up' error when reuse - // free socket and timeout happen in the same time. - if (reqTimeoutListenerCount === 0) { - const error = new Error('Socket timeout'); - error.code = 'ERR_SOCKET_TIMEOUT'; - error.timeout = timeout; - // must manually call socket.end() or socket.destroy() to end the connection. - // https://nodejs.org/dist/latest-v10.x/docs/api/net.html#net_socket_settimeout_timeout_callback - socket.destroy(error); - agent.removeSocket(socket, options); - debug('%s destroy with timeout error', socket[SOCKET_NAME]); - } - } - } - socket.on('timeout', onTimeout); - - function onError(err) { - const listenerCount = socket.listeners('error').length; - debug('%s(requests: %s, finished: %s) error: %s, listenerCount: %s', - socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], - err, listenerCount); - agent.errorSocketCount++; - if (listenerCount === 1) { - // if socket don't contain error event handler, don't catch it, emit it again - debug('%s emit uncaught error event', socket[SOCKET_NAME]); - socket.removeListener('error', onError); - socket.emit('error', err); - } - } - socket.on('error', onError); - - function onRemove() { - debug('%s(requests: %s, finished: %s) agentRemove', - socket[SOCKET_NAME], - socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]); - // We need this function for cases like HTTP 'upgrade' - // (defined by WebSockets) where we need to remove a socket from the - // pool because it'll be locked up indefinitely - socket.removeListener('close', onClose); - socket.removeListener('error', onError); - socket.removeListener('free', onFree); - socket.removeListener('timeout', onTimeout); - socket.removeListener('agentRemove', onRemove); - } - socket.on('agentRemove', onRemove); -} - -module.exports = Agent; - -function inspect(obj) { - const res = {}; - for (const key in obj) { - res[key] = obj[key].length; - } - return res; -} - - -/***/ }), - -/***/ 47151: -/***/ ((module) => { - -"use strict"; - - -module.exports = { - // agent - CURRENT_ID: Symbol('agentkeepalive#currentId'), - CREATE_ID: Symbol('agentkeepalive#createId'), - INIT_SOCKET: Symbol('agentkeepalive#initSocket'), - CREATE_HTTPS_CONNECTION: Symbol('agentkeepalive#createHttpsConnection'), - // socket - SOCKET_CREATED_TIME: Symbol('agentkeepalive#socketCreatedTime'), - SOCKET_NAME: Symbol('agentkeepalive#socketName'), - SOCKET_REQUEST_COUNT: Symbol('agentkeepalive#socketRequestCount'), - SOCKET_REQUEST_FINISHED_COUNT: Symbol('agentkeepalive#socketRequestFinishedCount'), -}; - - -/***/ }), - -/***/ 96210: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -const OriginalHttpsAgent = (__nccwpck_require__(95687).Agent); -const HttpAgent = __nccwpck_require__(20854); -const { - INIT_SOCKET, - CREATE_HTTPS_CONNECTION, -} = __nccwpck_require__(47151); - -class HttpsAgent extends HttpAgent { - constructor(options) { - super(options); - - this.defaultPort = 443; - this.protocol = 'https:'; - this.maxCachedSessions = this.options.maxCachedSessions; - /* istanbul ignore next */ - if (this.maxCachedSessions === undefined) { - this.maxCachedSessions = 100; - } - - this._sessionCache = { - map: {}, - list: [], - }; - } - - createConnection(options, oncreate) { - const socket = this[CREATE_HTTPS_CONNECTION](options, oncreate); - this[INIT_SOCKET](socket, options); - return socket; - } -} - -// https://github.com/nodejs/node/blob/master/lib/https.js#L89 -HttpsAgent.prototype[CREATE_HTTPS_CONNECTION] = OriginalHttpsAgent.prototype.createConnection; - -[ - 'getName', - '_getSession', - '_cacheSession', - // https://github.com/nodejs/node/pull/4982 - '_evictSession', -].forEach(function(method) { - /* istanbul ignore next */ - if (typeof OriginalHttpsAgent.prototype[method] === 'function') { - HttpsAgent.prototype[method] = OriginalHttpsAgent.prototype[method]; - } -}); - -module.exports = HttpsAgent; - - -/***/ }), - -/***/ 33786: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - -const indentString = __nccwpck_require__(17160); -const cleanStack = __nccwpck_require__(20523); - -const cleanInternalStack = stack => stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, ''); - -class AggregateError extends Error { - constructor(errors) { - if (!Array.isArray(errors)) { - throw new TypeError(`Expected input to be an Array, got ${typeof errors}`); - } - - errors = [...errors].map(error => { - if (error instanceof Error) { - return error; - } - - if (error !== null && typeof error === 'object') { - // Handle plain error objects with message property and/or possibly other metadata - return Object.assign(new Error(error.message), error); - } - - return new Error(error); - }); - - let message = errors - .map(error => { - // The `stack` property is not standardized, so we can't assume it exists - return typeof error.stack === 'string' ? cleanInternalStack(cleanStack(error.stack)) : String(error); - }) - .join('\n'); - message = '\n' + indentString(message, 4); - super(message); - - this.name = 'AggregateError'; - - Object.defineProperty(this, '_errors', {value: errors}); - } - - * [Symbol.iterator]() { - for (const error of this._errors) { - yield error; - } - } -} - -module.exports = AggregateError; - - -/***/ }), - -/***/ 65486: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -var compileSchema = __nccwpck_require__(35397) - , resolve = __nccwpck_require__(4453) - , Cache = __nccwpck_require__(4546) - , SchemaObject = __nccwpck_require__(53678) - , stableStringify = __nccwpck_require__(59034) - , formats = __nccwpck_require__(1053) - , rules = __nccwpck_require__(19451) - , $dataMetaSchema = __nccwpck_require__(72693) - , util = __nccwpck_require__(54797); - -module.exports = Ajv; - -Ajv.prototype.validate = validate; -Ajv.prototype.compile = compile; -Ajv.prototype.addSchema = addSchema; -Ajv.prototype.addMetaSchema = addMetaSchema; -Ajv.prototype.validateSchema = validateSchema; -Ajv.prototype.getSchema = getSchema; -Ajv.prototype.removeSchema = removeSchema; -Ajv.prototype.addFormat = addFormat; -Ajv.prototype.errorsText = errorsText; - -Ajv.prototype._addSchema = _addSchema; -Ajv.prototype._compile = _compile; - -Ajv.prototype.compileAsync = __nccwpck_require__(9689); -var customKeyword = __nccwpck_require__(65930); -Ajv.prototype.addKeyword = customKeyword.add; -Ajv.prototype.getKeyword = customKeyword.get; -Ajv.prototype.removeKeyword = customKeyword.remove; -Ajv.prototype.validateKeyword = customKeyword.validate; - -var errorClasses = __nccwpck_require__(8649); -Ajv.ValidationError = errorClasses.Validation; -Ajv.MissingRefError = errorClasses.MissingRef; -Ajv.$dataMetaSchema = $dataMetaSchema; - -var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema'; - -var META_IGNORE_OPTIONS = [ 'removeAdditional', 'useDefaults', 'coerceTypes', 'strictDefaults' ]; -var META_SUPPORT_DATA = ['/properties']; - -/** - * Creates validator instance. - * Usage: `Ajv(opts)` - * @param {Object} opts optional options - * @return {Object} ajv instance - */ -function Ajv(opts) { - if (!(this instanceof Ajv)) return new Ajv(opts); - opts = this._opts = util.copy(opts) || {}; - setLogger(this); - this._schemas = {}; - this._refs = {}; - this._fragments = {}; - this._formats = formats(opts.format); - - this._cache = opts.cache || new Cache; - this._loadingSchemas = {}; - this._compilations = []; - this.RULES = rules(); - this._getId = chooseGetId(opts); - - opts.loopRequired = opts.loopRequired || Infinity; - if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true; - if (opts.serialize === undefined) opts.serialize = stableStringify; - this._metaOpts = getMetaSchemaOptions(this); - - if (opts.formats) addInitialFormats(this); - if (opts.keywords) addInitialKeywords(this); - addDefaultMetaSchema(this); - if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta); - if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}}); - addInitialSchemas(this); -} - - - -/** - * Validate data using schema - * Schema will be compiled and cached (using serialized JSON as key. [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize. - * @this Ajv - * @param {String|Object} schemaKeyRef key, ref or schema object - * @param {Any} data to be validated - * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`). - */ -function validate(schemaKeyRef, data) { - var v; - if (typeof schemaKeyRef == 'string') { - v = this.getSchema(schemaKeyRef); - if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"'); - } else { - var schemaObj = this._addSchema(schemaKeyRef); - v = schemaObj.validate || this._compile(schemaObj); - } - - var valid = v(data); - if (v.$async !== true) this.errors = v.errors; - return valid; -} - - -/** - * Create validating function for passed schema. - * @this Ajv - * @param {Object} schema schema object - * @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords. - * @return {Function} validating function - */ -function compile(schema, _meta) { - var schemaObj = this._addSchema(schema, undefined, _meta); - return schemaObj.validate || this._compile(schemaObj); -} - - -/** - * Adds schema to the instance. - * @this Ajv - * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored. - * @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`. - * @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead. - * @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead. - * @return {Ajv} this for method chaining - */ -function addSchema(schema, key, _skipValidation, _meta) { - if (Array.isArray(schema)){ - for (var i=0; i} errors optional array of validation errors, if not passed errors from the instance are used. - * @param {Object} options optional options with properties `separator` and `dataVar`. - * @return {String} human readable string with all errors descriptions - */ -function errorsText(errors, options) { - errors = errors || this.errors; - if (!errors) return 'No errors'; - options = options || {}; - var separator = options.separator === undefined ? ', ' : options.separator; - var dataVar = options.dataVar === undefined ? 'data' : options.dataVar; - - var text = ''; - for (var i=0; i { - -"use strict"; - - - -var Cache = module.exports = function Cache() { - this._cache = {}; -}; - - -Cache.prototype.put = function Cache_put(key, value) { - this._cache[key] = value; -}; - - -Cache.prototype.get = function Cache_get(key) { - return this._cache[key]; -}; - - -Cache.prototype.del = function Cache_del(key) { - delete this._cache[key]; -}; - - -Cache.prototype.clear = function Cache_clear() { - this._cache = {}; -}; - - -/***/ }), - -/***/ 9689: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -var MissingRefError = (__nccwpck_require__(8649).MissingRef); - -module.exports = compileAsync; - - -/** - * Creates validating function for passed schema with asynchronous loading of missing schemas. - * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema. - * @this Ajv - * @param {Object} schema schema object - * @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped - * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function. - * @return {Promise} promise that resolves with a validating function. - */ -function compileAsync(schema, meta, callback) { - /* eslint no-shadow: 0 */ - /* global Promise */ - /* jshint validthis: true */ - var self = this; - if (typeof this._opts.loadSchema != 'function') - throw new Error('options.loadSchema should be a function'); - - if (typeof meta == 'function') { - callback = meta; - meta = undefined; - } - - var p = loadMetaSchemaOf(schema).then(function () { - var schemaObj = self._addSchema(schema, undefined, meta); - return schemaObj.validate || _compileAsync(schemaObj); - }); - - if (callback) { - p.then( - function(v) { callback(null, v); }, - callback - ); - } - - return p; - - - function loadMetaSchemaOf(sch) { - var $schema = sch.$schema; - return $schema && !self.getSchema($schema) - ? compileAsync.call(self, { $ref: $schema }, true) - : Promise.resolve(); - } - - - function _compileAsync(schemaObj) { - try { return self._compile(schemaObj); } - catch(e) { - if (e instanceof MissingRefError) return loadMissingSchema(e); - throw e; - } - - - function loadMissingSchema(e) { - var ref = e.missingSchema; - if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved'); - - var schemaPromise = self._loadingSchemas[ref]; - if (!schemaPromise) { - schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref); - schemaPromise.then(removePromise, removePromise); - } - - return schemaPromise.then(function (sch) { - if (!added(ref)) { - return loadMetaSchemaOf(sch).then(function () { - if (!added(ref)) self.addSchema(sch, ref, undefined, meta); - }); - } - }).then(function() { - return _compileAsync(schemaObj); - }); - - function removePromise() { - delete self._loadingSchemas[ref]; - } - - function added(ref) { - return self._refs[ref] || self._schemas[ref]; - } - } - } -} - - -/***/ }), - -/***/ 88178: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -// do NOT remove this file - it would break pre-compiled schemas -// https://github.com/ajv-validator/ajv/issues/889 -module.exports = __nccwpck_require__(5103); - - -/***/ }), - -/***/ 8649: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -var resolve = __nccwpck_require__(4453); - -module.exports = { - Validation: errorSubclass(ValidationError), - MissingRef: errorSubclass(MissingRefError) -}; - - -function ValidationError(errors) { - this.message = 'validation failed'; - this.errors = errors; - this.ajv = this.validation = true; -} - - -MissingRefError.message = function (baseId, ref) { - return 'can\'t resolve reference ' + ref + ' from id ' + baseId; -}; - - -function MissingRefError(baseId, ref, message) { - this.message = message || MissingRefError.message(baseId, ref); - this.missingRef = resolve.url(baseId, ref); - this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef)); -} - - -function errorSubclass(Subclass) { - Subclass.prototype = Object.create(Error.prototype); - Subclass.prototype.constructor = Subclass; - return Subclass; -} - - -/***/ }), - -/***/ 1053: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -var util = __nccwpck_require__(54797); - -var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/; -var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31]; -var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i; -var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i; -var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i; -var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i; -// uri-template: https://tools.ietf.org/html/rfc6570 -var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i; -// For the source: https://gist.github.com/dperini/729294 -// For test cases: https://mathiasbynens.be/demo/url-regex -// @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983. -// var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu; -var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i; -var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i; -var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/; -var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i; -var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/; - - -module.exports = formats; - -function formats(mode) { - mode = mode == 'full' ? 'full' : 'fast'; - return util.copy(formats[mode]); -} - - -formats.fast = { - // date: http://tools.ietf.org/html/rfc3339#section-5.6 - date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/, - // date-time: http://tools.ietf.org/html/rfc3339#section-5.6 - time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, - 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, - // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js - uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i, - 'uri-reference': /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i, - 'uri-template': URITEMPLATE, - url: URL, - // email (sources from jsen validator): - // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363 - // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation') - email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i, - hostname: HOSTNAME, - // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html - ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, - // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses - ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i, - regex: regex, - // uuid: http://tools.ietf.org/html/rfc4122 - uuid: UUID, - // JSON-pointer: https://tools.ietf.org/html/rfc6901 - // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A - 'json-pointer': JSON_POINTER, - 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT, - // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00 - 'relative-json-pointer': RELATIVE_JSON_POINTER -}; - - -formats.full = { - date: date, - time: time, - 'date-time': date_time, - uri: uri, - 'uri-reference': URIREF, - 'uri-template': URITEMPLATE, - url: URL, - email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i, - hostname: HOSTNAME, - ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, - ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i, - regex: regex, - uuid: UUID, - 'json-pointer': JSON_POINTER, - 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT, - 'relative-json-pointer': RELATIVE_JSON_POINTER -}; - - -function isLeapYear(year) { - // https://tools.ietf.org/html/rfc3339#appendix-C - return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); -} - - -function date(str) { - // full-date from http://tools.ietf.org/html/rfc3339#section-5.6 - var matches = str.match(DATE); - if (!matches) return false; - - var year = +matches[1]; - var month = +matches[2]; - var day = +matches[3]; - - return month >= 1 && month <= 12 && day >= 1 && - day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]); -} - - -function time(str, full) { - var matches = str.match(TIME); - if (!matches) return false; - - var hour = matches[1]; - var minute = matches[2]; - var second = matches[3]; - var timeZone = matches[5]; - return ((hour <= 23 && minute <= 59 && second <= 59) || - (hour == 23 && minute == 59 && second == 60)) && - (!full || timeZone); -} - - -var DATE_TIME_SEPARATOR = /t|\s/i; -function date_time(str) { - // http://tools.ietf.org/html/rfc3339#section-5.6 - var dateTime = str.split(DATE_TIME_SEPARATOR); - return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true); -} - - -var NOT_URI_FRAGMENT = /\/|:/; -function uri(str) { - // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "." - return NOT_URI_FRAGMENT.test(str) && URI.test(str); -} - - -var Z_ANCHOR = /[^\\]\\Z/; -function regex(str) { - if (Z_ANCHOR.test(str)) return false; - try { - new RegExp(str); - return true; - } catch(e) { - return false; - } -} - - -/***/ }), - -/***/ 35397: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -var resolve = __nccwpck_require__(4453) - , util = __nccwpck_require__(54797) - , errorClasses = __nccwpck_require__(8649) - , stableStringify = __nccwpck_require__(59034); - -var validateGenerator = __nccwpck_require__(24887); - -/** - * Functions below are used inside compiled validations function - */ - -var ucs2length = util.ucs2length; -var equal = __nccwpck_require__(5103); - -// this error is thrown by async schemas to return validation errors via exception -var ValidationError = errorClasses.Validation; - -module.exports = compile; - - -/** - * Compiles schema to validation function - * @this Ajv - * @param {Object} schema schema object - * @param {Object} root object with information about the root schema for this schema - * @param {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution - * @param {String} baseId base ID for IDs in the schema - * @return {Function} validation function - */ -function compile(schema, root, localRefs, baseId) { - /* jshint validthis: true, evil: true */ - /* eslint no-shadow: 0 */ - var self = this - , opts = this._opts - , refVal = [ undefined ] - , refs = {} - , patterns = [] - , patternsHash = {} - , defaults = [] - , defaultsHash = {} - , customRules = []; - - root = root || { schema: schema, refVal: refVal, refs: refs }; - - var c = checkCompiling.call(this, schema, root, baseId); - var compilation = this._compilations[c.index]; - if (c.compiling) return (compilation.callValidate = callValidate); - - var formats = this._formats; - var RULES = this.RULES; - - try { - var v = localCompile(schema, root, localRefs, baseId); - compilation.validate = v; - var cv = compilation.callValidate; - if (cv) { - cv.schema = v.schema; - cv.errors = null; - cv.refs = v.refs; - cv.refVal = v.refVal; - cv.root = v.root; - cv.$async = v.$async; - if (opts.sourceCode) cv.source = v.source; - } - return v; - } finally { - endCompiling.call(this, schema, root, baseId); - } - - /* @this {*} - custom context, see passContext option */ - function callValidate() { - /* jshint validthis: true */ - var validate = compilation.validate; - var result = validate.apply(this, arguments); - callValidate.errors = validate.errors; - return result; - } - - function localCompile(_schema, _root, localRefs, baseId) { - var isRoot = !_root || (_root && _root.schema == _schema); - if (_root.schema != root.schema) - return compile.call(self, _schema, _root, localRefs, baseId); - - var $async = _schema.$async === true; - - var sourceCode = validateGenerator({ - isTop: true, - schema: _schema, - isRoot: isRoot, - baseId: baseId, - root: _root, - schemaPath: '', - errSchemaPath: '#', - errorPath: '""', - MissingRefError: errorClasses.MissingRef, - RULES: RULES, - validate: validateGenerator, - util: util, - resolve: resolve, - resolveRef: resolveRef, - usePattern: usePattern, - useDefault: useDefault, - useCustomRule: useCustomRule, - opts: opts, - formats: formats, - logger: self.logger, - self: self - }); - - sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode) - + vars(defaults, defaultCode) + vars(customRules, customRuleCode) - + sourceCode; - - if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema); - // console.log('\n\n\n *** \n', JSON.stringify(sourceCode)); - var validate; - try { - var makeValidate = new Function( - 'self', - 'RULES', - 'formats', - 'root', - 'refVal', - 'defaults', - 'customRules', - 'equal', - 'ucs2length', - 'ValidationError', - sourceCode - ); - - validate = makeValidate( - self, - RULES, - formats, - root, - refVal, - defaults, - customRules, - equal, - ucs2length, - ValidationError - ); - - refVal[0] = validate; - } catch(e) { - self.logger.error('Error compiling schema, function code:', sourceCode); - throw e; - } - - validate.schema = _schema; - validate.errors = null; - validate.refs = refs; - validate.refVal = refVal; - validate.root = isRoot ? validate : _root; - if ($async) validate.$async = true; - if (opts.sourceCode === true) { - validate.source = { - code: sourceCode, - patterns: patterns, - defaults: defaults - }; - } - - return validate; - } - - function resolveRef(baseId, ref, isRoot) { - ref = resolve.url(baseId, ref); - var refIndex = refs[ref]; - var _refVal, refCode; - if (refIndex !== undefined) { - _refVal = refVal[refIndex]; - refCode = 'refVal[' + refIndex + ']'; - return resolvedRef(_refVal, refCode); - } - if (!isRoot && root.refs) { - var rootRefId = root.refs[ref]; - if (rootRefId !== undefined) { - _refVal = root.refVal[rootRefId]; - refCode = addLocalRef(ref, _refVal); - return resolvedRef(_refVal, refCode); - } - } - - refCode = addLocalRef(ref); - var v = resolve.call(self, localCompile, root, ref); - if (v === undefined) { - var localSchema = localRefs && localRefs[ref]; - if (localSchema) { - v = resolve.inlineRef(localSchema, opts.inlineRefs) - ? localSchema - : compile.call(self, localSchema, root, localRefs, baseId); - } - } - - if (v === undefined) { - removeLocalRef(ref); - } else { - replaceLocalRef(ref, v); - return resolvedRef(v, refCode); - } - } - - function addLocalRef(ref, v) { - var refId = refVal.length; - refVal[refId] = v; - refs[ref] = refId; - return 'refVal' + refId; - } - - function removeLocalRef(ref) { - delete refs[ref]; - } - - function replaceLocalRef(ref, v) { - var refId = refs[ref]; - refVal[refId] = v; - } - - function resolvedRef(refVal, code) { - return typeof refVal == 'object' || typeof refVal == 'boolean' - ? { code: code, schema: refVal, inline: true } - : { code: code, $async: refVal && !!refVal.$async }; - } - - function usePattern(regexStr) { - var index = patternsHash[regexStr]; - if (index === undefined) { - index = patternsHash[regexStr] = patterns.length; - patterns[index] = regexStr; - } - return 'pattern' + index; - } - - function useDefault(value) { - switch (typeof value) { - case 'boolean': - case 'number': - return '' + value; - case 'string': - return util.toQuotedString(value); - case 'object': - if (value === null) return 'null'; - var valueStr = stableStringify(value); - var index = defaultsHash[valueStr]; - if (index === undefined) { - index = defaultsHash[valueStr] = defaults.length; - defaults[index] = value; - } - return 'default' + index; - } - } - - function useCustomRule(rule, schema, parentSchema, it) { - if (self._opts.validateSchema !== false) { - var deps = rule.definition.dependencies; - if (deps && !deps.every(function(keyword) { - return Object.prototype.hasOwnProperty.call(parentSchema, keyword); - })) - throw new Error('parent schema must have all required keywords: ' + deps.join(',')); - - var validateSchema = rule.definition.validateSchema; - if (validateSchema) { - var valid = validateSchema(schema); - if (!valid) { - var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors); - if (self._opts.validateSchema == 'log') self.logger.error(message); - else throw new Error(message); - } - } - } - - var compile = rule.definition.compile - , inline = rule.definition.inline - , macro = rule.definition.macro; - - var validate; - if (compile) { - validate = compile.call(self, schema, parentSchema, it); - } else if (macro) { - validate = macro.call(self, schema, parentSchema, it); - if (opts.validateSchema !== false) self.validateSchema(validate, true); - } else if (inline) { - validate = inline.call(self, it, rule.keyword, schema, parentSchema); - } else { - validate = rule.definition.validate; - if (!validate) return; - } - - if (validate === undefined) - throw new Error('custom keyword "' + rule.keyword + '"failed to compile'); - - var index = customRules.length; - customRules[index] = validate; - - return { - code: 'customRule' + index, - validate: validate - }; - } -} - - -/** - * Checks if the schema is currently compiled - * @this Ajv - * @param {Object} schema schema to compile - * @param {Object} root root object - * @param {String} baseId base schema ID - * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean) - */ -function checkCompiling(schema, root, baseId) { - /* jshint validthis: true */ - var index = compIndex.call(this, schema, root, baseId); - if (index >= 0) return { index: index, compiling: true }; - index = this._compilations.length; - this._compilations[index] = { - schema: schema, - root: root, - baseId: baseId - }; - return { index: index, compiling: false }; -} - - -/** - * Removes the schema from the currently compiled list - * @this Ajv - * @param {Object} schema schema to compile - * @param {Object} root root object - * @param {String} baseId base schema ID - */ -function endCompiling(schema, root, baseId) { - /* jshint validthis: true */ - var i = compIndex.call(this, schema, root, baseId); - if (i >= 0) this._compilations.splice(i, 1); -} - - -/** - * Index of schema compilation in the currently compiled list - * @this Ajv - * @param {Object} schema schema to compile - * @param {Object} root root object - * @param {String} baseId base schema ID - * @return {Integer} compilation index - */ -function compIndex(schema, root, baseId) { - /* jshint validthis: true */ - for (var i=0; i { - -"use strict"; - - -var URI = __nccwpck_require__(16471) - , equal = __nccwpck_require__(5103) - , util = __nccwpck_require__(54797) - , SchemaObject = __nccwpck_require__(53678) - , traverse = __nccwpck_require__(33282); - -module.exports = resolve; - -resolve.normalizeId = normalizeId; -resolve.fullPath = getFullPath; -resolve.url = resolveUrl; -resolve.ids = resolveIds; -resolve.inlineRef = inlineRef; -resolve.schema = resolveSchema; - -/** - * [resolve and compile the references ($ref)] - * @this Ajv - * @param {Function} compile reference to schema compilation funciton (localCompile) - * @param {Object} root object with information about the root schema for the current schema - * @param {String} ref reference to resolve - * @return {Object|Function} schema object (if the schema can be inlined) or validation function - */ -function resolve(compile, root, ref) { - /* jshint validthis: true */ - var refVal = this._refs[ref]; - if (typeof refVal == 'string') { - if (this._refs[refVal]) refVal = this._refs[refVal]; - else return resolve.call(this, compile, root, refVal); - } - - refVal = refVal || this._schemas[ref]; - if (refVal instanceof SchemaObject) { - return inlineRef(refVal.schema, this._opts.inlineRefs) - ? refVal.schema - : refVal.validate || this._compile(refVal); - } - - var res = resolveSchema.call(this, root, ref); - var schema, v, baseId; - if (res) { - schema = res.schema; - root = res.root; - baseId = res.baseId; - } - - if (schema instanceof SchemaObject) { - v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId); - } else if (schema !== undefined) { - v = inlineRef(schema, this._opts.inlineRefs) - ? schema - : compile.call(this, schema, root, undefined, baseId); - } - - return v; -} - - -/** - * Resolve schema, its root and baseId - * @this Ajv - * @param {Object} root root object with properties schema, refVal, refs - * @param {String} ref reference to resolve - * @return {Object} object with properties schema, root, baseId - */ -function resolveSchema(root, ref) { - /* jshint validthis: true */ - var p = URI.parse(ref) - , refPath = _getFullPath(p) - , baseId = getFullPath(this._getId(root.schema)); - if (Object.keys(root.schema).length === 0 || refPath !== baseId) { - var id = normalizeId(refPath); - var refVal = this._refs[id]; - if (typeof refVal == 'string') { - return resolveRecursive.call(this, root, refVal, p); - } else if (refVal instanceof SchemaObject) { - if (!refVal.validate) this._compile(refVal); - root = refVal; - } else { - refVal = this._schemas[id]; - if (refVal instanceof SchemaObject) { - if (!refVal.validate) this._compile(refVal); - if (id == normalizeId(ref)) - return { schema: refVal, root: root, baseId: baseId }; - root = refVal; - } else { - return; - } - } - if (!root.schema) return; - baseId = getFullPath(this._getId(root.schema)); - } - return getJsonPointer.call(this, p, baseId, root.schema, root); -} - - -/* @this Ajv */ -function resolveRecursive(root, ref, parsedRef) { - /* jshint validthis: true */ - var res = resolveSchema.call(this, root, ref); - if (res) { - var schema = res.schema; - var baseId = res.baseId; - root = res.root; - var id = this._getId(schema); - if (id) baseId = resolveUrl(baseId, id); - return getJsonPointer.call(this, parsedRef, baseId, schema, root); - } -} - - -var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']); -/* @this Ajv */ -function getJsonPointer(parsedRef, baseId, schema, root) { - /* jshint validthis: true */ - parsedRef.fragment = parsedRef.fragment || ''; - if (parsedRef.fragment.slice(0,1) != '/') return; - var parts = parsedRef.fragment.split('/'); - - for (var i = 1; i < parts.length; i++) { - var part = parts[i]; - if (part) { - part = util.unescapeFragment(part); - schema = schema[part]; - if (schema === undefined) break; - var id; - if (!PREVENT_SCOPE_CHANGE[part]) { - id = this._getId(schema); - if (id) baseId = resolveUrl(baseId, id); - if (schema.$ref) { - var $ref = resolveUrl(baseId, schema.$ref); - var res = resolveSchema.call(this, root, $ref); - if (res) { - schema = res.schema; - root = res.root; - baseId = res.baseId; - } - } - } - } - } - if (schema !== undefined && schema !== root.schema) - return { schema: schema, root: root, baseId: baseId }; -} - - -var SIMPLE_INLINED = util.toHash([ - 'type', 'format', 'pattern', - 'maxLength', 'minLength', - 'maxProperties', 'minProperties', - 'maxItems', 'minItems', - 'maximum', 'minimum', - 'uniqueItems', 'multipleOf', - 'required', 'enum' -]); -function inlineRef(schema, limit) { - if (limit === false) return false; - if (limit === undefined || limit === true) return checkNoRef(schema); - else if (limit) return countKeys(schema) <= limit; -} - - -function checkNoRef(schema) { - var item; - if (Array.isArray(schema)) { - for (var i=0; i { - -"use strict"; - - -var ruleModules = __nccwpck_require__(20795) - , toHash = (__nccwpck_require__(54797).toHash); - -module.exports = function rules() { - var RULES = [ - { type: 'number', - rules: [ { 'maximum': ['exclusiveMaximum'] }, - { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] }, - { type: 'string', - rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] }, - { type: 'array', - rules: [ 'maxItems', 'minItems', 'items', 'contains', 'uniqueItems' ] }, - { type: 'object', - rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames', - { 'properties': ['additionalProperties', 'patternProperties'] } ] }, - { rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if' ] } - ]; - - var ALL = [ 'type', '$comment' ]; - var KEYWORDS = [ - '$schema', '$id', 'id', '$data', '$async', 'title', - 'description', 'default', 'definitions', - 'examples', 'readOnly', 'writeOnly', - 'contentMediaType', 'contentEncoding', - 'additionalItems', 'then', 'else' - ]; - var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ]; - RULES.all = toHash(ALL); - RULES.types = toHash(TYPES); - - RULES.forEach(function (group) { - group.rules = group.rules.map(function (keyword) { - var implKeywords; - if (typeof keyword == 'object') { - var key = Object.keys(keyword)[0]; - implKeywords = keyword[key]; - keyword = key; - implKeywords.forEach(function (k) { - ALL.push(k); - RULES.all[k] = true; - }); - } - ALL.push(keyword); - var rule = RULES.all[keyword] = { - keyword: keyword, - code: ruleModules[keyword], - implements: implKeywords - }; - return rule; - }); - - RULES.all.$comment = { - keyword: '$comment', - code: ruleModules.$comment - }; - - if (group.type) RULES.types[group.type] = group; - }); - - RULES.keywords = toHash(ALL.concat(KEYWORDS)); - RULES.custom = {}; - - return RULES; -}; - - -/***/ }), - -/***/ 53678: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -var util = __nccwpck_require__(54797); - -module.exports = SchemaObject; - -function SchemaObject(obj) { - util.copy(obj, this); -} - - -/***/ }), - -/***/ 76473: -/***/ ((module) => { - -"use strict"; - - -// https://mathiasbynens.be/notes/javascript-encoding -// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode -module.exports = function ucs2length(str) { - var length = 0 - , len = str.length - , pos = 0 - , value; - while (pos < len) { - length++; - value = str.charCodeAt(pos++); - if (value >= 0xD800 && value <= 0xDBFF && pos < len) { - // high surrogate, and there is a next character - value = str.charCodeAt(pos); - if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate - } - } - return length; -}; - - -/***/ }), - -/***/ 54797: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - - -module.exports = { - copy: copy, - checkDataType: checkDataType, - checkDataTypes: checkDataTypes, - coerceToTypes: coerceToTypes, - toHash: toHash, - getProperty: getProperty, - escapeQuotes: escapeQuotes, - equal: __nccwpck_require__(5103), - ucs2length: __nccwpck_require__(76473), - varOccurences: varOccurences, - varReplace: varReplace, - schemaHasRules: schemaHasRules, - schemaHasRulesExcept: schemaHasRulesExcept, - schemaUnknownRules: schemaUnknownRules, - toQuotedString: toQuotedString, - getPathExpr: getPathExpr, - getPath: getPath, - getData: getData, - unescapeFragment: unescapeFragment, - unescapeJsonPointer: unescapeJsonPointer, - escapeFragment: escapeFragment, - escapeJsonPointer: escapeJsonPointer -}; - - -function copy(o, to) { - to = to || {}; - for (var key in o) to[key] = o[key]; - return to; -} - - -function checkDataType(dataType, data, strictNumbers, negate) { - var EQUAL = negate ? ' !== ' : ' === ' - , AND = negate ? ' || ' : ' && ' - , OK = negate ? '!' : '' - , NOT = negate ? '' : '!'; - switch (dataType) { - case 'null': return data + EQUAL + 'null'; - case 'array': return OK + 'Array.isArray(' + data + ')'; - case 'object': return '(' + OK + data + AND + - 'typeof ' + data + EQUAL + '"object"' + AND + - NOT + 'Array.isArray(' + data + '))'; - case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND + - NOT + '(' + data + ' % 1)' + - AND + data + EQUAL + data + - (strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')'; - case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' + - (strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')'; - default: return 'typeof ' + data + EQUAL + '"' + dataType + '"'; - } -} - - -function checkDataTypes(dataTypes, data, strictNumbers) { - switch (dataTypes.length) { - case 1: return checkDataType(dataTypes[0], data, strictNumbers, true); - default: - var code = ''; - var types = toHash(dataTypes); - if (types.array && types.object) { - code = types.null ? '(': '(!' + data + ' || '; - code += 'typeof ' + data + ' !== "object")'; - delete types.null; - delete types.array; - delete types.object; - } - if (types.number) delete types.integer; - for (var t in types) - code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true); - - return code; - } -} - - -var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]); -function coerceToTypes(optionCoerceTypes, dataTypes) { - if (Array.isArray(dataTypes)) { - var types = []; - for (var i=0; i= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl); - return paths[lvl - up]; - } - - if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl); - data = 'data' + ((lvl - up) || ''); - if (!jsonPointer) return data; - } - - var expr = data; - var segments = jsonPointer.split('/'); - for (var i=0; i { - -"use strict"; - - -var KEYWORDS = [ - 'multipleOf', - 'maximum', - 'exclusiveMaximum', - 'minimum', - 'exclusiveMinimum', - 'maxLength', - 'minLength', - 'pattern', - 'additionalItems', - 'maxItems', - 'minItems', - 'uniqueItems', - 'maxProperties', - 'minProperties', - 'required', - 'additionalProperties', - 'enum', - 'format', - 'const' -]; - -module.exports = function (metaSchema, keywordsJsonPointers) { - for (var i=0; i { - -"use strict"; - - -var metaSchema = __nccwpck_require__(69451); - -module.exports = { - $id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js', - definitions: { - simpleTypes: metaSchema.definitions.simpleTypes - }, - type: 'object', - dependencies: { - schema: ['validate'], - $data: ['validate'], - statements: ['inline'], - valid: {not: {required: ['macro']}} - }, - properties: { - type: metaSchema.properties.type, - schema: {type: 'boolean'}, - statements: {type: 'boolean'}, - dependencies: { - type: 'array', - items: {type: 'string'} - }, - metaSchema: {type: 'object'}, - modifying: {type: 'boolean'}, - valid: {type: 'boolean'}, - $data: {type: 'boolean'}, - async: {type: 'boolean'}, - errors: { - anyOf: [ - {type: 'boolean'}, - {const: 'full'} - ] - } - } -}; - - -/***/ }), - -/***/ 7622: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate__limit(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $errorKeyword; - var $data = 'data' + ($dataLvl || ''); - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - var $isMax = $keyword == 'maximum', - $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum', - $schemaExcl = it.schema[$exclusiveKeyword], - $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data, - $op = $isMax ? '<' : '>', - $notOp = $isMax ? '>' : '<', - $errorKeyword = undefined; - if (!($isData || typeof $schema == 'number' || $schema === undefined)) { - throw new Error($keyword + ' must be number'); - } - if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) { - throw new Error($exclusiveKeyword + ' must be number or boolean'); - } - if ($isDataExcl) { - var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr), - $exclusive = 'exclusive' + $lvl, - $exclType = 'exclType' + $lvl, - $exclIsNumber = 'exclIsNumber' + $lvl, - $opExpr = 'op' + $lvl, - $opStr = '\' + ' + $opExpr + ' + \''; - out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; '; - $schemaValueExcl = 'schemaExcl' + $lvl; - out += ' var ' + ($exclusive) + '; var ' + ($exclType) + ' = typeof ' + ($schemaValueExcl) + '; if (' + ($exclType) + ' != \'boolean\' && ' + ($exclType) + ' != \'undefined\' && ' + ($exclType) + ' != \'number\') { '; - var $errorKeyword = $exclusiveKeyword; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; - if (it.opts.messages !== false) { - out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } else if ( '; - if ($isData) { - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; - } - out += ' ' + ($exclType) + ' == \'number\' ? ( (' + ($exclusive) + ' = ' + ($schemaValue) + ' === undefined || ' + ($schemaValueExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ') ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValueExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) : ( (' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true) ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValue) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\'; '; - if ($schema === undefined) { - $errorKeyword = $exclusiveKeyword; - $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword; - $schemaValue = $schemaValueExcl; - $isData = $isDataExcl; - } - } else { - var $exclIsNumber = typeof $schemaExcl == 'number', - $opStr = $op; - if ($exclIsNumber && $isData) { - var $opExpr = '\'' + $opStr + '\''; - out += ' if ( '; - if ($isData) { - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; - } - out += ' ( ' + ($schemaValue) + ' === undefined || ' + ($schemaExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ' ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { '; - } else { - if ($exclIsNumber && $schema === undefined) { - $exclusive = true; - $errorKeyword = $exclusiveKeyword; - $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword; - $schemaValue = $schemaExcl; - $notOp += '='; - } else { - if ($exclIsNumber) $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema); - if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) { - $exclusive = true; - $errorKeyword = $exclusiveKeyword; - $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword; - $notOp += '='; - } else { - $exclusive = false; - $opStr += '='; - } - } - var $opExpr = '\'' + $opStr + '\''; - out += ' if ( '; - if ($isData) { - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; - } - out += ' ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' || ' + ($data) + ' !== ' + ($data) + ') { '; - } - } - $errorKeyword = $errorKeyword || $keyword; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ' + ($schemaValue) + ', exclusive: ' + ($exclusive) + ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should be ' + ($opStr) + ' '; - if ($isData) { - out += '\' + ' + ($schemaValue); - } else { - out += '' + ($schemaValue) + '\''; - } - } - if (it.opts.verbose) { - out += ' , schema: '; - if ($isData) { - out += 'validate.schema' + ($schemaPath); - } else { - out += '' + ($schema); - } - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } '; - if ($breakOnError) { - out += ' else { '; - } - return out; -} - - -/***/ }), - -/***/ 15065: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate__limitItems(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $errorKeyword; - var $data = 'data' + ($dataLvl || ''); - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - if (!($isData || typeof $schema == 'number')) { - throw new Error($keyword + ' must be number'); - } - var $op = $keyword == 'maxItems' ? '>' : '<'; - out += 'if ( '; - if ($isData) { - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; - } - out += ' ' + ($data) + '.length ' + ($op) + ' ' + ($schemaValue) + ') { '; - var $errorKeyword = $keyword; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ($errorKeyword || '_limitItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should NOT have '; - if ($keyword == 'maxItems') { - out += 'more'; - } else { - out += 'fewer'; - } - out += ' than '; - if ($isData) { - out += '\' + ' + ($schemaValue) + ' + \''; - } else { - out += '' + ($schema); - } - out += ' items\' '; - } - if (it.opts.verbose) { - out += ' , schema: '; - if ($isData) { - out += 'validate.schema' + ($schemaPath); - } else { - out += '' + ($schema); - } - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += '} '; - if ($breakOnError) { - out += ' else { '; - } - return out; -} - - -/***/ }), - -/***/ 83884: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate__limitLength(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $errorKeyword; - var $data = 'data' + ($dataLvl || ''); - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - if (!($isData || typeof $schema == 'number')) { - throw new Error($keyword + ' must be number'); - } - var $op = $keyword == 'maxLength' ? '>' : '<'; - out += 'if ( '; - if ($isData) { - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; - } - if (it.opts.unicode === false) { - out += ' ' + ($data) + '.length '; - } else { - out += ' ucs2length(' + ($data) + ') '; - } - out += ' ' + ($op) + ' ' + ($schemaValue) + ') { '; - var $errorKeyword = $keyword; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should NOT be '; - if ($keyword == 'maxLength') { - out += 'longer'; - } else { - out += 'shorter'; - } - out += ' than '; - if ($isData) { - out += '\' + ' + ($schemaValue) + ' + \''; - } else { - out += '' + ($schema); - } - out += ' characters\' '; - } - if (it.opts.verbose) { - out += ' , schema: '; - if ($isData) { - out += 'validate.schema' + ($schemaPath); - } else { - out += '' + ($schema); - } - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += '} '; - if ($breakOnError) { - out += ' else { '; - } - return out; -} - - -/***/ }), - -/***/ 79737: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate__limitProperties(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $errorKeyword; - var $data = 'data' + ($dataLvl || ''); - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - if (!($isData || typeof $schema == 'number')) { - throw new Error($keyword + ' must be number'); - } - var $op = $keyword == 'maxProperties' ? '>' : '<'; - out += 'if ( '; - if ($isData) { - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || '; - } - out += ' Object.keys(' + ($data) + ').length ' + ($op) + ' ' + ($schemaValue) + ') { '; - var $errorKeyword = $keyword; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ($errorKeyword || '_limitProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should NOT have '; - if ($keyword == 'maxProperties') { - out += 'more'; - } else { - out += 'fewer'; - } - out += ' than '; - if ($isData) { - out += '\' + ' + ($schemaValue) + ' + \''; - } else { - out += '' + ($schema); - } - out += ' properties\' '; - } - if (it.opts.verbose) { - out += ' , schema: '; - if ($isData) { - out += 'validate.schema' + ($schemaPath); - } else { - out += '' + ($schema); - } - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += '} '; - if ($breakOnError) { - out += ' else { '; - } - return out; -} - - -/***/ }), - -/***/ 5713: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_allOf(it, $keyword, $ruleType) { - var out = ' '; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $it = it.util.copy(it); - var $closingBraces = ''; - $it.level++; - var $nextValid = 'valid' + $it.level; - var $currentBaseId = $it.baseId, - $allSchemasEmpty = true; - var arr1 = $schema; - if (arr1) { - var $sch, $i = -1, - l1 = arr1.length - 1; - while ($i < l1) { - $sch = arr1[$i += 1]; - if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { - $allSchemasEmpty = false; - $it.schema = $sch; - $it.schemaPath = $schemaPath + '[' + $i + ']'; - $it.errSchemaPath = $errSchemaPath + '/' + $i; - out += ' ' + (it.validate($it)) + ' '; - $it.baseId = $currentBaseId; - if ($breakOnError) { - out += ' if (' + ($nextValid) + ') { '; - $closingBraces += '}'; - } - } - } - } - if ($breakOnError) { - if ($allSchemasEmpty) { - out += ' if (true) { '; - } else { - out += ' ' + ($closingBraces.slice(0, -1)) + ' '; - } - } - return out; -} - - -/***/ }), - -/***/ 61989: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_anyOf(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $errs = 'errs__' + $lvl; - var $it = it.util.copy(it); - var $closingBraces = ''; - $it.level++; - var $nextValid = 'valid' + $it.level; - var $noEmptySchema = $schema.every(function($sch) { - return (it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)); - }); - if ($noEmptySchema) { - var $currentBaseId = $it.baseId; - out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = false; '; - var $wasComposite = it.compositeRule; - it.compositeRule = $it.compositeRule = true; - var arr1 = $schema; - if (arr1) { - var $sch, $i = -1, - l1 = arr1.length - 1; - while ($i < l1) { - $sch = arr1[$i += 1]; - $it.schema = $sch; - $it.schemaPath = $schemaPath + '[' + $i + ']'; - $it.errSchemaPath = $errSchemaPath + '/' + $i; - out += ' ' + (it.validate($it)) + ' '; - $it.baseId = $currentBaseId; - out += ' ' + ($valid) + ' = ' + ($valid) + ' || ' + ($nextValid) + '; if (!' + ($valid) + ') { '; - $closingBraces += '}'; - } - } - it.compositeRule = $it.compositeRule = $wasComposite; - out += ' ' + ($closingBraces) + ' if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('anyOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; - if (it.opts.messages !== false) { - out += ' , message: \'should match some schema in anyOf\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError(vErrors); '; - } else { - out += ' validate.errors = vErrors; return false; '; - } - } - out += ' } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } '; - if (it.opts.allErrors) { - out += ' } '; - } - } else { - if ($breakOnError) { - out += ' if (true) { '; - } - } - return out; -} - - -/***/ }), - -/***/ 55249: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_comment(it, $keyword, $ruleType) { - var out = ' '; - var $schema = it.schema[$keyword]; - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $comment = it.util.toQuotedString($schema); - if (it.opts.$comment === true) { - out += ' console.log(' + ($comment) + ');'; - } else if (typeof it.opts.$comment == 'function') { - out += ' self._opts.$comment(' + ($comment) + ', ' + (it.util.toQuotedString($errSchemaPath)) + ', validate.root.schema);'; - } - return out; -} - - -/***/ }), - -/***/ 76023: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_const(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - if (!$isData) { - out += ' var schema' + ($lvl) + ' = validate.schema' + ($schemaPath) + ';'; - } - out += 'var ' + ($valid) + ' = equal(' + ($data) + ', schema' + ($lvl) + '); if (!' + ($valid) + ') { '; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('const') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValue: schema' + ($lvl) + ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should be equal to constant\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' }'; - if ($breakOnError) { - out += ' else { '; - } - return out; -} - - -/***/ }), - -/***/ 4173: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_contains(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $errs = 'errs__' + $lvl; - var $it = it.util.copy(it); - var $closingBraces = ''; - $it.level++; - var $nextValid = 'valid' + $it.level; - var $idx = 'i' + $lvl, - $dataNxt = $it.dataLevel = it.dataLevel + 1, - $nextData = 'data' + $dataNxt, - $currentBaseId = it.baseId, - $nonEmptySchema = (it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all)); - out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';'; - if ($nonEmptySchema) { - var $wasComposite = it.compositeRule; - it.compositeRule = $it.compositeRule = true; - $it.schema = $schema; - $it.schemaPath = $schemaPath; - $it.errSchemaPath = $errSchemaPath; - out += ' var ' + ($nextValid) + ' = false; for (var ' + ($idx) + ' = 0; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { '; - $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true); - var $passData = $data + '[' + $idx + ']'; - $it.dataPathArr[$dataNxt] = $idx; - var $code = it.validate($it); - $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { - out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; - } else { - out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; - } - out += ' if (' + ($nextValid) + ') break; } '; - it.compositeRule = $it.compositeRule = $wasComposite; - out += ' ' + ($closingBraces) + ' if (!' + ($nextValid) + ') {'; - } else { - out += ' if (' + ($data) + '.length == 0) {'; - } - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('contains') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; - if (it.opts.messages !== false) { - out += ' , message: \'should contain a valid item\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } else { '; - if ($nonEmptySchema) { - out += ' errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } '; - } - if (it.opts.allErrors) { - out += ' } '; - } - return out; -} - - -/***/ }), - -/***/ 55832: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_custom(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $errorKeyword; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $errs = 'errs__' + $lvl; - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - var $rule = this, - $definition = 'definition' + $lvl, - $rDef = $rule.definition, - $closingBraces = ''; - var $compile, $inline, $macro, $ruleValidate, $validateCode; - if ($isData && $rDef.$data) { - $validateCode = 'keywordValidate' + $lvl; - var $validateSchema = $rDef.validateSchema; - out += ' var ' + ($definition) + ' = RULES.custom[\'' + ($keyword) + '\'].definition; var ' + ($validateCode) + ' = ' + ($definition) + '.validate;'; - } else { - $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it); - if (!$ruleValidate) return; - $schemaValue = 'validate.schema' + $schemaPath; - $validateCode = $ruleValidate.code; - $compile = $rDef.compile; - $inline = $rDef.inline; - $macro = $rDef.macro; - } - var $ruleErrs = $validateCode + '.errors', - $i = 'i' + $lvl, - $ruleErr = 'ruleErr' + $lvl, - $asyncKeyword = $rDef.async; - if ($asyncKeyword && !it.async) throw new Error('async keyword in sync schema'); - if (!($inline || $macro)) { - out += '' + ($ruleErrs) + ' = null;'; - } - out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';'; - if ($isData && $rDef.$data) { - $closingBraces += '}'; - out += ' if (' + ($schemaValue) + ' === undefined) { ' + ($valid) + ' = true; } else { '; - if ($validateSchema) { - $closingBraces += '}'; - out += ' ' + ($valid) + ' = ' + ($definition) + '.validateSchema(' + ($schemaValue) + '); if (' + ($valid) + ') { '; - } - } - if ($inline) { - if ($rDef.statements) { - out += ' ' + ($ruleValidate.validate) + ' '; - } else { - out += ' ' + ($valid) + ' = ' + ($ruleValidate.validate) + '; '; - } - } else if ($macro) { - var $it = it.util.copy(it); - var $closingBraces = ''; - $it.level++; - var $nextValid = 'valid' + $it.level; - $it.schema = $ruleValidate.validate; - $it.schemaPath = ''; - var $wasComposite = it.compositeRule; - it.compositeRule = $it.compositeRule = true; - var $code = it.validate($it).replace(/validate\.schema/g, $validateCode); - it.compositeRule = $it.compositeRule = $wasComposite; - out += ' ' + ($code); - } else { - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; - out += ' ' + ($validateCode) + '.call( '; - if (it.opts.passContext) { - out += 'this'; - } else { - out += 'self'; - } - if ($compile || $rDef.schema === false) { - out += ' , ' + ($data) + ' '; - } else { - out += ' , ' + ($schemaValue) + ' , ' + ($data) + ' , validate.schema' + (it.schemaPath) + ' '; - } - out += ' , (dataPath || \'\')'; - if (it.errorPath != '""') { - out += ' + ' + (it.errorPath); - } - var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData', - $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty'; - out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ' , rootData ) '; - var def_callRuleValidate = out; - out = $$outStack.pop(); - if ($rDef.errors === false) { - out += ' ' + ($valid) + ' = '; - if ($asyncKeyword) { - out += 'await '; - } - out += '' + (def_callRuleValidate) + '; '; - } else { - if ($asyncKeyword) { - $ruleErrs = 'customErrors' + $lvl; - out += ' var ' + ($ruleErrs) + ' = null; try { ' + ($valid) + ' = await ' + (def_callRuleValidate) + '; } catch (e) { ' + ($valid) + ' = false; if (e instanceof ValidationError) ' + ($ruleErrs) + ' = e.errors; else throw e; } '; - } else { - out += ' ' + ($ruleErrs) + ' = null; ' + ($valid) + ' = ' + (def_callRuleValidate) + '; '; - } - } - } - if ($rDef.modifying) { - out += ' if (' + ($parentData) + ') ' + ($data) + ' = ' + ($parentData) + '[' + ($parentDataProperty) + '];'; - } - out += '' + ($closingBraces); - if ($rDef.valid) { - if ($breakOnError) { - out += ' if (true) { '; - } - } else { - out += ' if ( '; - if ($rDef.valid === undefined) { - out += ' !'; - if ($macro) { - out += '' + ($nextValid); - } else { - out += '' + ($valid); - } - } else { - out += ' ' + (!$rDef.valid) + ' '; - } - out += ') { '; - $errorKeyword = $rule.keyword; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - var def_customError = out; - out = $$outStack.pop(); - if ($inline) { - if ($rDef.errors) { - if ($rDef.errors != 'full') { - out += ' for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + ' { - -"use strict"; - -module.exports = function generate_dependencies(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $errs = 'errs__' + $lvl; - var $it = it.util.copy(it); - var $closingBraces = ''; - $it.level++; - var $nextValid = 'valid' + $it.level; - var $schemaDeps = {}, - $propertyDeps = {}, - $ownProperties = it.opts.ownProperties; - for ($property in $schema) { - if ($property == '__proto__') continue; - var $sch = $schema[$property]; - var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps; - $deps[$property] = $sch; - } - out += 'var ' + ($errs) + ' = errors;'; - var $currentErrorPath = it.errorPath; - out += 'var missing' + ($lvl) + ';'; - for (var $property in $propertyDeps) { - $deps = $propertyDeps[$property]; - if ($deps.length) { - out += ' if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined '; - if ($ownProperties) { - out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') '; - } - if ($breakOnError) { - out += ' && ( '; - var arr1 = $deps; - if (arr1) { - var $propertyKey, $i = -1, - l1 = arr1.length - 1; - while ($i < l1) { - $propertyKey = arr1[$i += 1]; - if ($i) { - out += ' || '; - } - var $prop = it.util.getProperty($propertyKey), - $useData = $data + $prop; - out += ' ( ( ' + ($useData) + ' === undefined '; - if ($ownProperties) { - out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; - } - out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) '; - } - } - out += ')) { '; - var $propertyPath = 'missing' + $lvl, - $missingProperty = '\' + ' + $propertyPath + ' + \''; - if (it.opts._errorDataPathProperty) { - it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath; - } - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should have '; - if ($deps.length == 1) { - out += 'property ' + (it.util.escapeQuotes($deps[0])); - } else { - out += 'properties ' + (it.util.escapeQuotes($deps.join(", "))); - } - out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - } else { - out += ' ) { '; - var arr2 = $deps; - if (arr2) { - var $propertyKey, i2 = -1, - l2 = arr2.length - 1; - while (i2 < l2) { - $propertyKey = arr2[i2 += 1]; - var $prop = it.util.getProperty($propertyKey), - $missingProperty = it.util.escapeQuotes($propertyKey), - $useData = $data + $prop; - if (it.opts._errorDataPathProperty) { - it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers); - } - out += ' if ( ' + ($useData) + ' === undefined '; - if ($ownProperties) { - out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; - } - out += ') { var err = '; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should have '; - if ($deps.length == 1) { - out += 'property ' + (it.util.escapeQuotes($deps[0])); - } else { - out += 'properties ' + (it.util.escapeQuotes($deps.join(", "))); - } - out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } '; - } - } - } - out += ' } '; - if ($breakOnError) { - $closingBraces += '}'; - out += ' else { '; - } - } - } - it.errorPath = $currentErrorPath; - var $currentBaseId = $it.baseId; - for (var $property in $schemaDeps) { - var $sch = $schemaDeps[$property]; - if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { - out += ' ' + ($nextValid) + ' = true; if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined '; - if ($ownProperties) { - out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') '; - } - out += ') { '; - $it.schema = $sch; - $it.schemaPath = $schemaPath + it.util.getProperty($property); - $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property); - out += ' ' + (it.validate($it)) + ' '; - $it.baseId = $currentBaseId; - out += ' } '; - if ($breakOnError) { - out += ' if (' + ($nextValid) + ') { '; - $closingBraces += '}'; - } - } - } - if ($breakOnError) { - out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; - } - return out; -} - - -/***/ }), - -/***/ 31435: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_enum(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - var $i = 'i' + $lvl, - $vSchema = 'schema' + $lvl; - if (!$isData) { - out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + ';'; - } - out += 'var ' + ($valid) + ';'; - if ($isData) { - out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {'; - } - out += '' + ($valid) + ' = false;for (var ' + ($i) + '=0; ' + ($i) + '<' + ($vSchema) + '.length; ' + ($i) + '++) if (equal(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + '])) { ' + ($valid) + ' = true; break; }'; - if ($isData) { - out += ' } '; - } - out += ' if (!' + ($valid) + ') { '; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('enum') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValues: schema' + ($lvl) + ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should be equal to one of the allowed values\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' }'; - if ($breakOnError) { - out += ' else { '; - } - return out; -} - - -/***/ }), - -/***/ 47663: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_format(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - if (it.opts.format === false) { - if ($breakOnError) { - out += ' if (true) { '; - } - return out; - } - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - var $unknownFormats = it.opts.unknownFormats, - $allowUnknown = Array.isArray($unknownFormats); - if ($isData) { - var $format = 'format' + $lvl, - $isObject = 'isObject' + $lvl, - $formatType = 'formatType' + $lvl; - out += ' var ' + ($format) + ' = formats[' + ($schemaValue) + ']; var ' + ($isObject) + ' = typeof ' + ($format) + ' == \'object\' && !(' + ($format) + ' instanceof RegExp) && ' + ($format) + '.validate; var ' + ($formatType) + ' = ' + ($isObject) + ' && ' + ($format) + '.type || \'string\'; if (' + ($isObject) + ') { '; - if (it.async) { - out += ' var async' + ($lvl) + ' = ' + ($format) + '.async; '; - } - out += ' ' + ($format) + ' = ' + ($format) + '.validate; } if ( '; - if ($isData) { - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || '; - } - out += ' ('; - if ($unknownFormats != 'ignore') { - out += ' (' + ($schemaValue) + ' && !' + ($format) + ' '; - if ($allowUnknown) { - out += ' && self._opts.unknownFormats.indexOf(' + ($schemaValue) + ') == -1 '; - } - out += ') || '; - } - out += ' (' + ($format) + ' && ' + ($formatType) + ' == \'' + ($ruleType) + '\' && !(typeof ' + ($format) + ' == \'function\' ? '; - if (it.async) { - out += ' (async' + ($lvl) + ' ? await ' + ($format) + '(' + ($data) + ') : ' + ($format) + '(' + ($data) + ')) '; - } else { - out += ' ' + ($format) + '(' + ($data) + ') '; - } - out += ' : ' + ($format) + '.test(' + ($data) + '))))) {'; - } else { - var $format = it.formats[$schema]; - if (!$format) { - if ($unknownFormats == 'ignore') { - it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"'); - if ($breakOnError) { - out += ' if (true) { '; - } - return out; - } else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) { - if ($breakOnError) { - out += ' if (true) { '; - } - return out; - } else { - throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"'); - } - } - var $isObject = typeof $format == 'object' && !($format instanceof RegExp) && $format.validate; - var $formatType = $isObject && $format.type || 'string'; - if ($isObject) { - var $async = $format.async === true; - $format = $format.validate; - } - if ($formatType != $ruleType) { - if ($breakOnError) { - out += ' if (true) { '; - } - return out; - } - if ($async) { - if (!it.async) throw new Error('async format in sync schema'); - var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate'; - out += ' if (!(await ' + ($formatRef) + '(' + ($data) + '))) { '; - } else { - out += ' if (! '; - var $formatRef = 'formats' + it.util.getProperty($schema); - if ($isObject) $formatRef += '.validate'; - if (typeof $format == 'function') { - out += ' ' + ($formatRef) + '(' + ($data) + ') '; - } else { - out += ' ' + ($formatRef) + '.test(' + ($data) + ') '; - } - out += ') { '; - } - } - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('format') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { format: '; - if ($isData) { - out += '' + ($schemaValue); - } else { - out += '' + (it.util.toQuotedString($schema)); - } - out += ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should match format "'; - if ($isData) { - out += '\' + ' + ($schemaValue) + ' + \''; - } else { - out += '' + (it.util.escapeQuotes($schema)); - } - out += '"\' '; - } - if (it.opts.verbose) { - out += ' , schema: '; - if ($isData) { - out += 'validate.schema' + ($schemaPath); - } else { - out += '' + (it.util.toQuotedString($schema)); - } - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } '; - if ($breakOnError) { - out += ' else { '; - } - return out; -} - - -/***/ }), - -/***/ 77978: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_if(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $errs = 'errs__' + $lvl; - var $it = it.util.copy(it); - $it.level++; - var $nextValid = 'valid' + $it.level; - var $thenSch = it.schema['then'], - $elseSch = it.schema['else'], - $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? (typeof $thenSch == 'object' && Object.keys($thenSch).length > 0) || $thenSch === false : it.util.schemaHasRules($thenSch, it.RULES.all)), - $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? (typeof $elseSch == 'object' && Object.keys($elseSch).length > 0) || $elseSch === false : it.util.schemaHasRules($elseSch, it.RULES.all)), - $currentBaseId = $it.baseId; - if ($thenPresent || $elsePresent) { - var $ifClause; - $it.createErrors = false; - $it.schema = $schema; - $it.schemaPath = $schemaPath; - $it.errSchemaPath = $errSchemaPath; - out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = true; '; - var $wasComposite = it.compositeRule; - it.compositeRule = $it.compositeRule = true; - out += ' ' + (it.validate($it)) + ' '; - $it.baseId = $currentBaseId; - $it.createErrors = true; - out += ' errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } '; - it.compositeRule = $it.compositeRule = $wasComposite; - if ($thenPresent) { - out += ' if (' + ($nextValid) + ') { '; - $it.schema = it.schema['then']; - $it.schemaPath = it.schemaPath + '.then'; - $it.errSchemaPath = it.errSchemaPath + '/then'; - out += ' ' + (it.validate($it)) + ' '; - $it.baseId = $currentBaseId; - out += ' ' + ($valid) + ' = ' + ($nextValid) + '; '; - if ($thenPresent && $elsePresent) { - $ifClause = 'ifClause' + $lvl; - out += ' var ' + ($ifClause) + ' = \'then\'; '; - } else { - $ifClause = '\'then\''; - } - out += ' } '; - if ($elsePresent) { - out += ' else { '; - } - } else { - out += ' if (!' + ($nextValid) + ') { '; - } - if ($elsePresent) { - $it.schema = it.schema['else']; - $it.schemaPath = it.schemaPath + '.else'; - $it.errSchemaPath = it.errSchemaPath + '/else'; - out += ' ' + (it.validate($it)) + ' '; - $it.baseId = $currentBaseId; - out += ' ' + ($valid) + ' = ' + ($nextValid) + '; '; - if ($thenPresent && $elsePresent) { - $ifClause = 'ifClause' + $lvl; - out += ' var ' + ($ifClause) + ' = \'else\'; '; - } else { - $ifClause = '\'else\''; - } - out += ' } '; - } - out += ' if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('if') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { failingKeyword: ' + ($ifClause) + ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should match "\' + ' + ($ifClause) + ' + \'" schema\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError(vErrors); '; - } else { - out += ' validate.errors = vErrors; return false; '; - } - } - out += ' } '; - if ($breakOnError) { - out += ' else { '; - } - } else { - if ($breakOnError) { - out += ' if (true) { '; - } - } - return out; -} - - -/***/ }), - -/***/ 20795: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -//all requires must be explicit because browserify won't work with dynamic requires -module.exports = { - '$ref': __nccwpck_require__(29313), - allOf: __nccwpck_require__(5713), - anyOf: __nccwpck_require__(61989), - '$comment': __nccwpck_require__(55249), - const: __nccwpck_require__(76023), - contains: __nccwpck_require__(4173), - dependencies: __nccwpck_require__(55531), - 'enum': __nccwpck_require__(31435), - format: __nccwpck_require__(47663), - 'if': __nccwpck_require__(77978), - items: __nccwpck_require__(15144), - maximum: __nccwpck_require__(7622), - minimum: __nccwpck_require__(7622), - maxItems: __nccwpck_require__(15065), - minItems: __nccwpck_require__(15065), - maxLength: __nccwpck_require__(83884), - minLength: __nccwpck_require__(83884), - maxProperties: __nccwpck_require__(79737), - minProperties: __nccwpck_require__(79737), - multipleOf: __nccwpck_require__(96072), - not: __nccwpck_require__(33629), - oneOf: __nccwpck_require__(25195), - pattern: __nccwpck_require__(56754), - properties: __nccwpck_require__(39795), - propertyNames: __nccwpck_require__(3837), - required: __nccwpck_require__(21106), - uniqueItems: __nccwpck_require__(19466), - validate: __nccwpck_require__(24887) -}; - - -/***/ }), - -/***/ 15144: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_items(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $errs = 'errs__' + $lvl; - var $it = it.util.copy(it); - var $closingBraces = ''; - $it.level++; - var $nextValid = 'valid' + $it.level; - var $idx = 'i' + $lvl, - $dataNxt = $it.dataLevel = it.dataLevel + 1, - $nextData = 'data' + $dataNxt, - $currentBaseId = it.baseId; - out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';'; - if (Array.isArray($schema)) { - var $additionalItems = it.schema.additionalItems; - if ($additionalItems === false) { - out += ' ' + ($valid) + ' = ' + ($data) + '.length <= ' + ($schema.length) + '; '; - var $currErrSchemaPath = $errSchemaPath; - $errSchemaPath = it.errSchemaPath + '/additionalItems'; - out += ' if (!' + ($valid) + ') { '; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('additionalItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schema.length) + ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should NOT have more than ' + ($schema.length) + ' items\' '; - } - if (it.opts.verbose) { - out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } '; - $errSchemaPath = $currErrSchemaPath; - if ($breakOnError) { - $closingBraces += '}'; - out += ' else { '; - } - } - var arr1 = $schema; - if (arr1) { - var $sch, $i = -1, - l1 = arr1.length - 1; - while ($i < l1) { - $sch = arr1[$i += 1]; - if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { - out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($i) + ') { '; - var $passData = $data + '[' + $i + ']'; - $it.schema = $sch; - $it.schemaPath = $schemaPath + '[' + $i + ']'; - $it.errSchemaPath = $errSchemaPath + '/' + $i; - $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true); - $it.dataPathArr[$dataNxt] = $i; - var $code = it.validate($it); - $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { - out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; - } else { - out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; - } - out += ' } '; - if ($breakOnError) { - out += ' if (' + ($nextValid) + ') { '; - $closingBraces += '}'; - } - } - } - } - if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? (typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0) || $additionalItems === false : it.util.schemaHasRules($additionalItems, it.RULES.all))) { - $it.schema = $additionalItems; - $it.schemaPath = it.schemaPath + '.additionalItems'; - $it.errSchemaPath = it.errSchemaPath + '/additionalItems'; - out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($schema.length) + ') { for (var ' + ($idx) + ' = ' + ($schema.length) + '; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { '; - $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true); - var $passData = $data + '[' + $idx + ']'; - $it.dataPathArr[$dataNxt] = $idx; - var $code = it.validate($it); - $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { - out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; - } else { - out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; - } - if ($breakOnError) { - out += ' if (!' + ($nextValid) + ') break; '; - } - out += ' } } '; - if ($breakOnError) { - out += ' if (' + ($nextValid) + ') { '; - $closingBraces += '}'; - } - } - } else if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { - $it.schema = $schema; - $it.schemaPath = $schemaPath; - $it.errSchemaPath = $errSchemaPath; - out += ' for (var ' + ($idx) + ' = ' + (0) + '; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { '; - $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true); - var $passData = $data + '[' + $idx + ']'; - $it.dataPathArr[$dataNxt] = $idx; - var $code = it.validate($it); - $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { - out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; - } else { - out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; - } - if ($breakOnError) { - out += ' if (!' + ($nextValid) + ') break; '; - } - out += ' }'; - } - if ($breakOnError) { - out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; - } - return out; -} + }) + + return function (callback) { + called = true; + var index = cbCount++; + return function (err, result) { + if (callback) callback.apply(null, arguments); + if (err && !error) error = err; + results[index] = result; + process.nextTick(function () { + if (!--cbCount) done(error, results); + }); + }; + }; +}; /***/ }), -/***/ 96072: -/***/ ((module) => { +/***/ 39381: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -module.exports = function generate_multipleOf(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - if (!($isData || typeof $schema == 'number')) { - throw new Error($keyword + ' must be number'); - } - out += 'var division' + ($lvl) + ';if ('; - if ($isData) { - out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || '; - } - out += ' (division' + ($lvl) + ' = ' + ($data) + ' / ' + ($schemaValue) + ', '; - if (it.opts.multipleOfPrecision) { - out += ' Math.abs(Math.round(division' + ($lvl) + ') - division' + ($lvl) + ') > 1e-' + (it.opts.multipleOfPrecision) + ' '; - } else { - out += ' division' + ($lvl) + ' !== parseInt(division' + ($lvl) + ') '; - } - out += ' ) '; - if ($isData) { - out += ' ) '; - } - out += ' ) { '; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('multipleOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { multipleOf: ' + ($schemaValue) + ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should be multiple of '; - if ($isData) { - out += '\' + ' + ($schemaValue); - } else { - out += '' + ($schemaValue) + '\''; - } - } - if (it.opts.verbose) { - out += ' , schema: '; - if ($isData) { - out += 'validate.schema' + ($schemaPath); - } else { - out += '' + ($schema); - } - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += '} '; - if ($breakOnError) { - out += ' else { '; - } - return out; -} + +module.exports = __nccwpck_require__(20854); +module.exports.HttpsAgent = __nccwpck_require__(96210); +module.exports.constants = __nccwpck_require__(47151); /***/ }), -/***/ 33629: -/***/ ((module) => { +/***/ 20854: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -module.exports = function generate_not(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $errs = 'errs__' + $lvl; - var $it = it.util.copy(it); - $it.level++; - var $nextValid = 'valid' + $it.level; - if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { - $it.schema = $schema; - $it.schemaPath = $schemaPath; - $it.errSchemaPath = $errSchemaPath; - out += ' var ' + ($errs) + ' = errors; '; - var $wasComposite = it.compositeRule; - it.compositeRule = $it.compositeRule = true; - $it.createErrors = false; - var $allErrorsOption; - if ($it.opts.allErrors) { - $allErrorsOption = $it.opts.allErrors; - $it.opts.allErrors = false; - } - out += ' ' + (it.validate($it)) + ' '; - $it.createErrors = true; - if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption; - it.compositeRule = $it.compositeRule = $wasComposite; - out += ' if (' + ($nextValid) + ') { '; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; - if (it.opts.messages !== false) { - out += ' , message: \'should NOT be valid\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } '; - if (it.opts.allErrors) { - out += ' } '; - } - } else { - out += ' var err = '; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; - if (it.opts.messages !== false) { - out += ' , message: \'should NOT be valid\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - if ($breakOnError) { - out += ' if (false) { '; - } - } - return out; -} +const OriginalAgent = (__nccwpck_require__(13685).Agent); +const ms = __nccwpck_require__(72462); +const debug = (__nccwpck_require__(73837).debuglog)('agentkeepalive'); +const { + INIT_SOCKET, + CURRENT_ID, + CREATE_ID, + SOCKET_CREATED_TIME, + SOCKET_NAME, + SOCKET_REQUEST_COUNT, + SOCKET_REQUEST_FINISHED_COUNT, +} = __nccwpck_require__(47151); -/***/ }), +// OriginalAgent come from +// - https://github.com/nodejs/node/blob/v8.12.0/lib/_http_agent.js +// - https://github.com/nodejs/node/blob/v10.12.0/lib/_http_agent.js -/***/ 25195: -/***/ ((module) => { +// node <= 10 +let defaultTimeoutListenerCount = 1; +const majorVersion = parseInt(process.version.split('.', 1)[0].substring(1)); +if (majorVersion >= 11 && majorVersion <= 12) { + defaultTimeoutListenerCount = 2; +} else if (majorVersion >= 13) { + defaultTimeoutListenerCount = 3; +} -"use strict"; +function deprecate(message) { + console.log('[agentkeepalive:deprecated] %s', message); +} -module.exports = function generate_oneOf(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $errs = 'errs__' + $lvl; - var $it = it.util.copy(it); - var $closingBraces = ''; - $it.level++; - var $nextValid = 'valid' + $it.level; - var $currentBaseId = $it.baseId, - $prevValid = 'prevValid' + $lvl, - $passingSchemas = 'passingSchemas' + $lvl; - out += 'var ' + ($errs) + ' = errors , ' + ($prevValid) + ' = false , ' + ($valid) + ' = false , ' + ($passingSchemas) + ' = null; '; - var $wasComposite = it.compositeRule; - it.compositeRule = $it.compositeRule = true; - var arr1 = $schema; - if (arr1) { - var $sch, $i = -1, - l1 = arr1.length - 1; - while ($i < l1) { - $sch = arr1[$i += 1]; - if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { - $it.schema = $sch; - $it.schemaPath = $schemaPath + '[' + $i + ']'; - $it.errSchemaPath = $errSchemaPath + '/' + $i; - out += ' ' + (it.validate($it)) + ' '; - $it.baseId = $currentBaseId; - } else { - out += ' var ' + ($nextValid) + ' = true; '; - } - if ($i) { - out += ' if (' + ($nextValid) + ' && ' + ($prevValid) + ') { ' + ($valid) + ' = false; ' + ($passingSchemas) + ' = [' + ($passingSchemas) + ', ' + ($i) + ']; } else { '; - $closingBraces += '}'; - } - out += ' if (' + ($nextValid) + ') { ' + ($valid) + ' = ' + ($prevValid) + ' = true; ' + ($passingSchemas) + ' = ' + ($i) + '; }'; +class Agent extends OriginalAgent { + constructor(options) { + options = options || {}; + options.keepAlive = options.keepAlive !== false; + // default is keep-alive and 4s free socket timeout + // see https://medium.com/ssense-tech/reduce-networking-errors-in-nodejs-23b4eb9f2d83 + if (options.freeSocketTimeout === undefined) { + options.freeSocketTimeout = 4000; } - } - it.compositeRule = $it.compositeRule = $wasComposite; - out += '' + ($closingBraces) + 'if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('oneOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { passingSchemas: ' + ($passingSchemas) + ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should match exactly one schema in oneOf\' '; + // Legacy API: keepAliveTimeout should be rename to `freeSocketTimeout` + if (options.keepAliveTimeout) { + deprecate('options.keepAliveTimeout is deprecated, please use options.freeSocketTimeout instead'); + options.freeSocketTimeout = options.keepAliveTimeout; + delete options.keepAliveTimeout; } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; + // Legacy API: freeSocketKeepAliveTimeout should be rename to `freeSocketTimeout` + if (options.freeSocketKeepAliveTimeout) { + deprecate('options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead'); + options.freeSocketTimeout = options.freeSocketKeepAliveTimeout; + delete options.freeSocketKeepAliveTimeout; } - out += ' } '; - } else { - out += ' {} '; - } - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError(vErrors); '; - } else { - out += ' validate.errors = vErrors; return false; '; + + // Sets the socket to timeout after timeout milliseconds of inactivity on the socket. + // By default is double free socket timeout. + if (options.timeout === undefined) { + // make sure socket default inactivity timeout >= 8s + options.timeout = Math.max(options.freeSocketTimeout * 2, 8000); } - } - out += '} else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; }'; - if (it.opts.allErrors) { - out += ' } '; - } - return out; -} + // support humanize format + options.timeout = ms(options.timeout); + options.freeSocketTimeout = ms(options.freeSocketTimeout); + options.socketActiveTTL = options.socketActiveTTL ? ms(options.socketActiveTTL) : 0; -/***/ }), + super(options); -/***/ 56754: -/***/ ((module) => { + this[CURRENT_ID] = 0; -"use strict"; + // create socket success counter + this.createSocketCount = 0; + this.createSocketCountLastCheck = 0; -module.exports = function generate_pattern(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema); - out += 'if ( '; - if ($isData) { - out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || '; - } - out += ' !' + ($regexp) + '.test(' + ($data) + ') ) { '; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('pattern') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { pattern: '; - if ($isData) { - out += '' + ($schemaValue); - } else { - out += '' + (it.util.toQuotedString($schema)); - } - out += ' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should match pattern "'; - if ($isData) { - out += '\' + ' + ($schemaValue) + ' + \''; - } else { - out += '' + (it.util.escapeQuotes($schema)); - } - out += '"\' '; - } - if (it.opts.verbose) { - out += ' , schema: '; - if ($isData) { - out += 'validate.schema' + ($schemaPath); - } else { - out += '' + (it.util.toQuotedString($schema)); - } - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += '} '; - if ($breakOnError) { - out += ' else { '; - } - return out; -} + this.createSocketErrorCount = 0; + this.createSocketErrorCountLastCheck = 0; + this.closeSocketCount = 0; + this.closeSocketCountLastCheck = 0; -/***/ }), + // socket error event count + this.errorSocketCount = 0; + this.errorSocketCountLastCheck = 0; -/***/ 39795: -/***/ ((module) => { + // request finished counter + this.requestCount = 0; + this.requestCountLastCheck = 0; -"use strict"; + // including free socket timeout counter + this.timeoutSocketCount = 0; + this.timeoutSocketCountLastCheck = 0; -module.exports = function generate_properties(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $errs = 'errs__' + $lvl; - var $it = it.util.copy(it); - var $closingBraces = ''; - $it.level++; - var $nextValid = 'valid' + $it.level; - var $key = 'key' + $lvl, - $idx = 'idx' + $lvl, - $dataNxt = $it.dataLevel = it.dataLevel + 1, - $nextData = 'data' + $dataNxt, - $dataProperties = 'dataProperties' + $lvl; - var $schemaKeys = Object.keys($schema || {}).filter(notProto), - $pProperties = it.schema.patternProperties || {}, - $pPropertyKeys = Object.keys($pProperties).filter(notProto), - $aProperties = it.schema.additionalProperties, - $someProperties = $schemaKeys.length || $pPropertyKeys.length, - $noAdditional = $aProperties === false, - $additionalIsSchema = typeof $aProperties == 'object' && Object.keys($aProperties).length, - $removeAdditional = it.opts.removeAdditional, - $checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional, - $ownProperties = it.opts.ownProperties, - $currentBaseId = it.baseId; - var $required = it.schema.required; - if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) { - var $requiredHash = it.util.toHash($required); - } - - function notProto(p) { - return p !== '__proto__'; - } - out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;'; - if ($ownProperties) { - out += ' var ' + ($dataProperties) + ' = undefined;'; - } - if ($checkAdditional) { - if ($ownProperties) { - out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; '; - } else { - out += ' for (var ' + ($key) + ' in ' + ($data) + ') { '; - } - if ($someProperties) { - out += ' var isAdditional' + ($lvl) + ' = !(false '; - if ($schemaKeys.length) { - if ($schemaKeys.length > 8) { - out += ' || validate.schema' + ($schemaPath) + '.hasOwnProperty(' + ($key) + ') '; - } else { - var arr1 = $schemaKeys; - if (arr1) { - var $propertyKey, i1 = -1, - l1 = arr1.length - 1; - while (i1 < l1) { - $propertyKey = arr1[i1 += 1]; - out += ' || ' + ($key) + ' == ' + (it.util.toQuotedString($propertyKey)) + ' '; - } - } - } - } - if ($pPropertyKeys.length) { - var arr2 = $pPropertyKeys; - if (arr2) { - var $pProperty, $i = -1, - l2 = arr2.length - 1; - while ($i < l2) { - $pProperty = arr2[$i += 1]; - out += ' || ' + (it.usePattern($pProperty)) + '.test(' + ($key) + ') '; - } - } - } - out += ' ); if (isAdditional' + ($lvl) + ') { '; - } - if ($removeAdditional == 'all') { - out += ' delete ' + ($data) + '[' + ($key) + ']; '; - } else { - var $currentErrorPath = it.errorPath; - var $additionalProperty = '\' + ' + $key + ' + \''; - if (it.opts._errorDataPathProperty) { - it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers); - } - if ($noAdditional) { - if ($removeAdditional) { - out += ' delete ' + ($data) + '[' + ($key) + ']; '; - } else { - out += ' ' + ($nextValid) + ' = false; '; - var $currErrSchemaPath = $errSchemaPath; - $errSchemaPath = it.errSchemaPath + '/additionalProperties'; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('additionalProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { additionalProperty: \'' + ($additionalProperty) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \''; - if (it.opts._errorDataPathProperty) { - out += 'is an invalid additional property'; - } else { - out += 'should NOT have additional properties'; - } - out += '\' '; - } - if (it.opts.verbose) { - out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - $errSchemaPath = $currErrSchemaPath; - if ($breakOnError) { - out += ' break; '; - } - } - } else if ($additionalIsSchema) { - if ($removeAdditional == 'failing') { - out += ' var ' + ($errs) + ' = errors; '; - var $wasComposite = it.compositeRule; - it.compositeRule = $it.compositeRule = true; - $it.schema = $aProperties; - $it.schemaPath = it.schemaPath + '.additionalProperties'; - $it.errSchemaPath = it.errSchemaPath + '/additionalProperties'; - $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers); - var $passData = $data + '[' + $key + ']'; - $it.dataPathArr[$dataNxt] = $key; - var $code = it.validate($it); - $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { - out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; - } else { - out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; - } - out += ' if (!' + ($nextValid) + ') { errors = ' + ($errs) + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + ($data) + '[' + ($key) + ']; } '; - it.compositeRule = $it.compositeRule = $wasComposite; - } else { - $it.schema = $aProperties; - $it.schemaPath = it.schemaPath + '.additionalProperties'; - $it.errSchemaPath = it.errSchemaPath + '/additionalProperties'; - $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers); - var $passData = $data + '[' + $key + ']'; - $it.dataPathArr[$dataNxt] = $key; - var $code = it.validate($it); - $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { - out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; - } else { - out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; - } - if ($breakOnError) { - out += ' if (!' + ($nextValid) + ') break; '; - } - } - } - it.errorPath = $currentErrorPath; - } - if ($someProperties) { - out += ' } '; - } - out += ' } '; - if ($breakOnError) { - out += ' if (' + ($nextValid) + ') { '; - $closingBraces += '}'; - } - } - var $useDefaults = it.opts.useDefaults && !it.compositeRule; - if ($schemaKeys.length) { - var arr3 = $schemaKeys; - if (arr3) { - var $propertyKey, i3 = -1, - l3 = arr3.length - 1; - while (i3 < l3) { - $propertyKey = arr3[i3 += 1]; - var $sch = $schema[$propertyKey]; - if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { - var $prop = it.util.getProperty($propertyKey), - $passData = $data + $prop, - $hasDefault = $useDefaults && $sch.default !== undefined; - $it.schema = $sch; - $it.schemaPath = $schemaPath + $prop; - $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey); - $it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers); - $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey); - var $code = it.validate($it); - $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { - $code = it.util.varReplace($code, $nextData, $passData); - var $useData = $passData; - } else { - var $useData = $nextData; - out += ' var ' + ($nextData) + ' = ' + ($passData) + '; '; - } - if ($hasDefault) { - out += ' ' + ($code) + ' '; - } else { - if ($requiredHash && $requiredHash[$propertyKey]) { - out += ' if ( ' + ($useData) + ' === undefined '; - if ($ownProperties) { - out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; - } - out += ') { ' + ($nextValid) + ' = false; '; - var $currentErrorPath = it.errorPath, - $currErrSchemaPath = $errSchemaPath, - $missingProperty = it.util.escapeQuotes($propertyKey); - if (it.opts._errorDataPathProperty) { - it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers); - } - $errSchemaPath = it.errSchemaPath + '/required'; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \''; - if (it.opts._errorDataPathProperty) { - out += 'is a required property'; - } else { - out += 'should have required property \\\'' + ($missingProperty) + '\\\''; - } - out += '\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - $errSchemaPath = $currErrSchemaPath; - it.errorPath = $currentErrorPath; - out += ' } else { '; - } else { - if ($breakOnError) { - out += ' if ( ' + ($useData) + ' === undefined '; - if ($ownProperties) { - out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; - } - out += ') { ' + ($nextValid) + ' = true; } else { '; - } else { - out += ' if (' + ($useData) + ' !== undefined '; - if ($ownProperties) { - out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; - } - out += ' ) { '; - } - } - out += ' ' + ($code) + ' } '; - } - } - if ($breakOnError) { - out += ' if (' + ($nextValid) + ') { '; - $closingBraces += '}'; - } - } - } - } - if ($pPropertyKeys.length) { - var arr4 = $pPropertyKeys; - if (arr4) { - var $pProperty, i4 = -1, - l4 = arr4.length - 1; - while (i4 < l4) { - $pProperty = arr4[i4 += 1]; - var $sch = $pProperties[$pProperty]; - if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { - $it.schema = $sch; - $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty); - $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty); - if ($ownProperties) { - out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; '; - } else { - out += ' for (var ' + ($key) + ' in ' + ($data) + ') { '; - } - out += ' if (' + (it.usePattern($pProperty)) + '.test(' + ($key) + ')) { '; - $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers); - var $passData = $data + '[' + $key + ']'; - $it.dataPathArr[$dataNxt] = $key; - var $code = it.validate($it); - $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { - out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; - } else { - out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; - } - if ($breakOnError) { - out += ' if (!' + ($nextValid) + ') break; '; - } - out += ' } '; - if ($breakOnError) { - out += ' else ' + ($nextValid) + ' = true; '; - } - out += ' } '; - if ($breakOnError) { - out += ' if (' + ($nextValid) + ') { '; - $closingBraces += '}'; - } - } + this.on('free', socket => { + // https://github.com/nodejs/node/pull/32000 + // Node.js native agent will check socket timeout eqs agent.options.timeout. + // Use the ttl or freeSocketTimeout to overwrite. + const timeout = this.calcSocketTimeout(socket); + if (timeout > 0 && socket.timeout !== timeout) { + socket.setTimeout(timeout); } - } - } - if ($breakOnError) { - out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; + }); } - return out; -} + get freeSocketKeepAliveTimeout() { + deprecate('agent.freeSocketKeepAliveTimeout is deprecated, please use agent.options.freeSocketTimeout instead'); + return this.options.freeSocketTimeout; + } -/***/ }), - -/***/ 3837: -/***/ ((module) => { + get timeout() { + deprecate('agent.timeout is deprecated, please use agent.options.timeout instead'); + return this.options.timeout; + } -"use strict"; + get socketActiveTTL() { + deprecate('agent.socketActiveTTL is deprecated, please use agent.options.socketActiveTTL instead'); + return this.options.socketActiveTTL; + } -module.exports = function generate_propertyNames(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $errs = 'errs__' + $lvl; - var $it = it.util.copy(it); - var $closingBraces = ''; - $it.level++; - var $nextValid = 'valid' + $it.level; - out += 'var ' + ($errs) + ' = errors;'; - if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { - $it.schema = $schema; - $it.schemaPath = $schemaPath; - $it.errSchemaPath = $errSchemaPath; - var $key = 'key' + $lvl, - $idx = 'idx' + $lvl, - $i = 'i' + $lvl, - $invalidName = '\' + ' + $key + ' + \'', - $dataNxt = $it.dataLevel = it.dataLevel + 1, - $nextData = 'data' + $dataNxt, - $dataProperties = 'dataProperties' + $lvl, - $ownProperties = it.opts.ownProperties, - $currentBaseId = it.baseId; - if ($ownProperties) { - out += ' var ' + ($dataProperties) + ' = undefined; '; - } - if ($ownProperties) { - out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; '; - } else { - out += ' for (var ' + ($key) + ' in ' + ($data) + ') { '; - } - out += ' var startErrs' + ($lvl) + ' = errors; '; - var $passData = $key; - var $wasComposite = it.compositeRule; - it.compositeRule = $it.compositeRule = true; - var $code = it.validate($it); - $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { - out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; - } else { - out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; - } - it.compositeRule = $it.compositeRule = $wasComposite; - out += ' if (!' + ($nextValid) + ') { for (var ' + ($i) + '=startErrs' + ($lvl) + '; ' + ($i) + ' 0: should update socket timeout + * return undefined: not find custom timeout + */ + let freeSocketTimeout = this.options.freeSocketTimeout; + const socketActiveTTL = this.options.socketActiveTTL; + if (socketActiveTTL) { + // check socketActiveTTL + const aliveTime = Date.now() - socket[SOCKET_CREATED_TIME]; + const diff = socketActiveTTL - aliveTime; + if (diff <= 0) { + return diff; } - out += ' } '; - } else { - out += ' {} '; - } - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError(vErrors); '; - } else { - out += ' validate.errors = vErrors; return false; '; + if (freeSocketTimeout && diff < freeSocketTimeout) { + freeSocketTimeout = diff; } } - if ($breakOnError) { - out += ' break; '; + // set freeSocketTimeout + if (freeSocketTimeout) { + // set free keepalive timer + // try to use socket custom freeSocketTimeout first, support headers['keep-alive'] + // https://github.com/node-modules/urllib/blob/b76053020923f4d99a1c93cf2e16e0c5ba10bacf/lib/urllib.js#L498 + const customFreeSocketTimeout = socket.freeSocketTimeout || socket.freeSocketKeepAliveTimeout; + return customFreeSocketTimeout || freeSocketTimeout; } - out += ' } }'; - } - if ($breakOnError) { - out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; } - return out; -} + keepSocketAlive(socket) { + const result = super.keepSocketAlive(socket); + // should not keepAlive, do nothing + if (!result) return result; -/***/ }), - -/***/ 29313: -/***/ ((module) => { - -"use strict"; - -module.exports = function generate_ref(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $async, $refCode; - if ($schema == '#' || $schema == '#/') { - if (it.isRoot) { - $async = it.async; - $refCode = 'validate'; - } else { - $async = it.root.schema.$async === true; - $refCode = 'root.refVal[0]'; + const customTimeout = this.calcSocketTimeout(socket); + if (typeof customTimeout === 'undefined') { + return true; } - } else { - var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot); - if ($refVal === undefined) { - var $message = it.MissingRefError.message(it.baseId, $schema); - if (it.opts.missingRefs == 'fail') { - it.logger.error($message); - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('$ref') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { ref: \'' + (it.util.escapeQuotes($schema)) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \'can\\\'t resolve reference ' + (it.util.escapeQuotes($schema)) + '\' '; - } - if (it.opts.verbose) { - out += ' , schema: ' + (it.util.toQuotedString($schema)) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - if ($breakOnError) { - out += ' if (false) { '; - } - } else if (it.opts.missingRefs == 'ignore') { - it.logger.warn($message); - if ($breakOnError) { - out += ' if (true) { '; - } - } else { - throw new it.MissingRefError(it.baseId, $schema, $message); - } - } else if ($refVal.inline) { - var $it = it.util.copy(it); - $it.level++; - var $nextValid = 'valid' + $it.level; - $it.schema = $refVal.schema; - $it.schemaPath = ''; - $it.errSchemaPath = $schema; - var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code); - out += ' ' + ($code) + ' '; - if ($breakOnError) { - out += ' if (' + ($nextValid) + ') { '; - } - } else { - $async = $refVal.$async === true || (it.async && $refVal.$async !== false); - $refCode = $refVal.code; + if (customTimeout <= 0) { + debug('%s(requests: %s, finished: %s) free but need to destroy by TTL, request count %s, diff is %s', + socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], customTimeout); + return false; } - } - if ($refCode) { - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; - if (it.opts.passContext) { - out += ' ' + ($refCode) + '.call(this, '; - } else { - out += ' ' + ($refCode) + '( '; - } - out += ' ' + ($data) + ', (dataPath || \'\')'; - if (it.errorPath != '""') { - out += ' + ' + (it.errorPath); - } - var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData', - $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty'; - out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ', rootData) '; - var __callValidate = out; - out = $$outStack.pop(); - if ($async) { - if (!it.async) throw new Error('async schema referenced by sync schema'); - if ($breakOnError) { - out += ' var ' + ($valid) + '; '; - } - out += ' try { await ' + (__callValidate) + '; '; - if ($breakOnError) { - out += ' ' + ($valid) + ' = true; '; - } - out += ' } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; '; - if ($breakOnError) { - out += ' ' + ($valid) + ' = false; '; - } - out += ' } '; - if ($breakOnError) { - out += ' if (' + ($valid) + ') { '; - } - } else { - out += ' if (!' + (__callValidate) + ') { if (vErrors === null) vErrors = ' + ($refCode) + '.errors; else vErrors = vErrors.concat(' + ($refCode) + '.errors); errors = vErrors.length; } '; - if ($breakOnError) { - out += ' else { '; - } + if (socket.timeout !== customTimeout) { + socket.setTimeout(customTimeout); } + return true; } - return out; -} - - -/***/ }), -/***/ 21106: -/***/ ((module) => { + // only call on addRequest + reuseSocket(...args) { + // reuseSocket(socket, req) + super.reuseSocket(...args); + const socket = args[0]; + const req = args[1]; + req.reusedSocket = true; + const agentTimeout = this.options.timeout; + if (getSocketTimeout(socket) !== agentTimeout) { + // reset timeout before use + socket.setTimeout(agentTimeout); + debug('%s reset timeout to %sms', socket[SOCKET_NAME], agentTimeout); + } + socket[SOCKET_REQUEST_COUNT]++; + debug('%s(requests: %s, finished: %s) reuse on addRequest, timeout %sms', + socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], + getSocketTimeout(socket)); + } -"use strict"; + [CREATE_ID]() { + const id = this[CURRENT_ID]++; + if (this[CURRENT_ID] === Number.MAX_SAFE_INTEGER) this[CURRENT_ID] = 0; + return id; + } -module.exports = function generate_required(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; - } - var $vSchema = 'schema' + $lvl; - if (!$isData) { - if ($schema.length < it.opts.loopRequired && it.schema.properties && Object.keys(it.schema.properties).length) { - var $required = []; - var arr1 = $schema; - if (arr1) { - var $property, i1 = -1, - l1 = arr1.length - 1; - while (i1 < l1) { - $property = arr1[i1 += 1]; - var $propertySch = it.schema.properties[$property]; - if (!($propertySch && (it.opts.strictKeywords ? (typeof $propertySch == 'object' && Object.keys($propertySch).length > 0) || $propertySch === false : it.util.schemaHasRules($propertySch, it.RULES.all)))) { - $required[$required.length] = $property; - } - } - } - } else { - var $required = $schema; - } - } - if ($isData || $required.length) { - var $currentErrorPath = it.errorPath, - $loopRequired = $isData || $required.length >= it.opts.loopRequired, - $ownProperties = it.opts.ownProperties; - if ($breakOnError) { - out += ' var missing' + ($lvl) + '; '; - if ($loopRequired) { - if (!$isData) { - out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + '; '; - } - var $i = 'i' + $lvl, - $propertyPath = 'schema' + $lvl + '[' + $i + ']', - $missingProperty = '\' + ' + $propertyPath + ' + \''; - if (it.opts._errorDataPathProperty) { - it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers); - } - out += ' var ' + ($valid) + ' = true; '; - if ($isData) { - out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {'; - } - out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { ' + ($valid) + ' = ' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] !== undefined '; - if ($ownProperties) { - out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) '; - } - out += '; if (!' + ($valid) + ') break; } '; - if ($isData) { - out += ' } '; - } - out += ' if (!' + ($valid) + ') { '; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \''; - if (it.opts._errorDataPathProperty) { - out += 'is a required property'; - } else { - out += 'should have required property \\\'' + ($missingProperty) + '\\\''; - } - out += '\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } else { '; - } else { - out += ' if ( '; - var arr2 = $required; - if (arr2) { - var $propertyKey, $i = -1, - l2 = arr2.length - 1; - while ($i < l2) { - $propertyKey = arr2[$i += 1]; - if ($i) { - out += ' || '; - } - var $prop = it.util.getProperty($propertyKey), - $useData = $data + $prop; - out += ' ( ( ' + ($useData) + ' === undefined '; - if ($ownProperties) { - out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; - } - out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) '; - } - } - out += ') { '; - var $propertyPath = 'missing' + $lvl, - $missingProperty = '\' + ' + $propertyPath + ' + \''; - if (it.opts._errorDataPathProperty) { - it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath; - } - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \''; - if (it.opts._errorDataPathProperty) { - out += 'is a required property'; - } else { - out += 'should have required property \\\'' + ($missingProperty) + '\\\''; - } - out += '\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } else { '; - } - } else { - if ($loopRequired) { - if (!$isData) { - out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + '; '; - } - var $i = 'i' + $lvl, - $propertyPath = 'schema' + $lvl + '[' + $i + ']', - $missingProperty = '\' + ' + $propertyPath + ' + \''; - if (it.opts._errorDataPathProperty) { - it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers); - } - if ($isData) { - out += ' if (' + ($vSchema) + ' && !Array.isArray(' + ($vSchema) + ')) { var err = '; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \''; - if (it.opts._errorDataPathProperty) { - out += 'is a required property'; - } else { - out += 'should have required property \\\'' + ($missingProperty) + '\\\''; - } - out += '\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (' + ($vSchema) + ' !== undefined) { '; - } - out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { if (' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] === undefined '; - if ($ownProperties) { - out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) '; - } - out += ') { var err = '; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \''; - if (it.opts._errorDataPathProperty) { - out += 'is a required property'; - } else { - out += 'should have required property \\\'' + ($missingProperty) + '\\\''; - } - out += '\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } '; - if ($isData) { - out += ' } '; - } - } else { - var arr3 = $required; - if (arr3) { - var $propertyKey, i3 = -1, - l3 = arr3.length - 1; - while (i3 < l3) { - $propertyKey = arr3[i3 += 1]; - var $prop = it.util.getProperty($propertyKey), - $missingProperty = it.util.escapeQuotes($propertyKey), - $useData = $data + $prop; - if (it.opts._errorDataPathProperty) { - it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers); - } - out += ' if ( ' + ($useData) + ' === undefined '; - if ($ownProperties) { - out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') '; - } - out += ') { var err = '; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \''; - if (it.opts._errorDataPathProperty) { - out += 'is a required property'; - } else { - out += 'should have required property \\\'' + ($missingProperty) + '\\\''; - } - out += '\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } '; - } - } + [INIT_SOCKET](socket, options) { + // bugfix here. + // https on node 8, 10 won't set agent.options.timeout by default + // TODO: need to fix on node itself + if (options.timeout) { + const timeout = getSocketTimeout(socket); + if (!timeout) { + socket.setTimeout(options.timeout); } } - it.errorPath = $currentErrorPath; - } else if ($breakOnError) { - out += ' if (true) {'; - } - return out; -} + if (this.options.keepAlive) { + // Disable Nagle's algorithm: http://blog.caustik.com/2012/04/08/scaling-node-js-to-100k-concurrent-connections/ + // https://fengmk2.com/benchmark/nagle-algorithm-delayed-ack-mock.html + socket.setNoDelay(true); + } + this.createSocketCount++; + if (this.options.socketActiveTTL) { + socket[SOCKET_CREATED_TIME] = Date.now(); + } + // don't show the hole '-----BEGIN CERTIFICATE----' key string + socket[SOCKET_NAME] = `sock[${this[CREATE_ID]()}#${options._agentKey}]`.split('-----BEGIN', 1)[0]; + socket[SOCKET_REQUEST_COUNT] = 1; + socket[SOCKET_REQUEST_FINISHED_COUNT] = 0; + installListeners(this, socket, options); + } -/***/ }), - -/***/ 19466: -/***/ ((module) => { + createConnection(options, oncreate) { + let called = false; + const onNewCreate = (err, socket) => { + if (called) return; + called = true; -"use strict"; + if (err) { + this.createSocketErrorCount++; + return oncreate(err); + } + this[INIT_SOCKET](socket, options); + oncreate(err, socket); + }; -module.exports = function generate_uniqueItems(it, $keyword, $ruleType) { - var out = ' '; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - var $isData = it.opts.$data && $schema && $schema.$data, - $schemaValue; - if ($isData) { - out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; '; - $schemaValue = 'schema' + $lvl; - } else { - $schemaValue = $schema; + const newSocket = super.createConnection(options, onNewCreate); + if (newSocket) onNewCreate(null, newSocket); + return newSocket; } - if (($schema || $isData) && it.opts.uniqueItems !== false) { - if ($isData) { - out += ' var ' + ($valid) + '; if (' + ($schemaValue) + ' === false || ' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'boolean\') ' + ($valid) + ' = false; else { '; - } - out += ' var i = ' + ($data) + '.length , ' + ($valid) + ' = true , j; if (i > 1) { '; - var $itemType = it.schema.items && it.schema.items.type, - $typeIsArray = Array.isArray($itemType); - if (!$itemType || $itemType == 'object' || $itemType == 'array' || ($typeIsArray && ($itemType.indexOf('object') >= 0 || $itemType.indexOf('array') >= 0))) { - out += ' outer: for (;i--;) { for (j = i; j--;) { if (equal(' + ($data) + '[i], ' + ($data) + '[j])) { ' + ($valid) + ' = false; break outer; } } } '; - } else { - out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; '; - var $method = 'checkDataType' + ($typeIsArray ? 's' : ''); - out += ' if (' + (it.util[$method]($itemType, 'item', it.opts.strictNumbers, true)) + ') continue; '; - if ($typeIsArray) { - out += ' if (typeof item == \'string\') item = \'"\' + item; '; - } - out += ' if (typeof itemIndices[item] == \'number\') { ' + ($valid) + ' = false; j = itemIndices[item]; break; } itemIndices[item] = i; } '; - } - out += ' } '; - if ($isData) { - out += ' } '; - } - out += ' if (!' + ($valid) + ') { '; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ('uniqueItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { i: i, j: j } '; - if (it.opts.messages !== false) { - out += ' , message: \'should NOT have duplicate items (items ## \' + j + \' and \' + i + \' are identical)\' '; - } - if (it.opts.verbose) { - out += ' , schema: '; - if ($isData) { - out += 'validate.schema' + ($schemaPath); - } else { - out += '' + ($schema); - } - out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } '; - if ($breakOnError) { - out += ' else { '; - } - } else { - if ($breakOnError) { - out += ' if (true) { '; + + get statusChanged() { + const changed = this.createSocketCount !== this.createSocketCountLastCheck || + this.createSocketErrorCount !== this.createSocketErrorCountLastCheck || + this.closeSocketCount !== this.closeSocketCountLastCheck || + this.errorSocketCount !== this.errorSocketCountLastCheck || + this.timeoutSocketCount !== this.timeoutSocketCountLastCheck || + this.requestCount !== this.requestCountLastCheck; + if (changed) { + this.createSocketCountLastCheck = this.createSocketCount; + this.createSocketErrorCountLastCheck = this.createSocketErrorCount; + this.closeSocketCountLastCheck = this.closeSocketCount; + this.errorSocketCountLastCheck = this.errorSocketCount; + this.timeoutSocketCountLastCheck = this.timeoutSocketCount; + this.requestCountLastCheck = this.requestCount; } + return changed; + } + + getCurrentStatus() { + return { + createSocketCount: this.createSocketCount, + createSocketErrorCount: this.createSocketErrorCount, + closeSocketCount: this.closeSocketCount, + errorSocketCount: this.errorSocketCount, + timeoutSocketCount: this.timeoutSocketCount, + requestCount: this.requestCount, + freeSockets: inspect(this.freeSockets), + sockets: inspect(this.sockets), + requests: inspect(this.requests), + }; } - return out; } +// node 8 don't has timeout attribute on socket +// https://github.com/nodejs/node/pull/21204/files#diff-e6ef024c3775d787c38487a6309e491dR408 +function getSocketTimeout(socket) { + return socket.timeout || socket._idleTimeout; +} -/***/ }), +function installListeners(agent, socket, options) { + debug('%s create, timeout %sms', socket[SOCKET_NAME], getSocketTimeout(socket)); -/***/ 24887: -/***/ ((module) => { + // listener socket events: close, timeout, error, free + function onFree() { + // create and socket.emit('free') logic + // https://github.com/nodejs/node/blob/master/lib/_http_agent.js#L311 + // no req on the socket, it should be the new socket + if (!socket._httpMessage && socket[SOCKET_REQUEST_COUNT] === 1) return; -"use strict"; + socket[SOCKET_REQUEST_FINISHED_COUNT]++; + agent.requestCount++; + debug('%s(requests: %s, finished: %s) free', + socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]); -module.exports = function generate_validate(it, $keyword, $ruleType) { - var out = ''; - var $async = it.schema.$async === true, - $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'), - $id = it.self._getId(it.schema); - if (it.opts.strictKeywords) { - var $unknownKwd = it.util.schemaUnknownRules(it.schema, it.RULES.keywords); - if ($unknownKwd) { - var $keywordsMsg = 'unknown keyword: ' + $unknownKwd; - if (it.opts.strictKeywords === 'log') it.logger.warn($keywordsMsg); - else throw new Error($keywordsMsg); - } - } - if (it.isTop) { - out += ' var validate = '; - if ($async) { - it.async = true; - out += 'async '; - } - out += 'function(data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; '; - if ($id && (it.opts.sourceCode || it.opts.processCode)) { - out += ' ' + ('/\*# sourceURL=' + $id + ' */') + ' '; - } - } - if (typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref)) { - var $keyword = 'false schema'; - var $lvl = it.level; - var $dataLvl = it.dataLevel; - var $schema = it.schema[$keyword]; - var $schemaPath = it.schemaPath + it.util.getProperty($keyword); - var $errSchemaPath = it.errSchemaPath + '/' + $keyword; - var $breakOnError = !it.opts.allErrors; - var $errorKeyword; - var $data = 'data' + ($dataLvl || ''); - var $valid = 'valid' + $lvl; - if (it.schema === false) { - if (it.isTop) { - $breakOnError = true; - } else { - out += ' var ' + ($valid) + ' = false; '; - } - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ($errorKeyword || 'false schema') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} '; - if (it.opts.messages !== false) { - out += ' , message: \'boolean schema is false\' '; - } - if (it.opts.verbose) { - out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - } else { - if (it.isTop) { - if ($async) { - out += ' return data; '; - } else { - out += ' validate.errors = null; return true; '; - } - } else { - out += ' var ' + ($valid) + ' = true; '; - } - } - if (it.isTop) { - out += ' }; return validate; '; + // should reuse on pedding requests? + const name = agent.getName(options); + if (socket.writable && agent.requests[name] && agent.requests[name].length) { + // will be reuse on agent free listener + socket[SOCKET_REQUEST_COUNT]++; + debug('%s(requests: %s, finished: %s) will be reuse on agent free event', + socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]); } - return out; } - if (it.isTop) { - var $top = it.isTop, - $lvl = it.level = 0, - $dataLvl = it.dataLevel = 0, - $data = 'data'; - it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema)); - it.baseId = it.baseId || it.rootId; - delete it.isTop; - it.dataPathArr = [""]; - if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) { - var $defaultMsg = 'default is ignored in the schema root'; - if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg); - else throw new Error($defaultMsg); - } - out += ' var vErrors = null; '; - out += ' var errors = 0; '; - out += ' if (rootData === undefined) rootData = data; '; - } else { - var $lvl = it.level, - $dataLvl = it.dataLevel, - $data = 'data' + ($dataLvl || ''); - if ($id) it.baseId = it.resolve.url(it.baseId, $id); - if ($async && !it.async) throw new Error('async schema in sync schema'); - out += ' var errs_' + ($lvl) + ' = errors;'; - } - var $valid = 'valid' + $lvl, - $breakOnError = !it.opts.allErrors, - $closingBraces1 = '', - $closingBraces2 = ''; - var $errorKeyword; - var $typeSchema = it.schema.type, - $typeIsArray = Array.isArray($typeSchema); - if ($typeSchema && it.opts.nullable && it.schema.nullable === true) { - if ($typeIsArray) { - if ($typeSchema.indexOf('null') == -1) $typeSchema = $typeSchema.concat('null'); - } else if ($typeSchema != 'null') { - $typeSchema = [$typeSchema, 'null']; - $typeIsArray = true; - } - } - if ($typeIsArray && $typeSchema.length == 1) { - $typeSchema = $typeSchema[0]; - $typeIsArray = false; - } - if (it.schema.$ref && $refKeywords) { - if (it.opts.extendRefs == 'fail') { - throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)'); - } else if (it.opts.extendRefs !== true) { - $refKeywords = false; - it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"'); - } - } - if (it.schema.$comment && it.opts.$comment) { - out += ' ' + (it.RULES.all.$comment.code(it, '$comment')); - } - if ($typeSchema) { - if (it.opts.coerceTypes) { - var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema); - } - var $rulesGroup = it.RULES.types[$typeSchema]; - if ($coerceToTypes || $typeIsArray || $rulesGroup === true || ($rulesGroup && !$shouldUseGroup($rulesGroup))) { - var $schemaPath = it.schemaPath + '.type', - $errSchemaPath = it.errSchemaPath + '/type'; - var $schemaPath = it.schemaPath + '.type', - $errSchemaPath = it.errSchemaPath + '/type', - $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType'; - out += ' if (' + (it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true)) + ') { '; - if ($coerceToTypes) { - var $dataType = 'dataType' + $lvl, - $coerced = 'coerced' + $lvl; - out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; var ' + ($coerced) + ' = undefined; '; - if (it.opts.coerceTypes == 'array') { - out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ') && ' + ($data) + '.length == 1) { ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + '; if (' + (it.util.checkDataType(it.schema.type, $data, it.opts.strictNumbers)) + ') ' + ($coerced) + ' = ' + ($data) + '; } '; - } - out += ' if (' + ($coerced) + ' !== undefined) ; '; - var arr1 = $coerceToTypes; - if (arr1) { - var $type, $i = -1, - l1 = arr1.length - 1; - while ($i < l1) { - $type = arr1[$i += 1]; - if ($type == 'string') { - out += ' else if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; '; - } else if ($type == 'number' || $type == 'integer') { - out += ' else if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' '; - if ($type == 'integer') { - out += ' && !(' + ($data) + ' % 1)'; - } - out += ')) ' + ($coerced) + ' = +' + ($data) + '; '; - } else if ($type == 'boolean') { - out += ' else if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; '; - } else if ($type == 'null') { - out += ' else if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; '; - } else if (it.opts.coerceTypes == 'array' && $type == 'array') { - out += ' else if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; '; - } - } - } - out += ' else { '; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \''; - if ($typeIsArray) { - out += '' + ($typeSchema.join(",")); - } else { - out += '' + ($typeSchema); - } - out += '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should be '; - if ($typeIsArray) { - out += '' + ($typeSchema.join(",")); - } else { - out += '' + ($typeSchema); - } - out += '\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } if (' + ($coerced) + ' !== undefined) { '; - var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData', - $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty'; - out += ' ' + ($data) + ' = ' + ($coerced) + '; '; - if (!$dataLvl) { - out += 'if (' + ($parentData) + ' !== undefined)'; - } - out += ' ' + ($parentData) + '[' + ($parentDataProperty) + '] = ' + ($coerced) + '; } '; - } else { - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \''; - if ($typeIsArray) { - out += '' + ($typeSchema.join(",")); - } else { - out += '' + ($typeSchema); - } - out += '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should be '; - if ($typeIsArray) { - out += '' + ($typeSchema.join(",")); - } else { - out += '' + ($typeSchema); - } - out += '\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - } - out += ' } '; - } + socket.on('free', onFree); + + function onClose(isError) { + debug('%s(requests: %s, finished: %s) close, isError: %s', + socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], isError); + agent.closeSocketCount++; } - if (it.schema.$ref && !$refKeywords) { - out += ' ' + (it.RULES.all.$ref.code(it, '$ref')) + ' '; - if ($breakOnError) { - out += ' } if (errors === '; - if ($top) { - out += '0'; - } else { - out += 'errs_' + ($lvl); - } - out += ') { '; - $closingBraces2 += '}'; + socket.on('close', onClose); + + // start socket timeout handler + function onTimeout() { + // onTimeout and emitRequestTimeout(_http_client.js) + // https://github.com/nodejs/node/blob/v12.x/lib/_http_client.js#L711 + const listenerCount = socket.listeners('timeout').length; + // node <= 10, default listenerCount is 1, onTimeout + // 11 < node <= 12, default listenerCount is 2, onTimeout and emitRequestTimeout + // node >= 13, default listenerCount is 3, onTimeout, + // onTimeout(https://github.com/nodejs/node/pull/32000/files#diff-5f7fb0850412c6be189faeddea6c5359R333) + // and emitRequestTimeout + const timeout = getSocketTimeout(socket); + const req = socket._httpMessage; + const reqTimeoutListenerCount = req && req.listeners('timeout').length || 0; + debug('%s(requests: %s, finished: %s) timeout after %sms, listeners %s, defaultTimeoutListenerCount %s, hasHttpRequest %s, HttpRequest timeoutListenerCount %s', + socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], + timeout, listenerCount, defaultTimeoutListenerCount, !!req, reqTimeoutListenerCount); + if (debug.enabled) { + debug('timeout listeners: %s', socket.listeners('timeout').map(f => f.name).join(', ')); } - } else { - var arr2 = it.RULES; - if (arr2) { - var $rulesGroup, i2 = -1, - l2 = arr2.length - 1; - while (i2 < l2) { - $rulesGroup = arr2[i2 += 1]; - if ($shouldUseGroup($rulesGroup)) { - if ($rulesGroup.type) { - out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers)) + ') { '; - } - if (it.opts.useDefaults) { - if ($rulesGroup.type == 'object' && it.schema.properties) { - var $schema = it.schema.properties, - $schemaKeys = Object.keys($schema); - var arr3 = $schemaKeys; - if (arr3) { - var $propertyKey, i3 = -1, - l3 = arr3.length - 1; - while (i3 < l3) { - $propertyKey = arr3[i3 += 1]; - var $sch = $schema[$propertyKey]; - if ($sch.default !== undefined) { - var $passData = $data + it.util.getProperty($propertyKey); - if (it.compositeRule) { - if (it.opts.strictDefaults) { - var $defaultMsg = 'default is ignored for: ' + $passData; - if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg); - else throw new Error($defaultMsg); - } - } else { - out += ' if (' + ($passData) + ' === undefined '; - if (it.opts.useDefaults == 'empty') { - out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' '; - } - out += ' ) ' + ($passData) + ' = '; - if (it.opts.useDefaults == 'shared') { - out += ' ' + (it.useDefault($sch.default)) + ' '; - } else { - out += ' ' + (JSON.stringify($sch.default)) + ' '; - } - out += '; '; - } - } - } - } - } else if ($rulesGroup.type == 'array' && Array.isArray(it.schema.items)) { - var arr4 = it.schema.items; - if (arr4) { - var $sch, $i = -1, - l4 = arr4.length - 1; - while ($i < l4) { - $sch = arr4[$i += 1]; - if ($sch.default !== undefined) { - var $passData = $data + '[' + $i + ']'; - if (it.compositeRule) { - if (it.opts.strictDefaults) { - var $defaultMsg = 'default is ignored for: ' + $passData; - if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg); - else throw new Error($defaultMsg); - } - } else { - out += ' if (' + ($passData) + ' === undefined '; - if (it.opts.useDefaults == 'empty') { - out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' '; - } - out += ' ) ' + ($passData) + ' = '; - if (it.opts.useDefaults == 'shared') { - out += ' ' + (it.useDefault($sch.default)) + ' '; - } else { - out += ' ' + (JSON.stringify($sch.default)) + ' '; - } - out += '; '; - } - } - } - } - } - } - var arr5 = $rulesGroup.rules; - if (arr5) { - var $rule, i5 = -1, - l5 = arr5.length - 1; - while (i5 < l5) { - $rule = arr5[i5 += 1]; - if ($shouldUseRule($rule)) { - var $code = $rule.code(it, $rule.keyword, $rulesGroup.type); - if ($code) { - out += ' ' + ($code) + ' '; - if ($breakOnError) { - $closingBraces1 += '}'; - } - } - } - } - } - if ($breakOnError) { - out += ' ' + ($closingBraces1) + ' '; - $closingBraces1 = ''; - } - if ($rulesGroup.type) { - out += ' } '; - if ($typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes) { - out += ' else { '; - var $schemaPath = it.schemaPath + '.type', - $errSchemaPath = it.errSchemaPath + '/type'; - var $$outStack = $$outStack || []; - $$outStack.push(out); - out = ''; /* istanbul ignore else */ - if (it.createErrors !== false) { - out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \''; - if ($typeIsArray) { - out += '' + ($typeSchema.join(",")); - } else { - out += '' + ($typeSchema); - } - out += '\' } '; - if (it.opts.messages !== false) { - out += ' , message: \'should be '; - if ($typeIsArray) { - out += '' + ($typeSchema.join(",")); - } else { - out += '' + ($typeSchema); - } - out += '\' '; - } - if (it.opts.verbose) { - out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' '; - } - out += ' } '; - } else { - out += ' {} '; - } - var __err = out; - out = $$outStack.pop(); - if (!it.compositeRule && $breakOnError) { - /* istanbul ignore if */ - if (it.async) { - out += ' throw new ValidationError([' + (__err) + ']); '; - } else { - out += ' validate.errors = [' + (__err) + ']; return false; '; - } - } else { - out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; '; - } - out += ' } '; - } - } - if ($breakOnError) { - out += ' if (errors === '; - if ($top) { - out += '0'; - } else { - out += 'errs_' + ($lvl); - } - out += ') { '; - $closingBraces2 += '}'; - } - } + agent.timeoutSocketCount++; + const name = agent.getName(options); + if (agent.freeSockets[name] && agent.freeSockets[name].indexOf(socket) !== -1) { + // free socket timeout, destroy quietly + socket.destroy(); + // Remove it from freeSockets list immediately to prevent new requests + // from being sent through this socket. + agent.removeSocket(socket, options); + debug('%s is free, destroy quietly', socket[SOCKET_NAME]); + } else { + // if there is no any request socket timeout handler, + // agent need to handle socket timeout itself. + // + // custom request socket timeout handle logic must follow these rules: + // 1. Destroy socket first + // 2. Must emit socket 'agentRemove' event tell agent remove socket + // from freeSockets list immediately. + // Otherise you may be get 'socket hang up' error when reuse + // free socket and timeout happen in the same time. + if (reqTimeoutListenerCount === 0) { + const error = new Error('Socket timeout'); + error.code = 'ERR_SOCKET_TIMEOUT'; + error.timeout = timeout; + // must manually call socket.end() or socket.destroy() to end the connection. + // https://nodejs.org/dist/latest-v10.x/docs/api/net.html#net_socket_settimeout_timeout_callback + socket.destroy(error); + agent.removeSocket(socket, options); + debug('%s destroy with timeout error', socket[SOCKET_NAME]); } } } - if ($breakOnError) { - out += ' ' + ($closingBraces2) + ' '; - } - if ($top) { - if ($async) { - out += ' if (errors === 0) return data; '; - out += ' else throw new ValidationError(vErrors); '; - } else { - out += ' validate.errors = vErrors; '; - out += ' return errors === 0; '; + socket.on('timeout', onTimeout); + + function onError(err) { + const listenerCount = socket.listeners('error').length; + debug('%s(requests: %s, finished: %s) error: %s, listenerCount: %s', + socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], + err, listenerCount); + agent.errorSocketCount++; + if (listenerCount === 1) { + // if socket don't contain error event handler, don't catch it, emit it again + debug('%s emit uncaught error event', socket[SOCKET_NAME]); + socket.removeListener('error', onError); + socket.emit('error', err); } - out += ' }; return validate;'; - } else { - out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';'; } + socket.on('error', onError); - function $shouldUseGroup($rulesGroup) { - var rules = $rulesGroup.rules; - for (var i = 0; i < rules.length; i++) - if ($shouldUseRule(rules[i])) return true; + function onRemove() { + debug('%s(requests: %s, finished: %s) agentRemove', + socket[SOCKET_NAME], + socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]); + // We need this function for cases like HTTP 'upgrade' + // (defined by WebSockets) where we need to remove a socket from the + // pool because it'll be locked up indefinitely + socket.removeListener('close', onClose); + socket.removeListener('error', onError); + socket.removeListener('free', onFree); + socket.removeListener('timeout', onTimeout); + socket.removeListener('agentRemove', onRemove); } + socket.on('agentRemove', onRemove); +} - function $shouldUseRule($rule) { - return it.schema[$rule.keyword] !== undefined || ($rule.implements && $ruleImplementsSomeKeyword($rule)); - } +module.exports = Agent; - function $ruleImplementsSomeKeyword($rule) { - var impl = $rule.implements; - for (var i = 0; i < impl.length; i++) - if (it.schema[impl[i]] !== undefined) return true; +function inspect(obj) { + const res = {}; + for (const key in obj) { + res[key] = obj[key].length; } - return out; + return res; } /***/ }), -/***/ 65930: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ 47151: +/***/ ((module) => { "use strict"; -var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i; -var customRuleCode = __nccwpck_require__(55832); -var definitionSchema = __nccwpck_require__(2924); - module.exports = { - add: addKeyword, - get: getKeyword, - remove: removeKeyword, - validate: validateKeyword + // agent + CURRENT_ID: Symbol('agentkeepalive#currentId'), + CREATE_ID: Symbol('agentkeepalive#createId'), + INIT_SOCKET: Symbol('agentkeepalive#initSocket'), + CREATE_HTTPS_CONNECTION: Symbol('agentkeepalive#createHttpsConnection'), + // socket + SOCKET_CREATED_TIME: Symbol('agentkeepalive#socketCreatedTime'), + SOCKET_NAME: Symbol('agentkeepalive#socketName'), + SOCKET_REQUEST_COUNT: Symbol('agentkeepalive#socketRequestCount'), + SOCKET_REQUEST_FINISHED_COUNT: Symbol('agentkeepalive#socketRequestFinishedCount'), }; -/** - * Define custom keyword - * @this Ajv - * @param {String} keyword custom keyword, should be unique (including different from all standard, custom and macro keywords). - * @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`. - * @return {Ajv} this for method chaining - */ -function addKeyword(keyword, definition) { - /* jshint validthis: true */ - /* eslint no-shadow: 0 */ - var RULES = this.RULES; - if (RULES.keywords[keyword]) - throw new Error('Keyword ' + keyword + ' is already defined'); - - if (!IDENTIFIER.test(keyword)) - throw new Error('Keyword ' + keyword + ' is not a valid identifier'); - - if (definition) { - this.validateKeyword(definition, true); +/***/ }), - var dataType = definition.type; - if (Array.isArray(dataType)) { - for (var i=0; i { - var metaSchema = definition.metaSchema; - if (metaSchema) { - if (definition.$data && this._opts.$data) { - metaSchema = { - anyOf: [ - metaSchema, - { '$ref': 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' } - ] - }; - } - definition.validateSchema = this.compile(metaSchema, true); - } - } +"use strict"; - RULES.keywords[keyword] = RULES.all[keyword] = true; +const OriginalHttpsAgent = (__nccwpck_require__(95687).Agent); +const HttpAgent = __nccwpck_require__(20854); +const { + INIT_SOCKET, + CREATE_HTTPS_CONNECTION, +} = __nccwpck_require__(47151); - function _addRule(keyword, dataType, definition) { - var ruleGroup; - for (var i=0; i { - if (v(definition)) return true; - validateKeyword.errors = v.errors; - if (throwError) - throw new Error('custom keyword definition is invalid: ' + this.errorsText(v.errors)); - else - return false; +"use strict"; + +const indentString = __nccwpck_require__(17160); +const cleanStack = __nccwpck_require__(20523); + +const cleanInternalStack = stack => stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, ''); + +class AggregateError extends Error { + constructor(errors) { + if (!Array.isArray(errors)) { + throw new TypeError(`Expected input to be an Array, got ${typeof errors}`); + } + + errors = [...errors].map(error => { + if (error instanceof Error) { + return error; + } + + if (error !== null && typeof error === 'object') { + // Handle plain error objects with message property and/or possibly other metadata + return Object.assign(new Error(error.message), error); + } + + return new Error(error); + }); + + let message = errors + .map(error => { + // The `stack` property is not standardized, so we can't assume it exists + return typeof error.stack === 'string' ? cleanInternalStack(cleanStack(error.stack)) : String(error); + }) + .join('\n'); + message = '\n' + indentString(message, 4); + super(message); + + this.name = 'AggregateError'; + + Object.defineProperty(this, '_errors', {value: errors}); + } + + * [Symbol.iterator]() { + for (const error of this._errors) { + yield error; + } + } } +module.exports = AggregateError; + /***/ }), @@ -42831,7 +37217,7 @@ function handlePromise(promise, callback) { return promise.then(value => { invokeCallback(callback, null, value); }, err => { - invokeCallback(callback, err && err.message ? err : new Error(err)); + invokeCallback(callback, err && (err instanceof Error || err.message) ? err : new Error(err)); }); } @@ -42844,7 +37230,7 @@ function invokeCallback(callback, error, value) { }, err); } } -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43036,7 +37422,7 @@ function eachOf(coll, iteratee, callback) { } exports["default"] = (0, _awaitify2.default)(eachOf, 3); -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43047,7 +37433,7 @@ module.exports = exports['default']; Object.defineProperty(exports, "__esModule", ({ - value: true + value: true })); var _eachOfLimit2 = __nccwpck_require__(60092); @@ -43086,11 +37472,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @returns {Promise} a promise, if a callback is omitted */ function eachOfLimit(coll, limit, iteratee, callback) { - return (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback); + return (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback); } exports["default"] = (0, _awaitify2.default)(eachOfLimit, 4); -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43101,7 +37487,7 @@ module.exports = exports['default']; Object.defineProperty(exports, "__esModule", ({ - value: true + value: true })); var _eachOfLimit = __nccwpck_require__(85928); @@ -43133,10 +37519,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @returns {Promise} a promise, if a callback is omitted */ function eachOfSeries(coll, iteratee, callback) { - return (0, _eachOfLimit2.default)(coll, 1, iteratee, callback); + return (0, _eachOfLimit2.default)(coll, 1, iteratee, callback); } exports["default"] = (0, _awaitify2.default)(eachOfSeries, 3); -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43147,7 +37533,7 @@ module.exports = exports['default']; Object.defineProperty(exports, "__esModule", ({ - value: true + value: true })); var _eachOf = __nccwpck_require__(79173); @@ -43268,11 +37654,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * */ function eachLimit(coll, iteratee, callback) { - return (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback); + return (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback); } exports["default"] = (0, _awaitify2.default)(eachLimit, 3); -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43354,7 +37740,7 @@ function asyncEachOfLimit(generator, limit, iteratee, callback) { replenish(); } -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43370,7 +37756,8 @@ Object.defineProperty(exports, "__esModule", ({ exports["default"] = awaitify; // conditionally promisify a function. // only return a promise if a callback is omitted -function awaitify(asyncFn, arity = asyncFn.length) { +function awaitify(asyncFn, arity) { + if (!arity) arity = asyncFn.length; if (!arity) throw new Error('arity is undefined'); function awaitable(...args) { if (typeof args[arity - 1] === 'function') { @@ -43388,7 +37775,7 @@ function awaitify(asyncFn, arity = asyncFn.length) { return awaitable; } -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43399,13 +37786,13 @@ module.exports = exports['default']; Object.defineProperty(exports, "__esModule", ({ - value: true + value: true })); // A temporary value used to identify if the loop should be broken. // See #1064, #1293 const breakLoop = {}; exports["default"] = breakLoop; -module.exports = exports["default"]; +module.exports = exports.default; /***/ }), @@ -43502,7 +37889,7 @@ exports["default"] = limit => { }; }; -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43520,7 +37907,7 @@ exports["default"] = function (coll) { return coll[Symbol.iterator] && coll[Symbol.iterator](); }; -module.exports = exports["default"]; +module.exports = exports.default; /***/ }), @@ -43541,7 +37928,7 @@ exports["default"] = function (fn) { }; }; -module.exports = exports["default"]; +module.exports = exports.default; /***/ }), @@ -43558,7 +37945,7 @@ exports["default"] = isArrayLike; function isArrayLike(value) { return value && typeof value.length === 'number' && value.length >= 0 && value.length % 1 === 0; } -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43622,7 +38009,7 @@ function createIterator(coll) { var iterator = (0, _getIterator2.default)(coll); return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll); } -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43646,7 +38033,7 @@ function once(fn) { Object.assign(wrapper, fn); return wrapper; } -module.exports = exports["default"]; +module.exports = exports.default; /***/ }), @@ -43668,7 +38055,7 @@ function onlyOnce(fn) { callFn.apply(this, args); }; } -module.exports = exports["default"]; +module.exports = exports.default; /***/ }), @@ -43709,7 +38096,7 @@ exports["default"] = (0, _awaitify2.default)((eachfn, tasks, callback) => { }); }, err => callback(err, results)); }, 3); -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -43767,7 +38154,7 @@ exports["default"] = _withoutIndex; function _withoutIndex(iteratee) { return (value, index, callback) => iteratee(value, callback); } -module.exports = exports["default"]; +module.exports = exports.default; /***/ }), @@ -43819,7 +38206,7 @@ exports.isAsyncIterable = isAsyncIterable; Object.defineProperty(exports, "__esModule", ({ - value: true + value: true })); exports["default"] = series; @@ -43999,9 +38386,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * */ function series(tasks, callback) { - return (0, _parallel3.default)(_eachOfSeries2.default, tasks, callback); + return (0, _parallel3.default)(_eachOfSeries2.default, tasks, callback); } -module.exports = exports['default']; +module.exports = exports.default; /***/ }), @@ -46654,12 +41041,13 @@ module.exports = function callBoundIntrinsic(name, allowMissing) { var bind = __nccwpck_require__(41631); var GetIntrinsic = __nccwpck_require__(19253); +var setFunctionLength = __nccwpck_require__(8078); +var $TypeError = GetIntrinsic('%TypeError%'); var $apply = GetIntrinsic('%Function.prototype.apply%'); var $call = GetIntrinsic('%Function.prototype.call%'); var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply); -var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); var $defineProperty = GetIntrinsic('%Object.defineProperty%', true); var $max = GetIntrinsic('%Math.max%'); @@ -46673,19 +41061,15 @@ if ($defineProperty) { } module.exports = function callBind(originalFunction) { - var func = $reflectApply(bind, $call, arguments); - if ($gOPD && $defineProperty) { - var desc = $gOPD(func, 'length'); - if (desc.configurable) { - // original length, plus the receiver, minus any additional arguments (after the receiver) - $defineProperty( - func, - 'length', - { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) } - ); - } + if (typeof originalFunction !== 'function') { + throw new $TypeError('a function is required'); } - return func; + var func = $reflectApply(bind, $call, arguments); + return setFunctionLength( + func, + 1 + $max(0, originalFunction.length - (arguments.length - 1)), + true + ); }; var applyBind = function applyBind() { @@ -53503,163 +47887,98 @@ formatters.O = function (v) { /***/ }), -/***/ 21558: -/***/ ((module) => { - -"use strict"; +/***/ 58317: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +var clone = __nccwpck_require__(44619); -var isMergeableObject = function isMergeableObject(value) { - return isNonNullObject(value) - && !isSpecial(value) -}; +module.exports = function(options, defaults) { + options = options || {}; -function isNonNullObject(value) { - return !!value && typeof value === 'object' -} + Object.keys(defaults).forEach(function(key) { + if (typeof options[key] === 'undefined') { + options[key] = clone(defaults[key]); + } + }); -function isSpecial(value) { - var stringValue = Object.prototype.toString.call(value); + return options; +}; - return stringValue === '[object RegExp]' - || stringValue === '[object Date]' - || isReactElement(value) -} +/***/ }), -// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 -var canUseSymbol = typeof Symbol === 'function' && Symbol.for; -var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; +/***/ 3893: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -function isReactElement(value) { - return value.$$typeof === REACT_ELEMENT_TYPE -} +"use strict"; -function emptyTarget(val) { - return Array.isArray(val) ? [] : {} -} -function cloneUnlessOtherwiseSpecified(value, options) { - return (options.clone !== false && options.isMergeableObject(value)) - ? deepmerge(emptyTarget(value), value, options) - : value -} +var hasPropertyDescriptors = __nccwpck_require__(1943)(); -function defaultArrayMerge(target, source, options) { - return target.concat(source).map(function(element) { - return cloneUnlessOtherwiseSpecified(element, options) - }) -} +var GetIntrinsic = __nccwpck_require__(19253); -function getMergeFunction(key, options) { - if (!options.customMerge) { - return deepmerge +var $defineProperty = hasPropertyDescriptors && GetIntrinsic('%Object.defineProperty%', true); +if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + } catch (e) { + // IE 8 has a broken defineProperty + $defineProperty = false; } - var customMerge = options.customMerge(key); - return typeof customMerge === 'function' ? customMerge : deepmerge } -function getEnumerableOwnPropertySymbols(target) { - return Object.getOwnPropertySymbols - ? Object.getOwnPropertySymbols(target).filter(function(symbol) { - return Object.propertyIsEnumerable.call(target, symbol) - }) - : [] -} +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); -function getKeys(target) { - return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) -} +var gopd = __nccwpck_require__(22852); -function propertyIsOnObject(object, property) { - try { - return property in object - } catch(_) { - return false +/** @type {(obj: Record, property: PropertyKey, value: unknown, nonEnumerable?: boolean | null, nonWritable?: boolean | null, nonConfigurable?: boolean | null, loose?: boolean) => void} */ +module.exports = function defineDataProperty( + obj, + property, + value +) { + if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { + throw new $TypeError('`obj` must be an object or a function`'); } -} - -// Protects from prototype poisoning and unexpected merging up the prototype chain. -function propertyIsUnsafe(target, key) { - return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, - && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, - && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. -} - -function mergeObject(target, source, options) { - var destination = {}; - if (options.isMergeableObject(target)) { - getKeys(target).forEach(function(key) { - destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); - }); + if (typeof property !== 'string' && typeof property !== 'symbol') { + throw new $TypeError('`property` must be a string or a symbol`'); + } + if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { + throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); + } + if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { + throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); + } + if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { + throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); + } + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('`loose`, if provided, must be a boolean'); } - getKeys(source).forEach(function(key) { - if (propertyIsUnsafe(target, key)) { - return - } - - if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { - destination[key] = getMergeFunction(key, options)(target[key], source[key], options); - } else { - destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); - } - }); - return destination -} -function deepmerge(target, source, options) { - options = options || {}; - options.arrayMerge = options.arrayMerge || defaultArrayMerge; - options.isMergeableObject = options.isMergeableObject || isMergeableObject; - // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() - // implementations can use it. The caller may not replace it. - options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; + var nonEnumerable = arguments.length > 3 ? arguments[3] : null; + var nonWritable = arguments.length > 4 ? arguments[4] : null; + var nonConfigurable = arguments.length > 5 ? arguments[5] : null; + var loose = arguments.length > 6 ? arguments[6] : false; - var sourceIsArray = Array.isArray(source); - var targetIsArray = Array.isArray(target); - var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; + /* @type {false | TypedPropertyDescriptor} */ + var desc = !!gopd && gopd(obj, property); - if (!sourceAndTargetTypesMatch) { - return cloneUnlessOtherwiseSpecified(source, options) - } else if (sourceIsArray) { - return options.arrayMerge(target, source, options) + if ($defineProperty) { + $defineProperty(obj, property, { + configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, + enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, + value: value, + writable: nonWritable === null && desc ? desc.writable : !nonWritable + }); + } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { + // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable + obj[property] = value; // eslint-disable-line no-param-reassign } else { - return mergeObject(target, source, options) - } -} - -deepmerge.all = function deepmergeAll(array, options) { - if (!Array.isArray(array)) { - throw new Error('first argument should be an array') + throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); } - - return array.reduce(function(prev, next) { - return deepmerge(prev, next, options) - }, {}) }; -var deepmerge_1 = deepmerge; - -module.exports = deepmerge_1; - - -/***/ }), - -/***/ 58317: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -var clone = __nccwpck_require__(44619); - -module.exports = function(options, defaults) { - options = options || {}; - - Object.keys(defaults).forEach(function(key) { - if (typeof options[key] === 'undefined') { - options[key] = clone(defaults[key]); - } - }); - - return options; -}; /***/ }), @@ -53674,15 +47993,13 @@ var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbo var toStr = Object.prototype.toString; var concat = Array.prototype.concat; -var origDefineProperty = Object.defineProperty; +var defineDataProperty = __nccwpck_require__(3893); var isFunction = function (fn) { return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; }; -var hasPropertyDescriptors = __nccwpck_require__(1943)(); - -var supportsDescriptors = origDefineProperty && hasPropertyDescriptors; +var supportsDescriptors = __nccwpck_require__(1943)(); var defineProperty = function (object, name, value, predicate) { if (name in object) { @@ -53694,15 +48011,11 @@ var defineProperty = function (object, name, value, predicate) { return; } } + if (supportsDescriptors) { - origDefineProperty(object, name, { - configurable: true, - enumerable: false, - value: value, - writable: true - }); + defineDataProperty(object, name, value, true); } else { - object[name] = value; // eslint-disable-line no-param-reassign + defineDataProperty(object, name, value); } }; @@ -68249,6 +62562,7 @@ const semver = __nccwpck_require__(79707); const { getDBDestination } = __nccwpck_require__(71024); const shimmer = __nccwpck_require__(32924); +const kListenersAdded = Symbol('kListenersAdded'); // Match expected `:`, e.g. "mongo:27017", "::1:27017", // "127.0.0.1:27017". @@ -68256,7 +62570,7 @@ const HOSTNAME_PORT_RE = /^(.+):(\d+)$/; module.exports = (mongodb, agent, { version, enabled }) => { if (!enabled) return mongodb; - if (!semver.satisfies(version, '>=3.3 <6.0')) { + if (!semver.satisfies(version, '>=3.3 <7.0')) { agent.logger.debug( 'mongodb version %s not instrumented (mongodb <3.3 is instrumented via mongodb-core)', version, @@ -68291,6 +62605,7 @@ module.exports = (mongodb, agent, { version, enabled }) => { this.on('commandStarted', onStart); this.on('commandSucceeded', onEnd); this.on('commandFailed', onEnd); + this[kListenersAdded] = true; } } Object.defineProperty(mongodb, 'MongoClient', { @@ -68299,6 +62614,7 @@ module.exports = (mongodb, agent, { version, enabled }) => { return MongoClientTraced; }, }); + shimmer.wrap(mongodb.MongoClient, 'connect', wrapConnect); } else { agent.logger.warn('could not instrument mongodb@%s', version); @@ -68309,6 +62625,14 @@ module.exports = (mongodb, agent, { version, enabled }) => { // It calls back with `function (err, client)` or returns a Promise that // resolves to the client. // https://github.com/mongodb/node-mongodb-native/blob/v4.2.1/src/mongo_client.ts#L503-L511 + // + // From versions >=4.11.0 the method uses `new this` to create the client instance. Hence + // our `MongoClientTraced`'s constructor is used and the command listeners are already + // registered. We should check if the client has already added the listeners to avoid handling + // the same events twice + // NOTE: prefering to use a Symbol over version check since internal implementation may + // change in future versions + // https://github.com/mongodb/node-mongodb-native/blob/v4.11.0/src/mongo_client.ts#L618 function wrapConnect(origConnect) { return function wrappedConnect(url, options, callback) { if (typeof options === 'function') { @@ -68328,9 +62652,12 @@ module.exports = (mongodb, agent, { version, enabled }) => { if (err) { callback(err); } else { - client.on('commandStarted', onStart); - client.on('commandSucceeded', onEnd); - client.on('commandFailed', onEnd); + if (!client[kListenersAdded]) { + client.on('commandStarted', onStart); + client.on('commandSucceeded', onEnd); + client.on('commandFailed', onEnd); + client[kListenersAdded] = true; + } callback(err, client); } }, @@ -68338,9 +62665,12 @@ module.exports = (mongodb, agent, { version, enabled }) => { } else { const p = origConnect.call(this, url, options, callback); p.then((client) => { - client.on('commandStarted', onStart); - client.on('commandSucceeded', onEnd); - client.on('commandFailed', onEnd); + if (!client[kListenersAdded]) { + client.on('commandStarted', onStart); + client.on('commandSucceeded', onEnd); + client.on('commandFailed', onEnd); + client[kListenersAdded] = true; + } }); return p; } @@ -71589,7 +65919,15 @@ Span.prototype._inferServiceTargetAndDestinationService = function () { } } else if (this._http && this._http.url) { try { - this._serviceTarget.name = new URL(this._http.url).host; + const defaultPorts = { 'https:': '443', 'http:': '80' }; + const url = new URL(this._http.url); + if (!url.port && defaultPorts[url.protocol]) { + this._serviceTarget.name = `${url.host}:${ + defaultPorts[url.protocol] + }`; + } else { + this._serviceTarget.name = url.host; + } } catch (invalidUrlErr) { this._agent.logger.debug( 'cannot set "service.target.name": %s (ignoring)', @@ -84019,60 +78357,6 @@ var ExternalEditor = /** @class */ (function () { exports.ExternalEditor = ExternalEditor; -/***/ }), - -/***/ 5103: -/***/ ((module) => { - -"use strict"; - - -// do not edit .js files directly - edit src/index.jst - - - -module.exports = function equal(a, b) { - if (a === b) return true; - - if (a && b && typeof a == 'object' && typeof b == 'object') { - if (a.constructor !== b.constructor) return false; - - var length, i, keys; - if (Array.isArray(a)) { - length = a.length; - if (length != b.length) return false; - for (i = length; i-- !== 0;) - if (!equal(a[i], b[i])) return false; - return true; - } - - - - if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; - if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); - if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); - - keys = Object.keys(a); - length = keys.length; - if (length !== Object.keys(b).length) return false; - - for (i = length; i-- !== 0;) - if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; - - for (i = length; i-- !== 0;) { - var key = keys[i]; - - if (!equal(a[key], b[key])) return false; - } - - return true; - } - - // true if both NaN, false otherwise - return a!==a && b!==b; -}; - - /***/ }), /***/ 59652: @@ -85182,11 +79466,11 @@ const IS_WINDOWS_PLATFORM = os.platform() === 'win32'; const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\ /** * All non-escaped special characters. - * Posix: ()*?[\]{|}, !+@ before (, ! at the beginning, \\ before non-special characters. - * Windows: (){}, !+@ before (, ! at the beginning. + * Posix: ()*?[]{|}, !+@ before (, ! at the beginning, \\ before non-special characters. + * Windows: (){}[], !+@ before (, ! at the beginning. */ const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g; -const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([(){}]|^!|[!+@](?=\())/g; +const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g; /** * The device path (\\.\ or \\?\). * https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths @@ -85197,7 +79481,7 @@ const DOS_DEVICE_PATH_RE = /^\\\\([.?])/; * Windows: !()+@{} * https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions */ -const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@{}])/g; +const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g; /** * Designed to work only with simple paths: `dir\\file`. */ @@ -85385,7 +79669,7 @@ function expandPatternsWithBraceExpansion(patterns) { } exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion; function expandBraceExpansion(pattern) { - const patterns = micromatch.braces(pattern, { expand: true, nodupes: true }); + const patterns = micromatch.braces(pattern, { expand: true, nodupes: true, keepEscaping: true }); /** * Sort the patterns by length so that the same depth patterns are processed side by side. * `a/{b,}/{c,}/*` – `['a///*', 'a/b//*', 'a//c/*', 'a/b/c/*']` @@ -85483,3210 +79767,6 @@ function isEmpty(input) { exports.isEmpty = isEmpty; -/***/ }), - -/***/ 59034: -/***/ ((module) => { - -"use strict"; - - -module.exports = function (data, opts) { - if (!opts) opts = {}; - if (typeof opts === 'function') opts = { cmp: opts }; - var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false; - - var cmp = opts.cmp && (function (f) { - return function (node) { - return function (a, b) { - var aobj = { key: a, value: node[a] }; - var bobj = { key: b, value: node[b] }; - return f(aobj, bobj); - }; - }; - })(opts.cmp); - - var seen = []; - return (function stringify (node) { - if (node && node.toJSON && typeof node.toJSON === 'function') { - node = node.toJSON(); - } - - if (node === undefined) return; - if (typeof node == 'number') return isFinite(node) ? '' + node : 'null'; - if (typeof node !== 'object') return JSON.stringify(node); - - var i, out; - if (Array.isArray(node)) { - out = '['; - for (i = 0; i < node.length; i++) { - if (i) out += ','; - out += stringify(node[i]) || 'null'; - } - return out + ']'; - } - - if (node === null) return 'null'; - - if (seen.indexOf(node) !== -1) { - if (cycles) return JSON.stringify('__cycle__'); - throw new TypeError('Converting circular structure to JSON'); - } - - var seenIndex = seen.push(node) - 1; - var keys = Object.keys(node).sort(cmp && cmp(node)); - out = ''; - for (i = 0; i < keys.length; i++) { - var key = keys[i]; - var value = stringify(node[key]); - - if (!value) continue; - if (out) out += ','; - out += JSON.stringify(key) + ':' + value; - } - seen.splice(seenIndex, 1); - return '{' + out + '}'; - })(data); -}; - - -/***/ }), - -/***/ 87613: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -/* eslint no-prototype-builtins: 0 */ - -const Ajv = __nccwpck_require__(65486) -const merge = __nccwpck_require__(21558) -const clone = __nccwpck_require__(44608)({ proto: true }) -const fjsCloned = Symbol('fast-json-stringify.cloned') - -const validate = __nccwpck_require__(49194) -let stringSimilarity = null - -let isLong -try { - isLong = (__nccwpck_require__(91128).isLong) -} catch (e) { - isLong = null -} - -const addComma = ` - if (addComma) { - json += ',' - } else { - addComma = true - } -` - -function isValidSchema (schema, name) { - if (!validate(schema)) { - if (name) { - name = `"${name}" ` - } else { - name = '' - } - const first = validate.errors[0] - const err = new Error(`${name}schema is invalid: data${first.dataPath} ${first.message}`) - err.errors = isValidSchema.errors - throw err - } -} - -function mergeLocation (source, dest) { - return { - schema: dest.schema || source.schema, - root: dest.root || source.root, - externalSchema: dest.externalSchema || source.externalSchema - } -} - -const arrayItemsReferenceSerializersMap = new Map() -const objectReferenceSerializersMap = new Map() - -function build (schema, options) { - arrayItemsReferenceSerializersMap.clear() - objectReferenceSerializersMap.clear() - options = options || {} - isValidSchema(schema) - if (options.schema) { - // eslint-disable-next-line - for (var key of Object.keys(options.schema)) { - isValidSchema(options.schema[key], key) - } - } - - let intParseFunctionName = 'trunc' - if (options.rounding) { - if (['floor', 'ceil', 'round'].includes(options.rounding)) { - intParseFunctionName = options.rounding - } else { - throw new Error(`Unsupported integer rounding method ${options.rounding}`) - } - } - - /* eslint no-new-func: "off" */ - let code = ` - 'use strict' - ` - - code += ` - ${asFunctions} - - var isLong = ${isLong ? isLong.toString() : false} - - function parseInteger(int) { return Math.${intParseFunctionName}(int) } - ` - - let location = { - schema, - root: schema, - externalSchema: options.schema - } - - if (schema.$ref) { - location = refFinder(schema.$ref, location) - schema = location.schema - } - - if (schema.type === undefined) { - schema.type = inferTypeByKeyword(schema) - } - - let main - - switch (schema.type) { - case 'object': - main = '$main' - code = buildObject(location, code, main) - break - case 'string': - main = schema.nullable ? '$asStringNullable' : getStringSerializer(schema.format) - break - case 'integer': - main = schema.nullable ? '$asIntegerNullable' : '$asInteger' - break - case 'number': - main = schema.nullable ? '$asNumberNullable' : '$asNumber' - break - case 'boolean': - main = schema.nullable ? '$asBooleanNullable' : '$asBoolean' - break - case 'null': - main = '$asNull' - break - case 'array': - main = '$main' - code = buildArray(location, code, main) - schema = location.schema - break - case undefined: - main = '$asAny' - break - default: - throw new Error(`${schema.type} unsupported`) - } - - code += ` - ; - return ${main} - ` - - const dependencies = [new Ajv(options.ajv)] - const dependenciesName = ['ajv'] - dependenciesName.push(code) - - if (options.debugMode) { - dependenciesName.toString = function () { - return dependenciesName.join('\n') - } - return dependenciesName - } - - arrayItemsReferenceSerializersMap.clear() - objectReferenceSerializersMap.clear() - - return (Function.apply(null, dependenciesName).apply(null, dependencies)) -} - -const objectKeywords = [ - 'maxProperties', - 'minProperties', - 'required', - 'properties', - 'patternProperties', - 'additionalProperties', - 'dependencies' -] - -const arrayKeywords = [ - 'items', - 'additionalItems', - 'maxItems', - 'minItems', - 'uniqueItems', - 'contains' -] - -const stringKeywords = [ - 'maxLength', - 'minLength', - 'pattern' -] - -const numberKeywords = [ - 'multipleOf', - 'maximum', - 'exclusiveMaximum', - 'minimum', - 'exclusiveMinimum' -] - -/** - * Infer type based on keyword in order to generate optimized code - * https://json-schema.org/latest/json-schema-validation.html#rfc.section.6 - */ -function inferTypeByKeyword (schema) { - // eslint-disable-next-line - for (var keyword of objectKeywords) { - if (keyword in schema) return 'object' - } - // eslint-disable-next-line - for (var keyword of arrayKeywords) { - if (keyword in schema) return 'array' - } - // eslint-disable-next-line - for (var keyword of stringKeywords) { - if (keyword in schema) return 'string' - } - // eslint-disable-next-line - for (var keyword of numberKeywords) { - if (keyword in schema) return 'number' - } - return schema.type -} - -const stringSerializerMap = { - 'date-time': '$asDatetime', - date: '$asDate', - time: '$asTime' -} - -function getStringSerializer (format) { - return stringSerializerMap[format] || - '$asString' -} - -function getTestSerializer (format) { - return stringSerializerMap[format] -} - -const asFunctions = ` -function $pad2Zeros (num) { - const s = '00' + num - return s[s.length - 2] + s[s.length - 1] -} - -function $asAny (i) { - return JSON.stringify(i) -} - -function $asNull () { - return 'null' -} - -function $asInteger (i) { - if (isLong && isLong(i)) { - return i.toString() - } else if (typeof i === 'bigint') { - return i.toString() - } else if (Number.isInteger(i)) { - return $asNumber(i) - } else { - /* eslint no-undef: "off" */ - return $asNumber(parseInteger(i)) - } -} - -function $asIntegerNullable (i) { - return i === null ? null : $asInteger(i) -} - -function $asNumber (i) { - const num = Number(i) - if (isNaN(num)) { - return 'null' - } else { - return '' + num - } -} - -function $asNumberNullable (i) { - return i === null ? null : $asNumber(i) -} - -function $asBoolean (bool) { - return bool && 'true' || 'false' // eslint-disable-line -} - -function $asBooleanNullable (bool) { - return bool === null ? null : $asBoolean(bool) -} - -function $asDatetime (date, skipQuotes) { - const quotes = skipQuotes === true ? '' : '"' - if (date instanceof Date) { - return quotes + date.toISOString() + quotes - } else if (date && typeof date.toISOString === 'function') { - return quotes + date.toISOString() + quotes - } else { - return $asString(date, skipQuotes) - } -} - -function $asDate (date, skipQuotes) { - const quotes = skipQuotes === true ? '' : '"' - if (date instanceof Date) { - return quotes + new Date(date.getTime() - (date.getTimezoneOffset() * 60000 )).toISOString().slice(0, 10) + quotes - } else if (date && typeof date.format === 'function') { - return quotes + date.format('YYYY-MM-DD') + quotes - } else { - return $asString(date, skipQuotes) - } -} - -function $asTime (date, skipQuotes) { - const quotes = skipQuotes === true ? '' : '"' - if (date instanceof Date) { - const hour = new Intl.DateTimeFormat('en', { hour: 'numeric', hour12: false }).format(date) - const minute = new Intl.DateTimeFormat('en', { minute: 'numeric' }).format(date) - const second = new Intl.DateTimeFormat('en', { second: 'numeric' }).format(date) - return quotes + $pad2Zeros(hour) + ':' + $pad2Zeros(minute) + ':' + $pad2Zeros(second) + quotes - } else if (date && typeof date.format === 'function') { - return quotes + date.format('HH:mm:ss') + quotes - } else { - return $asString(date, skipQuotes) - } -} - -function $asString (str, skipQuotes) { - const quotes = skipQuotes === true ? '' : '"' - if (str instanceof Date) { - return quotes + str.toISOString() + quotes - } else if (str === null) { - return quotes + quotes - } else if (str instanceof RegExp) { - str = str.source - } else if (typeof str !== 'string') { - str = str.toString() - } - // If we skipQuotes it means that we are using it as test - // no need to test the string length for the render - if (skipQuotes) { - return str - } - - if (str.length < 42) { - return $asStringSmall(str) - } else { - return JSON.stringify(str) - } -} - -function $asStringNullable (str) { - return str === null ? null : $asString(str) -} - -// magically escape strings for json -// relying on their charCodeAt -// everything below 32 needs JSON.stringify() -// every string that contain surrogate needs JSON.stringify() -// 34 and 92 happens all the time, so we -// have a fast case for them -function $asStringSmall (str) { - const l = str.length - let result = '' - let last = 0 - let found = false - let surrogateFound = false - let point = 255 - // eslint-disable-next-line - for (var i = 0; i < l && point >= 32; i++) { - point = str.charCodeAt(i) - if (point >= 0xD800 && point <= 0xDFFF) { - // The current character is a surrogate. - surrogateFound = true - } - if (point === 34 || point === 92) { - result += str.slice(last, i) + '\\\\' - last = i - found = true - } - } - - if (!found) { - result = str - } else { - result += str.slice(last) - } - return ((point < 32) || (surrogateFound === true)) ? JSON.stringify(str) : '"' + result + '"' -} -` - -function addPatternProperties (location) { - const schema = location.schema - const pp = schema.patternProperties - let code = ` - var properties = ${JSON.stringify(schema.properties)} || {} - var keys = Object.keys(obj) - for (var i = 0; i < keys.length; i++) { - if (properties[keys[i]]) continue - ` - Object.keys(pp).forEach((regex, index) => { - let ppLocation = mergeLocation(location, { schema: pp[regex] }) - if (pp[regex].$ref) { - ppLocation = refFinder(pp[regex].$ref, location) - pp[regex] = ppLocation.schema - } - const type = pp[regex].type - const format = pp[regex].format - const stringSerializer = getStringSerializer(format) - try { - RegExp(regex) - } catch (err) { - throw new Error(`${err.message}. Found at ${regex} matching ${JSON.stringify(pp[regex])}`) - } - - const ifPpKeyExists = `if (/${regex.replace(/\\*\//g, '\\/')}/.test(keys[i])) {` - - if (type === 'object') { - code += `${buildObject(ppLocation, '', 'buildObjectPP' + index)} - ${ifPpKeyExists} - ${addComma} - json += $asString(keys[i]) + ':' + buildObjectPP${index}(obj[keys[i]]) - ` - } else if (type === 'array') { - code += `${buildArray(ppLocation, '', 'buildArrayPP' + index)} - ${ifPpKeyExists} - ${addComma} - json += $asString(keys[i]) + ':' + buildArrayPP${index}(obj[keys[i]]) - ` - } else if (type === 'null') { - code += ` - ${ifPpKeyExists} - ${addComma} - json += $asString(keys[i]) +':null' - ` - } else if (type === 'string') { - code += ` - ${ifPpKeyExists} - ${addComma} - json += $asString(keys[i]) + ':' + ${stringSerializer}(obj[keys[i]]) - ` - } else if (type === 'integer') { - code += ` - ${ifPpKeyExists} - ${addComma} - json += $asString(keys[i]) + ':' + $asInteger(obj[keys[i]]) - ` - } else if (type === 'number') { - code += ` - ${ifPpKeyExists} - ${addComma} - json += $asString(keys[i]) + ':' + $asNumber(obj[keys[i]]) - ` - } else if (type === 'boolean') { - code += ` - ${ifPpKeyExists} - ${addComma} - json += $asString(keys[i]) + ':' + $asBoolean(obj[keys[i]]) - ` - } else if (type === undefined) { - code += ` - ${ifPpKeyExists} - ${addComma} - json += $asString(keys[i]) + ':' + $asAny(obj[keys[i]]) - ` - } else { - code += ` - ${ifPpKeyExists} - throw new Error('Cannot coerce ' + obj[keys[i]] + ' to ' + ${JSON.stringify(type)}) - ` - } - - code += ` - continue - } - ` - }) - if (schema.additionalProperties) { - code += additionalProperty(location) - } - - code += ` - } - ` - return code -} - -function additionalProperty (location) { - let ap = location.schema.additionalProperties - let code = '' - if (ap === true) { - return ` - if (obj[keys[i]] !== undefined && typeof obj[keys[i]] !== 'function' && typeof obj[keys[i]] !== 'symbol') { - ${addComma} - json += $asString(keys[i]) + ':' + JSON.stringify(obj[keys[i]]) - } - ` - } - let apLocation = mergeLocation(location, { schema: ap }) - if (ap.$ref) { - apLocation = refFinder(ap.$ref, location) - ap = apLocation.schema - } - - const type = ap.type - const format = ap.format - const stringSerializer = getStringSerializer(format) - if (type === 'object') { - code += `${buildObject(apLocation, '', 'buildObjectAP')} - ${addComma} - json += $asString(keys[i]) + ':' + buildObjectAP(obj[keys[i]]) - ` - } else if (type === 'array') { - code += `${buildArray(apLocation, '', 'buildArrayAP')} - ${addComma} - json += $asString(keys[i]) + ':' + buildArrayAP(obj[keys[i]]) - ` - } else if (type === 'null') { - code += ` - ${addComma} - json += $asString(keys[i]) +':null' - ` - } else if (type === 'string') { - code += ` - ${addComma} - json += $asString(keys[i]) + ':' + ${stringSerializer}(obj[keys[i]]) - ` - } else if (type === 'integer') { - code += ` - var t = Number(obj[keys[i]]) - ` - if (isLong) { - code += ` - if (isLong(obj[keys[i]]) || !isNaN(t)) { - ${addComma} - json += $asString(keys[i]) + ':' + $asInteger(obj[keys[i]]) - } - ` - } else { - code += ` - if (!isNaN(t)) { - ${addComma} - json += $asString(keys[i]) + ':' + t - } - ` - } - } else if (type === 'number') { - code += ` - var t = Number(obj[keys[i]]) - if (!isNaN(t)) { - ${addComma} - json += $asString(keys[i]) + ':' + t - } - ` - } else if (type === 'boolean') { - code += ` - ${addComma} - json += $asString(keys[i]) + ':' + $asBoolean(obj[keys[i]]) - ` - } else if (type === undefined) { - code += ` - ${addComma} - json += $asString(keys[i]) + ':' + $asAny(obj[keys[i]]) - ` - } else { - code += ` - throw new Error('Cannot coerce ' + obj[keys[i]] + ' to ' + ${JSON.stringify(type)}) - ` - } - return code -} - -function addAdditionalProperties (location) { - return ` - var properties = ${JSON.stringify(location.schema.properties)} || {} - var keys = Object.keys(obj) - for (var i = 0; i < keys.length; i++) { - if (properties[keys[i]]) continue - ${additionalProperty(location)} - } - ` -} - -function idFinder (schema, searchedId) { - let objSchema - const explore = (schema, searchedId) => { - Object.keys(schema || {}).forEach((key, i, a) => { - if (key === '$id' && schema[key] === searchedId) { - objSchema = schema - } else if (objSchema === undefined && typeof schema[key] === 'object') { - explore(schema[key], searchedId) - } - }) - } - explore(schema, searchedId) - return objSchema -} - -function refFinder (ref, location) { - const externalSchema = location.externalSchema - let root = location.root - let schema = location.schema - - if (externalSchema && externalSchema[ref]) { - return { - schema: externalSchema[ref], - root: externalSchema[ref], - externalSchema: externalSchema - } - } - - // Split file from walk - ref = ref.split('#') - - // If external file - if (ref[0]) { - schema = externalSchema[ref[0]] - root = externalSchema[ref[0]] - - if (schema === undefined) { - findBadKey(externalSchema, [ref[0]]) - } - - if (schema.$ref) { - return refFinder(schema.$ref, { - schema: schema, - root: root, - externalSchema: externalSchema - }) - } - } - - let code = 'return schema' - // If it has a path - if (ref[1]) { - // ref[1] could contain a JSON pointer - ex: /definitions/num - // or plain name fragment id without suffix # - ex: customId - const walk = ref[1].split('/') - if (walk.length === 1) { - const targetId = `#${ref[1]}` - let dereferenced = idFinder(schema, targetId) - if (dereferenced === undefined && !ref[0]) { - // eslint-disable-next-line - for (var key of Object.keys(externalSchema)) { - dereferenced = idFinder(externalSchema[key], targetId) - if (dereferenced !== undefined) { - root = externalSchema[key] - break - } - } - } - - return { - schema: dereferenced, - root: root, - externalSchema: externalSchema - } - } else { - // eslint-disable-next-line - for (var i = 1; i < walk.length; i++) { - code += `[${JSON.stringify(walk[i])}]` - } - } - } - let result - try { - result = (new Function('schema', code))(root) - } catch (err) {} - - if (result === undefined && ref[1]) { - const walk = ref[1].split('/') - findBadKey(schema, walk.slice(1)) - } - - if (result.$ref) { - return refFinder(result.$ref, { - schema: schema, - root: root, - externalSchema: externalSchema - }) - } - - return { - schema: result, - root: root, - externalSchema: externalSchema - } - - function findBadKey (obj, keys) { - if (keys.length === 0) return null - const key = keys.shift() - if (obj[key] === undefined) { - stringSimilarity = stringSimilarity || __nccwpck_require__(74649) - const { bestMatch } = stringSimilarity.findBestMatch(key, Object.keys(obj)) - if (bestMatch.rating >= 0.5) { - throw new Error(`Cannot find reference ${JSON.stringify(key)}, did you mean ${JSON.stringify(bestMatch.target)}?`) - } else { - throw new Error(`Cannot find reference ${JSON.stringify(key)}`) - } - } - return findBadKey(obj[key], keys) - } -} - -function buildCode (location, code, laterCode, name) { - if (location.schema.$ref) { - location = refFinder(location.schema.$ref, location) - } - - const schema = location.schema - let required = schema.required - - Object.keys(schema.properties || {}).forEach((key, i, a) => { - let propertyLocation = mergeLocation(location, { schema: schema.properties[key] }) - if (schema.properties[key].$ref) { - propertyLocation = refFinder(schema.properties[key].$ref, location) - schema.properties[key] = propertyLocation.schema - } - - // Using obj['key'] !== undefined instead of obj.hasOwnProperty(prop) for perf reasons, - // see https://github.com/mcollina/fast-json-stringify/pull/3 for discussion. - - const type = schema.properties[key].type - const nullable = schema.properties[key].nullable - const sanitized = JSON.stringify(key) - const asString = JSON.stringify(sanitized) - - if (nullable) { - code += ` - if (obj[${sanitized}] === null) { - ${addComma} - json += ${asString} + ':null' - var rendered = true - } else { - ` - } - - if (type === 'number') { - code += ` - var t = Number(obj[${sanitized}]) - if (!isNaN(t)) { - ${addComma} - json += ${asString} + ':' + t - ` - } else if (type === 'integer') { - code += ` - var rendered = false - ` - if (isLong) { - code += ` - if (isLong(obj[${sanitized}])) { - ${addComma} - json += ${asString} + ':' + obj[${sanitized}].toString() - rendered = true - } else { - var t = Number(obj[${sanitized}]) - if (!isNaN(t)) { - ${addComma} - json += ${asString} + ':' + t - rendered = true - } - } - ` - } else { - code += ` - var t = $asInteger(obj[${sanitized}]) - if (!isNaN(t)) { - ${addComma} - json += ${asString} + ':' + t - rendered = true - } - ` - } - code += ` - if (rendered) { - ` - } else { - code += ` - if (obj[${sanitized}] !== undefined) { - ${addComma} - json += ${asString} + ':' - ` - - const result = nested(laterCode, name, key, mergeLocation(propertyLocation, { schema: schema.properties[key] }), undefined, false) - code += result.code - laterCode = result.laterCode - } - - const defaultValue = schema.properties[key].default - if (defaultValue !== undefined) { - required = filterRequired(required, key) - code += ` - } else { - ${addComma} - json += ${asString} + ':' + ${JSON.stringify(JSON.stringify(defaultValue))} - ` - } else if (required && required.indexOf(key) !== -1) { - required = filterRequired(required, key) - code += ` - } else { - throw new Error('${sanitized} is required!') - ` - } - - code += ` - } - ` - - if (nullable) { - code += ` - } - ` - } - }) - - if (required && required.length > 0) { - code += 'var required = [' - // eslint-disable-next-line - for (var i = 0; i < required.length; i++) { - if (i > 0) { - code += ',' - } - code += `${JSON.stringify(required[i])}` - } - code += `] - for (var i = 0; i < required.length; i++) { - if (obj[required[i]] === undefined) throw new Error('"' + required[i] + '" is required!') - } - ` - } - - if (schema.allOf) { - const builtCode = buildCodeWithAllOfs(location, code, laterCode, name) - code = builtCode.code - laterCode = builtCode.laterCode - } - - return { code: code, laterCode: laterCode } -} - -function filterRequired (required, key) { - if (!required) { - return required - } - return required.filter(k => k !== key) -} - -function buildCodeWithAllOfs (location, code, laterCode, name) { - if (location.schema.allOf) { - location.schema.allOf.forEach((ss) => { - const builtCode = buildCodeWithAllOfs(mergeLocation(location, { schema: ss }), code, laterCode, name) - code = builtCode.code - laterCode = builtCode.laterCode - }) - } else { - const builtCode = buildCode(location, code, laterCode, name) - - code = builtCode.code - laterCode = builtCode.laterCode - } - - return { code: code, laterCode: laterCode } -} - -function buildInnerObject (location, name) { - const schema = location.schema - const result = buildCodeWithAllOfs(location, '', '', name) - if (schema.patternProperties) { - result.code += addPatternProperties(location) - } else if (schema.additionalProperties && !schema.patternProperties) { - result.code += addAdditionalProperties(location) - } - return result -} - -function addIfThenElse (location, name) { - let code = '' - let r - let laterCode = '' - let innerR - - const schema = location.schema - const copy = merge({}, schema) - const i = copy.if - const then = copy.then - const e = copy.else ? copy.else : { additionalProperties: true } - delete copy.if - delete copy.then - delete copy.else - let merged = merge(copy, then) - let mergedLocation = mergeLocation(location, { schema: merged }) - - code += ` - valid = ajv.validate(${JSON.stringify(i)}, obj) - if (valid) { - ` - if (merged.if && merged.then) { - innerR = addIfThenElse(mergedLocation, name + 'Then') - code += innerR.code - laterCode = innerR.laterCode - } - - r = buildInnerObject(mergedLocation, name + 'Then') - code += r.code - laterCode += r.laterCode - - code += ` - } - ` - merged = merge(copy, e) - mergedLocation = mergeLocation(mergedLocation, { schema: merged }) - - code += ` - else { - ` - - if (merged.if && merged.then) { - innerR = addIfThenElse(mergedLocation, name + 'Else') - code += innerR.code - laterCode += innerR.laterCode - } - - r = buildInnerObject(mergedLocation, name + 'Else') - code += r.code - laterCode += r.laterCode - - code += ` - } - ` - return { code: code, laterCode: laterCode } -} - -function toJSON (variableName) { - return `(${variableName} && typeof ${variableName}.toJSON === 'function') - ? ${variableName}.toJSON() - : ${variableName} - ` -} - -function buildObject (location, code, name) { - const schema = location.schema - - code += ` - function ${name} (input) { - ` - if (schema.nullable) { - code += ` - if(input === null) { - return 'null'; - } - ` - } - - if (objectReferenceSerializersMap.has(schema)) { - code += ` - return ${objectReferenceSerializersMap.get(schema)}(input) - } - ` - return code - } - objectReferenceSerializersMap.set(schema, name) - - code += ` - var obj = ${toJSON('input')} - var json = '{' - var addComma = false - ` - - let r - if (schema.if && schema.then) { - code += ` - var valid - ` - r = addIfThenElse(location, name) - } else { - r = buildInnerObject(location, name) - } - - // Removes the comma if is the last element of the string (in case there are not properties) - code += `${r.code} - json += '}' - return json - } - ${r.laterCode} - ` - - return code -} - -function buildArray (location, code, name, key = null) { - let schema = location.schema - code += ` - function ${name} (obj) { - ` - if (schema.nullable) { - code += ` - if(obj === null) { - return 'null'; - } - ` - } - const laterCode = '' - - // default to any items type - if (!schema.items) { - schema.items = {} - } - - if (schema.items.$ref) { - if (!schema[fjsCloned]) { - location.schema = clone(location.schema) - schema = location.schema - schema[fjsCloned] = true - } - - location = refFinder(schema.items.$ref, location) - schema.items = location.schema - - if (arrayItemsReferenceSerializersMap.has(schema.items)) { - code += ` - return ${arrayItemsReferenceSerializersMap.get(schema.items)}(obj) - } - ` - return code - } - arrayItemsReferenceSerializersMap.set(schema.items, name) - } - - let result = { code: '', laterCode: '' } - const accessor = '[i]' - if (Array.isArray(schema.items)) { - result = schema.items.reduce((res, item, i) => { - const tmpRes = nested(laterCode, name, accessor, mergeLocation(location, { schema: item }), i, true) - const condition = `i === ${i} && ${buildArrayTypeCondition(item.type, accessor)}` - return { - code: `${res.code} - ${i > 0 ? 'else' : ''} if (${condition}) { - ${tmpRes.code} - }`, - laterCode: `${res.laterCode} - ${tmpRes.laterCode}` - } - }, result) - - if (schema.additionalItems) { - const tmpRes = nested(laterCode, name, accessor, mergeLocation(location, { schema: schema.items }), undefined, true) - result.code += ` - else if (i >= ${schema.items.length}) { - ${tmpRes.code} - } - ` - } - - result.code += ` - else { - throw new Error(\`Item at $\{i} does not match schema definition.\`) - } - ` - } else { - result = nested(laterCode, name, accessor, mergeLocation(location, { schema: schema.items }), undefined, true) - } - - if (key) { - code += ` - if(!Array.isArray(obj)) { - throw new TypeError(\`Property '${key}' should be of type array, received '$\{obj}' instead.\`) - } - ` - } - - code += ` - var l = obj.length - var jsonOutput= '' - for (var i = 0; i < l; i++) { - var json = '' - ${result.code} - jsonOutput += json - - if (json.length > 0 && i < l - 1) { - jsonOutput += ',' - } - } - return \`[\${jsonOutput}]\` - } - ${result.laterCode} - ` - - return code -} - -function buildArrayTypeCondition (type, accessor) { - let condition - switch (type) { - case 'null': - condition = `obj${accessor} === null` - break - case 'string': - condition = `typeof obj${accessor} === 'string'` - break - case 'integer': - condition = `Number.isInteger(obj${accessor})` - break - case 'number': - condition = `Number.isFinite(obj${accessor})` - break - case 'boolean': - condition = `typeof obj${accessor} === 'boolean'` - break - case 'object': - condition = `obj${accessor} && typeof obj${accessor} === 'object' && obj${accessor}.constructor === Object` - break - case 'array': - condition = `Array.isArray(obj${accessor})` - break - default: - if (Array.isArray(type)) { - const conditions = type.map((subType) => { - return buildArrayTypeCondition(subType, accessor) - }) - condition = `(${conditions.join(' || ')})` - } else { - throw new Error(`${type} unsupported`) - } - } - return condition -} - -function dereferenceOfRefs (location, type) { - if (!location.schema[fjsCloned]) { - const schemaClone = clone(location.schema) - schemaClone[fjsCloned] = true - location.schema = schemaClone - } - - const schema = location.schema - const locations = [] - - schema[type].forEach((s, index) => { - // follow the refs - let sLocation = mergeLocation(location, { schema: s }) - while (s.$ref) { - sLocation = refFinder(s.$ref, sLocation) - schema[type][index] = sLocation.schema - s = schema[type][index] - } - locations[index] = sLocation - }) - - return locations -} - -let strNameCounter = 0 -function asFuncName (str) { - // only allow chars that can work - let rep = str.replace(/[^a-zA-Z0-9$_]/g, '') - - if (rep.length === 0) { - return 'anan' + strNameCounter++ - } else if (rep !== str) { - rep += strNameCounter++ - } - - return rep -} - -function nested (laterCode, name, key, location, subKey, isArray) { - let code = '' - let funcName - - subKey = subKey || '' - - let schema = location.schema - - if (schema.$ref) { - schema = refFinder(schema.$ref, location) - } - - if (schema.type === undefined) { - const inferredType = inferTypeByKeyword(schema) - if (inferredType) { - schema.type = inferredType - } - } - - const type = schema.type - const nullable = schema.nullable === true - - const accessor = isArray ? key : `[${JSON.stringify(key)}]` - - switch (type) { - case 'null': - code += ` - json += $asNull() - ` - break - case 'string': { - const stringSerializer = getStringSerializer(schema.format) - code += nullable ? `json += obj${accessor} === null ? null : ${stringSerializer}(obj${accessor})` : `json += ${stringSerializer}(obj${accessor})` - break - } - case 'integer': - code += nullable ? `json += obj${accessor} === null ? null : $asInteger(obj${accessor})` : `json += $asInteger(obj${accessor})` - break - case 'number': - code += nullable ? `json += obj${accessor} === null ? null : $asNumber(obj${accessor})` : `json += $asNumber(obj${accessor})` - break - case 'boolean': - code += nullable ? `json += obj${accessor} === null ? null : $asBoolean(obj${accessor})` : `json += $asBoolean(obj${accessor})` - break - case 'object': - funcName = asFuncName(name + key + subKey) - laterCode = buildObject(location, laterCode, funcName) - code += ` - json += ${funcName}(obj${accessor}) - ` - break - case 'array': - funcName = asFuncName('$arr' + name + key + subKey) // eslint-disable-line - laterCode = buildArray(location, laterCode, funcName, key) - code += ` - json += ${funcName}(obj${accessor}) - ` - break - case undefined: - if ('anyOf' in schema) { - // beware: dereferenceOfRefs has side effects and changes schema.anyOf - const anyOfLocations = dereferenceOfRefs(location, 'anyOf') - anyOfLocations.forEach((location, index) => { - const nestedResult = nested(laterCode, name, key, location, subKey !== '' ? subKey : 'i' + index, isArray) - // We need a test serializer as the String serializer will not work with - // date/time ajv validations - // see: https://github.com/fastify/fast-json-stringify/issues/325 - const testSerializer = getTestSerializer(location.schema.format) - const testValue = testSerializer !== undefined ? `${testSerializer}(obj${accessor}, true)` : `obj${accessor}` - - // Since we are only passing the relevant schema to ajv.validate, it needs to be full dereferenced - // otherwise any $ref pointing to an external schema would result in an error. - // Full dereference of the schema happens as side effect of two functions: - // 1. `dereferenceOfRefs` loops through the `schema.anyOf`` array and replaces any top level reference - // with the actual schema - // 2. `nested`, through `buildCode`, replaces any reference in object properties with the actual schema - // (see https://github.com/fastify/fast-json-stringify/blob/6da3b3e8ac24b1ca5578223adedb4083b7adf8db/index.js#L631) - code += ` - ${index === 0 ? 'if' : 'else if'}(ajv.validate(${JSON.stringify(location.schema)}, ${testValue})) - ${nestedResult.code} - ` - laterCode = nestedResult.laterCode - }) - code += ` - else json+= null - ` - } else if ('oneOf' in schema) { - // beware: dereferenceOfRefs has side effects and changes schema.oneOf - const oneOfLocations = dereferenceOfRefs(location, 'oneOf') - oneOfLocations.forEach((location, index) => { - const nestedResult = nested(laterCode, name, key, location, subKey !== '' ? subKey : 'i' + index, isArray) - const testSerializer = getTestSerializer(location.schema.format) - const testValue = testSerializer !== undefined ? `${testSerializer}(obj${accessor}, true)` : `obj${accessor}` - // see comment on anyOf about dereferencing the schema before calling ajv.validate - code += ` - ${index === 0 ? 'if' : 'else if'}(ajv.validate(${JSON.stringify(location.schema)}, ${testValue})) - ${nestedResult.code} - ` - laterCode = nestedResult.laterCode - }) - - if (!isArray) { - code += ` - else json+= null - ` - } - } else if (isEmpty(schema)) { - code += ` - json += JSON.stringify(obj${accessor}) - ` - } else if ('const' in schema) { - code += ` - if(ajv.validate(${JSON.stringify(schema)}, obj${accessor})) - json += '${JSON.stringify(schema.const)}' - else - throw new Error(\`Item $\{JSON.stringify(obj${accessor})} does not match schema definition.\`) - ` - } else if (schema.type === undefined) { - code += ` - json += JSON.stringify(obj${accessor}) - ` - } else { - throw new Error(`${schema.type} unsupported`) - } - break - default: - if (Array.isArray(type)) { - const nullIndex = type.indexOf('null') - const sortedTypes = nullIndex !== -1 ? [type[nullIndex]].concat(type.slice(0, nullIndex)).concat(type.slice(nullIndex + 1)) : type - sortedTypes.forEach((type, index) => { - const statement = index === 0 ? 'if' : 'else if' - const tempSchema = Object.assign({}, schema, { type }) - const nestedResult = nested(laterCode, name, key, mergeLocation(location, { schema: tempSchema }), subKey, isArray) - switch (type) { - case 'string': { - code += ` - ${statement}(obj${accessor} === null || typeof obj${accessor} === "${type}" || obj${accessor} instanceof Date || typeof obj${accessor}.toISOString === "function" || obj${accessor} instanceof RegExp || (typeof obj${accessor} === "object" && Object.hasOwnProperty.call(obj${accessor}, "toString"))) - ${nestedResult.code} - ` - break - } - case 'null': { - code += ` - ${statement}(obj${accessor} == null) - ${nestedResult.code} - ` - break - } - case 'array': { - code += ` - ${statement}(Array.isArray(obj${accessor})) - ${nestedResult.code} - ` - break - } - case 'integer': { - code += ` - ${statement}(Number.isInteger(obj${accessor}) || obj${accessor} === null) - ${nestedResult.code} - ` - break - } - case 'number': { - code += ` - ${statement}(isNaN(obj${accessor}) === false) - ${nestedResult.code} - ` - break - } - default: { - code += ` - ${statement}(typeof obj${accessor} === "${type}") - ${nestedResult.code} - ` - break - } - } - laterCode = nestedResult.laterCode - }) - code += ` - else json+= null - ` - } else { - throw new Error(`${type} unsupported`) - } - } - - return { - code, - laterCode - } -} - -function isEmpty (schema) { - // eslint-disable-next-line - for (var key in schema) { - if (schema.hasOwnProperty(key) && schema[key] !== undefined) { - return false - } - } - return true -} - -module.exports = build - -module.exports.restore = function (debugModeStr, options = {}) { - const dependencies = [debugModeStr] - const args = [] - if (debugModeStr.startsWith('ajv')) { - dependencies.unshift('ajv') - args.push(new Ajv(options.ajv)) - } - - // eslint-disable-next-line - return (Function.apply(null, ['ajv', debugModeStr]) - .apply(null, args)) -} - - -/***/ }), - -/***/ 49194: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -// This file is autogenerated by build-schema-validator.js, do not edit - -function nop () { return true } - -'use strict'; -var formats = __nccwpck_require__(1053)(); -var equal = __nccwpck_require__(88178); -var validate = (function() { - var refVal = []; - var refVal1 = { - "type": "integer", - "minimum": 0 - }; - refVal[1] = refVal1; - var refVal2 = (function() { - return function validate(data, dataPath, parentData, parentDataProperty, rootData) { - 'use strict'; - var vErrors = null; - var errors = 0; - var errs_1 = errors; - var errs_2 = errors; - if ((typeof data !== "number" || (data % 1) || data !== data)) { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + "", - schemaPath: '#/definitions/nonNegativeInteger/type', - params: { - type: 'integer' - }, - message: 'should be integer' - }]; - return false; - } - if (typeof data === "number") { - if (data < 0 || data !== data) { - validate.errors = [{ - keyword: 'minimum', - dataPath: (dataPath || '') + "", - schemaPath: '#/definitions/nonNegativeInteger/minimum', - params: { - comparison: '>=', - limit: 0, - exclusive: false - }, - message: 'should be >= 0' - }]; - return false; - } - } - var valid2 = errors === errs_2; - var valid1 = errors === errs_1; - validate.errors = vErrors; - return errors === 0; - }; - })(); - refVal2.schema = { - "allOf": [{ - "$ref": "#/definitions/nonNegativeInteger" - }, { - "default": 0 - }] - }; - refVal2.errors = null; - refVal[2] = refVal2; - var refVal3 = (function() { - return function validate(data, dataPath, parentData, parentDataProperty, rootData) { - 'use strict'; - var vErrors = null; - var errors = 0; - if (rootData === undefined) rootData = data; - if (Array.isArray(data)) { - if (data.length < 1) { - validate.errors = [{ - keyword: 'minItems', - dataPath: (dataPath || '') + "", - schemaPath: '#/minItems', - params: { - limit: 1 - }, - message: 'should NOT have fewer than 1 items' - }]; - return false; - } else { - var errs__0 = errors; - var valid0; - for (var i0 = 0; i0 < data.length; i0++) { - var errs_1 = errors; - if (!nop(data[i0], (dataPath || '') + '[' + i0 + ']', data, i0, rootData)) { - if (vErrors === null) vErrors = nop.errors; - else vErrors = vErrors.concat(nop.errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - if (!valid1) break; - } - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + "", - schemaPath: '#/type', - params: { - type: 'array' - }, - message: 'should be array' - }]; - return false; - } - validate.errors = vErrors; - return errors === 0; - }; - })(); - refVal3.schema = { - "type": "array", - "minItems": 1, - "items": { - "$ref": "#" - } - }; - refVal3.errors = null; - refVal[3] = refVal3; - var refVal4 = { - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true, - "default": [] - }; - refVal[4] = refVal4; - var refVal5 = { - "enum": ["array", "boolean", "integer", "null", "number", "object", "string"] - }; - refVal[5] = refVal5; - return function validate(data, dataPath, parentData, parentDataProperty, rootData) { - 'use strict'; /*# sourceURL=http://json-schema.org/draft-07/schema# */ - var vErrors = null; - var errors = 0; - if (rootData === undefined) rootData = data; - if ((!data || typeof data !== "object" || Array.isArray(data)) && typeof data !== "boolean") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + "", - schemaPath: '#/type', - params: { - type: 'object,boolean' - }, - message: 'should be object,boolean' - }]; - return false; - } - if ((data && typeof data === "object" && !Array.isArray(data))) { - var errs__0 = errors; - var valid1 = true; - var data1 = data.$id; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (errors === errs_1) { - if (typeof data1 === "string") { - if (!formats['uri-reference'].test(data1)) { - validate.errors = [{ - keyword: 'format', - dataPath: (dataPath || '') + '.$id', - schemaPath: '#/properties/%24id/format', - params: { - format: 'uri-reference' - }, - message: 'should match format "uri-reference"' - }]; - return false; - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.$id', - schemaPath: '#/properties/%24id/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.$schema; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (errors === errs_1) { - if (typeof data1 === "string") { - if (!formats.uri.test(data1)) { - validate.errors = [{ - keyword: 'format', - dataPath: (dataPath || '') + '.$schema', - schemaPath: '#/properties/%24schema/format', - params: { - format: 'uri' - }, - message: 'should match format "uri"' - }]; - return false; - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.$schema', - schemaPath: '#/properties/%24schema/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.$ref; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (errors === errs_1) { - if (typeof data1 === "string") { - if (!formats['uri-reference'].test(data1)) { - validate.errors = [{ - keyword: 'format', - dataPath: (dataPath || '') + '.$ref', - schemaPath: '#/properties/%24ref/format', - params: { - format: 'uri-reference' - }, - message: 'should match format "uri-reference"' - }]; - return false; - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.$ref', - schemaPath: '#/properties/%24ref/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.$comment === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.$comment !== "string") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.$comment', - schemaPath: '#/properties/%24comment/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.title === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.title !== "string") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.title', - schemaPath: '#/properties/title/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.description === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.description !== "string") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.description', - schemaPath: '#/properties/description/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (valid1) { - if (data.readOnly === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.readOnly !== "boolean") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.readOnly', - schemaPath: '#/properties/readOnly/type', - params: { - type: 'boolean' - }, - message: 'should be boolean' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.examples === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (Array.isArray(data.examples)) { - var errs__1 = errors; - var valid1; - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.examples', - schemaPath: '#/properties/examples/type', - params: { - type: 'array' - }, - message: 'should be array' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.multipleOf; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data1 === "number") { - if (data1 <= 0 || data1 !== data1) { - validate.errors = [{ - keyword: 'exclusiveMinimum', - dataPath: (dataPath || '') + '.multipleOf', - schemaPath: '#/properties/multipleOf/exclusiveMinimum', - params: { - comparison: '>', - limit: 0, - exclusive: true - }, - message: 'should be > 0' - }]; - return false; - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.multipleOf', - schemaPath: '#/properties/multipleOf/type', - params: { - type: 'number' - }, - message: 'should be number' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.maximum === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.maximum !== "number") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.maximum', - schemaPath: '#/properties/maximum/type', - params: { - type: 'number' - }, - message: 'should be number' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.exclusiveMaximum === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.exclusiveMaximum !== "number") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.exclusiveMaximum', - schemaPath: '#/properties/exclusiveMaximum/type', - params: { - type: 'number' - }, - message: 'should be number' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.minimum === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.minimum !== "number") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.minimum', - schemaPath: '#/properties/minimum/type', - params: { - type: 'number' - }, - message: 'should be number' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.exclusiveMinimum === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.exclusiveMinimum !== "number") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.exclusiveMinimum', - schemaPath: '#/properties/exclusiveMinimum/type', - params: { - type: 'number' - }, - message: 'should be number' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.maxLength; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - var errs_2 = errors; - if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.maxLength', - schemaPath: '#/definitions/nonNegativeInteger/type', - params: { - type: 'integer' - }, - message: 'should be integer' - }]; - return false; - } - if (typeof data1 === "number") { - if (data1 < 0 || data1 !== data1) { - validate.errors = [{ - keyword: 'minimum', - dataPath: (dataPath || '') + '.maxLength', - schemaPath: '#/definitions/nonNegativeInteger/minimum', - params: { - comparison: '>=', - limit: 0, - exclusive: false - }, - message: 'should be >= 0' - }]; - return false; - } - } - var valid2 = errors === errs_2; - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.minLength === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!refVal2(data.minLength, (dataPath || '') + '.minLength', data, 'minLength', rootData)) { - if (vErrors === null) vErrors = refVal2.errors; - else vErrors = vErrors.concat(refVal2.errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.pattern; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (errors === errs_1) { - if (typeof data1 === "string") { - if (!formats.regex(data1)) { - validate.errors = [{ - keyword: 'format', - dataPath: (dataPath || '') + '.pattern', - schemaPath: '#/properties/pattern/format', - params: { - format: 'regex' - }, - message: 'should match format "regex"' - }]; - return false; - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.pattern', - schemaPath: '#/properties/pattern/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.additionalItems === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!validate(data.additionalItems, (dataPath || '') + '.additionalItems', data, 'additionalItems', rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.items; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - var errs__1 = errors; - var valid1 = false; - var errs_2 = errors; - if (!validate(data1, (dataPath || '') + '.items', data, 'items', rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid2 = errors === errs_2; - valid1 = valid1 || valid2; - if (!valid1) { - var errs_2 = errors; - if (!refVal3(data1, (dataPath || '') + '.items', data, 'items', rootData)) { - if (vErrors === null) vErrors = refVal3.errors; - else vErrors = vErrors.concat(refVal3.errors); - errors = vErrors.length; - } - var valid2 = errors === errs_2; - valid1 = valid1 || valid2; - } - if (!valid1) { - var err = { - keyword: 'anyOf', - dataPath: (dataPath || '') + '.items', - schemaPath: '#/properties/items/anyOf', - params: {}, - message: 'should match some schema in anyOf' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - validate.errors = vErrors; - return false; - } else { - errors = errs__1; - if (vErrors !== null) { - if (errs__1) vErrors.length = errs__1; - else vErrors = null; - } - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.maxItems; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - var errs_2 = errors; - if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.maxItems', - schemaPath: '#/definitions/nonNegativeInteger/type', - params: { - type: 'integer' - }, - message: 'should be integer' - }]; - return false; - } - if (typeof data1 === "number") { - if (data1 < 0 || data1 !== data1) { - validate.errors = [{ - keyword: 'minimum', - dataPath: (dataPath || '') + '.maxItems', - schemaPath: '#/definitions/nonNegativeInteger/minimum', - params: { - comparison: '>=', - limit: 0, - exclusive: false - }, - message: 'should be >= 0' - }]; - return false; - } - } - var valid2 = errors === errs_2; - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.minItems === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!refVal[2](data.minItems, (dataPath || '') + '.minItems', data, 'minItems', rootData)) { - if (vErrors === null) vErrors = refVal[2].errors; - else vErrors = vErrors.concat(refVal[2].errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.uniqueItems === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.uniqueItems !== "boolean") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.uniqueItems', - schemaPath: '#/properties/uniqueItems/type', - params: { - type: 'boolean' - }, - message: 'should be boolean' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.contains === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!validate(data.contains, (dataPath || '') + '.contains', data, 'contains', rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.maxProperties; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - var errs_2 = errors; - if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.maxProperties', - schemaPath: '#/definitions/nonNegativeInteger/type', - params: { - type: 'integer' - }, - message: 'should be integer' - }]; - return false; - } - if (typeof data1 === "number") { - if (data1 < 0 || data1 !== data1) { - validate.errors = [{ - keyword: 'minimum', - dataPath: (dataPath || '') + '.maxProperties', - schemaPath: '#/definitions/nonNegativeInteger/minimum', - params: { - comparison: '>=', - limit: 0, - exclusive: false - }, - message: 'should be >= 0' - }]; - return false; - } - } - var valid2 = errors === errs_2; - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.minProperties === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!refVal[2](data.minProperties, (dataPath || '') + '.minProperties', data, 'minProperties', rootData)) { - if (vErrors === null) vErrors = refVal[2].errors; - else vErrors = vErrors.concat(refVal[2].errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.required; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - var errs_2 = errors; - if (Array.isArray(data1)) { - var errs__2 = errors; - var valid2; - for (var i2 = 0; i2 < data1.length; i2++) { - var errs_3 = errors; - if (typeof data1[i2] !== "string") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.required[' + i2 + ']', - schemaPath: '#/definitions/stringArray/items/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - var valid3 = errors === errs_3; - if (!valid3) break; - } - if (errs__2 == errors) { - var i = data1.length, - valid2 = true, - j; - if (i > 1) { - var itemIndices = {}, - item; - for (; i--;) { - var item = data1[i]; - if (typeof item !== "string") continue; - if (typeof itemIndices[item] == 'number') { - valid2 = false; - j = itemIndices[item]; - break; - } - itemIndices[item] = i; - } - } - if (!valid2) { - validate.errors = [{ - keyword: 'uniqueItems', - dataPath: (dataPath || '') + '.required', - schemaPath: '#/definitions/stringArray/uniqueItems', - params: { - i: i, - j: j - }, - message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' - }]; - return false; - } - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.required', - schemaPath: '#/definitions/stringArray/type', - params: { - type: 'array' - }, - message: 'should be array' - }]; - return false; - } - var valid2 = errors === errs_2; - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.additionalProperties === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!validate(data.additionalProperties, (dataPath || '') + '.additionalProperties', data, 'additionalProperties', rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.definitions; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) { - var errs__1 = errors; - var valid2 = true; - for (var key1 in data1) { - var errs_2 = errors; - if (!validate(data1[key1], (dataPath || '') + '.definitions[\'' + key1 + '\']', data1, key1, rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid2 = errors === errs_2; - if (!valid2) break; - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.definitions', - schemaPath: '#/properties/definitions/type', - params: { - type: 'object' - }, - message: 'should be object' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.properties; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) { - var errs__1 = errors; - var valid2 = true; - for (var key1 in data1) { - var errs_2 = errors; - if (!validate(data1[key1], (dataPath || '') + '.properties[\'' + key1 + '\']', data1, key1, rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid2 = errors === errs_2; - if (!valid2) break; - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.properties', - schemaPath: '#/properties/properties/type', - params: { - type: 'object' - }, - message: 'should be object' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.patternProperties; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) { - var errs__1 = errors; - for (var key1 in data1) { - var startErrs1 = errors; - var data2 = key1; - var errs_2 = errors; - if (errors === errs_2) { - if (typeof data2 === "string") { - if (!formats.regex(data2)) { - var err = { - keyword: 'format', - dataPath: (dataPath || '') + '.patternProperties', - schemaPath: '#/properties/patternProperties/propertyNames/format', - params: { - format: 'regex' - }, - message: 'should match format "regex"' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - } - } - } - var valid2 = errors === errs_2; - if (!valid2) { - for (var i1 = startErrs1; i1 < errors; i1++) { - vErrors[i1].propertyName = key1; - } - var err = { - keyword: 'propertyNames', - dataPath: (dataPath || '') + '.patternProperties', - schemaPath: '#/properties/patternProperties/propertyNames', - params: { - propertyName: '' + key1 + '' - }, - message: 'property name \'' + key1 + '\' is invalid' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - validate.errors = vErrors; - return false; - break; - } - } - if (errs__1 == errors) { - var errs__1 = errors; - var valid2 = true; - for (var key1 in data1) { - var errs_2 = errors; - if (!validate(data1[key1], (dataPath || '') + '.patternProperties[\'' + key1 + '\']', data1, key1, rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid2 = errors === errs_2; - if (!valid2) break; - } - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.patternProperties', - schemaPath: '#/properties/patternProperties/type', - params: { - type: 'object' - }, - message: 'should be object' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.dependencies; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) { - var errs__1 = errors; - var valid2 = true; - for (var key1 in data1) { - var data2 = data1[key1]; - var errs_2 = errors; - var errs__2 = errors; - var valid2 = false; - var errs_3 = errors; - if (!validate(data2, (dataPath || '') + '.dependencies[\'' + key1 + '\']', data1, key1, rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid3 = errors === errs_3; - valid2 = valid2 || valid3; - if (!valid2) { - var errs_3 = errors; - var errs_4 = errors; - if (Array.isArray(data2)) { - var errs__4 = errors; - var valid4; - for (var i4 = 0; i4 < data2.length; i4++) { - var errs_5 = errors; - if (typeof data2[i4] !== "string") { - var err = { - keyword: 'type', - dataPath: (dataPath || '') + '.dependencies[\'' + key1 + '\'][' + i4 + ']', - schemaPath: '#/definitions/stringArray/items/type', - params: { - type: 'string' - }, - message: 'should be string' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - } - var valid5 = errors === errs_5; - if (!valid5) break; - } - if (errs__4 == errors) { - var i = data2.length, - valid4 = true, - j; - if (i > 1) { - var itemIndices = {}, - item; - for (; i--;) { - var item = data2[i]; - if (typeof item !== "string") continue; - if (typeof itemIndices[item] == 'number') { - valid4 = false; - j = itemIndices[item]; - break; - } - itemIndices[item] = i; - } - } - if (!valid4) { - var err = { - keyword: 'uniqueItems', - dataPath: (dataPath || '') + '.dependencies[\'' + key1 + '\']', - schemaPath: '#/definitions/stringArray/uniqueItems', - params: { - i: i, - j: j - }, - message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - } - } - } else { - var err = { - keyword: 'type', - dataPath: (dataPath || '') + '.dependencies[\'' + key1 + '\']', - schemaPath: '#/definitions/stringArray/type', - params: { - type: 'array' - }, - message: 'should be array' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - } - var valid4 = errors === errs_4; - var valid3 = errors === errs_3; - valid2 = valid2 || valid3; - } - if (!valid2) { - var err = { - keyword: 'anyOf', - dataPath: (dataPath || '') + '.dependencies[\'' + key1 + '\']', - schemaPath: '#/properties/dependencies/additionalProperties/anyOf', - params: {}, - message: 'should match some schema in anyOf' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - validate.errors = vErrors; - return false; - } else { - errors = errs__2; - if (vErrors !== null) { - if (errs__2) vErrors.length = errs__2; - else vErrors = null; - } - } - var valid2 = errors === errs_2; - if (!valid2) break; - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.dependencies', - schemaPath: '#/properties/dependencies/type', - params: { - type: 'object' - }, - message: 'should be object' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.propertyNames === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!validate(data.propertyNames, (dataPath || '') + '.propertyNames', data, 'propertyNames', rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (valid1) { - var data1 = data.enum; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (Array.isArray(data1)) { - if (data1.length < 1) { - validate.errors = [{ - keyword: 'minItems', - dataPath: (dataPath || '') + '.enum', - schemaPath: '#/properties/enum/minItems', - params: { - limit: 1 - }, - message: 'should NOT have fewer than 1 items' - }]; - return false; - } else { - var errs__1 = errors; - var valid1; - if (errs__1 == errors) { - var i = data1.length, - valid1 = true, - j; - if (i > 1) { - outer: for (; i--;) { - for (j = i; j--;) { - if (equal(data1[i], data1[j])) { - valid1 = false; - break outer; - } - } - } - } - if (!valid1) { - validate.errors = [{ - keyword: 'uniqueItems', - dataPath: (dataPath || '') + '.enum', - schemaPath: '#/properties/enum/uniqueItems', - params: { - i: i, - j: j - }, - message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' - }]; - return false; - } - } - } - } else { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.enum', - schemaPath: '#/properties/enum/type', - params: { - type: 'array' - }, - message: 'should be array' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - var data1 = data.type; - if (data1 === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - var errs__1 = errors; - var valid1 = false; - var errs_2 = errors; - var errs_3 = errors; - var schema3 = refVal5.enum; - var valid3; - valid3 = false; - for (var i3 = 0; i3 < schema3.length; i3++) - if (equal(data1, schema3[i3])) { - valid3 = true; - break; - } if (!valid3) { - var err = { - keyword: 'enum', - dataPath: (dataPath || '') + '.type', - schemaPath: '#/definitions/simpleTypes/enum', - params: { - allowedValues: schema3 - }, - message: 'should be equal to one of the allowed values' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - } - var valid3 = errors === errs_3; - var valid2 = errors === errs_2; - valid1 = valid1 || valid2; - if (!valid1) { - var errs_2 = errors; - if (Array.isArray(data1)) { - if (data1.length < 1) { - var err = { - keyword: 'minItems', - dataPath: (dataPath || '') + '.type', - schemaPath: '#/properties/type/anyOf/1/minItems', - params: { - limit: 1 - }, - message: 'should NOT have fewer than 1 items' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - } else { - var errs__2 = errors; - var valid2; - for (var i2 = 0; i2 < data1.length; i2++) { - var errs_3 = errors; - var errs_4 = errors; - var schema4 = refVal[5].enum; - var valid4; - valid4 = false; - for (var i4 = 0; i4 < schema4.length; i4++) - if (equal(data1[i2], schema4[i4])) { - valid4 = true; - break; - } if (!valid4) { - var err = { - keyword: 'enum', - dataPath: (dataPath || '') + '.type[' + i2 + ']', - schemaPath: '#/definitions/simpleTypes/enum', - params: { - allowedValues: schema4 - }, - message: 'should be equal to one of the allowed values' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - } - var valid4 = errors === errs_4; - var valid3 = errors === errs_3; - if (!valid3) break; - } - if (errs__2 == errors) { - var i = data1.length, - valid2 = true, - j; - if (i > 1) { - outer: for (; i--;) { - for (j = i; j--;) { - if (equal(data1[i], data1[j])) { - valid2 = false; - break outer; - } - } - } - } - if (!valid2) { - var err = { - keyword: 'uniqueItems', - dataPath: (dataPath || '') + '.type', - schemaPath: '#/properties/type/anyOf/1/uniqueItems', - params: { - i: i, - j: j - }, - message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - } - } - } - } else { - var err = { - keyword: 'type', - dataPath: (dataPath || '') + '.type', - schemaPath: '#/properties/type/anyOf/1/type', - params: { - type: 'array' - }, - message: 'should be array' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - } - var valid2 = errors === errs_2; - valid1 = valid1 || valid2; - } - if (!valid1) { - var err = { - keyword: 'anyOf', - dataPath: (dataPath || '') + '.type', - schemaPath: '#/properties/type/anyOf', - params: {}, - message: 'should match some schema in anyOf' - }; - if (vErrors === null) vErrors = [err]; - else vErrors.push(err); - errors++; - validate.errors = vErrors; - return false; - } else { - errors = errs__1; - if (vErrors !== null) { - if (errs__1) vErrors.length = errs__1; - else vErrors = null; - } - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.format === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.format !== "string") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.format', - schemaPath: '#/properties/format/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.contentMediaType === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.contentMediaType !== "string") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.contentMediaType', - schemaPath: '#/properties/contentMediaType/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.contentEncoding === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (typeof data.contentEncoding !== "string") { - validate.errors = [{ - keyword: 'type', - dataPath: (dataPath || '') + '.contentEncoding', - schemaPath: '#/properties/contentEncoding/type', - params: { - type: 'string' - }, - message: 'should be string' - }]; - return false; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.if === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!validate(data.if, (dataPath || '') + '.if', data, 'if', rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.then === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!validate(data.then, (dataPath || '') + '.then', data, 'then', rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.else === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!validate(data.else, (dataPath || '') + '.else', data, 'else', rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.allOf === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!refVal[3](data.allOf, (dataPath || '') + '.allOf', data, 'allOf', rootData)) { - if (vErrors === null) vErrors = refVal[3].errors; - else vErrors = vErrors.concat(refVal[3].errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.anyOf === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!refVal[3](data.anyOf, (dataPath || '') + '.anyOf', data, 'anyOf', rootData)) { - if (vErrors === null) vErrors = refVal[3].errors; - else vErrors = vErrors.concat(refVal[3].errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.oneOf === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!refVal[3](data.oneOf, (dataPath || '') + '.oneOf', data, 'oneOf', rootData)) { - if (vErrors === null) vErrors = refVal[3].errors; - else vErrors = vErrors.concat(refVal[3].errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - if (valid1) { - if (data.not === undefined) { - valid1 = true; - } else { - var errs_1 = errors; - if (!validate(data.not, (dataPath || '') + '.not', data, 'not', rootData)) { - if (vErrors === null) vErrors = validate.errors; - else vErrors = vErrors.concat(validate.errors); - errors = vErrors.length; - } - var valid1 = errors === errs_1; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - validate.errors = vErrors; - return errors === 0; - }; -})(); -validate.schema = { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://json-schema.org/draft-07/schema#", - "title": "Core schema meta-schema", - "definitions": { - "schemaArray": { - "type": "array", - "minItems": 1, - "items": { - "$ref": "#" - } - }, - "nonNegativeInteger": { - "type": "integer", - "minimum": 0 - }, - "nonNegativeIntegerDefault0": { - "allOf": [{ - "$ref": "#/definitions/nonNegativeInteger" - }, { - "default": 0 - }] - }, - "simpleTypes": { - "enum": ["array", "boolean", "integer", "null", "number", "object", "string"] - }, - "stringArray": { - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true, - "default": [] - } - }, - "type": ["object", "boolean"], - "properties": { - "$id": { - "type": "string", - "format": "uri-reference" - }, - "$schema": { - "type": "string", - "format": "uri" - }, - "$ref": { - "type": "string", - "format": "uri-reference" - }, - "$comment": { - "type": "string" - }, - "title": { - "type": "string" - }, - "description": { - "type": "string" - }, - "default": true, - "readOnly": { - "type": "boolean", - "default": false - }, - "examples": { - "type": "array", - "items": true - }, - "multipleOf": { - "type": "number", - "exclusiveMinimum": 0 - }, - "maximum": { - "type": "number" - }, - "exclusiveMaximum": { - "type": "number" - }, - "minimum": { - "type": "number" - }, - "exclusiveMinimum": { - "type": "number" - }, - "maxLength": { - "$ref": "#/definitions/nonNegativeInteger" - }, - "minLength": { - "$ref": "#/definitions/nonNegativeIntegerDefault0" - }, - "pattern": { - "type": "string", - "format": "regex" - }, - "additionalItems": { - "$ref": "#" - }, - "items": { - "anyOf": [{ - "$ref": "#" - }, { - "$ref": "#/definitions/schemaArray" - }], - "default": true - }, - "maxItems": { - "$ref": "#/definitions/nonNegativeInteger" - }, - "minItems": { - "$ref": "#/definitions/nonNegativeIntegerDefault0" - }, - "uniqueItems": { - "type": "boolean", - "default": false - }, - "contains": { - "$ref": "#" - }, - "maxProperties": { - "$ref": "#/definitions/nonNegativeInteger" - }, - "minProperties": { - "$ref": "#/definitions/nonNegativeIntegerDefault0" - }, - "required": { - "$ref": "#/definitions/stringArray" - }, - "additionalProperties": { - "$ref": "#" - }, - "definitions": { - "type": "object", - "additionalProperties": { - "$ref": "#" - }, - "default": {} - }, - "properties": { - "type": "object", - "additionalProperties": { - "$ref": "#" - }, - "default": {} - }, - "patternProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#" - }, - "propertyNames": { - "format": "regex" - }, - "default": {} - }, - "dependencies": { - "type": "object", - "additionalProperties": { - "anyOf": [{ - "$ref": "#" - }, { - "$ref": "#/definitions/stringArray" - }] - } - }, - "propertyNames": { - "$ref": "#" - }, - "const": true, - "enum": { - "type": "array", - "items": true, - "minItems": 1, - "uniqueItems": true - }, - "type": { - "anyOf": [{ - "$ref": "#/definitions/simpleTypes" - }, { - "type": "array", - "items": { - "$ref": "#/definitions/simpleTypes" - }, - "minItems": 1, - "uniqueItems": true - }] - }, - "format": { - "type": "string" - }, - "contentMediaType": { - "type": "string" - }, - "contentEncoding": { - "type": "string" - }, - "if": { - "$ref": "#" - }, - "then": { - "$ref": "#" - }, - "else": { - "$ref": "#" - }, - "allOf": { - "$ref": "#/definitions/schemaArray" - }, - "anyOf": { - "$ref": "#/definitions/schemaArray" - }, - "oneOf": { - "$ref": "#/definitions/schemaArray" - }, - "not": { - "$ref": "#" - } - }, - "default": true -}; -validate.errors = null; -module.exports = validate; - - /***/ }), /***/ 64039: @@ -91044,6 +82124,9 @@ var WriteAfterEndError = createErrorType( "write after end" ); +// istanbul ignore next +var destroy = Writable.prototype.destroy || noop; + // An HTTP(S) request that can be redirected function RedirectableRequest(options, responseCallback) { // Initialize the request @@ -91074,10 +82157,17 @@ function RedirectableRequest(options, responseCallback) { RedirectableRequest.prototype = Object.create(Writable.prototype); RedirectableRequest.prototype.abort = function () { - abortRequest(this._currentRequest); + destroyRequest(this._currentRequest); + this._currentRequest.abort(); this.emit("abort"); }; +RedirectableRequest.prototype.destroy = function (error) { + destroyRequest(this._currentRequest, error); + destroy.call(this, error); + return this; +}; + // Writes buffered data to the current native request RedirectableRequest.prototype.write = function (data, encoding, callback) { // Writing is not allowed if end has been called @@ -91190,6 +82280,7 @@ RedirectableRequest.prototype.setTimeout = function (msecs, callback) { self.removeListener("abort", clearTimer); self.removeListener("error", clearTimer); self.removeListener("response", clearTimer); + self.removeListener("close", clearTimer); if (callback) { self.removeListener("timeout", callback); } @@ -91216,6 +82307,7 @@ RedirectableRequest.prototype.setTimeout = function (msecs, callback) { this.on("abort", clearTimer); this.on("error", clearTimer); this.on("response", clearTimer); + this.on("close", clearTimer); return this; }; @@ -91367,7 +82459,7 @@ RedirectableRequest.prototype._processResponse = function (response) { } // The response is a redirect, so abort the current request - abortRequest(this._currentRequest); + destroyRequest(this._currentRequest); // Discard the remainder of the response to avoid waiting for data response.destroy(); @@ -91596,12 +82688,12 @@ function createErrorType(code, message, baseClass) { return CustomError; } -function abortRequest(request) { +function destroyRequest(request, error) { for (var event of events) { request.removeListener(event, eventHandlers[event]); } request.on("error", noop); - request.abort(); + request.destroy(error); } function isSubdomain(subdomain, domain) { @@ -92827,43 +83919,75 @@ exports.realpath = function realpath(p, cache, cb) { /* eslint no-invalid-this: 1 */ var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible '; -var slice = Array.prototype.slice; var toStr = Object.prototype.toString; +var max = Math.max; var funcType = '[object Function]'; +var concatty = function concatty(a, b) { + var arr = []; + + for (var i = 0; i < a.length; i += 1) { + arr[i] = a[i]; + } + for (var j = 0; j < b.length; j += 1) { + arr[j + a.length] = b[j]; + } + + return arr; +}; + +var slicy = function slicy(arrLike, offset) { + var arr = []; + for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) { + arr[j] = arrLike[i]; + } + return arr; +}; + +var joiny = function (arr, joiner) { + var str = ''; + for (var i = 0; i < arr.length; i += 1) { + str += arr[i]; + if (i + 1 < arr.length) { + str += joiner; + } + } + return str; +}; + module.exports = function bind(that) { var target = this; - if (typeof target !== 'function' || toStr.call(target) !== funcType) { + if (typeof target !== 'function' || toStr.apply(target) !== funcType) { throw new TypeError(ERROR_MESSAGE + target); } - var args = slice.call(arguments, 1); + var args = slicy(arguments, 1); var bound; var binder = function () { if (this instanceof bound) { var result = target.apply( this, - args.concat(slice.call(arguments)) + concatty(args, arguments) ); if (Object(result) === result) { return result; } return this; - } else { - return target.apply( - that, - args.concat(slice.call(arguments)) - ); } + return target.apply( + that, + concatty(args, arguments) + ); + }; - var boundLength = Math.max(0, target.length - args.length); + var boundLength = max(0, target.length - args.length); var boundArgs = []; for (var i = 0; i < boundLength; i++) { - boundArgs.push('$' + i); + boundArgs[i] = '$' + i; } - bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder); + bound = Function('binder', 'return function (' + joiny(boundArgs, ',') + '){ return binder.apply(this,arguments); }')(binder); if (target.prototype) { var Empty = function Empty() {}; @@ -93140,7 +84264,7 @@ var LEGACY_ALIASES = { }; var bind = __nccwpck_require__(41631); -var hasOwn = __nccwpck_require__(64223); +var hasOwn = __nccwpck_require__(54397); var $concat = bind.call(Function.call, Array.prototype.concat); var $spliceApply = bind.call(Function.apply, Array.prototype.splice); var $replace = bind.call(Function.call, String.prototype.replace); @@ -95183,6 +86307,30 @@ module.exports = { }; +/***/ }), + +/***/ 22852: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var GetIntrinsic = __nccwpck_require__(19253); + +var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); + +if ($gOPD) { + try { + $gOPD([], 'length'); + } catch (e) { + // IE 8 has a broken gOPD + $gOPD = null; + } +} + +module.exports = $gOPD; + + /***/ }), /***/ 30870: @@ -117027,7 +108175,7 @@ function findConflict( ]; } // Two field calls must have the same arguments. - if (stringifyArguments(node1) !== stringifyArguments(node2)) { + if (!sameArguments(node1, node2)) { return [ [responseName, 'they have differing arguments'], [node1], @@ -117072,27 +108220,40 @@ function findConflict( } } -function stringifyArguments(fieldNode) { - var _fieldNode$arguments; +function sameArguments(node1, node2) { + const args1 = node1.arguments; + const args2 = node2.arguments; - // FIXME https://github.com/graphql/graphql-js/issues/2203 - const args = + if (args1 === undefined || args1.length === 0) { + return args2 === undefined || args2.length === 0; + } + + if (args2 === undefined || args2.length === 0) { + return false; + } + /* c8 ignore next */ + + if (args1.length !== args2.length) { /* c8 ignore next */ - (_fieldNode$arguments = fieldNode.arguments) !== null && - _fieldNode$arguments !== void 0 - ? _fieldNode$arguments - : []; - const inputObjectWithArgs = { - kind: _kinds.Kind.OBJECT, - fields: args.map((argNode) => ({ - kind: _kinds.Kind.OBJECT_FIELD, - name: argNode.name, - value: argNode.value, - })), - }; - return (0, _printer.print)( - (0, _sortValueNode.sortValueNode)(inputObjectWithArgs), - ); + return false; + /* c8 ignore next */ + } + + const values2 = new Map(args2.map(({ name, value }) => [name.value, value])); + return args1.every((arg1) => { + const value1 = arg1.value; + const value2 = values2.get(arg1.name.value); + + if (value2 === undefined) { + return false; + } + + return stringifyValue(value1) === stringifyValue(value2); + }); +} + +function stringifyValue(value) { + return (0, _printer.print)((0, _sortValueNode.sortValueNode)(value)); } // Two types conflict if both types could not apply to a value simultaneously. // Composite types are ignored as their individual field types will be compared // later recursively. However List and Non-Null types must match. @@ -119683,7 +110844,7 @@ exports.versionInfo = exports.version = void 0; /** * A string containing the version of the GraphQL.js library */ -const version = '16.8.0'; +const version = '16.8.1'; /** * An object containing the components of the GraphQL.js version string */ @@ -119692,7 +110853,7 @@ exports.version = version; const versionInfo = Object.freeze({ major: 16, minor: 8, - patch: 0, + patch: 1, preReleaseTag: null, }); exports.versionInfo = versionInfo; @@ -125042,15 +116203,18 @@ module.exports = function hasSymbols() { /***/ }), -/***/ 64223: +/***/ 54397: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; +var call = Function.prototype.call; +var $hasOwn = Object.prototype.hasOwnProperty; var bind = __nccwpck_require__(41631); -module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty); +/** @type {(o: {}, p: PropertyKey) => p is keyof o} */ +module.exports = bind.call(call, $hasOwn); /***/ }), @@ -131945,7 +123109,7 @@ module.exports = (string, columns, options) => { "use strict"; -var has = __nccwpck_require__(64223); +var hasOwn = __nccwpck_require__(54397); function specifierIncluded(current, specifier) { var nodeParts = current.split('.'); @@ -132010,7 +123174,7 @@ function versionIncluded(nodeVersion, specifierValue) { var data = __nccwpck_require__(13447); module.exports = function isCore(x, nodeVersion) { - return has(data, x) && versionIncluded(nodeVersion, data[x]); + return hasOwn(data, x) && versionIncluded(nodeVersion, data[x]); }; @@ -132557,103 +123721,6 @@ module.exports = () => { }; -/***/ }), - -/***/ 33282: -/***/ ((module) => { - -"use strict"; - - -var traverse = module.exports = function (schema, opts, cb) { - // Legacy support for v0.3.1 and earlier. - if (typeof opts == 'function') { - cb = opts; - opts = {}; - } - - cb = opts.cb || cb; - var pre = (typeof cb == 'function') ? cb : cb.pre || function() {}; - var post = cb.post || function() {}; - - _traverse(opts, pre, post, schema, '', schema); -}; - - -traverse.keywords = { - additionalItems: true, - items: true, - contains: true, - additionalProperties: true, - propertyNames: true, - not: true -}; - -traverse.arrayKeywords = { - items: true, - allOf: true, - anyOf: true, - oneOf: true -}; - -traverse.propsKeywords = { - definitions: true, - properties: true, - patternProperties: true, - dependencies: true -}; - -traverse.skipKeywords = { - default: true, - enum: true, - const: true, - required: true, - maximum: true, - minimum: true, - exclusiveMaximum: true, - exclusiveMinimum: true, - multipleOf: true, - maxLength: true, - minLength: true, - pattern: true, - format: true, - maxItems: true, - minItems: true, - uniqueItems: true, - maxProperties: true, - minProperties: true -}; - - -function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) { - if (schema && typeof schema == 'object' && !Array.isArray(schema)) { - pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex); - for (var key in schema) { - var sch = schema[key]; - if (Array.isArray(sch)) { - if (key in traverse.arrayKeywords) { - for (var i=0; i { - -"use strict"; - -module.exports = rfdc - -function copyBuffer (cur) { - if (cur instanceof Buffer) { - return Buffer.from(cur) - } - - return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length) -} - -function rfdc (opts) { - opts = opts || {} - - if (opts.circles) return rfdcCircles(opts) - return opts.proto ? cloneProto : clone - - function cloneArray (a, fn) { - var keys = Object.keys(a) - var a2 = new Array(keys.length) - for (var i = 0; i < keys.length; i++) { - var k = keys[i] - var cur = a[k] - if (typeof cur !== 'object' || cur === null) { - a2[k] = cur - } else if (cur instanceof Date) { - a2[k] = new Date(cur) - } else if (ArrayBuffer.isView(cur)) { - a2[k] = copyBuffer(cur) - } else { - a2[k] = fn(cur) - } - } - return a2 - } - - function clone (o) { - if (typeof o !== 'object' || o === null) return o - if (o instanceof Date) return new Date(o) - if (Array.isArray(o)) return cloneArray(o, clone) - if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone)) - if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone)) - var o2 = {} - for (var k in o) { - if (Object.hasOwnProperty.call(o, k) === false) continue - var cur = o[k] - if (typeof cur !== 'object' || cur === null) { - o2[k] = cur - } else if (cur instanceof Date) { - o2[k] = new Date(cur) - } else if (cur instanceof Map) { - o2[k] = new Map(cloneArray(Array.from(cur), clone)) - } else if (cur instanceof Set) { - o2[k] = new Set(cloneArray(Array.from(cur), clone)) - } else if (ArrayBuffer.isView(cur)) { - o2[k] = copyBuffer(cur) - } else { - o2[k] = clone(cur) - } - } - return o2 - } - - function cloneProto (o) { - if (typeof o !== 'object' || o === null) return o - if (o instanceof Date) return new Date(o) - if (Array.isArray(o)) return cloneArray(o, cloneProto) - if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto)) - if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto)) - var o2 = {} - for (var k in o) { - var cur = o[k] - if (typeof cur !== 'object' || cur === null) { - o2[k] = cur - } else if (cur instanceof Date) { - o2[k] = new Date(cur) - } else if (cur instanceof Map) { - o2[k] = new Map(cloneArray(Array.from(cur), cloneProto)) - } else if (cur instanceof Set) { - o2[k] = new Set(cloneArray(Array.from(cur), cloneProto)) - } else if (ArrayBuffer.isView(cur)) { - o2[k] = copyBuffer(cur) - } else { - o2[k] = cloneProto(cur) - } - } - return o2 - } -} - -function rfdcCircles (opts) { - var refs = [] - var refsNew = [] - - return opts.proto ? cloneProto : clone - - function cloneArray (a, fn) { - var keys = Object.keys(a) - var a2 = new Array(keys.length) - for (var i = 0; i < keys.length; i++) { - var k = keys[i] - var cur = a[k] - if (typeof cur !== 'object' || cur === null) { - a2[k] = cur - } else if (cur instanceof Date) { - a2[k] = new Date(cur) - } else if (ArrayBuffer.isView(cur)) { - a2[k] = copyBuffer(cur) - } else { - var index = refs.indexOf(cur) - if (index !== -1) { - a2[k] = refsNew[index] - } else { - a2[k] = fn(cur) - } - } - } - return a2 - } - - function clone (o) { - if (typeof o !== 'object' || o === null) return o - if (o instanceof Date) return new Date(o) - if (Array.isArray(o)) return cloneArray(o, clone) - if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone)) - if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone)) - var o2 = {} - refs.push(o) - refsNew.push(o2) - for (var k in o) { - if (Object.hasOwnProperty.call(o, k) === false) continue - var cur = o[k] - if (typeof cur !== 'object' || cur === null) { - o2[k] = cur - } else if (cur instanceof Date) { - o2[k] = new Date(cur) - } else if (cur instanceof Map) { - o2[k] = new Map(cloneArray(Array.from(cur), clone)) - } else if (cur instanceof Set) { - o2[k] = new Set(cloneArray(Array.from(cur), clone)) - } else if (ArrayBuffer.isView(cur)) { - o2[k] = copyBuffer(cur) - } else { - var i = refs.indexOf(cur) - if (i !== -1) { - o2[k] = refsNew[i] - } else { - o2[k] = clone(cur) - } - } - } - refs.pop() - refsNew.pop() - return o2 - } - - function cloneProto (o) { - if (typeof o !== 'object' || o === null) return o - if (o instanceof Date) return new Date(o) - if (Array.isArray(o)) return cloneArray(o, cloneProto) - if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto)) - if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto)) - var o2 = {} - refs.push(o) - refsNew.push(o2) - for (var k in o) { - var cur = o[k] - if (typeof cur !== 'object' || cur === null) { - o2[k] = cur - } else if (cur instanceof Date) { - o2[k] = new Date(cur) - } else if (cur instanceof Map) { - o2[k] = new Map(cloneArray(Array.from(cur), cloneProto)) - } else if (cur instanceof Set) { - o2[k] = new Set(cloneArray(Array.from(cur), cloneProto)) - } else if (ArrayBuffer.isView(cur)) { - o2[k] = copyBuffer(cur) - } else { - var i = refs.indexOf(cur) - if (i !== -1) { - o2[k] = refsNew[i] - } else { - o2[k] = cloneProto(cur) - } - } - } - refs.pop() - refsNew.pop() - return o2 - } -} - - /***/ }), /***/ 89515: @@ -189320,6 +180188,55 @@ if (!safer.constants) { module.exports = safer +/***/ }), + +/***/ 8078: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var GetIntrinsic = __nccwpck_require__(19253); +var define = __nccwpck_require__(3893); +var hasDescriptors = __nccwpck_require__(1943)(); +var gOPD = __nccwpck_require__(22852); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $floor = GetIntrinsic('%Math.floor%'); + +module.exports = function setFunctionLength(fn, length) { + if (typeof fn !== 'function') { + throw new $TypeError('`fn` is not a function'); + } + if (typeof length !== 'number' || length < 0 || length > 0xFFFFFFFF || $floor(length) !== length) { + throw new $TypeError('`length` must be a positive 32-bit integer'); + } + + var loose = arguments.length > 2 && !!arguments[2]; + + var functionLengthIsConfigurable = true; + var functionLengthIsWritable = true; + if ('length' in fn && gOPD) { + var desc = gOPD(fn, 'length'); + if (desc && !desc.configurable) { + functionLengthIsConfigurable = false; + } + if (desc && !desc.writable) { + functionLengthIsWritable = false; + } + } + + if (functionLengthIsConfigurable || functionLengthIsWritable || !loose) { + if (hasDescriptors) { + define(fn, 'length', length, true, true); + } else { + define(fn, 'length', length); + } + } + return fn; +}; + + /***/ }), /***/ 86936: @@ -193949,79 +184866,6 @@ function destroyStream (stream, cb) { } -/***/ }), - -/***/ 74649: -/***/ ((module) => { - -module.exports = { - compareTwoStrings:compareTwoStrings, - findBestMatch:findBestMatch -}; - -function compareTwoStrings(first, second) { - first = first.replace(/\s+/g, '') - second = second.replace(/\s+/g, '') - - if (first === second) return 1; // identical or empty - if (first.length < 2 || second.length < 2) return 0; // if either is a 0-letter or 1-letter string - - let firstBigrams = new Map(); - for (let i = 0; i < first.length - 1; i++) { - const bigram = first.substring(i, i + 2); - const count = firstBigrams.has(bigram) - ? firstBigrams.get(bigram) + 1 - : 1; - - firstBigrams.set(bigram, count); - }; - - let intersectionSize = 0; - for (let i = 0; i < second.length - 1; i++) { - const bigram = second.substring(i, i + 2); - const count = firstBigrams.has(bigram) - ? firstBigrams.get(bigram) - : 0; - - if (count > 0) { - firstBigrams.set(bigram, count - 1); - intersectionSize++; - } - } - - return (2.0 * intersectionSize) / (first.length + second.length - 2); -} - -function findBestMatch(mainString, targetStrings) { - if (!areArgsValid(mainString, targetStrings)) throw new Error('Bad arguments: First argument should be a string, second should be an array of strings'); - - const ratings = []; - let bestMatchIndex = 0; - - for (let i = 0; i < targetStrings.length; i++) { - const currentTargetString = targetStrings[i]; - const currentRating = compareTwoStrings(mainString, currentTargetString) - ratings.push({target: currentTargetString, rating: currentRating}) - if (currentRating > ratings[bestMatchIndex].rating) { - bestMatchIndex = i - } - } - - - const bestMatch = ratings[bestMatchIndex] - - return { ratings: ratings, bestMatch: bestMatch, bestMatchIndex: bestMatchIndex }; -} - -function areArgsValid(mainString, targetStrings) { - if (typeof mainString !== 'string') return false; - if (!Array.isArray(targetStrings)) return false; - if (!targetStrings.length) return false; - if (targetStrings.find( function (s) { return typeof s !== 'string'})) return false; - return true; -} - - /***/ }), /***/ 26135: @@ -196696,7 +187540,7 @@ function getUserAgent() { return navigator.userAgent; } - if (typeof process === "object" && "version" in process) { + if (typeof process === "object" && process.version !== undefined) { return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`; } @@ -196707,1455 +187551,6 @@ exports.getUserAgent = getUserAgent; //# sourceMappingURL=index.js.map -/***/ }), - -/***/ 16471: -/***/ (function(__unused_webpack_module, exports) { - -/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */ -(function (global, factory) { - true ? factory(exports) : - 0; -}(this, (function (exports) { 'use strict'; - -function merge() { - for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) { - sets[_key] = arguments[_key]; - } - - if (sets.length > 1) { - sets[0] = sets[0].slice(0, -1); - var xl = sets.length - 1; - for (var x = 1; x < xl; ++x) { - sets[x] = sets[x].slice(1, -1); - } - sets[xl] = sets[xl].slice(1); - return sets.join(''); - } else { - return sets[0]; - } -} -function subexp(str) { - return "(?:" + str + ")"; -} -function typeOf(o) { - return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase(); -} -function toUpperCase(str) { - return str.toUpperCase(); -} -function toArray(obj) { - return obj !== undefined && obj !== null ? obj instanceof Array ? obj : typeof obj.length !== "number" || obj.split || obj.setInterval || obj.call ? [obj] : Array.prototype.slice.call(obj) : []; -} -function assign(target, source) { - var obj = target; - if (source) { - for (var key in source) { - obj[key] = source[key]; - } - } - return obj; -} - -function buildExps(isIRI) { - var ALPHA$$ = "[A-Za-z]", - CR$ = "[\\x0D]", - DIGIT$$ = "[0-9]", - DQUOTE$$ = "[\\x22]", - HEXDIG$$ = merge(DIGIT$$, "[A-Fa-f]"), - //case-insensitive - LF$$ = "[\\x0A]", - SP$$ = "[\\x20]", - PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)), - //expanded - GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]", - SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]", - RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$), - UCSCHAR$$ = isIRI ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]", - //subset, excludes bidi control characters - IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]", - //subset - UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$), - SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"), - USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"), - DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$), - DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$), - //relaxed parsing rules - IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$), - H16$ = subexp(HEXDIG$$ + "{1,4}"), - LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$), - IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$), - // 6( h16 ":" ) ls32 - IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$), - // "::" 5( h16 ":" ) ls32 - IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$), - //[ h16 ] "::" 4( h16 ":" ) ls32 - IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$), - //[ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32 - IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$), - //[ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32 - IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$), - //[ *3( h16 ":" ) h16 ] "::" h16 ":" ls32 - IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$), - //[ *4( h16 ":" ) h16 ] "::" ls32 - IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$), - //[ *5( h16 ":" ) h16 ] "::" h16 - IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"), - //[ *6( h16 ":" ) h16 ] "::" - IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")), - ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"), - //RFC 6874 - IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$), - //RFC 6874 - IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$), - //RFC 6874, with relaxed parsing rules - IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"), - IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"), - //RFC 6874 - REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"), - HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$), - PORT$ = subexp(DIGIT$$ + "*"), - AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"), - PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")), - SEGMENT$ = subexp(PCHAR$ + "*"), - SEGMENT_NZ$ = subexp(PCHAR$ + "+"), - SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"), - PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"), - PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"), - //simplified - PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$), - //simplified - PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$), - //simplified - PATH_EMPTY$ = "(?!" + PCHAR$ + ")", - PATH$ = subexp(PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$), - QUERY$ = subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*"), - FRAGMENT$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"), - HIER_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$), - URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"), - RELATIVE_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$), - RELATIVE$ = subexp(RELATIVE_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"), - URI_REFERENCE$ = subexp(URI$ + "|" + RELATIVE$), - ABSOLUTE_URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?"), - GENERIC_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$", - RELATIVE_REF$ = "^(){0}" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$", - ABSOLUTE_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?$", - SAMEDOC_REF$ = "^" + subexp("\\#(" + FRAGMENT$ + ")") + "?$", - AUTHORITY_REF$ = "^" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?$"; - return { - NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"), - NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"), - NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"), - NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"), - NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"), - NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"), - NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"), - ESCAPE: new RegExp(merge("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"), - UNRESERVED: new RegExp(UNRESERVED$$, "g"), - OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$, RESERVED$$), "g"), - PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"), - IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"), - IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules - }; -} -var URI_PROTOCOL = buildExps(false); - -var IRI_PROTOCOL = buildExps(true); - -var slicedToArray = function () { - function sliceIterator(arr, i) { - var _arr = []; - var _n = true; - var _d = false; - var _e = undefined; - - try { - for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { - _arr.push(_s.value); - - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally { - try { - if (!_n && _i["return"]) _i["return"](); - } finally { - if (_d) throw _e; - } - } - - return _arr; - } - - return function (arr, i) { - if (Array.isArray(arr)) { - return arr; - } else if (Symbol.iterator in Object(arr)) { - return sliceIterator(arr, i); - } else { - throw new TypeError("Invalid attempt to destructure non-iterable instance"); - } - }; -}(); - - - - - - - - - - - - - -var toConsumableArray = function (arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; - - return arr2; - } else { - return Array.from(arr); - } -}; - -/** Highest positive signed 32-bit float value */ - -var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1 - -/** Bootstring parameters */ -var base = 36; -var tMin = 1; -var tMax = 26; -var skew = 38; -var damp = 700; -var initialBias = 72; -var initialN = 128; // 0x80 -var delimiter = '-'; // '\x2D' - -/** Regular expressions */ -var regexPunycode = /^xn--/; -var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars -var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators - -/** Error messages */ -var errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' -}; - -/** Convenience shortcuts */ -var baseMinusTMin = base - tMin; -var floor = Math.floor; -var stringFromCharCode = String.fromCharCode; - -/*--------------------------------------------------------------------------*/ - -/** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ -function error$1(type) { - throw new RangeError(errors[type]); -} - -/** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ -function map(array, fn) { - var result = []; - var length = array.length; - while (length--) { - result[length] = fn(array[length]); - } - return result; -} - -/** - * A simple `Array#map`-like wrapper to work with domain name strings or email - * addresses. - * @private - * @param {String} domain The domain name or email address. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ -function mapDomain(string, fn) { - var parts = string.split('@'); - var result = ''; - if (parts.length > 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - // Avoid `split(regex)` for IE8 compatibility. See #17. - string = string.replace(regexSeparators, '\x2E'); - var labels = string.split('.'); - var encoded = map(labels, fn).join('.'); - return result + encoded; -} - -/** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ -function ucs2decode(string) { - var output = []; - var counter = 0; - var length = string.length; - while (counter < length) { - var value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // It's a high surrogate, and there is a next character. - var extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { - // Low surrogate. - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // It's an unmatched surrogate; only append this code unit, in case the - // next code unit is the high surrogate of a surrogate pair. - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; -} - -/** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ -var ucs2encode = function ucs2encode(array) { - return String.fromCodePoint.apply(String, toConsumableArray(array)); -}; - -/** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ -var basicToDigit = function basicToDigit(codePoint) { - if (codePoint - 0x30 < 0x0A) { - return codePoint - 0x16; - } - if (codePoint - 0x41 < 0x1A) { - return codePoint - 0x41; - } - if (codePoint - 0x61 < 0x1A) { - return codePoint - 0x61; - } - return base; -}; - -/** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ -var digitToBasic = function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); -}; - -/** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ -var adapt = function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); -}; - -/** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ -var decode = function decode(input) { - // Don't use UCS-2. - var output = []; - var inputLength = input.length; - var i = 0; - var n = initialN; - var bias = initialBias; - - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. - - var basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } - - for (var j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error$1('not-basic'); - } - output.push(input.charCodeAt(j)); - } - - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. - - for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{ - - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - var oldi = i; - for (var w = 1, k = base;; /* no condition */k += base) { - - if (index >= inputLength) { - error$1('invalid-input'); - } - - var digit = basicToDigit(input.charCodeAt(index++)); - - if (digit >= base || digit > floor((maxInt - i) / w)) { - error$1('overflow'); - } - - i += digit * w; - var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias; - - if (digit < t) { - break; - } - - var baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error$1('overflow'); - } - - w *= baseMinusT; - } - - var out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); - - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error$1('overflow'); - } - - n += floor(i / out); - i %= out; - - // Insert `n` at position `i` of the output. - output.splice(i++, 0, n); - } - - return String.fromCodePoint.apply(String, output); -}; - -/** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ -var encode = function encode(input) { - var output = []; - - // Convert the input in UCS-2 to an array of Unicode code points. - input = ucs2decode(input); - - // Cache the length. - var inputLength = input.length; - - // Initialize the state. - var n = initialN; - var delta = 0; - var bias = initialBias; - - // Handle the basic code points. - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var _currentValue2 = _step.value; - - if (_currentValue2 < 0x80) { - output.push(stringFromCharCode(_currentValue2)); - } - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - var basicLength = output.length; - var handledCPCount = basicLength; - - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. - - // Finish the basic string with a delimiter unless it's empty. - if (basicLength) { - output.push(delimiter); - } - - // Main encoding loop: - while (handledCPCount < inputLength) { - - // All non-basic code points < n have been handled already. Find the next - // larger one: - var m = maxInt; - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var currentValue = _step2.value; - - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } - - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow. - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - - var handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error$1('overflow'); - } - - delta += (m - n) * handledCPCountPlusOne; - n = m; - - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var _currentValue = _step3.value; - - if (_currentValue < n && ++delta > maxInt) { - error$1('overflow'); - } - if (_currentValue == n) { - // Represent delta as a generalized variable-length integer. - var q = delta; - for (var k = base;; /* no condition */k += base) { - var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias; - if (q < t) { - break; - } - var qMinusT = q - t; - var baseMinusT = base - t; - output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))); - q = floor(qMinusT / baseMinusT); - } - - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } - - ++delta; - ++n; - } - return output.join(''); -}; - -/** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. - * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ -var toUnicode = function toUnicode(input) { - return mapDomain(input, function (string) { - return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string; - }); -}; - -/** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. - * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. - */ -var toASCII = function toASCII(input) { - return mapDomain(input, function (string) { - return regexNonASCII.test(string) ? 'xn--' + encode(string) : string; - }); -}; - -/*--------------------------------------------------------------------------*/ - -/** Define the public API */ -var punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '2.1.0', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode -}; - -/** - * URI.js - * - * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript. - * @author Gary Court - * @see http://github.com/garycourt/uri-js - */ -/** - * Copyright 2011 Gary Court. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of Gary Court. - */ -var SCHEMES = {}; -function pctEncChar(chr) { - var c = chr.charCodeAt(0); - var e = void 0; - if (c < 16) e = "%0" + c.toString(16).toUpperCase();else if (c < 128) e = "%" + c.toString(16).toUpperCase();else if (c < 2048) e = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();else e = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase(); - return e; -} -function pctDecChars(str) { - var newStr = ""; - var i = 0; - var il = str.length; - while (i < il) { - var c = parseInt(str.substr(i + 1, 2), 16); - if (c < 128) { - newStr += String.fromCharCode(c); - i += 3; - } else if (c >= 194 && c < 224) { - if (il - i >= 6) { - var c2 = parseInt(str.substr(i + 4, 2), 16); - newStr += String.fromCharCode((c & 31) << 6 | c2 & 63); - } else { - newStr += str.substr(i, 6); - } - i += 6; - } else if (c >= 224) { - if (il - i >= 9) { - var _c = parseInt(str.substr(i + 4, 2), 16); - var c3 = parseInt(str.substr(i + 7, 2), 16); - newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63); - } else { - newStr += str.substr(i, 9); - } - i += 9; - } else { - newStr += str.substr(i, 3); - i += 3; - } - } - return newStr; -} -function _normalizeComponentEncoding(components, protocol) { - function decodeUnreserved(str) { - var decStr = pctDecChars(str); - return !decStr.match(protocol.UNRESERVED) ? str : decStr; - } - if (components.scheme) components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, ""); - if (components.userinfo !== undefined) components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase); - if (components.host !== undefined) components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase); - if (components.path !== undefined) components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase); - if (components.query !== undefined) components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase); - if (components.fragment !== undefined) components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase); - return components; -} - -function _stripLeadingZeros(str) { - return str.replace(/^0*(.*)/, "$1") || "0"; -} -function _normalizeIPv4(host, protocol) { - var matches = host.match(protocol.IPV4ADDRESS) || []; - - var _matches = slicedToArray(matches, 2), - address = _matches[1]; - - if (address) { - return address.split(".").map(_stripLeadingZeros).join("."); - } else { - return host; - } -} -function _normalizeIPv6(host, protocol) { - var matches = host.match(protocol.IPV6ADDRESS) || []; - - var _matches2 = slicedToArray(matches, 3), - address = _matches2[1], - zone = _matches2[2]; - - if (address) { - var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(), - _address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2), - last = _address$toLowerCase$2[0], - first = _address$toLowerCase$2[1]; - - var firstFields = first ? first.split(":").map(_stripLeadingZeros) : []; - var lastFields = last.split(":").map(_stripLeadingZeros); - var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]); - var fieldCount = isLastFieldIPv4Address ? 7 : 8; - var lastFieldsStart = lastFields.length - fieldCount; - var fields = Array(fieldCount); - for (var x = 0; x < fieldCount; ++x) { - fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || ''; - } - if (isLastFieldIPv4Address) { - fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol); - } - var allZeroFields = fields.reduce(function (acc, field, index) { - if (!field || field === "0") { - var lastLongest = acc[acc.length - 1]; - if (lastLongest && lastLongest.index + lastLongest.length === index) { - lastLongest.length++; - } else { - acc.push({ index: index, length: 1 }); - } - } - return acc; - }, []); - var longestZeroFields = allZeroFields.sort(function (a, b) { - return b.length - a.length; - })[0]; - var newHost = void 0; - if (longestZeroFields && longestZeroFields.length > 1) { - var newFirst = fields.slice(0, longestZeroFields.index); - var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length); - newHost = newFirst.join(":") + "::" + newLast.join(":"); - } else { - newHost = fields.join(":"); - } - if (zone) { - newHost += "%" + zone; - } - return newHost; - } else { - return host; - } -} -var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i; -var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined; -function parse(uriString) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - var components = {}; - var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL; - if (options.reference === "suffix") uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString; - var matches = uriString.match(URI_PARSE); - if (matches) { - if (NO_MATCH_IS_UNDEFINED) { - //store each component - components.scheme = matches[1]; - components.userinfo = matches[3]; - components.host = matches[4]; - components.port = parseInt(matches[5], 10); - components.path = matches[6] || ""; - components.query = matches[7]; - components.fragment = matches[8]; - //fix port number - if (isNaN(components.port)) { - components.port = matches[5]; - } - } else { - //IE FIX for improper RegExp matching - //store each component - components.scheme = matches[1] || undefined; - components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined; - components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined; - components.port = parseInt(matches[5], 10); - components.path = matches[6] || ""; - components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined; - components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined; - //fix port number - if (isNaN(components.port)) { - components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined; - } - } - if (components.host) { - //normalize IP hosts - components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol); - } - //determine reference type - if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) { - components.reference = "same-document"; - } else if (components.scheme === undefined) { - components.reference = "relative"; - } else if (components.fragment === undefined) { - components.reference = "absolute"; - } else { - components.reference = "uri"; - } - //check for reference errors - if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) { - components.error = components.error || "URI is not a " + options.reference + " reference."; - } - //find scheme handler - var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; - //check if scheme can't handle IRIs - if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) { - //if host component is a domain name - if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) { - //convert Unicode IDN -> ASCII IDN - try { - components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()); - } catch (e) { - components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e; - } - } - //convert IRI -> URI - _normalizeComponentEncoding(components, URI_PROTOCOL); - } else { - //normalize encodings - _normalizeComponentEncoding(components, protocol); - } - //perform scheme specific parsing - if (schemeHandler && schemeHandler.parse) { - schemeHandler.parse(components, options); - } - } else { - components.error = components.error || "URI can not be parsed."; - } - return components; -} - -function _recomposeAuthority(components, options) { - var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL; - var uriTokens = []; - if (components.userinfo !== undefined) { - uriTokens.push(components.userinfo); - uriTokens.push("@"); - } - if (components.host !== undefined) { - //normalize IP hosts, add brackets and escape zone separator for IPv6 - uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) { - return "[" + $1 + ($2 ? "%25" + $2 : "") + "]"; - })); - } - if (typeof components.port === "number" || typeof components.port === "string") { - uriTokens.push(":"); - uriTokens.push(String(components.port)); - } - return uriTokens.length ? uriTokens.join("") : undefined; -} - -var RDS1 = /^\.\.?\//; -var RDS2 = /^\/\.(\/|$)/; -var RDS3 = /^\/\.\.(\/|$)/; -var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/; -function removeDotSegments(input) { - var output = []; - while (input.length) { - if (input.match(RDS1)) { - input = input.replace(RDS1, ""); - } else if (input.match(RDS2)) { - input = input.replace(RDS2, "/"); - } else if (input.match(RDS3)) { - input = input.replace(RDS3, "/"); - output.pop(); - } else if (input === "." || input === "..") { - input = ""; - } else { - var im = input.match(RDS5); - if (im) { - var s = im[0]; - input = input.slice(s.length); - output.push(s); - } else { - throw new Error("Unexpected dot segment condition"); - } - } - } - return output.join(""); -} - -function serialize(components) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL; - var uriTokens = []; - //find scheme handler - var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; - //perform scheme specific serialization - if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options); - if (components.host) { - //if host component is an IPv6 address - if (protocol.IPV6ADDRESS.test(components.host)) {} - //TODO: normalize IPv6 address as per RFC 5952 - - //if host component is a domain name - else if (options.domainHost || schemeHandler && schemeHandler.domainHost) { - //convert IDN via punycode - try { - components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host); - } catch (e) { - components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e; - } - } - } - //normalize encoding - _normalizeComponentEncoding(components, protocol); - if (options.reference !== "suffix" && components.scheme) { - uriTokens.push(components.scheme); - uriTokens.push(":"); - } - var authority = _recomposeAuthority(components, options); - if (authority !== undefined) { - if (options.reference !== "suffix") { - uriTokens.push("//"); - } - uriTokens.push(authority); - if (components.path && components.path.charAt(0) !== "/") { - uriTokens.push("/"); - } - } - if (components.path !== undefined) { - var s = components.path; - if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) { - s = removeDotSegments(s); - } - if (authority === undefined) { - s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//" - } - uriTokens.push(s); - } - if (components.query !== undefined) { - uriTokens.push("?"); - uriTokens.push(components.query); - } - if (components.fragment !== undefined) { - uriTokens.push("#"); - uriTokens.push(components.fragment); - } - return uriTokens.join(""); //merge tokens into a string -} - -function resolveComponents(base, relative) { - var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - var skipNormalization = arguments[3]; - - var target = {}; - if (!skipNormalization) { - base = parse(serialize(base, options), options); //normalize base components - relative = parse(serialize(relative, options), options); //normalize relative components - } - options = options || {}; - if (!options.tolerant && relative.scheme) { - target.scheme = relative.scheme; - //target.authority = relative.authority; - target.userinfo = relative.userinfo; - target.host = relative.host; - target.port = relative.port; - target.path = removeDotSegments(relative.path || ""); - target.query = relative.query; - } else { - if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) { - //target.authority = relative.authority; - target.userinfo = relative.userinfo; - target.host = relative.host; - target.port = relative.port; - target.path = removeDotSegments(relative.path || ""); - target.query = relative.query; - } else { - if (!relative.path) { - target.path = base.path; - if (relative.query !== undefined) { - target.query = relative.query; - } else { - target.query = base.query; - } - } else { - if (relative.path.charAt(0) === "/") { - target.path = removeDotSegments(relative.path); - } else { - if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) { - target.path = "/" + relative.path; - } else if (!base.path) { - target.path = relative.path; - } else { - target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path; - } - target.path = removeDotSegments(target.path); - } - target.query = relative.query; - } - //target.authority = base.authority; - target.userinfo = base.userinfo; - target.host = base.host; - target.port = base.port; - } - target.scheme = base.scheme; - } - target.fragment = relative.fragment; - return target; -} - -function resolve(baseURI, relativeURI, options) { - var schemelessOptions = assign({ scheme: 'null' }, options); - return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions); -} - -function normalize(uri, options) { - if (typeof uri === "string") { - uri = serialize(parse(uri, options), options); - } else if (typeOf(uri) === "object") { - uri = parse(serialize(uri, options), options); - } - return uri; -} - -function equal(uriA, uriB, options) { - if (typeof uriA === "string") { - uriA = serialize(parse(uriA, options), options); - } else if (typeOf(uriA) === "object") { - uriA = serialize(uriA, options); - } - if (typeof uriB === "string") { - uriB = serialize(parse(uriB, options), options); - } else if (typeOf(uriB) === "object") { - uriB = serialize(uriB, options); - } - return uriA === uriB; -} - -function escapeComponent(str, options) { - return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar); -} - -function unescapeComponent(str, options) { - return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars); -} - -var handler = { - scheme: "http", - domainHost: true, - parse: function parse(components, options) { - //report missing host - if (!components.host) { - components.error = components.error || "HTTP URIs must have a host."; - } - return components; - }, - serialize: function serialize(components, options) { - var secure = String(components.scheme).toLowerCase() === "https"; - //normalize the default port - if (components.port === (secure ? 443 : 80) || components.port === "") { - components.port = undefined; - } - //normalize the empty path - if (!components.path) { - components.path = "/"; - } - //NOTE: We do not parse query strings for HTTP URIs - //as WWW Form Url Encoded query strings are part of the HTML4+ spec, - //and not the HTTP spec. - return components; - } -}; - -var handler$1 = { - scheme: "https", - domainHost: handler.domainHost, - parse: handler.parse, - serialize: handler.serialize -}; - -function isSecure(wsComponents) { - return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss"; -} -//RFC 6455 -var handler$2 = { - scheme: "ws", - domainHost: true, - parse: function parse(components, options) { - var wsComponents = components; - //indicate if the secure flag is set - wsComponents.secure = isSecure(wsComponents); - //construct resouce name - wsComponents.resourceName = (wsComponents.path || '/') + (wsComponents.query ? '?' + wsComponents.query : ''); - wsComponents.path = undefined; - wsComponents.query = undefined; - return wsComponents; - }, - serialize: function serialize(wsComponents, options) { - //normalize the default port - if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") { - wsComponents.port = undefined; - } - //ensure scheme matches secure flag - if (typeof wsComponents.secure === 'boolean') { - wsComponents.scheme = wsComponents.secure ? 'wss' : 'ws'; - wsComponents.secure = undefined; - } - //reconstruct path from resource name - if (wsComponents.resourceName) { - var _wsComponents$resourc = wsComponents.resourceName.split('?'), - _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2), - path = _wsComponents$resourc2[0], - query = _wsComponents$resourc2[1]; - - wsComponents.path = path && path !== '/' ? path : undefined; - wsComponents.query = query; - wsComponents.resourceName = undefined; - } - //forbid fragment component - wsComponents.fragment = undefined; - return wsComponents; - } -}; - -var handler$3 = { - scheme: "wss", - domainHost: handler$2.domainHost, - parse: handler$2.parse, - serialize: handler$2.serialize -}; - -var O = {}; -var isIRI = true; -//RFC 3986 -var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + (isIRI ? "\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" : "") + "]"; -var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive -var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded -//RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; = -//const ATEXT$$ = "[A-Za-z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]"; -//const WSP$$ = "[\\x20\\x09]"; -//const OBS_QTEXT$$ = "[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]"; //(%d1-8 / %d11-12 / %d14-31 / %d127) -//const QTEXT$$ = merge("[\\x21\\x23-\\x5B\\x5D-\\x7E]", OBS_QTEXT$$); //%d33 / %d35-91 / %d93-126 / obs-qtext -//const VCHAR$$ = "[\\x21-\\x7E]"; -//const WSP$$ = "[\\x20\\x09]"; -//const OBS_QP$ = subexp("\\\\" + merge("[\\x00\\x0D\\x0A]", OBS_QTEXT$$)); //%d0 / CR / LF / obs-qtext -//const FWS$ = subexp(subexp(WSP$$ + "*" + "\\x0D\\x0A") + "?" + WSP$$ + "+"); -//const QUOTED_PAIR$ = subexp(subexp("\\\\" + subexp(VCHAR$$ + "|" + WSP$$)) + "|" + OBS_QP$); -//const QUOTED_STRING$ = subexp('\\"' + subexp(FWS$ + "?" + QCONTENT$) + "*" + FWS$ + "?" + '\\"'); -var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]"; -var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]"; -var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]"); -var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]"; -var UNRESERVED = new RegExp(UNRESERVED$$, "g"); -var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g"); -var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", '[\\"]', VCHAR$$), "g"); -var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g"); -var NOT_HFVALUE = NOT_HFNAME; -function decodeUnreserved(str) { - var decStr = pctDecChars(str); - return !decStr.match(UNRESERVED) ? str : decStr; -} -var handler$4 = { - scheme: "mailto", - parse: function parse$$1(components, options) { - var mailtoComponents = components; - var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : []; - mailtoComponents.path = undefined; - if (mailtoComponents.query) { - var unknownHeaders = false; - var headers = {}; - var hfields = mailtoComponents.query.split("&"); - for (var x = 0, xl = hfields.length; x < xl; ++x) { - var hfield = hfields[x].split("="); - switch (hfield[0]) { - case "to": - var toAddrs = hfield[1].split(","); - for (var _x = 0, _xl = toAddrs.length; _x < _xl; ++_x) { - to.push(toAddrs[_x]); - } - break; - case "subject": - mailtoComponents.subject = unescapeComponent(hfield[1], options); - break; - case "body": - mailtoComponents.body = unescapeComponent(hfield[1], options); - break; - default: - unknownHeaders = true; - headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options); - break; - } - } - if (unknownHeaders) mailtoComponents.headers = headers; - } - mailtoComponents.query = undefined; - for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) { - var addr = to[_x2].split("@"); - addr[0] = unescapeComponent(addr[0]); - if (!options.unicodeSupport) { - //convert Unicode IDN -> ASCII IDN - try { - addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase()); - } catch (e) { - mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e; - } - } else { - addr[1] = unescapeComponent(addr[1], options).toLowerCase(); - } - to[_x2] = addr.join("@"); - } - return mailtoComponents; - }, - serialize: function serialize$$1(mailtoComponents, options) { - var components = mailtoComponents; - var to = toArray(mailtoComponents.to); - if (to) { - for (var x = 0, xl = to.length; x < xl; ++x) { - var toAddr = String(to[x]); - var atIdx = toAddr.lastIndexOf("@"); - var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar); - var domain = toAddr.slice(atIdx + 1); - //convert IDN via punycode - try { - domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain); - } catch (e) { - components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e; - } - to[x] = localPart + "@" + domain; - } - components.path = to.join(","); - } - var headers = mailtoComponents.headers = mailtoComponents.headers || {}; - if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject; - if (mailtoComponents.body) headers["body"] = mailtoComponents.body; - var fields = []; - for (var name in headers) { - if (headers[name] !== O[name]) { - fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar)); - } - } - if (fields.length) { - components.query = fields.join("&"); - } - return components; - } -}; - -var URN_PARSE = /^([^\:]+)\:(.*)/; -//RFC 2141 -var handler$5 = { - scheme: "urn", - parse: function parse$$1(components, options) { - var matches = components.path && components.path.match(URN_PARSE); - var urnComponents = components; - if (matches) { - var scheme = options.scheme || urnComponents.scheme || "urn"; - var nid = matches[1].toLowerCase(); - var nss = matches[2]; - var urnScheme = scheme + ":" + (options.nid || nid); - var schemeHandler = SCHEMES[urnScheme]; - urnComponents.nid = nid; - urnComponents.nss = nss; - urnComponents.path = undefined; - if (schemeHandler) { - urnComponents = schemeHandler.parse(urnComponents, options); - } - } else { - urnComponents.error = urnComponents.error || "URN can not be parsed."; - } - return urnComponents; - }, - serialize: function serialize$$1(urnComponents, options) { - var scheme = options.scheme || urnComponents.scheme || "urn"; - var nid = urnComponents.nid; - var urnScheme = scheme + ":" + (options.nid || nid); - var schemeHandler = SCHEMES[urnScheme]; - if (schemeHandler) { - urnComponents = schemeHandler.serialize(urnComponents, options); - } - var uriComponents = urnComponents; - var nss = urnComponents.nss; - uriComponents.path = (nid || options.nid) + ":" + nss; - return uriComponents; - } -}; - -var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/; -//RFC 4122 -var handler$6 = { - scheme: "urn:uuid", - parse: function parse(urnComponents, options) { - var uuidComponents = urnComponents; - uuidComponents.uuid = uuidComponents.nss; - uuidComponents.nss = undefined; - if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) { - uuidComponents.error = uuidComponents.error || "UUID is not valid."; - } - return uuidComponents; - }, - serialize: function serialize(uuidComponents, options) { - var urnComponents = uuidComponents; - //normalize UUID - urnComponents.nss = (uuidComponents.uuid || "").toLowerCase(); - return urnComponents; - } -}; - -SCHEMES[handler.scheme] = handler; -SCHEMES[handler$1.scheme] = handler$1; -SCHEMES[handler$2.scheme] = handler$2; -SCHEMES[handler$3.scheme] = handler$3; -SCHEMES[handler$4.scheme] = handler$4; -SCHEMES[handler$5.scheme] = handler$5; -SCHEMES[handler$6.scheme] = handler$6; - -exports.SCHEMES = SCHEMES; -exports.pctEncChar = pctEncChar; -exports.pctDecChars = pctDecChars; -exports.parse = parse; -exports.removeDotSegments = removeDotSegments; -exports.serialize = serialize; -exports.resolveComponents = resolveComponents; -exports.resolve = resolve; -exports.normalize = normalize; -exports.equal = equal; -exports.escapeComponent = escapeComponent; -exports.unescapeComponent = unescapeComponent; - -Object.defineProperty(exports, '__esModule', { value: true }); - -}))); -//# sourceMappingURL=uri.all.js.map - - /***/ }), /***/ 66931: @@ -200208,7 +189603,7 @@ module.exports = Logger; /***/ }), /***/ 42458: -/***/ ((module) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; /** @@ -200219,13 +189614,12 @@ module.exports = Logger; */ - /** * TODO: add class description. * @type {Profiler} * @private */ -module.exports = class Profiler { +class Profiler { /** * Constructor function for the Profiler instance used by * `Logger.prototype.startTimer`. When done is called the timer will finish @@ -200234,12 +189628,13 @@ module.exports = class Profiler { * @private */ constructor(logger) { - if (!logger) { - throw new Error('Logger is required for profiling.'); + const Logger = __nccwpck_require__(55437); + if (typeof logger !== 'object' || Array.isArray(logger) || !(logger instanceof Logger)) { + throw new Error('Logger is required for profiling'); + } else { + this.logger = logger; + this.start = Date.now(); } - - this.logger = logger; - this.start = Date.now(); } /** @@ -200263,6 +189658,8 @@ module.exports = class Profiler { } }; +module.exports = Profiler; + /***/ }), @@ -202672,14 +192069,6 @@ module.exports = eval("require")("@azure/functions-core"); module.exports = eval("require")("encoding"); -/***/ }), - -/***/ 91128: -/***/ ((module) => { - -module.exports = eval("require")("long"); - - /***/ }), /***/ 21462: @@ -202975,7 +192364,7 @@ module.exports = require("zlib"); /***/ }), -/***/ 11333: +/***/ 23231: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; @@ -203012,7 +192401,7 @@ module.exports = function CheckObjectCoercible(value, optMessage) { /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -// Axios v1.4.0 Copyright (c) 2023 Matt Zabriskie and contributors +// Axios v1.6.2 Copyright (c) 2023 Matt Zabriskie and contributors const FormData$1 = __nccwpck_require__(63082); @@ -203582,8 +192971,9 @@ const reduceDescriptors = (obj, reducer) => { const reducedDescriptors = {}; forEach(descriptors, (descriptor, name) => { - if (reducer(descriptor, name, obj) !== false) { - reducedDescriptors[name] = descriptor; + let ret; + if ((ret = reducer(descriptor, name, obj)) !== false) { + reducedDescriptors[name] = ret || descriptor; } }); @@ -203709,7 +193099,7 @@ const isAsyncFn = kindOfTest('AsyncFunction'); const isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch); -const utils = { +const utils$1 = { isArray, isArrayBuffer, isBuffer, @@ -203791,7 +193181,7 @@ function AxiosError(message, code, config, request, response) { response && (this.response = response); } -utils.inherits(AxiosError, Error, { +utils$1.inherits(AxiosError, Error, { toJSON: function toJSON() { return { // Standard @@ -203806,7 +193196,7 @@ utils.inherits(AxiosError, Error, { columnNumber: this.columnNumber, stack: this.stack, // Axios - config: utils.toJSONObject(this.config), + config: utils$1.toJSONObject(this.config), code: this.code, status: this.response && this.response.status ? this.response.status : null }; @@ -203841,7 +193231,7 @@ Object.defineProperty(prototype$1, 'isAxiosError', {value: true}); AxiosError.from = (error, code, config, request, response, customProps) => { const axiosError = Object.create(prototype$1); - utils.toFlatObject(error, axiosError, function filter(obj) { + utils$1.toFlatObject(error, axiosError, function filter(obj) { return obj !== Error.prototype; }, prop => { return prop !== 'isAxiosError'; @@ -203866,7 +193256,7 @@ AxiosError.from = (error, code, config, request, response, customProps) => { * @returns {boolean} */ function isVisitable(thing) { - return utils.isPlainObject(thing) || utils.isArray(thing); + return utils$1.isPlainObject(thing) || utils$1.isArray(thing); } /** @@ -203877,7 +193267,7 @@ function isVisitable(thing) { * @returns {string} the key without the brackets. */ function removeBrackets(key) { - return utils.endsWith(key, '[]') ? key.slice(0, -2) : key; + return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key; } /** @@ -203906,10 +193296,10 @@ function renderKey(path, key, dots) { * @returns {boolean} */ function isFlatArray(arr) { - return utils.isArray(arr) && !arr.some(isVisitable); + return utils$1.isArray(arr) && !arr.some(isVisitable); } -const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) { +const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) { return /^is[A-Z]/.test(prop); }); @@ -203937,7 +193327,7 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) { * @returns */ function toFormData(obj, formData, options) { - if (!utils.isObject(obj)) { + if (!utils$1.isObject(obj)) { throw new TypeError('target must be an object'); } @@ -203945,13 +193335,13 @@ function toFormData(obj, formData, options) { formData = formData || new (FormData__default["default"] || FormData)(); // eslint-disable-next-line no-param-reassign - options = utils.toFlatObject(options, { + options = utils$1.toFlatObject(options, { metaTokens: true, dots: false, indexes: false }, false, function defined(option, source) { // eslint-disable-next-line no-eq-null,eqeqeq - return !utils.isUndefined(source[option]); + return !utils$1.isUndefined(source[option]); }); const metaTokens = options.metaTokens; @@ -203960,24 +193350,24 @@ function toFormData(obj, formData, options) { const dots = options.dots; const indexes = options.indexes; const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob; - const useBlob = _Blob && utils.isSpecCompliantForm(formData); + const useBlob = _Blob && utils$1.isSpecCompliantForm(formData); - if (!utils.isFunction(visitor)) { + if (!utils$1.isFunction(visitor)) { throw new TypeError('visitor must be a function'); } function convertValue(value) { if (value === null) return ''; - if (utils.isDate(value)) { + if (utils$1.isDate(value)) { return value.toISOString(); } - if (!useBlob && utils.isBlob(value)) { + if (!useBlob && utils$1.isBlob(value)) { throw new AxiosError('Blob is not supported. Use a Buffer instead.'); } - if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) { + if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) { return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value); } @@ -203998,20 +193388,20 @@ function toFormData(obj, formData, options) { let arr = value; if (value && !path && typeof value === 'object') { - if (utils.endsWith(key, '{}')) { + if (utils$1.endsWith(key, '{}')) { // eslint-disable-next-line no-param-reassign key = metaTokens ? key : key.slice(0, -2); // eslint-disable-next-line no-param-reassign value = JSON.stringify(value); } else if ( - (utils.isArray(value) && isFlatArray(value)) || - ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value)) + (utils$1.isArray(value) && isFlatArray(value)) || + ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)) )) { // eslint-disable-next-line no-param-reassign key = removeBrackets(key); arr.forEach(function each(el, index) { - !(utils.isUndefined(el) || el === null) && formData.append( + !(utils$1.isUndefined(el) || el === null) && formData.append( // eslint-disable-next-line no-nested-ternary indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'), convertValue(el) @@ -204039,7 +193429,7 @@ function toFormData(obj, formData, options) { }); function build(value, path) { - if (utils.isUndefined(value)) return; + if (utils$1.isUndefined(value)) return; if (stack.indexOf(value) !== -1) { throw Error('Circular reference detected in ' + path.join('.')); @@ -204047,9 +193437,9 @@ function toFormData(obj, formData, options) { stack.push(value); - utils.forEach(value, function each(el, key) { - const result = !(utils.isUndefined(el) || el === null) && visitor.call( - formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers + utils$1.forEach(value, function each(el, key) { + const result = !(utils$1.isUndefined(el) || el === null) && visitor.call( + formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers ); if (result === true) { @@ -204060,7 +193450,7 @@ function toFormData(obj, formData, options) { stack.pop(); } - if (!utils.isObject(obj)) { + if (!utils$1.isObject(obj)) { throw new TypeError('data must be an object'); } @@ -204164,7 +193554,7 @@ function buildURL(url, params, options) { if (serializeFn) { serializedParams = serializeFn(params, options); } else { - serializedParams = utils.isURLSearchParams(params) ? + serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode); } @@ -204239,7 +193629,7 @@ class InterceptorManager { * @returns {void} */ forEach(fn) { - utils.forEach(this.handlers, function forEachHandler(h) { + utils$1.forEach(this.handlers, function forEachHandler(h) { if (h !== null) { fn(h); } @@ -204257,7 +193647,7 @@ const transitionalDefaults = { const URLSearchParams = url__default["default"].URLSearchParams; -const platform = { +const platform$1 = { isNode: true, classes: { URLSearchParams, @@ -204267,10 +193657,64 @@ const platform = { protocols: [ 'http', 'https', 'file', 'data' ] }; +const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined'; + +/** + * Determine if we're running in a standard browser environment + * + * This allows axios to run in a web worker, and react-native. + * Both environments support XMLHttpRequest, but not fully standard globals. + * + * web workers: + * typeof window -> undefined + * typeof document -> undefined + * + * react-native: + * navigator.product -> 'ReactNative' + * nativescript + * navigator.product -> 'NativeScript' or 'NS' + * + * @returns {boolean} + */ +const hasStandardBrowserEnv = ( + (product) => { + return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0 + })(typeof navigator !== 'undefined' && navigator.product); + +/** + * Determine if we're running in a standard browser webWorker environment + * + * Although the `isStandardBrowserEnv` method indicates that + * `allows axios to run in a web worker`, the WebWorker will still be + * filtered out due to its judgment standard + * `typeof window !== 'undefined' && typeof document !== 'undefined'`. + * This leads to a problem when axios post `FormData` in webWorker + */ +const hasStandardBrowserWebWorkerEnv = (() => { + return ( + typeof WorkerGlobalScope !== 'undefined' && + // eslint-disable-next-line no-undef + self instanceof WorkerGlobalScope && + typeof self.importScripts === 'function' + ); +})(); + +const utils = /*#__PURE__*/Object.freeze({ + __proto__: null, + hasBrowserEnv: hasBrowserEnv, + hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv, + hasStandardBrowserEnv: hasStandardBrowserEnv +}); + +const platform = { + ...utils, + ...platform$1 +}; + function toURLEncodedForm(data, options) { return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({ visitor: function(value, key, path, helpers) { - if (utils.isBuffer(value)) { + if (platform.isNode && utils$1.isBuffer(value)) { this.append(key, value.toString('base64')); return false; } @@ -204292,7 +193736,7 @@ function parsePropPath(name) { // foo.x.y.z // foo-x-y-z // foo x y z - return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => { + return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => { return match[0] === '[]' ? '' : match[1] || match[0]; }); } @@ -204329,10 +193773,10 @@ function formDataToJSON(formData) { let name = path[index++]; const isNumericKey = Number.isFinite(+name); const isLast = index >= path.length; - name = !name && utils.isArray(target) ? target.length : name; + name = !name && utils$1.isArray(target) ? target.length : name; if (isLast) { - if (utils.hasOwnProp(target, name)) { + if (utils$1.hasOwnProp(target, name)) { target[name] = [target[name], value]; } else { target[name] = value; @@ -204341,23 +193785,23 @@ function formDataToJSON(formData) { return !isNumericKey; } - if (!target[name] || !utils.isObject(target[name])) { + if (!target[name] || !utils$1.isObject(target[name])) { target[name] = []; } const result = buildPath(path, value, target[name], index); - if (result && utils.isArray(target[name])) { + if (result && utils$1.isArray(target[name])) { target[name] = arrayToObject(target[name]); } return !isNumericKey; } - if (utils.isFormData(formData) && utils.isFunction(formData.entries)) { + if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) { const obj = {}; - utils.forEachEntry(formData, (name, value) => { + utils$1.forEachEntry(formData, (name, value) => { buildPath(parsePropPath(name), value, obj, 0); }); @@ -204367,10 +193811,6 @@ function formDataToJSON(formData) { return null; } -const DEFAULT_CONTENT_TYPE = { - 'Content-Type': undefined -}; - /** * It takes a string, tries to parse it, and if it fails, it returns the stringified version * of the input @@ -204382,10 +193822,10 @@ const DEFAULT_CONTENT_TYPE = { * @returns {string} A stringified version of the rawValue. */ function stringifySafely(rawValue, parser, encoder) { - if (utils.isString(rawValue)) { + if (utils$1.isString(rawValue)) { try { (parser || JSON.parse)(rawValue); - return utils.trim(rawValue); + return utils$1.trim(rawValue); } catch (e) { if (e.name !== 'SyntaxError') { throw e; @@ -204405,13 +193845,13 @@ const defaults = { transformRequest: [function transformRequest(data, headers) { const contentType = headers.getContentType() || ''; const hasJSONContentType = contentType.indexOf('application/json') > -1; - const isObjectPayload = utils.isObject(data); + const isObjectPayload = utils$1.isObject(data); - if (isObjectPayload && utils.isHTMLForm(data)) { + if (isObjectPayload && utils$1.isHTMLForm(data)) { data = new FormData(data); } - const isFormData = utils.isFormData(data); + const isFormData = utils$1.isFormData(data); if (isFormData) { if (!hasJSONContentType) { @@ -204420,18 +193860,18 @@ const defaults = { return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data; } - if (utils.isArrayBuffer(data) || - utils.isBuffer(data) || - utils.isStream(data) || - utils.isFile(data) || - utils.isBlob(data) + if (utils$1.isArrayBuffer(data) || + utils$1.isBuffer(data) || + utils$1.isStream(data) || + utils$1.isFile(data) || + utils$1.isBlob(data) ) { return data; } - if (utils.isArrayBufferView(data)) { + if (utils$1.isArrayBufferView(data)) { return data.buffer; } - if (utils.isURLSearchParams(data)) { + if (utils$1.isURLSearchParams(data)) { headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false); return data.toString(); } @@ -204443,7 +193883,7 @@ const defaults = { return toURLEncodedForm(data, this.formSerializer).toString(); } - if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) { + if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) { const _FormData = this.env && this.env.FormData; return toFormData( @@ -204467,7 +193907,7 @@ const defaults = { const forcedJSONParsing = transitional && transitional.forcedJSONParsing; const JSONRequested = this.responseType === 'json'; - if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) { + if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) { const silentJSONParsing = transitional && transitional.silentJSONParsing; const strictJSONParsing = !silentJSONParsing && JSONRequested; @@ -204509,24 +193949,21 @@ const defaults = { headers: { common: { - 'Accept': 'application/json, text/plain, */*' + 'Accept': 'application/json, text/plain, */*', + 'Content-Type': undefined } } }; -utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { +utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => { defaults.headers[method] = {}; }); -utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { - defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); -}); - const defaults$1 = defaults; // RawAxiosHeaders whose duplicates are ignored by node // c.f. https://nodejs.org/api/http.html#http_message_headers -const ignoreDuplicateOf = utils.toObjectSet([ +const ignoreDuplicateOf = utils$1.toObjectSet([ 'age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', @@ -204587,7 +194024,7 @@ function normalizeValue(value) { return value; } - return utils.isArray(value) ? value.map(normalizeValue) : String(value); + return utils$1.isArray(value) ? value.map(normalizeValue) : String(value); } function parseTokens(str) { @@ -204605,7 +194042,7 @@ function parseTokens(str) { const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim()); function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) { - if (utils.isFunction(filter)) { + if (utils$1.isFunction(filter)) { return filter.call(this, value, header); } @@ -204613,13 +194050,13 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) { value = header; } - if (!utils.isString(value)) return; + if (!utils$1.isString(value)) return; - if (utils.isString(filter)) { + if (utils$1.isString(filter)) { return value.indexOf(filter) !== -1; } - if (utils.isRegExp(filter)) { + if (utils$1.isRegExp(filter)) { return filter.test(value); } } @@ -204632,7 +194069,7 @@ function formatHeader(header) { } function buildAccessors(obj, header) { - const accessorName = utils.toCamelCase(' ' + header); + const accessorName = utils$1.toCamelCase(' ' + header); ['get', 'set', 'has'].forEach(methodName => { Object.defineProperty(obj, methodName + accessorName, { @@ -204659,7 +194096,7 @@ class AxiosHeaders { throw new Error('header name must be a non-empty string'); } - const key = utils.findKey(self, lHeader); + const key = utils$1.findKey(self, lHeader); if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) { self[key || _header] = normalizeValue(_value); @@ -204667,11 +194104,11 @@ class AxiosHeaders { } const setHeaders = (headers, _rewrite) => - utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite)); + utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite)); - if (utils.isPlainObject(header) || header instanceof this.constructor) { + if (utils$1.isPlainObject(header) || header instanceof this.constructor) { setHeaders(header, valueOrRewrite); - } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) { + } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) { setHeaders(parseHeaders(header), valueOrRewrite); } else { header != null && setHeader(valueOrRewrite, header, rewrite); @@ -204684,7 +194121,7 @@ class AxiosHeaders { header = normalizeHeader(header); if (header) { - const key = utils.findKey(this, header); + const key = utils$1.findKey(this, header); if (key) { const value = this[key]; @@ -204697,11 +194134,11 @@ class AxiosHeaders { return parseTokens(value); } - if (utils.isFunction(parser)) { + if (utils$1.isFunction(parser)) { return parser.call(this, value, key); } - if (utils.isRegExp(parser)) { + if (utils$1.isRegExp(parser)) { return parser.exec(value); } @@ -204714,7 +194151,7 @@ class AxiosHeaders { header = normalizeHeader(header); if (header) { - const key = utils.findKey(this, header); + const key = utils$1.findKey(this, header); return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher))); } @@ -204730,7 +194167,7 @@ class AxiosHeaders { _header = normalizeHeader(_header); if (_header) { - const key = utils.findKey(self, _header); + const key = utils$1.findKey(self, _header); if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) { delete self[key]; @@ -204740,7 +194177,7 @@ class AxiosHeaders { } } - if (utils.isArray(header)) { + if (utils$1.isArray(header)) { header.forEach(deleteHeader); } else { deleteHeader(header); @@ -204769,8 +194206,8 @@ class AxiosHeaders { const self = this; const headers = {}; - utils.forEach(this, (value, header) => { - const key = utils.findKey(headers, header); + utils$1.forEach(this, (value, header) => { + const key = utils$1.findKey(headers, header); if (key) { self[key] = normalizeValue(value); @@ -204799,8 +194236,8 @@ class AxiosHeaders { toJSON(asStrings) { const obj = Object.create(null); - utils.forEach(this, (value, header) => { - value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value); + utils$1.forEach(this, (value, header) => { + value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value); }); return obj; @@ -204847,7 +194284,7 @@ class AxiosHeaders { } } - utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header); + utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header); return this; } @@ -204855,8 +194292,18 @@ class AxiosHeaders { AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']); -utils.freezeMethods(AxiosHeaders.prototype); -utils.freezeMethods(AxiosHeaders); +// reserved names hotfix +utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => { + let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set` + return { + get: () => value, + set(headerValue) { + this[mapped] = headerValue; + } + } +}); + +utils$1.freezeMethods(AxiosHeaders); const AxiosHeaders$1 = AxiosHeaders; @@ -204874,7 +194321,7 @@ function transformData(fns, response) { const headers = AxiosHeaders$1.from(context.headers); let data = context.data; - utils.forEach(fns, function transform(fn) { + utils$1.forEach(fns, function transform(fn) { data = fn.call(config, data, headers.normalize(), response ? response.status : undefined); }); @@ -204902,7 +194349,7 @@ function CanceledError(message, config, request) { this.name = 'CanceledError'; } -utils.inherits(CanceledError, AxiosError, { +utils$1.inherits(CanceledError, AxiosError, { __CANCEL__: true }); @@ -204975,7 +194422,7 @@ function buildFullPath(baseURL, requestedURL) { return requestedURL; } -const VERSION = "1.4.0"; +const VERSION = "1.6.2"; function parseProtocol(url) { const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url); @@ -205116,7 +194563,7 @@ const kInternals = Symbol('internals'); class AxiosTransformStream extends stream__default["default"].Transform{ constructor(options) { - options = utils.toFlatObject(options, { + options = utils$1.toFlatObject(options, { maxRate: 0, chunkSize: 64 * 1024, minChunkSize: 100, @@ -205124,7 +194571,7 @@ class AxiosTransformStream extends stream__default["default"].Transform{ ticksRate: 2, samplesCount: 15 }, null, (prop, source) => { - return !utils.isUndefined(source[prop]); + return !utils$1.isUndefined(source[prop]); }); super({ @@ -205313,7 +194760,7 @@ const readBlob = async function* (blob) { const readBlob$1 = readBlob; -const BOUNDARY_ALPHABET = utils.ALPHABET.ALPHA_DIGIT + '-_'; +const BOUNDARY_ALPHABET = utils$1.ALPHABET.ALPHA_DIGIT + '-_'; const textEncoder = new util.TextEncoder(); @@ -205324,7 +194771,7 @@ const CRLF_BYTES_COUNT = 2; class FormDataPart { constructor(name, value) { const {escapeName} = this.constructor; - const isStringValue = utils.isString(value); + const isStringValue = utils$1.isString(value); let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${ !isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : '' @@ -205351,7 +194798,7 @@ class FormDataPart { const {value} = this; - if(utils.isTypedArray(value)) { + if(utils$1.isTypedArray(value)) { yield value; } else { yield* readBlob$1(value); @@ -205373,10 +194820,10 @@ const formDataToStream = (form, headersHandler, options) => { const { tag = 'form-data-boundary', size = 25, - boundary = tag + '-' + utils.generateString(size, BOUNDARY_ALPHABET) + boundary = tag + '-' + utils$1.generateString(size, BOUNDARY_ALPHABET) } = options || {}; - if(!utils.isFormData(form)) { + if(!utils$1.isFormData(form)) { throw TypeError('FormData instance required'); } @@ -205396,7 +194843,7 @@ const formDataToStream = (form, headersHandler, options) => { contentLength += boundaryBytes.byteLength * parts.length; - contentLength = utils.toFiniteNumber(contentLength); + contentLength = utils$1.toFiniteNumber(contentLength); const computedHeaders = { 'Content-Type': `multipart/form-data; boundary=${boundary}` @@ -205446,7 +194893,7 @@ class ZlibHeaderTransformStream extends stream__default["default"].Transform { const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream; const callbackify = (fn, reducer) => { - return utils.isAsyncFn(fn) ? function (...args) { + return utils$1.isAsyncFn(fn) ? function (...args) { const cb = args.pop(); fn.apply(this, args).then((value) => { try { @@ -205470,7 +194917,7 @@ const brotliOptions = { finishFlush: zlib__default["default"].constants.BROTLI_OPERATION_FLUSH }; -const isBrotliSupported = utils.isFunction(zlib__default["default"].createBrotliDecompress); +const isBrotliSupported = utils$1.isFunction(zlib__default["default"].createBrotliDecompress); const {http: httpFollow, https: httpsFollow} = followRedirects__default["default"]; @@ -205550,7 +194997,7 @@ function setProxy(options, configProxy, location) { }; } -const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process'; +const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(process) === 'process'; // temporary hotfix @@ -205579,6 +195026,18 @@ const wrapAsync = (asyncExecutor) => { }) }; +const resolveFamily = ({address, family}) => { + if (!utils$1.isString(address)) { + throw TypeError('address must be a string'); + } + return ({ + address, + family: family || (address.indexOf('.') < 0 ? 6 : 4) + }); +}; + +const buildAddressEntry = (address, family) => resolveFamily(utils$1.isObject(address) ? address : {address, family}); + /*eslint consistent-return:0*/ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) { @@ -205589,15 +195048,16 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { let rejected = false; let req; - if (lookup && utils.isAsyncFn(lookup)) { - lookup = callbackify$1(lookup, (entry) => { - if(utils.isString(entry)) { - entry = [entry, entry.indexOf('.') < 0 ? 6 : 4]; - } else if (!utils.isArray(entry)) { - throw new TypeError('lookup async function must return an array [ip: string, family: number]]') - } - return entry; - }); + if (lookup) { + const _lookup = callbackify$1(lookup, (value) => utils$1.isArray(value) ? value : [value]); + // hotfix to support opt.all option which is required for node 20.x + lookup = (hostname, opt, cb) => { + _lookup(hostname, opt, (err, arg0, arg1) => { + const addresses = utils$1.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)]; + + opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family); + }); + }; } // temporary internal emitter until the AxiosRequest class will be implemented @@ -205665,7 +195125,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { convertedData = convertedData.toString(responseEncoding); if (!responseEncoding || responseEncoding === 'utf8') { - convertedData = utils.stripBOM(convertedData); + convertedData = utils$1.stripBOM(convertedData); } } else if (responseType === 'stream') { convertedData = stream__default["default"].Readable.from(convertedData); @@ -205703,7 +195163,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { let maxDownloadRate = undefined; // support for spec compliant FormData objects - if (utils.isSpecCompliantForm(data)) { + if (utils$1.isSpecCompliantForm(data)) { const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i); data = formDataToStream$1(data, (formHeaders) => { @@ -205713,7 +195173,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { boundary: userBoundary && userBoundary[1] || undefined }); // support for https://www.npmjs.com/package/form-data api - } else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) { + } else if (utils$1.isFormData(data) && utils$1.isFunction(data.getHeaders)) { headers.set(data.getHeaders()); if (!headers.hasContentLength()) { @@ -205724,14 +195184,14 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { } catch (e) { } } - } else if (utils.isBlob(data)) { + } else if (utils$1.isBlob(data)) { data.size && headers.setContentType(data.type || 'application/octet-stream'); headers.setContentLength(data.size || 0); data = stream__default["default"].Readable.from(readBlob$1(data)); - } else if (data && !utils.isStream(data)) { - if (Buffer.isBuffer(data)) ; else if (utils.isArrayBuffer(data)) { + } else if (data && !utils$1.isStream(data)) { + if (Buffer.isBuffer(data)) ; else if (utils$1.isArrayBuffer(data)) { data = Buffer.from(new Uint8Array(data)); - } else if (utils.isString(data)) { + } else if (utils$1.isString(data)) { data = Buffer.from(data, 'utf-8'); } else { return reject(new AxiosError( @@ -205753,9 +195213,9 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { } } - const contentLength = utils.toFiniteNumber(headers.getContentLength()); + const contentLength = utils$1.toFiniteNumber(headers.getContentLength()); - if (utils.isArray(maxRate)) { + if (utils$1.isArray(maxRate)) { maxUploadRate = maxRate[0]; maxDownloadRate = maxRate[1]; } else { @@ -205763,14 +195223,14 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { } if (data && (onUploadProgress || maxUploadRate)) { - if (!utils.isStream(data)) { + if (!utils$1.isStream(data)) { data = stream__default["default"].Readable.from(data, {objectMode: false}); } data = stream__default["default"].pipeline([data, new AxiosTransformStream$1({ length: contentLength, - maxRate: utils.toFiniteNumber(maxUploadRate) - })], utils.noop); + maxRate: utils$1.toFiniteNumber(maxUploadRate) + })], utils$1.noop); onUploadProgress && data.on('progress', progress => { onUploadProgress(Object.assign(progress, { @@ -205824,11 +195284,13 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { auth, protocol, family, - lookup, beforeRedirect: dispatchBeforeRedirect, beforeRedirects: {} }; + // cacheable-lookup integration hotfix + !utils$1.isUndefined(lookup) && (options.lookup = lookup); + if (config.socketPath) { options.socketPath = config.socketPath; } else { @@ -205875,8 +195337,8 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { if (onDownloadProgress) { const transformStream = new AxiosTransformStream$1({ - length: utils.toFiniteNumber(responseLength), - maxRate: utils.toFiniteNumber(maxDownloadRate) + length: utils$1.toFiniteNumber(responseLength), + maxRate: utils$1.toFiniteNumber(maxDownloadRate) }); onDownloadProgress && transformStream.on('progress', progress => { @@ -205902,7 +195364,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { delete res.headers['content-encoding']; } - switch (res.headers['content-encoding']) { + switch ((res.headers['content-encoding'] || '').toLowerCase()) { /*eslint default-case:0*/ case 'gzip': case 'x-gzip': @@ -205931,7 +195393,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { } } - responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils.noop) : streams[0]; + responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils$1.noop) : streams[0]; const offListeners = stream__default["default"].finished(responseStream, () => { offListeners(); @@ -205993,12 +195455,12 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { if (responseType !== 'arraybuffer') { responseData = responseData.toString(responseEncoding); if (!responseEncoding || responseEncoding === 'utf8') { - responseData = utils.stripBOM(responseData); + responseData = utils$1.stripBOM(responseData); } } response.data = responseData; } catch (err) { - reject(AxiosError.from(err, null, config, response.request, response)); + return reject(AxiosError.from(err, null, config, response.request, response)); } settle(resolve, reject, response); }); @@ -206035,7 +195497,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types. const timeout = parseInt(config.timeout, 10); - if (isNaN(timeout)) { + if (Number.isNaN(timeout)) { reject(new AxiosError( 'error trying to parse `config.timeout` to int', AxiosError.ERR_BAD_OPTION_VALUE, @@ -206070,7 +195532,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { // Send the request - if (utils.isStream(data)) { + if (utils$1.isStream(data)) { let ended = false; let errored = false; @@ -206096,55 +195558,46 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) { }); }; -const cookies = platform.isStandardBrowserEnv ? +const cookies = platform.hasStandardBrowserEnv ? -// Standard browser envs support document.cookie - (function standardBrowserEnv() { - return { - write: function write(name, value, expires, path, domain, secure) { - const cookie = []; - cookie.push(name + '=' + encodeURIComponent(value)); + // Standard browser envs support document.cookie + { + write(name, value, expires, path, domain, secure) { + const cookie = [name + '=' + encodeURIComponent(value)]; - if (utils.isNumber(expires)) { - cookie.push('expires=' + new Date(expires).toGMTString()); - } + utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString()); - if (utils.isString(path)) { - cookie.push('path=' + path); - } + utils$1.isString(path) && cookie.push('path=' + path); - if (utils.isString(domain)) { - cookie.push('domain=' + domain); - } + utils$1.isString(domain) && cookie.push('domain=' + domain); - if (secure === true) { - cookie.push('secure'); - } + secure === true && cookie.push('secure'); - document.cookie = cookie.join('; '); - }, + document.cookie = cookie.join('; '); + }, - read: function read(name) { - const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); - return (match ? decodeURIComponent(match[3]) : null); - }, + read(name) { + const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); + return (match ? decodeURIComponent(match[3]) : null); + }, - remove: function remove(name) { - this.write(name, '', Date.now() - 86400000); - } - }; - })() : + remove(name) { + this.write(name, '', Date.now() - 86400000); + } + } -// Non standard browser env (web workers, react-native) lack needed support. - (function nonStandardBrowserEnv() { - return { - write: function write() {}, - read: function read() { return null; }, - remove: function remove() {} - }; - })(); + : -const isURLSameOrigin = platform.isStandardBrowserEnv ? + // Non-standard browser env (web workers, react-native) lack needed support. + { + write() {}, + read() { + return null; + }, + remove() {} + }; + +const isURLSameOrigin = platform.hasStandardBrowserEnv ? // Standard browser envs have full support of the APIs needed to test // whether the request URL is of the same origin as current location. @@ -206154,7 +195607,7 @@ const isURLSameOrigin = platform.isStandardBrowserEnv ? let originURL; /** - * Parse a URL to discover it's components + * Parse a URL to discover its components * * @param {String} url The URL to be parsed * @returns {Object} @@ -206194,7 +195647,7 @@ const isURLSameOrigin = platform.isStandardBrowserEnv ? * @returns {boolean} True if URL shares the same origin, otherwise false */ return function isURLSameOrigin(requestURL) { - const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; + const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL; return (parsed.protocol === originURL.protocol && parsed.host === originURL.host); }; @@ -206242,7 +195695,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) { return new Promise(function dispatchXhrRequest(resolve, reject) { let requestData = config.data; const requestHeaders = AxiosHeaders$1.from(config.headers).normalize(); - const responseType = config.responseType; + let {responseType, withXSRFToken} = config; let onCanceled; function done() { if (config.cancelToken) { @@ -206254,11 +195707,15 @@ const xhrAdapter = isXHRAdapterSupported && function (config) { } } - if (utils.isFormData(requestData)) { - if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) { + let contentType; + + if (utils$1.isFormData(requestData)) { + if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) { requestHeaders.setContentType(false); // Let the browser set it - } else { - requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks + } else if ((contentType = requestHeaders.getContentType()) !== false) { + // fix semicolon duplication issue for ReactNative FormData implementation + const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : []; + requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; ')); } } @@ -206374,13 +195831,16 @@ const xhrAdapter = isXHRAdapterSupported && function (config) { // Add xsrf header // This is only done if running in a standard browser environment. // Specifically not if we're in a web worker, or react-native. - if (platform.isStandardBrowserEnv) { - // Add xsrf header - const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) - && config.xsrfCookieName && cookies.read(config.xsrfCookieName); + if(platform.hasStandardBrowserEnv) { + withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config)); + + if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) { + // Add xsrf header + const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName); - if (xsrfValue) { - requestHeaders.set(config.xsrfHeaderName, xsrfValue); + if (xsrfValue) { + requestHeaders.set(config.xsrfHeaderName, xsrfValue); + } } } @@ -206389,13 +195849,13 @@ const xhrAdapter = isXHRAdapterSupported && function (config) { // Add headers to the request if ('setRequestHeader' in request) { - utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) { + utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) { request.setRequestHeader(key, val); }); } // Add withCredentials to request if needed - if (!utils.isUndefined(config.withCredentials)) { + if (!utils$1.isUndefined(config.withCredentials)) { request.withCredentials = !!config.withCredentials; } @@ -206450,8 +195910,8 @@ const knownAdapters = { xhr: xhrAdapter }; -utils.forEach(knownAdapters, (fn, value) => { - if(fn) { +utils$1.forEach(knownAdapters, (fn, value) => { + if (fn) { try { Object.defineProperty(fn, 'name', {value}); } catch (e) { @@ -206461,38 +195921,56 @@ utils.forEach(knownAdapters, (fn, value) => { } }); +const renderReason = (reason) => `- ${reason}`; + +const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false; + const adapters = { getAdapter: (adapters) => { - adapters = utils.isArray(adapters) ? adapters : [adapters]; + adapters = utils$1.isArray(adapters) ? adapters : [adapters]; const {length} = adapters; let nameOrAdapter; let adapter; + const rejectedReasons = {}; + for (let i = 0; i < length; i++) { nameOrAdapter = adapters[i]; - if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) { + let id; + + adapter = nameOrAdapter; + + if (!isResolvedHandle(nameOrAdapter)) { + adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()]; + + if (adapter === undefined) { + throw new AxiosError(`Unknown adapter '${id}'`); + } + } + + if (adapter) { break; } + + rejectedReasons[id || '#' + i] = adapter; } if (!adapter) { - if (adapter === false) { - throw new AxiosError( - `Adapter ${nameOrAdapter} is not supported by the environment`, - 'ERR_NOT_SUPPORT' + + const reasons = Object.entries(rejectedReasons) + .map(([id, state]) => `adapter ${id} ` + + (state === false ? 'is not supported by the environment' : 'is not available in the build') ); - } - throw new Error( - utils.hasOwnProp(knownAdapters, nameOrAdapter) ? - `Adapter '${nameOrAdapter}' is not available in the build` : - `Unknown adapter '${nameOrAdapter}'` - ); - } + let s = length ? + (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) : + 'as no adapter specified'; - if (!utils.isFunction(adapter)) { - throw new TypeError('adapter is not a function'); + throw new AxiosError( + `There is no suitable adapter to dispatch the request ` + s, + 'ERR_NOT_SUPPORT' + ); } return adapter; @@ -206590,11 +196068,11 @@ function mergeConfig(config1, config2) { const config = {}; function getMergedValue(target, source, caseless) { - if (utils.isPlainObject(target) && utils.isPlainObject(source)) { - return utils.merge.call({caseless}, target, source); - } else if (utils.isPlainObject(source)) { - return utils.merge({}, source); - } else if (utils.isArray(source)) { + if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) { + return utils$1.merge.call({caseless}, target, source); + } else if (utils$1.isPlainObject(source)) { + return utils$1.merge({}, source); + } else if (utils$1.isArray(source)) { return source.slice(); } return source; @@ -206602,25 +196080,25 @@ function mergeConfig(config1, config2) { // eslint-disable-next-line consistent-return function mergeDeepProperties(a, b, caseless) { - if (!utils.isUndefined(b)) { + if (!utils$1.isUndefined(b)) { return getMergedValue(a, b, caseless); - } else if (!utils.isUndefined(a)) { + } else if (!utils$1.isUndefined(a)) { return getMergedValue(undefined, a, caseless); } } // eslint-disable-next-line consistent-return function valueFromConfig2(a, b) { - if (!utils.isUndefined(b)) { + if (!utils$1.isUndefined(b)) { return getMergedValue(undefined, b); } } // eslint-disable-next-line consistent-return function defaultToConfig2(a, b) { - if (!utils.isUndefined(b)) { + if (!utils$1.isUndefined(b)) { return getMergedValue(undefined, b); - } else if (!utils.isUndefined(a)) { + } else if (!utils$1.isUndefined(a)) { return getMergedValue(undefined, a); } } @@ -206645,6 +196123,7 @@ function mergeConfig(config1, config2) { timeout: defaultToConfig2, timeoutMessage: defaultToConfig2, withCredentials: defaultToConfig2, + withXSRFToken: defaultToConfig2, adapter: defaultToConfig2, responseType: defaultToConfig2, xsrfCookieName: defaultToConfig2, @@ -206665,10 +196144,10 @@ function mergeConfig(config1, config2) { headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true) }; - utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) { + utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) { const merge = mergeMap[prop] || mergeDeepProperties; const configValue = merge(config1[prop], config2[prop], prop); - (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); + (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); }); return config; @@ -206810,7 +196289,7 @@ class Axios { } if (paramsSerializer != null) { - if (utils.isFunction(paramsSerializer)) { + if (utils$1.isFunction(paramsSerializer)) { config.paramsSerializer = { serialize: paramsSerializer }; @@ -206825,15 +196304,13 @@ class Axios { // Set config.method config.method = (config.method || this.defaults.method || 'get').toLowerCase(); - let contextHeaders; - // Flatten headers - contextHeaders = headers && utils.merge( + let contextHeaders = headers && utils$1.merge( headers.common, headers[config.method] ); - contextHeaders && utils.forEach( + headers && utils$1.forEach( ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => { delete headers[method]; @@ -206920,7 +196397,7 @@ class Axios { } // Provide aliases for supported request methods -utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { +utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { /*eslint func-names:0*/ Axios.prototype[method] = function(url, config) { return this.request(mergeConfig(config || {}, { @@ -206931,7 +196408,7 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData }; }); -utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { +utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { /*eslint func-names:0*/ function generateHTTPMethod(isForm) { @@ -207107,7 +196584,7 @@ function spread(callback) { * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false */ function isAxiosError(payload) { - return utils.isObject(payload) && (payload.isAxiosError === true); + return utils$1.isObject(payload) && (payload.isAxiosError === true); } const HttpStatusCode = { @@ -207194,10 +196671,10 @@ function createInstance(defaultConfig) { const instance = bind(Axios$1.prototype.request, context); // Copy axios.prototype to instance - utils.extend(instance, Axios$1.prototype, context, {allOwnKeys: true}); + utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true}); // Copy context to instance - utils.extend(instance, context, null, {allOwnKeys: true}); + utils$1.extend(instance, context, null, {allOwnKeys: true}); // Factory for creating new instances instance.create = function create(instanceConfig) { @@ -207241,7 +196718,9 @@ axios.mergeConfig = mergeConfig; axios.AxiosHeaders = AxiosHeaders$1; -axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing); +axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing); + +axios.getAdapter = adapters.getAdapter; axios.HttpStatusCode = HttpStatusCode$1; @@ -208913,27 +198392,11 @@ module.exports = {"h$":{"d":">=14"}}; /***/ }), -/***/ 87300: -/***/ ((module) => { - -"use strict"; -module.exports = JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON Schema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}'); - -/***/ }), - -/***/ 69451: -/***/ ((module) => { - -"use strict"; -module.exports = JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}'); - -/***/ }), - /***/ 22352: /***/ ((module) => { "use strict"; -module.exports = JSON.parse('{"dots":{"interval":80,"frames":["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]},"dots2":{"interval":80,"frames":["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"]},"dots3":{"interval":80,"frames":["⠋","⠙","⠚","⠞","⠖","⠦","⠴","⠲","⠳","⠓"]},"dots4":{"interval":80,"frames":["⠄","⠆","⠇","⠋","⠙","⠸","⠰","⠠","⠰","⠸","⠙","⠋","⠇","⠆"]},"dots5":{"interval":80,"frames":["⠋","⠙","⠚","⠒","⠂","⠂","⠒","⠲","⠴","⠦","⠖","⠒","⠐","⠐","⠒","⠓","⠋"]},"dots6":{"interval":80,"frames":["⠁","⠉","⠙","⠚","⠒","⠂","⠂","⠒","⠲","⠴","⠤","⠄","⠄","⠤","⠴","⠲","⠒","⠂","⠂","⠒","⠚","⠙","⠉","⠁"]},"dots7":{"interval":80,"frames":["⠈","⠉","⠋","⠓","⠒","⠐","⠐","⠒","⠖","⠦","⠤","⠠","⠠","⠤","⠦","⠖","⠒","⠐","⠐","⠒","⠓","⠋","⠉","⠈"]},"dots8":{"interval":80,"frames":["⠁","⠁","⠉","⠙","⠚","⠒","⠂","⠂","⠒","⠲","⠴","⠤","⠄","⠄","⠤","⠠","⠠","⠤","⠦","⠖","⠒","⠐","⠐","⠒","⠓","⠋","⠉","⠈","⠈"]},"dots9":{"interval":80,"frames":["⢹","⢺","⢼","⣸","⣇","⡧","⡗","⡏"]},"dots10":{"interval":80,"frames":["⢄","⢂","⢁","⡁","⡈","⡐","⡠"]},"dots11":{"interval":100,"frames":["⠁","⠂","⠄","⡀","⢀","⠠","⠐","⠈"]},"dots12":{"interval":80,"frames":["⢀⠀","⡀⠀","⠄⠀","⢂⠀","⡂⠀","⠅⠀","⢃⠀","⡃⠀","⠍⠀","⢋⠀","⡋⠀","⠍⠁","⢋⠁","⡋⠁","⠍⠉","⠋⠉","⠋⠉","⠉⠙","⠉⠙","⠉⠩","⠈⢙","⠈⡙","⢈⠩","⡀⢙","⠄⡙","⢂⠩","⡂⢘","⠅⡘","⢃⠨","⡃⢐","⠍⡐","⢋⠠","⡋⢀","⠍⡁","⢋⠁","⡋⠁","⠍⠉","⠋⠉","⠋⠉","⠉⠙","⠉⠙","⠉⠩","⠈⢙","⠈⡙","⠈⠩","⠀⢙","⠀⡙","⠀⠩","⠀⢘","⠀⡘","⠀⠨","⠀⢐","⠀⡐","⠀⠠","⠀⢀","⠀⡀"]},"dots13":{"interval":80,"frames":["⣼","⣹","⢻","⠿","⡟","⣏","⣧","⣶"]},"dots8Bit":{"interval":80,"frames":["⠀","⠁","⠂","⠃","⠄","⠅","⠆","⠇","⡀","⡁","⡂","⡃","⡄","⡅","⡆","⡇","⠈","⠉","⠊","⠋","⠌","⠍","⠎","⠏","⡈","⡉","⡊","⡋","⡌","⡍","⡎","⡏","⠐","⠑","⠒","⠓","⠔","⠕","⠖","⠗","⡐","⡑","⡒","⡓","⡔","⡕","⡖","⡗","⠘","⠙","⠚","⠛","⠜","⠝","⠞","⠟","⡘","⡙","⡚","⡛","⡜","⡝","⡞","⡟","⠠","⠡","⠢","⠣","⠤","⠥","⠦","⠧","⡠","⡡","⡢","⡣","⡤","⡥","⡦","⡧","⠨","⠩","⠪","⠫","⠬","⠭","⠮","⠯","⡨","⡩","⡪","⡫","⡬","⡭","⡮","⡯","⠰","⠱","⠲","⠳","⠴","⠵","⠶","⠷","⡰","⡱","⡲","⡳","⡴","⡵","⡶","⡷","⠸","⠹","⠺","⠻","⠼","⠽","⠾","⠿","⡸","⡹","⡺","⡻","⡼","⡽","⡾","⡿","⢀","⢁","⢂","⢃","⢄","⢅","⢆","⢇","⣀","⣁","⣂","⣃","⣄","⣅","⣆","⣇","⢈","⢉","⢊","⢋","⢌","⢍","⢎","⢏","⣈","⣉","⣊","⣋","⣌","⣍","⣎","⣏","⢐","⢑","⢒","⢓","⢔","⢕","⢖","⢗","⣐","⣑","⣒","⣓","⣔","⣕","⣖","⣗","⢘","⢙","⢚","⢛","⢜","⢝","⢞","⢟","⣘","⣙","⣚","⣛","⣜","⣝","⣞","⣟","⢠","⢡","⢢","⢣","⢤","⢥","⢦","⢧","⣠","⣡","⣢","⣣","⣤","⣥","⣦","⣧","⢨","⢩","⢪","⢫","⢬","⢭","⢮","⢯","⣨","⣩","⣪","⣫","⣬","⣭","⣮","⣯","⢰","⢱","⢲","⢳","⢴","⢵","⢶","⢷","⣰","⣱","⣲","⣳","⣴","⣵","⣶","⣷","⢸","⢹","⢺","⢻","⢼","⢽","⢾","⢿","⣸","⣹","⣺","⣻","⣼","⣽","⣾","⣿"]},"sand":{"interval":80,"frames":["⠁","⠂","⠄","⡀","⡈","⡐","⡠","⣀","⣁","⣂","⣄","⣌","⣔","⣤","⣥","⣦","⣮","⣶","⣷","⣿","⡿","⠿","⢟","⠟","⡛","⠛","⠫","⢋","⠋","⠍","⡉","⠉","⠑","⠡","⢁"]},"line":{"interval":130,"frames":["-","\\\\","|","/"]},"line2":{"interval":100,"frames":["⠂","-","–","—","–","-"]},"pipe":{"interval":100,"frames":["┤","┘","┴","└","├","┌","┬","┐"]},"simpleDots":{"interval":400,"frames":[". ",".. ","..."," "]},"simpleDotsScrolling":{"interval":200,"frames":[". ",".. ","..."," .."," ."," "]},"star":{"interval":70,"frames":["✶","✸","✹","✺","✹","✷"]},"star2":{"interval":80,"frames":["+","x","*"]},"flip":{"interval":70,"frames":["_","_","_","-","`","`","\'","´","-","_","_","_"]},"hamburger":{"interval":100,"frames":["☱","☲","☴"]},"growVertical":{"interval":120,"frames":["▁","▃","▄","▅","▆","▇","▆","▅","▄","▃"]},"growHorizontal":{"interval":120,"frames":["▏","▎","▍","▌","▋","▊","▉","▊","▋","▌","▍","▎"]},"balloon":{"interval":140,"frames":[" ",".","o","O","@","*"," "]},"balloon2":{"interval":120,"frames":[".","o","O","°","O","o","."]},"noise":{"interval":100,"frames":["▓","▒","░"]},"bounce":{"interval":120,"frames":["⠁","⠂","⠄","⠂"]},"boxBounce":{"interval":120,"frames":["▖","▘","▝","▗"]},"boxBounce2":{"interval":100,"frames":["▌","▀","▐","▄"]},"triangle":{"interval":50,"frames":["◢","◣","◤","◥"]},"binary":{"interval":80,"frames":["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},"arc":{"interval":100,"frames":["◜","◠","◝","◞","◡","◟"]},"circle":{"interval":120,"frames":["◡","⊙","◠"]},"squareCorners":{"interval":180,"frames":["◰","◳","◲","◱"]},"circleQuarters":{"interval":120,"frames":["◴","◷","◶","◵"]},"circleHalves":{"interval":50,"frames":["◐","◓","◑","◒"]},"squish":{"interval":100,"frames":["╫","╪"]},"toggle":{"interval":250,"frames":["⊶","⊷"]},"toggle2":{"interval":80,"frames":["▫","▪"]},"toggle3":{"interval":120,"frames":["□","■"]},"toggle4":{"interval":100,"frames":["■","□","▪","▫"]},"toggle5":{"interval":100,"frames":["▮","▯"]},"toggle6":{"interval":300,"frames":["ဝ","၀"]},"toggle7":{"interval":80,"frames":["⦾","⦿"]},"toggle8":{"interval":100,"frames":["◍","◌"]},"toggle9":{"interval":100,"frames":["◉","◎"]},"toggle10":{"interval":100,"frames":["㊂","㊀","㊁"]},"toggle11":{"interval":50,"frames":["⧇","⧆"]},"toggle12":{"interval":120,"frames":["☗","☖"]},"toggle13":{"interval":80,"frames":["=","*","-"]},"arrow":{"interval":100,"frames":["←","↖","↑","↗","→","↘","↓","↙"]},"arrow2":{"interval":80,"frames":["⬆️ ","↗️ ","➡️ ","↘️ ","⬇️ ","↙️ ","⬅️ ","↖️ "]},"arrow3":{"interval":120,"frames":["▹▹▹▹▹","▸▹▹▹▹","▹▸▹▹▹","▹▹▸▹▹","▹▹▹▸▹","▹▹▹▹▸"]},"bouncingBar":{"interval":80,"frames":["[ ]","[= ]","[== ]","[=== ]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},"bouncingBall":{"interval":80,"frames":["( ● )","( ● )","( ● )","( ● )","( ●)","( ● )","( ● )","( ● )","( ● )","(● )"]},"smiley":{"interval":200,"frames":["😄 ","😝 "]},"monkey":{"interval":300,"frames":["🙈 ","🙈 ","🙉 ","🙊 "]},"hearts":{"interval":100,"frames":["💛 ","💙 ","💜 ","💚 ","❤️ "]},"clock":{"interval":100,"frames":["🕛 ","🕐 ","🕑 ","🕒 ","🕓 ","🕔 ","🕕 ","🕖 ","🕗 ","🕘 ","🕙 ","🕚 "]},"earth":{"interval":180,"frames":["🌍 ","🌎 ","🌏 "]},"material":{"interval":17,"frames":["█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁","██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁","███████▁▁▁▁▁▁▁▁▁▁▁▁▁","████████▁▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","██████████▁▁▁▁▁▁▁▁▁▁","███████████▁▁▁▁▁▁▁▁▁","█████████████▁▁▁▁▁▁▁","██████████████▁▁▁▁▁▁","██████████████▁▁▁▁▁▁","▁██████████████▁▁▁▁▁","▁██████████████▁▁▁▁▁","▁██████████████▁▁▁▁▁","▁▁██████████████▁▁▁▁","▁▁▁██████████████▁▁▁","▁▁▁▁█████████████▁▁▁","▁▁▁▁██████████████▁▁","▁▁▁▁██████████████▁▁","▁▁▁▁▁██████████████▁","▁▁▁▁▁██████████████▁","▁▁▁▁▁██████████████▁","▁▁▁▁▁▁██████████████","▁▁▁▁▁▁██████████████","▁▁▁▁▁▁▁█████████████","▁▁▁▁▁▁▁█████████████","▁▁▁▁▁▁▁▁████████████","▁▁▁▁▁▁▁▁████████████","▁▁▁▁▁▁▁▁▁███████████","▁▁▁▁▁▁▁▁▁███████████","▁▁▁▁▁▁▁▁▁▁██████████","▁▁▁▁▁▁▁▁▁▁██████████","▁▁▁▁▁▁▁▁▁▁▁▁████████","▁▁▁▁▁▁▁▁▁▁▁▁▁███████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████","█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████","██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███","██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███","███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███","████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██","█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█","█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█","██████▁▁▁▁▁▁▁▁▁▁▁▁▁█","████████▁▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","███████████▁▁▁▁▁▁▁▁▁","████████████▁▁▁▁▁▁▁▁","████████████▁▁▁▁▁▁▁▁","██████████████▁▁▁▁▁▁","██████████████▁▁▁▁▁▁","▁██████████████▁▁▁▁▁","▁██████████████▁▁▁▁▁","▁▁▁█████████████▁▁▁▁","▁▁▁▁▁████████████▁▁▁","▁▁▁▁▁████████████▁▁▁","▁▁▁▁▁▁███████████▁▁▁","▁▁▁▁▁▁▁▁█████████▁▁▁","▁▁▁▁▁▁▁▁█████████▁▁▁","▁▁▁▁▁▁▁▁▁█████████▁▁","▁▁▁▁▁▁▁▁▁█████████▁▁","▁▁▁▁▁▁▁▁▁▁█████████▁","▁▁▁▁▁▁▁▁▁▁▁████████▁","▁▁▁▁▁▁▁▁▁▁▁████████▁","▁▁▁▁▁▁▁▁▁▁▁▁███████▁","▁▁▁▁▁▁▁▁▁▁▁▁███████▁","▁▁▁▁▁▁▁▁▁▁▁▁▁███████","▁▁▁▁▁▁▁▁▁▁▁▁▁███████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁"]},"moon":{"interval":80,"frames":["🌑 ","🌒 ","🌓 ","🌔 ","🌕 ","🌖 ","🌗 ","🌘 "]},"runner":{"interval":140,"frames":["🚶 ","🏃 "]},"pong":{"interval":80,"frames":["▐⠂ ▌","▐⠈ ▌","▐ ⠂ ▌","▐ ⠠ ▌","▐ ⡀ ▌","▐ ⠠ ▌","▐ ⠂ ▌","▐ ⠈ ▌","▐ ⠂ ▌","▐ ⠠ ▌","▐ ⡀ ▌","▐ ⠠ ▌","▐ ⠂ ▌","▐ ⠈ ▌","▐ ⠂▌","▐ ⠠▌","▐ ⡀▌","▐ ⠠ ▌","▐ ⠂ ▌","▐ ⠈ ▌","▐ ⠂ ▌","▐ ⠠ ▌","▐ ⡀ ▌","▐ ⠠ ▌","▐ ⠂ ▌","▐ ⠈ ▌","▐ ⠂ ▌","▐ ⠠ ▌","▐ ⡀ ▌","▐⠠ ▌"]},"shark":{"interval":120,"frames":["▐|\\\\____________▌","▐_|\\\\___________▌","▐__|\\\\__________▌","▐___|\\\\_________▌","▐____|\\\\________▌","▐_____|\\\\_______▌","▐______|\\\\______▌","▐_______|\\\\_____▌","▐________|\\\\____▌","▐_________|\\\\___▌","▐__________|\\\\__▌","▐___________|\\\\_▌","▐____________|\\\\▌","▐____________/|▌","▐___________/|_▌","▐__________/|__▌","▐_________/|___▌","▐________/|____▌","▐_______/|_____▌","▐______/|______▌","▐_____/|_______▌","▐____/|________▌","▐___/|_________▌","▐__/|__________▌","▐_/|___________▌","▐/|____________▌"]},"dqpb":{"interval":100,"frames":["d","q","p","b"]},"weather":{"interval":100,"frames":["☀️ ","☀️ ","☀️ ","🌤 ","⛅️ ","🌥 ","☁️ ","🌧 ","🌨 ","🌧 ","🌨 ","🌧 ","🌨 ","⛈ ","🌨 ","🌧 ","🌨 ","☁️ ","🌥 ","⛅️ ","🌤 ","☀️ ","☀️ "]},"christmas":{"interval":400,"frames":["🌲","🎄"]},"grenade":{"interval":80,"frames":["، ","′ "," ´ "," ‾ "," ⸌"," ⸊"," |"," ⁎"," ⁕"," ෴ "," ⁓"," "," "," "]},"point":{"interval":125,"frames":["∙∙∙","●∙∙","∙●∙","∙∙●","∙∙∙"]},"layer":{"interval":150,"frames":["-","=","≡"]},"betaWave":{"interval":80,"frames":["ρββββββ","βρβββββ","ββρββββ","βββρβββ","ββββρββ","βββββρβ","ββββββρ"]},"fingerDance":{"interval":160,"frames":["🤘 ","🤟 ","🖖 ","✋ ","🤚 ","👆 "]},"fistBump":{"interval":80,"frames":["🤜    🤛 ","🤜    🤛 ","🤜    🤛 "," 🤜  🤛  ","  🤜🤛   "," 🤜✨🤛   ","🤜 ✨ 🤛  "]},"soccerHeader":{"interval":80,"frames":[" 🧑⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 "]},"mindblown":{"interval":160,"frames":["😐 ","😐 ","😮 ","😮 ","😦 ","😦 ","😧 ","😧 ","🤯 ","💥 ","✨ ","  ","  ","  "]},"speaker":{"interval":160,"frames":["🔈 ","🔉 ","🔊 ","🔉 "]},"orangePulse":{"interval":100,"frames":["🔸 ","🔶 ","🟠 ","🟠 ","🔶 "]},"bluePulse":{"interval":100,"frames":["🔹 ","🔷 ","🔵 ","🔵 ","🔷 "]},"orangeBluePulse":{"interval":100,"frames":["🔸 ","🔶 ","🟠 ","🟠 ","🔶 ","🔹 ","🔷 ","🔵 ","🔵 ","🔷 "]},"timeTravel":{"interval":100,"frames":["🕛 ","🕚 ","🕙 ","🕘 ","🕗 ","🕖 ","🕕 ","🕔 ","🕓 ","🕒 ","🕑 ","🕐 "]},"aesthetic":{"interval":80,"frames":["▰▱▱▱▱▱▱","▰▰▱▱▱▱▱","▰▰▰▱▱▱▱","▰▰▰▰▱▱▱","▰▰▰▰▰▱▱","▰▰▰▰▰▰▱","▰▰▰▰▰▰▰","▰▱▱▱▱▱▱"]},"dwarfFortress":{"interval":80,"frames":[" ██████£££ ","☺██████£££ ","☺██████£££ ","☺▓█████£££ ","☺▓█████£££ ","☺▒█████£££ ","☺▒█████£££ ","☺░█████£££ ","☺░█████£££ ","☺ █████£££ "," ☺█████£££ "," ☺█████£££ "," ☺▓████£££ "," ☺▓████£££ "," ☺▒████£££ "," ☺▒████£££ "," ☺░████£££ "," ☺░████£££ "," ☺ ████£££ "," ☺████£££ "," ☺████£££ "," ☺▓███£££ "," ☺▓███£££ "," ☺▒███£££ "," ☺▒███£££ "," ☺░███£££ "," ☺░███£££ "," ☺ ███£££ "," ☺███£££ "," ☺███£££ "," ☺▓██£££ "," ☺▓██£££ "," ☺▒██£££ "," ☺▒██£££ "," ☺░██£££ "," ☺░██£££ "," ☺ ██£££ "," ☺██£££ "," ☺██£££ "," ☺▓█£££ "," ☺▓█£££ "," ☺▒█£££ "," ☺▒█£££ "," ☺░█£££ "," ☺░█£££ "," ☺ █£££ "," ☺█£££ "," ☺█£££ "," ☺▓£££ "," ☺▓£££ "," ☺▒£££ "," ☺▒£££ "," ☺░£££ "," ☺░£££ "," ☺ £££ "," ☺£££ "," ☺£££ "," ☺▓££ "," ☺▓££ "," ☺▒££ "," ☺▒££ "," ☺░££ "," ☺░££ "," ☺ ££ "," ☺££ "," ☺££ "," ☺▓£ "," ☺▓£ "," ☺▒£ "," ☺▒£ "," ☺░£ "," ☺░£ "," ☺ £ "," ☺£ "," ☺£ "," ☺▓ "," ☺▓ "," ☺▒ "," ☺▒ "," ☺░ "," ☺░ "," ☺ "," ☺ &"," ☺ ☼&"," ☺ ☼ &"," ☺☼ &"," ☺☼ & "," ‼ & "," ☺ & "," ‼ & "," ☺ & "," ‼ & "," ☺ & ","‼ & "," & "," & "," & ░ "," & ▒ "," & ▓ "," & £ "," & ░£ "," & ▒£ "," & ▓£ "," & ££ "," & ░££ "," & ▒££ ","& ▓££ ","& £££ "," ░£££ "," ▒£££ "," ▓£££ "," █£££ "," ░█£££ "," ▒█£££ "," ▓█£££ "," ██£££ "," ░██£££ "," ▒██£££ "," ▓██£££ "," ███£££ "," ░███£££ "," ▒███£££ "," ▓███£££ "," ████£££ "," ░████£££ "," ▒████£££ "," ▓████£££ "," █████£££ "," ░█████£££ "," ▒█████£££ "," ▓█████£££ "," ██████£££ "," ██████£££ "]}}'); +module.exports = JSON.parse('{"dots":{"interval":80,"frames":["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]},"dots2":{"interval":80,"frames":["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"]},"dots3":{"interval":80,"frames":["⠋","⠙","⠚","⠞","⠖","⠦","⠴","⠲","⠳","⠓"]},"dots4":{"interval":80,"frames":["⠄","⠆","⠇","⠋","⠙","⠸","⠰","⠠","⠰","⠸","⠙","⠋","⠇","⠆"]},"dots5":{"interval":80,"frames":["⠋","⠙","⠚","⠒","⠂","⠂","⠒","⠲","⠴","⠦","⠖","⠒","⠐","⠐","⠒","⠓","⠋"]},"dots6":{"interval":80,"frames":["⠁","⠉","⠙","⠚","⠒","⠂","⠂","⠒","⠲","⠴","⠤","⠄","⠄","⠤","⠴","⠲","⠒","⠂","⠂","⠒","⠚","⠙","⠉","⠁"]},"dots7":{"interval":80,"frames":["⠈","⠉","⠋","⠓","⠒","⠐","⠐","⠒","⠖","⠦","⠤","⠠","⠠","⠤","⠦","⠖","⠒","⠐","⠐","⠒","⠓","⠋","⠉","⠈"]},"dots8":{"interval":80,"frames":["⠁","⠁","⠉","⠙","⠚","⠒","⠂","⠂","⠒","⠲","⠴","⠤","⠄","⠄","⠤","⠠","⠠","⠤","⠦","⠖","⠒","⠐","⠐","⠒","⠓","⠋","⠉","⠈","⠈"]},"dots9":{"interval":80,"frames":["⢹","⢺","⢼","⣸","⣇","⡧","⡗","⡏"]},"dots10":{"interval":80,"frames":["⢄","⢂","⢁","⡁","⡈","⡐","⡠"]},"dots11":{"interval":100,"frames":["⠁","⠂","⠄","⡀","⢀","⠠","⠐","⠈"]},"dots12":{"interval":80,"frames":["⢀⠀","⡀⠀","⠄⠀","⢂⠀","⡂⠀","⠅⠀","⢃⠀","⡃⠀","⠍⠀","⢋⠀","⡋⠀","⠍⠁","⢋⠁","⡋⠁","⠍⠉","⠋⠉","⠋⠉","⠉⠙","⠉⠙","⠉⠩","⠈⢙","⠈⡙","⢈⠩","⡀⢙","⠄⡙","⢂⠩","⡂⢘","⠅⡘","⢃⠨","⡃⢐","⠍⡐","⢋⠠","⡋⢀","⠍⡁","⢋⠁","⡋⠁","⠍⠉","⠋⠉","⠋⠉","⠉⠙","⠉⠙","⠉⠩","⠈⢙","⠈⡙","⠈⠩","⠀⢙","⠀⡙","⠀⠩","⠀⢘","⠀⡘","⠀⠨","⠀⢐","⠀⡐","⠀⠠","⠀⢀","⠀⡀"]},"dots13":{"interval":80,"frames":["⣼","⣹","⢻","⠿","⡟","⣏","⣧","⣶"]},"dots8Bit":{"interval":80,"frames":["⠀","⠁","⠂","⠃","⠄","⠅","⠆","⠇","⡀","⡁","⡂","⡃","⡄","⡅","⡆","⡇","⠈","⠉","⠊","⠋","⠌","⠍","⠎","⠏","⡈","⡉","⡊","⡋","⡌","⡍","⡎","⡏","⠐","⠑","⠒","⠓","⠔","⠕","⠖","⠗","⡐","⡑","⡒","⡓","⡔","⡕","⡖","⡗","⠘","⠙","⠚","⠛","⠜","⠝","⠞","⠟","⡘","⡙","⡚","⡛","⡜","⡝","⡞","⡟","⠠","⠡","⠢","⠣","⠤","⠥","⠦","⠧","⡠","⡡","⡢","⡣","⡤","⡥","⡦","⡧","⠨","⠩","⠪","⠫","⠬","⠭","⠮","⠯","⡨","⡩","⡪","⡫","⡬","⡭","⡮","⡯","⠰","⠱","⠲","⠳","⠴","⠵","⠶","⠷","⡰","⡱","⡲","⡳","⡴","⡵","⡶","⡷","⠸","⠹","⠺","⠻","⠼","⠽","⠾","⠿","⡸","⡹","⡺","⡻","⡼","⡽","⡾","⡿","⢀","⢁","⢂","⢃","⢄","⢅","⢆","⢇","⣀","⣁","⣂","⣃","⣄","⣅","⣆","⣇","⢈","⢉","⢊","⢋","⢌","⢍","⢎","⢏","⣈","⣉","⣊","⣋","⣌","⣍","⣎","⣏","⢐","⢑","⢒","⢓","⢔","⢕","⢖","⢗","⣐","⣑","⣒","⣓","⣔","⣕","⣖","⣗","⢘","⢙","⢚","⢛","⢜","⢝","⢞","⢟","⣘","⣙","⣚","⣛","⣜","⣝","⣞","⣟","⢠","⢡","⢢","⢣","⢤","⢥","⢦","⢧","⣠","⣡","⣢","⣣","⣤","⣥","⣦","⣧","⢨","⢩","⢪","⢫","⢬","⢭","⢮","⢯","⣨","⣩","⣪","⣫","⣬","⣭","⣮","⣯","⢰","⢱","⢲","⢳","⢴","⢵","⢶","⢷","⣰","⣱","⣲","⣳","⣴","⣵","⣶","⣷","⢸","⢹","⢺","⢻","⢼","⢽","⢾","⢿","⣸","⣹","⣺","⣻","⣼","⣽","⣾","⣿"]},"sand":{"interval":80,"frames":["⠁","⠂","⠄","⡀","⡈","⡐","⡠","⣀","⣁","⣂","⣄","⣌","⣔","⣤","⣥","⣦","⣮","⣶","⣷","⣿","⡿","⠿","⢟","⠟","⡛","⠛","⠫","⢋","⠋","⠍","⡉","⠉","⠑","⠡","⢁"]},"line":{"interval":130,"frames":["-","\\\\","|","/"]},"line2":{"interval":100,"frames":["⠂","-","–","—","–","-"]},"pipe":{"interval":100,"frames":["┤","┘","┴","└","├","┌","┬","┐"]},"simpleDots":{"interval":400,"frames":[". ",".. ","..."," "]},"simpleDotsScrolling":{"interval":200,"frames":[". ",".. ","..."," .."," ."," "]},"star":{"interval":70,"frames":["✶","✸","✹","✺","✹","✷"]},"star2":{"interval":80,"frames":["+","x","*"]},"flip":{"interval":70,"frames":["_","_","_","-","`","`","\'","´","-","_","_","_"]},"hamburger":{"interval":100,"frames":["☱","☲","☴"]},"growVertical":{"interval":120,"frames":["▁","▃","▄","▅","▆","▇","▆","▅","▄","▃"]},"growHorizontal":{"interval":120,"frames":["▏","▎","▍","▌","▋","▊","▉","▊","▋","▌","▍","▎"]},"balloon":{"interval":140,"frames":[" ",".","o","O","@","*"," "]},"balloon2":{"interval":120,"frames":[".","o","O","°","O","o","."]},"noise":{"interval":100,"frames":["▓","▒","░"]},"bounce":{"interval":120,"frames":["⠁","⠂","⠄","⠂"]},"boxBounce":{"interval":120,"frames":["▖","▘","▝","▗"]},"boxBounce2":{"interval":100,"frames":["▌","▀","▐","▄"]},"triangle":{"interval":50,"frames":["◢","◣","◤","◥"]},"binary":{"interval":80,"frames":["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},"arc":{"interval":100,"frames":["◜","◠","◝","◞","◡","◟"]},"circle":{"interval":120,"frames":["◡","⊙","◠"]},"squareCorners":{"interval":180,"frames":["◰","◳","◲","◱"]},"circleQuarters":{"interval":120,"frames":["◴","◷","◶","◵"]},"circleHalves":{"interval":50,"frames":["◐","◓","◑","◒"]},"squish":{"interval":100,"frames":["╫","╪"]},"toggle":{"interval":250,"frames":["⊶","⊷"]},"toggle2":{"interval":80,"frames":["▫","▪"]},"toggle3":{"interval":120,"frames":["□","■"]},"toggle4":{"interval":100,"frames":["■","□","▪","▫"]},"toggle5":{"interval":100,"frames":["▮","▯"]},"toggle6":{"interval":300,"frames":["ဝ","၀"]},"toggle7":{"interval":80,"frames":["⦾","⦿"]},"toggle8":{"interval":100,"frames":["◍","◌"]},"toggle9":{"interval":100,"frames":["◉","◎"]},"toggle10":{"interval":100,"frames":["㊂","㊀","㊁"]},"toggle11":{"interval":50,"frames":["⧇","⧆"]},"toggle12":{"interval":120,"frames":["☗","☖"]},"toggle13":{"interval":80,"frames":["=","*","-"]},"arrow":{"interval":100,"frames":["←","↖","↑","↗","→","↘","↓","↙"]},"arrow2":{"interval":80,"frames":["⬆️ ","↗️ ","➡️ ","↘️ ","⬇️ ","↙️ ","⬅️ ","↖️ "]},"arrow3":{"interval":120,"frames":["▹▹▹▹▹","▸▹▹▹▹","▹▸▹▹▹","▹▹▸▹▹","▹▹▹▸▹","▹▹▹▹▸"]},"bouncingBar":{"interval":80,"frames":["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},"bouncingBall":{"interval":80,"frames":["( ● )","( ● )","( ● )","( ● )","( ●)","( ● )","( ● )","( ● )","( ● )","(● )"]},"smiley":{"interval":200,"frames":["😄 ","😝 "]},"monkey":{"interval":300,"frames":["🙈 ","🙈 ","🙉 ","🙊 "]},"hearts":{"interval":100,"frames":["💛 ","💙 ","💜 ","💚 ","❤️ "]},"clock":{"interval":100,"frames":["🕛 ","🕐 ","🕑 ","🕒 ","🕓 ","🕔 ","🕕 ","🕖 ","🕗 ","🕘 ","🕙 ","🕚 "]},"earth":{"interval":180,"frames":["🌍 ","🌎 ","🌏 "]},"material":{"interval":17,"frames":["█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁","██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁","███████▁▁▁▁▁▁▁▁▁▁▁▁▁","████████▁▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","██████████▁▁▁▁▁▁▁▁▁▁","███████████▁▁▁▁▁▁▁▁▁","█████████████▁▁▁▁▁▁▁","██████████████▁▁▁▁▁▁","██████████████▁▁▁▁▁▁","▁██████████████▁▁▁▁▁","▁██████████████▁▁▁▁▁","▁██████████████▁▁▁▁▁","▁▁██████████████▁▁▁▁","▁▁▁██████████████▁▁▁","▁▁▁▁█████████████▁▁▁","▁▁▁▁██████████████▁▁","▁▁▁▁██████████████▁▁","▁▁▁▁▁██████████████▁","▁▁▁▁▁██████████████▁","▁▁▁▁▁██████████████▁","▁▁▁▁▁▁██████████████","▁▁▁▁▁▁██████████████","▁▁▁▁▁▁▁█████████████","▁▁▁▁▁▁▁█████████████","▁▁▁▁▁▁▁▁████████████","▁▁▁▁▁▁▁▁████████████","▁▁▁▁▁▁▁▁▁███████████","▁▁▁▁▁▁▁▁▁███████████","▁▁▁▁▁▁▁▁▁▁██████████","▁▁▁▁▁▁▁▁▁▁██████████","▁▁▁▁▁▁▁▁▁▁▁▁████████","▁▁▁▁▁▁▁▁▁▁▁▁▁███████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████","█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████","██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███","██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███","███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███","████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██","█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█","█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█","██████▁▁▁▁▁▁▁▁▁▁▁▁▁█","████████▁▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","█████████▁▁▁▁▁▁▁▁▁▁▁","███████████▁▁▁▁▁▁▁▁▁","████████████▁▁▁▁▁▁▁▁","████████████▁▁▁▁▁▁▁▁","██████████████▁▁▁▁▁▁","██████████████▁▁▁▁▁▁","▁██████████████▁▁▁▁▁","▁██████████████▁▁▁▁▁","▁▁▁█████████████▁▁▁▁","▁▁▁▁▁████████████▁▁▁","▁▁▁▁▁████████████▁▁▁","▁▁▁▁▁▁███████████▁▁▁","▁▁▁▁▁▁▁▁█████████▁▁▁","▁▁▁▁▁▁▁▁█████████▁▁▁","▁▁▁▁▁▁▁▁▁█████████▁▁","▁▁▁▁▁▁▁▁▁█████████▁▁","▁▁▁▁▁▁▁▁▁▁█████████▁","▁▁▁▁▁▁▁▁▁▁▁████████▁","▁▁▁▁▁▁▁▁▁▁▁████████▁","▁▁▁▁▁▁▁▁▁▁▁▁███████▁","▁▁▁▁▁▁▁▁▁▁▁▁███████▁","▁▁▁▁▁▁▁▁▁▁▁▁▁███████","▁▁▁▁▁▁▁▁▁▁▁▁▁███████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁","▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁"]},"moon":{"interval":80,"frames":["🌑 ","🌒 ","🌓 ","🌔 ","🌕 ","🌖 ","🌗 ","🌘 "]},"runner":{"interval":140,"frames":["🚶 ","🏃 "]},"pong":{"interval":80,"frames":["▐⠂ ▌","▐⠈ ▌","▐ ⠂ ▌","▐ ⠠ ▌","▐ ⡀ ▌","▐ ⠠ ▌","▐ ⠂ ▌","▐ ⠈ ▌","▐ ⠂ ▌","▐ ⠠ ▌","▐ ⡀ ▌","▐ ⠠ ▌","▐ ⠂ ▌","▐ ⠈ ▌","▐ ⠂▌","▐ ⠠▌","▐ ⡀▌","▐ ⠠ ▌","▐ ⠂ ▌","▐ ⠈ ▌","▐ ⠂ ▌","▐ ⠠ ▌","▐ ⡀ ▌","▐ ⠠ ▌","▐ ⠂ ▌","▐ ⠈ ▌","▐ ⠂ ▌","▐ ⠠ ▌","▐ ⡀ ▌","▐⠠ ▌"]},"shark":{"interval":120,"frames":["▐|\\\\____________▌","▐_|\\\\___________▌","▐__|\\\\__________▌","▐___|\\\\_________▌","▐____|\\\\________▌","▐_____|\\\\_______▌","▐______|\\\\______▌","▐_______|\\\\_____▌","▐________|\\\\____▌","▐_________|\\\\___▌","▐__________|\\\\__▌","▐___________|\\\\_▌","▐____________|\\\\▌","▐____________/|▌","▐___________/|_▌","▐__________/|__▌","▐_________/|___▌","▐________/|____▌","▐_______/|_____▌","▐______/|______▌","▐_____/|_______▌","▐____/|________▌","▐___/|_________▌","▐__/|__________▌","▐_/|___________▌","▐/|____________▌"]},"dqpb":{"interval":100,"frames":["d","q","p","b"]},"weather":{"interval":100,"frames":["☀️ ","☀️ ","☀️ ","🌤 ","⛅️ ","🌥 ","☁️ ","🌧 ","🌨 ","🌧 ","🌨 ","🌧 ","🌨 ","⛈ ","🌨 ","🌧 ","🌨 ","☁️ ","🌥 ","⛅️ ","🌤 ","☀️ ","☀️ "]},"christmas":{"interval":400,"frames":["🌲","🎄"]},"grenade":{"interval":80,"frames":["، ","′ "," ´ "," ‾ "," ⸌"," ⸊"," |"," ⁎"," ⁕"," ෴ "," ⁓"," "," "," "]},"point":{"interval":125,"frames":["∙∙∙","●∙∙","∙●∙","∙∙●","∙∙∙"]},"layer":{"interval":150,"frames":["-","=","≡"]},"betaWave":{"interval":80,"frames":["ρββββββ","βρβββββ","ββρββββ","βββρβββ","ββββρββ","βββββρβ","ββββββρ"]},"fingerDance":{"interval":160,"frames":["🤘 ","🤟 ","🖖 ","✋ ","🤚 ","👆 "]},"fistBump":{"interval":80,"frames":["🤜    🤛 ","🤜    🤛 ","🤜    🤛 "," 🤜  🤛  ","  🤜🤛   "," 🤜✨🤛   ","🤜 ✨ 🤛  "]},"soccerHeader":{"interval":80,"frames":[" 🧑⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 ","🧑 ⚽️ 🧑 "]},"mindblown":{"interval":160,"frames":["😐 ","😐 ","😮 ","😮 ","😦 ","😦 ","😧 ","😧 ","🤯 ","💥 ","✨ ","  ","  ","  "]},"speaker":{"interval":160,"frames":["🔈 ","🔉 ","🔊 ","🔉 "]},"orangePulse":{"interval":100,"frames":["🔸 ","🔶 ","🟠 ","🟠 ","🔶 "]},"bluePulse":{"interval":100,"frames":["🔹 ","🔷 ","🔵 ","🔵 ","🔷 "]},"orangeBluePulse":{"interval":100,"frames":["🔸 ","🔶 ","🟠 ","🟠 ","🔶 ","🔹 ","🔷 ","🔵 ","🔵 ","🔷 "]},"timeTravel":{"interval":100,"frames":["🕛 ","🕚 ","🕙 ","🕘 ","🕗 ","🕖 ","🕕 ","🕔 ","🕓 ","🕒 ","🕑 ","🕐 "]},"aesthetic":{"interval":80,"frames":["▰▱▱▱▱▱▱","▰▰▱▱▱▱▱","▰▰▰▱▱▱▱","▰▰▰▰▱▱▱","▰▰▰▰▰▱▱","▰▰▰▰▰▰▱","▰▰▰▰▰▰▰","▰▱▱▱▱▱▱"]},"dwarfFortress":{"interval":80,"frames":[" ██████£££ ","☺██████£££ ","☺██████£££ ","☺▓█████£££ ","☺▓█████£££ ","☺▒█████£££ ","☺▒█████£££ ","☺░█████£££ ","☺░█████£££ ","☺ █████£££ "," ☺█████£££ "," ☺█████£££ "," ☺▓████£££ "," ☺▓████£££ "," ☺▒████£££ "," ☺▒████£££ "," ☺░████£££ "," ☺░████£££ "," ☺ ████£££ "," ☺████£££ "," ☺████£££ "," ☺▓███£££ "," ☺▓███£££ "," ☺▒███£££ "," ☺▒███£££ "," ☺░███£££ "," ☺░███£££ "," ☺ ███£££ "," ☺███£££ "," ☺███£££ "," ☺▓██£££ "," ☺▓██£££ "," ☺▒██£££ "," ☺▒██£££ "," ☺░██£££ "," ☺░██£££ "," ☺ ██£££ "," ☺██£££ "," ☺██£££ "," ☺▓█£££ "," ☺▓█£££ "," ☺▒█£££ "," ☺▒█£££ "," ☺░█£££ "," ☺░█£££ "," ☺ █£££ "," ☺█£££ "," ☺█£££ "," ☺▓£££ "," ☺▓£££ "," ☺▒£££ "," ☺▒£££ "," ☺░£££ "," ☺░£££ "," ☺ £££ "," ☺£££ "," ☺£££ "," ☺▓££ "," ☺▓££ "," ☺▒££ "," ☺▒££ "," ☺░££ "," ☺░££ "," ☺ ££ "," ☺££ "," ☺££ "," ☺▓£ "," ☺▓£ "," ☺▒£ "," ☺▒£ "," ☺░£ "," ☺░£ "," ☺ £ "," ☺£ "," ☺£ "," ☺▓ "," ☺▓ "," ☺▒ "," ☺▒ "," ☺░ "," ☺░ "," ☺ "," ☺ &"," ☺ ☼&"," ☺ ☼ &"," ☺☼ &"," ☺☼ & "," ‼ & "," ☺ & "," ‼ & "," ☺ & "," ‼ & "," ☺ & ","‼ & "," & "," & "," & ░ "," & ▒ "," & ▓ "," & £ "," & ░£ "," & ▒£ "," & ▓£ "," & ££ "," & ░££ "," & ▒££ ","& ▓££ ","& £££ "," ░£££ "," ▒£££ "," ▓£££ "," █£££ "," ░█£££ "," ▒█£££ "," ▓█£££ "," ██£££ "," ░██£££ "," ▒██£££ "," ▓██£££ "," ███£££ "," ░███£££ "," ▒███£££ "," ▓███£££ "," ████£££ "," ░████£££ "," ▒████£££ "," ▓████£££ "," █████£££ "," ░█████£££ "," ▒█████£££ "," ▓█████£££ "," ██████£££ "," ██████£££ "]}}'); /***/ }), @@ -208941,7 +198404,7 @@ module.exports = JSON.parse('{"dots":{"interval":80,"frames":["⠋","⠙","⠹", /***/ ((module) => { "use strict"; -module.exports = {"i8":"3.49.1"}; +module.exports = {"i8":"3.50.0"}; /***/ }), @@ -209061,7 +198524,7 @@ module.exports = JSON.parse('{"assert":true,"node:assert":[">= 14.18 && < 15","> /***/ ((module) => { "use strict"; -module.exports = {"version":"3.10.0"}; +module.exports = {"version":"3.11.0"}; /***/ }) diff --git a/src/run.test.ts b/src/run.test.ts index 06aa6bf..abd3226 100644 --- a/src/run.test.ts +++ b/src/run.test.ts @@ -36,8 +36,8 @@ describe('run', () => { payload: { pull_request: { number: 1345, - user: { login: 'sqren' }, - requested_reviewers: [{ login: 'sqren' }], + user: { login: 'sorenlouv' }, + requested_reviewers: [{ login: 'sorenlouv' }], }, }, serverUrl: 'https://github.my-own-enterprise.com', @@ -50,7 +50,7 @@ describe('run', () => { exitCodeOnFailure: false, options: { accessToken: 'very-secret', - assignees: ['sqren'], + assignees: ['sorenlouv'], branchLabelMapping: { '^backport-to-(.+)$': '$1', }, @@ -64,7 +64,7 @@ describe('run', () => { githubActionRunId: undefined, githubApiBaseUrlV3: 'https://github.my-own-enterprise.com/api/v3', githubApiBaseUrlV4: 'https://github.my-own-enterprise.com/api/graphql', - reviewers: ['sqren'], + reviewers: ['sorenlouv'], }, }); }); @@ -90,8 +90,8 @@ describe('run', () => { payload: { pull_request: { number: 1345, - user: { login: 'sqren' }, - requested_reviewers: [{ login: 'sqren' }], + user: { login: 'sorenlouv' }, + requested_reviewers: [{ login: 'sorenlouv' }], }, }, serverUrl: 'https://github.my-own-enterprise.com',