Skip to content

Commit d076cc6

Browse files
Merge pull request #112 from appwrite/dev
chore: regenerate sdk
2 parents 74e8afb + 0521717 commit d076cc6

File tree

11 files changed

+151
-17
lines changed

11 files changed

+151
-17
lines changed

CHANGELOG.md

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,68 @@
11
# Change Log
22

3+
## 17.1.0
4+
5+
* Add `upsertDocument` method
6+
* Add `dart-3.8` and `flutter-3.32` runtimes
7+
* Add `gif` image format
8+
* Update bulk operation methods to reflect warning message
9+
* Fix file parameter handling in chunked upload method
10+
311
## 17.0.0
412

5-
* Add `<REGION>` to doc examples due to the new multi region endpoints
13+
* Add `REGION` to doc examples due to the new multi region endpoints
614
* Add doc examples and methods for bulk api transactions: `createDocuments`, `deleteDocuments` etc.
715
* Add doc examples, class and methods for new `Sites` service
816
* Add doc examples, class and methods for new `Tokens` service
9-
* Add enums for `BuildRuntime `, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType`
17+
* Add enums for `BuildRuntime`, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType`
1018
* Updates enum for `runtimes` with Pythonml312, Dart219, Flutter327 and Flutter329
1119
* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage
1220
* Add `queries` and `search` params to `listMemberships` method
13-
* Removes `search` param from `listExecutions` method
21+
* Removes `search` param from `listExecutions` method
22+
23+
## 16.0.0
24+
25+
* Fix: remove content-type from GET requests
26+
* Update (breaking): min and max params are now optional in `updateFloatAttribute` and `updateIntegerAttribute` methods (changes their positioning in method definition)
27+
28+
## 15.0.1
29+
30+
* Remove titles from all function descriptions
31+
* Fix typing for collection "attribute" key
32+
* Remove unnecessary awaits and asyncs
33+
* Ensure `AppwriteException` response is always string
34+
35+
## 15.0.0
36+
37+
* Fix: pong response & chunked upload
38+
39+
## 14.2.0
40+
41+
* Add new push message parameters
42+
43+
## 14.1.0
44+
45+
* Support updating attribute name and size
46+
47+
## 14.0.0
48+
49+
* Support for Appwrite 1.6
50+
* Add `key` attribute to `Runtime` response model.
51+
* Add `buildSize` attribute to `Deployments` response model
52+
* Add `scheduledAt` attribute to `Executions` response model
53+
* Add `scopes` attribute to `Functions` response model
54+
* Add `specifications` attribute to `Functions` response model
55+
* Add new response model for `Specifications`
56+
* Add new response model for `Builds`
57+
* Add `createJWT()` : Enables creating a JWT using the `userId`
58+
* Add `listSpecifications()`: Enables listing available runtime specifications
59+
* Add `deleteExecution()` : Enables deleting executions
60+
* Add `updateDeploymentBuild()`: Enables cancelling a deployment
61+
* Add `scheduledAt` parameter to `createExecution()`: Enables creating a delayed execution
62+
* Breaking changes
63+
* Remove `otp` parameter from `deleteMFAAuthenticator`.
64+
* Add `scopes` parameter for create/update function.
65+
* Rename `templateBranch` to `templateVersion` in `createFunction()`.
66+
* Rename `downloadDeployment()` to `getDeploymentDownload()`
67+
68+
> You can find the new syntax for breaking changes in the [Appwrite API references](https://appwrite.io/docs/references). Select version `1.6.x`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Appwrite Node.js SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-node.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)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const sdk = require('node-appwrite');
2+
3+
const client = new sdk.Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>') // Your project ID
6+
.setSession(''); // The user session to authenticate with
7+
8+
const databases = new sdk.Databases(client);
9+
10+
const result = await databases.upsertDocument(
11+
'<DATABASE_ID>', // databaseId
12+
'<COLLECTION_ID>', // collectionId
13+
'<DOCUMENT_ID>', // documentId
14+
{}, // data
15+
["read("any")"] // permissions (optional)
16+
);

docs/examples/databases/upsert-documents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ const databases = new sdk.Databases(client);
1010
const result = await databases.upsertDocuments(
1111
'<DATABASE_ID>', // databaseId
1212
'<COLLECTION_ID>', // collectionId
13-
[] // documents (optional)
13+
[] // documents
1414
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "node-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": "17.0.0",
5+
"version": "17.1.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/index.js",
88
"type": "commonjs",

src/client.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AppwriteException extends Error {
3333
}
3434

3535
function getUserAgent() {
36-
let ua = 'AppwriteNodeJSSDK/17.0.0';
36+
let ua = 'AppwriteNodeJSSDK/17.1.0';
3737

3838
// `process` is a global in Node.js, but not fully available in all runtimes.
3939
const platform: string[] = [];
@@ -82,7 +82,7 @@ class Client {
8282
'x-sdk-name': 'Node.js',
8383
'x-sdk-platform': 'server',
8484
'x-sdk-language': 'nodejs',
85-
'x-sdk-version': '17.0.0',
85+
'x-sdk-version': '17.1.0',
8686
'user-agent' : getUserAgent(),
8787
'X-Appwrite-Response-Format': '1.7.0',
8888
};
@@ -266,9 +266,9 @@ class Client {
266266
}
267267

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

271-
if (!file) {
271+
if (!file || !fileParam) {
272272
throw new Error('File not found in payload');
273273
}
274274

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

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

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

src/enums/build-runtime.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export enum BuildRuntime {
3636
Dart31 = 'dart-3.1',
3737
Dart33 = 'dart-3.3',
3838
Dart35 = 'dart-3.5',
39+
Dart38 = 'dart-3.8',
3940
Dotnet60 = 'dotnet-6.0',
4041
Dotnet70 = 'dotnet-7.0',
4142
Dotnet80 = 'dotnet-8.0',
@@ -62,4 +63,5 @@ export enum BuildRuntime {
6263
Flutter324 = 'flutter-3.24',
6364
Flutter327 = 'flutter-3.27',
6465
Flutter329 = 'flutter-3.29',
66+
Flutter332 = 'flutter-3.32',
6567
}

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/enums/runtime.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export enum Runtime {
3636
Dart31 = 'dart-3.1',
3737
Dart33 = 'dart-3.3',
3838
Dart35 = 'dart-3.5',
39+
Dart38 = 'dart-3.8',
3940
Dotnet60 = 'dotnet-6.0',
4041
Dotnet70 = 'dotnet-7.0',
4142
Dotnet80 = 'dotnet-8.0',
@@ -62,4 +63,5 @@ export enum Runtime {
6263
Flutter324 = 'flutter-3.24',
6364
Flutter327 = 'flutter-3.27',
6465
Flutter329 = 'flutter-3.29',
66+
Flutter332 = 'flutter-3.32',
6567
}

src/services/databases.ts

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,9 @@ export class Databases {
16601660
);
16611661
}
16621662
/**
1663-
* Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
1663+
* **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.
1664+
1665+
Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
16641666
*
16651667
* @param {string} databaseId
16661668
* @param {string} collectionId
@@ -1697,22 +1699,26 @@ export class Databases {
16971699
);
16981700
}
16991701
/**
1700-
* Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
1702+
* **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.
17011703
1704+
Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
17021705
*
17031706
* @param {string} databaseId
17041707
* @param {string} collectionId
17051708
* @param {object[]} documents
17061709
* @throws {AppwriteException}
17071710
* @returns {Promise<Models.DocumentList<Document>>}
17081711
*/
1709-
upsertDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, documents?: object[]): Promise<Models.DocumentList<Document>> {
1712+
upsertDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, documents: object[]): Promise<Models.DocumentList<Document>> {
17101713
if (typeof databaseId === 'undefined') {
17111714
throw new AppwriteException('Missing required parameter: "databaseId"');
17121715
}
17131716
if (typeof collectionId === 'undefined') {
17141717
throw new AppwriteException('Missing required parameter: "collectionId"');
17151718
}
1719+
if (typeof documents === 'undefined') {
1720+
throw new AppwriteException('Missing required parameter: "documents"');
1721+
}
17161722
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
17171723
const payload: Payload = {};
17181724
if (typeof documents !== 'undefined') {
@@ -1732,7 +1738,9 @@ export class Databases {
17321738
);
17331739
}
17341740
/**
1735-
* Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated.
1741+
* **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.
1742+
1743+
Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated.
17361744
*
17371745
* @param {string} databaseId
17381746
* @param {string} collectionId
@@ -1770,7 +1778,9 @@ export class Databases {
17701778
);
17711779
}
17721780
/**
1773-
* Bulk delete documents using queries, if no queries are passed then all documents are deleted.
1781+
* **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.
1782+
1783+
Bulk delete documents using queries, if no queries are passed then all documents are deleted.
17741784
*
17751785
* @param {string} databaseId
17761786
* @param {string} collectionId
@@ -1840,6 +1850,53 @@ export class Databases {
18401850
payload,
18411851
);
18421852
}
1853+
/**
1854+
* **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.
1855+
1856+
Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
1857+
*
1858+
* @param {string} databaseId
1859+
* @param {string} collectionId
1860+
* @param {string} documentId
1861+
* @param {object} data
1862+
* @param {string[]} permissions
1863+
* @throws {AppwriteException}
1864+
* @returns {Promise<Document>}
1865+
*/
1866+
upsertDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise<Document> {
1867+
if (typeof databaseId === 'undefined') {
1868+
throw new AppwriteException('Missing required parameter: "databaseId"');
1869+
}
1870+
if (typeof collectionId === 'undefined') {
1871+
throw new AppwriteException('Missing required parameter: "collectionId"');
1872+
}
1873+
if (typeof documentId === 'undefined') {
1874+
throw new AppwriteException('Missing required parameter: "documentId"');
1875+
}
1876+
if (typeof data === 'undefined') {
1877+
throw new AppwriteException('Missing required parameter: "data"');
1878+
}
1879+
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
1880+
const payload: Payload = {};
1881+
if (typeof data !== 'undefined') {
1882+
payload['data'] = data;
1883+
}
1884+
if (typeof permissions !== 'undefined') {
1885+
payload['permissions'] = permissions;
1886+
}
1887+
const uri = new URL(this.client.config.endpoint + apiPath);
1888+
1889+
const apiHeaders: { [header: string]: string } = {
1890+
'content-type': 'application/json',
1891+
}
1892+
1893+
return this.client.call(
1894+
'put',
1895+
uri,
1896+
apiHeaders,
1897+
payload,
1898+
);
1899+
}
18431900
/**
18441901
* Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
18451902
*

0 commit comments

Comments
 (0)