Modules@robinpath/supabase
supabase

@robinpath/supabase

0.1.1Node.jsPublic

Supabase module for RobinPath.

Supabase

Supabase module for RobinPath.

Package: @robinpath/supabase | Category: Database | Type: Utility

Authentication

supabase.setCredentials "https://xyz.supabase.co" "eyJhbGc..."

Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.

Use Cases

Use the supabase module when you need to:

  • Select rows from a table with optional filters, ordering, and pagination -- Use supabase.select to perform this operation
  • Insert one or more rows into a table -- Use supabase.insert to perform this operation
  • Update rows matching filters -- Use supabase.update to perform this operation
  • Insert or update rows (merge on conflict) -- Use supabase.upsert to perform this operation
  • Delete rows matching filters -- Use supabase.delete to perform this operation

Quick Reference

FunctionDescriptionReturns
setCredentialsStore Supabase project URL and anon/service API key{ success, profile }
setServiceKeyStore a service role key for admin operations (Auth admin, etc.){ success, profile }
selectSelect rows from a table with optional filters, ordering, and paginationArray of matching rows
insertInsert one or more rows into a tableArray of inserted rows (if returning enabled)
updateUpdate rows matching filtersArray of updated rows
upsertInsert or update rows (merge on conflict)Array of upserted rows
deleteDelete rows matching filtersArray of deleted rows
rpcCall a Postgres function via RPCFunction return value
signUpSign up a new user with email and passwordSign up response with user and session
signInSign in a user with email and passwordAuth token response with access_token, refresh_token, user
signInWithOtpSend a magic link to the user's email for passwordless sign inOTP send confirmation
signOutSign out a user by invalidating their access tokenSign out confirmation
getUserGet the user object from a JWT access tokenUser object with id, email, metadata, etc.
updateUserUpdate user attributes (email, password, metadata)Updated user object
listUsersAdmin: List all users (requires service role key)Paginated list of users
deleteUserAdmin: Delete a user by ID (requires service role key)Deletion confirmation
inviteUserAdmin: Invite a user by email (requires service role key)Invite confirmation
listBucketsList all storage bucketsArray of bucket objects
createBucketCreate a new storage bucketCreated bucket info
deleteBucketDelete a storage bucket (must be empty first)Deletion confirmation
emptyBucketRemove all files from a storage bucketEmpty confirmation
listFilesList files in a storage bucket/folderArray of file/folder objects
uploadFileUpload a file to a storage bucketUpload result with key
downloadFileDownload a file from a storage bucketFile content as string
deleteFileDelete one or more files from a storage bucketDeletion result
getPublicUrlGet the public URL for a file in a public bucket{ publicUrl }
createSignedUrlCreate a signed URL for temporary access to a private file{ signedUrl, expiresIn }

Functions

setCredentials

Store Supabase project URL and anon/service API key

Module: supabase | Returns: object -- { success, profile }

supabase.setCredentials "https://xyz.supabase.co" "eyJhbGc..."
ParameterTypeRequiredDescription
projectUrlstringYesSupabase project URL (e.g. https://xyz.supabase.co)
apiKeystringYesSupabase anon or service_role key
profilestringNoOptional credential profile name

setServiceKey

Store a service role key for admin operations (Auth admin, etc.)

Module: supabase | Returns: object -- { success, profile }

supabase.setServiceKey "https://xyz.supabase.co" "eyJhbGc..."
ParameterTypeRequiredDescription
projectUrlstringYesSupabase project URL
serviceKeystringYesSupabase service_role key
profilestringNoOptional credential profile name

select

Select rows from a table with optional filters, ordering, and pagination

Module: supabase | Returns: array -- Array of matching rows

supabase.select "users" "*" {"eq": {"status": "active"}, "limit": 10}
ParameterTypeRequiredDescription
tablestringYesTable name
columnsstringNoComma-separated column names or * (default *)
optionsobjectNoFilters (eq, neq, gt, lt, gte, lte, like, ilike, in, is), order, limit, offset, range, profile

insert

Insert one or more rows into a table

Module: supabase | Returns: array -- Array of inserted rows (if returning enabled)

supabase.insert "users" {"name": "Alice", "email": "alice@example.com"}
ParameterTypeRequiredDescription
tablestringYesTable name
dataobjectYesRow object or array of row objects
optionsobjectNoOptions: returning, onConflict (for upsert), columns, profile

update

Update rows matching filters

Module: supabase | Returns: array -- Array of updated rows

supabase.update "users" {"status": "inactive"} {"id": 42}
ParameterTypeRequiredDescription
tablestringYesTable name
dataobjectYesFields to update
matchobjectYesFilter conditions to match rows (eq filters)
optionsobjectNoOptions: profile

upsert

Insert or update rows (merge on conflict)

Module: supabase | Returns: array -- Array of upserted rows

supabase.upsert "users" {"id": 1, "name": "Alice"} {"onConflict": "id"}
ParameterTypeRequiredDescription
tablestringYesTable name
dataobjectYesRow object or array of row objects
optionsobjectNoOptions: onConflict (conflict column), profile

delete

Delete rows matching filters

Module: supabase | Returns: array -- Array of deleted rows

supabase.delete "users" {"id": 42}
ParameterTypeRequiredDescription
tablestringYesTable name
matchobjectYesFilter conditions to match rows for deletion
optionsobjectNoOptions: profile

rpc

Call a Postgres function via RPC

Module: supabase | Returns: any -- Function return value

supabase.rpc "get_total_users" {"status": "active"}
ParameterTypeRequiredDescription
functionNamestringYesName of the Postgres function
paramsobjectNoParameters to pass to the function
optionsobjectNoOptions: profile

signUp

Sign up a new user with email and password

Module: supabase | Returns: object -- Sign up response with user and session

supabase.signUp "user@example.com" "securePassword123"
ParameterTypeRequiredDescription
emailstringYesUser email address
passwordstringYesUser password
optionsobjectNoOptions: data (user metadata), profile

signIn

Sign in a user with email and password

Module: supabase | Returns: object -- Auth token response with access_token, refresh_token, user

supabase.signIn "user@example.com" "securePassword123"
ParameterTypeRequiredDescription
emailstringYesUser email address
passwordstringYesUser password
optionsobjectNoOptions: profile

signInWithOtp

Send a magic link to the user's email for passwordless sign in

Module: supabase | Returns: object -- OTP send confirmation

supabase.signInWithOtp "user@example.com"
ParameterTypeRequiredDescription
emailstringYesUser email address
optionsobjectNoOptions: profile

signOut

Sign out a user by invalidating their access token

Module: supabase | Returns: object -- Sign out confirmation

supabase.signOut "eyJhbGc..."
ParameterTypeRequiredDescription
accessTokenstringYesUser's access token
optionsobjectNoOptions: profile

getUser

Get the user object from a JWT access token

Module: supabase | Returns: object -- User object with id, email, metadata, etc.

supabase.getUser "eyJhbGc..."
ParameterTypeRequiredDescription
accessTokenstringYesUser's access token
optionsobjectNoOptions: profile

updateUser

Update user attributes (email, password, metadata)

Module: supabase | Returns: object -- Updated user object

supabase.updateUser "eyJhbGc..." {"data": {"name": "New Name"}}
ParameterTypeRequiredDescription
accessTokenstringYesUser's access token
attributesobjectYesAttributes to update: email, password, data (metadata)
optionsobjectNoOptions: profile

listUsers

Admin: List all users (requires service role key)

Module: supabase | Returns: object -- Paginated list of users

supabase.listUsers {"page": 1, "perPage": 50}
ParameterTypeRequiredDescription
optionsobjectNoOptions: page, perPage, profile

deleteUser

Admin: Delete a user by ID (requires service role key)

Module: supabase | Returns: object -- Deletion confirmation

supabase.deleteUser "uuid-of-user"
ParameterTypeRequiredDescription
userIdstringYesUUID of the user to delete
optionsobjectNoOptions: profile

inviteUser

Admin: Invite a user by email (requires service role key)

Module: supabase | Returns: object -- Invite confirmation

supabase.inviteUser "newuser@example.com"
ParameterTypeRequiredDescription
emailstringYesEmail address to invite
optionsobjectNoOptions: profile

listBuckets

List all storage buckets

Module: supabase | Returns: array -- Array of bucket objects

supabase.listBuckets
ParameterTypeRequiredDescription
optionsobjectNoOptions: profile

createBucket

Create a new storage bucket

Module: supabase | Returns: object -- Created bucket info

supabase.createBucket "avatars" {"public": true}
ParameterTypeRequiredDescription
namestringYesBucket name
optionsobjectNoOptions: public, fileSizeLimit, allowedMimeTypes, profile

deleteBucket

Delete a storage bucket (must be empty first)

Module: supabase | Returns: object -- Deletion confirmation

supabase.deleteBucket "avatars"
ParameterTypeRequiredDescription
bucketIdstringYesBucket ID/name
optionsobjectNoOptions: profile

emptyBucket

Remove all files from a storage bucket

Module: supabase | Returns: object -- Empty confirmation

supabase.emptyBucket "avatars"
ParameterTypeRequiredDescription
bucketIdstringYesBucket ID/name
optionsobjectNoOptions: profile

listFiles

List files in a storage bucket/folder

Module: supabase | Returns: array -- Array of file/folder objects

supabase.listFiles "avatars" "users/"
ParameterTypeRequiredDescription
bucketIdstringYesBucket ID/name
pathstringNoFolder path within bucket (default root)
optionsobjectNoOptions: limit, offset, sortBy, search, profile

uploadFile

Upload a file to a storage bucket

Module: supabase | Returns: object -- Upload result with key

supabase.uploadFile "avatars" "user1.png" $fileContent {"contentType": "image/png"}
ParameterTypeRequiredDescription
bucketIdstringYesBucket ID/name
pathstringYesFile path within bucket
contentstringYesFile content (string or Buffer)
optionsobjectNoOptions: contentType, upsert, profile

downloadFile

Download a file from a storage bucket

Module: supabase | Returns: string -- File content as string

supabase.downloadFile "documents" "report.txt"
ParameterTypeRequiredDescription
bucketIdstringYesBucket ID/name
pathstringYesFile path within bucket
optionsobjectNoOptions: profile

deleteFile

Delete one or more files from a storage bucket

Module: supabase | Returns: object -- Deletion result

supabase.deleteFile "avatars" ["user1.png", "user2.png"]
ParameterTypeRequiredDescription
bucketIdstringYesBucket ID/name
pathsarrayYesArray of file paths to delete
optionsobjectNoOptions: profile

getPublicUrl

Get the public URL for a file in a public bucket

Module: supabase | Returns: object -- { publicUrl }

supabase.getPublicUrl "avatars" "user1.png"
ParameterTypeRequiredDescription
bucketIdstringYesBucket ID/name
pathstringYesFile path within bucket
optionsobjectNoOptions: profile

createSignedUrl

Create a signed URL for temporary access to a private file

Module: supabase | Returns: object -- { signedUrl, expiresIn }

supabase.createSignedUrl "documents" "report.pdf" 3600
ParameterTypeRequiredDescription
bucketIdstringYesBucket ID/name
pathstringYesFile path within bucket
expiresInnumberYesExpiry time in seconds
optionsobjectNoOptions: profile

Error Handling

All functions throw on failure. Common errors:

ErrorCause
Supabase ${res.status}: ${msg}Check the error message for details
Supabase ${res.status}: ${text}Check the error message for details
@desc "Select and validate result"
do
  set $result as supabase.select "users" "*" {"eq": {"status": "active"}, "limit": 10}
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. List and iterate User

Retrieve all items and loop through them.

@desc "Setup authentication"
do
  supabase.setCredentials $token
enddo

@desc "Get user and iterate results"
do
  set $result as supabase.getUser "eyJhbGc..."
  each $item in $result
    print $item
  end
enddo

2. Create a new item with createBucket

Create a new resource and capture the result.

@desc "Setup authentication"
do
  supabase.setCredentials $token
enddo

@desc "Create bucket"
do
  set $result as supabase.createBucket "avatars" {"public": true}
  print "Created: " + $result
enddo

3. Create and update workflow

Create an item and then update it.

@desc "Setup authentication"
do
  supabase.setCredentials $token
enddo

@desc "Create bucket and update"
do
  set $created as supabase.createBucket "avatars" {"public": true}
  # Update the created item
  supabase.update "users" {"status": "inactive"} {"id": 42}
enddo

4. Check before creating

List existing items and only create if needed.

@desc "Setup authentication"
do
  supabase.setCredentials $token
enddo

@desc "Get user and create bucket"
do
  set $existing as supabase.getUser "eyJhbGc..."
  if $existing == null
    supabase.createBucket "avatars" {"public": true}
    print "Item created"
  else
    print "Item already exists"
  end
enddo

5. Multi-step Supabase workflow

Chain multiple supabase operations together.

@desc "Setup authentication"
do
  supabase.setCredentials $token
enddo

@desc "Select, insert, and more"
do
  set $r_select as supabase.select "users" "*" {"eq": {"status": "active"}, "limit": 10}
  set $r_insert as supabase.insert "users" {"name": "Alice", "email": "alice@example.com"}
  set $r_update as supabase.update "users" {"status": "inactive"} {"id": 42}
  print "All operations complete"
enddo

6. Safe select with validation

Check results before proceeding.

@desc "Setup authentication"
do
  supabase.setCredentials $token
enddo

@desc "Select and validate result"
do
  set $result as supabase.select "users" "*" {"eq": {"status": "active"}, "limit": 10}
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • mysql -- MySQL module for complementary functionality
  • postgres -- PostgreSQL module for complementary functionality
  • mongo -- Mongo module for complementary functionality
  • redis -- Redis module for complementary functionality
  • firebase -- Firebase module for complementary functionality

Versions (1)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/supabase

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size10.2 KB
Versions1
Weekly Downloads21
Total Downloads21
Stars0
Last Publish1 months ago
Created1 months ago

Category

data