@supabase/realtime-js 2.108.3-canary.2 → 2.110.0-canary.0
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 +114 -0
- package/dist/main/RealtimeChannel.d.ts +89 -3
- package/dist/main/RealtimeChannel.d.ts.map +1 -1
- package/dist/main/RealtimeChannel.js +16 -1
- package/dist/main/RealtimeChannel.js.map +1 -1
- package/dist/main/RealtimeClient.d.ts.map +1 -1
- package/dist/main/RealtimeClient.js +0 -13
- package/dist/main/RealtimeClient.js.map +1 -1
- package/dist/main/RealtimePostgresFilterBuilder.d.ts +132 -0
- package/dist/main/RealtimePostgresFilterBuilder.d.ts.map +1 -0
- package/dist/main/RealtimePostgresFilterBuilder.js +165 -0
- package/dist/main/RealtimePostgresFilterBuilder.js.map +1 -0
- package/dist/main/index.d.ts +2 -2
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +3 -1
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/constants.d.ts +2 -2
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/lib/websocket-factory.d.ts +1 -1
- package/dist/main/lib/websocket-factory.d.ts.map +1 -1
- package/dist/main/lib/websocket-factory.js +5 -22
- package/dist/main/lib/websocket-factory.js.map +1 -1
- package/dist/module/RealtimeChannel.d.ts +89 -3
- package/dist/module/RealtimeChannel.d.ts.map +1 -1
- package/dist/module/RealtimeChannel.js +13 -0
- package/dist/module/RealtimeChannel.js.map +1 -1
- package/dist/module/RealtimeClient.d.ts.map +1 -1
- package/dist/module/RealtimeClient.js +0 -13
- package/dist/module/RealtimeClient.js.map +1 -1
- package/dist/module/RealtimePostgresFilterBuilder.d.ts +132 -0
- package/dist/module/RealtimePostgresFilterBuilder.d.ts.map +1 -0
- package/dist/module/RealtimePostgresFilterBuilder.js +160 -0
- package/dist/module/RealtimePostgresFilterBuilder.js.map +1 -0
- package/dist/module/index.d.ts +2 -2
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +2 -2
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/constants.d.ts +2 -2
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/lib/websocket-factory.d.ts +1 -1
- package/dist/module/lib/websocket-factory.d.ts.map +1 -1
- package/dist/module/lib/websocket-factory.js +5 -22
- package/dist/module/lib/websocket-factory.js.map +1 -1
- package/dist/tsconfig.module.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/RealtimeChannel.ts +116 -4
- package/src/RealtimeClient.ts +0 -16
- package/src/RealtimePostgresFilterBuilder.ts +253 -0
- package/src/index.ts +8 -0
- package/src/lib/version.ts +1 -1
- package/src/lib/websocket-factory.ts +6 -25
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comparison operators accepted in a Postgres Changes `filter` string.
|
|
3
|
+
*
|
|
4
|
+
* These mirror the PostgREST operator surface and are evaluated server-side.
|
|
5
|
+
* Any operator can be negated via {@link RealtimePostgresFilterBuilder.not}
|
|
6
|
+
* (the `not.` prefix).
|
|
7
|
+
*
|
|
8
|
+
* This is the subset of PostgREST's `FilterOperator` (see `postgrest-js`) that
|
|
9
|
+
* Realtime Postgres Changes supports. Containment, range and full-text search
|
|
10
|
+
* operators (`cs`, `cd`, `ov`, range ops, `fts`, …) are intentionally not
|
|
11
|
+
* included because the Realtime server does not evaluate them.
|
|
12
|
+
*
|
|
13
|
+
* - `eq`, `neq`, `lt`, `lte`, `gt`, `gte` — comparison
|
|
14
|
+
* - `in` — membership: `status=in.(active,pending)`
|
|
15
|
+
* - `like`, `ilike` — pattern match (case-sensitive / insensitive): `title=like.%foo%`
|
|
16
|
+
* - `is` — `IS` check against `null` / `true` / `false` / `unknown`: `deleted_at=is.null`
|
|
17
|
+
* - `match`, `imatch` — POSIX regex match (`~` / `~*`)
|
|
18
|
+
* - `isdistinct` — NULL-safe inequality (`IS DISTINCT FROM`)
|
|
19
|
+
*/
|
|
20
|
+
export type RealtimePostgresChangesFilterOperator = 'eq' | 'neq' | 'lt' | 'lte' | 'gt' | 'gte' | 'in' | 'like' | 'ilike' | 'is' | 'match' | 'imatch' | 'isdistinct';
|
|
21
|
+
/** Scalar value accepted by a single filter operator. */
|
|
22
|
+
export type RealtimeFilterValue = string | number | boolean | null;
|
|
23
|
+
/** Value accepted by the `is` operator. */
|
|
24
|
+
export type RealtimeIsFilterValue = null | boolean | 'null' | 'true' | 'false' | 'unknown';
|
|
25
|
+
/**
|
|
26
|
+
* Fluent builder for Postgres Changes `filter` strings.
|
|
27
|
+
*
|
|
28
|
+
* Each method appends a single `column=operator.value` condition. Multiple
|
|
29
|
+
* conditions are combined with commas, which the Realtime server applies as an
|
|
30
|
+
* `AND`. Pass an instance straight to `channel.on('postgres_changes', …)` — the
|
|
31
|
+
* SDK serializes it to a string automatically — or call {@link build} to obtain
|
|
32
|
+
* the string yourself.
|
|
33
|
+
*
|
|
34
|
+
* The builder mirrors the `postgrest-js` filter API (`eq`, `neq`, `in`, `like`,
|
|
35
|
+
* `not`, …) for the operators that Realtime supports. Values containing reserved
|
|
36
|
+
* characters (`,`, `(`, `)`, `"`, `\`) — or surrounding whitespace — are
|
|
37
|
+
* automatically double-quoted and escaped the same way PostgREST does, so they
|
|
38
|
+
* survive the server's filter parser; all other values are sent verbatim.
|
|
39
|
+
*
|
|
40
|
+
* The filter is snapshotted when passed to `channel.on(...)`; mutating the
|
|
41
|
+
* builder afterwards does not affect an existing subscription. An empty builder
|
|
42
|
+
* serializes to `''`, which the server treats as "no filter".
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* channel.on('postgres_changes', {
|
|
46
|
+
* event: '*',
|
|
47
|
+
* schema: 'public',
|
|
48
|
+
* table: 'users',
|
|
49
|
+
* filter: postgresChangesFilter().eq('id', 1).lt('age', 30), // → 'id=eq.1,age=lt.30'
|
|
50
|
+
* }, (payload) => { ... })
|
|
51
|
+
*/
|
|
52
|
+
export declare class RealtimePostgresFilterBuilder {
|
|
53
|
+
private readonly filters;
|
|
54
|
+
private add;
|
|
55
|
+
/** Match rows where `column` equals `value` (`column=eq.value`). */
|
|
56
|
+
eq(column: string, value: RealtimeFilterValue): this;
|
|
57
|
+
/** Match rows where `column` does not equal `value` (`column=neq.value`). */
|
|
58
|
+
neq(column: string, value: RealtimeFilterValue): this;
|
|
59
|
+
/** Match rows where `column` is greater than `value` (`column=gt.value`). */
|
|
60
|
+
gt(column: string, value: RealtimeFilterValue): this;
|
|
61
|
+
/** Match rows where `column` is greater than or equal to `value` (`column=gte.value`). */
|
|
62
|
+
gte(column: string, value: RealtimeFilterValue): this;
|
|
63
|
+
/** Match rows where `column` is less than `value` (`column=lt.value`). */
|
|
64
|
+
lt(column: string, value: RealtimeFilterValue): this;
|
|
65
|
+
/** Match rows where `column` is less than or equal to `value` (`column=lte.value`). */
|
|
66
|
+
lte(column: string, value: RealtimeFilterValue): this;
|
|
67
|
+
/**
|
|
68
|
+
* Match rows where `column` is one of `values` (`column=in.(a,b,c)`).
|
|
69
|
+
* Requires at least one value; duplicates are removed. An element containing a
|
|
70
|
+
* reserved character is double-quoted (`in.("a,b",c)`), so commas inside an
|
|
71
|
+
* element are preserved. `null` is intentionally not accepted (`IN (null)`
|
|
72
|
+
* never matches in SQL) — use `is`/`not('col','is',null)` for null checks.
|
|
73
|
+
*/
|
|
74
|
+
in(column: string, values: ReadonlyArray<string | number | boolean>): this;
|
|
75
|
+
/** Match rows where `column` matches the case-sensitive `pattern` (`column=like.pattern`). */
|
|
76
|
+
like(column: string, pattern: string): this;
|
|
77
|
+
/** Match rows where `column` matches the case-insensitive `pattern` (`column=ilike.pattern`). */
|
|
78
|
+
ilike(column: string, pattern: string): this;
|
|
79
|
+
/** Match rows where `column` matches the POSIX regex `pattern` (`column=match.pattern`). */
|
|
80
|
+
match(column: string, pattern: string): this;
|
|
81
|
+
/** Match rows where `column` matches the case-insensitive POSIX regex `pattern` (`column=imatch.pattern`). */
|
|
82
|
+
imatch(column: string, pattern: string): this;
|
|
83
|
+
/**
|
|
84
|
+
* Match rows where `column` `IS` the given value (`column=is.null`).
|
|
85
|
+
* Accepts `null`, a boolean, or the keywords `'null' | 'true' | 'false' | 'unknown'`.
|
|
86
|
+
*/
|
|
87
|
+
is(column: string, value: RealtimeIsFilterValue): this;
|
|
88
|
+
/** Match rows where `column` is distinct from `value` (`column=isdistinct.value`). NULL-safe inequality. */
|
|
89
|
+
isDistinct(column: string, value: RealtimeFilterValue): this;
|
|
90
|
+
/**
|
|
91
|
+
* Negate any operator with the `not.` prefix (`column=not.operator.value`).
|
|
92
|
+
* `in` takes an array, `is` takes an `IS` keyword/boolean/null, and every
|
|
93
|
+
* other operator takes a scalar value.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* postgresChangesFilter().not('status', 'in', ['draft', 'archived'])
|
|
97
|
+
* // → status=not.in.(draft,archived)
|
|
98
|
+
* postgresChangesFilter().not('deleted_at', 'is', null)
|
|
99
|
+
* // → deleted_at=not.is.null
|
|
100
|
+
*/
|
|
101
|
+
not(column: string, operator: 'in', value: ReadonlyArray<string | number | boolean>): this;
|
|
102
|
+
not(column: string, operator: 'is', value: RealtimeIsFilterValue): this;
|
|
103
|
+
not(column: string, operator: Exclude<RealtimePostgresChangesFilterOperator, 'in' | 'is'>, value: RealtimeFilterValue): this;
|
|
104
|
+
/**
|
|
105
|
+
* Serialize all conditions into the comma-separated (AND) filter string.
|
|
106
|
+
*
|
|
107
|
+
* Conditions are joined by commas, which the server applies as `AND`. A scalar
|
|
108
|
+
* value (or single `in` element) that contains a reserved character — `,`,
|
|
109
|
+
* `(`, `)`, `"`, `\` — or surrounding whitespace is double-quoted and escaped
|
|
110
|
+
* the way PostgREST does, so commas inside a value are preserved rather than
|
|
111
|
+
* read as a condition boundary.
|
|
112
|
+
*/
|
|
113
|
+
build(): string;
|
|
114
|
+
/** Alias for {@link build}; lets the builder be used wherever a string is expected. */
|
|
115
|
+
toString(): string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create a {@link RealtimePostgresFilterBuilder} for composing a Postgres
|
|
119
|
+
* Changes `filter`. Conditions are combined with `AND`.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* import { postgresChangesFilter } from '@supabase/realtime-js'
|
|
123
|
+
*
|
|
124
|
+
* channel.on('postgres_changes', {
|
|
125
|
+
* event: 'UPDATE',
|
|
126
|
+
* schema: 'public',
|
|
127
|
+
* table: 'orders',
|
|
128
|
+
* filter: postgresChangesFilter().gt('amount', 100).eq('status', 'open'),
|
|
129
|
+
* }, (payload) => { ... })
|
|
130
|
+
*/
|
|
131
|
+
export declare const postgresChangesFilter: () => RealtimePostgresFilterBuilder;
|
|
132
|
+
//# sourceMappingURL=RealtimePostgresFilterBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RealtimePostgresFilterBuilder.d.ts","sourceRoot":"","sources":["../../src/RealtimePostgresFilterBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,qCAAqC,GAC7C,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,MAAM,GACN,OAAO,GACP,IAAI,GACJ,OAAO,GACP,QAAQ,GACR,YAAY,CAAA;AAEhB,yDAAyD;AACzD,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAElE,2CAA2C;AAC3C,MAAM,MAAM,qBAAqB,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;AAuC1F;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;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AAI;IAI5D;;;;;;;;;;OAUG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI;IAC1F,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,GAAG,IAAI;IACvE,GAAG,CACD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,CAAC,qCAAqC,EAAE,IAAI,GAAG,IAAI,CAAC,EACrE,KAAK,EAAE,mBAAmB,GACzB,IAAI;IASP;;;;;;;;OAQG;IACH,KAAK,IAAI,MAAM;IAIf,uFAAuF;IACvF,QAAQ,IAAI,MAAM;CAGnB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,QAAO,6BACJ,CAAA"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postgresChangesFilter = exports.RealtimePostgresFilterBuilder = void 0;
|
|
4
|
+
// Reserved characters that force PostgREST-style quoting: `[,()]` (which the
|
|
5
|
+
// server reads as condition/list delimiters) plus `"`/`\` (escaped inside quotes).
|
|
6
|
+
const PostgrestReservedCharsRegexp = /[,()"\\]/;
|
|
7
|
+
const needsQuoting = (value) => PostgrestReservedCharsRegexp.test(value) || value !== value.trim();
|
|
8
|
+
const quote = (value) => `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
9
|
+
const serializeScalar = (value) => {
|
|
10
|
+
const serialized = value === null ? 'null' : String(value);
|
|
11
|
+
return needsQuoting(serialized) ? quote(serialized) : serialized;
|
|
12
|
+
};
|
|
13
|
+
const serializeIsValue = (value) => value === null ? 'null' : String(value);
|
|
14
|
+
// Builds the `operator.value` portion of a filter (everything after `column=`).
|
|
15
|
+
const serialize = (operator, value) => {
|
|
16
|
+
if (operator === 'in') {
|
|
17
|
+
const values = Array.isArray(value) ? value : [value];
|
|
18
|
+
if (values.length === 0) {
|
|
19
|
+
throw new Error('Realtime `in` filter requires at least one value.');
|
|
20
|
+
}
|
|
21
|
+
const items = Array.from(new Set(values))
|
|
22
|
+
.map((v) => serializeScalar(v))
|
|
23
|
+
.join(',');
|
|
24
|
+
return `in.(${items})`;
|
|
25
|
+
}
|
|
26
|
+
if (operator === 'is') {
|
|
27
|
+
return `is.${serializeIsValue(value)}`;
|
|
28
|
+
}
|
|
29
|
+
return `${operator}.${serializeScalar(value)}`;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Fluent builder for Postgres Changes `filter` strings.
|
|
33
|
+
*
|
|
34
|
+
* Each method appends a single `column=operator.value` condition. Multiple
|
|
35
|
+
* conditions are combined with commas, which the Realtime server applies as an
|
|
36
|
+
* `AND`. Pass an instance straight to `channel.on('postgres_changes', …)` — the
|
|
37
|
+
* SDK serializes it to a string automatically — or call {@link build} to obtain
|
|
38
|
+
* the string yourself.
|
|
39
|
+
*
|
|
40
|
+
* The builder mirrors the `postgrest-js` filter API (`eq`, `neq`, `in`, `like`,
|
|
41
|
+
* `not`, …) for the operators that Realtime supports. Values containing reserved
|
|
42
|
+
* characters (`,`, `(`, `)`, `"`, `\`) — or surrounding whitespace — are
|
|
43
|
+
* automatically double-quoted and escaped the same way PostgREST does, so they
|
|
44
|
+
* survive the server's filter parser; all other values are sent verbatim.
|
|
45
|
+
*
|
|
46
|
+
* The filter is snapshotted when passed to `channel.on(...)`; mutating the
|
|
47
|
+
* builder afterwards does not affect an existing subscription. An empty builder
|
|
48
|
+
* serializes to `''`, which the server treats as "no filter".
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* channel.on('postgres_changes', {
|
|
52
|
+
* event: '*',
|
|
53
|
+
* schema: 'public',
|
|
54
|
+
* table: 'users',
|
|
55
|
+
* filter: postgresChangesFilter().eq('id', 1).lt('age', 30), // → 'id=eq.1,age=lt.30'
|
|
56
|
+
* }, (payload) => { ... })
|
|
57
|
+
*/
|
|
58
|
+
class RealtimePostgresFilterBuilder {
|
|
59
|
+
constructor() {
|
|
60
|
+
this.filters = [];
|
|
61
|
+
}
|
|
62
|
+
add(column, operator, value, negate = false) {
|
|
63
|
+
const prefix = negate ? 'not.' : '';
|
|
64
|
+
this.filters.push(`${column}=${prefix}${serialize(operator, value)}`);
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
/** Match rows where `column` equals `value` (`column=eq.value`). */
|
|
68
|
+
eq(column, value) {
|
|
69
|
+
return this.add(column, 'eq', value);
|
|
70
|
+
}
|
|
71
|
+
/** Match rows where `column` does not equal `value` (`column=neq.value`). */
|
|
72
|
+
neq(column, value) {
|
|
73
|
+
return this.add(column, 'neq', value);
|
|
74
|
+
}
|
|
75
|
+
/** Match rows where `column` is greater than `value` (`column=gt.value`). */
|
|
76
|
+
gt(column, value) {
|
|
77
|
+
return this.add(column, 'gt', value);
|
|
78
|
+
}
|
|
79
|
+
/** Match rows where `column` is greater than or equal to `value` (`column=gte.value`). */
|
|
80
|
+
gte(column, value) {
|
|
81
|
+
return this.add(column, 'gte', value);
|
|
82
|
+
}
|
|
83
|
+
/** Match rows where `column` is less than `value` (`column=lt.value`). */
|
|
84
|
+
lt(column, value) {
|
|
85
|
+
return this.add(column, 'lt', value);
|
|
86
|
+
}
|
|
87
|
+
/** Match rows where `column` is less than or equal to `value` (`column=lte.value`). */
|
|
88
|
+
lte(column, value) {
|
|
89
|
+
return this.add(column, 'lte', value);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Match rows where `column` is one of `values` (`column=in.(a,b,c)`).
|
|
93
|
+
* Requires at least one value; duplicates are removed. An element containing a
|
|
94
|
+
* reserved character is double-quoted (`in.("a,b",c)`), so commas inside an
|
|
95
|
+
* element are preserved. `null` is intentionally not accepted (`IN (null)`
|
|
96
|
+
* never matches in SQL) — use `is`/`not('col','is',null)` for null checks.
|
|
97
|
+
*/
|
|
98
|
+
in(column, values) {
|
|
99
|
+
return this.add(column, 'in', values);
|
|
100
|
+
}
|
|
101
|
+
/** Match rows where `column` matches the case-sensitive `pattern` (`column=like.pattern`). */
|
|
102
|
+
like(column, pattern) {
|
|
103
|
+
return this.add(column, 'like', pattern);
|
|
104
|
+
}
|
|
105
|
+
/** Match rows where `column` matches the case-insensitive `pattern` (`column=ilike.pattern`). */
|
|
106
|
+
ilike(column, pattern) {
|
|
107
|
+
return this.add(column, 'ilike', pattern);
|
|
108
|
+
}
|
|
109
|
+
/** Match rows where `column` matches the POSIX regex `pattern` (`column=match.pattern`). */
|
|
110
|
+
match(column, pattern) {
|
|
111
|
+
return this.add(column, 'match', pattern);
|
|
112
|
+
}
|
|
113
|
+
/** Match rows where `column` matches the case-insensitive POSIX regex `pattern` (`column=imatch.pattern`). */
|
|
114
|
+
imatch(column, pattern) {
|
|
115
|
+
return this.add(column, 'imatch', pattern);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Match rows where `column` `IS` the given value (`column=is.null`).
|
|
119
|
+
* Accepts `null`, a boolean, or the keywords `'null' | 'true' | 'false' | 'unknown'`.
|
|
120
|
+
*/
|
|
121
|
+
is(column, value) {
|
|
122
|
+
return this.add(column, 'is', value);
|
|
123
|
+
}
|
|
124
|
+
/** Match rows where `column` is distinct from `value` (`column=isdistinct.value`). NULL-safe inequality. */
|
|
125
|
+
isDistinct(column, value) {
|
|
126
|
+
return this.add(column, 'isdistinct', value);
|
|
127
|
+
}
|
|
128
|
+
not(column, operator, value) {
|
|
129
|
+
return this.add(column, operator, value, true);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Serialize all conditions into the comma-separated (AND) filter string.
|
|
133
|
+
*
|
|
134
|
+
* Conditions are joined by commas, which the server applies as `AND`. A scalar
|
|
135
|
+
* value (or single `in` element) that contains a reserved character — `,`,
|
|
136
|
+
* `(`, `)`, `"`, `\` — or surrounding whitespace is double-quoted and escaped
|
|
137
|
+
* the way PostgREST does, so commas inside a value are preserved rather than
|
|
138
|
+
* read as a condition boundary.
|
|
139
|
+
*/
|
|
140
|
+
build() {
|
|
141
|
+
return this.filters.join(',');
|
|
142
|
+
}
|
|
143
|
+
/** Alias for {@link build}; lets the builder be used wherever a string is expected. */
|
|
144
|
+
toString() {
|
|
145
|
+
return this.build();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.RealtimePostgresFilterBuilder = RealtimePostgresFilterBuilder;
|
|
149
|
+
/**
|
|
150
|
+
* Create a {@link RealtimePostgresFilterBuilder} for composing a Postgres
|
|
151
|
+
* Changes `filter`. Conditions are combined with `AND`.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* import { postgresChangesFilter } from '@supabase/realtime-js'
|
|
155
|
+
*
|
|
156
|
+
* channel.on('postgres_changes', {
|
|
157
|
+
* event: 'UPDATE',
|
|
158
|
+
* schema: 'public',
|
|
159
|
+
* table: 'orders',
|
|
160
|
+
* filter: postgresChangesFilter().gt('amount', 100).eq('status', 'open'),
|
|
161
|
+
* }, (payload) => { ... })
|
|
162
|
+
*/
|
|
163
|
+
const postgresChangesFilter = () => new RealtimePostgresFilterBuilder();
|
|
164
|
+
exports.postgresChangesFilter = postgresChangesFilter;
|
|
165
|
+
//# sourceMappingURL=RealtimePostgresFilterBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RealtimePostgresFilterBuilder.js","sourceRoot":"","sources":["../../src/RealtimePostgresFilterBuilder.ts"],"names":[],"mappings":";;;AAwCA,6EAA6E;AAC7E,mFAAmF;AACnF,MAAM,4BAA4B,GAAG,UAAU,CAAA;AAE/C,MAAM,YAAY,GAAG,CAAC,KAAa,EAAW,EAAE,CAC9C,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAA;AAEpE,MAAM,KAAK,GAAG,CAAC,KA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C,EAC/C,KAAqE;QAErE,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IAChD,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED,uFAAuF;IACvF,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC;CACF;AAnID,sEAmIC;AAED;;;;;;;;;;;;;GAaG;AACI,MAAM,qBAAqB,GAAG,GAAkC,EAAE,CACvE,IAAI,6BAA6B,EAAE,CAAA;AADxB,QAAA,qBAAqB,yBACG"}
|
package/dist/main/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import RealtimeClient, { RealtimeClientOptions, RealtimeMessage, RealtimeRemoveChannelResponse, WebSocketLikeConstructor } from './RealtimeClient';
|
|
2
|
-
import RealtimeChannel, { RealtimeChannelOptions, RealtimeChannelSendResponse, RealtimePostgresChangesFilter, RealtimePostgresChangesPayload, RealtimePostgresInsertPayload, RealtimePostgresUpdatePayload, RealtimePostgresDeletePayload, REALTIME_LISTEN_TYPES, REALTIME_POSTGRES_CHANGES_LISTEN_EVENT, REALTIME_SUBSCRIBE_STATES, REALTIME_CHANNEL_STATES } from './RealtimeChannel';
|
|
2
|
+
import RealtimeChannel, { RealtimeChannelOptions, RealtimeChannelSendResponse, RealtimePostgresChangesFilter, RealtimePostgresChangesFilterOperator, RealtimePostgresFilterBuilder, postgresChangesFilter, RealtimePostgresChangesPayload, RealtimePostgresInsertPayload, RealtimePostgresUpdatePayload, RealtimePostgresDeletePayload, RealtimeSystemPayload, REALTIME_LISTEN_TYPES, REALTIME_POSTGRES_CHANGES_LISTEN_EVENT, REALTIME_SUBSCRIBE_STATES, REALTIME_CHANNEL_STATES } from './RealtimeChannel';
|
|
3
3
|
import RealtimePresence, { RealtimePresenceState, RealtimePresenceJoinPayload, RealtimePresenceLeavePayload, REALTIME_PRESENCE_LISTEN_EVENTS } from './RealtimePresence';
|
|
4
4
|
import WebSocketFactory, { WebSocketLike } from './lib/websocket-factory';
|
|
5
|
-
export { RealtimePresence, RealtimeChannel, RealtimeChannelOptions, RealtimeChannelSendResponse, RealtimeClient, RealtimeClientOptions, RealtimeMessage, RealtimePostgresChangesFilter, RealtimePostgresChangesPayload, RealtimePostgresInsertPayload, RealtimePostgresUpdatePayload, RealtimePostgresDeletePayload, RealtimePresenceJoinPayload, RealtimePresenceLeavePayload, RealtimePresenceState, RealtimeRemoveChannelResponse, REALTIME_LISTEN_TYPES, REALTIME_POSTGRES_CHANGES_LISTEN_EVENT, REALTIME_PRESENCE_LISTEN_EVENTS, REALTIME_SUBSCRIBE_STATES, REALTIME_CHANNEL_STATES, WebSocketFactory, WebSocketLike, WebSocketLikeConstructor, };
|
|
5
|
+
export { RealtimePresence, RealtimeChannel, RealtimeChannelOptions, RealtimeChannelSendResponse, RealtimeClient, RealtimeClientOptions, RealtimeMessage, RealtimePostgresChangesFilter, RealtimePostgresChangesFilterOperator, RealtimePostgresFilterBuilder, postgresChangesFilter, RealtimePostgresChangesPayload, RealtimePostgresInsertPayload, RealtimePostgresUpdatePayload, RealtimePostgresDeletePayload, RealtimeSystemPayload, RealtimePresenceJoinPayload, RealtimePresenceLeavePayload, RealtimePresenceState, RealtimeRemoveChannelResponse, REALTIME_LISTEN_TYPES, REALTIME_POSTGRES_CHANGES_LISTEN_EVENT, REALTIME_PRESENCE_LISTEN_EVENTS, REALTIME_SUBSCRIBE_STATES, REALTIME_CHANNEL_STATES, WebSocketFactory, WebSocketLike, WebSocketLikeConstructor, };
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/main/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,EAAE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qB,EACrB,sCAAsC,EACtC,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,gBAAgB,EAAE,EACvB,qBAAqB,EACrB,2BAA2B,EAC3B,4BAA4B,EAC5B,+BAA+B,EAChC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,gBAAgB,EAAE,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAEzE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,6BAA6B,EAC7B,qCAAqC,EACrC,6BAA6B,EAC7B,qBAAqB,EACrB,8BAA8B,EAC9B,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,qBAAqB,EACrB,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,6BAA6B,EAC7B,qBAAqB,EACrB,sCAAsC,EACtC,+BAA+B,EAC/B,yBAAyB,EACzB,uBAAuB,EACvB,gBAAgB,EAChB,aAAa,EACb,wBAAwB,GACzB,CAAA"}
|
package/dist/main/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebSocketFactory = exports.REALTIME_CHANNEL_STATES = exports.REALTIME_SUBSCRIBE_STATES = exports.REALTIME_PRESENCE_LISTEN_EVENTS = exports.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = exports.REALTIME_LISTEN_TYPES = exports.RealtimeClient = exports.RealtimeChannel = exports.RealtimePresence = void 0;
|
|
3
|
+
exports.WebSocketFactory = exports.REALTIME_CHANNEL_STATES = exports.REALTIME_SUBSCRIBE_STATES = exports.REALTIME_PRESENCE_LISTEN_EVENTS = exports.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = exports.REALTIME_LISTEN_TYPES = exports.postgresChangesFilter = exports.RealtimePostgresFilterBuilder = exports.RealtimeClient = exports.RealtimeChannel = exports.RealtimePresence = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const RealtimeClient_1 = tslib_1.__importDefault(require("./RealtimeClient"));
|
|
6
6
|
exports.RealtimeClient = RealtimeClient_1.default;
|
|
7
7
|
const RealtimeChannel_1 = tslib_1.__importStar(require("./RealtimeChannel"));
|
|
8
8
|
exports.RealtimeChannel = RealtimeChannel_1.default;
|
|
9
|
+
Object.defineProperty(exports, "RealtimePostgresFilterBuilder", { enumerable: true, get: function () { return RealtimeChannel_1.RealtimePostgresFilterBuilder; } });
|
|
10
|
+
Object.defineProperty(exports, "postgresChangesFilter", { enumerable: true, get: function () { return RealtimeChannel_1.postgresChangesFilter; } });
|
|
9
11
|
Object.defineProperty(exports, "REALTIME_LISTEN_TYPES", { enumerable: true, get: function () { return RealtimeChannel_1.REALTIME_LISTEN_TYPES; } });
|
|
10
12
|
Object.defineProperty(exports, "REALTIME_POSTGRES_CHANGES_LISTEN_EVENT", { enumerable: true, get: function () { return RealtimeChannel_1.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT; } });
|
|
11
13
|
Object.defineProperty(exports, "REALTIME_SUBSCRIBE_STATES", { enumerable: true, get: function () { return RealtimeChannel_1.REALTIME_SUBSCRIBE_STATES; } });
|
package/dist/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,8EAKyB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,8EAKyB;AA+BvB,yBApCK,wBAAc,CAoCL;AA9BhB,6EAgB0B;AAWxB,0BA3BK,yBAAe,CA2BL;AAQf,8GA9BA,+CAA6B,OA8BA;AAC7B,sGA9BA,uCAAqB,OA8BA;AAUrB,sGAlCA,uCAAqB,OAkCA;AACrB,uHAlCA,wDAAsC,OAkCA;AAEtC,0GAnCA,2CAAyB,OAmCA;AACzB,wGAnCA,yCAAuB,OAmCA;AAjCzB,+EAK2B;AAIzB,2BATK,0BAAgB,CASL;AAsBhB,gHA3BA,kDAA+B,OA2BA;AAzBjC,wFAAyE;AA4BvE,2BA5BK,2BAAgB,CA4BL"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { SocketState, ChannelState, ChannelEvent as PhoenixChannelEvent, Transport, Vsn } from '../phoenix/types';
|
|
2
2
|
export type { SocketState, ChannelState, Transport };
|
|
3
|
-
export declare const DEFAULT_VERSION = "realtime-js/2.
|
|
3
|
+
export declare const DEFAULT_VERSION = "realtime-js/2.110.0-canary.0";
|
|
4
4
|
export declare const VSN_1_0_0: Vsn;
|
|
5
5
|
export declare const VSN_2_0_0: Vsn;
|
|
6
6
|
export declare const DEFAULT_VSN: Vsn;
|
|
7
|
-
export declare const VERSION = "2.
|
|
7
|
+
export declare const VERSION = "2.110.0-canary.0";
|
|
8
8
|
export declare const DEFAULT_TIMEOUT = 10000;
|
|
9
9
|
export declare const WS_CLOSE_NORMAL = 1000;
|
|
10
10
|
export declare const MAX_PUSH_BUFFER_SIZE = 100;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.110.0-canary.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/main/lib/version.js
CHANGED
|
@@ -7,5 +7,5 @@ exports.version = void 0;
|
|
|
7
7
|
// - Debugging and support (identifying which version is running)
|
|
8
8
|
// - Telemetry and logging (version reporting in errors/analytics)
|
|
9
9
|
// - Ensuring build artifacts match the published package version
|
|
10
|
-
exports.version = '2.
|
|
10
|
+
exports.version = '2.110.0-canary.0';
|
|
11
11
|
//# sourceMappingURL=version.js.map
|
|
@@ -32,7 +32,7 @@ export interface WebSocketLike {
|
|
|
32
32
|
dispatchEvent?: (event: Event) => boolean;
|
|
33
33
|
}
|
|
34
34
|
export interface WebSocketEnvironment {
|
|
35
|
-
type: 'native' | '
|
|
35
|
+
type: 'native' | 'cloudflare' | 'unsupported';
|
|
36
36
|
/** WebSocket constructor for this environment, if available. */
|
|
37
37
|
wsConstructor?: typeof WebSocket;
|
|
38
38
|
error?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket-factory.d.ts","sourceRoot":"","sources":["../../../src/lib/websocket-factory.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3C;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,GAAG,eAAe,GAAG,IAAI,CAAA;IAEnE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,KAAK,GAAG,CAAC,GAAG,IAAI,CAAA;IAC9C,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,YAAY,KAAK,GAAG,CAAC,GAAG,IAAI,CAAA;IACxD,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,KAAK,GAAG,CAAC,GAAG,IAAI,CAAA;IACpD,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,KAAK,GAAG,CAAC,GAAG,IAAI,CAAA;I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AE,YAAY,KAAK,GAAG,CAAC,GAAG,IAAI,CAAA;IACxD,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,KAAK,GAAG,CAAC,GAAG,IAAI,CAAA;IACpD,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,KAAK,GAAG,CAAC,GAAG,IAAI,CAAA;IAE/C;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAA;IAC7D;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAA;IAGhE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAA;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,QAAQ,GAAG,YAAY,GAAG,aAAa,CAAA;IAC7C,gEAAgE;IAChE,aAAa,CAAC,EAAE,OAAO,SAAS,CAAA;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAYD;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,OAAO;IACP,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAqEhC;;;;;;;;;;;;;;OAcG;WACW,uBAAuB,IAAI,OAAO,SAAS;IAYzD;;;;;;;;;;;;OAYG;WACW,oBAAoB,IAAI,OAAO;CAQ9C;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -44,29 +44,12 @@ class WebSocketFactory {
|
|
|
44
44
|
if (_process) {
|
|
45
45
|
const processVersions = _process['versions'];
|
|
46
46
|
if (processVersions && processVersions['node']) {
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
const nodeVersion = parseInt(versionString.replace(/^v/, '').split('.')[0]);
|
|
50
|
-
// Node.js 22+ should have native WebSocket
|
|
51
|
-
if (nodeVersion >= 22) {
|
|
52
|
-
// Check if native WebSocket is available (should be in Node.js 22+)
|
|
53
|
-
if (typeof globalThis.WebSocket !== 'undefined') {
|
|
54
|
-
return { type: 'native', wsConstructor: globalThis.WebSocket };
|
|
55
|
-
}
|
|
56
|
-
// If not available, user needs to provide it
|
|
57
|
-
return {
|
|
58
|
-
type: 'unsupported',
|
|
59
|
-
error: `Node.js ${nodeVersion} detected but native WebSocket not found.`,
|
|
60
|
-
workaround: 'Provide a WebSocket implementation via the transport option.',
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
// Node.js < 22 doesn't have native WebSocket
|
|
47
|
+
// Reaching here means an earlier check did not find a native WebSocket,
|
|
48
|
+
// so this Node.js process is missing the global WebSocket (Node.js 22+).
|
|
64
49
|
return {
|
|
65
50
|
type: 'unsupported',
|
|
66
|
-
error:
|
|
67
|
-
workaround: '
|
|
68
|
-
'import ws from "ws"\n' +
|
|
69
|
-
'new RealtimeClient(url, { transport: ws })',
|
|
51
|
+
error: 'Node.js detected but native WebSocket not found.',
|
|
52
|
+
workaround: 'Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option.',
|
|
70
53
|
};
|
|
71
54
|
}
|
|
72
55
|
}
|
|
@@ -118,7 +101,7 @@ class WebSocketFactory {
|
|
|
118
101
|
static isWebSocketSupported() {
|
|
119
102
|
try {
|
|
120
103
|
const env = this.detectEnvironment();
|
|
121
|
-
return env.type === 'native'
|
|
104
|
+
return env.type === 'native';
|
|
122
105
|
}
|
|
123
106
|
catch (_a) {
|
|
124
107
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket-factory.js","sourceRoot":"","sources":["../../../src/lib/websocket-factory.ts"],"names":[],"mappings":";;;AAyDA;;GAEG;AACH,MAAa,gBAAgB;IAC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C;QACD,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;IAC/B,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,oBAAoB;QAChC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;YACpC,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAA;QAC9B,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;CACF;AA1HD,4CA0HC;AAED,kBAAe,gBAAgB,CAAA"}
|
|
@@ -4,6 +4,9 @@ import RealtimePresence, { REALTIME_PRESENCE_LISTEN_EVENTS } from './RealtimePre
|
|
|
4
4
|
import type { RealtimePresenceJoinPayload, RealtimePresenceLeavePayload, RealtimePresenceState } from './RealtimePresence';
|
|
5
5
|
import { ChannelBindingCallback } from './phoenix/types';
|
|
6
6
|
import type { Timer } from './phoenix/types';
|
|
7
|
+
import { RealtimePostgresFilterBuilder } from './RealtimePostgresFilterBuilder';
|
|
8
|
+
export type { RealtimePostgresChangesFilterOperator } from './RealtimePostgresFilterBuilder';
|
|
9
|
+
export { RealtimePostgresFilterBuilder, postgresChangesFilter, } from './RealtimePostgresFilterBuilder';
|
|
7
10
|
type ReplayOption = {
|
|
8
11
|
since: number;
|
|
9
12
|
limit?: number;
|
|
@@ -14,11 +17,17 @@ export type RealtimeChannelOptions = {
|
|
|
14
17
|
* self option enables client to receive message it broadcast
|
|
15
18
|
* ack option instructs server to acknowledge that broadcast message was received
|
|
16
19
|
* replay option instructs server to replay broadcast messages
|
|
20
|
+
* replication_ready option instructs the server to emit a `system` event once the
|
|
21
|
+
* Postgres replication connection backing this channel is established and ready to
|
|
22
|
+
* stream changes. Listen for it with `channel.on('system', {}, (payload) => ...)`;
|
|
23
|
+
* the payload's `status` is `'ok'` (`message: 'Replication connection established'`)
|
|
24
|
+
* on success or `'error'` if the connection is not ready in time.
|
|
17
25
|
*/
|
|
18
26
|
broadcast?: {
|
|
19
27
|
self?: boolean;
|
|
20
28
|
ack?: boolean;
|
|
21
29
|
replay?: ReplayOption;
|
|
30
|
+
replication_ready?: boolean;
|
|
22
31
|
};
|
|
23
32
|
/**
|
|
24
33
|
* key option is used to track presence payload across clients
|
|
@@ -108,11 +117,64 @@ export type RealtimePostgresChangesFilter<T extends `${REALTIME_POSTGRES_CHANGES
|
|
|
108
117
|
*/
|
|
109
118
|
table?: string;
|
|
110
119
|
/**
|
|
111
|
-
* Receive database changes when filter is matched.
|
|
120
|
+
* Receive database changes only when the filter is matched.
|
|
121
|
+
*
|
|
122
|
+
* A filter is a `column=operator.value` expression, e.g. `id=eq.1` or
|
|
123
|
+
* `title=like.%foo%`. See {@link RealtimePostgresChangesFilterOperator} for
|
|
124
|
+
* the available operators.
|
|
125
|
+
*
|
|
126
|
+
* Multiple filters can be combined with commas; they are applied as an `AND`
|
|
127
|
+
* condition: `filter: 'id=gt.0,id=lt.100'`.
|
|
128
|
+
*
|
|
129
|
+
* Any operator can be negated with the `not.` prefix: `filter: 'status=not.in.(draft,archived)'`.
|
|
130
|
+
*
|
|
131
|
+
* The server splits conditions on commas outside quotes/parentheses. To
|
|
132
|
+
* include a reserved character (`,`, `(`, `)`) in a value, wrap it in double
|
|
133
|
+
* quotes PostgREST-style: `name=eq."a,b"`. The {@link RealtimePostgresFilterBuilder}
|
|
134
|
+
* does this quoting for you.
|
|
135
|
+
*
|
|
136
|
+
* Instead of a raw string you can pass a {@link RealtimePostgresFilterBuilder}
|
|
137
|
+
* (via `postgresChangesFilter()`) for a type-checked, ergonomic way to compose filters; the
|
|
138
|
+
* SDK serializes it to a string automatically.
|
|
112
139
|
*/
|
|
113
|
-
filter?: string;
|
|
140
|
+
filter?: string | RealtimePostgresFilterBuilder;
|
|
141
|
+
/**
|
|
142
|
+
* Restrict the change payload to a subset of columns instead of receiving the
|
|
143
|
+
* full row. Reduces payload size (helpful for large `bytea`/`jsonb` columns)
|
|
144
|
+
* and the data transferred per event.
|
|
145
|
+
*
|
|
146
|
+
* The listed columns must be selectable by the subscribing role.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* channel.on('postgres_changes', {
|
|
150
|
+
* event: '*',
|
|
151
|
+
* schema: 'public',
|
|
152
|
+
* table: 'users',
|
|
153
|
+
* select: ['id', 'first_name'],
|
|
154
|
+
* }, (payload) => {
|
|
155
|
+
* // payload.new only contains { id, first_name }
|
|
156
|
+
* })
|
|
157
|
+
*/
|
|
158
|
+
select?: string[];
|
|
114
159
|
};
|
|
115
160
|
export type RealtimeChannelSendResponse = 'ok' | 'timed out' | 'error' | (string & {});
|
|
161
|
+
/**
|
|
162
|
+
* Payload of a `system` event emitted by the server.
|
|
163
|
+
*
|
|
164
|
+
* Most notably, when a channel is created with `config.broadcast.replication_ready: true`,
|
|
165
|
+
* the server sends one of these once the Postgres replication connection is ready
|
|
166
|
+
* (`status: 'ok'`) or fails to become ready in time (`status: 'error'`).
|
|
167
|
+
*/
|
|
168
|
+
export type RealtimeSystemPayload = {
|
|
169
|
+
/** The extension that produced the message, e.g. `'system'` or `'postgres_changes'`. */
|
|
170
|
+
extension: 'system' | 'postgres_changes' | (string & {});
|
|
171
|
+
/** `'ok'` on success, `'error'` on failure. */
|
|
172
|
+
status: 'ok' | 'error' | (string & {});
|
|
173
|
+
/** Human-readable description, e.g. `'Replication connection established'`. */
|
|
174
|
+
message: string;
|
|
175
|
+
/** The channel (sub)topic the message refers to. */
|
|
176
|
+
channel: string;
|
|
177
|
+
};
|
|
116
178
|
export declare enum REALTIME_POSTGRES_CHANGES_LISTEN_EVENT {
|
|
117
179
|
ALL = "*",
|
|
118
180
|
INSERT = "INSERT",
|
|
@@ -357,6 +419,31 @@ export default class RealtimeChannel {
|
|
|
357
419
|
event: REALTIME_POSTGRES_CHANGES_LISTEN_EVENT.DELETE;
|
|
358
420
|
payload: RealtimeBroadcastDeletePayload<T>;
|
|
359
421
|
}) => void): RealtimeChannel;
|
|
422
|
+
/**
|
|
423
|
+
* Listen for `system` events on this channel.
|
|
424
|
+
*
|
|
425
|
+
* The payload follows the {@link RealtimeSystemPayload} shape. Opt in to the replication-ready
|
|
426
|
+
* notification with `config.broadcast.replication_ready: true` when creating the channel, then
|
|
427
|
+
* watch for `payload.status === 'ok'` to know the Postgres replication connection is ready.
|
|
428
|
+
*
|
|
429
|
+
* @example Know when the replication connection is ready
|
|
430
|
+
* ```js
|
|
431
|
+
* const channel = supabase.channel('room1', {
|
|
432
|
+
* config: { broadcast: { replication_ready: true } },
|
|
433
|
+
* })
|
|
434
|
+
*
|
|
435
|
+
* channel
|
|
436
|
+
* .on('postgres_changes', { event: '*', schema: 'public', table: 'messages' }, (payload) => {
|
|
437
|
+
* console.log('Change received!', payload)
|
|
438
|
+
* })
|
|
439
|
+
* .on('system', {}, (payload) => {
|
|
440
|
+
* if (payload.extension === 'system' && payload.status === 'ok') {
|
|
441
|
+
* console.log('Replication connection is ready:', payload.message)
|
|
442
|
+
* }
|
|
443
|
+
* })
|
|
444
|
+
* .subscribe()
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
360
447
|
on<T extends {
|
|
361
448
|
[key: string]: any;
|
|
362
449
|
}>(type: `${REALTIME_LISTEN_TYPES.SYSTEM}`, filter: {}, callback: (payload: any) => void): RealtimeChannel;
|
|
@@ -468,5 +555,4 @@ export default class RealtimeChannel {
|
|
|
468
555
|
teardown(): void;
|
|
469
556
|
copyBindings(other: RealtimeChannel): void;
|
|
470
557
|
}
|
|
471
|
-
export {};
|
|
472
558
|
//# sourceMappingURL=RealtimeChannel.d.ts.map
|