Skip to content

Commit 9876f42

Browse files
Merge pull request #32 from appwrite/dev
feat: add authPhone to organisation and project uage
2 parents 2ee8ea8 + d31574a commit 9876f42

16 files changed

+174
-210
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors.
1+
Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Appwrite Console SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
@@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console";
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.io/[email protected].4"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/[email protected].6"></script>
3737
```
3838

3939

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { Client, Migrations } from "@appwrite.io/console";
1+
import { Client, Account } from "@appwrite.io/console";
22

33
const client = new Client()
44
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
55
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
66

7-
const migrations = new Migrations(client);
7+
const account = new Account(client);
88

9-
const result = await migrations.deleteFirebaseAuth();
9+
const result = await account.getCoupon(
10+
'<COUPON_ID>' // couponId
11+
);
1012

1113
console.log(result);

docs/examples/account/update-payment-method.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const account = new Account(client);
99
const result = await account.updatePaymentMethod(
1010
'<PAYMENT_METHOD_ID>', // paymentMethodId
1111
1, // expiryMonth
12-
2024 // expiryYear
12+
2025 // expiryYear
1313
);
1414

1515
console.log(result);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Client, Console } from "@appwrite.io/console";
2+
3+
const client = new Client()
4+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
const console = new Console(client);
8+
9+
const result = await console.createProgramMembership(
10+
'<PROGRAM_ID>' // programId
11+
);
12+
13+
console.log(result);

docs/examples/migrations/create-firebase-o-auth-migration.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

docs/examples/migrations/get-firebase-report-o-auth.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

docs/examples/migrations/list-firebase-projects.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@appwrite.io/console",
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": "1.4.4",
5+
"version": "1.4.6",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {

src/client.ts

Lines changed: 30 additions & 5 deletions
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
*
@@ -304,7 +316,7 @@ class Client {
304316
'x-sdk-name': 'Console',
305317
'x-sdk-platform': 'console',
306318
'x-sdk-language': 'web',
307-
'x-sdk-version': '1.4.4',
319+
'x-sdk-version': '1.4.6',
308320
'X-Appwrite-Response-Format': '1.6.0',
309321
};
310322

@@ -407,6 +419,7 @@ class Client {
407419
private realtime: Realtime = {
408420
socket: undefined,
409421
timeout: undefined,
422+
heartbeat: undefined,
410423
url: '',
411424
channels: new Set(),
412425
subscriptions: new Map(),
@@ -432,6 +445,17 @@ class Client {
432445
return 60_000;
433446
}
434447
},
448+
createHeartbeat: () => {
449+
if (this.realtime.heartbeat) {
450+
clearTimeout(this.realtime.heartbeat);
451+
}
452+
453+
this.realtime.heartbeat = window?.setInterval(() => {
454+
this.realtime.socket?.send(JSON.stringify({
455+
type: 'ping'
456+
}));
457+
}, 20_000);
458+
},
435459
createSocket: () => {
436460
if (this.realtime.channels.size < 1) {
437461
this.realtime.reconnect = false;
@@ -465,6 +489,7 @@ class Client {
465489
this.realtime.socket.addEventListener('message', this.realtime.onMessage);
466490
this.realtime.socket.addEventListener('open', _event => {
467491
this.realtime.reconnectAttempts = 0;
492+
this.realtime.createHeartbeat();
468493
});
469494
this.realtime.socket.addEventListener('close', event => {
470495
if (

0 commit comments

Comments
 (0)