Skip to content

Commit

Permalink
Merge pull request #52 from appwrite/dev
Browse files Browse the repository at this point in the history
update to appwrite 1.3.0
  • Loading branch information
christyjacob4 authored Apr 12, 2023
2 parents 1dde5c7 + 97913bf commit 7b37a2b
Show file tree
Hide file tree
Showing 15 changed files with 300 additions and 52 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors.
Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Appwrite Web SDK

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

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

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)

Expand All @@ -33,7 +33,7 @@ import { Client, Account } from "appwrite";
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:

```html
<script src="https://cdn.jsdelivr.net/npm/appwrite@10.2.0"></script>
<script src="https://cdn.jsdelivr.net/npm/appwrite@11.0.0"></script>
```


Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ client
.setProject('5df5acd0d48c2') // Your project ID
;

const promise = account.create('[USER_ID]', 'email@example.com', 'password');
const promise = account.create('[USER_ID]', 'email@example.com', '');

promise.then(function (response) {
console.log(response); // Success
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/update-password.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ client
.setProject('5df5acd0d48c2') // Your project ID
;

const promise = account.updatePassword('password');
const promise = account.updatePassword('');

promise.then(function (response) {
console.log(response); // Success
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/teams/create-membership.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ client
.setProject('5df5acd0d48c2') // Your project ID
;

const promise = teams.createMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com');
const promise = teams.createMembership('[TEAM_ID]', [], 'https://example.com');

promise.then(function (response) {
console.log(response); // Success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ client
.setProject('5df5acd0d48c2') // Your project ID
;

const promise = teams.update('[TEAM_ID]', '[NAME]');
const promise = teams.getPrefs('[TEAM_ID]');

promise.then(function (response) {
console.log(response); // Success
Expand Down
18 changes: 18 additions & 0 deletions docs/examples/teams/update-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Client, Teams } from "appwrite";

const client = new Client();

const teams = new Teams(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

const promise = teams.updateName('[TEAM_ID]', '[NAME]');

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
18 changes: 18 additions & 0 deletions docs/examples/teams/update-prefs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Client, Teams } from "appwrite";

const client = new Client();

const teams = new Teams(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

const promise = teams.updatePrefs('[TEAM_ID]', {});

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "appwrite",
"homepage": "https://appwrite.io/support",
"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",
"version": "10.2.0",
"version": "11.0.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Client {
'x-sdk-name': 'Web',
'x-sdk-platform': 'client',
'x-sdk-language': 'web',
'x-sdk-version': '10.2.0',
'x-sdk-version': '11.0.0',
'X-Appwrite-Response-Format': '1.0.0',
};

Expand Down
131 changes: 125 additions & 6 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ export namespace Models {
/**
* Teams List
*/
export type TeamList = {
export type TeamList<Preferences extends Models.Preferences> = {
/**
* Total number of teams documents that matched your query.
*/
total: number;
/**
* List of teams.
*/
teams: Team[];
teams: Team<Preferences>[];
}
/**
* Memberships List
Expand Down Expand Up @@ -275,9 +275,9 @@ export namespace Models {
countryName: string;
}
/**
* Account
* User
*/
export type Account<Preferences extends Models.Preferences> = {
export type User<Preferences extends Models.Preferences> = {
/**
* User ID.
*/
Expand All @@ -294,6 +294,18 @@ export namespace Models {
* User name.
*/
name: string;
/**
* Hashed user password.
*/
password?: string;
/**
* Password hashing algorithm.
*/
hash?: string;
/**
* Password hashing algorithm configuration.
*/
hashOptions?: object;
/**
* User registration date in ISO 8601 format.
*/
Expand Down Expand Up @@ -327,6 +339,109 @@ export namespace Models {
*/
prefs: Preferences;
}
/**
* AlgoMD5
*/
export type AlgoMd5 = {
/**
* Algo type.
*/
type: string;
}
/**
* AlgoSHA
*/
export type AlgoSha = {
/**
* Algo type.
*/
type: string;
}
/**
* AlgoPHPass
*/
export type AlgoPhpass = {
/**
* Algo type.
*/
type: string;
}
/**
* AlgoBcrypt
*/
export type AlgoBcrypt = {
/**
* Algo type.
*/
type: string;
}
/**
* AlgoScrypt
*/
export type AlgoScrypt = {
/**
* Algo type.
*/
type: string;
/**
* CPU complexity of computed hash.
*/
costCpu: number;
/**
* Memory complexity of computed hash.
*/
costMemory: number;
/**
* Parallelization of computed hash.
*/
costParallel: number;
/**
* Length used to compute hash.
*/
length: number;
}
/**
* AlgoScryptModified
*/
export type AlgoScryptModified = {
/**
* Algo type.
*/
type: string;
/**
* Salt used to compute hash.
*/
salt: string;
/**
* Separator used to compute hash.
*/
saltSeparator: string;
/**
* Key used to compute hash.
*/
signerKey: string;
}
/**
* AlgoArgon2
*/
export type AlgoArgon2 = {
/**
* Algo type.
*/
type: string;
/**
* Memory used to compute hash.
*/
memoryCost: number;
/**
* Amount of time consumed to compute hash
*/
timeCost: number;
/**
* Number of threads used to compute hash.
*/
threads: number;
}
/**
* Preferences
*/
Expand Down Expand Up @@ -497,7 +612,7 @@ export namespace Models {
*/
continent: string;
/**
* True if country is part of the Europian Union.
* True if country is part of the European Union.
*/
eu: boolean;
/**
Expand Down Expand Up @@ -557,7 +672,7 @@ export namespace Models {
/**
* Team
*/
export type Team = {
export type Team<Preferences extends Models.Preferences> = {
/**
* Team ID.
*/
Expand All @@ -578,6 +693,10 @@ export namespace Models {
* Total number of team members.
*/
total: number;
/**
* Team preferences as a key-value object
*/
prefs: Preferences;
}
/**
* Membership
Expand Down
18 changes: 18 additions & 0 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ export class Query {
static greaterThanEqual = (attribute: string, value: QueryTypes): string =>
Query.addQuery(attribute, "greaterThanEqual", value);

static isNull = (attribute: string): string =>
`isNull("${attribute}")`;

static isNotNull = (attribute: string): string =>
`isNotNull("${attribute}")`;

static between = (attribute: string, start: string|number, end: string|number): string =>
`between("${attribute}", [${Query.parseValues(start)},${Query.parseValues(end)}])`;

static startsWith = (attribute: string, value: string): string =>
Query.addQuery(attribute, "startsWith", value);

static endsWith = (attribute: string, value: string): string =>
Query.addQuery(attribute, "endsWith", value);

static select = (attributes: string[]): string =>
`select([${attributes.map((attr: string) => `"${attr}"`).join(",")}])`;

static search = (attribute: string, value: string): string =>
Query.addQuery(attribute, "search", value);

Expand Down
Loading

0 comments on commit 7b37a2b

Please sign in to comment.