Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

enhance(ref docs): add params and returns for realtime and storage (#26687)

Charis9c03be41e4c3
diff --git a/apps/docs/spec/supabase_js_v2.yml b/apps/docs/spec/supabase_js_v2.yml
index 96f9fa8a3f9..8cb92c51011 100644
--- a/apps/docs/spec/supabase_js_v2.yml
+++ b/apps/docs/spec/supabase_js_v2.yml
@@ -6726,20 +6726,19 @@ functions:
isSpotlight: true
code: |
```js
- supabase
- .channel('room1')
- .on('broadcast', { event: 'cursor-pos' }, payload => {
- console.log('Cursor position received!', payload)
- })
- .subscribe((status) => {
- if (status === 'SUBSCRIBED') {
- channel.send({
- type: 'broadcast',
- event: 'cursor-pos',
- payload: { x: Math.random(), y: Math.random() },
- })
- }
- })
+ const channel = supabase.channel("room1")
+
+ channel.on("broadcast", { event: "cursor-pos" }, (payload) => {
+ console.log("Cursor position received!", payload);
+ }).subscribe((status) => {
+ if (status === "SUBSCRIBED") {
+ channel.send({
+ type: "broadcast",
+ event: "cursor-pos",
+ payload: { x: Math.random(), y: Math.random() },
+ });
+ }
+ });
```
- id: listen-to-presence-sync
name: Listen to presence sync
@@ -6909,6 +6908,10 @@ functions:
}
})
```
+ response: |
+ ```
+ ok | timed out | error
+ ```
- id: send-a-message-via-rest
name: Send a message via REST
isSpotlight: true
@@ -6981,6 +6984,26 @@ functions:
.storage
.listBuckets()
```
+ response: |
+ ```json
+ {
+ "data": [
+ {
+ "id": "avatars",
+ "name": "avatars",
+ "owner": "",
+ "public": false,
+ "file_size_limit": 1024,
+ "allowed_mime_types": [
+ "image/png"
+ ],
+ "created_at": "2024-05-22T22:26:05.100Z",
+ "updated_at": "2024-05-22T22:26:05.100Z"
+ }
+ ],
+ "error": null
+ }
+ ```
- id: get-bucket
title: getBucket()
@@ -7000,6 +7023,24 @@ functions:
.storage
.getBucket('avatars')
```
+ response: |
+ ```json
+ {
+ "data": {
+ "id": "avatars",
+ "name": "avatars",
+ "owner": "",
+ "public": false,
+ "file_size_limit": 1024,
+ "allowed_mime_types": [
+ "image/png"
+ ],
+ "created_at": "2024-05-22T22:26:05.100Z",
+ "updated_at": "2024-05-22T22:26:05.100Z"
+ },
+ "error": null
+ }
+ ```
- id: create-bucket
title: createBucket()
@@ -7023,6 +7064,15 @@ functions:
fileSizeLimit: 1024
})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "name": "avatars"
+ },
+ "error": null
+ }
+ ```
- id: empty-bucket
title: emptyBucket()
@@ -7042,6 +7092,15 @@ functions:
.storage
.emptyBucket('avatars')
```
+ response: |
+ ```json
+ {
+ "data": {
+ "message": "Successfully emptied"
+ },
+ "error": null
+ }
+ ```
- id: update-bucket
title: updateBucket()
$ref: '@supabase/storage-js.packages/StorageBucketApi.default.updateBucket'
@@ -7064,6 +7123,15 @@ functions:
fileSizeLimit: 1024
})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "message": "Successfully updated"
+ },
+ "error": null
+ }
+ ```
- id: delete-bucket
title: deleteBucket()
@@ -7083,6 +7151,15 @@ functions:
.storage
.deleteBucket('avatars')
```
+ response: |
+ ```json
+ {
+ "data": {
+ "message": "Successfully deleted"
+ },
+ "error": null
+ }
+ ```
- id: from-upload
title: from.upload()
@@ -7108,6 +7185,14 @@ functions:
upsert: false
})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "path": "avatars/public/avatar1.png"
+ },
+ "error": null
+ }
- id: upload-file-using-arraybuffer-from-base64-file-data
name: Upload file using `ArrayBuffer` from base64 file data
code: |
@@ -7146,6 +7231,15 @@ functions:
upsert: true
})
```
+ response: |
+ ```json
+ {
+ "data": {
+ "path": "avatars/public/avatar1.png"
+ },
+ "error": null
+ }
+ ```
- id: update-file-using-arraybuffer-from-base64-file-data
name: Update file using `ArrayBuffer` from base64 file data
code: |
@@ -7179,6 +7273,15 @@ functions:
.from('avatars')
.move('public/avatar1.png', 'private/avatar2.png')
```
+ response: |
+ ```json
+ {
+ "data": {
+ "message": "Successfully moved"
+ },
+ "error": null
+ }
+ ```
- id: from-copy
title: from.copy()
@@ -7199,6 +7302,15 @@ functions:
.from('avatars')
.copy('public/avatar1.png', 'private/avatar2.png')
```
+ response: |
+ ```json
+ {
+ "data": {
+ "path": "avatars/private/avatar2.png"
+ },
+ "error": null
+ }
+ ```
- id: from-create-signed-url
title: from.createSignedUrl()
@@ -7219,6 +7331,15 @@ functions:
.from('avatars')
.createSignedUrl('folder/avatar1.png', 60)
```
+ response: |
+ ```json
+ {
+ "data": {
+ "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar1.png?token=<TOKEN>"
+ },
+ "error": null
+ }
+ ```
- id: create-signed-url-with-transformations
name: Create a signed URL for an asset with transformations
isSpotlight: true
@@ -7266,6 +7387,26 @@ functions:
.from('avatars')
.createSignedUrls(['folder/avatar1.png', 'folder/avatar2.png'], 60)
```
+ response: |
+ ```json
+ {
+ "data": [
+ {
+ "error": null,
+ "path": "folder/avatar1.png",
+ "signedURL": "/object/sign/avatars/folder/avatar1.png?token=<TOKEN>",
+ "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar1.png?token=<TOKEN>"
+ },
+ {
+ "error": null,
+ "path": "folder/avatar2.png",
+ "signedURL": "/object/sign/avatars/folder/avatar2.png?token=<TOKEN>",
+ "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar2.png?token=<TOKEN>"
+ }
+ ],
+ "error": null
+ }
+ ```
- id: from-create-signed-upload-url
title: from.createSignedUploadUrl()
@@ -7286,6 +7427,17 @@ functions:
.from('avatars')
.createSignedUploadUrl('folder/cat.jpg')
```
+ response: |
+ ```json
+ {
+ "data": {
+ "signedUrl": "https://example.supabase.co/storage/v1/object/upload/sign/avatars/folder/cat.jpg?token=<TOKEN>",
+ "path": "folder/cat.jpg",
+ "token": "<TOKEN>"
+ },
+ "error": null
+ }
+ ```
- id: from-upload-to-signed-url
title: from.uploadToSignedUrl()
@@ -7306,6 +7458,16 @@ functions:
.from('avatars')
.uploadToSignedUrl('folder/cat.jpg', 'token-from-createSignedUploadUrl', file)
```
+ response: |
+ ```json
+ {
+ "data": {
+ "path": "folder/cat.jpg",
+ "fullPath": "avatars/folder/cat.jpg"
+ },
+ "error": null
+ }
+ ```
- id: from-get-public-url
title: from.getPublicUrl()
@@ -7327,6 +7489,14 @@ functions:
.from('public-bucket')
.getPublicUrl('folder/avatar1.png')
```
+ response: |
+ ```json
+ {
+ "data": {
+ "publicUrl": "https://example.supabase.co/storage/v1/object/public/public-bucket/folder/avatar1.png"
+ }
+ }
+ ```
- id: transform-asset-in-public-bucket
name: Returns the URL for an asset in a public bucket with transformations
isSpotlight: true
@@ -7374,6 +7544,13 @@ functions:
.from('avatars')
.download('folder/avatar1.png')
```
+ response: |
+ ```json
+ {
+ "data": <BLOB>,
+ "error": null
+ }
+ ```
- id: download-file-with-transformations
name: Download file with transformations
isSpotlight: true
@@ -7410,6 +7587,13 @@ functions:
.from('avatars')
.remove(['folder/avatar1.png'])
```
+ response: |
+ ```json
+ {
+ "data": [],
+ "error": null
+ }
+ ```
- id: from-list
title: from.list()
@@ -7434,6 +7618,30 @@ functions:
sortBy: { column: 'name', order: 'asc' },
})
```
+ response: |
+ ```json
+ {
+ "data": [
+ {
+ "name": "avatar1.png",
+ "id": "e668cf7f-821b-4a2f-9dce-7dfa5dd1cfd2",
+ "updated_at": "2024-05-22T23:06:05.580Z",
+ "created_at": "2024-05-22T23:04:34.443Z",
+ "last_accessed_at": "2024-05-22T23:04:34.443Z",
+ "metadata": {
+ "eTag": "\"c5e8c553235d9af30ef4f6e280790b92\"",
+ "size": 32175,
+ "mimetype": "image/png",
+ "cacheControl": "max-age=3600",
+ "lastModified": "2024-05-22T23:06:05.574Z",
+ "contentLength": 32175,
+ "httpStatusCode": 200
+ }
+ }
+ ],
+ "error": null
+ }
+ ```
- id: search-files-in-a-bucket
name: Search files in a bucket
code: |