mirror of
https://github.com/github/codeql-action.git
synced 2025-12-14 11:29:20 +08:00
Compare commits
18 Commits
codeql-bun
...
v1.1.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2cc7cc006 | ||
|
|
c7b049b347 | ||
|
|
f679ec9aa9 | ||
|
|
d9f89b3dfd | ||
|
|
0ab00f44cb | ||
|
|
026ff35db0 | ||
|
|
1fc1008278 | ||
|
|
7eac76fcb4 | ||
|
|
3d10ffe493 | ||
|
|
f5e5590fc8 | ||
|
|
380041ed00 | ||
|
|
8165d30832 | ||
|
|
4c1021c504 | ||
|
|
9da34a6ec6 | ||
|
|
f83be76fd8 | ||
|
|
b45efc9e42 | ||
|
|
75743c96fc | ||
|
|
03a275bc11 |
55
.github/update-release-branch.py
vendored
55
.github/update-release-branch.py
vendored
@@ -19,19 +19,15 @@ V1_MODE = 'v1-release'
|
|||||||
# Value of the mode flag for a v2 release
|
# Value of the mode flag for a v2 release
|
||||||
V2_MODE = 'v2-release'
|
V2_MODE = 'v2-release'
|
||||||
|
|
||||||
SOURCE_BRANCH_FOR_MODE = { V1_MODE: 'releases/v2', V2_MODE: 'main' }
|
|
||||||
TARGET_BRANCH_FOR_MODE = { V1_MODE: 'releases/v1', V2_MODE: 'releases/v2' }
|
|
||||||
|
|
||||||
# Name of the remote
|
# Name of the remote
|
||||||
ORIGIN = 'origin'
|
ORIGIN = 'origin'
|
||||||
|
|
||||||
# Runs git with the given args and returns the stdout.
|
# Runs git with the given args and returns the stdout.
|
||||||
# Raises an error if git does not exit successfully (unless passed
|
# Raises an error if git does not exit successfully.
|
||||||
# allow_non_zero_exit_code=True).
|
def run_git(*args):
|
||||||
def run_git(*args, allow_non_zero_exit_code=False):
|
|
||||||
cmd = ['git', *args]
|
cmd = ['git', *args]
|
||||||
p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if not allow_non_zero_exit_code and p.returncode != 0:
|
if (p.returncode != 0):
|
||||||
raise Exception('Call to ' + ' '.join(cmd) + ' exited with code ' + str(p.returncode) + ' stderr:' + p.stderr.decode('ascii'))
|
raise Exception('Call to ' + ' '.join(cmd) + ' exited with code ' + str(p.returncode) + ' stderr:' + p.stderr.decode('ascii'))
|
||||||
return p.stdout.decode('ascii')
|
return p.stdout.decode('ascii')
|
||||||
|
|
||||||
@@ -40,9 +36,7 @@ def branch_exists_on_remote(branch_name):
|
|||||||
return run_git('ls-remote', '--heads', ORIGIN, branch_name).strip() != ''
|
return run_git('ls-remote', '--heads', ORIGIN, branch_name).strip() != ''
|
||||||
|
|
||||||
# Opens a PR from the given branch to the target branch
|
# Opens a PR from the given branch to the target branch
|
||||||
def open_pr(
|
def open_pr(repo, all_commits, source_branch_short_sha, new_branch_name, source_branch, target_branch, conductor, is_v2_release, labels):
|
||||||
repo, all_commits, source_branch_short_sha, new_branch_name, source_branch, target_branch,
|
|
||||||
conductor, is_v2_release, labels, conflicted_files):
|
|
||||||
# Sort the commits into the pull requests that introduced them,
|
# Sort the commits into the pull requests that introduced them,
|
||||||
# and any commits that don't have a pull request
|
# and any commits that don't have a pull request
|
||||||
pull_requests = []
|
pull_requests = []
|
||||||
@@ -87,12 +81,6 @@ def open_pr(
|
|||||||
|
|
||||||
body.append('')
|
body.append('')
|
||||||
body.append('Please review the following:')
|
body.append('Please review the following:')
|
||||||
if len(conflicted_files) > 0:
|
|
||||||
body.append(' - [ ] You have added commits to this branch that resolve the merge conflicts ' +
|
|
||||||
'in the following files:')
|
|
||||||
body.extend([f' - [ ] `{file}`' for file in conflicted_files])
|
|
||||||
body.append(' - [ ] Another maintainer has reviewed the additional commits you added to this ' +
|
|
||||||
'branch to resolve the merge conflicts.')
|
|
||||||
body.append(' - [ ] The CHANGELOG displays the correct version and date.')
|
body.append(' - [ ] The CHANGELOG displays the correct version and date.')
|
||||||
body.append(' - [ ] The CHANGELOG includes all relevant, user-facing changes since the last release.')
|
body.append(' - [ ] The CHANGELOG includes all relevant, user-facing changes since the last release.')
|
||||||
body.append(' - [ ] There are no unexpected commits being merged into the ' + target_branch + ' branch.')
|
body.append(' - [ ] There are no unexpected commits being merged into the ' + target_branch + ' branch.')
|
||||||
@@ -203,10 +191,8 @@ def main():
|
|||||||
type=str,
|
type=str,
|
||||||
required=True,
|
required=True,
|
||||||
choices=[V2_MODE, V1_MODE],
|
choices=[V2_MODE, V1_MODE],
|
||||||
help=f"Which release to perform. '{V2_MODE}' uses {SOURCE_BRANCH_FOR_MODE[V2_MODE]} as the source " +
|
help=f"Which release to perform. '{V2_MODE}' uses main as the source branch and v2 as the target branch. " +
|
||||||
f"branch and {TARGET_BRANCH_FOR_MODE[V2_MODE]} as the target branch. " +
|
f"'{V1_MODE}' uses v2 as the source branch and v1 as the target branch."
|
||||||
f"'{V1_MODE}' uses {SOURCE_BRANCH_FOR_MODE[V1_MODE]} as the source branch and " +
|
|
||||||
f"{TARGET_BRANCH_FOR_MODE[V1_MODE]} as the target branch."
|
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--conductor',
|
'--conductor',
|
||||||
@@ -217,8 +203,14 @@ def main():
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
source_branch = SOURCE_BRANCH_FOR_MODE[args.mode]
|
if args.mode == V2_MODE:
|
||||||
target_branch = TARGET_BRANCH_FOR_MODE[args.mode]
|
source_branch = 'main'
|
||||||
|
target_branch = 'v2'
|
||||||
|
elif args.mode == V1_MODE:
|
||||||
|
source_branch = 'v2'
|
||||||
|
target_branch = 'v1'
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Unexpected value for release mode: '{args.mode}'")
|
||||||
|
|
||||||
repo = Github(args.github_token).get_repo(args.repository_nwo)
|
repo = Github(args.github_token).get_repo(args.repository_nwo)
|
||||||
version = get_current_version()
|
version = get_current_version()
|
||||||
@@ -254,15 +246,10 @@ def main():
|
|||||||
# Create the new branch and push it to the remote
|
# Create the new branch and push it to the remote
|
||||||
print('Creating branch ' + new_branch_name)
|
print('Creating branch ' + new_branch_name)
|
||||||
|
|
||||||
# The process of creating the v1 release can run into merge conflicts. We commit the unresolved
|
|
||||||
# conflicts so a maintainer can easily resolve them (vs erroring and requiring maintainers to
|
|
||||||
# reconstruct the release manually)
|
|
||||||
conflicted_files = []
|
|
||||||
|
|
||||||
if args.mode == V1_MODE:
|
if args.mode == V1_MODE:
|
||||||
# If we're performing a backport, start from the target branch
|
# If we're performing a backport, start from the v1 branch
|
||||||
print(f'Creating {new_branch_name} from the {ORIGIN}/{target_branch} branch')
|
print(f'Creating {new_branch_name} from the {ORIGIN}/v1 branch')
|
||||||
run_git('checkout', '-b', new_branch_name, f'{ORIGIN}/{target_branch}')
|
run_git('checkout', '-b', new_branch_name, f'{ORIGIN}/v1')
|
||||||
|
|
||||||
# Revert the commit that we made as part of the last release that updated the version number and
|
# Revert the commit that we made as part of the last release that updated the version number and
|
||||||
# changelog to refer to 1.x.x variants. This avoids merge conflicts in the changelog and
|
# changelog to refer to 1.x.x variants. This avoids merge conflicts in the changelog and
|
||||||
@@ -287,12 +274,7 @@ def main():
|
|||||||
print(' Nothing to revert.')
|
print(' Nothing to revert.')
|
||||||
|
|
||||||
print(f'Merging {ORIGIN}/{source_branch} into the release prep branch')
|
print(f'Merging {ORIGIN}/{source_branch} into the release prep branch')
|
||||||
# Commit any conflicts (see the comment for `conflicted_files`)
|
run_git('merge', f'{ORIGIN}/{source_branch}', '--no-edit')
|
||||||
run_git('merge', f'{ORIGIN}/{source_branch}', allow_non_zero_exit_code=True)
|
|
||||||
conflicted_files = run_git('diff', '--name-only', '--diff-filter', 'U').splitlines()
|
|
||||||
if len(conflicted_files) > 0:
|
|
||||||
run_git('add', '.')
|
|
||||||
run_git('commit', '--no-edit')
|
|
||||||
|
|
||||||
# Migrate the package version number from a v2 version number to a v1 version number
|
# Migrate the package version number from a v2 version number to a v1 version number
|
||||||
print(f'Setting version number to {version}')
|
print(f'Setting version number to {version}')
|
||||||
@@ -335,7 +317,6 @@ def main():
|
|||||||
conductor=args.conductor,
|
conductor=args.conductor,
|
||||||
is_v2_release=args.mode == V2_MODE,
|
is_v2_release=args.mode == V2_MODE,
|
||||||
labels=['Update dependencies'] if args.mode == V1_MODE else [],
|
labels=['Update dependencies'] if args.mode == V1_MODE else [],
|
||||||
conflicted_files=conflicted_files
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
4
.github/workflows/__analyze-ref-input.yml
generated
vendored
4
.github/workflows/__analyze-ref-input.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__debug-artifacts.yml
generated
vendored
4
.github/workflows/__debug-artifacts.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__extractor-ram-threads.yml
generated
vendored
4
.github/workflows/__extractor-ram-threads.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__go-custom-queries.yml
generated
vendored
4
.github/workflows/__go-custom-queries.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__go-custom-tracing-autobuild.yml
generated
vendored
4
.github/workflows/__go-custom-tracing-autobuild.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__go-custom-tracing.yml
generated
vendored
4
.github/workflows/__go-custom-tracing.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__javascript-source-root.yml
generated
vendored
4
.github/workflows/__javascript-source-root.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__ml-powered-queries.yml
generated
vendored
4
.github/workflows/__ml-powered-queries.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__multi-language-autodetect.yml
generated
vendored
4
.github/workflows/__multi-language-autodetect.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
34
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
34
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
@@ -26,27 +26,9 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: latest
|
version: nightly-20210831
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
version: latest
|
version: nightly-20210831
|
||||||
- os: windows-2019
|
|
||||||
version: latest
|
|
||||||
- os: windows-2022
|
|
||||||
version: latest
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: cached
|
|
||||||
- os: macos-latest
|
|
||||||
version: cached
|
|
||||||
- os: windows-2019
|
|
||||||
version: cached
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: nightly-latest
|
|
||||||
- os: macos-latest
|
|
||||||
version: nightly-latest
|
|
||||||
- os: windows-2019
|
|
||||||
version: nightly-latest
|
|
||||||
- os: windows-2022
|
|
||||||
version: nightly-latest
|
|
||||||
name: 'Packaging: Config and input'
|
name: 'Packaging: Config and input'
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -61,7 +43,7 @@ jobs:
|
|||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
config-file: .github/codeql/codeql-config-packaging3.yml
|
config-file: .github/codeql/codeql-config-packaging3.yml
|
||||||
packs: +dsp-testing/codeql-pack1@1.0.0
|
packs: +dsp-testing/codeql-pack1@0.1.0
|
||||||
languages: javascript
|
languages: javascript
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
- name: Build code
|
- name: Build code
|
||||||
@@ -76,11 +58,11 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd "$RUNNER_TEMP/results"
|
cd "$RUNNER_TEMP/results"
|
||||||
# We should have 4 hits from these rules
|
# We should have 3 hits from these rules
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
||||||
echo "Found matching rules '$RULES'"
|
echo "Found matching rules '$RULES'"
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
|||||||
32
.github/workflows/__packaging-config-js.yml
generated
vendored
32
.github/workflows/__packaging-config-js.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
@@ -26,27 +26,9 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: latest
|
version: nightly-20210831
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
version: latest
|
version: nightly-20210831
|
||||||
- os: windows-2019
|
|
||||||
version: latest
|
|
||||||
- os: windows-2022
|
|
||||||
version: latest
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: cached
|
|
||||||
- os: macos-latest
|
|
||||||
version: cached
|
|
||||||
- os: windows-2019
|
|
||||||
version: cached
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: nightly-latest
|
|
||||||
- os: macos-latest
|
|
||||||
version: nightly-latest
|
|
||||||
- os: windows-2019
|
|
||||||
version: nightly-latest
|
|
||||||
- os: windows-2022
|
|
||||||
version: nightly-latest
|
|
||||||
name: 'Packaging: Config file'
|
name: 'Packaging: Config file'
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -75,11 +57,11 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd "$RUNNER_TEMP/results"
|
cd "$RUNNER_TEMP/results"
|
||||||
# We should have 4 hits from these rules
|
# We should have 3 hits from these rules
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
||||||
echo "Found matching rules '$RULES'"
|
echo "Found matching rules '$RULES'"
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
|||||||
34
.github/workflows/__packaging-inputs-js.yml
generated
vendored
34
.github/workflows/__packaging-inputs-js.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
@@ -26,27 +26,9 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: latest
|
version: nightly-20210831
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
version: latest
|
version: nightly-20210831
|
||||||
- os: windows-2019
|
|
||||||
version: latest
|
|
||||||
- os: windows-2022
|
|
||||||
version: latest
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: cached
|
|
||||||
- os: macos-latest
|
|
||||||
version: cached
|
|
||||||
- os: windows-2019
|
|
||||||
version: cached
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: nightly-latest
|
|
||||||
- os: macos-latest
|
|
||||||
version: nightly-latest
|
|
||||||
- os: windows-2019
|
|
||||||
version: nightly-latest
|
|
||||||
- os: windows-2022
|
|
||||||
version: nightly-latest
|
|
||||||
name: 'Packaging: Action input'
|
name: 'Packaging: Action input'
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -62,7 +44,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
config-file: .github/codeql/codeql-config-packaging2.yml
|
config-file: .github/codeql/codeql-config-packaging2.yml
|
||||||
languages: javascript
|
languages: javascript
|
||||||
packs: dsp-testing/codeql-pack1@1.0.0, dsp-testing/codeql-pack2, dsp-testing/codeql-pack3:other-query.ql
|
packs: dsp-testing/codeql-pack1@0.1.0, dsp-testing/codeql-pack2
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
- name: Build code
|
- name: Build code
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -76,11 +58,11 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd "$RUNNER_TEMP/results"
|
cd "$RUNNER_TEMP/results"
|
||||||
# We should have 4 hits from these rules
|
# We should have 3 hits from these rules
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
||||||
echo "Found matching rules '$RULES'"
|
echo "Found matching rules '$RULES'"
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
|||||||
4
.github/workflows/__remote-config.yml
generated
vendored
4
.github/workflows/__remote-config.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__rubocop-multi-language.yml
generated
vendored
4
.github/workflows/__rubocop-multi-language.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
24
.github/workflows/__split-workflow.yml
generated
vendored
24
.github/workflows/__split-workflow.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
@@ -26,17 +26,9 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: latest
|
version: nightly-20210831
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
version: latest
|
version: nightly-20210831
|
||||||
- os: ubuntu-latest
|
|
||||||
version: cached
|
|
||||||
- os: macos-latest
|
|
||||||
version: cached
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: nightly-latest
|
|
||||||
- os: macos-latest
|
|
||||||
version: nightly-latest
|
|
||||||
name: Split workflow
|
name: Split workflow
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -51,7 +43,7 @@ jobs:
|
|||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
config-file: .github/codeql/codeql-config-packaging3.yml
|
config-file: .github/codeql/codeql-config-packaging3.yml
|
||||||
packs: +dsp-testing/codeql-pack1@1.0.0
|
packs: +dsp-testing/codeql-pack1@0.1.0
|
||||||
languages: javascript
|
languages: javascript
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
- name: Build code
|
- name: Build code
|
||||||
@@ -80,11 +72,11 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd "$RUNNER_TEMP/results"
|
cd "$RUNNER_TEMP/results"
|
||||||
# We should have 4 hits from these rules
|
# We should have 3 hits from these rules
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
||||||
echo "Found matching rules '$RULES'"
|
echo "Found matching rules '$RULES'"
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
|||||||
67
.github/workflows/__test-autobuild-working-dir.yml
generated
vendored
67
.github/workflows/__test-autobuild-working-dir.yml
generated
vendored
@@ -1,67 +0,0 @@
|
|||||||
# Warning: This file is generated automatically, and should not be modified.
|
|
||||||
# Instead, please modify the template in the pr-checks directory and run:
|
|
||||||
# pip install ruamel.yaml && python3 sync.py
|
|
||||||
# to regenerate this file.
|
|
||||||
|
|
||||||
name: PR Check - Autobuild working directory
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
GO111MODULE: auto
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- releases/v1
|
|
||||||
- releases/v2
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- synchronize
|
|
||||||
- reopened
|
|
||||||
- ready_for_review
|
|
||||||
workflow_dispatch: {}
|
|
||||||
jobs:
|
|
||||||
test-autobuild-working-dir:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: latest
|
|
||||||
name: Autobuild working directory
|
|
||||||
timeout-minutes: 45
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Check out repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Prepare test
|
|
||||||
id: prepare-test
|
|
||||||
uses: ./.github/prepare-test
|
|
||||||
with:
|
|
||||||
version: ${{ matrix.version }}
|
|
||||||
- name: Test setup
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
# Make sure that Gradle build succeeds in autobuild-dir ...
|
|
||||||
cp -a ../action/tests/java-repo autobuild-dir
|
|
||||||
# ... and fails if attempted in the current directory
|
|
||||||
echo > build.gradle
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
languages: java
|
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
|
||||||
- uses: ./../action/autobuild
|
|
||||||
with:
|
|
||||||
working-directory: autobuild-dir
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- name: Check database
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd "$RUNNER_TEMP/codeql_databases"
|
|
||||||
if [[ ! -d java ]]; then
|
|
||||||
echo "Did not find a Java database"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
env:
|
|
||||||
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
|
||||||
4
.github/workflows/__test-local-codeql.yml
generated
vendored
4
.github/workflows/__test-local-codeql.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__test-proxy.yml
generated
vendored
4
.github/workflows/__test-proxy.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__test-ruby.yml
generated
vendored
4
.github/workflows/__test-ruby.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__unset-environment.yml
generated
vendored
4
.github/workflows/__unset-environment.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__upload-ref-sha-input.yml
generated
vendored
4
.github/workflows/__upload-ref-sha-input.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
4
.github/workflows/__with-checkout-path.yml
generated
vendored
4
.github/workflows/__with-checkout-path.yml
generated
vendored
@@ -11,8 +11,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|||||||
31
.github/workflows/check-for-conflicts.yml
vendored
31
.github/workflows/check-for-conflicts.yml
vendored
@@ -1,31 +0,0 @@
|
|||||||
# Checks for any conflict markers created by git. This check is primarily intended to validate that
|
|
||||||
# any merge conflicts in the v2 -> v1 backport PR are fixed before the PR is merged.
|
|
||||||
name: Check for conflicts
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: [main, v1, v2]
|
|
||||||
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
|
||||||
# by other workflows.
|
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check-for-conflicts:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Check for conflicts
|
|
||||||
run: |
|
|
||||||
# Use `|| true` since grep returns exit code 1 if there are no matches, and we don't want
|
|
||||||
# this to fail the workflow.
|
|
||||||
FILES_WITH_CONFLICTS=$(grep --extended-regexp --ignore-case --line-number --recursive \
|
|
||||||
'^(<<<<<<<|>>>>>>>)' . || true)
|
|
||||||
if [[ "${FILES_WITH_CONFLICTS}" ]]; then
|
|
||||||
echo "Fail: Found merge conflict markers in the following files:"
|
|
||||||
echo ""
|
|
||||||
echo "${FILES_WITH_CONFLICTS}"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "Success: Found no merge conflict markers."
|
|
||||||
fi
|
|
||||||
4
.github/workflows/codeql.yml
vendored
4
.github/workflows/codeql.yml
vendored
@@ -2,9 +2,9 @@ name: "CodeQL action"
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, releases/v1, releases/v2]
|
branches: [main, v1, v2]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, releases/v1, releases/v2]
|
branches: [main, v1, v2]
|
||||||
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
||||||
# by other workflows.
|
# by other workflows.
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
types: [opened, synchronize, reopened, ready_for_review]
|
||||||
|
|||||||
76
.github/workflows/post-release-mergeback.yml
vendored
76
.github/workflows/post-release-mergeback.yml
vendored
@@ -1,8 +1,7 @@
|
|||||||
# This workflow runs after a release of the action. For v2 releases, it merges any changes from the
|
# This workflow runs after a release of the action.
|
||||||
# release back into the main branch. Typically, this is just a single commit that updates the
|
# It merges any changes from the release back into the
|
||||||
# changelog. For v2 and v1 releases, it then (a) tags the merge commit on the release branch that
|
# main branch. Typically, this is just a single commit
|
||||||
# represents the new release with an `vx.y.z` tag and (b) updates the `vx` tag to refer to this
|
# that updates the changelog.
|
||||||
# commit.
|
|
||||||
name: Tag release and merge back
|
name: Tag release and merge back
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -15,8 +14,8 @@ on:
|
|||||||
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- releases/v1
|
- v1
|
||||||
- releases/v2
|
- v2
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
merge-back:
|
merge-back:
|
||||||
@@ -33,7 +32,7 @@ jobs:
|
|||||||
- name: Dump GitHub context
|
- name: Dump GitHub context
|
||||||
env:
|
env:
|
||||||
GITHUB_CONTEXT: '${{ toJson(github) }}'
|
GITHUB_CONTEXT: '${{ toJson(github) }}'
|
||||||
run: echo "${GITHUB_CONTEXT}"
|
run: echo "$GITHUB_CONTEXT"
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
@@ -47,25 +46,25 @@ jobs:
|
|||||||
id: getVersion
|
id: getVersion
|
||||||
run: |
|
run: |
|
||||||
VERSION="v$(jq '.version' -r 'package.json')"
|
VERSION="v$(jq '.version' -r 'package.json')"
|
||||||
echo "::set-output name=version::${VERSION}"
|
SHORT_SHA="${GITHUB_SHA:0:8}"
|
||||||
short_sha="${GITHUB_SHA:0:8}"
|
echo "::set-output name=version::$VERSION"
|
||||||
NEW_BRANCH="mergeback/${VERSION}-to-${BASE_BRANCH}-${short_sha}"
|
NEW_BRANCH="mergeback/${VERSION}-to-${BASE_BRANCH}-${SHORT_SHA}"
|
||||||
echo "::set-output name=newBranch::${NEW_BRANCH}"
|
echo "::set-output name=newBranch::$NEW_BRANCH"
|
||||||
|
|
||||||
|
|
||||||
- name: Dump branches
|
- name: Dump branches
|
||||||
env:
|
env:
|
||||||
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
|
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
|
||||||
run: |
|
run: |
|
||||||
echo "BASE_BRANCH ${BASE_BRANCH}"
|
echo "BASE_BRANCH $BASE_BRANCH"
|
||||||
echo "HEAD_BRANCH ${HEAD_BRANCH}"
|
echo "HEAD_BRANCH $HEAD_BRANCH"
|
||||||
echo "NEW_BRANCH ${NEW_BRANCH}"
|
echo "NEW_BRANCH $NEW_BRANCH"
|
||||||
|
|
||||||
- name: Create mergeback branch
|
- name: Create mergeback branch
|
||||||
env:
|
env:
|
||||||
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
|
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
|
||||||
run: |
|
run: |
|
||||||
git checkout -b "${NEW_BRANCH}"
|
git checkout -b "$NEW_BRANCH"
|
||||||
|
|
||||||
- name: Check for tag
|
- name: Check for tag
|
||||||
id: check
|
id: check
|
||||||
@@ -73,13 +72,13 @@ jobs:
|
|||||||
VERSION: "${{ steps.getVersion.outputs.version }}"
|
VERSION: "${{ steps.getVersion.outputs.version }}"
|
||||||
run: |
|
run: |
|
||||||
set +e # don't fail on an errored command
|
set +e # don't fail on an errored command
|
||||||
git ls-remote --tags origin | grep "${VERSION}"
|
git ls-remote --tags origin | grep "$VERSION"
|
||||||
exists="$?"
|
EXISTS="$?"
|
||||||
if [ "${exists}" -eq 0 ]; then
|
if [ "$EXISTS" -eq 0 ]; then
|
||||||
echo "Tag ${VERSION} exists. Not going to re-release."
|
echo "Tag $TAG exists. Not going to re-release."
|
||||||
echo "::set-output name=exists::true"
|
echo "::set-output name=exists::true"
|
||||||
else
|
else
|
||||||
echo "Tag ${VERSION} does not exist yet."
|
echo "Tag $TAG does not exist yet."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# we didn't tag the release during the update-release-branch workflow because the
|
# we didn't tag the release during the update-release-branch workflow because the
|
||||||
@@ -90,31 +89,20 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
VERSION: ${{ steps.getVersion.outputs.version }}
|
VERSION: ${{ steps.getVersion.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
# Unshallow the repo in order to allow pushes
|
git tag -a "$VERSION" -m "$VERSION"
|
||||||
git fetch --unshallow
|
git fetch --unshallow # unshallow the repo in order to allow pushes
|
||||||
# Create the `vx.y.z` tag
|
git push origin --follow-tags "$VERSION"
|
||||||
git tag --annotate "${VERSION}" --message "${VERSION}"
|
|
||||||
# Update the `vx` tag
|
|
||||||
major_version_tag=$(cut -d '.' -f1 <<< "${VERSION}")
|
|
||||||
# Use `--force` to overwrite the major version tag
|
|
||||||
git tag --annotate "${major_version_tag}" --message "${major_version_tag}" --force
|
|
||||||
# Push the tags, using:
|
|
||||||
# - `--atomic` to make sure we either update both tags or neither (an intermediate state,
|
|
||||||
# e.g. where we update the v2.x.y tag on the remote but not the v2 tag, could result in
|
|
||||||
# unwanted Dependabot updates, e.g. from v2 to v2.x.y)
|
|
||||||
# - `--force` since we're overwriting the `vx` tag
|
|
||||||
git push origin --atomic --force refs/tags/"${VERSION}" refs/tags/"${major_version_tag}"
|
|
||||||
|
|
||||||
- name: Create mergeback branch
|
- name: Create mergeback branch
|
||||||
if: steps.check.outputs.exists != 'true' && contains(github.ref, 'releases/v2')
|
if: steps.check.outputs.exists != 'true' && contains(github.ref, 'v2')
|
||||||
env:
|
env:
|
||||||
VERSION: "${{ steps.getVersion.outputs.version }}"
|
VERSION: "${{ steps.getVersion.outputs.version }}"
|
||||||
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
|
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
|
||||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
run: |
|
run: |
|
||||||
set -exu
|
set -exu
|
||||||
pr_title="Mergeback ${VERSION} ${HEAD_BRANCH} into ${BASE_BRANCH}"
|
PR_TITLE="Mergeback $VERSION $HEAD_BRANCH into $BASE_BRANCH"
|
||||||
pr_body="Updates version and changelog."
|
PR_BODY="Updates version and changelog."
|
||||||
|
|
||||||
# Update the version number ready for the next release
|
# Update the version number ready for the next release
|
||||||
npm version patch --no-git-tag-version
|
npm version patch --no-git-tag-version
|
||||||
@@ -122,16 +110,16 @@ jobs:
|
|||||||
# Update the changelog
|
# Update the changelog
|
||||||
perl -i -pe 's/^/## \[UNRELEASED\]\n\nNo user facing changes.\n\n/ if($.==3)' CHANGELOG.md
|
perl -i -pe 's/^/## \[UNRELEASED\]\n\nNo user facing changes.\n\n/ if($.==3)' CHANGELOG.md
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Update changelog and version after ${VERSION}"
|
git commit -m "Update changelog and version after $VERSION"
|
||||||
|
|
||||||
git push origin "${NEW_BRANCH}"
|
git push origin "$NEW_BRANCH"
|
||||||
|
|
||||||
# PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft
|
# PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft
|
||||||
# so that a maintainer can take the PR out of draft, thereby triggering the PR checks.
|
# so that a maintainer can take the PR out of draft, thereby triggering the PR checks.
|
||||||
gh pr create \
|
gh pr create \
|
||||||
--head "${NEW_BRANCH}" \
|
--head "$NEW_BRANCH" \
|
||||||
--base "${BASE_BRANCH}" \
|
--base "$BASE_BRANCH" \
|
||||||
--title "${pr_title}" \
|
--title "$PR_TITLE" \
|
||||||
--label "Update dependencies" \
|
--label "Update dependencies" \
|
||||||
--body "${pr_body}" \
|
--body "$PR_BODY" \
|
||||||
--draft
|
--draft
|
||||||
|
|||||||
2
.github/workflows/pr-checks.yml
vendored
2
.github/workflows/pr-checks.yml
vendored
@@ -2,7 +2,7 @@ name: PR Checks (Basic Checks and Runner)
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, releases/v1, releases/v2]
|
branches: [main, v1, v2]
|
||||||
pull_request:
|
pull_request:
|
||||||
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
||||||
# by other workflows.
|
# by other workflows.
|
||||||
|
|||||||
2
.github/workflows/python-deps.yml
vendored
2
.github/workflows/python-deps.yml
vendored
@@ -2,7 +2,7 @@ name: Test Python Package Installation on Linux and Mac
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, releases/v1, releases/v2]
|
branches: [main, v1, v2]
|
||||||
pull_request:
|
pull_request:
|
||||||
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
||||||
# by other workflows.
|
# by other workflows.
|
||||||
|
|||||||
2
.github/workflows/update-release-branch.yml
vendored
2
.github/workflows/update-release-branch.yml
vendored
@@ -7,7 +7,7 @@ on:
|
|||||||
# When the v2 release is complete, this workflow will open a PR to update the v1 release branch.
|
# When the v2 release is complete, this workflow will open a PR to update the v1 release branch.
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- releases/v2
|
- v2
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
|
|||||||
45
.github/workflows/update-required-checks.yml
vendored
45
.github/workflows/update-required-checks.yml
vendored
@@ -1,45 +0,0 @@
|
|||||||
|
|
||||||
# This job updates the required checks on the codeql-action repository based on the
|
|
||||||
# checks performed on the most recent commit.
|
|
||||||
|
|
||||||
name: Update required checks
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# 23:01 on Saturdays
|
|
||||||
- cron: "1 23 * * 6"
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update-required-checks:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Dump environment
|
|
||||||
run: env
|
|
||||||
|
|
||||||
- name: Dump GitHub context
|
|
||||||
env:
|
|
||||||
GITHUB_CONTEXT: '${{ toJson(github) }}'
|
|
||||||
run: echo "$GITHUB_CONTEXT"
|
|
||||||
|
|
||||||
- name: Update checks
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: "${{ secrets.CODEQL_CI_TOKEN }}"
|
|
||||||
run: |
|
|
||||||
# Update the required checks based on the current branch.
|
|
||||||
# Typically, this will be main.
|
|
||||||
echo "Getting checks for $GITHUB_SHA"
|
|
||||||
|
|
||||||
# Ignore any checks with "https://", CodeQL, LGTM, and Update checks.
|
|
||||||
CHECKS="$(gh api repos/github/codeql-action/commits/${GITHUB_SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or contains("Update") or contains("update-") | not)] | sort')"
|
|
||||||
|
|
||||||
echo "::group::New Checks"
|
|
||||||
echo "$CHECKS" | jq
|
|
||||||
echo "::endgroup::"
|
|
||||||
|
|
||||||
echo "{\"contexts\": ${CHECKS}}" > checks.json
|
|
||||||
echo "Updating main"
|
|
||||||
gh api -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json
|
|
||||||
echo "Updating v2"
|
|
||||||
gh api -X "PATCH" repos/github/codeql-action/branches/releases/v2/protection/required_status_checks --input checks.json
|
|
||||||
echo "Updating v1"
|
|
||||||
gh api -X "PATCH" repos/github/codeql-action/branches/releases/v1/protection/required_status_checks --input checks.json
|
|
||||||
18
CHANGELOG.md
18
CHANGELOG.md
@@ -1,28 +1,16 @@
|
|||||||
# CodeQL Action Changelog
|
# CodeQL Action Changelog
|
||||||
|
|
||||||
## [UNRELEASED]
|
## 1.1.8 - 08 Apr 2022
|
||||||
|
|
||||||
- When `wait-for-processing` is enabled, the workflow will now fail if there were any errors that occurred during processing of the analysis results.
|
|
||||||
|
|
||||||
## 2.1.9 - 27 Apr 2022
|
|
||||||
|
|
||||||
- Add `working-directory` input to the `autobuild` action. [#1024](https://github.com/github/codeql-action/pull/1024)
|
|
||||||
- The `analyze` and `upload-sarif` actions will now wait up to 2 minutes for processing to complete after they have uploaded the results so they can report any processing errors that occurred. This behavior can be disabled by setting the `wait-for-processing` action input to `"false"`. [#1007](https://github.com/github/codeql-action/pull/1007)
|
|
||||||
- Update default CodeQL bundle version to 2.9.0.
|
|
||||||
- Fix a bug where [status reporting fails on Windows](https://github.com/github/codeql-action/issues/1041). [#1042](https://github.com/github/codeql-action/pull/1042)
|
|
||||||
|
|
||||||
## 2.1.8 - 08 Apr 2022
|
|
||||||
|
|
||||||
- Update default CodeQL bundle version to 2.8.5. [#1014](https://github.com/github/codeql-action/pull/1014)
|
- Update default CodeQL bundle version to 2.8.5. [#1014](https://github.com/github/codeql-action/pull/1014)
|
||||||
- Fix error where the init action would fail due to a GitHub API request that was taking too long to complete [#1025](https://github.com/github/codeql-action/pull/1025)
|
- Fix error where the init action would fail due to a GitHub API request that was taking too long to complete [#1025](https://github.com/github/codeql-action/pull/1025)
|
||||||
|
|
||||||
## 2.1.7 - 05 Apr 2022
|
## 1.1.7 - 05 Apr 2022
|
||||||
|
|
||||||
- A bug where additional queries specified in the workflow file would sometimes not be respected has been fixed. [#1018](https://github.com/github/codeql-action/pull/1018)
|
- A bug where additional queries specified in the workflow file would sometimes not be respected has been fixed. [#1018](https://github.com/github/codeql-action/pull/1018)
|
||||||
|
|
||||||
## 2.1.6 - 30 Mar 2022
|
## 1.1.6 - 30 Mar 2022
|
||||||
|
|
||||||
- [v2+ only] The CodeQL Action now runs on Node.js v16. [#1000](https://github.com/github/codeql-action/pull/1000)
|
|
||||||
- Update default CodeQL bundle version to 2.8.4. [#990](https://github.com/github/codeql-action/pull/990)
|
- Update default CodeQL bundle version to 2.8.4. [#990](https://github.com/github/codeql-action/pull/990)
|
||||||
- Fix a bug where an invalid `commit_oid` was being sent to code scanning when a custom checkout path was being used. [#956](https://github.com/github/codeql-action/pull/956)
|
- Fix a bug where an invalid `commit_oid` was being sent to code scanning when a custom checkout path was being used. [#956](https://github.com/github/codeql-action/pull/956)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1 @@
|
|||||||
**/* @github/codeql-action-reviewers
|
**/* @github/codeql-action-reviewers
|
||||||
|
|
||||||
/python-setup/ @github/codeql-python @github/codeql-action-reviewers
|
|
||||||
|
|||||||
@@ -61,42 +61,41 @@ Here are a few things you can do that will increase the likelihood of your pull
|
|||||||
## Releasing (write access required)
|
## Releasing (write access required)
|
||||||
|
|
||||||
1. The first step of releasing a new version of the `codeql-action` is running the "Update release branch" workflow.
|
1. The first step of releasing a new version of the `codeql-action` is running the "Update release branch" workflow.
|
||||||
This workflow goes through the pull requests that have been merged to `main` since the last release, creates a changelog, then opens a pull request to merge the changes since the last release into the `releases/v2` release branch.
|
This workflow goes through the pull requests that have been merged to `main` since the last release, creates a changelog, then opens a pull request to merge the changes since the last release into the `v2` release branch.
|
||||||
|
|
||||||
You can start a release by triggering this workflow via [workflow dispatch](https://github.com/github/codeql-action/actions/workflows/update-release-branch.yml).
|
You can start a release by triggering this workflow via [workflow dispatch](https://github.com/github/codeql-action/actions/workflows/update-release-branch.yml).
|
||||||
1. The workflow run will open a pull request titled "Merge main into releases/v2". Mark the pull request as [ready for review](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#marking-a-pull-request-as-ready-for-review) to trigger the PR checks.
|
1. The workflow run will open a pull request titled "Merge main into v2". Mark the pull request as [ready for review](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#marking-a-pull-request-as-ready-for-review) to trigger the PR checks.
|
||||||
1. Review the checklist items in the pull request description.
|
1. Review the checklist items in the pull request description.
|
||||||
Once you've checked off all but the last two of these, approve the PR and automerge it.
|
Once you've checked off all but the last two of these, approve the PR and automerge it.
|
||||||
1. When the "Merge main into releases/v2" pull request is merged into the `releases/v2` branch, the "Tag release and merge back" workflow will create a mergeback PR.
|
1. When the "Merge main into v2" pull request is merged into the `v2` branch, the "Tag release and merge back" workflow will create a mergeback PR.
|
||||||
This mergeback incorporates the changelog updates into `main`, tags the release using the merge commit of the "Merge main into releases/v2" pull request, and bumps the patch version of the CodeQL Action.
|
This mergeback incorporates the changelog updates into `main`, tags the release using the merge commit of the "Merge main into v2" pull request, and bumps the patch version of the CodeQL Action.
|
||||||
|
|
||||||
Approve the mergeback PR and automerge it.
|
Approve the mergeback PR and automerge it.
|
||||||
1. When the "Merge main into releases/v2" pull request is merged into the `releases/v2` branch, the "Update release branch" workflow will create a "Merge releases/v2 into releases/v1" pull request to merge the changes since the last release into the `releases/v1` release branch.
|
1. When the "Merge main into v2" pull request is merged into the `v2` branch, the "Update release branch" workflow will create a "Merge v2 into v1" pull request to merge the changes since the last release into the `v1` release branch.
|
||||||
This ensures we keep both the `releases/v1` and `releases/v2` release branches up to date and fully supported.
|
This ensures we keep both the `v1` and `v2` release branches up to date and fully supported.
|
||||||
|
|
||||||
Review the checklist items in the pull request description.
|
Review the checklist items in the pull request description.
|
||||||
Once you've checked off all the items, approve the PR and automerge it.
|
Once you've checked off all the items, approve the PR and automerge it.
|
||||||
1. Once the mergeback has been merged to `main` and the "Merge releases/v2 into releases/v1" PR has been merged to `releases/v1`, the release is complete.
|
1. Once the mergeback has been merged to `main` and the "Merge v2 into v1" PR has been merged to `v1`, the release is complete.
|
||||||
|
|
||||||
## Keeping the PR checks up to date (admin access required)
|
## Keeping the PR checks up to date (admin access required)
|
||||||
|
|
||||||
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred jobs that need to pass in order for a PR to turn green. You can regenerate the checks automatically by running the [Update required checks](.github/workflows/update-required-checks.yml) workflow.
|
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred jobs that need to pass in order for a PR to turn green. Managing these PR checks manually is time consuming and complex. Here is a semi-automated approach.
|
||||||
|
|
||||||
Or you can use this semi-automated approach:
|
To regenerate the PR jobs for the action:
|
||||||
|
|
||||||
1. In a terminal check out the `SHA` whose checks you want to use as the base. Typically, this will be `main`.
|
1. From a terminal, run the following commands (replace `SHA` with the sha of the commit whose checks you want to use, typically this should be the latest from `main`):
|
||||||
2. From a terminal, run the following commands:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
SHA="$(git rev-parse HEAD)"
|
SHA= ####
|
||||||
CHECKS="$(gh api repos/github/codeql-action/commits/${SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or . == "Update dependencies" or . == "Update Supported Enterprise Server Versions" | not)]')"
|
CHECKS="$(gh api repos/github/codeql-action/commits/${SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or . == "Update dependencies" or . == "Update Supported Enterprise Server Versions" | not)]')"
|
||||||
echo "{\"contexts\": ${CHECKS}}" > checks.json
|
echo "{\"contexts\": ${CHECKS}}" > checks.json
|
||||||
gh api -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json
|
gh api -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json
|
||||||
gh api -X "PATCH" repos/github/codeql-action/branches/releases/v2/protection/required_status_checks --input checks.json
|
gh api -X "PATCH" repos/github/codeql-action/branches/v2/protection/required_status_checks --input checks.json
|
||||||
gh api -X "PATCH" repos/github/codeql-action/branches/releases/v1/protection/required_status_checks --input checks.json
|
gh api -X "PATCH" repos/github/codeql-action/branches/v1/protection/required_status_checks --input checks.json
|
||||||
````
|
````
|
||||||
|
|
||||||
3. Go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules have been updated.
|
2. Go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules have been updated.
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ jobs:
|
|||||||
uses: github/codeql-action/autobuild@v2
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following
|
||||||
# three lines and modify them (or add more) to build your code if your
|
# three lines and modify them (or add more) to build your code if your
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ inputs:
|
|||||||
wait-for-processing:
|
wait-for-processing:
|
||||||
description: If true, the Action will wait for the uploaded SARIF to be processed before completing.
|
description: If true, the Action will wait for the uploaded SARIF to be processed before completing.
|
||||||
required: true
|
required: true
|
||||||
default: "true"
|
default: "false"
|
||||||
token:
|
token:
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
matrix:
|
matrix:
|
||||||
@@ -72,5 +72,5 @@ outputs:
|
|||||||
sarif-id:
|
sarif-id:
|
||||||
description: The ID of the uploaded SARIF file.
|
description: The ID of the uploaded SARIF file.
|
||||||
runs:
|
runs:
|
||||||
using: "node16"
|
using: "node12"
|
||||||
main: "../lib/analyze-action.js"
|
main: "../lib/analyze-action.js"
|
||||||
|
|||||||
@@ -6,12 +6,6 @@ inputs:
|
|||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
matrix:
|
matrix:
|
||||||
default: ${{ toJson(matrix) }}
|
default: ${{ toJson(matrix) }}
|
||||||
working-directory:
|
|
||||||
description: >-
|
|
||||||
Run the autobuilder using this path (relative to $GITHUB_WORKSPACE) as
|
|
||||||
working directory. If this input is not set, the autobuilder runs with
|
|
||||||
$GITHUB_WORKSPACE as its working directory.
|
|
||||||
required: false
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node12'
|
||||||
main: '../lib/autobuild-action.js'
|
main: '../lib/autobuild-action.js'
|
||||||
@@ -73,5 +73,5 @@ outputs:
|
|||||||
codeql-path:
|
codeql-path:
|
||||||
description: The path of the CodeQL binary used for analysis
|
description: The path of the CodeQL binary used for analysis
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node12'
|
||||||
main: '../lib/init-action.js'
|
main: '../lib/init-action.js'
|
||||||
|
|||||||
3
lib/actions-util.js
generated
3
lib/actions-util.js
generated
@@ -584,7 +584,8 @@ async function sendStatusReport(statusReport) {
|
|||||||
const statusReportJSON = JSON.stringify(statusReport);
|
const statusReportJSON = JSON.stringify(statusReport);
|
||||||
core.debug(`Sending status report: ${statusReportJSON}`);
|
core.debug(`Sending status report: ${statusReportJSON}`);
|
||||||
// If in test mode we don't want to upload the results
|
// If in test mode we don't want to upload the results
|
||||||
if ((0, util_1.isInTestMode)()) {
|
const testMode = process.env["TEST_MODE"] === "true" || false;
|
||||||
|
if (testMode) {
|
||||||
core.debug("In test mode. Status reports are not uploaded.");
|
core.debug("In test mode. Status reports are not uploaded.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
7
lib/analyze-action.js
generated
7
lib/analyze-action.js
generated
@@ -57,7 +57,6 @@ async function run() {
|
|||||||
let runStats = undefined;
|
let runStats = undefined;
|
||||||
let config = undefined;
|
let config = undefined;
|
||||||
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
||||||
await util.checkActionVersion(pkg.version);
|
|
||||||
try {
|
try {
|
||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) {
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) {
|
||||||
return;
|
return;
|
||||||
@@ -118,11 +117,7 @@ async function run() {
|
|||||||
}
|
}
|
||||||
// Possibly upload the database bundles for remote queries
|
// Possibly upload the database bundles for remote queries
|
||||||
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, apiDetails, logger);
|
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, apiDetails, logger);
|
||||||
// We don't upload results in test mode, so don't wait for processing
|
if (uploadResult !== undefined &&
|
||||||
if (util.isInTestMode()) {
|
|
||||||
core.debug("In test mode. Waiting for processing is disabled.");
|
|
||||||
}
|
|
||||||
else if (uploadResult !== undefined &&
|
|
||||||
actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
||||||
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
24
lib/analyze.js
generated
24
lib/analyze.js
generated
@@ -159,7 +159,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (packsWithVersion.length > 0) {
|
if (packsWithVersion.length > 0) {
|
||||||
querySuitePaths.push(...(await runQueryPacks(language, "packs", packsWithVersion, undefined)));
|
querySuitePaths.push(await runQueryGroup(language, "packs", createPackSuiteContents(packsWithVersion), undefined));
|
||||||
ranCustom = true;
|
ranCustom = true;
|
||||||
}
|
}
|
||||||
if (ranCustom) {
|
if (ranCustom) {
|
||||||
@@ -217,23 +217,21 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
|
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
|
||||||
return querySuitePath;
|
return querySuitePath;
|
||||||
}
|
}
|
||||||
async function runQueryPacks(language, type, packs, searchPath) {
|
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
|
||||||
// Run the queries individually instead of all at once to avoid command
|
|
||||||
// line length restrictions, particularly on windows.
|
|
||||||
for (const pack of packs) {
|
|
||||||
logger.debug(`Running query pack for ${language}-${type}: ${pack}`);
|
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
|
||||||
await codeql.databaseRunQueries(databasePath, searchPath, pack, memoryFlag, threadsFlag);
|
|
||||||
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
|
|
||||||
}
|
|
||||||
return packs;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exports.runQueries = runQueries;
|
exports.runQueries = runQueries;
|
||||||
function createQuerySuiteContents(queries) {
|
function createQuerySuiteContents(queries) {
|
||||||
return queries.map((q) => `- query: ${q}`).join("\n");
|
return queries.map((q) => `- query: ${q}`).join("\n");
|
||||||
}
|
}
|
||||||
|
function createPackSuiteContents(packsWithVersion) {
|
||||||
|
return packsWithVersion.map(packWithVersionToQuerySuiteEntry).join("\n");
|
||||||
|
}
|
||||||
|
function packWithVersionToQuerySuiteEntry(pack) {
|
||||||
|
let text = `- qlpack: ${pack.packName}`;
|
||||||
|
if (pack.version) {
|
||||||
|
text += `\n version: ${pack.version}`;
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
if (await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
|
if (await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
37
lib/analyze.test.js
generated
37
lib/analyze.test.js
generated
@@ -26,6 +26,7 @@ const fs = __importStar(require("fs"));
|
|||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
|
const semver_1 = require("semver");
|
||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -52,8 +53,18 @@ const util = __importStar(require("./util"));
|
|||||||
const addSnippetsFlag = "";
|
const addSnippetsFlag = "";
|
||||||
const threadsFlag = "";
|
const threadsFlag = "";
|
||||||
const packs = {
|
const packs = {
|
||||||
[languages_1.Language.cpp]: ["a/b@1.0.0"],
|
[languages_1.Language.cpp]: [
|
||||||
[languages_1.Language.java]: ["c/d@2.0.0"],
|
{
|
||||||
|
packName: "a/b",
|
||||||
|
version: (0, semver_1.clean)("1.0.0"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[languages_1.Language.java]: [
|
||||||
|
{
|
||||||
|
packName: "c/d",
|
||||||
|
version: (0, semver_1.clean)("2.0.0"),
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
for (const language of Object.values(languages_1.Language)) {
|
for (const language of Object.values(languages_1.Language)) {
|
||||||
(0, codeql_1.setCodeQL)({
|
(0, codeql_1.setCodeQL)({
|
||||||
@@ -198,10 +209,32 @@ const util = __importStar(require("./util"));
|
|||||||
query: "bar.ql",
|
query: "bar.ql",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
const qlsPackContentCpp = [
|
||||||
|
{
|
||||||
|
qlpack: "a/b",
|
||||||
|
version: "1.0.0",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const qlsPackContentJava = [
|
||||||
|
{
|
||||||
|
qlpack: "c/d",
|
||||||
|
version: "2.0.0",
|
||||||
|
},
|
||||||
|
];
|
||||||
for (const lang of Object.values(languages_1.Language)) {
|
for (const lang of Object.values(languages_1.Language)) {
|
||||||
t.deepEqual(readContents(`${lang}-queries-builtin.qls`), qlsContent);
|
t.deepEqual(readContents(`${lang}-queries-builtin.qls`), qlsContent);
|
||||||
t.deepEqual(readContents(`${lang}-queries-custom-0.qls`), qlsContent);
|
t.deepEqual(readContents(`${lang}-queries-custom-0.qls`), qlsContent);
|
||||||
t.deepEqual(readContents(`${lang}-queries-custom-1.qls`), qlsContent2);
|
t.deepEqual(readContents(`${lang}-queries-custom-1.qls`), qlsContent2);
|
||||||
|
const packSuiteName = `${lang}-queries-packs.qls`;
|
||||||
|
if (lang === languages_1.Language.cpp) {
|
||||||
|
t.deepEqual(readContents(packSuiteName), qlsPackContentCpp);
|
||||||
|
}
|
||||||
|
else if (lang === languages_1.Language.java) {
|
||||||
|
t.deepEqual(readContents(packSuiteName), qlsPackContentJava);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
t.false(fs.existsSync(path.join(tmpDir, "codeql_databases", packSuiteName)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function readContents(name) {
|
function readContents(name) {
|
||||||
const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8");
|
const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8");
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
8
lib/autobuild-action.js
generated
8
lib/autobuild-action.js
generated
@@ -39,9 +39,8 @@ async function sendCompletedStatusReport(startedAt, allLanguages, failingLanguag
|
|||||||
await (0, actions_util_1.sendStatusReport)(statusReport);
|
await (0, actions_util_1.sendStatusReport)(statusReport);
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
const startedAt = new Date();
|
|
||||||
const logger = (0, logging_1.getActionsLogger)();
|
const logger = (0, logging_1.getActionsLogger)();
|
||||||
await (0, util_1.checkActionVersion)(pkg.version);
|
const startedAt = new Date();
|
||||||
let language = undefined;
|
let language = undefined;
|
||||||
try {
|
try {
|
||||||
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("autobuild", "starting", startedAt)))) {
|
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("autobuild", "starting", startedAt)))) {
|
||||||
@@ -53,11 +52,6 @@ async function run() {
|
|||||||
}
|
}
|
||||||
language = (0, autobuild_1.determineAutobuildLanguage)(config, logger);
|
language = (0, autobuild_1.determineAutobuildLanguage)(config, logger);
|
||||||
if (language !== undefined) {
|
if (language !== undefined) {
|
||||||
const workingDirectory = (0, actions_util_1.getOptionalInput)("working-directory");
|
|
||||||
if (workingDirectory) {
|
|
||||||
logger.info(`Changing autobuilder working directory to ${workingDirectory}`);
|
|
||||||
process.chdir(workingDirectory);
|
|
||||||
}
|
|
||||||
await (0, autobuild_1.runAutobuild)(language, config, logger);
|
await (0, autobuild_1.runAutobuild)(language, config, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,iDAOwB;AACxB,2CAAuE;AACvE,6DAA+C;AAE/C,uCAA6C;AAC7C,iCAAyE;AAEzE,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AASvC,KAAK,UAAU,yBAAyB,CACtC,SAAe,EACf,YAAsB,EACtB,eAAwB,EACxB,KAAa;IAEb,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAEjD,MAAM,MAAM,GAAG,IAAA,+BAAgB,EAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IACxD,MAAM,gBAAgB,GAAG,MAAM,IAAA,qCAAsB,EACnD,WAAW,EACX,MAAM,EACN,SAAS,EACT,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EACd,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CACb,CAAC;IACF,MAAM,YAAY,GAA0B;QAC1C,GAAG,gBAAgB;QACnB,mBAAmB,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3C,iBAAiB,EAAE,eAAe;KACnC,CAAC;IACF,MAAM,IAAA,+BAAgB,EAAC,YAAY,CAAC,CAAC;AACvC,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAClC,MAAM,IAAA,yBAAkB,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,QAAQ,GAAyB,SAAS,CAAC;IAC/C,IAAI;QACF,IACE,CAAC,CAAC,MAAM,IAAA,+BAAgB,EACtB,MAAM,IAAA,qCAAsB,EAAC,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC,CACjE,CAAC,EACF;YACA,OAAO;SACR;QAED,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,SAAS,CACzC,IAAA,oCAAqB,GAAE,EACvB,MAAM,CACP,CAAC;QACF,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;SACH;QACD,QAAQ,GAAG,IAAA,sCAA0B,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,MAAM,gBAAgB,GAAG,IAAA,+BAAgB,EAAC,mBAAmB,CAAC,CAAC;YAC/D,IAAI,gBAAgB,EAAE;gBACpB,MAAM,CAAC,IAAI,CACT,6CAA6C,gBAAgB,EAAE,CAChE,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;aACjC;YACD,MAAM,IAAA,wBAAY,EAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SAC9C;KACF;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CACZ,mIACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,yBAAyB,CAC7B,SAAS,EACT,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,EAC1B,QAAQ,EACR,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAC1D,CAAC;QACF,OAAO;KACR;IAED,MAAM,yBAAyB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,iDAMwB;AACxB,2CAAuE;AACvE,6DAA+C;AAE/C,uCAA6C;AAC7C,iCAAqD;AAErD,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AASvC,KAAK,UAAU,yBAAyB,CACtC,SAAe,EACf,YAAsB,EACtB,eAAwB,EACxB,KAAa;IAEb,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAEjD,MAAM,MAAM,GAAG,IAAA,+BAAgB,EAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IACxD,MAAM,gBAAgB,GAAG,MAAM,IAAA,qCAAsB,EACnD,WAAW,EACX,MAAM,EACN,SAAS,EACT,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EACd,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CACb,CAAC;IACF,MAAM,YAAY,GAA0B;QAC1C,GAAG,gBAAgB;QACnB,mBAAmB,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3C,iBAAiB,EAAE,eAAe;KACnC,CAAC;IACF,MAAM,IAAA,+BAAgB,EAAC,YAAY,CAAC,CAAC;AACvC,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAClC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IAAI,QAAQ,GAAyB,SAAS,CAAC;IAC/C,IAAI;QACF,IACE,CAAC,CAAC,MAAM,IAAA,+BAAgB,EACtB,MAAM,IAAA,qCAAsB,EAAC,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC,CACjE,CAAC,EACF;YACA,OAAO;SACR;QAED,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,SAAS,CACzC,IAAA,oCAAqB,GAAE,EACvB,MAAM,CACP,CAAC;QACF,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;SACH;QACD,QAAQ,GAAG,IAAA,sCAA0B,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,MAAM,IAAA,wBAAY,EAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SAC9C;KACF;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CACZ,mIACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,yBAAyB,CAC7B,SAAS,EACT,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,EAC1B,QAAQ,EACR,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAC1D,CAAC;QACF,OAAO;KACR;IAED,MAAM,yBAAyB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||||
8
lib/codeql.js
generated
8
lib/codeql.js
generated
@@ -394,7 +394,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
async getVersion() {
|
async getVersion() {
|
||||||
let result = util.getCachedCodeQlVersion();
|
let result = util.getCachedCodeQlVersion();
|
||||||
if (result === undefined) {
|
if (result === undefined) {
|
||||||
result = (await runTool(cmd, ["version", "--format=terse"])).trim();
|
result = await runTool(cmd, ["version", "--format=terse"]);
|
||||||
util.cacheCodeQlVersion(result);
|
util.cacheCodeQlVersion(result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -641,9 +641,8 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
"pack",
|
"pack",
|
||||||
"download",
|
"download",
|
||||||
"--format=json",
|
"--format=json",
|
||||||
"--resolve-query-specs",
|
|
||||||
...getExtraOptionsFromEnv(["pack", "download"]),
|
...getExtraOptionsFromEnv(["pack", "download"]),
|
||||||
...packs,
|
...packs.map(packWithVersionToString),
|
||||||
];
|
];
|
||||||
const output = await runTool(cmd, codeqlArgs);
|
const output = await runTool(cmd, codeqlArgs);
|
||||||
try {
|
try {
|
||||||
@@ -699,6 +698,9 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
}
|
}
|
||||||
return codeql;
|
return codeql;
|
||||||
}
|
}
|
||||||
|
function packWithVersionToString(pack) {
|
||||||
|
return pack.version ? `${pack.packName}@${pack.version}` : pack.packName;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the options for `path` of `options` as an array of extra option strings.
|
* Gets the options for `path` of `options` as an array of extra option strings.
|
||||||
*/
|
*/
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
79
lib/config-utils.js
generated
79
lib/config-utils.js
generated
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.parsePacks = exports.validatePacksSpecification = exports.parsePacksFromConfig = exports.getDefaultConfig = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getLocalPathDoesNotExist = exports.getLocalPathOutsideOfRepository = exports.getPacksStrInvalid = exports.getPacksInvalid = exports.getPacksInvalidSplit = exports.getPacksRequireLanguage = exports.getPathsInvalid = exports.getPathsIgnoreInvalid = exports.getQueryUsesInvalid = exports.getQueriesInvalid = exports.getDisableDefaultQueriesInvalid = exports.getNameInvalid = exports.validateAndSanitisePath = void 0;
|
exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.parsePacks = exports.parsePacksFromConfig = exports.getDefaultConfig = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getLocalPathDoesNotExist = exports.getLocalPathOutsideOfRepository = exports.getPacksStrInvalid = exports.getPacksInvalid = exports.getPacksInvalidSplit = exports.getPacksRequireLanguage = exports.getPathsInvalid = exports.getPathsIgnoreInvalid = exports.getQueryUsesInvalid = exports.getQueriesInvalid = exports.getDisableDefaultQueriesInvalid = exports.getNameInvalid = exports.validateAndSanitisePath = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
@@ -135,7 +135,7 @@ async function addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, suite
|
|||||||
process.platform !== "win32" &&
|
process.platform !== "win32" &&
|
||||||
languages.includes("javascript") &&
|
languages.includes("javascript") &&
|
||||||
(found === "security-extended" || found === "security-and-quality") &&
|
(found === "security-extended" || found === "security-and-quality") &&
|
||||||
!((_a = packs.javascript) === null || _a === void 0 ? void 0 : _a.some(isMlPoweredJsQueriesPack)) &&
|
!((_a = packs.javascript) === null || _a === void 0 ? void 0 : _a.some((pack) => pack.packName === util_1.ML_POWERED_JS_QUERIES_PACK_NAME)) &&
|
||||||
(await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled)) &&
|
(await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled)) &&
|
||||||
(await (0, util_1.codeQlVersionAbove)(codeQL, codeql_1.CODEQL_VERSION_ML_POWERED_QUERIES))) {
|
(await (0, util_1.codeQlVersionAbove)(codeQL, codeql_1.CODEQL_VERSION_ML_POWERED_QUERIES))) {
|
||||||
if (!packs.javascript) {
|
if (!packs.javascript) {
|
||||||
@@ -148,11 +148,6 @@ async function addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, suite
|
|||||||
await runResolveQueries(codeQL, resultMap, suites, undefined);
|
await runResolveQueries(codeQL, resultMap, suites, undefined);
|
||||||
return injectedMlQueries;
|
return injectedMlQueries;
|
||||||
}
|
}
|
||||||
function isMlPoweredJsQueriesPack(pack) {
|
|
||||||
return (pack === util_1.ML_POWERED_JS_QUERIES_PACK_NAME ||
|
|
||||||
pack.startsWith(`${util_1.ML_POWERED_JS_QUERIES_PACK_NAME}@`) ||
|
|
||||||
pack.startsWith(`${util_1.ML_POWERED_JS_QUERIES_PACK_NAME}:`));
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the set of queries at localQueryPath and add them to resultMap.
|
* Retrieve the set of queries at localQueryPath and add them to resultMap.
|
||||||
*/
|
*/
|
||||||
@@ -639,7 +634,7 @@ function parsePacksFromConfig(packsByLanguage, languages, configFile) {
|
|||||||
}
|
}
|
||||||
packs[lang] = [];
|
packs[lang] = [];
|
||||||
for (const packStr of packsArr) {
|
for (const packStr of packsArr) {
|
||||||
packs[lang].push(validatePacksSpecification(packStr, configFile));
|
packs[lang].push(toPackWithVersion(packStr, configFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return packs;
|
return packs;
|
||||||
@@ -664,74 +659,32 @@ function parsePacksFromInput(packsInput, languages) {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
[languages[0]]: packsInput.split(",").reduce((packs, pack) => {
|
[languages[0]]: packsInput.split(",").reduce((packs, pack) => {
|
||||||
packs.push(validatePacksSpecification(pack, ""));
|
packs.push(toPackWithVersion(pack, ""));
|
||||||
return packs;
|
return packs;
|
||||||
}, []),
|
}, []),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
function toPackWithVersion(packStr, configFile) {
|
||||||
* Validates that this package specification is syntactically correct.
|
|
||||||
* It may not point to any real package, but after this function returns
|
|
||||||
* without throwing, we are guaranteed that the package specification
|
|
||||||
* is roughly correct.
|
|
||||||
*
|
|
||||||
* The CLI itself will do a more thorough validation of the package
|
|
||||||
* specification.
|
|
||||||
*
|
|
||||||
* A package specification looks like this:
|
|
||||||
*
|
|
||||||
* `scope/name@version:path`
|
|
||||||
*
|
|
||||||
* Version and path are optional.
|
|
||||||
*
|
|
||||||
* @param packStr the package specification to verify.
|
|
||||||
* @param configFile Config file to use for error reporting
|
|
||||||
*/
|
|
||||||
function validatePacksSpecification(packStr, configFile) {
|
|
||||||
if (typeof packStr !== "string") {
|
if (typeof packStr !== "string") {
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
throw new Error(getPacksStrInvalid(packStr, configFile));
|
||||||
}
|
}
|
||||||
packStr = packStr.trim();
|
const nameWithVersion = packStr.trim().split("@");
|
||||||
const atIndex = packStr.indexOf("@");
|
let version;
|
||||||
const colonIndex = packStr.indexOf(":", atIndex);
|
if (nameWithVersion.length > 2 ||
|
||||||
const packStart = 0;
|
!PACK_IDENTIFIER_PATTERN.test(nameWithVersion[0])) {
|
||||||
const versionStart = atIndex + 1 || undefined;
|
|
||||||
const pathStart = colonIndex + 1 || undefined;
|
|
||||||
const packEnd = Math.min(atIndex > 0 ? atIndex : Infinity, colonIndex > 0 ? colonIndex : Infinity, packStr.length);
|
|
||||||
const versionEnd = versionStart
|
|
||||||
? Math.min(colonIndex > 0 ? colonIndex : Infinity, packStr.length)
|
|
||||||
: undefined;
|
|
||||||
const pathEnd = pathStart ? packStr.length : undefined;
|
|
||||||
const packName = packStr.slice(packStart, packEnd).trim();
|
|
||||||
const version = versionStart
|
|
||||||
? packStr.slice(versionStart, versionEnd).trim()
|
|
||||||
: undefined;
|
|
||||||
const packPath = pathStart
|
|
||||||
? packStr.slice(pathStart, pathEnd).trim()
|
|
||||||
: undefined;
|
|
||||||
if (!PACK_IDENTIFIER_PATTERN.test(packName)) {
|
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
throw new Error(getPacksStrInvalid(packStr, configFile));
|
||||||
}
|
}
|
||||||
if (version) {
|
else if (nameWithVersion.length === 2) {
|
||||||
try {
|
version = semver.clean(nameWithVersion[1]) || undefined;
|
||||||
new semver.Range(version);
|
if (!version) {
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
// The range string is invalid. OK to ignore the caught error
|
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
throw new Error(getPacksStrInvalid(packStr, configFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (packPath &&
|
return {
|
||||||
(path.isAbsolute(packPath) || path.normalize(packPath) !== packPath)) {
|
packName: nameWithVersion[0].trim(),
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
version,
|
||||||
}
|
};
|
||||||
if (!packPath && pathStart) {
|
|
||||||
// 0 length path
|
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
|
||||||
}
|
|
||||||
return (packName + (version ? `@${version}` : "") + (packPath ? `:${packPath}` : ""));
|
|
||||||
}
|
}
|
||||||
exports.validatePacksSpecification = validatePacksSpecification;
|
|
||||||
// exported for testing
|
// exported for testing
|
||||||
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile) {
|
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile) {
|
||||||
const packsFromInput = parsePacksFromInput(rawPacksInput, languages);
|
const packsFromInput = parsePacksFromInput(rawPacksInput, languages);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
112
lib/config-utils.test.js
generated
112
lib/config-utils.test.js
generated
@@ -26,6 +26,7 @@ const fs = __importStar(require("fs"));
|
|||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const github = __importStar(require("@actions/github"));
|
const github = __importStar(require("@actions/github"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
|
const semver_1 = require("semver");
|
||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -600,7 +601,12 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const { packs } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
const { packs } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: ["a/b@1.2.3"],
|
[languages_1.Language.javascript]: [
|
||||||
|
{
|
||||||
|
packName: "a/b",
|
||||||
|
version: (0, semver_1.clean)("1.2.3"),
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -634,8 +640,18 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
const languages = "javascript,python,cpp";
|
const languages = "javascript,python,cpp";
|
||||||
const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example" }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example" }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: ["a/b@1.2.3"],
|
[languages_1.Language.javascript]: [
|
||||||
[languages_1.Language.python]: ["c/d@1.2.3"],
|
{
|
||||||
|
packName: "a/b",
|
||||||
|
version: (0, semver_1.clean)("1.2.3"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[languages_1.Language.python]: [
|
||||||
|
{
|
||||||
|
packName: "c/d",
|
||||||
|
version: (0, semver_1.clean)("1.2.3"),
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
t.deepEqual(queries, {
|
t.deepEqual(queries, {
|
||||||
cpp: {
|
cpp: {
|
||||||
@@ -770,47 +786,28 @@ const invalidPackNameMacro = ava_1.default.macro({
|
|||||||
});
|
});
|
||||||
(0, ava_1.default)("no packs", parsePacksMacro, {}, [], {});
|
(0, ava_1.default)("no packs", parsePacksMacro, {}, [], {});
|
||||||
(0, ava_1.default)("two packs", parsePacksMacro, ["a/b", "c/d@1.2.3"], [languages_1.Language.cpp], {
|
(0, ava_1.default)("two packs", parsePacksMacro, ["a/b", "c/d@1.2.3"], [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("two packs with spaces", parsePacksMacro, [" a/b ", " c/d@1.2.3 "], [languages_1.Language.cpp], {
|
(0, ava_1.default)("two packs with spaces", parsePacksMacro, [" a/b ", " c/d@1.2.3 "], [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("two packs with language", parsePacksMacro, {
|
(0, ava_1.default)("two packs with language", parsePacksMacro, {
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
||||||
}, [languages_1.Language.cpp, languages_1.Language.java, languages_1.Language.csharp], {
|
}, [languages_1.Language.cpp, languages_1.Language.java, languages_1.Language.csharp], {
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
|
||||||
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
|
||||||
});
|
|
||||||
(0, ava_1.default)("packs with other valid names", parsePacksMacro, [
|
|
||||||
// ranges are ok
|
|
||||||
"c/d@1.0",
|
|
||||||
"c/d@~1.0.0",
|
|
||||||
"c/d@~1.0.0:a/b",
|
|
||||||
"c/d@~1.0.0+abc:a/b",
|
|
||||||
"c/d@~1.0.0-abc:a/b",
|
|
||||||
"c/d:a/b",
|
|
||||||
// whitespace is removed
|
|
||||||
" c/d @ ~1.0.0 : b.qls ",
|
|
||||||
// and it is retained within a path
|
|
||||||
" c/d @ ~1.0.0 : b/a path with/spaces.qls ",
|
|
||||||
// this is valid. the path is '@'. It will probably fail when passed to the CLI
|
|
||||||
"c/d@1.2.3:@",
|
|
||||||
// this is valid, too. It will fail if it doesn't match a path
|
|
||||||
// (globbing is not done)
|
|
||||||
"c/d@1.2.3:+*)_(",
|
|
||||||
], [languages_1.Language.cpp], {
|
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: [
|
||||||
"c/d@1.0",
|
{ packName: "a/b", version: undefined },
|
||||||
"c/d@~1.0.0",
|
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
|
||||||
"c/d@~1.0.0:a/b",
|
],
|
||||||
"c/d@~1.0.0+abc:a/b",
|
[languages_1.Language.java]: [
|
||||||
"c/d@~1.0.0-abc:a/b",
|
{ packName: "d/e", version: undefined },
|
||||||
"c/d:a/b",
|
{ packName: "f/g", version: (0, semver_1.clean)("1.2.3") },
|
||||||
"c/d@~1.0.0:b.qls",
|
|
||||||
"c/d@~1.0.0:b/a path with/spaces.qls",
|
|
||||||
"c/d@1.2.3:@",
|
|
||||||
"c/d@1.2.3:+*)_(",
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/);
|
(0, ava_1.default)("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/);
|
||||||
@@ -820,14 +817,7 @@ const invalidPackNameMacro = ava_1.default.macro({
|
|||||||
(0, ava_1.default)(invalidPackNameMacro, "c-/d");
|
(0, ava_1.default)(invalidPackNameMacro, "c-/d");
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "-c/d");
|
(0, ava_1.default)(invalidPackNameMacro, "-c/d");
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c/d_d");
|
(0, ava_1.default)(invalidPackNameMacro, "c/d_d");
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c/d@@");
|
(0, ava_1.default)(invalidPackNameMacro, "c/d@x");
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c/d@1.0.0:");
|
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c/d:");
|
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c/d:/a");
|
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "@1.0.0:a");
|
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c/d@../a");
|
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c/d@b/../a");
|
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c/d:z@1");
|
|
||||||
/**
|
/**
|
||||||
* Test macro for testing the packs block and the packs input
|
* Test macro for testing the packs block and the packs input
|
||||||
*/
|
*/
|
||||||
@@ -844,22 +834,39 @@ function parseInputAndConfigErrorMacro(t, packsFromConfig, packsFromInput, langu
|
|||||||
}
|
}
|
||||||
parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and config Error: ${providedTitle}`;
|
parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and config Error: ${providedTitle}`;
|
||||||
(0, ava_1.default)("input only", parseInputAndConfigMacro, {}, " c/d ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input only", parseInputAndConfigMacro, {}, " c/d ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: ["c/d"],
|
[languages_1.Language.cpp]: [{ packName: "c/d", version: undefined }],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("input only with multiple", parseInputAndConfigMacro, {}, "a/b , c/d@1.2.3", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input only with multiple", parseInputAndConfigMacro, {}, "a/b , c/d@1.2.3", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: "1.2.3" },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("input only with +", parseInputAndConfigMacro, {}, " + a/b , c/d@1.2.3 ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input only with +", parseInputAndConfigMacro, {}, " + a/b , c/d@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: "1.2.3" },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("config only", parseInputAndConfigMacro, ["a/b", "c/d"], " ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("config only", parseInputAndConfigMacro, ["a/b", "c/d"], " ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d"],
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: undefined },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("input overrides", parseInputAndConfigMacro, ["a/b", "c/d"], " e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input overrides", parseInputAndConfigMacro, ["a/b", "c/d"], " e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: ["e/f", "g/h@1.2.3"],
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "e/f", version: undefined },
|
||||||
|
{ packName: "g/h", version: "1.2.3" },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: ["e/f", "g/h@1.2.3", "a/b", "c/d"],
|
[languages_1.Language.cpp]: [
|
||||||
|
{ packName: "e/f", version: undefined },
|
||||||
|
{ packName: "g/h", version: "1.2.3" },
|
||||||
|
{ packName: "a/b", version: undefined },
|
||||||
|
{ packName: "c/d", version: undefined },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/);
|
(0, ava_1.default)("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/);
|
||||||
(0, ava_1.default)("input with two languages", parseInputAndConfigErrorMacro, {}, "c/d", [languages_1.Language.cpp, languages_1.Language.csharp], /multi-language analysis/);
|
(0, ava_1.default)("input with two languages", parseInputAndConfigErrorMacro, {}, "c/d", [languages_1.Language.cpp, languages_1.Language.csharp], /multi-language analysis/);
|
||||||
@@ -888,7 +895,10 @@ const mlPoweredQueriesMacro = ava_1.default.macro({
|
|||||||
if (expectedVersionString !== undefined) {
|
if (expectedVersionString !== undefined) {
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: [
|
[languages_1.Language.javascript]: [
|
||||||
`codeql/javascript-experimental-atm-queries@${expectedVersionString}`,
|
{
|
||||||
|
packName: "codeql/javascript-experimental-atm-queries",
|
||||||
|
version: expectedVersionString,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20220421"
|
"bundleVersion": "codeql-bundle-20220401"
|
||||||
}
|
}
|
||||||
|
|||||||
1
lib/init-action.js
generated
1
lib/init-action.js
generated
@@ -71,7 +71,6 @@ async function run() {
|
|||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
const logger = (0, logging_1.getActionsLogger)();
|
const logger = (0, logging_1.getActionsLogger)();
|
||||||
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
||||||
await (0, util_1.checkActionVersion)(pkg.version);
|
|
||||||
let config;
|
let config;
|
||||||
let codeql;
|
let codeql;
|
||||||
let toolsVersion;
|
let toolsVersion;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
29
lib/upload-lib.js
generated
29
lib/upload-lib.js
generated
@@ -93,7 +93,8 @@ function getAutomationID(category, analysis_key, environment) {
|
|||||||
async function uploadPayload(payload, repositoryNwo, apiDetails, logger) {
|
async function uploadPayload(payload, repositoryNwo, apiDetails, logger) {
|
||||||
logger.info("Uploading results");
|
logger.info("Uploading results");
|
||||||
// If in test mode we don't want to upload the results
|
// If in test mode we don't want to upload the results
|
||||||
if (util.isInTestMode()) {
|
const testMode = process.env["TEST_MODE"] === "true" || false;
|
||||||
|
if (testMode) {
|
||||||
const payloadSaveFile = path.join(actionsUtil.getTemporaryDirectory(), "payload.json");
|
const payloadSaveFile = path.join(actionsUtil.getTemporaryDirectory(), "payload.json");
|
||||||
logger.info(`In test mode. Results are not uploaded. Saving to ${payloadSaveFile}`);
|
logger.info(`In test mode. Results are not uploaded. Saving to ${payloadSaveFile}`);
|
||||||
logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`);
|
logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`);
|
||||||
@@ -310,29 +311,35 @@ async function waitForProcessing(repositoryNwo, sarifID, apiDetails, logger) {
|
|||||||
logger.warning("Timed out waiting for analysis to finish processing. Continuing.");
|
logger.warning("Timed out waiting for analysis to finish processing. Continuing.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let response = undefined;
|
|
||||||
try {
|
try {
|
||||||
response = await client.request("GET /repos/:owner/:repo/code-scanning/sarifs/:sarif_id", {
|
const response = await client.request("GET /repos/:owner/:repo/code-scanning/sarifs/:sarif_id", {
|
||||||
owner: repositoryNwo.owner,
|
owner: repositoryNwo.owner,
|
||||||
repo: repositoryNwo.repo,
|
repo: repositoryNwo.repo,
|
||||||
sarif_id: sarifID,
|
sarif_id: sarifID,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
logger.warning(`An error occurred checking the status of the delivery. ${e} It should still be processed in the background, but errors that occur during processing may not be reported.`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const status = response.data.processing_status;
|
const status = response.data.processing_status;
|
||||||
logger.info(`Analysis upload status is ${status}.`);
|
logger.info(`Analysis upload status is ${status}.`);
|
||||||
if (status === "complete") {
|
if (status === "complete") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (status === "pending") {
|
|
||||||
logger.debug("Analysis processing is still pending...");
|
|
||||||
}
|
|
||||||
else if (status === "failed") {
|
else if (status === "failed") {
|
||||||
throw new Error(`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`);
|
throw new Error(`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (util.isHTTPError(e)) {
|
||||||
|
switch (e.status) {
|
||||||
|
case 404:
|
||||||
|
logger.debug("Analysis is not found yet...");
|
||||||
|
break; // Note this breaks from the case statement, not the outer loop.
|
||||||
|
default:
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS);
|
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS);
|
||||||
}
|
}
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
9
lib/upload-sarif-action.js
generated
9
lib/upload-sarif-action.js
generated
@@ -37,9 +37,8 @@ async function sendSuccessStatusReport(startedAt, uploadStats) {
|
|||||||
await actionsUtil.sendStatusReport(statusReport);
|
await actionsUtil.sendStatusReport(statusReport);
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
const startedAt = new Date();
|
|
||||||
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
||||||
await (0, util_1.checkActionVersion)(pkg.version);
|
const startedAt = new Date();
|
||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("upload-sarif", "starting", startedAt)))) {
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("upload-sarif", "starting", startedAt)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -51,11 +50,7 @@ async function run() {
|
|||||||
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
|
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
|
||||||
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, (0, logging_1.getActionsLogger)());
|
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, (0, logging_1.getActionsLogger)());
|
||||||
core.setOutput("sarif-id", uploadResult.sarifID);
|
core.setOutput("sarif-id", uploadResult.sarifID);
|
||||||
// We don't upload results in test mode, so don't wait for processing
|
if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
||||||
if ((0, util_1.isInTestMode)()) {
|
|
||||||
core.debug("In test mode. Waiting for processing is disabled.");
|
|
||||||
}
|
|
||||||
else if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
|
||||||
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
||||||
}
|
}
|
||||||
await sendSuccessStatusReport(startedAt, uploadResult.statusReport);
|
await sendSuccessStatusReport(startedAt, uploadResult.statusReport);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,6CAA2D;AAC3D,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAC3C,iCAMgB;AAEhB,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAMvC,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAA4B;QAC5C,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,IAAA,yBAAkB,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IACE,CAAC,CAAC,MAAM,WAAW,CAAC,gBAAgB,CAClC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,UAAU,EACV,SAAS,CACV,CACF,CAAC,EACF;QACA,OAAO;KACR;IAED,IAAI;QACF,MAAM,UAAU,GAAG;YACjB,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC;YAC3C,GAAG,EAAE,IAAA,0BAAmB,EAAC,mBAAmB,CAAC;SAC9C,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,IAAA,wCAA2B,GAAE,CAAC;QAE1D,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,iBAAiB,CACrD,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAC1C,aAAa,EACb,UAAU,EACV,IAAA,0BAAgB,GAAE,CACnB,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QAEjD,qEAAqE;QACrE,IAAI,IAAA,mBAAY,GAAE,EAAE;YAClB,IAAI,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;SACjE;aAAM,IAAI,WAAW,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,KAAK,MAAM,EAAE;YACzE,MAAM,UAAU,CAAC,iBAAiB,CAChC,IAAA,+BAAkB,EAAC,IAAA,0BAAmB,EAAC,mBAAmB,CAAC,CAAC,EAC5D,YAAY,CAAC,OAAO,EACpB,UAAU,EACV,IAAA,0BAAgB,GAAE,CACnB,CAAC;SACH;QACD,MAAM,uBAAuB,CAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;KACrE;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,EACnC,SAAS,EACT,OAAO,EACP,KAAK,CACN,CACF,CAAC;QACF,OAAO;KACR;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,6CAA2D;AAC3D,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAC3C,iCAA0E;AAE1E,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAMvC,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAA4B;QAC5C,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IACE,CAAC,CAAC,MAAM,WAAW,CAAC,gBAAgB,CAClC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,UAAU,EACV,SAAS,CACV,CACF,CAAC,EACF;QACA,OAAO;KACR;IAED,IAAI;QACF,MAAM,UAAU,GAAG;YACjB,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC;YAC3C,GAAG,EAAE,IAAA,0BAAmB,EAAC,mBAAmB,CAAC;SAC9C,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,IAAA,wCAA2B,GAAE,CAAC;QAE1D,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,iBAAiB,CACrD,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAC1C,aAAa,EACb,UAAU,EACV,IAAA,0BAAgB,GAAE,CACnB,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,WAAW,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,KAAK,MAAM,EAAE;YAClE,MAAM,UAAU,CAAC,iBAAiB,CAChC,IAAA,+BAAkB,EAAC,IAAA,0BAAmB,EAAC,mBAAmB,CAAC,CAAC,EAC5D,YAAY,CAAC,OAAO,EACpB,UAAU,EACV,IAAA,0BAAgB,GAAE,CACnB,CAAC;SACH;QACD,MAAM,uBAAuB,CAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;KACrE;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,EACnC,SAAS,EACT,OAAO,EACP,KAAK,CACN,CACF,CAAC;QACF,OAAO;KACR;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||||
50
lib/util.js
generated
50
lib/util.js
generated
@@ -22,14 +22,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.isInTestMode = exports.checkActionVersion = exports.getMlPoweredJsQueriesStatus = exports.getMlPoweredJsQueriesPack = exports.ML_POWERED_JS_QUERIES_PACK_NAME = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.getCachedCodeQlVersion = exports.cacheCodeQlVersion = exports.isGitHubGhesVersionBelow = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
exports.getMlPoweredJsQueriesStatus = exports.getMlPoweredJsQueriesPack = exports.ML_POWERED_JS_QUERIES_PACK_NAME = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.getCachedCodeQlVersion = exports.cacheCodeQlVersion = exports.isGitHubGhesVersionBelow = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const del_1 = __importDefault(require("del"));
|
const del_1 = __importDefault(require("del"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const api = __importStar(require("./api-client"));
|
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
const apiCompatibility = __importStar(require("./api-compatibility.json"));
|
const apiCompatibility = __importStar(require("./api-compatibility.json"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -553,9 +552,9 @@ exports.ML_POWERED_JS_QUERIES_PACK_NAME = "codeql/javascript-experimental-atm-qu
|
|||||||
*/
|
*/
|
||||||
async function getMlPoweredJsQueriesPack(codeQL) {
|
async function getMlPoweredJsQueriesPack(codeQL) {
|
||||||
if (await codeQlVersionAbove(codeQL, "2.8.4")) {
|
if (await codeQlVersionAbove(codeQL, "2.8.4")) {
|
||||||
return `${exports.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.2.0`;
|
return { packName: exports.ML_POWERED_JS_QUERIES_PACK_NAME, version: "~0.2.0" };
|
||||||
}
|
}
|
||||||
return `${exports.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.1.0`;
|
return { packName: exports.ML_POWERED_JS_QUERIES_PACK_NAME, version: "~0.1.0" };
|
||||||
}
|
}
|
||||||
exports.getMlPoweredJsQueriesPack = getMlPoweredJsQueriesPack;
|
exports.getMlPoweredJsQueriesPack = getMlPoweredJsQueriesPack;
|
||||||
/**
|
/**
|
||||||
@@ -580,10 +579,7 @@ exports.getMlPoweredJsQueriesPack = getMlPoweredJsQueriesPack;
|
|||||||
* explanation as to why this is.
|
* explanation as to why this is.
|
||||||
*/
|
*/
|
||||||
function getMlPoweredJsQueriesStatus(config) {
|
function getMlPoweredJsQueriesStatus(config) {
|
||||||
const mlPoweredJsQueryPacks = (config.packs.javascript || [])
|
const mlPoweredJsQueryPacks = (config.packs.javascript || []).filter((pack) => pack.packName === exports.ML_POWERED_JS_QUERIES_PACK_NAME);
|
||||||
.map((pack) => pack.split("@"))
|
|
||||||
.filter((packNameVersion) => packNameVersion[0] === "codeql/javascript-experimental-atm-queries" &&
|
|
||||||
packNameVersion.length <= 2);
|
|
||||||
switch (mlPoweredJsQueryPacks.length) {
|
switch (mlPoweredJsQueryPacks.length) {
|
||||||
case 1:
|
case 1:
|
||||||
// We should always specify an explicit version string in `getMlPoweredJsQueriesPack`,
|
// We should always specify an explicit version string in `getMlPoweredJsQueriesPack`,
|
||||||
@@ -591,7 +587,7 @@ function getMlPoweredJsQueriesStatus(config) {
|
|||||||
// with each version of the CodeQL Action. Therefore in practice we should only hit the
|
// with each version of the CodeQL Action. Therefore in practice we should only hit the
|
||||||
// `latest` case here when customers have explicitly added the ML-powered query pack to their
|
// `latest` case here when customers have explicitly added the ML-powered query pack to their
|
||||||
// CodeQL config.
|
// CodeQL config.
|
||||||
return mlPoweredJsQueryPacks[0][1] || "latest";
|
return mlPoweredJsQueryPacks[0].version || "latest";
|
||||||
case 0:
|
case 0:
|
||||||
return "false";
|
return "false";
|
||||||
default:
|
default:
|
||||||
@@ -599,40 +595,4 @@ function getMlPoweredJsQueriesStatus(config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getMlPoweredJsQueriesStatus = getMlPoweredJsQueriesStatus;
|
exports.getMlPoweredJsQueriesStatus = getMlPoweredJsQueriesStatus;
|
||||||
/**
|
|
||||||
* Prompt the customer to upgrade to CodeQL Action v2, if appropriate.
|
|
||||||
*
|
|
||||||
* Check whether a customer is running v1. If they are, and we can determine that the GitHub
|
|
||||||
* instance supports v2, then log a warning about v1's upcoming deprecation prompting the customer
|
|
||||||
* to upgrade to v2.
|
|
||||||
*/
|
|
||||||
async function checkActionVersion(version) {
|
|
||||||
var _a;
|
|
||||||
if (!semver.satisfies(version, ">=2")) {
|
|
||||||
const githubVersion = await api.getGitHubVersionActionsOnly();
|
|
||||||
// Only log a warning for versions of GHES that are compatible with CodeQL Action version 2.
|
|
||||||
//
|
|
||||||
// GHES 3.4 shipped without the v2 tag, but it also shipped without this warning message code.
|
|
||||||
// Therefore users who are seeing this warning message code have pulled in a new version of the
|
|
||||||
// Action, and with it the v2 tag.
|
|
||||||
if (githubVersion.type === GitHubVariant.DOTCOM ||
|
|
||||||
githubVersion.type === GitHubVariant.GHAE ||
|
|
||||||
(githubVersion.type === GitHubVariant.GHES &&
|
|
||||||
semver.satisfies((_a = semver.coerce(githubVersion.version)) !== null && _a !== void 0 ? _a : "0.0.0", ">=3.4"))) {
|
|
||||||
core.warning("CodeQL Action v1 will be deprecated on December 7th, 2022. Please upgrade to v2. For " +
|
|
||||||
"more information, see " +
|
|
||||||
"https://github.blog/changelog/2022-04-27-code-scanning-deprecation-of-codeql-action-v1/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.checkActionVersion = checkActionVersion;
|
|
||||||
/*
|
|
||||||
* Returns whether we are in test mode.
|
|
||||||
*
|
|
||||||
* In test mode, we don't upload SARIF results or status reports to the GitHub API.
|
|
||||||
*/
|
|
||||||
function isInTestMode() {
|
|
||||||
return process.env["TEST_MODE"] === "true" || false;
|
|
||||||
}
|
|
||||||
exports.isInTestMode = isInTestMode;
|
|
||||||
//# sourceMappingURL=util.js.map
|
//# sourceMappingURL=util.js.map
|
||||||
File diff suppressed because one or more lines are too long
73
lib/util.test.js
generated
73
lib/util.test.js
generated
@@ -25,7 +25,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const stream = __importStar(require("stream"));
|
const stream = __importStar(require("stream"));
|
||||||
const core = __importStar(require("@actions/core"));
|
|
||||||
const github = __importStar(require("@actions/github"));
|
const github = __importStar(require("@actions/github"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
@@ -209,28 +208,40 @@ const ML_POWERED_JS_STATUS_TESTS = [
|
|||||||
// If no packs are loaded, status is false.
|
// If no packs are loaded, status is false.
|
||||||
[[], "false"],
|
[[], "false"],
|
||||||
// If another pack is loaded but not the ML-powered query pack, status is false.
|
// If another pack is loaded but not the ML-powered query pack, status is false.
|
||||||
[["someOtherPack"], "false"],
|
[[{ packName: "someOtherPack" }], "false"],
|
||||||
// If the ML-powered query pack is loaded with a specific version, status is that version.
|
// If the ML-powered query pack is loaded with a specific version, status is that version.
|
||||||
[[`${util.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.1.0`], "~0.1.0"],
|
[
|
||||||
|
[{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME, version: "~0.1.0" }],
|
||||||
|
"~0.1.0",
|
||||||
|
],
|
||||||
// If the ML-powered query pack is loaded with a specific version and another pack is loaded, the
|
// If the ML-powered query pack is loaded with a specific version and another pack is loaded, the
|
||||||
// status is the version of the ML-powered query pack.
|
// status is the version of the ML-powered query pack.
|
||||||
[
|
[
|
||||||
["someOtherPack", `${util.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.1.0`],
|
[
|
||||||
|
{ packName: "someOtherPack" },
|
||||||
|
{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME, version: "~0.1.0" },
|
||||||
|
],
|
||||||
"~0.1.0",
|
"~0.1.0",
|
||||||
],
|
],
|
||||||
// If the ML-powered query pack is loaded without a version, the status is "latest".
|
// If the ML-powered query pack is loaded without a version, the status is "latest".
|
||||||
[[util.ML_POWERED_JS_QUERIES_PACK_NAME], "latest"],
|
[[{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME }], "latest"],
|
||||||
// If the ML-powered query pack is loaded with two different versions, the status is "other".
|
// If the ML-powered query pack is loaded with two different versions, the status is "other".
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
`${util.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.0.1`,
|
{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME, version: "0.0.1" },
|
||||||
`${util.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.0.2`,
|
{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME, version: "0.0.2" },
|
||||||
],
|
],
|
||||||
"other",
|
"other",
|
||||||
],
|
],
|
||||||
// If the ML-powered query pack is loaded with no specific version, and another pack is loaded,
|
// If the ML-powered query pack is loaded with no specific version, and another pack is loaded,
|
||||||
// the status is "latest".
|
// the status is "latest".
|
||||||
[["someOtherPack", util.ML_POWERED_JS_QUERIES_PACK_NAME], "latest"],
|
[
|
||||||
|
[
|
||||||
|
{ packName: "someOtherPack" },
|
||||||
|
{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME },
|
||||||
|
],
|
||||||
|
"latest",
|
||||||
|
],
|
||||||
];
|
];
|
||||||
for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
||||||
const packDescriptions = `[${packs
|
const packDescriptions = `[${packs
|
||||||
@@ -270,50 +281,4 @@ for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
|||||||
t.falsy(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.2.0" }, "3.2.0"));
|
t.falsy(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.2.0" }, "3.2.0"));
|
||||||
t.true(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.1.2" }, "3.2.0"));
|
t.true(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.1.2" }, "3.2.0"));
|
||||||
});
|
});
|
||||||
function formatGitHubVersion(version) {
|
|
||||||
switch (version.type) {
|
|
||||||
case util.GitHubVariant.DOTCOM:
|
|
||||||
return "dotcom";
|
|
||||||
case util.GitHubVariant.GHAE:
|
|
||||||
return "GHAE";
|
|
||||||
case util.GitHubVariant.GHES:
|
|
||||||
return `GHES ${version.version}`;
|
|
||||||
default:
|
|
||||||
util.assertNever(version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const CHECK_ACTION_VERSION_TESTS = [
|
|
||||||
["1.2.1", { type: util.GitHubVariant.DOTCOM }, true],
|
|
||||||
["1.2.1", { type: util.GitHubVariant.GHAE }, true],
|
|
||||||
["1.2.1", { type: util.GitHubVariant.GHES, version: "3.3" }, false],
|
|
||||||
["1.2.1", { type: util.GitHubVariant.GHES, version: "3.4" }, true],
|
|
||||||
["1.2.1", { type: util.GitHubVariant.GHES, version: "3.5" }, true],
|
|
||||||
["2.2.1", { type: util.GitHubVariant.DOTCOM }, false],
|
|
||||||
["2.2.1", { type: util.GitHubVariant.GHAE }, false],
|
|
||||||
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.3" }, false],
|
|
||||||
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.4" }, false],
|
|
||||||
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.5" }, false],
|
|
||||||
];
|
|
||||||
for (const [version, githubVersion, shouldReportWarning,] of CHECK_ACTION_VERSION_TESTS) {
|
|
||||||
const reportWarningDescription = shouldReportWarning
|
|
||||||
? "reports warning"
|
|
||||||
: "doesn't report warning";
|
|
||||||
const versionsDescription = `CodeQL Action version ${version} and GitHub version ${formatGitHubVersion(githubVersion)}`;
|
|
||||||
(0, ava_1.default)(`checkActionVersion ${reportWarningDescription} for ${versionsDescription}`, async (t) => {
|
|
||||||
const warningSpy = sinon.spy(core, "warning");
|
|
||||||
const versionStub = sinon
|
|
||||||
.stub(api, "getGitHubVersionActionsOnly")
|
|
||||||
.resolves(githubVersion);
|
|
||||||
const isActionsStub = sinon.stub(util, "isActions").returns(true);
|
|
||||||
await util.checkActionVersion(version);
|
|
||||||
if (shouldReportWarning) {
|
|
||||||
t.true(warningSpy.calledOnceWithExactly(sinon.match("CodeQL Action v1 will be deprecated")));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
t.false(warningSpy.called);
|
|
||||||
}
|
|
||||||
versionStub.restore();
|
|
||||||
isActionsStub.restore();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=util.test.js.map
|
//# sourceMappingURL=util.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
74
node_modules/.package-lock.json
generated
vendored
74
node_modules/.package-lock.json
generated
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.10",
|
"version": "1.1.8",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
@@ -481,9 +481,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "16.11.22",
|
"version": "12.12.70",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.22.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.70.tgz",
|
||||||
"integrity": "sha512-DYNtJWauMQ9RNpesl4aVothr97/tIJM8HbyOXJ0AYT1Z2bEjLHyfjOBPAQQVMLf8h3kSShYfNk8Wnto8B2zHUA=="
|
"integrity": "sha512-i5y7HTbvhonZQE+GnUM2rz1Bi8QkzxdQmEv1LKOv4nWyaQk/gdeiTApuQR3PDJHX7WomAbpx2wlWSEpxXGZ/UQ=="
|
||||||
},
|
},
|
||||||
"node_modules/@types/semver": {
|
"node_modules/@types/semver": {
|
||||||
"version": "7.3.8",
|
"version": "7.3.8",
|
||||||
@@ -2811,25 +2811,6 @@
|
|||||||
"version": "2.20.3",
|
"version": "2.20.3",
|
||||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="
|
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="
|
||||||
},
|
},
|
||||||
"node_modules/github-linguist/node_modules/glob": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
|
||||||
"dependencies": {
|
|
||||||
"fs.realpath": "^1.0.0",
|
|
||||||
"inflight": "^1.0.4",
|
|
||||||
"inherits": "2",
|
|
||||||
"minimatch": "^3.0.4",
|
|
||||||
"once": "^1.3.0",
|
|
||||||
"path-is-absolute": "^1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "*"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/github-linguist/node_modules/globby": {
|
"node_modules/github-linguist/node_modules/globby": {
|
||||||
"version": "6.1.0",
|
"version": "6.1.0",
|
||||||
"integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=",
|
"integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=",
|
||||||
@@ -2852,19 +2833,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/glob": {
|
"node_modules/glob": {
|
||||||
"version": "8.0.1",
|
"version": "7.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-8.0.1.tgz",
|
"integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==",
|
||||||
"integrity": "sha512-cF7FYZZ47YzmCu7dDy50xSRRfO3ErRfrXuLZcNIuyiJEco0XSrGtuilG19L5xp3NcwTx7Gn+X6Tv3fmsUPTbow==",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs.realpath": "^1.0.0",
|
"fs.realpath": "^1.0.0",
|
||||||
"inflight": "^1.0.4",
|
"inflight": "^1.0.4",
|
||||||
"inherits": "2",
|
"inherits": "2",
|
||||||
"minimatch": "^5.0.1",
|
"minimatch": "^3.0.4",
|
||||||
"once": "^1.3.0",
|
"once": "^1.3.0",
|
||||||
"path-is-absolute": "^1.0.0"
|
"path-is-absolute": "^1.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": "*"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
@@ -2881,25 +2861,6 @@
|
|||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/glob/node_modules/brace-expansion": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
|
||||||
"dependencies": {
|
|
||||||
"balanced-match": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/glob/node_modules/minimatch": {
|
|
||||||
"version": "5.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz",
|
|
||||||
"integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==",
|
|
||||||
"dependencies": {
|
|
||||||
"brace-expansion": "^2.0.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/globals": {
|
"node_modules/globals": {
|
||||||
"version": "13.10.0",
|
"version": "13.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/globals/-/globals-13.10.0.tgz",
|
||||||
@@ -4507,25 +4468,6 @@
|
|||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/rimraf/node_modules/glob": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
|
||||||
"dependencies": {
|
|
||||||
"fs.realpath": "^1.0.0",
|
|
||||||
"inflight": "^1.0.4",
|
|
||||||
"inherits": "2",
|
|
||||||
"minimatch": "^3.0.4",
|
|
||||||
"once": "^1.3.0",
|
|
||||||
"path-is-absolute": "^1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "*"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/run-parallel": {
|
"node_modules/run-parallel": {
|
||||||
"version": "1.1.9",
|
"version": "1.1.9",
|
||||||
"integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q=="
|
"integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q=="
|
||||||
|
|||||||
0
node_modules/@types/node/LICENSE
generated
vendored
Executable file → Normal file
0
node_modules/@types/node/LICENSE
generated
vendored
Executable file → Normal file
10
node_modules/@types/node/README.md
generated
vendored
Executable file → Normal file
10
node_modules/@types/node/README.md
generated
vendored
Executable file → Normal file
@@ -2,15 +2,15 @@
|
|||||||
> `npm install --save @types/node`
|
> `npm install --save @types/node`
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
This package contains type definitions for Node.js (https://nodejs.org/).
|
This package contains type definitions for Node.js (http://nodejs.org/).
|
||||||
|
|
||||||
# Details
|
# Details
|
||||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v16.
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v12.
|
||||||
|
|
||||||
### Additional Details
|
### Additional Details
|
||||||
* Last updated: Tue, 01 Feb 2022 08:31:30 GMT
|
* Last updated: Wed, 21 Oct 2020 17:47:46 GMT
|
||||||
* Dependencies: none
|
* Dependencies: none
|
||||||
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`
|
* Global values: `Buffer`, `NodeJS`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
|
||||||
|
|
||||||
# Credits
|
# Credits
|
||||||
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Seth Westphal](https://github.com/westy92), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), and [wafuwafu13](https://github.com/wafuwafu13).
|
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alexander T.](https://github.com/a-tarasyuk), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Bruno Scheufler](https://github.com/brunoscheufler), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Flarna](https://github.com/Flarna), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Hoàng Văn Khải](https://github.com/KSXGitHub), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Zane Hannan AU](https://github.com/ZaneHannanAU), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Jordi Oliveras Rovira](https://github.com/j-oliveras), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Minh Son Nguyen](https://github.com/nguymin4), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), and [Jason Kwok](https://github.com/JasonHK).
|
||||||
|
|||||||
963
node_modules/@types/node/assert.d.ts
generated
vendored
Executable file → Normal file
963
node_modules/@types/node/assert.d.ts
generated
vendored
Executable file → Normal file
@@ -1,912 +1,91 @@
|
|||||||
/**
|
|
||||||
* The `assert` module provides a set of assertion functions for verifying
|
|
||||||
* invariants.
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/assert.js)
|
|
||||||
*/
|
|
||||||
declare module 'assert' {
|
declare module 'assert' {
|
||||||
/**
|
function assert(value: any, message?: string | Error): asserts value;
|
||||||
* An alias of {@link ok}.
|
|
||||||
* @since v0.5.9
|
|
||||||
* @param value The input that is checked for being truthy.
|
|
||||||
*/
|
|
||||||
function assert(value: unknown, message?: string | Error): asserts value;
|
|
||||||
namespace assert {
|
namespace assert {
|
||||||
/**
|
class AssertionError implements Error {
|
||||||
* Indicates the failure of an assertion. All errors thrown by the `assert` module
|
name: string;
|
||||||
* will be instances of the `AssertionError` class.
|
message: string;
|
||||||
*/
|
actual: any;
|
||||||
class AssertionError extends Error {
|
expected: any;
|
||||||
actual: unknown;
|
|
||||||
expected: unknown;
|
|
||||||
operator: string;
|
operator: string;
|
||||||
generatedMessage: boolean;
|
generatedMessage: boolean;
|
||||||
code: 'ERR_ASSERTION';
|
code: 'ERR_ASSERTION';
|
||||||
|
|
||||||
constructor(options?: {
|
constructor(options?: {
|
||||||
/** If provided, the error message is set to this value. */
|
message?: string;
|
||||||
message?: string | undefined;
|
actual?: any;
|
||||||
/** The `actual` property on the error instance. */
|
expected?: any;
|
||||||
actual?: unknown | undefined;
|
operator?: string;
|
||||||
/** The `expected` property on the error instance. */
|
stackStartFn?: Function;
|
||||||
expected?: unknown | undefined;
|
|
||||||
/** The `operator` property on the error instance. */
|
|
||||||
operator?: string | undefined;
|
|
||||||
/** If provided, the generated stack trace omits frames before this function. */
|
|
||||||
// tslint:disable-next-line:ban-types
|
|
||||||
stackStartFn?: Function | undefined;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* This feature is currently experimental and behavior might still change.
|
|
||||||
* @since v14.2.0, v12.19.0
|
|
||||||
* @experimental
|
|
||||||
*/
|
|
||||||
class CallTracker {
|
|
||||||
/**
|
|
||||||
* The wrapper function is expected to be called exactly `exact` times. If the
|
|
||||||
* function has not been called exactly `exact` times when `tracker.verify()` is called, then `tracker.verify()` will throw an
|
|
||||||
* error.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert';
|
|
||||||
*
|
|
||||||
* // Creates call tracker.
|
|
||||||
* const tracker = new assert.CallTracker();
|
|
||||||
*
|
|
||||||
* function func() {}
|
|
||||||
*
|
|
||||||
* // Returns a function that wraps func() that must be called exact times
|
|
||||||
* // before tracker.verify().
|
|
||||||
* const callsfunc = tracker.calls(func);
|
|
||||||
* ```
|
|
||||||
* @since v14.2.0, v12.19.0
|
|
||||||
* @param [fn='A no-op function']
|
|
||||||
* @param [exact=1]
|
|
||||||
* @return that wraps `fn`.
|
|
||||||
*/
|
|
||||||
calls(exact?: number): () => void;
|
|
||||||
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
|
|
||||||
/**
|
|
||||||
* The arrays contains information about the expected and actual number of calls of
|
|
||||||
* the functions that have not been called the expected number of times.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert';
|
|
||||||
*
|
|
||||||
* // Creates call tracker.
|
|
||||||
* const tracker = new assert.CallTracker();
|
|
||||||
*
|
|
||||||
* function func() {}
|
|
||||||
*
|
|
||||||
* function foo() {}
|
|
||||||
*
|
|
||||||
* // Returns a function that wraps func() that must be called exact times
|
|
||||||
* // before tracker.verify().
|
|
||||||
* const callsfunc = tracker.calls(func, 2);
|
|
||||||
*
|
|
||||||
* // Returns an array containing information on callsfunc()
|
|
||||||
* tracker.report();
|
|
||||||
* // [
|
|
||||||
* // {
|
|
||||||
* // message: 'Expected the func function to be executed 2 time(s) but was
|
|
||||||
* // executed 0 time(s).',
|
|
||||||
* // actual: 0,
|
|
||||||
* // expected: 2,
|
|
||||||
* // operator: 'func',
|
|
||||||
* // stack: stack trace
|
|
||||||
* // }
|
|
||||||
* // ]
|
|
||||||
* ```
|
|
||||||
* @since v14.2.0, v12.19.0
|
|
||||||
* @return of objects containing information about the wrapper functions returned by `calls`.
|
|
||||||
*/
|
|
||||||
report(): CallTrackerReportInformation[];
|
|
||||||
/**
|
|
||||||
* Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that
|
|
||||||
* have not been called the expected number of times.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert';
|
|
||||||
*
|
|
||||||
* // Creates call tracker.
|
|
||||||
* const tracker = new assert.CallTracker();
|
|
||||||
*
|
|
||||||
* function func() {}
|
|
||||||
*
|
|
||||||
* // Returns a function that wraps func() that must be called exact times
|
|
||||||
* // before tracker.verify().
|
|
||||||
* const callsfunc = tracker.calls(func, 2);
|
|
||||||
*
|
|
||||||
* callsfunc();
|
|
||||||
*
|
|
||||||
* // Will throw an error since callsfunc() was only called once.
|
|
||||||
* tracker.verify();
|
|
||||||
* ```
|
|
||||||
* @since v14.2.0, v12.19.0
|
|
||||||
*/
|
|
||||||
verify(): void;
|
|
||||||
}
|
|
||||||
interface CallTrackerReportInformation {
|
|
||||||
message: string;
|
|
||||||
/** The actual number of times the function was called. */
|
|
||||||
actual: number;
|
|
||||||
/** The number of times the function was expected to be called. */
|
|
||||||
expected: number;
|
|
||||||
/** The name of the function that is wrapped. */
|
|
||||||
operator: string;
|
|
||||||
/** A stack trace of the function. */
|
|
||||||
stack: object;
|
|
||||||
}
|
|
||||||
type AssertPredicate = RegExp | (new () => object) | ((thrown: unknown) => boolean) | object | Error;
|
|
||||||
/**
|
|
||||||
* Throws an `AssertionError` with the provided error message or a default
|
|
||||||
* error message. If the `message` parameter is an instance of an `Error` then
|
|
||||||
* it will be thrown instead of the `AssertionError`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.fail();
|
|
||||||
* // AssertionError [ERR_ASSERTION]: Failed
|
|
||||||
*
|
|
||||||
* assert.fail('boom');
|
|
||||||
* // AssertionError [ERR_ASSERTION]: boom
|
|
||||||
*
|
|
||||||
* assert.fail(new TypeError('need array'));
|
|
||||||
* // TypeError: need array
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Using `assert.fail()` with more than two arguments is possible but deprecated.
|
|
||||||
* See below for further details.
|
|
||||||
* @since v0.1.21
|
|
||||||
* @param [message='Failed']
|
|
||||||
*/
|
|
||||||
function fail(message?: string | Error): never;
|
function fail(message?: string | Error): never;
|
||||||
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
||||||
function fail(
|
function fail(
|
||||||
actual: unknown,
|
actual: any,
|
||||||
expected: unknown,
|
expected: any,
|
||||||
message?: string | Error,
|
message?: string | Error,
|
||||||
operator?: string,
|
operator?: string,
|
||||||
// tslint:disable-next-line:ban-types
|
stackStartFn?: Function,
|
||||||
stackStartFn?: Function
|
|
||||||
): never;
|
): never;
|
||||||
/**
|
function ok(value: any, message?: string | Error): asserts value;
|
||||||
* Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`.
|
/** @deprecated since v9.9.0 - use strictEqual() instead. */
|
||||||
*
|
function equal(actual: any, expected: any, message?: string | Error): void;
|
||||||
* If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default
|
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
|
||||||
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
function notEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
* If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
|
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
|
||||||
*
|
function deepEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
* Be aware that in the `repl` the error message will be different to the one
|
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
|
||||||
* thrown in a file! See below for further details.
|
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
*
|
function strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
||||||
* ```js
|
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
* import assert from 'assert/strict';
|
function deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
||||||
*
|
function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
* assert.ok(true);
|
|
||||||
* // OK
|
function throws(block: () => any, message?: string | Error): void;
|
||||||
* assert.ok(1);
|
function throws(block: () => any, error: RegExp | Function | Object | Error, message?: string | Error): void;
|
||||||
* // OK
|
function doesNotThrow(block: () => any, message?: string | Error): void;
|
||||||
*
|
function doesNotThrow(block: () => any, error: RegExp | Function, message?: string | Error): void;
|
||||||
* assert.ok();
|
|
||||||
* // AssertionError: No value argument passed to `assert.ok()`
|
function ifError(value: any): asserts value is null | undefined;
|
||||||
*
|
|
||||||
* assert.ok(false, 'it\'s false');
|
function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
||||||
* // AssertionError: it's false
|
function rejects(
|
||||||
*
|
block: (() => Promise<any>) | Promise<any>,
|
||||||
* // In the repl:
|
error: RegExp | Function | Object | Error,
|
||||||
* assert.ok(typeof 123 === 'string');
|
message?: string | Error,
|
||||||
* // AssertionError: false == true
|
): Promise<void>;
|
||||||
*
|
function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
||||||
* // In a file (e.g. test.js):
|
function doesNotReject(
|
||||||
* assert.ok(typeof 123 === 'string');
|
block: (() => Promise<any>) | Promise<any>,
|
||||||
* // AssertionError: The expression evaluated to a falsy value:
|
error: RegExp | Function,
|
||||||
* //
|
message?: string | Error,
|
||||||
* // assert.ok(typeof 123 === 'string')
|
): Promise<void>;
|
||||||
*
|
|
||||||
* assert.ok(false);
|
const strict: Omit<
|
||||||
* // AssertionError: The expression evaluated to a falsy value:
|
typeof assert,
|
||||||
* //
|
| 'strict'
|
||||||
* // assert.ok(false)
|
| 'deepEqual'
|
||||||
*
|
| 'notDeepEqual'
|
||||||
* assert.ok(0);
|
| 'equal'
|
||||||
* // AssertionError: The expression evaluated to a falsy value:
|
| 'notEqual'
|
||||||
* //
|
| 'ok'
|
||||||
* // assert.ok(0)
|
| 'strictEqual'
|
||||||
* ```
|
| 'deepStrictEqual'
|
||||||
*
|
| 'ifError'
|
||||||
* ```js
|
> & {
|
||||||
* import assert from 'assert/strict';
|
(value: any, message?: string | Error): asserts value;
|
||||||
*
|
strict: typeof strict;
|
||||||
* // Using `assert()` works the same:
|
|
||||||
* assert(0);
|
|
||||||
* // AssertionError: The expression evaluated to a falsy value:
|
|
||||||
* //
|
|
||||||
* // assert(0)
|
|
||||||
* ```
|
|
||||||
* @since v0.1.21
|
|
||||||
*/
|
|
||||||
function ok(value: unknown, message?: string | Error): asserts value;
|
|
||||||
/**
|
|
||||||
* **Strict assertion mode**
|
|
||||||
*
|
|
||||||
* An alias of {@link strictEqual}.
|
|
||||||
*
|
|
||||||
* **Legacy assertion mode**
|
|
||||||
*
|
|
||||||
* > Stability: 3 - Legacy: Use {@link strictEqual} instead.
|
|
||||||
*
|
|
||||||
* Tests shallow, coercive equality between the `actual` and `expected` parameters
|
|
||||||
* using the [Abstract Equality Comparison](https://tc39.github.io/ecma262/#sec-abstract-equality-comparison) ( `==` ). `NaN` is special handled
|
|
||||||
* and treated as being identical in case both sides are `NaN`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert';
|
|
||||||
*
|
|
||||||
* assert.equal(1, 1);
|
|
||||||
* // OK, 1 == 1
|
|
||||||
* assert.equal(1, '1');
|
|
||||||
* // OK, 1 == '1'
|
|
||||||
* assert.equal(NaN, NaN);
|
|
||||||
* // OK
|
|
||||||
*
|
|
||||||
* assert.equal(1, 2);
|
|
||||||
* // AssertionError: 1 == 2
|
|
||||||
* assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
|
|
||||||
* // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default
|
|
||||||
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
|
||||||
* @since v0.1.21
|
|
||||||
*/
|
|
||||||
function equal(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
/**
|
|
||||||
* **Strict assertion mode**
|
|
||||||
*
|
|
||||||
* An alias of {@link notStrictEqual}.
|
|
||||||
*
|
|
||||||
* **Legacy assertion mode**
|
|
||||||
*
|
|
||||||
* > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
|
|
||||||
*
|
|
||||||
* Tests shallow, coercive inequality with the [Abstract Equality Comparison](https://tc39.github.io/ecma262/#sec-abstract-equality-comparison)(`!=` ). `NaN` is special handled and treated as
|
|
||||||
* being identical in case both
|
|
||||||
* sides are `NaN`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert';
|
|
||||||
*
|
|
||||||
* assert.notEqual(1, 2);
|
|
||||||
* // OK
|
|
||||||
*
|
|
||||||
* assert.notEqual(1, 1);
|
|
||||||
* // AssertionError: 1 != 1
|
|
||||||
*
|
|
||||||
* assert.notEqual(1, '1');
|
|
||||||
* // AssertionError: 1 != '1'
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error
|
|
||||||
* message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
|
||||||
* @since v0.1.21
|
|
||||||
*/
|
|
||||||
function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
/**
|
|
||||||
* **Strict assertion mode**
|
|
||||||
*
|
|
||||||
* An alias of {@link deepStrictEqual}.
|
|
||||||
*
|
|
||||||
* **Legacy assertion mode**
|
|
||||||
*
|
|
||||||
* > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead.
|
|
||||||
*
|
|
||||||
* Tests for deep equality between the `actual` and `expected` parameters. Consider
|
|
||||||
* using {@link deepStrictEqual} instead. {@link deepEqual} can have
|
|
||||||
* surprising results.
|
|
||||||
*
|
|
||||||
* _Deep equality_ means that the enumerable "own" properties of child objects
|
|
||||||
* are also recursively evaluated by the following rules.
|
|
||||||
* @since v0.1.21
|
|
||||||
*/
|
|
||||||
function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
/**
|
|
||||||
* **Strict assertion mode**
|
|
||||||
*
|
|
||||||
* An alias of {@link notDeepStrictEqual}.
|
|
||||||
*
|
|
||||||
* **Legacy assertion mode**
|
|
||||||
*
|
|
||||||
* > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead.
|
|
||||||
*
|
|
||||||
* Tests for any deep inequality. Opposite of {@link deepEqual}.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert';
|
|
||||||
*
|
|
||||||
* const obj1 = {
|
|
||||||
* a: {
|
|
||||||
* b: 1
|
|
||||||
* }
|
|
||||||
* };
|
|
||||||
* const obj2 = {
|
|
||||||
* a: {
|
|
||||||
* b: 2
|
|
||||||
* }
|
|
||||||
* };
|
|
||||||
* const obj3 = {
|
|
||||||
* a: {
|
|
||||||
* b: 1
|
|
||||||
* }
|
|
||||||
* };
|
|
||||||
* const obj4 = Object.create(obj1);
|
|
||||||
*
|
|
||||||
* assert.notDeepEqual(obj1, obj1);
|
|
||||||
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
|
||||||
*
|
|
||||||
* assert.notDeepEqual(obj1, obj2);
|
|
||||||
* // OK
|
|
||||||
*
|
|
||||||
* assert.notDeepEqual(obj1, obj3);
|
|
||||||
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
|
||||||
*
|
|
||||||
* assert.notDeepEqual(obj1, obj4);
|
|
||||||
* // OK
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default
|
|
||||||
* error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
|
||||||
* instead of the `AssertionError`.
|
|
||||||
* @since v0.1.21
|
|
||||||
*/
|
|
||||||
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
/**
|
|
||||||
* Tests strict equality between the `actual` and `expected` parameters as
|
|
||||||
* determined by the [SameValue Comparison](https://tc39.github.io/ecma262/#sec-samevalue).
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.strictEqual(1, 2);
|
|
||||||
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
|
||||||
* //
|
|
||||||
* // 1 !== 2
|
|
||||||
*
|
|
||||||
* assert.strictEqual(1, 1);
|
|
||||||
* // OK
|
|
||||||
*
|
|
||||||
* assert.strictEqual('Hello foobar', 'Hello World!');
|
|
||||||
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
|
||||||
* // + actual - expected
|
|
||||||
* //
|
|
||||||
* // + 'Hello foobar'
|
|
||||||
* // - 'Hello World!'
|
|
||||||
* // ^
|
|
||||||
*
|
|
||||||
* const apples = 1;
|
|
||||||
* const oranges = 2;
|
|
||||||
* assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
|
|
||||||
* // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
|
|
||||||
*
|
|
||||||
* assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
|
|
||||||
* // TypeError: Inputs are not identical
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
|
||||||
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
|
||||||
* instead of the `AssertionError`.
|
|
||||||
* @since v0.1.21
|
|
||||||
*/
|
|
||||||
function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
|
||||||
/**
|
|
||||||
* Tests strict inequality between the `actual` and `expected` parameters as
|
|
||||||
* determined by the [SameValue Comparison](https://tc39.github.io/ecma262/#sec-samevalue).
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.notStrictEqual(1, 2);
|
|
||||||
* // OK
|
|
||||||
*
|
|
||||||
* assert.notStrictEqual(1, 1);
|
|
||||||
* // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to:
|
|
||||||
* //
|
|
||||||
* // 1
|
|
||||||
*
|
|
||||||
* assert.notStrictEqual(1, '1');
|
|
||||||
* // OK
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
|
||||||
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
|
||||||
* instead of the `AssertionError`.
|
|
||||||
* @since v0.1.21
|
|
||||||
*/
|
|
||||||
function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
/**
|
|
||||||
* Tests for deep equality between the `actual` and `expected` parameters.
|
|
||||||
* "Deep" equality means that the enumerable "own" properties of child objects
|
|
||||||
* are recursively evaluated also by the following rules.
|
|
||||||
* @since v1.2.0
|
|
||||||
*/
|
|
||||||
function deepStrictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
|
||||||
/**
|
|
||||||
* Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
|
|
||||||
* // OK
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If the values are deeply and strictly equal, an `AssertionError` is thrown
|
|
||||||
* with a `message` property set equal to the value of the `message` parameter. If
|
|
||||||
* the `message` parameter is undefined, a default error message is assigned. If
|
|
||||||
* the `message` parameter is an instance of an `Error` then it will be thrown
|
|
||||||
* instead of the `AssertionError`.
|
|
||||||
* @since v1.2.0
|
|
||||||
*/
|
|
||||||
function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
/**
|
|
||||||
* Expects the function `fn` to throw an error.
|
|
||||||
*
|
|
||||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
|
||||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
|
||||||
* a validation object where each property will be tested for strict deep equality,
|
|
||||||
* or an instance of error where each property will be tested for strict deep
|
|
||||||
* equality including the non-enumerable `message` and `name` properties. When
|
|
||||||
* using an object, it is also possible to use a regular expression, when
|
|
||||||
* validating against a string property. See below for examples.
|
|
||||||
*
|
|
||||||
* If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation
|
|
||||||
* fails.
|
|
||||||
*
|
|
||||||
* Custom validation object/error instance:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* const err = new TypeError('Wrong value');
|
|
||||||
* err.code = 404;
|
|
||||||
* err.foo = 'bar';
|
|
||||||
* err.info = {
|
|
||||||
* nested: true,
|
|
||||||
* baz: 'text'
|
|
||||||
* };
|
|
||||||
* err.reg = /abc/i;
|
|
||||||
*
|
|
||||||
* assert.throws(
|
|
||||||
* () => {
|
|
||||||
* throw err;
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* name: 'TypeError',
|
|
||||||
* message: 'Wrong value',
|
|
||||||
* info: {
|
|
||||||
* nested: true,
|
|
||||||
* baz: 'text'
|
|
||||||
* }
|
|
||||||
* // Only properties on the validation object will be tested for.
|
|
||||||
* // Using nested objects requires all properties to be present. Otherwise
|
|
||||||
* // the validation is going to fail.
|
|
||||||
* }
|
|
||||||
* );
|
|
||||||
*
|
|
||||||
* // Using regular expressions to validate error properties:
|
|
||||||
* throws(
|
|
||||||
* () => {
|
|
||||||
* throw err;
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* // The `name` and `message` properties are strings and using regular
|
|
||||||
* // expressions on those will match against the string. If they fail, an
|
|
||||||
* // error is thrown.
|
|
||||||
* name: /^TypeError$/,
|
|
||||||
* message: /Wrong/,
|
|
||||||
* foo: 'bar',
|
|
||||||
* info: {
|
|
||||||
* nested: true,
|
|
||||||
* // It is not possible to use regular expressions for nested properties!
|
|
||||||
* baz: 'text'
|
|
||||||
* },
|
|
||||||
* // The `reg` property contains a regular expression and only if the
|
|
||||||
* // validation object contains an identical regular expression, it is going
|
|
||||||
* // to pass.
|
|
||||||
* reg: /abc/i
|
|
||||||
* }
|
|
||||||
* );
|
|
||||||
*
|
|
||||||
* // Fails due to the different `message` and `name` properties:
|
|
||||||
* throws(
|
|
||||||
* () => {
|
|
||||||
* const otherErr = new Error('Not found');
|
|
||||||
* // Copy all enumerable properties from `err` to `otherErr`.
|
|
||||||
* for (const [key, value] of Object.entries(err)) {
|
|
||||||
* otherErr[key] = value;
|
|
||||||
* }
|
|
||||||
* throw otherErr;
|
|
||||||
* },
|
|
||||||
* // The error's `message` and `name` properties will also be checked when using
|
|
||||||
* // an error as validation object.
|
|
||||||
* err
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Validate instanceof using constructor:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.throws(
|
|
||||||
* () => {
|
|
||||||
* throw new Error('Wrong value');
|
|
||||||
* },
|
|
||||||
* Error
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions):
|
|
||||||
*
|
|
||||||
* Using a regular expression runs `.toString` on the error object, and will
|
|
||||||
* therefore also include the error name.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.throws(
|
|
||||||
* () => {
|
|
||||||
* throw new Error('Wrong value');
|
|
||||||
* },
|
|
||||||
* /^Error: Wrong value$/
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Custom error validation:
|
|
||||||
*
|
|
||||||
* The function must return `true` to indicate all internal validations passed.
|
|
||||||
* It will otherwise fail with an `AssertionError`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.throws(
|
|
||||||
* () => {
|
|
||||||
* throw new Error('Wrong value');
|
|
||||||
* },
|
|
||||||
* (err) => {
|
|
||||||
* assert(err instanceof Error);
|
|
||||||
* assert(/value/.test(err));
|
|
||||||
* // Avoid returning anything from validation functions besides `true`.
|
|
||||||
* // Otherwise, it's not clear what part of the validation failed. Instead,
|
|
||||||
* // throw an error about the specific validation that failed (as done in this
|
|
||||||
* // example) and add as much helpful debugging information to that error as
|
|
||||||
* // possible.
|
|
||||||
* return true;
|
|
||||||
* },
|
|
||||||
* 'unexpected error'
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* `error` cannot be a string. If a string is provided as the second
|
|
||||||
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same
|
|
||||||
* message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
|
|
||||||
* a string as the second argument gets considered:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* function throwingFirst() {
|
|
||||||
* throw new Error('First');
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* function throwingSecond() {
|
|
||||||
* throw new Error('Second');
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* function notThrowing() {}
|
|
||||||
*
|
|
||||||
* // The second argument is a string and the input function threw an Error.
|
|
||||||
* // The first case will not throw as it does not match for the error message
|
|
||||||
* // thrown by the input function!
|
|
||||||
* assert.throws(throwingFirst, 'Second');
|
|
||||||
* // In the next example the message has no benefit over the message from the
|
|
||||||
* // error and since it is not clear if the user intended to actually match
|
|
||||||
* // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
|
|
||||||
* assert.throws(throwingSecond, 'Second');
|
|
||||||
* // TypeError [ERR_AMBIGUOUS_ARGUMENT]
|
|
||||||
*
|
|
||||||
* // The string is only used (as message) in case the function does not throw:
|
|
||||||
* assert.throws(notThrowing, 'Second');
|
|
||||||
* // AssertionError [ERR_ASSERTION]: Missing expected exception: Second
|
|
||||||
*
|
|
||||||
* // If it was intended to match for the error message do this instead:
|
|
||||||
* // It does not throw because the error messages match.
|
|
||||||
* assert.throws(throwingSecond, /Second$/);
|
|
||||||
*
|
|
||||||
* // If the error message does not match, an AssertionError is thrown.
|
|
||||||
* assert.throws(throwingFirst, /Second$/);
|
|
||||||
* // AssertionError [ERR_ASSERTION]
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Due to the confusing error-prone notation, avoid a string as the second
|
|
||||||
* argument.
|
|
||||||
* @since v0.1.21
|
|
||||||
*/
|
|
||||||
function throws(block: () => unknown, message?: string | Error): void;
|
|
||||||
function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
|
||||||
/**
|
|
||||||
* Asserts that the function `fn` does not throw an error.
|
|
||||||
*
|
|
||||||
* Using `assert.doesNotThrow()` is actually not useful because there
|
|
||||||
* is no benefit in catching an error and then rethrowing it. Instead, consider
|
|
||||||
* adding a comment next to the specific code path that should not throw and keep
|
|
||||||
* error messages as expressive as possible.
|
|
||||||
*
|
|
||||||
* When `assert.doesNotThrow()` is called, it will immediately call the `fn`function.
|
|
||||||
*
|
|
||||||
* If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a
|
|
||||||
* different type, or if the `error` parameter is undefined, the error is
|
|
||||||
* propagated back to the caller.
|
|
||||||
*
|
|
||||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
|
||||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
|
|
||||||
* function. See {@link throws} for more details.
|
|
||||||
*
|
|
||||||
* The following, for instance, will throw the `TypeError` because there is no
|
|
||||||
* matching error type in the assertion:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.doesNotThrow(
|
|
||||||
* () => {
|
|
||||||
* throw new TypeError('Wrong value');
|
|
||||||
* },
|
|
||||||
* SyntaxError
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* However, the following will result in an `AssertionError` with the message
|
|
||||||
* 'Got unwanted exception...':
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.doesNotThrow(
|
|
||||||
* () => {
|
|
||||||
* throw new TypeError('Wrong value');
|
|
||||||
* },
|
|
||||||
* TypeError
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.doesNotThrow(
|
|
||||||
* () => {
|
|
||||||
* throw new TypeError('Wrong value');
|
|
||||||
* },
|
|
||||||
* /Wrong value/,
|
|
||||||
* 'Whoops'
|
|
||||||
* );
|
|
||||||
* // Throws: AssertionError: Got unwanted exception: Whoops
|
|
||||||
* ```
|
|
||||||
* @since v0.1.21
|
|
||||||
*/
|
|
||||||
function doesNotThrow(block: () => unknown, message?: string | Error): void;
|
|
||||||
function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
|
||||||
/**
|
|
||||||
* Throws `value` if `value` is not `undefined` or `null`. This is useful when
|
|
||||||
* testing the `error` argument in callbacks. The stack trace contains all frames
|
|
||||||
* from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.ifError(null);
|
|
||||||
* // OK
|
|
||||||
* assert.ifError(0);
|
|
||||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0
|
|
||||||
* assert.ifError('error');
|
|
||||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
|
|
||||||
* assert.ifError(new Error());
|
|
||||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error
|
|
||||||
*
|
|
||||||
* // Create some random error frames.
|
|
||||||
* let err;
|
|
||||||
* (function errorFrame() {
|
|
||||||
* err = new Error('test error');
|
|
||||||
* })();
|
|
||||||
*
|
|
||||||
* (function ifErrorFrame() {
|
|
||||||
* assert.ifError(err);
|
|
||||||
* })();
|
|
||||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
|
|
||||||
* // at ifErrorFrame
|
|
||||||
* // at errorFrame
|
|
||||||
* ```
|
|
||||||
* @since v0.1.97
|
|
||||||
*/
|
|
||||||
function ifError(value: unknown): asserts value is null | undefined;
|
|
||||||
/**
|
|
||||||
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
|
||||||
* calls the function and awaits the returned promise to complete. It will then
|
|
||||||
* check that the promise is rejected.
|
|
||||||
*
|
|
||||||
* If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the
|
|
||||||
* function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error
|
|
||||||
* handler is skipped.
|
|
||||||
*
|
|
||||||
* Besides the async nature to await the completion behaves identically to {@link throws}.
|
|
||||||
*
|
|
||||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
|
||||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
|
||||||
* an object where each property will be tested for, or an instance of error where
|
|
||||||
* each property will be tested for including the non-enumerable `message` and`name` properties.
|
|
||||||
*
|
|
||||||
* If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* await assert.rejects(
|
|
||||||
* async () => {
|
|
||||||
* throw new TypeError('Wrong value');
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* name: 'TypeError',
|
|
||||||
* message: 'Wrong value'
|
|
||||||
* }
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* await assert.rejects(
|
|
||||||
* async () => {
|
|
||||||
* throw new TypeError('Wrong value');
|
|
||||||
* },
|
|
||||||
* (err) => {
|
|
||||||
* assert.strictEqual(err.name, 'TypeError');
|
|
||||||
* assert.strictEqual(err.message, 'Wrong value');
|
|
||||||
* return true;
|
|
||||||
* }
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.rejects(
|
|
||||||
* Promise.reject(new Error('Wrong value')),
|
|
||||||
* Error
|
|
||||||
* ).then(() => {
|
|
||||||
* // ...
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* `error` cannot be a string. If a string is provided as the second
|
|
||||||
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the
|
|
||||||
* example in {@link throws} carefully if using a string as the second
|
|
||||||
* argument gets considered.
|
|
||||||
* @since v10.0.0
|
|
||||||
*/
|
|
||||||
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
|
||||||
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: string | Error): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
|
||||||
* calls the function and awaits the returned promise to complete. It will then
|
|
||||||
* check that the promise is not rejected.
|
|
||||||
*
|
|
||||||
* If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If
|
|
||||||
* the function does not return a promise, `assert.doesNotReject()` will return a
|
|
||||||
* rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases
|
|
||||||
* the error handler is skipped.
|
|
||||||
*
|
|
||||||
* Using `assert.doesNotReject()` is actually not useful because there is little
|
|
||||||
* benefit in catching a rejection and then rejecting it again. Instead, consider
|
|
||||||
* adding a comment next to the specific code path that should not reject and keep
|
|
||||||
* error messages as expressive as possible.
|
|
||||||
*
|
|
||||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
|
||||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
|
|
||||||
* function. See {@link throws} for more details.
|
|
||||||
*
|
|
||||||
* Besides the async nature to await the completion behaves identically to {@link doesNotThrow}.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* await assert.doesNotReject(
|
|
||||||
* async () => {
|
|
||||||
* throw new TypeError('Wrong value');
|
|
||||||
* },
|
|
||||||
* SyntaxError
|
|
||||||
* );
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
|
|
||||||
* .then(() => {
|
|
||||||
* // ...
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v10.0.0
|
|
||||||
*/
|
|
||||||
function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
|
||||||
function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: string | Error): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Expects the `string` input to match the regular expression.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.match('I will fail', /pass/);
|
|
||||||
* // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
|
|
||||||
*
|
|
||||||
* assert.match(123, /pass/);
|
|
||||||
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
|
||||||
*
|
|
||||||
* assert.match('I will pass', /pass/);
|
|
||||||
* // OK
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
|
||||||
* to the value of the `message` parameter. If the `message` parameter is
|
|
||||||
* undefined, a default error message is assigned. If the `message` parameter is an
|
|
||||||
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
|
||||||
* @since v13.6.0, v12.16.0
|
|
||||||
*/
|
|
||||||
function match(value: string, regExp: RegExp, message?: string | Error): void;
|
|
||||||
/**
|
|
||||||
* Expects the `string` input not to match the regular expression.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import assert from 'assert/strict';
|
|
||||||
*
|
|
||||||
* assert.doesNotMatch('I will fail', /fail/);
|
|
||||||
* // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
|
|
||||||
*
|
|
||||||
* assert.doesNotMatch(123, /pass/);
|
|
||||||
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
|
||||||
*
|
|
||||||
* assert.doesNotMatch('I will pass', /different/);
|
|
||||||
* // OK
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
|
||||||
* to the value of the `message` parameter. If the `message` parameter is
|
|
||||||
* undefined, a default error message is assigned. If the `message` parameter is an
|
|
||||||
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
|
||||||
* @since v13.6.0, v12.16.0
|
|
||||||
*/
|
|
||||||
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
|
||||||
const strict: Omit<typeof assert, 'equal' | 'notEqual' | 'deepEqual' | 'notDeepEqual' | 'ok' | 'strictEqual' | 'deepStrictEqual' | 'ifError' | 'strict'> & {
|
|
||||||
(value: unknown, message?: string | Error): asserts value;
|
|
||||||
equal: typeof strictEqual;
|
|
||||||
notEqual: typeof notStrictEqual;
|
|
||||||
deepEqual: typeof deepStrictEqual;
|
deepEqual: typeof deepStrictEqual;
|
||||||
notDeepEqual: typeof notDeepStrictEqual;
|
notDeepEqual: typeof notDeepStrictEqual;
|
||||||
// Mapped types and assertion functions are incompatible?
|
equal: typeof strictEqual;
|
||||||
// TS2775: Assertions require every name in the call target
|
notEqual: typeof notStrictEqual;
|
||||||
// to be declared with an explicit type annotation.
|
ok(value: any, message?: string | Error): asserts value;
|
||||||
ok: typeof ok;
|
strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
||||||
strictEqual: typeof strictEqual;
|
deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
||||||
deepStrictEqual: typeof deepStrictEqual;
|
ifError(value: any): asserts value is null | undefined;
|
||||||
ifError: typeof ifError;
|
|
||||||
strict: typeof strict;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
export = assert;
|
|
||||||
}
|
|
||||||
declare module 'node:assert' {
|
|
||||||
import assert = require('assert');
|
|
||||||
export = assert;
|
export = assert;
|
||||||
}
|
}
|
||||||
|
|||||||
8
node_modules/@types/node/assert/strict.d.ts
generated
vendored
8
node_modules/@types/node/assert/strict.d.ts
generated
vendored
@@ -1,8 +0,0 @@
|
|||||||
declare module 'assert/strict' {
|
|
||||||
import { strict } from 'node:assert';
|
|
||||||
export = strict;
|
|
||||||
}
|
|
||||||
declare module 'node:assert/strict' {
|
|
||||||
import { strict } from 'node:assert';
|
|
||||||
export = strict;
|
|
||||||
}
|
|
||||||
480
node_modules/@types/node/async_hooks.d.ts
generated
vendored
Executable file → Normal file
480
node_modules/@types/node/async_hooks.d.ts
generated
vendored
Executable file → Normal file
@@ -1,47 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* The `async_hooks` module provides an API to track asynchronous resources. It
|
* Async Hooks module: https://nodejs.org/api/async_hooks.html
|
||||||
* can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import async_hooks from 'async_hooks';
|
|
||||||
* ```
|
|
||||||
* @experimental
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/async_hooks.js)
|
|
||||||
*/
|
*/
|
||||||
declare module 'async_hooks' {
|
declare module "async_hooks" {
|
||||||
/**
|
/**
|
||||||
* ```js
|
* Returns the asyncId of the current execution context.
|
||||||
* import { executionAsyncId } from 'async_hooks';
|
|
||||||
*
|
|
||||||
* console.log(executionAsyncId()); // 1 - bootstrap
|
|
||||||
* fs.open(path, 'r', (err, fd) => {
|
|
||||||
* console.log(executionAsyncId()); // 6 - open()
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The ID returned from `executionAsyncId()` is related to execution timing, not
|
|
||||||
* causality (which is covered by `triggerAsyncId()`):
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const server = net.createServer((conn) => {
|
|
||||||
* // Returns the ID of the server, not of the new connection, because the
|
|
||||||
* // callback runs in the execution scope of the server's MakeCallback().
|
|
||||||
* async_hooks.executionAsyncId();
|
|
||||||
*
|
|
||||||
* }).listen(port, () => {
|
|
||||||
* // Returns the ID of a TickObject (process.nextTick()) because all
|
|
||||||
* // callbacks passed to .listen() are wrapped in a nextTick().
|
|
||||||
* async_hooks.executionAsyncId();
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Promise contexts may not get precise `executionAsyncIds` by default.
|
|
||||||
* See the section on `promise execution tracking`.
|
|
||||||
* @since v8.1.0
|
|
||||||
* @return The `asyncId` of the current execution context. Useful to track when something calls.
|
|
||||||
*/
|
*/
|
||||||
function executionAsyncId(): number;
|
function executionAsyncId(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The resource representing the current execution.
|
||||||
|
* Useful to store data within the resource.
|
||||||
|
*
|
||||||
* Resource objects returned by `executionAsyncResource()` are most often internal
|
* Resource objects returned by `executionAsyncResource()` are most often internal
|
||||||
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
||||||
* on the object is likely to crash your application and should be avoided.
|
* on the object is likely to crash your application and should be avoided.
|
||||||
@@ -49,70 +18,14 @@ declare module 'async_hooks' {
|
|||||||
* Using `executionAsyncResource()` in the top-level execution context will
|
* Using `executionAsyncResource()` in the top-level execution context will
|
||||||
* return an empty object as there is no handle or request object to use,
|
* return an empty object as there is no handle or request object to use,
|
||||||
* but having an object representing the top-level can be helpful.
|
* but having an object representing the top-level can be helpful.
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { open } from 'fs';
|
|
||||||
* import { executionAsyncId, executionAsyncResource } from 'async_hooks';
|
|
||||||
*
|
|
||||||
* console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
|
|
||||||
* open(new URL(import.meta.url), 'r', (err, fd) => {
|
|
||||||
* console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* This can be used to implement continuation local storage without the
|
|
||||||
* use of a tracking `Map` to store the metadata:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { createServer } from 'http';
|
|
||||||
* import {
|
|
||||||
* executionAsyncId,
|
|
||||||
* executionAsyncResource,
|
|
||||||
* createHook
|
|
||||||
* } from 'async_hooks';
|
|
||||||
* const sym = Symbol('state'); // Private symbol to avoid pollution
|
|
||||||
*
|
|
||||||
* createHook({
|
|
||||||
* init(asyncId, type, triggerAsyncId, resource) {
|
|
||||||
* const cr = executionAsyncResource();
|
|
||||||
* if (cr) {
|
|
||||||
* resource[sym] = cr[sym];
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }).enable();
|
|
||||||
*
|
|
||||||
* const server = createServer((req, res) => {
|
|
||||||
* executionAsyncResource()[sym] = { state: req.url };
|
|
||||||
* setTimeout(function() {
|
|
||||||
* res.end(JSON.stringify(executionAsyncResource()[sym]));
|
|
||||||
* }, 100);
|
|
||||||
* }).listen(3000);
|
|
||||||
* ```
|
|
||||||
* @since v13.9.0, v12.17.0
|
|
||||||
* @return The resource representing the current execution. Useful to store data within the resource.
|
|
||||||
*/
|
*/
|
||||||
function executionAsyncResource(): object;
|
function executionAsyncResource(): object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ```js
|
* Returns the ID of the resource responsible for calling the callback that is currently being executed.
|
||||||
* const server = net.createServer((conn) => {
|
|
||||||
* // The resource that caused (or triggered) this callback to be called
|
|
||||||
* // was that of the new connection. Thus the return value of triggerAsyncId()
|
|
||||||
* // is the asyncId of "conn".
|
|
||||||
* async_hooks.triggerAsyncId();
|
|
||||||
*
|
|
||||||
* }).listen(port, () => {
|
|
||||||
* // Even though all callbacks passed to .listen() are wrapped in a nextTick()
|
|
||||||
* // the callback itself exists because the call to the server's .listen()
|
|
||||||
* // was made. So the return value would be the ID of the server.
|
|
||||||
* async_hooks.triggerAsyncId();
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Promise contexts may not get valid `triggerAsyncId`s by default. See
|
|
||||||
* the section on `promise execution tracking`.
|
|
||||||
* @return The ID of the resource responsible for calling the callback that is currently being executed.
|
|
||||||
*/
|
*/
|
||||||
function triggerAsyncId(): number;
|
function triggerAsyncId(): number;
|
||||||
|
|
||||||
interface HookCallbacks {
|
interface HookCallbacks {
|
||||||
/**
|
/**
|
||||||
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
||||||
@@ -122,133 +35,73 @@ declare module 'async_hooks' {
|
|||||||
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
||||||
*/
|
*/
|
||||||
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
||||||
* The before callback is called just before said callback is executed.
|
* The before callback is called just before said callback is executed.
|
||||||
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
||||||
*/
|
*/
|
||||||
before?(asyncId: number): void;
|
before?(asyncId: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called immediately after the callback specified in before is completed.
|
* Called immediately after the callback specified in before is completed.
|
||||||
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
||||||
*/
|
*/
|
||||||
after?(asyncId: number): void;
|
after?(asyncId: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a promise has resolve() called. This may not be in the same execution id
|
* Called when a promise has resolve() called. This may not be in the same execution id
|
||||||
* as the promise itself.
|
* as the promise itself.
|
||||||
* @param asyncId the unique id for the promise that was resolve()d.
|
* @param asyncId the unique id for the promise that was resolve()d.
|
||||||
*/
|
*/
|
||||||
promiseResolve?(asyncId: number): void;
|
promiseResolve?(asyncId: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after the resource corresponding to asyncId is destroyed
|
* Called after the resource corresponding to asyncId is destroyed
|
||||||
* @param asyncId a unique ID for the async resource
|
* @param asyncId a unique ID for the async resource
|
||||||
*/
|
*/
|
||||||
destroy?(asyncId: number): void;
|
destroy?(asyncId: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AsyncHook {
|
interface AsyncHook {
|
||||||
/**
|
/**
|
||||||
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
||||||
*/
|
*/
|
||||||
enable(): this;
|
enable(): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
||||||
*/
|
*/
|
||||||
disable(): this;
|
disable(): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers functions to be called for different lifetime events of each async
|
* Registers functions to be called for different lifetime events of each async operation.
|
||||||
* operation.
|
* @param options the callbacks to register
|
||||||
*
|
* @return an AsyncHooks instance used for disabling and enabling hooks
|
||||||
* The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
|
|
||||||
* respective asynchronous event during a resource's lifetime.
|
|
||||||
*
|
|
||||||
* All callbacks are optional. For example, if only resource cleanup needs to
|
|
||||||
* be tracked, then only the `destroy` callback needs to be passed. The
|
|
||||||
* specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { createHook } from 'async_hooks';
|
|
||||||
*
|
|
||||||
* const asyncHook = createHook({
|
|
||||||
* init(asyncId, type, triggerAsyncId, resource) { },
|
|
||||||
* destroy(asyncId) { }
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The callbacks will be inherited via the prototype chain:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* class MyAsyncCallbacks {
|
|
||||||
* init(asyncId, type, triggerAsyncId, resource) { }
|
|
||||||
* destroy(asyncId) {}
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* class MyAddedCallbacks extends MyAsyncCallbacks {
|
|
||||||
* before(asyncId) { }
|
|
||||||
* after(asyncId) { }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Because promises are asynchronous resources whose lifecycle is tracked
|
|
||||||
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
|
|
||||||
* @since v8.1.0
|
|
||||||
* @param callbacks The `Hook Callbacks` to register
|
|
||||||
* @return Instance used for disabling and enabling hooks
|
|
||||||
*/
|
*/
|
||||||
function createHook(callbacks: HookCallbacks): AsyncHook;
|
function createHook(options: HookCallbacks): AsyncHook;
|
||||||
|
|
||||||
interface AsyncResourceOptions {
|
interface AsyncResourceOptions {
|
||||||
/**
|
/**
|
||||||
* The ID of the execution context that created this async event.
|
* The ID of the execution context that created this async event.
|
||||||
* @default executionAsyncId()
|
* Default: `executionAsyncId()`
|
||||||
*/
|
*/
|
||||||
triggerAsyncId?: number | undefined;
|
triggerAsyncId?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables automatic `emitDestroy` when the object is garbage collected.
|
* Disables automatic `emitDestroy` when the object is garbage collected.
|
||||||
* This usually does not need to be set (even if `emitDestroy` is called
|
* This usually does not need to be set (even if `emitDestroy` is called
|
||||||
* manually), unless the resource's `asyncId` is retrieved and the
|
* manually), unless the resource's `asyncId` is retrieved and the
|
||||||
* sensitive API's `emitDestroy` is called with it.
|
* sensitive API's `emitDestroy` is called with it.
|
||||||
* @default false
|
* Default: `false`
|
||||||
*/
|
*/
|
||||||
requireManualDestroy?: boolean | undefined;
|
requireManualDestroy?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class `AsyncResource` is designed to be extended by the embedder's async
|
* The class AsyncResource was designed to be extended by the embedder's async resources.
|
||||||
* resources. Using this, users can easily trigger the lifetime events of their
|
* Using this users can easily trigger the lifetime events of their own resources.
|
||||||
* own resources.
|
|
||||||
*
|
|
||||||
* The `init` hook will trigger when an `AsyncResource` is instantiated.
|
|
||||||
*
|
|
||||||
* The following is an overview of the `AsyncResource` API.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { AsyncResource, executionAsyncId } from 'async_hooks';
|
|
||||||
*
|
|
||||||
* // AsyncResource() is meant to be extended. Instantiating a
|
|
||||||
* // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
|
||||||
* // async_hook.executionAsyncId() is used.
|
|
||||||
* const asyncResource = new AsyncResource(
|
|
||||||
* type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false }
|
|
||||||
* );
|
|
||||||
*
|
|
||||||
* // Run a function in the execution context of the resource. This will
|
|
||||||
* // * establish the context of the resource
|
|
||||||
* // * trigger the AsyncHooks before callbacks
|
|
||||||
* // * call the provided function `fn` with the supplied arguments
|
|
||||||
* // * trigger the AsyncHooks after callbacks
|
|
||||||
* // * restore the original execution context
|
|
||||||
* asyncResource.runInAsyncScope(fn, thisArg, ...args);
|
|
||||||
*
|
|
||||||
* // Call AsyncHooks destroy callbacks.
|
|
||||||
* asyncResource.emitDestroy();
|
|
||||||
*
|
|
||||||
* // Return the unique ID assigned to the AsyncResource instance.
|
|
||||||
* asyncResource.asyncId();
|
|
||||||
*
|
|
||||||
* // Return the trigger ID for the AsyncResource instance.
|
|
||||||
* asyncResource.triggerAsyncId();
|
|
||||||
* ```
|
|
||||||
*/
|
*/
|
||||||
class AsyncResource {
|
class AsyncResource {
|
||||||
/**
|
/**
|
||||||
@@ -260,238 +113,135 @@ declare module 'async_hooks' {
|
|||||||
* this async event (default: `executionAsyncId()`), or an
|
* this async event (default: `executionAsyncId()`), or an
|
||||||
* AsyncResourceOptions object (since 9.3)
|
* AsyncResourceOptions object (since 9.3)
|
||||||
*/
|
*/
|
||||||
constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
|
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds the given function to the current execution context.
|
* Call the provided function with the provided arguments in the
|
||||||
*
|
* execution context of the async resource. This will establish the
|
||||||
* The returned function will have an `asyncResource` property referencing
|
* context, trigger the AsyncHooks before callbacks, call the function,
|
||||||
* the `AsyncResource` to which the function is bound.
|
* trigger the AsyncHooks after callbacks, and then restore the original
|
||||||
* @since v14.8.0, v12.19.0
|
* execution context.
|
||||||
* @param fn The function to bind to the current execution context.
|
* @param fn The function to call in the execution context of this
|
||||||
* @param type An optional name to associate with the underlying `AsyncResource`.
|
* async resource.
|
||||||
*/
|
|
||||||
static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
|
|
||||||
fn: Func,
|
|
||||||
type?: string,
|
|
||||||
thisArg?: ThisArg
|
|
||||||
): Func & {
|
|
||||||
asyncResource: AsyncResource;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Binds the given function to execute to this `AsyncResource`'s scope.
|
|
||||||
*
|
|
||||||
* The returned function will have an `asyncResource` property referencing
|
|
||||||
* the `AsyncResource` to which the function is bound.
|
|
||||||
* @since v14.8.0, v12.19.0
|
|
||||||
* @param fn The function to bind to the current `AsyncResource`.
|
|
||||||
*/
|
|
||||||
bind<Func extends (...args: any[]) => any>(
|
|
||||||
fn: Func
|
|
||||||
): Func & {
|
|
||||||
asyncResource: AsyncResource;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Call the provided function with the provided arguments in the execution context
|
|
||||||
* of the async resource. This will establish the context, trigger the AsyncHooks
|
|
||||||
* before callbacks, call the function, trigger the AsyncHooks after callbacks, and
|
|
||||||
* then restore the original execution context.
|
|
||||||
* @since v9.6.0
|
|
||||||
* @param fn The function to call in the execution context of this async resource.
|
|
||||||
* @param thisArg The receiver to be used for the function call.
|
* @param thisArg The receiver to be used for the function call.
|
||||||
* @param args Optional arguments to pass to the function.
|
* @param args Optional arguments to pass to the function.
|
||||||
*/
|
*/
|
||||||
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
|
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call all `destroy` hooks. This should only ever be called once. An error will
|
* Call AsyncHooks destroy callbacks.
|
||||||
* be thrown if it is called more than once. This **must** be manually called. If
|
|
||||||
* the resource is left to be collected by the GC then the `destroy` hooks will
|
|
||||||
* never be called.
|
|
||||||
* @return A reference to `asyncResource`.
|
|
||||||
*/
|
*/
|
||||||
emitDestroy(): this;
|
emitDestroy(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The unique `asyncId` assigned to the resource.
|
* @return the unique ID assigned to this AsyncResource instance.
|
||||||
*/
|
*/
|
||||||
asyncId(): number;
|
asyncId(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return the trigger ID for this AsyncResource instance.
|
||||||
* @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
|
|
||||||
*/
|
*/
|
||||||
triggerAsyncId(): number;
|
triggerAsyncId(): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class creates stores that stay coherent through asynchronous operations.
|
* When having multiple instances of `AsyncLocalStorage`, they are independent
|
||||||
*
|
* from each other. It is safe to instantiate this class multiple times.
|
||||||
* While you can create your own implementation on top of the `async_hooks` module,`AsyncLocalStorage` should be preferred as it is a performant and memory safe
|
|
||||||
* implementation that involves significant optimizations that are non-obvious to
|
|
||||||
* implement.
|
|
||||||
*
|
|
||||||
* The following example uses `AsyncLocalStorage` to build a simple logger
|
|
||||||
* that assigns IDs to incoming HTTP requests and includes them in messages
|
|
||||||
* logged within each request.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import http from 'http';
|
|
||||||
* import { AsyncLocalStorage } from 'async_hooks';
|
|
||||||
*
|
|
||||||
* const asyncLocalStorage = new AsyncLocalStorage();
|
|
||||||
*
|
|
||||||
* function logWithId(msg) {
|
|
||||||
* const id = asyncLocalStorage.getStore();
|
|
||||||
* console.log(`${id !== undefined ? id : '-'}:`, msg);
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* let idSeq = 0;
|
|
||||||
* http.createServer((req, res) => {
|
|
||||||
* asyncLocalStorage.run(idSeq++, () => {
|
|
||||||
* logWithId('start');
|
|
||||||
* // Imagine any chain of async operations here
|
|
||||||
* setImmediate(() => {
|
|
||||||
* logWithId('finish');
|
|
||||||
* res.end();
|
|
||||||
* });
|
|
||||||
* });
|
|
||||||
* }).listen(8080);
|
|
||||||
*
|
|
||||||
* http.get('http://localhost:8080');
|
|
||||||
* http.get('http://localhost:8080');
|
|
||||||
* // Prints:
|
|
||||||
* // 0: start
|
|
||||||
* // 1: start
|
|
||||||
* // 0: finish
|
|
||||||
* // 1: finish
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
|
||||||
* Multiple instances can safely exist simultaneously without risk of interfering
|
|
||||||
* with each other data.
|
|
||||||
* @since v13.10.0, v12.17.0
|
|
||||||
*/
|
*/
|
||||||
class AsyncLocalStorage<T> {
|
class AsyncLocalStorage<T> {
|
||||||
/**
|
/**
|
||||||
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
* This method disables the instance of `AsyncLocalStorage`. All subsequent calls
|
||||||
* to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
* to `asyncLocalStorage.getStore()` will return `undefined` until
|
||||||
|
* `asyncLocalStorage.run()` or `asyncLocalStorage.runSyncAndReturn()`
|
||||||
|
* is called again.
|
||||||
*
|
*
|
||||||
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||||
* instance will be exited.
|
* instance will be exited.
|
||||||
*
|
*
|
||||||
* Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores
|
* Calling `asyncLocalStorage.disable()` is required before the
|
||||||
|
* `asyncLocalStorage` can be garbage collected. This does not apply to stores
|
||||||
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
||||||
* along with the corresponding async resources.
|
* along with the corresponding async resources.
|
||||||
*
|
*
|
||||||
* Use this method when the `asyncLocalStorage` is not in use anymore
|
* This method is to be used when the `asyncLocalStorage` is not in use anymore
|
||||||
* in the current process.
|
* in the current process.
|
||||||
* @since v13.10.0, v12.17.0
|
|
||||||
* @experimental
|
|
||||||
*/
|
*/
|
||||||
disable(): void;
|
disable(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current store.
|
* This method returns the current store.
|
||||||
* If called outside of an asynchronous context initialized by
|
* If this method is called outside of an asynchronous context initialized by
|
||||||
* calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
|
* calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will
|
||||||
* returns `undefined`.
|
* return `undefined`.
|
||||||
* @since v13.10.0, v12.17.0
|
|
||||||
*/
|
*/
|
||||||
getStore(): T | undefined;
|
getStore(): T | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a function synchronously within a context and returns its
|
* Calling `asyncLocalStorage.run(callback)` will create a new asynchronous
|
||||||
|
* context.
|
||||||
|
* Within the callback function and the asynchronous operations from the callback,
|
||||||
|
* `asyncLocalStorage.getStore()` will return an instance of `Map` known as
|
||||||
|
* "the store". This store will be persistent through the following
|
||||||
|
* asynchronous calls.
|
||||||
|
*
|
||||||
|
* The callback will be ran asynchronously. Optionally, arguments can be passed
|
||||||
|
* to the function. They will be passed to the callback function.
|
||||||
|
*
|
||||||
|
* If an error is thrown by the callback function, it will not be caught by
|
||||||
|
* a `try/catch` block as the callback is ran in a new asynchronous resource.
|
||||||
|
* Also, the stacktrace will be impacted by the asynchronous call.
|
||||||
|
*/
|
||||||
|
// TODO: Apply generic vararg once available
|
||||||
|
run(store: T, callback: (...args: any[]) => void, ...args: any[]): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous
|
||||||
|
* context.
|
||||||
|
* Within the callback function and the asynchronous operations from the callback,
|
||||||
|
* `asyncLocalStorage.getStore()` will return `undefined`.
|
||||||
|
*
|
||||||
|
* The callback will be ran asynchronously. Optionally, arguments can be passed
|
||||||
|
* to the function. They will be passed to the callback function.
|
||||||
|
*
|
||||||
|
* If an error is thrown by the callback function, it will not be caught by
|
||||||
|
* a `try/catch` block as the callback is ran in a new asynchronous resource.
|
||||||
|
* Also, the stacktrace will be impacted by the asynchronous call.
|
||||||
|
*/
|
||||||
|
exit(callback: (...args: any[]) => void, ...args: any[]): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This methods runs a function synchronously within a context and return its
|
||||||
* return value. The store is not accessible outside of the callback function or
|
* return value. The store is not accessible outside of the callback function or
|
||||||
* the asynchronous operations created within the callback.
|
* the asynchronous operations created within the callback.
|
||||||
*
|
*
|
||||||
* The optional `args` are passed to the callback function.
|
* Optionally, arguments can be passed to the function. They will be passed to
|
||||||
|
* the callback function.
|
||||||
*
|
*
|
||||||
* If the callback function throws an error, the error is thrown by `run()` too.
|
* If the callback function throws an error, it will be thrown by
|
||||||
* The stacktrace is not impacted by this call and the context is exited.
|
* `runSyncAndReturn` too. The stacktrace will not be impacted by this call and
|
||||||
*
|
* the context will be exited.
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const store = { id: 2 };
|
|
||||||
* try {
|
|
||||||
* asyncLocalStorage.run(store, () => {
|
|
||||||
* asyncLocalStorage.getStore(); // Returns the store object
|
|
||||||
* throw new Error();
|
|
||||||
* });
|
|
||||||
* } catch (e) {
|
|
||||||
* asyncLocalStorage.getStore(); // Returns undefined
|
|
||||||
* // The error will be caught here
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v13.10.0, v12.17.0
|
|
||||||
*/
|
*/
|
||||||
run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
runSyncAndReturn<R>(store: T, callback: (...args: any[]) => R, ...args: any[]): R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a function synchronously outside of a context and returns its
|
* This methods runs a function synchronously outside of a context and return its
|
||||||
* return value. The store is not accessible within the callback function or
|
* return value. The store is not accessible within the callback function or
|
||||||
* the asynchronous operations created within the callback. Any `getStore()`call done within the callback function will always return `undefined`.
|
* the asynchronous operations created within the callback.
|
||||||
*
|
*
|
||||||
* The optional `args` are passed to the callback function.
|
* Optionally, arguments can be passed to the function. They will be passed to
|
||||||
|
* the callback function.
|
||||||
*
|
*
|
||||||
* If the callback function throws an error, the error is thrown by `exit()` too.
|
* If the callback function throws an error, it will be thrown by
|
||||||
* The stacktrace is not impacted by this call and the context is re-entered.
|
* `exitSyncAndReturn` too. The stacktrace will not be impacted by this call and
|
||||||
*
|
* the context will be re-entered.
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* // Within a call to run
|
|
||||||
* try {
|
|
||||||
* asyncLocalStorage.getStore(); // Returns the store object or value
|
|
||||||
* asyncLocalStorage.exit(() => {
|
|
||||||
* asyncLocalStorage.getStore(); // Returns undefined
|
|
||||||
* throw new Error();
|
|
||||||
* });
|
|
||||||
* } catch (e) {
|
|
||||||
* asyncLocalStorage.getStore(); // Returns the same object or value
|
|
||||||
* // The error will be caught here
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v13.10.0, v12.17.0
|
|
||||||
* @experimental
|
|
||||||
*/
|
*/
|
||||||
exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
|
exitSyncAndReturn<R>(callback: (...args: any[]) => R, ...args: any[]): R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transitions into the context for the remainder of the current
|
* Calling `asyncLocalStorage.enterWith(store)` will transition into the context
|
||||||
* synchronous execution and then persists the store through any following
|
* for the remainder of the current synchronous execution and will persist
|
||||||
* asynchronous calls.
|
* through any following asynchronous calls.
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const store = { id: 1 };
|
|
||||||
* // Replaces previous store with the given store object
|
|
||||||
* asyncLocalStorage.enterWith(store);
|
|
||||||
* asyncLocalStorage.getStore(); // Returns the store object
|
|
||||||
* someAsyncOperation(() => {
|
|
||||||
* asyncLocalStorage.getStore(); // Returns the same object
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* This transition will continue for the _entire_ synchronous execution.
|
|
||||||
* This means that if, for example, the context is entered within an event
|
|
||||||
* handler subsequent event handlers will also run within that context unless
|
|
||||||
* specifically bound to another context with an `AsyncResource`. That is why`run()` should be preferred over `enterWith()` unless there are strong reasons
|
|
||||||
* to use the latter method.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const store = { id: 1 };
|
|
||||||
*
|
|
||||||
* emitter.on('my-event', () => {
|
|
||||||
* asyncLocalStorage.enterWith(store);
|
|
||||||
* });
|
|
||||||
* emitter.on('my-event', () => {
|
|
||||||
* asyncLocalStorage.getStore(); // Returns the same object
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* asyncLocalStorage.getStore(); // Returns undefined
|
|
||||||
* emitter.emit('my-event');
|
|
||||||
* asyncLocalStorage.getStore(); // Returns the same object
|
|
||||||
* ```
|
|
||||||
* @since v13.11.0, v12.17.0
|
|
||||||
* @experimental
|
|
||||||
*/
|
*/
|
||||||
enterWith(store: T): void;
|
enterWith(store: T): void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module 'node:async_hooks' {
|
|
||||||
export * from 'async_hooks';
|
|
||||||
}
|
|
||||||
|
|||||||
20
node_modules/@types/node/base.d.ts
generated
vendored
Normal file
20
node_modules/@types/node/base.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// NOTE: These definitions support NodeJS and TypeScript 3.7.
|
||||||
|
|
||||||
|
// NOTE: TypeScript version-specific augmentations can be found in the following paths:
|
||||||
|
// - ~/base.d.ts - Shared definitions common to all TypeScript versions
|
||||||
|
// - ~/index.d.ts - Definitions specific to TypeScript 2.1
|
||||||
|
// - ~/ts3.7/base.d.ts - Definitions specific to TypeScript 3.7
|
||||||
|
// - ~/ts3.7/index.d.ts - Definitions specific to TypeScript 3.7 with assert pulled in
|
||||||
|
|
||||||
|
// Reference required types from the default lib:
|
||||||
|
/// <reference lib="es2018" />
|
||||||
|
/// <reference lib="esnext.asynciterable" />
|
||||||
|
/// <reference lib="esnext.intl" />
|
||||||
|
/// <reference lib="esnext.bigint" />
|
||||||
|
|
||||||
|
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
|
||||||
|
// tslint:disable-next-line:no-bad-reference
|
||||||
|
/// <reference path="ts3.6/base.d.ts" />
|
||||||
|
|
||||||
|
// TypeScript 3.7-specific augmentations:
|
||||||
|
/// <reference path="assert.d.ts" />
|
||||||
2140
node_modules/@types/node/buffer.d.ts
generated
vendored
Executable file → Normal file
2140
node_modules/@types/node/buffer.d.ts
generated
vendored
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
1494
node_modules/@types/node/child_process.d.ts
generated
vendored
Executable file → Normal file
1494
node_modules/@types/node/child_process.d.ts
generated
vendored
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
574
node_modules/@types/node/cluster.d.ts
generated
vendored
Executable file → Normal file
574
node_modules/@types/node/cluster.d.ts
generated
vendored
Executable file → Normal file
@@ -1,278 +1,37 @@
|
|||||||
/**
|
declare module "cluster" {
|
||||||
* A single instance of Node.js runs in a single thread. To take advantage of
|
import * as child from "child_process";
|
||||||
* multi-core systems, the user will sometimes want to launch a cluster of Node.js
|
import * as events from "events";
|
||||||
* processes to handle the load.
|
import * as net from "net";
|
||||||
*
|
|
||||||
* The cluster module allows easy creation of child processes that all share
|
// interfaces
|
||||||
* server ports.
|
interface ClusterSettings {
|
||||||
*
|
execArgv?: string[]; // default: process.execArgv
|
||||||
* ```js
|
exec?: string;
|
||||||
* import cluster from 'cluster';
|
args?: string[];
|
||||||
* import http from 'http';
|
silent?: boolean;
|
||||||
* import { cpus } from 'os';
|
stdio?: any[];
|
||||||
* import process from 'process';
|
uid?: number;
|
||||||
*
|
gid?: number;
|
||||||
* const numCPUs = cpus().length;
|
inspectPort?: number | (() => number);
|
||||||
*
|
|
||||||
* if (cluster.isPrimary) {
|
|
||||||
* console.log(`Primary ${process.pid} is running`);
|
|
||||||
*
|
|
||||||
* // Fork workers.
|
|
||||||
* for (let i = 0; i < numCPUs; i++) {
|
|
||||||
* cluster.fork();
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* cluster.on('exit', (worker, code, signal) => {
|
|
||||||
* console.log(`worker ${worker.process.pid} died`);
|
|
||||||
* });
|
|
||||||
* } else {
|
|
||||||
* // Workers can share any TCP connection
|
|
||||||
* // In this case it is an HTTP server
|
|
||||||
* http.createServer((req, res) => {
|
|
||||||
* res.writeHead(200);
|
|
||||||
* res.end('hello world\n');
|
|
||||||
* }).listen(8000);
|
|
||||||
*
|
|
||||||
* console.log(`Worker ${process.pid} started`);
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Running Node.js will now share port 8000 between the workers:
|
|
||||||
*
|
|
||||||
* ```console
|
|
||||||
* $ node server.js
|
|
||||||
* Primary 3596 is running
|
|
||||||
* Worker 4324 started
|
|
||||||
* Worker 4520 started
|
|
||||||
* Worker 6056 started
|
|
||||||
* Worker 5644 started
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/cluster.js)
|
|
||||||
*/
|
|
||||||
declare module 'cluster' {
|
|
||||||
import * as child from 'node:child_process';
|
|
||||||
import EventEmitter = require('node:events');
|
|
||||||
import * as net from 'node:net';
|
|
||||||
export interface ClusterSettings {
|
|
||||||
execArgv?: string[] | undefined; // default: process.execArgv
|
|
||||||
exec?: string | undefined;
|
|
||||||
args?: string[] | undefined;
|
|
||||||
silent?: boolean | undefined;
|
|
||||||
stdio?: any[] | undefined;
|
|
||||||
uid?: number | undefined;
|
|
||||||
gid?: number | undefined;
|
|
||||||
inspectPort?: number | (() => number) | undefined;
|
|
||||||
}
|
}
|
||||||
export interface Address {
|
|
||||||
|
interface Address {
|
||||||
address: string;
|
address: string;
|
||||||
port: number;
|
port: number;
|
||||||
addressType: number | 'udp4' | 'udp6'; // 4, 6, -1, "udp4", "udp6"
|
addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6"
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* A `Worker` object contains all public information and method about a worker.
|
class Worker extends events.EventEmitter {
|
||||||
* In the primary it can be obtained using `cluster.workers`. In a worker
|
|
||||||
* it can be obtained using `cluster.worker`.
|
|
||||||
* @since v0.7.0
|
|
||||||
*/
|
|
||||||
export class Worker extends EventEmitter {
|
|
||||||
/**
|
|
||||||
* Each new worker is given its own unique id, this id is stored in the`id`.
|
|
||||||
*
|
|
||||||
* While a worker is alive, this is the key that indexes it in`cluster.workers`.
|
|
||||||
* @since v0.8.0
|
|
||||||
*/
|
|
||||||
id: number;
|
id: number;
|
||||||
/**
|
|
||||||
* All workers are created using `child_process.fork()`, the returned object
|
|
||||||
* from this function is stored as `.process`. In a worker, the global `process`is stored.
|
|
||||||
*
|
|
||||||
* See: `Child Process module`.
|
|
||||||
*
|
|
||||||
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
|
||||||
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
|
||||||
* accidental disconnection.
|
|
||||||
* @since v0.7.0
|
|
||||||
*/
|
|
||||||
process: child.ChildProcess;
|
process: child.ChildProcess;
|
||||||
/**
|
send(message: any, sendHandle?: any, callback?: (error: Error | null) => void): boolean;
|
||||||
* Send a message to a worker or primary, optionally with a handle.
|
|
||||||
*
|
|
||||||
* In the primary this sends a message to a specific worker. It is identical to `ChildProcess.send()`.
|
|
||||||
*
|
|
||||||
* In a worker this sends a message to the primary. It is identical to`process.send()`.
|
|
||||||
*
|
|
||||||
* This example will echo back all messages from the primary:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* if (cluster.isPrimary) {
|
|
||||||
* const worker = cluster.fork();
|
|
||||||
* worker.send('hi there');
|
|
||||||
*
|
|
||||||
* } else if (cluster.isWorker) {
|
|
||||||
* process.on('message', (msg) => {
|
|
||||||
* process.send(msg);
|
|
||||||
* });
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v0.7.0
|
|
||||||
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
|
|
||||||
*/
|
|
||||||
send(message: child.Serializable, callback?: (error: Error | null) => void): boolean;
|
|
||||||
send(message: child.Serializable, sendHandle: child.SendHandle, callback?: (error: Error | null) => void): boolean;
|
|
||||||
send(message: child.Serializable, sendHandle: child.SendHandle, options?: child.MessageOptions, callback?: (error: Error | null) => void): boolean;
|
|
||||||
/**
|
|
||||||
* This function will kill the worker. In the primary, it does this
|
|
||||||
* by disconnecting the `worker.process`, and once disconnected, killing
|
|
||||||
* with `signal`. In the worker, it does it by disconnecting the channel,
|
|
||||||
* and then exiting with code `0`.
|
|
||||||
*
|
|
||||||
* Because `kill()` attempts to gracefully disconnect the worker process, it is
|
|
||||||
* susceptible to waiting indefinitely for the disconnect to complete. For example,
|
|
||||||
* if the worker enters an infinite loop, a graceful disconnect will never occur.
|
|
||||||
* If the graceful disconnect behavior is not needed, use `worker.process.kill()`.
|
|
||||||
*
|
|
||||||
* Causes `.exitedAfterDisconnect` to be set.
|
|
||||||
*
|
|
||||||
* This method is aliased as `worker.destroy()` for backward compatibility.
|
|
||||||
*
|
|
||||||
* In a worker, `process.kill()` exists, but it is not this function;
|
|
||||||
* it is `kill()`.
|
|
||||||
* @since v0.9.12
|
|
||||||
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
|
|
||||||
*/
|
|
||||||
kill(signal?: string): void;
|
kill(signal?: string): void;
|
||||||
destroy(signal?: string): void;
|
destroy(signal?: string): void;
|
||||||
/**
|
|
||||||
* In a worker, this function will close all servers, wait for the `'close'` event
|
|
||||||
* on those servers, and then disconnect the IPC channel.
|
|
||||||
*
|
|
||||||
* In the primary, an internal message is sent to the worker causing it to call`.disconnect()` on itself.
|
|
||||||
*
|
|
||||||
* Causes `.exitedAfterDisconnect` to be set.
|
|
||||||
*
|
|
||||||
* After a server is closed, it will no longer accept new connections,
|
|
||||||
* but connections may be accepted by any other listening worker. Existing
|
|
||||||
* connections will be allowed to close as usual. When no more connections exist,
|
|
||||||
* see `server.close()`, the IPC channel to the worker will close allowing it
|
|
||||||
* to die gracefully.
|
|
||||||
*
|
|
||||||
* The above applies _only_ to server connections, client connections are not
|
|
||||||
* automatically closed by workers, and disconnect does not wait for them to close
|
|
||||||
* before exiting.
|
|
||||||
*
|
|
||||||
* In a worker, `process.disconnect` exists, but it is not this function;
|
|
||||||
* it is `disconnect()`.
|
|
||||||
*
|
|
||||||
* Because long living server connections may block workers from disconnecting, it
|
|
||||||
* may be useful to send a message, so application specific actions may be taken to
|
|
||||||
* close them. It also may be useful to implement a timeout, killing a worker if
|
|
||||||
* the `'disconnect'` event has not been emitted after some time.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* if (cluster.isPrimary) {
|
|
||||||
* const worker = cluster.fork();
|
|
||||||
* let timeout;
|
|
||||||
*
|
|
||||||
* worker.on('listening', (address) => {
|
|
||||||
* worker.send('shutdown');
|
|
||||||
* worker.disconnect();
|
|
||||||
* timeout = setTimeout(() => {
|
|
||||||
* worker.kill();
|
|
||||||
* }, 2000);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* worker.on('disconnect', () => {
|
|
||||||
* clearTimeout(timeout);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* } else if (cluster.isWorker) {
|
|
||||||
* const net = require('net');
|
|
||||||
* const server = net.createServer((socket) => {
|
|
||||||
* // Connections never end
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* server.listen(8000);
|
|
||||||
*
|
|
||||||
* process.on('message', (msg) => {
|
|
||||||
* if (msg === 'shutdown') {
|
|
||||||
* // Initiate graceful close of any connections to server
|
|
||||||
* }
|
|
||||||
* });
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v0.7.7
|
|
||||||
* @return A reference to `worker`.
|
|
||||||
*/
|
|
||||||
disconnect(): void;
|
disconnect(): void;
|
||||||
/**
|
|
||||||
* This function returns `true` if the worker is connected to its primary via its
|
|
||||||
* IPC channel, `false` otherwise. A worker is connected to its primary after it
|
|
||||||
* has been created. It is disconnected after the `'disconnect'` event is emitted.
|
|
||||||
* @since v0.11.14
|
|
||||||
*/
|
|
||||||
isConnected(): boolean;
|
isConnected(): boolean;
|
||||||
/**
|
|
||||||
* This function returns `true` if the worker's process has terminated (either
|
|
||||||
* because of exiting or being signaled). Otherwise, it returns `false`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import cluster from 'cluster';
|
|
||||||
* import http from 'http';
|
|
||||||
* import { cpus } from 'os';
|
|
||||||
* import process from 'process';
|
|
||||||
*
|
|
||||||
* const numCPUs = cpus().length;
|
|
||||||
*
|
|
||||||
* if (cluster.isPrimary) {
|
|
||||||
* console.log(`Primary ${process.pid} is running`);
|
|
||||||
*
|
|
||||||
* // Fork workers.
|
|
||||||
* for (let i = 0; i < numCPUs; i++) {
|
|
||||||
* cluster.fork();
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* cluster.on('fork', (worker) => {
|
|
||||||
* console.log('worker is dead:', worker.isDead());
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* cluster.on('exit', (worker, code, signal) => {
|
|
||||||
* console.log('worker is dead:', worker.isDead());
|
|
||||||
* });
|
|
||||||
* } else {
|
|
||||||
* // Workers can share any TCP connection. In this case, it is an HTTP server.
|
|
||||||
* http.createServer((req, res) => {
|
|
||||||
* res.writeHead(200);
|
|
||||||
* res.end(`Current process\n ${process.pid}`);
|
|
||||||
* process.kill(process.pid);
|
|
||||||
* }).listen(8000);
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v0.11.14
|
|
||||||
*/
|
|
||||||
isDead(): boolean;
|
isDead(): boolean;
|
||||||
/**
|
|
||||||
* This property is `true` if the worker exited due to `.kill()` or`.disconnect()`. If the worker exited any other way, it is `false`. If the
|
|
||||||
* worker has not exited, it is `undefined`.
|
|
||||||
*
|
|
||||||
* The boolean `worker.exitedAfterDisconnect` allows distinguishing between
|
|
||||||
* voluntary and accidental exit, the primary may choose not to respawn a worker
|
|
||||||
* based on this value.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* cluster.on('exit', (worker, code, signal) => {
|
|
||||||
* if (worker.exitedAfterDisconnect === true) {
|
|
||||||
* console.log('Oh, it was just voluntary – no need to worry');
|
|
||||||
* }
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* // kill worker
|
|
||||||
* worker.kill();
|
|
||||||
* ```
|
|
||||||
* @since v6.0.0
|
|
||||||
*/
|
|
||||||
exitedAfterDisconnect: boolean;
|
exitedAfterDisconnect: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. disconnect
|
* 1. disconnect
|
||||||
@@ -283,67 +42,68 @@ declare module 'cluster' {
|
|||||||
* 6. online
|
* 6. online
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'disconnect', listener: () => void): this;
|
addListener(event: "disconnect", listener: () => void): this;
|
||||||
addListener(event: 'error', listener: (error: Error) => void): this;
|
addListener(event: "error", listener: (error: Error) => void): this;
|
||||||
addListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
addListener(event: 'listening', listener: (address: Address) => void): this;
|
addListener(event: "listening", listener: (address: Address) => void): this;
|
||||||
addListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
addListener(event: 'online', listener: () => void): this;
|
addListener(event: "online", listener: () => void): this;
|
||||||
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'disconnect'): boolean;
|
emit(event: "disconnect"): boolean;
|
||||||
emit(event: 'error', error: Error): boolean;
|
emit(event: "error", error: Error): boolean;
|
||||||
emit(event: 'exit', code: number, signal: string): boolean;
|
emit(event: "exit", code: number, signal: string): boolean;
|
||||||
emit(event: 'listening', address: Address): boolean;
|
emit(event: "listening", address: Address): boolean;
|
||||||
emit(event: 'message', message: any, handle: net.Socket | net.Server): boolean;
|
emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
|
||||||
emit(event: 'online'): boolean;
|
emit(event: "online"): boolean;
|
||||||
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'disconnect', listener: () => void): this;
|
on(event: "disconnect", listener: () => void): this;
|
||||||
on(event: 'error', listener: (error: Error) => void): this;
|
on(event: "error", listener: (error: Error) => void): this;
|
||||||
on(event: 'exit', listener: (code: number, signal: string) => void): this;
|
on(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
on(event: 'listening', listener: (address: Address) => void): this;
|
on(event: "listening", listener: (address: Address) => void): this;
|
||||||
on(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
on(event: 'online', listener: () => void): this;
|
on(event: "online", listener: () => void): this;
|
||||||
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'disconnect', listener: () => void): this;
|
once(event: "disconnect", listener: () => void): this;
|
||||||
once(event: 'error', listener: (error: Error) => void): this;
|
once(event: "error", listener: (error: Error) => void): this;
|
||||||
once(event: 'exit', listener: (code: number, signal: string) => void): this;
|
once(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
once(event: 'listening', listener: (address: Address) => void): this;
|
once(event: "listening", listener: (address: Address) => void): this;
|
||||||
once(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
once(event: 'online', listener: () => void): this;
|
once(event: "online", listener: () => void): this;
|
||||||
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'disconnect', listener: () => void): this;
|
prependListener(event: "disconnect", listener: () => void): this;
|
||||||
prependListener(event: 'error', listener: (error: Error) => void): this;
|
prependListener(event: "error", listener: (error: Error) => void): this;
|
||||||
prependListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
prependListener(event: 'listening', listener: (address: Address) => void): this;
|
prependListener(event: "listening", listener: (address: Address) => void): this;
|
||||||
prependListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
prependListener(event: 'online', listener: () => void): this;
|
prependListener(event: "online", listener: () => void): this;
|
||||||
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'disconnect', listener: () => void): this;
|
prependOnceListener(event: "disconnect", listener: () => void): this;
|
||||||
prependOnceListener(event: 'error', listener: (error: Error) => void): this;
|
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
||||||
prependOnceListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
prependOnceListener(event: 'listening', listener: (address: Address) => void): this;
|
prependOnceListener(event: "listening", listener: (address: Address) => void): this;
|
||||||
prependOnceListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
prependOnceListener(event: 'online', listener: () => void): this;
|
prependOnceListener(event: "online", listener: () => void): this;
|
||||||
}
|
}
|
||||||
export interface Cluster extends EventEmitter {
|
|
||||||
|
interface Cluster extends events.EventEmitter {
|
||||||
|
Worker: Worker;
|
||||||
disconnect(callback?: () => void): void;
|
disconnect(callback?: () => void): void;
|
||||||
fork(env?: any): Worker;
|
fork(env?: any): Worker;
|
||||||
/** @deprecated since v16.0.0 - use isPrimary. */
|
isMaster: boolean;
|
||||||
readonly isMaster: boolean;
|
isWorker: boolean;
|
||||||
readonly isPrimary: boolean;
|
// TODO: cluster.schedulingPolicy
|
||||||
readonly isWorker: boolean;
|
settings: ClusterSettings;
|
||||||
schedulingPolicy: number;
|
|
||||||
readonly settings: ClusterSettings;
|
|
||||||
/** @deprecated since v16.0.0 - use setupPrimary. */
|
|
||||||
setupMaster(settings?: ClusterSettings): void;
|
setupMaster(settings?: ClusterSettings): void;
|
||||||
/**
|
worker?: Worker;
|
||||||
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings.
|
workers?: {
|
||||||
*/
|
[index: string]: Worker | undefined
|
||||||
setupPrimary(settings?: ClusterSettings): void;
|
};
|
||||||
readonly worker?: Worker | undefined;
|
|
||||||
readonly workers?: NodeJS.Dict<Worker> | undefined;
|
|
||||||
readonly SCHED_NONE: number;
|
|
||||||
readonly SCHED_RR: number;
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. disconnect
|
* 1. disconnect
|
||||||
@@ -355,60 +115,146 @@ declare module 'cluster' {
|
|||||||
* 7. setup
|
* 7. setup
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
addListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
addListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
addListener(event: 'fork', listener: (worker: Worker) => void): this;
|
addListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
addListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
addListener(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
addListener(event: 'online', listener: (worker: Worker) => void): this;
|
addListener(event: "online", listener: (worker: Worker) => void): this;
|
||||||
addListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
addListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'disconnect', worker: Worker): boolean;
|
emit(event: "disconnect", worker: Worker): boolean;
|
||||||
emit(event: 'exit', worker: Worker, code: number, signal: string): boolean;
|
emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
|
||||||
emit(event: 'fork', worker: Worker): boolean;
|
emit(event: "fork", worker: Worker): boolean;
|
||||||
emit(event: 'listening', worker: Worker, address: Address): boolean;
|
emit(event: "listening", worker: Worker, address: Address): boolean;
|
||||||
emit(event: 'message', worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
||||||
emit(event: 'online', worker: Worker): boolean;
|
emit(event: "online", worker: Worker): boolean;
|
||||||
emit(event: 'setup', settings: ClusterSettings): boolean;
|
emit(event: "setup", settings: ClusterSettings): boolean;
|
||||||
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'disconnect', listener: (worker: Worker) => void): this;
|
on(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
on(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
on(event: 'fork', listener: (worker: Worker) => void): this;
|
on(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
on(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
on(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
on(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
on(event: 'online', listener: (worker: Worker) => void): this;
|
on(event: "online", listener: (worker: Worker) => void): this;
|
||||||
on(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
on(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'disconnect', listener: (worker: Worker) => void): this;
|
once(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
once(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
once(event: 'fork', listener: (worker: Worker) => void): this;
|
once(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
once(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
once(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
once(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
once(event: 'online', listener: (worker: Worker) => void): this;
|
once(event: "online", listener: (worker: Worker) => void): this;
|
||||||
once(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
once(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
prependListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
prependListener(event: 'fork', listener: (worker: Worker) => void): this;
|
prependListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
prependListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
// the handle is a net.Socket or net.Server object, or undefined.
|
prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
prependListener(event: 'message', listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void): this;
|
prependListener(event: "online", listener: (worker: Worker) => void): this;
|
||||||
prependListener(event: 'online', listener: (worker: Worker) => void): this;
|
prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
prependListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
prependOnceListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
prependOnceListener(event: 'fork', listener: (worker: Worker) => void): this;
|
prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
prependOnceListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
// the handle is a net.Socket or net.Server object, or undefined.
|
// the handle is a net.Socket or net.Server object, or undefined.
|
||||||
prependOnceListener(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this;
|
prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this;
|
||||||
prependOnceListener(event: 'online', listener: (worker: Worker) => void): this;
|
prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
|
||||||
prependOnceListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
}
|
}
|
||||||
const cluster: Cluster;
|
|
||||||
export default cluster;
|
function disconnect(callback?: () => void): void;
|
||||||
}
|
function fork(env?: any): Worker;
|
||||||
declare module 'node:cluster' {
|
const isMaster: boolean;
|
||||||
export * from 'cluster';
|
const isWorker: boolean;
|
||||||
export { default as default } from 'cluster';
|
// TODO: cluster.schedulingPolicy
|
||||||
|
const settings: ClusterSettings;
|
||||||
|
function setupMaster(settings?: ClusterSettings): void;
|
||||||
|
const worker: Worker;
|
||||||
|
const workers: {
|
||||||
|
[index: string]: Worker | undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* events.EventEmitter
|
||||||
|
* 1. disconnect
|
||||||
|
* 2. exit
|
||||||
|
* 3. fork
|
||||||
|
* 4. listening
|
||||||
|
* 5. message
|
||||||
|
* 6. online
|
||||||
|
* 7. setup
|
||||||
|
*/
|
||||||
|
function addListener(event: string, listener: (...args: any[]) => void): Cluster;
|
||||||
|
function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
|
||||||
|
function addListener(event: "fork", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
|
||||||
|
// the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
function addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
|
||||||
|
function addListener(event: "online", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function addListener(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
|
||||||
|
|
||||||
|
function emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
|
function emit(event: "disconnect", worker: Worker): boolean;
|
||||||
|
function emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
|
||||||
|
function emit(event: "fork", worker: Worker): boolean;
|
||||||
|
function emit(event: "listening", worker: Worker, address: Address): boolean;
|
||||||
|
function emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
||||||
|
function emit(event: "online", worker: Worker): boolean;
|
||||||
|
function emit(event: "setup", settings: ClusterSettings): boolean;
|
||||||
|
|
||||||
|
function on(event: string, listener: (...args: any[]) => void): Cluster;
|
||||||
|
function on(event: "disconnect", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
|
||||||
|
function on(event: "fork", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
|
||||||
|
function on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
function on(event: "online", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function on(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
|
||||||
|
|
||||||
|
function once(event: string, listener: (...args: any[]) => void): Cluster;
|
||||||
|
function once(event: "disconnect", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
|
||||||
|
function once(event: "fork", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
|
||||||
|
function once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
function once(event: "online", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function once(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
|
||||||
|
|
||||||
|
function removeListener(event: string, listener: (...args: any[]) => void): Cluster;
|
||||||
|
function removeAllListeners(event?: string): Cluster;
|
||||||
|
function setMaxListeners(n: number): Cluster;
|
||||||
|
function getMaxListeners(): number;
|
||||||
|
function listeners(event: string): Function[];
|
||||||
|
function listenerCount(type: string): number;
|
||||||
|
|
||||||
|
function prependListener(event: string, listener: (...args: any[]) => void): Cluster;
|
||||||
|
function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
|
||||||
|
function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
|
||||||
|
// the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
function prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
|
||||||
|
function prependListener(event: "online", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function prependListener(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
|
||||||
|
|
||||||
|
function prependOnceListener(event: string, listener: (...args: any[]) => void): Cluster;
|
||||||
|
function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
|
||||||
|
function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
|
||||||
|
// the handle is a net.Socket or net.Server object, or undefined.
|
||||||
|
function prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
|
||||||
|
function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster;
|
||||||
|
function prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
|
||||||
|
|
||||||
|
function eventNames(): string[];
|
||||||
}
|
}
|
||||||
|
|||||||
411
node_modules/@types/node/console.d.ts
generated
vendored
Executable file → Normal file
411
node_modules/@types/node/console.d.ts
generated
vendored
Executable file → Normal file
@@ -1,412 +1,3 @@
|
|||||||
/**
|
declare module "console" {
|
||||||
* The `console` module provides a simple debugging console that is similar to the
|
|
||||||
* JavaScript console mechanism provided by web browsers.
|
|
||||||
*
|
|
||||||
* The module exports two specific components:
|
|
||||||
*
|
|
||||||
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
|
|
||||||
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
|
||||||
*
|
|
||||||
* _**Warning**_: The global console object's methods are neither consistently
|
|
||||||
* synchronous like the browser APIs they resemble, nor are they consistently
|
|
||||||
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
|
||||||
* more information.
|
|
||||||
*
|
|
||||||
* Example using the global `console`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* console.log('hello world');
|
|
||||||
* // Prints: hello world, to stdout
|
|
||||||
* console.log('hello %s', 'world');
|
|
||||||
* // Prints: hello world, to stdout
|
|
||||||
* console.error(new Error('Whoops, something bad happened'));
|
|
||||||
* // Prints error message and stack trace to stderr:
|
|
||||||
* // Error: Whoops, something bad happened
|
|
||||||
* // at [eval]:5:15
|
|
||||||
* // at Script.runInThisContext (node:vm:132:18)
|
|
||||||
* // at Object.runInThisContext (node:vm:309:38)
|
|
||||||
* // at node:internal/process/execution:77:19
|
|
||||||
* // at [eval]-wrapper:6:22
|
|
||||||
* // at evalScript (node:internal/process/execution:76:60)
|
|
||||||
* // at node:internal/main/eval_string:23:3
|
|
||||||
*
|
|
||||||
* const name = 'Will Robinson';
|
|
||||||
* console.warn(`Danger ${name}! Danger!`);
|
|
||||||
* // Prints: Danger Will Robinson! Danger!, to stderr
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Example using the `Console` class:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const out = getStreamSomehow();
|
|
||||||
* const err = getStreamSomehow();
|
|
||||||
* const myConsole = new console.Console(out, err);
|
|
||||||
*
|
|
||||||
* myConsole.log('hello world');
|
|
||||||
* // Prints: hello world, to out
|
|
||||||
* myConsole.log('hello %s', 'world');
|
|
||||||
* // Prints: hello world, to out
|
|
||||||
* myConsole.error(new Error('Whoops, something bad happened'));
|
|
||||||
* // Prints: [Error: Whoops, something bad happened], to err
|
|
||||||
*
|
|
||||||
* const name = 'Will Robinson';
|
|
||||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
|
||||||
* // Prints: Danger Will Robinson! Danger!, to err
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/console.js)
|
|
||||||
*/
|
|
||||||
declare module 'console' {
|
|
||||||
import console = require('node:console');
|
|
||||||
export = console;
|
export = console;
|
||||||
}
|
}
|
||||||
declare module 'node:console' {
|
|
||||||
import { InspectOptions } from 'node:util';
|
|
||||||
global {
|
|
||||||
// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
|
|
||||||
interface Console {
|
|
||||||
Console: console.ConsoleConstructor;
|
|
||||||
/**
|
|
||||||
* `console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only
|
|
||||||
* writes a message and does not otherwise affect execution. The output always
|
|
||||||
* starts with `"Assertion failed"`. If provided, `message` is formatted using `util.format()`.
|
|
||||||
*
|
|
||||||
* If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* console.assert(true, 'does nothing');
|
|
||||||
*
|
|
||||||
* console.assert(false, 'Whoops %s work', 'didn\'t');
|
|
||||||
* // Assertion failed: Whoops didn't work
|
|
||||||
*
|
|
||||||
* console.assert();
|
|
||||||
* // Assertion failed
|
|
||||||
* ```
|
|
||||||
* @since v0.1.101
|
|
||||||
* @param value The value tested for being truthy.
|
|
||||||
* @param message All arguments besides `value` are used as error message.
|
|
||||||
*/
|
|
||||||
assert(value: any, message?: string, ...optionalParams: any[]): void;
|
|
||||||
/**
|
|
||||||
* When `stdout` is a TTY, calling `console.clear()` will attempt to clear the
|
|
||||||
* TTY. When `stdout` is not a TTY, this method does nothing.
|
|
||||||
*
|
|
||||||
* The specific operation of `console.clear()` can vary across operating systems
|
|
||||||
* and terminal types. For most Linux operating systems, `console.clear()`operates similarly to the `clear` shell command. On Windows, `console.clear()`will clear only the output in the
|
|
||||||
* current terminal viewport for the Node.js
|
|
||||||
* binary.
|
|
||||||
* @since v8.3.0
|
|
||||||
*/
|
|
||||||
clear(): void;
|
|
||||||
/**
|
|
||||||
* Maintains an internal counter specific to `label` and outputs to `stdout` the
|
|
||||||
* number of times `console.count()` has been called with the given `label`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* > console.count()
|
|
||||||
* default: 1
|
|
||||||
* undefined
|
|
||||||
* > console.count('default')
|
|
||||||
* default: 2
|
|
||||||
* undefined
|
|
||||||
* > console.count('abc')
|
|
||||||
* abc: 1
|
|
||||||
* undefined
|
|
||||||
* > console.count('xyz')
|
|
||||||
* xyz: 1
|
|
||||||
* undefined
|
|
||||||
* > console.count('abc')
|
|
||||||
* abc: 2
|
|
||||||
* undefined
|
|
||||||
* > console.count()
|
|
||||||
* default: 3
|
|
||||||
* undefined
|
|
||||||
* >
|
|
||||||
* ```
|
|
||||||
* @since v8.3.0
|
|
||||||
* @param label The display label for the counter.
|
|
||||||
*/
|
|
||||||
count(label?: string): void;
|
|
||||||
/**
|
|
||||||
* Resets the internal counter specific to `label`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* > console.count('abc');
|
|
||||||
* abc: 1
|
|
||||||
* undefined
|
|
||||||
* > console.countReset('abc');
|
|
||||||
* undefined
|
|
||||||
* > console.count('abc');
|
|
||||||
* abc: 1
|
|
||||||
* undefined
|
|
||||||
* >
|
|
||||||
* ```
|
|
||||||
* @since v8.3.0
|
|
||||||
* @param label The display label for the counter.
|
|
||||||
*/
|
|
||||||
countReset(label?: string): void;
|
|
||||||
/**
|
|
||||||
* The `console.debug()` function is an alias for {@link log}.
|
|
||||||
* @since v8.0.0
|
|
||||||
*/
|
|
||||||
debug(message?: any, ...optionalParams: any[]): void;
|
|
||||||
/**
|
|
||||||
* Uses `util.inspect()` on `obj` and prints the resulting string to `stdout`.
|
|
||||||
* This function bypasses any custom `inspect()` function defined on `obj`.
|
|
||||||
* @since v0.1.101
|
|
||||||
*/
|
|
||||||
dir(obj: any, options?: InspectOptions): void;
|
|
||||||
/**
|
|
||||||
* This method calls `console.log()` passing it the arguments received.
|
|
||||||
* This method does not produce any XML formatting.
|
|
||||||
* @since v8.0.0
|
|
||||||
*/
|
|
||||||
dirxml(...data: any[]): void;
|
|
||||||
/**
|
|
||||||
* Prints to `stderr` with newline. Multiple arguments can be passed, with the
|
|
||||||
* first used as the primary message and all additional used as substitution
|
|
||||||
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const code = 5;
|
|
||||||
* console.error('error #%d', code);
|
|
||||||
* // Prints: error #5, to stderr
|
|
||||||
* console.error('error', code);
|
|
||||||
* // Prints: error 5, to stderr
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If formatting elements (e.g. `%d`) are not found in the first string then `util.inspect()` is called on each argument and the resulting string
|
|
||||||
* values are concatenated. See `util.format()` for more information.
|
|
||||||
* @since v0.1.100
|
|
||||||
*/
|
|
||||||
error(message?: any, ...optionalParams: any[]): void;
|
|
||||||
/**
|
|
||||||
* Increases indentation of subsequent lines by spaces for `groupIndentation`length.
|
|
||||||
*
|
|
||||||
* If one or more `label`s are provided, those are printed first without the
|
|
||||||
* additional indentation.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
|
||||||
group(...label: any[]): void;
|
|
||||||
/**
|
|
||||||
* An alias for {@link group}.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
|
||||||
groupCollapsed(...label: any[]): void;
|
|
||||||
/**
|
|
||||||
* Decreases indentation of subsequent lines by spaces for `groupIndentation`length.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
|
||||||
groupEnd(): void;
|
|
||||||
/**
|
|
||||||
* The `console.info()` function is an alias for {@link log}.
|
|
||||||
* @since v0.1.100
|
|
||||||
*/
|
|
||||||
info(message?: any, ...optionalParams: any[]): void;
|
|
||||||
/**
|
|
||||||
* Prints to `stdout` with newline. Multiple arguments can be passed, with the
|
|
||||||
* first used as the primary message and all additional used as substitution
|
|
||||||
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const count = 5;
|
|
||||||
* console.log('count: %d', count);
|
|
||||||
* // Prints: count: 5, to stdout
|
|
||||||
* console.log('count:', count);
|
|
||||||
* // Prints: count: 5, to stdout
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* See `util.format()` for more information.
|
|
||||||
* @since v0.1.100
|
|
||||||
*/
|
|
||||||
log(message?: any, ...optionalParams: any[]): void;
|
|
||||||
/**
|
|
||||||
* Try to construct a table with the columns of the properties of `tabularData`(or use `properties`) and rows of `tabularData` and log it. Falls back to just
|
|
||||||
* logging the argument if it can’t be parsed as tabular.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* // These can't be parsed as tabular data
|
|
||||||
* console.table(Symbol());
|
|
||||||
* // Symbol()
|
|
||||||
*
|
|
||||||
* console.table(undefined);
|
|
||||||
* // undefined
|
|
||||||
*
|
|
||||||
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
|
|
||||||
* // ┌─────────┬─────┬─────┐
|
|
||||||
* // │ (index) │ a │ b │
|
|
||||||
* // ├─────────┼─────┼─────┤
|
|
||||||
* // │ 0 │ 1 │ 'Y' │
|
|
||||||
* // │ 1 │ 'Z' │ 2 │
|
|
||||||
* // └─────────┴─────┴─────┘
|
|
||||||
*
|
|
||||||
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
|
|
||||||
* // ┌─────────┬─────┐
|
|
||||||
* // │ (index) │ a │
|
|
||||||
* // ├─────────┼─────┤
|
|
||||||
* // │ 0 │ 1 │
|
|
||||||
* // │ 1 │ 'Z' │
|
|
||||||
* // └─────────┴─────┘
|
|
||||||
* ```
|
|
||||||
* @since v10.0.0
|
|
||||||
* @param properties Alternate properties for constructing the table.
|
|
||||||
*/
|
|
||||||
table(tabularData: any, properties?: ReadonlyArray<string>): void;
|
|
||||||
/**
|
|
||||||
* Starts a timer that can be used to compute the duration of an operation. Timers
|
|
||||||
* are identified by a unique `label`. Use the same `label` when calling {@link timeEnd} to stop the timer and output the elapsed time in
|
|
||||||
* suitable time units to `stdout`. For example, if the elapsed
|
|
||||||
* time is 3869ms, `console.timeEnd()` displays "3.869s".
|
|
||||||
* @since v0.1.104
|
|
||||||
*/
|
|
||||||
time(label?: string): void;
|
|
||||||
/**
|
|
||||||
* Stops a timer that was previously started by calling {@link time} and
|
|
||||||
* prints the result to `stdout`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* console.time('100-elements');
|
|
||||||
* for (let i = 0; i < 100; i++) {}
|
|
||||||
* console.timeEnd('100-elements');
|
|
||||||
* // prints 100-elements: 225.438ms
|
|
||||||
* ```
|
|
||||||
* @since v0.1.104
|
|
||||||
*/
|
|
||||||
timeEnd(label?: string): void;
|
|
||||||
/**
|
|
||||||
* For a timer that was previously started by calling {@link time}, prints
|
|
||||||
* the elapsed time and other `data` arguments to `stdout`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* console.time('process');
|
|
||||||
* const value = expensiveProcess1(); // Returns 42
|
|
||||||
* console.timeLog('process', value);
|
|
||||||
* // Prints "process: 365.227ms 42".
|
|
||||||
* doExpensiveProcess2(value);
|
|
||||||
* console.timeEnd('process');
|
|
||||||
* ```
|
|
||||||
* @since v10.7.0
|
|
||||||
*/
|
|
||||||
timeLog(label?: string, ...data: any[]): void;
|
|
||||||
/**
|
|
||||||
* Prints to `stderr` the string `'Trace: '`, followed by the `util.format()` formatted message and stack trace to the current position in the code.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* console.trace('Show me');
|
|
||||||
* // Prints: (stack trace will vary based on where trace is called)
|
|
||||||
* // Trace: Show me
|
|
||||||
* // at repl:2:9
|
|
||||||
* // at REPLServer.defaultEval (repl.js:248:27)
|
|
||||||
* // at bound (domain.js:287:14)
|
|
||||||
* // at REPLServer.runBound [as eval] (domain.js:300:12)
|
|
||||||
* // at REPLServer.<anonymous> (repl.js:412:12)
|
|
||||||
* // at emitOne (events.js:82:20)
|
|
||||||
* // at REPLServer.emit (events.js:169:7)
|
|
||||||
* // at REPLServer.Interface._onLine (readline.js:210:10)
|
|
||||||
* // at REPLServer.Interface._line (readline.js:549:8)
|
|
||||||
* // at REPLServer.Interface._ttyWrite (readline.js:826:14)
|
|
||||||
* ```
|
|
||||||
* @since v0.1.104
|
|
||||||
*/
|
|
||||||
trace(message?: any, ...optionalParams: any[]): void;
|
|
||||||
/**
|
|
||||||
* The `console.warn()` function is an alias for {@link error}.
|
|
||||||
* @since v0.1.100
|
|
||||||
*/
|
|
||||||
warn(message?: any, ...optionalParams: any[]): void;
|
|
||||||
// --- Inspector mode only ---
|
|
||||||
/**
|
|
||||||
* This method does not display anything unless used in the inspector.
|
|
||||||
* Starts a JavaScript CPU profile with an optional label.
|
|
||||||
*/
|
|
||||||
profile(label?: string): void;
|
|
||||||
/**
|
|
||||||
* This method does not display anything unless used in the inspector.
|
|
||||||
* Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
|
|
||||||
*/
|
|
||||||
profileEnd(label?: string): void;
|
|
||||||
/**
|
|
||||||
* This method does not display anything unless used in the inspector.
|
|
||||||
* Adds an event with the label `label` to the Timeline panel of the inspector.
|
|
||||||
*/
|
|
||||||
timeStamp(label?: string): void;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* The `console` module provides a simple debugging console that is similar to the
|
|
||||||
* JavaScript console mechanism provided by web browsers.
|
|
||||||
*
|
|
||||||
* The module exports two specific components:
|
|
||||||
*
|
|
||||||
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
|
|
||||||
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
|
||||||
*
|
|
||||||
* _**Warning**_: The global console object's methods are neither consistently
|
|
||||||
* synchronous like the browser APIs they resemble, nor are they consistently
|
|
||||||
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
|
||||||
* more information.
|
|
||||||
*
|
|
||||||
* Example using the global `console`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* console.log('hello world');
|
|
||||||
* // Prints: hello world, to stdout
|
|
||||||
* console.log('hello %s', 'world');
|
|
||||||
* // Prints: hello world, to stdout
|
|
||||||
* console.error(new Error('Whoops, something bad happened'));
|
|
||||||
* // Prints error message and stack trace to stderr:
|
|
||||||
* // Error: Whoops, something bad happened
|
|
||||||
* // at [eval]:5:15
|
|
||||||
* // at Script.runInThisContext (node:vm:132:18)
|
|
||||||
* // at Object.runInThisContext (node:vm:309:38)
|
|
||||||
* // at node:internal/process/execution:77:19
|
|
||||||
* // at [eval]-wrapper:6:22
|
|
||||||
* // at evalScript (node:internal/process/execution:76:60)
|
|
||||||
* // at node:internal/main/eval_string:23:3
|
|
||||||
*
|
|
||||||
* const name = 'Will Robinson';
|
|
||||||
* console.warn(`Danger ${name}! Danger!`);
|
|
||||||
* // Prints: Danger Will Robinson! Danger!, to stderr
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Example using the `Console` class:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const out = getStreamSomehow();
|
|
||||||
* const err = getStreamSomehow();
|
|
||||||
* const myConsole = new console.Console(out, err);
|
|
||||||
*
|
|
||||||
* myConsole.log('hello world');
|
|
||||||
* // Prints: hello world, to out
|
|
||||||
* myConsole.log('hello %s', 'world');
|
|
||||||
* // Prints: hello world, to out
|
|
||||||
* myConsole.error(new Error('Whoops, something bad happened'));
|
|
||||||
* // Prints: [Error: Whoops, something bad happened], to err
|
|
||||||
*
|
|
||||||
* const name = 'Will Robinson';
|
|
||||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
|
||||||
* // Prints: Danger Will Robinson! Danger!, to err
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js)
|
|
||||||
*/
|
|
||||||
namespace console {
|
|
||||||
interface ConsoleConstructorOptions {
|
|
||||||
stdout: NodeJS.WritableStream;
|
|
||||||
stderr?: NodeJS.WritableStream | undefined;
|
|
||||||
ignoreErrors?: boolean | undefined;
|
|
||||||
colorMode?: boolean | 'auto' | undefined;
|
|
||||||
inspectOptions?: InspectOptions | undefined;
|
|
||||||
/**
|
|
||||||
* Set group indentation
|
|
||||||
* @default 2
|
|
||||||
*/
|
|
||||||
groupIndentation?: number | undefined;
|
|
||||||
}
|
|
||||||
interface ConsoleConstructor {
|
|
||||||
prototype: Console;
|
|
||||||
new (stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): Console;
|
|
||||||
new (options: ConsoleConstructorOptions): Console;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var console: Console;
|
|
||||||
}
|
|
||||||
export = globalThis.console;
|
|
||||||
}
|
|
||||||
|
|||||||
462
node_modules/@types/node/constants.d.ts
generated
vendored
Executable file → Normal file
462
node_modules/@types/node/constants.d.ts
generated
vendored
Executable file → Normal file
@@ -1,18 +1,448 @@
|
|||||||
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
|
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
|
||||||
declare module 'constants' {
|
declare module "constants" {
|
||||||
import { constants as osConstants, SignalConstants } from 'node:os';
|
/** @deprecated since v6.3.0 - use `os.constants.errno.E2BIG` instead. */
|
||||||
import { constants as cryptoConstants } from 'node:crypto';
|
const E2BIG: number;
|
||||||
import { constants as fsConstants } from 'node:fs';
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EACCES` instead. */
|
||||||
|
const EACCES: number;
|
||||||
const exp: typeof osConstants.errno &
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EADDRINUSE` instead. */
|
||||||
typeof osConstants.priority &
|
const EADDRINUSE: number;
|
||||||
SignalConstants &
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EADDRNOTAVAIL` instead. */
|
||||||
typeof cryptoConstants &
|
const EADDRNOTAVAIL: number;
|
||||||
typeof fsConstants;
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EAFNOSUPPORT` instead. */
|
||||||
export = exp;
|
const EAFNOSUPPORT: number;
|
||||||
}
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EAGAIN` instead. */
|
||||||
|
const EAGAIN: number;
|
||||||
declare module 'node:constants' {
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EALREADY` instead. */
|
||||||
import constants = require('constants');
|
const EALREADY: number;
|
||||||
export = constants;
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EBADF` instead. */
|
||||||
|
const EBADF: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EBADMSG` instead. */
|
||||||
|
const EBADMSG: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EBUSY` instead. */
|
||||||
|
const EBUSY: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ECANCELED` instead. */
|
||||||
|
const ECANCELED: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ECHILD` instead. */
|
||||||
|
const ECHILD: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ECONNABORTED` instead. */
|
||||||
|
const ECONNABORTED: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ECONNREFUSED` instead. */
|
||||||
|
const ECONNREFUSED: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ECONNRESET` instead. */
|
||||||
|
const ECONNRESET: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EDEADLK` instead. */
|
||||||
|
const EDEADLK: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EDESTADDRREQ` instead. */
|
||||||
|
const EDESTADDRREQ: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EDOM` instead. */
|
||||||
|
const EDOM: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EEXIST` instead. */
|
||||||
|
const EEXIST: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EFAULT` instead. */
|
||||||
|
const EFAULT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EFBIG` instead. */
|
||||||
|
const EFBIG: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EHOSTUNREACH` instead. */
|
||||||
|
const EHOSTUNREACH: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EIDRM` instead. */
|
||||||
|
const EIDRM: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EILSEQ` instead. */
|
||||||
|
const EILSEQ: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EINPROGRESS` instead. */
|
||||||
|
const EINPROGRESS: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EINTR` instead. */
|
||||||
|
const EINTR: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EINVAL` instead. */
|
||||||
|
const EINVAL: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EIO` instead. */
|
||||||
|
const EIO: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EISCONN` instead. */
|
||||||
|
const EISCONN: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EISDIR` instead. */
|
||||||
|
const EISDIR: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ELOOP` instead. */
|
||||||
|
const ELOOP: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EMFILE` instead. */
|
||||||
|
const EMFILE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EMLINK` instead. */
|
||||||
|
const EMLINK: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EMSGSIZE` instead. */
|
||||||
|
const EMSGSIZE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENAMETOOLONG` instead. */
|
||||||
|
const ENAMETOOLONG: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENETDOWN` instead. */
|
||||||
|
const ENETDOWN: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENETRESET` instead. */
|
||||||
|
const ENETRESET: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENETUNREACH` instead. */
|
||||||
|
const ENETUNREACH: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENFILE` instead. */
|
||||||
|
const ENFILE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOBUFS` instead. */
|
||||||
|
const ENOBUFS: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENODATA` instead. */
|
||||||
|
const ENODATA: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENODEV` instead. */
|
||||||
|
const ENODEV: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOENT` instead. */
|
||||||
|
const ENOENT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOEXEC` instead. */
|
||||||
|
const ENOEXEC: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOLCK` instead. */
|
||||||
|
const ENOLCK: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOLINK` instead. */
|
||||||
|
const ENOLINK: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOMEM` instead. */
|
||||||
|
const ENOMEM: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOMSG` instead. */
|
||||||
|
const ENOMSG: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOPROTOOPT` instead. */
|
||||||
|
const ENOPROTOOPT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSPC` instead. */
|
||||||
|
const ENOSPC: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSR` instead. */
|
||||||
|
const ENOSR: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSTR` instead. */
|
||||||
|
const ENOSTR: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSYS` instead. */
|
||||||
|
const ENOSYS: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTCONN` instead. */
|
||||||
|
const ENOTCONN: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTDIR` instead. */
|
||||||
|
const ENOTDIR: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTEMPTY` instead. */
|
||||||
|
const ENOTEMPTY: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTSOCK` instead. */
|
||||||
|
const ENOTSOCK: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTSUP` instead. */
|
||||||
|
const ENOTSUP: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTTY` instead. */
|
||||||
|
const ENOTTY: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ENXIO` instead. */
|
||||||
|
const ENXIO: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EOPNOTSUPP` instead. */
|
||||||
|
const EOPNOTSUPP: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EOVERFLOW` instead. */
|
||||||
|
const EOVERFLOW: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EPERM` instead. */
|
||||||
|
const EPERM: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EPIPE` instead. */
|
||||||
|
const EPIPE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EPROTO` instead. */
|
||||||
|
const EPROTO: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EPROTONOSUPPORT` instead. */
|
||||||
|
const EPROTONOSUPPORT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EPROTOTYPE` instead. */
|
||||||
|
const EPROTOTYPE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ERANGE` instead. */
|
||||||
|
const ERANGE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EROFS` instead. */
|
||||||
|
const EROFS: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ESPIPE` instead. */
|
||||||
|
const ESPIPE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ESRCH` instead. */
|
||||||
|
const ESRCH: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ETIME` instead. */
|
||||||
|
const ETIME: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ETIMEDOUT` instead. */
|
||||||
|
const ETIMEDOUT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.ETXTBSY` instead. */
|
||||||
|
const ETXTBSY: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EWOULDBLOCK` instead. */
|
||||||
|
const EWOULDBLOCK: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EXDEV` instead. */
|
||||||
|
const EXDEV: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINTR` instead. */
|
||||||
|
const WSAEINTR: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEBADF` instead. */
|
||||||
|
const WSAEBADF: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEACCES` instead. */
|
||||||
|
const WSAEACCES: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEFAULT` instead. */
|
||||||
|
const WSAEFAULT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINVAL` instead. */
|
||||||
|
const WSAEINVAL: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEMFILE` instead. */
|
||||||
|
const WSAEMFILE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEWOULDBLOCK` instead. */
|
||||||
|
const WSAEWOULDBLOCK: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINPROGRESS` instead. */
|
||||||
|
const WSAEINPROGRESS: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEALREADY` instead. */
|
||||||
|
const WSAEALREADY: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOTSOCK` instead. */
|
||||||
|
const WSAENOTSOCK: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEDESTADDRREQ` instead. */
|
||||||
|
const WSAEDESTADDRREQ: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEMSGSIZE` instead. */
|
||||||
|
const WSAEMSGSIZE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROTOTYPE` instead. */
|
||||||
|
const WSAEPROTOTYPE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOPROTOOPT` instead. */
|
||||||
|
const WSAENOPROTOOPT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROTONOSUPPORT` instead. */
|
||||||
|
const WSAEPROTONOSUPPORT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAESOCKTNOSUPPORT` instead. */
|
||||||
|
const WSAESOCKTNOSUPPORT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEOPNOTSUPP` instead. */
|
||||||
|
const WSAEOPNOTSUPP: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPFNOSUPPORT` instead. */
|
||||||
|
const WSAEPFNOSUPPORT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEAFNOSUPPORT` instead. */
|
||||||
|
const WSAEAFNOSUPPORT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEADDRINUSE` instead. */
|
||||||
|
const WSAEADDRINUSE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEADDRNOTAVAIL` instead. */
|
||||||
|
const WSAEADDRNOTAVAIL: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENETDOWN` instead. */
|
||||||
|
const WSAENETDOWN: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENETUNREACH` instead. */
|
||||||
|
const WSAENETUNREACH: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENETRESET` instead. */
|
||||||
|
const WSAENETRESET: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECONNABORTED` instead. */
|
||||||
|
const WSAECONNABORTED: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECONNRESET` instead. */
|
||||||
|
const WSAECONNRESET: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOBUFS` instead. */
|
||||||
|
const WSAENOBUFS: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEISCONN` instead. */
|
||||||
|
const WSAEISCONN: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOTCONN` instead. */
|
||||||
|
const WSAENOTCONN: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAESHUTDOWN` instead. */
|
||||||
|
const WSAESHUTDOWN: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAETOOMANYREFS` instead. */
|
||||||
|
const WSAETOOMANYREFS: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAETIMEDOUT` instead. */
|
||||||
|
const WSAETIMEDOUT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECONNREFUSED` instead. */
|
||||||
|
const WSAECONNREFUSED: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAELOOP` instead. */
|
||||||
|
const WSAELOOP: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENAMETOOLONG` instead. */
|
||||||
|
const WSAENAMETOOLONG: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEHOSTDOWN` instead. */
|
||||||
|
const WSAEHOSTDOWN: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEHOSTUNREACH` instead. */
|
||||||
|
const WSAEHOSTUNREACH: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOTEMPTY` instead. */
|
||||||
|
const WSAENOTEMPTY: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROCLIM` instead. */
|
||||||
|
const WSAEPROCLIM: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEUSERS` instead. */
|
||||||
|
const WSAEUSERS: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEDQUOT` instead. */
|
||||||
|
const WSAEDQUOT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAESTALE` instead. */
|
||||||
|
const WSAESTALE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEREMOTE` instead. */
|
||||||
|
const WSAEREMOTE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSASYSNOTREADY` instead. */
|
||||||
|
const WSASYSNOTREADY: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAVERNOTSUPPORTED` instead. */
|
||||||
|
const WSAVERNOTSUPPORTED: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSANOTINITIALISED` instead. */
|
||||||
|
const WSANOTINITIALISED: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEDISCON` instead. */
|
||||||
|
const WSAEDISCON: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOMORE` instead. */
|
||||||
|
const WSAENOMORE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECANCELLED` instead. */
|
||||||
|
const WSAECANCELLED: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINVALIDPROCTABLE` instead. */
|
||||||
|
const WSAEINVALIDPROCTABLE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINVALIDPROVIDER` instead. */
|
||||||
|
const WSAEINVALIDPROVIDER: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROVIDERFAILEDINIT` instead. */
|
||||||
|
const WSAEPROVIDERFAILEDINIT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSASYSCALLFAILURE` instead. */
|
||||||
|
const WSASYSCALLFAILURE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSASERVICE_NOT_FOUND` instead. */
|
||||||
|
const WSASERVICE_NOT_FOUND: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSATYPE_NOT_FOUND` instead. */
|
||||||
|
const WSATYPE_NOT_FOUND: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSA_E_NO_MORE` instead. */
|
||||||
|
const WSA_E_NO_MORE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSA_E_CANCELLED` instead. */
|
||||||
|
const WSA_E_CANCELLED: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEREFUSED` instead. */
|
||||||
|
const WSAEREFUSED: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGHUP` instead. */
|
||||||
|
const SIGHUP: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGINT` instead. */
|
||||||
|
const SIGINT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGILL` instead. */
|
||||||
|
const SIGILL: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGABRT` instead. */
|
||||||
|
const SIGABRT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGFPE` instead. */
|
||||||
|
const SIGFPE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGKILL` instead. */
|
||||||
|
const SIGKILL: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSEGV` instead. */
|
||||||
|
const SIGSEGV: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTERM` instead. */
|
||||||
|
const SIGTERM: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGBREAK` instead. */
|
||||||
|
const SIGBREAK: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGWINCH` instead. */
|
||||||
|
const SIGWINCH: number;
|
||||||
|
const SSL_OP_ALL: number;
|
||||||
|
const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
|
||||||
|
const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
|
||||||
|
const SSL_OP_CISCO_ANYCONNECT: number;
|
||||||
|
const SSL_OP_COOKIE_EXCHANGE: number;
|
||||||
|
const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
|
||||||
|
const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
|
||||||
|
const SSL_OP_EPHEMERAL_RSA: number;
|
||||||
|
const SSL_OP_LEGACY_SERVER_CONNECT: number;
|
||||||
|
const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
|
||||||
|
const SSL_OP_MICROSOFT_SESS_ID_BUG: number;
|
||||||
|
const SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
|
||||||
|
const SSL_OP_NETSCAPE_CA_DN_BUG: number;
|
||||||
|
const SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
|
||||||
|
const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
|
||||||
|
const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
|
||||||
|
const SSL_OP_NO_COMPRESSION: number;
|
||||||
|
const SSL_OP_NO_QUERY_MTU: number;
|
||||||
|
const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
|
||||||
|
const SSL_OP_NO_SSLv2: number;
|
||||||
|
const SSL_OP_NO_SSLv3: number;
|
||||||
|
const SSL_OP_NO_TICKET: number;
|
||||||
|
const SSL_OP_NO_TLSv1: number;
|
||||||
|
const SSL_OP_NO_TLSv1_1: number;
|
||||||
|
const SSL_OP_NO_TLSv1_2: number;
|
||||||
|
const SSL_OP_PKCS1_CHECK_1: number;
|
||||||
|
const SSL_OP_PKCS1_CHECK_2: number;
|
||||||
|
const SSL_OP_SINGLE_DH_USE: number;
|
||||||
|
const SSL_OP_SINGLE_ECDH_USE: number;
|
||||||
|
const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
|
||||||
|
const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
|
||||||
|
const SSL_OP_TLS_BLOCK_PADDING_BUG: number;
|
||||||
|
const SSL_OP_TLS_D5_BUG: number;
|
||||||
|
const SSL_OP_TLS_ROLLBACK_BUG: number;
|
||||||
|
const ENGINE_METHOD_DSA: number;
|
||||||
|
const ENGINE_METHOD_DH: number;
|
||||||
|
const ENGINE_METHOD_RAND: number;
|
||||||
|
const ENGINE_METHOD_ECDH: number;
|
||||||
|
const ENGINE_METHOD_ECDSA: number;
|
||||||
|
const ENGINE_METHOD_CIPHERS: number;
|
||||||
|
const ENGINE_METHOD_DIGESTS: number;
|
||||||
|
const ENGINE_METHOD_STORE: number;
|
||||||
|
const ENGINE_METHOD_PKEY_METHS: number;
|
||||||
|
const ENGINE_METHOD_PKEY_ASN1_METHS: number;
|
||||||
|
const ENGINE_METHOD_ALL: number;
|
||||||
|
const ENGINE_METHOD_NONE: number;
|
||||||
|
const DH_CHECK_P_NOT_SAFE_PRIME: number;
|
||||||
|
const DH_CHECK_P_NOT_PRIME: number;
|
||||||
|
const DH_UNABLE_TO_CHECK_GENERATOR: number;
|
||||||
|
const DH_NOT_SUITABLE_GENERATOR: number;
|
||||||
|
const RSA_PKCS1_PADDING: number;
|
||||||
|
const RSA_SSLV23_PADDING: number;
|
||||||
|
const RSA_NO_PADDING: number;
|
||||||
|
const RSA_PKCS1_OAEP_PADDING: number;
|
||||||
|
const RSA_X931_PADDING: number;
|
||||||
|
const RSA_PKCS1_PSS_PADDING: number;
|
||||||
|
const POINT_CONVERSION_COMPRESSED: number;
|
||||||
|
const POINT_CONVERSION_UNCOMPRESSED: number;
|
||||||
|
const POINT_CONVERSION_HYBRID: number;
|
||||||
|
const O_RDONLY: number;
|
||||||
|
const O_WRONLY: number;
|
||||||
|
const O_RDWR: number;
|
||||||
|
const S_IFMT: number;
|
||||||
|
const S_IFREG: number;
|
||||||
|
const S_IFDIR: number;
|
||||||
|
const S_IFCHR: number;
|
||||||
|
const S_IFBLK: number;
|
||||||
|
const S_IFIFO: number;
|
||||||
|
const S_IFSOCK: number;
|
||||||
|
const S_IRWXU: number;
|
||||||
|
const S_IRUSR: number;
|
||||||
|
const S_IWUSR: number;
|
||||||
|
const S_IXUSR: number;
|
||||||
|
const S_IRWXG: number;
|
||||||
|
const S_IRGRP: number;
|
||||||
|
const S_IWGRP: number;
|
||||||
|
const S_IXGRP: number;
|
||||||
|
const S_IRWXO: number;
|
||||||
|
const S_IROTH: number;
|
||||||
|
const S_IWOTH: number;
|
||||||
|
const S_IXOTH: number;
|
||||||
|
const S_IFLNK: number;
|
||||||
|
const O_CREAT: number;
|
||||||
|
const O_EXCL: number;
|
||||||
|
const O_NOCTTY: number;
|
||||||
|
const O_DIRECTORY: number;
|
||||||
|
const O_NOATIME: number;
|
||||||
|
const O_NOFOLLOW: number;
|
||||||
|
const O_SYNC: number;
|
||||||
|
const O_DSYNC: number;
|
||||||
|
const O_SYMLINK: number;
|
||||||
|
const O_DIRECT: number;
|
||||||
|
const O_NONBLOCK: number;
|
||||||
|
const O_TRUNC: number;
|
||||||
|
const O_APPEND: number;
|
||||||
|
const F_OK: number;
|
||||||
|
const R_OK: number;
|
||||||
|
const W_OK: number;
|
||||||
|
const X_OK: number;
|
||||||
|
const COPYFILE_EXCL: number;
|
||||||
|
const COPYFILE_FICLONE: number;
|
||||||
|
const COPYFILE_FICLONE_FORCE: number;
|
||||||
|
const UV_UDP_REUSEADDR: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGQUIT` instead. */
|
||||||
|
const SIGQUIT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTRAP` instead. */
|
||||||
|
const SIGTRAP: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGIOT` instead. */
|
||||||
|
const SIGIOT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGBUS` instead. */
|
||||||
|
const SIGBUS: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGUSR1` instead. */
|
||||||
|
const SIGUSR1: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGUSR2` instead. */
|
||||||
|
const SIGUSR2: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPIPE` instead. */
|
||||||
|
const SIGPIPE: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGALRM` instead. */
|
||||||
|
const SIGALRM: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGCHLD` instead. */
|
||||||
|
const SIGCHLD: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSTKFLT` instead. */
|
||||||
|
const SIGSTKFLT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGCONT` instead. */
|
||||||
|
const SIGCONT: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSTOP` instead. */
|
||||||
|
const SIGSTOP: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTSTP` instead. */
|
||||||
|
const SIGTSTP: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTTIN` instead. */
|
||||||
|
const SIGTTIN: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTTOU` instead. */
|
||||||
|
const SIGTTOU: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGURG` instead. */
|
||||||
|
const SIGURG: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGXCPU` instead. */
|
||||||
|
const SIGXCPU: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGXFSZ` instead. */
|
||||||
|
const SIGXFSZ: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGVTALRM` instead. */
|
||||||
|
const SIGVTALRM: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPROF` instead. */
|
||||||
|
const SIGPROF: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGIO` instead. */
|
||||||
|
const SIGIO: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPOLL` instead. */
|
||||||
|
const SIGPOLL: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPWR` instead. */
|
||||||
|
const SIGPWR: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSYS` instead. */
|
||||||
|
const SIGSYS: number;
|
||||||
|
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGUNUSED` instead. */
|
||||||
|
const SIGUNUSED: number;
|
||||||
|
const defaultCoreCipherList: string;
|
||||||
|
const defaultCipherList: string;
|
||||||
|
const ENGINE_METHOD_RSA: number;
|
||||||
|
const ALPN_ENABLED: number;
|
||||||
}
|
}
|
||||||
|
|||||||
3184
node_modules/@types/node/crypto.d.ts
generated
vendored
Executable file → Normal file
3184
node_modules/@types/node/crypto.d.ts
generated
vendored
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
559
node_modules/@types/node/dgram.d.ts
generated
vendored
Executable file → Normal file
559
node_modules/@types/node/dgram.d.ts
generated
vendored
Executable file → Normal file
@@ -1,499 +1,70 @@
|
|||||||
/**
|
declare module "dgram" {
|
||||||
* The `dgram` module provides an implementation of UDP datagram sockets.
|
import { AddressInfo } from "net";
|
||||||
*
|
import * as dns from "dns";
|
||||||
* ```js
|
import * as events from "events";
|
||||||
* import dgram from 'dgram';
|
|
||||||
*
|
|
||||||
* const server = dgram.createSocket('udp4');
|
|
||||||
*
|
|
||||||
* server.on('error', (err) => {
|
|
||||||
* console.log(`server error:\n${err.stack}`);
|
|
||||||
* server.close();
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* server.on('message', (msg, rinfo) => {
|
|
||||||
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* server.on('listening', () => {
|
|
||||||
* const address = server.address();
|
|
||||||
* console.log(`server listening ${address.address}:${address.port}`);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* server.bind(41234);
|
|
||||||
* // Prints: server listening 0.0.0.0:41234
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/dgram.js)
|
|
||||||
*/
|
|
||||||
declare module 'dgram' {
|
|
||||||
import { AddressInfo } from 'node:net';
|
|
||||||
import * as dns from 'node:dns';
|
|
||||||
import { EventEmitter, Abortable } from 'node:events';
|
|
||||||
interface RemoteInfo {
|
interface RemoteInfo {
|
||||||
address: string;
|
address: string;
|
||||||
family: 'IPv4' | 'IPv6';
|
family: 'IPv4' | 'IPv6';
|
||||||
port: number;
|
port: number;
|
||||||
size: number;
|
size: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BindOptions {
|
interface BindOptions {
|
||||||
port?: number | undefined;
|
port?: number;
|
||||||
address?: string | undefined;
|
address?: string;
|
||||||
exclusive?: boolean | undefined;
|
exclusive?: boolean;
|
||||||
fd?: number | undefined;
|
fd?: number;
|
||||||
}
|
}
|
||||||
type SocketType = 'udp4' | 'udp6';
|
|
||||||
interface SocketOptions extends Abortable {
|
type SocketType = "udp4" | "udp6";
|
||||||
|
|
||||||
|
interface SocketOptions {
|
||||||
type: SocketType;
|
type: SocketType;
|
||||||
reuseAddr?: boolean | undefined;
|
reuseAddr?: boolean;
|
||||||
/**
|
/**
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
ipv6Only?: boolean | undefined;
|
ipv6Only?: boolean;
|
||||||
recvBufferSize?: number | undefined;
|
recvBufferSize?: number;
|
||||||
sendBufferSize?: number | undefined;
|
sendBufferSize?: number;
|
||||||
lookup?: ((hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void) | undefined;
|
lookup?: (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram
|
|
||||||
* messages. When `address` and `port` are not passed to `socket.bind()` the
|
|
||||||
* method will bind the socket to the "all interfaces" address on a random port
|
|
||||||
* (it does the right thing for both `udp4` and `udp6` sockets). The bound address
|
|
||||||
* and port can be retrieved using `socket.address().address` and `socket.address().port`.
|
|
||||||
*
|
|
||||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.close()` on the socket:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const controller = new AbortController();
|
|
||||||
* const { signal } = controller;
|
|
||||||
* const server = dgram.createSocket({ type: 'udp4', signal });
|
|
||||||
* server.on('message', (msg, rinfo) => {
|
|
||||||
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
|
||||||
* });
|
|
||||||
* // Later, when you want to close the server.
|
|
||||||
* controller.abort();
|
|
||||||
* ```
|
|
||||||
* @since v0.11.13
|
|
||||||
* @param options Available options are:
|
|
||||||
* @param callback Attached as a listener for `'message'` events. Optional.
|
|
||||||
*/
|
|
||||||
function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||||
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||||
/**
|
|
||||||
* Encapsulates the datagram functionality.
|
class Socket extends events.EventEmitter {
|
||||||
*
|
|
||||||
* New instances of `dgram.Socket` are created using {@link createSocket}.
|
|
||||||
* The `new` keyword is not to be used to create `dgram.Socket` instances.
|
|
||||||
* @since v0.1.99
|
|
||||||
*/
|
|
||||||
class Socket extends EventEmitter {
|
|
||||||
/**
|
|
||||||
* Tells the kernel to join a multicast group at the given `multicastAddress` and`multicastInterface` using the `IP_ADD_MEMBERSHIP` socket option. If the`multicastInterface` argument is not
|
|
||||||
* specified, the operating system will choose
|
|
||||||
* one interface and will add membership to it. To add membership to every
|
|
||||||
* available interface, call `addMembership` multiple times, once per interface.
|
|
||||||
*
|
|
||||||
* When called on an unbound socket, this method will implicitly bind to a random
|
|
||||||
* port, listening on all interfaces.
|
|
||||||
*
|
|
||||||
* When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import cluster from 'cluster';
|
|
||||||
* import dgram from 'dgram';
|
|
||||||
*
|
|
||||||
* if (cluster.isPrimary) {
|
|
||||||
* cluster.fork(); // Works ok.
|
|
||||||
* cluster.fork(); // Fails with EADDRINUSE.
|
|
||||||
* } else {
|
|
||||||
* const s = dgram.createSocket('udp4');
|
|
||||||
* s.bind(1234, () => {
|
|
||||||
* s.addMembership('224.0.0.114');
|
|
||||||
* });
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v0.6.9
|
|
||||||
*/
|
|
||||||
addMembership(multicastAddress: string, multicastInterface?: string): void;
|
addMembership(multicastAddress: string, multicastInterface?: string): void;
|
||||||
/**
|
|
||||||
* Returns an object containing the address information for a socket.
|
|
||||||
* For UDP sockets, this object will contain `address`, `family` and `port`properties.
|
|
||||||
*
|
|
||||||
* This method throws `EBADF` if called on an unbound socket.
|
|
||||||
* @since v0.1.99
|
|
||||||
*/
|
|
||||||
address(): AddressInfo;
|
address(): AddressInfo;
|
||||||
/**
|
bind(port?: number, address?: string, callback?: () => void): void;
|
||||||
* For UDP sockets, causes the `dgram.Socket` to listen for datagram
|
bind(port?: number, callback?: () => void): void;
|
||||||
* messages on a named `port` and optional `address`. If `port` is not
|
bind(callback?: () => void): void;
|
||||||
* specified or is `0`, the operating system will attempt to bind to a
|
bind(options: BindOptions, callback?: () => void): void;
|
||||||
* random port. If `address` is not specified, the operating system will
|
close(callback?: () => void): void;
|
||||||
* attempt to listen on all addresses. Once binding is complete, a`'listening'` event is emitted and the optional `callback` function is
|
|
||||||
* called.
|
|
||||||
*
|
|
||||||
* Specifying both a `'listening'` event listener and passing a`callback` to the `socket.bind()` method is not harmful but not very
|
|
||||||
* useful.
|
|
||||||
*
|
|
||||||
* A bound datagram socket keeps the Node.js process running to receive
|
|
||||||
* datagram messages.
|
|
||||||
*
|
|
||||||
* If binding fails, an `'error'` event is generated. In rare case (e.g.
|
|
||||||
* attempting to bind with a closed socket), an `Error` may be thrown.
|
|
||||||
*
|
|
||||||
* Example of a UDP server listening on port 41234:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import dgram from 'dgram';
|
|
||||||
*
|
|
||||||
* const server = dgram.createSocket('udp4');
|
|
||||||
*
|
|
||||||
* server.on('error', (err) => {
|
|
||||||
* console.log(`server error:\n${err.stack}`);
|
|
||||||
* server.close();
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* server.on('message', (msg, rinfo) => {
|
|
||||||
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* server.on('listening', () => {
|
|
||||||
* const address = server.address();
|
|
||||||
* console.log(`server listening ${address.address}:${address.port}`);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* server.bind(41234);
|
|
||||||
* // Prints: server listening 0.0.0.0:41234
|
|
||||||
* ```
|
|
||||||
* @since v0.1.99
|
|
||||||
* @param callback with no parameters. Called when binding is complete.
|
|
||||||
*/
|
|
||||||
bind(port?: number, address?: string, callback?: () => void): this;
|
|
||||||
bind(port?: number, callback?: () => void): this;
|
|
||||||
bind(callback?: () => void): this;
|
|
||||||
bind(options: BindOptions, callback?: () => void): this;
|
|
||||||
/**
|
|
||||||
* Close the underlying socket and stop listening for data on it. If a callback is
|
|
||||||
* provided, it is added as a listener for the `'close'` event.
|
|
||||||
* @since v0.1.99
|
|
||||||
* @param callback Called when the socket has been closed.
|
|
||||||
*/
|
|
||||||
close(callback?: () => void): this;
|
|
||||||
/**
|
|
||||||
* Associates the `dgram.Socket` to a remote address and port. Every
|
|
||||||
* message sent by this handle is automatically sent to that destination. Also,
|
|
||||||
* the socket will only receive messages from that remote peer.
|
|
||||||
* Trying to call `connect()` on an already connected socket will result
|
|
||||||
* in an `ERR_SOCKET_DGRAM_IS_CONNECTED` exception. If `address` is not
|
|
||||||
* provided, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for `udp6` sockets)
|
|
||||||
* will be used by default. Once the connection is complete, a `'connect'` event
|
|
||||||
* is emitted and the optional `callback` function is called. In case of failure,
|
|
||||||
* the `callback` is called or, failing this, an `'error'` event is emitted.
|
|
||||||
* @since v12.0.0
|
|
||||||
* @param callback Called when the connection is completed or on error.
|
|
||||||
*/
|
|
||||||
connect(port: number, address?: string, callback?: () => void): void;
|
connect(port: number, address?: string, callback?: () => void): void;
|
||||||
connect(port: number, callback: () => void): void;
|
connect(port: number, callback: () => void): void;
|
||||||
/**
|
|
||||||
* A synchronous function that disassociates a connected `dgram.Socket` from
|
|
||||||
* its remote address. Trying to call `disconnect()` on an unbound or already
|
|
||||||
* disconnected socket will result in an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception.
|
|
||||||
* @since v12.0.0
|
|
||||||
*/
|
|
||||||
disconnect(): void;
|
disconnect(): void;
|
||||||
/**
|
|
||||||
* Instructs the kernel to leave a multicast group at `multicastAddress` using the`IP_DROP_MEMBERSHIP` socket option. This method is automatically called by the
|
|
||||||
* kernel when the socket is closed or the process terminates, so most apps will
|
|
||||||
* never have reason to call this.
|
|
||||||
*
|
|
||||||
* If `multicastInterface` is not specified, the operating system will attempt to
|
|
||||||
* drop membership on all valid interfaces.
|
|
||||||
* @since v0.6.9
|
|
||||||
*/
|
|
||||||
dropMembership(multicastAddress: string, multicastInterface?: string): void;
|
dropMembership(multicastAddress: string, multicastInterface?: string): void;
|
||||||
/**
|
|
||||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
|
||||||
* @since v8.7.0
|
|
||||||
* @return the `SO_RCVBUF` socket receive buffer size in bytes.
|
|
||||||
*/
|
|
||||||
getRecvBufferSize(): number;
|
getRecvBufferSize(): number;
|
||||||
/**
|
|
||||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
|
||||||
* @since v8.7.0
|
|
||||||
* @return the `SO_SNDBUF` socket send buffer size in bytes.
|
|
||||||
*/
|
|
||||||
getSendBufferSize(): number;
|
getSendBufferSize(): number;
|
||||||
/**
|
|
||||||
* By default, binding a socket will cause it to block the Node.js process from
|
|
||||||
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
|
||||||
* to exclude the socket from the reference counting that keeps the Node.js
|
|
||||||
* process active. The `socket.ref()` method adds the socket back to the reference
|
|
||||||
* counting and restores the default behavior.
|
|
||||||
*
|
|
||||||
* Calling `socket.ref()` multiples times will have no additional effect.
|
|
||||||
*
|
|
||||||
* The `socket.ref()` method returns a reference to the socket so calls can be
|
|
||||||
* chained.
|
|
||||||
* @since v0.9.1
|
|
||||||
*/
|
|
||||||
ref(): this;
|
ref(): this;
|
||||||
/**
|
|
||||||
* Returns an object containing the `address`, `family`, and `port` of the remote
|
|
||||||
* endpoint. This method throws an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception
|
|
||||||
* if the socket is not connected.
|
|
||||||
* @since v12.0.0
|
|
||||||
*/
|
|
||||||
remoteAddress(): AddressInfo;
|
remoteAddress(): AddressInfo;
|
||||||
/**
|
|
||||||
* Broadcasts a datagram on the socket.
|
|
||||||
* For connectionless sockets, the destination `port` and `address` must be
|
|
||||||
* specified. Connected sockets, on the other hand, will use their associated
|
|
||||||
* remote endpoint, so the `port` and `address` arguments must not be set.
|
|
||||||
*
|
|
||||||
* The `msg` argument contains the message to be sent.
|
|
||||||
* Depending on its type, different behavior can apply. If `msg` is a `Buffer`,
|
|
||||||
* any `TypedArray` or a `DataView`,
|
|
||||||
* the `offset` and `length` specify the offset within the `Buffer` where the
|
|
||||||
* message begins and the number of bytes in the message, respectively.
|
|
||||||
* If `msg` is a `String`, then it is automatically converted to a `Buffer`with `'utf8'` encoding. With messages that
|
|
||||||
* contain multi-byte characters, `offset` and `length` will be calculated with
|
|
||||||
* respect to `byte length` and not the character position.
|
|
||||||
* If `msg` is an array, `offset` and `length` must not be specified.
|
|
||||||
*
|
|
||||||
* The `address` argument is a string. If the value of `address` is a host name,
|
|
||||||
* DNS will be used to resolve the address of the host. If `address` is not
|
|
||||||
* provided or otherwise falsy, `'127.0.0.1'` (for `udp4` sockets) or `'::1'`(for `udp6` sockets) will be used by default.
|
|
||||||
*
|
|
||||||
* If the socket has not been previously bound with a call to `bind`, the socket
|
|
||||||
* is assigned a random port number and is bound to the "all interfaces" address
|
|
||||||
* (`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.)
|
|
||||||
*
|
|
||||||
* An optional `callback` function may be specified to as a way of reporting
|
|
||||||
* DNS errors or for determining when it is safe to reuse the `buf` object.
|
|
||||||
* DNS lookups delay the time to send for at least one tick of the
|
|
||||||
* Node.js event loop.
|
|
||||||
*
|
|
||||||
* The only way to know for sure that the datagram has been sent is by using a`callback`. If an error occurs and a `callback` is given, the error will be
|
|
||||||
* passed as the first argument to the `callback`. If a `callback` is not given,
|
|
||||||
* the error is emitted as an `'error'` event on the `socket` object.
|
|
||||||
*
|
|
||||||
* Offset and length are optional but both _must_ be set if either are used.
|
|
||||||
* They are supported only when the first argument is a `Buffer`, a `TypedArray`,
|
|
||||||
* or a `DataView`.
|
|
||||||
*
|
|
||||||
* This method throws `ERR_SOCKET_BAD_PORT` if called on an unbound socket.
|
|
||||||
*
|
|
||||||
* Example of sending a UDP packet to a port on `localhost`;
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import dgram from 'dgram';
|
|
||||||
* import { Buffer } from 'buffer';
|
|
||||||
*
|
|
||||||
* const message = Buffer.from('Some bytes');
|
|
||||||
* const client = dgram.createSocket('udp4');
|
|
||||||
* client.send(message, 41234, 'localhost', (err) => {
|
|
||||||
* client.close();
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`;
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import dgram from 'dgram';
|
|
||||||
* import { Buffer } from 'buffer';
|
|
||||||
*
|
|
||||||
* const buf1 = Buffer.from('Some ');
|
|
||||||
* const buf2 = Buffer.from('bytes');
|
|
||||||
* const client = dgram.createSocket('udp4');
|
|
||||||
* client.send([buf1, buf2], 41234, (err) => {
|
|
||||||
* client.close();
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Sending multiple buffers might be faster or slower depending on the
|
|
||||||
* application and operating system. Run benchmarks to
|
|
||||||
* determine the optimal strategy on a case-by-case basis. Generally speaking,
|
|
||||||
* however, sending multiple buffers is faster.
|
|
||||||
*
|
|
||||||
* Example of sending a UDP packet using a socket connected to a port on`localhost`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import dgram from 'dgram';
|
|
||||||
* import { Buffer } from 'buffer';
|
|
||||||
*
|
|
||||||
* const message = Buffer.from('Some bytes');
|
|
||||||
* const client = dgram.createSocket('udp4');
|
|
||||||
* client.connect(41234, 'localhost', (err) => {
|
|
||||||
* client.send(message, (err) => {
|
|
||||||
* client.close();
|
|
||||||
* });
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v0.1.99
|
|
||||||
* @param msg Message to be sent.
|
|
||||||
* @param offset Offset in the buffer where the message starts.
|
|
||||||
* @param length Number of bytes in the message.
|
|
||||||
* @param port Destination port.
|
|
||||||
* @param address Destination host name or IP address.
|
|
||||||
* @param callback Called when the message has been sent.
|
|
||||||
*/
|
|
||||||
send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
||||||
send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
|
send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
|
||||||
send(msg: string | Uint8Array | ReadonlyArray<any>, callback?: (error: Error | null, bytes: number) => void): void;
|
send(msg: string | Uint8Array | ReadonlyArray<any>, callback?: (error: Error | null, bytes: number) => void): void;
|
||||||
send(msg: string | Uint8Array, offset: number, length: number, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
send(msg: string | Uint8Array, offset: number, length: number, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
||||||
send(msg: string | Uint8Array, offset: number, length: number, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
|
send(msg: string | Uint8Array, offset: number, length: number, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
|
||||||
send(msg: string | Uint8Array, offset: number, length: number, callback?: (error: Error | null, bytes: number) => void): void;
|
send(msg: string | Uint8Array, offset: number, length: number, callback?: (error: Error | null, bytes: number) => void): void;
|
||||||
/**
|
|
||||||
* Sets or clears the `SO_BROADCAST` socket option. When set to `true`, UDP
|
|
||||||
* packets may be sent to a local interface's broadcast address.
|
|
||||||
*
|
|
||||||
* This method throws `EBADF` if called on an unbound socket.
|
|
||||||
* @since v0.6.9
|
|
||||||
*/
|
|
||||||
setBroadcast(flag: boolean): void;
|
setBroadcast(flag: boolean): void;
|
||||||
/**
|
|
||||||
* _All references to scope in this section are referring to [IPv6 Zone Indices](https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses), which are defined by [RFC
|
|
||||||
* 4007](https://tools.ietf.org/html/rfc4007). In string form, an IP_
|
|
||||||
* _with a scope index is written as `'IP%scope'` where scope is an interface name_
|
|
||||||
* _or interface number._
|
|
||||||
*
|
|
||||||
* Sets the default outgoing multicast interface of the socket to a chosen
|
|
||||||
* interface or back to system interface selection. The `multicastInterface` must
|
|
||||||
* be a valid string representation of an IP from the socket's family.
|
|
||||||
*
|
|
||||||
* For IPv4 sockets, this should be the IP configured for the desired physical
|
|
||||||
* interface. All packets sent to multicast on the socket will be sent on the
|
|
||||||
* interface determined by the most recent successful use of this call.
|
|
||||||
*
|
|
||||||
* For IPv6 sockets, `multicastInterface` should include a scope to indicate the
|
|
||||||
* interface as in the examples that follow. In IPv6, individual `send` calls can
|
|
||||||
* also use explicit scope in addresses, so only packets sent to a multicast
|
|
||||||
* address without specifying an explicit scope are affected by the most recent
|
|
||||||
* successful use of this call.
|
|
||||||
*
|
|
||||||
* This method throws `EBADF` if called on an unbound socket.
|
|
||||||
*
|
|
||||||
* #### Example: IPv6 outgoing multicast interface
|
|
||||||
*
|
|
||||||
* On most systems, where scope format uses the interface name:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const socket = dgram.createSocket('udp6');
|
|
||||||
*
|
|
||||||
* socket.bind(1234, () => {
|
|
||||||
* socket.setMulticastInterface('::%eth1');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* On Windows, where scope format uses an interface number:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const socket = dgram.createSocket('udp6');
|
|
||||||
*
|
|
||||||
* socket.bind(1234, () => {
|
|
||||||
* socket.setMulticastInterface('::%2');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* #### Example: IPv4 outgoing multicast interface
|
|
||||||
*
|
|
||||||
* All systems use an IP of the host on the desired physical interface:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const socket = dgram.createSocket('udp4');
|
|
||||||
*
|
|
||||||
* socket.bind(1234, () => {
|
|
||||||
* socket.setMulticastInterface('10.0.0.2');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v8.6.0
|
|
||||||
*/
|
|
||||||
setMulticastInterface(multicastInterface: string): void;
|
setMulticastInterface(multicastInterface: string): void;
|
||||||
/**
|
setMulticastLoopback(flag: boolean): void;
|
||||||
* Sets or clears the `IP_MULTICAST_LOOP` socket option. When set to `true`,
|
setMulticastTTL(ttl: number): void;
|
||||||
* multicast packets will also be received on the local interface.
|
|
||||||
*
|
|
||||||
* This method throws `EBADF` if called on an unbound socket.
|
|
||||||
* @since v0.3.8
|
|
||||||
*/
|
|
||||||
setMulticastLoopback(flag: boolean): boolean;
|
|
||||||
/**
|
|
||||||
* Sets the `IP_MULTICAST_TTL` socket option. While TTL generally stands for
|
|
||||||
* "Time to Live", in this context it specifies the number of IP hops that a
|
|
||||||
* packet is allowed to travel through, specifically for multicast traffic. Each
|
|
||||||
* router or gateway that forwards a packet decrements the TTL. If the TTL is
|
|
||||||
* decremented to 0 by a router, it will not be forwarded.
|
|
||||||
*
|
|
||||||
* The `ttl` argument may be between 0 and 255\. The default on most systems is `1`.
|
|
||||||
*
|
|
||||||
* This method throws `EBADF` if called on an unbound socket.
|
|
||||||
* @since v0.3.8
|
|
||||||
*/
|
|
||||||
setMulticastTTL(ttl: number): number;
|
|
||||||
/**
|
|
||||||
* Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer
|
|
||||||
* in bytes.
|
|
||||||
*
|
|
||||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
|
||||||
* @since v8.7.0
|
|
||||||
*/
|
|
||||||
setRecvBufferSize(size: number): void;
|
setRecvBufferSize(size: number): void;
|
||||||
/**
|
|
||||||
* Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer
|
|
||||||
* in bytes.
|
|
||||||
*
|
|
||||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
|
||||||
* @since v8.7.0
|
|
||||||
*/
|
|
||||||
setSendBufferSize(size: number): void;
|
setSendBufferSize(size: number): void;
|
||||||
/**
|
setTTL(ttl: number): void;
|
||||||
* Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live",
|
|
||||||
* in this context it specifies the number of IP hops that a packet is allowed to
|
|
||||||
* travel through. Each router or gateway that forwards a packet decrements the
|
|
||||||
* TTL. If the TTL is decremented to 0 by a router, it will not be forwarded.
|
|
||||||
* Changing TTL values is typically done for network probes or when multicasting.
|
|
||||||
*
|
|
||||||
* The `ttl` argument may be between between 1 and 255\. The default on most systems
|
|
||||||
* is 64.
|
|
||||||
*
|
|
||||||
* This method throws `EBADF` if called on an unbound socket.
|
|
||||||
* @since v0.1.101
|
|
||||||
*/
|
|
||||||
setTTL(ttl: number): number;
|
|
||||||
/**
|
|
||||||
* By default, binding a socket will cause it to block the Node.js process from
|
|
||||||
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
|
||||||
* to exclude the socket from the reference counting that keeps the Node.js
|
|
||||||
* process active, allowing the process to exit even if the socket is still
|
|
||||||
* listening.
|
|
||||||
*
|
|
||||||
* Calling `socket.unref()` multiple times will have no addition effect.
|
|
||||||
*
|
|
||||||
* The `socket.unref()` method returns a reference to the socket so calls can be
|
|
||||||
* chained.
|
|
||||||
* @since v0.9.1
|
|
||||||
*/
|
|
||||||
unref(): this;
|
unref(): this;
|
||||||
/**
|
|
||||||
* Tells the kernel to join a source-specific multicast channel at the given`sourceAddress` and `groupAddress`, using the `multicastInterface` with the`IP_ADD_SOURCE_MEMBERSHIP` socket
|
|
||||||
* option. If the `multicastInterface` argument
|
|
||||||
* is not specified, the operating system will choose one interface and will add
|
|
||||||
* membership to it. To add membership to every available interface, call`socket.addSourceSpecificMembership()` multiple times, once per interface.
|
|
||||||
*
|
|
||||||
* When called on an unbound socket, this method will implicitly bind to a random
|
|
||||||
* port, listening on all interfaces.
|
|
||||||
* @since v13.1.0, v12.16.0
|
|
||||||
*/
|
|
||||||
addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
|
||||||
/**
|
|
||||||
* Instructs the kernel to leave a source-specific multicast channel at the given`sourceAddress` and `groupAddress` using the `IP_DROP_SOURCE_MEMBERSHIP`socket option. This method is
|
|
||||||
* automatically called by the kernel when the
|
|
||||||
* socket is closed or the process terminates, so most apps will never have
|
|
||||||
* reason to call this.
|
|
||||||
*
|
|
||||||
* If `multicastInterface` is not specified, the operating system will attempt to
|
|
||||||
* drop membership on all valid interfaces.
|
|
||||||
* @since v13.1.0, v12.16.0
|
|
||||||
*/
|
|
||||||
dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. close
|
* 1. close
|
||||||
@@ -503,43 +74,45 @@ declare module 'dgram' {
|
|||||||
* 5. message
|
* 5. message
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: () => void): this;
|
addListener(event: "close", listener: () => void): this;
|
||||||
addListener(event: 'connect', listener: () => void): this;
|
addListener(event: "connect", listener: () => void): this;
|
||||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
addListener(event: 'listening', listener: () => void): this;
|
addListener(event: "listening", listener: () => void): this;
|
||||||
addListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'close'): boolean;
|
emit(event: "close"): boolean;
|
||||||
emit(event: 'connect'): boolean;
|
emit(event: "connect"): boolean;
|
||||||
emit(event: 'error', err: Error): boolean;
|
emit(event: "error", err: Error): boolean;
|
||||||
emit(event: 'listening'): boolean;
|
emit(event: "listening"): boolean;
|
||||||
emit(event: 'message', msg: Buffer, rinfo: RemoteInfo): boolean;
|
emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean;
|
||||||
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'close', listener: () => void): this;
|
on(event: "close", listener: () => void): this;
|
||||||
on(event: 'connect', listener: () => void): this;
|
on(event: "connect", listener: () => void): this;
|
||||||
on(event: 'error', listener: (err: Error) => void): this;
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
on(event: 'listening', listener: () => void): this;
|
on(event: "listening", listener: () => void): this;
|
||||||
on(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'close', listener: () => void): this;
|
once(event: "close", listener: () => void): this;
|
||||||
once(event: 'connect', listener: () => void): this;
|
once(event: "connect", listener: () => void): this;
|
||||||
once(event: 'error', listener: (err: Error) => void): this;
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
once(event: 'listening', listener: () => void): this;
|
once(event: "listening", listener: () => void): this;
|
||||||
once(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'close', listener: () => void): this;
|
prependListener(event: "close", listener: () => void): this;
|
||||||
prependListener(event: 'connect', listener: () => void): this;
|
prependListener(event: "connect", listener: () => void): this;
|
||||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependListener(event: 'listening', listener: () => void): this;
|
prependListener(event: "listening", listener: () => void): this;
|
||||||
prependListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'close', listener: () => void): this;
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
prependOnceListener(event: 'connect', listener: () => void): this;
|
prependOnceListener(event: "connect", listener: () => void): this;
|
||||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
prependOnceListener(event: "listening", listener: () => void): this;
|
||||||
prependOnceListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module 'node:dgram' {
|
|
||||||
export * from 'dgram';
|
|
||||||
}
|
|
||||||
|
|||||||
134
node_modules/@types/node/diagnostics_channel.d.ts
generated
vendored
134
node_modules/@types/node/diagnostics_channel.d.ts
generated
vendored
@@ -1,134 +0,0 @@
|
|||||||
/**
|
|
||||||
* The `diagnostics_channel` module provides an API to create named channels
|
|
||||||
* to report arbitrary message data for diagnostics purposes.
|
|
||||||
*
|
|
||||||
* It can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import diagnostics_channel from 'diagnostics_channel';
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* It is intended that a module writer wanting to report diagnostics messages
|
|
||||||
* will create one or many top-level channels to report messages through.
|
|
||||||
* Channels may also be acquired at runtime but it is not encouraged
|
|
||||||
* due to the additional overhead of doing so. Channels may be exported for
|
|
||||||
* convenience, but as long as the name is known it can be acquired anywhere.
|
|
||||||
*
|
|
||||||
* If you intend for your module to produce diagnostics data for others to
|
|
||||||
* consume it is recommended that you include documentation of what named
|
|
||||||
* channels are used along with the shape of the message data. Channel names
|
|
||||||
* should generally include the module name to avoid collisions with data from
|
|
||||||
* other modules.
|
|
||||||
* @experimental
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/diagnostics_channel.js)
|
|
||||||
*/
|
|
||||||
declare module 'diagnostics_channel' {
|
|
||||||
/**
|
|
||||||
* Check if there are active subscribers to the named channel. This is helpful if
|
|
||||||
* the message you want to send might be expensive to prepare.
|
|
||||||
*
|
|
||||||
* This API is optional but helpful when trying to publish messages from very
|
|
||||||
* performance-sensitive code.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import diagnostics_channel from 'diagnostics_channel';
|
|
||||||
*
|
|
||||||
* if (diagnostics_channel.hasSubscribers('my-channel')) {
|
|
||||||
* // There are subscribers, prepare and publish message
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v15.1.0, v14.17.0
|
|
||||||
* @param name The channel name
|
|
||||||
* @return If there are active subscribers
|
|
||||||
*/
|
|
||||||
function hasSubscribers(name: string): boolean;
|
|
||||||
/**
|
|
||||||
* This is the primary entry-point for anyone wanting to interact with a named
|
|
||||||
* channel. It produces a channel object which is optimized to reduce overhead at
|
|
||||||
* publish time as much as possible.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import diagnostics_channel from 'diagnostics_channel';
|
|
||||||
*
|
|
||||||
* const channel = diagnostics_channel.channel('my-channel');
|
|
||||||
* ```
|
|
||||||
* @since v15.1.0, v14.17.0
|
|
||||||
* @param name The channel name
|
|
||||||
* @return The named channel object
|
|
||||||
*/
|
|
||||||
function channel(name: string): Channel;
|
|
||||||
type ChannelListener = (name: string, message: unknown) => void;
|
|
||||||
/**
|
|
||||||
* The class `Channel` represents an individual named channel within the data
|
|
||||||
* pipeline. It is use to track subscribers and to publish messages when there
|
|
||||||
* are subscribers present. It exists as a separate object to avoid channel
|
|
||||||
* lookups at publish time, enabling very fast publish speeds and allowing
|
|
||||||
* for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly
|
|
||||||
* with `new Channel(name)` is not supported.
|
|
||||||
* @since v15.1.0, v14.17.0
|
|
||||||
*/
|
|
||||||
class Channel {
|
|
||||||
readonly name: string;
|
|
||||||
/**
|
|
||||||
* Check if there are active subscribers to this channel. This is helpful if
|
|
||||||
* the message you want to send might be expensive to prepare.
|
|
||||||
*
|
|
||||||
* This API is optional but helpful when trying to publish messages from very
|
|
||||||
* performance-sensitive code.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import diagnostics_channel from 'diagnostics_channel';
|
|
||||||
*
|
|
||||||
* const channel = diagnostics_channel.channel('my-channel');
|
|
||||||
*
|
|
||||||
* if (channel.hasSubscribers) {
|
|
||||||
* // There are subscribers, prepare and publish message
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v15.1.0, v14.17.0
|
|
||||||
*/
|
|
||||||
readonly hasSubscribers: boolean;
|
|
||||||
private constructor(name: string);
|
|
||||||
/**
|
|
||||||
* Register a message handler to subscribe to this channel. This message handler
|
|
||||||
* will be run synchronously whenever a message is published to the channel. Any
|
|
||||||
* errors thrown in the message handler will trigger an `'uncaughtException'`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import diagnostics_channel from 'diagnostics_channel';
|
|
||||||
*
|
|
||||||
* const channel = diagnostics_channel.channel('my-channel');
|
|
||||||
*
|
|
||||||
* channel.subscribe((message, name) => {
|
|
||||||
* // Received data
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v15.1.0, v14.17.0
|
|
||||||
* @param onMessage The handler to receive channel messages
|
|
||||||
*/
|
|
||||||
subscribe(onMessage: ChannelListener): void;
|
|
||||||
/**
|
|
||||||
* Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import diagnostics_channel from 'diagnostics_channel';
|
|
||||||
*
|
|
||||||
* const channel = diagnostics_channel.channel('my-channel');
|
|
||||||
*
|
|
||||||
* function onMessage(message, name) {
|
|
||||||
* // Received data
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* channel.subscribe(onMessage);
|
|
||||||
*
|
|
||||||
* channel.unsubscribe(onMessage);
|
|
||||||
* ```
|
|
||||||
* @since v15.1.0, v14.17.0
|
|
||||||
* @param onMessage The previous subscribed handler to remove
|
|
||||||
*/
|
|
||||||
unsubscribe(onMessage: ChannelListener): void;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
declare module 'node:diagnostics_channel' {
|
|
||||||
export * from 'diagnostics_channel';
|
|
||||||
}
|
|
||||||
806
node_modules/@types/node/dns.d.ts
generated
vendored
Executable file → Normal file
806
node_modules/@types/node/dns.d.ts
generated
vendored
Executable file → Normal file
@@ -1,191 +1,81 @@
|
|||||||
/**
|
declare module "dns" {
|
||||||
* The `dns` module enables name resolution. For example, use it to look up IP
|
|
||||||
* addresses of host names.
|
|
||||||
*
|
|
||||||
* Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the
|
|
||||||
* DNS protocol for lookups. {@link lookup} uses the operating system
|
|
||||||
* facilities to perform name resolution. It may not need to perform any network
|
|
||||||
* communication. To perform name resolution the way other applications on the same
|
|
||||||
* system do, use {@link lookup}.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const dns = require('dns');
|
|
||||||
*
|
|
||||||
* dns.lookup('example.org', (err, address, family) => {
|
|
||||||
* console.log('address: %j family: IPv%s', address, family);
|
|
||||||
* });
|
|
||||||
* // address: "93.184.216.34" family: IPv4
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* All other functions in the `dns` module connect to an actual DNS server to
|
|
||||||
* perform name resolution. They will always use the network to perform DNS
|
|
||||||
* queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform
|
|
||||||
* DNS queries, bypassing other name-resolution facilities.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const dns = require('dns');
|
|
||||||
*
|
|
||||||
* dns.resolve4('archive.org', (err, addresses) => {
|
|
||||||
* if (err) throw err;
|
|
||||||
*
|
|
||||||
* console.log(`addresses: ${JSON.stringify(addresses)}`);
|
|
||||||
*
|
|
||||||
* addresses.forEach((a) => {
|
|
||||||
* dns.reverse(a, (err, hostnames) => {
|
|
||||||
* if (err) {
|
|
||||||
* throw err;
|
|
||||||
* }
|
|
||||||
* console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`);
|
|
||||||
* });
|
|
||||||
* });
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* See the `Implementation considerations section` for more information.
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/dns.js)
|
|
||||||
*/
|
|
||||||
declare module 'dns' {
|
|
||||||
import * as dnsPromises from 'node:dns/promises';
|
|
||||||
// Supported getaddrinfo flags.
|
// Supported getaddrinfo flags.
|
||||||
export const ADDRCONFIG: number;
|
const ADDRCONFIG: number;
|
||||||
export const V4MAPPED: number;
|
const V4MAPPED: number;
|
||||||
/**
|
|
||||||
* If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
|
interface LookupOptions {
|
||||||
* well as IPv4 mapped IPv6 addresses.
|
family?: number;
|
||||||
*/
|
hints?: number;
|
||||||
export const ALL: number;
|
all?: boolean;
|
||||||
export interface LookupOptions {
|
verbatim?: boolean;
|
||||||
family?: number | undefined;
|
|
||||||
hints?: number | undefined;
|
|
||||||
all?: boolean | undefined;
|
|
||||||
verbatim?: boolean | undefined;
|
|
||||||
}
|
}
|
||||||
export interface LookupOneOptions extends LookupOptions {
|
|
||||||
all?: false | undefined;
|
interface LookupOneOptions extends LookupOptions {
|
||||||
|
all?: false;
|
||||||
}
|
}
|
||||||
export interface LookupAllOptions extends LookupOptions {
|
|
||||||
|
interface LookupAllOptions extends LookupOptions {
|
||||||
all: true;
|
all: true;
|
||||||
}
|
}
|
||||||
export interface LookupAddress {
|
|
||||||
|
interface LookupAddress {
|
||||||
address: string;
|
address: string;
|
||||||
family: number;
|
family: number;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||||
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||||
* integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
|
function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
|
||||||
* and IPv6 addresses are both returned if found.
|
function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void): void;
|
||||||
*
|
function lookup(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||||
* With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the
|
|
||||||
* properties `address` and `family`.
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||||
*
|
namespace lookup {
|
||||||
* On error, `err` is an `Error` object, where `err.code` is the error code.
|
|
||||||
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
|
||||||
* the host name does not exist but also when the lookup fails in other ways
|
|
||||||
* such as no available file descriptors.
|
|
||||||
*
|
|
||||||
* `dns.lookup()` does not necessarily have anything to do with the DNS protocol.
|
|
||||||
* The implementation uses an operating system facility that can associate names
|
|
||||||
* with addresses, and vice versa. This implementation can have subtle but
|
|
||||||
* important consequences on the behavior of any Node.js program. Please take some
|
|
||||||
* time to consult the `Implementation considerations section` before using`dns.lookup()`.
|
|
||||||
*
|
|
||||||
* Example usage:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const dns = require('dns');
|
|
||||||
* const options = {
|
|
||||||
* family: 6,
|
|
||||||
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
|
||||||
* };
|
|
||||||
* dns.lookup('example.com', options, (err, address, family) =>
|
|
||||||
* console.log('address: %j family: IPv%s', address, family));
|
|
||||||
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
|
||||||
*
|
|
||||||
* // When options.all is true, the result will be an Array.
|
|
||||||
* options.all = true;
|
|
||||||
* dns.lookup('example.com', options, (err, addresses) =>
|
|
||||||
* console.log('addresses: %j', addresses));
|
|
||||||
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If this method is invoked as its `util.promisify()` ed version, and `all`is not set to `true`, it returns a `Promise` for an `Object` with `address` and`family` properties.
|
|
||||||
* @since v0.1.90
|
|
||||||
*/
|
|
||||||
export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
|
||||||
export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
|
||||||
export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
|
|
||||||
export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void): void;
|
|
||||||
export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
|
||||||
export namespace lookup {
|
|
||||||
function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
||||||
function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
|
function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
|
||||||
function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Resolves the given `address` and `port` into a host name and service using
|
function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
|
||||||
* the operating system's underlying `getnameinfo` implementation.
|
|
||||||
*
|
namespace lookupService {
|
||||||
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
function __promisify__(address: string, port: number): Promise<{ hostname: string, service: string }>;
|
||||||
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
|
|
||||||
*
|
|
||||||
* On an error, `err` is an `Error` object, where `err.code` is the error code.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const dns = require('dns');
|
|
||||||
* dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
|
|
||||||
* console.log(hostname, service);
|
|
||||||
* // Prints: localhost ssh
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If this method is invoked as its `util.promisify()` ed version, it returns a`Promise` for an `Object` with `hostname` and `service` properties.
|
|
||||||
* @since v0.11.14
|
|
||||||
*/
|
|
||||||
export function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
|
|
||||||
export namespace lookupService {
|
|
||||||
function __promisify__(
|
|
||||||
address: string,
|
|
||||||
port: number
|
|
||||||
): Promise<{
|
|
||||||
hostname: string;
|
|
||||||
service: string;
|
|
||||||
}>;
|
|
||||||
}
|
}
|
||||||
export interface ResolveOptions {
|
|
||||||
|
interface ResolveOptions {
|
||||||
ttl: boolean;
|
ttl: boolean;
|
||||||
}
|
}
|
||||||
export interface ResolveWithTtlOptions extends ResolveOptions {
|
|
||||||
|
interface ResolveWithTtlOptions extends ResolveOptions {
|
||||||
ttl: true;
|
ttl: true;
|
||||||
}
|
}
|
||||||
export interface RecordWithTtl {
|
|
||||||
|
interface RecordWithTtl {
|
||||||
address: string;
|
address: string;
|
||||||
ttl: number;
|
ttl: number;
|
||||||
}
|
}
|
||||||
/** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
|
|
||||||
export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
/** @deprecated Use AnyARecord or AnyAaaaRecord instead. */
|
||||||
export interface AnyARecord extends RecordWithTtl {
|
type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
||||||
type: 'A';
|
|
||||||
|
interface AnyARecord extends RecordWithTtl {
|
||||||
|
type: "A";
|
||||||
}
|
}
|
||||||
export interface AnyAaaaRecord extends RecordWithTtl {
|
|
||||||
type: 'AAAA';
|
interface AnyAaaaRecord extends RecordWithTtl {
|
||||||
|
type: "AAAA";
|
||||||
}
|
}
|
||||||
export interface CaaRecord {
|
|
||||||
critial: number;
|
interface MxRecord {
|
||||||
issue?: string | undefined;
|
|
||||||
issuewild?: string | undefined;
|
|
||||||
iodef?: string | undefined;
|
|
||||||
contactemail?: string | undefined;
|
|
||||||
contactphone?: string | undefined;
|
|
||||||
}
|
|
||||||
export interface MxRecord {
|
|
||||||
priority: number;
|
priority: number;
|
||||||
exchange: string;
|
exchange: string;
|
||||||
}
|
}
|
||||||
export interface AnyMxRecord extends MxRecord {
|
|
||||||
type: 'MX';
|
interface AnyMxRecord extends MxRecord {
|
||||||
|
type: "MX";
|
||||||
}
|
}
|
||||||
export interface NaptrRecord {
|
|
||||||
|
interface NaptrRecord {
|
||||||
flags: string;
|
flags: string;
|
||||||
service: string;
|
service: string;
|
||||||
regexp: string;
|
regexp: string;
|
||||||
@@ -193,10 +83,12 @@ declare module 'dns' {
|
|||||||
order: number;
|
order: number;
|
||||||
preference: number;
|
preference: number;
|
||||||
}
|
}
|
||||||
export interface AnyNaptrRecord extends NaptrRecord {
|
|
||||||
type: 'NAPTR';
|
interface AnyNaptrRecord extends NaptrRecord {
|
||||||
|
type: "NAPTR";
|
||||||
}
|
}
|
||||||
export interface SoaRecord {
|
|
||||||
|
interface SoaRecord {
|
||||||
nsname: string;
|
nsname: string;
|
||||||
hostmaster: string;
|
hostmaster: string;
|
||||||
serial: number;
|
serial: number;
|
||||||
@@ -205,416 +97,255 @@ declare module 'dns' {
|
|||||||
expire: number;
|
expire: number;
|
||||||
minttl: number;
|
minttl: number;
|
||||||
}
|
}
|
||||||
export interface AnySoaRecord extends SoaRecord {
|
|
||||||
type: 'SOA';
|
interface AnySoaRecord extends SoaRecord {
|
||||||
|
type: "SOA";
|
||||||
}
|
}
|
||||||
export interface SrvRecord {
|
|
||||||
|
interface SrvRecord {
|
||||||
priority: number;
|
priority: number;
|
||||||
weight: number;
|
weight: number;
|
||||||
port: number;
|
port: number;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
export interface AnySrvRecord extends SrvRecord {
|
|
||||||
type: 'SRV';
|
interface AnySrvRecord extends SrvRecord {
|
||||||
|
type: "SRV";
|
||||||
}
|
}
|
||||||
export interface AnyTxtRecord {
|
|
||||||
type: 'TXT';
|
interface AnyTxtRecord {
|
||||||
|
type: "TXT";
|
||||||
entries: string[];
|
entries: string[];
|
||||||
}
|
}
|
||||||
export interface AnyNsRecord {
|
|
||||||
type: 'NS';
|
interface AnyNsRecord {
|
||||||
|
type: "NS";
|
||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
export interface AnyPtrRecord {
|
|
||||||
type: 'PTR';
|
interface AnyPtrRecord {
|
||||||
|
type: "PTR";
|
||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
export interface AnyCnameRecord {
|
|
||||||
type: 'CNAME';
|
interface AnyCnameRecord {
|
||||||
|
type: "CNAME";
|
||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
export type AnyRecord = AnyARecord | AnyAaaaRecord | AnyCnameRecord | AnyMxRecord | AnyNaptrRecord | AnyNsRecord | AnyPtrRecord | AnySoaRecord | AnySrvRecord | AnyTxtRecord;
|
|
||||||
/**
|
type AnyRecord = AnyARecord |
|
||||||
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
AnyAaaaRecord |
|
||||||
* of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource
|
AnyCnameRecord |
|
||||||
* records. The type and structure of individual results varies based on `rrtype`:
|
AnyMxRecord |
|
||||||
*
|
AnyNaptrRecord |
|
||||||
* <omitted>
|
AnyNsRecord |
|
||||||
*
|
AnyPtrRecord |
|
||||||
* On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`.
|
AnySoaRecord |
|
||||||
* @since v0.1.27
|
AnySrvRecord |
|
||||||
* @param hostname Host name to resolve.
|
AnyTxtRecord;
|
||||||
* @param [rrtype='A'] Resource record type.
|
|
||||||
*/
|
function resolve(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'A', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'AAAA', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
function resolve(hostname: string, rrtype: "ANY", callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'ANY', callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'CNAME', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'MX', callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'NAPTR', callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'NS', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'PTR', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'SOA', callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void): void;
|
function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'SRV', callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
||||||
export function resolve(hostname: string, rrtype: 'TXT', callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
function resolve(
|
||||||
export function resolve(
|
|
||||||
hostname: string,
|
hostname: string,
|
||||||
rrtype: string,
|
rrtype: string,
|
||||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]) => void
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]) => void,
|
||||||
): void;
|
): void;
|
||||||
export namespace resolve {
|
|
||||||
function __promisify__(hostname: string, rrtype?: 'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR'): Promise<string[]>;
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||||
function __promisify__(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
|
namespace resolve {
|
||||||
function __promisify__(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
|
function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
|
||||||
function __promisify__(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
|
function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||||
function __promisify__(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
|
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||||
function __promisify__(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
|
function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||||
function __promisify__(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
|
function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||||
|
function __promisify__(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
||||||
|
function __promisify__(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
||||||
function __promisify__(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
function __promisify__(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
* will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
||||||
* @since v0.1.16
|
function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
||||||
* @param hostname Host name to resolve.
|
|
||||||
*/
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||||
export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
namespace resolve4 {
|
||||||
export function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
|
||||||
export function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
|
||||||
export namespace resolve4 {
|
|
||||||
function __promisify__(hostname: string): Promise<string[]>;
|
function __promisify__(hostname: string): Promise<string[]>;
|
||||||
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||||
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
* will contain an array of IPv6 addresses.
|
function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
||||||
* @since v0.1.16
|
function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
||||||
* @param hostname Host name to resolve.
|
|
||||||
*/
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||||
export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
namespace resolve6 {
|
||||||
export function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
|
||||||
export function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
|
||||||
export namespace resolve6 {
|
|
||||||
function __promisify__(hostname: string): Promise<string[]>;
|
function __promisify__(hostname: string): Promise<string[]>;
|
||||||
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||||
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
* will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
|
namespace resolveCname {
|
||||||
* @since v0.3.2
|
|
||||||
*/
|
|
||||||
export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
|
||||||
export namespace resolveCname {
|
|
||||||
function __promisify__(hostname: string): Promise<string[]>;
|
function __promisify__(hostname: string): Promise<string[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
||||||
* will contain an array of certification authority authorization records
|
namespace resolveMx {
|
||||||
* available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
|
|
||||||
* @since v15.0.0
|
|
||||||
*/
|
|
||||||
export function resolveCaa(hostname: string, callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void): void;
|
|
||||||
export namespace resolveCaa {
|
|
||||||
function __promisify__(hostname: string): Promise<CaaRecord[]>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
|
||||||
* contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
|
||||||
* @since v0.1.27
|
|
||||||
*/
|
|
||||||
export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
|
||||||
export namespace resolveMx {
|
|
||||||
function __promisify__(hostname: string): Promise<MxRecord[]>;
|
function __promisify__(hostname: string): Promise<MxRecord[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of
|
function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
||||||
* objects with the following properties:
|
namespace resolveNaptr {
|
||||||
*
|
|
||||||
* * `flags`
|
|
||||||
* * `service`
|
|
||||||
* * `regexp`
|
|
||||||
* * `replacement`
|
|
||||||
* * `order`
|
|
||||||
* * `preference`
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* {
|
|
||||||
* flags: 's',
|
|
||||||
* service: 'SIP+D2U',
|
|
||||||
* regexp: '',
|
|
||||||
* replacement: '_sip._udp.example.com',
|
|
||||||
* order: 30,
|
|
||||||
* preference: 100
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v0.9.12
|
|
||||||
*/
|
|
||||||
export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
|
||||||
export namespace resolveNaptr {
|
|
||||||
function __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
function __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
* contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
|
namespace resolveNs {
|
||||||
* @since v0.1.90
|
|
||||||
*/
|
|
||||||
export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
|
||||||
export namespace resolveNs {
|
|
||||||
function __promisify__(hostname: string): Promise<string[]>;
|
function __promisify__(hostname: string): Promise<string[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
* be an array of strings containing the reply records.
|
namespace resolvePtr {
|
||||||
* @since v6.0.0
|
|
||||||
*/
|
|
||||||
export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
|
||||||
export namespace resolvePtr {
|
|
||||||
function __promisify__(hostname: string): Promise<string[]>;
|
function __promisify__(hostname: string): Promise<string[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
|
||||||
* the `hostname`. The `address` argument passed to the `callback` function will
|
namespace resolveSoa {
|
||||||
* be an object with the following properties:
|
|
||||||
*
|
|
||||||
* * `nsname`
|
|
||||||
* * `hostmaster`
|
|
||||||
* * `serial`
|
|
||||||
* * `refresh`
|
|
||||||
* * `retry`
|
|
||||||
* * `expire`
|
|
||||||
* * `minttl`
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* {
|
|
||||||
* nsname: 'ns.example.com',
|
|
||||||
* hostmaster: 'root.example.com',
|
|
||||||
* serial: 2013101809,
|
|
||||||
* refresh: 10000,
|
|
||||||
* retry: 2400,
|
|
||||||
* expire: 604800,
|
|
||||||
* minttl: 3600
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v0.11.10
|
|
||||||
*/
|
|
||||||
export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
|
|
||||||
export namespace resolveSoa {
|
|
||||||
function __promisify__(hostname: string): Promise<SoaRecord>;
|
function __promisify__(hostname: string): Promise<SoaRecord>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
||||||
* be an array of objects with the following properties:
|
namespace resolveSrv {
|
||||||
*
|
|
||||||
* * `priority`
|
|
||||||
* * `weight`
|
|
||||||
* * `port`
|
|
||||||
* * `name`
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* {
|
|
||||||
* priority: 10,
|
|
||||||
* weight: 5,
|
|
||||||
* port: 21223,
|
|
||||||
* name: 'service.example.com'
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v0.1.27
|
|
||||||
*/
|
|
||||||
export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
|
||||||
export namespace resolveSrv {
|
|
||||||
function __promisify__(hostname: string): Promise<SrvRecord[]>;
|
function __promisify__(hostname: string): Promise<SrvRecord[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
|
function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
||||||
* two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
namespace resolveTxt {
|
||||||
* one record. Depending on the use case, these could be either joined together or
|
|
||||||
* treated separately.
|
|
||||||
* @since v0.1.27
|
|
||||||
*/
|
|
||||||
export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
|
||||||
export namespace resolveTxt {
|
|
||||||
function __promisify__(hostname: string): Promise<string[][]>;
|
function __promisify__(hostname: string): Promise<string[][]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
||||||
* The `ret` argument passed to the `callback` function will be an array containing
|
namespace resolveAny {
|
||||||
* various types of records. Each object has a property `type` that indicates the
|
|
||||||
* type of the current record. And depending on the `type`, additional properties
|
|
||||||
* will be present on the object:
|
|
||||||
*
|
|
||||||
* <omitted>
|
|
||||||
*
|
|
||||||
* Here is an example of the `ret` object passed to the callback:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
|
||||||
* { type: 'CNAME', value: 'example.com' },
|
|
||||||
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
|
||||||
* { type: 'NS', value: 'ns1.example.com' },
|
|
||||||
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
|
||||||
* { type: 'SOA',
|
|
||||||
* nsname: 'ns1.example.com',
|
|
||||||
* hostmaster: 'admin.example.com',
|
|
||||||
* serial: 156696742,
|
|
||||||
* refresh: 900,
|
|
||||||
* retry: 900,
|
|
||||||
* expire: 1800,
|
|
||||||
* minttl: 60 } ]
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* DNS server operators may choose not to respond to `ANY`queries. It may be better to call individual methods like {@link resolve4},{@link resolveMx}, and so on. For more details, see [RFC
|
|
||||||
* 8482](https://tools.ietf.org/html/rfc8482).
|
|
||||||
*/
|
|
||||||
export function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
|
||||||
export namespace resolveAny {
|
|
||||||
function __promisify__(hostname: string): Promise<AnyRecord[]>;
|
function __promisify__(hostname: string): Promise<AnyRecord[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
|
||||||
* array of host names.
|
function setServers(servers: ReadonlyArray<string>): void;
|
||||||
*
|
function getServers(): string[];
|
||||||
* On error, `err` is an `Error` object, where `err.code` is
|
|
||||||
* one of the `DNS error codes`.
|
|
||||||
* @since v0.1.16
|
|
||||||
*/
|
|
||||||
export function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
|
|
||||||
/**
|
|
||||||
* Sets the IP address and port of servers to be used when performing DNS
|
|
||||||
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
|
||||||
* addresses. If the port is the IANA default DNS port (53) it can be omitted.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* dns.setServers([
|
|
||||||
* '4.4.4.4',
|
|
||||||
* '[2001:4860:4860::8888]',
|
|
||||||
* '4.4.4.4:1053',
|
|
||||||
* '[2001:4860:4860::8888]:1053',
|
|
||||||
* ]);
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* An error will be thrown if an invalid address is provided.
|
|
||||||
*
|
|
||||||
* The `dns.setServers()` method must not be called while a DNS query is in
|
|
||||||
* progress.
|
|
||||||
*
|
|
||||||
* The {@link setServers} method affects only {@link resolve},`dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}).
|
|
||||||
*
|
|
||||||
* This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
|
|
||||||
* That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
|
|
||||||
* subsequent servers provided. Fallback DNS servers will only be used if the
|
|
||||||
* earlier ones time out or result in some other error.
|
|
||||||
* @since v0.11.3
|
|
||||||
* @param servers array of `RFC 5952` formatted addresses
|
|
||||||
*/
|
|
||||||
export function setServers(servers: ReadonlyArray<string>): void;
|
|
||||||
/**
|
|
||||||
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
|
||||||
* that are currently configured for DNS resolution. A string will include a port
|
|
||||||
* section if a custom port is used.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* [
|
|
||||||
* '4.4.4.4',
|
|
||||||
* '2001:4860:4860::8888',
|
|
||||||
* '4.4.4.4:1053',
|
|
||||||
* '[2001:4860:4860::8888]:1053',
|
|
||||||
* ]
|
|
||||||
* ```
|
|
||||||
* @since v0.11.3
|
|
||||||
*/
|
|
||||||
export function getServers(): string[];
|
|
||||||
/**
|
|
||||||
* Set the default value of `verbatim` in {@link lookup}. The value could be:
|
|
||||||
* - `ipv4first`: sets default `verbatim` `false`.
|
|
||||||
* - `verbatim`: sets default `verbatim` `true`.
|
|
||||||
*
|
|
||||||
* The default is `ipv4first` and {@link setDefaultResultOrder} have higher priority than `--dns-result-order`.
|
|
||||||
* When using worker threads, {@link setDefaultResultOrder} from the main thread won't affect the default dns orders in workers.
|
|
||||||
* @since v14.18.0
|
|
||||||
* @param order must be 'ipv4first' or 'verbatim'.
|
|
||||||
*/
|
|
||||||
export function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
|
|
||||||
// Error codes
|
// Error codes
|
||||||
export const NODATA: string;
|
const NODATA: string;
|
||||||
export const FORMERR: string;
|
const FORMERR: string;
|
||||||
export const SERVFAIL: string;
|
const SERVFAIL: string;
|
||||||
export const NOTFOUND: string;
|
const NOTFOUND: string;
|
||||||
export const NOTIMP: string;
|
const NOTIMP: string;
|
||||||
export const REFUSED: string;
|
const REFUSED: string;
|
||||||
export const BADQUERY: string;
|
const BADQUERY: string;
|
||||||
export const BADNAME: string;
|
const BADNAME: string;
|
||||||
export const BADFAMILY: string;
|
const BADFAMILY: string;
|
||||||
export const BADRESP: string;
|
const BADRESP: string;
|
||||||
export const CONNREFUSED: string;
|
const CONNREFUSED: string;
|
||||||
export const TIMEOUT: string;
|
const TIMEOUT: string;
|
||||||
export const EOF: string;
|
const EOF: string;
|
||||||
export const FILE: string;
|
const FILE: string;
|
||||||
export const NOMEM: string;
|
const NOMEM: string;
|
||||||
export const DESTRUCTION: string;
|
const DESTRUCTION: string;
|
||||||
export const BADSTR: string;
|
const BADSTR: string;
|
||||||
export const BADFLAGS: string;
|
const BADFLAGS: string;
|
||||||
export const NONAME: string;
|
const NONAME: string;
|
||||||
export const BADHINTS: string;
|
const BADHINTS: string;
|
||||||
export const NOTINITIALIZED: string;
|
const NOTINITIALIZED: string;
|
||||||
export const LOADIPHLPAPI: string;
|
const LOADIPHLPAPI: string;
|
||||||
export const ADDRGETNETWORKPARAMS: string;
|
const ADDRGETNETWORKPARAMS: string;
|
||||||
export const CANCELLED: string;
|
const CANCELLED: string;
|
||||||
export interface ResolverOptions {
|
|
||||||
timeout?: number | undefined;
|
class Resolver {
|
||||||
/**
|
getServers: typeof getServers;
|
||||||
* @default 4
|
setServers: typeof setServers;
|
||||||
*/
|
resolve: typeof resolve;
|
||||||
tries?: number;
|
resolve4: typeof resolve4;
|
||||||
}
|
resolve6: typeof resolve6;
|
||||||
/**
|
resolveAny: typeof resolveAny;
|
||||||
* An independent resolver for DNS requests.
|
resolveCname: typeof resolveCname;
|
||||||
*
|
resolveMx: typeof resolveMx;
|
||||||
* Creating a new resolver uses the default server settings. Setting
|
resolveNaptr: typeof resolveNaptr;
|
||||||
* the servers used for a resolver using `resolver.setServers()` does not affect
|
resolveNs: typeof resolveNs;
|
||||||
* other resolvers:
|
resolvePtr: typeof resolvePtr;
|
||||||
*
|
resolveSoa: typeof resolveSoa;
|
||||||
* ```js
|
resolveSrv: typeof resolveSrv;
|
||||||
* const { Resolver } = require('dns');
|
resolveTxt: typeof resolveTxt;
|
||||||
* const resolver = new Resolver();
|
reverse: typeof reverse;
|
||||||
* resolver.setServers(['4.4.4.4']);
|
|
||||||
*
|
|
||||||
* // This request will use the server at 4.4.4.4, independent of global settings.
|
|
||||||
* resolver.resolve4('example.org', (err, addresses) => {
|
|
||||||
* // ...
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The following methods from the `dns` module are available:
|
|
||||||
*
|
|
||||||
* * `resolver.getServers()`
|
|
||||||
* * `resolver.resolve()`
|
|
||||||
* * `resolver.resolve4()`
|
|
||||||
* * `resolver.resolve6()`
|
|
||||||
* * `resolver.resolveAny()`
|
|
||||||
* * `resolver.resolveCaa()`
|
|
||||||
* * `resolver.resolveCname()`
|
|
||||||
* * `resolver.resolveMx()`
|
|
||||||
* * `resolver.resolveNaptr()`
|
|
||||||
* * `resolver.resolveNs()`
|
|
||||||
* * `resolver.resolvePtr()`
|
|
||||||
* * `resolver.resolveSoa()`
|
|
||||||
* * `resolver.resolveSrv()`
|
|
||||||
* * `resolver.resolveTxt()`
|
|
||||||
* * `resolver.reverse()`
|
|
||||||
* * `resolver.setServers()`
|
|
||||||
* @since v8.3.0
|
|
||||||
*/
|
|
||||||
export class Resolver {
|
|
||||||
constructor(options?: ResolverOptions);
|
|
||||||
/**
|
|
||||||
* Cancel all outstanding DNS queries made by this resolver. The corresponding
|
|
||||||
* callbacks will be called with an error with code `ECANCELLED`.
|
|
||||||
* @since v8.3.0
|
|
||||||
*/
|
|
||||||
cancel(): void;
|
cancel(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace promises {
|
||||||
|
function getServers(): string[];
|
||||||
|
|
||||||
|
function lookup(hostname: string, family: number): Promise<LookupAddress>;
|
||||||
|
function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;
|
||||||
|
function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
||||||
|
function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
||||||
|
function lookup(hostname: string): Promise<LookupAddress>;
|
||||||
|
|
||||||
|
function lookupService(address: string, port: number): Promise<{ hostname: string, service: string }>;
|
||||||
|
|
||||||
|
function resolve(hostname: string): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||||
|
function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
||||||
|
function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
||||||
|
function resolve(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
||||||
|
|
||||||
|
function resolve4(hostname: string): Promise<string[]>;
|
||||||
|
function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||||
|
function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||||
|
|
||||||
|
function resolve6(hostname: string): Promise<string[]>;
|
||||||
|
function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||||
|
function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||||
|
|
||||||
|
function resolveAny(hostname: string): Promise<AnyRecord[]>;
|
||||||
|
|
||||||
|
function resolveCname(hostname: string): Promise<string[]>;
|
||||||
|
|
||||||
|
function resolveMx(hostname: string): Promise<MxRecord[]>;
|
||||||
|
|
||||||
|
function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
|
||||||
|
|
||||||
|
function resolveNs(hostname: string): Promise<string[]>;
|
||||||
|
|
||||||
|
function resolvePtr(hostname: string): Promise<string[]>;
|
||||||
|
|
||||||
|
function resolveSoa(hostname: string): Promise<SoaRecord>;
|
||||||
|
|
||||||
|
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
||||||
|
|
||||||
|
function resolveTxt(hostname: string): Promise<string[][]>;
|
||||||
|
|
||||||
|
function reverse(ip: string): Promise<string[]>;
|
||||||
|
|
||||||
|
function setServers(servers: ReadonlyArray<string>): void;
|
||||||
|
|
||||||
|
class Resolver {
|
||||||
getServers: typeof getServers;
|
getServers: typeof getServers;
|
||||||
resolve: typeof resolve;
|
resolve: typeof resolve;
|
||||||
resolve4: typeof resolve4;
|
resolve4: typeof resolve4;
|
||||||
@@ -629,26 +360,7 @@ declare module 'dns' {
|
|||||||
resolveSrv: typeof resolveSrv;
|
resolveSrv: typeof resolveSrv;
|
||||||
resolveTxt: typeof resolveTxt;
|
resolveTxt: typeof resolveTxt;
|
||||||
reverse: typeof reverse;
|
reverse: typeof reverse;
|
||||||
/**
|
|
||||||
* The resolver instance will send its requests from the specified IP address.
|
|
||||||
* This allows programs to specify outbound interfaces when used on multi-homed
|
|
||||||
* systems.
|
|
||||||
*
|
|
||||||
* If a v4 or v6 address is not specified, it is set to the default, and the
|
|
||||||
* operating system will choose a local address automatically.
|
|
||||||
*
|
|
||||||
* The resolver will use the v4 local address when making requests to IPv4 DNS
|
|
||||||
* servers, and the v6 local address when making requests to IPv6 DNS servers.
|
|
||||||
* The `rrtype` of resolution requests has no impact on the local address used.
|
|
||||||
* @since v15.1.0
|
|
||||||
* @param [ipv4='0.0.0.0'] A string representation of an IPv4 address.
|
|
||||||
* @param [ipv6='::0'] A string representation of an IPv6 address.
|
|
||||||
*/
|
|
||||||
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
|
||||||
setServers: typeof setServers;
|
setServers: typeof setServers;
|
||||||
}
|
}
|
||||||
export { dnsPromises as promises };
|
}
|
||||||
}
|
|
||||||
declare module 'node:dns' {
|
|
||||||
export * from 'dns';
|
|
||||||
}
|
}
|
||||||
|
|||||||
368
node_modules/@types/node/dns/promises.d.ts
generated
vendored
368
node_modules/@types/node/dns/promises.d.ts
generated
vendored
@@ -1,368 +0,0 @@
|
|||||||
/**
|
|
||||||
* The `dns.promises` API provides an alternative set of asynchronous DNS methods
|
|
||||||
* that return `Promise` objects rather than using callbacks. The API is accessible
|
|
||||||
* via `require('dns').promises` or `require('dns/promises')`.
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
declare module 'dns/promises' {
|
|
||||||
import {
|
|
||||||
LookupAddress,
|
|
||||||
LookupOneOptions,
|
|
||||||
LookupAllOptions,
|
|
||||||
LookupOptions,
|
|
||||||
AnyRecord,
|
|
||||||
CaaRecord,
|
|
||||||
MxRecord,
|
|
||||||
NaptrRecord,
|
|
||||||
SoaRecord,
|
|
||||||
SrvRecord,
|
|
||||||
ResolveWithTtlOptions,
|
|
||||||
RecordWithTtl,
|
|
||||||
ResolveOptions,
|
|
||||||
ResolverOptions,
|
|
||||||
} from 'node:dns';
|
|
||||||
/**
|
|
||||||
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
|
||||||
* that are currently configured for DNS resolution. A string will include a port
|
|
||||||
* section if a custom port is used.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* [
|
|
||||||
* '4.4.4.4',
|
|
||||||
* '2001:4860:4860::8888',
|
|
||||||
* '4.4.4.4:1053',
|
|
||||||
* '[2001:4860:4860::8888]:1053',
|
|
||||||
* ]
|
|
||||||
* ```
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function getServers(): string[];
|
|
||||||
/**
|
|
||||||
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
|
||||||
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
|
||||||
* integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
|
|
||||||
* and IPv6 addresses are both returned if found.
|
|
||||||
*
|
|
||||||
* With the `all` option set to `true`, the `Promise` is resolved with `addresses`being an array of objects with the properties `address` and `family`.
|
|
||||||
*
|
|
||||||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
|
|
||||||
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
|
||||||
* the host name does not exist but also when the lookup fails in other ways
|
|
||||||
* such as no available file descriptors.
|
|
||||||
*
|
|
||||||
* `dnsPromises.lookup()` does not necessarily have anything to do with the DNS
|
|
||||||
* protocol. The implementation uses an operating system facility that can
|
|
||||||
* associate names with addresses, and vice versa. This implementation can have
|
|
||||||
* subtle but important consequences on the behavior of any Node.js program. Please
|
|
||||||
* take some time to consult the `Implementation considerations section` before
|
|
||||||
* using `dnsPromises.lookup()`.
|
|
||||||
*
|
|
||||||
* Example usage:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const dns = require('dns');
|
|
||||||
* const dnsPromises = dns.promises;
|
|
||||||
* const options = {
|
|
||||||
* family: 6,
|
|
||||||
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* dnsPromises.lookup('example.com', options).then((result) => {
|
|
||||||
* console.log('address: %j family: IPv%s', result.address, result.family);
|
|
||||||
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* // When options.all is true, the result will be an Array.
|
|
||||||
* options.all = true;
|
|
||||||
* dnsPromises.lookup('example.com', options).then((result) => {
|
|
||||||
* console.log('addresses: %j', result);
|
|
||||||
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function lookup(hostname: string, family: number): Promise<LookupAddress>;
|
|
||||||
function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;
|
|
||||||
function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
|
||||||
function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
|
||||||
function lookup(hostname: string): Promise<LookupAddress>;
|
|
||||||
/**
|
|
||||||
* Resolves the given `address` and `port` into a host name and service using
|
|
||||||
* the operating system's underlying `getnameinfo` implementation.
|
|
||||||
*
|
|
||||||
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
|
||||||
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
|
|
||||||
*
|
|
||||||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const dnsPromises = require('dns').promises;
|
|
||||||
* dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
|
|
||||||
* console.log(result.hostname, result.service);
|
|
||||||
* // Prints: localhost ssh
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function lookupService(
|
|
||||||
address: string,
|
|
||||||
port: number
|
|
||||||
): Promise<{
|
|
||||||
hostname: string;
|
|
||||||
service: string;
|
|
||||||
}>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
|
||||||
* of the resource records. When successful, the `Promise` is resolved with an
|
|
||||||
* array of resource records. The type and structure of individual results vary
|
|
||||||
* based on `rrtype`:
|
|
||||||
*
|
|
||||||
* <omitted>
|
|
||||||
*
|
|
||||||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
|
|
||||||
* @since v10.6.0
|
|
||||||
* @param hostname Host name to resolve.
|
|
||||||
* @param [rrtype='A'] Resource record type.
|
|
||||||
*/
|
|
||||||
function resolve(hostname: string): Promise<string[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'A'): Promise<string[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'AAAA'): Promise<string[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'CAA'): Promise<CaaRecord[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'CNAME'): Promise<string[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'NS'): Promise<string[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'PTR'): Promise<string[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
|
|
||||||
function resolve(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
|
|
||||||
function resolve(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
|
|
||||||
function resolve(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv4
|
|
||||||
* addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
|
||||||
* @since v10.6.0
|
|
||||||
* @param hostname Host name to resolve.
|
|
||||||
*/
|
|
||||||
function resolve4(hostname: string): Promise<string[]>;
|
|
||||||
function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
|
||||||
function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv6
|
|
||||||
* addresses.
|
|
||||||
* @since v10.6.0
|
|
||||||
* @param hostname Host name to resolve.
|
|
||||||
*/
|
|
||||||
function resolve6(hostname: string): Promise<string[]>;
|
|
||||||
function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
|
||||||
function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
|
||||||
* On success, the `Promise` is resolved with an array containing various types of
|
|
||||||
* records. Each object has a property `type` that indicates the type of the
|
|
||||||
* current record. And depending on the `type`, additional properties will be
|
|
||||||
* present on the object:
|
|
||||||
*
|
|
||||||
* <omitted>
|
|
||||||
*
|
|
||||||
* Here is an example of the result object:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
|
||||||
* { type: 'CNAME', value: 'example.com' },
|
|
||||||
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
|
||||||
* { type: 'NS', value: 'ns1.example.com' },
|
|
||||||
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
|
||||||
* { type: 'SOA',
|
|
||||||
* nsname: 'ns1.example.com',
|
|
||||||
* hostmaster: 'admin.example.com',
|
|
||||||
* serial: 156696742,
|
|
||||||
* refresh: 900,
|
|
||||||
* retry: 900,
|
|
||||||
* expire: 1800,
|
|
||||||
* minttl: 60 } ]
|
|
||||||
* ```
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function resolveAny(hostname: string): Promise<AnyRecord[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,
|
|
||||||
* the `Promise` is resolved with an array of objects containing available
|
|
||||||
* certification authority authorization records available for the `hostname`(e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).
|
|
||||||
* @since v15.0.0
|
|
||||||
*/
|
|
||||||
function resolveCaa(hostname: string): Promise<CaaRecord[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,
|
|
||||||
* the `Promise` is resolved with an array of canonical name records available for
|
|
||||||
* the `hostname` (e.g. `['bar.example.com']`).
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function resolveCname(hostname: string): Promise<string[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects
|
|
||||||
* containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function resolveMx(hostname: string): Promise<MxRecord[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array
|
|
||||||
* of objects with the following properties:
|
|
||||||
*
|
|
||||||
* * `flags`
|
|
||||||
* * `service`
|
|
||||||
* * `regexp`
|
|
||||||
* * `replacement`
|
|
||||||
* * `order`
|
|
||||||
* * `preference`
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* {
|
|
||||||
* flags: 's',
|
|
||||||
* service: 'SIP+D2U',
|
|
||||||
* regexp: '',
|
|
||||||
* replacement: '_sip._udp.example.com',
|
|
||||||
* order: 30,
|
|
||||||
* preference: 100
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. On success, the `Promise` is resolved with an array of name server
|
|
||||||
* records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function resolveNs(hostname: string): Promise<string[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. On success, the `Promise` is resolved with an array of strings
|
|
||||||
* containing the reply records.
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function resolvePtr(hostname: string): Promise<string[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
|
||||||
* the `hostname`. On success, the `Promise` is resolved with an object with the
|
|
||||||
* following properties:
|
|
||||||
*
|
|
||||||
* * `nsname`
|
|
||||||
* * `hostmaster`
|
|
||||||
* * `serial`
|
|
||||||
* * `refresh`
|
|
||||||
* * `retry`
|
|
||||||
* * `expire`
|
|
||||||
* * `minttl`
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* {
|
|
||||||
* nsname: 'ns.example.com',
|
|
||||||
* hostmaster: 'root.example.com',
|
|
||||||
* serial: 2013101809,
|
|
||||||
* refresh: 10000,
|
|
||||||
* retry: 2400,
|
|
||||||
* expire: 604800,
|
|
||||||
* minttl: 3600
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function resolveSoa(hostname: string): Promise<SoaRecord>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects with
|
|
||||||
* the following properties:
|
|
||||||
*
|
|
||||||
* * `priority`
|
|
||||||
* * `weight`
|
|
||||||
* * `port`
|
|
||||||
* * `name`
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* {
|
|
||||||
* priority: 10,
|
|
||||||
* weight: 5,
|
|
||||||
* port: 21223,
|
|
||||||
* name: 'service.example.com'
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. On success, the `Promise` is resolved with a two-dimensional array
|
|
||||||
* of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
|
||||||
* one record. Depending on the use case, these could be either joined together or
|
|
||||||
* treated separately.
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function resolveTxt(hostname: string): Promise<string[][]>;
|
|
||||||
/**
|
|
||||||
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
|
||||||
* array of host names.
|
|
||||||
*
|
|
||||||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
|
|
||||||
* @since v10.6.0
|
|
||||||
*/
|
|
||||||
function reverse(ip: string): Promise<string[]>;
|
|
||||||
/**
|
|
||||||
* Sets the IP address and port of servers to be used when performing DNS
|
|
||||||
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
|
||||||
* addresses. If the port is the IANA default DNS port (53) it can be omitted.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* dnsPromises.setServers([
|
|
||||||
* '4.4.4.4',
|
|
||||||
* '[2001:4860:4860::8888]',
|
|
||||||
* '4.4.4.4:1053',
|
|
||||||
* '[2001:4860:4860::8888]:1053',
|
|
||||||
* ]);
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* An error will be thrown if an invalid address is provided.
|
|
||||||
*
|
|
||||||
* The `dnsPromises.setServers()` method must not be called while a DNS query is in
|
|
||||||
* progress.
|
|
||||||
*
|
|
||||||
* This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
|
|
||||||
* That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
|
|
||||||
* subsequent servers provided. Fallback DNS servers will only be used if the
|
|
||||||
* earlier ones time out or result in some other error.
|
|
||||||
* @since v10.6.0
|
|
||||||
* @param servers array of `RFC 5952` formatted addresses
|
|
||||||
*/
|
|
||||||
function setServers(servers: ReadonlyArray<string>): void;
|
|
||||||
/**
|
|
||||||
* Set the default value of `verbatim` in {@link lookup}. The value could be:
|
|
||||||
* - `ipv4first`: sets default `verbatim` `false`.
|
|
||||||
* - `verbatim`: sets default `verbatim` `true`.
|
|
||||||
*
|
|
||||||
* The default is `ipv4first` and {@link setDefaultResultOrder} have higher priority than `--dns-result-order`.
|
|
||||||
* When using worker threads, {@link setDefaultResultOrder} from the main thread won't affect the default dns orders in workers.
|
|
||||||
* @since v14.18.0
|
|
||||||
* @param order must be 'ipv4first' or 'verbatim'.
|
|
||||||
*/
|
|
||||||
function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
|
|
||||||
class Resolver {
|
|
||||||
constructor(options?: ResolverOptions);
|
|
||||||
cancel(): void;
|
|
||||||
getServers: typeof getServers;
|
|
||||||
resolve: typeof resolve;
|
|
||||||
resolve4: typeof resolve4;
|
|
||||||
resolve6: typeof resolve6;
|
|
||||||
resolveAny: typeof resolveAny;
|
|
||||||
resolveCname: typeof resolveCname;
|
|
||||||
resolveMx: typeof resolveMx;
|
|
||||||
resolveNaptr: typeof resolveNaptr;
|
|
||||||
resolveNs: typeof resolveNs;
|
|
||||||
resolvePtr: typeof resolvePtr;
|
|
||||||
resolveSoa: typeof resolveSoa;
|
|
||||||
resolveSrv: typeof resolveSrv;
|
|
||||||
resolveTxt: typeof resolveTxt;
|
|
||||||
reverse: typeof reverse;
|
|
||||||
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
|
||||||
setServers: typeof setServers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
declare module 'node:dns/promises' {
|
|
||||||
export * from 'dns/promises';
|
|
||||||
}
|
|
||||||
177
node_modules/@types/node/domain.d.ts
generated
vendored
Executable file → Normal file
177
node_modules/@types/node/domain.d.ts
generated
vendored
Executable file → Normal file
@@ -1,169 +1,16 @@
|
|||||||
/**
|
declare module "domain" {
|
||||||
* **This module is pending deprecation.** Once a replacement API has been
|
import * as events from "events";
|
||||||
* finalized, this module will be fully deprecated. Most developers should**not** have cause to use this module. Users who absolutely must have
|
|
||||||
* the functionality that domains provide may rely on it for the time being
|
class Domain extends events.EventEmitter implements NodeJS.Domain {
|
||||||
* but should expect to have to migrate to a different solution
|
|
||||||
* in the future.
|
|
||||||
*
|
|
||||||
* Domains provide a way to handle multiple different IO operations as a
|
|
||||||
* single group. If any of the event emitters or callbacks registered to a
|
|
||||||
* domain emit an `'error'` event, or throw an error, then the domain object
|
|
||||||
* will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to
|
|
||||||
* exit immediately with an error code.
|
|
||||||
* @deprecated Since v1.4.2 - Deprecated
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/domain.js)
|
|
||||||
*/
|
|
||||||
declare module 'domain' {
|
|
||||||
import EventEmitter = require('node:events');
|
|
||||||
/**
|
|
||||||
* The `Domain` class encapsulates the functionality of routing errors and
|
|
||||||
* uncaught exceptions to the active `Domain` object.
|
|
||||||
*
|
|
||||||
* To handle the errors that it catches, listen to its `'error'` event.
|
|
||||||
*/
|
|
||||||
class Domain extends EventEmitter {
|
|
||||||
/**
|
|
||||||
* An array of timers and event emitters that have been explicitly added
|
|
||||||
* to the domain.
|
|
||||||
*/
|
|
||||||
members: Array<EventEmitter | NodeJS.Timer>;
|
|
||||||
/**
|
|
||||||
* The `enter()` method is plumbing used by the `run()`, `bind()`, and`intercept()` methods to set the active domain. It sets `domain.active` and`process.domain` to the domain, and implicitly
|
|
||||||
* pushes the domain onto the domain
|
|
||||||
* stack managed by the domain module (see {@link exit} for details on the
|
|
||||||
* domain stack). The call to `enter()` delimits the beginning of a chain of
|
|
||||||
* asynchronous calls and I/O operations bound to a domain.
|
|
||||||
*
|
|
||||||
* Calling `enter()` changes only the active domain, and does not alter the domain
|
|
||||||
* itself. `enter()` and `exit()` can be called an arbitrary number of times on a
|
|
||||||
* single domain.
|
|
||||||
*/
|
|
||||||
enter(): void;
|
|
||||||
/**
|
|
||||||
* The `exit()` method exits the current domain, popping it off the domain stack.
|
|
||||||
* Any time execution is going to switch to the context of a different chain of
|
|
||||||
* asynchronous calls, it's important to ensure that the current domain is exited.
|
|
||||||
* The call to `exit()` delimits either the end of or an interruption to the chain
|
|
||||||
* of asynchronous calls and I/O operations bound to a domain.
|
|
||||||
*
|
|
||||||
* If there are multiple, nested domains bound to the current execution context,`exit()` will exit any domains nested within this domain.
|
|
||||||
*
|
|
||||||
* Calling `exit()` changes only the active domain, and does not alter the domain
|
|
||||||
* itself. `enter()` and `exit()` can be called an arbitrary number of times on a
|
|
||||||
* single domain.
|
|
||||||
*/
|
|
||||||
exit(): void;
|
|
||||||
/**
|
|
||||||
* Run the supplied function in the context of the domain, implicitly
|
|
||||||
* binding all event emitters, timers, and lowlevel requests that are
|
|
||||||
* created in that context. Optionally, arguments can be passed to
|
|
||||||
* the function.
|
|
||||||
*
|
|
||||||
* This is the most basic way to use a domain.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const domain = require('domain');
|
|
||||||
* const fs = require('fs');
|
|
||||||
* const d = domain.create();
|
|
||||||
* d.on('error', (er) => {
|
|
||||||
* console.error('Caught error!', er);
|
|
||||||
* });
|
|
||||||
* d.run(() => {
|
|
||||||
* process.nextTick(() => {
|
|
||||||
* setTimeout(() => { // Simulating some various async stuff
|
|
||||||
* fs.open('non-existent file', 'r', (er, fd) => {
|
|
||||||
* if (er) throw er;
|
|
||||||
* // proceed...
|
|
||||||
* });
|
|
||||||
* }, 100);
|
|
||||||
* });
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* In this example, the `d.on('error')` handler will be triggered, rather
|
|
||||||
* than crashing the program.
|
|
||||||
*/
|
|
||||||
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
|
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
|
||||||
/**
|
add(emitter: events.EventEmitter | NodeJS.Timer): void;
|
||||||
* Explicitly adds an emitter to the domain. If any event handlers called by
|
remove(emitter: events.EventEmitter | NodeJS.Timer): void;
|
||||||
* the emitter throw an error, or if the emitter emits an `'error'` event, it
|
bind<T extends Function>(cb: T): T;
|
||||||
* will be routed to the domain's `'error'` event, just like with implicit
|
intercept<T extends Function>(cb: T): T;
|
||||||
* binding.
|
members: Array<events.EventEmitter | NodeJS.Timer>;
|
||||||
*
|
enter(): void;
|
||||||
* This also works with timers that are returned from `setInterval()` and `setTimeout()`. If their callback function throws, it will be caught by
|
exit(): void;
|
||||||
* the domain `'error'` handler.
|
|
||||||
*
|
|
||||||
* If the Timer or `EventEmitter` was already bound to a domain, it is removed
|
|
||||||
* from that one, and bound to this one instead.
|
|
||||||
* @param emitter emitter or timer to be added to the domain
|
|
||||||
*/
|
|
||||||
add(emitter: EventEmitter | NodeJS.Timer): void;
|
|
||||||
/**
|
|
||||||
* The opposite of {@link add}. Removes domain handling from the
|
|
||||||
* specified emitter.
|
|
||||||
* @param emitter emitter or timer to be removed from the domain
|
|
||||||
*/
|
|
||||||
remove(emitter: EventEmitter | NodeJS.Timer): void;
|
|
||||||
/**
|
|
||||||
* The returned function will be a wrapper around the supplied callback
|
|
||||||
* function. When the returned function is called, any errors that are
|
|
||||||
* thrown will be routed to the domain's `'error'` event.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const d = domain.create();
|
|
||||||
*
|
|
||||||
* function readSomeFile(filename, cb) {
|
|
||||||
* fs.readFile(filename, 'utf8', d.bind((er, data) => {
|
|
||||||
* // If this throws, it will also be passed to the domain.
|
|
||||||
* return cb(er, data ? JSON.parse(data) : null);
|
|
||||||
* }));
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* d.on('error', (er) => {
|
|
||||||
* // An error occurred somewhere. If we throw it now, it will crash the program
|
|
||||||
* // with the normal line number and stack message.
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @param callback The callback function
|
|
||||||
* @return The bound function
|
|
||||||
*/
|
|
||||||
bind<T extends Function>(callback: T): T;
|
|
||||||
/**
|
|
||||||
* This method is almost identical to {@link bind}. However, in
|
|
||||||
* addition to catching thrown errors, it will also intercept `Error` objects sent as the first argument to the function.
|
|
||||||
*
|
|
||||||
* In this way, the common `if (err) return callback(err);` pattern can be replaced
|
|
||||||
* with a single error handler in a single place.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const d = domain.create();
|
|
||||||
*
|
|
||||||
* function readSomeFile(filename, cb) {
|
|
||||||
* fs.readFile(filename, 'utf8', d.intercept((data) => {
|
|
||||||
* // Note, the first argument is never passed to the
|
|
||||||
* // callback since it is assumed to be the 'Error' argument
|
|
||||||
* // and thus intercepted by the domain.
|
|
||||||
*
|
|
||||||
* // If this throws, it will also be passed to the domain
|
|
||||||
* // so the error-handling logic can be moved to the 'error'
|
|
||||||
* // event on the domain instead of being repeated throughout
|
|
||||||
* // the program.
|
|
||||||
* return cb(null, JSON.parse(data));
|
|
||||||
* }));
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* d.on('error', (er) => {
|
|
||||||
* // An error occurred somewhere. If we throw it now, it will crash the program
|
|
||||||
* // with the normal line number and stack message.
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @param callback The callback function
|
|
||||||
* @return The intercepted function
|
|
||||||
*/
|
|
||||||
intercept<T extends Function>(callback: T): T;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function create(): Domain;
|
function create(): Domain;
|
||||||
}
|
}
|
||||||
declare module 'node:domain' {
|
|
||||||
export * from 'domain';
|
|
||||||
}
|
|
||||||
|
|||||||
632
node_modules/@types/node/events.d.ts
generated
vendored
Executable file → Normal file
632
node_modules/@types/node/events.d.ts
generated
vendored
Executable file → Normal file
@@ -1,265 +1,18 @@
|
|||||||
/**
|
declare module "events" {
|
||||||
* Much of the Node.js core API is built around an idiomatic asynchronous
|
class internal extends NodeJS.EventEmitter { }
|
||||||
* event-driven architecture in which certain kinds of objects (called "emitters")
|
|
||||||
* emit named events that cause `Function` objects ("listeners") to be called.
|
|
||||||
*
|
|
||||||
* For instance: a `net.Server` object emits an event each time a peer
|
|
||||||
* connects to it; a `fs.ReadStream` emits an event when the file is opened;
|
|
||||||
* a `stream` emits an event whenever data is available to be read.
|
|
||||||
*
|
|
||||||
* All objects that emit events are instances of the `EventEmitter` class. These
|
|
||||||
* objects expose an `eventEmitter.on()` function that allows one or more
|
|
||||||
* functions to be attached to named events emitted by the object. Typically,
|
|
||||||
* event names are camel-cased strings but any valid JavaScript property key
|
|
||||||
* can be used.
|
|
||||||
*
|
|
||||||
* When the `EventEmitter` object emits an event, all of the functions attached
|
|
||||||
* to that specific event are called _synchronously_. Any values returned by the
|
|
||||||
* called listeners are _ignored_ and discarded.
|
|
||||||
*
|
|
||||||
* The following example shows a simple `EventEmitter` instance with a single
|
|
||||||
* listener. The `eventEmitter.on()` method is used to register listeners, while
|
|
||||||
* the `eventEmitter.emit()` method is used to trigger the event.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const EventEmitter = require('events');
|
|
||||||
*
|
|
||||||
* class MyEmitter extends EventEmitter {}
|
|
||||||
*
|
|
||||||
* const myEmitter = new MyEmitter();
|
|
||||||
* myEmitter.on('event', () => {
|
|
||||||
* console.log('an event occurred!');
|
|
||||||
* });
|
|
||||||
* myEmitter.emit('event');
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/events.js)
|
|
||||||
*/
|
|
||||||
declare module 'events' {
|
|
||||||
interface EventEmitterOptions {
|
|
||||||
/**
|
|
||||||
* Enables automatic capturing of promise rejection.
|
|
||||||
*/
|
|
||||||
captureRejections?: boolean | undefined;
|
|
||||||
}
|
|
||||||
interface NodeEventTarget {
|
interface NodeEventTarget {
|
||||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DOMEventTarget {
|
interface DOMEventTarget {
|
||||||
addEventListener(
|
addEventListener(event: string, listener: (...args: any[]) => void, opts?: { once: boolean }): any;
|
||||||
eventName: string,
|
|
||||||
listener: (...args: any[]) => void,
|
|
||||||
opts?: {
|
|
||||||
once: boolean;
|
|
||||||
}
|
}
|
||||||
): any;
|
|
||||||
}
|
namespace internal {
|
||||||
interface StaticEventEmitterOptions {
|
function once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>;
|
||||||
signal?: AbortSignal | undefined;
|
function once(emitter: DOMEventTarget, event: string): Promise<any[]>;
|
||||||
}
|
|
||||||
interface EventEmitter extends NodeJS.EventEmitter {}
|
|
||||||
/**
|
|
||||||
* The `EventEmitter` class is defined and exposed by the `events` module:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const EventEmitter = require('events');
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* All `EventEmitter`s emit the event `'newListener'` when new listeners are
|
|
||||||
* added and `'removeListener'` when existing listeners are removed.
|
|
||||||
*
|
|
||||||
* It supports the following option:
|
|
||||||
* @since v0.1.26
|
|
||||||
*/
|
|
||||||
class EventEmitter {
|
|
||||||
constructor(options?: EventEmitterOptions);
|
|
||||||
/**
|
|
||||||
* Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
|
|
||||||
* event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
|
|
||||||
* The `Promise` will resolve with an array of all the arguments emitted to the
|
|
||||||
* given event.
|
|
||||||
*
|
|
||||||
* This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
|
|
||||||
* semantics and does not listen to the `'error'` event.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { once, EventEmitter } = require('events');
|
|
||||||
*
|
|
||||||
* async function run() {
|
|
||||||
* const ee = new EventEmitter();
|
|
||||||
*
|
|
||||||
* process.nextTick(() => {
|
|
||||||
* ee.emit('myevent', 42);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* const [value] = await once(ee, 'myevent');
|
|
||||||
* console.log(value);
|
|
||||||
*
|
|
||||||
* const err = new Error('kaboom');
|
|
||||||
* process.nextTick(() => {
|
|
||||||
* ee.emit('error', err);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* try {
|
|
||||||
* await once(ee, 'myevent');
|
|
||||||
* } catch (err) {
|
|
||||||
* console.log('error happened', err);
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* run();
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the
|
|
||||||
* '`error'` event itself, then it is treated as any other kind of event without
|
|
||||||
* special handling:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { EventEmitter, once } = require('events');
|
|
||||||
*
|
|
||||||
* const ee = new EventEmitter();
|
|
||||||
*
|
|
||||||
* once(ee, 'error')
|
|
||||||
* .then(([err]) => console.log('ok', err.message))
|
|
||||||
* .catch((err) => console.log('error', err.message));
|
|
||||||
*
|
|
||||||
* ee.emit('error', new Error('boom'));
|
|
||||||
*
|
|
||||||
* // Prints: ok boom
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* An `AbortSignal` can be used to cancel waiting for the event:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { EventEmitter, once } = require('events');
|
|
||||||
*
|
|
||||||
* const ee = new EventEmitter();
|
|
||||||
* const ac = new AbortController();
|
|
||||||
*
|
|
||||||
* async function foo(emitter, event, signal) {
|
|
||||||
* try {
|
|
||||||
* await once(emitter, event, { signal });
|
|
||||||
* console.log('event emitted!');
|
|
||||||
* } catch (error) {
|
|
||||||
* if (error.name === 'AbortError') {
|
|
||||||
* console.error('Waiting for the event was canceled!');
|
|
||||||
* } else {
|
|
||||||
* console.error('There was an error', error.message);
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* foo(ee, 'foo', ac.signal);
|
|
||||||
* ac.abort(); // Abort waiting for the event
|
|
||||||
* ee.emit('foo'); // Prints: Waiting for the event was canceled!
|
|
||||||
* ```
|
|
||||||
* @since v11.13.0, v10.16.0
|
|
||||||
*/
|
|
||||||
static once(emitter: NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
|
|
||||||
static once(emitter: DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
|
||||||
/**
|
|
||||||
* ```js
|
|
||||||
* const { on, EventEmitter } = require('events');
|
|
||||||
*
|
|
||||||
* (async () => {
|
|
||||||
* const ee = new EventEmitter();
|
|
||||||
*
|
|
||||||
* // Emit later on
|
|
||||||
* process.nextTick(() => {
|
|
||||||
* ee.emit('foo', 'bar');
|
|
||||||
* ee.emit('foo', 42);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* for await (const event of on(ee, 'foo')) {
|
|
||||||
* // The execution of this inner block is synchronous and it
|
|
||||||
* // processes one event at a time (even with await). Do not use
|
|
||||||
* // if concurrent execution is required.
|
|
||||||
* console.log(event); // prints ['bar'] [42]
|
|
||||||
* }
|
|
||||||
* // Unreachable here
|
|
||||||
* })();
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Returns an `AsyncIterator` that iterates `eventName` events. It will throw
|
|
||||||
* if the `EventEmitter` emits `'error'`. It removes all listeners when
|
|
||||||
* exiting the loop. The `value` returned by each iteration is an array
|
|
||||||
* composed of the emitted event arguments.
|
|
||||||
*
|
|
||||||
* An `AbortSignal` can be used to cancel waiting on events:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { on, EventEmitter } = require('events');
|
|
||||||
* const ac = new AbortController();
|
|
||||||
*
|
|
||||||
* (async () => {
|
|
||||||
* const ee = new EventEmitter();
|
|
||||||
*
|
|
||||||
* // Emit later on
|
|
||||||
* process.nextTick(() => {
|
|
||||||
* ee.emit('foo', 'bar');
|
|
||||||
* ee.emit('foo', 42);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* for await (const event of on(ee, 'foo', { signal: ac.signal })) {
|
|
||||||
* // The execution of this inner block is synchronous and it
|
|
||||||
* // processes one event at a time (even with await). Do not use
|
|
||||||
* // if concurrent execution is required.
|
|
||||||
* console.log(event); // prints ['bar'] [42]
|
|
||||||
* }
|
|
||||||
* // Unreachable here
|
|
||||||
* })();
|
|
||||||
*
|
|
||||||
* process.nextTick(() => ac.abort());
|
|
||||||
* ```
|
|
||||||
* @since v13.6.0, v12.16.0
|
|
||||||
* @param eventName The name of the event being listened for
|
|
||||||
* @return that iterates `eventName` events emitted by the `emitter`
|
|
||||||
*/
|
|
||||||
static on(emitter: NodeJS.EventEmitter, eventName: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>;
|
|
||||||
/**
|
|
||||||
* A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { EventEmitter, listenerCount } = require('events');
|
|
||||||
* const myEmitter = new EventEmitter();
|
|
||||||
* myEmitter.on('event', () => {});
|
|
||||||
* myEmitter.on('event', () => {});
|
|
||||||
* console.log(listenerCount(myEmitter, 'event'));
|
|
||||||
* // Prints: 2
|
|
||||||
* ```
|
|
||||||
* @since v0.9.12
|
|
||||||
* @deprecated Since v3.2.0 - Use `listenerCount` instead.
|
|
||||||
* @param emitter The emitter to query
|
|
||||||
* @param eventName The event name
|
|
||||||
*/
|
|
||||||
static listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number;
|
|
||||||
/**
|
|
||||||
* Returns a copy of the array of listeners for the event named `eventName`.
|
|
||||||
*
|
|
||||||
* For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
|
|
||||||
* the emitter.
|
|
||||||
*
|
|
||||||
* For `EventTarget`s this is the only way to get the event listeners for the
|
|
||||||
* event target. This is useful for debugging and diagnostic purposes.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { getEventListeners, EventEmitter } = require('events');
|
|
||||||
*
|
|
||||||
* {
|
|
||||||
* const ee = new EventEmitter();
|
|
||||||
* const listener = () => console.log('Events are fun');
|
|
||||||
* ee.on('foo', listener);
|
|
||||||
* getEventListeners(ee, 'foo'); // [listener]
|
|
||||||
* }
|
|
||||||
* {
|
|
||||||
* const et = new EventTarget();
|
|
||||||
* const listener = () => console.log('Events are fun');
|
|
||||||
* et.addEventListener('foo', listener);
|
|
||||||
* getEventListeners(et, 'foo'); // [listener]
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v15.2.0
|
|
||||||
*/
|
|
||||||
static getEventListeners(emitter: DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
|
||||||
/**
|
/**
|
||||||
* This symbol shall be used to install a listener for only monitoring `'error'`
|
* This symbol shall be used to install a listener for only monitoring `'error'`
|
||||||
* events. Listeners installed using this symbol are called before the regular
|
* events. Listeners installed using this symbol are called before the regular
|
||||||
@@ -269,355 +22,30 @@ declare module 'events' {
|
|||||||
* `'error'` event is emitted, therefore the process will still crash if no
|
* `'error'` event is emitted, therefore the process will still crash if no
|
||||||
* regular `'error'` listener is installed.
|
* regular `'error'` listener is installed.
|
||||||
*/
|
*/
|
||||||
static readonly errorMonitor: unique symbol;
|
const errorMonitor: unique symbol;
|
||||||
static readonly captureRejectionSymbol: unique symbol;
|
|
||||||
/**
|
class EventEmitter extends internal {
|
||||||
* Sets or gets the default captureRejection value for all emitters.
|
/** @deprecated since v4.0.0 */
|
||||||
*/
|
static listenerCount(emitter: EventEmitter, event: string | symbol): number;
|
||||||
// TODO: These should be described using static getter/setter pairs:
|
|
||||||
static captureRejections: boolean;
|
|
||||||
static defaultMaxListeners: number;
|
static defaultMaxListeners: number;
|
||||||
}
|
|
||||||
import internal = require('node:events');
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
namespace EventEmitter {
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
// Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
export { internal as EventEmitter };
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
export interface Abortable {
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
/**
|
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
* When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
|
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
*/
|
|
||||||
signal?: AbortSignal | undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
global {
|
|
||||||
namespace NodeJS {
|
|
||||||
interface EventEmitter {
|
|
||||||
/**
|
|
||||||
* Alias for `emitter.on(eventName, listener)`.
|
|
||||||
* @since v0.1.26
|
|
||||||
*/
|
|
||||||
addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
||||||
/**
|
|
||||||
* Adds the `listener` function to the end of the listeners array for the
|
|
||||||
* event named `eventName`. No checks are made to see if the `listener` has
|
|
||||||
* already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
|
|
||||||
* times.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* server.on('connection', (stream) => {
|
|
||||||
* console.log('someone connected!');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
||||||
*
|
|
||||||
* By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the
|
|
||||||
* event listener to the beginning of the listeners array.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const myEE = new EventEmitter();
|
|
||||||
* myEE.on('foo', () => console.log('a'));
|
|
||||||
* myEE.prependListener('foo', () => console.log('b'));
|
|
||||||
* myEE.emit('foo');
|
|
||||||
* // Prints:
|
|
||||||
* // b
|
|
||||||
* // a
|
|
||||||
* ```
|
|
||||||
* @since v0.1.101
|
|
||||||
* @param eventName The name of the event.
|
|
||||||
* @param listener The callback function
|
|
||||||
*/
|
|
||||||
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
||||||
/**
|
|
||||||
* Adds a **one-time**`listener` function for the event named `eventName`. The
|
|
||||||
* next time `eventName` is triggered, this listener is removed and then invoked.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* server.once('connection', (stream) => {
|
|
||||||
* console.log('Ah, we have our first user!');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
||||||
*
|
|
||||||
* By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the
|
|
||||||
* event listener to the beginning of the listeners array.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const myEE = new EventEmitter();
|
|
||||||
* myEE.once('foo', () => console.log('a'));
|
|
||||||
* myEE.prependOnceListener('foo', () => console.log('b'));
|
|
||||||
* myEE.emit('foo');
|
|
||||||
* // Prints:
|
|
||||||
* // b
|
|
||||||
* // a
|
|
||||||
* ```
|
|
||||||
* @since v0.3.0
|
|
||||||
* @param eventName The name of the event.
|
|
||||||
* @param listener The callback function
|
|
||||||
*/
|
|
||||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
||||||
/**
|
|
||||||
* Removes the specified `listener` from the listener array for the event named`eventName`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const callback = (stream) => {
|
|
||||||
* console.log('someone connected!');
|
|
||||||
* };
|
|
||||||
* server.on('connection', callback);
|
|
||||||
* // ...
|
|
||||||
* server.removeListener('connection', callback);
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* `removeListener()` will remove, at most, one instance of a listener from the
|
|
||||||
* listener array. If any single listener has been added multiple times to the
|
|
||||||
* listener array for the specified `eventName`, then `removeListener()` must be
|
|
||||||
* called multiple times to remove each instance.
|
|
||||||
*
|
|
||||||
* Once an event is emitted, all listeners attached to it at the
|
|
||||||
* time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and_before_ the last listener finishes execution will
|
|
||||||
* not remove them from`emit()` in progress. Subsequent events behave as expected.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const myEmitter = new MyEmitter();
|
|
||||||
*
|
|
||||||
* const callbackA = () => {
|
|
||||||
* console.log('A');
|
|
||||||
* myEmitter.removeListener('event', callbackB);
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* const callbackB = () => {
|
|
||||||
* console.log('B');
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* myEmitter.on('event', callbackA);
|
|
||||||
*
|
|
||||||
* myEmitter.on('event', callbackB);
|
|
||||||
*
|
|
||||||
* // callbackA removes listener callbackB but it will still be called.
|
|
||||||
* // Internal listener array at time of emit [callbackA, callbackB]
|
|
||||||
* myEmitter.emit('event');
|
|
||||||
* // Prints:
|
|
||||||
* // A
|
|
||||||
* // B
|
|
||||||
*
|
|
||||||
* // callbackB is now removed.
|
|
||||||
* // Internal listener array [callbackA]
|
|
||||||
* myEmitter.emit('event');
|
|
||||||
* // Prints:
|
|
||||||
* // A
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Because listeners are managed using an internal array, calling this will
|
|
||||||
* change the position indices of any listener registered _after_ the listener
|
|
||||||
* being removed. This will not impact the order in which listeners are called,
|
|
||||||
* but it means that any copies of the listener array as returned by
|
|
||||||
* the `emitter.listeners()` method will need to be recreated.
|
|
||||||
*
|
|
||||||
* When a single function has been added as a handler multiple times for a single
|
|
||||||
* event (as in the example below), `removeListener()` will remove the most
|
|
||||||
* recently added instance. In the example the `once('ping')`listener is removed:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const ee = new EventEmitter();
|
|
||||||
*
|
|
||||||
* function pong() {
|
|
||||||
* console.log('pong');
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* ee.on('ping', pong);
|
|
||||||
* ee.once('ping', pong);
|
|
||||||
* ee.removeListener('ping', pong);
|
|
||||||
*
|
|
||||||
* ee.emit('ping');
|
|
||||||
* ee.emit('ping');
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
||||||
* @since v0.1.26
|
|
||||||
*/
|
|
||||||
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
||||||
/**
|
|
||||||
* Alias for `emitter.removeListener()`.
|
|
||||||
* @since v10.0.0
|
|
||||||
*/
|
|
||||||
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
||||||
/**
|
|
||||||
* Removes all listeners, or those of the specified `eventName`.
|
|
||||||
*
|
|
||||||
* It is bad practice to remove listeners added elsewhere in the code,
|
|
||||||
* particularly when the `EventEmitter` instance was created by some other
|
|
||||||
* component or module (e.g. sockets or file streams).
|
|
||||||
*
|
|
||||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
||||||
* @since v0.1.26
|
|
||||||
*/
|
|
||||||
removeAllListeners(event?: string | symbol): this;
|
removeAllListeners(event?: string | symbol): this;
|
||||||
/**
|
|
||||||
* By default `EventEmitter`s will print a warning if more than `10` listeners are
|
|
||||||
* added for a particular event. This is a useful default that helps finding
|
|
||||||
* memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
|
|
||||||
* modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
|
|
||||||
*
|
|
||||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
||||||
* @since v0.3.5
|
|
||||||
*/
|
|
||||||
setMaxListeners(n: number): this;
|
setMaxListeners(n: number): this;
|
||||||
/**
|
|
||||||
* Returns the current max listener value for the `EventEmitter` which is either
|
|
||||||
* set by `emitter.setMaxListeners(n)` or defaults to {@link defaultMaxListeners}.
|
|
||||||
* @since v1.0.0
|
|
||||||
*/
|
|
||||||
getMaxListeners(): number;
|
getMaxListeners(): number;
|
||||||
/**
|
listeners(event: string | symbol): Function[];
|
||||||
* Returns a copy of the array of listeners for the event named `eventName`.
|
rawListeners(event: string | symbol): Function[];
|
||||||
*
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
* ```js
|
|
||||||
* server.on('connection', (stream) => {
|
|
||||||
* console.log('someone connected!');
|
|
||||||
* });
|
|
||||||
* console.log(util.inspect(server.listeners('connection')));
|
|
||||||
* // Prints: [ [Function] ]
|
|
||||||
* ```
|
|
||||||
* @since v0.1.26
|
|
||||||
*/
|
|
||||||
listeners(eventName: string | symbol): Function[];
|
|
||||||
/**
|
|
||||||
* Returns a copy of the array of listeners for the event named `eventName`,
|
|
||||||
* including any wrappers (such as those created by `.once()`).
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const emitter = new EventEmitter();
|
|
||||||
* emitter.once('log', () => console.log('log once'));
|
|
||||||
*
|
|
||||||
* // Returns a new Array with a function `onceWrapper` which has a property
|
|
||||||
* // `listener` which contains the original listener bound above
|
|
||||||
* const listeners = emitter.rawListeners('log');
|
|
||||||
* const logFnWrapper = listeners[0];
|
|
||||||
*
|
|
||||||
* // Logs "log once" to the console and does not unbind the `once` event
|
|
||||||
* logFnWrapper.listener();
|
|
||||||
*
|
|
||||||
* // Logs "log once" to the console and removes the listener
|
|
||||||
* logFnWrapper();
|
|
||||||
*
|
|
||||||
* emitter.on('log', () => console.log('log persistently'));
|
|
||||||
* // Will return a new Array with a single function bound by `.on()` above
|
|
||||||
* const newListeners = emitter.rawListeners('log');
|
|
||||||
*
|
|
||||||
* // Logs "log persistently" twice
|
|
||||||
* newListeners[0]();
|
|
||||||
* emitter.emit('log');
|
|
||||||
* ```
|
|
||||||
* @since v9.4.0
|
|
||||||
*/
|
|
||||||
rawListeners(eventName: string | symbol): Function[];
|
|
||||||
/**
|
|
||||||
* Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
|
|
||||||
* to each.
|
|
||||||
*
|
|
||||||
* Returns `true` if the event had listeners, `false` otherwise.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const EventEmitter = require('events');
|
|
||||||
* const myEmitter = new EventEmitter();
|
|
||||||
*
|
|
||||||
* // First listener
|
|
||||||
* myEmitter.on('event', function firstListener() {
|
|
||||||
* console.log('Helloooo! first listener');
|
|
||||||
* });
|
|
||||||
* // Second listener
|
|
||||||
* myEmitter.on('event', function secondListener(arg1, arg2) {
|
|
||||||
* console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
|
|
||||||
* });
|
|
||||||
* // Third listener
|
|
||||||
* myEmitter.on('event', function thirdListener(...args) {
|
|
||||||
* const parameters = args.join(', ');
|
|
||||||
* console.log(`event with parameters ${parameters} in third listener`);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* console.log(myEmitter.listeners('event'));
|
|
||||||
*
|
|
||||||
* myEmitter.emit('event', 1, 2, 3, 4, 5);
|
|
||||||
*
|
|
||||||
* // Prints:
|
|
||||||
* // [
|
|
||||||
* // [Function: firstListener],
|
|
||||||
* // [Function: secondListener],
|
|
||||||
* // [Function: thirdListener]
|
|
||||||
* // ]
|
|
||||||
* // Helloooo! first listener
|
|
||||||
* // event with parameters 1, 2 in second listener
|
|
||||||
* // event with parameters 1, 2, 3, 4, 5 in third listener
|
|
||||||
* ```
|
|
||||||
* @since v0.1.26
|
|
||||||
*/
|
|
||||||
emit(eventName: string | symbol, ...args: any[]): boolean;
|
|
||||||
/**
|
|
||||||
* Returns the number of listeners listening to the event named `eventName`.
|
|
||||||
* @since v3.2.0
|
|
||||||
* @param eventName The name of the event being listened for
|
|
||||||
*/
|
|
||||||
listenerCount(eventName: string | symbol): number;
|
|
||||||
/**
|
|
||||||
* Adds the `listener` function to the _beginning_ of the listeners array for the
|
|
||||||
* event named `eventName`. No checks are made to see if the `listener` has
|
|
||||||
* already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
|
|
||||||
* times.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* server.prependListener('connection', (stream) => {
|
|
||||||
* console.log('someone connected!');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
||||||
* @since v6.0.0
|
|
||||||
* @param eventName The name of the event.
|
|
||||||
* @param listener The callback function
|
|
||||||
*/
|
|
||||||
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
||||||
/**
|
|
||||||
* Adds a **one-time**`listener` function for the event named `eventName` to the_beginning_ of the listeners array. The next time `eventName` is triggered, this
|
|
||||||
* listener is removed, and then invoked.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* server.prependOnceListener('connection', (stream) => {
|
|
||||||
* console.log('Ah, we have our first user!');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
||||||
* @since v6.0.0
|
|
||||||
* @param eventName The name of the event.
|
|
||||||
* @param listener The callback function
|
|
||||||
*/
|
|
||||||
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
||||||
/**
|
|
||||||
* Returns an array listing the events for which the emitter has registered
|
|
||||||
* listeners. The values in the array are strings or `Symbol`s.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const EventEmitter = require('events');
|
|
||||||
* const myEE = new EventEmitter();
|
|
||||||
* myEE.on('foo', () => {});
|
|
||||||
* myEE.on('bar', () => {});
|
|
||||||
*
|
|
||||||
* const sym = Symbol('symbol');
|
|
||||||
* myEE.on(sym, () => {});
|
|
||||||
*
|
|
||||||
* console.log(myEE.eventNames());
|
|
||||||
* // Prints: [ 'foo', 'bar', Symbol(symbol) ]
|
|
||||||
* ```
|
|
||||||
* @since v6.0.0
|
|
||||||
*/
|
|
||||||
eventNames(): Array<string | symbol>;
|
eventNames(): Array<string | symbol>;
|
||||||
|
listenerCount(type: string | symbol): number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export = EventEmitter;
|
export = internal;
|
||||||
}
|
|
||||||
declare module 'node:events' {
|
|
||||||
import events = require('events');
|
|
||||||
export = events;
|
|
||||||
}
|
}
|
||||||
|
|||||||
4411
node_modules/@types/node/fs.d.ts
generated
vendored
Executable file → Normal file
4411
node_modules/@types/node/fs.d.ts
generated
vendored
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
1091
node_modules/@types/node/fs/promises.d.ts
generated
vendored
1091
node_modules/@types/node/fs/promises.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
1144
node_modules/@types/node/globals.d.ts
generated
vendored
Executable file → Normal file
1144
node_modules/@types/node/globals.d.ts
generated
vendored
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
2
node_modules/@types/node/globals.global.d.ts
generated
vendored
Executable file → Normal file
2
node_modules/@types/node/globals.global.d.ts
generated
vendored
Executable file → Normal file
@@ -1 +1 @@
|
|||||||
declare var global: typeof globalThis;
|
declare var global: NodeJS.Global & typeof globalThis;
|
||||||
|
|||||||
1338
node_modules/@types/node/http.d.ts
generated
vendored
Executable file → Normal file
1338
node_modules/@types/node/http.d.ts
generated
vendored
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
2219
node_modules/@types/node/http2.d.ts
generated
vendored
Executable file → Normal file
2219
node_modules/@types/node/http2.d.ts
generated
vendored
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
402
node_modules/@types/node/https.d.ts
generated
vendored
Executable file → Normal file
402
node_modules/@types/node/https.d.ts
generated
vendored
Executable file → Normal file
@@ -1,391 +1,53 @@
|
|||||||
/**
|
declare module "https" {
|
||||||
* HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
|
import * as tls from "tls";
|
||||||
* separate module.
|
import * as events from "events";
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/https.js)
|
import * as http from "http";
|
||||||
*/
|
import { URL } from "url";
|
||||||
declare module 'https' {
|
|
||||||
import { Duplex } from 'node:stream';
|
|
||||||
import * as tls from 'node:tls';
|
|
||||||
import * as http from 'node:http';
|
|
||||||
import { URL } from 'node:url';
|
|
||||||
type ServerOptions = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions;
|
type ServerOptions = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions;
|
||||||
type RequestOptions = http.RequestOptions &
|
|
||||||
tls.SecureContextOptions & {
|
type RequestOptions = http.RequestOptions & tls.SecureContextOptions & {
|
||||||
rejectUnauthorized?: boolean | undefined; // Defaults to true
|
rejectUnauthorized?: boolean; // Defaults to true
|
||||||
servername?: string | undefined; // SNI TLS Extension
|
servername?: string; // SNI TLS Extension
|
||||||
};
|
};
|
||||||
|
|
||||||
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
|
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
|
||||||
rejectUnauthorized?: boolean | undefined;
|
rejectUnauthorized?: boolean;
|
||||||
maxCachedSessions?: number | undefined;
|
maxCachedSessions?: number;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information.
|
|
||||||
* @since v0.4.5
|
|
||||||
*/
|
|
||||||
class Agent extends http.Agent {
|
class Agent extends http.Agent {
|
||||||
constructor(options?: AgentOptions);
|
constructor(options?: AgentOptions);
|
||||||
options: AgentOptions;
|
options: AgentOptions;
|
||||||
}
|
}
|
||||||
interface Server extends http.Server {}
|
|
||||||
/**
|
|
||||||
* See `http.Server` for more information.
|
|
||||||
* @since v0.3.4
|
|
||||||
*/
|
|
||||||
class Server extends tls.Server {
|
class Server extends tls.Server {
|
||||||
constructor(requestListener?: http.RequestListener);
|
constructor(requestListener?: http.RequestListener);
|
||||||
constructor(options: ServerOptions, requestListener?: http.RequestListener);
|
constructor(options: ServerOptions, requestListener?: http.RequestListener);
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
||||||
addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
setTimeout(callback: () => void): this;
|
||||||
addListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
setTimeout(msecs?: number, callback?: () => void): this;
|
||||||
addListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
|
|
||||||
addListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
|
|
||||||
addListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
addListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
addListener(event: 'close', listener: () => void): this;
|
|
||||||
addListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
|
||||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
|
||||||
addListener(event: 'listening', listener: () => void): this;
|
|
||||||
addListener(event: 'checkContinue', listener: http.RequestListener): this;
|
|
||||||
addListener(event: 'checkExpectation', listener: http.RequestListener): this;
|
|
||||||
addListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
|
||||||
addListener(event: 'connect', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
|
||||||
addListener(event: 'request', listener: http.RequestListener): this;
|
|
||||||
addListener(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
|
||||||
emit(event: string, ...args: any[]): boolean;
|
|
||||||
emit(event: 'keylog', line: Buffer, tlsSocket: tls.TLSSocket): boolean;
|
|
||||||
emit(event: 'newSession', sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void): boolean;
|
|
||||||
emit(event: 'OCSPRequest', certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void): boolean;
|
|
||||||
emit(event: 'resumeSession', sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
|
|
||||||
emit(event: 'secureConnection', tlsSocket: tls.TLSSocket): boolean;
|
|
||||||
emit(event: 'tlsClientError', err: Error, tlsSocket: tls.TLSSocket): boolean;
|
|
||||||
emit(event: 'close'): boolean;
|
|
||||||
emit(event: 'connection', socket: Duplex): boolean;
|
|
||||||
emit(event: 'error', err: Error): boolean;
|
|
||||||
emit(event: 'listening'): boolean;
|
|
||||||
emit(event: 'checkContinue', req: http.IncomingMessage, res: http.ServerResponse): boolean;
|
|
||||||
emit(event: 'checkExpectation', req: http.IncomingMessage, res: http.ServerResponse): boolean;
|
|
||||||
emit(event: 'clientError', err: Error, socket: Duplex): boolean;
|
|
||||||
emit(event: 'connect', req: http.IncomingMessage, socket: Duplex, head: Buffer): boolean;
|
|
||||||
emit(event: 'request', req: http.IncomingMessage, res: http.ServerResponse): boolean;
|
|
||||||
emit(event: 'upgrade', req: http.IncomingMessage, socket: Duplex, head: Buffer): boolean;
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
|
||||||
on(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
on(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
|
||||||
on(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
|
|
||||||
on(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
|
|
||||||
on(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
on(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
on(event: 'close', listener: () => void): this;
|
|
||||||
on(event: 'connection', listener: (socket: Duplex) => void): this;
|
|
||||||
on(event: 'error', listener: (err: Error) => void): this;
|
|
||||||
on(event: 'listening', listener: () => void): this;
|
|
||||||
on(event: 'checkContinue', listener: http.RequestListener): this;
|
|
||||||
on(event: 'checkExpectation', listener: http.RequestListener): this;
|
|
||||||
on(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
|
||||||
on(event: 'connect', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
|
||||||
on(event: 'request', listener: http.RequestListener): this;
|
|
||||||
on(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
|
||||||
once(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
once(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
|
||||||
once(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
|
|
||||||
once(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
|
|
||||||
once(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
once(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
once(event: 'close', listener: () => void): this;
|
|
||||||
once(event: 'connection', listener: (socket: Duplex) => void): this;
|
|
||||||
once(event: 'error', listener: (err: Error) => void): this;
|
|
||||||
once(event: 'listening', listener: () => void): this;
|
|
||||||
once(event: 'checkContinue', listener: http.RequestListener): this;
|
|
||||||
once(event: 'checkExpectation', listener: http.RequestListener): this;
|
|
||||||
once(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
|
||||||
once(event: 'connect', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
|
||||||
once(event: 'request', listener: http.RequestListener): this;
|
|
||||||
once(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
||||||
prependListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
prependListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
|
||||||
prependListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
|
|
||||||
prependListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
|
|
||||||
prependListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
prependListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
prependListener(event: 'close', listener: () => void): this;
|
|
||||||
prependListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
|
||||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
|
||||||
prependListener(event: 'listening', listener: () => void): this;
|
|
||||||
prependListener(event: 'checkContinue', listener: http.RequestListener): this;
|
|
||||||
prependListener(event: 'checkExpectation', listener: http.RequestListener): this;
|
|
||||||
prependListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
|
||||||
prependListener(event: 'connect', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
|
||||||
prependListener(event: 'request', listener: http.RequestListener): this;
|
|
||||||
prependListener(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
||||||
prependOnceListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
prependOnceListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
|
||||||
prependOnceListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
|
|
||||||
prependOnceListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
|
|
||||||
prependOnceListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
prependOnceListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
|
||||||
prependOnceListener(event: 'close', listener: () => void): this;
|
|
||||||
prependOnceListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
|
||||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
|
||||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
|
||||||
prependOnceListener(event: 'checkContinue', listener: http.RequestListener): this;
|
|
||||||
prependOnceListener(event: 'checkExpectation', listener: http.RequestListener): this;
|
|
||||||
prependOnceListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
|
||||||
prependOnceListener(event: 'connect', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
|
||||||
prependOnceListener(event: 'request', listener: http.RequestListener): this;
|
|
||||||
prependOnceListener(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* ```js
|
* Limits maximum incoming headers count. If set to 0, no limit will be applied.
|
||||||
* // curl -k https://localhost:8000/
|
* @default 2000
|
||||||
* const https = require('https');
|
* {@link https://nodejs.org/api/http.html#http_server_maxheaderscount}
|
||||||
* const fs = require('fs');
|
|
||||||
*
|
|
||||||
* const options = {
|
|
||||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
|
||||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* https.createServer(options, (req, res) => {
|
|
||||||
* res.writeHead(200);
|
|
||||||
* res.end('hello world\n');
|
|
||||||
* }).listen(8000);
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Or
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const https = require('https');
|
|
||||||
* const fs = require('fs');
|
|
||||||
*
|
|
||||||
* const options = {
|
|
||||||
* pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
|
|
||||||
* passphrase: 'sample'
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* https.createServer(options, (req, res) => {
|
|
||||||
* res.writeHead(200);
|
|
||||||
* res.end('hello world\n');
|
|
||||||
* }).listen(8000);
|
|
||||||
* ```
|
|
||||||
* @since v0.3.4
|
|
||||||
* @param options Accepts `options` from `createServer`, `createSecureContext` and `createServer`.
|
|
||||||
* @param requestListener A listener to be added to the `'request'` event.
|
|
||||||
*/
|
*/
|
||||||
|
maxHeadersCount: number | null;
|
||||||
|
timeout: number;
|
||||||
|
/**
|
||||||
|
* Limit the amount of time the parser will wait to receive the complete HTTP headers.
|
||||||
|
* @default 40000
|
||||||
|
* {@link https://nodejs.org/api/http.html#http_server_headerstimeout}
|
||||||
|
*/
|
||||||
|
headersTimeout: number;
|
||||||
|
keepAliveTimeout: number;
|
||||||
|
}
|
||||||
|
|
||||||
function createServer(requestListener?: http.RequestListener): Server;
|
function createServer(requestListener?: http.RequestListener): Server;
|
||||||
function createServer(options: ServerOptions, requestListener?: http.RequestListener): Server;
|
function createServer(options: ServerOptions, requestListener?: http.RequestListener): Server;
|
||||||
/**
|
|
||||||
* Makes a request to a secure web server.
|
|
||||||
*
|
|
||||||
* The following additional `options` from `tls.connect()` are also accepted:`ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`,`honorCipherOrder`, `key`, `passphrase`,
|
|
||||||
* `pfx`, `rejectUnauthorized`,`secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`,`highWaterMark`.
|
|
||||||
*
|
|
||||||
* `options` can be an object, a string, or a `URL` object. If `options` is a
|
|
||||||
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
|
||||||
*
|
|
||||||
* `https.request()` returns an instance of the `http.ClientRequest` class. The `ClientRequest` instance is a writable stream. If one needs to
|
|
||||||
* upload a file with a POST request, then write to the `ClientRequest` object.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const https = require('https');
|
|
||||||
*
|
|
||||||
* const options = {
|
|
||||||
* hostname: 'encrypted.google.com',
|
|
||||||
* port: 443,
|
|
||||||
* path: '/',
|
|
||||||
* method: 'GET'
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* const req = https.request(options, (res) => {
|
|
||||||
* console.log('statusCode:', res.statusCode);
|
|
||||||
* console.log('headers:', res.headers);
|
|
||||||
*
|
|
||||||
* res.on('data', (d) => {
|
|
||||||
* process.stdout.write(d);
|
|
||||||
* });
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* req.on('error', (e) => {
|
|
||||||
* console.error(e);
|
|
||||||
* });
|
|
||||||
* req.end();
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Example using options from `tls.connect()`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const options = {
|
|
||||||
* hostname: 'encrypted.google.com',
|
|
||||||
* port: 443,
|
|
||||||
* path: '/',
|
|
||||||
* method: 'GET',
|
|
||||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
|
||||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
|
|
||||||
* };
|
|
||||||
* options.agent = new https.Agent(options);
|
|
||||||
*
|
|
||||||
* const req = https.request(options, (res) => {
|
|
||||||
* // ...
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Alternatively, opt out of connection pooling by not using an `Agent`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const options = {
|
|
||||||
* hostname: 'encrypted.google.com',
|
|
||||||
* port: 443,
|
|
||||||
* path: '/',
|
|
||||||
* method: 'GET',
|
|
||||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
|
||||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
|
|
||||||
* agent: false
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* const req = https.request(options, (res) => {
|
|
||||||
* // ...
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Example using a `URL` as `options`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const options = new URL('https://abc:xyz@example.com');
|
|
||||||
*
|
|
||||||
* const req = https.request(options, (res) => {
|
|
||||||
* // ...
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const tls = require('tls');
|
|
||||||
* const https = require('https');
|
|
||||||
* const crypto = require('crypto');
|
|
||||||
*
|
|
||||||
* function sha256(s) {
|
|
||||||
* return crypto.createHash('sha256').update(s).digest('base64');
|
|
||||||
* }
|
|
||||||
* const options = {
|
|
||||||
* hostname: 'github.com',
|
|
||||||
* port: 443,
|
|
||||||
* path: '/',
|
|
||||||
* method: 'GET',
|
|
||||||
* checkServerIdentity: function(host, cert) {
|
|
||||||
* // Make sure the certificate is issued to the host we are connected to
|
|
||||||
* const err = tls.checkServerIdentity(host, cert);
|
|
||||||
* if (err) {
|
|
||||||
* return err;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* // Pin the public key, similar to HPKP pin-sha25 pinning
|
|
||||||
* const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=';
|
|
||||||
* if (sha256(cert.pubkey) !== pubkey256) {
|
|
||||||
* const msg = 'Certificate verification error: ' +
|
|
||||||
* `The public key of '${cert.subject.CN}' ` +
|
|
||||||
* 'does not match our pinned fingerprint';
|
|
||||||
* return new Error(msg);
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* // Pin the exact certificate, rather than the pub key
|
|
||||||
* const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' +
|
|
||||||
* 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16';
|
|
||||||
* if (cert.fingerprint256 !== cert256) {
|
|
||||||
* const msg = 'Certificate verification error: ' +
|
|
||||||
* `The certificate of '${cert.subject.CN}' ` +
|
|
||||||
* 'does not match our pinned fingerprint';
|
|
||||||
* return new Error(msg);
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* // This loop is informational only.
|
|
||||||
* // Print the certificate and public key fingerprints of all certs in the
|
|
||||||
* // chain. Its common to pin the public key of the issuer on the public
|
|
||||||
* // internet, while pinning the public key of the service in sensitive
|
|
||||||
* // environments.
|
|
||||||
* do {
|
|
||||||
* console.log('Subject Common Name:', cert.subject.CN);
|
|
||||||
* console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256);
|
|
||||||
*
|
|
||||||
* hash = crypto.createHash('sha256');
|
|
||||||
* console.log(' Public key ping-sha256:', sha256(cert.pubkey));
|
|
||||||
*
|
|
||||||
* lastprint256 = cert.fingerprint256;
|
|
||||||
* cert = cert.issuerCertificate;
|
|
||||||
* } while (cert.fingerprint256 !== lastprint256);
|
|
||||||
*
|
|
||||||
* },
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* options.agent = new https.Agent(options);
|
|
||||||
* const req = https.request(options, (res) => {
|
|
||||||
* console.log('All OK. Server matched our pinned cert or public key');
|
|
||||||
* console.log('statusCode:', res.statusCode);
|
|
||||||
* // Print the HPKP values
|
|
||||||
* console.log('headers:', res.headers['public-key-pins']);
|
|
||||||
*
|
|
||||||
* res.on('data', (d) => {});
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* req.on('error', (e) => {
|
|
||||||
* console.error(e.message);
|
|
||||||
* });
|
|
||||||
* req.end();
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Outputs for example:
|
|
||||||
*
|
|
||||||
* ```text
|
|
||||||
* Subject Common Name: github.com
|
|
||||||
* Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16
|
|
||||||
* Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=
|
|
||||||
* Subject Common Name: DigiCert SHA2 Extended Validation Server CA
|
|
||||||
* Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A
|
|
||||||
* Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=
|
|
||||||
* Subject Common Name: DigiCert High Assurance EV Root CA
|
|
||||||
* Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF
|
|
||||||
* Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=
|
|
||||||
* All OK. Server matched our pinned cert or public key
|
|
||||||
* statusCode: 200
|
|
||||||
* headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=";
|
|
||||||
* pin-sha256="k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4=";
|
|
||||||
* pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0="; pin-sha256="LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A="; includeSubDomains
|
|
||||||
* ```
|
|
||||||
* @since v0.3.6
|
|
||||||
* @param options Accepts all `options` from `request`, with some differences in default values:
|
|
||||||
*/
|
|
||||||
function request(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
function request(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||||
function request(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
function request(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||||
/**
|
|
||||||
* Like `http.get()` but for HTTPS.
|
|
||||||
*
|
|
||||||
* `options` can be an object, a string, or a `URL` object. If `options` is a
|
|
||||||
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const https = require('https');
|
|
||||||
*
|
|
||||||
* https.get('https://encrypted.google.com/', (res) => {
|
|
||||||
* console.log('statusCode:', res.statusCode);
|
|
||||||
* console.log('headers:', res.headers);
|
|
||||||
*
|
|
||||||
* res.on('data', (d) => {
|
|
||||||
* process.stdout.write(d);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* }).on('error', (e) => {
|
|
||||||
* console.error(e);
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v0.3.6
|
|
||||||
* @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`.
|
|
||||||
*/
|
|
||||||
function get(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
function get(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||||
function get(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
function get(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||||
let globalAgent: Agent;
|
let globalAgent: Agent;
|
||||||
}
|
}
|
||||||
declare module 'node:https' {
|
|
||||||
export * from 'https';
|
|
||||||
}
|
|
||||||
|
|||||||
108
node_modules/@types/node/index.d.ts
generated
vendored
Executable file → Normal file
108
node_modules/@types/node/index.d.ts
generated
vendored
Executable file → Normal file
@@ -1,16 +1,20 @@
|
|||||||
// Type definitions for non-npm package Node.js 16.11
|
// Type definitions for non-npm package Node.js 12.12
|
||||||
// Project: https://nodejs.org/
|
// Project: http://nodejs.org/
|
||||||
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
|
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
|
||||||
// DefinitelyTyped <https://github.com/DefinitelyTyped>
|
// DefinitelyTyped <https://github.com/DefinitelyTyped>
|
||||||
// Alberto Schiabel <https://github.com/jkomyno>
|
// Alberto Schiabel <https://github.com/jkomyno>
|
||||||
|
// Alexander T. <https://github.com/a-tarasyuk>
|
||||||
// Alvis HT Tang <https://github.com/alvis>
|
// Alvis HT Tang <https://github.com/alvis>
|
||||||
// Andrew Makarov <https://github.com/r3nya>
|
// Andrew Makarov <https://github.com/r3nya>
|
||||||
// Benjamin Toueg <https://github.com/btoueg>
|
// Benjamin Toueg <https://github.com/btoueg>
|
||||||
|
// Bruno Scheufler <https://github.com/brunoscheufler>
|
||||||
// Chigozirim C. <https://github.com/smac89>
|
// Chigozirim C. <https://github.com/smac89>
|
||||||
// David Junger <https://github.com/touffy>
|
// David Junger <https://github.com/touffy>
|
||||||
// Deividas Bakanas <https://github.com/DeividasBakanas>
|
// Deividas Bakanas <https://github.com/DeividasBakanas>
|
||||||
// Eugene Y. Q. Shen <https://github.com/eyqs>
|
// Eugene Y. Q. Shen <https://github.com/eyqs>
|
||||||
|
// Flarna <https://github.com/Flarna>
|
||||||
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
|
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
|
||||||
|
// Hoàng Văn Khải <https://github.com/KSXGitHub>
|
||||||
// Huw <https://github.com/hoo29>
|
// Huw <https://github.com/hoo29>
|
||||||
// Kelvin Jin <https://github.com/kjin>
|
// Kelvin Jin <https://github.com/kjin>
|
||||||
// Klaus Meinhardt <https://github.com/ajafff>
|
// Klaus Meinhardt <https://github.com/ajafff>
|
||||||
@@ -21,110 +25,26 @@
|
|||||||
// Nikita Galkin <https://github.com/galkin>
|
// Nikita Galkin <https://github.com/galkin>
|
||||||
// Parambir Singh <https://github.com/parambirs>
|
// Parambir Singh <https://github.com/parambirs>
|
||||||
// Sebastian Silbermann <https://github.com/eps1lon>
|
// Sebastian Silbermann <https://github.com/eps1lon>
|
||||||
// Seth Westphal <https://github.com/westy92>
|
|
||||||
// Simon Schick <https://github.com/SimonSchick>
|
// Simon Schick <https://github.com/SimonSchick>
|
||||||
// Thomas den Hollander <https://github.com/ThomasdenH>
|
// Thomas den Hollander <https://github.com/ThomasdenH>
|
||||||
// Wilco Bakker <https://github.com/WilcoBakker>
|
// Wilco Bakker <https://github.com/WilcoBakker>
|
||||||
// wwwy3y3 <https://github.com/wwwy3y3>
|
// wwwy3y3 <https://github.com/wwwy3y3>
|
||||||
|
// Zane Hannan AU <https://github.com/ZaneHannanAU>
|
||||||
// Samuel Ainsworth <https://github.com/samuela>
|
// Samuel Ainsworth <https://github.com/samuela>
|
||||||
// Kyle Uehlein <https://github.com/kuehlein>
|
// Kyle Uehlein <https://github.com/kuehlein>
|
||||||
|
// Jordi Oliveras Rovira <https://github.com/j-oliveras>
|
||||||
// Thanik Bhongbhibhat <https://github.com/bhongy>
|
// Thanik Bhongbhibhat <https://github.com/bhongy>
|
||||||
// Marcin Kopacz <https://github.com/chyzwar>
|
// Marcin Kopacz <https://github.com/chyzwar>
|
||||||
// Trivikram Kamat <https://github.com/trivikr>
|
// Trivikram Kamat <https://github.com/trivikr>
|
||||||
|
// Minh Son Nguyen <https://github.com/nguymin4>
|
||||||
// Junxiao Shi <https://github.com/yoursunny>
|
// Junxiao Shi <https://github.com/yoursunny>
|
||||||
// Ilia Baryshnikov <https://github.com/qwelias>
|
// Ilia Baryshnikov <https://github.com/qwelias>
|
||||||
// ExE Boss <https://github.com/ExE-Boss>
|
// ExE Boss <https://github.com/ExE-Boss>
|
||||||
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
// Jason Kwok <https://github.com/JasonHK>
|
||||||
// Anna Henningsen <https://github.com/addaleax>
|
|
||||||
// Victor Perin <https://github.com/victorperin>
|
|
||||||
// Yongsheng Zhang <https://github.com/ZYSzys>
|
|
||||||
// NodeJS Contributors <https://github.com/NodeJS>
|
|
||||||
// Linus Unnebäck <https://github.com/LinusU>
|
|
||||||
// wafuwafu13 <https://github.com/wafuwafu13>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
|
||||||
/**
|
// NOTE: These definitions support NodeJS and TypeScript 3.7.
|
||||||
* License for programmatically and manually incorporated
|
// This isn't strictly needed since 3.7 has the assert module, but this way we're consistent.
|
||||||
* documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc
|
// Typically type modificatons should be made in base.d.ts instead of here
|
||||||
*
|
|
||||||
* Copyright Node.js contributors. All rights reserved.
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to
|
|
||||||
* deal in the Software without restriction, including without limitation the
|
|
||||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
||||||
* sell copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
||||||
* IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// NOTE: These definitions support NodeJS and TypeScript 3.7+.
|
/// <reference path="base.d.ts" />
|
||||||
|
|
||||||
// Reference required types from the default lib:
|
|
||||||
/// <reference lib="es2020" />
|
|
||||||
/// <reference lib="esnext.asynciterable" />
|
|
||||||
/// <reference lib="esnext.intl" />
|
|
||||||
/// <reference lib="esnext.bigint" />
|
|
||||||
|
|
||||||
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
|
|
||||||
/// <reference path="assert.d.ts" />
|
|
||||||
/// <reference path="assert/strict.d.ts" />
|
|
||||||
/// <reference path="globals.d.ts" />
|
|
||||||
/// <reference path="async_hooks.d.ts" />
|
|
||||||
/// <reference path="buffer.d.ts" />
|
|
||||||
/// <reference path="child_process.d.ts" />
|
|
||||||
/// <reference path="cluster.d.ts" />
|
|
||||||
/// <reference path="console.d.ts" />
|
|
||||||
/// <reference path="constants.d.ts" />
|
|
||||||
/// <reference path="crypto.d.ts" />
|
|
||||||
/// <reference path="dgram.d.ts" />
|
|
||||||
/// <reference path="diagnostics_channel.d.ts" />
|
|
||||||
/// <reference path="dns.d.ts" />
|
|
||||||
/// <reference path="dns/promises.d.ts" />
|
|
||||||
/// <reference path="dns/promises.d.ts" />
|
|
||||||
/// <reference path="domain.d.ts" />
|
|
||||||
/// <reference path="events.d.ts" />
|
|
||||||
/// <reference path="fs.d.ts" />
|
|
||||||
/// <reference path="fs/promises.d.ts" />
|
|
||||||
/// <reference path="http.d.ts" />
|
|
||||||
/// <reference path="http2.d.ts" />
|
|
||||||
/// <reference path="https.d.ts" />
|
|
||||||
/// <reference path="inspector.d.ts" />
|
|
||||||
/// <reference path="module.d.ts" />
|
|
||||||
/// <reference path="net.d.ts" />
|
|
||||||
/// <reference path="os.d.ts" />
|
|
||||||
/// <reference path="path.d.ts" />
|
|
||||||
/// <reference path="perf_hooks.d.ts" />
|
|
||||||
/// <reference path="process.d.ts" />
|
|
||||||
/// <reference path="punycode.d.ts" />
|
|
||||||
/// <reference path="querystring.d.ts" />
|
|
||||||
/// <reference path="readline.d.ts" />
|
|
||||||
/// <reference path="repl.d.ts" />
|
|
||||||
/// <reference path="stream.d.ts" />
|
|
||||||
/// <reference path="stream/promises.d.ts" />
|
|
||||||
/// <reference path="stream/consumers.d.ts" />
|
|
||||||
/// <reference path="stream/web.d.ts" />
|
|
||||||
/// <reference path="string_decoder.d.ts" />
|
|
||||||
/// <reference path="timers.d.ts" />
|
|
||||||
/// <reference path="timers/promises.d.ts" />
|
|
||||||
/// <reference path="tls.d.ts" />
|
|
||||||
/// <reference path="trace_events.d.ts" />
|
|
||||||
/// <reference path="tty.d.ts" />
|
|
||||||
/// <reference path="url.d.ts" />
|
|
||||||
/// <reference path="util.d.ts" />
|
|
||||||
/// <reference path="v8.d.ts" />
|
|
||||||
/// <reference path="vm.d.ts" />
|
|
||||||
/// <reference path="wasi.d.ts" />
|
|
||||||
/// <reference path="worker_threads.d.ts" />
|
|
||||||
/// <reference path="zlib.d.ts" />
|
|
||||||
|
|
||||||
/// <reference path="globals.global.d.ts" />
|
|
||||||
|
|||||||
1325
node_modules/@types/node/inspector.d.ts
generated
vendored
Executable file → Normal file
1325
node_modules/@types/node/inspector.d.ts
generated
vendored
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
115
node_modules/@types/node/module.d.ts
generated
vendored
Executable file → Normal file
115
node_modules/@types/node/module.d.ts
generated
vendored
Executable file → Normal file
@@ -1,114 +1,3 @@
|
|||||||
/**
|
declare module "module" {
|
||||||
* @since v0.3.7
|
export = NodeJS.Module;
|
||||||
*/
|
|
||||||
declare module 'module' {
|
|
||||||
import { URL } from 'node:url';
|
|
||||||
namespace Module {
|
|
||||||
/**
|
|
||||||
* The `module.syncBuiltinESMExports()` method updates all the live bindings for
|
|
||||||
* builtin `ES Modules` to match the properties of the `CommonJS` exports. It
|
|
||||||
* does not add or remove exported names from the `ES Modules`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const fs = require('fs');
|
|
||||||
* const assert = require('assert');
|
|
||||||
* const { syncBuiltinESMExports } = require('module');
|
|
||||||
*
|
|
||||||
* fs.readFile = newAPI;
|
|
||||||
*
|
|
||||||
* delete fs.readFileSync;
|
|
||||||
*
|
|
||||||
* function newAPI() {
|
|
||||||
* // ...
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* fs.newAPI = newAPI;
|
|
||||||
*
|
|
||||||
* syncBuiltinESMExports();
|
|
||||||
*
|
|
||||||
* import('fs').then((esmFS) => {
|
|
||||||
* // It syncs the existing readFile property with the new value
|
|
||||||
* assert.strictEqual(esmFS.readFile, newAPI);
|
|
||||||
* // readFileSync has been deleted from the required fs
|
|
||||||
* assert.strictEqual('readFileSync' in fs, false);
|
|
||||||
* // syncBuiltinESMExports() does not remove readFileSync from esmFS
|
|
||||||
* assert.strictEqual('readFileSync' in esmFS, true);
|
|
||||||
* // syncBuiltinESMExports() does not add names
|
|
||||||
* assert.strictEqual(esmFS.newAPI, undefined);
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v12.12.0
|
|
||||||
*/
|
|
||||||
function syncBuiltinESMExports(): void;
|
|
||||||
/**
|
|
||||||
* `path` is the resolved path for the file for which a corresponding source map
|
|
||||||
* should be fetched.
|
|
||||||
* @since v13.7.0, v12.17.0
|
|
||||||
*/
|
|
||||||
function findSourceMap(path: string, error?: Error): SourceMap;
|
|
||||||
interface SourceMapPayload {
|
|
||||||
file: string;
|
|
||||||
version: number;
|
|
||||||
sources: string[];
|
|
||||||
sourcesContent: string[];
|
|
||||||
names: string[];
|
|
||||||
mappings: string;
|
|
||||||
sourceRoot: string;
|
|
||||||
}
|
|
||||||
interface SourceMapping {
|
|
||||||
generatedLine: number;
|
|
||||||
generatedColumn: number;
|
|
||||||
originalSource: string;
|
|
||||||
originalLine: number;
|
|
||||||
originalColumn: number;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @since v13.7.0, v12.17.0
|
|
||||||
*/
|
|
||||||
class SourceMap {
|
|
||||||
/**
|
|
||||||
* Getter for the payload used to construct the `SourceMap` instance.
|
|
||||||
*/
|
|
||||||
readonly payload: SourceMapPayload;
|
|
||||||
constructor(payload: SourceMapPayload);
|
|
||||||
/**
|
|
||||||
* Given a line number and column number in the generated source file, returns
|
|
||||||
* an object representing the position in the original file. The object returned
|
|
||||||
* consists of the following keys:
|
|
||||||
*/
|
|
||||||
findEntry(line: number, column: number): SourceMapping;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
interface Module extends NodeModule {}
|
|
||||||
class Module {
|
|
||||||
static runMain(): void;
|
|
||||||
static wrap(code: string): string;
|
|
||||||
static createRequire(path: string | URL): NodeRequire;
|
|
||||||
static builtinModules: string[];
|
|
||||||
static Module: typeof Module;
|
|
||||||
constructor(id: string, parent?: Module);
|
|
||||||
}
|
|
||||||
global {
|
|
||||||
interface ImportMeta {
|
|
||||||
url: string;
|
|
||||||
/**
|
|
||||||
* @experimental
|
|
||||||
* This feature is only available with the `--experimental-import-meta-resolve`
|
|
||||||
* command flag enabled.
|
|
||||||
*
|
|
||||||
* Provides a module-relative resolution function scoped to each module, returning
|
|
||||||
* the URL string.
|
|
||||||
*
|
|
||||||
* @param specified The module specifier to resolve relative to `parent`.
|
|
||||||
* @param parent The absolute parent module URL to resolve from. If none
|
|
||||||
* is specified, the value of `import.meta.url` is used as the default.
|
|
||||||
*/
|
|
||||||
resolve?(specified: string, parent?: string | URL): Promise<string>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export = Module;
|
|
||||||
}
|
|
||||||
declare module 'node:module' {
|
|
||||||
import module = require('module');
|
|
||||||
export = module;
|
|
||||||
}
|
}
|
||||||
|
|||||||
816
node_modules/@types/node/net.d.ts
generated
vendored
Executable file → Normal file
816
node_modules/@types/node/net.d.ts
generated
vendored
Executable file → Normal file
@@ -1,34 +1,23 @@
|
|||||||
/**
|
declare module "net" {
|
||||||
* > Stability: 2 - Stable
|
import * as stream from "stream";
|
||||||
*
|
import * as events from "events";
|
||||||
* The `net` module provides an asynchronous network API for creating stream-based
|
import * as dns from "dns";
|
||||||
* TCP or `IPC` servers ({@link createServer}) and clients
|
|
||||||
* ({@link createConnection}).
|
|
||||||
*
|
|
||||||
* It can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const net = require('net');
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/net.js)
|
|
||||||
*/
|
|
||||||
declare module 'net' {
|
|
||||||
import * as stream from 'node:stream';
|
|
||||||
import { Abortable, EventEmitter } from 'node:events';
|
|
||||||
import * as dns from 'node:dns';
|
|
||||||
type LookupFunction = (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
|
type LookupFunction = (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
|
||||||
|
|
||||||
interface AddressInfo {
|
interface AddressInfo {
|
||||||
address: string;
|
address: string;
|
||||||
family: string;
|
family: string;
|
||||||
port: number;
|
port: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SocketConstructorOpts {
|
interface SocketConstructorOpts {
|
||||||
fd?: number | undefined;
|
fd?: number;
|
||||||
allowHalfOpen?: boolean | undefined;
|
allowHalfOpen?: boolean;
|
||||||
readable?: boolean | undefined;
|
readable?: boolean;
|
||||||
writable?: boolean | undefined;
|
writable?: boolean;
|
||||||
signal?: AbortSignal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OnReadOpts {
|
interface OnReadOpts {
|
||||||
buffer: Uint8Array | (() => Uint8Array);
|
buffer: Uint8Array | (() => Uint8Array);
|
||||||
/**
|
/**
|
||||||
@@ -38,259 +27,70 @@ declare module 'net' {
|
|||||||
*/
|
*/
|
||||||
callback(bytesWritten: number, buf: Uint8Array): boolean;
|
callback(bytesWritten: number, buf: Uint8Array): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConnectOpts {
|
interface ConnectOpts {
|
||||||
/**
|
/**
|
||||||
* If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
|
* If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
|
||||||
* Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
|
* Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
|
||||||
* still be emitted as normal and methods like pause() and resume() will also behave as expected.
|
* still be emitted as normal and methods like pause() and resume() will also behave as expected.
|
||||||
*/
|
*/
|
||||||
onread?: OnReadOpts | undefined;
|
onread?: OnReadOpts;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TcpSocketConnectOpts extends ConnectOpts {
|
interface TcpSocketConnectOpts extends ConnectOpts {
|
||||||
port: number;
|
port: number;
|
||||||
host?: string | undefined;
|
host?: string;
|
||||||
localAddress?: string | undefined;
|
localAddress?: string;
|
||||||
localPort?: number | undefined;
|
localPort?: number;
|
||||||
hints?: number | undefined;
|
hints?: number;
|
||||||
family?: number | undefined;
|
family?: number;
|
||||||
lookup?: LookupFunction | undefined;
|
lookup?: LookupFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IpcSocketConnectOpts extends ConnectOpts {
|
interface IpcSocketConnectOpts extends ConnectOpts {
|
||||||
path: string;
|
path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
|
type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
|
||||||
/**
|
|
||||||
* This class is an abstraction of a TCP socket or a streaming `IPC` endpoint
|
|
||||||
* (uses named pipes on Windows, and Unix domain sockets otherwise). It is also
|
|
||||||
* an `EventEmitter`.
|
|
||||||
*
|
|
||||||
* A `net.Socket` can be created by the user and used directly to interact with
|
|
||||||
* a server. For example, it is returned by {@link createConnection},
|
|
||||||
* so the user can use it to talk to the server.
|
|
||||||
*
|
|
||||||
* It can also be created by Node.js and passed to the user when a connection
|
|
||||||
* is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use
|
|
||||||
* it to interact with the client.
|
|
||||||
* @since v0.3.4
|
|
||||||
*/
|
|
||||||
class Socket extends stream.Duplex {
|
class Socket extends stream.Duplex {
|
||||||
constructor(options?: SocketConstructorOpts);
|
constructor(options?: SocketConstructorOpts);
|
||||||
/**
|
|
||||||
* Sends data on the socket. The second parameter specifies the encoding in the
|
// Extended base methods
|
||||||
* case of a string. It defaults to UTF8 encoding.
|
|
||||||
*
|
|
||||||
* Returns `true` if the entire data was flushed successfully to the kernel
|
|
||||||
* buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free.
|
|
||||||
*
|
|
||||||
* The optional `callback` parameter will be executed when the data is finally
|
|
||||||
* written out, which may not be immediately.
|
|
||||||
*
|
|
||||||
* See `Writable` stream `write()` method for more
|
|
||||||
* information.
|
|
||||||
* @since v0.1.90
|
|
||||||
* @param [encoding='utf8'] Only used when data is `string`.
|
|
||||||
*/
|
|
||||||
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
||||||
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
|
write(str: Uint8Array | string, encoding?: string, cb?: (err?: Error) => void): boolean;
|
||||||
/**
|
|
||||||
* Initiate a connection on a given socket.
|
|
||||||
*
|
|
||||||
* Possible signatures:
|
|
||||||
*
|
|
||||||
* * `socket.connect(options[, connectListener])`
|
|
||||||
* * `socket.connect(path[, connectListener])` for `IPC` connections.
|
|
||||||
* * `socket.connect(port[, host][, connectListener])` for TCP connections.
|
|
||||||
* * Returns: `net.Socket` The socket itself.
|
|
||||||
*
|
|
||||||
* This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting,
|
|
||||||
* instead of a `'connect'` event, an `'error'` event will be emitted with
|
|
||||||
* the error passed to the `'error'` listener.
|
|
||||||
* The last parameter `connectListener`, if supplied, will be added as a listener
|
|
||||||
* for the `'connect'` event **once**.
|
|
||||||
*
|
|
||||||
* This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined
|
|
||||||
* behavior.
|
|
||||||
*/
|
|
||||||
connect(options: SocketConnectOpts, connectionListener?: () => void): this;
|
connect(options: SocketConnectOpts, connectionListener?: () => void): this;
|
||||||
connect(port: number, host: string, connectionListener?: () => void): this;
|
connect(port: number, host: string, connectionListener?: () => void): this;
|
||||||
connect(port: number, connectionListener?: () => void): this;
|
connect(port: number, connectionListener?: () => void): this;
|
||||||
connect(path: string, connectionListener?: () => void): this;
|
connect(path: string, connectionListener?: () => void): this;
|
||||||
/**
|
|
||||||
* Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information.
|
setEncoding(encoding?: string): this;
|
||||||
* @since v0.1.90
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
setEncoding(encoding?: BufferEncoding): this;
|
|
||||||
/**
|
|
||||||
* Pauses the reading of data. That is, `'data'` events will not be emitted.
|
|
||||||
* Useful to throttle back an upload.
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
pause(): this;
|
pause(): this;
|
||||||
/**
|
|
||||||
* Resumes reading after a call to `socket.pause()`.
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
resume(): this;
|
resume(): this;
|
||||||
/**
|
|
||||||
* Sets the socket to timeout after `timeout` milliseconds of inactivity on
|
|
||||||
* the socket. By default `net.Socket` do not have a timeout.
|
|
||||||
*
|
|
||||||
* When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to
|
|
||||||
* end the connection.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* socket.setTimeout(3000);
|
|
||||||
* socket.on('timeout', () => {
|
|
||||||
* console.log('socket timeout');
|
|
||||||
* socket.end();
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If `timeout` is 0, then the existing idle timeout is disabled.
|
|
||||||
*
|
|
||||||
* The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event.
|
|
||||||
* @since v0.1.90
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
setTimeout(timeout: number, callback?: () => void): this;
|
setTimeout(timeout: number, callback?: () => void): this;
|
||||||
/**
|
|
||||||
* Enable/disable the use of Nagle's algorithm.
|
|
||||||
*
|
|
||||||
* When a TCP connection is created, it will have Nagle's algorithm enabled.
|
|
||||||
*
|
|
||||||
* Nagle's algorithm delays data before it is sent via the network. It attempts
|
|
||||||
* to optimize throughput at the expense of latency.
|
|
||||||
*
|
|
||||||
* Passing `true` for `noDelay` or not passing an argument will disable Nagle's
|
|
||||||
* algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's
|
|
||||||
* algorithm.
|
|
||||||
* @since v0.1.90
|
|
||||||
* @param [noDelay=true]
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
setNoDelay(noDelay?: boolean): this;
|
setNoDelay(noDelay?: boolean): this;
|
||||||
/**
|
|
||||||
* Enable/disable keep-alive functionality, and optionally set the initial
|
|
||||||
* delay before the first keepalive probe is sent on an idle socket.
|
|
||||||
*
|
|
||||||
* Set `initialDelay` (in milliseconds) to set the delay between the last
|
|
||||||
* data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default
|
|
||||||
* (or previous) setting.
|
|
||||||
*
|
|
||||||
* Enabling the keep-alive functionality will set the following socket options:
|
|
||||||
*
|
|
||||||
* * `SO_KEEPALIVE=1`
|
|
||||||
* * `TCP_KEEPIDLE=initialDelay`
|
|
||||||
* * `TCP_KEEPCNT=10`
|
|
||||||
* * `TCP_KEEPINTVL=1`
|
|
||||||
* @since v0.1.92
|
|
||||||
* @param [enable=false]
|
|
||||||
* @param [initialDelay=0]
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
setKeepAlive(enable?: boolean, initialDelay?: number): this;
|
setKeepAlive(enable?: boolean, initialDelay?: number): this;
|
||||||
/**
|
address(): AddressInfo | string;
|
||||||
* Returns the bound `address`, the address `family` name and `port` of the
|
unref(): void;
|
||||||
* socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
|
ref(): void;
|
||||||
* @since v0.1.90
|
|
||||||
*/
|
|
||||||
address(): AddressInfo | {};
|
|
||||||
/**
|
|
||||||
* Calling `unref()` on a socket will allow the program to exit if this is the only
|
|
||||||
* active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect.
|
|
||||||
* @since v0.9.1
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
unref(): this;
|
|
||||||
/**
|
|
||||||
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will_not_ let the program exit if it's the only socket left (the default behavior).
|
|
||||||
* If the socket is `ref`ed calling `ref` again will have no effect.
|
|
||||||
* @since v0.9.1
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
ref(): this;
|
|
||||||
/**
|
|
||||||
* This property shows the number of characters buffered for writing. The buffer
|
|
||||||
* may contain strings whose length after encoding is not yet known. So this number
|
|
||||||
* is only an approximation of the number of bytes in the buffer.
|
|
||||||
*
|
|
||||||
* `net.Socket` has the property that `socket.write()` always works. This is to
|
|
||||||
* help users get up and running quickly. The computer cannot always keep up
|
|
||||||
* with the amount of data that is written to a socket. The network connection
|
|
||||||
* simply might be too slow. Node.js will internally queue up the data written to a
|
|
||||||
* socket and send it out over the wire when it is possible.
|
|
||||||
*
|
|
||||||
* The consequence of this internal buffering is that memory may grow.
|
|
||||||
* Users who experience large or growing `bufferSize` should attempt to
|
|
||||||
* "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`.
|
|
||||||
* @since v0.3.8
|
|
||||||
* @deprecated Since v14.6.0 - Use `writableLength` instead.
|
|
||||||
*/
|
|
||||||
readonly bufferSize: number;
|
readonly bufferSize: number;
|
||||||
/**
|
|
||||||
* The amount of received bytes.
|
|
||||||
* @since v0.5.3
|
|
||||||
*/
|
|
||||||
readonly bytesRead: number;
|
readonly bytesRead: number;
|
||||||
/**
|
|
||||||
* The amount of bytes sent.
|
|
||||||
* @since v0.5.3
|
|
||||||
*/
|
|
||||||
readonly bytesWritten: number;
|
readonly bytesWritten: number;
|
||||||
/**
|
|
||||||
* If `true`,`socket.connect(options[, connectListener])` was
|
|
||||||
* called and has not yet finished. It will stay `true` until the socket becomes
|
|
||||||
* connected, then it is set to `false` and the `'connect'` event is emitted. Note
|
|
||||||
* that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event.
|
|
||||||
* @since v6.1.0
|
|
||||||
*/
|
|
||||||
readonly connecting: boolean;
|
readonly connecting: boolean;
|
||||||
/**
|
|
||||||
* See `writable.destroyed` for further details.
|
|
||||||
*/
|
|
||||||
readonly destroyed: boolean;
|
readonly destroyed: boolean;
|
||||||
/**
|
readonly localAddress: string;
|
||||||
* The string representation of the local IP address the remote client is
|
readonly localPort: number;
|
||||||
* connecting on. For example, in a server listening on `'0.0.0.0'`, if a client
|
readonly remoteAddress?: string;
|
||||||
* connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`.
|
readonly remoteFamily?: string;
|
||||||
* @since v0.9.6
|
readonly remotePort?: number;
|
||||||
*/
|
|
||||||
readonly localAddress?: string;
|
// Extended base methods
|
||||||
/**
|
end(cb?: () => void): void;
|
||||||
* The numeric representation of the local port. For example, `80` or `21`.
|
end(buffer: Uint8Array | string, cb?: () => void): void;
|
||||||
* @since v0.9.6
|
end(str: Uint8Array | string, encoding?: string, cb?: () => void): void;
|
||||||
*/
|
|
||||||
readonly localPort?: number;
|
|
||||||
/**
|
|
||||||
* The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
|
|
||||||
* the socket is destroyed (for example, if the client disconnected).
|
|
||||||
* @since v0.5.10
|
|
||||||
*/
|
|
||||||
readonly remoteAddress?: string | undefined;
|
|
||||||
/**
|
|
||||||
* The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
|
|
||||||
* @since v0.11.14
|
|
||||||
*/
|
|
||||||
readonly remoteFamily?: string | undefined;
|
|
||||||
/**
|
|
||||||
* The numeric representation of the remote port. For example, `80` or `21`.
|
|
||||||
* @since v0.5.10
|
|
||||||
*/
|
|
||||||
readonly remotePort?: number | undefined;
|
|
||||||
/**
|
|
||||||
* Half-closes the socket. i.e., it sends a FIN packet. It is possible the
|
|
||||||
* server will still send some data.
|
|
||||||
*
|
|
||||||
* See `writable.end()` for further details.
|
|
||||||
* @since v0.1.90
|
|
||||||
* @param [encoding='utf8'] Only used when data is `string`.
|
|
||||||
* @param callback Optional callback for when the socket is finished.
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
end(callback?: () => void): void;
|
|
||||||
end(buffer: Uint8Array | string, callback?: () => void): void;
|
|
||||||
end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): void;
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. close
|
* 1. close
|
||||||
@@ -303,139 +103,85 @@ declare module 'net' {
|
|||||||
* 8. timeout
|
* 8. timeout
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: (hadError: boolean) => void): this;
|
addListener(event: "close", listener: (had_error: boolean) => void): this;
|
||||||
addListener(event: 'connect', listener: () => void): this;
|
addListener(event: "connect", listener: () => void): this;
|
||||||
addListener(event: 'data', listener: (data: Buffer) => void): this;
|
addListener(event: "data", listener: (data: Buffer) => void): this;
|
||||||
addListener(event: 'drain', listener: () => void): this;
|
addListener(event: "drain", listener: () => void): this;
|
||||||
addListener(event: 'end', listener: () => void): this;
|
addListener(event: "end", listener: () => void): this;
|
||||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
addListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||||
addListener(event: 'ready', listener: () => void): this;
|
addListener(event: "timeout", listener: () => void): this;
|
||||||
addListener(event: 'timeout', listener: () => void): this;
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'close', hadError: boolean): boolean;
|
emit(event: "close", had_error: boolean): boolean;
|
||||||
emit(event: 'connect'): boolean;
|
emit(event: "connect"): boolean;
|
||||||
emit(event: 'data', data: Buffer): boolean;
|
emit(event: "data", data: Buffer): boolean;
|
||||||
emit(event: 'drain'): boolean;
|
emit(event: "drain"): boolean;
|
||||||
emit(event: 'end'): boolean;
|
emit(event: "end"): boolean;
|
||||||
emit(event: 'error', err: Error): boolean;
|
emit(event: "error", err: Error): boolean;
|
||||||
emit(event: 'lookup', err: Error, address: string, family: string | number, host: string): boolean;
|
emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean;
|
||||||
emit(event: 'ready'): boolean;
|
emit(event: "timeout"): boolean;
|
||||||
emit(event: 'timeout'): boolean;
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'close', listener: (hadError: boolean) => void): this;
|
on(event: "close", listener: (had_error: boolean) => void): this;
|
||||||
on(event: 'connect', listener: () => void): this;
|
on(event: "connect", listener: () => void): this;
|
||||||
on(event: 'data', listener: (data: Buffer) => void): this;
|
on(event: "data", listener: (data: Buffer) => void): this;
|
||||||
on(event: 'drain', listener: () => void): this;
|
on(event: "drain", listener: () => void): this;
|
||||||
on(event: 'end', listener: () => void): this;
|
on(event: "end", listener: () => void): this;
|
||||||
on(event: 'error', listener: (err: Error) => void): this;
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
on(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||||
on(event: 'ready', listener: () => void): this;
|
on(event: "timeout", listener: () => void): this;
|
||||||
on(event: 'timeout', listener: () => void): this;
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'close', listener: (hadError: boolean) => void): this;
|
once(event: "close", listener: (had_error: boolean) => void): this;
|
||||||
once(event: 'connect', listener: () => void): this;
|
once(event: "connect", listener: () => void): this;
|
||||||
once(event: 'data', listener: (data: Buffer) => void): this;
|
once(event: "data", listener: (data: Buffer) => void): this;
|
||||||
once(event: 'drain', listener: () => void): this;
|
once(event: "drain", listener: () => void): this;
|
||||||
once(event: 'end', listener: () => void): this;
|
once(event: "end", listener: () => void): this;
|
||||||
once(event: 'error', listener: (err: Error) => void): this;
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
once(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||||
once(event: 'ready', listener: () => void): this;
|
once(event: "timeout", listener: () => void): this;
|
||||||
once(event: 'timeout', listener: () => void): this;
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'close', listener: (hadError: boolean) => void): this;
|
prependListener(event: "close", listener: (had_error: boolean) => void): this;
|
||||||
prependListener(event: 'connect', listener: () => void): this;
|
prependListener(event: "connect", listener: () => void): this;
|
||||||
prependListener(event: 'data', listener: (data: Buffer) => void): this;
|
prependListener(event: "data", listener: (data: Buffer) => void): this;
|
||||||
prependListener(event: 'drain', listener: () => void): this;
|
prependListener(event: "drain", listener: () => void): this;
|
||||||
prependListener(event: 'end', listener: () => void): this;
|
prependListener(event: "end", listener: () => void): this;
|
||||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||||
prependListener(event: 'ready', listener: () => void): this;
|
prependListener(event: "timeout", listener: () => void): this;
|
||||||
prependListener(event: 'timeout', listener: () => void): this;
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'close', listener: (hadError: boolean) => void): this;
|
prependOnceListener(event: "close", listener: (had_error: boolean) => void): this;
|
||||||
prependOnceListener(event: 'connect', listener: () => void): this;
|
prependOnceListener(event: "connect", listener: () => void): this;
|
||||||
prependOnceListener(event: 'data', listener: (data: Buffer) => void): this;
|
prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
|
||||||
prependOnceListener(event: 'drain', listener: () => void): this;
|
prependOnceListener(event: "drain", listener: () => void): this;
|
||||||
prependOnceListener(event: 'end', listener: () => void): this;
|
prependOnceListener(event: "end", listener: () => void): this;
|
||||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependOnceListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||||
prependOnceListener(event: 'ready', listener: () => void): this;
|
prependOnceListener(event: "timeout", listener: () => void): this;
|
||||||
prependOnceListener(event: 'timeout', listener: () => void): this;
|
|
||||||
}
|
}
|
||||||
interface ListenOptions extends Abortable {
|
|
||||||
port?: number | undefined;
|
interface ListenOptions {
|
||||||
host?: string | undefined;
|
port?: number;
|
||||||
backlog?: number | undefined;
|
host?: string;
|
||||||
path?: string | undefined;
|
backlog?: number;
|
||||||
exclusive?: boolean | undefined;
|
path?: string;
|
||||||
readableAll?: boolean | undefined;
|
exclusive?: boolean;
|
||||||
writableAll?: boolean | undefined;
|
readableAll?: boolean;
|
||||||
|
writableAll?: boolean;
|
||||||
/**
|
/**
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
ipv6Only?: boolean | undefined;
|
ipv6Only?: boolean;
|
||||||
}
|
}
|
||||||
interface ServerOpts {
|
|
||||||
/**
|
// https://github.com/nodejs/node/blob/master/lib/net.js
|
||||||
* Indicates whether half-opened TCP connections are allowed.
|
class Server extends events.EventEmitter {
|
||||||
* @default false
|
|
||||||
*/
|
|
||||||
allowHalfOpen?: boolean | undefined;
|
|
||||||
/**
|
|
||||||
* Indicates whether the socket should be paused on incoming connections.
|
|
||||||
* @default false
|
|
||||||
*/
|
|
||||||
pauseOnConnect?: boolean | undefined;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* This class is used to create a TCP or `IPC` server.
|
|
||||||
* @since v0.1.90
|
|
||||||
*/
|
|
||||||
class Server extends EventEmitter {
|
|
||||||
constructor(connectionListener?: (socket: Socket) => void);
|
constructor(connectionListener?: (socket: Socket) => void);
|
||||||
constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
|
constructor(options?: { allowHalfOpen?: boolean, pauseOnConnect?: boolean }, connectionListener?: (socket: Socket) => void);
|
||||||
/**
|
|
||||||
* Start a server listening for connections. A `net.Server` can be a TCP or
|
|
||||||
* an `IPC` server depending on what it listens to.
|
|
||||||
*
|
|
||||||
* Possible signatures:
|
|
||||||
*
|
|
||||||
* * `server.listen(handle[, backlog][, callback])`
|
|
||||||
* * `server.listen(options[, callback])`
|
|
||||||
* * `server.listen(path[, backlog][, callback])` for `IPC` servers
|
|
||||||
* * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers
|
|
||||||
*
|
|
||||||
* This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'`
|
|
||||||
* event.
|
|
||||||
*
|
|
||||||
* All `listen()` methods can take a `backlog` parameter to specify the maximum
|
|
||||||
* length of the queue of pending connections. The actual length will be determined
|
|
||||||
* by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn`on Linux. The default value of this parameter is 511 (not 512).
|
|
||||||
*
|
|
||||||
* All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for
|
|
||||||
* details).
|
|
||||||
*
|
|
||||||
* The `server.listen()` method can be called again if and only if there was an
|
|
||||||
* error during the first `server.listen()` call or `server.close()` has been
|
|
||||||
* called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown.
|
|
||||||
*
|
|
||||||
* One of the most common errors raised when listening is `EADDRINUSE`.
|
|
||||||
* This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry
|
|
||||||
* after a certain amount of time:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* server.on('error', (e) => {
|
|
||||||
* if (e.code === 'EADDRINUSE') {
|
|
||||||
* console.log('Address in use, retrying...');
|
|
||||||
* setTimeout(() => {
|
|
||||||
* server.close();
|
|
||||||
* server.listen(PORT, HOST);
|
|
||||||
* }, 1000);
|
|
||||||
* }
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
|
listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
|
||||||
listen(port?: number, hostname?: string, listeningListener?: () => void): this;
|
listen(port?: number, hostname?: string, listeningListener?: () => void): this;
|
||||||
listen(port?: number, backlog?: number, listeningListener?: () => void): this;
|
listen(port?: number, backlog?: number, listeningListener?: () => void): this;
|
||||||
@@ -445,79 +191,15 @@ declare module 'net' {
|
|||||||
listen(options: ListenOptions, listeningListener?: () => void): this;
|
listen(options: ListenOptions, listeningListener?: () => void): this;
|
||||||
listen(handle: any, backlog?: number, listeningListener?: () => void): this;
|
listen(handle: any, backlog?: number, listeningListener?: () => void): this;
|
||||||
listen(handle: any, listeningListener?: () => void): this;
|
listen(handle: any, listeningListener?: () => void): this;
|
||||||
/**
|
|
||||||
* Stops the server from accepting new connections and keeps existing
|
|
||||||
* connections. This function is asynchronous, the server is finally closed
|
|
||||||
* when all connections are ended and the server emits a `'close'` event.
|
|
||||||
* The optional `callback` will be called once the `'close'` event occurs. Unlike
|
|
||||||
* that event, it will be called with an `Error` as its only argument if the server
|
|
||||||
* was not open when it was closed.
|
|
||||||
* @since v0.1.90
|
|
||||||
* @param callback Called when the server is closed.
|
|
||||||
*/
|
|
||||||
close(callback?: (err?: Error) => void): this;
|
close(callback?: (err?: Error) => void): this;
|
||||||
/**
|
|
||||||
* Returns the bound `address`, the address `family` name, and `port` of the server
|
|
||||||
* as reported by the operating system if listening on an IP socket
|
|
||||||
* (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
|
|
||||||
*
|
|
||||||
* For a server listening on a pipe or Unix domain socket, the name is returned
|
|
||||||
* as a string.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const server = net.createServer((socket) => {
|
|
||||||
* socket.end('goodbye\n');
|
|
||||||
* }).on('error', (err) => {
|
|
||||||
* // Handle errors here.
|
|
||||||
* throw err;
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* // Grab an arbitrary unused port.
|
|
||||||
* server.listen(() => {
|
|
||||||
* console.log('opened server on', server.address());
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* `server.address()` returns `null` before the `'listening'` event has been
|
|
||||||
* emitted or after calling `server.close()`.
|
|
||||||
* @since v0.1.90
|
|
||||||
*/
|
|
||||||
address(): AddressInfo | string | null;
|
address(): AddressInfo | string | null;
|
||||||
/**
|
|
||||||
* Asynchronously get the number of concurrent connections on the server. Works
|
|
||||||
* when sockets were sent to forks.
|
|
||||||
*
|
|
||||||
* Callback should take two arguments `err` and `count`.
|
|
||||||
* @since v0.9.7
|
|
||||||
*/
|
|
||||||
getConnections(cb: (error: Error | null, count: number) => void): void;
|
getConnections(cb: (error: Error | null, count: number) => void): void;
|
||||||
/**
|
|
||||||
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will_not_ let the program exit if it's the only server left (the default behavior).
|
|
||||||
* If the server is `ref`ed calling `ref()` again will have no effect.
|
|
||||||
* @since v0.9.1
|
|
||||||
*/
|
|
||||||
ref(): this;
|
ref(): this;
|
||||||
/**
|
|
||||||
* Calling `unref()` on a server will allow the program to exit if this is the only
|
|
||||||
* active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect.
|
|
||||||
* @since v0.9.1
|
|
||||||
*/
|
|
||||||
unref(): this;
|
unref(): this;
|
||||||
/**
|
|
||||||
* Set this property to reject connections when the server's connection count gets
|
|
||||||
* high.
|
|
||||||
*
|
|
||||||
* It is not recommended to use this option once a socket has been sent to a child
|
|
||||||
* with `child_process.fork()`.
|
|
||||||
* @since v0.2.0
|
|
||||||
*/
|
|
||||||
maxConnections: number;
|
maxConnections: number;
|
||||||
connections: number;
|
connections: number;
|
||||||
/**
|
|
||||||
* Indicates whether or not the server is listening for connections.
|
|
||||||
* @since v5.7.0
|
|
||||||
*/
|
|
||||||
listening: boolean;
|
listening: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. close
|
* 1. close
|
||||||
@@ -526,259 +208,61 @@ declare module 'net' {
|
|||||||
* 4. listening
|
* 4. listening
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: () => void): this;
|
addListener(event: "close", listener: () => void): this;
|
||||||
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
addListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
addListener(event: 'listening', listener: () => void): this;
|
addListener(event: "listening", listener: () => void): this;
|
||||||
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'close'): boolean;
|
emit(event: "close"): boolean;
|
||||||
emit(event: 'connection', socket: Socket): boolean;
|
emit(event: "connection", socket: Socket): boolean;
|
||||||
emit(event: 'error', err: Error): boolean;
|
emit(event: "error", err: Error): boolean;
|
||||||
emit(event: 'listening'): boolean;
|
emit(event: "listening"): boolean;
|
||||||
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'close', listener: () => void): this;
|
on(event: "close", listener: () => void): this;
|
||||||
on(event: 'connection', listener: (socket: Socket) => void): this;
|
on(event: "connection", listener: (socket: Socket) => void): this;
|
||||||
on(event: 'error', listener: (err: Error) => void): this;
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
on(event: 'listening', listener: () => void): this;
|
on(event: "listening", listener: () => void): this;
|
||||||
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'close', listener: () => void): this;
|
once(event: "close", listener: () => void): this;
|
||||||
once(event: 'connection', listener: (socket: Socket) => void): this;
|
once(event: "connection", listener: (socket: Socket) => void): this;
|
||||||
once(event: 'error', listener: (err: Error) => void): this;
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
once(event: 'listening', listener: () => void): this;
|
once(event: "listening", listener: () => void): this;
|
||||||
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'close', listener: () => void): this;
|
prependListener(event: "close", listener: () => void): this;
|
||||||
prependListener(event: 'connection', listener: (socket: Socket) => void): this;
|
prependListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependListener(event: 'listening', listener: () => void): this;
|
prependListener(event: "listening", listener: () => void): this;
|
||||||
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'close', listener: () => void): this;
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
|
prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
prependOnceListener(event: "listening", listener: () => void): this;
|
||||||
}
|
|
||||||
type IPVersion = 'ipv4' | 'ipv6';
|
|
||||||
/**
|
|
||||||
* The `BlockList` object can be used with some network APIs to specify rules for
|
|
||||||
* disabling inbound or outbound access to specific IP addresses, IP ranges, or
|
|
||||||
* IP subnets.
|
|
||||||
* @since v15.0.0
|
|
||||||
*/
|
|
||||||
class BlockList {
|
|
||||||
/**
|
|
||||||
* Adds a rule to block the given IP address.
|
|
||||||
* @since v15.0.0
|
|
||||||
* @param address An IPv4 or IPv6 address.
|
|
||||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
|
||||||
*/
|
|
||||||
addAddress(address: string, type?: IPVersion): void;
|
|
||||||
addAddress(address: SocketAddress): void;
|
|
||||||
/**
|
|
||||||
* Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
|
|
||||||
* @since v15.0.0
|
|
||||||
* @param start The starting IPv4 or IPv6 address in the range.
|
|
||||||
* @param end The ending IPv4 or IPv6 address in the range.
|
|
||||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
|
||||||
*/
|
|
||||||
addRange(start: string, end: string, type?: IPVersion): void;
|
|
||||||
addRange(start: SocketAddress, end: SocketAddress): void;
|
|
||||||
/**
|
|
||||||
* Adds a rule to block a range of IP addresses specified as a subnet mask.
|
|
||||||
* @since v15.0.0
|
|
||||||
* @param net The network IPv4 or IPv6 address.
|
|
||||||
* @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`.
|
|
||||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
|
||||||
*/
|
|
||||||
addSubnet(net: SocketAddress, prefix: number): void;
|
|
||||||
addSubnet(net: string, prefix: number, type?: IPVersion): void;
|
|
||||||
/**
|
|
||||||
* Returns `true` if the given IP address matches any of the rules added to the`BlockList`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const blockList = new net.BlockList();
|
|
||||||
* blockList.addAddress('123.123.123.123');
|
|
||||||
* blockList.addRange('10.0.0.1', '10.0.0.10');
|
|
||||||
* blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');
|
|
||||||
*
|
|
||||||
* console.log(blockList.check('123.123.123.123')); // Prints: true
|
|
||||||
* console.log(blockList.check('10.0.0.3')); // Prints: true
|
|
||||||
* console.log(blockList.check('222.111.111.222')); // Prints: false
|
|
||||||
*
|
|
||||||
* // IPv6 notation for IPv4 addresses works:
|
|
||||||
* console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
|
|
||||||
* console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true
|
|
||||||
* ```
|
|
||||||
* @since v15.0.0
|
|
||||||
* @param address The IP address to check
|
|
||||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
|
||||||
*/
|
|
||||||
check(address: SocketAddress): boolean;
|
|
||||||
check(address: string, type?: IPVersion): boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
||||||
timeout?: number | undefined;
|
timeout?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
|
interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
|
||||||
timeout?: number | undefined;
|
timeout?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
|
type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
|
||||||
/**
|
|
||||||
* Creates a new TCP or `IPC` server.
|
|
||||||
*
|
|
||||||
* If `allowHalfOpen` is set to `true`, when the other end of the socket
|
|
||||||
* signals the end of transmission, the server will only send back the end of
|
|
||||||
* transmission when `socket.end()` is explicitly called. For example, in the
|
|
||||||
* context of TCP, when a FIN packed is received, a FIN packed is sent
|
|
||||||
* back only when `socket.end()` is explicitly called. Until then the
|
|
||||||
* connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information.
|
|
||||||
*
|
|
||||||
* If `pauseOnConnect` is set to `true`, then the socket associated with each
|
|
||||||
* incoming connection will be paused, and no data will be read from its handle.
|
|
||||||
* This allows connections to be passed between processes without any data being
|
|
||||||
* read by the original process. To begin reading data from a paused socket, call `socket.resume()`.
|
|
||||||
*
|
|
||||||
* The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
|
|
||||||
*
|
|
||||||
* Here is an example of an TCP echo server which listens for connections
|
|
||||||
* on port 8124:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const net = require('net');
|
|
||||||
* const server = net.createServer((c) => {
|
|
||||||
* // 'connection' listener.
|
|
||||||
* console.log('client connected');
|
|
||||||
* c.on('end', () => {
|
|
||||||
* console.log('client disconnected');
|
|
||||||
* });
|
|
||||||
* c.write('hello\r\n');
|
|
||||||
* c.pipe(c);
|
|
||||||
* });
|
|
||||||
* server.on('error', (err) => {
|
|
||||||
* throw err;
|
|
||||||
* });
|
|
||||||
* server.listen(8124, () => {
|
|
||||||
* console.log('server bound');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Test this by using `telnet`:
|
|
||||||
*
|
|
||||||
* ```console
|
|
||||||
* $ telnet localhost 8124
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* To listen on the socket `/tmp/echo.sock`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* server.listen('/tmp/echo.sock', () => {
|
|
||||||
* console.log('server bound');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Use `nc` to connect to a Unix domain socket server:
|
|
||||||
*
|
|
||||||
* ```console
|
|
||||||
* $ nc -U /tmp/echo.sock
|
|
||||||
* ```
|
|
||||||
* @since v0.5.0
|
|
||||||
* @param connectionListener Automatically set as a listener for the {@link 'connection'} event.
|
|
||||||
*/
|
|
||||||
function createServer(connectionListener?: (socket: Socket) => void): Server;
|
function createServer(connectionListener?: (socket: Socket) => void): Server;
|
||||||
function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server;
|
function createServer(options?: { allowHalfOpen?: boolean, pauseOnConnect?: boolean }, connectionListener?: (socket: Socket) => void): Server;
|
||||||
/**
|
|
||||||
* Aliases to {@link createConnection}.
|
|
||||||
*
|
|
||||||
* Possible signatures:
|
|
||||||
*
|
|
||||||
* * {@link connect}
|
|
||||||
* * {@link connect} for `IPC` connections.
|
|
||||||
* * {@link connect} for TCP connections.
|
|
||||||
*/
|
|
||||||
function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
||||||
function connect(port: number, host?: string, connectionListener?: () => void): Socket;
|
function connect(port: number, host?: string, connectionListener?: () => void): Socket;
|
||||||
function connect(path: string, connectionListener?: () => void): Socket;
|
function connect(path: string, connectionListener?: () => void): Socket;
|
||||||
/**
|
|
||||||
* A factory function, which creates a new {@link Socket},
|
|
||||||
* immediately initiates connection with `socket.connect()`,
|
|
||||||
* then returns the `net.Socket` that starts the connection.
|
|
||||||
*
|
|
||||||
* When the connection is established, a `'connect'` event will be emitted
|
|
||||||
* on the returned socket. The last parameter `connectListener`, if supplied,
|
|
||||||
* will be added as a listener for the `'connect'` event **once**.
|
|
||||||
*
|
|
||||||
* Possible signatures:
|
|
||||||
*
|
|
||||||
* * {@link createConnection}
|
|
||||||
* * {@link createConnection} for `IPC` connections.
|
|
||||||
* * {@link createConnection} for TCP connections.
|
|
||||||
*
|
|
||||||
* The {@link connect} function is an alias to this function.
|
|
||||||
*/
|
|
||||||
function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
||||||
function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
|
function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
|
||||||
function createConnection(path: string, connectionListener?: () => void): Socket;
|
function createConnection(path: string, connectionListener?: () => void): Socket;
|
||||||
/**
|
|
||||||
* Tests if input is an IP address. Returns `0` for invalid strings,
|
|
||||||
* returns `4` for IP version 4 addresses, and returns `6` for IP version 6
|
|
||||||
* addresses.
|
|
||||||
* @since v0.3.0
|
|
||||||
*/
|
|
||||||
function isIP(input: string): number;
|
function isIP(input: string): number;
|
||||||
/**
|
|
||||||
* Returns `true` if input is a version 4 IP address, otherwise returns `false`.
|
|
||||||
* @since v0.3.0
|
|
||||||
*/
|
|
||||||
function isIPv4(input: string): boolean;
|
function isIPv4(input: string): boolean;
|
||||||
/**
|
|
||||||
* Returns `true` if input is a version 6 IP address, otherwise returns `false`.
|
|
||||||
* @since v0.3.0
|
|
||||||
*/
|
|
||||||
function isIPv6(input: string): boolean;
|
function isIPv6(input: string): boolean;
|
||||||
interface SocketAddressInitOptions {
|
|
||||||
/**
|
|
||||||
* The network address as either an IPv4 or IPv6 string.
|
|
||||||
* @default 127.0.0.1
|
|
||||||
*/
|
|
||||||
address?: string | undefined;
|
|
||||||
/**
|
|
||||||
* @default `'ipv4'`
|
|
||||||
*/
|
|
||||||
family?: IPVersion | undefined;
|
|
||||||
/**
|
|
||||||
* An IPv6 flow-label used only if `family` is `'ipv6'`.
|
|
||||||
* @default 0
|
|
||||||
*/
|
|
||||||
flowlabel?: number | undefined;
|
|
||||||
/**
|
|
||||||
* An IP port.
|
|
||||||
* @default 0
|
|
||||||
*/
|
|
||||||
port?: number | undefined;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @since v15.14.0
|
|
||||||
*/
|
|
||||||
class SocketAddress {
|
|
||||||
constructor(options: SocketAddressInitOptions);
|
|
||||||
/**
|
|
||||||
* Either \`'ipv4'\` or \`'ipv6'\`.
|
|
||||||
* @since v15.14.0
|
|
||||||
*/
|
|
||||||
readonly address: string;
|
|
||||||
/**
|
|
||||||
* Either \`'ipv4'\` or \`'ipv6'\`.
|
|
||||||
* @since v15.14.0
|
|
||||||
*/
|
|
||||||
readonly family: IPVersion;
|
|
||||||
/**
|
|
||||||
* @since v15.14.0
|
|
||||||
*/
|
|
||||||
readonly port: number;
|
|
||||||
/**
|
|
||||||
* @since v15.14.0
|
|
||||||
*/
|
|
||||||
readonly flowlabel: number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
declare module 'node:net' {
|
|
||||||
export * from 'net';
|
|
||||||
}
|
}
|
||||||
|
|||||||
610
node_modules/@types/node/os.d.ts
generated
vendored
Executable file → Normal file
610
node_modules/@types/node/os.d.ts
generated
vendored
Executable file → Normal file
@@ -1,13 +1,4 @@
|
|||||||
/**
|
declare module "os" {
|
||||||
* The `os` module provides operating system-related utility methods and
|
|
||||||
* properties. It can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const os = require('os');
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/os.js)
|
|
||||||
*/
|
|
||||||
declare module 'os' {
|
|
||||||
interface CpuInfo {
|
interface CpuInfo {
|
||||||
model: string;
|
model: string;
|
||||||
speed: number;
|
speed: number;
|
||||||
@@ -19,6 +10,7 @@ declare module 'os' {
|
|||||||
irq: number;
|
irq: number;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NetworkInterfaceBase {
|
interface NetworkInterfaceBase {
|
||||||
address: string;
|
address: string;
|
||||||
netmask: string;
|
netmask: string;
|
||||||
@@ -26,13 +18,16 @@ declare module 'os' {
|
|||||||
internal: boolean;
|
internal: boolean;
|
||||||
cidr: string | null;
|
cidr: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
||||||
family: 'IPv4';
|
family: "IPv4";
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
||||||
family: 'IPv6';
|
family: "IPv6";
|
||||||
scopeid: number;
|
scopeid: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UserInfo<T> {
|
interface UserInfo<T> {
|
||||||
username: T;
|
username: T;
|
||||||
uid: number;
|
uid: number;
|
||||||
@@ -40,416 +35,229 @@ declare module 'os' {
|
|||||||
shell: T;
|
shell: T;
|
||||||
homedir: T;
|
homedir: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
|
type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
|
||||||
/**
|
|
||||||
* Returns the host name of the operating system as a string.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function hostname(): string;
|
function hostname(): string;
|
||||||
/**
|
|
||||||
* Returns an array containing the 1, 5, and 15 minute load averages.
|
|
||||||
*
|
|
||||||
* The load average is a measure of system activity calculated by the operating
|
|
||||||
* system and expressed as a fractional number.
|
|
||||||
*
|
|
||||||
* The load average is a Unix-specific concept. On Windows, the return value is
|
|
||||||
* always `[0, 0, 0]`.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function loadavg(): number[];
|
function loadavg(): number[];
|
||||||
/**
|
|
||||||
* Returns the system uptime in number of seconds.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function uptime(): number;
|
function uptime(): number;
|
||||||
/**
|
|
||||||
* Returns the amount of free system memory in bytes as an integer.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function freemem(): number;
|
function freemem(): number;
|
||||||
/**
|
|
||||||
* Returns the total amount of system memory in bytes as an integer.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function totalmem(): number;
|
function totalmem(): number;
|
||||||
/**
|
|
||||||
* Returns an array of objects containing information about each logical CPU core.
|
|
||||||
*
|
|
||||||
* The properties included on each object include:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* [
|
|
||||||
* {
|
|
||||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
|
||||||
* speed: 2926,
|
|
||||||
* times: {
|
|
||||||
* user: 252020,
|
|
||||||
* nice: 0,
|
|
||||||
* sys: 30340,
|
|
||||||
* idle: 1070356870,
|
|
||||||
* irq: 0
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
|
||||||
* speed: 2926,
|
|
||||||
* times: {
|
|
||||||
* user: 306960,
|
|
||||||
* nice: 0,
|
|
||||||
* sys: 26980,
|
|
||||||
* idle: 1071569080,
|
|
||||||
* irq: 0
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
|
||||||
* speed: 2926,
|
|
||||||
* times: {
|
|
||||||
* user: 248450,
|
|
||||||
* nice: 0,
|
|
||||||
* sys: 21750,
|
|
||||||
* idle: 1070919370,
|
|
||||||
* irq: 0
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
|
||||||
* speed: 2926,
|
|
||||||
* times: {
|
|
||||||
* user: 256880,
|
|
||||||
* nice: 0,
|
|
||||||
* sys: 19430,
|
|
||||||
* idle: 1070905480,
|
|
||||||
* irq: 20
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* ]
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* `nice` values are POSIX-only. On Windows, the `nice` values of all processors
|
|
||||||
* are always 0.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function cpus(): CpuInfo[];
|
function cpus(): CpuInfo[];
|
||||||
/**
|
|
||||||
* Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it
|
|
||||||
* returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows.
|
|
||||||
*
|
|
||||||
* See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for additional information
|
|
||||||
* about the output of running [`uname(3)`](https://linux.die.net/man/3/uname) on various operating systems.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function type(): string;
|
function type(): string;
|
||||||
/**
|
|
||||||
* Returns the operating system as a string.
|
|
||||||
*
|
|
||||||
* On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `GetVersionExW()` is used. See
|
|
||||||
* [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function release(): string;
|
function release(): string;
|
||||||
/**
|
function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] };
|
||||||
* Returns an object containing network interfaces that have been assigned a
|
|
||||||
* network address.
|
|
||||||
*
|
|
||||||
* Each key on the returned object identifies a network interface. The associated
|
|
||||||
* value is an array of objects that each describe an assigned network address.
|
|
||||||
*
|
|
||||||
* The properties available on the assigned network address object include:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* {
|
|
||||||
* lo: [
|
|
||||||
* {
|
|
||||||
* address: '127.0.0.1',
|
|
||||||
* netmask: '255.0.0.0',
|
|
||||||
* family: 'IPv4',
|
|
||||||
* mac: '00:00:00:00:00:00',
|
|
||||||
* internal: true,
|
|
||||||
* cidr: '127.0.0.1/8'
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* address: '::1',
|
|
||||||
* netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
|
|
||||||
* family: 'IPv6',
|
|
||||||
* mac: '00:00:00:00:00:00',
|
|
||||||
* scopeid: 0,
|
|
||||||
* internal: true,
|
|
||||||
* cidr: '::1/128'
|
|
||||||
* }
|
|
||||||
* ],
|
|
||||||
* eth0: [
|
|
||||||
* {
|
|
||||||
* address: '192.168.1.108',
|
|
||||||
* netmask: '255.255.255.0',
|
|
||||||
* family: 'IPv4',
|
|
||||||
* mac: '01:02:03:0a:0b:0c',
|
|
||||||
* internal: false,
|
|
||||||
* cidr: '192.168.1.108/24'
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* address: 'fe80::a00:27ff:fe4e:66a1',
|
|
||||||
* netmask: 'ffff:ffff:ffff:ffff::',
|
|
||||||
* family: 'IPv6',
|
|
||||||
* mac: '01:02:03:0a:0b:0c',
|
|
||||||
* scopeid: 1,
|
|
||||||
* internal: false,
|
|
||||||
* cidr: 'fe80::a00:27ff:fe4e:66a1/64'
|
|
||||||
* }
|
|
||||||
* ]
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v0.6.0
|
|
||||||
*/
|
|
||||||
function networkInterfaces(): NodeJS.Dict<NetworkInterfaceInfo[]>;
|
|
||||||
/**
|
|
||||||
* Returns the string path of the current user's home directory.
|
|
||||||
*
|
|
||||||
* On POSIX, it uses the `$HOME` environment variable if defined. Otherwise it
|
|
||||||
* uses the [effective UID](https://en.wikipedia.org/wiki/User_identifier#Effective_user_ID) to look up the user's home directory.
|
|
||||||
*
|
|
||||||
* On Windows, it uses the `USERPROFILE` environment variable if defined.
|
|
||||||
* Otherwise it uses the path to the profile directory of the current user.
|
|
||||||
* @since v2.3.0
|
|
||||||
*/
|
|
||||||
function homedir(): string;
|
function homedir(): string;
|
||||||
/**
|
|
||||||
* Returns information about the currently effective user. On POSIX platforms,
|
|
||||||
* this is typically a subset of the password file. The returned object includes
|
|
||||||
* the `username`, `uid`, `gid`, `shell`, and `homedir`. On Windows, the `uid` and`gid` fields are `-1`, and `shell` is `null`.
|
|
||||||
*
|
|
||||||
* The value of `homedir` returned by `os.userInfo()` is provided by the operating
|
|
||||||
* system. This differs from the result of `os.homedir()`, which queries
|
|
||||||
* environment variables for the home directory before falling back to the
|
|
||||||
* operating system response.
|
|
||||||
*
|
|
||||||
* Throws a `SystemError` if a user has no `username` or `homedir`.
|
|
||||||
* @since v6.0.0
|
|
||||||
*/
|
|
||||||
function userInfo(options: { encoding: 'buffer' }): UserInfo<Buffer>;
|
function userInfo(options: { encoding: 'buffer' }): UserInfo<Buffer>;
|
||||||
function userInfo(options?: { encoding: BufferEncoding }): UserInfo<string>;
|
function userInfo(options?: { encoding: string }): UserInfo<string>;
|
||||||
type SignalConstants = {
|
const constants: {
|
||||||
[key in NodeJS.Signals]: number;
|
UV_UDP_REUSEADDR: number;
|
||||||
|
// signals: { [key in NodeJS.Signals]: number; }; @todo: change after migration to typescript 2.1
|
||||||
|
signals: {
|
||||||
|
SIGHUP: number;
|
||||||
|
SIGINT: number;
|
||||||
|
SIGQUIT: number;
|
||||||
|
SIGILL: number;
|
||||||
|
SIGTRAP: number;
|
||||||
|
SIGABRT: number;
|
||||||
|
SIGIOT: number;
|
||||||
|
SIGBUS: number;
|
||||||
|
SIGFPE: number;
|
||||||
|
SIGKILL: number;
|
||||||
|
SIGUSR1: number;
|
||||||
|
SIGSEGV: number;
|
||||||
|
SIGUSR2: number;
|
||||||
|
SIGPIPE: number;
|
||||||
|
SIGALRM: number;
|
||||||
|
SIGTERM: number;
|
||||||
|
SIGCHLD: number;
|
||||||
|
SIGSTKFLT: number;
|
||||||
|
SIGCONT: number;
|
||||||
|
SIGSTOP: number;
|
||||||
|
SIGTSTP: number;
|
||||||
|
SIGBREAK: number;
|
||||||
|
SIGTTIN: number;
|
||||||
|
SIGTTOU: number;
|
||||||
|
SIGURG: number;
|
||||||
|
SIGXCPU: number;
|
||||||
|
SIGXFSZ: number;
|
||||||
|
SIGVTALRM: number;
|
||||||
|
SIGPROF: number;
|
||||||
|
SIGWINCH: number;
|
||||||
|
SIGIO: number;
|
||||||
|
SIGPOLL: number;
|
||||||
|
SIGLOST: number;
|
||||||
|
SIGPWR: number;
|
||||||
|
SIGINFO: number;
|
||||||
|
SIGSYS: number;
|
||||||
|
SIGUNUSED: number;
|
||||||
};
|
};
|
||||||
namespace constants {
|
errno: {
|
||||||
const UV_UDP_REUSEADDR: number;
|
E2BIG: number;
|
||||||
namespace signals {}
|
EACCES: number;
|
||||||
const signals: SignalConstants;
|
EADDRINUSE: number;
|
||||||
namespace errno {
|
EADDRNOTAVAIL: number;
|
||||||
const E2BIG: number;
|
EAFNOSUPPORT: number;
|
||||||
const EACCES: number;
|
EAGAIN: number;
|
||||||
const EADDRINUSE: number;
|
EALREADY: number;
|
||||||
const EADDRNOTAVAIL: number;
|
EBADF: number;
|
||||||
const EAFNOSUPPORT: number;
|
EBADMSG: number;
|
||||||
const EAGAIN: number;
|
EBUSY: number;
|
||||||
const EALREADY: number;
|
ECANCELED: number;
|
||||||
const EBADF: number;
|
ECHILD: number;
|
||||||
const EBADMSG: number;
|
ECONNABORTED: number;
|
||||||
const EBUSY: number;
|
ECONNREFUSED: number;
|
||||||
const ECANCELED: number;
|
ECONNRESET: number;
|
||||||
const ECHILD: number;
|
EDEADLK: number;
|
||||||
const ECONNABORTED: number;
|
EDESTADDRREQ: number;
|
||||||
const ECONNREFUSED: number;
|
EDOM: number;
|
||||||
const ECONNRESET: number;
|
EDQUOT: number;
|
||||||
const EDEADLK: number;
|
EEXIST: number;
|
||||||
const EDESTADDRREQ: number;
|
EFAULT: number;
|
||||||
const EDOM: number;
|
EFBIG: number;
|
||||||
const EDQUOT: number;
|
EHOSTUNREACH: number;
|
||||||
const EEXIST: number;
|
EIDRM: number;
|
||||||
const EFAULT: number;
|
EILSEQ: number;
|
||||||
const EFBIG: number;
|
EINPROGRESS: number;
|
||||||
const EHOSTUNREACH: number;
|
EINTR: number;
|
||||||
const EIDRM: number;
|
EINVAL: number;
|
||||||
const EILSEQ: number;
|
EIO: number;
|
||||||
const EINPROGRESS: number;
|
EISCONN: number;
|
||||||
const EINTR: number;
|
EISDIR: number;
|
||||||
const EINVAL: number;
|
ELOOP: number;
|
||||||
const EIO: number;
|
EMFILE: number;
|
||||||
const EISCONN: number;
|
EMLINK: number;
|
||||||
const EISDIR: number;
|
EMSGSIZE: number;
|
||||||
const ELOOP: number;
|
EMULTIHOP: number;
|
||||||
const EMFILE: number;
|
ENAMETOOLONG: number;
|
||||||
const EMLINK: number;
|
ENETDOWN: number;
|
||||||
const EMSGSIZE: number;
|
ENETRESET: number;
|
||||||
const EMULTIHOP: number;
|
ENETUNREACH: number;
|
||||||
const ENAMETOOLONG: number;
|
ENFILE: number;
|
||||||
const ENETDOWN: number;
|
ENOBUFS: number;
|
||||||
const ENETRESET: number;
|
ENODATA: number;
|
||||||
const ENETUNREACH: number;
|
ENODEV: number;
|
||||||
const ENFILE: number;
|
ENOENT: number;
|
||||||
const ENOBUFS: number;
|
ENOEXEC: number;
|
||||||
const ENODATA: number;
|
ENOLCK: number;
|
||||||
const ENODEV: number;
|
ENOLINK: number;
|
||||||
const ENOENT: number;
|
ENOMEM: number;
|
||||||
const ENOEXEC: number;
|
ENOMSG: number;
|
||||||
const ENOLCK: number;
|
ENOPROTOOPT: number;
|
||||||
const ENOLINK: number;
|
ENOSPC: number;
|
||||||
const ENOMEM: number;
|
ENOSR: number;
|
||||||
const ENOMSG: number;
|
ENOSTR: number;
|
||||||
const ENOPROTOOPT: number;
|
ENOSYS: number;
|
||||||
const ENOSPC: number;
|
ENOTCONN: number;
|
||||||
const ENOSR: number;
|
ENOTDIR: number;
|
||||||
const ENOSTR: number;
|
ENOTEMPTY: number;
|
||||||
const ENOSYS: number;
|
ENOTSOCK: number;
|
||||||
const ENOTCONN: number;
|
ENOTSUP: number;
|
||||||
const ENOTDIR: number;
|
ENOTTY: number;
|
||||||
const ENOTEMPTY: number;
|
ENXIO: number;
|
||||||
const ENOTSOCK: number;
|
EOPNOTSUPP: number;
|
||||||
const ENOTSUP: number;
|
EOVERFLOW: number;
|
||||||
const ENOTTY: number;
|
EPERM: number;
|
||||||
const ENXIO: number;
|
EPIPE: number;
|
||||||
const EOPNOTSUPP: number;
|
EPROTO: number;
|
||||||
const EOVERFLOW: number;
|
EPROTONOSUPPORT: number;
|
||||||
const EPERM: number;
|
EPROTOTYPE: number;
|
||||||
const EPIPE: number;
|
ERANGE: number;
|
||||||
const EPROTO: number;
|
EROFS: number;
|
||||||
const EPROTONOSUPPORT: number;
|
ESPIPE: number;
|
||||||
const EPROTOTYPE: number;
|
ESRCH: number;
|
||||||
const ERANGE: number;
|
ESTALE: number;
|
||||||
const EROFS: number;
|
ETIME: number;
|
||||||
const ESPIPE: number;
|
ETIMEDOUT: number;
|
||||||
const ESRCH: number;
|
ETXTBSY: number;
|
||||||
const ESTALE: number;
|
EWOULDBLOCK: number;
|
||||||
const ETIME: number;
|
EXDEV: number;
|
||||||
const ETIMEDOUT: number;
|
WSAEINTR: number;
|
||||||
const ETXTBSY: number;
|
WSAEBADF: number;
|
||||||
const EWOULDBLOCK: number;
|
WSAEACCES: number;
|
||||||
const EXDEV: number;
|
WSAEFAULT: number;
|
||||||
const WSAEINTR: number;
|
WSAEINVAL: number;
|
||||||
const WSAEBADF: number;
|
WSAEMFILE: number;
|
||||||
const WSAEACCES: number;
|
WSAEWOULDBLOCK: number;
|
||||||
const WSAEFAULT: number;
|
WSAEINPROGRESS: number;
|
||||||
const WSAEINVAL: number;
|
WSAEALREADY: number;
|
||||||
const WSAEMFILE: number;
|
WSAENOTSOCK: number;
|
||||||
const WSAEWOULDBLOCK: number;
|
WSAEDESTADDRREQ: number;
|
||||||
const WSAEINPROGRESS: number;
|
WSAEMSGSIZE: number;
|
||||||
const WSAEALREADY: number;
|
WSAEPROTOTYPE: number;
|
||||||
const WSAENOTSOCK: number;
|
WSAENOPROTOOPT: number;
|
||||||
const WSAEDESTADDRREQ: number;
|
WSAEPROTONOSUPPORT: number;
|
||||||
const WSAEMSGSIZE: number;
|
WSAESOCKTNOSUPPORT: number;
|
||||||
const WSAEPROTOTYPE: number;
|
WSAEOPNOTSUPP: number;
|
||||||
const WSAENOPROTOOPT: number;
|
WSAEPFNOSUPPORT: number;
|
||||||
const WSAEPROTONOSUPPORT: number;
|
WSAEAFNOSUPPORT: number;
|
||||||
const WSAESOCKTNOSUPPORT: number;
|
WSAEADDRINUSE: number;
|
||||||
const WSAEOPNOTSUPP: number;
|
WSAEADDRNOTAVAIL: number;
|
||||||
const WSAEPFNOSUPPORT: number;
|
WSAENETDOWN: number;
|
||||||
const WSAEAFNOSUPPORT: number;
|
WSAENETUNREACH: number;
|
||||||
const WSAEADDRINUSE: number;
|
WSAENETRESET: number;
|
||||||
const WSAEADDRNOTAVAIL: number;
|
WSAECONNABORTED: number;
|
||||||
const WSAENETDOWN: number;
|
WSAECONNRESET: number;
|
||||||
const WSAENETUNREACH: number;
|
WSAENOBUFS: number;
|
||||||
const WSAENETRESET: number;
|
WSAEISCONN: number;
|
||||||
const WSAECONNABORTED: number;
|
WSAENOTCONN: number;
|
||||||
const WSAECONNRESET: number;
|
WSAESHUTDOWN: number;
|
||||||
const WSAENOBUFS: number;
|
WSAETOOMANYREFS: number;
|
||||||
const WSAEISCONN: number;
|
WSAETIMEDOUT: number;
|
||||||
const WSAENOTCONN: number;
|
WSAECONNREFUSED: number;
|
||||||
const WSAESHUTDOWN: number;
|
WSAELOOP: number;
|
||||||
const WSAETOOMANYREFS: number;
|
WSAENAMETOOLONG: number;
|
||||||
const WSAETIMEDOUT: number;
|
WSAEHOSTDOWN: number;
|
||||||
const WSAECONNREFUSED: number;
|
WSAEHOSTUNREACH: number;
|
||||||
const WSAELOOP: number;
|
WSAENOTEMPTY: number;
|
||||||
const WSAENAMETOOLONG: number;
|
WSAEPROCLIM: number;
|
||||||
const WSAEHOSTDOWN: number;
|
WSAEUSERS: number;
|
||||||
const WSAEHOSTUNREACH: number;
|
WSAEDQUOT: number;
|
||||||
const WSAENOTEMPTY: number;
|
WSAESTALE: number;
|
||||||
const WSAEPROCLIM: number;
|
WSAEREMOTE: number;
|
||||||
const WSAEUSERS: number;
|
WSASYSNOTREADY: number;
|
||||||
const WSAEDQUOT: number;
|
WSAVERNOTSUPPORTED: number;
|
||||||
const WSAESTALE: number;
|
WSANOTINITIALISED: number;
|
||||||
const WSAEREMOTE: number;
|
WSAEDISCON: number;
|
||||||
const WSASYSNOTREADY: number;
|
WSAENOMORE: number;
|
||||||
const WSAVERNOTSUPPORTED: number;
|
WSAECANCELLED: number;
|
||||||
const WSANOTINITIALISED: number;
|
WSAEINVALIDPROCTABLE: number;
|
||||||
const WSAEDISCON: number;
|
WSAEINVALIDPROVIDER: number;
|
||||||
const WSAENOMORE: number;
|
WSAEPROVIDERFAILEDINIT: number;
|
||||||
const WSAECANCELLED: number;
|
WSASYSCALLFAILURE: number;
|
||||||
const WSAEINVALIDPROCTABLE: number;
|
WSASERVICE_NOT_FOUND: number;
|
||||||
const WSAEINVALIDPROVIDER: number;
|
WSATYPE_NOT_FOUND: number;
|
||||||
const WSAEPROVIDERFAILEDINIT: number;
|
WSA_E_NO_MORE: number;
|
||||||
const WSASYSCALLFAILURE: number;
|
WSA_E_CANCELLED: number;
|
||||||
const WSASERVICE_NOT_FOUND: number;
|
WSAEREFUSED: number;
|
||||||
const WSATYPE_NOT_FOUND: number;
|
};
|
||||||
const WSA_E_NO_MORE: number;
|
priority: {
|
||||||
const WSA_E_CANCELLED: number;
|
PRIORITY_LOW: number;
|
||||||
const WSAEREFUSED: number;
|
PRIORITY_BELOW_NORMAL: number;
|
||||||
|
PRIORITY_NORMAL: number;
|
||||||
|
PRIORITY_ABOVE_NORMAL: number;
|
||||||
|
PRIORITY_HIGH: number;
|
||||||
|
PRIORITY_HIGHEST: number;
|
||||||
}
|
}
|
||||||
namespace priority {
|
};
|
||||||
const PRIORITY_LOW: number;
|
|
||||||
const PRIORITY_BELOW_NORMAL: number;
|
|
||||||
const PRIORITY_NORMAL: number;
|
|
||||||
const PRIORITY_ABOVE_NORMAL: number;
|
|
||||||
const PRIORITY_HIGH: number;
|
|
||||||
const PRIORITY_HIGHEST: number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const devNull: string;
|
|
||||||
const EOL: string;
|
|
||||||
/**
|
|
||||||
* Returns the operating system CPU architecture for which the Node.js binary was
|
|
||||||
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, `'x32'`, and `'x64'`.
|
|
||||||
*
|
|
||||||
* The return value is equivalent to `process.arch`.
|
|
||||||
* @since v0.5.0
|
|
||||||
*/
|
|
||||||
function arch(): string;
|
function arch(): string;
|
||||||
/**
|
|
||||||
* Returns a string identifying the kernel version.
|
|
||||||
*
|
|
||||||
* On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not
|
|
||||||
* available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
|
|
||||||
* @since v13.11.0, v12.17.0
|
|
||||||
*/
|
|
||||||
function version(): string;
|
|
||||||
/**
|
|
||||||
* Returns a string identifying the operating system platform. The value is set
|
|
||||||
* at compile time. Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`, `'openbsd'`, `'sunos'`, and `'win32'`.
|
|
||||||
*
|
|
||||||
* The return value is equivalent to `process.platform`.
|
|
||||||
*
|
|
||||||
* The value `'android'` may also be returned if Node.js is built on the Android
|
|
||||||
* operating system. [Android support is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os).
|
|
||||||
* @since v0.5.0
|
|
||||||
*/
|
|
||||||
function platform(): NodeJS.Platform;
|
function platform(): NodeJS.Platform;
|
||||||
/**
|
|
||||||
* Returns the operating system's default directory for temporary files as a
|
|
||||||
* string.
|
|
||||||
* @since v0.9.9
|
|
||||||
*/
|
|
||||||
function tmpdir(): string;
|
function tmpdir(): string;
|
||||||
|
const EOL: string;
|
||||||
|
function endianness(): "BE" | "LE";
|
||||||
/**
|
/**
|
||||||
* Returns a string identifying the endianness of the CPU for which the Node.js
|
* Gets the priority of a process.
|
||||||
* binary was compiled.
|
* Defaults to current process.
|
||||||
*
|
|
||||||
* Possible values are `'BE'` for big endian and `'LE'` for little endian.
|
|
||||||
* @since v0.9.4
|
|
||||||
*/
|
|
||||||
function endianness(): 'BE' | 'LE';
|
|
||||||
/**
|
|
||||||
* Returns the scheduling priority for the process specified by `pid`. If `pid` is
|
|
||||||
* not provided or is `0`, the priority of the current process is returned.
|
|
||||||
* @since v10.10.0
|
|
||||||
* @param [pid=0] The process ID to retrieve scheduling priority for.
|
|
||||||
*/
|
*/
|
||||||
function getPriority(pid?: number): number;
|
function getPriority(pid?: number): number;
|
||||||
/**
|
/**
|
||||||
* Attempts to set the scheduling priority for the process specified by `pid`. If`pid` is not provided or is `0`, the process ID of the current process is used.
|
* Sets the priority of the current process.
|
||||||
*
|
* @param priority Must be in range of -20 to 19
|
||||||
* The `priority` input must be an integer between `-20` (high priority) and `19`(low priority). Due to differences between Unix priority levels and Windows
|
|
||||||
* priority classes, `priority` is mapped to one of six priority constants in`os.constants.priority`. When retrieving a process priority level, this range
|
|
||||||
* mapping may cause the return value to be slightly different on Windows. To avoid
|
|
||||||
* confusion, set `priority` to one of the priority constants.
|
|
||||||
*
|
|
||||||
* On Windows, setting priority to `PRIORITY_HIGHEST` requires elevated user
|
|
||||||
* privileges. Otherwise the set priority will be silently reduced to`PRIORITY_HIGH`.
|
|
||||||
* @since v10.10.0
|
|
||||||
* @param [pid=0] The process ID to set scheduling priority for.
|
|
||||||
* @param priority The scheduling priority to assign to the process.
|
|
||||||
*/
|
*/
|
||||||
function setPriority(priority: number): void;
|
function setPriority(priority: number): void;
|
||||||
|
/**
|
||||||
|
* Sets the priority of the process specified process.
|
||||||
|
* @param priority Must be in range of -20 to 19
|
||||||
|
*/
|
||||||
function setPriority(pid: number, priority: number): void;
|
function setPriority(pid: number, priority: number): void;
|
||||||
}
|
}
|
||||||
declare module 'node:os' {
|
|
||||||
export * from 'os';
|
|
||||||
}
|
|
||||||
|
|||||||
95
node_modules/@types/node/package.json
generated
vendored
Executable file → Normal file
95
node_modules/@types/node/package.json
generated
vendored
Executable file → Normal file
@@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@types/node",
|
"name": "@types/node",
|
||||||
"version": "16.11.22",
|
"version": "12.12.70",
|
||||||
"description": "TypeScript definitions for Node.js",
|
"description": "TypeScript definitions for Node.js",
|
||||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
@@ -20,6 +19,11 @@
|
|||||||
"url": "https://github.com/jkomyno",
|
"url": "https://github.com/jkomyno",
|
||||||
"githubUsername": "jkomyno"
|
"githubUsername": "jkomyno"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexander T.",
|
||||||
|
"url": "https://github.com/a-tarasyuk",
|
||||||
|
"githubUsername": "a-tarasyuk"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Alvis HT Tang",
|
"name": "Alvis HT Tang",
|
||||||
"url": "https://github.com/alvis",
|
"url": "https://github.com/alvis",
|
||||||
@@ -35,6 +39,11 @@
|
|||||||
"url": "https://github.com/btoueg",
|
"url": "https://github.com/btoueg",
|
||||||
"githubUsername": "btoueg"
|
"githubUsername": "btoueg"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Bruno Scheufler",
|
||||||
|
"url": "https://github.com/brunoscheufler",
|
||||||
|
"githubUsername": "brunoscheufler"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Chigozirim C.",
|
"name": "Chigozirim C.",
|
||||||
"url": "https://github.com/smac89",
|
"url": "https://github.com/smac89",
|
||||||
@@ -55,11 +64,21 @@
|
|||||||
"url": "https://github.com/eyqs",
|
"url": "https://github.com/eyqs",
|
||||||
"githubUsername": "eyqs"
|
"githubUsername": "eyqs"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Flarna",
|
||||||
|
"url": "https://github.com/Flarna",
|
||||||
|
"githubUsername": "Flarna"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Hannes Magnusson",
|
"name": "Hannes Magnusson",
|
||||||
"url": "https://github.com/Hannes-Magnusson-CK",
|
"url": "https://github.com/Hannes-Magnusson-CK",
|
||||||
"githubUsername": "Hannes-Magnusson-CK"
|
"githubUsername": "Hannes-Magnusson-CK"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Hoàng Văn Khải",
|
||||||
|
"url": "https://github.com/KSXGitHub",
|
||||||
|
"githubUsername": "KSXGitHub"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Huw",
|
"name": "Huw",
|
||||||
"url": "https://github.com/hoo29",
|
"url": "https://github.com/hoo29",
|
||||||
@@ -110,11 +129,6 @@
|
|||||||
"url": "https://github.com/eps1lon",
|
"url": "https://github.com/eps1lon",
|
||||||
"githubUsername": "eps1lon"
|
"githubUsername": "eps1lon"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "Seth Westphal",
|
|
||||||
"url": "https://github.com/westy92",
|
|
||||||
"githubUsername": "westy92"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Simon Schick",
|
"name": "Simon Schick",
|
||||||
"url": "https://github.com/SimonSchick",
|
"url": "https://github.com/SimonSchick",
|
||||||
@@ -135,6 +149,11 @@
|
|||||||
"url": "https://github.com/wwwy3y3",
|
"url": "https://github.com/wwwy3y3",
|
||||||
"githubUsername": "wwwy3y3"
|
"githubUsername": "wwwy3y3"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Zane Hannan AU",
|
||||||
|
"url": "https://github.com/ZaneHannanAU",
|
||||||
|
"githubUsername": "ZaneHannanAU"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Samuel Ainsworth",
|
"name": "Samuel Ainsworth",
|
||||||
"url": "https://github.com/samuela",
|
"url": "https://github.com/samuela",
|
||||||
@@ -145,6 +164,11 @@
|
|||||||
"url": "https://github.com/kuehlein",
|
"url": "https://github.com/kuehlein",
|
||||||
"githubUsername": "kuehlein"
|
"githubUsername": "kuehlein"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Jordi Oliveras Rovira",
|
||||||
|
"url": "https://github.com/j-oliveras",
|
||||||
|
"githubUsername": "j-oliveras"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Thanik Bhongbhibhat",
|
"name": "Thanik Bhongbhibhat",
|
||||||
"url": "https://github.com/bhongy",
|
"url": "https://github.com/bhongy",
|
||||||
@@ -160,6 +184,11 @@
|
|||||||
"url": "https://github.com/trivikr",
|
"url": "https://github.com/trivikr",
|
||||||
"githubUsername": "trivikr"
|
"githubUsername": "trivikr"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Minh Son Nguyen",
|
||||||
|
"url": "https://github.com/nguymin4",
|
||||||
|
"githubUsername": "nguymin4"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Junxiao Shi",
|
"name": "Junxiao Shi",
|
||||||
"url": "https://github.com/yoursunny",
|
"url": "https://github.com/yoursunny",
|
||||||
@@ -176,43 +205,25 @@
|
|||||||
"githubUsername": "ExE-Boss"
|
"githubUsername": "ExE-Boss"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Piotr Błażejewicz",
|
"name": "Jason Kwok",
|
||||||
"url": "https://github.com/peterblazejewicz",
|
"url": "https://github.com/JasonHK",
|
||||||
"githubUsername": "peterblazejewicz"
|
"githubUsername": "JasonHK"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Anna Henningsen",
|
|
||||||
"url": "https://github.com/addaleax",
|
|
||||||
"githubUsername": "addaleax"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Victor Perin",
|
|
||||||
"url": "https://github.com/victorperin",
|
|
||||||
"githubUsername": "victorperin"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Yongsheng Zhang",
|
|
||||||
"url": "https://github.com/ZYSzys",
|
|
||||||
"githubUsername": "ZYSzys"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "NodeJS Contributors",
|
|
||||||
"url": "https://github.com/NodeJS",
|
|
||||||
"githubUsername": "NodeJS"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Linus Unnebäck",
|
|
||||||
"url": "https://github.com/LinusU",
|
|
||||||
"githubUsername": "LinusU"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "wafuwafu13",
|
|
||||||
"url": "https://github.com/wafuwafu13",
|
|
||||||
"githubUsername": "wafuwafu13"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"main": "",
|
"main": "",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
|
"typesVersions": {
|
||||||
|
"<=3.3": {
|
||||||
|
"*": [
|
||||||
|
"ts3.3/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"<=3.6": {
|
||||||
|
"*": [
|
||||||
|
"ts3.6/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
@@ -220,6 +231,6 @@
|
|||||||
},
|
},
|
||||||
"scripts": {},
|
"scripts": {},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"typesPublisherContentHash": "57a94e60cf640ea4d81b4fa914f3fb5929a63ae0b4d5141d7daf250c569e7d10",
|
"typesPublisherContentHash": "86d21f1f394b808863aabd5045402fca03a666e6e4c13c81302c4c82c28462bd",
|
||||||
"typeScriptVersion": "3.8"
|
"typeScriptVersion": "3.2"
|
||||||
}
|
}
|
||||||
115
node_modules/@types/node/path.d.ts
generated
vendored
Executable file → Normal file
115
node_modules/@types/node/path.d.ts
generated
vendored
Executable file → Normal file
@@ -1,22 +1,4 @@
|
|||||||
declare module 'path/posix' {
|
declare module "path" {
|
||||||
import path = require('path');
|
|
||||||
export = path;
|
|
||||||
}
|
|
||||||
declare module 'path/win32' {
|
|
||||||
import path = require('path');
|
|
||||||
export = path;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* The `path` module provides utilities for working with file and directory paths.
|
|
||||||
* It can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const path = require('path');
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/path.js)
|
|
||||||
*/
|
|
||||||
declare module 'path' {
|
|
||||||
namespace path {
|
|
||||||
/**
|
/**
|
||||||
* A parsed path object generated by path.parse() or consumed by path.format().
|
* A parsed path object generated by path.parse() or consumed by path.format().
|
||||||
*/
|
*/
|
||||||
@@ -46,39 +28,39 @@ declare module 'path' {
|
|||||||
/**
|
/**
|
||||||
* The root of the path such as '/' or 'c:\'
|
* The root of the path such as '/' or 'c:\'
|
||||||
*/
|
*/
|
||||||
root?: string | undefined;
|
root?: string;
|
||||||
/**
|
/**
|
||||||
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
||||||
*/
|
*/
|
||||||
dir?: string | undefined;
|
dir?: string;
|
||||||
/**
|
/**
|
||||||
* The file name including extension (if any) such as 'index.html'
|
* The file name including extension (if any) such as 'index.html'
|
||||||
*/
|
*/
|
||||||
base?: string | undefined;
|
base?: string;
|
||||||
/**
|
/**
|
||||||
* The file extension (if any) such as '.html'
|
* The file extension (if any) such as '.html'
|
||||||
*/
|
*/
|
||||||
ext?: string | undefined;
|
ext?: string;
|
||||||
/**
|
/**
|
||||||
* The file name without extension (if any) such as 'index'
|
* The file name without extension (if any) such as 'index'
|
||||||
*/
|
*/
|
||||||
name?: string | undefined;
|
name?: string;
|
||||||
}
|
}
|
||||||
interface PlatformPath {
|
|
||||||
/**
|
/**
|
||||||
* Normalize a string path, reducing '..' and '.' parts.
|
* Normalize a string path, reducing '..' and '.' parts.
|
||||||
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
|
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
|
||||||
*
|
*
|
||||||
* @param p string path to normalize.
|
* @param p string path to normalize.
|
||||||
*/
|
*/
|
||||||
normalize(p: string): string;
|
function normalize(p: string): string;
|
||||||
/**
|
/**
|
||||||
* Join all arguments together and normalize the resulting path.
|
* Join all arguments together and normalize the resulting path.
|
||||||
* Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
|
* Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
|
||||||
*
|
*
|
||||||
* @param paths paths to join.
|
* @param paths paths to join.
|
||||||
*/
|
*/
|
||||||
join(...paths: string[]): string;
|
function join(...paths: string[]): string;
|
||||||
/**
|
/**
|
||||||
* The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
|
* The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
|
||||||
*
|
*
|
||||||
@@ -91,24 +73,24 @@ declare module 'path' {
|
|||||||
*
|
*
|
||||||
* @param pathSegments string paths to join. Non-string arguments are ignored.
|
* @param pathSegments string paths to join. Non-string arguments are ignored.
|
||||||
*/
|
*/
|
||||||
resolve(...pathSegments: string[]): string;
|
function resolve(...pathSegments: string[]): string;
|
||||||
/**
|
/**
|
||||||
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
|
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
|
||||||
*
|
*
|
||||||
* @param path path to test.
|
* @param path path to test.
|
||||||
*/
|
*/
|
||||||
isAbsolute(p: string): boolean;
|
function isAbsolute(path: string): boolean;
|
||||||
/**
|
/**
|
||||||
* Solve the relative path from {from} to {to}.
|
* Solve the relative path from {from} to {to}.
|
||||||
* At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
|
* At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
|
||||||
*/
|
*/
|
||||||
relative(from: string, to: string): string;
|
function relative(from: string, to: string): string;
|
||||||
/**
|
/**
|
||||||
* Return the directory name of a path. Similar to the Unix dirname command.
|
* Return the directory name of a path. Similar to the Unix dirname command.
|
||||||
*
|
*
|
||||||
* @param p the path to evaluate.
|
* @param p the path to evaluate.
|
||||||
*/
|
*/
|
||||||
dirname(p: string): string;
|
function dirname(p: string): string;
|
||||||
/**
|
/**
|
||||||
* Return the last portion of a path. Similar to the Unix basename command.
|
* Return the last portion of a path. Similar to the Unix basename command.
|
||||||
* Often used to extract the file name from a fully qualified path.
|
* Often used to extract the file name from a fully qualified path.
|
||||||
@@ -116,65 +98,62 @@ declare module 'path' {
|
|||||||
* @param p the path to evaluate.
|
* @param p the path to evaluate.
|
||||||
* @param ext optionally, an extension to remove from the result.
|
* @param ext optionally, an extension to remove from the result.
|
||||||
*/
|
*/
|
||||||
basename(p: string, ext?: string): string;
|
function basename(p: string, ext?: string): string;
|
||||||
/**
|
/**
|
||||||
* Return the extension of the path, from the last '.' to end of string in the last portion of the path.
|
* Return the extension of the path, from the last '.' to end of string in the last portion of the path.
|
||||||
* If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
|
* If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
|
||||||
*
|
*
|
||||||
* @param p the path to evaluate.
|
* @param p the path to evaluate.
|
||||||
*/
|
*/
|
||||||
extname(p: string): string;
|
function extname(p: string): string;
|
||||||
/**
|
/**
|
||||||
* The platform-specific file separator. '\\' or '/'.
|
* The platform-specific file separator. '\\' or '/'.
|
||||||
*/
|
*/
|
||||||
readonly sep: string;
|
const sep: '\\' | '/';
|
||||||
/**
|
/**
|
||||||
* The platform-specific file delimiter. ';' or ':'.
|
* The platform-specific file delimiter. ';' or ':'.
|
||||||
*/
|
*/
|
||||||
readonly delimiter: string;
|
const delimiter: ';' | ':';
|
||||||
/**
|
/**
|
||||||
* Returns an object from a path string - the opposite of format().
|
* Returns an object from a path string - the opposite of format().
|
||||||
*
|
*
|
||||||
* @param pathString path to evaluate.
|
* @param pathString path to evaluate.
|
||||||
*/
|
*/
|
||||||
parse(p: string): ParsedPath;
|
function parse(pathString: string): ParsedPath;
|
||||||
/**
|
/**
|
||||||
* Returns a path string from an object - the opposite of parse().
|
* Returns a path string from an object - the opposite of parse().
|
||||||
*
|
*
|
||||||
* @param pathString path to evaluate.
|
* @param pathString path to evaluate.
|
||||||
*/
|
*/
|
||||||
format(pP: FormatInputPathObject): string;
|
function format(pathObject: FormatInputPathObject): string;
|
||||||
/**
|
|
||||||
* On Windows systems only, returns an equivalent namespace-prefixed path for the given path.
|
namespace posix {
|
||||||
* If path is not a string, path will be returned without modifications.
|
function normalize(p: string): string;
|
||||||
* This method is meaningful only on Windows system.
|
function join(...paths: string[]): string;
|
||||||
* On POSIX systems, the method is non-operational and always returns path without modifications.
|
function resolve(...pathSegments: string[]): string;
|
||||||
*/
|
function isAbsolute(p: string): boolean;
|
||||||
toNamespacedPath(path: string): string;
|
function relative(from: string, to: string): string;
|
||||||
/**
|
function dirname(p: string): string;
|
||||||
* Posix specific pathing.
|
function basename(p: string, ext?: string): string;
|
||||||
* Same as parent object on posix.
|
function extname(p: string): string;
|
||||||
*/
|
const sep: string;
|
||||||
readonly posix: PlatformPath;
|
const delimiter: string;
|
||||||
/**
|
function parse(p: string): ParsedPath;
|
||||||
* Windows specific pathing.
|
function format(pP: FormatInputPathObject): string;
|
||||||
* Same as parent object on windows
|
|
||||||
*/
|
|
||||||
readonly win32: PlatformPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace win32 {
|
||||||
|
function normalize(p: string): string;
|
||||||
|
function join(...paths: string[]): string;
|
||||||
|
function resolve(...pathSegments: string[]): string;
|
||||||
|
function isAbsolute(p: string): boolean;
|
||||||
|
function relative(from: string, to: string): string;
|
||||||
|
function dirname(p: string): string;
|
||||||
|
function basename(p: string, ext?: string): string;
|
||||||
|
function extname(p: string): string;
|
||||||
|
const sep: string;
|
||||||
|
const delimiter: string;
|
||||||
|
function parse(p: string): ParsedPath;
|
||||||
|
function format(pP: FormatInputPathObject): string;
|
||||||
}
|
}
|
||||||
const path: path.PlatformPath;
|
|
||||||
export = path;
|
|
||||||
}
|
|
||||||
declare module 'node:path' {
|
|
||||||
import path = require('path');
|
|
||||||
export = path;
|
|
||||||
}
|
|
||||||
declare module 'node:path/posix' {
|
|
||||||
import path = require('path/posix');
|
|
||||||
export = path;
|
|
||||||
}
|
|
||||||
declare module 'node:path/win32' {
|
|
||||||
import path = require('path/win32');
|
|
||||||
export = path;
|
|
||||||
}
|
}
|
||||||
|
|||||||
559
node_modules/@types/node/perf_hooks.d.ts
generated
vendored
Executable file → Normal file
559
node_modules/@types/node/perf_hooks.d.ts
generated
vendored
Executable file → Normal file
@@ -1,189 +1,74 @@
|
|||||||
/**
|
declare module "perf_hooks" {
|
||||||
* This module provides an implementation of a subset of the W3C [Web Performance APIs](https://w3c.github.io/perf-timing-primer/) as well as additional APIs for
|
import { AsyncResource } from "async_hooks";
|
||||||
* Node.js-specific performance measurements.
|
|
||||||
*
|
interface PerformanceEntry {
|
||||||
* Node.js supports the following [Web Performance APIs](https://w3c.github.io/perf-timing-primer/):
|
|
||||||
*
|
|
||||||
* * [High Resolution Time](https://www.w3.org/TR/hr-time-2)
|
|
||||||
* * [Performance Timeline](https://w3c.github.io/performance-timeline/)
|
|
||||||
* * [User Timing](https://www.w3.org/TR/user-timing/)
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { PerformanceObserver, performance } = require('perf_hooks');
|
|
||||||
*
|
|
||||||
* const obs = new PerformanceObserver((items) => {
|
|
||||||
* console.log(items.getEntries()[0].duration);
|
|
||||||
* performance.clearMarks();
|
|
||||||
* });
|
|
||||||
* obs.observe({ type: 'measure' });
|
|
||||||
* performance.measure('Start to Now');
|
|
||||||
*
|
|
||||||
* performance.mark('A');
|
|
||||||
* doSomeLongRunningProcess(() => {
|
|
||||||
* performance.measure('A to Now', 'A');
|
|
||||||
*
|
|
||||||
* performance.mark('B');
|
|
||||||
* performance.measure('A to B', 'A', 'B');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/perf_hooks.js)
|
|
||||||
*/
|
|
||||||
declare module 'perf_hooks' {
|
|
||||||
import { AsyncResource } from 'node:async_hooks';
|
|
||||||
type EntryType = 'node' | 'mark' | 'measure' | 'gc' | 'function' | 'http2' | 'http';
|
|
||||||
interface NodeGCPerformanceDetail {
|
|
||||||
/**
|
/**
|
||||||
* When `performanceEntry.entryType` is equal to 'gc', `the performance.kind` property identifies
|
* The total number of milliseconds elapsed for this entry.
|
||||||
* the type of garbage collection operation that occurred.
|
* This value will not be meaningful for all Performance Entry types.
|
||||||
* See perf_hooks.constants for valid values.
|
|
||||||
*/
|
|
||||||
readonly kind?: number | undefined;
|
|
||||||
/**
|
|
||||||
* When `performanceEntry.entryType` is equal to 'gc', the `performance.flags`
|
|
||||||
* property contains additional information about garbage collection operation.
|
|
||||||
* See perf_hooks.constants for valid values.
|
|
||||||
*/
|
|
||||||
readonly flags?: number | undefined;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
|
||||||
class PerformanceEntry {
|
|
||||||
protected constructor();
|
|
||||||
/**
|
|
||||||
* The total number of milliseconds elapsed for this entry. This value will not
|
|
||||||
* be meaningful for all Performance Entry types.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly duration: number;
|
readonly duration: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the performance entry.
|
* The name of the performance entry.
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The high resolution millisecond timestamp marking the starting time of the
|
* The high resolution millisecond timestamp marking the starting time of the Performance Entry.
|
||||||
* Performance Entry.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly startTime: number;
|
readonly startTime: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the performance entry. It may be one of:
|
* The type of the performance entry.
|
||||||
*
|
* Currently it may be one of: 'node', 'mark', 'measure', 'gc', or 'function'.
|
||||||
* * `'node'` (Node.js only)
|
|
||||||
* * `'mark'` (available on the Web)
|
|
||||||
* * `'measure'` (available on the Web)
|
|
||||||
* * `'gc'` (Node.js only)
|
|
||||||
* * `'function'` (Node.js only)
|
|
||||||
* * `'http2'` (Node.js only)
|
|
||||||
* * `'http'` (Node.js only)
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly entryType: EntryType;
|
readonly entryType: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional detail specific to the `entryType`.
|
* When performanceEntry.entryType is equal to 'gc', the performance.kind property identifies
|
||||||
* @since v16.0.0
|
* the type of garbage collection operation that occurred.
|
||||||
|
* The value may be one of perf_hooks.constants.
|
||||||
*/
|
*/
|
||||||
readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type.
|
readonly kind?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface PerformanceNodeTiming extends PerformanceEntry {
|
||||||
/**
|
/**
|
||||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
* The high resolution millisecond timestamp at which the Node.js process completed bootstrap.
|
||||||
*
|
* If bootstrapping has not yet finished, the property has the value of -1.
|
||||||
* Provides timing details for Node.js itself. The constructor of this class
|
|
||||||
* is not exposed to users.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
|
||||||
class PerformanceNodeTiming extends PerformanceEntry {
|
|
||||||
/**
|
|
||||||
* The high resolution millisecond timestamp at which the Node.js process
|
|
||||||
* completed bootstrapping. If bootstrapping has not yet finished, the property
|
|
||||||
* has the value of -1.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly bootstrapComplete: number;
|
readonly bootstrapComplete: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The high resolution millisecond timestamp at which the Node.js environment was
|
* The high resolution millisecond timestamp at which the Node.js process completed bootstrapping.
|
||||||
* initialized.
|
* If bootstrapping has not yet finished, the property has the value of -1.
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly environment: number;
|
readonly environment: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The high resolution millisecond timestamp of the amount of time the event loop
|
* The high resolution millisecond timestamp at which the Node.js event loop exited.
|
||||||
* has been idle within the event loop's event provider (e.g. `epoll_wait`). This
|
* If the event loop has not yet exited, the property has the value of -1.
|
||||||
* does not take CPU usage into consideration. If the event loop has not yet
|
* It can only have a value of not -1 in a handler of the 'exit' event.
|
||||||
* started (e.g., in the first tick of the main script), the property has the
|
|
||||||
* value of 0.
|
|
||||||
* @since v14.10.0, v12.19.0
|
|
||||||
*/
|
|
||||||
readonly idleTime: number;
|
|
||||||
/**
|
|
||||||
* The high resolution millisecond timestamp at which the Node.js event loop
|
|
||||||
* exited. If the event loop has not yet exited, the property has the value of -1\.
|
|
||||||
* It can only have a value of not -1 in a handler of the `'exit'` event.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly loopExit: number;
|
readonly loopExit: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The high resolution millisecond timestamp at which the Node.js event loop
|
* The high resolution millisecond timestamp at which the Node.js event loop started.
|
||||||
* started. If the event loop has not yet started (e.g., in the first tick of the
|
* If the event loop has not yet started (e.g., in the first tick of the main script), the property has the value of -1.
|
||||||
* main script), the property has the value of -1.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly loopStart: number;
|
readonly loopStart: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The high resolution millisecond timestamp at which the V8 platform was
|
* The high resolution millisecond timestamp at which the Node.js process was initialized.
|
||||||
* initialized.
|
*/
|
||||||
* @since v8.5.0
|
readonly nodeStart: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp at which the V8 platform was initialized.
|
||||||
*/
|
*/
|
||||||
readonly v8Start: number;
|
readonly v8Start: number;
|
||||||
}
|
}
|
||||||
interface EventLoopUtilization {
|
|
||||||
idle: number;
|
|
||||||
active: number;
|
|
||||||
utilization: number;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param util1 The result of a previous call to eventLoopUtilization()
|
|
||||||
* @param util2 The result of a previous call to eventLoopUtilization() prior to util1
|
|
||||||
*/
|
|
||||||
type EventLoopUtilityFunction = (util1?: EventLoopUtilization, util2?: EventLoopUtilization) => EventLoopUtilization;
|
|
||||||
interface MarkOptions {
|
|
||||||
/**
|
|
||||||
* Additional optional detail to include with the mark.
|
|
||||||
*/
|
|
||||||
detail?: unknown | undefined;
|
|
||||||
/**
|
|
||||||
* An optional timestamp to be used as the mark time.
|
|
||||||
* @default `performance.now()`.
|
|
||||||
*/
|
|
||||||
startTime?: number | undefined;
|
|
||||||
}
|
|
||||||
interface MeasureOptions {
|
|
||||||
/**
|
|
||||||
* Additional optional detail to include with the mark.
|
|
||||||
*/
|
|
||||||
detail?: unknown | undefined;
|
|
||||||
/**
|
|
||||||
* Duration between start and end times.
|
|
||||||
*/
|
|
||||||
duration?: number | undefined;
|
|
||||||
/**
|
|
||||||
* Timestamp to be used as the end time, or a string identifying a previously recorded mark.
|
|
||||||
*/
|
|
||||||
end?: number | string | undefined;
|
|
||||||
/**
|
|
||||||
* Timestamp to be used as the start time, or a string identifying a previously recorded mark.
|
|
||||||
*/
|
|
||||||
start?: number | string | undefined;
|
|
||||||
}
|
|
||||||
interface TimerifyOptions {
|
|
||||||
/**
|
|
||||||
* A histogram object created using
|
|
||||||
* `perf_hooks.createHistogram()` that will record runtime durations in
|
|
||||||
* nanoseconds.
|
|
||||||
*/
|
|
||||||
histogram?: RecordableHistogram | undefined;
|
|
||||||
}
|
|
||||||
interface Performance {
|
interface Performance {
|
||||||
/**
|
/**
|
||||||
* If name is not provided, removes all PerformanceMark objects from the Performance Timeline.
|
* If name is not provided, removes all PerformanceMark objects from the Performance Timeline.
|
||||||
@@ -191,6 +76,7 @@ declare module 'perf_hooks' {
|
|||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
clearMarks(name?: string): void;
|
clearMarks(name?: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new PerformanceMark entry in the Performance Timeline.
|
* Creates a new PerformanceMark entry in the Performance Timeline.
|
||||||
* A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark',
|
* A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark',
|
||||||
@@ -198,7 +84,8 @@ declare module 'perf_hooks' {
|
|||||||
* Performance marks are used to mark specific significant moments in the Performance Timeline.
|
* Performance marks are used to mark specific significant moments in the Performance Timeline.
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
mark(name?: string, options?: MarkOptions): void;
|
mark(name?: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
||||||
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
||||||
@@ -214,344 +101,138 @@ declare module 'perf_hooks' {
|
|||||||
* @param startMark
|
* @param startMark
|
||||||
* @param endMark
|
* @param endMark
|
||||||
*/
|
*/
|
||||||
measure(name: string, startMark?: string, endMark?: string): void;
|
measure(name: string, startMark: string, endMark: string): void;
|
||||||
measure(name: string, options: MeasureOptions): void;
|
|
||||||
/**
|
/**
|
||||||
* An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
|
* An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
|
||||||
*/
|
*/
|
||||||
readonly nodeTiming: PerformanceNodeTiming;
|
readonly nodeTiming: PerformanceNodeTiming;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the current high resolution millisecond timestamp
|
* @return the current high resolution millisecond timestamp
|
||||||
*/
|
*/
|
||||||
now(): number;
|
now(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured.
|
* The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured.
|
||||||
*/
|
*/
|
||||||
readonly timeOrigin: number;
|
readonly timeOrigin: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps a function within a new function that measures the running time of the wrapped function.
|
* Wraps a function within a new function that measures the running time of the wrapped function.
|
||||||
* A PerformanceObserver must be subscribed to the 'function' event type in order for the timing details to be accessed.
|
* A PerformanceObserver must be subscribed to the 'function' event type in order for the timing details to be accessed.
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
timerify<T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions): T;
|
timerify<T extends (...optionalParams: any[]) => any>(fn: T): T;
|
||||||
/**
|
|
||||||
* eventLoopUtilization is similar to CPU utilization except that it is calculated using high precision wall-clock time.
|
|
||||||
* It represents the percentage of time the event loop has spent outside the event loop's event provider (e.g. epoll_wait).
|
|
||||||
* No other CPU idle time is taken into consideration.
|
|
||||||
*/
|
|
||||||
eventLoopUtilization: EventLoopUtilityFunction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PerformanceObserverEntryList {
|
interface PerformanceObserverEntryList {
|
||||||
/**
|
/**
|
||||||
* Returns a list of `PerformanceEntry` objects in chronological order
|
* @return a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime.
|
||||||
* with respect to `performanceEntry.startTime`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const {
|
|
||||||
* performance,
|
|
||||||
* PerformanceObserver
|
|
||||||
* } = require('perf_hooks');
|
|
||||||
*
|
|
||||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
||||||
* console.log(perfObserverList.getEntries());
|
|
||||||
*
|
|
||||||
* * [
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'test',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 81.465639,
|
|
||||||
* * duration: 0
|
|
||||||
* * },
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'meow',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 81.860064,
|
|
||||||
* * duration: 0
|
|
||||||
* * }
|
|
||||||
* * ]
|
|
||||||
*
|
|
||||||
* observer.disconnect();
|
|
||||||
* });
|
|
||||||
* obs.observe({ type: 'mark' });
|
|
||||||
*
|
|
||||||
* performance.mark('test');
|
|
||||||
* performance.mark('meow');
|
|
||||||
* ```
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
getEntries(): PerformanceEntry[];
|
getEntries(): PerformanceEntry[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of `PerformanceEntry` objects in chronological order
|
* @return a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime
|
||||||
* with respect to `performanceEntry.startTime` whose `performanceEntry.name` is
|
* whose performanceEntry.name is equal to name, and optionally, whose performanceEntry.entryType is equal to type.
|
||||||
* equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to`type`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const {
|
|
||||||
* performance,
|
|
||||||
* PerformanceObserver
|
|
||||||
* } = require('perf_hooks');
|
|
||||||
*
|
|
||||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
||||||
* console.log(perfObserverList.getEntriesByName('meow'));
|
|
||||||
*
|
|
||||||
* * [
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'meow',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 98.545991,
|
|
||||||
* * duration: 0
|
|
||||||
* * }
|
|
||||||
* * ]
|
|
||||||
*
|
|
||||||
* console.log(perfObserverList.getEntriesByName('nope')); // []
|
|
||||||
*
|
|
||||||
* console.log(perfObserverList.getEntriesByName('test', 'mark'));
|
|
||||||
*
|
|
||||||
* * [
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'test',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 63.518931,
|
|
||||||
* * duration: 0
|
|
||||||
* * }
|
|
||||||
* * ]
|
|
||||||
*
|
|
||||||
* console.log(perfObserverList.getEntriesByName('test', 'measure')); // []
|
|
||||||
* observer.disconnect();
|
|
||||||
* });
|
|
||||||
* obs.observe({ entryTypes: ['mark', 'measure'] });
|
|
||||||
*
|
|
||||||
* performance.mark('test');
|
|
||||||
* performance.mark('meow');
|
|
||||||
* ```
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
getEntriesByName(name: string, type?: EntryType): PerformanceEntry[];
|
getEntriesByName(name: string, type?: string): PerformanceEntry[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of `PerformanceEntry` objects in chronological order
|
* @return Returns a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime
|
||||||
* with respect to `performanceEntry.startTime` whose `performanceEntry.entryType`is equal to `type`.
|
* whose performanceEntry.entryType is equal to type.
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const {
|
|
||||||
* performance,
|
|
||||||
* PerformanceObserver
|
|
||||||
* } = require('perf_hooks');
|
|
||||||
*
|
|
||||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
||||||
* console.log(perfObserverList.getEntriesByType('mark'));
|
|
||||||
*
|
|
||||||
* * [
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'test',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 55.897834,
|
|
||||||
* * duration: 0
|
|
||||||
* * },
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'meow',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 56.350146,
|
|
||||||
* * duration: 0
|
|
||||||
* * }
|
|
||||||
* * ]
|
|
||||||
*
|
|
||||||
* observer.disconnect();
|
|
||||||
* });
|
|
||||||
* obs.observe({ type: 'mark' });
|
|
||||||
*
|
|
||||||
* performance.mark('test');
|
|
||||||
* performance.mark('meow');
|
|
||||||
* ```
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
getEntriesByType(type: EntryType): PerformanceEntry[];
|
getEntriesByType(type: string): PerformanceEntry[];
|
||||||
}
|
}
|
||||||
|
|
||||||
type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void;
|
type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void;
|
||||||
|
|
||||||
class PerformanceObserver extends AsyncResource {
|
class PerformanceObserver extends AsyncResource {
|
||||||
constructor(callback: PerformanceObserverCallback);
|
constructor(callback: PerformanceObserverCallback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects the `PerformanceObserver` instance from all notifications.
|
* Disconnects the PerformanceObserver instance from all notifications.
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
disconnect(): void;
|
disconnect(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes the `PerformanceObserver` instance to notifications of new `PerformanceEntry` instances identified either by `options.entryTypes`or `options.type`:
|
* Subscribes the PerformanceObserver instance to notifications of new PerformanceEntry instances identified by options.entryTypes.
|
||||||
*
|
* When options.buffered is false, the callback will be invoked once for every PerformanceEntry instance.
|
||||||
* ```js
|
* Property buffered defaults to false.
|
||||||
* const {
|
* @param options
|
||||||
* performance,
|
|
||||||
* PerformanceObserver
|
|
||||||
* } = require('perf_hooks');
|
|
||||||
*
|
|
||||||
* const obs = new PerformanceObserver((list, observer) => {
|
|
||||||
* // Called three times synchronously. `list` contains one item.
|
|
||||||
* });
|
|
||||||
* obs.observe({ type: 'mark' });
|
|
||||||
*
|
|
||||||
* for (let n = 0; n < 3; n++)
|
|
||||||
* performance.mark(`test${n}`);
|
|
||||||
* ```
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
observe(
|
observe(options: { entryTypes: ReadonlyArray<string>, buffered?: boolean }): void;
|
||||||
options:
|
|
||||||
| {
|
|
||||||
entryTypes: ReadonlyArray<EntryType>;
|
|
||||||
buffered?: boolean | undefined;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: EntryType;
|
|
||||||
buffered?: boolean | undefined;
|
|
||||||
}
|
|
||||||
): void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace constants {
|
namespace constants {
|
||||||
const NODE_PERFORMANCE_GC_MAJOR: number;
|
const NODE_PERFORMANCE_GC_MAJOR: number;
|
||||||
const NODE_PERFORMANCE_GC_MINOR: number;
|
const NODE_PERFORMANCE_GC_MINOR: number;
|
||||||
const NODE_PERFORMANCE_GC_INCREMENTAL: number;
|
const NODE_PERFORMANCE_GC_INCREMENTAL: number;
|
||||||
const NODE_PERFORMANCE_GC_WEAKCB: number;
|
const NODE_PERFORMANCE_GC_WEAKCB: number;
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_NO: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_FORCED: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const performance: Performance;
|
const performance: Performance;
|
||||||
|
|
||||||
interface EventLoopMonitorOptions {
|
interface EventLoopMonitorOptions {
|
||||||
/**
|
/**
|
||||||
* The sampling rate in milliseconds.
|
* The sampling rate in milliseconds.
|
||||||
* Must be greater than zero.
|
* Must be greater than zero.
|
||||||
* @default 10
|
* @default 10
|
||||||
*/
|
*/
|
||||||
resolution?: number | undefined;
|
resolution?: number;
|
||||||
}
|
}
|
||||||
interface Histogram {
|
|
||||||
|
interface EventLoopDelayMonitor {
|
||||||
/**
|
/**
|
||||||
* Returns a `Map` object detailing the accumulated percentile distribution.
|
* Enables the event loop delay sample timer. Returns `true` if the timer was started, `false` if it was already started.
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly percentiles: Map<number, number>;
|
|
||||||
/**
|
|
||||||
* The number of times the event loop delay exceeded the maximum 1 hour event
|
|
||||||
* loop delay threshold.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly exceeds: number;
|
|
||||||
/**
|
|
||||||
* The minimum recorded event loop delay.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly min: number;
|
|
||||||
/**
|
|
||||||
* The maximum recorded event loop delay.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly max: number;
|
|
||||||
/**
|
|
||||||
* The mean of the recorded event loop delays.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly mean: number;
|
|
||||||
/**
|
|
||||||
* The standard deviation of the recorded event loop delays.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly stddev: number;
|
|
||||||
/**
|
|
||||||
* Resets the collected histogram data.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
reset(): void;
|
|
||||||
/**
|
|
||||||
* Returns the value at the given percentile.
|
|
||||||
* @since v11.10.0
|
|
||||||
* @param percentile A percentile value in the range (0, 100].
|
|
||||||
*/
|
|
||||||
percentile(percentile: number): number;
|
|
||||||
}
|
|
||||||
interface IntervalHistogram extends Histogram {
|
|
||||||
/**
|
|
||||||
* Enables the update interval timer. Returns `true` if the timer was
|
|
||||||
* started, `false` if it was already started.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
*/
|
||||||
enable(): boolean;
|
enable(): boolean;
|
||||||
/**
|
/**
|
||||||
* Disables the update interval timer. Returns `true` if the timer was
|
* Disables the event loop delay sample timer. Returns `true` if the timer was stopped, `false` if it was already stopped.
|
||||||
* stopped, `false` if it was already stopped.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
*/
|
||||||
disable(): boolean;
|
disable(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the collected histogram data.
|
||||||
|
*/
|
||||||
|
reset(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value at the given percentile.
|
||||||
|
* @param percentile A percentile value between 1 and 100.
|
||||||
|
*/
|
||||||
|
percentile(percentile: number): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A `Map` object detailing the accumulated percentile distribution.
|
||||||
|
*/
|
||||||
|
readonly percentiles: Map<number, number>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of times the event loop delay exceeded the maximum 1 hour eventloop delay threshold.
|
||||||
|
*/
|
||||||
|
readonly exceeds: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum recorded event loop delay.
|
||||||
|
*/
|
||||||
|
readonly min: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum recorded event loop delay.
|
||||||
|
*/
|
||||||
|
readonly max: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mean of the recorded event loop delays.
|
||||||
|
*/
|
||||||
|
readonly mean: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The standard deviation of the recorded event loop delays.
|
||||||
|
*/
|
||||||
|
readonly stddev: number;
|
||||||
}
|
}
|
||||||
interface RecordableHistogram extends Histogram {
|
|
||||||
/**
|
function monitorEventLoopDelay(options?: EventLoopMonitorOptions): EventLoopDelayMonitor;
|
||||||
* @since v15.9.0
|
|
||||||
* @param val The amount to record in the histogram.
|
|
||||||
*/
|
|
||||||
record(val: number | bigint): void;
|
|
||||||
/**
|
|
||||||
* Calculates the amount of time (in nanoseconds) that has passed since the
|
|
||||||
* previous call to `recordDelta()` and records that amount in the histogram.
|
|
||||||
*
|
|
||||||
* ## Examples
|
|
||||||
* @since v15.9.0
|
|
||||||
*/
|
|
||||||
recordDelta(): void;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
|
||||||
*
|
|
||||||
* Creates an `IntervalHistogram` object that samples and reports the event loop
|
|
||||||
* delay over time. The delays will be reported in nanoseconds.
|
|
||||||
*
|
|
||||||
* Using a timer to detect approximate event loop delay works because the
|
|
||||||
* execution of timers is tied specifically to the lifecycle of the libuv
|
|
||||||
* event loop. That is, a delay in the loop will cause a delay in the execution
|
|
||||||
* of the timer, and those delays are specifically what this API is intended to
|
|
||||||
* detect.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { monitorEventLoopDelay } = require('perf_hooks');
|
|
||||||
* const h = monitorEventLoopDelay({ resolution: 20 });
|
|
||||||
* h.enable();
|
|
||||||
* // Do something.
|
|
||||||
* h.disable();
|
|
||||||
* console.log(h.min);
|
|
||||||
* console.log(h.max);
|
|
||||||
* console.log(h.mean);
|
|
||||||
* console.log(h.stddev);
|
|
||||||
* console.log(h.percentiles);
|
|
||||||
* console.log(h.percentile(50));
|
|
||||||
* console.log(h.percentile(99));
|
|
||||||
* ```
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram;
|
|
||||||
interface CreateHistogramOptions {
|
|
||||||
/**
|
|
||||||
* The minimum recordable value. Must be an integer value greater than 0.
|
|
||||||
* @default 1
|
|
||||||
*/
|
|
||||||
min?: number | bigint | undefined;
|
|
||||||
/**
|
|
||||||
* The maximum recordable value. Must be an integer value greater than min.
|
|
||||||
* @default Number.MAX_SAFE_INTEGER
|
|
||||||
*/
|
|
||||||
max?: number | bigint | undefined;
|
|
||||||
/**
|
|
||||||
* The number of accuracy digits. Must be a number between 1 and 5.
|
|
||||||
* @default 3
|
|
||||||
*/
|
|
||||||
figures?: number | undefined;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns a `RecordableHistogram`.
|
|
||||||
* @since v15.9.0
|
|
||||||
*/
|
|
||||||
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
|
|
||||||
}
|
|
||||||
declare module 'node:perf_hooks' {
|
|
||||||
export * from 'perf_hooks';
|
|
||||||
}
|
}
|
||||||
|
|||||||
1474
node_modules/@types/node/process.d.ts
generated
vendored
Executable file → Normal file
1474
node_modules/@types/node/process.d.ts
generated
vendored
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
91
node_modules/@types/node/punycode.d.ts
generated
vendored
Executable file → Normal file
91
node_modules/@types/node/punycode.d.ts
generated
vendored
Executable file → Normal file
@@ -1,80 +1,34 @@
|
|||||||
/**
|
declare module "punycode" {
|
||||||
* **The version of the punycode module bundled in Node.js is being deprecated.**In a future major version of Node.js this module will be removed. Users
|
|
||||||
* currently depending on the `punycode` module should switch to using the
|
|
||||||
* userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL
|
|
||||||
* encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`.
|
|
||||||
*
|
|
||||||
* The `punycode` module is a bundled version of the [Punycode.js](https://github.com/bestiejs/punycode.js) module. It
|
|
||||||
* can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const punycode = require('punycode');
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is
|
|
||||||
* primarily intended for use in Internationalized Domain Names. Because host
|
|
||||||
* names in URLs are limited to ASCII characters only, Domain Names that contain
|
|
||||||
* non-ASCII characters must be converted into ASCII using the Punycode scheme.
|
|
||||||
* For instance, the Japanese character that translates into the English word,`'example'` is `'例'`. The Internationalized Domain Name, `'例.com'` (equivalent
|
|
||||||
* to `'example.com'`) is represented by Punycode as the ASCII string`'xn--fsq.com'`.
|
|
||||||
*
|
|
||||||
* The `punycode` module provides a simple implementation of the Punycode standard.
|
|
||||||
*
|
|
||||||
* The `punycode` module is a third-party dependency used by Node.js and
|
|
||||||
* made available to developers as a convenience. Fixes or other modifications to
|
|
||||||
* the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project.
|
|
||||||
* @deprecated Since v7.0.0 - Deprecated
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/punycode.js)
|
|
||||||
*/
|
|
||||||
declare module 'punycode' {
|
|
||||||
/**
|
/**
|
||||||
* The `punycode.decode()` method converts a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only
|
* @deprecated since v7.0.0
|
||||||
* characters to the equivalent string of Unicode codepoints.
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
*
|
* In a future major version of Node.js this module will be removed.
|
||||||
* ```js
|
* Users currently depending on the punycode module should switch to using
|
||||||
* punycode.decode('maana-pta'); // 'mañana'
|
* the userland-provided Punycode.js module instead.
|
||||||
* punycode.decode('--dqo34k'); // '☃-⌘'
|
|
||||||
* ```
|
|
||||||
* @since v0.5.1
|
|
||||||
*/
|
*/
|
||||||
function decode(string: string): string;
|
function decode(string: string): string;
|
||||||
/**
|
/**
|
||||||
* The `punycode.encode()` method converts a string of Unicode codepoints to a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only characters.
|
* @deprecated since v7.0.0
|
||||||
*
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
* ```js
|
* In a future major version of Node.js this module will be removed.
|
||||||
* punycode.encode('mañana'); // 'maana-pta'
|
* Users currently depending on the punycode module should switch to using
|
||||||
* punycode.encode('☃-⌘'); // '--dqo34k'
|
* the userland-provided Punycode.js module instead.
|
||||||
* ```
|
|
||||||
* @since v0.5.1
|
|
||||||
*/
|
*/
|
||||||
function encode(string: string): string;
|
function encode(string: string): string;
|
||||||
/**
|
/**
|
||||||
* The `punycode.toUnicode()` method converts a string representing a domain name
|
* @deprecated since v7.0.0
|
||||||
* containing [Punycode](https://tools.ietf.org/html/rfc3492) encoded characters into Unicode. Only the [Punycode](https://tools.ietf.org/html/rfc3492) encoded parts of the domain name are be
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
* converted.
|
* In a future major version of Node.js this module will be removed.
|
||||||
*
|
* Users currently depending on the punycode module should switch to using
|
||||||
* ```js
|
* the userland-provided Punycode.js module instead.
|
||||||
* // decode domain names
|
|
||||||
* punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com'
|
|
||||||
* punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com'
|
|
||||||
* punycode.toUnicode('example.com'); // 'example.com'
|
|
||||||
* ```
|
|
||||||
* @since v0.6.1
|
|
||||||
*/
|
*/
|
||||||
function toUnicode(domain: string): string;
|
function toUnicode(domain: string): string;
|
||||||
/**
|
/**
|
||||||
* The `punycode.toASCII()` method converts a Unicode string representing an
|
* @deprecated since v7.0.0
|
||||||
* Internationalized Domain Name to [Punycode](https://tools.ietf.org/html/rfc3492). Only the non-ASCII parts of the
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
* domain name will be converted. Calling `punycode.toASCII()` on a string that
|
* In a future major version of Node.js this module will be removed.
|
||||||
* already only contains ASCII characters will have no effect.
|
* Users currently depending on the punycode module should switch to using
|
||||||
*
|
* the userland-provided Punycode.js module instead.
|
||||||
* ```js
|
|
||||||
* // encode domain names
|
|
||||||
* punycode.toASCII('mañana.com'); // 'xn--maana-pta.com'
|
|
||||||
* punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com'
|
|
||||||
* punycode.toASCII('example.com'); // 'example.com'
|
|
||||||
* ```
|
|
||||||
* @since v0.6.1
|
|
||||||
*/
|
*/
|
||||||
function toASCII(domain: string): string;
|
function toASCII(domain: string): string;
|
||||||
/**
|
/**
|
||||||
@@ -112,6 +66,3 @@ declare module 'punycode' {
|
|||||||
*/
|
*/
|
||||||
const version: string;
|
const version: string;
|
||||||
}
|
}
|
||||||
declare module 'node:punycode' {
|
|
||||||
export * from 'punycode';
|
|
||||||
}
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user