appwrite-web-server-preview-isomorphic-chiragagg5k 0.0.0-rc.2
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/LICENSE +1 -0
- package/README.md +46 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/sdk.js +23912 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/sdk.js +23884 -0
- package/dist/esm/sdk.js.map +1 -0
- package/dist/iife/sdk.js +27711 -0
- package/package.json +50 -0
- package/types/channel.d.ts +74 -0
- package/types/client.d.ts +345 -0
- package/types/enums/adapter.d.ts +4 -0
- package/types/enums/attribute-status.d.ts +7 -0
- package/types/enums/authentication-factor.d.ts +6 -0
- package/types/enums/authenticator-type.d.ts +3 -0
- package/types/enums/backup-services.d.ts +8 -0
- package/types/enums/browser-permission.d.ts +22 -0
- package/types/enums/browser.d.ts +16 -0
- package/types/enums/build-runtime.d.ts +94 -0
- package/types/enums/column-status.d.ts +7 -0
- package/types/enums/compression.d.ts +5 -0
- package/types/enums/credit-card.d.ts +19 -0
- package/types/enums/database-type.d.ts +6 -0
- package/types/enums/databases-index-type.d.ts +6 -0
- package/types/enums/deployment-download-type.d.ts +4 -0
- package/types/enums/deployment-status.d.ts +8 -0
- package/types/enums/email-template-locale.d.ts +133 -0
- package/types/enums/email-template-type.d.ts +9 -0
- package/types/enums/execution-method.d.ts +9 -0
- package/types/enums/execution-status.d.ts +7 -0
- package/types/enums/execution-trigger.d.ts +5 -0
- package/types/enums/flag.d.ts +197 -0
- package/types/enums/framework.d.ts +17 -0
- package/types/enums/health-antivirus-status.d.ts +5 -0
- package/types/enums/health-check-status.d.ts +4 -0
- package/types/enums/image-format.d.ts +9 -0
- package/types/enums/image-gravity.d.ts +11 -0
- package/types/enums/index-status.d.ts +7 -0
- package/types/enums/message-priority.d.ts +4 -0
- package/types/enums/message-status.d.ts +7 -0
- package/types/enums/messaging-provider-type.d.ts +5 -0
- package/types/enums/method-id.d.ts +9 -0
- package/types/enums/name.d.ts +15 -0
- package/types/enums/o-auth-provider.d.ts +45 -0
- package/types/enums/order-by.d.ts +4 -0
- package/types/enums/password-hash.d.ts +13 -0
- package/types/enums/platform-type.d.ts +7 -0
- package/types/enums/policy-id.d.ts +11 -0
- package/types/enums/protocol-id.d.ts +5 -0
- package/types/enums/relation-mutate.d.ts +5 -0
- package/types/enums/relationship-type.d.ts +6 -0
- package/types/enums/runtime.d.ts +94 -0
- package/types/enums/scopes.d.ts +89 -0
- package/types/enums/secure.d.ts +4 -0
- package/types/enums/service-id.d.ts +19 -0
- package/types/enums/smtp-encryption.d.ts +5 -0
- package/types/enums/tables-db-index-type.d.ts +6 -0
- package/types/enums/template-reference-type.d.ts +5 -0
- package/types/enums/theme.d.ts +4 -0
- package/types/enums/timezone.d.ts +421 -0
- package/types/enums/vcs-reference-type.d.ts +5 -0
- package/types/id.d.ts +20 -0
- package/types/index.d.ts +85 -0
- package/types/models.d.ts +6555 -0
- package/types/operator.d.ts +180 -0
- package/types/permission.d.ts +43 -0
- package/types/query.d.ts +442 -0
- package/types/role.d.ts +70 -0
- package/types/service.d.ts +11 -0
- package/types/services/account.d.ts +1016 -0
- package/types/services/activities.d.ts +51 -0
- package/types/services/avatars.d.ts +327 -0
- package/types/services/backups.d.ts +282 -0
- package/types/services/databases.d.ts +2297 -0
- package/types/services/functions.d.ts +755 -0
- package/types/services/graphql.d.ts +50 -0
- package/types/services/health.d.ts +482 -0
- package/types/services/locale.d.ts +71 -0
- package/types/services/messaging.d.ts +1996 -0
- package/types/services/project.d.ts +2342 -0
- package/types/services/realtime.d.ts +155 -0
- package/types/services/sites.d.ts +714 -0
- package/types/services/storage.d.ts +428 -0
- package/types/services/tables-db.d.ts +2242 -0
- package/types/services/teams.d.ts +348 -0
- package/types/services/tokens.d.ts +124 -0
- package/types/services/users.d.ts +1191 -0
- package/types/services/webhooks.d.ts +176 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Client, type ClientAuth } from '../client';
|
|
2
|
+
import { Channel, ActionableChannel, ResolvedChannel } from '../channel';
|
|
3
|
+
import { Query } from '../query';
|
|
4
|
+
export type RealtimeSubscriptionUpdate = {
|
|
5
|
+
channels?: (string | Channel<any> | ActionableChannel | ResolvedChannel)[];
|
|
6
|
+
queries?: (string | Query)[];
|
|
7
|
+
};
|
|
8
|
+
export type RealtimeSubscription = {
|
|
9
|
+
/**
|
|
10
|
+
* Remove this subscription only. Keeps the WebSocket open so other subscriptions keep receiving events.
|
|
11
|
+
* Use `Realtime.disconnect()` to close the connection entirely.
|
|
12
|
+
*/
|
|
13
|
+
unsubscribe: () => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Replace the channels and/or queries for this subscription on the server without re-creating it.
|
|
16
|
+
*/
|
|
17
|
+
update: (changes: RealtimeSubscriptionUpdate) => Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Alias of `unsubscribe()` plus legacy auto-disconnect when this was the last active subscription.
|
|
20
|
+
* Prefer `unsubscribe()` for per-subscription teardown and `Realtime.disconnect()` for full shutdown.
|
|
21
|
+
*/
|
|
22
|
+
close: () => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
export type RealtimeCallback<T = any> = {
|
|
25
|
+
channels: Set<string>;
|
|
26
|
+
queries: string[];
|
|
27
|
+
callback: (event: RealtimeResponseEvent<T>) => void;
|
|
28
|
+
};
|
|
29
|
+
export type RealtimeResponse = {
|
|
30
|
+
type: string;
|
|
31
|
+
data?: any;
|
|
32
|
+
};
|
|
33
|
+
export type RealtimeResponseEvent<T = any> = {
|
|
34
|
+
events: string[];
|
|
35
|
+
channels: string[];
|
|
36
|
+
timestamp: string;
|
|
37
|
+
payload: T;
|
|
38
|
+
subscriptions: string[];
|
|
39
|
+
};
|
|
40
|
+
export type RealtimeResponseConnected = {
|
|
41
|
+
channels: string[];
|
|
42
|
+
user?: object;
|
|
43
|
+
};
|
|
44
|
+
export type RealtimeRequest = {
|
|
45
|
+
type: 'authentication' | 'subscribe' | 'unsubscribe';
|
|
46
|
+
data: any;
|
|
47
|
+
};
|
|
48
|
+
export declare enum RealtimeCode {
|
|
49
|
+
NORMAL_CLOSURE = 1000,
|
|
50
|
+
POLICY_VIOLATION = 1008,
|
|
51
|
+
UNKNOWN_ERROR = -1
|
|
52
|
+
}
|
|
53
|
+
export declare class Realtime {
|
|
54
|
+
private readonly TYPE_ERROR;
|
|
55
|
+
private readonly TYPE_EVENT;
|
|
56
|
+
private readonly TYPE_PONG;
|
|
57
|
+
private readonly TYPE_CONNECTED;
|
|
58
|
+
private readonly TYPE_RESPONSE;
|
|
59
|
+
private readonly DEBOUNCE_MS;
|
|
60
|
+
private readonly HEARTBEAT_INTERVAL;
|
|
61
|
+
private client;
|
|
62
|
+
private socket?;
|
|
63
|
+
private activeSubscriptions;
|
|
64
|
+
private pendingSubscribes;
|
|
65
|
+
private heartbeatTimer?;
|
|
66
|
+
private subCallDepth;
|
|
67
|
+
private reconnectAttempts;
|
|
68
|
+
private connectionId;
|
|
69
|
+
private reconnect;
|
|
70
|
+
private onErrorCallbacks;
|
|
71
|
+
private onCloseCallbacks;
|
|
72
|
+
private onOpenCallbacks;
|
|
73
|
+
constructor(client: Client<ClientAuth>);
|
|
74
|
+
/**
|
|
75
|
+
* Register a callback function to be called when an error occurs
|
|
76
|
+
*
|
|
77
|
+
* @param {Function} callback - Callback function to handle errors
|
|
78
|
+
* @returns {void}
|
|
79
|
+
*/
|
|
80
|
+
onError(callback: (error?: Error, statusCode?: number) => void): void;
|
|
81
|
+
/**
|
|
82
|
+
* Register a callback function to be called when the connection closes
|
|
83
|
+
*
|
|
84
|
+
* @param {Function} callback - Callback function to handle connection close
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
onClose(callback: () => void): void;
|
|
88
|
+
/**
|
|
89
|
+
* Register a callback function to be called when the connection opens
|
|
90
|
+
*
|
|
91
|
+
* @param {Function} callback - Callback function to handle connection open
|
|
92
|
+
* @returns {void}
|
|
93
|
+
*/
|
|
94
|
+
onOpen(callback: () => void): void;
|
|
95
|
+
private startHeartbeat;
|
|
96
|
+
private stopHeartbeat;
|
|
97
|
+
private createSocket;
|
|
98
|
+
private closeSocket;
|
|
99
|
+
private getTimeout;
|
|
100
|
+
private sleep;
|
|
101
|
+
private sendUnsubscribeMessage;
|
|
102
|
+
private generateUniqueSubscriptionId;
|
|
103
|
+
private enqueuePendingSubscribe;
|
|
104
|
+
/**
|
|
105
|
+
* Close the WebSocket connection and drop all active subscriptions client-side.
|
|
106
|
+
* Use this instead of calling `unsubscribe()` on every subscription when you want to tear everything down.
|
|
107
|
+
*/
|
|
108
|
+
disconnect(): Promise<void>;
|
|
109
|
+
private sendPendingSubscribes;
|
|
110
|
+
/**
|
|
111
|
+
* Convert a channel value to a string
|
|
112
|
+
*
|
|
113
|
+
* @private
|
|
114
|
+
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel value (string or Channel builder instance)
|
|
115
|
+
* @returns {string} Channel string representation
|
|
116
|
+
*/
|
|
117
|
+
private channelToString;
|
|
118
|
+
/**
|
|
119
|
+
* Subscribe to a single channel
|
|
120
|
+
*
|
|
121
|
+
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel name to subscribe to (string or Channel builder instance)
|
|
122
|
+
* @param {Function} callback - Callback function to handle events
|
|
123
|
+
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
124
|
+
*/
|
|
125
|
+
subscribe(channel: string | Channel<any> | ActionableChannel | ResolvedChannel, callback: (event: RealtimeResponseEvent<any>) => void, queries?: (string | Query)[]): Promise<RealtimeSubscription>;
|
|
126
|
+
/**
|
|
127
|
+
* Subscribe to multiple channels
|
|
128
|
+
*
|
|
129
|
+
* @param {(string | Channel<any> | ActionableChannel | ResolvedChannel)[]} channels - Array of channel names to subscribe to (strings or Channel builder instances)
|
|
130
|
+
* @param {Function} callback - Callback function to handle events
|
|
131
|
+
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
132
|
+
*/
|
|
133
|
+
subscribe(channels: (string | Channel<any> | ActionableChannel | ResolvedChannel)[], callback: (event: RealtimeResponseEvent<any>) => void, queries?: (string | Query)[]): Promise<RealtimeSubscription>;
|
|
134
|
+
/**
|
|
135
|
+
* Subscribe to a single channel with typed payload
|
|
136
|
+
*
|
|
137
|
+
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel name to subscribe to (string or Channel builder instance)
|
|
138
|
+
* @param {Function} callback - Callback function to handle events with typed payload
|
|
139
|
+
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
140
|
+
*/
|
|
141
|
+
subscribe<T>(channel: string | Channel<any> | ActionableChannel | ResolvedChannel, callback: (event: RealtimeResponseEvent<T>) => void, queries?: (string | Query)[]): Promise<RealtimeSubscription>;
|
|
142
|
+
/**
|
|
143
|
+
* Subscribe to multiple channels with typed payload
|
|
144
|
+
*
|
|
145
|
+
* @param {(string | Channel<any> | ActionableChannel | ResolvedChannel)[]} channels - Array of channel names to subscribe to (strings or Channel builder instances)
|
|
146
|
+
* @param {Function} callback - Callback function to handle events with typed payload
|
|
147
|
+
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
148
|
+
*/
|
|
149
|
+
subscribe<T>(channels: (string | Channel<any> | ActionableChannel | ResolvedChannel)[], callback: (event: RealtimeResponseEvent<T>) => void, queries?: (string | Query)[]): Promise<RealtimeSubscription>;
|
|
150
|
+
private handleMessage;
|
|
151
|
+
private handleResponseConnected;
|
|
152
|
+
private handleResponseError;
|
|
153
|
+
private handleResponseEvent;
|
|
154
|
+
private handleResponseAction;
|
|
155
|
+
}
|