Skip to content

fix(adapter): transistion to surrealdb@^1.0.0 #11911

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

Merged
merged 31 commits into from
Jun 8, 2025
Merged

Conversation

dvanmali
Copy link
Contributor

☕️ Reasoning

Moves package dependency to version 1 of the surrealdb javascript library. Package includes websocket connectivity, type safety, updates to the setup documentation, and package peer dependency change.

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

#11732 - solves this by transistioning to [email protected] package. Docs state to use new connection string.
#11866 - javascript package supports surrealdb v2
#11471 - uses current surrealdb software

📌 Resources

Copy link

vercel bot commented Sep 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 3, 2025 10:30am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Jun 3, 2025 10:30am

Copy link

vercel bot commented Sep 26, 2024

@dvanmali is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added adapters Changes related to the core code concerning database adapters surrealdb labels Sep 26, 2024
@dvanmali dvanmali mentioned this pull request Sep 26, 2024
3 tasks
@dvanmali dvanmali changed the title Transition to surrealdb@^1.0.0 feat(adapter): transistion to surrealdb@^1.0.0 Sep 26, 2024
@dvanmali dvanmali changed the title feat(adapter): transistion to surrealdb@^1.0.0 fix(adapter): transistion to surrealdb@^1.0.0 Sep 26, 2024
@liamwh
Copy link
Contributor

liamwh commented Oct 7, 2024

Any updates on this PR? Would love to see it merged so we can use SurrealDB with Auth.js!

@dvanmali
Copy link
Contributor Author

Sure @ThangHuuVu, just updated the lockfile and fixed the shell script so it can now pass your test scripts. It appears that Surrealdb v3-alpha is currently tied to latest so it may not currently be compatible as they mention on their javascript library.

@dvanmali
Copy link
Contributor Author

dvanmali commented May 13, 2025

Feel free to message this thread again if you wish for another update or add a PR or issue to my main. Unfortunately because I don't have write access to this repo, i can't make a branch here, hence the forked repo from main

@dvanmali
Copy link
Contributor Author

Were you able to take a look @ThangHuuVu?

@ThangHuuVu
Copy link
Member

@dvanmali just approved the jobs but the build is failing, could u help check it? 🙏

@dvanmali
Copy link
Contributor Author

Gtg @ThangHuuVu 👍

@dvanmali
Copy link
Contributor Author

dvanmali commented Jun 2, 2025

@ndom91 @balazsorban44 @ThangHuuVu gtg

Copy link

codecov bot commented Jun 3, 2025

Codecov Report

Attention: Patch coverage is 95.95376% with 14 lines in your changes missing coverage. Please review.

Project coverage is 39.43%. Comparing base (22c1b8b) to head (f27fa22).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/adapter-surrealdb/src/index.ts 95.95% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11911      +/-   ##
==========================================
+ Coverage   39.19%   39.43%   +0.23%     
==========================================
  Files         200      200              
  Lines       31615    31756     +141     
  Branches     1381     1399      +18     
==========================================
+ Hits        12391    12522     +131     
- Misses      19224    19234      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dvanmali
Copy link
Contributor Author

dvanmali commented Jun 5, 2025

@ndom91 @balazsorban44 @ThangHuuVu Vercel keeps blocking the build with "authorization required to deploy"

@ThangHuuVu ThangHuuVu merged commit 07b7d93 into nextauthjs:main Jun 8, 2025
12 of 14 checks passed
@ThangHuuVu
Copy link
Member

I merged, thanks for your consistent effort @dvanmali

@dvanmali
Copy link
Contributor Author

Love it! Thank you @ThangHuuVu

if (userDoc.length) {
return docToUser(userDoc[0])
}
} catch {}
throw new Error("User not created")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dvanmali Finally getting around to try out your changes and noticed something and had a suggestion. this error always gets thrown. If you have time it would also be great if you could use the logger to log the errors being caught as well.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't have time I don't mind submitting a PR, it would just be easier to continue this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you submit a PR? This one got merged so a new PR would be needed anyways. Feel free to tag me if you need assistance

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, I should have some time tonight or tomorrow. Thanks!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed the return just above, so it turns out the error doesn't always get thrown. I looked into the logger, and I guess it's not easily accessible. Some better logging would be helpful though, but perhaps that's more on AuthJS side as a stacktrace doesn't even get logged.

@geodox
Copy link

geodox commented Jun 28, 2025

@dvanmali Can you provide SurrealQL code to setup schemafull tables? Here's what I have so far. The user table is working, the account table is not, and the remainder are untested. Nevermind I got it, below is the working schemafull tables (I included some useful statements)

// User table
DEFINE TABLE user SCHEMAFULL;
DEFINE FIELD email ON user TYPE string ASSERT string::is::email($value);
DEFINE FIELD password ON user TYPE option<string>;
DEFINE FIELD name ON user TYPE string;
DEFINE FIELD image ON user TYPE option<string>;
DEFINE FIELD created_at ON user TYPE datetime DEFAULT time::now();
DEFINE FIELD updated_at ON user TYPE datetime DEFAULT time::now();
DEFINE FIELD last_login ON user TYPE datetime DEFAULT time::now();
DEFINE INDEX email_idx ON user COLUMNS email UNIQUE;

// Session table
DEFINE TABLE session SCHEMAFULL;
DEFINE FIELD userId ON session TYPE record<user>;
DEFINE FIELD expires ON session TYPE datetime;
DEFINE FIELD sessionToken ON session TYPE string;
DEFINE INDEX session_token_idx ON session COLUMNS sessionToken UNIQUE;

// Account table
DEFINE TABLE account SCHEMAFULL;
DEFINE FIELD userId ON account TYPE record<user>;
DEFINE FIELD type ON account TYPE string;
DEFINE FIELD provider ON account TYPE string;
DEFINE FIELD providerAccountId ON account TYPE string;
DEFINE FIELD refresh_token ON account TYPE option<string>;
DEFINE FIELD access_token ON account TYPE string;
DEFINE FIELD expires_at ON account TYPE int;
DEFINE FIELD token_type ON account TYPE string;
DEFINE FIELD scope ON account TYPE string;
DEFINE FIELD id_token ON account TYPE string;
DEFINE FIELD session_state ON account TYPE option<string>;
DEFINE INDEX provider_account_idx ON account COLUMNS provider, providerAccountId UNIQUE;

// VerificationToken table
DEFINE TABLE verification_token SCHEMAFULL;
DEFINE FIELD identifier ON verification_token TYPE string;
DEFINE FIELD token ON verification_token TYPE string;
DEFINE FIELD expires ON verification_token TYPE datetime;
DEFINE INDEX verification_token_idx ON verification_token COLUMNS token UNIQUE;
DEFINE INDEX verification_identifier_token_idx ON verification_token COLUMNS identifier, token UNIQUE;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adapters Changes related to the core code concerning database adapters surrealdb
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants