diff --git a/package.json b/package.json index d1df893b..20295c3a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-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": "0.7.0", + "version": "0.7.1", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 66e57aa9..0a2d8ae0 100644 --- a/src/client.ts +++ b/src/client.ts @@ -114,7 +114,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.7.0', + 'x-sdk-version': '0.7.1', 'X-Appwrite-Response-Format': '1.6.0', }; @@ -453,6 +453,7 @@ class Client { try { let data = null; const response = await fetch(url.toString(), options); + const text = await response.text() const warnings = response.headers.get('x-appwrite-warning'); if (warnings) { @@ -463,12 +464,12 @@ class Client { data = await response.json(); } else { data = { - message: await response.text() + message: text }; } if (400 <= response.status) { - throw new AppwriteException(data?.message, response.status, data?.type, data); + throw new AppwriteException(data?.message, response.status, data?.type, text); } const cookieFallback = response.headers.get('X-Fallback-Cookies'); diff --git a/src/services/account.ts b/src/services/account.ts index 14740891..7c4927d5 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -17,26 +17,22 @@ export class Account extends Service { } /** - * Get account - * * Get the currently logged in user. * * @throws {AppwriteException} * @returns {Promise} */ - async get(): Promise> { + get(): Promise> { const apiPath = '/account'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Create account - * * 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 @@ -52,7 +48,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async 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"'); } @@ -85,14 +81,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Update email - * * 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 @@ -107,7 +101,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateEmail(email: string, password: string): Promise> { + updateEmail(email: string, password: string): Promise> { if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } @@ -128,21 +122,19 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * List identities - * * Get the list of identities for the currently logged in user. * * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} */ - async listIdentities(queries?: string[]): Promise { + listIdentities(queries?: string[]): Promise { const apiPath = '/account/identities'; const payload: Payload = {}; @@ -151,21 +143,19 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Delete identity - * * Delete an identity by its unique ID. * * @param {string} identityId * @throws {AppwriteException} * @returns {Promise} */ - async deleteIdentity(identityId: string): Promise<{}> { + deleteIdentity(identityId: string): Promise<{}> { if (typeof identityId === 'undefined') { throw new AppwriteException('Missing required parameter: "identityId"'); } @@ -174,14 +164,12 @@ export class Account extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('delete', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } /** - * Create JWT - * * 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 @@ -191,19 +179,17 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createJWT(): Promise { + createJWT(): Promise { const apiPath = '/account/jwts'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * List logs - * * 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. * @@ -211,7 +197,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async listLogs(queries?: string[]): Promise { + listLogs(queries?: string[]): Promise { const apiPath = '/account/logs'; const payload: Payload = {}; @@ -220,21 +206,19 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Update MFA - * * Enable or disable MFA on an account. * * @param {boolean} mfa * @throws {AppwriteException} * @returns {Promise} */ - async updateMFA(mfa: boolean): Promise> { + updateMFA(mfa: boolean): Promise> { if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } @@ -247,14 +231,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Create authenticator - * * 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) @@ -264,7 +246,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createMfaAuthenticator(type: AuthenticatorType): Promise { + createMfaAuthenticator(type: AuthenticatorType): Promise { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } @@ -273,14 +255,12 @@ export class Account extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Verify authenticator - * * Verify an authenticator app after adding it using the [add * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) * method. @@ -290,7 +270,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateMfaAuthenticator(type: AuthenticatorType, otp: string): Promise> { + updateMfaAuthenticator(type: AuthenticatorType, otp: string): Promise> { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } @@ -307,21 +287,19 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } /** - * Delete authenticator - * * Delete an authenticator for a user by ID. * * @param {AuthenticatorType} type * @throws {AppwriteException} * @returns {Promise} */ - async deleteMfaAuthenticator(type: AuthenticatorType): Promise<{}> { + deleteMfaAuthenticator(type: AuthenticatorType): Promise<{}> { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } @@ -330,14 +308,12 @@ export class Account extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('delete', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } /** - * Create MFA challenge - * * Begin the process of MFA verification after sign-in. Finish the flow with * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) * method. @@ -346,7 +322,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createMfaChallenge(factor: AuthenticationFactor): Promise { + createMfaChallenge(factor: AuthenticationFactor): Promise { if (typeof factor === 'undefined') { throw new AppwriteException('Missing required parameter: "factor"'); } @@ -359,14 +335,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Create MFA challenge (confirmation) - * * 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 @@ -378,7 +352,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateMfaChallenge(challengeId: string, otp: string): Promise { + updateMfaChallenge(challengeId: string, otp: string): Promise { if (typeof challengeId === 'undefined') { throw new AppwriteException('Missing required parameter: "challengeId"'); } @@ -399,32 +373,28 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } /** - * List factors - * * List the factors available on the account to be used as a MFA challange. * * @throws {AppwriteException} * @returns {Promise} */ - async listMfaFactors(): Promise { + listMfaFactors(): Promise { const apiPath = '/account/mfa/factors'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Get MFA recovery codes - * * 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) @@ -433,19 +403,17 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async getMfaRecoveryCodes(): Promise { + getMfaRecoveryCodes(): Promise { const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Create MFA recovery codes - * * 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 @@ -455,19 +423,17 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createMfaRecoveryCodes(): Promise { + createMfaRecoveryCodes(): Promise { const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Regenerate MFA recovery codes - * * 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) @@ -476,26 +442,24 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateMfaRecoveryCodes(): Promise { + updateMfaRecoveryCodes(): Promise { const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Update name - * * Update currently logged in user account name. * * @param {string} name * @throws {AppwriteException} * @returns {Promise} */ - async updateName(name: string): Promise> { + updateName(name: string): Promise> { if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } @@ -508,14 +472,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Update password - * * 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. @@ -525,7 +487,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updatePassword(password: string, oldPassword?: string): Promise> { + updatePassword(password: string, oldPassword?: string): Promise> { if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } @@ -542,14 +504,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Update phone - * * 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 @@ -561,7 +521,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updatePhone(phone: string, password: string): Promise> { + updatePhone(phone: string, password: string): Promise> { if (typeof phone === 'undefined') { throw new AppwriteException('Missing required parameter: "phone"'); } @@ -582,32 +542,28 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Get account preferences - * * Get the preferences as a key-value object for the currently logged in user. * * @throws {AppwriteException} * @returns {Promise} */ - async getPrefs(): Promise { + getPrefs(): Promise { const apiPath = '/account/prefs'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Update preferences - * * 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. @@ -616,7 +572,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updatePrefs(prefs: object): Promise> { + updatePrefs(prefs: object): Promise> { if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } @@ -629,14 +585,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Create password recovery - * * 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 @@ -651,7 +605,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createRecovery(email: string, url: string): Promise { + createRecovery(email: string, url: string): Promise { if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } @@ -672,14 +626,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Create password recovery (confirmation) - * * 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 @@ -697,7 +649,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateRecovery(userId: string, secret: string, password: string): Promise { + updateRecovery(userId: string, secret: string, password: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -726,52 +678,46 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } /** - * List sessions - * * Get the list of active sessions across different devices for the currently * logged in user. * * @throws {AppwriteException} * @returns {Promise} */ - async listSessions(): Promise { + listSessions(): Promise { const apiPath = '/account/sessions'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Delete sessions - * * Delete all sessions from the user account and remove any sessions cookies * from the end client. * * @throws {AppwriteException} * @returns {Promise} */ - async deleteSessions(): Promise<{}> { + deleteSessions(): Promise<{}> { const apiPath = '/account/sessions'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('delete', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } /** - * Create anonymous session - * * 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 @@ -783,19 +729,17 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createAnonymousSession(): Promise { + createAnonymousSession(): Promise { const apiPath = '/account/sessions/anonymous'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Create email password session - * * 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. * @@ -808,7 +752,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createEmailPasswordSession(email: string, password: string): Promise { + createEmailPasswordSession(email: string, password: string): Promise { if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } @@ -829,14 +773,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Update magic URL session - * * 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. @@ -846,7 +788,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateMagicURLSession(userId: string, secret: string): Promise { + updateMagicURLSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -867,14 +809,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } /** - * Create OAuth2 session - * * 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 @@ -930,8 +870,6 @@ export class Account extends Service { } /** - * Update phone session - * * 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. @@ -941,7 +879,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updatePhoneSession(userId: string, secret: string): Promise { + updatePhoneSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -962,14 +900,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } /** - * Create session - * * 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. @@ -979,7 +915,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createSession(userId: string, secret: string): Promise { + createSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -1000,14 +936,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Get session - * * Use this endpoint to get a logged in user's session using a Session ID. * Inputting 'current' will return the current session being used. * @@ -1015,7 +949,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async getSession(sessionId: string): Promise { + getSession(sessionId: string): Promise { if (typeof sessionId === 'undefined') { throw new AppwriteException('Missing required parameter: "sessionId"'); } @@ -1024,14 +958,12 @@ export class Account extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Update session - * * 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. @@ -1040,7 +972,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateSession(sessionId: string): Promise { + updateSession(sessionId: string): Promise { if (typeof sessionId === 'undefined') { throw new AppwriteException('Missing required parameter: "sessionId"'); } @@ -1049,14 +981,12 @@ export class Account extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Delete session - * * 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 @@ -1067,7 +997,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async deleteSession(sessionId: string): Promise<{}> { + deleteSession(sessionId: string): Promise<{}> { if (typeof sessionId === 'undefined') { throw new AppwriteException('Missing required parameter: "sessionId"'); } @@ -1076,14 +1006,12 @@ export class Account extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('delete', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } /** - * Update status - * * 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. @@ -1091,19 +1019,17 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateStatus(): Promise> { + updateStatus(): Promise> { const apiPath = '/account/status'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Create push target - * * 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 @@ -1116,7 +1042,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createPushTarget(targetId: string, identifier: string, providerId?: string): Promise { + createPushTarget(targetId: string, identifier: string, providerId?: string): Promise { if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); } @@ -1141,14 +1067,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Update push target - * * 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. @@ -1160,7 +1084,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updatePushTarget(targetId: string, identifier: string): Promise { + updatePushTarget(targetId: string, identifier: string): Promise { if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); } @@ -1177,14 +1101,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } /** - * Delete push target - * * 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. @@ -1193,7 +1115,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async deletePushTarget(targetId: string): Promise<{}> { + deletePushTarget(targetId: string): Promise<{}> { if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); } @@ -1202,14 +1124,12 @@ export class Account extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('delete', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } /** - * Create email token (OTP) - * * 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 @@ -1227,7 +1147,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createEmailToken(userId: string, email: string, phrase?: boolean): Promise { + createEmailToken(userId: string, email: string, phrase?: boolean): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -1252,14 +1172,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Create magic URL token - * * 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 @@ -1282,7 +1200,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createMagicURLToken(userId: string, email: string, url?: string, phrase?: boolean): Promise { + createMagicURLToken(userId: string, email: string, url?: string, phrase?: boolean): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -1311,14 +1229,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Create OAuth2 token - * * 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 @@ -1372,8 +1288,6 @@ export class Account extends Service { } /** - * Create phone token - * * 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 @@ -1390,7 +1304,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createPhoneToken(userId: string, phone: string): Promise { + createPhoneToken(userId: string, phone: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -1411,14 +1325,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Create email verification - * * 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 @@ -1439,7 +1351,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createVerification(url: string): Promise { + createVerification(url: string): Promise { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } @@ -1452,14 +1364,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Create email verification (confirmation) - * * 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 @@ -1470,7 +1380,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateVerification(userId: string, secret: string): Promise { + updateVerification(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -1491,14 +1401,12 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } /** - * Create phone verification - * * 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 @@ -1511,19 +1419,17 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createPhoneVerification(): Promise { + createPhoneVerification(): Promise { const apiPath = '/account/verification/phone'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Update phone verification (confirmation) - * * 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 @@ -1534,7 +1440,7 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updatePhoneVerification(userId: string, secret: string): Promise { + updatePhoneVerification(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -1555,7 +1461,7 @@ export class Account extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } diff --git a/src/services/avatars.ts b/src/services/avatars.ts index acd80ed6..1d640843 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -17,8 +17,6 @@ export class Avatars extends Service { } /** - * Get browser icon - * * 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) @@ -68,8 +66,6 @@ export class Avatars extends Service { } /** - * Get credit card icon - * * 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. @@ -118,8 +114,6 @@ export class Avatars extends Service { } /** - * Get favicon - * * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote * website URL. * @@ -152,8 +146,6 @@ export class Avatars extends Service { } /** - * Get country flag - * * 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 @@ -203,8 +195,6 @@ export class Avatars extends Service { } /** - * Get image from URL - * * 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 @@ -254,8 +244,6 @@ export class Avatars extends Service { } /** - * Get user initials - * * 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' @@ -311,8 +299,6 @@ export class Avatars extends Service { } /** - * Get QR code - * * 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. * diff --git a/src/services/databases.ts b/src/services/databases.ts index eb36315c..7882d8ca 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -14,8 +14,6 @@ export class Databases extends Service { } /** - * List documents - * * Get a list of all the user's documents in a given collection. You can use * the query params to filter your results. * @@ -25,7 +23,7 @@ export class Databases extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async 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,14 +40,12 @@ export class Databases extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Create document - * * 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) @@ -63,7 +59,7 @@ export class Databases extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { + createDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -96,14 +92,12 @@ export class Databases extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Get document - * * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. * @@ -114,7 +108,7 @@ export class Databases extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async 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"'); } @@ -135,14 +129,12 @@ export class Databases extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Update document - * * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. * @@ -154,7 +146,7 @@ export class Databases extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateDocument(databaseId: string, collectionId: string, documentId: string, data?: object, permissions?: string[]): Promise { + updateDocument(databaseId: string, collectionId: string, documentId: string, data?: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -179,14 +171,12 @@ export class Databases extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Delete document - * * Delete a document by its unique ID. * * @param {string} databaseId @@ -195,7 +185,7 @@ export class Databases extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}> { + deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}> { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -212,7 +202,7 @@ export class Databases extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('delete', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } diff --git a/src/services/functions.ts b/src/services/functions.ts index e015aea6..89aa791a 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -15,8 +15,6 @@ export class Functions extends Service { } /** - * List executions - * * Get a list of all the current user function execution logs. You can use the * query params to filter your results. * @@ -26,7 +24,7 @@ export class Functions extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async listExecutions(functionId: string, queries?: string[], search?: string): Promise { + listExecutions(functionId: string, queries?: string[], search?: string): Promise { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -43,14 +41,12 @@ export class Functions extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Create execution - * * 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 @@ -66,7 +62,7 @@ export class Functions extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise { + createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -99,14 +95,12 @@ export class Functions extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Get execution - * * Get a function execution log by its unique ID. * * @param {string} functionId @@ -114,7 +108,7 @@ export class Functions extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async getExecution(functionId: string, executionId: string): Promise { + getExecution(functionId: string, executionId: string): Promise { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -127,7 +121,7 @@ export class Functions extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } diff --git a/src/services/graphql.ts b/src/services/graphql.ts index 8b1f2b85..a24adaa4 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -14,15 +14,13 @@ export class Graphql extends Service { } /** - * GraphQL endpoint - * * Execute a GraphQL mutation. * * @param {object} query * @throws {AppwriteException} * @returns {Promise} */ - async query(query: object): Promise<{}> { + query(query: object): Promise<{}> { if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); } @@ -35,22 +33,20 @@ export class Graphql extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'x-sdk-graphql': 'true', 'content-type': 'application/json', }, payload); } /** - * GraphQL endpoint - * * Execute a GraphQL mutation. * * @param {object} query * @throws {AppwriteException} * @returns {Promise} */ - async mutation(query: object): Promise<{}> { + mutation(query: object): Promise<{}> { if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); } @@ -63,7 +59,7 @@ export class Graphql extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'x-sdk-graphql': 'true', 'content-type': 'application/json', }, payload); diff --git a/src/services/locale.ts b/src/services/locale.ts index 7850948d..6a99b833 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -14,8 +14,6 @@ export class Locale extends Service { } /** - * Get user 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 @@ -26,114 +24,102 @@ export class Locale extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async get(): Promise { + get(): Promise { const apiPath = '/locale'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * List locale codes - * * List of all locale codes in [ISO * 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). * * @throws {AppwriteException} * @returns {Promise} */ - async listCodes(): Promise { + listCodes(): Promise { const apiPath = '/locale/codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * List continents - * * List of all continents. You can use the locale header to get the data in a * supported language. * * @throws {AppwriteException} * @returns {Promise} */ - async listContinents(): Promise { + listContinents(): Promise { const apiPath = '/locale/continents'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * List countries - * * List of all countries. You can use the locale header to get the data in a * supported language. * * @throws {AppwriteException} * @returns {Promise} */ - async listCountries(): Promise { + listCountries(): Promise { const apiPath = '/locale/countries'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * List EU countries - * * 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. * * @throws {AppwriteException} * @returns {Promise} */ - async listCountriesEU(): Promise { + listCountriesEU(): Promise { const apiPath = '/locale/countries/eu'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * List countries phone codes - * * List of all countries phone codes. You can use the locale header to get the * data in a supported language. * * @throws {AppwriteException} * @returns {Promise} */ - async listCountriesPhones(): Promise { + listCountriesPhones(): Promise { const apiPath = '/locale/countries/phones'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * List currencies - * * 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. @@ -141,31 +127,29 @@ export class Locale extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async listCurrencies(): Promise { + listCurrencies(): Promise { const apiPath = '/locale/currencies'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * List languages - * * List of all languages classified by ISO 639-1 including 2-letter code, name * in English, and name in the respective language. * * @throws {AppwriteException} * @returns {Promise} */ - async listLanguages(): Promise { + listLanguages(): Promise { const apiPath = '/locale/languages'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 26ceb317..6e33b9ab 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -14,8 +14,6 @@ export class Messaging extends Service { } /** - * Create subscriber - * * Create a new subscriber. * * @param {string} topicId @@ -24,7 +22,7 @@ export class Messaging extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createSubscriber(topicId: string, subscriberId: string, targetId: string): Promise { + createSubscriber(topicId: string, subscriberId: string, targetId: string): Promise { if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } @@ -49,14 +47,12 @@ export class Messaging extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Delete subscriber - * * Delete a subscriber by its unique ID. * * @param {string} topicId @@ -64,7 +60,7 @@ export class Messaging extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async deleteSubscriber(topicId: string, subscriberId: string): Promise<{}> { + deleteSubscriber(topicId: string, subscriberId: string): Promise<{}> { if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } @@ -77,7 +73,7 @@ export class Messaging extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('delete', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } diff --git a/src/services/storage.ts b/src/services/storage.ts index 6661387b..5101f7d8 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -16,8 +16,6 @@ export class Storage extends Service { } /** - * List files - * * Get a list of all the user files. You can use the query params to filter * your results. * @@ -27,7 +25,7 @@ export class Storage extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async listFiles(bucketId: string, queries?: string[], search?: string): Promise { + listFiles(bucketId: string, queries?: string[], search?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -44,14 +42,12 @@ export class Storage extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Create file - * * 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) @@ -111,7 +107,7 @@ export class Storage extends Service { const size = file.size; if (size <= Service.CHUNK_SIZE) { - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'multipart/form-data', }, payload); } @@ -167,8 +163,6 @@ export class Storage extends Service { } /** - * Get file - * * Get a file by its unique ID. This endpoint response returns a JSON object * with the file metadata. * @@ -177,7 +171,7 @@ export class Storage extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async getFile(bucketId: string, fileId: string): Promise { + getFile(bucketId: string, fileId: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -190,14 +184,12 @@ export class Storage extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Update file - * * Update a file by its unique ID. Only users with write permissions have * access to update this resource. * @@ -208,7 +200,7 @@ export class Storage extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise { + updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -229,14 +221,12 @@ export class Storage extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } /** - * Delete file - * * Delete a file by its unique ID. Only users with write permissions have * access to delete this resource. * @@ -245,7 +235,7 @@ export class Storage extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async deleteFile(bucketId: string, fileId: string): Promise<{}> { + deleteFile(bucketId: string, fileId: string): Promise<{}> { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -258,14 +248,12 @@ export class Storage extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('delete', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } /** - * Get file for download - * * 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. @@ -298,8 +286,6 @@ export class Storage extends Service { } /** - * Get file preview - * * 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 @@ -389,8 +375,6 @@ export class Storage extends Service { } /** - * Get file for view - * * 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 61917206..8eb69e1f 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -14,8 +14,6 @@ export class Teams extends Service { } /** - * List teams - * * Get a list of all the teams in which the current user is a member. You can * use the parameters to filter your results. * @@ -24,7 +22,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async list(queries?: string[], search?: string): Promise> { + list(queries?: string[], search?: string): Promise> { const apiPath = '/teams'; const payload: Payload = {}; @@ -37,14 +35,12 @@ export class Teams extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Create team - * * 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. @@ -55,7 +51,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async 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"'); } @@ -80,21 +76,19 @@ export class Teams extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Get team - * * Get a team by its ID. All team members have read access for this resource. * * @param {string} teamId * @throws {AppwriteException} * @returns {Promise} */ - async get(teamId: string): Promise> { + get(teamId: string): Promise> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -103,14 +97,12 @@ export class Teams extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Update name - * * Update the team's name by its unique ID. * * @param {string} teamId @@ -118,7 +110,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateName(teamId: string, name: string): Promise> { + updateName(teamId: string, name: string): Promise> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -135,14 +127,12 @@ export class Teams extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); } /** - * Delete team - * * Delete a team using its ID. Only team members with the owner role can * delete the team. * @@ -150,7 +140,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async delete(teamId: string): Promise<{}> { + delete(teamId: string): Promise<{}> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -159,14 +149,12 @@ export class Teams extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('delete', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } /** - * List team memberships - * * 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. @@ -177,7 +165,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async listMemberships(teamId: string, queries?: string[], search?: string): Promise { + listMemberships(teamId: string, queries?: string[], search?: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -194,14 +182,12 @@ export class Teams extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Create team membership - * * 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 @@ -234,7 +220,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async createMembership(teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise { + createMembership(teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -271,14 +257,12 @@ export class Teams extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('post', uri, { + return this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** - * Get team membership - * * 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. @@ -288,7 +272,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async getMembership(teamId: string, membershipId: string): Promise { + getMembership(teamId: string, membershipId: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -301,14 +285,12 @@ export class Teams extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Update membership - * * 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). @@ -320,7 +302,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateMembership(teamId: string, membershipId: string, roles: string[]): Promise { + updateMembership(teamId: string, membershipId: string, roles: string[]): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -341,14 +323,12 @@ export class Teams extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Delete team membership - * * 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. @@ -358,7 +338,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async deleteMembership(teamId: string, membershipId: string): Promise<{}> { + deleteMembership(teamId: string, membershipId: string): Promise<{}> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -371,14 +351,12 @@ export class Teams extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('delete', uri, { + return this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } /** - * Update team membership status - * * 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. @@ -394,7 +372,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updateMembershipStatus(teamId: string, membershipId: string, userId: string, secret: string): Promise { + updateMembershipStatus(teamId: string, membershipId: string, userId: string, secret: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -423,14 +401,12 @@ export class Teams extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('patch', uri, { + return this.client.call('patch', uri, { 'content-type': 'application/json', }, payload); } /** - * Get team preferences - * * 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). @@ -439,7 +415,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async getPrefs(teamId: string): Promise { + getPrefs(teamId: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -448,14 +424,12 @@ export class Teams extends Service { const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('get', uri, { + return this.client.call('get', uri, { 'content-type': 'application/json', }, payload); } /** - * Update preferences - * * 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. @@ -465,7 +439,7 @@ export class Teams extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async updatePrefs(teamId: string, prefs: object): Promise { + updatePrefs(teamId: string, prefs: object): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -482,7 +456,7 @@ export class Teams extends Service { } const uri = new URL(this.client.config.endpoint + apiPath); - return await this.client.call('put', uri, { + return this.client.call('put', uri, { 'content-type': 'application/json', }, payload); }