diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 2c62241dd..daa6acd2c 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -14,6 +14,7 @@ module.exports = { // aren't imported as 'import type' in other parts of the generated // querybuilder, so set this option to ensure we always do that "@typescript-eslint/consistent-type-imports": "error", - "@typescript-eslint/no-namespace": "off" + "@typescript-eslint/no-namespace": "off", + "@typescript-eslint/no-inferrable-types": "off", } }; diff --git a/compileForDeno.ts b/compileForDeno.ts index dfee239ed..419d410d8 100644 --- a/compileForDeno.ts +++ b/compileForDeno.ts @@ -135,7 +135,7 @@ export async function run({ let resolvedImportPath = resolveImportPath(importPath, sourcePath); - for (const name of ["adapter", "adapter.shared", "adapter.crypto"]) { + for (const name of ["adapter", "adapter.crypto"]) { if (resolvedImportPath.endsWith(`/${name}.node.ts`)) { resolvedImportPath = resolvedImportPath.replace( `/${name}.node.ts`, diff --git a/packages/driver/src/adapter.node.ts b/packages/driver/src/adapter.node.ts index e549ded9e..cb563a02c 100644 --- a/packages/driver/src/adapter.node.ts +++ b/packages/driver/src/adapter.node.ts @@ -1,13 +1,13 @@ -import * as crypto from "crypto"; -import { promises as fs } from "fs"; -import * as net from "net"; -import * as os from "os"; -import * as path from "path"; -import * as tls from "tls"; +import * as crypto from "node:crypto"; +import { promises as fs } from "node:fs"; +import * as net from "node:net"; +import * as os from "node:os"; +import * as path from "node:path"; +import * as tls from "node:tls"; -import process from "process"; -import * as readline from "readline"; -import { Writable } from "stream"; +import process from "node:process"; +import * as readline from "node:readline"; +import { Writable } from "node:stream"; export { path, net, fs, tls, process }; @@ -84,7 +84,7 @@ export function input( ): Promise { let silent = false; - const output = !!params?.silent + const output = params?.silent ? new Writable({ write( chunk: any, @@ -101,7 +101,7 @@ export function input( output, }); - return new Promise((resolve, rej) => { + return new Promise((resolve) => { rl.question(message, (val) => { rl.close(); resolve(val); diff --git a/packages/driver/src/adapter.shared.deno.ts b/packages/driver/src/adapter.shared.deno.ts deleted file mode 100644 index 2edbab714..000000000 --- a/packages/driver/src/adapter.shared.deno.ts +++ /dev/null @@ -1,12 +0,0 @@ -export function getEnv(envName: string, required = false): string | undefined { - if (!required) { - const state = Deno.permissions.querySync({ - name: "env", - variable: envName, - }).state; - if (state !== "granted") { - return undefined; - } - } - return Deno.env.get(envName); -} diff --git a/packages/driver/src/adapter.shared.node.ts b/packages/driver/src/adapter.shared.node.ts deleted file mode 100644 index 0c47fe445..000000000 --- a/packages/driver/src/adapter.shared.node.ts +++ /dev/null @@ -1,6 +0,0 @@ -export function getEnv( - envName: string, - required: boolean = false -): string | undefined { - return process.env[envName]; -} diff --git a/packages/driver/src/browserClient.ts b/packages/driver/src/browserClient.ts index 255d648cc..8c2818f9a 100644 --- a/packages/driver/src/browserClient.ts +++ b/packages/driver/src/browserClient.ts @@ -1,4 +1,4 @@ -import { BaseClientPool, Client, ConnectOptions } from "./baseClient"; +import { BaseClientPool, Client, type ConnectOptions } from "./baseClient"; import { getConnectArgumentsParser } from "./conUtils"; import cryptoUtils from "./browserCrypto"; import { EdgeDBError } from "./errors"; @@ -6,7 +6,8 @@ import { FetchConnection } from "./fetchConn"; import { getHTTPSCRAMAuth } from "./httpScram"; import { Options } from "./options"; -const parseConnectArguments = getConnectArgumentsParser(null); +const makeConnectArgumentsParser = (env: Record) => + getConnectArgumentsParser(null, env); const httpSCRAMAuth = getHTTPSCRAMAuth(cryptoUtils); class FetchClientPool extends BaseClientPool { @@ -22,11 +23,12 @@ export function createClient(): Client { } export function createHttpClient( - options?: string | ConnectOptions | null + options?: string | ConnectOptions | null, + env: Record = {} ): Client { return new Client( new FetchClientPool( - parseConnectArguments, + makeConnectArgumentsParser(env), typeof options === "string" ? { dsn: options } : options ?? {} ), Options.defaults() diff --git a/packages/driver/src/conUtils.server.ts b/packages/driver/src/conUtils.server.ts index ab9fef048..fa9eecd12 100644 --- a/packages/driver/src/conUtils.server.ts +++ b/packages/driver/src/conUtils.server.ts @@ -59,4 +59,5 @@ export const serverUtils = { searchConfigDir: platform.searchConfigDir, }; -export const parseConnectArguments = getConnectArgumentsParser(serverUtils); +export const makeConnectArgumentsParser = () => + getConnectArgumentsParser(serverUtils, process.env); diff --git a/packages/driver/src/conUtils.ts b/packages/driver/src/conUtils.ts index ff4ee0147..43102a65b 100644 --- a/packages/driver/src/conUtils.ts +++ b/packages/driver/src/conUtils.ts @@ -18,12 +18,11 @@ import * as errors from "./errors"; import { - Credentials, + type Credentials, getCredentialsPath, readCredentialsFile, validateCredentials, } from "./credentials"; -import { getEnv } from "./adapter.shared.node"; import { Duration, parseHumanDurationString } from "./datatypes/datetime"; import { checkValidEdgeDBDuration } from "./codecs/datetime"; import { InterfaceError } from "./errors"; @@ -101,11 +100,12 @@ export type ConnectArgumentsParser = ( ) => Promise; export function getConnectArgumentsParser( - utils: ServerUtils | null + utils: ServerUtils | null, + env: { [key: string]: string | undefined } ): ConnectArgumentsParser { return async (opts: ConnectConfig) => { return { - ...(await parseConnectDsnAndArgs(opts, utils)), + ...(await parseConnectDsnAndArgs(opts, utils, env)), connectTimeout: opts.timeout, logging: opts.logging ?? true, }; @@ -156,8 +156,11 @@ export class ResolvedConnectConfig { _waitUntilAvailableSource: string | null = null; serverSettings: { [key: string]: string } = {}; + env: { [key: string]: string | undefined } = {}; + + constructor(env: { [key: string]: string | undefined }) { + this.env = env; - constructor() { this.setHost = this.setHost.bind(this); this.setPort = this.setPort.bind(this); this.setDatabase = this.setDatabase.bind(this); @@ -271,7 +274,7 @@ export class ResolvedConnectConfig { .join(", ")}` ); } - const clientSecurity = getEnv("EDGEDB_CLIENT_SECURITY"); + const clientSecurity = this.env["EDGEDB_CLIENT_SECURITY"]; if (clientSecurity !== undefined) { if ( !["default", "insecure_dev_mode", "strict"].includes(clientSecurity) @@ -483,9 +486,10 @@ export function parseDuration(duration: string | number | Duration): number { async function parseConnectDsnAndArgs( config: ConnectConfig, - serverUtils: ServerUtils | null + serverUtils: ServerUtils | null, + env: { [key: string]: string | undefined } ): Promise { - const resolvedConfig = new ResolvedConnectConfig(); + const resolvedConfig = new ResolvedConnectConfig(env); let fromEnv = false; let fromProject = false; @@ -510,7 +514,7 @@ async function parseConnectDsnAndArgs( user: config.user, password: config.password, secretKey: config.secretKey, - cloudProfile: getEnv("EDGEDB_CLOUD_PROFILE"), + cloudProfile: env["EDGEDB_CLOUD_PROFILE"], tlsCA: config.tlsCA, tlsCAFile: config.tlsCAFile, tlsSecurity: config.tlsSecurity, @@ -540,13 +544,14 @@ async function parseConnectDsnAndArgs( }, `Cannot have more than one of the following connection options: ` + `'dsn', 'instanceName', 'credentials', 'credentialsFile' or 'host'/'port'`, - serverUtils + serverUtils, + env ); if (!hasCompoundOptions) { // resolve config from env vars - let port: string | undefined = getEnv("EDGEDB_PORT"); + let port: string | undefined = env["EDGEDB_PORT"]; if (resolvedConfig._port === null && port?.startsWith("tcp://")) { // EDGEDB_PORT is set by 'docker --link' so ignore and warn // tslint:disable-next-line: no-console @@ -560,20 +565,20 @@ async function parseConnectDsnAndArgs( await resolveConfigOptions( resolvedConfig, { - dsn: getEnv("EDGEDB_DSN"), - instanceName: getEnv("EDGEDB_INSTANCE"), - credentials: getEnv("EDGEDB_CREDENTIALS"), - credentialsFile: getEnv("EDGEDB_CREDENTIALS_FILE"), - host: getEnv("EDGEDB_HOST"), + dsn: env["EDGEDB_DSN"], + instanceName: env["EDGEDB_INSTANCE"], + credentials: env["EDGEDB_CREDENTIALS"], + credentialsFile: env["EDGEDB_CREDENTIALS_FILE"], + host: env["EDGEDB_HOST"], port, - database: getEnv("EDGEDB_DATABASE"), - user: getEnv("EDGEDB_USER"), - password: getEnv("EDGEDB_PASSWORD"), - secretKey: getEnv("EDGEDB_SECRET_KEY"), - tlsCA: getEnv("EDGEDB_TLS_CA"), - tlsCAFile: getEnv("EDGEDB_TLS_CA_FILE"), - tlsSecurity: getEnv("EDGEDB_CLIENT_TLS_SECURITY"), - waitUntilAvailable: getEnv("EDGEDB_WAIT_UNTIL_AVAILABLE"), + database: env["EDGEDB_DATABASE"], + user: env["EDGEDB_USER"], + password: env["EDGEDB_PASSWORD"], + secretKey: env["EDGEDB_SECRET_KEY"], + tlsCA: env["EDGEDB_TLS_CA"], + tlsCAFile: env["EDGEDB_TLS_CA_FILE"], + tlsSecurity: env["EDGEDB_CLIENT_TLS_SECURITY"], + waitUntilAvailable: env["EDGEDB_WAIT_UNTIL_AVAILABLE"], }, { dsn: `'EDGEDB_DSN' environment variable`, @@ -594,7 +599,8 @@ async function parseConnectDsnAndArgs( `Cannot have more than one of the following connection environment variables: ` + `'EDGEDB_DSN', 'EDGEDB_INSTANCE', 'EDGEDB_CREDENTIALS', ` + `'EDGEDB_CREDENTIALS_FILE' or 'EDGEDB_HOST'`, - serverUtils + serverUtils, + env )); } @@ -643,7 +649,8 @@ async function parseConnectDsnAndArgs( database: `project default database`, }, "", - serverUtils + serverUtils, + env ); fromProject = true; } else { @@ -690,7 +697,8 @@ async function resolveConfigOptions< config: Config, sources: { [key in keyof Config]: string }, compoundParamsError: string, - serverUtils: ServerUtils | null + serverUtils: ServerUtils | null, + env: Record ): Promise<{ hasCompoundOptions: boolean; anyOptionsUsed: boolean }> { let anyOptionsUsed = false; @@ -780,7 +788,8 @@ async function resolveConfigOptions< : config.host !== undefined ? sources.host! : sources.port!, - readFile + readFile, + env ); } else { let creds: Credentials; @@ -848,13 +857,14 @@ async function parseDSNIntoConfig( _dsnString: string, config: ResolvedConnectConfig, source: string, - readFile: (fn: string) => Promise + readFile: (fn: string) => Promise, + env: Record ): Promise { // URL api does not support ipv6 zone ids, so extract zone id before parsing // https://url.spec.whatwg.org/#host-representation let dsnString = _dsnString; let regexHostname: string | null = null; - let zoneId: string = ""; + let zoneId = ""; const regexResult = /\[(.*?)(%25.+?)\]/.exec(_dsnString); if (regexResult) { regexHostname = regexResult[1]; @@ -920,15 +930,15 @@ async function parseDSNIntoConfig( let param = value || (searchParams.get(paramName) ?? null); let paramSource = source; if (param === null) { - const env = searchParams.get(`${paramName}_env`); - if (env != null) { - param = getEnv(env, true) ?? null; + const key = searchParams.get(`${paramName}_env`); + if (key != null) { + param = env[key] ?? null; if (param === null) { throw new InterfaceError( - `'${paramName}_env' environment variable '${env}' doesn't exist` + `'${paramName}_env' environment variable '${key}' doesn't exist` ); } - paramSource += ` (${paramName}_env: ${env})`; + paramSource += ` (${paramName}_env: ${key})`; } } if (param === null) { diff --git a/packages/driver/src/nodeClient.ts b/packages/driver/src/nodeClient.ts index 00b08f5c5..904a18927 100644 --- a/packages/driver/src/nodeClient.ts +++ b/packages/driver/src/nodeClient.ts @@ -1,11 +1,13 @@ -import { BaseClientPool, Client, ConnectOptions } from "./baseClient"; -import { parseConnectArguments } from "./conUtils.server"; +import { BaseClientPool, Client, type ConnectOptions } from "./baseClient"; +import { makeConnectArgumentsParser } from "./conUtils.server"; import cryptoUtils from "./adapter.crypto.node"; import { Options } from "./options"; import { RawConnection } from "./rawConn"; import { FetchConnection } from "./fetchConn"; import { getHTTPSCRAMAuth } from "./httpScram"; +const parseConnectArguments = makeConnectArgumentsParser(); + class ClientPool extends BaseClientPool { isStateless = false; _connectWithTimeout = RawConnection.connectWithTimeout.bind(RawConnection); diff --git a/packages/driver/src/primitives/buffer.ts b/packages/driver/src/primitives/buffer.ts index 536e39005..8bb650957 100644 --- a/packages/driver/src/primitives/buffer.ts +++ b/packages/driver/src/primitives/buffer.ts @@ -34,16 +34,19 @@ let decodeB64: (b64: string) => Uint8Array; let encodeB64: (data: Uint8Array) => string; // @ts-ignore: Buffer is not defined in Deno -if (Buffer === "function") { +globalThis.Buffer = globalThis.Buffer || undefined; + +// @ts-ignore: Buffer is not defined in Deno +if (globalThis.Buffer && globalThis.Buffer === "function") { decodeB64 = (b64: string): Uint8Array => { // @ts-ignore: Buffer is not defined in Deno - return Buffer.from(b64, "base64"); + return globalThis.Buffer.from(b64, "base64"); }; encodeB64 = (data: Uint8Array): string => { // @ts-ignore: Buffer is not defined in Deno - const buf = !Buffer.isBuffer(data) + const buf = !globalThis.Buffer.isBuffer(data) ? // @ts-ignore: Buffer is not defined in Deno - Buffer.from(data.buffer, data.byteOffset, data.byteLength) + globalThis.Buffer.from(data.buffer, data.byteOffset, data.byteLength) : data; return buf.toString("base64"); }; diff --git a/packages/driver/test/browser.test.ts b/packages/driver/test/browser.test.ts index 486423fae..e072d3455 100644 --- a/packages/driver/test/browser.test.ts +++ b/packages/driver/test/browser.test.ts @@ -18,45 +18,45 @@ const version = getEdgeDBVersion(); beforeAll(async () => { for (const nodeModule of [ - "assert", - "async_hooks", - "buffer", - "child_process", - "cluster", - "console", - "constants", - "crypto", - "dgram", - "dns", - "domain", - "events", - "fs", - "http", - "http2", - "https", - "inspector", - "module", - "net", - "os", - "path", - "perf_hooks", - "process", - "punycode", - "querystring", - "readline", - "repl", - "stream", - "string_decoder", - "timers", - "tls", - "trace_events", - "tty", - "url", - "util", - "v8", - "vm", - "worker_threads", - "zlib", + "node:assert", + "node:async_hooks", + "node:buffer", + "node:child_process", + "node:cluster", + "node:console", + "node:constants", + "node:crypto", + "node:dgram", + "node:dns", + "node:domain", + "node:events", + "node:fs", + "node:http", + "node:http2", + "node:https", + "node:inspector", + "node:module", + "node:net", + "node:os", + "node:path", + "node:perf_hooks", + "node:process", + "node:punycode", + "node:querystring", + "node:readline", + "node:repl", + "node:stream", + "node:string_decoder", + "node:timers", + "node:tls", + "node:trace_events", + "node:tty", + "node:url", + "node:util", + "node:v8", + "node:vm", + "node:worker_threads", + "node:zlib", ]) { jest.mock(nodeModule, () => { throw new Error(`Cannot use node module '${nodeModule}' in browser`); diff --git a/packages/driver/test/client.test.ts b/packages/driver/test/client.test.ts index 2326169e8..a3b55ba48 100644 --- a/packages/driver/test/client.test.ts +++ b/packages/driver/test/client.test.ts @@ -17,7 +17,7 @@ */ import fc from "fast-check"; -import { parseConnectArguments } from "../src/conUtils.server"; +import { makeConnectArgumentsParser } from "../src/conUtils.server"; import type { Client, Executor, _ICodec } from "../src/index.node"; import { DivisionByZeroError, @@ -2071,7 +2071,7 @@ function _decodeResultBuffer(outCodec: _ICodec, resultData: Uint8Array) { if (!isDeno && getAvailableFeatures().has("binary-over-http")) { test("binary protocol over http", async () => { const codecsRegistry = new _CodecsRegistry(); - const config = await parseConnectArguments(getConnectOptions()); + const config = await makeConnectArgumentsParser()(getConnectOptions()); const { address, user, password } = config.connectionParams; const token = await getHTTPSCRAMAuth(cryptoUtils)( @@ -2114,7 +2114,7 @@ if (!isDeno && getAvailableFeatures().has("binary-over-http")) { test("binary protocol over http failing auth", async () => { const codecsRegistry = new _CodecsRegistry(); - const config = await parseConnectArguments(getConnectOptions()); + const config = await makeConnectArgumentsParser()(getConnectOptions()); const fetchConn = AdminUIFetchConnection.create( { address: config.connectionParams.address, diff --git a/packages/driver/test/connection.test.ts b/packages/driver/test/connection.test.ts index 9b66daa39..102f5a70d 100644 --- a/packages/driver/test/connection.test.ts +++ b/packages/driver/test/connection.test.ts @@ -20,8 +20,8 @@ let mockFs = false; let mockedFiles: { [key: string]: string } = {}; let homedir: string | null = null; -jest.mock("fs", () => { - const actualFs = jest.requireActual("fs"); +jest.mock("node:fs", () => { + const actualFs = jest.requireActual("node:fs"); return { ...actualFs, @@ -61,8 +61,8 @@ jest.mock("fs", () => { }, }; }); -jest.mock("os", () => { - const actualOs = jest.requireActual("os"); +jest.mock("node:os", () => { + const actualOs = jest.requireActual("node:os"); return { ...actualOs, @@ -77,7 +77,10 @@ import * as crypto from "crypto"; import { join as pathJoin } from "path"; import { Client, Duration } from "../src/index.node"; import { parseDuration } from "../src/conUtils"; -import { parseConnectArguments, findStashPath } from "../src/conUtils.server"; +import { + makeConnectArgumentsParser, + findStashPath, +} from "../src/conUtils.server"; import { getClient } from "./testbase"; import * as errors from "../src/errors"; import * as platform from "../src/platform"; @@ -253,14 +256,14 @@ async function runConnectionTest(testcase: ConnectionTestCase): Promise { } await expect(() => - envWrap({ env, fs }, () => parseConnectArguments(opts)) + envWrap({ env, fs }, () => makeConnectArgumentsParser()(opts)) ).rejects.toThrow(error); } else { const warnings = await envWrap( { env, fs, captureWarnings: !!testcase.warnings }, async () => { try { - const { connectionParams } = await parseConnectArguments(opts); + const { connectionParams } = await makeConnectArgumentsParser()(opts); let waitMilli = connectionParams.waitUntilAvailable; const waitHours = Math.floor(waitMilli / 3_600_000); @@ -298,8 +301,15 @@ async function runConnectionTest(testcase: ConnectionTestCase): Promise { ), }); } catch (e) { - console.log(testcase); - throw e; + throw new Error( + `\ +Failing test case: +${JSON.stringify(testcase, null, 2)} +process.env: ${JSON.stringify(process.env)}`, + { + cause: e, + } + ); } } ); @@ -315,7 +325,7 @@ async function runConnectionTest(testcase: ConnectionTestCase): Promise { } } -test("parseConnectArguments", async () => { +describe("parseConnectArguments", () => { let connectionTestcases: any[]; try { connectionTestcases = JSON.parse( @@ -332,9 +342,12 @@ test("parseConnectArguments", async () => { ); } - for (const testcase of connectionTestcases) { - await runConnectionTest(testcase); - } + test.each(connectionTestcases)( + "connection test %#", + async (testcase: ConnectionTestCase) => { + await runConnectionTest(testcase); + } + ); }); const platformNames: { [key: string]: string } = { @@ -343,7 +356,7 @@ const platformNames: { [key: string]: string } = { linux: "linux", }; -test("project path hashing", async () => { +describe("project path hashing", () => { let hashingTestcases: { platform: string; homeDir: string; @@ -368,7 +381,7 @@ test("project path hashing", async () => { ); } - for (const testcase of hashingTestcases) { + test.each(hashingTestcases)("hashing test %#", async (testcase) => { if (platformNames[testcase.platform] === process.platform) { await envWrap( { env: testcase.env ?? {}, fs: { homedir: testcase.homeDir } }, @@ -376,10 +389,10 @@ test("project path hashing", async () => { expect(await findStashPath(testcase.project)).toBe(testcase.result) ); } - } + }); }); -test("logging, inProject, fromProject, fromEnv", async () => { +describe("logging, inProject, fromProject, fromEnv", () => { const defaults = { address: ["localhost", 5656], database: "edgedb", @@ -390,7 +403,7 @@ test("logging, inProject, fromProject, fromEnv", async () => { serverSettings: {}, }; - for (const testcase of [ + const testcases = [ { opts: { host: "localhost", user: "user", logging: false }, result: { ...defaults, user: "user" }, @@ -520,19 +533,21 @@ test("logging, inProject, fromProject, fromEnv", async () => { fromProject: false, fromEnv: false, }, - ]) { + ]; + + test.each(testcases)("test %#", async (testcase) => { if ( testcase.fs && (process.platform === "win32" || process.platform === "darwin") ) { - continue; + return; } await envWrap( { env: testcase.env as any, fs: testcase.fs as any }, async () => { const { connectionParams, logging, inProject, fromProject, fromEnv } = - await parseConnectArguments(testcase.opts); + await makeConnectArgumentsParser()(testcase.opts); expect({ address: connectionParams.address, database: connectionParams.database, @@ -548,10 +563,10 @@ test("logging, inProject, fromProject, fromEnv", async () => { expect(fromEnv).toEqual(testcase.fromEnv); } ); - } + }); }); -test("EDGEDB_CLIENT_SECURITY env var", async () => { +describe("EDGEDB_CLIENT_SECURITY env var", () => { const truthTable: [string, string, string | null][] = [ // CLIENT_SECURITY, CLIENT_TLS_SECURITY, result ["default", "default", "default"], @@ -568,27 +583,30 @@ test("EDGEDB_CLIENT_SECURITY env var", async () => { ["strict", "strict", "strict"], ]; - for (const [clientSecurity, clientTlsSecurity, result] of truthTable) { - await envWrap( - { - env: { - EDGEDB_CLIENT_SECURITY: clientSecurity, + test.each(truthTable)( + "given CLIENT_SECURITY %s and CLIENT_TLS_SECURITY %s, expects result %s", + async (clientSecurity, clientTlsSecurity, result) => { + await envWrap( + { + env: { + EDGEDB_CLIENT_SECURITY: clientSecurity, + }, }, - }, - async () => { - const parseConnectArgs = parseConnectArguments({ - host: "localhost", - tlsSecurity: clientTlsSecurity as any, - }); - if (!result) { - await expect(parseConnectArgs).rejects.toThrow(); - } else { - const { connectionParams } = await parseConnectArgs; - expect(connectionParams._tlsSecurity).toBe(result); + async () => { + const parseConnectArgs = makeConnectArgumentsParser()({ + host: "localhost", + tlsSecurity: clientTlsSecurity as any, + }); + if (!result) { + await expect(parseConnectArgs).rejects.toThrow(); + } else { + const { connectionParams } = await parseConnectArgs; + expect(connectionParams._tlsSecurity).toBe(result); + } } - } - ); - } + ); + } + ); }); test("connect: timeout", async () => { diff --git a/packages/driver/test/retryConnError.test.ts b/packages/driver/test/retryConnError.test.ts index c21fe8d8c..05a31afcb 100644 --- a/packages/driver/test/retryConnError.test.ts +++ b/packages/driver/test/retryConnError.test.ts @@ -25,8 +25,8 @@ interface PatchedTLSSocket extends TLSSocket { let currentSocket: PatchedTLSSocket | null = null; -jest.mock("tls", () => { - const actualTls = jest.requireActual("tls"); +jest.mock("node:tls", () => { + const actualTls = jest.requireActual("node:tls"); function patchTlsSocket(_socket: TLSSocket) { const socket = _socket as PatchedTLSSocket; diff --git a/packages/driver/tsconfig.json b/packages/driver/tsconfig.json index 73bb1f242..fdcdb857e 100644 --- a/packages/driver/tsconfig.json +++ b/packages/driver/tsconfig.json @@ -3,7 +3,10 @@ "compilerOptions": { "declarationDir": "./dist", "outDir": "./dist", - "downlevelIteration": true + "downlevelIteration": true, + "lib": [ + "es2022" + ] // "baseUrl": ".", // "typeRoots": [ // "./node_modules/@types" diff --git a/packages/generate/src/cli.ts b/packages/generate/src/cli.ts index d48bd9d83..7051ae5a4 100644 --- a/packages/generate/src/cli.ts +++ b/packages/generate/src/cli.ts @@ -9,7 +9,7 @@ import { validTlsSecurityValues, isValidTlsSecurityValue, } from "edgedb/dist/conUtils"; -import { parseConnectArguments } from "edgedb/dist/conUtils.server"; +import { makeConnectArgumentsParser } from "edgedb/dist/conUtils.server"; import { type CommandOptions, promptForPassword, @@ -34,6 +34,8 @@ Available generators: - queries (query files) - interfaces`; +const parseConnectArguments = makeConnectArgumentsParser(); + const run = async () => { const args = adapter.process.argv.slice(2); const generator: Generator = args.shift() as any;