Skip to content

Commit 90564b7

Browse files
authored
Merge pull request #115 from appwrite/1.6.x
Merge 1.6.x to main
2 parents c33e480 + c286ee1 commit 90564b7

9 files changed

+58
-24
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { Client, Account } from "appwrite";
3333
To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:
3434

3535
```html
36-
<script src="https://cdn.jsdelivr.net/npm/appwrite@16.0.2"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/appwrite@16.1.0"></script>
3737
```
3838

3939

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "appwrite",
33
"homepage": "https://appwrite.io/support",
44
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5-
"version": "16.0.2",
5+
"version": "16.1.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {

src/client.ts

+34-5
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ type Headers = {
1919
*/
2020
type RealtimeResponse = {
2121
/**
22-
* Type of the response: 'error', 'event', 'connected', or 'response'.
22+
* Type of the response: 'error', 'event', 'connected', 'pong', or 'response'.
2323
*/
24-
type: 'error' | 'event' | 'connected' | 'response';
24+
type: 'error' | 'event' | 'connected' | 'response' | 'pong';
2525

2626
/**
2727
* Data associated with the response based on the response type.
@@ -129,6 +129,8 @@ type RealtimeRequestAuthenticate = {
129129
session: string;
130130
}
131131

132+
type TimeoutHandle = ReturnType<typeof setTimeout> | number;
133+
132134
/**
133135
* Realtime interface representing the structure of a realtime communication object.
134136
*/
@@ -139,9 +141,14 @@ type Realtime = {
139141
socket?: WebSocket;
140142

141143
/**
142-
* Timeout duration for communication operations.
144+
* Timeout for reconnect operations.
143145
*/
144-
timeout?: number;
146+
timeout?: TimeoutHandle;
147+
148+
/**
149+
* Heartbeat interval for the realtime connection.
150+
*/
151+
heartbeat?: TimeoutHandle;
145152

146153
/**
147154
* URL for establishing the WebSocket connection.
@@ -196,6 +203,11 @@ type Realtime = {
196203
*/
197204
createSocket: () => void;
198205

206+
/**
207+
* Function to create a new heartbeat interval.
208+
*/
209+
createHeartbeat: () => void;
210+
199211
/**
200212
* Function to clean up resources associated with specified channels.
201213
*
@@ -303,7 +315,7 @@ class Client {
303315
'x-sdk-name': 'Web',
304316
'x-sdk-platform': 'client',
305317
'x-sdk-language': 'web',
306-
'x-sdk-version': '16.0.2',
318+
'x-sdk-version': '16.1.0',
307319
'X-Appwrite-Response-Format': '1.6.0',
308320
};
309321

@@ -394,6 +406,7 @@ class Client {
394406
private realtime: Realtime = {
395407
socket: undefined,
396408
timeout: undefined,
409+
heartbeat: undefined,
397410
url: '',
398411
channels: new Set(),
399412
subscriptions: new Map(),
@@ -419,6 +432,17 @@ class Client {
419432
return 60_000;
420433
}
421434
},
435+
createHeartbeat: () => {
436+
if (this.realtime.heartbeat) {
437+
clearTimeout(this.realtime.heartbeat);
438+
}
439+
440+
this.realtime.heartbeat = window?.setInterval(() => {
441+
this.realtime.socket?.send(JSON.stringify({
442+
type: 'ping'
443+
}));
444+
}, 20_000);
445+
},
422446
createSocket: () => {
423447
if (this.realtime.channels.size < 1) {
424448
this.realtime.reconnect = false;
@@ -452,6 +476,7 @@ class Client {
452476
this.realtime.socket.addEventListener('message', this.realtime.onMessage);
453477
this.realtime.socket.addEventListener('open', _event => {
454478
this.realtime.reconnectAttempts = 0;
479+
this.realtime.createHeartbeat();
455480
});
456481
this.realtime.socket.addEventListener('close', event => {
457482
if (
@@ -669,6 +694,10 @@ class Client {
669694
return response;
670695
}
671696

697+
async ping(): Promise<string> {
698+
return this.call('GET', new URL(this.config.endpoint + '/ping'));
699+
}
700+
672701
async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise<any> {
673702
const { uri, options } = this.prepareRequest(method, url, headers, params);
674703

src/enums/image-format.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export enum ImageFormat {
44
Gif = 'gif',
55
Png = 'png',
66
Webp = 'webp',
7+
Avif = 'avif',
78
}

src/models.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -842,11 +842,11 @@ export namespace Models {
842842
*/
843843
userId: string;
844844
/**
845-
* User name.
845+
* User name. Hide this attribute by toggling membership privacy in the Console.
846846
*/
847847
userName: string;
848848
/**
849-
* User email address.
849+
* User email address. Hide this attribute by toggling membership privacy in the Console.
850850
*/
851851
userEmail: string;
852852
/**
@@ -870,7 +870,7 @@ export namespace Models {
870870
*/
871871
confirm: boolean;
872872
/**
873-
* Multi factor authentication status, true if the user has MFA enabled or false otherwise.
873+
* Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console.
874874
*/
875875
mfa: boolean;
876876
/**
@@ -1198,5 +1198,9 @@ export namespace Models {
11981198
* The target identifier.
11991199
*/
12001200
identifier: string;
1201+
/**
1202+
* Is the target expired.
1203+
*/
1204+
expired: boolean;
12011205
}
12021206
}

src/services/account.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
129129
);
130130
}
131131
/**
132-
* List Identities
132+
* List identities
133133
*
134134
* Get the list of identities for the currently logged in user.
135135
*
@@ -273,7 +273,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
273273
);
274274
}
275275
/**
276-
* Create Authenticator
276+
* Create authenticator
277277
*
278278
* Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method.
279279
*
@@ -302,7 +302,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
302302
);
303303
}
304304
/**
305-
* Verify Authenticator
305+
* Verify authenticator
306306
*
307307
* Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method.
308308
*
@@ -338,7 +338,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
338338
);
339339
}
340340
/**
341-
* Delete Authenticator
341+
* Delete authenticator
342342
*
343343
* Delete an authenticator for a user by ID.
344344
*
@@ -367,7 +367,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
367367
);
368368
}
369369
/**
370-
* Create MFA Challenge
370+
* Create MFA challenge
371371
*
372372
* Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method.
373373
*
@@ -399,7 +399,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
399399
);
400400
}
401401
/**
402-
* Create MFA Challenge (confirmation)
402+
* Create MFA challenge (confirmation)
403403
*
404404
* Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
405405
*
@@ -438,7 +438,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
438438
);
439439
}
440440
/**
441-
* List Factors
441+
* List factors
442442
*
443443
* List the factors available on the account to be used as a MFA challange.
444444
*
@@ -463,7 +463,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
463463
);
464464
}
465465
/**
466-
* Get MFA Recovery Codes
466+
* Get MFA recovery codes
467467
*
468468
* Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes.
469469
*
@@ -488,7 +488,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
488488
);
489489
}
490490
/**
491-
* Create MFA Recovery Codes
491+
* Create MFA recovery codes
492492
*
493493
* Generate recovery codes as backup for MFA flow. It&#039;s recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
494494
*
@@ -513,7 +513,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
513513
);
514514
}
515515
/**
516-
* Regenerate MFA Recovery Codes
516+
* Regenerate MFA recovery codes
517517
*
518518
* Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes.
519519
*

src/services/locale.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class Locale {
3737
);
3838
}
3939
/**
40-
* List Locale Codes
40+
* List locale codes
4141
*
4242
* List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
4343
*

src/services/storage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ If you&#039;re creating a new file using one of the Appwrite SDKs, all the chunk
178178
);
179179
}
180180
/**
181-
* Delete File
181+
* Delete file
182182
*
183183
* Delete a file by its unique ID. Only users with write permissions have access to delete this resource.
184184
*

src/services/teams.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export class Teams {
182182
/**
183183
* List team memberships
184184
*
185-
* Use this endpoint to list a team&#039;s members using the team&#039;s ID. All team members have read access to this endpoint.
185+
* Use this endpoint to list a team&#039;s members using the team&#039;s ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console.
186186
*
187187
* @param {string} teamId
188188
* @param {string[]} queries
@@ -282,7 +282,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee
282282
/**
283283
* Get team membership
284284
*
285-
* Get a team member by the membership unique id. All team members have read access for this resource.
285+
* Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console.
286286
*
287287
* @param {string} teamId
288288
* @param {string} membershipId

0 commit comments

Comments
 (0)