@appwrite.io/console 2.1.2 → 2.1.3
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/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/dist/cjs/sdk.js +213 -11
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +212 -12
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +246 -64
- package/package.json +3 -2
- package/src/channel.ts +134 -0
- package/src/client.ts +79 -9
- package/src/index.ts +1 -0
- package/src/query.ts +42 -0
- package/src/services/realtime.ts +35 -12
- package/types/channel.d.ts +71 -0
- package/types/client.d.ts +11 -3
- package/types/index.d.ts +1 -0
- package/types/query.d.ts +30 -0
- package/types/services/realtime.d.ts +17 -8
package/src/client.ts
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
import { Models } from './models';
|
|
2
|
+
import { Channel, ActionableChannel, ResolvedChannel } from './channel';
|
|
2
3
|
import JSONbigModule from 'json-bigint';
|
|
3
|
-
|
|
4
|
+
import BigNumber from 'bignumber.js';
|
|
5
|
+
const JSONbigParser = JSONbigModule({ storeAsString: false });
|
|
6
|
+
const JSONbigSerializer = JSONbigModule({ useNativeBigInt: true });
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Converts BigNumber objects from json-bigint to native types.
|
|
10
|
+
* - Integer BigNumbers → BigInt (if unsafe) or number (if safe)
|
|
11
|
+
* - Float BigNumbers → number
|
|
12
|
+
* - Strings remain strings (never converted to BigNumber by json-bigint)
|
|
13
|
+
*/
|
|
14
|
+
const MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
|
|
15
|
+
const MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
|
|
16
|
+
|
|
17
|
+
function convertBigNumbers(value: any): any {
|
|
18
|
+
if (value === null || value === undefined) return value;
|
|
19
|
+
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
return value.map(convertBigNumbers);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (BigNumber.isBigNumber(value)) {
|
|
25
|
+
if (value.isInteger()) {
|
|
26
|
+
const str = value.toFixed();
|
|
27
|
+
const bi = BigInt(str);
|
|
28
|
+
|
|
29
|
+
if (bi >= MIN_SAFE && bi <= MAX_SAFE) {
|
|
30
|
+
return Number(str);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return bi;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// float
|
|
37
|
+
return value.toNumber();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (typeof value === 'object') {
|
|
41
|
+
const result: any = {};
|
|
42
|
+
for (const [k, v] of Object.entries(value)) {
|
|
43
|
+
result[k] = convertBigNumbers(v);
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const JSONbig = {
|
|
52
|
+
parse: (text: string) => convertBigNumbers(JSONbigParser.parse(text)),
|
|
53
|
+
stringify: JSONbigSerializer.stringify
|
|
54
|
+
};
|
|
4
55
|
|
|
5
56
|
/**
|
|
6
57
|
* Payload type representing a key-value pair with string keys and any values.
|
|
@@ -334,7 +385,7 @@ class Client {
|
|
|
334
385
|
'x-sdk-name': 'Console',
|
|
335
386
|
'x-sdk-platform': 'console',
|
|
336
387
|
'x-sdk-language': 'web',
|
|
337
|
-
'x-sdk-version': '2.1.
|
|
388
|
+
'x-sdk-version': '2.1.3',
|
|
338
389
|
'X-Appwrite-Response-Format': '1.8.0',
|
|
339
390
|
};
|
|
340
391
|
|
|
@@ -654,8 +705,8 @@ class Client {
|
|
|
654
705
|
* @deprecated Use the Realtime service instead.
|
|
655
706
|
* @see Realtime
|
|
656
707
|
*
|
|
657
|
-
* @param {string|string[]} channels
|
|
658
|
-
* Channel to subscribe - pass a single channel as a string or multiple with an array
|
|
708
|
+
* @param {string|string[]|Channel<any>|ActionableChannel|ResolvedChannel|(Channel<any>|ActionableChannel|ResolvedChannel)[]} channels
|
|
709
|
+
* Channel to subscribe - pass a single channel as a string or Channel builder instance, or multiple with an array.
|
|
659
710
|
*
|
|
660
711
|
* Possible channels are:
|
|
661
712
|
* - account
|
|
@@ -673,16 +724,35 @@ class Client {
|
|
|
673
724
|
* - teams.[ID]
|
|
674
725
|
* - memberships
|
|
675
726
|
* - memberships.[ID]
|
|
727
|
+
*
|
|
728
|
+
* You can also use Channel builders:
|
|
729
|
+
* - Channel.database('db').collection('col').document('doc').create()
|
|
730
|
+
* - Channel.bucket('bucket').file('file').update()
|
|
731
|
+
* - Channel.function('func').execution('exec').delete()
|
|
732
|
+
* - Channel.team('team').create()
|
|
733
|
+
* - Channel.membership('membership').update()
|
|
676
734
|
* @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update.
|
|
677
735
|
* @returns {() => void} Unsubscribes from events.
|
|
678
736
|
*/
|
|
679
|
-
subscribe<T extends unknown>(channels: string | string[], callback: (payload: RealtimeResponseEvent<T>) => void): () => void {
|
|
680
|
-
|
|
681
|
-
|
|
737
|
+
subscribe<T extends unknown>(channels: string | string[] | Channel<any> | ActionableChannel | ResolvedChannel | (Channel<any> | ActionableChannel | ResolvedChannel)[], callback: (payload: RealtimeResponseEvent<T>) => void): () => void {
|
|
738
|
+
const channelArray = Array.isArray(channels) ? channels : [channels];
|
|
739
|
+
// Convert Channel instances to strings
|
|
740
|
+
const channelStrings = channelArray.map(ch => {
|
|
741
|
+
if (typeof ch === 'string') {
|
|
742
|
+
return ch;
|
|
743
|
+
}
|
|
744
|
+
// All Channel instances have toString() method
|
|
745
|
+
if (ch && typeof (ch as Channel<any>).toString === 'function') {
|
|
746
|
+
return (ch as Channel<any>).toString();
|
|
747
|
+
}
|
|
748
|
+
// Fallback to generic string conversion
|
|
749
|
+
return String(ch);
|
|
750
|
+
});
|
|
751
|
+
channelStrings.forEach(channel => this.realtime.channels.add(channel));
|
|
682
752
|
|
|
683
753
|
const counter = this.realtime.subscriptionsCounter++;
|
|
684
754
|
this.realtime.subscriptions.set(counter, {
|
|
685
|
-
channels:
|
|
755
|
+
channels: channelStrings,
|
|
686
756
|
callback
|
|
687
757
|
});
|
|
688
758
|
|
|
@@ -690,7 +760,7 @@ class Client {
|
|
|
690
760
|
|
|
691
761
|
return () => {
|
|
692
762
|
this.realtime.subscriptions.delete(counter);
|
|
693
|
-
this.realtime.cleanUp(
|
|
763
|
+
this.realtime.cleanUp(channelStrings);
|
|
694
764
|
this.realtime.connect();
|
|
695
765
|
}
|
|
696
766
|
}
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ export type { QueryTypes, QueryTypesList } from './query';
|
|
|
36
36
|
export { Permission } from './permission';
|
|
37
37
|
export { Role } from './role';
|
|
38
38
|
export { ID } from './id';
|
|
39
|
+
export { Channel } from './channel';
|
|
39
40
|
export { Operator, Condition } from './operator';
|
|
40
41
|
export { AuthenticatorType } from './enums/authenticator-type';
|
|
41
42
|
export { AuthenticationFactor } from './enums/authentication-factor';
|
package/src/query.ts
CHANGED
|
@@ -71,6 +71,16 @@ export class Query {
|
|
|
71
71
|
static notEqual = (attribute: string, value: QueryTypes): string =>
|
|
72
72
|
new Query("notEqual", attribute, value).toString();
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Filter resources where attribute matches a regular expression pattern.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} attribute The attribute to filter on.
|
|
78
|
+
* @param {string} pattern The regular expression pattern to match.
|
|
79
|
+
* @returns {string}
|
|
80
|
+
*/
|
|
81
|
+
static regex = (attribute: string, pattern: string): string =>
|
|
82
|
+
new Query("regex", attribute, pattern).toString();
|
|
83
|
+
|
|
74
84
|
/**
|
|
75
85
|
* Filter resources where attribute is less than value.
|
|
76
86
|
*
|
|
@@ -129,6 +139,24 @@ export class Query {
|
|
|
129
139
|
static isNotNull = (attribute: string): string =>
|
|
130
140
|
new Query("isNotNull", attribute).toString();
|
|
131
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Filter resources where the specified attributes exist.
|
|
144
|
+
*
|
|
145
|
+
* @param {string[]} attributes The list of attributes that must exist.
|
|
146
|
+
* @returns {string}
|
|
147
|
+
*/
|
|
148
|
+
static exists = (attributes: string[]): string =>
|
|
149
|
+
new Query("exists", undefined, attributes).toString();
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Filter resources where the specified attributes do not exist.
|
|
153
|
+
*
|
|
154
|
+
* @param {string[]} attributes The list of attributes that must not exist.
|
|
155
|
+
* @returns {string}
|
|
156
|
+
*/
|
|
157
|
+
static notExists = (attributes: string[]): string =>
|
|
158
|
+
new Query("notExists", undefined, attributes).toString();
|
|
159
|
+
|
|
132
160
|
/**
|
|
133
161
|
* Filter resources where attribute is between start and end (inclusive).
|
|
134
162
|
*
|
|
@@ -378,6 +406,20 @@ export class Query {
|
|
|
378
406
|
static and = (queries: string[]) =>
|
|
379
407
|
new Query("and", undefined, queries.map((query) => JSONbig.parse(query))).toString();
|
|
380
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Filter array elements where at least one element matches all the specified queries.
|
|
411
|
+
*
|
|
412
|
+
* @param {string} attribute The attribute containing the array to filter on.
|
|
413
|
+
* @param {string[]} queries The list of query strings to match against array elements.
|
|
414
|
+
* @returns {string}
|
|
415
|
+
*/
|
|
416
|
+
static elemMatch = (attribute: string, queries: string[]): string =>
|
|
417
|
+
new Query(
|
|
418
|
+
"elemMatch",
|
|
419
|
+
attribute,
|
|
420
|
+
queries.map((query) => JSONbig.parse(query))
|
|
421
|
+
).toString();
|
|
422
|
+
|
|
381
423
|
/**
|
|
382
424
|
* Filter resources where attribute is at a specific distance from the given coordinates.
|
|
383
425
|
*
|
package/src/services/realtime.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AppwriteException, Client } from '../client';
|
|
2
|
+
import { Channel, ActionableChannel, ResolvedChannel } from '../channel';
|
|
2
3
|
|
|
3
4
|
export type RealtimeSubscription = {
|
|
4
5
|
close: () => Promise<void>;
|
|
@@ -237,61 +238,83 @@ export class Realtime {
|
|
|
237
238
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
238
239
|
}
|
|
239
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Convert a channel value to a string
|
|
243
|
+
*
|
|
244
|
+
* @private
|
|
245
|
+
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel value (string or Channel builder instance)
|
|
246
|
+
* @returns {string} Channel string representation
|
|
247
|
+
*/
|
|
248
|
+
private channelToString(channel: string | Channel<any> | ActionableChannel | ResolvedChannel): string {
|
|
249
|
+
if (typeof channel === 'string') {
|
|
250
|
+
return channel;
|
|
251
|
+
}
|
|
252
|
+
// All Channel instances have toString() method
|
|
253
|
+
if (channel && typeof (channel as Channel<any>).toString === 'function') {
|
|
254
|
+
return (channel as Channel<any>).toString();
|
|
255
|
+
}
|
|
256
|
+
return String(channel);
|
|
257
|
+
}
|
|
258
|
+
|
|
240
259
|
/**
|
|
241
260
|
* Subscribe to a single channel
|
|
242
261
|
*
|
|
243
|
-
* @param {string} channel - Channel name to subscribe to
|
|
262
|
+
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel name to subscribe to (string or Channel builder instance)
|
|
244
263
|
* @param {Function} callback - Callback function to handle events
|
|
245
264
|
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
246
265
|
*/
|
|
247
266
|
public async subscribe(
|
|
248
|
-
channel: string,
|
|
267
|
+
channel: string | Channel<any> | ActionableChannel | ResolvedChannel,
|
|
249
268
|
callback: (event: RealtimeResponseEvent<any>) => void
|
|
250
269
|
): Promise<RealtimeSubscription>;
|
|
251
270
|
|
|
252
271
|
/**
|
|
253
272
|
* Subscribe to multiple channels
|
|
254
273
|
*
|
|
255
|
-
* @param {string[]} channels - Array of channel names to subscribe to
|
|
274
|
+
* @param {(string | Channel<any> | ActionableChannel | ResolvedChannel)[]} channels - Array of channel names to subscribe to (strings or Channel builder instances)
|
|
256
275
|
* @param {Function} callback - Callback function to handle events
|
|
257
276
|
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
258
277
|
*/
|
|
259
278
|
public async subscribe(
|
|
260
|
-
channels: string[],
|
|
279
|
+
channels: (string | Channel<any> | ActionableChannel | ResolvedChannel)[],
|
|
261
280
|
callback: (event: RealtimeResponseEvent<any>) => void
|
|
262
281
|
): Promise<RealtimeSubscription>;
|
|
263
282
|
|
|
264
283
|
/**
|
|
265
284
|
* Subscribe to a single channel with typed payload
|
|
266
285
|
*
|
|
267
|
-
* @param {string} channel - Channel name to subscribe to
|
|
286
|
+
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel name to subscribe to (string or Channel builder instance)
|
|
268
287
|
* @param {Function} callback - Callback function to handle events with typed payload
|
|
269
288
|
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
270
289
|
*/
|
|
271
290
|
public async subscribe<T>(
|
|
272
|
-
channel: string,
|
|
291
|
+
channel: string | Channel<any> | ActionableChannel | ResolvedChannel,
|
|
273
292
|
callback: (event: RealtimeResponseEvent<T>) => void
|
|
274
293
|
): Promise<RealtimeSubscription>;
|
|
275
294
|
|
|
276
295
|
/**
|
|
277
296
|
* Subscribe to multiple channels with typed payload
|
|
278
297
|
*
|
|
279
|
-
* @param {string[]} channels - Array of channel names to subscribe to
|
|
298
|
+
* @param {(string | Channel<any> | ActionableChannel | ResolvedChannel)[]} channels - Array of channel names to subscribe to (strings or Channel builder instances)
|
|
280
299
|
* @param {Function} callback - Callback function to handle events with typed payload
|
|
281
300
|
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
282
301
|
*/
|
|
283
302
|
public async subscribe<T>(
|
|
284
|
-
channels: string[],
|
|
303
|
+
channels: (string | Channel<any> | ActionableChannel | ResolvedChannel)[],
|
|
285
304
|
callback: (event: RealtimeResponseEvent<T>) => void
|
|
286
305
|
): Promise<RealtimeSubscription>;
|
|
287
306
|
|
|
288
307
|
public async subscribe<T = any>(
|
|
289
|
-
channelsOrChannel: string | string[],
|
|
308
|
+
channelsOrChannel: string | Channel<any> | ActionableChannel | ResolvedChannel | (string | Channel<any> | ActionableChannel | ResolvedChannel)[],
|
|
290
309
|
callback: (event: RealtimeResponseEvent<T>) => void
|
|
291
310
|
): Promise<RealtimeSubscription> {
|
|
292
|
-
const
|
|
293
|
-
?
|
|
294
|
-
:
|
|
311
|
+
const channelArray = Array.isArray(channelsOrChannel)
|
|
312
|
+
? channelsOrChannel
|
|
313
|
+
: [channelsOrChannel];
|
|
314
|
+
|
|
315
|
+
// Convert all channels to strings
|
|
316
|
+
const channelStrings = channelArray.map(ch => this.channelToString(ch));
|
|
317
|
+
const channels = new Set(channelStrings);
|
|
295
318
|
|
|
296
319
|
this.subscriptionsCounter++;
|
|
297
320
|
const count = this.subscriptionsCounter;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
interface Database {
|
|
2
|
+
_db: any;
|
|
3
|
+
}
|
|
4
|
+
interface Collection {
|
|
5
|
+
_coll: any;
|
|
6
|
+
}
|
|
7
|
+
interface Document {
|
|
8
|
+
_doc: any;
|
|
9
|
+
}
|
|
10
|
+
interface TablesDB {
|
|
11
|
+
_tdb: any;
|
|
12
|
+
}
|
|
13
|
+
interface Table {
|
|
14
|
+
_tbl: any;
|
|
15
|
+
}
|
|
16
|
+
interface Row {
|
|
17
|
+
_row: any;
|
|
18
|
+
}
|
|
19
|
+
interface Bucket {
|
|
20
|
+
_bkt: any;
|
|
21
|
+
}
|
|
22
|
+
interface File {
|
|
23
|
+
_file: any;
|
|
24
|
+
}
|
|
25
|
+
interface Func {
|
|
26
|
+
_fn: any;
|
|
27
|
+
}
|
|
28
|
+
interface Execution {
|
|
29
|
+
_exec: any;
|
|
30
|
+
}
|
|
31
|
+
interface Team {
|
|
32
|
+
_team: any;
|
|
33
|
+
}
|
|
34
|
+
interface Membership {
|
|
35
|
+
_mem: any;
|
|
36
|
+
}
|
|
37
|
+
interface Resolved {
|
|
38
|
+
_res: any;
|
|
39
|
+
}
|
|
40
|
+
declare type Actionable = Document | Row | File | Execution | Team | Membership;
|
|
41
|
+
export declare class Channel<T> {
|
|
42
|
+
private readonly segments;
|
|
43
|
+
_type: T;
|
|
44
|
+
private constructor();
|
|
45
|
+
private next;
|
|
46
|
+
private resolve;
|
|
47
|
+
toString(): string;
|
|
48
|
+
collection(this: Channel<Database>, id?: string): Channel<Collection>;
|
|
49
|
+
document(this: Channel<Collection>, id?: string): Channel<Document>;
|
|
50
|
+
table(this: Channel<TablesDB>, id?: string): Channel<Table>;
|
|
51
|
+
row(this: Channel<Table>, id?: string): Channel<Row>;
|
|
52
|
+
file(this: Channel<Bucket>, id?: string): Channel<File>;
|
|
53
|
+
execution(this: Channel<Func>, id?: string): Channel<Execution>;
|
|
54
|
+
create(this: Channel<Actionable>): Channel<Resolved>;
|
|
55
|
+
update(this: Channel<Actionable>): Channel<Resolved>;
|
|
56
|
+
delete(this: Channel<Actionable>): Channel<Resolved>;
|
|
57
|
+
static database(id?: string): Channel<Database>;
|
|
58
|
+
static tablesdb(id?: string): Channel<TablesDB>;
|
|
59
|
+
static bucket(id?: string): Channel<Bucket>;
|
|
60
|
+
static function(id?: string): Channel<Func>;
|
|
61
|
+
static team(id?: string): Channel<Team>;
|
|
62
|
+
static membership(id?: string): Channel<Membership>;
|
|
63
|
+
static account(userId?: string): string;
|
|
64
|
+
static get documents(): string;
|
|
65
|
+
static get rows(): string;
|
|
66
|
+
static get files(): string;
|
|
67
|
+
static get executions(): string;
|
|
68
|
+
}
|
|
69
|
+
export declare type ActionableChannel = Channel<Document> | Channel<Row> | Channel<File> | Channel<Execution> | Channel<Team> | Channel<Membership>;
|
|
70
|
+
export declare type ResolvedChannel = Channel<Resolved>;
|
|
71
|
+
export {};
|
package/types/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Models } from './models';
|
|
2
|
+
import { Channel, ActionableChannel, ResolvedChannel } from './channel';
|
|
2
3
|
/**
|
|
3
4
|
* Payload type representing a key-value pair with string keys and any values.
|
|
4
5
|
*/
|
|
@@ -208,8 +209,8 @@ declare class Client {
|
|
|
208
209
|
* @deprecated Use the Realtime service instead.
|
|
209
210
|
* @see Realtime
|
|
210
211
|
*
|
|
211
|
-
* @param {string|string[]} channels
|
|
212
|
-
* Channel to subscribe - pass a single channel as a string or multiple with an array
|
|
212
|
+
* @param {string|string[]|Channel<any>|ActionableChannel|ResolvedChannel|(Channel<any>|ActionableChannel|ResolvedChannel)[]} channels
|
|
213
|
+
* Channel to subscribe - pass a single channel as a string or Channel builder instance, or multiple with an array.
|
|
213
214
|
*
|
|
214
215
|
* Possible channels are:
|
|
215
216
|
* - account
|
|
@@ -227,10 +228,17 @@ declare class Client {
|
|
|
227
228
|
* - teams.[ID]
|
|
228
229
|
* - memberships
|
|
229
230
|
* - memberships.[ID]
|
|
231
|
+
*
|
|
232
|
+
* You can also use Channel builders:
|
|
233
|
+
* - Channel.database('db').collection('col').document('doc').create()
|
|
234
|
+
* - Channel.bucket('bucket').file('file').update()
|
|
235
|
+
* - Channel.function('func').execution('exec').delete()
|
|
236
|
+
* - Channel.team('team').create()
|
|
237
|
+
* - Channel.membership('membership').update()
|
|
230
238
|
* @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update.
|
|
231
239
|
* @returns {() => void} Unsubscribes from events.
|
|
232
240
|
*/
|
|
233
|
-
subscribe<T extends unknown>(channels: string | string[], callback: (payload: RealtimeResponseEvent<T>) => void): () => void;
|
|
241
|
+
subscribe<T extends unknown>(channels: string | string[] | Channel<any> | ActionableChannel | ResolvedChannel | (Channel<any> | ActionableChannel | ResolvedChannel)[], callback: (payload: RealtimeResponseEvent<T>) => void): () => void;
|
|
234
242
|
prepareRequest(method: string, url: URL, headers?: Headers, params?: Payload): {
|
|
235
243
|
uri: string;
|
|
236
244
|
options: RequestInit;
|
package/types/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export type { QueryTypes, QueryTypesList } from './query';
|
|
|
36
36
|
export { Permission } from './permission';
|
|
37
37
|
export { Role } from './role';
|
|
38
38
|
export { ID } from './id';
|
|
39
|
+
export { Channel } from './channel';
|
|
39
40
|
export { Operator, Condition } from './operator';
|
|
40
41
|
export { AuthenticatorType } from './enums/authenticator-type';
|
|
41
42
|
export { AuthenticationFactor } from './enums/authentication-factor';
|
package/types/query.d.ts
CHANGED
|
@@ -39,6 +39,14 @@ export declare class Query {
|
|
|
39
39
|
* @returns {string}
|
|
40
40
|
*/
|
|
41
41
|
static notEqual: (attribute: string, value: QueryTypes) => string;
|
|
42
|
+
/**
|
|
43
|
+
* Filter resources where attribute matches a regular expression pattern.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} attribute The attribute to filter on.
|
|
46
|
+
* @param {string} pattern The regular expression pattern to match.
|
|
47
|
+
* @returns {string}
|
|
48
|
+
*/
|
|
49
|
+
static regex: (attribute: string, pattern: string) => string;
|
|
42
50
|
/**
|
|
43
51
|
* Filter resources where attribute is less than value.
|
|
44
52
|
*
|
|
@@ -85,6 +93,20 @@ export declare class Query {
|
|
|
85
93
|
* @returns {string}
|
|
86
94
|
*/
|
|
87
95
|
static isNotNull: (attribute: string) => string;
|
|
96
|
+
/**
|
|
97
|
+
* Filter resources where the specified attributes exist.
|
|
98
|
+
*
|
|
99
|
+
* @param {string[]} attributes The list of attributes that must exist.
|
|
100
|
+
* @returns {string}
|
|
101
|
+
*/
|
|
102
|
+
static exists: (attributes: string[]) => string;
|
|
103
|
+
/**
|
|
104
|
+
* Filter resources where the specified attributes do not exist.
|
|
105
|
+
*
|
|
106
|
+
* @param {string[]} attributes The list of attributes that must not exist.
|
|
107
|
+
* @returns {string}
|
|
108
|
+
*/
|
|
109
|
+
static notExists: (attributes: string[]) => string;
|
|
88
110
|
/**
|
|
89
111
|
* Filter resources where attribute is between start and end (inclusive).
|
|
90
112
|
*
|
|
@@ -282,6 +304,14 @@ export declare class Query {
|
|
|
282
304
|
* @returns {string}
|
|
283
305
|
*/
|
|
284
306
|
static and: (queries: string[]) => string;
|
|
307
|
+
/**
|
|
308
|
+
* Filter array elements where at least one element matches all the specified queries.
|
|
309
|
+
*
|
|
310
|
+
* @param {string} attribute The attribute containing the array to filter on.
|
|
311
|
+
* @param {string[]} queries The list of query strings to match against array elements.
|
|
312
|
+
* @returns {string}
|
|
313
|
+
*/
|
|
314
|
+
static elemMatch: (attribute: string, queries: string[]) => string;
|
|
285
315
|
/**
|
|
286
316
|
* Filter resources where attribute is at a specific distance from the given coordinates.
|
|
287
317
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Client } from '../client';
|
|
2
|
+
import { Channel, ActionableChannel, ResolvedChannel } from '../channel';
|
|
2
3
|
export declare type RealtimeSubscription = {
|
|
3
4
|
close: () => Promise<void>;
|
|
4
5
|
};
|
|
@@ -78,38 +79,46 @@ export declare class Realtime {
|
|
|
78
79
|
private closeSocket;
|
|
79
80
|
private getTimeout;
|
|
80
81
|
private sleep;
|
|
82
|
+
/**
|
|
83
|
+
* Convert a channel value to a string
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel value (string or Channel builder instance)
|
|
87
|
+
* @returns {string} Channel string representation
|
|
88
|
+
*/
|
|
89
|
+
private channelToString;
|
|
81
90
|
/**
|
|
82
91
|
* Subscribe to a single channel
|
|
83
92
|
*
|
|
84
|
-
* @param {string} channel - Channel name to subscribe to
|
|
93
|
+
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel name to subscribe to (string or Channel builder instance)
|
|
85
94
|
* @param {Function} callback - Callback function to handle events
|
|
86
95
|
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
87
96
|
*/
|
|
88
|
-
subscribe(channel: string, callback: (event: RealtimeResponseEvent<any>) => void): Promise<RealtimeSubscription>;
|
|
97
|
+
subscribe(channel: string | Channel<any> | ActionableChannel | ResolvedChannel, callback: (event: RealtimeResponseEvent<any>) => void): Promise<RealtimeSubscription>;
|
|
89
98
|
/**
|
|
90
99
|
* Subscribe to multiple channels
|
|
91
100
|
*
|
|
92
|
-
* @param {string[]} channels - Array of channel names to subscribe to
|
|
101
|
+
* @param {(string | Channel<any> | ActionableChannel | ResolvedChannel)[]} channels - Array of channel names to subscribe to (strings or Channel builder instances)
|
|
93
102
|
* @param {Function} callback - Callback function to handle events
|
|
94
103
|
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
95
104
|
*/
|
|
96
|
-
subscribe(channels: string[], callback: (event: RealtimeResponseEvent<any>) => void): Promise<RealtimeSubscription>;
|
|
105
|
+
subscribe(channels: (string | Channel<any> | ActionableChannel | ResolvedChannel)[], callback: (event: RealtimeResponseEvent<any>) => void): Promise<RealtimeSubscription>;
|
|
97
106
|
/**
|
|
98
107
|
* Subscribe to a single channel with typed payload
|
|
99
108
|
*
|
|
100
|
-
* @param {string} channel - Channel name to subscribe to
|
|
109
|
+
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel name to subscribe to (string or Channel builder instance)
|
|
101
110
|
* @param {Function} callback - Callback function to handle events with typed payload
|
|
102
111
|
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
103
112
|
*/
|
|
104
|
-
subscribe<T>(channel: string, callback: (event: RealtimeResponseEvent<T>) => void): Promise<RealtimeSubscription>;
|
|
113
|
+
subscribe<T>(channel: string | Channel<any> | ActionableChannel | ResolvedChannel, callback: (event: RealtimeResponseEvent<T>) => void): Promise<RealtimeSubscription>;
|
|
105
114
|
/**
|
|
106
115
|
* Subscribe to multiple channels with typed payload
|
|
107
116
|
*
|
|
108
|
-
* @param {string[]} channels - Array of channel names to subscribe to
|
|
117
|
+
* @param {(string | Channel<any> | ActionableChannel | ResolvedChannel)[]} channels - Array of channel names to subscribe to (strings or Channel builder instances)
|
|
109
118
|
* @param {Function} callback - Callback function to handle events with typed payload
|
|
110
119
|
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
111
120
|
*/
|
|
112
|
-
subscribe<T>(channels: string[], callback: (event: RealtimeResponseEvent<T>) => void): Promise<RealtimeSubscription>;
|
|
121
|
+
subscribe<T>(channels: (string | Channel<any> | ActionableChannel | ResolvedChannel)[], callback: (event: RealtimeResponseEvent<T>) => void): Promise<RealtimeSubscription>;
|
|
113
122
|
private cleanUp;
|
|
114
123
|
private handleMessage;
|
|
115
124
|
private handleResponseConnected;
|