next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

fix(adapter): transistion to surrealdb@^1.0.0

Open dvanmali opened this issue 1 year ago β€’ 5 comments

β˜•οΈ 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

  • [x] Documentation
  • [x] Tests
  • [x] 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

dvanmali avatar Sep 26 '24 01:09 dvanmali

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

vercel[bot] avatar Sep 26 '24 01:09 vercel[bot]

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

A member of the Team first needs to authorize it.

vercel[bot] avatar Sep 26 '24 01:09 vercel[bot]

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

liamwh avatar Oct 07 '24 14:10 liamwh

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

Package is ready to go. Still waiting for PR to merge.

@ubbe-xyz @ndom91

dvanmali avatar Oct 09 '24 16:10 dvanmali

Bump. I'm waiting for this PR to use Auth.js since I'm using Surrealdb.

applied-mathematician avatar Oct 25 '24 18:10 applied-mathematician

This is breaking, right? Well have to make sure we bump the surreal adapter appropriately

ndom91 avatar Nov 09 '24 13:11 ndom91

ndom91 This is breaking, right? Well have to make sure we bump the surreal adapter appropriately

Yes, this is a breaking update because the underlying storage layer and transmission layer are now both typed. Thus this package jumps to version 2.0.0 with surrealdb@^1.0.0

dvanmali avatar Nov 12 '24 19:11 dvanmali

Surreal Cloud just launched! I am planning to use it everywhere I can. Do you know what is blocking this PR?

ctison avatar Dec 07 '24 22:12 ctison

Is this PR still up-to-date ? Looking forward to use SurrealDB and AuthJS together but with surrealdb v2 it doesnt work anymore.

p-arndt avatar Feb 07 '25 17:02 p-arndt

Is this PR still up-to-date ? Looking forward to use SurrealDB and AuthJS together but with surrealdb v2 it doesnt work anymore.

Yes this PR should still work with v2, if you have issues let me know

dvanmali avatar Feb 07 '25 17:02 dvanmali

@dvanmali sorry for my bad english, i ment whether this PR will ever get merged :D

I just copied your index.ts file and imported from local package, works perfectly fine. ThanksπŸ«±πŸΌβ€πŸ«²πŸ½

p-arndt avatar Feb 07 '25 17:02 p-arndt

@ndom91 @0ubbe PR updates? It's been 5 months since opening

dvanmali avatar Feb 10 '25 17:02 dvanmali

Hi @ThangHuuVu ! πŸ‘‹

Hope you are doing well!

Could you please help give a review and ship this PR?

This has been blocking for SurrealDB and Auth.js users for a while.

Thank you in advance!

tz-torchai avatar May 04 '25 11:05 tz-torchai

@ThangHuuVu Since this is a blocking PR, can we get this reviewed and merged ASAP please?

geodox avatar May 08 '25 15:05 geodox

@dvanmali the lockfile needs to be updated, could u help with that? You are creating the PR from your main which makes it a bit hard for maintainers to push changes to.

ThangHuuVu avatar May 10 '25 04:05 ThangHuuVu

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 avatar May 13 '25 00:05 dvanmali

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 avatar May 13 '25 00:05 dvanmali

Were you able to take a look @ThangHuuVu?

dvanmali avatar May 14 '25 16:05 dvanmali

@dvanmali just approved the jobs but the build is failing, could u help check it? πŸ™

ThangHuuVu avatar May 18 '25 04:05 ThangHuuVu

Gtg @ThangHuuVu πŸ‘

dvanmali avatar May 19 '25 16:05 dvanmali

@ndom91 @balazsorban44 @ThangHuuVu gtg

dvanmali avatar Jun 02 '25 16:06 dvanmali

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 :warning:
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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Jun 03 '25 10:06 codecov[bot]

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

dvanmali avatar Jun 05 '25 16:06 dvanmali

I merged, thanks for your consistent effort @dvanmali

ThangHuuVu avatar Jun 08 '25 11:06 ThangHuuVu

Love it! Thank you @ThangHuuVu

dvanmali avatar Jun 10 '25 17:06 dvanmali

@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;

geodox avatar Jun 28 '25 02:06 geodox