@e-techsolutions/e-baas-sdk 1.0.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 +235 -0
- package/dist/index.d.ts +622 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +81 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
import { HttpClient as HttpClient$1, EBaaSError as EBaaSError$1 } from 'infra';
|
|
2
|
+
import { SelectOptions as SelectOptions$1, InsertOptions as InsertOptions$1, UpdateOptions as UpdateOptions$1, DeleteOptions as DeleteOptions$1 } from 'infra/types/common';
|
|
3
|
+
import { Socket } from 'socket.io-client';
|
|
4
|
+
import { EventEmitter } from 'eventemitter3';
|
|
5
|
+
import { AxiosRequestConfig } from 'axios';
|
|
6
|
+
|
|
7
|
+
interface HttpClientConfig {
|
|
8
|
+
url: string;
|
|
9
|
+
apiKey: string;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
interface ApiResponse<T = any> {
|
|
14
|
+
data: T;
|
|
15
|
+
status: number;
|
|
16
|
+
statusText: string;
|
|
17
|
+
headers: any;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class HttpClient {
|
|
21
|
+
private client;
|
|
22
|
+
private baseURL;
|
|
23
|
+
private apiKey;
|
|
24
|
+
constructor(config: HttpClientConfig);
|
|
25
|
+
private setupInterceptors;
|
|
26
|
+
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
27
|
+
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
28
|
+
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
29
|
+
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
30
|
+
delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
31
|
+
setAuthToken(token: string): void;
|
|
32
|
+
removeAuthToken(): void;
|
|
33
|
+
private handleError;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare class EBaaSError extends Error {
|
|
37
|
+
readonly status: number;
|
|
38
|
+
readonly details?: any;
|
|
39
|
+
constructor(message: string, status?: number, details?: any);
|
|
40
|
+
toJSON(): {
|
|
41
|
+
name: string;
|
|
42
|
+
message: string;
|
|
43
|
+
status: number;
|
|
44
|
+
details: any;
|
|
45
|
+
stack: string | undefined;
|
|
46
|
+
};
|
|
47
|
+
toString(): string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface EBaaSClientOptions {
|
|
51
|
+
supabaseUrl: string;
|
|
52
|
+
supabaseKey: string;
|
|
53
|
+
options?: {
|
|
54
|
+
auth?: {
|
|
55
|
+
autoRefreshToken?: boolean;
|
|
56
|
+
persistSession?: boolean;
|
|
57
|
+
detectSessionInUrl?: boolean;
|
|
58
|
+
};
|
|
59
|
+
realtime?: {
|
|
60
|
+
params?: Record<string, string>;
|
|
61
|
+
};
|
|
62
|
+
global?: {
|
|
63
|
+
headers?: Record<string, string>;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
interface DatabaseFilters {
|
|
68
|
+
eq?: any;
|
|
69
|
+
neq?: any;
|
|
70
|
+
gt?: any;
|
|
71
|
+
gte?: any;
|
|
72
|
+
lt?: any;
|
|
73
|
+
lte?: any;
|
|
74
|
+
like?: string;
|
|
75
|
+
ilike?: string;
|
|
76
|
+
is?: any;
|
|
77
|
+
in?: any[];
|
|
78
|
+
contains?: any;
|
|
79
|
+
contained_by?: any;
|
|
80
|
+
range_gt?: any;
|
|
81
|
+
range_gte?: any;
|
|
82
|
+
range_lt?: any;
|
|
83
|
+
range_lte?: any;
|
|
84
|
+
range_adjacent?: any;
|
|
85
|
+
overlaps?: any;
|
|
86
|
+
text_search?: string;
|
|
87
|
+
match?: Record<string, any>;
|
|
88
|
+
}
|
|
89
|
+
interface QueryOptions {
|
|
90
|
+
count?: 'exact' | 'planned' | 'estimated';
|
|
91
|
+
head?: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface SelectOptions extends QueryOptions {
|
|
94
|
+
columns?: string;
|
|
95
|
+
}
|
|
96
|
+
interface InsertOptions extends QueryOptions {
|
|
97
|
+
returning?: 'minimal' | 'representation';
|
|
98
|
+
upsert?: boolean;
|
|
99
|
+
onConflict?: string;
|
|
100
|
+
}
|
|
101
|
+
interface UpdateOptions extends QueryOptions {
|
|
102
|
+
returning?: 'minimal' | 'representation';
|
|
103
|
+
}
|
|
104
|
+
interface DeleteOptions extends QueryOptions {
|
|
105
|
+
returning?: 'minimal' | 'representation';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface AuthUser {
|
|
109
|
+
id: string;
|
|
110
|
+
email: string;
|
|
111
|
+
phone?: string;
|
|
112
|
+
name?: string;
|
|
113
|
+
avatar_url?: string;
|
|
114
|
+
created_at: string;
|
|
115
|
+
updated_at: string;
|
|
116
|
+
email_verified: boolean;
|
|
117
|
+
phone_verified: boolean;
|
|
118
|
+
app_metadata?: Record<string, any>;
|
|
119
|
+
user_metadata?: Record<string, any>;
|
|
120
|
+
}
|
|
121
|
+
interface AuthSession {
|
|
122
|
+
access_token: string;
|
|
123
|
+
refresh_token: string;
|
|
124
|
+
expires_in: number;
|
|
125
|
+
expires_at: number;
|
|
126
|
+
token_type: string;
|
|
127
|
+
user: AuthUser;
|
|
128
|
+
}
|
|
129
|
+
interface AuthResponse {
|
|
130
|
+
user?: AuthUser;
|
|
131
|
+
session?: AuthSession;
|
|
132
|
+
error?: string;
|
|
133
|
+
}
|
|
134
|
+
interface SignUpData {
|
|
135
|
+
email: string;
|
|
136
|
+
password: string;
|
|
137
|
+
name?: string;
|
|
138
|
+
phone?: string;
|
|
139
|
+
data?: Record<string, any>;
|
|
140
|
+
}
|
|
141
|
+
interface SignInData {
|
|
142
|
+
email: string;
|
|
143
|
+
password: string;
|
|
144
|
+
}
|
|
145
|
+
interface OAuthProvider {
|
|
146
|
+
provider: 'google' | 'github' | 'facebook';
|
|
147
|
+
redirectTo?: string;
|
|
148
|
+
scopes?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare class AuthClient {
|
|
152
|
+
private httpClient;
|
|
153
|
+
private currentSession;
|
|
154
|
+
constructor(httpClient: HttpClient$1);
|
|
155
|
+
signUp(data: SignUpData): Promise<AuthResponse>;
|
|
156
|
+
signIn(data: SignInData): Promise<AuthResponse>;
|
|
157
|
+
signOut(): Promise<void>;
|
|
158
|
+
getUser(): Promise<AuthUser | null>;
|
|
159
|
+
refreshSession(): Promise<AuthSession | null>;
|
|
160
|
+
resetPassword(email: string): Promise<void>;
|
|
161
|
+
updateUser(data: Partial<AuthUser>): Promise<AuthUser>;
|
|
162
|
+
getSession(): AuthSession | null;
|
|
163
|
+
onAuthStateChange(callback: (event: string, session: AuthSession | null) => void): () => void;
|
|
164
|
+
private setSession;
|
|
165
|
+
private clearSession;
|
|
166
|
+
private loadSession;
|
|
167
|
+
private handleAuthError;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare class QueryBuilder<T = any> {
|
|
171
|
+
private httpClient;
|
|
172
|
+
private table;
|
|
173
|
+
private query;
|
|
174
|
+
constructor(httpClient: HttpClient$1, table: string);
|
|
175
|
+
select(columns?: string, options?: SelectOptions$1): this;
|
|
176
|
+
insert(data: Partial<T> | Partial<T>[], options?: InsertOptions$1): Promise<{
|
|
177
|
+
data: T[] | null;
|
|
178
|
+
error: EBaaSError$1 | null;
|
|
179
|
+
}>;
|
|
180
|
+
update(data: Partial<T>, options?: UpdateOptions$1): Promise<{
|
|
181
|
+
data: T[] | null;
|
|
182
|
+
error: EBaaSError$1 | null;
|
|
183
|
+
}>;
|
|
184
|
+
upsert(data: Partial<T> | Partial<T>[], options?: InsertOptions$1): Promise<{
|
|
185
|
+
data: T[] | null;
|
|
186
|
+
error: EBaaSError$1 | null;
|
|
187
|
+
}>;
|
|
188
|
+
delete(options?: DeleteOptions$1): Promise<{
|
|
189
|
+
data: T[] | null;
|
|
190
|
+
error: EBaaSError$1 | null;
|
|
191
|
+
}>;
|
|
192
|
+
eq(column: string, value: any): this;
|
|
193
|
+
neq(column: string, value: any): this;
|
|
194
|
+
gt(column: string, value: any): this;
|
|
195
|
+
gte(column: string, value: any): this;
|
|
196
|
+
lt(column: string, value: any): this;
|
|
197
|
+
lte(column: string, value: any): this;
|
|
198
|
+
like(column: string, pattern: string): this;
|
|
199
|
+
ilike(column: string, pattern: string): this;
|
|
200
|
+
is(column: string, value: any): this;
|
|
201
|
+
in(column: string, values: any[]): this;
|
|
202
|
+
contains(column: string, value: any): this;
|
|
203
|
+
match(query: Record<string, any>): this;
|
|
204
|
+
order(column: string, options?: {
|
|
205
|
+
ascending?: boolean;
|
|
206
|
+
}): this;
|
|
207
|
+
limit(count: number): this;
|
|
208
|
+
range(from: number, to: number): this;
|
|
209
|
+
execute(): Promise<{
|
|
210
|
+
data: T[] | null;
|
|
211
|
+
error: EBaaSError$1 | null;
|
|
212
|
+
count?: number;
|
|
213
|
+
}>;
|
|
214
|
+
single(): Promise<{
|
|
215
|
+
data: T | null;
|
|
216
|
+
error: EBaaSError$1 | null;
|
|
217
|
+
}>;
|
|
218
|
+
private executeQuery;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare class DatabaseClient {
|
|
222
|
+
private httpClient;
|
|
223
|
+
constructor(httpClient: HttpClient$1);
|
|
224
|
+
from(table: string): QueryBuilder;
|
|
225
|
+
rpc(fn: string, args?: Record<string, any>): Promise<any>;
|
|
226
|
+
schema(schema: string): DatabaseClient;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
interface StorageFile {
|
|
230
|
+
id: string;
|
|
231
|
+
name: string;
|
|
232
|
+
bucket_id: string;
|
|
233
|
+
path: string;
|
|
234
|
+
size: number;
|
|
235
|
+
mimetype: string;
|
|
236
|
+
etag: string;
|
|
237
|
+
created_at: string;
|
|
238
|
+
updated_at: string;
|
|
239
|
+
last_accessed_at?: string;
|
|
240
|
+
metadata?: Record<string, any>;
|
|
241
|
+
cache_control?: string;
|
|
242
|
+
content_encoding?: string;
|
|
243
|
+
content_disposition?: string;
|
|
244
|
+
content_language?: string;
|
|
245
|
+
}
|
|
246
|
+
interface Bucket {
|
|
247
|
+
id: string;
|
|
248
|
+
name: string;
|
|
249
|
+
owner: string;
|
|
250
|
+
public: boolean;
|
|
251
|
+
created_at: string;
|
|
252
|
+
updated_at: string;
|
|
253
|
+
allowed_mime_types?: string[];
|
|
254
|
+
file_size_limit?: number;
|
|
255
|
+
versioning_enabled?: boolean;
|
|
256
|
+
}
|
|
257
|
+
interface BucketOptions {
|
|
258
|
+
public?: boolean;
|
|
259
|
+
allowedMimeTypes?: string[];
|
|
260
|
+
fileSizeLimit?: number;
|
|
261
|
+
versioningEnabled?: boolean;
|
|
262
|
+
}
|
|
263
|
+
interface StorageUploadOptions {
|
|
264
|
+
cacheControl?: string;
|
|
265
|
+
contentType?: string;
|
|
266
|
+
upsert?: boolean;
|
|
267
|
+
metadata?: Record<string, any>;
|
|
268
|
+
duplex?: 'half';
|
|
269
|
+
}
|
|
270
|
+
interface StorageDownloadOptions {
|
|
271
|
+
transform?: {
|
|
272
|
+
width?: number;
|
|
273
|
+
height?: number;
|
|
274
|
+
resize?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside';
|
|
275
|
+
format?: 'jpeg' | 'png' | 'webp' | 'avif';
|
|
276
|
+
quality?: number;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
interface StorageListOptions {
|
|
280
|
+
limit?: number;
|
|
281
|
+
offset?: number;
|
|
282
|
+
sortBy?: {
|
|
283
|
+
column: 'name' | 'updated_at' | 'created_at' | 'last_accessed_at';
|
|
284
|
+
order: 'asc' | 'desc';
|
|
285
|
+
};
|
|
286
|
+
search?: string;
|
|
287
|
+
}
|
|
288
|
+
interface StorageSignedUrlOptions {
|
|
289
|
+
download?: boolean;
|
|
290
|
+
transform?: {
|
|
291
|
+
width?: number;
|
|
292
|
+
height?: number;
|
|
293
|
+
resize?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside';
|
|
294
|
+
format?: 'jpeg' | 'png' | 'webp' | 'avif';
|
|
295
|
+
quality?: number;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
interface FileUploadResponse {
|
|
299
|
+
id: string;
|
|
300
|
+
path: string;
|
|
301
|
+
fullPath: string;
|
|
302
|
+
key: string;
|
|
303
|
+
}
|
|
304
|
+
interface FileListResponse {
|
|
305
|
+
files: StorageFile[];
|
|
306
|
+
count: number;
|
|
307
|
+
hasMore: boolean;
|
|
308
|
+
}
|
|
309
|
+
interface SignedUrlResponse {
|
|
310
|
+
data: {
|
|
311
|
+
signedUrl: string;
|
|
312
|
+
path: string;
|
|
313
|
+
token: string;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
interface PublicUrlResponse {
|
|
317
|
+
data: {
|
|
318
|
+
publicUrl: string;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
interface StorageUsage {
|
|
322
|
+
total_size: number;
|
|
323
|
+
file_count: number;
|
|
324
|
+
bucket_count: number;
|
|
325
|
+
quota_used_percentage: number;
|
|
326
|
+
quota_limit?: number;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
declare class StorageBucket {
|
|
330
|
+
private httpClient;
|
|
331
|
+
private bucketId;
|
|
332
|
+
constructor(httpClient: HttpClient$1, bucketId: string);
|
|
333
|
+
upload(path: string, file: File | Blob | ArrayBuffer | string, options?: StorageUploadOptions): Promise<{
|
|
334
|
+
data: FileUploadResponse | null;
|
|
335
|
+
error: EBaaSError$1 | null;
|
|
336
|
+
}>;
|
|
337
|
+
download(path: string, options?: StorageDownloadOptions): Promise<{
|
|
338
|
+
data: Blob | null;
|
|
339
|
+
error: EBaaSError$1 | null;
|
|
340
|
+
}>;
|
|
341
|
+
list(prefix?: string, options?: StorageListOptions): Promise<{
|
|
342
|
+
data: FileListResponse | null;
|
|
343
|
+
error: EBaaSError$1 | null;
|
|
344
|
+
}>;
|
|
345
|
+
remove(paths: string[]): Promise<{
|
|
346
|
+
data: {
|
|
347
|
+
message: string;
|
|
348
|
+
} | null;
|
|
349
|
+
error: EBaaSError$1 | null;
|
|
350
|
+
}>;
|
|
351
|
+
move(fromPath: string, toPath: string): Promise<{
|
|
352
|
+
data: {
|
|
353
|
+
message: string;
|
|
354
|
+
} | null;
|
|
355
|
+
error: EBaaSError$1 | null;
|
|
356
|
+
}>;
|
|
357
|
+
copy(fromPath: string, toPath: string): Promise<{
|
|
358
|
+
data: {
|
|
359
|
+
message: string;
|
|
360
|
+
} | null;
|
|
361
|
+
error: EBaaSError$1 | null;
|
|
362
|
+
}>;
|
|
363
|
+
createSignedUrl(path: string, expiresIn: number, options?: StorageSignedUrlOptions): Promise<{
|
|
364
|
+
data: SignedUrlResponse | null;
|
|
365
|
+
error: EBaaSError$1 | null;
|
|
366
|
+
}>;
|
|
367
|
+
getPublicUrl(path: string, options?: {
|
|
368
|
+
transform?: Record<string, any>;
|
|
369
|
+
}): PublicUrlResponse;
|
|
370
|
+
getFileInfo(path: string): Promise<{
|
|
371
|
+
data: StorageFile | null;
|
|
372
|
+
error: EBaaSError$1 | null;
|
|
373
|
+
}>;
|
|
374
|
+
updateFileMetadata(path: string, metadata: Record<string, any>): Promise<{
|
|
375
|
+
data: StorageFile | null;
|
|
376
|
+
error: EBaaSError$1 | null;
|
|
377
|
+
}>;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
declare class StorageClient {
|
|
381
|
+
private httpClient;
|
|
382
|
+
constructor(httpClient: HttpClient$1);
|
|
383
|
+
from(bucketId: string): StorageBucket;
|
|
384
|
+
createBucket(id: string, options?: BucketOptions): Promise<{
|
|
385
|
+
data: Bucket | null;
|
|
386
|
+
error: EBaaSError$1 | null;
|
|
387
|
+
}>;
|
|
388
|
+
getBucket(id: string): Promise<{
|
|
389
|
+
data: Bucket | null;
|
|
390
|
+
error: EBaaSError$1 | null;
|
|
391
|
+
}>;
|
|
392
|
+
listBuckets(): Promise<{
|
|
393
|
+
data: Bucket[] | null;
|
|
394
|
+
error: EBaaSError$1 | null;
|
|
395
|
+
}>;
|
|
396
|
+
updateBucket(id: string, options: Partial<BucketOptions>): Promise<{
|
|
397
|
+
data: Bucket | null;
|
|
398
|
+
error: EBaaSError$1 | null;
|
|
399
|
+
}>;
|
|
400
|
+
deleteBucket(id: string): Promise<{
|
|
401
|
+
data: {
|
|
402
|
+
message: string;
|
|
403
|
+
} | null;
|
|
404
|
+
error: EBaaSError$1 | null;
|
|
405
|
+
}>;
|
|
406
|
+
getUsage(): Promise<{
|
|
407
|
+
data: StorageUsage | null;
|
|
408
|
+
error: EBaaSError$1 | null;
|
|
409
|
+
}>;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
interface RealtimeEvent {
|
|
413
|
+
schema: string;
|
|
414
|
+
table: string;
|
|
415
|
+
commit_timestamp: string;
|
|
416
|
+
eventType: 'INSERT' | 'UPDATE' | 'DELETE';
|
|
417
|
+
new?: Record<string, any>;
|
|
418
|
+
old?: Record<string, any>;
|
|
419
|
+
errors?: string[];
|
|
420
|
+
}
|
|
421
|
+
interface ChannelSubscription {
|
|
422
|
+
unsubscribe: () => void;
|
|
423
|
+
}
|
|
424
|
+
interface PresenceState {
|
|
425
|
+
[key: string]: {
|
|
426
|
+
metas: Array<{
|
|
427
|
+
[key: string]: any;
|
|
428
|
+
phx_ref: string;
|
|
429
|
+
phx_ref_prev?: string;
|
|
430
|
+
}>;
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
interface PostgresChangesFilter {
|
|
434
|
+
event: '*' | 'INSERT' | 'UPDATE' | 'DELETE';
|
|
435
|
+
schema: string;
|
|
436
|
+
table?: string;
|
|
437
|
+
filter?: string;
|
|
438
|
+
}
|
|
439
|
+
interface BroadcastFilter {
|
|
440
|
+
event: string;
|
|
441
|
+
}
|
|
442
|
+
interface PresenceFilter {
|
|
443
|
+
event: 'sync' | 'join' | 'leave';
|
|
444
|
+
}
|
|
445
|
+
type ChannelState = 'closed' | 'errored' | 'joined' | 'joining' | 'leaving';
|
|
446
|
+
type RealtimeConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
447
|
+
interface RealtimeClientOptions {
|
|
448
|
+
heartbeatInterval?: number;
|
|
449
|
+
reconnectInterval?: number;
|
|
450
|
+
maxReconnectAttempts?: number;
|
|
451
|
+
socketOptions?: {
|
|
452
|
+
[key: string]: any;
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
declare class RealtimeChannel extends EventEmitter {
|
|
457
|
+
topic: string;
|
|
458
|
+
private socket;
|
|
459
|
+
private joinedOnce;
|
|
460
|
+
private state;
|
|
461
|
+
private subscriptions;
|
|
462
|
+
constructor(topic: string, socket: Socket | null);
|
|
463
|
+
subscribe(callback?: (status: 'SUBSCRIBED' | 'CHANNEL_ERROR' | 'TIMED_OUT' | 'CLOSED') => void): RealtimeChannel;
|
|
464
|
+
onPostgresChanges(filter: PostgresChangesFilter, callback: (payload: RealtimeEvent) => void): ChannelSubscription;
|
|
465
|
+
onBroadcast(filter: BroadcastFilter, callback: (payload: any) => void): ChannelSubscription;
|
|
466
|
+
onPresence(filter: PresenceFilter, callback: (payload: PresenceState) => void): ChannelSubscription;
|
|
467
|
+
send(payload: {
|
|
468
|
+
type: 'broadcast';
|
|
469
|
+
event: string;
|
|
470
|
+
[key: string]: any;
|
|
471
|
+
}): Promise<'ok' | 'error' | 'timeout'>;
|
|
472
|
+
track(payload: Record<string, any>): Promise<'ok' | 'error' | 'timeout'>;
|
|
473
|
+
untrack(): Promise<'ok' | 'error' | 'timeout'>;
|
|
474
|
+
unsubscribe(): Promise<'ok' | 'error' | 'timeout'>;
|
|
475
|
+
_join(): void;
|
|
476
|
+
_rejoin(): void;
|
|
477
|
+
_trigger(event: string, payload: any): void;
|
|
478
|
+
_setState(state: ChannelState): void;
|
|
479
|
+
private makeRef;
|
|
480
|
+
getState(): ChannelState;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
declare class RealtimeClient {
|
|
484
|
+
private socket;
|
|
485
|
+
private url;
|
|
486
|
+
private apiKey;
|
|
487
|
+
private options;
|
|
488
|
+
private channels;
|
|
489
|
+
private connectionState;
|
|
490
|
+
private reconnectAttempts;
|
|
491
|
+
private maxReconnectAttempts;
|
|
492
|
+
constructor(url: string, apiKey: string, options?: RealtimeClientOptions);
|
|
493
|
+
connect(): Promise<void>;
|
|
494
|
+
disconnect(): void;
|
|
495
|
+
channel(topic: string): RealtimeChannel;
|
|
496
|
+
removeChannel(channel: RealtimeChannel): void;
|
|
497
|
+
removeAllChannels(): void;
|
|
498
|
+
getChannels(): RealtimeChannel[];
|
|
499
|
+
isConnected(): boolean;
|
|
500
|
+
getConnectionState(): RealtimeConnectionState;
|
|
501
|
+
onConnectionStateChange(callback: (state: RealtimeConnectionState) => void): () => void;
|
|
502
|
+
private setupHeartbeat;
|
|
503
|
+
_getSocket(): Socket | null;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
interface FunctionInvokeOptions {
|
|
507
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
508
|
+
headers?: Record<string, string>;
|
|
509
|
+
body?: any;
|
|
510
|
+
region?: string;
|
|
511
|
+
}
|
|
512
|
+
interface FunctionResponse<T = any> {
|
|
513
|
+
data: T;
|
|
514
|
+
error?: string;
|
|
515
|
+
}
|
|
516
|
+
interface EdgeFunction {
|
|
517
|
+
id: string;
|
|
518
|
+
name: string;
|
|
519
|
+
slug: string;
|
|
520
|
+
status: 'active' | 'inactive' | 'deploying' | 'failed';
|
|
521
|
+
version: number;
|
|
522
|
+
created_at: string;
|
|
523
|
+
updated_at: string;
|
|
524
|
+
entrypoint?: string;
|
|
525
|
+
env?: Record<string, string>;
|
|
526
|
+
import_map?: Record<string, any>;
|
|
527
|
+
verify_jwt?: boolean;
|
|
528
|
+
execution_stats?: {
|
|
529
|
+
total_executions: number;
|
|
530
|
+
total_errors: number;
|
|
531
|
+
avg_execution_time: number;
|
|
532
|
+
last_execution: string;
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
interface FunctionListResponse {
|
|
536
|
+
functions: EdgeFunction[];
|
|
537
|
+
count: number;
|
|
538
|
+
}
|
|
539
|
+
interface FunctionDeployOptions {
|
|
540
|
+
code: string | File;
|
|
541
|
+
entrypoint?: string;
|
|
542
|
+
env?: Record<string, string>;
|
|
543
|
+
importMap?: Record<string, any>;
|
|
544
|
+
verify?: boolean;
|
|
545
|
+
}
|
|
546
|
+
interface FunctionDeployResponse {
|
|
547
|
+
id: string;
|
|
548
|
+
name: string;
|
|
549
|
+
version: number;
|
|
550
|
+
status: 'deploying' | 'active' | 'failed';
|
|
551
|
+
deployment_id: string;
|
|
552
|
+
created_at: string;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
declare class FunctionsClient {
|
|
556
|
+
private httpClient;
|
|
557
|
+
constructor(httpClient: HttpClient$1);
|
|
558
|
+
invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<{
|
|
559
|
+
data: T | null;
|
|
560
|
+
error: EBaaSError$1 | null;
|
|
561
|
+
}>;
|
|
562
|
+
list(): Promise<{
|
|
563
|
+
data: FunctionListResponse | null;
|
|
564
|
+
error: EBaaSError$1 | null;
|
|
565
|
+
}>;
|
|
566
|
+
get(functionName: string): Promise<{
|
|
567
|
+
data: EdgeFunction | null;
|
|
568
|
+
error: EBaaSError$1 | null;
|
|
569
|
+
}>;
|
|
570
|
+
deploy(functionName: string, options: FunctionDeployOptions): Promise<{
|
|
571
|
+
data: FunctionDeployResponse | null;
|
|
572
|
+
error: EBaaSError$1 | null;
|
|
573
|
+
}>;
|
|
574
|
+
delete(functionName: string): Promise<{
|
|
575
|
+
data: {
|
|
576
|
+
message: string;
|
|
577
|
+
} | null;
|
|
578
|
+
error: EBaaSError$1 | null;
|
|
579
|
+
}>;
|
|
580
|
+
updateEnv(functionName: string, env: Record<string, string>): Promise<{
|
|
581
|
+
data: EdgeFunction | null;
|
|
582
|
+
error: EBaaSError$1 | null;
|
|
583
|
+
}>;
|
|
584
|
+
getLogs(functionName: string, options?: {
|
|
585
|
+
limit?: number;
|
|
586
|
+
offset?: number;
|
|
587
|
+
level?: 'info' | 'warn' | 'error' | 'debug';
|
|
588
|
+
}): Promise<{
|
|
589
|
+
data: any[] | null;
|
|
590
|
+
error: EBaaSError$1 | null;
|
|
591
|
+
}>;
|
|
592
|
+
getMetrics(functionName: string, options?: {
|
|
593
|
+
period?: '1h' | '24h' | '7d' | '30d';
|
|
594
|
+
}): Promise<{
|
|
595
|
+
data: any | null;
|
|
596
|
+
error: EBaaSError$1 | null;
|
|
597
|
+
}>;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
declare class EBaaSClient {
|
|
601
|
+
readonly auth: AuthClient;
|
|
602
|
+
readonly database: DatabaseClient;
|
|
603
|
+
readonly storage: StorageClient;
|
|
604
|
+
readonly realtime: RealtimeClient;
|
|
605
|
+
readonly functions: FunctionsClient;
|
|
606
|
+
private httpClient;
|
|
607
|
+
constructor(supabaseUrl: string, supabaseKey: string, options?: EBaaSClientOptions['options']);
|
|
608
|
+
from(table: string): QueryBuilder<any>;
|
|
609
|
+
rpc(fn: string, args?: Record<string, any>): Promise<any>;
|
|
610
|
+
bucket(id: string): StorageBucket;
|
|
611
|
+
channel(name: string): RealtimeChannel;
|
|
612
|
+
invoke(functionName: string, options?: any): Promise<{
|
|
613
|
+
data: any;
|
|
614
|
+
error: EBaaSError | null;
|
|
615
|
+
}>;
|
|
616
|
+
}
|
|
617
|
+
declare function createClient(supabaseUrl: string, supabaseKey: string, options?: EBaaSClientOptions['options']): EBaaSClient;
|
|
618
|
+
|
|
619
|
+
declare const version = "1.0.0";
|
|
620
|
+
|
|
621
|
+
export { AuthClient, DatabaseClient, EBaaSClient, EBaaSError, FunctionsClient, HttpClient, QueryBuilder, RealtimeChannel, RealtimeClient, StorageBucket, StorageClient, createClient, version };
|
|
622
|
+
export type { AuthResponse, AuthSession, AuthUser, BroadcastFilter, Bucket, BucketOptions, ChannelSubscription, DatabaseFilters, DeleteOptions, EBaaSClientOptions, EdgeFunction, FunctionDeployOptions, FunctionInvokeOptions, FunctionListResponse, FunctionResponse, InsertOptions, OAuthProvider, PostgresChangesFilter, PresenceFilter, PresenceState, QueryOptions, RealtimeClientOptions, RealtimeEvent, SelectOptions, SignInData, SignUpData, StorageDownloadOptions, StorageFile, StorageListOptions, StorageUploadOptions, StorageUsage, UpdateOptions };
|