Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[node] Add missing constants to node:constants, add missing dlopen types to v18 #71986

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions types/node/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
/**
* @deprecated The `node:constants` module is deprecated. When requiring access to constants
* relevant to specific Node.js builtin modules, developers should instead refer
* to the `constants` property exposed by the relevant module. For instance,
* `require('node:fs').constants` and `require('node:os').constants`.
*/
declare module "constants" {
import { constants as osConstants, SignalConstants } from "node:os";
import { constants as cryptoConstants } from "node:crypto";
import { constants as fsConstants } from "node:fs";

const exp:
& typeof osConstants.errno
& typeof osConstants.priority
& SignalConstants
& typeof cryptoConstants
& typeof fsConstants;
export = exp;
const constants:
& typeof import("node:os").constants.dlopen
& typeof import("node:os").constants.errno
& typeof import("node:os").constants.priority
& typeof import("node:os").constants.signals
& typeof import("node:fs").constants
& typeof import("node:crypto").constants;
export = constants;
}

declare module "node:constants" {
Expand Down
127 changes: 7 additions & 120 deletions types/node/test/constants.ts
Original file line number Diff line number Diff line change
@@ -1,121 +1,8 @@
import * as constants from "node:constants";
{
let str: string;
let num: number;
num = constants.SIGHUP;
num = constants.SIGINT;
num = constants.SIGQUIT;
num = constants.SIGILL;
num = constants.SIGTRAP;
num = constants.SIGABRT;
num = constants.SIGIOT;
num = constants.SIGBUS;
num = constants.SIGFPE;
num = constants.SIGKILL;
num = constants.SIGUSR1;
num = constants.SIGSEGV;
num = constants.SIGUSR2;
num = constants.SIGPIPE;
num = constants.SIGALRM;
num = constants.SIGTERM;
num = constants.SIGCHLD;
num = constants.SIGSTKFLT;
num = constants.SIGCONT;
num = constants.SIGSTOP;
num = constants.SIGTSTP;
num = constants.SIGTTIN;
num = constants.SIGTTOU;
num = constants.SIGURG;
num = constants.SIGXCPU;
num = constants.SIGXFSZ;
num = constants.SIGVTALRM;
num = constants.SIGPROF;
num = constants.SIGWINCH;
num = constants.SIGIO;
num = constants.SIGPOLL;
num = constants.SIGPWR;
num = constants.SIGSYS;
num = constants.SIGUNUSED;
num = constants.O_RDONLY;
num = constants.O_WRONLY;
num = constants.O_RDWR;
num = constants.S_IFMT;
num = constants.S_IFREG;
num = constants.S_IFDIR;
num = constants.S_IFCHR;
num = constants.S_IFBLK;
num = constants.S_IFIFO;
num = constants.S_IFLNK;
num = constants.S_IFSOCK;
num = constants.O_CREAT;
num = constants.O_EXCL;
num = constants.O_NOCTTY;
num = constants.O_TRUNC;
num = constants.O_APPEND;
num = constants.O_DIRECTORY;
num = constants.O_NOATIME;
num = constants.O_NOFOLLOW;
num = constants.O_SYNC;
num = constants.O_DSYNC;
num = constants.O_DIRECT;
num = constants.O_NONBLOCK;
num = constants.S_IRWXU;
num = constants.S_IRUSR;
num = constants.S_IWUSR;
num = constants.S_IXUSR;
num = constants.S_IRWXG;
num = constants.S_IRGRP;
num = constants.S_IWGRP;
num = constants.S_IXGRP;
num = constants.S_IRWXO;
num = constants.S_IROTH;
num = constants.S_IWOTH;
num = constants.S_IXOTH;
num = constants.F_OK;
num = constants.R_OK;
num = constants.W_OK;
num = constants.X_OK;
num = constants.SSL_OP_ALL;
num = constants.SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION;
num = constants.SSL_OP_CIPHER_SERVER_PREFERENCE;
num = constants.SSL_OP_CISCO_ANYCONNECT;
num = constants.SSL_OP_COOKIE_EXCHANGE;
num = constants.SSL_OP_CRYPTOPRO_TLSEXT_BUG;
num = constants.SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
num = constants.SSL_OP_LEGACY_SERVER_CONNECT;
num = constants.SSL_OP_NO_COMPRESSION;
num = constants.SSL_OP_NO_QUERY_MTU;
num = constants.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;
num = constants.SSL_OP_NO_SSLv2;
num = constants.SSL_OP_NO_SSLv3;
num = constants.SSL_OP_NO_TICKET;
num = constants.SSL_OP_NO_TLSv1;
num = constants.SSL_OP_NO_TLSv1_1;
num = constants.SSL_OP_NO_TLSv1_2;
num = constants.SSL_OP_TLS_ROLLBACK_BUG;
num = constants.ENGINE_METHOD_RSA;
num = constants.ENGINE_METHOD_DSA;
num = constants.ENGINE_METHOD_DH;
num = constants.ENGINE_METHOD_RAND;
num = constants.ENGINE_METHOD_CIPHERS;
num = constants.ENGINE_METHOD_DIGESTS;
num = constants.ENGINE_METHOD_PKEY_METHS;
num = constants.ENGINE_METHOD_PKEY_ASN1_METHS;
num = constants.ENGINE_METHOD_ALL;
num = constants.ENGINE_METHOD_NONE;
num = constants.DH_CHECK_P_NOT_SAFE_PRIME;
num = constants.DH_CHECK_P_NOT_PRIME;
num = constants.DH_UNABLE_TO_CHECK_GENERATOR;
num = constants.DH_NOT_SUITABLE_GENERATOR;
num = constants.RSA_PKCS1_PADDING;
num = constants.RSA_SSLV23_PADDING;
num = constants.RSA_NO_PADDING;
num = constants.RSA_PKCS1_OAEP_PADDING;
num = constants.RSA_X931_PADDING;
num = constants.RSA_PKCS1_PSS_PADDING;
num = constants.POINT_CONVERSION_COMPRESSED;
num = constants.POINT_CONVERSION_UNCOMPRESSED;
num = constants.POINT_CONVERSION_HYBRID;
str = constants.defaultCoreCipherList;
str = constants.defaultCipherList;
}

const dlopen: typeof import("node:os").constants.dlopen = constants;
const errno: typeof import("node:os").constants.errno = constants;
const priority: typeof import("node:os").constants.priority = constants;
const signals: typeof import("node:os").constants.signals = constants;
const fs: typeof import("node:fs").constants = constants;
const crypto: typeof import("node:crypto").constants = constants;
26 changes: 14 additions & 12 deletions types/node/v18/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
/**
* @deprecated The `node:constants` module is deprecated. When requiring access to constants
* relevant to specific Node.js builtin modules, developers should instead refer
* to the `constants` property exposed by the relevant module. For instance,
* `require('node:fs').constants` and `require('node:os').constants`.
*/
declare module "constants" {
import { constants as osConstants, SignalConstants } from "node:os";
import { constants as cryptoConstants } from "node:crypto";
import { constants as fsConstants } from "node:fs";

const exp:
& typeof osConstants.errno
& typeof osConstants.priority
& SignalConstants
& typeof cryptoConstants
& typeof fsConstants;
export = exp;
const constants:
& typeof import("node:os").constants.dlopen
& typeof import("node:os").constants.errno
& typeof import("node:os").constants.priority
& typeof import("node:os").constants.signals
& typeof import("node:fs").constants
& typeof import("node:crypto").constants;
export = constants;
}

declare module "node:constants" {
Expand Down
7 changes: 7 additions & 0 deletions types/node/v18/os.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ declare module "os" {
const WSA_E_CANCELLED: number;
const WSAEREFUSED: number;
}
namespace dlopen {
const RTLD_LAZY: number;
const RTLD_NOW: number;
const RTLD_GLOBAL: number;
const RTLD_LOCAL: number;
const RTLD_DEEPBIND: number;
}
namespace priority {
const PRIORITY_LOW: number;
const PRIORITY_BELOW_NORMAL: number;
Expand Down
27 changes: 27 additions & 0 deletions types/node/v18/process.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,33 @@ declare module "process" {
* @since v0.7.2
*/
debugPort: number;
/**
* The `process.dlopen()` method allows dynamically loading shared objects. It is primarily used by `require()` to load C++ Addons, and
* should not be used directly, except in special cases. In other words, `require()` should be preferred over `process.dlopen()`
* unless there are specific reasons such as custom dlopen flags or loading from ES modules.
*
* The `flags` argument is an integer that allows to specify dlopen behavior. See the `[os.constants.dlopen](https://nodejs.org/docs/latest-v20.x/api/os.html#dlopen-constants)`
* documentation for details.
*
* An important requirement when calling `process.dlopen()` is that the `module` instance must be passed. Functions exported by the C++ Addon
* are then accessible via `module.exports`.
*
* The example below shows how to load a C++ Addon, named `local.node`, that exports a `foo` function. All the symbols are loaded before the call returns, by passing the `RTLD_NOW` constant.
* In this example the constant is assumed to be available.
*
* ```js
* import { dlopen } from 'node:process';
* import { constants } from 'node:os';
* import { fileURLToPath } from 'node:url';
*
* const module = { exports: {} };
* dlopen(module, fileURLToPath(new URL('local.node', import.meta.url)),
* constants.dlopen.RTLD_NOW);
* module.exports.foo();
* ```
* @since v0.1.16
*/
dlopen(module: object, filename: string, flags?: number): void;
/**
* The `process.emitWarning()` method can be used to emit custom or application
* specific process warnings. These can be listened for by adding a handler to the `'warning'` event.
Expand Down
144 changes: 7 additions & 137 deletions types/node/v18/test/constants.ts
Original file line number Diff line number Diff line change
@@ -1,138 +1,8 @@
import * as constants from "node:constants";
{
let str: string;
let num: number;
num = constants.SIGHUP;
num = constants.SIGINT;
num = constants.SIGQUIT;
num = constants.SIGILL;
num = constants.SIGTRAP;
num = constants.SIGABRT;
num = constants.SIGIOT;
num = constants.SIGBUS;
num = constants.SIGFPE;
num = constants.SIGKILL;
num = constants.SIGUSR1;
num = constants.SIGSEGV;
num = constants.SIGUSR2;
num = constants.SIGPIPE;
num = constants.SIGALRM;
num = constants.SIGTERM;
num = constants.SIGCHLD;
num = constants.SIGSTKFLT;
num = constants.SIGCONT;
num = constants.SIGSTOP;
num = constants.SIGTSTP;
num = constants.SIGTTIN;
num = constants.SIGTTOU;
num = constants.SIGURG;
num = constants.SIGXCPU;
num = constants.SIGXFSZ;
num = constants.SIGVTALRM;
num = constants.SIGPROF;
num = constants.SIGWINCH;
num = constants.SIGIO;
num = constants.SIGPOLL;
num = constants.SIGPWR;
num = constants.SIGSYS;
num = constants.SIGUNUSED;
num = constants.O_RDONLY;
num = constants.O_WRONLY;
num = constants.O_RDWR;
num = constants.S_IFMT;
num = constants.S_IFREG;
num = constants.S_IFDIR;
num = constants.S_IFCHR;
num = constants.S_IFBLK;
num = constants.S_IFIFO;
num = constants.S_IFLNK;
num = constants.S_IFSOCK;
num = constants.O_CREAT;
num = constants.O_EXCL;
num = constants.O_NOCTTY;
num = constants.O_TRUNC;
num = constants.O_APPEND;
num = constants.O_DIRECTORY;
num = constants.O_NOATIME;
num = constants.O_NOFOLLOW;
num = constants.O_SYNC;
num = constants.O_DSYNC;
num = constants.O_DIRECT;
num = constants.O_NONBLOCK;
num = constants.S_IRWXU;
num = constants.S_IRUSR;
num = constants.S_IWUSR;
num = constants.S_IXUSR;
num = constants.S_IRWXG;
num = constants.S_IRGRP;
num = constants.S_IWGRP;
num = constants.S_IXGRP;
num = constants.S_IRWXO;
num = constants.S_IROTH;
num = constants.S_IWOTH;
num = constants.S_IXOTH;
num = constants.F_OK;
num = constants.R_OK;
num = constants.W_OK;
num = constants.X_OK;
num = constants.SSL_OP_ALL;
num = constants.SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION;
num = constants.SSL_OP_CIPHER_SERVER_PREFERENCE;
num = constants.SSL_OP_CISCO_ANYCONNECT;
num = constants.SSL_OP_COOKIE_EXCHANGE;
num = constants.SSL_OP_CRYPTOPRO_TLSEXT_BUG;
num = constants.SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
num = constants.SSL_OP_EPHEMERAL_RSA;
num = constants.SSL_OP_LEGACY_SERVER_CONNECT;
num = constants.SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER;
num = constants.SSL_OP_MICROSOFT_SESS_ID_BUG;
num = constants.SSL_OP_MSIE_SSLV2_RSA_PADDING;
num = constants.SSL_OP_NETSCAPE_CA_DN_BUG;
num = constants.SSL_OP_NETSCAPE_CHALLENGE_BUG;
num = constants.SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG;
num = constants.SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG;
num = constants.SSL_OP_NO_COMPRESSION;
num = constants.SSL_OP_NO_QUERY_MTU;
num = constants.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;
num = constants.SSL_OP_NO_SSLv2;
num = constants.SSL_OP_NO_SSLv3;
num = constants.SSL_OP_NO_TICKET;
num = constants.SSL_OP_NO_TLSv1;
num = constants.SSL_OP_NO_TLSv1_1;
num = constants.SSL_OP_NO_TLSv1_2;
num = constants.SSL_OP_PKCS1_CHECK_1;
num = constants.SSL_OP_PKCS1_CHECK_2;
num = constants.SSL_OP_SINGLE_DH_USE;
num = constants.SSL_OP_SINGLE_ECDH_USE;
num = constants.SSL_OP_SSLEAY_080_CLIENT_DH_BUG;
num = constants.SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG;
num = constants.SSL_OP_TLS_BLOCK_PADDING_BUG;
num = constants.SSL_OP_TLS_D5_BUG;
num = constants.SSL_OP_TLS_ROLLBACK_BUG;
num = constants.ENGINE_METHOD_RSA;
num = constants.ENGINE_METHOD_DSA;
num = constants.ENGINE_METHOD_DH;
num = constants.ENGINE_METHOD_RAND;
num = constants.ENGINE_METHOD_CIPHERS;
num = constants.ENGINE_METHOD_DIGESTS;
num = constants.ENGINE_METHOD_PKEY_METHS;
num = constants.ENGINE_METHOD_PKEY_ASN1_METHS;
num = constants.ENGINE_METHOD_ALL;
num = constants.ENGINE_METHOD_NONE;
num = constants.DH_CHECK_P_NOT_SAFE_PRIME;
num = constants.DH_CHECK_P_NOT_PRIME;
num = constants.DH_UNABLE_TO_CHECK_GENERATOR;
num = constants.DH_NOT_SUITABLE_GENERATOR;
num = constants.ALPN_ENABLED;
num = constants.RSA_PKCS1_PADDING;
num = constants.RSA_SSLV23_PADDING;
num = constants.RSA_NO_PADDING;
num = constants.RSA_PKCS1_OAEP_PADDING;
num = constants.RSA_X931_PADDING;
num = constants.RSA_PKCS1_PSS_PADDING;
num = constants.POINT_CONVERSION_COMPRESSED;
num = constants.POINT_CONVERSION_UNCOMPRESSED;
num = constants.POINT_CONVERSION_HYBRID;
str = constants.defaultCoreCipherList;
str = constants.defaultCipherList;
}

const dlopen: typeof import("node:os").constants.dlopen = constants;
const errno: typeof import("node:os").constants.errno = constants;
const priority: typeof import("node:os").constants.priority = constants;
const signals: typeof import("node:os").constants.signals = constants;
const fs: typeof import("node:fs").constants = constants;
const crypto: typeof import("node:crypto").constants = constants;
Loading