Skip to content

Commit 95c774a

Browse files
Merge pull request #17 from appwrite/dev
feat: update version
2 parents 81d81af + 263ef46 commit 95c774a

File tree

4 files changed

+62
-18
lines changed

4 files changed

+62
-18
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Appwrite Web SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-web.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-0.8.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-0.9.0-blue.svg?style=flat-square)
5+
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
56
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
67
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
78

8-
**This SDK is compatible with Appwrite server version 0.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-web/releases).**
9+
**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-web/releases).**
910

10-
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way.
11-
Use the Web SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
12-
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
11+
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Web SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1312

1413
![Appwrite](https://appwrite.io/images/github.png)
1514

@@ -34,7 +33,7 @@ import { Appwrite } from "appwrite";
3433
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:
3534

3635
```html
37-
<script src="https://cdn.jsdelivr.net/npm/appwrite@3.1.0"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/appwrite@3.2.0"></script>
3837
```
3938

4039

@@ -46,7 +45,7 @@ For you to init your SDK and interact with Appwrite services you need to add a w
4645
From the options, choose to add a **Web** platform and add your client app hostname. By adding your hostname to your project platform you are allowing cross-domain communication between your project and the Appwrite API.
4746

4847
### Init your SDK
49-
Initialize your SDK code with your project ID which can be found in your project settings page.
48+
Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page.
5049

5150
```js
5251
// Init your Web SDK
@@ -59,7 +58,7 @@ sdk
5958
```
6059

6160
### Make Your First Request
62-
Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
61+
Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
6362

6463
```js
6564
// Register User
@@ -92,7 +91,7 @@ sdk.account.create('[email protected]', 'password', 'Jane Doe')
9291
```
9392

9493
### Learn more
95-
You can use followng resources to learn more and get help
94+
You can use following resources to learn more and get help
9695
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-flutter)
9796
- 📜 [Appwrite Docs](https://appwrite.io/docs)
9897
- 💬 [Discord Community](https://appwrite.io/discord)

docs/examples/account/get-session.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
let sdk = new Appwrite();
2+
3+
sdk
4+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
5+
.setProject('5df5acd0d48c2') // Your project ID
6+
;
7+
8+
let promise = sdk.account.getSession('[SESSION_ID]');
9+
10+
promise.then(function (response) {
11+
console.log(response); // Success
12+
}, function (error) {
13+
console.log(error); // Failure
14+
});

package.json

Lines changed: 2 additions & 2 deletions
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": "3.1.0",
5+
"version": "3.2.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {
@@ -32,7 +32,7 @@
3232
"typescript": "^4.2.3"
3333
},
3434
"dependencies": {
35-
"cross-fetch": "^3.1.0",
35+
"cross-fetch": "^3.1.4",
3636
"isomorphic-form-data": "^2.0.0"
3737
},
3838
"jsdelivr": "dist/iife/sdk.js",

src/sdk.ts

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class Appwrite {
2929
locale: '',
3030
};
3131
headers: Headers = {
32-
'x-sdk-version': 'appwrite:web:3.1.0',
33-
'X-Appwrite-Response-Format': '0.8.0',
32+
'x-sdk-version': 'appwrite:web:3.2.0',
33+
'X-Appwrite-Response-Format': '0.9.0',
3434
};
3535

3636
/**
@@ -316,7 +316,8 @@ class Appwrite {
316316
* Use this endpoint to create a JSON Web Token. You can use the resulting JWT
317317
* to authenticate on behalf of the current user when working with the
318318
* Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
319-
* from its creation and will be invalid if the user will logout.
319+
* from its creation and will be invalid if the user will logout in that time
320+
* frame.
320321
*
321322
* @throws {AppwriteException}
322323
* @returns {Promise}
@@ -642,9 +643,10 @@ class Appwrite {
642643
*
643644
* Use this endpoint to allow a new user to register an anonymous account in
644645
* your project. This route will also create a new session for the user. To
645-
* allow the new user to convert an anonymous account to a normal account
646-
* account, you need to update its [email and
647-
* password](/docs/client/account#accountUpdateEmail).
646+
* allow the new user to convert an anonymous account to a normal account, you
647+
* need to update its [email and
648+
* password](/docs/client/account#accountUpdateEmail) or create an [OAuth2
649+
* session](/docs/client/account#accountCreateOAuth2Session).
648650
*
649651
* @throws {AppwriteException}
650652
* @returns {Promise}
@@ -708,6 +710,30 @@ class Appwrite {
708710
}
709711
},
710712

713+
/**
714+
* Get Session By ID
715+
*
716+
* Use this endpoint to get a logged in user's session using a Session ID.
717+
* Inputting 'current' will return the current session being used.
718+
*
719+
* @param {string} sessionId
720+
* @throws {AppwriteException}
721+
* @returns {Promise}
722+
*/
723+
getSession: async <T extends unknown>(sessionId: string): Promise<T> => {
724+
if (typeof sessionId === 'undefined') {
725+
throw new AppwriteException('Missing required parameter: "sessionId"');
726+
}
727+
728+
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
729+
let payload: Payload = {};
730+
731+
const uri = new URL(this.config.endpoint + path);
732+
return await this.call('get', uri, {
733+
'content-type': 'application/json',
734+
}, payload);
735+
},
736+
711737
/**
712738
* Delete Account Session
713739
*
@@ -1821,6 +1847,7 @@ class Appwrite {
18211847
* @param {string} fileId
18221848
* @param {number} width
18231849
* @param {number} height
1850+
* @param {string} gravity
18241851
* @param {number} quality
18251852
* @param {number} borderWidth
18261853
* @param {string} borderColor
@@ -1832,7 +1859,7 @@ class Appwrite {
18321859
* @throws {AppwriteException}
18331860
* @returns {URL}
18341861
*/
1835-
getFilePreview: (fileId: string, width?: number, height?: number, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: string): URL => {
1862+
getFilePreview: (fileId: string, width?: number, height?: number, gravity?: string, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: string): URL => {
18361863
if (typeof fileId === 'undefined') {
18371864
throw new AppwriteException('Missing required parameter: "fileId"');
18381865
}
@@ -1848,6 +1875,10 @@ class Appwrite {
18481875
payload['height'] = height;
18491876
}
18501877

1878+
if (typeof gravity !== 'undefined') {
1879+
payload['gravity'] = gravity;
1880+
}
1881+
18511882
if (typeof quality !== 'undefined') {
18521883
payload['quality'] = quality;
18531884
}

0 commit comments

Comments
 (0)