Skip to content

Commit c06dfd6

Browse files
committed
Add inc/dec
1 parent 76f137e commit c06dfd6

File tree

11 files changed

+147
-10
lines changed

11 files changed

+147
-10
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ jobs:
3939
- name: Publish
4040
run: npm publish --tag ${{ steps.release_tag.outputs.tag }}
4141
env:
42-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NO_ORG }}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 18.0.0
44

5-
* Add `<REGION>` to doc examples due to the new multi region endpoints
5+
* Add `<REGION>` to doc examples due to the new multi region endpoints
66
* Remove `Gif` from ImageFormat enum
77
* Remove `search` param from `listExecutions` method
88
* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage

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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +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+
.setAdmin('') //
56
.setSession('') // The user session to authenticate with
67
.setKey('') //
78
.setJWT('<YOUR_JWT>'); // Your secret JSON Web Token
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
}

src/models.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ export namespace Models {
192192
* Document ID.
193193
*/
194194
$id: string;
195+
/**
196+
* Document automatically incrementing ID.
197+
*/
198+
$sequence: number;
195199
/**
196200
* Collection ID.
197201
*/

0 commit comments

Comments
 (0)