@quatrain/cloudwrapper-supabase 1.1.21 → 1.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/lib/SupabaseCloudWrapper.js +5 -1
- package/package.json +4 -2
- package/src/SupabaseCloudWrapper.ts +2 -1
package/README.md
CHANGED
|
@@ -5,21 +5,21 @@ This package provides a Cloud Wrapper for Supabase, enabling real-time database
|
|
|
5
5
|
|
|
6
6
|
## Features
|
|
7
7
|
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
8
|
+
- Listens to database changes (`INSERT`, `UPDATE`, `DELETE`) on your Supabase Postgres database.
|
|
9
|
+
- Listens to storage changes in Supabase Storage.
|
|
10
|
+
- Monitors connection health with a heartbeat mechanism.
|
|
11
|
+
- Provides a configurable strategy for handling disconnections (exit process or attempt to reconnect).
|
|
12
|
+
- Consistent interface provided by `@quatrain/cloudwrapper`.
|
|
13
|
+
- Works with both SaaS and self-hosted Supabase instances.
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
# With npm
|
|
19
|
-
npm install @quatrain/cloudwrapper-supabase @supabase/supabase-js
|
|
19
|
+
npm install @quatrain/cloudwrapper-supabase @supabase/supabase-js ws
|
|
20
20
|
|
|
21
21
|
# With yarn
|
|
22
|
-
yarn add @quatrain/cloudwrapper-supabase @supabase/supabase-js
|
|
22
|
+
yarn add @quatrain/cloudwrapper-supabase @supabase/supabase-js ws
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
@@ -19,11 +19,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
19
|
}
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
22
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
26
|
exports.SupabaseCloudWrapper = exports.eventMap = void 0;
|
|
24
27
|
const cloudwrapper_1 = require("@quatrain/cloudwrapper");
|
|
25
28
|
const backend_1 = require("@quatrain/backend");
|
|
26
29
|
const supabase_js_1 = require("@supabase/supabase-js");
|
|
30
|
+
const ws_1 = __importDefault(require("ws"));
|
|
27
31
|
exports.eventMap = {
|
|
28
32
|
[backend_1.BackendAction.CREATE]: 'INSERT',
|
|
29
33
|
[backend_1.BackendAction.UPDATE]: 'UPDATE',
|
|
@@ -138,9 +142,9 @@ class SupabaseCloudWrapper extends cloudwrapper_1.AbstractCloudWrapper {
|
|
|
138
142
|
}
|
|
139
143
|
this._supabaseClient = (0, supabase_js_1.createClient)(this._params.url, this._params.key, {
|
|
140
144
|
realtime: {
|
|
145
|
+
transport: ws_1.default,
|
|
141
146
|
heartbeatIntervalMs: 5000,
|
|
142
147
|
heartbeatCallback: (status) => {
|
|
143
|
-
console.log('status received', status);
|
|
144
148
|
switch (status) {
|
|
145
149
|
case 'ok':
|
|
146
150
|
if (!this._heartbeatOkReceived) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/cloudwrapper-supabase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Cloud Wrapper adapter for Supabase",
|
|
6
6
|
"repository": {
|
|
@@ -22,12 +22,14 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@quatrain/backend": "^1.1.22",
|
|
24
24
|
"@quatrain/cloudwrapper": "^1.1.14",
|
|
25
|
-
"@supabase/supabase-js": "^2.82.0"
|
|
25
|
+
"@supabase/supabase-js": "^2.82.0",
|
|
26
|
+
"ws": "^8.18.3"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@tsconfig/recommended": "^1.0.1",
|
|
29
30
|
"@types/jest": "^27.0.3",
|
|
30
31
|
"@types/node": "^22.10.1",
|
|
32
|
+
"@types/ws": "^8.18.1",
|
|
31
33
|
"jest": "^30.1.2",
|
|
32
34
|
"jest-node-exports-resolver": "^1.1.6",
|
|
33
35
|
"jest-serial-runner": "^1.2.2",
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
RealtimeChannel,
|
|
13
13
|
} from '@supabase/supabase-js'
|
|
14
14
|
import { HeartbeatStatus } from '@supabase/realtime-js/dist/module/RealtimeClient'
|
|
15
|
+
import ws from 'ws'
|
|
15
16
|
import { FileType } from '@quatrain/storage'
|
|
16
17
|
|
|
17
18
|
export type SupabaseParams = {
|
|
@@ -190,9 +191,9 @@ export class SupabaseCloudWrapper extends AbstractCloudWrapper {
|
|
|
190
191
|
this._params.key,
|
|
191
192
|
{
|
|
192
193
|
realtime: {
|
|
194
|
+
transport: ws as any,
|
|
193
195
|
heartbeatIntervalMs: 5000,
|
|
194
196
|
heartbeatCallback: (status: HeartbeatStatus) => {
|
|
195
|
-
console.log('status received', status)
|
|
196
197
|
switch (status) {
|
|
197
198
|
case 'ok':
|
|
198
199
|
if (!this._heartbeatOkReceived) {
|