Initial commit
Some checks failed
Release / release (macos-latest) (push) Has been cancelled
Release / release (ubuntu-22.04) (push) Has been cancelled
Release / release (windows-latest) (push) Has been cancelled

I asked claude to scaffold a project.
I also made changes to it afterwards but they were mostly in getting workflows and testing stuff.
This commit is contained in:
2026-04-15 23:11:48 -04:00
commit faaea6c729
95 changed files with 13165 additions and 0 deletions

56
surreal/schema.surql Normal file
View File

@@ -0,0 +1,56 @@
OPTION IMPORT;
DEFINE ACCESS account ON DATABASE TYPE RECORD
SIGNUP (
CREATE user SET
email = $email,
username = $username,
password = crypto::argon2::generate($password),
created = time::now()
)
SIGNIN (
SELECT * FROM user
WHERE email = $email
AND crypto::argon2::compare(password, $password)
);
DEFINE TABLE user SCHEMAFULL
PERMISSIONS
FOR select WHERE id = $auth OR $auth IN (SELECT owner FROM contact WHERE target = id)
FOR update WHERE id = $auth
FOR create NONE
FOR delete NONE;
DEFINE FIELD username ON user TYPE string;
DEFINE FIELD email ON user TYPE string;
DEFINE FIELD password ON user TYPE string;
DEFINE FIELD avatar ON user TYPE option<string>;
DEFINE FIELD created ON user TYPE datetime DEFAULT time::now();
DEFINE INDEX email_idx ON user FIELDS email UNIQUE;
DEFINE TABLE room SCHEMAFULL
PERMISSIONS
FOR select, create FULL
FOR update, delete NONE;
DEFINE FIELD name ON room TYPE string;
DEFINE FIELD created ON room TYPE datetime DEFAULT time::now();
DEFINE TABLE message SCHEMAFULL
PERMISSIONS
FOR select FULL
FOR create WHERE author = $auth
FOR update WHERE author = $auth
FOR delete WHERE author = $auth;
DEFINE FIELD room ON message TYPE record<room>;
DEFINE FIELD author ON message TYPE record<user>;
DEFINE FIELD body ON message TYPE string;
DEFINE FIELD created ON message TYPE datetime DEFAULT time::now();
DEFINE TABLE contact SCHEMAFULL
PERMISSIONS
FOR select WHERE owner = $auth
FOR create WHERE owner = $auth
FOR delete WHERE owner = $auth
FOR update NONE;
DEFINE FIELD owner ON contact TYPE record<user>;
DEFINE FIELD target ON contact TYPE record<user>;
DEFINE INDEX unique_contact ON contact FIELDS owner, target UNIQUE;