Skip to content
Draft
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
13 changes: 11 additions & 2 deletions compileForDeno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ export async function run({
? rule.replace(match, sourcePath)
: rule.replace,
);
if (
if (path.endsWith(".js")) {
path.replace(".js", ".ts");
} else if (
!path.endsWith(".ts") &&
!path.startsWith("node:") &&
!path.startsWith("npm:")
Expand All @@ -197,7 +199,14 @@ export async function run({

if (!sourceFilePathMap.has(resolvedPath)) {
// If importPath doesn't exist, first try appending '.ts'
resolvedPath = join(dirname(sourcePath), importPath + ".ts");
if (importPath.endsWith(".js")) {
resolvedPath = join(
dirname(sourcePath),
importPath.slice(0, -3) + ".ts",
);
} else {
resolvedPath = join(dirname(sourcePath), importPath + ".ts");
}

if (!sourceFilePathMap.has(resolvedPath)) {
// If that path doesn't exist, next try appending '/index.ts'
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/legacy/smoke.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "node:assert/strict";
import { type Client } from "edgedb";
import e from "./db/schema/edgeql-js";
import { setupTests, teardownTests } from "./setupTeardown";
import e from "./db/schema/edgeql-js/index.js";
import { setupTests, teardownTests } from "./setupTeardown.js";

describe("legacy database version smoke tests", () => {
let client: Client;
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/legacy/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
startServer,
runCommand,
configToEnv,
} from "../../packages/driver/test/testUtil";
} from "../../packages/driver/test/testUtil.js";

(async function main() {
console.log("\nStarting EdgeDB test cluster...");
Expand Down
2 changes: 1 addition & 1 deletion packages/ai/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function createAI(client: Client, options: AIOptions) {
return new EdgeDBAI(client, options);
}

const httpSCRAMAuth = getHTTPSCRAMAuth(cryptoUtils.default);
const httpSCRAMAuth = getHTTPSCRAMAuth(cryptoUtils);

export class EdgeDBAI {
/** @internal */
Expand Down
2 changes: 1 addition & 1 deletion packages/ai/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@repo/tsconfig/client.json",
"extends": "@repo/tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist"
},
Expand Down
1 change: 1 addition & 0 deletions packages/auth-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Core helper library for the EdgeDB Auth extension",
"version": "0.2.1",
"author": "EdgeDB <[email protected]>",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/edgedb/edgedb-js.git",
Expand Down
12 changes: 6 additions & 6 deletions packages/auth-core/src/core.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { jwtDecode } from "jwt-decode";
import * as edgedb from "edgedb";
import { type ResolvedConnectConfig } from "edgedb/dist/conUtils";
import { type ResolvedConnectConfig } from "edgedb/dist/conUtils.js";

import * as pkce from "./pkce";
import * as pkce from "./pkce.js";
import {
type BuiltinOAuthProviderNames,
emailPasswordProviderName,
webAuthnProviderName,
magicLinkProviderName,
} from "./consts";
import { requestGET, requestPOST } from "./utils";
} from "./consts.js";
import { requestGET, requestPOST } from "./utils.js";
import type {
RegistrationResponseJSON,
AuthenticationResponseJSON,
TokenData,
RegistrationResponse,
SignupResponse,
} from "./types";
import * as errors from "./errors";
} from "./types.js";
import * as errors from "./errors.js";

export class Auth {
/** @internal */
Expand Down
10 changes: 5 additions & 5 deletions packages/auth-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from "./core";
export * from "./pkce";
export * from "./consts";
export * from "./types";
export * from "./errors";
export * from "./core.js";
export * from "./pkce.js";
export * from "./consts.js";
export * from "./types.js";
export * from "./errors.js";
2 changes: 1 addition & 1 deletion packages/auth-core/src/pkce.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bytesToBase64Url, sha256, randomBytes } from "./crypto";
import { bytesToBase64Url, sha256, randomBytes } from "./crypto.js";

export async function createVerifierChallengePair(): Promise<{
verifier: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-core/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as errors from "./errors";
import * as errors from "./errors.js";

export async function requestGET<ResponseT>(
href: string,
Expand Down
8 changes: 4 additions & 4 deletions packages/auth-core/src/webauthn.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { base64UrlToBytes, bytesToBase64Url } from "./crypto";
import { webAuthnProviderName } from "./consts";
import { requestGET, requestPOST } from "./utils";
import { base64UrlToBytes, bytesToBase64Url } from "./crypto.js";
import { webAuthnProviderName } from "./consts.js";
import { requestGET, requestPOST } from "./utils.js";
import type {
PublicKeyCredentialCreationOptionsJSON,
PublicKeyCredentialRequestOptionsJSON,
} from "./types";
} from "./types.js";

interface WebAuthnClientOptions {
signupOptionsUrl: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@repo/tsconfig/client.json",
"extends": "@repo/tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-express/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@repo/tsconfig/client.json",
"extends": "@repo/tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist"
},
Expand Down
1 change: 1 addition & 0 deletions packages/auth-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Helper library to integrate the EdgeDB Auth extension with Next.js",
"version": "0.3.1",
"author": "EdgeDB <[email protected]>",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/edgedb/edgedb-js.git",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-nextjs/src/app/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
type BuiltinProviderNames,
NextAuthHelpers,
type NextAuthOptions,
} from "../shared.client";
} from "../shared.client.js";

export * from "@edgedb/auth-core/errors";
export { type NextAuthOptions, type BuiltinProviderNames };
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-nextjs/src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
InvalidDataError,
} from "@edgedb/auth-core";
import type { Client } from "edgedb";
import { cookies } from "next/headers";
import { cookies } from "next/headers.js";
import { cache } from "react";

import {
Expand All @@ -15,7 +15,7 @@ import {
type BuiltinProviderNames,
type CreateAuthRouteHandlers,
_extractParams,
} from "../shared";
} from "../shared.js";

export * from "@edgedb/auth-core/errors";
export {
Expand Down
8 changes: 4 additions & 4 deletions packages/auth-nextjs/src/pages/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Router from "next/router";
import Router from "next/router.js";
import {
type BuiltinProviderNames,
NextAuthHelpers,
type NextAuthOptions,
} from "../shared.client";
} from "../shared.client.js";
import { errorMapping } from "@edgedb/auth-core/utils";

export * from "@edgedb/auth-core/errors";
Expand Down Expand Up @@ -103,9 +103,9 @@ async function apiRequest(url: string, _data: any) {
}
if (json._redirect) {
if (await json._redirect.replace) {
Router.replace(json._redirect.location);
Router.default.replace(json._redirect.location);
} else {
Router.push(json._redirect.location);
Router.default.push(json._redirect.location);
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-nextjs/src/pages/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
NextAuth,
type NextAuthOptions,
NextAuthSession,
} from "../shared";
} from "../shared.js";

export * from "@edgedb/auth-core/errors";
export {
Expand Down
8 changes: 4 additions & 4 deletions packages/auth-nextjs/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import {
type BuiltinProviderNames,
NextAuthHelpers,
type NextAuthOptions,
} from "./shared.client";
} from "./shared.client.js";

import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import type { NextRequest, NextResponse } from "next/server";
import { cookies } from "next/headers.js";
import { redirect } from "next/navigation.js";
import type { NextRequest, NextResponse } from "next/server.js";

export { type BuiltinProviderNames, NextAuthHelpers, type NextAuthOptions };

Expand Down
2 changes: 1 addition & 1 deletion packages/auth-nextjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@repo/tsconfig/client.json",
"extends": "@repo/tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-remix/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@repo/tsconfig/client.json",
"extends": "@repo/tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-sveltekit/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@repo/tsconfig/client.json",
"extends": "@repo/tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist"
},
Expand Down
15 changes: 11 additions & 4 deletions packages/driver/buildDeno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ await run({
},
{
match: /^\.\.\/src\/.+/,
replace: (match) =>
`${match.replace(/^\.\.\/src\//, "../_src/")}${
match.endsWith(".ts") ? "" : ".ts"
}`,
replace: (match) => {
let newPath = match.replace(/^\.\.\/\.\.\/src\//, "../_src/");

if (newPath.endsWith(".js")) {
newPath = newPath.replace(/\.js$/, ".ts");
} else if (!newPath.endsWith(".ts")) {
newPath += ".ts";
}

return newPath;
},
},
{
match: /^fast-check$/,
Expand Down
25 changes: 23 additions & 2 deletions packages/driver/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
module.exports = {
preset: "ts-jest",
export default {
preset: "ts-jest/presets/default-esm",
testEnvironment: "node",
testPathIgnorePatterns: ["./dist", "./test/deno/", "./qb"],
globalSetup: "./test/globalSetup.ts",
globalTeardown: "./test/globalTeardown.ts",
extensionsToTreatAsEsm: [".ts"],
moduleFileExtensions: ["ts", "js"],
transform: {
"\\.[jt]sx?$": [
"ts-jest",
{
useESM: true,
tsConfig: "./tsconfig.test.json",
},
],
},

transformIgnorePatterns: ["./node_modules/"],
transform: {
"\\.[jt]sx?$": "ts-jest",
},
moduleNameMapper: {
// "^(\\.{1,2}/.*)\\.[jt]s$": "$1",
"^(.*)\\.js$": "$1.ts",
},
resolver: "ts-jest-resolver",
};
2 changes: 1 addition & 1 deletion packages/driver/jest.connect-config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
preset: "ts-jest",
testEnvironment: "node",
testPathIgnorePatterns: ["./dist", "./test/deno/"],
Expand Down
10 changes: 7 additions & 3 deletions packages/driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"engines": {
"node": ">= 18.0.0"
},
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/edgedb/edgedb-js.git"
Expand All @@ -26,6 +27,7 @@
},
"devDependencies": {
"@js-temporal/polyfill": "0.4.3",
"@repo/tsconfig": "*",
"@types/jest": "^29.5.12",
"@types/semver": "^7.5.8",
"@types/shell-quote": "^1.7.5",
Expand All @@ -35,10 +37,10 @@
"globby": "^14.0.1",
"jest": "29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-ts-webcompat-resolver": "^1.0.0",
"ts-jest": "29.1.4",
"tsx": "^4.11.0",
"typescript": "^5.5.2",
"@repo/tsconfig": "*"
"typescript": "^5.5.2"
},
"scripts": {
"typecheck": "tsc --project tsconfig.json --noEmit",
Expand All @@ -47,7 +49,7 @@
"build:cjs": "tsc --project tsconfig.json",
"build:deno": "deno run --unstable --allow-all ./buildDeno.ts",
"lint:fix": "tslint 'packages/*/src/**/*.ts'",
"test": "NODE_OPTIONS='--experimental-global-webcrypto' npx jest --detectOpenHandles",
"test": "NODE_OPTIONS='--experimental-global-webcrypto --experimental-vm-modules' npx jest --detectOpenHandles",
"format": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
"gen-errors": "edb gen-errors-json --client | node genErrors.mjs",
"watch": "nodemon -e js,ts,tsx --ignore dist -x ",
Expand All @@ -58,6 +60,8 @@
"env-paths": "^3.0.0",
"semver": "^7.6.2",
"shell-quote": "^1.8.1",
"ts-jest-resolver": "^2.0.1",
"ts-node": "^10.9.2",
"which": "^4.0.0"
}
}
21 changes: 19 additions & 2 deletions packages/driver/src/adapter.crypto.node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { CryptoUtils } from "./utils";
import type { CryptoUtils } from "./utils.js";

let cryptoUtils: CryptoUtils;
// let cryptoUtils: CryptoUtils;
let cryptoUtilsPromise: Promise<CryptoUtils>;

<<<<<<< Updated upstream
function loadCrypto() {
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
Expand All @@ -16,7 +18,22 @@ function loadCrypto() {
throw new Error("No crypto implementation found");
}
}
=======
if (typeof crypto === "undefined") {
// eslint-disable-next-line @typescript-eslint/no-require-imports
// cryptoUtils = require("./nodeCrypto.js").cryptoUtils;
cryptoUtilsPromise = import("./nodeCrypto.js").then(
(module) => module.cryptoUtils,
);
} else {
// eslint-disable-next-line @typescript-eslint/no-require-imports
// cryptoUtils = require("./browserCrypto.js").cryptoUtils;
cryptoUtilsPromise = import("./browserCrypto.js").then(
(module) => module.cryptoUtils,
);
>>>>>>> Stashed changes
}
const cryptoUtils = await cryptoUtilsPromise;

loadCrypto();

Expand Down
Loading