diff --git a/CHANGELOG.md b/CHANGELOG.md index 9095ec8..328ef1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,41 @@ # Change Log +## 18.2.0 + +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `gif` support to `ImageFormat` enum +* Fix undefined `fileParam` error in `chunkedUpload` method +* Fix autocompletion not working for `Document` model even when generic is passed + +## 18.1.1 + +* Fix using `devKeys` resulting in an error by conditionally removing credentials + +## 18.1.0 + +* Add `devKeys` support to `Client` service +* Add `upsertDocument` support to `Databases` service + ## 18.0.0 -* Add `<REGION>` to doc examples due to the new multi region endpoints +* Add `` to doc examples due to the new multi region endpoints * Remove `Gif` from ImageFormat enum * Remove `search` param from `listExecutions` method * Add `token` param to `getFilePreview` and `getFileView` for File tokens usage -* Improve CORS error catching in `client.call` method \ No newline at end of file +* Improve CORS error catching in `client.call` method + +## 17.0.2 + +* Fix requests failing by removing `Content-Type` header from `GET` and `HEAD` requests + +## 17.0.1 + +* Remove unnecessary titles from method descriptions +* Fix duplicate adding of payload params +* Remove unnecessary awaits and asyncs +* Ensure `AppwriteException` response is always string + +## 17.0.0 + +* Fix pong response & chunked upload +* Add `ping` support to `Realtime` service diff --git a/README.md b/README.md index 48e37b6..f878dfd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Web SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-web.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.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) @@ -33,7 +33,7 @@ import { Client, Account } from "appwrite"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 401a674..916cc92 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,9 +2,7 @@ import { Client, Databases } from "appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // - .setJWT(''); // Your secret JSON Web Token + .setProject(''); // Your project ID const databases = new Databases(client); diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 0000000..10d785a --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,18 @@ +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.decrementDocumentAttribute( + '', // databaseId + '', // collectionId + '', // documentId + '', // attribute + null, // value (optional) + null // min (optional) +); + +console.log(result); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 0000000..4b32be9 --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,18 @@ +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.incrementDocumentAttribute( + '', // databaseId + '', // collectionId + '', // documentId + '', // attribute + null, // value (optional) + null // max (optional) +); + +console.log(result); diff --git a/package.json b/package.json index 02f06b6..cdedd7d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "18.1.1", + "version": "18.2.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index f36d800..30cde12 100644 --- a/src/client.ts +++ b/src/client.ts @@ -316,7 +316,7 @@ class Client { 'x-sdk-name': 'Web', 'x-sdk-platform': 'client', 'x-sdk-language': 'web', - 'x-sdk-version': '18.1.1', + 'x-sdk-version': '18.2.0', 'X-Appwrite-Response-Format': '1.7.0', }; @@ -679,9 +679,9 @@ class Client { } async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) { - const file = Object.values(originalPayload).find((value) => value instanceof File); + const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? []; - if (!file) { + if (!file || !fileParam) { throw new Error('File not found in payload'); } @@ -701,7 +701,8 @@ class Client { headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`; const chunk = file.slice(start, end); - let payload = { ...originalPayload, file: new File([chunk], file.name)}; + let payload = { ...originalPayload }; + payload[fileParam] = new File([chunk], file.name); response = await this.call(method, url, headers, payload); 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/models.ts b/src/models.ts index 87a04b0..62002ff 100644 --- a/src/models.ts +++ b/src/models.ts @@ -2,10 +2,13 @@ * Appwrite Models */ export namespace Models { + + declare const __default: unique symbol; + /** * Documents List */ - export type DocumentList = { + export type DocumentList = { /** * Total number of documents documents that matched your query. */ @@ -15,6 +18,7 @@ export namespace Models { */ documents: Document[]; } + /** * Sessions List */ @@ -28,6 +32,7 @@ export namespace Models { */ sessions: Session[]; } + /** * Identities List */ @@ -41,6 +46,7 @@ export namespace Models { */ identities: Identity[]; } + /** * Logs List */ @@ -54,6 +60,7 @@ export namespace Models { */ logs: Log[]; } + /** * Files List */ @@ -67,10 +74,11 @@ export namespace Models { */ files: File[]; } + /** * Teams List */ - export type TeamList = { + export type TeamList = { /** * Total number of teams documents that matched your query. */ @@ -80,6 +88,7 @@ export namespace Models { */ teams: Team[]; } + /** * Memberships List */ @@ -93,6 +102,7 @@ export namespace Models { */ memberships: Membership[]; } + /** * Executions List */ @@ -106,6 +116,7 @@ export namespace Models { */ executions: Execution[]; } + /** * Countries List */ @@ -119,6 +130,7 @@ export namespace Models { */ countries: Country[]; } + /** * Continents List */ @@ -132,6 +144,7 @@ export namespace Models { */ continents: Continent[]; } + /** * Languages List */ @@ -145,6 +158,7 @@ export namespace Models { */ languages: Language[]; } + /** * Currencies List */ @@ -158,6 +172,7 @@ export namespace Models { */ currencies: Currency[]; } + /** * Phones List */ @@ -171,6 +186,7 @@ export namespace Models { */ phones: Phone[]; } + /** * Locale codes list */ @@ -184,6 +200,7 @@ export namespace Models { */ localeCodes: LocaleCode[]; } + /** * Document */ @@ -192,6 +209,10 @@ export namespace Models { * Document ID. */ $id: string; + /** + * Document automatically incrementing ID. + */ + $sequence: number; /** * Collection ID. */ @@ -212,8 +233,19 @@ export namespace Models { * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ $permissions: string[]; - [key: string]: any; } + + export type DefaultDocument = Document & { + [key: string]: any; + [__default]: true; + }; + + export type DataWithoutDocumentKeys = { + [K in string]: any; + } & { + [K in keyof Document]?: never; + }; + /** * Log */ @@ -303,10 +335,11 @@ export namespace Models { */ countryName: string; } + /** * User */ - export type User = { + export type User = { /** * User ID. */ @@ -384,6 +417,7 @@ export namespace Models { */ accessedAt: string; } + /** * AlgoMD5 */ @@ -393,6 +427,7 @@ export namespace Models { */ type: string; } + /** * AlgoSHA */ @@ -402,6 +437,7 @@ export namespace Models { */ type: string; } + /** * AlgoPHPass */ @@ -411,6 +447,7 @@ export namespace Models { */ type: string; } + /** * AlgoBcrypt */ @@ -420,6 +457,7 @@ export namespace Models { */ type: string; } + /** * AlgoScrypt */ @@ -445,6 +483,7 @@ export namespace Models { */ length: number; } + /** * AlgoScryptModified */ @@ -466,6 +505,7 @@ export namespace Models { */ signerKey: string; } + /** * AlgoArgon2 */ @@ -487,12 +527,24 @@ export namespace Models { */ threads: number; } + /** * Preferences */ export type Preferences = { - [key: string]: any; } + + export type DefaultPreferences = Preferences & { + [key: string]: any; + [__default]: true; + }; + + export type DataWithoutPreferencesKeys = { + [K in string]: any; + } & { + [K in keyof Preferences]?: never; + }; + /** * Session */ @@ -614,6 +666,7 @@ export namespace Models { */ mfaUpdatedAt: string; } + /** * Identity */ @@ -659,6 +712,7 @@ export namespace Models { */ providerRefreshToken: string; } + /** * Token */ @@ -688,6 +742,7 @@ export namespace Models { */ phrase: string; } + /** * JWT */ @@ -697,6 +752,7 @@ export namespace Models { */ jwt: string; } + /** * Locale */ @@ -730,6 +786,7 @@ export namespace Models { */ currency: string; } + /** * LocaleCode */ @@ -743,6 +800,7 @@ export namespace Models { */ name: string; } + /** * File */ @@ -792,10 +850,11 @@ export namespace Models { */ chunksUploaded: number; } + /** * Team */ - export type Team = { + export type Team = { /** * Team ID. */ @@ -821,6 +880,7 @@ export namespace Models { */ prefs: Preferences; } + /** * Membership */ @@ -878,6 +938,7 @@ export namespace Models { */ roles: string[]; } + /** * Execution */ @@ -951,6 +1012,7 @@ export namespace Models { */ scheduledAt?: string; } + /** * Country */ @@ -964,6 +1026,7 @@ export namespace Models { */ code: string; } + /** * Continent */ @@ -977,6 +1040,7 @@ export namespace Models { */ code: string; } + /** * Language */ @@ -994,6 +1058,7 @@ export namespace Models { */ nativeName: string; } + /** * Currency */ @@ -1027,6 +1092,7 @@ export namespace Models { */ namePlural: string; } + /** * Phone */ @@ -1044,6 +1110,7 @@ export namespace Models { */ countryName: string; } + /** * Headers */ @@ -1057,6 +1124,7 @@ export namespace Models { */ value: string; } + /** * MFA Challenge */ @@ -1078,6 +1146,7 @@ export namespace Models { */ expire: string; } + /** * MFA Recovery Codes */ @@ -1087,6 +1156,7 @@ export namespace Models { */ recoveryCodes: string[]; } + /** * MFAType */ @@ -1100,6 +1170,7 @@ export namespace Models { */ uri: string; } + /** * MFAFactors */ @@ -1121,6 +1192,7 @@ export namespace Models { */ recoveryCode: boolean; } + /** * Subscriber */ @@ -1162,6 +1234,7 @@ export namespace Models { */ providerType: string; } + /** * Target */ diff --git a/src/services/account.ts b/src/services/account.ts index b3f42d8..a75cc5b 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -18,7 +18,7 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - get(): Promise> { + get(): Promise> { const apiPath = '/account'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -33,6 +33,7 @@ export class Account { payload ); } + /** * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * @@ -43,7 +44,7 @@ export class Account { * @throws {AppwriteException} * @returns {Promise>} */ - create(userId: string, email: string, password: string, name?: string): Promise> { + create(userId: string, email: string, password: string, name?: string): Promise> { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -80,17 +81,18 @@ export class Account { payload ); } + /** * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. -This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. - + * This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. + * * * @param {string} email * @param {string} password * @throws {AppwriteException} * @returns {Promise>} */ - updateEmail(email: string, password: string): Promise> { + updateEmail(email: string, password: string): Promise> { if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } @@ -118,6 +120,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Get the list of identities for the currently logged in user. * @@ -143,6 +146,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Delete an identity by its unique ID. * @@ -169,6 +173,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. * @@ -191,6 +196,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. * @@ -216,6 +222,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Enable or disable MFA on an account. * @@ -223,7 +230,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, * @throws {AppwriteException} * @returns {Promise>} */ - updateMFA(mfa: boolean): Promise> { + updateMFA(mfa: boolean): Promise> { if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } @@ -245,6 +252,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * @@ -271,6 +279,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -279,7 +288,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, * @throws {AppwriteException} * @returns {Promise>} */ - updateMfaAuthenticator(type: AuthenticatorType, otp: string): Promise> { + updateMfaAuthenticator(type: AuthenticatorType, otp: string): Promise> { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } @@ -304,6 +313,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Delete an authenticator for a user by ID. * @@ -330,6 +340,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * @@ -359,6 +370,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -395,6 +407,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * List the factors available on the account to be used as a MFA challange. * @@ -416,6 +429,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. * @@ -437,6 +451,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -459,6 +474,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. * @@ -481,6 +497,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Update currently logged in user account name. * @@ -488,7 +505,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, * @throws {AppwriteException} * @returns {Promise>} */ - updateName(name: string): Promise> { + updateName(name: string): Promise> { if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } @@ -510,6 +527,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. * @@ -518,7 +536,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, * @throws {AppwriteException} * @returns {Promise>} */ - updatePassword(password: string, oldPassword?: string): Promise> { + updatePassword(password: string, oldPassword?: string): Promise> { if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } @@ -543,6 +561,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. * @@ -551,7 +570,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, * @throws {AppwriteException} * @returns {Promise>} */ - updatePhone(phone: string, password: string): Promise> { + updatePhone(phone: string, password: string): Promise> { if (typeof phone === 'undefined') { throw new AppwriteException('Missing required parameter: "phone"'); } @@ -579,13 +598,14 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Get the preferences as a key-value object for the currently logged in user. * * @throws {AppwriteException} * @returns {Promise} */ - getPrefs(): Promise { + getPrefs(): Promise { const apiPath = '/account/prefs'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -600,6 +620,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. * @@ -607,7 +628,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, * @throws {AppwriteException} * @returns {Promise>} */ - updatePrefs(prefs: Partial): Promise> { + updatePrefs(prefs: Partial): Promise> { if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } @@ -629,6 +650,7 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour. * @@ -665,10 +687,11 @@ This endpoint can also be used to convert an anonymous account to a normal one, payload ); } + /** * Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint. - -Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + * + * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. * * @param {string} userId * @param {string} secret @@ -710,6 +733,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ payload ); } + /** * Get the list of active sessions across different devices for the currently logged in user. * @@ -731,6 +755,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ payload ); } + /** * Delete all sessions from the user account and remove any sessions cookies from the end client. * @@ -753,6 +778,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ payload ); } + /** * Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). * @@ -775,10 +801,11 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ payload ); } + /** * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. - -A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param {string} email * @param {string} password @@ -813,6 +840,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -849,13 +877,14 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. - -If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user. - -A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - + * + * If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * * * @param {OAuthProvider} provider * @param {string} success @@ -897,6 +926,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about return uri.toString(); } } + /** * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -933,6 +963,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -969,6 +1000,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. * @@ -994,6 +1026,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. * @@ -1020,6 +1053,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. * @@ -1046,13 +1080,14 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. * * @throws {AppwriteException} * @returns {Promise>} */ - updateStatus(): Promise> { + updateStatus(): Promise> { const apiPath = '/account/status'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1068,6 +1103,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Use this endpoint to register a device for push notifications. Provide a target ID (custom or generated using ID.unique()), a device identifier (usually a device token), and optionally specify which provider should send notifications to this target. The target is automatically linked to the current session and includes device information like brand and model. * @@ -1108,6 +1144,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Update the currently logged in user's push notification target. You can modify the target's identifier (device token) and provider ID (token, email, phone etc.). The target must exist and belong to the current user. If you change the provider ID, notifications will be sent through the new messaging provider instead. * @@ -1141,6 +1178,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Delete a push notification target for the currently logged in user. After deletion, the device will no longer receive push notifications. The target must exist and belong to the current user. * @@ -1167,10 +1205,11 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. - -A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param {string} userId * @param {string} email @@ -1209,11 +1248,12 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. - -A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * * * @param {string} userId * @param {string} email @@ -1256,12 +1296,13 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. - -If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. - -A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param {OAuthProvider} provider * @param {string} success @@ -1303,10 +1344,11 @@ A user is limited to 10 active sessions at a time by default. [Learn more about return uri.toString(); } } + /** * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. - -A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param {string} userId * @param {string} phone @@ -1341,11 +1383,12 @@ A user is limited to 10 active sessions at a time by default. [Learn more about payload ); } + /** * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - -Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - + * + * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + * * * @param {string} url * @throws {AppwriteException} @@ -1373,6 +1416,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ payload ); } + /** * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. * @@ -1409,6 +1453,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ payload ); } + /** * Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. * @@ -1431,6 +1476,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ payload ); } + /** * Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. * diff --git a/src/services/avatars.ts b/src/services/avatars.ts index f1960a6..4275fce 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -14,8 +14,8 @@ export class Avatars { /** * You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings. - -When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. + * + * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. * * @param {Browser} code * @param {number} width @@ -52,11 +52,12 @@ When one dimension is specified and the other is 0, the image is scaled with pre return uri.toString(); } + /** * The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. - -When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - + * + * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. + * * * @param {CreditCard} code * @param {number} width @@ -93,10 +94,11 @@ When one dimension is specified and the other is 0, the image is scaled with pre return uri.toString(); } + /** * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. - -This endpoint does not follow HTTP redirects. + * + * This endpoint does not follow HTTP redirects. * * @param {string} url * @throws {AppwriteException} @@ -124,11 +126,12 @@ This endpoint does not follow HTTP redirects. return uri.toString(); } + /** * You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - -When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - + * + * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. + * * * @param {Flag} code * @param {number} width @@ -165,12 +168,13 @@ When one dimension is specified and the other is 0, the image is scaled with pre return uri.toString(); } + /** * Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. - -When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px. - -This endpoint does not follow HTTP redirects. + * + * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px. + * + * This endpoint does not follow HTTP redirects. * * @param {string} url * @param {number} width @@ -206,13 +210,14 @@ This endpoint does not follow HTTP redirects. return uri.toString(); } + /** * Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. - -You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. - -When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. - + * + * You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. + * + * When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. + * * * @param {string} name * @param {number} width @@ -249,9 +254,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre return uri.toString(); } + /** * Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. - + * * * @param {string} text * @param {number} size diff --git a/src/services/databases.ts b/src/services/databases.ts index 4f2d50a..792b08e 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -18,7 +18,7 @@ export class Databases { * @throws {AppwriteException} * @returns {Promise>} */ - listDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise> { + listDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise> { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -42,18 +42,19 @@ export class Databases { payload ); } + /** * Create a new 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 {Omit} data + * @param {Document extends Models.DefaultDocument ? Models.DataWithoutDocumentKeys : Omit} data * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} */ - createDocument(databaseId: string, collectionId: string, documentId: string, data: Omit, permissions?: string[]): Promise { + createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Models.DataWithoutDocumentKeys : Omit, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -90,6 +91,7 @@ export class Databases { payload ); } + /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * @@ -100,7 +102,7 @@ export class Databases { * @throws {AppwriteException} * @returns {Promise} */ - getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise { + getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -127,7 +129,10 @@ export class Databases { payload ); } + /** + * **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 @@ -138,7 +143,7 @@ export class Databases { * @throws {AppwriteException} * @returns {Promise} */ - upsertDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { + upsertDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -172,18 +177,19 @@ export class Databases { payload ); } + /** * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. * * @param {string} databaseId * @param {string} collectionId * @param {string} documentId - * @param {Partial>} data + * @param {Partial>} data * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} */ - updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Partial>, permissions?: string[]): Promise { + updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Partial>, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -214,6 +220,7 @@ export class Databases { payload ); } + /** * Delete a document by its unique ID. * @@ -248,4 +255,98 @@ export class Databases { payload ); } + + /** + * 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} + */ + 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; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * 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} + */ + 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; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 195e6b1..af21c86 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -39,6 +39,7 @@ export class Functions { payload ); } + /** * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. * @@ -89,6 +90,7 @@ export class Functions { payload ); } + /** * Get a function execution log by its unique ID. * diff --git a/src/services/graphql.ts b/src/services/graphql.ts index 13bff01..9499d1b 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -39,6 +39,7 @@ export class Graphql { payload ); } + /** * Execute a GraphQL mutation. * diff --git a/src/services/locale.ts b/src/services/locale.ts index d36eaa3..f9d62c4 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -11,8 +11,8 @@ export class Locale { /** * Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language. - -([IP Geolocation by DB-IP](https://db-ip.com)) + * + * ([IP Geolocation by DB-IP](https://db-ip.com)) * * @throws {AppwriteException} * @returns {Promise} @@ -32,6 +32,7 @@ export class Locale { payload ); } + /** * List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). * @@ -53,6 +54,7 @@ export class Locale { payload ); } + /** * List of all continents. You can use the locale header to get the data in a supported language. * @@ -74,6 +76,7 @@ export class Locale { payload ); } + /** * List of all countries. You can use the locale header to get the data in a supported language. * @@ -95,6 +98,7 @@ export class Locale { payload ); } + /** * List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. * @@ -116,6 +120,7 @@ export class Locale { payload ); } + /** * List of all countries phone codes. You can use the locale header to get the data in a supported language. * @@ -137,6 +142,7 @@ export class Locale { payload ); } + /** * List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language. * @@ -158,6 +164,7 @@ export class Locale { payload ); } + /** * List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language. * diff --git a/src/services/messaging.ts b/src/services/messaging.ts index a438c89..ce1f85d 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -49,6 +49,7 @@ export class Messaging { payload ); } + /** * Delete a subscriber by its unique ID. * diff --git a/src/services/storage.ts b/src/services/storage.ts index 4cd5c10..43b8368 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -44,15 +44,16 @@ export class Storage { payload ); } + /** * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. - -Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes. - -When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one. - -If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. - + * + * Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes. + * + * When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one. + * + * If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. + * * * @param {string} bucketId * @param {string} fileId @@ -96,6 +97,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk onProgress ); } + /** * Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata. * @@ -125,6 +127,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk payload ); } + /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. * @@ -163,6 +166,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk payload ); } + /** * Delete a file by its unique ID. Only users with write permissions have access to delete this resource. * @@ -193,6 +197,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk payload ); } + /** * Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. * @@ -227,6 +232,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk return uri.toString(); } + /** * Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB. * @@ -305,6 +311,7 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk return uri.toString(); } + /** * Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. * diff --git a/src/services/teams.ts b/src/services/teams.ts index bb5d9da..0b9564a 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -17,7 +17,7 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - list(queries?: string[], search?: string): Promise> { + list(queries?: string[], search?: string): Promise> { const apiPath = '/teams'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -38,6 +38,7 @@ export class Teams { payload ); } + /** * Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. * @@ -47,7 +48,7 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - create(teamId: string, name: string, roles?: string[]): Promise> { + create(teamId: string, name: string, roles?: string[]): Promise> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -78,6 +79,7 @@ export class Teams { payload ); } + /** * Get a team by its ID. All team members have read access for this resource. * @@ -85,7 +87,7 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - get(teamId: string): Promise> { + get(teamId: string): Promise> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -103,6 +105,7 @@ export class Teams { payload ); } + /** * Update the team's name by its unique ID. * @@ -111,7 +114,7 @@ export class Teams { * @throws {AppwriteException} * @returns {Promise>} */ - updateName(teamId: string, name: string): Promise> { + updateName(teamId: string, name: string): Promise> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -136,6 +139,7 @@ export class Teams { payload ); } + /** * Delete a team using its ID. Only team members with the owner role can delete the team. * @@ -162,6 +166,7 @@ export class Teams { payload ); } + /** * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. * @@ -195,15 +200,16 @@ export class Teams { payload ); } + /** * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. - -You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. - -Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. - -Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. - + * + * You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. + * + * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. + * + * Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. + * * * @param {string} teamId * @param {string[]} roles @@ -255,6 +261,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee payload ); } + /** * Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console. * @@ -284,9 +291,10 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee payload ); } + /** * Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). - + * * * @param {string} teamId * @param {string} membershipId @@ -322,6 +330,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee payload ); } + /** * This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted. * @@ -352,11 +361,12 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee payload ); } + /** * Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user. - -If the request is successful, a session for the user is automatically created. - + * + * If the request is successful, a session for the user is automatically created. + * * * @param {string} teamId * @param {string} membershipId @@ -399,6 +409,7 @@ If the request is successful, a session for the user is automatically created. payload ); } + /** * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). * @@ -406,7 +417,7 @@ If the request is successful, a session for the user is automatically created. * @throws {AppwriteException} * @returns {Promise} */ - getPrefs(teamId: string): Promise { + getPrefs(teamId: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -424,6 +435,7 @@ If the request is successful, a session for the user is automatically created. payload ); } + /** * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. * @@ -432,7 +444,7 @@ If the request is successful, a session for the user is automatically created. * @throws {AppwriteException} * @returns {Promise} */ - updatePrefs(teamId: string, prefs: object): Promise { + updatePrefs(teamId: string, prefs: object): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); }