Skip to content

Commit f7316fd

Browse files
Merge pull request appwrite#134 from appwrite/dev
Add inc/dec
2 parents aa423f7 + e491959 commit f7316fd

18 files changed

+431
-107
lines changed

CHANGELOG.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
11
# Change Log
22

3+
## 18.2.0
4+
5+
* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
6+
* Add `gif` support to `ImageFormat` enum
7+
* Fix undefined `fileParam` error in `chunkedUpload` method
8+
* Fix autocompletion not working for `Document` model even when generic is passed
9+
10+
## 18.1.1
11+
12+
* Fix using `devKeys` resulting in an error by conditionally removing credentials
13+
14+
## 18.1.0
15+
16+
* Add `devKeys` support to `Client` service
17+
* Add `upsertDocument` support to `Databases` service
18+
319
## 18.0.0
420

5-
* Add `<REGION>` to doc examples due to the new multi region endpoints
21+
* Add `<REGION>` to doc examples due to the new multi region endpoints
622
* Remove `Gif` from ImageFormat enum
723
* Remove `search` param from `listExecutions` method
824
* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage
9-
* Improve CORS error catching in `client.call` method
25+
* Improve CORS error catching in `client.call` method
26+
27+
## 17.0.2
28+
29+
* Fix requests failing by removing `Content-Type` header from `GET` and `HEAD` requests
30+
31+
## 17.0.1
32+
33+
* Remove unnecessary titles from method descriptions
34+
* Fix duplicate adding of payload params
35+
* Remove unnecessary awaits and asyncs
36+
* Ensure `AppwriteException` response is always string
37+
38+
## 17.0.0
39+
40+
* Fix pong response & chunked upload
41+
* Add `ping` support to `Realtime` service

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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-1.7.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.7.4-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";
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@18.1.1"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/appwrite@18.2.0"></script>
3737
```
3838

3939

docs/examples/databases/create-document.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { Client, Databases } from "appwrite";
22

33
const client = new Client()
44
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5-
.setSession('') // The user session to authenticate with
6-
.setKey('') //
7-
.setJWT('<YOUR_JWT>'); // Your secret JSON Web Token
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
86

97
const databases = new Databases(client);
108

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Client, Databases } from "appwrite";
2+
3+
const client = new Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
const databases = new Databases(client);
8+
9+
const result = await databases.decrementDocumentAttribute(
10+
'<DATABASE_ID>', // databaseId
11+
'<COLLECTION_ID>', // collectionId
12+
'<DOCUMENT_ID>', // documentId
13+
'', // attribute
14+
null, // value (optional)
15+
null // min (optional)
16+
);
17+
18+
console.log(result);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Client, Databases } from "appwrite";
2+
3+
const client = new Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
const databases = new Databases(client);
8+
9+
const result = await databases.incrementDocumentAttribute(
10+
'<DATABASE_ID>', // databaseId
11+
'<COLLECTION_ID>', // collectionId
12+
'<DOCUMENT_ID>', // documentId
13+
'', // attribute
14+
null, // value (optional)
15+
null // max (optional)
16+
);
17+
18+
console.log(result);

package.json

Lines changed: 1 addition & 1 deletion
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": "18.1.1",
5+
"version": "18.2.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {

src/client.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class Client {
316316
'x-sdk-name': 'Web',
317317
'x-sdk-platform': 'client',
318318
'x-sdk-language': 'web',
319-
'x-sdk-version': '18.1.1',
319+
'x-sdk-version': '18.2.0',
320320
'X-Appwrite-Response-Format': '1.7.0',
321321
};
322322

@@ -679,9 +679,9 @@ class Client {
679679
}
680680

681681
async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
682-
const file = Object.values(originalPayload).find((value) => value instanceof File);
682+
const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? [];
683683

684-
if (!file) {
684+
if (!file || !fileParam) {
685685
throw new Error('File not found in payload');
686686
}
687687

@@ -701,7 +701,8 @@ class Client {
701701
headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`;
702702
const chunk = file.slice(start, end);
703703

704-
let payload = { ...originalPayload, file: new File([chunk], file.name)};
704+
let payload = { ...originalPayload };
705+
payload[fileParam] = new File([chunk], file.name);
705706

706707
response = await this.call(method, url, headers, payload);
707708

src/enums/image-format.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export enum ImageFormat {
55
Webp = 'webp',
66
Heic = 'heic',
77
Avif = 'avif',
8+
Gif = 'gif',
89
}

0 commit comments

Comments
 (0)