Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 18.0.0

* Add `<REGION>` to doc examples due to the new multi region endpoints
* Add `<REGION>` to doc examples due to the new multi region endpoints
* Remove `Gif` from ImageFormat enum
* Remove `search` param from `listExecutions` method
* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage
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.7.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.8.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.7.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.8.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@18.1.1"></script>
<script src="https://cdn.jsdelivr.net/npm/appwrite@19.0.0"></script>
```


Expand Down
8 changes: 4 additions & 4 deletions docs/examples/databases/upsert-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { Client, Databases } from "appwrite";

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

const databases = new Databases(client);

const result = await databases.upsertDocument(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'<DOCUMENT_ID>', // documentId
{}, // data
["read("any")"] // permissions (optional)
'<DOCUMENT_ID>' // documentId
);

console.log(result);
19 changes: 19 additions & 0 deletions docs/examples/tables/create-row.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Client, Tables } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setSession('') // The user session to authenticate with
.setKey('') //
.setJWT('<YOUR_JWT>'); // Your secret JSON Web Token

const tables = new Tables(client);

const result = await tables.createRow(
'<DATABASE_ID>', // databaseId
'<TABLE_ID>', // tableId
'<ROW_ID>', // rowId
{}, // data
["read("any")"] // permissions (optional)
);

console.log(result);
16 changes: 16 additions & 0 deletions docs/examples/tables/create-rows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Client, Tables } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setAdmin('') //
.setKey(''); //

const tables = new Tables(client);

const result = await tables.createRows(
'<DATABASE_ID>', // databaseId
'<TABLE_ID>', // tableId
[] // rows
);

console.log(result);
15 changes: 15 additions & 0 deletions docs/examples/tables/delete-row.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Client, Tables } from "appwrite";

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

const tables = new Tables(client);

const result = await tables.deleteRow(
'<DATABASE_ID>', // databaseId
'<TABLE_ID>', // tableId
'<ROW_ID>' // rowId
);

console.log(result);
16 changes: 16 additions & 0 deletions docs/examples/tables/get-row.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Client, Tables } from "appwrite";

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

const tables = new Tables(client);

const result = await tables.getRow(
'<DATABASE_ID>', // databaseId
'<TABLE_ID>', // tableId
'<ROW_ID>', // rowId
[] // queries (optional)
);

console.log(result);
15 changes: 15 additions & 0 deletions docs/examples/tables/list-rows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Client, Tables } from "appwrite";

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

const tables = new Tables(client);

const result = await tables.listRows(
'<DATABASE_ID>', // databaseId
'<TABLE_ID>', // tableId
[] // queries (optional)
);

console.log(result);
17 changes: 17 additions & 0 deletions docs/examples/tables/update-row.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Client, Tables } from "appwrite";

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

const tables = new Tables(client);

const result = await tables.updateRow(
'<DATABASE_ID>', // databaseId
'<TABLE_ID>', // tableId
'<ROW_ID>', // rowId
{}, // data (optional)
["read("any")"] // permissions (optional)
);

console.log(result);
17 changes: 17 additions & 0 deletions docs/examples/tables/upsert-row.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Client, Tables } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setSession('') // The user session to authenticate with
.setKey('') //
.setJWT('<YOUR_JWT>'); // Your secret JSON Web Token

const tables = new Tables(client);

const result = await tables.upsertRow(
'<DATABASE_ID>', // databaseId
'<TABLE_ID>', // tableId
'<ROW_ID>' // rowId
);

console.log(result);
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": "18.1.1",
"version": "19.0.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
11 changes: 6 additions & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ class Client {
'x-sdk-name': 'Web',
'x-sdk-platform': 'client',
'x-sdk-language': 'web',
'x-sdk-version': '18.1.1',
'X-Appwrite-Response-Format': '1.7.0',
'x-sdk-version': '19.0.0',
'X-Appwrite-Response-Format': '1.8.0',
};

/**
Expand Down Expand Up @@ -679,9 +679,9 @@ class Client {
}

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

if (!file) {
if (!file || !fileParam) {
throw new Error('File not found in payload');
}

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

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

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

Expand Down
1 change: 1 addition & 0 deletions src/enums/image-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export enum ImageFormat {
Webp = 'webp',
Heic = 'heic',
Avif = 'avif',
Gif = 'gif',
}
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/**
* Appwrite Web SDK
*
* This SDK is compatible with Appwrite server version 1.7.x.
* This SDK is compatible with Appwrite server version 1.8.x.
* For older versions, please check
* [previous releases](https://github.com/appwrite/sdk-for-web/releases).
*/
export { Client, Query, AppwriteException } from './client';
export { Account } from './services/account';
export { Avatars } from './services/avatars';
export { Databases } from './services/databases';
export { Tables } from './services/tables';
export { Functions } from './services/functions';
export { Graphql } from './services/graphql';
export { Locale } from './services/locale';
Expand Down
Loading