From dc768a587070b397fb069e9b5febe6351f265815 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 18 Jul 2025 12:49:48 +1200 Subject: [PATCH 1/5] Add inc/dec --- CHANGELOG.md | 14 +- README.md | 2 +- docs/examples/databases/create-document.md | 1 + .../databases/decrement-document-attribute.md | 17 ++ .../databases/increment-document-attribute.md | 17 ++ docs/examples/databases/upsert-document.md | 16 ++ docs/examples/databases/upsert-documents.md | 2 +- src/client.ts | 4 +- src/enums/build-runtime.ts | 2 + src/enums/image-format.ts | 1 + src/enums/runtime.ts | 2 + src/models.d.ts | 8 + src/services/databases.ts | 173 +++++++++++++++++- src/services/tokens.ts | 2 +- test/services/databases.test.ts | 76 ++++++++ 15 files changed, 329 insertions(+), 8 deletions(-) create mode 100644 docs/examples/databases/decrement-document-attribute.md create mode 100644 docs/examples/databases/increment-document-attribute.md create mode 100644 docs/examples/databases/upsert-document.md diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4d35e..e46648d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,13 @@ -# Change Log \ No newline at end of file +# Change Log + +## 15.0.0 + +* Add `` to doc examples due to the new multi region endpoints +* Add doc examples and methods for bulk api transactions: `createDocuments`, `deleteDocuments` etc. +* Add doc examples, class and methods for new `Sites` service +* Add doc examples, class and methods for new `Tokens` service +* Add enums for `BuildRuntime `, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType` +* Updates enum for `runtimes` with Pythonml312, Dart219, Flutter327 and Flutter329 +* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage +* Add `queries` and `search` params to `listMemberships` method +* Removes `search` param from `listExecutions` method \ No newline at end of file diff --git a/README.md b/README.md index a0b273f..e0a6459 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Deno SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-deno.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.7.4-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) diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index f18b4f3..7af3ac7 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,6 +2,7 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setAdmin('') // .setSession('') // The user session to authenticate with .setKey('') // Your secret API key .setJWT(''); // Your secret JSON Web Token diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 0000000..0142188 --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,17 @@ +import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const databases = new Databases(client); + +const response = await databases.decrementDocumentAttribute( + '', // databaseId + '', // collectionId + '', // documentId + '', // attribute + null, // value (optional) + null // min (optional) +); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 0000000..9202a94 --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,17 @@ +import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const databases = new Databases(client); + +const response = await databases.incrementDocumentAttribute( + '', // databaseId + '', // collectionId + '', // documentId + '', // attribute + null, // value (optional) + null // max (optional) +); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md new file mode 100644 index 0000000..f05100e --- /dev/null +++ b/docs/examples/databases/upsert-document.md @@ -0,0 +1,16 @@ +import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const databases = new Databases(client); + +const response = await databases.upsertDocument( + '', // databaseId + '', // collectionId + '', // documentId + {}, // data + ["read("any")"] // permissions (optional) +); diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index c0ee477..0cd804b 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -10,5 +10,5 @@ const databases = new Databases(client); const response = await databases.upsertDocuments( '', // databaseId '', // collectionId - [] // documents (optional) + [] // documents ); diff --git a/src/client.ts b/src/client.ts index 5e5780f..67e36f9 100644 --- a/src/client.ts +++ b/src/client.ts @@ -11,11 +11,11 @@ export class Client { endpoint: string = 'https://cloud.appwrite.io/v1'; headers: Payload = { 'content-type': '', - 'user-agent' : `AppwriteDenoSDK/15.0.0 (${Deno.build.os}; ${Deno.build.arch})`, + 'user-agent' : `AppwriteDenoSDK/15.1.0 (${Deno.build.os}; ${Deno.build.arch})`, 'x-sdk-name': 'Deno', 'x-sdk-platform': 'server', 'x-sdk-language': 'deno', - 'x-sdk-version': '15.0.0', + 'x-sdk-version': '15.1.0', 'X-Appwrite-Response-Format':'1.7.0', }; diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index 71b0beb..7c93cdc 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -36,6 +36,7 @@ export enum BuildRuntime { Dart31 = 'dart-3.1', Dart33 = 'dart-3.3', Dart35 = 'dart-3.5', + Dart38 = 'dart-3.8', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', Dotnet80 = 'dotnet-8.0', @@ -62,4 +63,5 @@ export enum BuildRuntime { Flutter324 = 'flutter-3.24', Flutter327 = 'flutter-3.27', Flutter329 = 'flutter-3.29', + Flutter332 = 'flutter-3.32', } \ No newline at end of file diff --git a/src/enums/image-format.ts b/src/enums/image-format.ts index 5aad5f0..758fad7 100644 --- a/src/enums/image-format.ts +++ b/src/enums/image-format.ts @@ -5,4 +5,5 @@ export enum ImageFormat { Webp = 'webp', Heic = 'heic', Avif = 'avif', + Gif = 'gif', } \ No newline at end of file diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index d9f2e41..36bb3ba 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -36,6 +36,7 @@ export enum Runtime { Dart31 = 'dart-3.1', Dart33 = 'dart-3.3', Dart35 = 'dart-3.5', + Dart38 = 'dart-3.8', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', Dotnet80 = 'dotnet-8.0', @@ -62,4 +63,5 @@ export enum Runtime { Flutter324 = 'flutter-3.24', Flutter327 = 'flutter-3.27', Flutter329 = 'flutter-3.29', + Flutter332 = 'flutter-3.32', } \ No newline at end of file diff --git a/src/models.d.ts b/src/models.d.ts index 1fd8be1..b47182e 100644 --- a/src/models.d.ts +++ b/src/models.d.ts @@ -542,6 +542,10 @@ export namespace Models { * Default value for attribute when not provided. Cannot be set when attribute is required. */ xdefault?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; } /** * AttributeInteger @@ -1021,6 +1025,10 @@ export namespace Models { * Document ID. */ $id: string; + /** + * Document automatically incrementing ID. + */ + $sequence: number; /** * Collection ID. */ diff --git a/src/services/databases.ts b/src/services/databases.ts index 5c5207f..fe82cf4 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1758,6 +1758,10 @@ export class Databases extends Service { ); } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * 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) @@ -1799,11 +1803,14 @@ export class Databases extends Service { ); } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * 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. - * * * @param {string} databaseId * @param {string} collectionId @@ -1811,7 +1818,7 @@ export class Databases extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async upsertDocuments(databaseId: string, collectionId: string, documents?: object[]): Promise> { + async upsertDocuments(databaseId: string, collectionId: string, documents: object[]): Promise> { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1820,6 +1827,10 @@ export class Databases extends Service { throw new AppwriteException('Missing required parameter: "collectionId"'); } + if (typeof documents === 'undefined') { + throw new AppwriteException('Missing required parameter: "documents"'); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; @@ -1837,6 +1848,10 @@ export class Databases extends Service { ); } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * 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. @@ -1877,6 +1892,10 @@ export class Databases extends Service { ); } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * Bulk delete documents using queries, if no queries are passed then all * documents are deleted. * @@ -1951,6 +1970,60 @@ export class Databases extends Service { 'json' ); } + /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * + * 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. + * + * @param {string} databaseId + * @param {string} collectionId + * @param {string} documentId + * @param {object} data + * @param {string[]} permissions + * @throws {AppwriteException} + * @returns {Promise} + */ + async upsertDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); + const payload: Payload = {}; + + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. @@ -2030,6 +2103,102 @@ export class Databases extends Service { 'json' ); } + /** + * Decrement a specific attribute of a document by a given value. + * + * @param {string} databaseId + * @param {string} collectionId + * @param {string} documentId + * @param {string} attribute + * @param {number} value + * @param {number} min + * @throws {AppwriteException} + * @returns {Promise} + */ + async decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if (typeof attribute === 'undefined') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); + const payload: Payload = {}; + + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Increment a specific attribute of a document by a given value. + * + * @param {string} databaseId + * @param {string} collectionId + * @param {string} documentId + * @param {string} attribute + * @param {number} value + * @param {number} max + * @throws {AppwriteException} + * @returns {Promise} + */ + async incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if (typeof attribute === 'undefined') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); + const payload: Payload = {}; + + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * List indexes in the collection. * diff --git a/src/services/tokens.ts b/src/services/tokens.ts index 2aac6fe..4ee7e18 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -58,7 +58,7 @@ export class Tokens extends Service { } /** * Create a new token. A token is linked to a file. Token can be passed as a - * header or request get parameter. + * request URL search parameter. * * @param {string} bucketId * @param {string} fileId diff --git a/test/services/databases.test.ts b/test/services/databases.test.ts index 4385b65..a2d03e0 100644 --- a/test/services/databases.test.ts +++ b/test/services/databases.test.ts @@ -798,6 +798,7 @@ describe('Databases service', () => { test('test method createDocument()', async () => { const data = { '\$id': '5e5ea5c16897e', + '\$sequence': 1, '\$collectionId': '5e5ea5c15117e', '\$databaseId': '5e5ea5c15117e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -846,6 +847,7 @@ describe('Databases service', () => { const response = await databases.upsertDocuments( '', '', + [], ); assertEquals(response, data); @@ -890,6 +892,7 @@ describe('Databases service', () => { test('test method getDocument()', async () => { const data = { '\$id': '5e5ea5c16897e', + '\$sequence': 1, '\$collectionId': '5e5ea5c15117e', '\$databaseId': '5e5ea5c15117e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -909,9 +912,34 @@ describe('Databases service', () => { }); + test('test method upsertDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await databases.upsertDocument( + '', + '', + '', + {}, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateDocument()', async () => { const data = { '\$id': '5e5ea5c16897e', + '\$sequence': 1, '\$collectionId': '5e5ea5c15117e', '\$databaseId': '5e5ea5c15117e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -948,6 +976,54 @@ describe('Databases service', () => { }); + test('test method decrementDocumentAttribute()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await databases.decrementDocumentAttribute( + '', + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method incrementDocumentAttribute()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await databases.incrementDocumentAttribute( + '', + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method listIndexes()', async () => { const data = { 'total': 5, From a9d89da1936e79bbb91749c62d7c46b29c54f0a8 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Jul 2025 16:16:16 +0000 Subject: [PATCH 2/5] chore: regenerate --- README.md | 4 +- docs/examples/databases/create-document.md | 1 - docs/examples/databases/create-documents.md | 1 + docs/examples/databases/upsert-document.md | 9 +- docs/examples/databases/upsert-documents.md | 5 +- docs/examples/tables/create-boolean-column.md | 17 + .../examples/tables/create-datetime-column.md | 17 + docs/examples/tables/create-email-column.md | 17 + docs/examples/tables/create-enum-column.md | 18 + docs/examples/tables/create-float-column.md | 19 + docs/examples/tables/create-index.md | 18 + docs/examples/tables/create-integer-column.md | 19 + docs/examples/tables/create-ip-column.md | 17 + .../tables/create-relationship-column.md | 19 + docs/examples/tables/create-row.md | 17 + docs/examples/tables/create-rows.md | 14 + docs/examples/tables/create-string-column.md | 19 + docs/examples/tables/create-url-column.md | 17 + docs/examples/tables/create.md | 17 + docs/examples/tables/decrement-row-column.md | 17 + docs/examples/tables/delete-column.md | 14 + docs/examples/tables/delete-index.md | 14 + docs/examples/tables/delete-row.md | 14 + docs/examples/tables/delete-rows.md | 14 + docs/examples/tables/delete.md | 13 + docs/examples/tables/get-column.md | 14 + docs/examples/tables/get-index.md | 14 + docs/examples/tables/get-row.md | 15 + docs/examples/tables/get.md | 13 + docs/examples/tables/increment-row-column.md | 17 + docs/examples/tables/list-columns.md | 14 + docs/examples/tables/list-indexes.md | 14 + docs/examples/tables/list-rows.md | 14 + docs/examples/tables/list.md | 14 + docs/examples/tables/update-boolean-column.md | 17 + .../examples/tables/update-datetime-column.md | 17 + docs/examples/tables/update-email-column.md | 17 + docs/examples/tables/update-enum-column.md | 18 + docs/examples/tables/update-float-column.md | 19 + docs/examples/tables/update-integer-column.md | 19 + docs/examples/tables/update-ip-column.md | 17 + .../tables/update-relationship-column.md | 16 + docs/examples/tables/update-row.md | 16 + docs/examples/tables/update-rows.md | 15 + docs/examples/tables/update-string-column.md | 18 + docs/examples/tables/update-url-column.md | 17 + docs/examples/tables/update.md | 17 + docs/examples/tables/upsert-row.md | 15 + docs/examples/tables/upsert-rows.md | 13 + mod.ts | 2 + src/client.ts | 6 +- src/models.d.ts | 713 +++++- src/services/account.ts | 2 + src/services/databases.ts | 73 +- src/services/tables.ts | 2169 +++++++++++++++++ test/services/databases.test.ts | 2 - test/services/tables.test.ts | 1019 ++++++++ 57 files changed, 4645 insertions(+), 72 deletions(-) create mode 100644 docs/examples/tables/create-boolean-column.md create mode 100644 docs/examples/tables/create-datetime-column.md create mode 100644 docs/examples/tables/create-email-column.md create mode 100644 docs/examples/tables/create-enum-column.md create mode 100644 docs/examples/tables/create-float-column.md create mode 100644 docs/examples/tables/create-index.md create mode 100644 docs/examples/tables/create-integer-column.md create mode 100644 docs/examples/tables/create-ip-column.md create mode 100644 docs/examples/tables/create-relationship-column.md create mode 100644 docs/examples/tables/create-row.md create mode 100644 docs/examples/tables/create-rows.md create mode 100644 docs/examples/tables/create-string-column.md create mode 100644 docs/examples/tables/create-url-column.md create mode 100644 docs/examples/tables/create.md create mode 100644 docs/examples/tables/decrement-row-column.md create mode 100644 docs/examples/tables/delete-column.md create mode 100644 docs/examples/tables/delete-index.md create mode 100644 docs/examples/tables/delete-row.md create mode 100644 docs/examples/tables/delete-rows.md create mode 100644 docs/examples/tables/delete.md create mode 100644 docs/examples/tables/get-column.md create mode 100644 docs/examples/tables/get-index.md create mode 100644 docs/examples/tables/get-row.md create mode 100644 docs/examples/tables/get.md create mode 100644 docs/examples/tables/increment-row-column.md create mode 100644 docs/examples/tables/list-columns.md create mode 100644 docs/examples/tables/list-indexes.md create mode 100644 docs/examples/tables/list-rows.md create mode 100644 docs/examples/tables/list.md create mode 100644 docs/examples/tables/update-boolean-column.md create mode 100644 docs/examples/tables/update-datetime-column.md create mode 100644 docs/examples/tables/update-email-column.md create mode 100644 docs/examples/tables/update-enum-column.md create mode 100644 docs/examples/tables/update-float-column.md create mode 100644 docs/examples/tables/update-integer-column.md create mode 100644 docs/examples/tables/update-ip-column.md create mode 100644 docs/examples/tables/update-relationship-column.md create mode 100644 docs/examples/tables/update-row.md create mode 100644 docs/examples/tables/update-rows.md create mode 100644 docs/examples/tables/update-string-column.md create mode 100644 docs/examples/tables/update-url-column.md create mode 100644 docs/examples/tables/update.md create mode 100644 docs/examples/tables/upsert-row.md create mode 100644 docs/examples/tables/upsert-rows.md create mode 100644 src/services/tables.ts create mode 100644 test/services/tables.test.ts diff --git a/README.md b/README.md index e0a6459..ff3c5be 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Deno SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-deno.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.4-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-deno/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-deno/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 Deno 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) diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 7af3ac7..f18b4f3 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,7 +2,6 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setAdmin('') // .setSession('') // The user session to authenticate with .setKey('') // Your secret API key .setJWT(''); // Your secret JSON Web Token diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index f5e320e..fa3fe84 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -2,6 +2,7 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setAdmin('') // .setKey(''); // Your secret API key const databases = new Databases(client); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index f05100e..a8a61ca 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -2,15 +2,14 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with + .setSession('') // The user session to authenticate with + .setKey('') // Your secret API key + .setJWT(''); // Your secret JSON Web Token const databases = new Databases(client); const response = await databases.upsertDocument( '', // databaseId '', // collectionId - '', // documentId - {}, // data - ["read("any")"] // permissions (optional) + '' // documentId ); diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 0cd804b..bf9e7de 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -2,13 +2,12 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID + .setAdmin('') // .setKey(''); // Your secret API key const databases = new Databases(client); const response = await databases.upsertDocuments( '', // databaseId - '', // collectionId - [] // documents + '' // collectionId ); diff --git a/docs/examples/tables/create-boolean-column.md b/docs/examples/tables/create-boolean-column.md new file mode 100644 index 0000000..3f9abc8 --- /dev/null +++ b/docs/examples/tables/create-boolean-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createBooleanColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + false, // default (optional) + false // array (optional) +); diff --git a/docs/examples/tables/create-datetime-column.md b/docs/examples/tables/create-datetime-column.md new file mode 100644 index 0000000..898b67a --- /dev/null +++ b/docs/examples/tables/create-datetime-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createDatetimeColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + '', // default (optional) + false // array (optional) +); diff --git a/docs/examples/tables/create-email-column.md b/docs/examples/tables/create-email-column.md new file mode 100644 index 0000000..82872e4 --- /dev/null +++ b/docs/examples/tables/create-email-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createEmailColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + 'email@example.com', // default (optional) + false // array (optional) +); diff --git a/docs/examples/tables/create-enum-column.md b/docs/examples/tables/create-enum-column.md new file mode 100644 index 0000000..afbb8d0 --- /dev/null +++ b/docs/examples/tables/create-enum-column.md @@ -0,0 +1,18 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createEnumColumn( + '', // databaseId + '', // tableId + '', // key + [], // elements + false, // required + '', // default (optional) + false // array (optional) +); diff --git a/docs/examples/tables/create-float-column.md b/docs/examples/tables/create-float-column.md new file mode 100644 index 0000000..44658bb --- /dev/null +++ b/docs/examples/tables/create-float-column.md @@ -0,0 +1,19 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createFloatColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + null, // min (optional) + null, // max (optional) + null, // default (optional) + false // array (optional) +); diff --git a/docs/examples/tables/create-index.md b/docs/examples/tables/create-index.md new file mode 100644 index 0000000..c255189 --- /dev/null +++ b/docs/examples/tables/create-index.md @@ -0,0 +1,18 @@ +import { Client, Tables, IndexType } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createIndex( + '', // databaseId + '', // tableId + '', // key + IndexType.Key, // type + [], // columns + [], // orders (optional) + [] // lengths (optional) +); diff --git a/docs/examples/tables/create-integer-column.md b/docs/examples/tables/create-integer-column.md new file mode 100644 index 0000000..0f1721b --- /dev/null +++ b/docs/examples/tables/create-integer-column.md @@ -0,0 +1,19 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createIntegerColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + null, // min (optional) + null, // max (optional) + null, // default (optional) + false // array (optional) +); diff --git a/docs/examples/tables/create-ip-column.md b/docs/examples/tables/create-ip-column.md new file mode 100644 index 0000000..ca96de6 --- /dev/null +++ b/docs/examples/tables/create-ip-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createIpColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + '', // default (optional) + false // array (optional) +); diff --git a/docs/examples/tables/create-relationship-column.md b/docs/examples/tables/create-relationship-column.md new file mode 100644 index 0000000..8c7e26e --- /dev/null +++ b/docs/examples/tables/create-relationship-column.md @@ -0,0 +1,19 @@ +import { Client, Tables, RelationshipType, RelationMutate } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createRelationshipColumn( + '', // databaseId + '', // tableId + '', // relatedTableId + RelationshipType.OneToOne, // type + false, // twoWay (optional) + '', // key (optional) + '', // twoWayKey (optional) + RelationMutate.Cascade // onDelete (optional) +); diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md new file mode 100644 index 0000000..12cec49 --- /dev/null +++ b/docs/examples/tables/create-row.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setKey('') // Your secret API key + .setJWT(''); // Your secret JSON Web Token + +const tables = new Tables(client); + +const response = await tables.createRow( + '', // databaseId + '', // tableId + '', // rowId + {}, // data + ["read("any")"] // permissions (optional) +); diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md new file mode 100644 index 0000000..6c4f7d5 --- /dev/null +++ b/docs/examples/tables/create-rows.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setAdmin('') // + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createRows( + '', // databaseId + '', // tableId + [] // rows +); diff --git a/docs/examples/tables/create-string-column.md b/docs/examples/tables/create-string-column.md new file mode 100644 index 0000000..db7ac8a --- /dev/null +++ b/docs/examples/tables/create-string-column.md @@ -0,0 +1,19 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createStringColumn( + '', // databaseId + '', // tableId + '', // key + 1, // size + false, // required + '', // default (optional) + false, // array (optional) + false // encrypt (optional) +); diff --git a/docs/examples/tables/create-url-column.md b/docs/examples/tables/create-url-column.md new file mode 100644 index 0000000..8d6f127 --- /dev/null +++ b/docs/examples/tables/create-url-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.createUrlColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + 'https://example.com', // default (optional) + false // array (optional) +); diff --git a/docs/examples/tables/create.md b/docs/examples/tables/create.md new file mode 100644 index 0000000..9c75c22 --- /dev/null +++ b/docs/examples/tables/create.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.create( + '', // databaseId + '', // tableId + '', // name + ["read("any")"], // permissions (optional) + false, // rowSecurity (optional) + false // enabled (optional) +); diff --git a/docs/examples/tables/decrement-row-column.md b/docs/examples/tables/decrement-row-column.md new file mode 100644 index 0000000..e561acc --- /dev/null +++ b/docs/examples/tables/decrement-row-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.decrementRowColumn( + '', // databaseId + '', // tableId + '', // rowId + '', // column + null, // value (optional) + null // min (optional) +); diff --git a/docs/examples/tables/delete-column.md b/docs/examples/tables/delete-column.md new file mode 100644 index 0000000..89900bf --- /dev/null +++ b/docs/examples/tables/delete-column.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.deleteColumn( + '', // databaseId + '', // tableId + '' // key +); diff --git a/docs/examples/tables/delete-index.md b/docs/examples/tables/delete-index.md new file mode 100644 index 0000000..a17791c --- /dev/null +++ b/docs/examples/tables/delete-index.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.deleteIndex( + '', // databaseId + '', // tableId + '' // key +); diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md new file mode 100644 index 0000000..8f30eae --- /dev/null +++ b/docs/examples/tables/delete-row.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const tables = new Tables(client); + +const response = await tables.deleteRow( + '', // databaseId + '', // tableId + '' // rowId +); diff --git a/docs/examples/tables/delete-rows.md b/docs/examples/tables/delete-rows.md new file mode 100644 index 0000000..c5aa88f --- /dev/null +++ b/docs/examples/tables/delete-rows.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.deleteRows( + '', // databaseId + '', // tableId + [] // queries (optional) +); diff --git a/docs/examples/tables/delete.md b/docs/examples/tables/delete.md new file mode 100644 index 0000000..36df137 --- /dev/null +++ b/docs/examples/tables/delete.md @@ -0,0 +1,13 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.delete( + '', // databaseId + '' // tableId +); diff --git a/docs/examples/tables/get-column.md b/docs/examples/tables/get-column.md new file mode 100644 index 0000000..8a56af6 --- /dev/null +++ b/docs/examples/tables/get-column.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.getColumn( + '', // databaseId + '', // tableId + '' // key +); diff --git a/docs/examples/tables/get-index.md b/docs/examples/tables/get-index.md new file mode 100644 index 0000000..61105dc --- /dev/null +++ b/docs/examples/tables/get-index.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.getIndex( + '', // databaseId + '', // tableId + '' // key +); diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md new file mode 100644 index 0000000..674ea3e --- /dev/null +++ b/docs/examples/tables/get-row.md @@ -0,0 +1,15 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const tables = new Tables(client); + +const response = await tables.getRow( + '', // databaseId + '', // tableId + '', // rowId + [] // queries (optional) +); diff --git a/docs/examples/tables/get.md b/docs/examples/tables/get.md new file mode 100644 index 0000000..cc1dcb8 --- /dev/null +++ b/docs/examples/tables/get.md @@ -0,0 +1,13 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.get( + '', // databaseId + '' // tableId +); diff --git a/docs/examples/tables/increment-row-column.md b/docs/examples/tables/increment-row-column.md new file mode 100644 index 0000000..9779d87 --- /dev/null +++ b/docs/examples/tables/increment-row-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.incrementRowColumn( + '', // databaseId + '', // tableId + '', // rowId + '', // column + null, // value (optional) + null // max (optional) +); diff --git a/docs/examples/tables/list-columns.md b/docs/examples/tables/list-columns.md new file mode 100644 index 0000000..63ec077 --- /dev/null +++ b/docs/examples/tables/list-columns.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.listColumns( + '', // databaseId + '', // tableId + [] // queries (optional) +); diff --git a/docs/examples/tables/list-indexes.md b/docs/examples/tables/list-indexes.md new file mode 100644 index 0000000..587d19f --- /dev/null +++ b/docs/examples/tables/list-indexes.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.listIndexes( + '', // databaseId + '', // tableId + [] // queries (optional) +); diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md new file mode 100644 index 0000000..6db6bea --- /dev/null +++ b/docs/examples/tables/list-rows.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const tables = new Tables(client); + +const response = await tables.listRows( + '', // databaseId + '', // tableId + [] // queries (optional) +); diff --git a/docs/examples/tables/list.md b/docs/examples/tables/list.md new file mode 100644 index 0000000..d4da840 --- /dev/null +++ b/docs/examples/tables/list.md @@ -0,0 +1,14 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.list( + '', // databaseId + [], // queries (optional) + '' // search (optional) +); diff --git a/docs/examples/tables/update-boolean-column.md b/docs/examples/tables/update-boolean-column.md new file mode 100644 index 0000000..8710c27 --- /dev/null +++ b/docs/examples/tables/update-boolean-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateBooleanColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + false, // default + '' // newKey (optional) +); diff --git a/docs/examples/tables/update-datetime-column.md b/docs/examples/tables/update-datetime-column.md new file mode 100644 index 0000000..e1ca760 --- /dev/null +++ b/docs/examples/tables/update-datetime-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateDatetimeColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + '', // default + '' // newKey (optional) +); diff --git a/docs/examples/tables/update-email-column.md b/docs/examples/tables/update-email-column.md new file mode 100644 index 0000000..b0e2534 --- /dev/null +++ b/docs/examples/tables/update-email-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateEmailColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + 'email@example.com', // default + '' // newKey (optional) +); diff --git a/docs/examples/tables/update-enum-column.md b/docs/examples/tables/update-enum-column.md new file mode 100644 index 0000000..8771213 --- /dev/null +++ b/docs/examples/tables/update-enum-column.md @@ -0,0 +1,18 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateEnumColumn( + '', // databaseId + '', // tableId + '', // key + [], // elements + false, // required + '', // default + '' // newKey (optional) +); diff --git a/docs/examples/tables/update-float-column.md b/docs/examples/tables/update-float-column.md new file mode 100644 index 0000000..a2e6f55 --- /dev/null +++ b/docs/examples/tables/update-float-column.md @@ -0,0 +1,19 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateFloatColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + null, // default + null, // min (optional) + null, // max (optional) + '' // newKey (optional) +); diff --git a/docs/examples/tables/update-integer-column.md b/docs/examples/tables/update-integer-column.md new file mode 100644 index 0000000..51ea17f --- /dev/null +++ b/docs/examples/tables/update-integer-column.md @@ -0,0 +1,19 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateIntegerColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + null, // default + null, // min (optional) + null, // max (optional) + '' // newKey (optional) +); diff --git a/docs/examples/tables/update-ip-column.md b/docs/examples/tables/update-ip-column.md new file mode 100644 index 0000000..4a5a1d0 --- /dev/null +++ b/docs/examples/tables/update-ip-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateIpColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + '', // default + '' // newKey (optional) +); diff --git a/docs/examples/tables/update-relationship-column.md b/docs/examples/tables/update-relationship-column.md new file mode 100644 index 0000000..c83b820 --- /dev/null +++ b/docs/examples/tables/update-relationship-column.md @@ -0,0 +1,16 @@ +import { Client, Tables, RelationMutate } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateRelationshipColumn( + '', // databaseId + '', // tableId + '', // key + RelationMutate.Cascade, // onDelete (optional) + '' // newKey (optional) +); diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md new file mode 100644 index 0000000..13da561 --- /dev/null +++ b/docs/examples/tables/update-row.md @@ -0,0 +1,16 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const tables = new Tables(client); + +const response = await tables.updateRow( + '', // databaseId + '', // tableId + '', // rowId + {}, // data (optional) + ["read("any")"] // permissions (optional) +); diff --git a/docs/examples/tables/update-rows.md b/docs/examples/tables/update-rows.md new file mode 100644 index 0000000..1bc0a18 --- /dev/null +++ b/docs/examples/tables/update-rows.md @@ -0,0 +1,15 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateRows( + '', // databaseId + '', // tableId + {}, // data (optional) + [] // queries (optional) +); diff --git a/docs/examples/tables/update-string-column.md b/docs/examples/tables/update-string-column.md new file mode 100644 index 0000000..00dd310 --- /dev/null +++ b/docs/examples/tables/update-string-column.md @@ -0,0 +1,18 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateStringColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + '', // default + 1, // size (optional) + '' // newKey (optional) +); diff --git a/docs/examples/tables/update-url-column.md b/docs/examples/tables/update-url-column.md new file mode 100644 index 0000000..2ebf80a --- /dev/null +++ b/docs/examples/tables/update-url-column.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.updateUrlColumn( + '', // databaseId + '', // tableId + '', // key + false, // required + 'https://example.com', // default + '' // newKey (optional) +); diff --git a/docs/examples/tables/update.md b/docs/examples/tables/update.md new file mode 100644 index 0000000..43b51bd --- /dev/null +++ b/docs/examples/tables/update.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.update( + '', // databaseId + '', // tableId + '', // name + ["read("any")"], // permissions (optional) + false, // rowSecurity (optional) + false // enabled (optional) +); diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md new file mode 100644 index 0000000..45e932c --- /dev/null +++ b/docs/examples/tables/upsert-row.md @@ -0,0 +1,15 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setKey('') // Your secret API key + .setJWT(''); // Your secret JSON Web Token + +const tables = new Tables(client); + +const response = await tables.upsertRow( + '', // databaseId + '', // tableId + '' // rowId +); diff --git a/docs/examples/tables/upsert-rows.md b/docs/examples/tables/upsert-rows.md new file mode 100644 index 0000000..9e3f542 --- /dev/null +++ b/docs/examples/tables/upsert-rows.md @@ -0,0 +1,13 @@ +import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setAdmin('') // + .setKey(''); // Your secret API key + +const tables = new Tables(client); + +const response = await tables.upsertRows( + '', // databaseId + '' // tableId +); diff --git a/mod.ts b/mod.ts index 35c4e91..7bbd078 100644 --- a/mod.ts +++ b/mod.ts @@ -8,6 +8,7 @@ import { AppwriteException } from "./src/exception.ts"; import { Account } from "./src/services/account.ts"; import { Avatars } from "./src/services/avatars.ts"; import { Databases } from "./src/services/databases.ts"; +import { Tables } from "./src/services/tables.ts"; import { Functions } from "./src/services/functions.ts"; import { Graphql } from "./src/services/graphql.ts"; import { Health } from "./src/services/health.ts"; @@ -54,6 +55,7 @@ export { Account, Avatars, Databases, + Tables, Functions, Graphql, Health, diff --git a/src/client.ts b/src/client.ts index 67e36f9..139c77b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -11,12 +11,12 @@ export class Client { endpoint: string = 'https://cloud.appwrite.io/v1'; headers: Payload = { 'content-type': '', - 'user-agent' : `AppwriteDenoSDK/15.1.0 (${Deno.build.os}; ${Deno.build.arch})`, + 'user-agent' : `AppwriteDenoSDK/16.0.0 (${Deno.build.os}; ${Deno.build.arch})`, 'x-sdk-name': 'Deno', 'x-sdk-platform': 'server', 'x-sdk-language': 'deno', - 'x-sdk-version': '15.1.0', - 'X-Appwrite-Response-Format':'1.7.0', + 'x-sdk-version': '16.0.0', + 'X-Appwrite-Response-Format':'1.8.0', }; /** diff --git a/src/models.d.ts b/src/models.d.ts index b47182e..a25e7a9 100644 --- a/src/models.d.ts +++ b/src/models.d.ts @@ -1,10 +1,23 @@ export namespace Models { + /** + * Rows List + */ + export type RowList = { + /** + * Total number of rows rows that matched your query. + */ + total: number; + /** + * List of rows. + */ + rows: Row[]; + } /** * Documents List */ export type DocumentList = { /** - * Total number of documents documents that matched your query. + * Total number of documents rows that matched your query. */ total: number; /** @@ -12,12 +25,25 @@ export namespace Models { */ documents: Document[]; } + /** + * Tables List + */ + export type TableList = { + /** + * Total number of tables rows that matched your query. + */ + total: number; + /** + * List of tables. + */ + tables: Table[]; + } /** * Collections List */ export type CollectionList = { /** - * Total number of collections documents that matched your query. + * Total number of collections rows that matched your query. */ total: number; /** @@ -30,7 +56,7 @@ export namespace Models { */ export type DatabaseList = { /** - * Total number of databases documents that matched your query. + * Total number of databases rows that matched your query. */ total: number; /** @@ -43,7 +69,7 @@ export namespace Models { */ export type IndexList = { /** - * Total number of indexes documents that matched your query. + * Total number of indexes rows that matched your query. */ total: number; /** @@ -51,12 +77,25 @@ export namespace Models { */ indexes: Index[]; } + /** + * Column Indexes List + */ + export type ColumnIndexList = { + /** + * Total number of indexes rows that matched your query. + */ + total: number; + /** + * List of indexes. + */ + indexes: ColumnIndex[]; + } /** * Users List */ export type UserList = { /** - * Total number of users documents that matched your query. + * Total number of users rows that matched your query. */ total: number; /** @@ -69,7 +108,7 @@ export namespace Models { */ export type SessionList = { /** - * Total number of sessions documents that matched your query. + * Total number of sessions rows that matched your query. */ total: number; /** @@ -82,7 +121,7 @@ export namespace Models { */ export type IdentityList = { /** - * Total number of identities documents that matched your query. + * Total number of identities rows that matched your query. */ total: number; /** @@ -95,7 +134,7 @@ export namespace Models { */ export type LogList = { /** - * Total number of logs documents that matched your query. + * Total number of logs rows that matched your query. */ total: number; /** @@ -108,7 +147,7 @@ export namespace Models { */ export type FileList = { /** - * Total number of files documents that matched your query. + * Total number of files rows that matched your query. */ total: number; /** @@ -121,7 +160,7 @@ export namespace Models { */ export type BucketList = { /** - * Total number of buckets documents that matched your query. + * Total number of buckets rows that matched your query. */ total: number; /** @@ -134,7 +173,7 @@ export namespace Models { */ export type ResourceTokenList = { /** - * Total number of tokens documents that matched your query. + * Total number of tokens rows that matched your query. */ total: number; /** @@ -147,7 +186,7 @@ export namespace Models { */ export type TeamList = { /** - * Total number of teams documents that matched your query. + * Total number of teams rows that matched your query. */ total: number; /** @@ -160,7 +199,7 @@ export namespace Models { */ export type MembershipList = { /** - * Total number of memberships documents that matched your query. + * Total number of memberships rows that matched your query. */ total: number; /** @@ -173,7 +212,7 @@ export namespace Models { */ export type SiteList = { /** - * Total number of sites documents that matched your query. + * Total number of sites rows that matched your query. */ total: number; /** @@ -186,7 +225,7 @@ export namespace Models { */ export type FunctionList = { /** - * Total number of functions documents that matched your query. + * Total number of functions rows that matched your query. */ total: number; /** @@ -199,7 +238,7 @@ export namespace Models { */ export type FrameworkList = { /** - * Total number of frameworks documents that matched your query. + * Total number of frameworks rows that matched your query. */ total: number; /** @@ -212,7 +251,7 @@ export namespace Models { */ export type RuntimeList = { /** - * Total number of runtimes documents that matched your query. + * Total number of runtimes rows that matched your query. */ total: number; /** @@ -225,7 +264,7 @@ export namespace Models { */ export type DeploymentList = { /** - * Total number of deployments documents that matched your query. + * Total number of deployments rows that matched your query. */ total: number; /** @@ -238,7 +277,7 @@ export namespace Models { */ export type ExecutionList = { /** - * Total number of executions documents that matched your query. + * Total number of executions rows that matched your query. */ total: number; /** @@ -251,7 +290,7 @@ export namespace Models { */ export type CountryList = { /** - * Total number of countries documents that matched your query. + * Total number of countries rows that matched your query. */ total: number; /** @@ -264,7 +303,7 @@ export namespace Models { */ export type ContinentList = { /** - * Total number of continents documents that matched your query. + * Total number of continents rows that matched your query. */ total: number; /** @@ -277,7 +316,7 @@ export namespace Models { */ export type LanguageList = { /** - * Total number of languages documents that matched your query. + * Total number of languages rows that matched your query. */ total: number; /** @@ -290,7 +329,7 @@ export namespace Models { */ export type CurrencyList = { /** - * Total number of currencies documents that matched your query. + * Total number of currencies rows that matched your query. */ total: number; /** @@ -303,7 +342,7 @@ export namespace Models { */ export type PhoneList = { /** - * Total number of phones documents that matched your query. + * Total number of phones rows that matched your query. */ total: number; /** @@ -316,7 +355,7 @@ export namespace Models { */ export type VariableList = { /** - * Total number of variables documents that matched your query. + * Total number of variables rows that matched your query. */ total: number; /** @@ -329,7 +368,7 @@ export namespace Models { */ export type LocaleCodeList = { /** - * Total number of localeCodes documents that matched your query. + * Total number of localeCodes rows that matched your query. */ total: number; /** @@ -342,7 +381,7 @@ export namespace Models { */ export type ProviderList = { /** - * Total number of providers documents that matched your query. + * Total number of providers rows that matched your query. */ total: number; /** @@ -355,7 +394,7 @@ export namespace Models { */ export type MessageList = { /** - * Total number of messages documents that matched your query. + * Total number of messages rows that matched your query. */ total: number; /** @@ -368,7 +407,7 @@ export namespace Models { */ export type TopicList = { /** - * Total number of topics documents that matched your query. + * Total number of topics rows that matched your query. */ total: number; /** @@ -381,7 +420,7 @@ export namespace Models { */ export type SubscriberList = { /** - * Total number of subscribers documents that matched your query. + * Total number of subscribers rows that matched your query. */ total: number; /** @@ -394,7 +433,7 @@ export namespace Models { */ export type TargetList = { /** - * Total number of targets documents that matched your query. + * Total number of targets rows that matched your query. */ total: number; /** @@ -407,7 +446,7 @@ export namespace Models { */ export type SpecificationList = { /** - * Total number of specifications documents that matched your query. + * Total number of specifications rows that matched your query. */ total: number; /** @@ -976,6 +1015,542 @@ export namespace Models { */ side: string; } + /** + * Table + */ + export type Table = { + /** + * Table ID. + */ + $id: string; + /** + * Table creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Table update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * Database ID. + */ + databaseId: string; + /** + * Table name. + */ + name: string; + /** + * Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. + */ + enabled: boolean; + /** + * Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + rowSecurity: boolean; + /** + * Table columns. + */ + columns: (ColumnBoolean | ColumnInteger | ColumnFloat | ColumnEmail | ColumnEnum | ColumnUrl | ColumnIp | ColumnDatetime | ColumnRelationship | ColumnString)[]; + /** + * Table indexes. + */ + indexes: ColumnIndex[]; + } + /** + * Columns List + */ + export type ColumnList = { + /** + * Total number of columns in the given table. + */ + total: number; + /** + * List of columns. + */ + columns: (ColumnBoolean | ColumnInteger | ColumnFloat | ColumnEmail | ColumnEnum | ColumnUrl | ColumnIp | ColumnDatetime | ColumnRelationship | ColumnString)[]; + } + /** + * ColumnString + */ + export type ColumnString = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Column size. + */ + size: number; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + xdefault?: string; + /** + * Defines whether this column is encrypted or not. + */ + encrypt?: boolean; + } + /** + * ColumnInteger + */ + export type ColumnInteger = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number; + /** + * Maximum value to enforce for new documents. + */ + max?: number; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + xdefault?: number; + } + /** + * ColumnFloat + */ + export type ColumnFloat = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number; + /** + * Maximum value to enforce for new documents. + */ + max?: number; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + xdefault?: number; + } + /** + * ColumnBoolean + */ + export type ColumnBoolean = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + xdefault?: boolean; + } + /** + * ColumnEmail + */ + export type ColumnEmail = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + xdefault?: string; + } + /** + * ColumnEnum + */ + export type ColumnEnum = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Array of elements in enumerated type. + */ + elements: string[]; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + xdefault?: string; + } + /** + * ColumnIP + */ + export type ColumnIp = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + xdefault?: string; + } + /** + * ColumnURL + */ + export type ColumnUrl = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + xdefault?: string; + } + /** + * ColumnDatetime + */ + export type ColumnDatetime = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * ISO 8601 format. + */ + format: string; + /** + * Default value for attribute when not provided. Only null is optional + */ + xdefault?: string; + } + /** + * ColumnRelationship + */ + export type ColumnRelationship = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * The ID of the related table. + */ + relatedTable: string; + /** + * The type of the relationship. + */ + relationType: string; + /** + * Is the relationship two-way? + */ + twoWay: boolean; + /** + * The key of the two-way relationship. + */ + twoWayKey: string; + /** + * How deleting the parent document will propagate to child documents. + */ + onDelete: string; + /** + * Whether this is the parent or child side of the relationship + */ + side: string; + } /** * Index */ @@ -1017,6 +1592,80 @@ export namespace Models { */ $updatedAt: string; } + /** + * Index + */ + export type ColumnIndex = { + /** + * Index Key. + */ + key: string; + /** + * Index type. + */ + type: string; + /** + * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an index. + */ + error: string; + /** + * Index columns. + */ + columns: string[]; + /** + * Index columns length. + */ + lengths: number[]; + /** + * Index orders. + */ + orders?: string[]; + /** + * Index creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Index update date in ISO 8601 format. + */ + $updatedAt: string; + } + /** + * Row + */ + export type Row = { + /** + * Row ID. + */ + $id: string; + /** + * Row automatically incrementing ID. + */ + $sequence: number; + /** + * Table ID. + */ + $tableId: string; + /** + * Database ID. + */ + $databaseId: string; + /** + * Row creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Row update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + } /** * Document */ diff --git a/src/services/account.ts b/src/services/account.ts index 8969794..29a42b8 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -876,6 +876,7 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated. */ async updateMagicURLSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { @@ -914,6 +915,7 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated. */ async updatePhoneSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { diff --git a/src/services/databases.ts b/src/services/databases.ts index fe82cf4..816e1cc 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -192,6 +192,7 @@ export class Databases extends Service { * @param {string} search * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.list` instead. */ async listCollections(databaseId: string, queries?: string[], search?: string): Promise { if (typeof databaseId === 'undefined') { @@ -232,6 +233,7 @@ export class Databases extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.create` instead. */ async createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -282,6 +284,7 @@ export class Databases extends Service { * @param {string} collectionId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.get` instead. */ async getCollection(databaseId: string, collectionId: string): Promise { if (typeof databaseId === 'undefined') { @@ -315,6 +318,7 @@ export class Databases extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.update` instead. */ async updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -362,6 +366,7 @@ export class Databases extends Service { * @param {string} collectionId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.delete` instead. */ async deleteCollection(databaseId: string, collectionId: string): Promise { if (typeof databaseId === 'undefined') { @@ -393,6 +398,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.listColumns` instead. */ async listAttributes(databaseId: string, collectionId: string, queries?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -431,6 +437,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createBooleanColumn` instead. */ async createBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -486,6 +493,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateBooleanColumn` instead. */ async updateBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -541,6 +549,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createDatetimeColumn` instead. */ async createDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -596,6 +605,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateDatetimeColumn` instead. */ async updateDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -652,6 +662,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createEmailColumn` instead. */ async createEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -708,6 +719,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateEmailColumn` instead. */ async updateEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -753,8 +765,8 @@ export class Databases extends Service { ); } /** - * Create an enumeration attribute. The `elements` param acts as a white-list - * of accepted values for this attribute. + * Create an enum attribute. The `elements` param acts as a white-list of + * accepted values for this attribute. * * * @param {string} databaseId @@ -766,6 +778,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createEnumColumn` instead. */ async createEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -830,6 +843,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateEnumColumn` instead. */ async updateEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -896,6 +910,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createFloatColumn` instead. */ async createFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -960,6 +975,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateFloatColumn` instead. */ async updateFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1025,6 +1041,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createIntegerColumn` instead. */ async createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -1089,6 +1106,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateIntegerColumn` instead. */ async updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1151,6 +1169,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createIpColumn` instead. */ async createIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -1207,6 +1226,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateIpColumn` instead. */ async updateIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1266,6 +1286,7 @@ export class Databases extends Service { * @param {RelationMutate} onDelete * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createRelationshipColumn` instead. */ async createRelationshipAttribute(databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise { if (typeof databaseId === 'undefined') { @@ -1329,6 +1350,7 @@ export class Databases extends Service { * @param {boolean} encrypt * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createStringColumn` instead. */ async createStringAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -1396,6 +1418,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateStringColumn` instead. */ async updateStringAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1455,6 +1478,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createUrlColumn` instead. */ async createUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -1511,6 +1535,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateUrlColumn` instead. */ async updateUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1563,6 +1588,7 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.getColumn` instead. */ async getAttribute(databaseId: string, collectionId: string, key: string): Promise { if (typeof databaseId === 'undefined') { @@ -1597,6 +1623,7 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.deleteColumn` instead. */ async deleteAttribute(databaseId: string, collectionId: string, key: string): Promise { if (typeof databaseId === 'undefined') { @@ -1636,6 +1663,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateRelationshipColumn` instead. */ async updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1678,6 +1706,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead. */ async listDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise> { if (typeof databaseId === 'undefined') { @@ -1717,6 +1746,7 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead. */ async createDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -1772,6 +1802,7 @@ export class Databases extends Service { * @param {object[]} documents * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead. */ async createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise> { if (typeof databaseId === 'undefined') { @@ -1811,14 +1842,15 @@ export class Databases extends Service { * new collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) * API or directly from your database console. + * * * @param {string} databaseId * @param {string} collectionId - * @param {object[]} documents * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.upsertRows` instead. */ - async upsertDocuments(databaseId: string, collectionId: string, documents: object[]): Promise> { + async upsertDocuments(databaseId: string, collectionId: string): Promise> { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1827,16 +1859,9 @@ export class Databases extends Service { throw new AppwriteException('Missing required parameter: "collectionId"'); } - if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; - if (typeof documents !== 'undefined') { - payload['documents'] = documents; - } return await this.client.call( 'put', apiPath, @@ -1862,6 +1887,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateRows` instead. */ async updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[]): Promise> { if (typeof databaseId === 'undefined') { @@ -1904,6 +1930,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.deleteRows` instead. */ async deleteDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise> { if (typeof databaseId === 'undefined') { @@ -1940,6 +1967,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead. */ async getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -1983,12 +2011,11 @@ export class Databases extends Service { * @param {string} databaseId * @param {string} collectionId * @param {string} documentId - * @param {object} data - * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead. */ - async upsertDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { + async upsertDocument(databaseId: string, collectionId: string, documentId: string): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -2001,19 +2028,9 @@ export class Databases extends Service { throw new AppwriteException('Missing required parameter: "documentId"'); } - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } return await this.client.call( 'put', apiPath, @@ -2035,6 +2052,7 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead. */ async updateDocument(databaseId: string, collectionId: string, documentId: string, data?: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -2076,6 +2094,7 @@ export class Databases extends Service { * @param {string} documentId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead. */ async deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise { if (typeof databaseId === 'undefined') { @@ -2114,6 +2133,7 @@ export class Databases extends Service { * @param {number} min * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.decrementRowColumn` instead. */ async decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise { if (typeof databaseId === 'undefined') { @@ -2162,6 +2182,7 @@ export class Databases extends Service { * @param {number} max * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.incrementRowColumn` instead. */ async incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise { if (typeof databaseId === 'undefined') { @@ -2207,6 +2228,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.listIndexes` instead. */ async listIndexes(databaseId: string, collectionId: string, queries?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -2247,6 +2269,7 @@ export class Databases extends Service { * @param {number[]} lengths * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createIndex` instead. */ async createIndex(databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: string[], lengths?: number[]): Promise { if (typeof databaseId === 'undefined') { @@ -2305,6 +2328,7 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.getIndex` instead. */ async getIndex(databaseId: string, collectionId: string, key: string): Promise { if (typeof databaseId === 'undefined') { @@ -2339,6 +2363,7 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.deleteIndex` instead. */ async deleteIndex(databaseId: string, collectionId: string, key: string): Promise { if (typeof databaseId === 'undefined') { diff --git a/src/services/tables.ts b/src/services/tables.ts new file mode 100644 index 0000000..51a05b8 --- /dev/null +++ b/src/services/tables.ts @@ -0,0 +1,2169 @@ +import { basename } from "https://deno.land/std@0.122.0/path/mod.ts"; +import { Service } from '../service.ts'; +import { Payload, Client } from '../client.ts'; +import { InputFile } from '../inputFile.ts'; +import { AppwriteException } from '../exception.ts'; +import type { Models } from '../models.d.ts'; +import { Query } from '../query.ts'; +import { RelationshipType } from '../enums/relationship-type.ts'; +import { RelationMutate } from '../enums/relation-mutate.ts'; +import { IndexType } from '../enums/index-type.ts'; + +export type UploadProgress = { + $id: string; + progress: number; + sizeUploaded: number; + chunksTotal: number; + chunksUploaded: number; +} + +export class Tables extends Service { + + constructor(client: Client) + { + super(client); + } + + /** + * Get a list of all tables that belong to the provided databaseId. You can + * use the search parameter to filter your results. + * + * @param {string} databaseId + * @param {string[]} queries + * @param {string} search + * @throws {AppwriteException} + * @returns {Promise} + */ + async list(databaseId: string, queries?: string[], search?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/databases/{databaseId}/tables'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + + if (typeof search !== 'undefined') { + payload['search'] = search; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Create a new Table. Before using this route, you should create a new + * database resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} name + * @param {string[]} permissions + * @param {boolean} rowSecurity + * @param {boolean} enabled + * @throws {AppwriteException} + * @returns {Promise} + */ + async create(databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/databases/{databaseId}/tables'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + + if (typeof tableId !== 'undefined') { + payload['tableId'] = tableId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof rowSecurity !== 'undefined') { + payload['rowSecurity'] = rowSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get a table by its unique ID. This endpoint response returns a JSON object + * with the table metadata. + * + * @param {string} databaseId + * @param {string} tableId + * @throws {AppwriteException} + * @returns {Promise} + */ + async get(databaseId: string, tableId: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Update a table by its unique ID. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} name + * @param {string[]} permissions + * @param {boolean} rowSecurity + * @param {boolean} enabled + * @throws {AppwriteException} + * @returns {Promise} + */ + async update(databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof rowSecurity !== 'undefined') { + payload['rowSecurity'] = rowSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Delete a table by its unique ID. Only users with write permissions have + * access to delete this resource. + * + * @param {string} databaseId + * @param {string} tableId + * @throws {AppwriteException} + * @returns {Promise} + */ + async delete(databaseId: string, tableId: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * List attributes in the collection. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async listColumns(databaseId: string, tableId: string, queries?: string[]): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Create a boolean column. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {boolean} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/boolean'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update a boolean column. Changing the `default` value will not update + * already existing rows. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {boolean} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/boolean/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create a date time column according to the ISO 8601 standard. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/datetime'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update a date time column. Changing the `default` value will not update + * already existing rows. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/datetime/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create an email column. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/email'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update an email column. Changing the `default` value will not update + * already existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/email/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create an enumeration column. The `elements` param acts as a white-list of + * accepted values for this column. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {string[]} elements + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof elements === 'undefined') { + throw new AppwriteException('Missing required parameter: "elements"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/enum'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof elements !== 'undefined') { + payload['elements'] = elements; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update an enum column. Changing the `default` value will not update already + * existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {string[]} elements + * @param {boolean} required + * @param {string} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof elements === 'undefined') { + throw new AppwriteException('Missing required parameter: "elements"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/enum/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + if (typeof elements !== 'undefined') { + payload['elements'] = elements; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create a float column. Optionally, minimum and maximum values can be + * provided. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {number} min + * @param {number} max + * @param {number} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/float'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update a float column. Changing the `default` value will not update already + * existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {number} xdefault + * @param {number} min + * @param {number} max + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/float/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create an integer column. Optionally, minimum and maximum values can be + * provided. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {number} min + * @param {number} max + * @param {number} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/integer'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update an integer column. Changing the `default` value will not update + * already existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {number} xdefault + * @param {number} min + * @param {number} max + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/integer/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create IP address column. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/ip'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update an ip column. Changing the `default` value will not update already + * existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/ip/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} relatedTableId + * @param {RelationshipType} type + * @param {boolean} twoWay + * @param {string} key + * @param {string} twoWayKey + * @param {RelationMutate} onDelete + * @throws {AppwriteException} + * @returns {Promise} + */ + async createRelationshipColumn(databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof relatedTableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "relatedTableId"'); + } + + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/relationship'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof relatedTableId !== 'undefined') { + payload['relatedTableId'] = relatedTableId; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof twoWay !== 'undefined') { + payload['twoWay'] = twoWay; + } + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof twoWayKey !== 'undefined') { + payload['twoWayKey'] = twoWayKey; + } + if (typeof onDelete !== 'undefined') { + payload['onDelete'] = onDelete; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create a string column. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {number} size + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @param {boolean} encrypt + * @throws {AppwriteException} + * @returns {Promise} + */ + async createStringColumn(databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof size === 'undefined') { + throw new AppwriteException('Missing required parameter: "size"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/string'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update a string column. Changing the `default` value will not update + * already existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {number} size + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateStringColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/string/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create a URL column. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/url'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update an url column. Changing the `default` value will not update already + * existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/url/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get column by ID. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @throws {AppwriteException} + * @returns {Promise} + */ + async getColumn(databaseId: string, tableId: string, key: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Deletes a column. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteColumn(databaseId: string, tableId: string, key: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {RelationMutate} onDelete + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateRelationshipColumn(databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/{key}/relationship'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + if (typeof onDelete !== 'undefined') { + payload['onDelete'] = onDelete; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * List indexes in the collection. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async listIndexes(databaseId: string, tableId: string, queries?: string[]): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Creates an index on the attributes listed. Your index should include all + * the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {IndexType} type + * @param {string[]} columns + * @param {string[]} orders + * @param {number[]} lengths + * @throws {AppwriteException} + * @returns {Promise} + */ + async createIndex(databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: string[], lengths?: number[]): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + if (typeof columns === 'undefined') { + throw new AppwriteException('Missing required parameter: "columns"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof columns !== 'undefined') { + payload['columns'] = columns; + } + if (typeof orders !== 'undefined') { + payload['orders'] = orders; + } + if (typeof lengths !== 'undefined') { + payload['lengths'] = lengths; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get index by ID. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @throws {AppwriteException} + * @returns {Promise} + */ + async getIndex(databaseId: string, tableId: string, key: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Delete an index. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteIndex(databaseId: string, tableId: string, key: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get a list of all the user's rows in a given table. You can use the query + * params to filter your results. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async listRows(databaseId: string, tableId: string, queries?: string[]): Promise> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Create a new Row. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {object} data + * @param {string[]} permissions + * @throws {AppwriteException} + * @returns {Promise} + */ + async createRow(databaseId: string, tableId: string, rowId: string, data: object, permissions?: string[]): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof rowId !== 'undefined') { + payload['rowId'] = rowId; + } + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create new Rows. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {object[]} rows + * @throws {AppwriteException} + * @returns {Promise} + */ + async createRows(databaseId: string, tableId: string, rows: object[]): Promise> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rows === 'undefined') { + throw new AppwriteException('Missing required parameter: "rows"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof rows !== 'undefined') { + payload['rows'] = rows; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create or update Rows. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * + * @param {string} databaseId + * @param {string} tableId + * @throws {AppwriteException} + * @returns {Promise} + */ + async upsertRows(databaseId: string, tableId: string): Promise> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update all rows that match your queries, if no queries are submitted then + * all rows are updated. You can pass only specific fields to be updated. + * + * @param {string} databaseId + * @param {string} tableId + * @param {object} data + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateRows(databaseId: string, tableId: string, data?: object, queries?: string[]): Promise> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Bulk delete rows using queries, if no queries are passed then all rows are + * deleted. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteRows(databaseId: string, tableId: string, queries?: string[]): Promise> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get a row by its unique ID. This endpoint response returns a JSON object + * with the row data. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async getRow(databaseId: string, tableId: string, rowId: string, queries?: string[]): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Create or update a Row. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @throws {AppwriteException} + * @returns {Promise} + */ + async upsertRow(databaseId: string, tableId: string, rowId: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update a row by its unique ID. Using the patch method you can pass only + * specific fields that will get updated. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {object} data + * @param {string[]} permissions + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateRow(databaseId: string, tableId: string, rowId: string, data?: object, permissions?: string[]): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Delete a row by its unique ID. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteRow(databaseId: string, tableId: string, rowId: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Decrement a specific column of a row by a given value. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {string} column + * @param {number} value + * @param {number} min + * @throws {AppwriteException} + * @returns {Promise} + */ + async decrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if (typeof column === 'undefined') { + throw new AppwriteException('Missing required parameter: "column"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId).replace('{column}', column); + const payload: Payload = {}; + + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Increment a specific column of a row by a given value. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {string} column + * @param {number} value + * @param {number} max + * @throws {AppwriteException} + * @returns {Promise} + */ + async incrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if (typeof column === 'undefined') { + throw new AppwriteException('Missing required parameter: "column"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId).replace('{column}', column); + const payload: Payload = {}; + + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } +} diff --git a/test/services/databases.test.ts b/test/services/databases.test.ts index a2d03e0..aa77fc3 100644 --- a/test/services/databases.test.ts +++ b/test/services/databases.test.ts @@ -847,7 +847,6 @@ describe('Databases service', () => { const response = await databases.upsertDocuments( '', '', - [], ); assertEquals(response, data); @@ -928,7 +927,6 @@ describe('Databases service', () => { '', '', '', - {}, ); assertEquals(response, data); diff --git a/test/services/tables.test.ts b/test/services/tables.test.ts new file mode 100644 index 0000000..15a26d2 --- /dev/null +++ b/test/services/tables.test.ts @@ -0,0 +1,1019 @@ +import {afterEach, describe, it as test} from "https://deno.land/std@0.204.0/testing/bdd.ts"; +import {restore, stub} from "https://deno.land/std@0.204.0/testing/mock.ts"; +import {assertEquals} from "https://deno.land/std@0.204.0/assert/assert_equals.ts"; +import { Tables } from "../../src/services/tables.ts"; +import {Client} from "../../src/client.ts"; +import {InputFile} from "../../src/inputFile.ts" + +describe('Tables service', () => { + const client = new Client(); + const tables = new Tables(client); + + afterEach(() => restore()) + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'tables': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.list( + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.create( + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.get( + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method update()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.update( + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method delete()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tables.delete( + '', + '', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method listColumns()', async () => { + const data = { + 'total': 5, + 'columns': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.listColumns( + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createBooleanColumn()', async () => { + const data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createBooleanColumn( + '', + '', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateBooleanColumn()', async () => { + const data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateBooleanColumn( + '', + '', + '', + true, + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createDatetimeColumn()', async () => { + const data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'datetime',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createDatetimeColumn( + '', + '', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateDatetimeColumn()', async () => { + const data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'datetime',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateDatetimeColumn( + '', + '', + '', + true, + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createEmailColumn()', async () => { + const data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'email',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createEmailColumn( + '', + '', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateEmailColumn()', async () => { + const data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'email',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateEmailColumn( + '', + '', + '', + true, + 'email@example.com', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createEnumColumn()', async () => { + const data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'elements': [], + 'format': 'enum',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createEnumColumn( + '', + '', + '', + [], + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateEnumColumn()', async () => { + const data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'elements': [], + 'format': 'enum',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateEnumColumn( + '', + '', + '', + [], + true, + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createFloatColumn()', async () => { + const data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createFloatColumn( + '', + '', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateFloatColumn()', async () => { + const data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateFloatColumn( + '', + '', + '', + true, + 1.0, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createIntegerColumn()', async () => { + const data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createIntegerColumn( + '', + '', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateIntegerColumn()', async () => { + const data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateIntegerColumn( + '', + '', + '', + true, + 1, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createIpColumn()', async () => { + const data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'ip',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createIpColumn( + '', + '', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateIpColumn()', async () => { + const data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'ip',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateIpColumn( + '', + '', + '', + true, + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createRelationshipColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'relatedTable': 'table', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createRelationshipColumn( + '', + '', + '', + 'oneToOne', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createStringColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createStringColumn( + '', + '', + '', + 1, + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateStringColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateStringColumn( + '', + '', + '', + true, + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createUrlColumn()', async () => { + const data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'url',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createUrlColumn( + '', + '', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateUrlColumn()', async () => { + const data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'url',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateUrlColumn( + '', + '', + '', + true, + 'https://example.com', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method getColumn()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tables.getColumn( + '', + '', + '', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method deleteColumn()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tables.deleteColumn( + '', + '', + '', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method updateRelationshipColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'relatedTable': 'table', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateRelationshipColumn( + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method listIndexes()', async () => { + const data = { + 'total': 5, + 'indexes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.listIndexes( + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createIndex()', async () => { + const data = { + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'columns': [], + 'lengths': [], + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createIndex( + '', + '', + '', + 'key', + [], + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method getIndex()', async () => { + const data = { + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'columns': [], + 'lengths': [], + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.getIndex( + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method deleteIndex()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tables.deleteIndex( + '', + '', + '', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method listRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.listRows( + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createRow( + '', + '', + '', + {}, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.createRows( + '', + '', + [], + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method upsertRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.upsertRows( + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateRows( + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method deleteRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.deleteRows( + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method getRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.getRow( + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method upsertRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.upsertRow( + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.updateRow( + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method deleteRow()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tables.deleteRow( + '', + '', + '', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method decrementRowColumn()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.decrementRowColumn( + '', + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method incrementRowColumn()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tables.incrementRowColumn( + '', + '', + '', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + }) From 2204590824360c4edb7ce696e28a96e811c453a7 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:42:45 +0000 Subject: [PATCH 3/5] chore: regen to 1.7.x --- README.md | 4 +- docs/examples/databases/create-document.md | 5 +- docs/examples/databases/create-documents.md | 2 +- docs/examples/databases/upsert-document.md | 9 +- docs/examples/databases/upsert-documents.md | 5 +- docs/examples/tables/create-boolean-column.md | 17 - .../examples/tables/create-datetime-column.md | 17 - docs/examples/tables/create-email-column.md | 17 - docs/examples/tables/create-enum-column.md | 18 - docs/examples/tables/create-float-column.md | 19 - docs/examples/tables/create-index.md | 18 - docs/examples/tables/create-integer-column.md | 19 - docs/examples/tables/create-ip-column.md | 17 - .../tables/create-relationship-column.md | 19 - docs/examples/tables/create-row.md | 17 - docs/examples/tables/create-rows.md | 14 - docs/examples/tables/create-string-column.md | 19 - docs/examples/tables/create-url-column.md | 17 - docs/examples/tables/create.md | 17 - docs/examples/tables/decrement-row-column.md | 17 - docs/examples/tables/delete-column.md | 14 - docs/examples/tables/delete-index.md | 14 - docs/examples/tables/delete-row.md | 14 - docs/examples/tables/delete-rows.md | 14 - docs/examples/tables/delete.md | 13 - docs/examples/tables/get-column.md | 14 - docs/examples/tables/get-index.md | 14 - docs/examples/tables/get-row.md | 15 - docs/examples/tables/get.md | 13 - docs/examples/tables/increment-row-column.md | 17 - docs/examples/tables/list-columns.md | 14 - docs/examples/tables/list-indexes.md | 14 - docs/examples/tables/list-rows.md | 14 - docs/examples/tables/list.md | 14 - docs/examples/tables/update-boolean-column.md | 17 - .../examples/tables/update-datetime-column.md | 17 - docs/examples/tables/update-email-column.md | 17 - docs/examples/tables/update-enum-column.md | 18 - docs/examples/tables/update-float-column.md | 19 - docs/examples/tables/update-integer-column.md | 19 - docs/examples/tables/update-ip-column.md | 17 - .../tables/update-relationship-column.md | 16 - docs/examples/tables/update-row.md | 16 - docs/examples/tables/update-rows.md | 15 - docs/examples/tables/update-string-column.md | 18 - docs/examples/tables/update-url-column.md | 17 - docs/examples/tables/update.md | 17 - docs/examples/tables/upsert-row.md | 15 - docs/examples/tables/upsert-rows.md | 13 - mod.ts | 2 - src/client.ts | 6 +- src/models.d.ts | 713 +----- src/services/account.ts | 2 - src/services/databases.ts | 72 +- src/services/tables.ts | 2169 ----------------- test/services/databases.test.ts | 2 + test/services/tables.test.ts | 1019 -------- 57 files changed, 74 insertions(+), 4647 deletions(-) delete mode 100644 docs/examples/tables/create-boolean-column.md delete mode 100644 docs/examples/tables/create-datetime-column.md delete mode 100644 docs/examples/tables/create-email-column.md delete mode 100644 docs/examples/tables/create-enum-column.md delete mode 100644 docs/examples/tables/create-float-column.md delete mode 100644 docs/examples/tables/create-index.md delete mode 100644 docs/examples/tables/create-integer-column.md delete mode 100644 docs/examples/tables/create-ip-column.md delete mode 100644 docs/examples/tables/create-relationship-column.md delete mode 100644 docs/examples/tables/create-row.md delete mode 100644 docs/examples/tables/create-rows.md delete mode 100644 docs/examples/tables/create-string-column.md delete mode 100644 docs/examples/tables/create-url-column.md delete mode 100644 docs/examples/tables/create.md delete mode 100644 docs/examples/tables/decrement-row-column.md delete mode 100644 docs/examples/tables/delete-column.md delete mode 100644 docs/examples/tables/delete-index.md delete mode 100644 docs/examples/tables/delete-row.md delete mode 100644 docs/examples/tables/delete-rows.md delete mode 100644 docs/examples/tables/delete.md delete mode 100644 docs/examples/tables/get-column.md delete mode 100644 docs/examples/tables/get-index.md delete mode 100644 docs/examples/tables/get-row.md delete mode 100644 docs/examples/tables/get.md delete mode 100644 docs/examples/tables/increment-row-column.md delete mode 100644 docs/examples/tables/list-columns.md delete mode 100644 docs/examples/tables/list-indexes.md delete mode 100644 docs/examples/tables/list-rows.md delete mode 100644 docs/examples/tables/list.md delete mode 100644 docs/examples/tables/update-boolean-column.md delete mode 100644 docs/examples/tables/update-datetime-column.md delete mode 100644 docs/examples/tables/update-email-column.md delete mode 100644 docs/examples/tables/update-enum-column.md delete mode 100644 docs/examples/tables/update-float-column.md delete mode 100644 docs/examples/tables/update-integer-column.md delete mode 100644 docs/examples/tables/update-ip-column.md delete mode 100644 docs/examples/tables/update-relationship-column.md delete mode 100644 docs/examples/tables/update-row.md delete mode 100644 docs/examples/tables/update-rows.md delete mode 100644 docs/examples/tables/update-string-column.md delete mode 100644 docs/examples/tables/update-url-column.md delete mode 100644 docs/examples/tables/update.md delete mode 100644 docs/examples/tables/upsert-row.md delete mode 100644 docs/examples/tables/upsert-rows.md delete mode 100644 src/services/tables.ts delete mode 100644 test/services/tables.test.ts diff --git a/README.md b/README.md index ff3c5be..e0a6459 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Deno SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-deno.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-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.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-deno/releases).** +**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-deno/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 Deno 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) diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index f18b4f3..be8a1bd 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,9 +2,8 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // Your secret API key - .setJWT(''); // Your secret JSON Web Token + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with const databases = new Databases(client); diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index fa3fe84..26c9796 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -2,7 +2,7 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setAdmin('') // + .setProject('') // Your project ID .setKey(''); // Your secret API key const databases = new Databases(client); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index a8a61ca..f05100e 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -2,14 +2,15 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // Your secret API key - .setJWT(''); // Your secret JSON Web Token + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with const databases = new Databases(client); const response = await databases.upsertDocument( '', // databaseId '', // collectionId - '' // documentId + '', // documentId + {}, // data + ["read("any")"] // permissions (optional) ); diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index bf9e7de..0cd804b 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -2,12 +2,13 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setAdmin('') // + .setProject('') // Your project ID .setKey(''); // Your secret API key const databases = new Databases(client); const response = await databases.upsertDocuments( '', // databaseId - '' // collectionId + '', // collectionId + [] // documents ); diff --git a/docs/examples/tables/create-boolean-column.md b/docs/examples/tables/create-boolean-column.md deleted file mode 100644 index 3f9abc8..0000000 --- a/docs/examples/tables/create-boolean-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createBooleanColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - false, // default (optional) - false // array (optional) -); diff --git a/docs/examples/tables/create-datetime-column.md b/docs/examples/tables/create-datetime-column.md deleted file mode 100644 index 898b67a..0000000 --- a/docs/examples/tables/create-datetime-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createDatetimeColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - '', // default (optional) - false // array (optional) -); diff --git a/docs/examples/tables/create-email-column.md b/docs/examples/tables/create-email-column.md deleted file mode 100644 index 82872e4..0000000 --- a/docs/examples/tables/create-email-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createEmailColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - 'email@example.com', // default (optional) - false // array (optional) -); diff --git a/docs/examples/tables/create-enum-column.md b/docs/examples/tables/create-enum-column.md deleted file mode 100644 index afbb8d0..0000000 --- a/docs/examples/tables/create-enum-column.md +++ /dev/null @@ -1,18 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createEnumColumn( - '', // databaseId - '', // tableId - '', // key - [], // elements - false, // required - '', // default (optional) - false // array (optional) -); diff --git a/docs/examples/tables/create-float-column.md b/docs/examples/tables/create-float-column.md deleted file mode 100644 index 44658bb..0000000 --- a/docs/examples/tables/create-float-column.md +++ /dev/null @@ -1,19 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createFloatColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - null, // min (optional) - null, // max (optional) - null, // default (optional) - false // array (optional) -); diff --git a/docs/examples/tables/create-index.md b/docs/examples/tables/create-index.md deleted file mode 100644 index c255189..0000000 --- a/docs/examples/tables/create-index.md +++ /dev/null @@ -1,18 +0,0 @@ -import { Client, Tables, IndexType } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createIndex( - '', // databaseId - '', // tableId - '', // key - IndexType.Key, // type - [], // columns - [], // orders (optional) - [] // lengths (optional) -); diff --git a/docs/examples/tables/create-integer-column.md b/docs/examples/tables/create-integer-column.md deleted file mode 100644 index 0f1721b..0000000 --- a/docs/examples/tables/create-integer-column.md +++ /dev/null @@ -1,19 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createIntegerColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - null, // min (optional) - null, // max (optional) - null, // default (optional) - false // array (optional) -); diff --git a/docs/examples/tables/create-ip-column.md b/docs/examples/tables/create-ip-column.md deleted file mode 100644 index ca96de6..0000000 --- a/docs/examples/tables/create-ip-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createIpColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - '', // default (optional) - false // array (optional) -); diff --git a/docs/examples/tables/create-relationship-column.md b/docs/examples/tables/create-relationship-column.md deleted file mode 100644 index 8c7e26e..0000000 --- a/docs/examples/tables/create-relationship-column.md +++ /dev/null @@ -1,19 +0,0 @@ -import { Client, Tables, RelationshipType, RelationMutate } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createRelationshipColumn( - '', // databaseId - '', // tableId - '', // relatedTableId - RelationshipType.OneToOne, // type - false, // twoWay (optional) - '', // key (optional) - '', // twoWayKey (optional) - RelationMutate.Cascade // onDelete (optional) -); diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md deleted file mode 100644 index 12cec49..0000000 --- a/docs/examples/tables/create-row.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // Your secret API key - .setJWT(''); // Your secret JSON Web Token - -const tables = new Tables(client); - -const response = await tables.createRow( - '', // databaseId - '', // tableId - '', // rowId - {}, // data - ["read("any")"] // permissions (optional) -); diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md deleted file mode 100644 index 6c4f7d5..0000000 --- a/docs/examples/tables/create-rows.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setAdmin('') // - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createRows( - '', // databaseId - '', // tableId - [] // rows -); diff --git a/docs/examples/tables/create-string-column.md b/docs/examples/tables/create-string-column.md deleted file mode 100644 index db7ac8a..0000000 --- a/docs/examples/tables/create-string-column.md +++ /dev/null @@ -1,19 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createStringColumn( - '', // databaseId - '', // tableId - '', // key - 1, // size - false, // required - '', // default (optional) - false, // array (optional) - false // encrypt (optional) -); diff --git a/docs/examples/tables/create-url-column.md b/docs/examples/tables/create-url-column.md deleted file mode 100644 index 8d6f127..0000000 --- a/docs/examples/tables/create-url-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.createUrlColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - 'https://example.com', // default (optional) - false // array (optional) -); diff --git a/docs/examples/tables/create.md b/docs/examples/tables/create.md deleted file mode 100644 index 9c75c22..0000000 --- a/docs/examples/tables/create.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.create( - '', // databaseId - '', // tableId - '', // name - ["read("any")"], // permissions (optional) - false, // rowSecurity (optional) - false // enabled (optional) -); diff --git a/docs/examples/tables/decrement-row-column.md b/docs/examples/tables/decrement-row-column.md deleted file mode 100644 index e561acc..0000000 --- a/docs/examples/tables/decrement-row-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.decrementRowColumn( - '', // databaseId - '', // tableId - '', // rowId - '', // column - null, // value (optional) - null // min (optional) -); diff --git a/docs/examples/tables/delete-column.md b/docs/examples/tables/delete-column.md deleted file mode 100644 index 89900bf..0000000 --- a/docs/examples/tables/delete-column.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.deleteColumn( - '', // databaseId - '', // tableId - '' // key -); diff --git a/docs/examples/tables/delete-index.md b/docs/examples/tables/delete-index.md deleted file mode 100644 index a17791c..0000000 --- a/docs/examples/tables/delete-index.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.deleteIndex( - '', // databaseId - '', // tableId - '' // key -); diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md deleted file mode 100644 index 8f30eae..0000000 --- a/docs/examples/tables/delete-row.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const tables = new Tables(client); - -const response = await tables.deleteRow( - '', // databaseId - '', // tableId - '' // rowId -); diff --git a/docs/examples/tables/delete-rows.md b/docs/examples/tables/delete-rows.md deleted file mode 100644 index c5aa88f..0000000 --- a/docs/examples/tables/delete-rows.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.deleteRows( - '', // databaseId - '', // tableId - [] // queries (optional) -); diff --git a/docs/examples/tables/delete.md b/docs/examples/tables/delete.md deleted file mode 100644 index 36df137..0000000 --- a/docs/examples/tables/delete.md +++ /dev/null @@ -1,13 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.delete( - '', // databaseId - '' // tableId -); diff --git a/docs/examples/tables/get-column.md b/docs/examples/tables/get-column.md deleted file mode 100644 index 8a56af6..0000000 --- a/docs/examples/tables/get-column.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.getColumn( - '', // databaseId - '', // tableId - '' // key -); diff --git a/docs/examples/tables/get-index.md b/docs/examples/tables/get-index.md deleted file mode 100644 index 61105dc..0000000 --- a/docs/examples/tables/get-index.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.getIndex( - '', // databaseId - '', // tableId - '' // key -); diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md deleted file mode 100644 index 674ea3e..0000000 --- a/docs/examples/tables/get-row.md +++ /dev/null @@ -1,15 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const tables = new Tables(client); - -const response = await tables.getRow( - '', // databaseId - '', // tableId - '', // rowId - [] // queries (optional) -); diff --git a/docs/examples/tables/get.md b/docs/examples/tables/get.md deleted file mode 100644 index cc1dcb8..0000000 --- a/docs/examples/tables/get.md +++ /dev/null @@ -1,13 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.get( - '', // databaseId - '' // tableId -); diff --git a/docs/examples/tables/increment-row-column.md b/docs/examples/tables/increment-row-column.md deleted file mode 100644 index 9779d87..0000000 --- a/docs/examples/tables/increment-row-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.incrementRowColumn( - '', // databaseId - '', // tableId - '', // rowId - '', // column - null, // value (optional) - null // max (optional) -); diff --git a/docs/examples/tables/list-columns.md b/docs/examples/tables/list-columns.md deleted file mode 100644 index 63ec077..0000000 --- a/docs/examples/tables/list-columns.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.listColumns( - '', // databaseId - '', // tableId - [] // queries (optional) -); diff --git a/docs/examples/tables/list-indexes.md b/docs/examples/tables/list-indexes.md deleted file mode 100644 index 587d19f..0000000 --- a/docs/examples/tables/list-indexes.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.listIndexes( - '', // databaseId - '', // tableId - [] // queries (optional) -); diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md deleted file mode 100644 index 6db6bea..0000000 --- a/docs/examples/tables/list-rows.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const tables = new Tables(client); - -const response = await tables.listRows( - '', // databaseId - '', // tableId - [] // queries (optional) -); diff --git a/docs/examples/tables/list.md b/docs/examples/tables/list.md deleted file mode 100644 index d4da840..0000000 --- a/docs/examples/tables/list.md +++ /dev/null @@ -1,14 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.list( - '', // databaseId - [], // queries (optional) - '' // search (optional) -); diff --git a/docs/examples/tables/update-boolean-column.md b/docs/examples/tables/update-boolean-column.md deleted file mode 100644 index 8710c27..0000000 --- a/docs/examples/tables/update-boolean-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateBooleanColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - false, // default - '' // newKey (optional) -); diff --git a/docs/examples/tables/update-datetime-column.md b/docs/examples/tables/update-datetime-column.md deleted file mode 100644 index e1ca760..0000000 --- a/docs/examples/tables/update-datetime-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateDatetimeColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - '', // default - '' // newKey (optional) -); diff --git a/docs/examples/tables/update-email-column.md b/docs/examples/tables/update-email-column.md deleted file mode 100644 index b0e2534..0000000 --- a/docs/examples/tables/update-email-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateEmailColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - 'email@example.com', // default - '' // newKey (optional) -); diff --git a/docs/examples/tables/update-enum-column.md b/docs/examples/tables/update-enum-column.md deleted file mode 100644 index 8771213..0000000 --- a/docs/examples/tables/update-enum-column.md +++ /dev/null @@ -1,18 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateEnumColumn( - '', // databaseId - '', // tableId - '', // key - [], // elements - false, // required - '', // default - '' // newKey (optional) -); diff --git a/docs/examples/tables/update-float-column.md b/docs/examples/tables/update-float-column.md deleted file mode 100644 index a2e6f55..0000000 --- a/docs/examples/tables/update-float-column.md +++ /dev/null @@ -1,19 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateFloatColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - null, // default - null, // min (optional) - null, // max (optional) - '' // newKey (optional) -); diff --git a/docs/examples/tables/update-integer-column.md b/docs/examples/tables/update-integer-column.md deleted file mode 100644 index 51ea17f..0000000 --- a/docs/examples/tables/update-integer-column.md +++ /dev/null @@ -1,19 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateIntegerColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - null, // default - null, // min (optional) - null, // max (optional) - '' // newKey (optional) -); diff --git a/docs/examples/tables/update-ip-column.md b/docs/examples/tables/update-ip-column.md deleted file mode 100644 index 4a5a1d0..0000000 --- a/docs/examples/tables/update-ip-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateIpColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - '', // default - '' // newKey (optional) -); diff --git a/docs/examples/tables/update-relationship-column.md b/docs/examples/tables/update-relationship-column.md deleted file mode 100644 index c83b820..0000000 --- a/docs/examples/tables/update-relationship-column.md +++ /dev/null @@ -1,16 +0,0 @@ -import { Client, Tables, RelationMutate } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateRelationshipColumn( - '', // databaseId - '', // tableId - '', // key - RelationMutate.Cascade, // onDelete (optional) - '' // newKey (optional) -); diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md deleted file mode 100644 index 13da561..0000000 --- a/docs/examples/tables/update-row.md +++ /dev/null @@ -1,16 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const tables = new Tables(client); - -const response = await tables.updateRow( - '', // databaseId - '', // tableId - '', // rowId - {}, // data (optional) - ["read("any")"] // permissions (optional) -); diff --git a/docs/examples/tables/update-rows.md b/docs/examples/tables/update-rows.md deleted file mode 100644 index 1bc0a18..0000000 --- a/docs/examples/tables/update-rows.md +++ /dev/null @@ -1,15 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateRows( - '', // databaseId - '', // tableId - {}, // data (optional) - [] // queries (optional) -); diff --git a/docs/examples/tables/update-string-column.md b/docs/examples/tables/update-string-column.md deleted file mode 100644 index 00dd310..0000000 --- a/docs/examples/tables/update-string-column.md +++ /dev/null @@ -1,18 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateStringColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - '', // default - 1, // size (optional) - '' // newKey (optional) -); diff --git a/docs/examples/tables/update-url-column.md b/docs/examples/tables/update-url-column.md deleted file mode 100644 index 2ebf80a..0000000 --- a/docs/examples/tables/update-url-column.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.updateUrlColumn( - '', // databaseId - '', // tableId - '', // key - false, // required - 'https://example.com', // default - '' // newKey (optional) -); diff --git a/docs/examples/tables/update.md b/docs/examples/tables/update.md deleted file mode 100644 index 43b51bd..0000000 --- a/docs/examples/tables/update.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.update( - '', // databaseId - '', // tableId - '', // name - ["read("any")"], // permissions (optional) - false, // rowSecurity (optional) - false // enabled (optional) -); diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md deleted file mode 100644 index 45e932c..0000000 --- a/docs/examples/tables/upsert-row.md +++ /dev/null @@ -1,15 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // Your secret API key - .setJWT(''); // Your secret JSON Web Token - -const tables = new Tables(client); - -const response = await tables.upsertRow( - '', // databaseId - '', // tableId - '' // rowId -); diff --git a/docs/examples/tables/upsert-rows.md b/docs/examples/tables/upsert-rows.md deleted file mode 100644 index 9e3f542..0000000 --- a/docs/examples/tables/upsert-rows.md +++ /dev/null @@ -1,13 +0,0 @@ -import { Client, Tables } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setAdmin('') // - .setKey(''); // Your secret API key - -const tables = new Tables(client); - -const response = await tables.upsertRows( - '', // databaseId - '' // tableId -); diff --git a/mod.ts b/mod.ts index 7bbd078..35c4e91 100644 --- a/mod.ts +++ b/mod.ts @@ -8,7 +8,6 @@ import { AppwriteException } from "./src/exception.ts"; import { Account } from "./src/services/account.ts"; import { Avatars } from "./src/services/avatars.ts"; import { Databases } from "./src/services/databases.ts"; -import { Tables } from "./src/services/tables.ts"; import { Functions } from "./src/services/functions.ts"; import { Graphql } from "./src/services/graphql.ts"; import { Health } from "./src/services/health.ts"; @@ -55,7 +54,6 @@ export { Account, Avatars, Databases, - Tables, Functions, Graphql, Health, diff --git a/src/client.ts b/src/client.ts index 139c77b..5e5780f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -11,12 +11,12 @@ export class Client { endpoint: string = 'https://cloud.appwrite.io/v1'; headers: Payload = { 'content-type': '', - 'user-agent' : `AppwriteDenoSDK/16.0.0 (${Deno.build.os}; ${Deno.build.arch})`, + 'user-agent' : `AppwriteDenoSDK/15.0.0 (${Deno.build.os}; ${Deno.build.arch})`, 'x-sdk-name': 'Deno', 'x-sdk-platform': 'server', 'x-sdk-language': 'deno', - 'x-sdk-version': '16.0.0', - 'X-Appwrite-Response-Format':'1.8.0', + 'x-sdk-version': '15.0.0', + 'X-Appwrite-Response-Format':'1.7.0', }; /** diff --git a/src/models.d.ts b/src/models.d.ts index a25e7a9..b47182e 100644 --- a/src/models.d.ts +++ b/src/models.d.ts @@ -1,23 +1,10 @@ export namespace Models { - /** - * Rows List - */ - export type RowList = { - /** - * Total number of rows rows that matched your query. - */ - total: number; - /** - * List of rows. - */ - rows: Row[]; - } /** * Documents List */ export type DocumentList = { /** - * Total number of documents rows that matched your query. + * Total number of documents documents that matched your query. */ total: number; /** @@ -25,25 +12,12 @@ export namespace Models { */ documents: Document[]; } - /** - * Tables List - */ - export type TableList = { - /** - * Total number of tables rows that matched your query. - */ - total: number; - /** - * List of tables. - */ - tables: Table[]; - } /** * Collections List */ export type CollectionList = { /** - * Total number of collections rows that matched your query. + * Total number of collections documents that matched your query. */ total: number; /** @@ -56,7 +30,7 @@ export namespace Models { */ export type DatabaseList = { /** - * Total number of databases rows that matched your query. + * Total number of databases documents that matched your query. */ total: number; /** @@ -69,7 +43,7 @@ export namespace Models { */ export type IndexList = { /** - * Total number of indexes rows that matched your query. + * Total number of indexes documents that matched your query. */ total: number; /** @@ -77,25 +51,12 @@ export namespace Models { */ indexes: Index[]; } - /** - * Column Indexes List - */ - export type ColumnIndexList = { - /** - * Total number of indexes rows that matched your query. - */ - total: number; - /** - * List of indexes. - */ - indexes: ColumnIndex[]; - } /** * Users List */ export type UserList = { /** - * Total number of users rows that matched your query. + * Total number of users documents that matched your query. */ total: number; /** @@ -108,7 +69,7 @@ export namespace Models { */ export type SessionList = { /** - * Total number of sessions rows that matched your query. + * Total number of sessions documents that matched your query. */ total: number; /** @@ -121,7 +82,7 @@ export namespace Models { */ export type IdentityList = { /** - * Total number of identities rows that matched your query. + * Total number of identities documents that matched your query. */ total: number; /** @@ -134,7 +95,7 @@ export namespace Models { */ export type LogList = { /** - * Total number of logs rows that matched your query. + * Total number of logs documents that matched your query. */ total: number; /** @@ -147,7 +108,7 @@ export namespace Models { */ export type FileList = { /** - * Total number of files rows that matched your query. + * Total number of files documents that matched your query. */ total: number; /** @@ -160,7 +121,7 @@ export namespace Models { */ export type BucketList = { /** - * Total number of buckets rows that matched your query. + * Total number of buckets documents that matched your query. */ total: number; /** @@ -173,7 +134,7 @@ export namespace Models { */ export type ResourceTokenList = { /** - * Total number of tokens rows that matched your query. + * Total number of tokens documents that matched your query. */ total: number; /** @@ -186,7 +147,7 @@ export namespace Models { */ export type TeamList = { /** - * Total number of teams rows that matched your query. + * Total number of teams documents that matched your query. */ total: number; /** @@ -199,7 +160,7 @@ export namespace Models { */ export type MembershipList = { /** - * Total number of memberships rows that matched your query. + * Total number of memberships documents that matched your query. */ total: number; /** @@ -212,7 +173,7 @@ export namespace Models { */ export type SiteList = { /** - * Total number of sites rows that matched your query. + * Total number of sites documents that matched your query. */ total: number; /** @@ -225,7 +186,7 @@ export namespace Models { */ export type FunctionList = { /** - * Total number of functions rows that matched your query. + * Total number of functions documents that matched your query. */ total: number; /** @@ -238,7 +199,7 @@ export namespace Models { */ export type FrameworkList = { /** - * Total number of frameworks rows that matched your query. + * Total number of frameworks documents that matched your query. */ total: number; /** @@ -251,7 +212,7 @@ export namespace Models { */ export type RuntimeList = { /** - * Total number of runtimes rows that matched your query. + * Total number of runtimes documents that matched your query. */ total: number; /** @@ -264,7 +225,7 @@ export namespace Models { */ export type DeploymentList = { /** - * Total number of deployments rows that matched your query. + * Total number of deployments documents that matched your query. */ total: number; /** @@ -277,7 +238,7 @@ export namespace Models { */ export type ExecutionList = { /** - * Total number of executions rows that matched your query. + * Total number of executions documents that matched your query. */ total: number; /** @@ -290,7 +251,7 @@ export namespace Models { */ export type CountryList = { /** - * Total number of countries rows that matched your query. + * Total number of countries documents that matched your query. */ total: number; /** @@ -303,7 +264,7 @@ export namespace Models { */ export type ContinentList = { /** - * Total number of continents rows that matched your query. + * Total number of continents documents that matched your query. */ total: number; /** @@ -316,7 +277,7 @@ export namespace Models { */ export type LanguageList = { /** - * Total number of languages rows that matched your query. + * Total number of languages documents that matched your query. */ total: number; /** @@ -329,7 +290,7 @@ export namespace Models { */ export type CurrencyList = { /** - * Total number of currencies rows that matched your query. + * Total number of currencies documents that matched your query. */ total: number; /** @@ -342,7 +303,7 @@ export namespace Models { */ export type PhoneList = { /** - * Total number of phones rows that matched your query. + * Total number of phones documents that matched your query. */ total: number; /** @@ -355,7 +316,7 @@ export namespace Models { */ export type VariableList = { /** - * Total number of variables rows that matched your query. + * Total number of variables documents that matched your query. */ total: number; /** @@ -368,7 +329,7 @@ export namespace Models { */ export type LocaleCodeList = { /** - * Total number of localeCodes rows that matched your query. + * Total number of localeCodes documents that matched your query. */ total: number; /** @@ -381,7 +342,7 @@ export namespace Models { */ export type ProviderList = { /** - * Total number of providers rows that matched your query. + * Total number of providers documents that matched your query. */ total: number; /** @@ -394,7 +355,7 @@ export namespace Models { */ export type MessageList = { /** - * Total number of messages rows that matched your query. + * Total number of messages documents that matched your query. */ total: number; /** @@ -407,7 +368,7 @@ export namespace Models { */ export type TopicList = { /** - * Total number of topics rows that matched your query. + * Total number of topics documents that matched your query. */ total: number; /** @@ -420,7 +381,7 @@ export namespace Models { */ export type SubscriberList = { /** - * Total number of subscribers rows that matched your query. + * Total number of subscribers documents that matched your query. */ total: number; /** @@ -433,7 +394,7 @@ export namespace Models { */ export type TargetList = { /** - * Total number of targets rows that matched your query. + * Total number of targets documents that matched your query. */ total: number; /** @@ -446,7 +407,7 @@ export namespace Models { */ export type SpecificationList = { /** - * Total number of specifications rows that matched your query. + * Total number of specifications documents that matched your query. */ total: number; /** @@ -1015,542 +976,6 @@ export namespace Models { */ side: string; } - /** - * Table - */ - export type Table = { - /** - * Table ID. - */ - $id: string; - /** - * Table creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Table update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - */ - $permissions: string[]; - /** - * Database ID. - */ - databaseId: string; - /** - * Table name. - */ - name: string; - /** - * Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. - */ - enabled: boolean; - /** - * Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). - */ - rowSecurity: boolean; - /** - * Table columns. - */ - columns: (ColumnBoolean | ColumnInteger | ColumnFloat | ColumnEmail | ColumnEnum | ColumnUrl | ColumnIp | ColumnDatetime | ColumnRelationship | ColumnString)[]; - /** - * Table indexes. - */ - indexes: ColumnIndex[]; - } - /** - * Columns List - */ - export type ColumnList = { - /** - * Total number of columns in the given table. - */ - total: number; - /** - * List of columns. - */ - columns: (ColumnBoolean | ColumnInteger | ColumnFloat | ColumnEmail | ColumnEnum | ColumnUrl | ColumnIp | ColumnDatetime | ColumnRelationship | ColumnString)[]; - } - /** - * ColumnString - */ - export type ColumnString = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an column. - */ - error: string; - /** - * Is column required? - */ - required: boolean; - /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Column size. - */ - size: number; - /** - * Default value for column when not provided. Cannot be set when column is required. - */ - xdefault?: string; - /** - * Defines whether this column is encrypted or not. - */ - encrypt?: boolean; - } - /** - * ColumnInteger - */ - export type ColumnInteger = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an column. - */ - error: string; - /** - * Is column required? - */ - required: boolean; - /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Minimum value to enforce for new documents. - */ - min?: number; - /** - * Maximum value to enforce for new documents. - */ - max?: number; - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - */ - xdefault?: number; - } - /** - * ColumnFloat - */ - export type ColumnFloat = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an column. - */ - error: string; - /** - * Is column required? - */ - required: boolean; - /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Minimum value to enforce for new documents. - */ - min?: number; - /** - * Maximum value to enforce for new documents. - */ - max?: number; - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - */ - xdefault?: number; - } - /** - * ColumnBoolean - */ - export type ColumnBoolean = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an column. - */ - error: string; - /** - * Is column required? - */ - required: boolean; - /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - */ - xdefault?: boolean; - } - /** - * ColumnEmail - */ - export type ColumnEmail = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an column. - */ - error: string; - /** - * Is column required? - */ - required: boolean; - /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * String format. - */ - format: string; - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - */ - xdefault?: string; - } - /** - * ColumnEnum - */ - export type ColumnEnum = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an column. - */ - error: string; - /** - * Is column required? - */ - required: boolean; - /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Array of elements in enumerated type. - */ - elements: string[]; - /** - * String format. - */ - format: string; - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - */ - xdefault?: string; - } - /** - * ColumnIP - */ - export type ColumnIp = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an column. - */ - error: string; - /** - * Is column required? - */ - required: boolean; - /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * String format. - */ - format: string; - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - */ - xdefault?: string; - } - /** - * ColumnURL - */ - export type ColumnUrl = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an column. - */ - error: string; - /** - * Is column required? - */ - required: boolean; - /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * String format. - */ - format: string; - /** - * Default value for column when not provided. Cannot be set when column is required. - */ - xdefault?: string; - } - /** - * ColumnDatetime - */ - export type ColumnDatetime = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an column. - */ - error: string; - /** - * Is column required? - */ - required: boolean; - /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * ISO 8601 format. - */ - format: string; - /** - * Default value for attribute when not provided. Only null is optional - */ - xdefault?: string; - } - /** - * ColumnRelationship - */ - export type ColumnRelationship = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an column. - */ - error: string; - /** - * Is column required? - */ - required: boolean; - /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * The ID of the related table. - */ - relatedTable: string; - /** - * The type of the relationship. - */ - relationType: string; - /** - * Is the relationship two-way? - */ - twoWay: boolean; - /** - * The key of the two-way relationship. - */ - twoWayKey: string; - /** - * How deleting the parent document will propagate to child documents. - */ - onDelete: string; - /** - * Whether this is the parent or child side of the relationship - */ - side: string; - } /** * Index */ @@ -1592,80 +1017,6 @@ export namespace Models { */ $updatedAt: string; } - /** - * Index - */ - export type ColumnIndex = { - /** - * Index Key. - */ - key: string; - /** - * Index type. - */ - type: string; - /** - * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: string; - /** - * Error message. Displays error generated on failure of creating or deleting an index. - */ - error: string; - /** - * Index columns. - */ - columns: string[]; - /** - * Index columns length. - */ - lengths: number[]; - /** - * Index orders. - */ - orders?: string[]; - /** - * Index creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Index update date in ISO 8601 format. - */ - $updatedAt: string; - } - /** - * Row - */ - export type Row = { - /** - * Row ID. - */ - $id: string; - /** - * Row automatically incrementing ID. - */ - $sequence: number; - /** - * Table ID. - */ - $tableId: string; - /** - * Database ID. - */ - $databaseId: string; - /** - * Row creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Row update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - */ - $permissions: string[]; - } /** * Document */ diff --git a/src/services/account.ts b/src/services/account.ts index 29a42b8..8969794 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -876,7 +876,6 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated. */ async updateMagicURLSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { @@ -915,7 +914,6 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated. */ async updatePhoneSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { diff --git a/src/services/databases.ts b/src/services/databases.ts index 816e1cc..9881842 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -192,7 +192,6 @@ export class Databases extends Service { * @param {string} search * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.list` instead. */ async listCollections(databaseId: string, queries?: string[], search?: string): Promise { if (typeof databaseId === 'undefined') { @@ -233,7 +232,6 @@ export class Databases extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.create` instead. */ async createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -284,7 +282,6 @@ export class Databases extends Service { * @param {string} collectionId * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.get` instead. */ async getCollection(databaseId: string, collectionId: string): Promise { if (typeof databaseId === 'undefined') { @@ -318,7 +315,6 @@ export class Databases extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.update` instead. */ async updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -366,7 +362,6 @@ export class Databases extends Service { * @param {string} collectionId * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.delete` instead. */ async deleteCollection(databaseId: string, collectionId: string): Promise { if (typeof databaseId === 'undefined') { @@ -398,7 +393,6 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.listColumns` instead. */ async listAttributes(databaseId: string, collectionId: string, queries?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -437,7 +431,6 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createBooleanColumn` instead. */ async createBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -493,7 +486,6 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateBooleanColumn` instead. */ async updateBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -549,7 +541,6 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createDatetimeColumn` instead. */ async createDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -605,7 +596,6 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateDatetimeColumn` instead. */ async updateDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -662,7 +652,6 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createEmailColumn` instead. */ async createEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -719,7 +708,6 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateEmailColumn` instead. */ async updateEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -765,8 +753,8 @@ export class Databases extends Service { ); } /** - * Create an enum attribute. The `elements` param acts as a white-list of - * accepted values for this attribute. + * Create an enumeration attribute. The `elements` param acts as a white-list + * of accepted values for this attribute. * * * @param {string} databaseId @@ -778,7 +766,6 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createEnumColumn` instead. */ async createEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -843,7 +830,6 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateEnumColumn` instead. */ async updateEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -910,7 +896,6 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createFloatColumn` instead. */ async createFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -975,7 +960,6 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateFloatColumn` instead. */ async updateFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1041,7 +1025,6 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createIntegerColumn` instead. */ async createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -1106,7 +1089,6 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateIntegerColumn` instead. */ async updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1169,7 +1151,6 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createIpColumn` instead. */ async createIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -1226,7 +1207,6 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateIpColumn` instead. */ async updateIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1286,7 +1266,6 @@ export class Databases extends Service { * @param {RelationMutate} onDelete * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createRelationshipColumn` instead. */ async createRelationshipAttribute(databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise { if (typeof databaseId === 'undefined') { @@ -1350,7 +1329,6 @@ export class Databases extends Service { * @param {boolean} encrypt * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createStringColumn` instead. */ async createStringAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -1418,7 +1396,6 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateStringColumn` instead. */ async updateStringAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1478,7 +1455,6 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createUrlColumn` instead. */ async createUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { if (typeof databaseId === 'undefined') { @@ -1535,7 +1511,6 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateUrlColumn` instead. */ async updateUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1588,7 +1563,6 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.getColumn` instead. */ async getAttribute(databaseId: string, collectionId: string, key: string): Promise { if (typeof databaseId === 'undefined') { @@ -1623,7 +1597,6 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.deleteColumn` instead. */ async deleteAttribute(databaseId: string, collectionId: string, key: string): Promise { if (typeof databaseId === 'undefined') { @@ -1663,7 +1636,6 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateRelationshipColumn` instead. */ async updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise { if (typeof databaseId === 'undefined') { @@ -1706,7 +1678,6 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead. */ async listDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise> { if (typeof databaseId === 'undefined') { @@ -1746,7 +1717,6 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead. */ async createDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -1802,7 +1772,6 @@ export class Databases extends Service { * @param {object[]} documents * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead. */ async createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise> { if (typeof databaseId === 'undefined') { @@ -1846,11 +1815,11 @@ export class Databases extends Service { * * @param {string} databaseId * @param {string} collectionId + * @param {object[]} documents * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.upsertRows` instead. */ - async upsertDocuments(databaseId: string, collectionId: string): Promise> { + async upsertDocuments(databaseId: string, collectionId: string, documents: object[]): Promise> { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1859,9 +1828,16 @@ export class Databases extends Service { throw new AppwriteException('Missing required parameter: "collectionId"'); } + if (typeof documents === 'undefined') { + throw new AppwriteException('Missing required parameter: "documents"'); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; + if (typeof documents !== 'undefined') { + payload['documents'] = documents; + } return await this.client.call( 'put', apiPath, @@ -1887,7 +1863,6 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateRows` instead. */ async updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[]): Promise> { if (typeof databaseId === 'undefined') { @@ -1930,7 +1905,6 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.deleteRows` instead. */ async deleteDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise> { if (typeof databaseId === 'undefined') { @@ -1967,7 +1941,6 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead. */ async getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -2011,11 +1984,12 @@ export class Databases extends Service { * @param {string} databaseId * @param {string} collectionId * @param {string} documentId + * @param {object} data + * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead. */ - async upsertDocument(databaseId: string, collectionId: string, documentId: string): Promise { + async upsertDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -2028,9 +2002,19 @@ export class Databases extends Service { throw new AppwriteException('Missing required parameter: "documentId"'); } + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } return await this.client.call( 'put', apiPath, @@ -2052,7 +2036,6 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead. */ async updateDocument(databaseId: string, collectionId: string, documentId: string, data?: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -2094,7 +2077,6 @@ export class Databases extends Service { * @param {string} documentId * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead. */ async deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise { if (typeof databaseId === 'undefined') { @@ -2133,7 +2115,6 @@ export class Databases extends Service { * @param {number} min * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.decrementRowColumn` instead. */ async decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise { if (typeof databaseId === 'undefined') { @@ -2182,7 +2163,6 @@ export class Databases extends Service { * @param {number} max * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.incrementRowColumn` instead. */ async incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise { if (typeof databaseId === 'undefined') { @@ -2228,7 +2208,6 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.listIndexes` instead. */ async listIndexes(databaseId: string, collectionId: string, queries?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -2269,7 +2248,6 @@ export class Databases extends Service { * @param {number[]} lengths * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createIndex` instead. */ async createIndex(databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: string[], lengths?: number[]): Promise { if (typeof databaseId === 'undefined') { @@ -2328,7 +2306,6 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.getIndex` instead. */ async getIndex(databaseId: string, collectionId: string, key: string): Promise { if (typeof databaseId === 'undefined') { @@ -2363,7 +2340,6 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.deleteIndex` instead. */ async deleteIndex(databaseId: string, collectionId: string, key: string): Promise { if (typeof databaseId === 'undefined') { diff --git a/src/services/tables.ts b/src/services/tables.ts deleted file mode 100644 index 51a05b8..0000000 --- a/src/services/tables.ts +++ /dev/null @@ -1,2169 +0,0 @@ -import { basename } from "https://deno.land/std@0.122.0/path/mod.ts"; -import { Service } from '../service.ts'; -import { Payload, Client } from '../client.ts'; -import { InputFile } from '../inputFile.ts'; -import { AppwriteException } from '../exception.ts'; -import type { Models } from '../models.d.ts'; -import { Query } from '../query.ts'; -import { RelationshipType } from '../enums/relationship-type.ts'; -import { RelationMutate } from '../enums/relation-mutate.ts'; -import { IndexType } from '../enums/index-type.ts'; - -export type UploadProgress = { - $id: string; - progress: number; - sizeUploaded: number; - chunksTotal: number; - chunksUploaded: number; -} - -export class Tables extends Service { - - constructor(client: Client) - { - super(client); - } - - /** - * Get a list of all tables that belong to the provided databaseId. You can - * use the search parameter to filter your results. - * - * @param {string} databaseId - * @param {string[]} queries - * @param {string} search - * @throws {AppwriteException} - * @returns {Promise} - */ - async list(databaseId: string, queries?: string[], search?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - const apiPath = '/databases/{databaseId}/tables'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - - if (typeof search !== 'undefined') { - payload['search'] = search; - } - - return await this.client.call( - 'get', - apiPath, - { - }, - payload, - 'json' - ); - } - /** - * Create a new Table. Before using this route, you should create a new - * database resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} name - * @param {string[]} permissions - * @param {boolean} rowSecurity - * @param {boolean} enabled - * @throws {AppwriteException} - * @returns {Promise} - */ - async create(databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/databases/{databaseId}/tables'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - - if (typeof tableId !== 'undefined') { - payload['tableId'] = tableId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - if (typeof rowSecurity !== 'undefined') { - payload['rowSecurity'] = rowSecurity; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Get a table by its unique ID. This endpoint response returns a JSON object - * with the table metadata. - * - * @param {string} databaseId - * @param {string} tableId - * @throws {AppwriteException} - * @returns {Promise} - */ - async get(databaseId: string, tableId: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - return await this.client.call( - 'get', - apiPath, - { - }, - payload, - 'json' - ); - } - /** - * Update a table by its unique ID. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} name - * @param {string[]} permissions - * @param {boolean} rowSecurity - * @param {boolean} enabled - * @throws {AppwriteException} - * @returns {Promise} - */ - async update(databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - if (typeof rowSecurity !== 'undefined') { - payload['rowSecurity'] = rowSecurity; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - return await this.client.call( - 'put', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Delete a table by its unique ID. Only users with write permissions have - * access to delete this resource. - * - * @param {string} databaseId - * @param {string} tableId - * @throws {AppwriteException} - * @returns {Promise} - */ - async delete(databaseId: string, tableId: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - return await this.client.call( - 'delete', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * List attributes in the collection. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string[]} queries - * @throws {AppwriteException} - * @returns {Promise} - */ - async listColumns(databaseId: string, tableId: string, queries?: string[]): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - - return await this.client.call( - 'get', - apiPath, - { - }, - payload, - 'json' - ); - } - /** - * Create a boolean column. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {boolean} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - async createBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/boolean'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update a boolean column. Changing the `default` value will not update - * already existing rows. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {boolean} xdefault - * @param {string} newKey - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/boolean/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create a date time column according to the ISO 8601 standard. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - async createDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/datetime'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update a date time column. Changing the `default` value will not update - * already existing rows. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {string} newKey - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/datetime/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create an email column. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - async createEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/email'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update an email column. Changing the `default` value will not update - * already existing rows. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {string} newKey - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/email/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create an enumeration column. The `elements` param acts as a white-list of - * accepted values for this column. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {string[]} elements - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - async createEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/enum'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof elements !== 'undefined') { - payload['elements'] = elements; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update an enum column. Changing the `default` value will not update already - * existing rows. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {string[]} elements - * @param {boolean} required - * @param {string} xdefault - * @param {string} newKey - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/enum/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - if (typeof elements !== 'undefined') { - payload['elements'] = elements; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create a float column. Optionally, minimum and maximum values can be - * provided. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {number} min - * @param {number} max - * @param {number} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - async createFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/float'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof min !== 'undefined') { - payload['min'] = min; - } - if (typeof max !== 'undefined') { - payload['max'] = max; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update a float column. Changing the `default` value will not update already - * existing rows. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {number} xdefault - * @param {number} min - * @param {number} max - * @param {string} newKey - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/float/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof min !== 'undefined') { - payload['min'] = min; - } - if (typeof max !== 'undefined') { - payload['max'] = max; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create an integer column. Optionally, minimum and maximum values can be - * provided. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {number} min - * @param {number} max - * @param {number} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - async createIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/integer'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof min !== 'undefined') { - payload['min'] = min; - } - if (typeof max !== 'undefined') { - payload['max'] = max; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update an integer column. Changing the `default` value will not update - * already existing rows. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {number} xdefault - * @param {number} min - * @param {number} max - * @param {string} newKey - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/integer/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof min !== 'undefined') { - payload['min'] = min; - } - if (typeof max !== 'undefined') { - payload['max'] = max; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create IP address column. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - async createIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/ip'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update an ip column. Changing the `default` value will not update already - * existing rows. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {string} newKey - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/ip/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create relationship column. [Learn more about relationship - * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} relatedTableId - * @param {RelationshipType} type - * @param {boolean} twoWay - * @param {string} key - * @param {string} twoWayKey - * @param {RelationMutate} onDelete - * @throws {AppwriteException} - * @returns {Promise} - */ - async createRelationshipColumn(databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof relatedTableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "relatedTableId"'); - } - - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/relationship'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof relatedTableId !== 'undefined') { - payload['relatedTableId'] = relatedTableId; - } - if (typeof type !== 'undefined') { - payload['type'] = type; - } - if (typeof twoWay !== 'undefined') { - payload['twoWay'] = twoWay; - } - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof twoWayKey !== 'undefined') { - payload['twoWayKey'] = twoWayKey; - } - if (typeof onDelete !== 'undefined') { - payload['onDelete'] = onDelete; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create a string column. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {number} size - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @param {boolean} encrypt - * @throws {AppwriteException} - * @returns {Promise} - */ - async createStringColumn(databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof size === 'undefined') { - throw new AppwriteException('Missing required parameter: "size"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/string'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof size !== 'undefined') { - payload['size'] = size; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - if (typeof encrypt !== 'undefined') { - payload['encrypt'] = encrypt; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update a string column. Changing the `default` value will not update - * already existing rows. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {number} size - * @param {string} newKey - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateStringColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/string/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof size !== 'undefined') { - payload['size'] = size; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create a URL column. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - async createUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/url'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update an url column. Changing the `default` value will not update already - * existing rows. - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {string} newKey - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - - if (typeof xdefault === 'undefined') { - throw new AppwriteException('Missing required parameter: "xdefault"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/url/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Get column by ID. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @throws {AppwriteException} - * @returns {Promise} - */ - async getColumn(databaseId: string, tableId: string, key: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - return await this.client.call( - 'get', - apiPath, - { - }, - payload, - 'json' - ); - } - /** - * Deletes a column. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @throws {AppwriteException} - * @returns {Promise} - */ - async deleteColumn(databaseId: string, tableId: string, key: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - return await this.client.call( - 'delete', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update relationship column. [Learn more about relationship - * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {RelationMutate} onDelete - * @param {string} newKey - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateRelationshipColumn(databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/columns/{key}/relationship'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - if (typeof onDelete !== 'undefined') { - payload['onDelete'] = onDelete; - } - if (typeof newKey !== 'undefined') { - payload['newKey'] = newKey; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * List indexes in the collection. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string[]} queries - * @throws {AppwriteException} - * @returns {Promise} - */ - async listIndexes(databaseId: string, tableId: string, queries?: string[]): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - - return await this.client.call( - 'get', - apiPath, - { - }, - payload, - 'json' - ); - } - /** - * Creates an index on the attributes listed. Your index should include all - * the attributes you will query in a single request. - * Attributes can be `key`, `fulltext`, and `unique`. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @param {IndexType} type - * @param {string[]} columns - * @param {string[]} orders - * @param {number[]} lengths - * @throws {AppwriteException} - * @returns {Promise} - */ - async createIndex(databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: string[], lengths?: number[]): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); - } - - if (typeof columns === 'undefined') { - throw new AppwriteException('Missing required parameter: "columns"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof type !== 'undefined') { - payload['type'] = type; - } - if (typeof columns !== 'undefined') { - payload['columns'] = columns; - } - if (typeof orders !== 'undefined') { - payload['orders'] = orders; - } - if (typeof lengths !== 'undefined') { - payload['lengths'] = lengths; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Get index by ID. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @throws {AppwriteException} - * @returns {Promise} - */ - async getIndex(databaseId: string, tableId: string, key: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - return await this.client.call( - 'get', - apiPath, - { - }, - payload, - 'json' - ); - } - /** - * Delete an index. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} key - * @throws {AppwriteException} - * @returns {Promise} - */ - async deleteIndex(databaseId: string, tableId: string, key: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); - const payload: Payload = {}; - - return await this.client.call( - 'delete', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Get a list of all the user's rows in a given table. You can use the query - * params to filter your results. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string[]} queries - * @throws {AppwriteException} - * @returns {Promise} - */ - async listRows(databaseId: string, tableId: string, queries?: string[]): Promise> { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - - return await this.client.call( - 'get', - apiPath, - { - }, - payload, - 'json' - ); - } - /** - * Create a new Row. Before using this route, you should create a new table - * resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @param {object} data - * @param {string[]} permissions - * @throws {AppwriteException} - * @returns {Promise} - */ - async createRow(databaseId: string, tableId: string, rowId: string, data: object, permissions?: string[]): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof rowId !== 'undefined') { - payload['rowId'] = rowId; - } - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create new Rows. Before using this route, you should create a new table - * resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param {string} databaseId - * @param {string} tableId - * @param {object[]} rows - * @throws {AppwriteException} - * @returns {Promise} - */ - async createRows(databaseId: string, tableId: string, rows: object[]): Promise> { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rows === 'undefined') { - throw new AppwriteException('Missing required parameter: "rows"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof rows !== 'undefined') { - payload['rows'] = rows; - } - return await this.client.call( - 'post', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Create or update Rows. Before using this route, you should create a new - * table resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * - * @param {string} databaseId - * @param {string} tableId - * @throws {AppwriteException} - * @returns {Promise} - */ - async upsertRows(databaseId: string, tableId: string): Promise> { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - return await this.client.call( - 'put', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update all rows that match your queries, if no queries are submitted then - * all rows are updated. You can pass only specific fields to be updated. - * - * @param {string} databaseId - * @param {string} tableId - * @param {object} data - * @param {string[]} queries - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateRows(databaseId: string, tableId: string, data?: object, queries?: string[]): Promise> { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Bulk delete rows using queries, if no queries are passed then all rows are - * deleted. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string[]} queries - * @throws {AppwriteException} - * @returns {Promise} - */ - async deleteRows(databaseId: string, tableId: string, queries?: string[]): Promise> { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - return await this.client.call( - 'delete', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Get a row by its unique ID. This endpoint response returns a JSON object - * with the row data. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @param {string[]} queries - * @throws {AppwriteException} - * @returns {Promise} - */ - async getRow(databaseId: string, tableId: string, rowId: string, queries?: string[]): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); - const payload: Payload = {}; - - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - - return await this.client.call( - 'get', - apiPath, - { - }, - payload, - 'json' - ); - } - /** - * Create or update a Row. Before using this route, you should create a new - * table resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @throws {AppwriteException} - * @returns {Promise} - */ - async upsertRow(databaseId: string, tableId: string, rowId: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); - const payload: Payload = {}; - - return await this.client.call( - 'put', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Update a row by its unique ID. Using the patch method you can pass only - * specific fields that will get updated. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @param {object} data - * @param {string[]} permissions - * @throws {AppwriteException} - * @returns {Promise} - */ - async updateRow(databaseId: string, tableId: string, rowId: string, data?: object, permissions?: string[]): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); - const payload: Payload = {}; - - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Delete a row by its unique ID. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @throws {AppwriteException} - * @returns {Promise} - */ - async deleteRow(databaseId: string, tableId: string, rowId: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); - const payload: Payload = {}; - - return await this.client.call( - 'delete', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Decrement a specific column of a row by a given value. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @param {string} column - * @param {number} value - * @param {number} min - * @throws {AppwriteException} - * @returns {Promise} - */ - async decrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - if (typeof column === 'undefined') { - throw new AppwriteException('Missing required parameter: "column"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId).replace('{column}', column); - const payload: Payload = {}; - - if (typeof value !== 'undefined') { - payload['value'] = value; - } - if (typeof min !== 'undefined') { - payload['min'] = min; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } - /** - * Increment a specific column of a row by a given value. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @param {string} column - * @param {number} value - * @param {number} max - * @throws {AppwriteException} - * @returns {Promise} - */ - async incrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - if (typeof column === 'undefined') { - throw new AppwriteException('Missing required parameter: "column"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId).replace('{column}', column); - const payload: Payload = {}; - - if (typeof value !== 'undefined') { - payload['value'] = value; - } - if (typeof max !== 'undefined') { - payload['max'] = max; - } - return await this.client.call( - 'patch', - apiPath, - { - 'content-type': 'application/json', - }, - payload, - 'json' - ); - } -} diff --git a/test/services/databases.test.ts b/test/services/databases.test.ts index aa77fc3..a2d03e0 100644 --- a/test/services/databases.test.ts +++ b/test/services/databases.test.ts @@ -847,6 +847,7 @@ describe('Databases service', () => { const response = await databases.upsertDocuments( '', '', + [], ); assertEquals(response, data); @@ -927,6 +928,7 @@ describe('Databases service', () => { '', '', '', + {}, ); assertEquals(response, data); diff --git a/test/services/tables.test.ts b/test/services/tables.test.ts deleted file mode 100644 index 15a26d2..0000000 --- a/test/services/tables.test.ts +++ /dev/null @@ -1,1019 +0,0 @@ -import {afterEach, describe, it as test} from "https://deno.land/std@0.204.0/testing/bdd.ts"; -import {restore, stub} from "https://deno.land/std@0.204.0/testing/mock.ts"; -import {assertEquals} from "https://deno.land/std@0.204.0/assert/assert_equals.ts"; -import { Tables } from "../../src/services/tables.ts"; -import {Client} from "../../src/client.ts"; -import {InputFile} from "../../src/inputFile.ts" - -describe('Tables service', () => { - const client = new Client(); - const tables = new Tables(client); - - afterEach(() => restore()) - - - test('test method list()', async () => { - const data = { - 'total': 5, - 'tables': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.list( - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method create()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Table', - 'enabled': true, - 'rowSecurity': true, - 'columns': [], - 'indexes': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.create( - '', - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method get()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Table', - 'enabled': true, - 'rowSecurity': true, - 'columns': [], - 'indexes': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.get( - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method update()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Table', - 'enabled': true, - 'rowSecurity': true, - 'columns': [], - 'indexes': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.update( - '', - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method delete()', async () => { - const data = ''; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) - - const response = await tables.delete( - '', - '', - ); - - const text = await response.text(); - assertEquals(text, data); - stubbedFetch.restore(); - }); - - - test('test method listColumns()', async () => { - const data = { - 'total': 5, - 'columns': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.listColumns( - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createBooleanColumn()', async () => { - const data = { - 'key': 'isEnabled', - 'type': 'boolean', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createBooleanColumn( - '', - '', - '', - true, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateBooleanColumn()', async () => { - const data = { - 'key': 'isEnabled', - 'type': 'boolean', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateBooleanColumn( - '', - '', - '', - true, - true, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createDatetimeColumn()', async () => { - const data = { - 'key': 'birthDay', - 'type': 'datetime', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'datetime',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createDatetimeColumn( - '', - '', - '', - true, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateDatetimeColumn()', async () => { - const data = { - 'key': 'birthDay', - 'type': 'datetime', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'datetime',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateDatetimeColumn( - '', - '', - '', - true, - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createEmailColumn()', async () => { - const data = { - 'key': 'userEmail', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'email',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createEmailColumn( - '', - '', - '', - true, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateEmailColumn()', async () => { - const data = { - 'key': 'userEmail', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'email',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateEmailColumn( - '', - '', - '', - true, - 'email@example.com', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createEnumColumn()', async () => { - const data = { - 'key': 'status', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'elements': [], - 'format': 'enum',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createEnumColumn( - '', - '', - '', - [], - true, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateEnumColumn()', async () => { - const data = { - 'key': 'status', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'elements': [], - 'format': 'enum',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateEnumColumn( - '', - '', - '', - [], - true, - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createFloatColumn()', async () => { - const data = { - 'key': 'percentageCompleted', - 'type': 'double', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createFloatColumn( - '', - '', - '', - true, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateFloatColumn()', async () => { - const data = { - 'key': 'percentageCompleted', - 'type': 'double', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateFloatColumn( - '', - '', - '', - true, - 1.0, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createIntegerColumn()', async () => { - const data = { - 'key': 'count', - 'type': 'integer', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createIntegerColumn( - '', - '', - '', - true, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateIntegerColumn()', async () => { - const data = { - 'key': 'count', - 'type': 'integer', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateIntegerColumn( - '', - '', - '', - true, - 1, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createIpColumn()', async () => { - const data = { - 'key': 'ipAddress', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'ip',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createIpColumn( - '', - '', - '', - true, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateIpColumn()', async () => { - const data = { - 'key': 'ipAddress', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'ip',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateIpColumn( - '', - '', - '', - true, - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createRelationshipColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'relatedTable': 'table', - 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', - 'twoWay': true, - 'twoWayKey': 'string', - 'onDelete': 'restrict|cascade|setNull', - 'side': 'parent|child',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createRelationshipColumn( - '', - '', - '', - 'oneToOne', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createStringColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createStringColumn( - '', - '', - '', - 1, - true, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateStringColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'size': 128,}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateStringColumn( - '', - '', - '', - true, - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createUrlColumn()', async () => { - const data = { - 'key': 'githubUrl', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'url',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createUrlColumn( - '', - '', - '', - true, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateUrlColumn()', async () => { - const data = { - 'key': 'githubUrl', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'format': 'url',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateUrlColumn( - '', - '', - '', - true, - 'https://example.com', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method getColumn()', async () => { - const data = ''; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) - - const response = await tables.getColumn( - '', - '', - '', - ); - - const text = await response.text(); - assertEquals(text, data); - stubbedFetch.restore(); - }); - - - test('test method deleteColumn()', async () => { - const data = ''; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) - - const response = await tables.deleteColumn( - '', - '', - '', - ); - - const text = await response.text(); - assertEquals(text, data); - stubbedFetch.restore(); - }); - - - test('test method updateRelationshipColumn()', async () => { - const data = { - 'key': 'fullName', - 'type': 'string', - 'status': 'available', - 'error': 'string', - 'required': true, - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'relatedTable': 'table', - 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', - 'twoWay': true, - 'twoWayKey': 'string', - 'onDelete': 'restrict|cascade|setNull', - 'side': 'parent|child',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateRelationshipColumn( - '', - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method listIndexes()', async () => { - const data = { - 'total': 5, - 'indexes': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.listIndexes( - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createIndex()', async () => { - const data = { - 'key': 'index1', - 'type': 'primary', - 'status': 'available', - 'error': 'string', - 'columns': [], - 'lengths': [], - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createIndex( - '', - '', - '', - 'key', - [], - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method getIndex()', async () => { - const data = { - 'key': 'index1', - 'type': 'primary', - 'status': 'available', - 'error': 'string', - 'columns': [], - 'lengths': [], - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.getIndex( - '', - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method deleteIndex()', async () => { - const data = ''; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) - - const response = await tables.deleteIndex( - '', - '', - '', - ); - - const text = await response.text(); - assertEquals(text, data); - stubbedFetch.restore(); - }); - - - test('test method listRows()', async () => { - const data = { - 'total': 5, - 'rows': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.listRows( - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createRow()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createRow( - '', - '', - '', - {}, - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method createRows()', async () => { - const data = { - 'total': 5, - 'rows': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.createRows( - '', - '', - [], - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method upsertRows()', async () => { - const data = { - 'total': 5, - 'rows': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.upsertRows( - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateRows()', async () => { - const data = { - 'total': 5, - 'rows': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateRows( - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method deleteRows()', async () => { - const data = { - 'total': 5, - 'rows': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.deleteRows( - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method getRow()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.getRow( - '', - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method upsertRow()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.upsertRow( - '', - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method updateRow()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.updateRow( - '', - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method deleteRow()', async () => { - const data = ''; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) - - const response = await tables.deleteRow( - '', - '', - '', - ); - - const text = await response.text(); - assertEquals(text, data); - stubbedFetch.restore(); - }); - - - test('test method decrementRowColumn()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.decrementRowColumn( - '', - '', - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - - test('test method incrementRowColumn()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': 1, - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); - - const response = await tables.incrementRowColumn( - '', - '', - '', - '', - ); - - assertEquals(response, data); - stubbedFetch.restore(); - }); - - }) From f193c59f8a11d68f9ef7586dab482f6173404c77 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 10:30:07 +0000 Subject: [PATCH 4/5] chore: add changelog --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e46648d..893f49d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Change Log +## 15.1.0 + +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `gif` support to `ImageFormat` enum +* Add `dart38` and `flutter332` support to runtime models +* Add `encrypt` support to `StringAttribute` model +* Add `sequence` support to `Document` model +* Add `upsertDocument` support to `Databases` service + ## 15.0.0 * Add `` to doc examples due to the new multi region endpoints @@ -10,4 +19,4 @@ * Updates enum for `runtimes` with Pythonml312, Dart219, Flutter327 and Flutter329 * Add `token` param to `getFilePreview` and `getFileView` for File tokens usage * Add `queries` and `search` params to `listMemberships` method -* Removes `search` param from `listExecutions` method \ No newline at end of file +* Removes `search` param from `listExecutions` method From 9746902141b460ae36c434eb477a33d02d6134b4 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 10:31:23 +0000 Subject: [PATCH 5/5] chore: update version --- src/client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client.ts b/src/client.ts index 5e5780f..67e36f9 100644 --- a/src/client.ts +++ b/src/client.ts @@ -11,11 +11,11 @@ export class Client { endpoint: string = 'https://cloud.appwrite.io/v1'; headers: Payload = { 'content-type': '', - 'user-agent' : `AppwriteDenoSDK/15.0.0 (${Deno.build.os}; ${Deno.build.arch})`, + 'user-agent' : `AppwriteDenoSDK/15.1.0 (${Deno.build.os}; ${Deno.build.arch})`, 'x-sdk-name': 'Deno', 'x-sdk-platform': 'server', 'x-sdk-language': 'deno', - 'x-sdk-version': '15.0.0', + 'x-sdk-version': '15.1.0', 'X-Appwrite-Response-Format':'1.7.0', };