diff --git a/README.md b/README.md index fe7f3dc..9cb41a6 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).** > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) @@ -27,6 +27,7 @@ npm install node-appwrite --save ## Getting Started ### Init your SDK + Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key project API keys section. ```js @@ -43,6 +44,7 @@ client ``` ### Make Your First Request + Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section. ```js @@ -80,7 +82,70 @@ promise.then(function (response) { }); ``` +### Type Safety with Models + +The Appwrite Node SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety. + +**TypeScript:** +```typescript +interface Book { + name: string; + author: string; + releaseYear?: string; + category?: string; + genre?: string[]; + isCheckedOut: boolean; +} + +const databases = new Databases(client); + +try { + const documents = await databases.listDocuments( + 'your-database-id', + 'your-collection-id' + ); + + documents.documents.forEach(book => { + console.log(`Book: ${book.name} by ${book.author}`); // Now you have full type safety + }); +} catch (error) { + console.error('Appwrite error:', error); +} +``` + +**JavaScript (with JSDoc for type hints):** +```javascript +/** + * @typedef {Object} Book + * @property {string} name + * @property {string} author + * @property {string} [releaseYear] + * @property {string} [category] + * @property {string[]} [genre] + * @property {boolean} isCheckedOut + */ + +const databases = new Databases(client); + +try { + /** @type {Models.DocumentList} */ + const documents = await databases.listDocuments( + 'your-database-id', + 'your-collection-id' + ); + + documents.documents.forEach(book => { + console.log(`Book: ${book.name} by ${book.author}`); // Type hints available in IDE + }); +} catch (error) { + console.error('Appwrite error:', error); +} +``` + +**Tip**: You can use the `appwrite types` command to automatically generate TypeScript interfaces based on your Appwrite database schema. Learn more about [type generation](https://appwrite.io/docs/products/databases/type-generation). + ### Error Handling + The Appwrite Node SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example. ```js diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index 6c940f5..f173d21 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -6,7 +6,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createEmailPasswordSession( - 'email@example.com', // email - 'password' // password -); +const result = await account.createEmailPasswordSession({ + email: 'email@example.com', + password: 'password' +}); diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md index b6be71d..eb071b9 100644 --- a/docs/examples/account/create-email-token.md +++ b/docs/examples/account/create-email-token.md @@ -6,8 +6,8 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createEmailToken( - '', // userId - 'email@example.com', // email - false // phrase (optional) -); +const result = await account.createEmailToken({ + userId: '', + email: 'email@example.com', + phrase: false // optional +}); diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-jwt.md similarity index 100% rename from docs/examples/account/create-j-w-t.md rename to docs/examples/account/create-jwt.md diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-url-token.md similarity index 56% rename from docs/examples/account/create-magic-u-r-l-token.md rename to docs/examples/account/create-magic-url-token.md index 6dbdc3d..59f7d10 100644 --- a/docs/examples/account/create-magic-u-r-l-token.md +++ b/docs/examples/account/create-magic-url-token.md @@ -6,9 +6,9 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createMagicURLToken( - '', // userId - 'email@example.com', // email - 'https://example.com', // url (optional) - false // phrase (optional) -); +const result = await account.createMagicURLToken({ + userId: '', + email: 'email@example.com', + url: 'https://example.com', // optional + phrase: false // optional +}); diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index e52658b..8dd6a59 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createMfaAuthenticator( - sdk.AuthenticatorType.Totp // type -); +const result = await account.createMFAAuthenticator({ + type: sdk.AuthenticatorType.Totp +}); diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index 79d5e89..4195f46 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -6,6 +6,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createMfaChallenge( - sdk.AuthenticationFactor.Email // factor -); +const result = await account.createMFAChallenge({ + factor: sdk.AuthenticationFactor.Email +}); diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index 42b3c8c..1392f44 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -7,4 +7,4 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createMfaRecoveryCodes(); +const result = await account.createMFARecoveryCodes(); diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth-2-token.md similarity index 53% rename from docs/examples/account/create-o-auth2token.md rename to docs/examples/account/create-o-auth-2-token.md index adae095..cc4f315 100644 --- a/docs/examples/account/create-o-auth2token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -6,9 +6,9 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createOAuth2Token( - sdk.OAuthProvider.Amazon, // provider - 'https://example.com', // success (optional) - 'https://example.com', // failure (optional) - [] // scopes (optional) -); +const result = await account.createOAuth2Token({ + provider: sdk.OAuthProvider.Amazon, + success: 'https://example.com', // optional + failure: 'https://example.com', // optional + scopes: [] // optional +}); diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md index aca0bd2..fe88e77 100644 --- a/docs/examples/account/create-phone-token.md +++ b/docs/examples/account/create-phone-token.md @@ -6,7 +6,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createPhoneToken( - '', // userId - '+12065550100' // phone -); +const result = await account.createPhoneToken({ + userId: '', + phone: '+12065550100' +}); diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index 660942a..eab8af6 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createRecovery( - 'email@example.com', // email - 'https://example.com' // url -); +const result = await account.createRecovery({ + email: 'email@example.com', + url: 'https://example.com' +}); diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md index 8c6b910..448f901 100644 --- a/docs/examples/account/create-session.md +++ b/docs/examples/account/create-session.md @@ -6,7 +6,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createSession( - '', // userId - '' // secret -); +const result = await account.createSession({ + userId: '', + secret: '' +}); diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index 1f1db27..02b9e78 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createVerification( - 'https://example.com' // url -); +const result = await account.createVerification({ + url: 'https://example.com' +}); diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index 85e3d2f..7ba2d42 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -6,9 +6,9 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.create( - '', // userId - 'email@example.com', // email - '', // password - '' // name (optional) -); +const result = await account.create({ + userId: '', + email: 'email@example.com', + password: '', + name: '' // optional +}); diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md index 0424ab2..222d4bf 100644 --- a/docs/examples/account/delete-identity.md +++ b/docs/examples/account/delete-identity.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.deleteIdentity( - '' // identityId -); +const result = await account.deleteIdentity({ + identityId: '' +}); diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index 5979c3a..f3d8093 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.deleteMfaAuthenticator( - sdk.AuthenticatorType.Totp // type -); +const result = await account.deleteMFAAuthenticator({ + type: sdk.AuthenticatorType.Totp +}); diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index 4276cca..82e1bd6 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.deleteSession( - '' // sessionId -); +const result = await account.deleteSession({ + sessionId: '' +}); diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index 27f9024..6461e6b 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -7,4 +7,4 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.getMfaRecoveryCodes(); +const result = await account.getMFARecoveryCodes(); diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index 63b6f08..edf3836 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.getSession( - '' // sessionId -); +const result = await account.getSession({ + sessionId: '' +}); diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index c49894c..b124065 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.listIdentities( - [] // queries (optional) -); +const result = await account.listIdentities({ + queries: [] // optional +}); diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index 4260a72..ca47edd 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.listLogs( - [] // queries (optional) -); +const result = await account.listLogs({ + queries: [] // optional +}); diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index a993e31..97f7f5f 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -7,4 +7,4 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.listMfaFactors(); +const result = await account.listMFAFactors(); diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index 6111f0e..58fea36 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updateEmail( - 'email@example.com', // email - 'password' // password -); +const result = await account.updateEmail({ + email: 'email@example.com', + password: 'password' +}); diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-url-session.md similarity index 70% rename from docs/examples/account/update-magic-u-r-l-session.md rename to docs/examples/account/update-magic-url-session.md index 3e059d8..d67d481 100644 --- a/docs/examples/account/update-magic-u-r-l-session.md +++ b/docs/examples/account/update-magic-url-session.md @@ -6,7 +6,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updateMagicURLSession( - '', // userId - '' // secret -); +const result = await account.updateMagicURLSession({ + userId: '', + secret: '' +}); diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index 7b24dc8..18e1575 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updateMfaAuthenticator( - sdk.AuthenticatorType.Totp, // type - '' // otp -); +const result = await account.updateMFAAuthenticator({ + type: sdk.AuthenticatorType.Totp, + otp: '' +}); diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index 4d30999..4903e1e 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updateMfaChallenge( - '', // challengeId - '' // otp -); +const result = await account.updateMFAChallenge({ + challengeId: '', + otp: '' +}); diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index 9db8217..fd5c1fd 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -7,4 +7,4 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updateMfaRecoveryCodes(); +const result = await account.updateMFARecoveryCodes(); diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-mfa.md similarity index 83% rename from docs/examples/account/update-m-f-a.md rename to docs/examples/account/update-mfa.md index 58629cd..378c23f 100644 --- a/docs/examples/account/update-m-f-a.md +++ b/docs/examples/account/update-mfa.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updateMFA( - false // mfa -); +const result = await account.updateMFA({ + mfa: false +}); diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index f47d215..f812116 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updateName( - '' // name -); +const result = await account.updateName({ + name: '' +}); diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index aa9d67a..e7e8437 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updatePassword( - '', // password - 'password' // oldPassword (optional) -); +const result = await account.updatePassword({ + password: '', + oldPassword: 'password' // optional +}); diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md index c208714..7d96800 100644 --- a/docs/examples/account/update-phone-session.md +++ b/docs/examples/account/update-phone-session.md @@ -6,7 +6,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updatePhoneSession( - '', // userId - '' // secret -); +const result = await account.updatePhoneSession({ + userId: '', + secret: '' +}); diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index 116d171..af05baf 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updatePhoneVerification( - '', // userId - '' // secret -); +const result = await account.updatePhoneVerification({ + userId: '', + secret: '' +}); diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index c6c02fd..b1f1daa 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updatePhone( - '+12065550100', // phone - 'password' // password -); +const result = await account.updatePhone({ + phone: '+12065550100', + password: 'password' +}); diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index ee8b042..113f867 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updatePrefs( - {} // prefs -); +const result = await account.updatePrefs({ + prefs: {} +}); diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index bd4a87c..c88b435 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updateRecovery( - '', // userId - '', // secret - '' // password -); +const result = await account.updateRecovery({ + userId: '', + secret: '', + password: '' +}); diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index be80c85..c189f68 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updateSession( - '' // sessionId -); +const result = await account.updateSession({ + sessionId: '' +}); diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 0abb562..d64b402 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.updateVerification( - '', // userId - '' // secret -); +const result = await account.updateVerification({ + userId: '', + secret: '' +}); diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 1cc825d..9f3b2cc 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const avatars = new sdk.Avatars(client); -const result = await avatars.getBrowser( - sdk.Browser.AvantBrowser, // code - 0, // width (optional) - 0, // height (optional) - -1 // quality (optional) -); +const result = await avatars.getBrowser({ + code: sdk.Browser.AvantBrowser, + width: 0, // optional + height: 0, // optional + quality: -1 // optional +}); diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index 7d62a96..1337d05 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const avatars = new sdk.Avatars(client); -const result = await avatars.getCreditCard( - sdk.CreditCard.AmericanExpress, // code - 0, // width (optional) - 0, // height (optional) - -1 // quality (optional) -); +const result = await avatars.getCreditCard({ + code: sdk.CreditCard.AmericanExpress, + width: 0, // optional + height: 0, // optional + quality: -1 // optional +}); diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index 6056354..6f79cb6 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const avatars = new sdk.Avatars(client); -const result = await avatars.getFavicon( - 'https://example.com' // url -); +const result = await avatars.getFavicon({ + url: 'https://example.com' +}); diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index a62f56d..672c18b 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const avatars = new sdk.Avatars(client); -const result = await avatars.getFlag( - sdk.Flag.Afghanistan, // code - 0, // width (optional) - 0, // height (optional) - -1 // quality (optional) -); +const result = await avatars.getFlag({ + code: sdk.Flag.Afghanistan, + width: 0, // optional + height: 0, // optional + quality: -1 // optional +}); diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index 7dac242..12aef10 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const avatars = new sdk.Avatars(client); -const result = await avatars.getImage( - 'https://example.com', // url - 0, // width (optional) - 0 // height (optional) -); +const result = await avatars.getImage({ + url: 'https://example.com', + width: 0, // optional + height: 0 // optional +}); diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 2cd45bf..584786f 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const avatars = new sdk.Avatars(client); -const result = await avatars.getInitials( - '', // name (optional) - 0, // width (optional) - 0, // height (optional) - '' // background (optional) -); +const result = await avatars.getInitials({ + name: '', // optional + width: 0, // optional + height: 0, // optional + background: '' // optional +}); diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-qr.md similarity index 67% rename from docs/examples/avatars/get-q-r.md rename to docs/examples/avatars/get-qr.md index cfd649e..fd08380 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-qr.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const avatars = new sdk.Avatars(client); -const result = await avatars.getQR( - '', // text - 1, // size (optional) - 0, // margin (optional) - false // download (optional) -); +const result = await avatars.getQR({ + text: '', + size: 1, // optional + margin: 0, // optional + download: false // optional +}); diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index b623969..2e9b562 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createBooleanAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - false, // default (optional) - false // array (optional) -); +const result = await databases.createBooleanAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: false, // optional + array: false // optional +}); diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index fc5c798..8ad770d 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createCollection( - '', // databaseId - '', // collectionId - '', // name - ["read("any")"], // permissions (optional) - false, // documentSecurity (optional) - false // enabled (optional) -); +const result = await databases.createCollection({ + databaseId: '', + collectionId: '', + name: '', + permissions: ["read("any")"], // optional + documentSecurity: false, // optional + enabled: false // optional +}); diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index 4c7328c..7ca8b55 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createDatetimeAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - '', // default (optional) - false // array (optional) -); +const result = await databases.createDatetimeAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +}); diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index a2e77b9..39442d1 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -7,10 +7,10 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createDocument( - '', // databaseId - '', // collectionId - '', // documentId - {}, // data - ["read("any")"] // permissions (optional) -); +const result = await databases.createDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + permissions: ["read("any")"] // optional +}); diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index d73df44..73d08aa 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createDocuments( - '', // databaseId - '', // collectionId - [] // documents -); +const result = await databases.createDocuments({ + databaseId: '', + collectionId: '', + documents: [] +}); diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index 47b2750..4afebf6 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createEmailAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - 'email@example.com', // default (optional) - false // array (optional) -); +const result = await databases.createEmailAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: 'email@example.com', // optional + array: false // optional +}); diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index 61c1d77..5866eab 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -7,12 +7,12 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createEnumAttribute( - '', // databaseId - '', // collectionId - '', // key - [], // elements - false, // required - '', // default (optional) - false // array (optional) -); +const result = await databases.createEnumAttribute({ + databaseId: '', + collectionId: '', + key: '', + elements: [], + required: false, + default: '', // optional + array: false // optional +}); diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index 3e60500..7843c16 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -7,13 +7,13 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createFloatAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - null, // min (optional) - null, // max (optional) - null, // default (optional) - false // array (optional) -); +const result = await databases.createFloatAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + default: null, // optional + array: false // optional +}); diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index ed03322..ce5214a 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -7,12 +7,12 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createIndex( - '', // databaseId - '', // collectionId - '', // key - sdk.IndexType.Key, // type - [], // attributes - [], // orders (optional) - [] // lengths (optional) -); +const result = await databases.createIndex({ + databaseId: '', + collectionId: '', + key: '', + type: sdk.IndexType.Key, + attributes: [], + orders: [], // optional + lengths: [] // optional +}); diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index ce62624..e375266 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -7,13 +7,13 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createIntegerAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - null, // min (optional) - null, // max (optional) - null, // default (optional) - false // array (optional) -); +const result = await databases.createIntegerAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + default: null, // optional + array: false // optional +}); diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index e3bbffe..110e3a8 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createIpAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - '', // default (optional) - false // array (optional) -); +const result = await databases.createIpAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +}); diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md index bb77bc0..b09c6a3 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -7,13 +7,13 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createRelationshipAttribute( - '', // databaseId - '', // collectionId - '', // relatedCollectionId - sdk.RelationshipType.OneToOne, // type - false, // twoWay (optional) - '', // key (optional) - '', // twoWayKey (optional) - sdk.RelationMutate.Cascade // onDelete (optional) -); +const result = await databases.createRelationshipAttribute({ + databaseId: '', + collectionId: '', + relatedCollectionId: '', + type: sdk.RelationshipType.OneToOne, + twoWay: false, // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: sdk.RelationMutate.Cascade // optional +}); diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index 94793e8..57ed8f4 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -7,13 +7,13 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createStringAttribute( - '', // databaseId - '', // collectionId - '', // key - 1, // size - false, // required - '', // default (optional) - false, // array (optional) - false // encrypt (optional) -); +const result = await databases.createStringAttribute({ + databaseId: '', + collectionId: '', + key: '', + size: 1, + required: false, + default: '', // optional + array: false, // optional + encrypt: false // optional +}); diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index 6b6b1da..af3177f 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.createUrlAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - 'https://example.com', // default (optional) - false // array (optional) -); +const result = await databases.createUrlAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: 'https://example.com', // optional + array: false // optional +}); diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index c1fd4ec..7392a85 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.create( - '', // databaseId - '', // name - false // enabled (optional) -); +const result = await databases.create({ + databaseId: '', + name: '', + enabled: false // optional +}); diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index 6bfc5f1..87e4d7d 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -3,15 +3,15 @@ const sdk = require('node-appwrite'); const client = new sdk.Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject('') // Your project ID - .setKey(''); // Your secret API key + .setSession(''); // The user session to authenticate with const databases = new sdk.Databases(client); -const result = await databases.decrementDocumentAttribute( - '', // databaseId - '', // collectionId - '', // documentId - '', // attribute - null, // value (optional) - null // min (optional) -); +const result = await databases.decrementDocumentAttribute({ + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: null, // optional + min: null // optional +}); diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md index 8291fc0..166aa19 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.deleteAttribute( - '', // databaseId - '', // collectionId - '' // key -); +const result = await databases.deleteAttribute({ + databaseId: '', + collectionId: '', + key: '' +}); diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md index 9551c55..f915076 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.deleteCollection( - '', // databaseId - '' // collectionId -); +const result = await databases.deleteCollection({ + databaseId: '', + collectionId: '' +}); diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 526f00e..429554b 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.deleteDocument( - '', // databaseId - '', // collectionId - '' // documentId -); +const result = await databases.deleteDocument({ + databaseId: '', + collectionId: '', + documentId: '' +}); diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 01814e5..0965d8d 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.deleteDocuments( - '', // databaseId - '', // collectionId - [] // queries (optional) -); +const result = await databases.deleteDocuments({ + databaseId: '', + collectionId: '', + queries: [] // optional +}); diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index 90353ea..24f74c6 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.deleteIndex( - '', // databaseId - '', // collectionId - '' // key -); +const result = await databases.deleteIndex({ + databaseId: '', + collectionId: '', + key: '' +}); diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index 65179d2..fc9ace4 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.delete( - '' // databaseId -); +const result = await databases.delete({ + databaseId: '' +}); diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index 8757265..4c68303 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.getAttribute( - '', // databaseId - '', // collectionId - '' // key -); +const result = await databases.getAttribute({ + databaseId: '', + collectionId: '', + key: '' +}); diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index 79c5674..4855471 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.getCollection( - '', // databaseId - '' // collectionId -); +const result = await databases.getCollection({ + databaseId: '', + collectionId: '' +}); diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index eee515b..7cc71cd 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.getDocument( - '', // databaseId - '', // collectionId - '', // documentId - [] // queries (optional) -); +const result = await databases.getDocument({ + databaseId: '', + collectionId: '', + documentId: '', + queries: [] // optional +}); diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index a4b3a45..d7edb84 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.getIndex( - '', // databaseId - '', // collectionId - '' // key -); +const result = await databases.getIndex({ + databaseId: '', + collectionId: '', + key: '' +}); diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index a8e8084..eb83ef7 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.get( - '' // databaseId -); +const result = await databases.get({ + databaseId: '' +}); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 0ba0245..2b47f5a 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -3,15 +3,15 @@ const sdk = require('node-appwrite'); const client = new sdk.Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject('') // Your project ID - .setKey(''); // Your secret API key + .setSession(''); // The user session to authenticate with const databases = new sdk.Databases(client); -const result = await databases.incrementDocumentAttribute( - '', // databaseId - '', // collectionId - '', // documentId - '', // attribute - null, // value (optional) - null // max (optional) -); +const result = await databases.incrementDocumentAttribute({ + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: null, // optional + max: null // optional +}); diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index e7b48fb..a69800c 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.listAttributes( - '', // databaseId - '', // collectionId - [] // queries (optional) -); +const result = await databases.listAttributes({ + databaseId: '', + collectionId: '', + queries: [] // optional +}); diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index bc31ead..933b53c 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.listCollections( - '', // databaseId - [], // queries (optional) - '' // search (optional) -); +const result = await databases.listCollections({ + databaseId: '', + queries: [], // optional + search: '' // optional +}); diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index d251485..148bf83 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.listDocuments( - '', // databaseId - '', // collectionId - [] // queries (optional) -); +const result = await databases.listDocuments({ + databaseId: '', + collectionId: '', + queries: [] // optional +}); diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index 86c6c26..f48112f 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.listIndexes( - '', // databaseId - '', // collectionId - [] // queries (optional) -); +const result = await databases.listIndexes({ + databaseId: '', + collectionId: '', + queries: [] // optional +}); diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index 06fe6a8..4ac7e47 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.list( - [], // queries (optional) - '' // search (optional) -); +const result = await databases.list({ + queries: [], // optional + search: '' // optional +}); diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md index d0d551c..224fc8e 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateBooleanAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - false, // default - '' // newKey (optional) -); +const result = await databases.updateBooleanAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: false, + newKey: '' // optional +}); diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 2618fc7..d0d25b7 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateCollection( - '', // databaseId - '', // collectionId - '', // name - ["read("any")"], // permissions (optional) - false, // documentSecurity (optional) - false // enabled (optional) -); +const result = await databases.updateCollection({ + databaseId: '', + collectionId: '', + name: '', + permissions: ["read("any")"], // optional + documentSecurity: false, // optional + enabled: false // optional +}); diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index d2378f9..2003448 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateDatetimeAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - '', // default - '' // newKey (optional) -); +const result = await databases.updateDatetimeAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +}); diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 9646803..8a9a685 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -7,10 +7,10 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateDocument( - '', // databaseId - '', // collectionId - '', // documentId - {}, // data (optional) - ["read("any")"] // permissions (optional) -); +const result = await databases.updateDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: ["read("any")"] // optional +}); diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 62b2271..2cfb8c7 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateDocuments( - '', // databaseId - '', // collectionId - {}, // data (optional) - [] // queries (optional) -); +const result = await databases.updateDocuments({ + databaseId: '', + collectionId: '', + data: {}, // optional + queries: [] // optional +}); diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md index 8b7afbe..738c533 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateEmailAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - 'email@example.com', // default - '' // newKey (optional) -); +const result = await databases.updateEmailAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: 'email@example.com', + newKey: '' // optional +}); diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index f328132..f240cb0 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -7,12 +7,12 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateEnumAttribute( - '', // databaseId - '', // collectionId - '', // key - [], // elements - false, // required - '', // default - '' // newKey (optional) -); +const result = await databases.updateEnumAttribute({ + databaseId: '', + collectionId: '', + key: '', + elements: [], + required: false, + default: '', + newKey: '' // optional +}); diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index abb93c2..877cad1 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -7,13 +7,13 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateFloatAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - null, // default - null, // min (optional) - null, // max (optional) - '' // newKey (optional) -); +const result = await databases.updateFloatAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index e126f31..cf7101e 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -7,13 +7,13 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateIntegerAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - null, // default - null, // min (optional) - null, // max (optional) - '' // newKey (optional) -); +const result = await databases.updateIntegerAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md index 1c8ac79..d41bb85 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateIpAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - '', // default - '' // newKey (optional) -); +const result = await databases.updateIpAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +}); diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md index 1a7a26c..aa476c4 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -7,10 +7,10 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateRelationshipAttribute( - '', // databaseId - '', // collectionId - '', // key - sdk.RelationMutate.Cascade, // onDelete (optional) - '' // newKey (optional) -); +const result = await databases.updateRelationshipAttribute({ + databaseId: '', + collectionId: '', + key: '', + onDelete: sdk.RelationMutate.Cascade, // optional + newKey: '' // optional +}); diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index 0e0656e..b0d7bea 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -7,12 +7,12 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateStringAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - '', // default - 1, // size (optional) - '' // newKey (optional) -); +const result = await databases.updateStringAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', + size: 1, // optional + newKey: '' // optional +}); diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md index 4a2aca0..48d9281 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.updateUrlAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - 'https://example.com', // default - '' // newKey (optional) -); +const result = await databases.updateUrlAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: 'https://example.com', + newKey: '' // optional +}); diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index 9c69bfd..9a0dbd2 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.update( - '', // databaseId - '', // name - false // enabled (optional) -); +const result = await databases.update({ + databaseId: '', + name: '', + enabled: false // optional +}); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index fcc62d6..5ec3e05 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -7,10 +7,10 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.upsertDocument( - '', // databaseId - '', // collectionId - '', // documentId - {}, // data - ["read("any")"] // permissions (optional) -); +const result = await databases.upsertDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + permissions: ["read("any")"] // optional +}); diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 425b7ba..8deec53 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const databases = new sdk.Databases(client); -const result = await databases.upsertDocuments( - '', // databaseId - '', // collectionId - [] // documents -); +const result = await databases.upsertDocuments({ + databaseId: '', + collectionId: '', + documents: [] +}); diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index 5ede954..77946a7 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -8,10 +8,10 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.createDeployment( - '', // functionId - InputFile.fromPath('/path/to/file', 'filename'), // code - false, // activate - '', // entrypoint (optional) - '' // commands (optional) -); +const result = await functions.createDeployment({ + functionId: '', + code: InputFile.fromPath('/path/to/file', 'filename'), + activate: false, + entrypoint: '', // optional + commands: '' // optional +}); diff --git a/docs/examples/functions/create-duplicate-deployment.md b/docs/examples/functions/create-duplicate-deployment.md index 33f77ff..03c68e7 100644 --- a/docs/examples/functions/create-duplicate-deployment.md +++ b/docs/examples/functions/create-duplicate-deployment.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.createDuplicateDeployment( - '', // functionId - '', // deploymentId - '' // buildId (optional) -); +const result = await functions.createDuplicateDeployment({ + functionId: '', + deploymentId: '', + buildId: '' // optional +}); diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 3c89030..5b2c18c 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -7,12 +7,12 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.createExecution( - '', // functionId - '', // body (optional) - false, // async (optional) - '', // path (optional) - sdk.ExecutionMethod.GET, // method (optional) - {}, // headers (optional) - '' // scheduledAt (optional) -); +const result = await functions.createExecution({ + functionId: '', + body: '', // optional + async: false, // optional + path: '', // optional + method: sdk.ExecutionMethod.GET, // optional + headers: {}, // optional + scheduledAt: '' // optional +}); diff --git a/docs/examples/functions/create-template-deployment.md b/docs/examples/functions/create-template-deployment.md index eef7148..8f6395f 100644 --- a/docs/examples/functions/create-template-deployment.md +++ b/docs/examples/functions/create-template-deployment.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.createTemplateDeployment( - '', // functionId - '', // repository - '', // owner - '', // rootDirectory - '', // version - false // activate (optional) -); +const result = await functions.createTemplateDeployment({ + functionId: '', + repository: '', + owner: '', + rootDirectory: '', + version: '', + activate: false // optional +}); diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index 5e75d19..4592839 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.createVariable( - '', // functionId - '', // key - '', // value - false // secret (optional) -); +const result = await functions.createVariable({ + functionId: '', + key: '', + value: '', + secret: false // optional +}); diff --git a/docs/examples/functions/create-vcs-deployment.md b/docs/examples/functions/create-vcs-deployment.md index ba1067f..0aabfcf 100644 --- a/docs/examples/functions/create-vcs-deployment.md +++ b/docs/examples/functions/create-vcs-deployment.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.createVcsDeployment( - '', // functionId - sdk.VCSDeploymentType.Branch, // type - '', // reference - false // activate (optional) -); +const result = await functions.createVcsDeployment({ + functionId: '', + type: sdk.VCSDeploymentType.Branch, + reference: '', + activate: false // optional +}); diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 646e2e5..d9f21ff 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -7,23 +7,23 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.create( - '', // functionId - '', // name - sdk..Node145, // runtime - ["any"], // execute (optional) - [], // events (optional) - '', // schedule (optional) - 1, // timeout (optional) - false, // enabled (optional) - false, // logging (optional) - '', // entrypoint (optional) - '', // commands (optional) - [], // scopes (optional) - '', // installationId (optional) - '', // providerRepositoryId (optional) - '', // providerBranch (optional) - false, // providerSilentMode (optional) - '', // providerRootDirectory (optional) - '' // specification (optional) -); +const result = await functions.create({ + functionId: '', + name: '', + runtime: sdk..Node145, + execute: ["any"], // optional + events: [], // optional + schedule: '', // optional + timeout: 1, // optional + enabled: false, // optional + logging: false, // optional + entrypoint: '', // optional + commands: '', // optional + scopes: [], // optional + installationId: '', // optional + providerRepositoryId: '', // optional + providerBranch: '', // optional + providerSilentMode: false, // optional + providerRootDirectory: '', // optional + specification: '' // optional +}); diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md index f6768ec..9f9815b 100644 --- a/docs/examples/functions/delete-deployment.md +++ b/docs/examples/functions/delete-deployment.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.deleteDeployment( - '', // functionId - '' // deploymentId -); +const result = await functions.deleteDeployment({ + functionId: '', + deploymentId: '' +}); diff --git a/docs/examples/functions/delete-execution.md b/docs/examples/functions/delete-execution.md index c3e77a6..cf9d107 100644 --- a/docs/examples/functions/delete-execution.md +++ b/docs/examples/functions/delete-execution.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.deleteExecution( - '', // functionId - '' // executionId -); +const result = await functions.deleteExecution({ + functionId: '', + executionId: '' +}); diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md index 7840b1d..70ee4f7 100644 --- a/docs/examples/functions/delete-variable.md +++ b/docs/examples/functions/delete-variable.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.deleteVariable( - '', // functionId - '' // variableId -); +const result = await functions.deleteVariable({ + functionId: '', + variableId: '' +}); diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index a2e0a23..635f271 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.delete( - '' // functionId -); +const result = await functions.delete({ + functionId: '' +}); diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md index 5ba1035..9e82998 100644 --- a/docs/examples/functions/get-deployment-download.md +++ b/docs/examples/functions/get-deployment-download.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.getDeploymentDownload( - '', // functionId - '', // deploymentId - sdk.DeploymentDownloadType.Source // type (optional) -); +const result = await functions.getDeploymentDownload({ + functionId: '', + deploymentId: '', + type: sdk.DeploymentDownloadType.Source // optional +}); diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md index 6a55534..c47081c 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.getDeployment( - '', // functionId - '' // deploymentId -); +const result = await functions.getDeployment({ + functionId: '', + deploymentId: '' +}); diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index b9fed55..ad3ff48 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.getExecution( - '', // functionId - '' // executionId -); +const result = await functions.getExecution({ + functionId: '', + executionId: '' +}); diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md index 3b6135f..9f47331 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.getVariable( - '', // functionId - '' // variableId -); +const result = await functions.getVariable({ + functionId: '', + variableId: '' +}); diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index b886092..463054d 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.get( - '' // functionId -); +const result = await functions.get({ + functionId: '' +}); diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index 731d1c4..e14c6d0 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.listDeployments( - '', // functionId - [], // queries (optional) - '' // search (optional) -); +const result = await functions.listDeployments({ + functionId: '', + queries: [], // optional + search: '' // optional +}); diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index 24d3e54..0d1ceb7 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.listExecutions( - '', // functionId - [] // queries (optional) -); +const result = await functions.listExecutions({ + functionId: '', + queries: [] // optional +}); diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index 4220918..962a810 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.listVariables( - '' // functionId -); +const result = await functions.listVariables({ + functionId: '' +}); diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index af5082c..847c345 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.list( - [], // queries (optional) - '' // search (optional) -); +const result = await functions.list({ + queries: [], // optional + search: '' // optional +}); diff --git a/docs/examples/functions/update-deployment-status.md b/docs/examples/functions/update-deployment-status.md index e7ce4a8..32b8a61 100644 --- a/docs/examples/functions/update-deployment-status.md +++ b/docs/examples/functions/update-deployment-status.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.updateDeploymentStatus( - '', // functionId - '' // deploymentId -); +const result = await functions.updateDeploymentStatus({ + functionId: '', + deploymentId: '' +}); diff --git a/docs/examples/functions/update-function-deployment.md b/docs/examples/functions/update-function-deployment.md index feef831..b0d3132 100644 --- a/docs/examples/functions/update-function-deployment.md +++ b/docs/examples/functions/update-function-deployment.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.updateFunctionDeployment( - '', // functionId - '' // deploymentId -); +const result = await functions.updateFunctionDeployment({ + functionId: '', + deploymentId: '' +}); diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index d9a7ac7..73ae49f 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -7,10 +7,10 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.updateVariable( - '', // functionId - '', // variableId - '', // key - '', // value (optional) - false // secret (optional) -); +const result = await functions.updateVariable({ + functionId: '', + variableId: '', + key: '', + value: '', // optional + secret: false // optional +}); diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index b6de177..8ed2828 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -7,23 +7,23 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); -const result = await functions.update( - '', // functionId - '', // name - sdk..Node145, // runtime (optional) - ["any"], // execute (optional) - [], // events (optional) - '', // schedule (optional) - 1, // timeout (optional) - false, // enabled (optional) - false, // logging (optional) - '', // entrypoint (optional) - '', // commands (optional) - [], // scopes (optional) - '', // installationId (optional) - '', // providerRepositoryId (optional) - '', // providerBranch (optional) - false, // providerSilentMode (optional) - '', // providerRootDirectory (optional) - '' // specification (optional) -); +const result = await functions.update({ + functionId: '', + name: '', + runtime: sdk..Node145, // optional + execute: ["any"], // optional + events: [], // optional + schedule: '', // optional + timeout: 1, // optional + enabled: false, // optional + logging: false, // optional + entrypoint: '', // optional + commands: '', // optional + scopes: [], // optional + installationId: '', // optional + providerRepositoryId: '', // optional + providerBranch: '', // optional + providerSilentMode: false, // optional + providerRootDirectory: '', // optional + specification: '' // optional +}); diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index 8031a52..dffb7b3 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const graphql = new sdk.Graphql(client); -const result = await graphql.mutation( - {} // query -); +const result = await graphql.mutation({ + query: {} +}); diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 1545675..1f873ed 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const graphql = new sdk.Graphql(client); -const result = await graphql.query( - {} // query -); +const result = await graphql.query({ + query: {} +}); diff --git a/docs/examples/health/get-certificate.md b/docs/examples/health/get-certificate.md index ec91293..ccb8800 100644 --- a/docs/examples/health/get-certificate.md +++ b/docs/examples/health/get-certificate.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getCertificate( - '' // domain (optional) -); +const result = await health.getCertificate({ + domain: '' // optional +}); diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-db.md similarity index 100% rename from docs/examples/health/get-d-b.md rename to docs/examples/health/get-db.md diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/health/get-failed-jobs.md index d88b7f2..bf77aa2 100644 --- a/docs/examples/health/get-failed-jobs.md +++ b/docs/examples/health/get-failed-jobs.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getFailedJobs( - sdk..V1Database, // name - null // threshold (optional) -); +const result = await health.getFailedJobs({ + name: sdk..V1Database, + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-builds.md b/docs/examples/health/get-queue-builds.md index 929f976..8e28054 100644 --- a/docs/examples/health/get-queue-builds.md +++ b/docs/examples/health/get-queue-builds.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueBuilds( - null // threshold (optional) -); +const result = await health.getQueueBuilds({ + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md index 33e71ec..89383ed 100644 --- a/docs/examples/health/get-queue-certificates.md +++ b/docs/examples/health/get-queue-certificates.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueCertificates( - null // threshold (optional) -); +const result = await health.getQueueCertificates({ + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-databases.md b/docs/examples/health/get-queue-databases.md index ca409c1..7845255 100644 --- a/docs/examples/health/get-queue-databases.md +++ b/docs/examples/health/get-queue-databases.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueDatabases( - '', // name (optional) - null // threshold (optional) -); +const result = await health.getQueueDatabases({ + name: '', // optional + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-deletes.md b/docs/examples/health/get-queue-deletes.md index 9f2d6f8..8248b5c 100644 --- a/docs/examples/health/get-queue-deletes.md +++ b/docs/examples/health/get-queue-deletes.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueDeletes( - null // threshold (optional) -); +const result = await health.getQueueDeletes({ + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md index 0392db1..5832a27 100644 --- a/docs/examples/health/get-queue-functions.md +++ b/docs/examples/health/get-queue-functions.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueFunctions( - null // threshold (optional) -); +const result = await health.getQueueFunctions({ + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md index a71ff13..055c525 100644 --- a/docs/examples/health/get-queue-logs.md +++ b/docs/examples/health/get-queue-logs.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueLogs( - null // threshold (optional) -); +const result = await health.getQueueLogs({ + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-mails.md b/docs/examples/health/get-queue-mails.md index 8c45c1a..fb29d08 100644 --- a/docs/examples/health/get-queue-mails.md +++ b/docs/examples/health/get-queue-mails.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueMails( - null // threshold (optional) -); +const result = await health.getQueueMails({ + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-messaging.md b/docs/examples/health/get-queue-messaging.md index 46160a0..cc8eb4b 100644 --- a/docs/examples/health/get-queue-messaging.md +++ b/docs/examples/health/get-queue-messaging.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueMessaging( - null // threshold (optional) -); +const result = await health.getQueueMessaging({ + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-migrations.md b/docs/examples/health/get-queue-migrations.md index 5f8d262..ddc7f51 100644 --- a/docs/examples/health/get-queue-migrations.md +++ b/docs/examples/health/get-queue-migrations.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueMigrations( - null // threshold (optional) -); +const result = await health.getQueueMigrations({ + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-stats-resources.md b/docs/examples/health/get-queue-stats-resources.md index 1b16e6d..dacf04c 100644 --- a/docs/examples/health/get-queue-stats-resources.md +++ b/docs/examples/health/get-queue-stats-resources.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueStatsResources( - null // threshold (optional) -); +const result = await health.getQueueStatsResources({ + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-usage.md b/docs/examples/health/get-queue-usage.md index 2a20620..5d06a7c 100644 --- a/docs/examples/health/get-queue-usage.md +++ b/docs/examples/health/get-queue-usage.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueUsage( - null // threshold (optional) -); +const result = await health.getQueueUsage({ + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md index acc2098..f4d0af8 100644 --- a/docs/examples/health/get-queue-webhooks.md +++ b/docs/examples/health/get-queue-webhooks.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const health = new sdk.Health(client); -const result = await health.getQueueWebhooks( - null // threshold (optional) -); +const result = await health.getQueueWebhooks({ + threshold: null // optional +}); diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-eu.md similarity index 100% rename from docs/examples/locale/list-countries-e-u.md rename to docs/examples/locale/list-countries-eu.md diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md index a283090..cd1a53b 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -7,13 +7,13 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createApnsProvider( - '', // providerId - '', // name - '', // authKey (optional) - '', // authKeyId (optional) - '', // teamId (optional) - '', // bundleId (optional) - false, // sandbox (optional) - false // enabled (optional) -); +const result = await messaging.createAPNSProvider({ + providerId: '', + name: '', + authKey: '', // optional + authKeyId: '', // optional + teamId: '', // optional + bundleId: '', // optional + sandbox: false, // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index b4b1f66..93fb2ef 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -7,17 +7,17 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createEmail( - '', // messageId - '', // subject - '', // content - [], // topics (optional) - [], // users (optional) - [], // targets (optional) - [], // cc (optional) - [], // bcc (optional) - [], // attachments (optional) - false, // draft (optional) - false, // html (optional) - '' // scheduledAt (optional) -); +const result = await messaging.createEmail({ + messageId: '', + subject: '', + content: '', + topics: [], // optional + users: [], // optional + targets: [], // optional + cc: [], // optional + bcc: [], // optional + attachments: [], // optional + draft: false, // optional + html: false, // optional + scheduledAt: '' // optional +}); diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md index a8af6ba..8041e7f 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createFcmProvider( - '', // providerId - '', // name - {}, // serviceAccountJSON (optional) - false // enabled (optional) -); +const result = await messaging.createFCMProvider({ + providerId: '', + name: '', + serviceAccountJSON: {}, // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md index ee49f64..dd8a0f6 100644 --- a/docs/examples/messaging/create-mailgun-provider.md +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -7,15 +7,15 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createMailgunProvider( - '', // providerId - '', // name - '', // apiKey (optional) - '', // domain (optional) - false, // isEuRegion (optional) - '', // fromName (optional) - 'email@example.com', // fromEmail (optional) - '', // replyToName (optional) - 'email@example.com', // replyToEmail (optional) - false // enabled (optional) -); +const result = await messaging.createMailgunProvider({ + providerId: '', + name: '', + apiKey: '', // optional + domain: '', // optional + isEuRegion: false, // optional + fromName: '', // optional + fromEmail: 'email@example.com', // optional + replyToName: '', // optional + replyToEmail: 'email@example.com', // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/create-msg91provider.md b/docs/examples/messaging/create-msg-91-provider.md similarity index 53% rename from docs/examples/messaging/create-msg91provider.md rename to docs/examples/messaging/create-msg-91-provider.md index e7075dc..7168e8b 100644 --- a/docs/examples/messaging/create-msg91provider.md +++ b/docs/examples/messaging/create-msg-91-provider.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createMsg91Provider( - '', // providerId - '', // name - '', // templateId (optional) - '', // senderId (optional) - '', // authKey (optional) - false // enabled (optional) -); +const result = await messaging.createMsg91Provider({ + providerId: '', + name: '', + templateId: '', // optional + senderId: '', // optional + authKey: '', // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index bd89f76..c0a7f47 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -7,24 +7,24 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createPush( - '', // messageId - '', // title (optional) - '<BODY>', // body (optional) - [], // topics (optional) - [], // users (optional) - [], // targets (optional) - {}, // data (optional) - '<ACTION>', // action (optional) - '[ID1:ID2]', // image (optional) - '<ICON>', // icon (optional) - '<SOUND>', // sound (optional) - '<COLOR>', // color (optional) - '<TAG>', // tag (optional) - null, // badge (optional) - false, // draft (optional) - '', // scheduledAt (optional) - false, // contentAvailable (optional) - false, // critical (optional) - sdk.MessagePriority.Normal // priority (optional) -); +const result = await messaging.createPush({ + messageId: '<MESSAGE_ID>', + title: '<TITLE>', // optional + body: '<BODY>', // optional + topics: [], // optional + users: [], // optional + targets: [], // optional + data: {}, // optional + action: '<ACTION>', // optional + image: '[ID1:ID2]', // optional + icon: '<ICON>', // optional + sound: '<SOUND>', // optional + color: '<COLOR>', // optional + tag: '<TAG>', // optional + badge: null, // optional + draft: false, // optional + scheduledAt: '', // optional + contentAvailable: false, // optional + critical: false, // optional + priority: sdk.MessagePriority.Normal // optional +}); diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md index 8cde02e..8b26b2f 100644 --- a/docs/examples/messaging/create-sendgrid-provider.md +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -7,13 +7,13 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createSendgridProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '<API_KEY>', // apiKey (optional) - '<FROM_NAME>', // fromName (optional) - 'email@example.com', // fromEmail (optional) - '<REPLY_TO_NAME>', // replyToName (optional) - 'email@example.com', // replyToEmail (optional) - false // enabled (optional) -); +const result = await messaging.createSendgridProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + apiKey: '<API_KEY>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: 'email@example.com', // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 226f47c..c477643 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -7,12 +7,12 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createSms( - '<MESSAGE_ID>', // messageId - '<CONTENT>', // content - [], // topics (optional) - [], // users (optional) - [], // targets (optional) - false, // draft (optional) - '' // scheduledAt (optional) -); +const result = await messaging.createSMS({ + messageId: '<MESSAGE_ID>', + content: '<CONTENT>', + topics: [], // optional + users: [], // optional + targets: [], // optional + draft: false, // optional + scheduledAt: '' // optional +}); diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index 50a8d20..241a0f0 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -7,19 +7,19 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createSmtpProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '<HOST>', // host - 1, // port (optional) - '<USERNAME>', // username (optional) - '<PASSWORD>', // password (optional) - sdk.SmtpEncryption.None, // encryption (optional) - false, // autoTLS (optional) - '<MAILER>', // mailer (optional) - '<FROM_NAME>', // fromName (optional) - 'email@example.com', // fromEmail (optional) - '<REPLY_TO_NAME>', // replyToName (optional) - 'email@example.com', // replyToEmail (optional) - false // enabled (optional) -); +const result = await messaging.createSMTPProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + host: '<HOST>', + port: 1, // optional + username: '<USERNAME>', // optional + password: '<PASSWORD>', // optional + encryption: sdk.SmtpEncryption.None, // optional + autoTLS: false, // optional + mailer: '<MAILER>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: 'email@example.com', // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md index 9874d07..f86a424 100644 --- a/docs/examples/messaging/create-subscriber.md +++ b/docs/examples/messaging/create-subscriber.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createSubscriber( - '<TOPIC_ID>', // topicId - '<SUBSCRIBER_ID>', // subscriberId - '<TARGET_ID>' // targetId -); +const result = await messaging.createSubscriber({ + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>', + targetId: '<TARGET_ID>' +}); diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md index b877172..b558fbd 100644 --- a/docs/examples/messaging/create-telesign-provider.md +++ b/docs/examples/messaging/create-telesign-provider.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createTelesignProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '+12065550100', // from (optional) - '<CUSTOMER_ID>', // customerId (optional) - '<API_KEY>', // apiKey (optional) - false // enabled (optional) -); +const result = await messaging.createTelesignProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + customerId: '<CUSTOMER_ID>', // optional + apiKey: '<API_KEY>', // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md index b40d5ee..82141ae 100644 --- a/docs/examples/messaging/create-textmagic-provider.md +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createTextmagicProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '+12065550100', // from (optional) - '<USERNAME>', // username (optional) - '<API_KEY>', // apiKey (optional) - false // enabled (optional) -); +const result = await messaging.createTextmagicProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + username: '<USERNAME>', // optional + apiKey: '<API_KEY>', // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 35c93ea..ce91b54 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createTopic( - '<TOPIC_ID>', // topicId - '<NAME>', // name - ["any"] // subscribe (optional) -); +const result = await messaging.createTopic({ + topicId: '<TOPIC_ID>', + name: '<NAME>', + subscribe: ["any"] // optional +}); diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 4dcb9a8..b3d9ba6 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createTwilioProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '+12065550100', // from (optional) - '<ACCOUNT_SID>', // accountSid (optional) - '<AUTH_TOKEN>', // authToken (optional) - false // enabled (optional) -); +const result = await messaging.createTwilioProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + accountSid: '<ACCOUNT_SID>', // optional + authToken: '<AUTH_TOKEN>', // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md index 493cd2b..b7a94ff 100644 --- a/docs/examples/messaging/create-vonage-provider.md +++ b/docs/examples/messaging/create-vonage-provider.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.createVonageProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '+12065550100', // from (optional) - '<API_KEY>', // apiKey (optional) - '<API_SECRET>', // apiSecret (optional) - false // enabled (optional) -); +const result = await messaging.createVonageProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + apiKey: '<API_KEY>', // optional + apiSecret: '<API_SECRET>', // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/delete-provider.md b/docs/examples/messaging/delete-provider.md index 23b474f..590b807 100644 --- a/docs/examples/messaging/delete-provider.md +++ b/docs/examples/messaging/delete-provider.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.deleteProvider( - '<PROVIDER_ID>' // providerId -); +const result = await messaging.deleteProvider({ + providerId: '<PROVIDER_ID>' +}); diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md index 1f5e21a..77f2f89 100644 --- a/docs/examples/messaging/delete-subscriber.md +++ b/docs/examples/messaging/delete-subscriber.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.deleteSubscriber( - '<TOPIC_ID>', // topicId - '<SUBSCRIBER_ID>' // subscriberId -); +const result = await messaging.deleteSubscriber({ + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>' +}); diff --git a/docs/examples/messaging/delete-topic.md b/docs/examples/messaging/delete-topic.md index af39f73..58ca2fb 100644 --- a/docs/examples/messaging/delete-topic.md +++ b/docs/examples/messaging/delete-topic.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.deleteTopic( - '<TOPIC_ID>' // topicId -); +const result = await messaging.deleteTopic({ + topicId: '<TOPIC_ID>' +}); diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md index fd49104..c2c0560 100644 --- a/docs/examples/messaging/delete.md +++ b/docs/examples/messaging/delete.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.delete( - '<MESSAGE_ID>' // messageId -); +const result = await messaging.delete({ + messageId: '<MESSAGE_ID>' +}); diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md index f83ab51..503da48 100644 --- a/docs/examples/messaging/get-message.md +++ b/docs/examples/messaging/get-message.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.getMessage( - '<MESSAGE_ID>' // messageId -); +const result = await messaging.getMessage({ + messageId: '<MESSAGE_ID>' +}); diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md index 2f52698..f7c7058 100644 --- a/docs/examples/messaging/get-provider.md +++ b/docs/examples/messaging/get-provider.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.getProvider( - '<PROVIDER_ID>' // providerId -); +const result = await messaging.getProvider({ + providerId: '<PROVIDER_ID>' +}); diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md index 5132f17..befc566 100644 --- a/docs/examples/messaging/get-subscriber.md +++ b/docs/examples/messaging/get-subscriber.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.getSubscriber( - '<TOPIC_ID>', // topicId - '<SUBSCRIBER_ID>' // subscriberId -); +const result = await messaging.getSubscriber({ + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>' +}); diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md index 98e3838..f537973 100644 --- a/docs/examples/messaging/get-topic.md +++ b/docs/examples/messaging/get-topic.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.getTopic( - '<TOPIC_ID>' // topicId -); +const result = await messaging.getTopic({ + topicId: '<TOPIC_ID>' +}); diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/messaging/list-message-logs.md index 56e1288..c2d32f0 100644 --- a/docs/examples/messaging/list-message-logs.md +++ b/docs/examples/messaging/list-message-logs.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.listMessageLogs( - '<MESSAGE_ID>', // messageId - [] // queries (optional) -); +const result = await messaging.listMessageLogs({ + messageId: '<MESSAGE_ID>', + queries: [] // optional +}); diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md index db0785e..2edc75f 100644 --- a/docs/examples/messaging/list-messages.md +++ b/docs/examples/messaging/list-messages.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.listMessages( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await messaging.listMessages({ + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md index 6cb2a01..35fd2cf 100644 --- a/docs/examples/messaging/list-provider-logs.md +++ b/docs/examples/messaging/list-provider-logs.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.listProviderLogs( - '<PROVIDER_ID>', // providerId - [] // queries (optional) -); +const result = await messaging.listProviderLogs({ + providerId: '<PROVIDER_ID>', + queries: [] // optional +}); diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md index aefb41d..2445597 100644 --- a/docs/examples/messaging/list-providers.md +++ b/docs/examples/messaging/list-providers.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.listProviders( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await messaging.listProviders({ + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md index 8d46a08..1da2c3b 100644 --- a/docs/examples/messaging/list-subscriber-logs.md +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.listSubscriberLogs( - '<SUBSCRIBER_ID>', // subscriberId - [] // queries (optional) -); +const result = await messaging.listSubscriberLogs({ + subscriberId: '<SUBSCRIBER_ID>', + queries: [] // optional +}); diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md index 167b48e..c2b594e 100644 --- a/docs/examples/messaging/list-subscribers.md +++ b/docs/examples/messaging/list-subscribers.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.listSubscribers( - '<TOPIC_ID>', // topicId - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await messaging.listSubscribers({ + topicId: '<TOPIC_ID>', + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md index 971285d..75a4aa6 100644 --- a/docs/examples/messaging/list-targets.md +++ b/docs/examples/messaging/list-targets.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.listTargets( - '<MESSAGE_ID>', // messageId - [] // queries (optional) -); +const result = await messaging.listTargets({ + messageId: '<MESSAGE_ID>', + queries: [] // optional +}); diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md index 39e8295..eacf482 100644 --- a/docs/examples/messaging/list-topic-logs.md +++ b/docs/examples/messaging/list-topic-logs.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.listTopicLogs( - '<TOPIC_ID>', // topicId - [] // queries (optional) -); +const result = await messaging.listTopicLogs({ + topicId: '<TOPIC_ID>', + queries: [] // optional +}); diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md index 6fd94bb..3ff5538 100644 --- a/docs/examples/messaging/list-topics.md +++ b/docs/examples/messaging/list-topics.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.listTopics( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await messaging.listTopics({ + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md index e782b8c..f57fe6a 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -7,13 +7,13 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateApnsProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<AUTH_KEY>', // authKey (optional) - '<AUTH_KEY_ID>', // authKeyId (optional) - '<TEAM_ID>', // teamId (optional) - '<BUNDLE_ID>', // bundleId (optional) - false // sandbox (optional) -); +const result = await messaging.updateAPNSProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + authKey: '<AUTH_KEY>', // optional + authKeyId: '<AUTH_KEY_ID>', // optional + teamId: '<TEAM_ID>', // optional + bundleId: '<BUNDLE_ID>', // optional + sandbox: false // optional +}); diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 2ea2941..575b463 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -7,17 +7,17 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateEmail( - '<MESSAGE_ID>', // messageId - [], // topics (optional) - [], // users (optional) - [], // targets (optional) - '<SUBJECT>', // subject (optional) - '<CONTENT>', // content (optional) - false, // draft (optional) - false, // html (optional) - [], // cc (optional) - [], // bcc (optional) - '', // scheduledAt (optional) - [] // attachments (optional) -); +const result = await messaging.updateEmail({ + messageId: '<MESSAGE_ID>', + topics: [], // optional + users: [], // optional + targets: [], // optional + subject: '<SUBJECT>', // optional + content: '<CONTENT>', // optional + draft: false, // optional + html: false, // optional + cc: [], // optional + bcc: [], // optional + scheduledAt: '', // optional + attachments: [] // optional +}); diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md index 9184f28..0a3134a 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateFcmProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - {} // serviceAccountJSON (optional) -); +const result = await messaging.updateFCMProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + serviceAccountJSON: {} // optional +}); diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md index a1ac18f..fbe2d07 100644 --- a/docs/examples/messaging/update-mailgun-provider.md +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -7,15 +7,15 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateMailgunProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - '<API_KEY>', // apiKey (optional) - '<DOMAIN>', // domain (optional) - false, // isEuRegion (optional) - false, // enabled (optional) - '<FROM_NAME>', // fromName (optional) - 'email@example.com', // fromEmail (optional) - '<REPLY_TO_NAME>', // replyToName (optional) - '<REPLY_TO_EMAIL>' // replyToEmail (optional) -); +const result = await messaging.updateMailgunProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + apiKey: '<API_KEY>', // optional + domain: '<DOMAIN>', // optional + isEuRegion: false, // optional + enabled: false, // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: '<REPLY_TO_EMAIL>' // optional +}); diff --git a/docs/examples/messaging/update-msg91provider.md b/docs/examples/messaging/update-msg-91-provider.md similarity index 52% rename from docs/examples/messaging/update-msg91provider.md rename to docs/examples/messaging/update-msg-91-provider.md index c66b91f..7ecb3f0 100644 --- a/docs/examples/messaging/update-msg91provider.md +++ b/docs/examples/messaging/update-msg-91-provider.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateMsg91Provider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<TEMPLATE_ID>', // templateId (optional) - '<SENDER_ID>', // senderId (optional) - '<AUTH_KEY>' // authKey (optional) -); +const result = await messaging.updateMsg91Provider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + templateId: '<TEMPLATE_ID>', // optional + senderId: '<SENDER_ID>', // optional + authKey: '<AUTH_KEY>' // optional +}); diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index db52bee..5e857f1 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -7,24 +7,24 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updatePush( - '<MESSAGE_ID>', // messageId - [], // topics (optional) - [], // users (optional) - [], // targets (optional) - '<TITLE>', // title (optional) - '<BODY>', // body (optional) - {}, // data (optional) - '<ACTION>', // action (optional) - '[ID1:ID2]', // image (optional) - '<ICON>', // icon (optional) - '<SOUND>', // sound (optional) - '<COLOR>', // color (optional) - '<TAG>', // tag (optional) - null, // badge (optional) - false, // draft (optional) - '', // scheduledAt (optional) - false, // contentAvailable (optional) - false, // critical (optional) - sdk.MessagePriority.Normal // priority (optional) -); +const result = await messaging.updatePush({ + messageId: '<MESSAGE_ID>', + topics: [], // optional + users: [], // optional + targets: [], // optional + title: '<TITLE>', // optional + body: '<BODY>', // optional + data: {}, // optional + action: '<ACTION>', // optional + image: '[ID1:ID2]', // optional + icon: '<ICON>', // optional + sound: '<SOUND>', // optional + color: '<COLOR>', // optional + tag: '<TAG>', // optional + badge: null, // optional + draft: false, // optional + scheduledAt: '', // optional + contentAvailable: false, // optional + critical: false, // optional + priority: sdk.MessagePriority.Normal // optional +}); diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md index 8420a2f..340f275 100644 --- a/docs/examples/messaging/update-sendgrid-provider.md +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -7,13 +7,13 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateSendgridProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<API_KEY>', // apiKey (optional) - '<FROM_NAME>', // fromName (optional) - 'email@example.com', // fromEmail (optional) - '<REPLY_TO_NAME>', // replyToName (optional) - '<REPLY_TO_EMAIL>' // replyToEmail (optional) -); +const result = await messaging.updateSendgridProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + apiKey: '<API_KEY>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: '<REPLY_TO_EMAIL>' // optional +}); diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 98ee6fe..a325b5a 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -7,12 +7,12 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateSms( - '<MESSAGE_ID>', // messageId - [], // topics (optional) - [], // users (optional) - [], // targets (optional) - '<CONTENT>', // content (optional) - false, // draft (optional) - '' // scheduledAt (optional) -); +const result = await messaging.updateSMS({ + messageId: '<MESSAGE_ID>', + topics: [], // optional + users: [], // optional + targets: [], // optional + content: '<CONTENT>', // optional + draft: false, // optional + scheduledAt: '' // optional +}); diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md index 0bbe4cd..7b2a811 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -7,19 +7,19 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateSmtpProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - '<HOST>', // host (optional) - 1, // port (optional) - '<USERNAME>', // username (optional) - '<PASSWORD>', // password (optional) - sdk.SmtpEncryption.None, // encryption (optional) - false, // autoTLS (optional) - '<MAILER>', // mailer (optional) - '<FROM_NAME>', // fromName (optional) - 'email@example.com', // fromEmail (optional) - '<REPLY_TO_NAME>', // replyToName (optional) - '<REPLY_TO_EMAIL>', // replyToEmail (optional) - false // enabled (optional) -); +const result = await messaging.updateSMTPProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + host: '<HOST>', // optional + port: 1, // optional + username: '<USERNAME>', // optional + password: '<PASSWORD>', // optional + encryption: sdk.SmtpEncryption.None, // optional + autoTLS: false, // optional + mailer: '<MAILER>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: '<REPLY_TO_EMAIL>', // optional + enabled: false // optional +}); diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md index 2f23a3b..8e1e236 100644 --- a/docs/examples/messaging/update-telesign-provider.md +++ b/docs/examples/messaging/update-telesign-provider.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateTelesignProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<CUSTOMER_ID>', // customerId (optional) - '<API_KEY>', // apiKey (optional) - '<FROM>' // from (optional) -); +const result = await messaging.updateTelesignProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + customerId: '<CUSTOMER_ID>', // optional + apiKey: '<API_KEY>', // optional + from: '<FROM>' // optional +}); diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md index 6fb6c82..8656723 100644 --- a/docs/examples/messaging/update-textmagic-provider.md +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateTextmagicProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<USERNAME>', // username (optional) - '<API_KEY>', // apiKey (optional) - '<FROM>' // from (optional) -); +const result = await messaging.updateTextmagicProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + username: '<USERNAME>', // optional + apiKey: '<API_KEY>', // optional + from: '<FROM>' // optional +}); diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index 6330970..cf34080 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateTopic( - '<TOPIC_ID>', // topicId - '<NAME>', // name (optional) - ["any"] // subscribe (optional) -); +const result = await messaging.updateTopic({ + topicId: '<TOPIC_ID>', + name: '<NAME>', // optional + subscribe: ["any"] // optional +}); diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md index e4667f5..6a20141 100644 --- a/docs/examples/messaging/update-twilio-provider.md +++ b/docs/examples/messaging/update-twilio-provider.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateTwilioProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<ACCOUNT_SID>', // accountSid (optional) - '<AUTH_TOKEN>', // authToken (optional) - '<FROM>' // from (optional) -); +const result = await messaging.updateTwilioProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + accountSid: '<ACCOUNT_SID>', // optional + authToken: '<AUTH_TOKEN>', // optional + from: '<FROM>' // optional +}); diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md index b95398b..d99c076 100644 --- a/docs/examples/messaging/update-vonage-provider.md +++ b/docs/examples/messaging/update-vonage-provider.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const messaging = new sdk.Messaging(client); -const result = await messaging.updateVonageProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<API_KEY>', // apiKey (optional) - '<API_SECRET>', // apiSecret (optional) - '<FROM>' // from (optional) -); +const result = await messaging.updateVonageProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + apiKey: '<API_KEY>', // optional + apiSecret: '<API_SECRET>', // optional + from: '<FROM>' // optional +}); diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md index 010da72..dbd78e0 100644 --- a/docs/examples/sites/create-deployment.md +++ b/docs/examples/sites/create-deployment.md @@ -8,11 +8,11 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.createDeployment( - '<SITE_ID>', // siteId - InputFile.fromPath('/path/to/file', 'filename'), // code - false, // activate - '<INSTALL_COMMAND>', // installCommand (optional) - '<BUILD_COMMAND>', // buildCommand (optional) - '<OUTPUT_DIRECTORY>' // outputDirectory (optional) -); +const result = await sites.createDeployment({ + siteId: '<SITE_ID>', + code: InputFile.fromPath('/path/to/file', 'filename'), + activate: false, + installCommand: '<INSTALL_COMMAND>', // optional + buildCommand: '<BUILD_COMMAND>', // optional + outputDirectory: '<OUTPUT_DIRECTORY>' // optional +}); diff --git a/docs/examples/sites/create-duplicate-deployment.md b/docs/examples/sites/create-duplicate-deployment.md index 3ce35ff..8d2bd4f 100644 --- a/docs/examples/sites/create-duplicate-deployment.md +++ b/docs/examples/sites/create-duplicate-deployment.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.createDuplicateDeployment( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>' // deploymentId -); +const result = await sites.createDuplicateDeployment({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>' +}); diff --git a/docs/examples/sites/create-template-deployment.md b/docs/examples/sites/create-template-deployment.md index aebc2b8..7dfb437 100644 --- a/docs/examples/sites/create-template-deployment.md +++ b/docs/examples/sites/create-template-deployment.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.createTemplateDeployment( - '<SITE_ID>', // siteId - '<REPOSITORY>', // repository - '<OWNER>', // owner - '<ROOT_DIRECTORY>', // rootDirectory - '<VERSION>', // version - false // activate (optional) -); +const result = await sites.createTemplateDeployment({ + siteId: '<SITE_ID>', + repository: '<REPOSITORY>', + owner: '<OWNER>', + rootDirectory: '<ROOT_DIRECTORY>', + version: '<VERSION>', + activate: false // optional +}); diff --git a/docs/examples/sites/create-variable.md b/docs/examples/sites/create-variable.md index 59a51ee..2ec774c 100644 --- a/docs/examples/sites/create-variable.md +++ b/docs/examples/sites/create-variable.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.createVariable( - '<SITE_ID>', // siteId - '<KEY>', // key - '<VALUE>', // value - false // secret (optional) -); +const result = await sites.createVariable({ + siteId: '<SITE_ID>', + key: '<KEY>', + value: '<VALUE>', + secret: false // optional +}); diff --git a/docs/examples/sites/create-vcs-deployment.md b/docs/examples/sites/create-vcs-deployment.md index 4bd8497..7f7c219 100644 --- a/docs/examples/sites/create-vcs-deployment.md +++ b/docs/examples/sites/create-vcs-deployment.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.createVcsDeployment( - '<SITE_ID>', // siteId - sdk.VCSDeploymentType.Branch, // type - '<REFERENCE>', // reference - false // activate (optional) -); +const result = await sites.createVcsDeployment({ + siteId: '<SITE_ID>', + type: sdk.VCSDeploymentType.Branch, + reference: '<REFERENCE>', + activate: false // optional +}); diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index ad68059..25c6715 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -7,23 +7,23 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.create( - '<SITE_ID>', // siteId - '<NAME>', // name - sdk..Analog, // framework - sdk..Node145, // buildRuntime - false, // enabled (optional) - false, // logging (optional) - 1, // timeout (optional) - '<INSTALL_COMMAND>', // installCommand (optional) - '<BUILD_COMMAND>', // buildCommand (optional) - '<OUTPUT_DIRECTORY>', // outputDirectory (optional) - sdk..Static, // adapter (optional) - '<INSTALLATION_ID>', // installationId (optional) - '<FALLBACK_FILE>', // fallbackFile (optional) - '<PROVIDER_REPOSITORY_ID>', // providerRepositoryId (optional) - '<PROVIDER_BRANCH>', // providerBranch (optional) - false, // providerSilentMode (optional) - '<PROVIDER_ROOT_DIRECTORY>', // providerRootDirectory (optional) - '' // specification (optional) -); +const result = await sites.create({ + siteId: '<SITE_ID>', + name: '<NAME>', + framework: sdk..Analog, + buildRuntime: sdk..Node145, + enabled: false, // optional + logging: false, // optional + timeout: 1, // optional + installCommand: '<INSTALL_COMMAND>', // optional + buildCommand: '<BUILD_COMMAND>', // optional + outputDirectory: '<OUTPUT_DIRECTORY>', // optional + adapter: sdk..Static, // optional + installationId: '<INSTALLATION_ID>', // optional + fallbackFile: '<FALLBACK_FILE>', // optional + providerRepositoryId: '<PROVIDER_REPOSITORY_ID>', // optional + providerBranch: '<PROVIDER_BRANCH>', // optional + providerSilentMode: false, // optional + providerRootDirectory: '<PROVIDER_ROOT_DIRECTORY>', // optional + specification: '' // optional +}); diff --git a/docs/examples/sites/delete-deployment.md b/docs/examples/sites/delete-deployment.md index c04a5c3..292f9e0 100644 --- a/docs/examples/sites/delete-deployment.md +++ b/docs/examples/sites/delete-deployment.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.deleteDeployment( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>' // deploymentId -); +const result = await sites.deleteDeployment({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>' +}); diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md index 88e58a5..d1850e1 100644 --- a/docs/examples/sites/delete-log.md +++ b/docs/examples/sites/delete-log.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.deleteLog( - '<SITE_ID>', // siteId - '<LOG_ID>' // logId -); +const result = await sites.deleteLog({ + siteId: '<SITE_ID>', + logId: '<LOG_ID>' +}); diff --git a/docs/examples/sites/delete-variable.md b/docs/examples/sites/delete-variable.md index abc7e3a..069ff8d 100644 --- a/docs/examples/sites/delete-variable.md +++ b/docs/examples/sites/delete-variable.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.deleteVariable( - '<SITE_ID>', // siteId - '<VARIABLE_ID>' // variableId -); +const result = await sites.deleteVariable({ + siteId: '<SITE_ID>', + variableId: '<VARIABLE_ID>' +}); diff --git a/docs/examples/sites/delete.md b/docs/examples/sites/delete.md index 87fd7d2..7f6ad8b 100644 --- a/docs/examples/sites/delete.md +++ b/docs/examples/sites/delete.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.delete( - '<SITE_ID>' // siteId -); +const result = await sites.delete({ + siteId: '<SITE_ID>' +}); diff --git a/docs/examples/sites/get-deployment-download.md b/docs/examples/sites/get-deployment-download.md index 414d50d..05e8705 100644 --- a/docs/examples/sites/get-deployment-download.md +++ b/docs/examples/sites/get-deployment-download.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.getDeploymentDownload( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>', // deploymentId - sdk.DeploymentDownloadType.Source // type (optional) -); +const result = await sites.getDeploymentDownload({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>', + type: sdk.DeploymentDownloadType.Source // optional +}); diff --git a/docs/examples/sites/get-deployment.md b/docs/examples/sites/get-deployment.md index 3f06b1a..68b6dcf 100644 --- a/docs/examples/sites/get-deployment.md +++ b/docs/examples/sites/get-deployment.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.getDeployment( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>' // deploymentId -); +const result = await sites.getDeployment({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>' +}); diff --git a/docs/examples/sites/get-log.md b/docs/examples/sites/get-log.md index 4318882..3a22d90 100644 --- a/docs/examples/sites/get-log.md +++ b/docs/examples/sites/get-log.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.getLog( - '<SITE_ID>', // siteId - '<LOG_ID>' // logId -); +const result = await sites.getLog({ + siteId: '<SITE_ID>', + logId: '<LOG_ID>' +}); diff --git a/docs/examples/sites/get-variable.md b/docs/examples/sites/get-variable.md index 287336f..7d0a759 100644 --- a/docs/examples/sites/get-variable.md +++ b/docs/examples/sites/get-variable.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.getVariable( - '<SITE_ID>', // siteId - '<VARIABLE_ID>' // variableId -); +const result = await sites.getVariable({ + siteId: '<SITE_ID>', + variableId: '<VARIABLE_ID>' +}); diff --git a/docs/examples/sites/get.md b/docs/examples/sites/get.md index d382efa..6d81808 100644 --- a/docs/examples/sites/get.md +++ b/docs/examples/sites/get.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.get( - '<SITE_ID>' // siteId -); +const result = await sites.get({ + siteId: '<SITE_ID>' +}); diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md index dce44ed..53a900e 100644 --- a/docs/examples/sites/list-deployments.md +++ b/docs/examples/sites/list-deployments.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.listDeployments( - '<SITE_ID>', // siteId - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await sites.listDeployments({ + siteId: '<SITE_ID>', + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/sites/list-logs.md b/docs/examples/sites/list-logs.md index faaf3d3..17428d7 100644 --- a/docs/examples/sites/list-logs.md +++ b/docs/examples/sites/list-logs.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.listLogs( - '<SITE_ID>', // siteId - [] // queries (optional) -); +const result = await sites.listLogs({ + siteId: '<SITE_ID>', + queries: [] // optional +}); diff --git a/docs/examples/sites/list-variables.md b/docs/examples/sites/list-variables.md index 948e977..498584e 100644 --- a/docs/examples/sites/list-variables.md +++ b/docs/examples/sites/list-variables.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.listVariables( - '<SITE_ID>' // siteId -); +const result = await sites.listVariables({ + siteId: '<SITE_ID>' +}); diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md index 184f4f3..2f2f884 100644 --- a/docs/examples/sites/list.md +++ b/docs/examples/sites/list.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.list( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await sites.list({ + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/sites/update-deployment-status.md b/docs/examples/sites/update-deployment-status.md index 7756424..88d55b0 100644 --- a/docs/examples/sites/update-deployment-status.md +++ b/docs/examples/sites/update-deployment-status.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.updateDeploymentStatus( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>' // deploymentId -); +const result = await sites.updateDeploymentStatus({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>' +}); diff --git a/docs/examples/sites/update-site-deployment.md b/docs/examples/sites/update-site-deployment.md index bfbc0f3..bb3adc4 100644 --- a/docs/examples/sites/update-site-deployment.md +++ b/docs/examples/sites/update-site-deployment.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.updateSiteDeployment( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>' // deploymentId -); +const result = await sites.updateSiteDeployment({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>' +}); diff --git a/docs/examples/sites/update-variable.md b/docs/examples/sites/update-variable.md index c790ca1..a7e3f6a 100644 --- a/docs/examples/sites/update-variable.md +++ b/docs/examples/sites/update-variable.md @@ -7,10 +7,10 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.updateVariable( - '<SITE_ID>', // siteId - '<VARIABLE_ID>', // variableId - '<KEY>', // key - '<VALUE>', // value (optional) - false // secret (optional) -); +const result = await sites.updateVariable({ + siteId: '<SITE_ID>', + variableId: '<VARIABLE_ID>', + key: '<KEY>', + value: '<VALUE>', // optional + secret: false // optional +}); diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index e801aed..5cb52f7 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -7,23 +7,23 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); -const result = await sites.update( - '<SITE_ID>', // siteId - '<NAME>', // name - sdk..Analog, // framework - false, // enabled (optional) - false, // logging (optional) - 1, // timeout (optional) - '<INSTALL_COMMAND>', // installCommand (optional) - '<BUILD_COMMAND>', // buildCommand (optional) - '<OUTPUT_DIRECTORY>', // outputDirectory (optional) - sdk..Node145, // buildRuntime (optional) - sdk..Static, // adapter (optional) - '<FALLBACK_FILE>', // fallbackFile (optional) - '<INSTALLATION_ID>', // installationId (optional) - '<PROVIDER_REPOSITORY_ID>', // providerRepositoryId (optional) - '<PROVIDER_BRANCH>', // providerBranch (optional) - false, // providerSilentMode (optional) - '<PROVIDER_ROOT_DIRECTORY>', // providerRootDirectory (optional) - '' // specification (optional) -); +const result = await sites.update({ + siteId: '<SITE_ID>', + name: '<NAME>', + framework: sdk..Analog, + enabled: false, // optional + logging: false, // optional + timeout: 1, // optional + installCommand: '<INSTALL_COMMAND>', // optional + buildCommand: '<BUILD_COMMAND>', // optional + outputDirectory: '<OUTPUT_DIRECTORY>', // optional + buildRuntime: sdk..Node145, // optional + adapter: sdk..Static, // optional + fallbackFile: '<FALLBACK_FILE>', // optional + installationId: '<INSTALLATION_ID>', // optional + providerRepositoryId: '<PROVIDER_REPOSITORY_ID>', // optional + providerBranch: '<PROVIDER_BRANCH>', // optional + providerSilentMode: false, // optional + providerRootDirectory: '<PROVIDER_ROOT_DIRECTORY>', // optional + specification: '' // optional +}); diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index fc318f1..f1f0294 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -7,15 +7,15 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.createBucket( - '<BUCKET_ID>', // bucketId - '<NAME>', // name - ["read("any")"], // permissions (optional) - false, // fileSecurity (optional) - false, // enabled (optional) - 1, // maximumFileSize (optional) - [], // allowedFileExtensions (optional) - sdk..None, // compression (optional) - false, // encryption (optional) - false // antivirus (optional) -); +const result = await storage.createBucket({ + bucketId: '<BUCKET_ID>', + name: '<NAME>', + permissions: ["read("any")"], // optional + fileSecurity: false, // optional + enabled: false, // optional + maximumFileSize: 1, // optional + allowedFileExtensions: [], // optional + compression: sdk..None, // optional + encryption: false, // optional + antivirus: false // optional +}); diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index b84d9ac..628faf7 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -8,9 +8,9 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.createFile( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - InputFile.fromPath('/path/to/file', 'filename'), // file - ["read("any")"] // permissions (optional) -); +const result = await storage.createFile({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + file: InputFile.fromPath('/path/to/file', 'filename'), + permissions: ["read("any")"] // optional +}); diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md index c2067ef..a59844d 100644 --- a/docs/examples/storage/delete-bucket.md +++ b/docs/examples/storage/delete-bucket.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.deleteBucket( - '<BUCKET_ID>' // bucketId -); +const result = await storage.deleteBucket({ + bucketId: '<BUCKET_ID>' +}); diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index 4d2e712..d973b5a 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.deleteFile( - '<BUCKET_ID>', // bucketId - '<FILE_ID>' // fileId -); +const result = await storage.deleteFile({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>' +}); diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md index c8a0b1c..2dd16cc 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.getBucket( - '<BUCKET_ID>' // bucketId -); +const result = await storage.getBucket({ + bucketId: '<BUCKET_ID>' +}); diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index 6935bed..253e638 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.getFileDownload( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - '<TOKEN>' // token (optional) -); +const result = await storage.getFileDownload({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + token: '<TOKEN>' // optional +}); diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index fe24419..d188e0d 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -7,19 +7,19 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.getFilePreview( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - 0, // width (optional) - 0, // height (optional) - sdk.ImageGravity.Center, // gravity (optional) - -1, // quality (optional) - 0, // borderWidth (optional) - '', // borderColor (optional) - 0, // borderRadius (optional) - 0, // opacity (optional) - -360, // rotation (optional) - '', // background (optional) - sdk.ImageFormat.Jpg, // output (optional) - '<TOKEN>' // token (optional) -); +const result = await storage.getFilePreview({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + width: 0, // optional + height: 0, // optional + gravity: sdk.ImageGravity.Center, // optional + quality: -1, // optional + borderWidth: 0, // optional + borderColor: '', // optional + borderRadius: 0, // optional + opacity: 0, // optional + rotation: -360, // optional + background: '', // optional + output: sdk.ImageFormat.Jpg, // optional + token: '<TOKEN>' // optional +}); diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 9493cfb..35c6ba2 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.getFileView( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - '<TOKEN>' // token (optional) -); +const result = await storage.getFileView({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + token: '<TOKEN>' // optional +}); diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index 1a6b500..a6c54c8 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.getFile( - '<BUCKET_ID>', // bucketId - '<FILE_ID>' // fileId -); +const result = await storage.getFile({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>' +}); diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index 3c4d4b1..a6dcf40 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.listBuckets( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await storage.listBuckets({ + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index fb595ef..b22c1c1 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.listFiles( - '<BUCKET_ID>', // bucketId - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await storage.listFiles({ + bucketId: '<BUCKET_ID>', + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index 24e4872..136ebaf 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -7,15 +7,15 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.updateBucket( - '<BUCKET_ID>', // bucketId - '<NAME>', // name - ["read("any")"], // permissions (optional) - false, // fileSecurity (optional) - false, // enabled (optional) - 1, // maximumFileSize (optional) - [], // allowedFileExtensions (optional) - sdk..None, // compression (optional) - false, // encryption (optional) - false // antivirus (optional) -); +const result = await storage.updateBucket({ + bucketId: '<BUCKET_ID>', + name: '<NAME>', + permissions: ["read("any")"], // optional + fileSecurity: false, // optional + enabled: false, // optional + maximumFileSize: 1, // optional + allowedFileExtensions: [], // optional + compression: sdk..None, // optional + encryption: false, // optional + antivirus: false // optional +}); diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index 7eed687..2d78d5f 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const storage = new sdk.Storage(client); -const result = await storage.updateFile( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - '<NAME>', // name (optional) - ["read("any")"] // permissions (optional) -); +const result = await storage.updateFile({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + name: '<NAME>', // optional + permissions: ["read("any")"] // optional +}); diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md new file mode 100644 index 0000000..129e646 --- /dev/null +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createBooleanColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: false, // optional + array: false // optional +}); diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md new file mode 100644 index 0000000..dcc6c1e --- /dev/null +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createDatetimeColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: '', // optional + array: false // optional +}); diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md new file mode 100644 index 0000000..a250d4a --- /dev/null +++ b/docs/examples/tablesdb/create-email-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createEmailColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: 'email@example.com', // optional + array: false // optional +}); diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md new file mode 100644 index 0000000..f1e1830 --- /dev/null +++ b/docs/examples/tablesdb/create-enum-column.md @@ -0,0 +1,18 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createEnumColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + elements: [], + required: false, + default: '<DEFAULT>', // optional + array: false // optional +}); diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md new file mode 100644 index 0000000..6dd4dfc --- /dev/null +++ b/docs/examples/tablesdb/create-float-column.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createFloatColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + min: null, // optional + max: null, // optional + default: null, // optional + array: false // optional +}); diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md new file mode 100644 index 0000000..ec84b06 --- /dev/null +++ b/docs/examples/tablesdb/create-index.md @@ -0,0 +1,18 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createIndex({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + type: sdk.IndexType.Key, + columns: [], + orders: [], // optional + lengths: [] // optional +}); diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md new file mode 100644 index 0000000..b682db4 --- /dev/null +++ b/docs/examples/tablesdb/create-integer-column.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createIntegerColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + min: null, // optional + max: null, // optional + default: null, // optional + array: false // optional +}); diff --git a/docs/examples/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md new file mode 100644 index 0000000..eaeb64a --- /dev/null +++ b/docs/examples/tablesdb/create-ip-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createIpColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: '', // optional + array: false // optional +}); diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md new file mode 100644 index 0000000..09ebd96 --- /dev/null +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createRelationshipColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + relatedTableId: '<RELATED_TABLE_ID>', + type: sdk.RelationshipType.OneToOne, + twoWay: false, // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: sdk.RelationMutate.Cascade // optional +}); diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md new file mode 100644 index 0000000..aa92423 --- /dev/null +++ b/docs/examples/tablesdb/create-row.md @@ -0,0 +1,16 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createRow({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rowId: '<ROW_ID>', + data: {}, + permissions: ["read("any")"] // optional +}); diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md new file mode 100644 index 0000000..61eb1d1 --- /dev/null +++ b/docs/examples/tablesdb/create-rows.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createRows({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rows: [] +}); diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md new file mode 100644 index 0000000..dbe0632 --- /dev/null +++ b/docs/examples/tablesdb/create-string-column.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createStringColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + size: 1, + required: false, + default: '<DEFAULT>', // optional + array: false, // optional + encrypt: false // optional +}); diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md new file mode 100644 index 0000000..1b252f1 --- /dev/null +++ b/docs/examples/tablesdb/create-table.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createTable({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + name: '<NAME>', + permissions: ["read("any")"], // optional + rowSecurity: false, // optional + enabled: false // optional +}); diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md new file mode 100644 index 0000000..a37424e --- /dev/null +++ b/docs/examples/tablesdb/create-url-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createUrlColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: 'https://example.com', // optional + array: false // optional +}); diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md new file mode 100644 index 0000000..a16191d --- /dev/null +++ b/docs/examples/tablesdb/create.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.create({ + databaseId: '<DATABASE_ID>', + name: '<NAME>', + enabled: false // optional +}); diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md new file mode 100644 index 0000000..e3b13a8 --- /dev/null +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.decrementRowColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rowId: '<ROW_ID>', + column: '', + value: null, // optional + min: null // optional +}); diff --git a/docs/examples/tablesdb/delete-column.md b/docs/examples/tablesdb/delete-column.md new file mode 100644 index 0000000..890393a --- /dev/null +++ b/docs/examples/tablesdb/delete-column.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.deleteColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '' +}); diff --git a/docs/examples/tablesdb/delete-index.md b/docs/examples/tablesdb/delete-index.md new file mode 100644 index 0000000..472b5de --- /dev/null +++ b/docs/examples/tablesdb/delete-index.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.deleteIndex({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '' +}); diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md new file mode 100644 index 0000000..9802f0d --- /dev/null +++ b/docs/examples/tablesdb/delete-row.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.deleteRow({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rowId: '<ROW_ID>' +}); diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md new file mode 100644 index 0000000..6f4d7cd --- /dev/null +++ b/docs/examples/tablesdb/delete-rows.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.deleteRows({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + queries: [] // optional +}); diff --git a/docs/examples/tablesdb/delete-table.md b/docs/examples/tablesdb/delete-table.md new file mode 100644 index 0000000..3c526e5 --- /dev/null +++ b/docs/examples/tablesdb/delete-table.md @@ -0,0 +1,13 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.deleteTable({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>' +}); diff --git a/docs/examples/tablesdb/delete.md b/docs/examples/tablesdb/delete.md new file mode 100644 index 0000000..351a40f --- /dev/null +++ b/docs/examples/tablesdb/delete.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.delete({ + databaseId: '<DATABASE_ID>' +}); diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md new file mode 100644 index 0000000..66bde58 --- /dev/null +++ b/docs/examples/tablesdb/get-column.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.getColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '' +}); diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md new file mode 100644 index 0000000..6dfa732 --- /dev/null +++ b/docs/examples/tablesdb/get-index.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.getIndex({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '' +}); diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md new file mode 100644 index 0000000..7ea3d1f --- /dev/null +++ b/docs/examples/tablesdb/get-row.md @@ -0,0 +1,15 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.getRow({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rowId: '<ROW_ID>', + queries: [] // optional +}); diff --git a/docs/examples/tablesdb/get-table.md b/docs/examples/tablesdb/get-table.md new file mode 100644 index 0000000..6d14204 --- /dev/null +++ b/docs/examples/tablesdb/get-table.md @@ -0,0 +1,13 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.getTable({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>' +}); diff --git a/docs/examples/tablesdb/get.md b/docs/examples/tablesdb/get.md new file mode 100644 index 0000000..1372966 --- /dev/null +++ b/docs/examples/tablesdb/get.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.get({ + databaseId: '<DATABASE_ID>' +}); diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md new file mode 100644 index 0000000..f5cac2e --- /dev/null +++ b/docs/examples/tablesdb/increment-row-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.incrementRowColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rowId: '<ROW_ID>', + column: '', + value: null, // optional + max: null // optional +}); diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md new file mode 100644 index 0000000..b756a3d --- /dev/null +++ b/docs/examples/tablesdb/list-columns.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.listColumns({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + queries: [] // optional +}); diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md new file mode 100644 index 0000000..1c99bf9 --- /dev/null +++ b/docs/examples/tablesdb/list-indexes.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.listIndexes({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + queries: [] // optional +}); diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md new file mode 100644 index 0000000..6d3b883 --- /dev/null +++ b/docs/examples/tablesdb/list-rows.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.listRows({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + queries: [] // optional +}); diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md new file mode 100644 index 0000000..f6d6608 --- /dev/null +++ b/docs/examples/tablesdb/list-tables.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.listTables({ + databaseId: '<DATABASE_ID>', + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md new file mode 100644 index 0000000..6648ea7 --- /dev/null +++ b/docs/examples/tablesdb/list.md @@ -0,0 +1,13 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.list({ + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md new file mode 100644 index 0000000..aa1d523 --- /dev/null +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateBooleanColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: false, + newKey: '' // optional +}); diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md new file mode 100644 index 0000000..10badcc --- /dev/null +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateDatetimeColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: '', + newKey: '' // optional +}); diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md new file mode 100644 index 0000000..ff40472 --- /dev/null +++ b/docs/examples/tablesdb/update-email-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateEmailColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: 'email@example.com', + newKey: '' // optional +}); diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md new file mode 100644 index 0000000..ccc70b1 --- /dev/null +++ b/docs/examples/tablesdb/update-enum-column.md @@ -0,0 +1,18 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateEnumColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + elements: [], + required: false, + default: '<DEFAULT>', + newKey: '' // optional +}); diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md new file mode 100644 index 0000000..73add7d --- /dev/null +++ b/docs/examples/tablesdb/update-float-column.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateFloatColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md new file mode 100644 index 0000000..18cceb0 --- /dev/null +++ b/docs/examples/tablesdb/update-integer-column.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateIntegerColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md new file mode 100644 index 0000000..c0313d1 --- /dev/null +++ b/docs/examples/tablesdb/update-ip-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateIpColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: '', + newKey: '' // optional +}); diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md new file mode 100644 index 0000000..a91b479 --- /dev/null +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -0,0 +1,16 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateRelationshipColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + onDelete: sdk.RelationMutate.Cascade, // optional + newKey: '' // optional +}); diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md new file mode 100644 index 0000000..1c7f0af --- /dev/null +++ b/docs/examples/tablesdb/update-row.md @@ -0,0 +1,16 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateRow({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rowId: '<ROW_ID>', + data: {}, // optional + permissions: ["read("any")"] // optional +}); diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md new file mode 100644 index 0000000..31628d7 --- /dev/null +++ b/docs/examples/tablesdb/update-rows.md @@ -0,0 +1,15 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateRows({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + data: {}, // optional + queries: [] // optional +}); diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md new file mode 100644 index 0000000..f30614e --- /dev/null +++ b/docs/examples/tablesdb/update-string-column.md @@ -0,0 +1,18 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateStringColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: '<DEFAULT>', + size: 1, // optional + newKey: '' // optional +}); diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md new file mode 100644 index 0000000..b61fd6a --- /dev/null +++ b/docs/examples/tablesdb/update-table.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateTable({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + name: '<NAME>', + permissions: ["read("any")"], // optional + rowSecurity: false, // optional + enabled: false // optional +}); diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md new file mode 100644 index 0000000..cb2440a --- /dev/null +++ b/docs/examples/tablesdb/update-url-column.md @@ -0,0 +1,17 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateUrlColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + default: 'https://example.com', + newKey: '' // optional +}); diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md new file mode 100644 index 0000000..85f98ee --- /dev/null +++ b/docs/examples/tablesdb/update.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.update({ + databaseId: '<DATABASE_ID>', + name: '<NAME>', + enabled: false // optional +}); diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md new file mode 100644 index 0000000..9963bb6 --- /dev/null +++ b/docs/examples/tablesdb/upsert-row.md @@ -0,0 +1,16 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.upsertRow({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rowId: '<ROW_ID>', + data: {}, // optional + permissions: ["read("any")"] // optional +}); diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md new file mode 100644 index 0000000..cca2b77 --- /dev/null +++ b/docs/examples/tablesdb/upsert-rows.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.upsertRows({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rows: [] +}); diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 7994423..28cb901 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -7,12 +7,12 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.createMembership( - '<TEAM_ID>', // teamId - [], // roles - 'email@example.com', // email (optional) - '<USER_ID>', // userId (optional) - '+12065550100', // phone (optional) - 'https://example.com', // url (optional) - '<NAME>' // name (optional) -); +const result = await teams.createMembership({ + teamId: '<TEAM_ID>', + roles: [], + email: 'email@example.com', // optional + userId: '<USER_ID>', // optional + phone: '+12065550100', // optional + url: 'https://example.com', // optional + name: '<NAME>' // optional +}); diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index 94de494..8b1bd1d 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.create( - '<TEAM_ID>', // teamId - '<NAME>', // name - [] // roles (optional) -); +const result = await teams.create({ + teamId: '<TEAM_ID>', + name: '<NAME>', + roles: [] // optional +}); diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index 5264af7..6fe5912 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.deleteMembership( - '<TEAM_ID>', // teamId - '<MEMBERSHIP_ID>' // membershipId -); +const result = await teams.deleteMembership({ + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>' +}); diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index 151bfb3..ebccae9 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.delete( - '<TEAM_ID>' // teamId -); +const result = await teams.delete({ + teamId: '<TEAM_ID>' +}); diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index a8e9fc7..a8deb55 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.getMembership( - '<TEAM_ID>', // teamId - '<MEMBERSHIP_ID>' // membershipId -); +const result = await teams.getMembership({ + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>' +}); diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md index 18afdaa..bf9d722 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.getPrefs( - '<TEAM_ID>' // teamId -); +const result = await teams.getPrefs({ + teamId: '<TEAM_ID>' +}); diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index 8afc800..2f4cc11 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.get( - '<TEAM_ID>' // teamId -); +const result = await teams.get({ + teamId: '<TEAM_ID>' +}); diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 4fead97..3a18bbb 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.listMemberships( - '<TEAM_ID>', // teamId - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await teams.listMemberships({ + teamId: '<TEAM_ID>', + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index 17fe585..ef4ab51 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.list( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await teams.list({ + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index 74fd958..f3b8ba2 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.updateMembershipStatus( - '<TEAM_ID>', // teamId - '<MEMBERSHIP_ID>', // membershipId - '<USER_ID>', // userId - '<SECRET>' // secret -); +const result = await teams.updateMembershipStatus({ + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', + userId: '<USER_ID>', + secret: '<SECRET>' +}); diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 649630d..f09e8e9 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.updateMembership( - '<TEAM_ID>', // teamId - '<MEMBERSHIP_ID>', // membershipId - [] // roles -); +const result = await teams.updateMembership({ + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', + roles: [] +}); diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md index 571f7ce..aaad80f 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.updateName( - '<TEAM_ID>', // teamId - '<NAME>' // name -); +const result = await teams.updateName({ + teamId: '<TEAM_ID>', + name: '<NAME>' +}); diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md index b054694..7f16f62 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const teams = new sdk.Teams(client); -const result = await teams.updatePrefs( - '<TEAM_ID>', // teamId - {} // prefs -); +const result = await teams.updatePrefs({ + teamId: '<TEAM_ID>', + prefs: {} +}); diff --git a/docs/examples/tokens/create-file-token.md b/docs/examples/tokens/create-file-token.md index d1409c4..2353720 100644 --- a/docs/examples/tokens/create-file-token.md +++ b/docs/examples/tokens/create-file-token.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const tokens = new sdk.Tokens(client); -const result = await tokens.createFileToken( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - '' // expire (optional) -); +const result = await tokens.createFileToken({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + expire: '' // optional +}); diff --git a/docs/examples/tokens/delete.md b/docs/examples/tokens/delete.md index 1249839..659c03e 100644 --- a/docs/examples/tokens/delete.md +++ b/docs/examples/tokens/delete.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const tokens = new sdk.Tokens(client); -const result = await tokens.delete( - '<TOKEN_ID>' // tokenId -); +const result = await tokens.delete({ + tokenId: '<TOKEN_ID>' +}); diff --git a/docs/examples/tokens/get.md b/docs/examples/tokens/get.md index efb2b8c..68371c3 100644 --- a/docs/examples/tokens/get.md +++ b/docs/examples/tokens/get.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const tokens = new sdk.Tokens(client); -const result = await tokens.get( - '<TOKEN_ID>' // tokenId -); +const result = await tokens.get({ + tokenId: '<TOKEN_ID>' +}); diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md index 8b708f2..41833b8 100644 --- a/docs/examples/tokens/list.md +++ b/docs/examples/tokens/list.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const tokens = new sdk.Tokens(client); -const result = await tokens.list( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - [] // queries (optional) -); +const result = await tokens.list({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + queries: [] // optional +}); diff --git a/docs/examples/tokens/update.md b/docs/examples/tokens/update.md index ebf5aa9..8178dd0 100644 --- a/docs/examples/tokens/update.md +++ b/docs/examples/tokens/update.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const tokens = new sdk.Tokens(client); -const result = await tokens.update( - '<TOKEN_ID>', // tokenId - '' // expire (optional) -); +const result = await tokens.update({ + tokenId: '<TOKEN_ID>', + expire: '' // optional +}); diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-argon-2-user.md similarity index 64% rename from docs/examples/users/create-m-d5user.md rename to docs/examples/users/create-argon-2-user.md index 954374c..46badb7 100644 --- a/docs/examples/users/create-m-d5user.md +++ b/docs/examples/users/create-argon-2-user.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createMD5User( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - '<NAME>' // name (optional) -); +const result = await users.createArgon2User({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md index d010676..9c94632 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createBcryptUser( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - '<NAME>' // name (optional) -); +const result = await users.createBcryptUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/create-j-w-t.md b/docs/examples/users/create-jwt.md similarity index 67% rename from docs/examples/users/create-j-w-t.md rename to docs/examples/users/create-jwt.md index a2c9b59..d46b9c6 100644 --- a/docs/examples/users/create-j-w-t.md +++ b/docs/examples/users/create-jwt.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createJWT( - '<USER_ID>', // userId - '<SESSION_ID>', // sessionId (optional) - 0 // duration (optional) -); +const result = await users.createJWT({ + userId: '<USER_ID>', + sessionId: '<SESSION_ID>', // optional + duration: 0 // optional +}); diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-md-5-user.md similarity index 63% rename from docs/examples/users/create-p-h-pass-user.md rename to docs/examples/users/create-md-5-user.md index eca31fe..c922274 100644 --- a/docs/examples/users/create-p-h-pass-user.md +++ b/docs/examples/users/create-md-5-user.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createPHPassUser( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - '<NAME>' // name (optional) -); +const result = await users.createMD5User({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md index 8b2ed93..5ebb6ac 100644 --- a/docs/examples/users/create-mfa-recovery-codes.md +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createMfaRecoveryCodes( - '<USER_ID>' // userId -); +const result = await users.createMFARecoveryCodes({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-ph-pass-user.md similarity index 63% rename from docs/examples/users/create-argon2user.md rename to docs/examples/users/create-ph-pass-user.md index dce3646..0a2207f 100644 --- a/docs/examples/users/create-argon2user.md +++ b/docs/examples/users/create-ph-pass-user.md @@ -7,9 +7,9 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createArgon2User( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - '<NAME>' // name (optional) -); +const result = await users.createPHPassUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-s-h-a-user.md deleted file mode 100644 index e7d8588..0000000 --- a/docs/examples/users/create-s-h-a-user.md +++ /dev/null @@ -1,16 +0,0 @@ -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('<YOUR_PROJECT_ID>') // Your project ID - .setKey('<YOUR_API_KEY>'); // Your secret API key - -const users = new sdk.Users(client); - -const result = await users.createSHAUser( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - sdk.PasswordHash.Sha1, // passwordVersion (optional) - '<NAME>' // name (optional) -); diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md index 831107b..bd30b25 100644 --- a/docs/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -7,12 +7,12 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createScryptModifiedUser( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - '<PASSWORD_SALT>', // passwordSalt - '<PASSWORD_SALT_SEPARATOR>', // passwordSaltSeparator - '<PASSWORD_SIGNER_KEY>', // passwordSignerKey - '<NAME>' // name (optional) -); +const result = await users.createScryptModifiedUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + passwordSalt: '<PASSWORD_SALT>', + passwordSaltSeparator: '<PASSWORD_SALT_SEPARATOR>', + passwordSignerKey: '<PASSWORD_SIGNER_KEY>', + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md index 2c2da7e..76f9e2f 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -7,14 +7,14 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createScryptUser( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - '<PASSWORD_SALT>', // passwordSalt - null, // passwordCpu - null, // passwordMemory - null, // passwordParallel - null, // passwordLength - '<NAME>' // name (optional) -); +const result = await users.createScryptUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + passwordSalt: '<PASSWORD_SALT>', + passwordCpu: null, + passwordMemory: null, + passwordParallel: null, + passwordLength: null, + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md index 9d8cc03..869e67f 100644 --- a/docs/examples/users/create-session.md +++ b/docs/examples/users/create-session.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createSession( - '<USER_ID>' // userId -); +const result = await users.createSession({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/create-sha-user.md b/docs/examples/users/create-sha-user.md new file mode 100644 index 0000000..bb940be --- /dev/null +++ b/docs/examples/users/create-sha-user.md @@ -0,0 +1,16 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.createSHAUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + passwordVersion: sdk.PasswordHash.Sha1, // optional + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md index 7b9e6b0..d856f3f 100644 --- a/docs/examples/users/create-target.md +++ b/docs/examples/users/create-target.md @@ -7,11 +7,11 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createTarget( - '<USER_ID>', // userId - '<TARGET_ID>', // targetId - sdk.MessagingProviderType.Email, // providerType - '<IDENTIFIER>', // identifier - '<PROVIDER_ID>', // providerId (optional) - '<NAME>' // name (optional) -); +const result = await users.createTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + providerType: sdk.MessagingProviderType.Email, + identifier: '<IDENTIFIER>', + providerId: '<PROVIDER_ID>', // optional + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md index de7d866..9f11692 100644 --- a/docs/examples/users/create-token.md +++ b/docs/examples/users/create-token.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.createToken( - '<USER_ID>', // userId - 4, // length (optional) - 60 // expire (optional) -); +const result = await users.createToken({ + userId: '<USER_ID>', + length: 4, // optional + expire: 60 // optional +}); diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 025c15a..3095dd1 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -7,10 +7,10 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.create( - '<USER_ID>', // userId - 'email@example.com', // email (optional) - '+12065550100', // phone (optional) - '', // password (optional) - '<NAME>' // name (optional) -); +const result = await users.create({ + userId: '<USER_ID>', + email: 'email@example.com', // optional + phone: '+12065550100', // optional + password: '', // optional + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md index 4c92f27..bcd0e9e 100644 --- a/docs/examples/users/delete-identity.md +++ b/docs/examples/users/delete-identity.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.deleteIdentity( - '<IDENTITY_ID>' // identityId -); +const result = await users.deleteIdentity({ + identityId: '<IDENTITY_ID>' +}); diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md index 456242e..16061c7 100644 --- a/docs/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.deleteMfaAuthenticator( - '<USER_ID>', // userId - sdk.AuthenticatorType.Totp // type -); +const result = await users.deleteMFAAuthenticator({ + userId: '<USER_ID>', + type: sdk.AuthenticatorType.Totp +}); diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index 3f08370..ce301fb 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.deleteSession( - '<USER_ID>', // userId - '<SESSION_ID>' // sessionId -); +const result = await users.deleteSession({ + userId: '<USER_ID>', + sessionId: '<SESSION_ID>' +}); diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index 48714a0..5495fcb 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.deleteSessions( - '<USER_ID>' // userId -); +const result = await users.deleteSessions({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md index ba7e6af..33278f4 100644 --- a/docs/examples/users/delete-target.md +++ b/docs/examples/users/delete-target.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.deleteTarget( - '<USER_ID>', // userId - '<TARGET_ID>' // targetId -); +const result = await users.deleteTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>' +}); diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index 8fdd9e9..1321044 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.delete( - '<USER_ID>' // userId -); +const result = await users.delete({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md index 233c337..25f4e0b 100644 --- a/docs/examples/users/get-mfa-recovery-codes.md +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.getMfaRecoveryCodes( - '<USER_ID>' // userId -); +const result = await users.getMFARecoveryCodes({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index 6193387..cb9d54f 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.getPrefs( - '<USER_ID>' // userId -); +const result = await users.getPrefs({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md index 00dc1f1..0c320bf 100644 --- a/docs/examples/users/get-target.md +++ b/docs/examples/users/get-target.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.getTarget( - '<USER_ID>', // userId - '<TARGET_ID>' // targetId -); +const result = await users.getTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>' +}); diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index 640aa63..594f034 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.get( - '<USER_ID>' // userId -); +const result = await users.get({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index 819b168..2ff959c 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.listIdentities( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await users.listIdentities({ + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md index c1155d5..345d736 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.listLogs( - '<USER_ID>', // userId - [] // queries (optional) -); +const result = await users.listLogs({ + userId: '<USER_ID>', + queries: [] // optional +}); diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index bbe4ed3..4b2cc1f 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -7,8 +7,8 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.listMemberships( - '<USER_ID>', // userId - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await users.listMemberships({ + userId: '<USER_ID>', + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md index 8bffa28..79ffcff 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.listMfaFactors( - '<USER_ID>' // userId -); +const result = await users.listMFAFactors({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index 51ba081..e1082c5 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.listSessions( - '<USER_ID>' // userId -); +const result = await users.listSessions({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md index d991dcc..ded1bbe 100644 --- a/docs/examples/users/list-targets.md +++ b/docs/examples/users/list-targets.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.listTargets( - '<USER_ID>', // userId - [] // queries (optional) -); +const result = await users.listTargets({ + userId: '<USER_ID>', + queries: [] // optional +}); diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index 2bf765b..74e72f5 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.list( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const result = await users.list({ + queries: [], // optional + search: '<SEARCH>' // optional +}); diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md index 9dac2d0..14ab8fb 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updateEmailVerification( - '<USER_ID>', // userId - false // emailVerification -); +const result = await users.updateEmailVerification({ + userId: '<USER_ID>', + emailVerification: false +}); diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md index 0a8b1aa..b8990cd 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updateEmail( - '<USER_ID>', // userId - 'email@example.com' // email -); +const result = await users.updateEmail({ + userId: '<USER_ID>', + email: 'email@example.com' +}); diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index db9e877..8e6588d 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updateLabels( - '<USER_ID>', // userId - [] // labels -); +const result = await users.updateLabels({ + userId: '<USER_ID>', + labels: [] +}); diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md index 9d47085..66513ae 100644 --- a/docs/examples/users/update-mfa-recovery-codes.md +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -7,6 +7,6 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updateMfaRecoveryCodes( - '<USER_ID>' // userId -); +const result = await users.updateMFARecoveryCodes({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index b4acc79..f867b06 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updateMfa( - '<USER_ID>', // userId - false // mfa -); +const result = await users.updateMFA({ + userId: '<USER_ID>', + mfa: false +}); diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md index 581e57b..914f2a3 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updateName( - '<USER_ID>', // userId - '<NAME>' // name -); +const result = await users.updateName({ + userId: '<USER_ID>', + name: '<NAME>' +}); diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md index f4af49d..dd32ede 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updatePassword( - '<USER_ID>', // userId - '' // password -); +const result = await users.updatePassword({ + userId: '<USER_ID>', + password: '' +}); diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md index ecbe759..bccc61a 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updatePhoneVerification( - '<USER_ID>', // userId - false // phoneVerification -); +const result = await users.updatePhoneVerification({ + userId: '<USER_ID>', + phoneVerification: false +}); diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md index 45e5a65..de534f6 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updatePhone( - '<USER_ID>', // userId - '+12065550100' // number -); +const result = await users.updatePhone({ + userId: '<USER_ID>', + number: '+12065550100' +}); diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index bb7eff8..9b5d9d4 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updatePrefs( - '<USER_ID>', // userId - {} // prefs -); +const result = await users.updatePrefs({ + userId: '<USER_ID>', + prefs: {} +}); diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index 57f64ce..c222030 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -7,7 +7,7 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updateStatus( - '<USER_ID>', // userId - false // status -); +const result = await users.updateStatus({ + userId: '<USER_ID>', + status: false +}); diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md index c6e4d9a..e77dbb5 100644 --- a/docs/examples/users/update-target.md +++ b/docs/examples/users/update-target.md @@ -7,10 +7,10 @@ const client = new sdk.Client() const users = new sdk.Users(client); -const result = await users.updateTarget( - '<USER_ID>', // userId - '<TARGET_ID>', // targetId - '<IDENTIFIER>', // identifier (optional) - '<PROVIDER_ID>', // providerId (optional) - '<NAME>' // name (optional) -); +const result = await users.updateTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + identifier: '<IDENTIFIER>', // optional + providerId: '<PROVIDER_ID>', // optional + name: '<NAME>' // optional +}); diff --git a/package.json b/package.json index ae74ea1..85f39d0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-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": "17.2.0", + "version": "18.0.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 7b74a1e..c27ae81 100644 --- a/src/client.ts +++ b/src/client.ts @@ -33,7 +33,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/17.2.0'; + let ua = 'AppwriteNodeJSSDK/18.0.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -82,9 +82,9 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '17.2.0', + 'x-sdk-version': '18.0.0', 'user-agent' : getUserAgent(), - 'X-Appwrite-Response-Format': '1.7.0', + 'X-Appwrite-Response-Format': '1.8.0', }; /** diff --git a/src/enums/v-c-s-deployment-type.ts b/src/enums/vcs-deployment-type.ts similarity index 100% rename from src/enums/v-c-s-deployment-type.ts rename to src/enums/vcs-deployment-type.ts diff --git a/src/index.ts b/src/index.ts index 849d8b1..e9170f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,7 @@ export { Locale } from './services/locale'; export { Messaging } from './services/messaging'; export { Sites } from './services/sites'; export { Storage } from './services/storage'; +export { TablesDB } from './services/tables-db'; export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; @@ -27,7 +28,7 @@ export { RelationshipType } from './enums/relationship-type'; export { RelationMutate } from './enums/relation-mutate'; export { IndexType } from './enums/index-type'; export { Runtime } from './enums/runtime'; -export { VCSDeploymentType } from './enums/v-c-s-deployment-type'; +export { VCSDeploymentType } from './enums/vcs-deployment-type'; export { DeploymentDownloadType } from './enums/deployment-download-type'; export { ExecutionMethod } from './enums/execution-method'; export { Name } from './enums/name'; diff --git a/src/models.ts b/src/models.ts index be2a8e2..2d0018f 100644 --- a/src/models.ts +++ b/src/models.ts @@ -5,12 +5,26 @@ export namespace Models { declare const __default: unique symbol; + /** + * Rows List + */ + export type RowList<Row extends Models.Row = Models.DefaultRow> = { + /** + * Total number of rows that matched your query. + */ + total: number; + /** + * List of rows. + */ + rows: Row[]; + } + /** * Documents List */ export type DocumentList<Document extends Models.Document = Models.DefaultDocument> = { /** - * Total number of documents documents that matched your query. + * Total number of documents that matched your query. */ total: number; /** @@ -19,12 +33,26 @@ export namespace Models { documents: Document[]; } + /** + * Tables List + */ + export type TableList = { + /** + * Total number of tables that matched your query. + */ + total: number; + /** + * List of tables. + */ + tables: Table[]; + } + /** * Collections List */ export type CollectionList = { /** - * Total number of collections documents that matched your query. + * Total number of collections that matched your query. */ total: number; /** @@ -38,7 +66,7 @@ export namespace Models { */ export type DatabaseList = { /** - * Total number of databases documents that matched your query. + * Total number of databases that matched your query. */ total: number; /** @@ -52,7 +80,7 @@ export namespace Models { */ export type IndexList = { /** - * Total number of indexes documents that matched your query. + * Total number of indexes that matched your query. */ total: number; /** @@ -61,12 +89,26 @@ export namespace Models { indexes: Index[]; } + /** + * Column Indexes List + */ + export type ColumnIndexList = { + /** + * Total number of indexes that matched your query. + */ + total: number; + /** + * List of indexes. + */ + indexes: ColumnIndex[]; + } + /** * Users List */ export type UserList<Preferences extends Models.Preferences = Models.DefaultPreferences> = { /** - * Total number of users documents that matched your query. + * Total number of users that matched your query. */ total: number; /** @@ -80,7 +122,7 @@ export namespace Models { */ export type SessionList = { /** - * Total number of sessions documents that matched your query. + * Total number of sessions that matched your query. */ total: number; /** @@ -94,7 +136,7 @@ export namespace Models { */ export type IdentityList = { /** - * Total number of identities documents that matched your query. + * Total number of identities that matched your query. */ total: number; /** @@ -108,7 +150,7 @@ export namespace Models { */ export type LogList = { /** - * Total number of logs documents that matched your query. + * Total number of logs that matched your query. */ total: number; /** @@ -122,7 +164,7 @@ export namespace Models { */ export type FileList = { /** - * Total number of files documents that matched your query. + * Total number of files that matched your query. */ total: number; /** @@ -136,7 +178,7 @@ export namespace Models { */ export type BucketList = { /** - * Total number of buckets documents that matched your query. + * Total number of buckets that matched your query. */ total: number; /** @@ -150,7 +192,7 @@ export namespace Models { */ export type ResourceTokenList = { /** - * Total number of tokens documents that matched your query. + * Total number of tokens that matched your query. */ total: number; /** @@ -164,7 +206,7 @@ export namespace Models { */ export type TeamList<Preferences extends Models.Preferences = Models.DefaultPreferences> = { /** - * Total number of teams documents that matched your query. + * Total number of teams that matched your query. */ total: number; /** @@ -178,7 +220,7 @@ export namespace Models { */ export type MembershipList = { /** - * Total number of memberships documents that matched your query. + * Total number of memberships that matched your query. */ total: number; /** @@ -192,7 +234,7 @@ export namespace Models { */ export type SiteList = { /** - * Total number of sites documents that matched your query. + * Total number of sites that matched your query. */ total: number; /** @@ -206,7 +248,7 @@ export namespace Models { */ export type FunctionList = { /** - * Total number of functions documents that matched your query. + * Total number of functions that matched your query. */ total: number; /** @@ -220,7 +262,7 @@ export namespace Models { */ export type FrameworkList = { /** - * Total number of frameworks documents that matched your query. + * Total number of frameworks that matched your query. */ total: number; /** @@ -234,7 +276,7 @@ export namespace Models { */ export type RuntimeList = { /** - * Total number of runtimes documents that matched your query. + * Total number of runtimes that matched your query. */ total: number; /** @@ -248,7 +290,7 @@ export namespace Models { */ export type DeploymentList = { /** - * Total number of deployments documents that matched your query. + * Total number of deployments that matched your query. */ total: number; /** @@ -262,7 +304,7 @@ export namespace Models { */ export type ExecutionList = { /** - * Total number of executions documents that matched your query. + * Total number of executions that matched your query. */ total: number; /** @@ -276,7 +318,7 @@ export namespace Models { */ export type CountryList = { /** - * Total number of countries documents that matched your query. + * Total number of countries that matched your query. */ total: number; /** @@ -290,7 +332,7 @@ export namespace Models { */ export type ContinentList = { /** - * Total number of continents documents that matched your query. + * Total number of continents that matched your query. */ total: number; /** @@ -304,7 +346,7 @@ export namespace Models { */ export type LanguageList = { /** - * Total number of languages documents that matched your query. + * Total number of languages that matched your query. */ total: number; /** @@ -318,7 +360,7 @@ export namespace Models { */ export type CurrencyList = { /** - * Total number of currencies documents that matched your query. + * Total number of currencies that matched your query. */ total: number; /** @@ -332,7 +374,7 @@ export namespace Models { */ export type PhoneList = { /** - * Total number of phones documents that matched your query. + * Total number of phones that matched your query. */ total: number; /** @@ -346,7 +388,7 @@ export namespace Models { */ export type VariableList = { /** - * Total number of variables documents that matched your query. + * Total number of variables that matched your query. */ total: number; /** @@ -360,7 +402,7 @@ export namespace Models { */ export type LocaleCodeList = { /** - * Total number of localeCodes documents that matched your query. + * Total number of localeCodes that matched your query. */ total: number; /** @@ -374,7 +416,7 @@ export namespace Models { */ export type ProviderList = { /** - * Total number of providers documents that matched your query. + * Total number of providers that matched your query. */ total: number; /** @@ -388,7 +430,7 @@ export namespace Models { */ export type MessageList = { /** - * Total number of messages documents that matched your query. + * Total number of messages that matched your query. */ total: number; /** @@ -402,7 +444,7 @@ export namespace Models { */ export type TopicList = { /** - * Total number of topics documents that matched your query. + * Total number of topics that matched your query. */ total: number; /** @@ -416,7 +458,7 @@ export namespace Models { */ export type SubscriberList = { /** - * Total number of subscribers documents that matched your query. + * Total number of subscribers that matched your query. */ total: number; /** @@ -430,73 +472,625 @@ export namespace Models { */ export type TargetList = { /** - * Total number of targets documents that matched your query. + * Total number of targets that matched your query. + */ + total: number; + /** + * List of targets. + */ + targets: Target[]; + } + + /** + * Specifications List + */ + export type SpecificationList = { + /** + * Total number of specifications that matched your query. + */ + total: number; + /** + * List of specifications. + */ + specifications: Specification[]; + } + + /** + * Database + */ + export type Database = { + /** + * Database ID. + */ + $id: string; + /** + * Database name. + */ + name: string; + /** + * Database creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Database update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. + */ + enabled: boolean; + /** + * Database type. + */ + type: string; + } + + /** + * Collection + */ + export type Collection = { + /** + * Collection ID. + */ + $id: string; + /** + * Collection creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Collection update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * Database ID. + */ + databaseId: string; + /** + * Collection name. + */ + name: string; + /** + * Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. + */ + enabled: boolean; + /** + * Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + documentSecurity: boolean; + /** + * Collection attributes. + */ + attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString)[]; + /** + * Collection indexes. + */ + indexes: Index[]; + } + + /** + * Attributes List + */ + export type AttributeList = { + /** + * Total number of attributes in the given collection. + */ + total: number; + /** + * List of attributes. + */ + attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString)[]; + } + + /** + * AttributeString + */ + export type AttributeString = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Attribute size. + */ + size: number; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; + } + + /** + * AttributeInteger + */ + export type AttributeInteger = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number; + /** + * Maximum value to enforce for new documents. + */ + max?: number; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: number; + } + + /** + * AttributeFloat + */ + export type AttributeFloat = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number; + /** + * Maximum value to enforce for new documents. + */ + max?: number; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: number; + } + + /** + * AttributeBoolean + */ + export type AttributeBoolean = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: boolean; + } + + /** + * AttributeEmail + */ + export type AttributeEmail = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + } + + /** + * AttributeEnum + */ + export type AttributeEnum = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Array of elements in enumerated type. + */ + elements: string[]; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + } + + /** + * AttributeIP + */ + export type AttributeIp = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + } + + /** + * AttributeURL + */ + export type AttributeUrl = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + } + + /** + * AttributeDatetime + */ + export type AttributeDatetime = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * ISO 8601 format. + */ + format: string; + /** + * Default value for attribute when not provided. Only null is optional + */ + default?: string; + } + + /** + * AttributeRelationship + */ + export type AttributeRelationship = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? */ - total: number; + array?: boolean; /** - * List of targets. + * Attribute creation date in ISO 8601 format. */ - targets: Target[]; - } - - /** - * Specifications List - */ - export type SpecificationList = { + $createdAt: string; /** - * Total number of specifications documents that matched your query. + * Attribute update date in ISO 8601 format. */ - total: number; + $updatedAt: string; /** - * List of specifications. + * The ID of the related collection. */ - specifications: Specification[]; - } - - /** - * Database - */ - export type Database = { + relatedCollection: string; /** - * Database ID. + * The type of the relationship. */ - $id: string; + relationType: string; /** - * Database name. + * Is the relationship two-way? */ - name: string; + twoWay: boolean; /** - * Database creation date in ISO 8601 format. + * The key of the two-way relationship. */ - $createdAt: string; + twoWayKey: string; /** - * Database update date in ISO 8601 format. + * How deleting the parent document will propagate to child documents. */ - $updatedAt: string; + onDelete: string; /** - * If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. + * Whether this is the parent or child side of the relationship */ - enabled: boolean; + side: string; } /** - * Collection + * Table */ - export type Collection = { + export type Table = { /** - * Collection ID. + * Table ID. */ $id: string; /** - * Collection creation date in ISO 8601 format. + * Table creation date in ISO 8601 format. */ $createdAt: string; /** - * Collection update date in ISO 8601 format. + * Table update date in ISO 8601 format. */ $updatedAt: string; /** - * Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ $permissions: string[]; /** @@ -504,125 +1098,125 @@ export namespace Models { */ databaseId: string; /** - * Collection name. + * Table name. */ name: string; /** - * Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. + * Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. */ enabled: boolean; /** - * Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - documentSecurity: boolean; + rowSecurity: boolean; /** - * Collection attributes. + * Table columns. */ - attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString)[]; + columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString)[]; /** - * Collection indexes. + * Table indexes. */ - indexes: Index[]; + indexes: ColumnIndex[]; } /** - * Attributes List + * Columns List */ - export type AttributeList = { + export type ColumnList = { /** - * Total number of attributes in the given collection. + * Total number of columns in the given table. */ total: number; /** - * List of attributes. + * List of columns. */ - attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString)[]; + columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString)[]; } /** - * AttributeString + * ColumnString */ - export type AttributeString = { + export type ColumnString = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ status: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * Attribute size. + * Column size. */ size: number; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for column when not provided. Cannot be set when column is required. */ default?: string; /** - * Defines whether this attribute is encrypted or not. + * Defines whether this column is encrypted or not. */ encrypt?: boolean; } /** - * AttributeInteger + * ColumnInteger */ - export type AttributeInteger = { + export type ColumnInteger = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ status: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** @@ -634,45 +1228,45 @@ export namespace Models { */ max?: number; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for column when not provided. Cannot be set when column is required. */ default?: number; } /** - * AttributeFloat + * ColumnFloat */ - export type AttributeFloat = { + export type ColumnFloat = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ status: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** @@ -684,87 +1278,87 @@ export namespace Models { */ max?: number; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for column when not provided. Cannot be set when column is required. */ default?: number; } /** - * AttributeBoolean + * ColumnBoolean */ - export type AttributeBoolean = { + export type ColumnBoolean = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ status: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for column when not provided. Cannot be set when column is required. */ default?: boolean; } /** - * AttributeEmail + * ColumnEmail */ - export type AttributeEmail = { + export type ColumnEmail = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ status: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** @@ -772,45 +1366,45 @@ export namespace Models { */ format: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for column when not provided. Cannot be set when column is required. */ default?: string; } /** - * AttributeEnum + * ColumnEnum */ - export type AttributeEnum = { + export type ColumnEnum = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ status: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** @@ -822,45 +1416,45 @@ export namespace Models { */ format: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for column when not provided. Cannot be set when column is required. */ default?: string; } /** - * AttributeIP + * ColumnIP */ - export type AttributeIp = { + export type ColumnIp = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ status: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** @@ -868,45 +1462,45 @@ export namespace Models { */ format: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for column when not provided. Cannot be set when column is required. */ default?: string; } /** - * AttributeURL + * ColumnURL */ - export type AttributeUrl = { + export type ColumnUrl = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ status: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** @@ -914,45 +1508,45 @@ export namespace Models { */ format: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for column when not provided. Cannot be set when column is required. */ default?: string; } /** - * AttributeDatetime + * ColumnDatetime */ - export type AttributeDatetime = { + export type ColumnDatetime = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ status: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** @@ -960,51 +1554,51 @@ export namespace Models { */ format: string; /** - * Default value for attribute when not provided. Only null is optional + * Default value for column when not provided. Only null is optional */ default?: string; } /** - * AttributeRelationship + * ColumnRelationship */ - export type AttributeRelationship = { + export type ColumnRelationship = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ status: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * The ID of the related collection. + * The ID of the related table. */ - relatedCollection: string; + relatedTable: string; /** * The type of the relationship. */ @@ -1032,7 +1626,19 @@ export namespace Models { */ export type Index = { /** - * Index Key. + * Index ID. + */ + $id: string; + /** + * Index creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Index update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Index key. */ key: string; /** @@ -1059,6 +1665,16 @@ export namespace Models { * Index orders. */ orders?: string[]; + } + + /** + * Index + */ + export type ColumnIndex = { + /** + * Index ID. + */ + $id: string; /** * Index creation date in ISO 8601 format. */ @@ -1067,8 +1683,75 @@ export namespace Models { * Index update date in ISO 8601 format. */ $updatedAt: string; + /** + * Index Key. + */ + key: string; + /** + * Index type. + */ + type: string; + /** + * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an index. + */ + error: string; + /** + * Index columns. + */ + columns: string[]; + /** + * Index columns length. + */ + lengths: number[]; + /** + * Index orders. + */ + orders?: string[]; + } + + /** + * Row + */ + export type Row = { + /** + * Row ID. + */ + $id: string; + /** + * Row automatically incrementing ID. + */ + $sequence: number; + /** + * Table ID. + */ + $tableId: string; + /** + * Database ID. + */ + $databaseId: string; + /** + * Row creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Row update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; } + export type DefaultRow = Row & { + [key: string]: any; + [__default]: true; + }; + /** * Document */ @@ -1108,12 +1791,6 @@ export namespace Models { [__default]: true; }; - export type DataWithoutDocumentKeys = { - [K in string]: any; - } & { - [K in keyof Document]?: never; - }; - /** * Log */ @@ -1407,12 +2084,6 @@ export namespace Models { [__default]: true; }; - export type DataWithoutPreferencesKeys = { - [K in string]: any; - } & { - [K in keyof Preferences]?: never; - }; - /** * Session */ @@ -1638,7 +2309,7 @@ export namespace Models { */ country: string; /** - * Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + * Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. */ continentCode: string; /** @@ -1920,7 +2591,7 @@ export namespace Models { */ enabled: boolean; /** - * Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration. + * Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration. */ live: boolean; /** @@ -1932,7 +2603,7 @@ export namespace Models { */ framework: string; /** - * Site's active deployment ID. + * Site's active deployment ID. */ deploymentId: string; /** @@ -1948,7 +2619,7 @@ export namespace Models { */ deploymentScreenshotDark: string; /** - * Site's latest deployment ID. + * Site's latest deployment ID. */ latestDeploymentId: string; /** @@ -1956,7 +2627,7 @@ export namespace Models { */ latestDeploymentCreatedAt: string; /** - * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". */ latestDeploymentStatus: string; /** @@ -2046,7 +2717,7 @@ export namespace Models { */ enabled: boolean; /** - * Is the function deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the function to update it with the latest configuration. + * Is the function deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the function to update it with the latest configuration. */ live: boolean; /** @@ -2058,7 +2729,7 @@ export namespace Models { */ runtime: string; /** - * Function's active deployment ID. + * Function's active deployment ID. */ deploymentId: string; /** @@ -2066,7 +2737,7 @@ export namespace Models { */ deploymentCreatedAt: string; /** - * Function's latest deployment ID. + * Function's latest deployment ID. */ latestDeploymentId: string; /** @@ -2074,7 +2745,7 @@ export namespace Models { */ latestDeploymentCreatedAt: string; /** - * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". */ latestDeploymentStatus: string; /** @@ -2286,7 +2957,7 @@ export namespace Models { */ screenshotDark: string; /** - * The deployment status. Possible values are "waiting", "processing", "building", "ready", and "failed". + * The deployment status. Possible values are "waiting", "processing", "building", "ready", and "failed". */ status: string; /** @@ -2352,7 +3023,7 @@ export namespace Models { */ $createdAt: string; /** - * Execution upate date in ISO 8601 format. + * Execution update date in ISO 8601 format. */ $updatedAt: string; /** @@ -2363,6 +3034,10 @@ export namespace Models { * Function ID. */ functionId: string; + /** + * Function's deployment ID used to create the execution. + */ + deploymentId: string; /** * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. */ @@ -2442,11 +3117,11 @@ export namespace Models { */ secret: boolean; /** - * Service to which the variable belongs. Possible values are "project", "function" + * Service to which the variable belongs. Possible values are "project", "function" */ resourceType: string; /** - * ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. + * ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. */ resourceId: string; } diff --git a/src/query.ts b/src/query.ts index acad038..ed016cb 100644 --- a/src/query.ts +++ b/src/query.ts @@ -241,6 +241,94 @@ export class Query { static contains = (attribute: string, value: string | string[]): string => new Query("contains", attribute, value).toString(); + /** + * Filter resources where attribute does not contain the specified value. + * + * @param {string} attribute + * @param {string | string[]} value + * @returns {string} + */ + static notContains = (attribute: string, value: string | string[]): string => + new Query("notContains", attribute, value).toString(); + + /** + * Filter resources by searching attribute for value (inverse of search). + * A fulltext index on attribute is required for this query to work. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static notSearch = (attribute: string, value: string): string => + new Query("notSearch", attribute, value).toString(); + + /** + * Filter resources where attribute is not between start and end (exclusive). + * + * @param {string} attribute + * @param {string | number} start + * @param {string | number} end + * @returns {string} + */ + static notBetween = (attribute: string, start: string | number, end: string | number): string => + new Query("notBetween", attribute, [start, end] as QueryTypesList).toString(); + + /** + * Filter resources where attribute does not start with value. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static notStartsWith = (attribute: string, value: string): string => + new Query("notStartsWith", attribute, value).toString(); + + /** + * Filter resources where attribute does not end with value. + * + * @param {string} attribute + * @param {string} value + * @returns {string} + */ + static notEndsWith = (attribute: string, value: string): string => + new Query("notEndsWith", attribute, value).toString(); + + /** + * Filter resources where document was created before date. + * + * @param {string} value + * @returns {string} + */ + static createdBefore = (value: string): string => + new Query("createdBefore", undefined, value).toString(); + + /** + * Filter resources where document was created after date. + * + * @param {string} value + * @returns {string} + */ + static createdAfter = (value: string): string => + new Query("createdAfter", undefined, value).toString(); + + /** + * Filter resources where document was updated before date. + * + * @param {string} value + * @returns {string} + */ + static updatedBefore = (value: string): string => + new Query("updatedBefore", undefined, value).toString(); + + /** + * Filter resources where document was updated after date. + * + * @param {string} value + * @returns {string} + */ + static updatedAfter = (value: string): string => + new Query("updatedAfter", undefined, value).toString(); + /** * Combine multiple queries using logical OR operator. * diff --git a/src/services/account.ts b/src/services/account.ts index 4bb5f6a..4efa6ee 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,5 +1,6 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; import { OAuthProvider } from '../enums/o-auth-provider'; @@ -18,6 +19,7 @@ export class Account { * @returns {Promise<Models.User<Preferences>>} */ get<Preferences extends Models.Preferences = Models.DefaultPreferences>(): Promise<Models.User<Preferences>> { + const apiPath = '/account'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -36,14 +38,48 @@ export class 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 [/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). * - * @param {string} userId - * @param {string} email - * @param {string} password - * @param {string} name + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - New user password. Must be between 8 and 256 chars. + * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - create<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> { + create<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * 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). + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - New user password. Must be between 8 and 256 chars. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>>; + create<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + name: rest[2] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -53,6 +89,7 @@ export class Account { if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/account'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -86,18 +123,49 @@ export class Account { * 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 + * @param {string} params.email - User email. + * @param {string} params.password - User password. Must be at least 8 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>(email: string, password: string): Promise<Models.User<Preferences>> { + updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { email: string, password: string }): Promise<Models.User<Preferences>>; + /** + * 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. + * + * + * @param {string} email - User email. + * @param {string} password - User password. Must be at least 8 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>(email: string, password: string): Promise<Models.User<Preferences>>; + updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { email: string, password: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { email: string, password: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { email: string, password: string }; + } else { + params = { + email: paramsOrFirst as string, + password: rest[0] as string + }; + } + + const email = params.email; + const password = params.password; + if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/account/email'; const payload: Payload = {}; if (typeof email !== 'undefined') { @@ -123,11 +191,36 @@ export class Account { /** * Get the list of identities for the currently logged in user. * - * @param {string[]} queries + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry * @throws {AppwriteException} * @returns {Promise<Models.IdentityList>} */ - listIdentities(queries?: string[]): Promise<Models.IdentityList> { + listIdentities(params?: { queries?: string[] }): Promise<Models.IdentityList>; + /** + * Get the list of identities for the currently logged in user. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry + * @throws {AppwriteException} + * @returns {Promise<Models.IdentityList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listIdentities(queries?: string[]): Promise<Models.IdentityList>; + listIdentities( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise<Models.IdentityList> { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + const apiPath = '/account/identities'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -149,14 +242,39 @@ export class Account { /** * Delete an identity by its unique ID. * - * @param {string} identityId + * @param {string} params.identityId - Identity ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteIdentity(params: { identityId: string }): Promise<{}>; + /** + * Delete an identity by its unique ID. + * + * @param {string} identityId - Identity ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteIdentity(identityId: string): Promise<{}> { + deleteIdentity(identityId: string): Promise<{}>; + deleteIdentity( + paramsOrFirst: { identityId: string } | string + ): Promise<{}> { + let params: { identityId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { identityId: string }; + } else { + params = { + identityId: paramsOrFirst as string + }; + } + + const identityId = params.identityId; + if (typeof identityId === 'undefined') { throw new AppwriteException('Missing required parameter: "identityId"'); } + const apiPath = '/account/identities/{identityId}'.replace('{identityId}', identityId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -180,6 +298,7 @@ export class Account { * @returns {Promise<Models.Jwt>} */ createJWT(): Promise<Models.Jwt> { + const apiPath = '/account/jwts'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -199,11 +318,36 @@ export class Account { /** * 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. * - * @param {string[]} queries + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @throws {AppwriteException} * @returns {Promise<Models.LogList>} */ - listLogs(queries?: string[]): Promise<Models.LogList> { + listLogs(params?: { queries?: string[] }): Promise<Models.LogList>; + /** + * 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. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listLogs(queries?: string[]): Promise<Models.LogList>; + listLogs( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise<Models.LogList> { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + const apiPath = '/account/logs'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -225,14 +369,39 @@ export class Account { /** * Enable or disable MFA on an account. * - * @param {boolean} mfa + * @param {boolean} params.mfa - Enable or disable MFA. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - updateMFA<Preferences extends Models.Preferences = Models.DefaultPreferences>(mfa: boolean): Promise<Models.User<Preferences>> { + updateMFA<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { mfa: boolean }): Promise<Models.User<Preferences>>; + /** + * Enable or disable MFA on an account. + * + * @param {boolean} mfa - Enable or disable MFA. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMFA<Preferences extends Models.Preferences = Models.DefaultPreferences>(mfa: boolean): Promise<Models.User<Preferences>>; + updateMFA<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { mfa: boolean } | boolean + ): Promise<Models.User<Preferences>> { + let params: { mfa: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { mfa: boolean }; + } else { + params = { + mfa: paramsOrFirst as boolean + }; + } + + const mfa = params.mfa; + if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } + const apiPath = '/account/mfa'; const payload: Payload = {}; if (typeof mfa !== 'undefined') { @@ -255,14 +424,92 @@ export class Account { /** * 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. * - * @param {AuthenticatorType} type + * @param {AuthenticatorType} params.type - Type of authenticator. Must be `totp` + * @throws {AppwriteException} + * @returns {Promise<Models.MfaType>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead. + */ + createMfaAuthenticator(params: { type: AuthenticatorType }): Promise<Models.MfaType>; + /** + * 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. + * + * @param {AuthenticatorType} type - Type of authenticator. Must be `totp` + * @throws {AppwriteException} + * @returns {Promise<Models.MfaType>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMfaAuthenticator(type: AuthenticatorType): Promise<Models.MfaType>; + createMfaAuthenticator( + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + ): Promise<Models.MfaType> { + let params: { type: AuthenticatorType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { type: AuthenticatorType }; + } else { + params = { + type: paramsOrFirst as AuthenticatorType + }; + } + + const type = params.type; + + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + 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. + * + * @param {AuthenticatorType} params.type - Type of authenticator. Must be `totp` + * @throws {AppwriteException} + * @returns {Promise<Models.MfaType>} + */ + createMFAAuthenticator(params: { type: AuthenticatorType }): Promise<Models.MfaType>; + /** + * 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. + * + * @param {AuthenticatorType} type - Type of authenticator. Must be `totp` * @throws {AppwriteException} * @returns {Promise<Models.MfaType>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createMfaAuthenticator(type: AuthenticatorType): Promise<Models.MfaType> { + createMFAAuthenticator(type: AuthenticatorType): Promise<Models.MfaType>; + createMFAAuthenticator( + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + ): Promise<Models.MfaType> { + let params: { type: AuthenticatorType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { type: AuthenticatorType }; + } else { + params = { + type: paramsOrFirst as AuthenticatorType + }; + } + + const type = params.type; + if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -282,31 +529,497 @@ export class Account { /** * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * - * @param {AuthenticatorType} type - * @param {string} otp + * @param {AuthenticatorType} params.type - Type of authenticator. + * @param {string} params.otp - Valid verification token. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead. */ - updateMfaAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>> { + updateMfaAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { type: AuthenticatorType, otp: string }): Promise<Models.User<Preferences>>; + /** + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. + * + * @param {AuthenticatorType} type - Type of authenticator. + * @param {string} otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMfaAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>>; + updateMfaAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { type: AuthenticatorType, otp: string } | AuthenticatorType, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { type: AuthenticatorType, otp: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string }; + } else { + params = { + type: paramsOrFirst as AuthenticatorType, + otp: rest[0] as string + }; + } + + const type = params.type; + const otp = params.otp; + + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof otp === 'undefined') { + throw new AppwriteException('Missing required parameter: "otp"'); + } + + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); + const payload: Payload = {}; + if (typeof otp !== 'undefined') { + payload['otp'] = otp; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. + * + * @param {AuthenticatorType} params.type - Type of authenticator. + * @param {string} params.otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateMFAAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { type: AuthenticatorType, otp: string }): Promise<Models.User<Preferences>>; + /** + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. + * + * @param {AuthenticatorType} type - Type of authenticator. + * @param {string} otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMFAAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>>; + updateMFAAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { type: AuthenticatorType, otp: string } | AuthenticatorType, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { type: AuthenticatorType, otp: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string }; + } else { + params = { + type: paramsOrFirst as AuthenticatorType, + otp: rest[0] as string + }; + } + + const type = params.type; + const otp = params.otp; + if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } if (typeof otp === 'undefined') { throw new AppwriteException('Missing required parameter: "otp"'); } + + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); + const payload: Payload = {}; + if (typeof otp !== 'undefined') { + payload['otp'] = otp; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete an authenticator for a user by ID. + * + * @param {AuthenticatorType} params.type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead. + */ + deleteMfaAuthenticator(params: { type: AuthenticatorType }): Promise<{}>; + /** + * Delete an authenticator for a user by ID. + * + * @param {AuthenticatorType} type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteMfaAuthenticator(type: AuthenticatorType): Promise<{}>; + deleteMfaAuthenticator( + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + ): Promise<{}> { + let params: { type: AuthenticatorType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { type: AuthenticatorType }; + } else { + params = { + type: paramsOrFirst as AuthenticatorType + }; + } + + const type = params.type; + + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete an authenticator for a user by ID. + * + * @param {AuthenticatorType} params.type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteMFAAuthenticator(params: { type: AuthenticatorType }): Promise<{}>; + /** + * Delete an authenticator for a user by ID. + * + * @param {AuthenticatorType} type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteMFAAuthenticator(type: AuthenticatorType): Promise<{}>; + deleteMFAAuthenticator( + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + ): Promise<{}> { + let params: { type: AuthenticatorType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { type: AuthenticatorType }; + } else { + params = { + type: paramsOrFirst as AuthenticatorType + }; + } + + const type = params.type; + + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. + * + * @param {AuthenticationFactor} params.factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaChallenge>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead. + */ + createMfaChallenge(params: { factor: AuthenticationFactor }): Promise<Models.MfaChallenge>; + /** + * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. + * + * @param {AuthenticationFactor} factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMfaChallenge(factor: AuthenticationFactor): Promise<Models.MfaChallenge>; + createMfaChallenge( + paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor + ): Promise<Models.MfaChallenge> { + let params: { factor: AuthenticationFactor }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { factor: AuthenticationFactor }; + } else { + params = { + factor: paramsOrFirst as AuthenticationFactor + }; + } + + const factor = params.factor; + + if (typeof factor === 'undefined') { + throw new AppwriteException('Missing required parameter: "factor"'); + } + + const apiPath = '/account/mfa/challenge'; + const payload: Payload = {}; + if (typeof factor !== 'undefined') { + payload['factor'] = factor; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. + * + * @param {AuthenticationFactor} params.factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaChallenge>} + */ + createMFAChallenge(params: { factor: AuthenticationFactor }): Promise<Models.MfaChallenge>; + /** + * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. + * + * @param {AuthenticationFactor} factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMFAChallenge(factor: AuthenticationFactor): Promise<Models.MfaChallenge>; + createMFAChallenge( + paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor + ): Promise<Models.MfaChallenge> { + let params: { factor: AuthenticationFactor }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { factor: AuthenticationFactor }; + } else { + params = { + factor: paramsOrFirst as AuthenticationFactor + }; + } + + const factor = params.factor; + + if (typeof factor === 'undefined') { + throw new AppwriteException('Missing required parameter: "factor"'); + } + + const apiPath = '/account/mfa/challenge'; + const payload: Payload = {}; + if (typeof factor !== 'undefined') { + payload['factor'] = factor; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + 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. + * + * @param {string} params.challengeId - ID of the challenge. + * @param {string} params.otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead. + */ + updateMfaChallenge(params: { challengeId: string, otp: string }): Promise<Models.Session>; + /** + * 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. + * + * @param {string} challengeId - ID of the challenge. + * @param {string} otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMfaChallenge(challengeId: string, otp: string): Promise<Models.Session>; + updateMfaChallenge( + paramsOrFirst: { challengeId: string, otp: string } | string, + ...rest: [(string)?] + ): Promise<Models.Session> { + let params: { challengeId: string, otp: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { challengeId: string, otp: string }; + } else { + params = { + challengeId: paramsOrFirst as string, + otp: rest[0] as string + }; + } + + const challengeId = params.challengeId; + const otp = params.otp; + + if (typeof challengeId === 'undefined') { + throw new AppwriteException('Missing required parameter: "challengeId"'); + } + if (typeof otp === 'undefined') { + throw new AppwriteException('Missing required parameter: "otp"'); + } + + const apiPath = '/account/mfa/challenge'; + const payload: Payload = {}; + if (typeof challengeId !== 'undefined') { + payload['challengeId'] = challengeId; + } + if (typeof otp !== 'undefined') { + payload['otp'] = otp; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + 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. + * + * @param {string} params.challengeId - ID of the challenge. + * @param {string} params.otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + */ + updateMFAChallenge(params: { challengeId: string, otp: string }): Promise<Models.Session>; + /** + * 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. + * + * @param {string} challengeId - ID of the challenge. + * @param {string} otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMFAChallenge(challengeId: string, otp: string): Promise<Models.Session>; + updateMFAChallenge( + paramsOrFirst: { challengeId: string, otp: string } | string, + ...rest: [(string)?] + ): Promise<Models.Session> { + let params: { challengeId: string, otp: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { challengeId: string, otp: string }; + } else { + params = { + challengeId: paramsOrFirst as string, + otp: rest[0] as string + }; + } + + const challengeId = params.challengeId; + const otp = params.otp; + + if (typeof challengeId === 'undefined') { + throw new AppwriteException('Missing required parameter: "challengeId"'); + } + if (typeof otp === 'undefined') { + throw new AppwriteException('Missing required parameter: "otp"'); + } + + const apiPath = '/account/mfa/challenge'; + const payload: Payload = {}; + if (typeof challengeId !== 'undefined') { + payload['challengeId'] = challengeId; + } if (typeof otp !== 'undefined') { payload['otp'] = otp; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * List the factors available on the account to be used as a MFA challange. + * + * @throws {AppwriteException} + * @returns {Promise<Models.MfaFactors>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead. + */ + listMfaFactors(): Promise<Models.MfaFactors> { + + const apiPath = '/account/mfa/factors'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { } return this.client.call( - 'put', + 'get', uri, apiHeaders, payload, @@ -314,26 +1027,22 @@ export class Account { } /** - * Delete an authenticator for a user by ID. + * List the factors available on the account to be used as a MFA challange. * - * @param {AuthenticatorType} type * @throws {AppwriteException} - * @returns {Promise<{}>} + * @returns {Promise<Models.MfaFactors>} */ - deleteMfaAuthenticator(type: AuthenticatorType): Promise<{}> { - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); - } - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); + listMFAFactors(): Promise<Models.MfaFactors> { + + const apiPath = '/account/mfa/factors'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', } return this.client.call( - 'delete', + 'get', uri, apiHeaders, payload, @@ -341,29 +1050,23 @@ export class Account { } /** - * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. + * 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. * - * @param {AuthenticationFactor} factor * @throws {AppwriteException} - * @returns {Promise<Models.MfaChallenge>} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead. */ - createMfaChallenge(factor: AuthenticationFactor): Promise<Models.MfaChallenge> { - if (typeof factor === 'undefined') { - throw new AppwriteException('Missing required parameter: "factor"'); - } - const apiPath = '/account/mfa/challenge'; + getMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + + const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; - if (typeof factor !== 'undefined') { - payload['factor'] = factor; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', } return this.client.call( - 'post', + 'get', uri, apiHeaders, payload, @@ -371,36 +1074,22 @@ export class Account { } /** - * 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. + * 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. * - * @param {string} challengeId - * @param {string} otp * @throws {AppwriteException} - * @returns {Promise<Models.Session>} + * @returns {Promise<Models.MfaRecoveryCodes>} */ - updateMfaChallenge(challengeId: string, otp: string): Promise<Models.Session> { - if (typeof challengeId === 'undefined') { - throw new AppwriteException('Missing required parameter: "challengeId"'); - } - if (typeof otp === 'undefined') { - throw new AppwriteException('Missing required parameter: "otp"'); - } - const apiPath = '/account/mfa/challenge'; + getMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + + const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; - if (typeof challengeId !== 'undefined') { - payload['challengeId'] = challengeId; - } - if (typeof otp !== 'undefined') { - payload['otp'] = otp; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', } return this.client.call( - 'put', + 'get', uri, apiHeaders, payload, @@ -408,21 +1097,24 @@ export class Account { } /** - * List the factors available on the account to be used as a MFA challange. + * 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. * * @throws {AppwriteException} - * @returns {Promise<Models.MfaFactors>} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead. */ - listMfaFactors(): Promise<Models.MfaFactors> { - const apiPath = '/account/mfa/factors'; + createMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + + const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', } return this.client.call( - 'get', + 'post', uri, apiHeaders, payload, @@ -430,21 +1122,23 @@ export class Account { } /** - * 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. + * 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. * * @throws {AppwriteException} * @returns {Promise<Models.MfaRecoveryCodes>} */ - getMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + createMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', } return this.client.call( - 'get', + 'post', uri, apiHeaders, payload, @@ -452,12 +1146,14 @@ export class Account { } /** - * 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. + * 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. * * @throws {AppwriteException} * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead. */ - createMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + updateMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -467,7 +1163,7 @@ export class Account { } return this.client.call( - 'post', + 'patch', uri, apiHeaders, payload, @@ -480,7 +1176,8 @@ export class Account { * @throws {AppwriteException} * @returns {Promise<Models.MfaRecoveryCodes>} */ - updateMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + updateMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -500,14 +1197,39 @@ export class Account { /** * Update currently logged in user account name. * - * @param {string} name + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { name: string }): Promise<Models.User<Preferences>>; + /** + * Update currently logged in user account name. + * + * @param {string} name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(name: string): Promise<Models.User<Preferences>> { + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(name: string): Promise<Models.User<Preferences>>; + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { name: string } | string + ): Promise<Models.User<Preferences>> { + let params: { name: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { name: string }; + } else { + params = { + name: paramsOrFirst as string + }; + } + + const name = params.name; + if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/account/name'; const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -530,15 +1252,44 @@ export class Account { /** * 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. * - * @param {string} password - * @param {string} oldPassword + * @param {string} params.password - New user password. Must be at least 8 chars. + * @param {string} params.oldPassword - Current user password. Must be at least 8 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { password: string, oldPassword?: string }): Promise<Models.User<Preferences>>; + /** + * 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. + * + * @param {string} password - New user password. Must be at least 8 chars. + * @param {string} oldPassword - Current user password. Must be at least 8 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>(password: string, oldPassword?: string): Promise<Models.User<Preferences>> { + updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>(password: string, oldPassword?: string): Promise<Models.User<Preferences>>; + updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { password: string, oldPassword?: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { password: string, oldPassword?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { password: string, oldPassword?: string }; + } else { + params = { + password: paramsOrFirst as string, + oldPassword: rest[0] as string + }; + } + + const password = params.password; + const oldPassword = params.oldPassword; + if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/account/password'; const payload: Payload = {}; if (typeof password !== 'undefined') { @@ -562,20 +1313,49 @@ export class Account { } /** - * 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. + * 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. + * + * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.password - User password. Must be at least 8 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { phone: string, password: string }): Promise<Models.User<Preferences>>; + /** + * 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. * - * @param {string} phone - * @param {string} password + * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} password - User password. Must be at least 8 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>(phone: string, password: string): Promise<Models.User<Preferences>> { + updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>(phone: string, password: string): Promise<Models.User<Preferences>>; + updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { phone: string, password: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { phone: string, password: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { phone: string, password: string }; + } else { + params = { + phone: paramsOrFirst as string, + password: rest[0] as string + }; + } + + const phone = params.phone; + const password = params.password; + if (typeof phone === 'undefined') { throw new AppwriteException('Missing required parameter: "phone"'); } if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/account/phone'; const payload: Payload = {}; if (typeof phone !== 'undefined') { @@ -605,6 +1385,7 @@ export class Account { * @returns {Promise<Preferences>} */ getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(): Promise<Preferences> { + const apiPath = '/account/prefs'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -623,14 +1404,39 @@ export class Account { /** * 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. * - * @param {Partial<Preferences>} prefs + * @param {Partial<Preferences>} params.prefs - Prefs key-value JSON object. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { prefs: Partial<Preferences> }): Promise<Models.User<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. + * + * @param {Partial<Preferences>} prefs - Prefs key-value JSON object. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(prefs: Partial<Preferences>): Promise<Models.User<Preferences>> { + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(prefs: Partial<Preferences>): Promise<Models.User<Preferences>>; + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { prefs: Partial<Preferences> } | Partial<Preferences> + ): Promise<Models.User<Preferences>> { + let params: { prefs: Partial<Preferences> }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'prefs' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { prefs: Partial<Preferences> }; + } else { + params = { + prefs: paramsOrFirst as Partial<Preferences> + }; + } + + const prefs = params.prefs; + if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } + const apiPath = '/account/prefs'; const payload: Payload = {}; if (typeof prefs !== 'undefined') { @@ -651,20 +1457,49 @@ export class Account { } /** - * 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. + * 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. + * + * @param {string} params.email - User email. + * @param {string} params.url - URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + */ + createRecovery(params: { email: string, url: string }): Promise<Models.Token>; + /** + * 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. * - * @param {string} email - * @param {string} url + * @param {string} email - User email. + * @param {string} url - URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @throws {AppwriteException} * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createRecovery(email: string, url: string): Promise<Models.Token> { + createRecovery(email: string, url: string): Promise<Models.Token>; + createRecovery( + paramsOrFirst: { email: string, url: string } | string, + ...rest: [(string)?] + ): Promise<Models.Token> { + let params: { email: string, url: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { email: string, url: string }; + } else { + params = { + email: paramsOrFirst as string, + url: rest[0] as string + }; + } + + const email = params.email; + const url = params.url; + if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } + const apiPath = '/account/recovery'; const payload: Payload = {}; if (typeof email !== 'undefined') { @@ -692,13 +1527,46 @@ export class Account { * * 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 - * @param {string} password + * @param {string} params.userId - User ID. + * @param {string} params.secret - Valid reset token. + * @param {string} params.password - New user password. Must be between 8 and 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + */ + updateRecovery(params: { userId: string, secret: string, password: string }): Promise<Models.Token>; + /** + * 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. + * + * @param {string} userId - User ID. + * @param {string} secret - Valid reset token. + * @param {string} password - New user password. Must be between 8 and 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateRecovery(userId: string, secret: string, password: string): Promise<Models.Token> { + updateRecovery(userId: string, secret: string, password: string): Promise<Models.Token>; + updateRecovery( + paramsOrFirst: { userId: string, secret: string, password: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.Token> { + let params: { userId: string, secret: string, password: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, secret: string, password: string }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string, + password: rest[1] as string + }; + } + + const userId = params.userId; + const secret = params.secret; + const password = params.password; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -708,6 +1576,7 @@ export class Account { if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/account/recovery'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -740,6 +1609,7 @@ export class Account { * @returns {Promise<Models.SessionList>} */ listSessions(): Promise<Models.SessionList> { + const apiPath = '/account/sessions'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -762,6 +1632,7 @@ export class Account { * @returns {Promise<{}>} */ deleteSessions(): Promise<{}> { + const apiPath = '/account/sessions'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -785,6 +1656,7 @@ export class Account { * @returns {Promise<Models.Session>} */ createAnonymousSession(): Promise<Models.Session> { + const apiPath = '/account/sessions/anonymous'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -806,18 +1678,49 @@ export class Account { * * 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 + * @param {string} params.email - User email. + * @param {string} params.password - User password. Must be at least 8 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + */ + createEmailPasswordSession(params: { email: string, password: string }): Promise<Models.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. + * + * 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 - User email. + * @param {string} password - User password. Must be at least 8 chars. * @throws {AppwriteException} * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailPasswordSession(email: string, password: string): Promise<Models.Session> { + createEmailPasswordSession(email: string, password: string): Promise<Models.Session>; + createEmailPasswordSession( + paramsOrFirst: { email: string, password: string } | string, + ...rest: [(string)?] + ): Promise<Models.Session> { + let params: { email: string, password: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { email: string, password: string }; + } else { + params = { + email: paramsOrFirst as string, + password: rest[0] as string + }; + } + + const email = params.email; + const password = params.password; + if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/account/sessions/email'; const payload: Payload = {}; if (typeof email !== 'undefined') { @@ -843,18 +1746,48 @@ export class Account { /** * 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. * - * @param {string} userId - * @param {string} secret + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.secret - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + * @deprecated This API has been deprecated. + */ + updateMagicURLSession(params: { userId: string, secret: string }): Promise<Models.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. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} secret - Valid verification token. * @throws {AppwriteException} * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateMagicURLSession(userId: string, secret: string): Promise<Models.Session> { + updateMagicURLSession(userId: string, secret: string): Promise<Models.Session>; + updateMagicURLSession( + paramsOrFirst: { userId: string, secret: string } | string, + ...rest: [(string)?] + ): Promise<Models.Session> { + let params: { userId: string, secret: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, secret: string }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string + }; + } + + const userId = params.userId; + const secret = params.secret; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } + const apiPath = '/account/sessions/magic-url'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -880,18 +1813,48 @@ export class Account { /** * 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. * - * @param {string} userId - * @param {string} secret + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.secret - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + * @deprecated This API has been deprecated. + */ + updatePhoneSession(params: { userId: string, secret: string }): Promise<Models.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. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} secret - Valid verification token. * @throws {AppwriteException} * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhoneSession(userId: string, secret: string): Promise<Models.Session> { + updatePhoneSession(userId: string, secret: string): Promise<Models.Session>; + updatePhoneSession( + paramsOrFirst: { userId: string, secret: string } | string, + ...rest: [(string)?] + ): Promise<Models.Session> { + let params: { userId: string, secret: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, secret: string }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string + }; + } + + const userId = params.userId; + const secret = params.secret; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } + const apiPath = '/account/sessions/phone'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -917,18 +1880,47 @@ export class Account { /** * 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. * - * @param {string} userId - * @param {string} secret + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.secret - Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + */ + createSession(params: { userId: string, secret: string }): Promise<Models.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. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} secret - Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods. * @throws {AppwriteException} * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createSession(userId: string, secret: string): Promise<Models.Session> { + createSession(userId: string, secret: string): Promise<Models.Session>; + createSession( + paramsOrFirst: { userId: string, secret: string } | string, + ...rest: [(string)?] + ): Promise<Models.Session> { + let params: { userId: string, secret: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, secret: string }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string + }; + } + + const userId = params.userId; + const secret = params.secret; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } + const apiPath = '/account/sessions/token'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -952,16 +1944,41 @@ export class Account { } /** - * Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. + * Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. + * + * @param {string} params.sessionId - Session ID. Use the string 'current' to get the current device session. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + */ + getSession(params: { sessionId: string }): Promise<Models.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. * - * @param {string} sessionId + * @param {string} sessionId - Session ID. Use the string 'current' to get the current device session. * @throws {AppwriteException} * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getSession(sessionId: string): Promise<Models.Session> { + getSession(sessionId: string): Promise<Models.Session>; + getSession( + paramsOrFirst: { sessionId: string } | string + ): Promise<Models.Session> { + let params: { sessionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { sessionId: string }; + } else { + params = { + sessionId: paramsOrFirst as string + }; + } + + const sessionId = params.sessionId; + if (typeof sessionId === 'undefined') { throw new AppwriteException('Missing required parameter: "sessionId"'); } + const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -978,16 +1995,41 @@ export class Account { } /** - * 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. + * 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. + * + * @param {string} params.sessionId - Session ID. Use the string 'current' to update the current device session. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + */ + updateSession(params: { sessionId: string }): Promise<Models.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. * - * @param {string} sessionId + * @param {string} sessionId - Session ID. Use the string 'current' to update the current device session. * @throws {AppwriteException} * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateSession(sessionId: string): Promise<Models.Session> { + updateSession(sessionId: string): Promise<Models.Session>; + updateSession( + paramsOrFirst: { sessionId: string } | string + ): Promise<Models.Session> { + let params: { sessionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { sessionId: string }; + } else { + params = { + sessionId: paramsOrFirst as string + }; + } + + const sessionId = params.sessionId; + if (typeof sessionId === 'undefined') { throw new AppwriteException('Missing required parameter: "sessionId"'); } + const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1005,16 +2047,41 @@ export class Account { } /** - * 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. + * 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. + * + * @param {string} params.sessionId - Session ID. Use the string 'current' to delete the current device session. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteSession(params: { sessionId: string }): Promise<{}>; + /** + * 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. * - * @param {string} sessionId + * @param {string} sessionId - Session ID. Use the string 'current' to delete the current device session. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteSession(sessionId: string): Promise<{}> { + deleteSession(sessionId: string): Promise<{}>; + deleteSession( + paramsOrFirst: { sessionId: string } | string + ): Promise<{}> { + let params: { sessionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { sessionId: string }; + } else { + params = { + sessionId: paramsOrFirst as string + }; + } + + const sessionId = params.sessionId; + if (typeof sessionId === 'undefined') { throw new AppwriteException('Missing required parameter: "sessionId"'); } + const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1038,6 +2105,7 @@ export class Account { * @returns {Promise<Models.User<Preferences>>} */ updateStatus<Preferences extends Models.Preferences = Models.DefaultPreferences>(): Promise<Models.User<Preferences>> { + const apiPath = '/account/status'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1055,23 +2123,59 @@ export class Account { } /** - * 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. + * Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. 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). + * + * + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. + * @param {string} params.email - User email. + * @param {boolean} params.phrase - Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + */ + createEmailToken(params: { userId: string, email: string, phrase?: boolean }): Promise<Models.Token>; + /** + * Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. 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). + * * - * @param {string} userId - * @param {string} email - * @param {boolean} phrase + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. + * @param {string} email - User email. + * @param {boolean} phrase - Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. * @throws {AppwriteException} * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailToken(userId: string, email: string, phrase?: boolean): Promise<Models.Token> { + createEmailToken(userId: string, email: string, phrase?: boolean): Promise<Models.Token>; + createEmailToken( + paramsOrFirst: { userId: string, email: string, phrase?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.Token> { + let params: { userId: string, email: string, phrase?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, phrase?: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + phrase: rest[1] as boolean + }; + } + + const userId = params.userId; + const email = params.email; + const phrase = params.phrase; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } + const apiPath = '/account/tokens/email'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -1098,25 +2202,63 @@ export class Account { } /** - * 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. + * 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). + * + * + * @param {string} params.userId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. + * @param {string} params.email - User email. + * @param {string} params.url - URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @param {boolean} params.phrase - Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + */ + createMagicURLToken(params: { userId: string, email: string, url?: string, phrase?: boolean }): Promise<Models.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 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). * * - * @param {string} userId - * @param {string} email - * @param {string} url - * @param {boolean} phrase + * @param {string} userId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. + * @param {string} email - User email. + * @param {string} url - URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @param {boolean} phrase - Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. * @throws {AppwriteException} * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createMagicURLToken(userId: string, email: string, url?: string, phrase?: boolean): Promise<Models.Token> { + createMagicURLToken(userId: string, email: string, url?: string, phrase?: boolean): Promise<Models.Token>; + createMagicURLToken( + paramsOrFirst: { userId: string, email: string, url?: string, phrase?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise<Models.Token> { + let params: { userId: string, email: string, url?: string, phrase?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, url?: string, phrase?: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + url: rest[1] as string, + phrase: rest[2] as boolean + }; + } + + const userId = params.userId; + const email = params.email; + const url = params.url; + const phrase = params.phrase; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } + const apiPath = '/account/tokens/magic-url'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -1146,23 +2288,62 @@ export class Account { } /** - * 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. + * 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). + * + * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<string>} + */ + createOAuth2Token(params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }): Promise<string>; + /** + * 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). * - * @param {OAuthProvider} provider - * @param {string} success - * @param {string} failure - * @param {string[]} scopes + * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. * @throws {AppwriteException} * @returns {Promise<string>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createOAuth2Token(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): Promise<string> { + createOAuth2Token(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): Promise<string>; + createOAuth2Token( + paramsOrFirst: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] } | OAuthProvider, + ...rest: [(string)?, (string)?, (string[])?] + ): Promise<string> { + let params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] }; + } else { + params = { + provider: paramsOrFirst as OAuthProvider, + success: rest[0] as string, + failure: rest[1] as string, + scopes: rest[2] as string[] + }; + } + + const provider = params.provider; + const success = params.success; + const failure = params.failure; + const scopes = params.scopes; + if (typeof provider === 'undefined') { throw new AppwriteException('Missing required parameter: "provider"'); } + const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', provider); const payload: Payload = {}; if (typeof success !== 'undefined') { @@ -1188,22 +2369,53 @@ export class Account { } /** - * 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. + * 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). + * + * @param {string} params.userId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored. + * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + */ + createPhoneToken(params: { userId: string, phone: string }): Promise<Models.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 /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). * - * @param {string} userId - * @param {string} phone + * @param {string} userId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored. + * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @throws {AppwriteException} * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createPhoneToken(userId: string, phone: string): Promise<Models.Token> { + createPhoneToken(userId: string, phone: string): Promise<Models.Token>; + createPhoneToken( + paramsOrFirst: { userId: string, phone: string } | string, + ...rest: [(string)?] + ): Promise<Models.Token> { + let params: { userId: string, phone: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, phone: string }; + } else { + params = { + userId: paramsOrFirst as string, + phone: rest[0] as string + }; + } + + const userId = params.userId; + const phone = params.phone; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof phone === 'undefined') { throw new AppwriteException('Missing required parameter: "phone"'); } + const apiPath = '/account/tokens/phone'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -1227,19 +2439,47 @@ export class Account { } /** - * 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. + * 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. + * + * + * @param {string} params.url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + */ + createVerification(params: { url: string }): Promise<Models.Token>; + /** + * 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. * * - * @param {string} url + * @param {string} url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @throws {AppwriteException} * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createVerification(url: string): Promise<Models.Token> { + createVerification(url: string): Promise<Models.Token>; + createVerification( + paramsOrFirst: { url: string } | string + ): Promise<Models.Token> { + let params: { url: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { url: string }; + } else { + params = { + url: paramsOrFirst as string + }; + } + + const url = params.url; + if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } + const apiPath = '/account/verification'; const payload: Payload = {}; if (typeof url !== 'undefined') { @@ -1262,18 +2502,47 @@ export class Account { /** * 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. * - * @param {string} userId - * @param {string} secret + * @param {string} params.userId - User ID. + * @param {string} params.secret - Valid verification token. * @throws {AppwriteException} * @returns {Promise<Models.Token>} */ - updateVerification(userId: string, secret: string): Promise<Models.Token> { + updateVerification(params: { userId: string, secret: string }): Promise<Models.Token>; + /** + * 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. + * + * @param {string} userId - User ID. + * @param {string} secret - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateVerification(userId: string, secret: string): Promise<Models.Token>; + updateVerification( + paramsOrFirst: { userId: string, secret: string } | string, + ...rest: [(string)?] + ): Promise<Models.Token> { + let params: { userId: string, secret: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, secret: string }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string + }; + } + + const userId = params.userId; + const secret = params.secret; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } + const apiPath = '/account/verification'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -1297,12 +2566,13 @@ export class Account { } /** - * 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. + * 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. * * @throws {AppwriteException} * @returns {Promise<Models.Token>} */ createPhoneVerification(): Promise<Models.Token> { + const apiPath = '/account/verification/phone'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1320,20 +2590,49 @@ export class Account { } /** - * 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. + * 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. + * + * @param {string} params.userId - User ID. + * @param {string} params.secret - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + */ + updatePhoneVerification(params: { userId: string, secret: string }): Promise<Models.Token>; + /** + * 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. * - * @param {string} userId - * @param {string} secret + * @param {string} userId - User ID. + * @param {string} secret - Valid verification token. * @throws {AppwriteException} * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhoneVerification(userId: string, secret: string): Promise<Models.Token> { + updatePhoneVerification(userId: string, secret: string): Promise<Models.Token>; + updatePhoneVerification( + paramsOrFirst: { userId: string, secret: string } | string, + ...rest: [(string)?] + ): Promise<Models.Token> { + let params: { userId: string, secret: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, secret: string }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string + }; + } + + const userId = params.userId; + const secret = params.secret; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } + const apiPath = '/account/verification/phone'; const payload: Payload = {}; if (typeof userId !== 'undefined') { diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 1ef7d79..07071c0 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -1,5 +1,6 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { Browser } from '../enums/browser'; import { CreditCard } from '../enums/credit-card'; import { Flag } from '../enums/flag'; @@ -16,17 +17,54 @@ export class Avatars { * * 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 - * @param {number} height - * @param {number} quality + * @param {Browser} params.code - Browser Code. + * @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} params.height - Image height. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} params.quality - Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + */ + getBrowser(params: { code: Browser, width?: number, height?: number, quality?: number }): Promise<ArrayBuffer>; + /** + * 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. + * + * @param {Browser} code - Browser Code. + * @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} height - Image height. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} quality - Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getBrowser(code: Browser, width?: number, height?: number, quality?: number): Promise<ArrayBuffer> { + getBrowser(code: Browser, width?: number, height?: number, quality?: number): Promise<ArrayBuffer>; + getBrowser( + paramsOrFirst: { code: Browser, width?: number, height?: number, quality?: number } | Browser, + ...rest: [(number)?, (number)?, (number)?] + ): Promise<ArrayBuffer> { + let params: { code: Browser, width?: number, height?: number, quality?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { code: Browser, width?: number, height?: number, quality?: number }; + } else { + params = { + code: paramsOrFirst as Browser, + width: rest[0] as number, + height: rest[1] as number, + quality: rest[2] as number + }; + } + + const code = params.code; + const width = params.width; + const height = params.height; + const quality = params.quality; + if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } + const apiPath = '/avatars/browsers/{code}'.replace('{code}', code); const payload: Payload = {}; if (typeof width !== 'undefined') { @@ -58,17 +96,55 @@ export class Avatars { * 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 - * @param {number} height - * @param {number} quality + * @param {CreditCard} params.code - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. + * @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} params.height - Image height. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} params.quality - Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + */ + getCreditCard(params: { code: CreditCard, width?: number, height?: number, quality?: number }): Promise<ArrayBuffer>; + /** + * 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. + * + * + * @param {CreditCard} code - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. + * @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} height - Image height. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} quality - Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): Promise<ArrayBuffer> { + getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): Promise<ArrayBuffer>; + getCreditCard( + paramsOrFirst: { code: CreditCard, width?: number, height?: number, quality?: number } | CreditCard, + ...rest: [(number)?, (number)?, (number)?] + ): Promise<ArrayBuffer> { + let params: { code: CreditCard, width?: number, height?: number, quality?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { code: CreditCard, width?: number, height?: number, quality?: number }; + } else { + params = { + code: paramsOrFirst as CreditCard, + width: rest[0] as number, + height: rest[1] as number, + quality: rest[2] as number + }; + } + + const code = params.code; + const width = params.width; + const height = params.height; + const quality = params.quality; + if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } + const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code); const payload: Payload = {}; if (typeof width !== 'undefined') { @@ -99,14 +175,41 @@ export class Avatars { * * This endpoint does not follow HTTP redirects. * - * @param {string} url + * @param {string} params.url - Website URL which you want to fetch the favicon from. * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} */ - getFavicon(url: string): Promise<ArrayBuffer> { + getFavicon(params: { url: string }): Promise<ArrayBuffer>; + /** + * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. + * + * This endpoint does not follow HTTP redirects. + * + * @param {string} url - Website URL which you want to fetch the favicon from. + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getFavicon(url: string): Promise<ArrayBuffer>; + getFavicon( + paramsOrFirst: { url: string } | string + ): Promise<ArrayBuffer> { + let params: { url: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { url: string }; + } else { + params = { + url: paramsOrFirst as string + }; + } + + const url = params.url; + if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } + const apiPath = '/avatars/favicon'; const payload: Payload = {}; if (typeof url !== 'undefined') { @@ -132,17 +235,55 @@ export class Avatars { * 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 - * @param {number} height - * @param {number} quality + * @param {Flag} params.code - Country Code. ISO Alpha-2 country code format. + * @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} params.height - Image height. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} params.quality - Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} */ - getFlag(code: Flag, width?: number, height?: number, quality?: number): Promise<ArrayBuffer> { + getFlag(params: { code: Flag, width?: number, height?: number, quality?: number }): Promise<ArrayBuffer>; + /** + * 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. + * + * + * @param {Flag} code - Country Code. ISO Alpha-2 country code format. + * @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} height - Image height. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} quality - Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getFlag(code: Flag, width?: number, height?: number, quality?: number): Promise<ArrayBuffer>; + getFlag( + paramsOrFirst: { code: Flag, width?: number, height?: number, quality?: number } | Flag, + ...rest: [(number)?, (number)?, (number)?] + ): Promise<ArrayBuffer> { + let params: { code: Flag, width?: number, height?: number, quality?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { code: Flag, width?: number, height?: number, quality?: number }; + } else { + params = { + code: paramsOrFirst as Flag, + width: rest[0] as number, + height: rest[1] as number, + quality: rest[2] as number + }; + } + + const code = params.code; + const width = params.width; + const height = params.height; + const quality = params.quality; + if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } + const apiPath = '/avatars/flags/{code}'.replace('{code}', code); const payload: Payload = {}; if (typeof width !== 'undefined') { @@ -175,16 +316,52 @@ export class Avatars { * * This endpoint does not follow HTTP redirects. * - * @param {string} url - * @param {number} width - * @param {number} height + * @param {string} params.url - Image URL which you want to crop. + * @param {number} params.width - Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400. + * @param {number} params.height - Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400. * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} */ - getImage(url: string, width?: number, height?: number): Promise<ArrayBuffer> { + getImage(params: { url: string, width?: number, height?: number }): Promise<ArrayBuffer>; + /** + * 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. + * + * @param {string} url - Image URL which you want to crop. + * @param {number} width - Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400. + * @param {number} height - Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400. + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getImage(url: string, width?: number, height?: number): Promise<ArrayBuffer>; + getImage( + paramsOrFirst: { url: string, width?: number, height?: number } | string, + ...rest: [(number)?, (number)?] + ): Promise<ArrayBuffer> { + let params: { url: string, width?: number, height?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { url: string, width?: number, height?: number }; + } else { + params = { + url: paramsOrFirst as string, + width: rest[0] as number, + height: rest[1] as number + }; + } + + const url = params.url; + const width = params.width; + const height = params.height; + if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } + const apiPath = '/avatars/image'; const payload: Payload = {}; if (typeof url !== 'undefined') { @@ -211,21 +388,61 @@ export class Avatars { } /** - * 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. + * 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. + * 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 - * @param {number} height - * @param {string} background + * @param {string} params.name - Full Name. When empty, current user name or email will be used. Max length: 128 chars. + * @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} params.height - Image height. Pass an integer between 0 to 2000. Defaults to 100. + * @param {string} params.background - Changes background color. By default a random color will be picked and stay will persistent to the given name. * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} */ - getInitials(name?: string, width?: number, height?: number, background?: string): Promise<ArrayBuffer> { + getInitials(params?: { name?: string, width?: number, height?: number, background?: string }): Promise<ArrayBuffer>; + /** + * 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. + * + * + * @param {string} name - Full Name. When empty, current user name or email will be used. Max length: 128 chars. + * @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100. + * @param {number} height - Image height. Pass an integer between 0 to 2000. Defaults to 100. + * @param {string} background - Changes background color. By default a random color will be picked and stay will persistent to the given name. + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getInitials(name?: string, width?: number, height?: number, background?: string): Promise<ArrayBuffer>; + getInitials( + paramsOrFirst?: { name?: string, width?: number, height?: number, background?: string } | string, + ...rest: [(number)?, (number)?, (string)?] + ): Promise<ArrayBuffer> { + let params: { name?: string, width?: number, height?: number, background?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { name?: string, width?: number, height?: number, background?: string }; + } else { + params = { + name: paramsOrFirst as string, + width: rest[0] as number, + height: rest[1] as number, + background: rest[2] as string + }; + } + + const name = params.name; + const width = params.width; + const height = params.height; + const background = params.background; + + const apiPath = '/avatars/initials'; const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -258,17 +475,53 @@ export class Avatars { * 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 - * @param {number} margin - * @param {boolean} download + * @param {string} params.text - Plain text to be converted to QR code image. + * @param {number} params.size - QR code size. Pass an integer between 1 to 1000. Defaults to 400. + * @param {number} params.margin - Margin from edge. Pass an integer between 0 to 10. Defaults to 1. + * @param {boolean} params.download - Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0. * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} */ - getQR(text: string, size?: number, margin?: number, download?: boolean): Promise<ArrayBuffer> { + getQR(params: { text: string, size?: number, margin?: number, download?: boolean }): Promise<ArrayBuffer>; + /** + * 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 - Plain text to be converted to QR code image. + * @param {number} size - QR code size. Pass an integer between 1 to 1000. Defaults to 400. + * @param {number} margin - Margin from edge. Pass an integer between 0 to 10. Defaults to 1. + * @param {boolean} download - Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0. + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQR(text: string, size?: number, margin?: number, download?: boolean): Promise<ArrayBuffer>; + getQR( + paramsOrFirst: { text: string, size?: number, margin?: number, download?: boolean } | string, + ...rest: [(number)?, (number)?, (boolean)?] + ): Promise<ArrayBuffer> { + let params: { text: string, size?: number, margin?: number, download?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { text: string, size?: number, margin?: number, download?: boolean }; + } else { + params = { + text: paramsOrFirst as string, + size: rest[0] as number, + margin: rest[1] as number, + download: rest[2] as boolean + }; + } + + const text = params.text; + const size = params.size; + const margin = params.margin; + const download = params.download; + if (typeof text === 'undefined') { throw new AppwriteException('Missing required parameter: "text"'); } + const apiPath = '/avatars/qr'; const payload: Payload = {}; if (typeof text !== 'undefined') { diff --git a/src/services/databases.ts b/src/services/databases.ts index 628239a..ad1cb92 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,5 +1,6 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; import { IndexType } from '../enums/index-type'; @@ -14,12 +15,42 @@ export class Databases { /** * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * - * @param {string[]} queries - * @param {string} search + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.DatabaseList>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.list` instead. + */ + list(params?: { queries?: string[], search?: string }): Promise<Models.DatabaseList>; + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.DatabaseList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string): Promise<Models.DatabaseList> { + list(queries?: string[], search?: string): Promise<Models.DatabaseList>; + list( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.DatabaseList> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + const apiPath = '/databases'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -45,19 +76,53 @@ export class Databases { * Create a new Database. * * - * @param {string} databaseId - * @param {string} name - * @param {boolean} enabled + * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createDatabase` instead. + */ + create(params: { databaseId: string, name: string, enabled?: boolean }): Promise<Models.Database>; + /** + * Create a new Database. + * + * + * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @throws {AppwriteException} * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database> { + create(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database>; + create( + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.Database> { + let params: { databaseId: string, name: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/databases'; const payload: Payload = {}; if (typeof databaseId !== 'undefined') { @@ -86,14 +151,40 @@ export class Databases { /** * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. * - * @param {string} databaseId + * @param {string} params.databaseId - Database ID. * @throws {AppwriteException} * @returns {Promise<Models.Database>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.get` instead. */ - get(databaseId: string): Promise<Models.Database> { + get(params: { databaseId: string }): Promise<Models.Database>; + /** + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(databaseId: string): Promise<Models.Database>; + get( + paramsOrFirst: { databaseId: string } | string + ): Promise<Models.Database> { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } + const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -112,19 +203,52 @@ export class Databases { /** * Update a database by its unique ID. * - * @param {string} databaseId - * @param {string} name - * @param {boolean} enabled + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @throws {AppwriteException} * @returns {Promise<Models.Database>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.update` instead. */ - update(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database> { + update(params: { databaseId: string, name: string, enabled?: boolean }): Promise<Models.Database>; + /** + * Update a database by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database>; + update( + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.Database> { + let params: { databaseId: string, name: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -150,14 +274,40 @@ export class Databases { /** * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. * - * @param {string} databaseId + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.delete` instead. + */ + delete(params: { databaseId: string }): Promise<{}>; + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} databaseId - Database ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - delete(databaseId: string): Promise<{}> { + delete(databaseId: string): Promise<{}>; + delete( + paramsOrFirst: { databaseId: string } | string + ): Promise<{}> { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } + const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -177,16 +327,49 @@ export class Databases { /** * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. * - * @param {string} databaseId - * @param {string[]} queries - * @param {string} search + * @param {string} params.databaseId - Database ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.CollectionList>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listTables` instead. */ - listCollections(databaseId: string, queries?: string[], search?: string): Promise<Models.CollectionList> { + listCollections(params: { databaseId: string, queries?: string[], search?: string }): Promise<Models.CollectionList>; + /** + * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} databaseId - Database ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.CollectionList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listCollections(databaseId: string, queries?: string[], search?: string): Promise<Models.CollectionList>; + listCollections( + paramsOrFirst: { databaseId: string, queries?: string[], search?: string } | string, + ...rest: [(string[])?, (string)?] + ): Promise<Models.CollectionList> { + let params: { databaseId: string, queries?: string[], search?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + const search = params.search; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } + const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -211,16 +394,57 @@ export class Databases { /** * Create a new Collection. Before using this route, you should create a new database 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} name - * @param {string[]} permissions - * @param {boolean} documentSecurity - * @param {boolean} enabled + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Collection name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Collection>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead. + */ + createCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise<Models.Collection>; + /** + * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Collection name. Max length: 128 chars. + * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. * @throws {AppwriteException} * @returns {Promise<Models.Collection>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise<Models.Collection> { + createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise<Models.Collection>; + createCollection( + paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?] + ): Promise<Models.Collection> { + let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + documentSecurity: rest[3] as boolean, + enabled: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -230,6 +454,7 @@ export class Databases { if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); const payload: Payload = {}; if (typeof collectionId !== 'undefined') { @@ -264,18 +489,48 @@ export class Databases { /** * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. * - * @param {string} databaseId - * @param {string} collectionId + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. * @throws {AppwriteException} * @returns {Promise<Models.Collection>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getTable` instead. */ - getCollection(databaseId: string, collectionId: string): Promise<Models.Collection> { + getCollection(params: { databaseId: string, collectionId: string }): Promise<Models.Collection>; + /** + * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Collection>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getCollection(databaseId: string, collectionId: string): Promise<Models.Collection>; + getCollection( + paramsOrFirst: { databaseId: string, collectionId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Collection> { + let params: { databaseId: string, collectionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } if (typeof collectionId === 'undefined') { throw new AppwriteException('Missing required parameter: "collectionId"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -294,16 +549,57 @@ export class Databases { /** * Update a collection by its unique ID. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} name - * @param {string[]} permissions - * @param {boolean} documentSecurity - * @param {boolean} enabled + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.name - Collection name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Collection>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTable` instead. + */ + updateCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise<Models.Collection>; + /** + * Update a collection by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} name - Collection name. Max length: 128 chars. + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. * @throws {AppwriteException} * @returns {Promise<Models.Collection>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise<Models.Collection> { + updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise<Models.Collection>; + updateCollection( + paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?] + ): Promise<Models.Collection> { + let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + documentSecurity: rest[3] as boolean, + enabled: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -313,6 +609,7 @@ export class Databases { if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -344,18 +641,48 @@ export class Databases { /** * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. * - * @param {string} databaseId - * @param {string} collectionId + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTable` instead. + */ + deleteCollection(params: { databaseId: string, collectionId: string }): Promise<{}>; + /** + * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteCollection(databaseId: string, collectionId: string): Promise<{}> { + deleteCollection(databaseId: string, collectionId: string): Promise<{}>; + deleteCollection( + paramsOrFirst: { databaseId: string, collectionId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } if (typeof collectionId === 'undefined') { throw new AppwriteException('Missing required parameter: "collectionId"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -375,19 +702,52 @@ export class Databases { /** * List attributes in the collection. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string[]} queries + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, size, required, array, status, error * @throws {AppwriteException} * @returns {Promise<Models.AttributeList>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listColumns` instead. */ - listAttributes(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.AttributeList> { + listAttributes(params: { databaseId: string, collectionId: string, queries?: string[] }): Promise<Models.AttributeList>; + /** + * List attributes in the collection. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, size, required, array, status, error + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listAttributes(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.AttributeList>; + listAttributes( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.AttributeList> { + let params: { databaseId: string, collectionId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } if (typeof collectionId === 'undefined') { throw new AppwriteException('Missing required parameter: "collectionId"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -410,16 +770,58 @@ export class Databases { * Create a boolean attribute. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {boolean} xdefault - * @param {boolean} array + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBoolean>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBooleanColumn` instead. + */ + createBooleanAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }): Promise<Models.AttributeBoolean>; + /** + * Create a boolean attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise<Models.AttributeBoolean> { + createBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise<Models.AttributeBoolean>; + createBooleanAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (boolean)?] + ): Promise<Models.AttributeBoolean> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as boolean, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -432,6 +834,7 @@ export class Databases { if (typeof required === 'undefined') { throw new AppwriteException('Missing required parameter: "required"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -463,16 +866,57 @@ export class Databases { /** * Update a boolean attribute. Changing the `default` value will not update already existing documents. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {boolean} xdefault - * @param {string} newKey + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead. */ - updateBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise<Models.AttributeBoolean> { + updateBooleanAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }): Promise<Models.AttributeBoolean>; + /** + * Update a boolean attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBoolean>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise<Models.AttributeBoolean>; + updateBooleanAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (string)?] + ): Promise<Models.AttributeBoolean> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as boolean, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -488,6 +932,7 @@ export class Databases { if (typeof xdefault === 'undefined') { throw new AppwriteException('Missing required parameter: "xdefault"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; if (typeof required !== 'undefined') { @@ -516,16 +961,57 @@ export class Databases { /** * Create a date time attribute according to the ISO 8601 standard. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createDatetimeColumn` instead. */ - createDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeDatetime> { + createDatetimeAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.AttributeDatetime>; + /** + * Create a date time attribute according to the ISO 8601 standard. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeDatetime>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeDatetime>; + createDatetimeAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.AttributeDatetime> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -538,6 +1024,7 @@ export class Databases { if (typeof required === 'undefined') { throw new AppwriteException('Missing required parameter: "required"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -569,16 +1056,57 @@ export class Databases { /** * Update a date time attribute. Changing the `default` value will not update already existing documents. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {string} newKey + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeDatetime>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead. + */ + updateDatetimeAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeDatetime>; + /** + * Update a date time attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeDatetime> { + updateDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeDatetime>; + updateDatetimeAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeDatetime> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -594,6 +1122,7 @@ export class Databases { if (typeof xdefault === 'undefined') { throw new AppwriteException('Missing required parameter: "xdefault"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; if (typeof required !== 'undefined') { @@ -623,16 +1152,58 @@ export class Databases { * Create an email attribute. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEmail>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createEmailColumn` instead. + */ + createEmailAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.AttributeEmail>; + /** + * Create an email attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeEmail> { + createEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeEmail>; + createEmailAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.AttributeEmail> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -645,6 +1216,7 @@ export class Databases { if (typeof required === 'undefined') { throw new AppwriteException('Missing required parameter: "required"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -677,16 +1249,58 @@ export class Databases { * Update an email attribute. Changing the `default` value will not update already existing documents. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {string} newKey + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead. */ - updateEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeEmail> { + updateEmailAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeEmail>; + /** + * Update an email attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEmail>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeEmail>; + updateEmailAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeEmail> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -702,6 +1316,7 @@ export class Databases { if (typeof xdefault === 'undefined') { throw new AppwriteException('Missing required parameter: "xdefault"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; if (typeof required !== 'undefined') { @@ -728,20 +1343,65 @@ export class Databases { } /** - * Create an enumeration attribute. The `elements` param acts as a white-list of accepted values for this attribute. + * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {string[]} params.elements - Array of enum values. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEnum>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createEnumColumn` instead. + */ + createEnumAttribute(params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }): Promise<Models.AttributeEnum>; + /** + * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {string[]} elements - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {string[]} elements - Array of enum values. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeEnum> { + createEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeEnum>; + createEnumAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.AttributeEnum> { + let params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + elements: rest[2] as string[], + required: rest[3] as boolean, + xdefault: rest[4] as string, + array: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const elements = params.elements; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -757,6 +1417,7 @@ export class Databases { if (typeof required === 'undefined') { throw new AppwriteException('Missing required parameter: "required"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -792,17 +1453,62 @@ export class Databases { * Update an enum attribute. Changing the `default` value will not update already existing documents. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {string[]} elements - * @param {boolean} required - * @param {string} xdefault - * @param {string} newKey + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {string[]} params.elements - Updated list of enum values. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEnum>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead. + */ + updateEnumAttribute(params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeEnum>; + /** + * Update an enum attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {string[]} elements - Updated list of enum values. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeEnum> { + updateEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeEnum>; + updateEnumAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeEnum> { + let params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + elements: rest[2] as string[], + required: rest[3] as boolean, + xdefault: rest[4] as string, + newKey: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const elements = params.elements; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -821,6 +1527,7 @@ export class Databases { if (typeof xdefault === 'undefined') { throw new AppwriteException('Missing required parameter: "xdefault"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; if (typeof elements !== 'undefined') { @@ -853,18 +1560,66 @@ export class Databases { * Create a float attribute. Optionally, minimum and maximum values can be provided. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {number} min - * @param {number} max - * @param {number} xdefault - * @param {boolean} array + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number} params.min - Minimum value. + * @param {number} params.max - Maximum value. + * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createFloatColumn` instead. */ - createFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.AttributeFloat> { + createFloatAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise<Models.AttributeFloat>; + /** + * Create a float attribute. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number} min - Minimum value. + * @param {number} max - Maximum value. + * @param {number} xdefault - Default value. Cannot be set when required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeFloat>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.AttributeFloat>; + createFloatAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + ): Promise<Models.AttributeFloat> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number, + max: rest[4] as number, + xdefault: rest[5] as number, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -877,6 +1632,7 @@ export class Databases { if (typeof required === 'undefined') { throw new AppwriteException('Missing required parameter: "required"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -915,18 +1671,66 @@ export class Databases { * Update a float attribute. Changing the `default` value will not update already existing documents. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {number} xdefault - * @param {number} min - * @param {number} max - * @param {string} newKey + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number} params.min - Minimum value. + * @param {number} params.max - Maximum value. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeFloat>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead. + */ + updateFloatAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise<Models.AttributeFloat>; + /** + * Update a float attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number} min - Minimum value. + * @param {number} max - Maximum value. + * @param {string} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.AttributeFloat> { + updateFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.AttributeFloat>; + updateFloatAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + ): Promise<Models.AttributeFloat> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number, + min: rest[4] as number, + max: rest[5] as number, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -942,6 +1746,7 @@ export class Databases { if (typeof xdefault === 'undefined') { throw new AppwriteException('Missing required parameter: "xdefault"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; if (typeof required !== 'undefined') { @@ -977,18 +1782,66 @@ export class Databases { * Create an integer attribute. Optionally, minimum and maximum values can be provided. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {number} min - * @param {number} max - * @param {number} xdefault - * @param {boolean} array + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number} params.min - Minimum value + * @param {number} params.max - Maximum value + * @param {number} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIntegerColumn` instead. */ - createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.AttributeInteger> { + createIntegerAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise<Models.AttributeInteger>; + /** + * Create an integer attribute. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number} min - Minimum value + * @param {number} max - Maximum value + * @param {number} xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeInteger>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.AttributeInteger>; + createIntegerAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + ): Promise<Models.AttributeInteger> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number, + max: rest[4] as number, + xdefault: rest[5] as number, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1001,6 +1854,7 @@ export class Databases { if (typeof required === 'undefined') { throw new AppwriteException('Missing required parameter: "required"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -1039,18 +1893,66 @@ export class Databases { * Update an integer attribute. Changing the `default` value will not update already existing documents. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {number} xdefault - * @param {number} min - * @param {number} max - * @param {string} newKey + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number} params.min - Minimum value + * @param {number} params.max - Maximum value + * @param {string} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. */ - updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.AttributeInteger> { + updateIntegerAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise<Models.AttributeInteger>; + /** + * Update an integer attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number} xdefault - Default value. Cannot be set when attribute is required. + * @param {number} min - Minimum value + * @param {number} max - Maximum value + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeInteger>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.AttributeInteger>; + updateIntegerAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + ): Promise<Models.AttributeInteger> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number, + min: rest[4] as number, + max: rest[5] as number, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1066,6 +1968,7 @@ export class Databases { if (typeof xdefault === 'undefined') { throw new AppwriteException('Missing required parameter: "xdefault"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; if (typeof required !== 'undefined') { @@ -1101,16 +2004,58 @@ export class Databases { * Create IP address attribute. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIpColumn` instead. */ - createIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeIp> { + createIpAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.AttributeIp>; + /** + * Create IP address attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeIp>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeIp>; + createIpAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.AttributeIp> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1123,6 +2068,7 @@ export class Databases { if (typeof required === 'undefined') { throw new AppwriteException('Missing required parameter: "required"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -1155,16 +2101,58 @@ export class Databases { * Update an ip attribute. Changing the `default` value will not update already existing documents. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {string} newKey + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeIp>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead. + */ + updateIpAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeIp>; + /** + * Update an ip attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeIp> { + updateIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeIp>; + updateIpAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeIp> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1180,6 +2168,7 @@ export class Databases { if (typeof xdefault === 'undefined') { throw new AppwriteException('Missing required parameter: "xdefault"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; if (typeof required !== 'undefined') { @@ -1209,18 +2198,66 @@ export class Databases { * Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} relatedCollectionId - * @param {RelationshipType} type - * @param {boolean} twoWay - * @param {string} key - * @param {string} twoWayKey - * @param {RelationMutate} onDelete + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.relatedCollectionId - Related Collection ID. + * @param {RelationshipType} params.type - Relation type + * @param {boolean} params.twoWay - Is Two Way? + * @param {string} params.key - Attribute Key. + * @param {string} params.twoWayKey - Two Way Attribute Key. + * @param {RelationMutate} params.onDelete - Constraints option * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRelationshipColumn` instead. */ - createRelationshipAttribute(databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise<Models.AttributeRelationship> { + createRelationshipAttribute(params: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }): Promise<Models.AttributeRelationship>; + /** + * Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} relatedCollectionId - Related Collection ID. + * @param {RelationshipType} type - Relation type + * @param {boolean} twoWay - Is Two Way? + * @param {string} key - Attribute Key. + * @param {string} twoWayKey - Two Way Attribute Key. + * @param {RelationMutate} onDelete - Constraints option + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeRelationship>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRelationshipAttribute(databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise<Models.AttributeRelationship>; + createRelationshipAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate } | string, + ...rest: [(string)?, (string)?, (RelationshipType)?, (boolean)?, (string)?, (string)?, (RelationMutate)?] + ): Promise<Models.AttributeRelationship> { + let params: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + relatedCollectionId: rest[1] as string, + type: rest[2] as RelationshipType, + twoWay: rest[3] as boolean, + key: rest[4] as string, + twoWayKey: rest[5] as string, + onDelete: rest[6] as RelationMutate + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const relatedCollectionId = params.relatedCollectionId; + const type = params.type; + const twoWay = params.twoWay; + const key = params.key; + const twoWayKey = params.twoWayKey; + const onDelete = params.onDelete; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1233,6 +2270,7 @@ export class Databases { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof relatedCollectionId !== 'undefined') { @@ -1271,18 +2309,66 @@ export class Databases { * Create a string attribute. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {number} size - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @param {boolean} encrypt + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {number} params.size - Attribute size for text attributes, in number of characters. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createStringColumn` instead. */ - createStringAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.AttributeString> { + createStringAttribute(params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.AttributeString>; + /** + * Create a string attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {number} size - Attribute size for text attributes, in number of characters. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeString>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createStringAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.AttributeString>; + createStringAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.AttributeString> { + let params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + size: rest[2] as number, + required: rest[3] as boolean, + xdefault: rest[4] as string, + array: rest[5] as boolean, + encrypt: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const size = params.size; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1298,6 +2384,7 @@ export class Databases { if (typeof required === 'undefined') { throw new AppwriteException('Missing required parameter: "required"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -1336,17 +2423,62 @@ export class Databases { * Update a string attribute. Changing the `default` value will not update already existing documents. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {number} size - * @param {string} newKey + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number} params.size - Maximum size of the string attribute. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeString>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead. + */ + updateStringAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise<Models.AttributeString>; + /** + * Update a string attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number} size - Maximum size of the string attribute. + * @param {string} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateStringAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise<Models.AttributeString> { + updateStringAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise<Models.AttributeString>; + updateStringAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + ): Promise<Models.AttributeString> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + size: rest[4] as number, + newKey: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const size = params.size; + const newKey = params.newKey; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1362,6 +2494,7 @@ export class Databases { if (typeof xdefault === 'undefined') { throw new AppwriteException('Missing required parameter: "xdefault"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; if (typeof required !== 'undefined') { @@ -1394,16 +2527,58 @@ export class Databases { * Create a URL attribute. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeUrl>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createUrlColumn` instead. + */ + createUrlAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.AttributeUrl>; + /** + * Create a URL attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeUrl> { + createUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeUrl>; + createUrlAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.AttributeUrl> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1416,6 +2591,7 @@ export class Databases { if (typeof required === 'undefined') { throw new AppwriteException('Missing required parameter: "required"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -1448,16 +2624,58 @@ export class Databases { * Update an url attribute. Changing the `default` value will not update already existing documents. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {string} newKey + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead. */ - updateUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeUrl> { + updateUrlAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeUrl>; + /** + * Update an url attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeUrl>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeUrl>; + updateUrlAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeUrl> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1473,6 +2691,7 @@ export class Databases { if (typeof xdefault === 'undefined') { throw new AppwriteException('Missing required parameter: "xdefault"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; if (typeof required !== 'undefined') { @@ -1501,13 +2720,45 @@ export class Databases { /** * Get attribute by ID. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead. + */ + getAttribute(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + /** + * Get attribute by ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getAttribute(databaseId: string, collectionId: string, key: string): Promise<{}> { + getAttribute(databaseId: string, collectionId: string, key: string): Promise<{}>; + getAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1517,6 +2768,7 @@ export class Databases { if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1535,13 +2787,45 @@ export class Databases { /** * Deletes an attribute. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteColumn` instead. */ - deleteAttribute(databaseId: string, collectionId: string, key: string): Promise<{}> { + deleteAttribute(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + /** + * Deletes an attribute. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteAttribute(databaseId: string, collectionId: string, key: string): Promise<{}>; + deleteAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1551,6 +2835,7 @@ export class Databases { if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1571,15 +2856,54 @@ export class Databases { * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). * * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {RelationMutate} onDelete - * @param {string} newKey + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {RelationMutate} params.onDelete - Constraints option + * @param {string} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. */ - updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.AttributeRelationship> { + updateRelationshipAttribute(params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }): Promise<Models.AttributeRelationship>; + /** + * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {RelationMutate} onDelete - Constraints option + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeRelationship>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.AttributeRelationship>; + updateRelationshipAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string } | string, + ...rest: [(string)?, (string)?, (RelationMutate)?, (string)?] + ): Promise<Models.AttributeRelationship> { + let params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + onDelete: rest[2] as RelationMutate, + newKey: rest[3] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const onDelete = params.onDelete; + const newKey = params.newKey; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1589,6 +2913,7 @@ export class Databases { if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; if (typeof onDelete !== 'undefined') { @@ -1612,21 +2937,54 @@ export class Databases { } /** - * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead. + */ + listDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, queries?: string[] }): Promise<Models.DocumentList<Document>>; + /** + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string[]} queries + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.DocumentList<Document>> { + listDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.DocumentList<Document>>; + listDocuments<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.DocumentList<Document>> { + let params: { databaseId: string, collectionId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } if (typeof collectionId === 'undefined') { throw new AppwriteException('Missing required parameter: "collectionId"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1648,15 +3006,53 @@ export class Databases { /** * 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 {Document extends Models.DefaultDocument ? Models.DataWithoutDocumentKeys : Omit<Document, keyof Models.Document>} data - * @param {string[]} permissions + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} params.data - Document data as JSON object. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Document>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. */ - createDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Models.DataWithoutDocumentKeys : Omit<Document, keyof Models.Document>, permissions?: string[]): Promise<Document> { + createDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] }): Promise<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) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} data - Document data as JSON object. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Document>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[]): Promise<Document>; + createDocument<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, (string[])?] + ): Promise<Document> { + let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, + permissions: rest[3] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1669,6 +3065,10 @@ export class Databases { if (typeof data === 'undefined') { throw new AppwriteException('Missing required parameter: "data"'); } + delete data?.$sequence; + delete data?.$collectionId; + delete data?.$databaseId; + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof documentId !== 'undefined') { @@ -1695,17 +3095,47 @@ export class Databases { } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. - * * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * - * @param {string} databaseId - * @param {string} collectionId - * @param {object[]} documents + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} params.documents - Array of documents data as JSON objects. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead. */ - createDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documents: object[]): Promise<Models.DocumentList<Document>> { + createDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documents: object[] }): Promise<Models.DocumentList<Document>>; + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} documents - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documents: object[]): Promise<Models.DocumentList<Document>>; + createDocuments<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string, + ...rest: [(string)?, (object[])?] + ): Promise<Models.DocumentList<Document>> { + let params: { databaseId: string, collectionId: string, documents: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1715,6 +3145,7 @@ export class Databases { if (typeof documents === 'undefined') { throw new AppwriteException('Missing required parameter: "documents"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof documents !== 'undefined') { @@ -1735,18 +3166,49 @@ export class Databases { } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object[]} params.documents - Array of document data as JSON objects. May contain partial documents. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. + */ + upsertDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documents: object[] }): Promise<Models.DocumentList<Document>>; + /** * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * - * @param {string} databaseId - * @param {string} collectionId - * @param {object[]} documents + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object[]} documents - Array of document data as JSON objects. May contain partial documents. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - upsertDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documents: object[]): Promise<Models.DocumentList<Document>> { + upsertDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documents: object[]): Promise<Models.DocumentList<Document>>; + upsertDocuments<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string, + ...rest: [(string)?, (object[])?] + ): Promise<Models.DocumentList<Document>> { + let params: { databaseId: string, collectionId: string, documents: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1756,6 +3218,7 @@ export class Databases { if (typeof documents === 'undefined') { throw new AppwriteException('Missing required parameter: "documents"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof documents !== 'undefined') { @@ -1776,24 +3239,58 @@ export class Databases { } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. - * * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. * - * @param {string} databaseId - * @param {string} collectionId - * @param {object} data - * @param {string[]} queries + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object} params.data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. */ - updateDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, data?: object, queries?: string[]): Promise<Models.DocumentList<Document>> { + updateDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, data?: object, queries?: string[] }): Promise<Models.DocumentList<Document>>; + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object} data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, data?: object, queries?: string[]): Promise<Models.DocumentList<Document>>; + updateDocuments<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[] } | string, + ...rest: [(string)?, (object)?, (string[])?] + ): Promise<Models.DocumentList<Document>> { + let params: { databaseId: string, collectionId: string, data?: object, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + data: rest[1] as object, + queries: rest[2] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const data = params.data; + const queries = params.queries; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } if (typeof collectionId === 'undefined') { throw new AppwriteException('Missing required parameter: "collectionId"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof data !== 'undefined') { @@ -1817,23 +3314,54 @@ export class Databases { } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. - * * Bulk delete documents using queries, if no queries are passed then all documents are deleted. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string[]} queries + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRows` instead. */ - deleteDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.DocumentList<Document>> { + deleteDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, queries?: string[] }): Promise<Models.DocumentList<Document>>; + /** + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.DocumentList<Document>>; + deleteDocuments<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.DocumentList<Document>> { + let params: { databaseId: string, collectionId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } if (typeof collectionId === 'undefined') { throw new AppwriteException('Missing required parameter: "collectionId"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1856,14 +3384,49 @@ export class Databases { /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} documentId - * @param {string[]} queries + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.documentId - Document ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Document>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead. + */ + getDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[] }): Promise<Document>; + /** + * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} documentId - Document ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @throws {AppwriteException} * @returns {Promise<Document>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Document> { + getDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Document>; + getDocument<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[] } | string, + ...rest: [(string)?, (string)?, (string[])?] + ): Promise<Document> { + let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + queries: rest[2] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1873,6 +3436,7 @@ export class Databases { if (typeof documentId === 'undefined') { throw new AppwriteException('Missing required parameter: "documentId"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1892,19 +3456,55 @@ export class Databases { } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. - * * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} documentId - * @param {object} data - * @param {string[]} permissions + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {object} params.data - Document data as JSON object. Include all required attributes of the document to be created or updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Document>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. */ - upsertDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise<Document> { + upsertDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[] }): Promise<Document>; + /** + * 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 - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {object} data - Document data as JSON object. Include all required attributes of the document to be created or updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Document>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise<Document>; + upsertDocument<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[] } | string, + ...rest: [(string)?, (string)?, (object)?, (string[])?] + ): Promise<Document> { + let params: { databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as object, + permissions: rest[3] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1917,6 +3517,10 @@ export class Databases { if (typeof data === 'undefined') { throw new AppwriteException('Missing required parameter: "data"'); } + delete data?.$sequence; + delete data?.$collectionId; + delete data?.$databaseId; + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; if (typeof data !== 'undefined') { @@ -1942,15 +3546,53 @@ export class Databases { /** * 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<Document extends Models.DefaultDocument ? Models.DataWithoutDocumentKeys : Omit<Document, keyof Models.Document>>} data - * @param {string[]} permissions + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Document>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead. + */ + updateDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] }): Promise<Document>; + /** + * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Document>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data?: Partial<Document extends Models.DefaultDocument ? Models.DataWithoutDocumentKeys : Omit<Document, keyof Models.Document>>, permissions?: string[]): Promise<Document> { + updateDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[]): Promise<Document>; + updateDocument<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, (string[])?] + ): Promise<Document> { + let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, + permissions: rest[3] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -1960,6 +3602,10 @@ export class Databases { if (typeof documentId === 'undefined') { throw new AppwriteException('Missing required parameter: "documentId"'); } + delete data?.$sequence; + delete data?.$collectionId; + delete data?.$databaseId; + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; if (typeof data !== 'undefined') { @@ -1985,13 +3631,45 @@ export class Databases { /** * Delete a document by its unique ID. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} documentId + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.documentId - Document ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead. + */ + deleteDocument(params: { databaseId: string, collectionId: string, documentId: string }): Promise<{}>; + /** + * Delete a document by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} documentId - Document ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}> { + deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}>; + deleteDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string, documentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -2001,6 +3679,7 @@ export class Databases { if (typeof documentId === 'undefined') { throw new AppwriteException('Missing required parameter: "documentId"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2020,16 +3699,57 @@ export class Databases { /** * 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 + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {string} params.attribute - Attribute key. + * @param {number} params.value - Value to increment the attribute by. The value must be a number. + * @param {number} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. * @throws {AppwriteException} * @returns {Promise<Document>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead. */ - decrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise<Document> { + decrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number }): Promise<Document>; + /** + * Decrement a specific attribute of a document by a given value. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {string} attribute - Attribute key. + * @param {number} value - Value to increment the attribute by. The value must be a number. + * @param {number} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @throws {AppwriteException} + * @returns {Promise<Document>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + decrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise<Document>; + decrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?] + ): Promise<Document> { + let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + attribute: rest[2] as string, + value: rest[3] as number, + min: rest[4] as number + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const attribute = params.attribute; + const value = params.value; + const min = params.min; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -2042,6 +3762,7 @@ export class Databases { 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') { @@ -2067,16 +3788,57 @@ export class Databases { /** * 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 + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {string} params.attribute - Attribute key. + * @param {number} params.value - Value to increment the attribute by. The value must be a number. + * @param {number} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @throws {AppwriteException} + * @returns {Promise<Document>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead. + */ + incrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number }): Promise<Document>; + /** + * Increment a specific attribute of a document by a given value. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {string} attribute - Attribute key. + * @param {number} value - Value to increment the attribute by. The value must be a number. + * @param {number} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. * @throws {AppwriteException} * @returns {Promise<Document>} + * @deprecated Use the object parameter style method for a better developer experience. */ - incrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise<Document> { + incrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise<Document>; + incrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?] + ): Promise<Document> { + let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + attribute: rest[2] as string, + value: rest[3] as number, + max: rest[4] as number + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const attribute = params.attribute; + const value = params.value; + const max = params.max; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -2089,6 +3851,7 @@ export class Databases { 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') { @@ -2114,19 +3877,52 @@ export class Databases { /** * List indexes in the collection. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string[]} queries + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error * @throws {AppwriteException} * @returns {Promise<Models.IndexList>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listIndexes` instead. */ - listIndexes(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.IndexList> { + listIndexes(params: { databaseId: string, collectionId: string, queries?: string[] }): Promise<Models.IndexList>; + /** + * List indexes in the collection. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error + * @throws {AppwriteException} + * @returns {Promise<Models.IndexList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listIndexes(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.IndexList>; + listIndexes( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.IndexList> { + let params: { databaseId: string, collectionId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } if (typeof collectionId === 'undefined') { throw new AppwriteException('Missing required parameter: "collectionId"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -2149,17 +3945,62 @@ export class Databases { * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. * Attributes can be `key`, `fulltext`, and `unique`. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {IndexType} type - * @param {string[]} attributes - * @param {string[]} orders - * @param {number[]} lengths + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @param {IndexType} params.type - Index type. + * @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {string[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} params.lengths - Length of index. Maximum of 100 * @throws {AppwriteException} * @returns {Promise<Models.Index>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIndex` instead. */ - createIndex(databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: string[], lengths?: number[]): Promise<Models.Index> { + createIndex(params: { databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: string[], lengths?: number[] }): Promise<Models.Index>; + /** + * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @param {IndexType} type - Index type. + * @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {string[]} orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise<Models.Index>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIndex(databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: string[], lengths?: number[]): Promise<Models.Index>; + createIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: string[], lengths?: number[] } | string, + ...rest: [(string)?, (string)?, (IndexType)?, (string[])?, (string[])?, (number[])?] + ): Promise<Models.Index> { + let params: { databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: string[], lengths?: number[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: string[], lengths?: number[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + type: rest[2] as IndexType, + attributes: rest[3] as string[], + orders: rest[4] as string[], + lengths: rest[5] as number[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const type = params.type; + const attributes = params.attributes; + const orders = params.orders; + const lengths = params.lengths; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -2175,6 +4016,7 @@ export class Databases { if (typeof attributes === 'undefined') { throw new AppwriteException('Missing required parameter: "attributes"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -2209,13 +4051,45 @@ export class Databases { /** * Get index by ID. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. * @throws {AppwriteException} * @returns {Promise<Models.Index>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getIndex` instead. */ - getIndex(databaseId: string, collectionId: string, key: string): Promise<Models.Index> { + getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<Models.Index>; + /** + * Get index by ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<Models.Index>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getIndex(databaseId: string, collectionId: string, key: string): Promise<Models.Index>; + getIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.Index> { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -2225,6 +4099,7 @@ export class Databases { if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2243,13 +4118,45 @@ export class Databases { /** * Delete an index. * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteIndex` instead. + */ + deleteIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + /** + * Delete an index. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}> { + deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}>; + deleteIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -2259,6 +4166,7 @@ export class Databases { if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); diff --git a/src/services/functions.ts b/src/services/functions.ts index 7b544ef..113a84e 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -1,7 +1,8 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { Runtime } from '../enums/runtime'; -import { VCSDeploymentType } from '../enums/v-c-s-deployment-type'; +import { VCSDeploymentType } from '../enums/vcs-deployment-type'; import { DeploymentDownloadType } from '../enums/deployment-download-type'; import { ExecutionMethod } from '../enums/execution-method'; @@ -13,14 +14,43 @@ export class Functions { } /** - * Get a list of all the project's functions. You can use the query params to filter your results. + * Get a list of all the project's functions. You can use the query params to filter your results. * - * @param {string[]} queries - * @param {string} search + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.FunctionList>} */ - list(queries?: string[], search?: string): Promise<Models.FunctionList> { + list(params?: { queries?: string[], search?: string }): Promise<Models.FunctionList>; + /** + * Get a list of all the project's functions. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.FunctionList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[], search?: string): Promise<Models.FunctionList>; + list( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.FunctionList> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + const apiPath = '/functions'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -45,28 +75,104 @@ export class Functions { /** * Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. * - * @param {string} functionId - * @param {string} name - * @param {Runtime} runtime - * @param {string[]} execute - * @param {string[]} events - * @param {string} schedule - * @param {number} timeout - * @param {boolean} enabled - * @param {boolean} logging - * @param {string} entrypoint - * @param {string} commands - * @param {string[]} scopes - * @param {string} installationId - * @param {string} providerRepositoryId - * @param {string} providerBranch - * @param {boolean} providerSilentMode - * @param {string} providerRootDirectory - * @param {string} specification + * @param {string} params.functionId - Function ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Function name. Max length: 128 chars. + * @param {Runtime} params.runtime - Execution runtime. + * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. + * @param {string} params.schedule - Schedule CRON syntax. + * @param {number} params.timeout - Function maximum execution time in seconds. + * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. + * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. + * @param {string} params.entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". + * @param {string} params.commands - Build Commands. + * @param {string[]} params.scopes - List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function. + * @param {string} params.providerBranch - Production branch for the repo linked to the function. + * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. + * @param {string} params.providerRootDirectory - Path to function code in the linked repo. + * @param {string} params.specification - Runtime specification for the function and builds. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ - create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Function> { + create(params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }): Promise<Models.Function>; + /** + * Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. + * + * @param {string} functionId - Function ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Function name. Max length: 128 chars. + * @param {Runtime} runtime - Execution runtime. + * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {string[]} events - Events list. Maximum of 100 events are allowed. + * @param {string} schedule - Schedule CRON syntax. + * @param {number} timeout - Function maximum execution time in seconds. + * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. + * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. + * @param {string} entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". + * @param {string} commands - Build Commands. + * @param {string[]} scopes - List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} providerRepositoryId - Repository ID of the repo linked to the function. + * @param {string} providerBranch - Production branch for the repo linked to the function. + * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. + * @param {string} providerRootDirectory - Path to function code in the linked repo. + * @param {string} specification - Runtime specification for the function and builds. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Function>; + create( + paramsOrFirst: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string } | string, + ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (string[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.Function> { + let params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + } else { + params = { + functionId: paramsOrFirst as string, + name: rest[0] as string, + runtime: rest[1] as Runtime, + execute: rest[2] as string[], + events: rest[3] as string[], + schedule: rest[4] as string, + timeout: rest[5] as number, + enabled: rest[6] as boolean, + logging: rest[7] as boolean, + entrypoint: rest[8] as string, + commands: rest[9] as string, + scopes: rest[10] as string[], + installationId: rest[11] as string, + providerRepositoryId: rest[12] as string, + providerBranch: rest[13] as string, + providerSilentMode: rest[14] as boolean, + providerRootDirectory: rest[15] as string, + specification: rest[16] as string + }; + } + + const functionId = params.functionId; + const name = params.name; + const runtime = params.runtime; + const execute = params.execute; + const events = params.events; + const schedule = params.schedule; + const timeout = params.timeout; + const enabled = params.enabled; + const logging = params.logging; + const entrypoint = params.entrypoint; + const commands = params.commands; + const scopes = params.scopes; + const installationId = params.installationId; + const providerRepositoryId = params.providerRepositoryId; + const providerBranch = params.providerBranch; + const providerSilentMode = params.providerSilentMode; + const providerRootDirectory = params.providerRootDirectory; + const specification = params.specification; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -76,6 +182,7 @@ export class Functions { if (typeof runtime === 'undefined') { throw new AppwriteException('Missing required parameter: "runtime"'); } + const apiPath = '/functions'; const payload: Payload = {}; if (typeof functionId !== 'undefined') { @@ -153,6 +260,7 @@ export class Functions { * @returns {Promise<Models.RuntimeList>} */ listRuntimes(): Promise<Models.RuntimeList> { + const apiPath = '/functions/runtimes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -175,6 +283,7 @@ export class Functions { * @returns {Promise<Models.SpecificationList>} */ listSpecifications(): Promise<Models.SpecificationList> { + const apiPath = '/functions/specifications'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -193,14 +302,39 @@ export class Functions { /** * Get a function by its unique ID. * - * @param {string} functionId + * @param {string} params.functionId - Function ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + */ + get(params: { functionId: string }): Promise<Models.Function>; + /** + * Get a function by its unique ID. + * + * @param {string} functionId - Function ID. * @throws {AppwriteException} * @returns {Promise<Models.Function>} + * @deprecated Use the object parameter style method for a better developer experience. */ - get(functionId: string): Promise<Models.Function> { + get(functionId: string): Promise<Models.Function>; + get( + paramsOrFirst: { functionId: string } | string + ): Promise<Models.Function> { + let params: { functionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string }; + } else { + params = { + functionId: paramsOrFirst as string + }; + } + + const functionId = params.functionId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } + const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -219,34 +353,111 @@ export class Functions { /** * Update function by its unique ID. * - * @param {string} functionId - * @param {string} name - * @param {Runtime} runtime - * @param {string[]} execute - * @param {string[]} events - * @param {string} schedule - * @param {number} timeout - * @param {boolean} enabled - * @param {boolean} logging - * @param {string} entrypoint - * @param {string} commands - * @param {string[]} scopes - * @param {string} installationId - * @param {string} providerRepositoryId - * @param {string} providerBranch - * @param {boolean} providerSilentMode - * @param {string} providerRootDirectory - * @param {string} specification + * @param {string} params.functionId - Function ID. + * @param {string} params.name - Function name. Max length: 128 chars. + * @param {Runtime} params.runtime - Execution runtime. + * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. + * @param {string} params.schedule - Schedule CRON syntax. + * @param {number} params.timeout - Maximum execution time in seconds. + * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. + * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. + * @param {string} params.entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". + * @param {string} params.commands - Build Commands. + * @param {string[]} params.scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. + * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function + * @param {string} params.providerBranch - Production branch for the repo linked to the function + * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. + * @param {string} params.providerRootDirectory - Path to function code in the linked repo. + * @param {string} params.specification - Runtime specification for the function and builds. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + */ + update(params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }): Promise<Models.Function>; + /** + * Update function by its unique ID. + * + * @param {string} functionId - Function ID. + * @param {string} name - Function name. Max length: 128 chars. + * @param {Runtime} runtime - Execution runtime. + * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {string[]} events - Events list. Maximum of 100 events are allowed. + * @param {string} schedule - Schedule CRON syntax. + * @param {number} timeout - Maximum execution time in seconds. + * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. + * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. + * @param {string} entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". + * @param {string} commands - Build Commands. + * @param {string[]} scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {string} installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. + * @param {string} providerRepositoryId - Repository ID of the repo linked to the function + * @param {string} providerBranch - Production branch for the repo linked to the function + * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. + * @param {string} providerRootDirectory - Path to function code in the linked repo. + * @param {string} specification - Runtime specification for the function and builds. * @throws {AppwriteException} * @returns {Promise<Models.Function>} + * @deprecated Use the object parameter style method for a better developer experience. */ - update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Function> { + update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Function>; + update( + paramsOrFirst: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string } | string, + ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (string[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.Function> { + let params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + } else { + params = { + functionId: paramsOrFirst as string, + name: rest[0] as string, + runtime: rest[1] as Runtime, + execute: rest[2] as string[], + events: rest[3] as string[], + schedule: rest[4] as string, + timeout: rest[5] as number, + enabled: rest[6] as boolean, + logging: rest[7] as boolean, + entrypoint: rest[8] as string, + commands: rest[9] as string, + scopes: rest[10] as string[], + installationId: rest[11] as string, + providerRepositoryId: rest[12] as string, + providerBranch: rest[13] as string, + providerSilentMode: rest[14] as boolean, + providerRootDirectory: rest[15] as string, + specification: rest[16] as string + }; + } + + const functionId = params.functionId; + const name = params.name; + const runtime = params.runtime; + const execute = params.execute; + const events = params.events; + const schedule = params.schedule; + const timeout = params.timeout; + const enabled = params.enabled; + const logging = params.logging; + const entrypoint = params.entrypoint; + const commands = params.commands; + const scopes = params.scopes; + const installationId = params.installationId; + const providerRepositoryId = params.providerRepositoryId; + const providerBranch = params.providerBranch; + const providerSilentMode = params.providerSilentMode; + const providerRootDirectory = params.providerRootDirectory; + const specification = params.specification; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -317,14 +528,39 @@ export class Functions { /** * Delete a function by its unique ID. * - * @param {string} functionId + * @param {string} params.functionId - Function ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { functionId: string }): Promise<{}>; + /** + * Delete a function by its unique ID. + * + * @param {string} functionId - Function ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - delete(functionId: string): Promise<{}> { + delete(functionId: string): Promise<{}>; + delete( + paramsOrFirst: { functionId: string } | string + ): Promise<{}> { + let params: { functionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string }; + } else { + params = { + functionId: paramsOrFirst as string + }; + } + + const functionId = params.functionId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } + const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -344,18 +580,47 @@ export class Functions { /** * Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. * - * @param {string} functionId - * @param {string} deploymentId + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + */ + updateFunctionDeployment(params: { functionId: string, deploymentId: string }): Promise<Models.Function>; + /** + * Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. * @throws {AppwriteException} * @returns {Promise<Models.Function>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateFunctionDeployment(functionId: string, deploymentId: string): Promise<Models.Function> { + updateFunctionDeployment(functionId: string, deploymentId: string): Promise<Models.Function>; + updateFunctionDeployment( + paramsOrFirst: { functionId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Function> { + let params: { functionId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/functions/{functionId}/deployment'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof deploymentId !== 'undefined') { @@ -376,18 +641,50 @@ export class Functions { } /** - * Get a list of all the function's code deployments. You can use the query params to filter your results. + * Get a list of all the function's code deployments. You can use the query params to filter your results. * - * @param {string} functionId - * @param {string[]} queries - * @param {string} search + * @param {string} params.functionId - Function ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.DeploymentList>} */ - listDeployments(functionId: string, queries?: string[], search?: string): Promise<Models.DeploymentList> { + listDeployments(params: { functionId: string, queries?: string[], search?: string }): Promise<Models.DeploymentList>; + /** + * Get a list of all the function's code deployments. You can use the query params to filter your results. + * + * @param {string} functionId - Function ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.DeploymentList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listDeployments(functionId: string, queries?: string[], search?: string): Promise<Models.DeploymentList>; + listDeployments( + paramsOrFirst: { functionId: string, queries?: string[], search?: string } | string, + ...rest: [(string[])?, (string)?] + ): Promise<Models.DeploymentList> { + let params: { functionId: string, queries?: string[], search?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, queries?: string[], search?: string }; + } else { + params = { + functionId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string + }; + } + + const functionId = params.functionId; + const queries = params.queries; + const search = params.search; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } + const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -410,21 +707,65 @@ export class Functions { } /** - * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. + * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. * * This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). * - * Use the "command" param to set the entrypoint used to execute your code. + * Use the "command" param to set the entrypoint used to execute your code. * - * @param {string} functionId - * @param {File} code - * @param {boolean} activate - * @param {string} entrypoint - * @param {string} commands + * @param {string} params.functionId - Function ID. + * @param {File} params.code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. + * @param {string} params.entrypoint - Entrypoint File. + * @param {string} params.commands - Build Commands. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ - createDeployment(functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress = (progress: UploadProgress) => {}): Promise<Models.Deployment> { + createDeployment(params: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string , onProgress?: (progress: UploadProgress) => void }): Promise<Models.Deployment>; + /** + * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. + * + * This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). + * + * Use the "command" param to set the entrypoint used to execute your code. + * + * @param {string} functionId - Function ID. + * @param {File} code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + * @param {boolean} activate - Automatically activate the deployment when it is finished building. + * @param {string} entrypoint - Entrypoint File. + * @param {string} commands - Build Commands. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDeployment(functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void): Promise<Models.Deployment>; + createDeployment( + paramsOrFirst: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void } | string, + ...rest: [(File)?, (boolean)?, (string)?, (string)?,((progress: UploadProgress) => void)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string }; + let onProgress: ((progress: UploadProgress) => void); + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string }; + onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + } else { + params = { + functionId: paramsOrFirst as string, + code: rest[0] as File, + activate: rest[1] as boolean, + entrypoint: rest[2] as string, + commands: rest[3] as string + }; + onProgress = rest[4] as ((progress: UploadProgress) => void); + } + + const functionId = params.functionId; + const code = params.code; + const activate = params.activate; + const entrypoint = params.entrypoint; + const commands = params.commands; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -434,6 +775,7 @@ export class Functions { if (typeof activate === 'undefined') { throw new AppwriteException('Missing required parameter: "activate"'); } + const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof entrypoint !== 'undefined') { @@ -464,21 +806,53 @@ export class Functions { } /** - * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. + * @param {string} params.buildId - Build unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createDuplicateDeployment(params: { functionId: string, deploymentId: string, buildId?: string }): Promise<Models.Deployment>; + /** + * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. * - * @param {string} functionId - * @param {string} deploymentId - * @param {string} buildId + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. + * @param {string} buildId - Build unique ID. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createDuplicateDeployment(functionId: string, deploymentId: string, buildId?: string): Promise<Models.Deployment> { + createDuplicateDeployment(functionId: string, deploymentId: string, buildId?: string): Promise<Models.Deployment>; + createDuplicateDeployment( + paramsOrFirst: { functionId: string, deploymentId: string, buildId?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, deploymentId: string, buildId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string, buildId?: string }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string, + buildId: rest[1] as string + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + const buildId = params.buildId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/functions/{functionId}/deployments/duplicate'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof deploymentId !== 'undefined') { @@ -506,16 +880,58 @@ export class Functions { * * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details. * - * @param {string} functionId - * @param {string} repository - * @param {string} owner - * @param {string} rootDirectory - * @param {string} version - * @param {boolean} activate + * @param {string} params.functionId - Function ID. + * @param {string} params.repository - Repository name of the template. + * @param {string} params.owner - The name of the owner of the template. + * @param {string} params.rootDirectory - Path to function code in the template repo. + * @param {string} params.version - Version (tag) for the repo linked to the function template. + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ - createTemplateDeployment(functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean): Promise<Models.Deployment> { + createTemplateDeployment(params: { functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }): Promise<Models.Deployment>; + /** + * Create a deployment based on a template. + * + * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details. + * + * @param {string} functionId - Function ID. + * @param {string} repository - Repository name of the template. + * @param {string} owner - The name of the owner of the template. + * @param {string} rootDirectory - Path to function code in the template repo. + * @param {string} version - Version (tag) for the repo linked to the function template. + * @param {boolean} activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTemplateDeployment(functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean): Promise<Models.Deployment>; + createTemplateDeployment( + paramsOrFirst: { functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }; + } else { + params = { + functionId: paramsOrFirst as string, + repository: rest[0] as string, + owner: rest[1] as string, + rootDirectory: rest[2] as string, + version: rest[3] as string, + activate: rest[4] as boolean + }; + } + + const functionId = params.functionId; + const repository = params.repository; + const owner = params.owner; + const rootDirectory = params.rootDirectory; + const version = params.version; + const activate = params.activate; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -531,6 +947,7 @@ export class Functions { if (typeof version === 'undefined') { throw new AppwriteException('Missing required parameter: "version"'); } + const apiPath = '/functions/{functionId}/deployments/template'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof repository !== 'undefined') { @@ -567,14 +984,50 @@ export class Functions { * * This endpoint lets you create deployment from a branch, commit, or a tag. * - * @param {string} functionId - * @param {VCSDeploymentType} type - * @param {string} reference - * @param {boolean} activate + * @param {string} params.functionId - Function ID. + * @param {VCSDeploymentType} params.type - Type of reference passed. Allowed values are: branch, commit + * @param {string} params.reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createVcsDeployment(params: { functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean }): Promise<Models.Deployment>; + /** + * Create a deployment when a function is connected to VCS. + * + * This endpoint lets you create deployment from a branch, commit, or a tag. + * + * @param {string} functionId - Function ID. + * @param {VCSDeploymentType} type - Type of reference passed. Allowed values are: branch, commit + * @param {string} reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + * @param {boolean} activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createVcsDeployment(functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean): Promise<Models.Deployment> { + createVcsDeployment(functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean): Promise<Models.Deployment>; + createVcsDeployment( + paramsOrFirst: { functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean } | string, + ...rest: [(VCSDeploymentType)?, (string)?, (boolean)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean }; + } else { + params = { + functionId: paramsOrFirst as string, + type: rest[0] as VCSDeploymentType, + reference: rest[1] as string, + activate: rest[2] as boolean + }; + } + + const functionId = params.functionId; + const type = params.type; + const reference = params.reference; + const activate = params.activate; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -584,6 +1037,7 @@ export class Functions { if (typeof reference === 'undefined') { throw new AppwriteException('Missing required parameter: "reference"'); } + const apiPath = '/functions/{functionId}/deployments/vcs'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof type !== 'undefined') { @@ -612,18 +1066,47 @@ export class Functions { /** * Get a function deployment by its unique ID. * - * @param {string} functionId - * @param {string} deploymentId + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + getDeployment(params: { functionId: string, deploymentId: string }): Promise<Models.Deployment>; + /** + * Get a function deployment by its unique ID. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getDeployment(functionId: string, deploymentId: string): Promise<Models.Deployment> { + getDeployment(functionId: string, deploymentId: string): Promise<Models.Deployment>; + getDeployment( + paramsOrFirst: { functionId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -642,18 +1125,47 @@ export class Functions { /** * Delete a code deployment by its unique ID. * - * @param {string} functionId - * @param {string} deploymentId + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteDeployment(functionId: string, deploymentId: string): Promise<{}> { + deleteDeployment(params: { functionId: string, deploymentId: string }): Promise<{}>; + /** + * Delete a code deployment by its unique ID. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDeployment(functionId: string, deploymentId: string): Promise<{}>; + deleteDeployment( + paramsOrFirst: { functionId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { functionId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -671,21 +1183,53 @@ export class Functions { } /** - * Get a function deployment 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. + * Get a function deployment 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. * - * @param {string} functionId - * @param {string} deploymentId - * @param {DeploymentDownloadType} type + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. + * @param {DeploymentDownloadType} params.type - Deployment file to download. Can be: "source", "output". * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} */ - getDeploymentDownload(functionId: string, deploymentId: string, type?: DeploymentDownloadType): Promise<ArrayBuffer> { + getDeploymentDownload(params: { functionId: string, deploymentId: string, type?: DeploymentDownloadType }): Promise<ArrayBuffer>; + /** + * Get a function deployment 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. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. + * @param {DeploymentDownloadType} type - Deployment file to download. Can be: "source", "output". + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDeploymentDownload(functionId: string, deploymentId: string, type?: DeploymentDownloadType): Promise<ArrayBuffer>; + getDeploymentDownload( + paramsOrFirst: { functionId: string, deploymentId: string, type?: DeploymentDownloadType } | string, + ...rest: [(string)?, (DeploymentDownloadType)?] + ): Promise<ArrayBuffer> { + let params: { functionId: string, deploymentId: string, type?: DeploymentDownloadType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string, type?: DeploymentDownloadType }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string, + type: rest[1] as DeploymentDownloadType + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + const type = params.type; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); const payload: Payload = {}; if (typeof type !== 'undefined') { @@ -706,20 +1250,49 @@ export class Functions { } /** - * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. * - * @param {string} functionId - * @param {string} deploymentId + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ - updateDeploymentStatus(functionId: string, deploymentId: string): Promise<Models.Deployment> { + updateDeploymentStatus(params: { functionId: string, deploymentId: string }): Promise<Models.Deployment>; + /** + * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDeploymentStatus(functionId: string, deploymentId: string): Promise<Models.Deployment>; + updateDeploymentStatus( + paramsOrFirst: { functionId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/functions/{functionId}/deployments/{deploymentId}/status'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -739,15 +1312,44 @@ export class Functions { /** * Get a list of all the current user function execution logs. You can use the query params to filter your results. * - * @param {string} functionId - * @param {string[]} queries + * @param {string} params.functionId - Function ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + * @throws {AppwriteException} + * @returns {Promise<Models.ExecutionList>} + */ + listExecutions(params: { functionId: string, queries?: string[] }): Promise<Models.ExecutionList>; + /** + * Get a list of all the current user function execution logs. You can use the query params to filter your results. + * + * @param {string} functionId - Function ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId * @throws {AppwriteException} * @returns {Promise<Models.ExecutionList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listExecutions(functionId: string, queries?: string[]): Promise<Models.ExecutionList> { + listExecutions(functionId: string, queries?: string[]): Promise<Models.ExecutionList>; + listExecutions( + paramsOrFirst: { functionId: string, queries?: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.ExecutionList> { + let params: { functionId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, queries?: string[] }; + } else { + params = { + functionId: paramsOrFirst as string, + queries: rest[0] as string[] + }; + } + + const functionId = params.functionId; + const queries = params.queries; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } + const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -769,20 +1371,64 @@ export class Functions { /** * 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. * - * @param {string} functionId - * @param {string} body - * @param {boolean} async - * @param {string} xpath - * @param {ExecutionMethod} method - * @param {object} headers - * @param {string} scheduledAt + * @param {string} params.functionId - Function ID. + * @param {string} params.body - HTTP body of execution. Default value is empty string. + * @param {boolean} params.async - Execute code in the background. Default value is false. + * @param {string} params.xpath - HTTP path of execution. Path can include query params. Default value is / + * @param {ExecutionMethod} params.method - HTTP method of execution. Default value is GET. + * @param {object} params.headers - HTTP headers of execution. Defaults to empty. + * @param {string} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @throws {AppwriteException} + * @returns {Promise<Models.Execution>} + */ + createExecution(params: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }): Promise<Models.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 function execution process will start asynchronously. + * + * @param {string} functionId - Function ID. + * @param {string} body - HTTP body of execution. Default value is empty string. + * @param {boolean} async - Execute code in the background. Default value is false. + * @param {string} xpath - HTTP path of execution. Path can include query params. Default value is / + * @param {ExecutionMethod} method - HTTP method of execution. Default value is GET. + * @param {object} headers - HTTP headers of execution. Defaults to empty. + * @param {string} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise<Models.Execution> { + createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise<Models.Execution>; + createExecution( + paramsOrFirst: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (ExecutionMethod)?, (object)?, (string)?] + ): Promise<Models.Execution> { + let params: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }; + } else { + params = { + functionId: paramsOrFirst as string, + body: rest[0] as string, + async: rest[1] as boolean, + xpath: rest[2] as string, + method: rest[3] as ExecutionMethod, + headers: rest[4] as object, + scheduledAt: rest[5] as string + }; + } + + const functionId = params.functionId; + const body = params.body; + const async = params.async; + const xpath = params.xpath; + const method = params.method; + const headers = params.headers; + const scheduledAt = params.scheduledAt; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } + const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof body !== 'undefined') { @@ -820,18 +1466,47 @@ export class Functions { /** * Get a function execution log by its unique ID. * - * @param {string} functionId - * @param {string} executionId + * @param {string} params.functionId - Function ID. + * @param {string} params.executionId - Execution ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Execution>} + */ + getExecution(params: { functionId: string, executionId: string }): Promise<Models.Execution>; + /** + * Get a function execution log by its unique ID. + * + * @param {string} functionId - Function ID. + * @param {string} executionId - Execution ID. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getExecution(functionId: string, executionId: string): Promise<Models.Execution> { + getExecution(functionId: string, executionId: string): Promise<Models.Execution>; + getExecution( + paramsOrFirst: { functionId: string, executionId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Execution> { + let params: { functionId: string, executionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, executionId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + executionId: rest[0] as string + }; + } + + const functionId = params.functionId; + const executionId = params.executionId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof executionId === 'undefined') { throw new AppwriteException('Missing required parameter: "executionId"'); } + const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -850,18 +1525,47 @@ export class Functions { /** * Delete a function execution by its unique ID. * - * @param {string} functionId - * @param {string} executionId + * @param {string} params.functionId - Function ID. + * @param {string} params.executionId - Execution ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteExecution(params: { functionId: string, executionId: string }): Promise<{}>; + /** + * Delete a function execution by its unique ID. + * + * @param {string} functionId - Function ID. + * @param {string} executionId - Execution ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteExecution(functionId: string, executionId: string): Promise<{}> { + deleteExecution(functionId: string, executionId: string): Promise<{}>; + deleteExecution( + paramsOrFirst: { functionId: string, executionId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { functionId: string, executionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, executionId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + executionId: rest[0] as string + }; + } + + const functionId = params.functionId; + const executionId = params.executionId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof executionId === 'undefined') { throw new AppwriteException('Missing required parameter: "executionId"'); } + const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -881,14 +1585,39 @@ export class Functions { /** * Get a list of all variables of a specific function. * - * @param {string} functionId + * @param {string} params.functionId - Function unique ID. * @throws {AppwriteException} * @returns {Promise<Models.VariableList>} */ - listVariables(functionId: string): Promise<Models.VariableList> { + listVariables(params: { functionId: string }): Promise<Models.VariableList>; + /** + * Get a list of all variables of a specific function. + * + * @param {string} functionId - Function unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.VariableList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listVariables(functionId: string): Promise<Models.VariableList>; + listVariables( + paramsOrFirst: { functionId: string } | string + ): Promise<Models.VariableList> { + let params: { functionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string }; + } else { + params = { + functionId: paramsOrFirst as string + }; + } + + const functionId = params.functionId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } + const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -907,14 +1636,48 @@ export class Functions { /** * Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. * - * @param {string} functionId - * @param {string} key - * @param {string} value - * @param {boolean} secret + * @param {string} params.functionId - Function unique ID. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + */ + createVariable(params: { functionId: string, key: string, value: string, secret?: boolean }): Promise<Models.Variable>; + /** + * Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. + * + * @param {string} functionId - Function unique ID. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createVariable(functionId: string, key: string, value: string, secret?: boolean): Promise<Models.Variable> { + createVariable(functionId: string, key: string, value: string, secret?: boolean): Promise<Models.Variable>; + createVariable( + paramsOrFirst: { functionId: string, key: string, value: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise<Models.Variable> { + let params: { functionId: string, key: string, value: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, key: string, value: string, secret?: boolean }; + } else { + params = { + functionId: paramsOrFirst as string, + key: rest[0] as string, + value: rest[1] as string, + secret: rest[2] as boolean + }; + } + + const functionId = params.functionId; + const key = params.key; + const value = params.value; + const secret = params.secret; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -924,6 +1687,7 @@ export class Functions { if (typeof value === 'undefined') { throw new AppwriteException('Missing required parameter: "value"'); } + const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -952,18 +1716,47 @@ export class Functions { /** * Get a variable by its unique ID. * - * @param {string} functionId - * @param {string} variableId + * @param {string} params.functionId - Function unique ID. + * @param {string} params.variableId - Variable unique ID. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ - getVariable(functionId: string, variableId: string): Promise<Models.Variable> { + getVariable(params: { functionId: string, variableId: string }): Promise<Models.Variable>; + /** + * Get a variable by its unique ID. + * + * @param {string} functionId - Function unique ID. + * @param {string} variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getVariable(functionId: string, variableId: string): Promise<Models.Variable>; + getVariable( + paramsOrFirst: { functionId: string, variableId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Variable> { + let params: { functionId: string, variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, variableId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + variableId: rest[0] as string + }; + } + + const functionId = params.functionId; + const variableId = params.variableId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof variableId === 'undefined') { throw new AppwriteException('Missing required parameter: "variableId"'); } + const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -982,15 +1775,52 @@ export class Functions { /** * Update variable by its unique ID. * - * @param {string} functionId - * @param {string} variableId - * @param {string} key - * @param {string} value - * @param {boolean} secret + * @param {string} params.functionId - Function unique ID. + * @param {string} params.variableId - Variable unique ID. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + */ + updateVariable(params: { functionId: string, variableId: string, key: string, value?: string, secret?: boolean }): Promise<Models.Variable>; + /** + * Update variable by its unique ID. + * + * @param {string} functionId - Function unique ID. + * @param {string} variableId - Variable unique ID. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateVariable(functionId: string, variableId: string, key: string, value?: string, secret?: boolean): Promise<Models.Variable> { + updateVariable(functionId: string, variableId: string, key: string, value?: string, secret?: boolean): Promise<Models.Variable>; + updateVariable( + paramsOrFirst: { functionId: string, variableId: string, key: string, value?: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Variable> { + let params: { functionId: string, variableId: string, key: string, value?: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, variableId: string, key: string, value?: string, secret?: boolean }; + } else { + params = { + functionId: paramsOrFirst as string, + variableId: rest[0] as string, + key: rest[1] as string, + value: rest[2] as string, + secret: rest[3] as boolean + }; + } + + const functionId = params.functionId; + const variableId = params.variableId; + const key = params.key; + const value = params.value; + const secret = params.secret; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -1000,6 +1830,7 @@ export class Functions { if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } + const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -1028,18 +1859,47 @@ export class Functions { /** * Delete a variable by its unique ID. * - * @param {string} functionId - * @param {string} variableId + * @param {string} params.functionId - Function unique ID. + * @param {string} params.variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteVariable(params: { functionId: string, variableId: string }): Promise<{}>; + /** + * Delete a variable by its unique ID. + * + * @param {string} functionId - Function unique ID. + * @param {string} variableId - Variable unique ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteVariable(functionId: string, variableId: string): Promise<{}> { + deleteVariable(functionId: string, variableId: string): Promise<{}>; + deleteVariable( + paramsOrFirst: { functionId: string, variableId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { functionId: string, variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, variableId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + variableId: rest[0] as string + }; + } + + const functionId = params.functionId; + const variableId = params.variableId; + if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } if (typeof variableId === 'undefined') { throw new AppwriteException('Missing required parameter: "variableId"'); } + const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); diff --git a/src/services/graphql.ts b/src/services/graphql.ts index fd34fb7..b94dde8 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + export class Graphql { client: Client; @@ -11,14 +12,39 @@ export class Graphql { /** * Execute a GraphQL mutation. * - * @param {object} query + * @param {object} params.query - The query or queries to execute. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + query(params: { query: object }): Promise<{}>; + /** + * Execute a GraphQL mutation. + * + * @param {object} query - The query or queries to execute. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - query(query: object): Promise<{}> { + query(query: object): Promise<{}>; + query( + paramsOrFirst: { query: object } | object + ): Promise<{}> { + let params: { query: object }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { query: object }; + } else { + params = { + query: paramsOrFirst as object + }; + } + + const query = params.query; + if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); } + const apiPath = '/graphql'; const payload: Payload = {}; if (typeof query !== 'undefined') { @@ -42,14 +68,39 @@ export class Graphql { /** * Execute a GraphQL mutation. * - * @param {object} query + * @param {object} params.query - The query or queries to execute. * @throws {AppwriteException} * @returns {Promise<{}>} */ - mutation(query: object): Promise<{}> { + mutation(params: { query: object }): Promise<{}>; + /** + * Execute a GraphQL mutation. + * + * @param {object} query - The query or queries to execute. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + mutation(query: object): Promise<{}>; + mutation( + paramsOrFirst: { query: object } | object + ): Promise<{}> { + let params: { query: object }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { query: object }; + } else { + params = { + query: paramsOrFirst as object + }; + } + + const query = params.query; + if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); } + const apiPath = '/graphql/mutation'; const payload: Payload = {}; if (typeof query !== 'undefined') { diff --git a/src/services/health.ts b/src/services/health.ts index c593277..8049935 100644 --- a/src/services/health.ts +++ b/src/services/health.ts @@ -1,5 +1,6 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { Name } from '../enums/name'; export class Health { @@ -16,6 +17,7 @@ export class Health { * @returns {Promise<Models.HealthStatus>} */ get(): Promise<Models.HealthStatus> { + const apiPath = '/health'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -38,6 +40,7 @@ export class Health { * @returns {Promise<Models.HealthAntivirus>} */ getAntivirus(): Promise<Models.HealthAntivirus> { + const apiPath = '/health/anti-virus'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -60,6 +63,7 @@ export class Health { * @returns {Promise<Models.HealthStatus>} */ getCache(): Promise<Models.HealthStatus> { + const apiPath = '/health/cache'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -78,11 +82,36 @@ export class Health { /** * Get the SSL certificate for a domain * - * @param {string} domain + * @param {string} params.domain - string + * @throws {AppwriteException} + * @returns {Promise<Models.HealthCertificate>} + */ + getCertificate(params?: { domain?: string }): Promise<Models.HealthCertificate>; + /** + * Get the SSL certificate for a domain + * + * @param {string} domain - string * @throws {AppwriteException} * @returns {Promise<Models.HealthCertificate>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getCertificate(domain?: string): Promise<Models.HealthCertificate> { + getCertificate(domain?: string): Promise<Models.HealthCertificate>; + getCertificate( + paramsOrFirst?: { domain?: string } | string + ): Promise<Models.HealthCertificate> { + let params: { domain?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain?: string }; + } else { + params = { + domain: paramsOrFirst as string + }; + } + + const domain = params.domain; + + const apiPath = '/health/certificate'; const payload: Payload = {}; if (typeof domain !== 'undefined') { @@ -108,6 +137,7 @@ export class Health { * @returns {Promise<Models.HealthStatus>} */ getDB(): Promise<Models.HealthStatus> { + const apiPath = '/health/db'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -130,6 +160,7 @@ export class Health { * @returns {Promise<Models.HealthStatus>} */ getPubSub(): Promise<Models.HealthStatus> { + const apiPath = '/health/pubsub'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -148,11 +179,36 @@ export class Health { /** * Get the number of builds that are waiting to be processed in the Appwrite internal queue server. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} */ - getQueueBuilds(threshold?: number): Promise<Models.HealthQueue> { + getQueueBuilds(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of builds that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueBuilds(threshold?: number): Promise<Models.HealthQueue>; + getQueueBuilds( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/builds'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -174,11 +230,36 @@ export class Health { /** * Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} */ - getQueueCertificates(threshold?: number): Promise<Models.HealthQueue> { + getQueueCertificates(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueCertificates(threshold?: number): Promise<Models.HealthQueue>; + getQueueCertificates( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/certificates'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -200,12 +281,41 @@ export class Health { /** * Get the number of database changes that are waiting to be processed in the Appwrite internal queue server. * - * @param {string} name - * @param {number} threshold + * @param {string} params.name - Queue name for which to check the queue size + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} */ - getQueueDatabases(name?: string, threshold?: number): Promise<Models.HealthQueue> { + getQueueDatabases(params?: { name?: string, threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of database changes that are waiting to be processed in the Appwrite internal queue server. + * + * @param {string} name - Queue name for which to check the queue size + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueDatabases(name?: string, threshold?: number): Promise<Models.HealthQueue>; + getQueueDatabases( + paramsOrFirst?: { name?: string, threshold?: number } | string, + ...rest: [(number)?] + ): Promise<Models.HealthQueue> { + let params: { name?: string, threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { name?: string, threshold?: number }; + } else { + params = { + name: paramsOrFirst as string, + threshold: rest[0] as number + }; + } + + const name = params.name; + const threshold = params.threshold; + + const apiPath = '/health/queue/databases'; const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -230,11 +340,36 @@ export class Health { /** * Get the number of background destructive changes that are waiting to be processed in the Appwrite internal queue server. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} */ - getQueueDeletes(threshold?: number): Promise<Models.HealthQueue> { + getQueueDeletes(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of background destructive changes that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueDeletes(threshold?: number): Promise<Models.HealthQueue>; + getQueueDeletes( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/deletes'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -257,15 +392,45 @@ export class Health { * Returns the amount of failed jobs in a given queue. * * - * @param {Name} name - * @param {number} threshold + * @param {Name} params.name - The name of the queue + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} */ - getFailedJobs(name: Name, threshold?: number): Promise<Models.HealthQueue> { + getFailedJobs(params: { name: Name, threshold?: number }): Promise<Models.HealthQueue>; + /** + * Returns the amount of failed jobs in a given queue. + * + * + * @param {Name} name - The name of the queue + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getFailedJobs(name: Name, threshold?: number): Promise<Models.HealthQueue>; + getFailedJobs( + paramsOrFirst: { name: Name, threshold?: number } | Name, + ...rest: [(number)?] + ): Promise<Models.HealthQueue> { + let params: { name: Name, threshold?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'name' in paramsOrFirst)) { + params = (paramsOrFirst || {}) as { name: Name, threshold?: number }; + } else { + params = { + name: paramsOrFirst as Name, + threshold: rest[0] as number + }; + } + + const name = params.name; + const threshold = params.threshold; + if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/health/queue/failed/{name}'.replace('{name}', name); const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -287,11 +452,36 @@ export class Health { /** * Get the number of function executions that are waiting to be processed in the Appwrite internal queue server. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueFunctions(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of function executions that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getQueueFunctions(threshold?: number): Promise<Models.HealthQueue> { + getQueueFunctions(threshold?: number): Promise<Models.HealthQueue>; + getQueueFunctions( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/functions'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -313,11 +503,36 @@ export class Health { /** * Get the number of logs that are waiting to be processed in the Appwrite internal queue server. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueLogs(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of logs that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getQueueLogs(threshold?: number): Promise<Models.HealthQueue> { + getQueueLogs(threshold?: number): Promise<Models.HealthQueue>; + getQueueLogs( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/logs'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -339,11 +554,36 @@ export class Health { /** * Get the number of mails that are waiting to be processed in the Appwrite internal queue server. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueMails(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of mails that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getQueueMails(threshold?: number): Promise<Models.HealthQueue> { + getQueueMails(threshold?: number): Promise<Models.HealthQueue>; + getQueueMails( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/mails'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -365,11 +605,36 @@ export class Health { /** * Get the number of messages that are waiting to be processed in the Appwrite internal queue server. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueMessaging(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of messages that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getQueueMessaging(threshold?: number): Promise<Models.HealthQueue> { + getQueueMessaging(threshold?: number): Promise<Models.HealthQueue>; + getQueueMessaging( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/messaging'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -391,11 +656,36 @@ export class Health { /** * Get the number of migrations that are waiting to be processed in the Appwrite internal queue server. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} */ - getQueueMigrations(threshold?: number): Promise<Models.HealthQueue> { + getQueueMigrations(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of migrations that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueMigrations(threshold?: number): Promise<Models.HealthQueue>; + getQueueMigrations( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/migrations'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -417,11 +707,36 @@ export class Health { /** * Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} */ - getQueueStatsResources(threshold?: number): Promise<Models.HealthQueue> { + getQueueStatsResources(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueStatsResources(threshold?: number): Promise<Models.HealthQueue>; + getQueueStatsResources( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/stats-resources'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -443,11 +758,36 @@ export class Health { /** * Get the number of metrics that are waiting to be processed in the Appwrite internal queue server. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueUsage(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of metrics that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getQueueUsage(threshold?: number): Promise<Models.HealthQueue> { + getQueueUsage(threshold?: number): Promise<Models.HealthQueue>; + getQueueUsage( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/stats-usage'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -469,11 +809,36 @@ export class Health { /** * Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. * - * @param {number} threshold + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise<Models.HealthQueue>} */ - getQueueWebhooks(threshold?: number): Promise<Models.HealthQueue> { + getQueueWebhooks(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueWebhooks(threshold?: number): Promise<Models.HealthQueue>; + getQueueWebhooks( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + const apiPath = '/health/queue/webhooks'; const payload: Payload = {}; if (typeof threshold !== 'undefined') { @@ -499,6 +864,7 @@ export class Health { * @returns {Promise<Models.HealthStatus>} */ getStorage(): Promise<Models.HealthStatus> { + const apiPath = '/health/storage'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -521,6 +887,7 @@ export class Health { * @returns {Promise<Models.HealthStatus>} */ getStorageLocal(): Promise<Models.HealthStatus> { + const apiPath = '/health/storage/local'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -543,6 +910,7 @@ export class Health { * @returns {Promise<Models.HealthTime>} */ getTime(): Promise<Models.HealthTime> { + const apiPath = '/health/time'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); diff --git a/src/services/locale.ts b/src/services/locale.ts index 48bba1f..e6b4087 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + export class Locale { client: Client; @@ -17,6 +18,7 @@ export class Locale { * @returns {Promise<Models.Locale>} */ get(): Promise<Models.Locale> { + const apiPath = '/locale'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -39,6 +41,7 @@ export class Locale { * @returns {Promise<Models.LocaleCodeList>} */ listCodes(): Promise<Models.LocaleCodeList> { + const apiPath = '/locale/codes'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -61,6 +64,7 @@ export class Locale { * @returns {Promise<Models.ContinentList>} */ listContinents(): Promise<Models.ContinentList> { + const apiPath = '/locale/continents'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -83,6 +87,7 @@ export class Locale { * @returns {Promise<Models.CountryList>} */ listCountries(): Promise<Models.CountryList> { + const apiPath = '/locale/countries'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -105,6 +110,7 @@ export class Locale { * @returns {Promise<Models.CountryList>} */ listCountriesEU(): Promise<Models.CountryList> { + const apiPath = '/locale/countries/eu'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -127,6 +133,7 @@ export class Locale { * @returns {Promise<Models.PhoneList>} */ listCountriesPhones(): Promise<Models.PhoneList> { + const apiPath = '/locale/countries/phones'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -149,6 +156,7 @@ export class Locale { * @returns {Promise<Models.CurrencyList>} */ listCurrencies(): Promise<Models.CurrencyList> { + const apiPath = '/locale/currencies'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -171,6 +179,7 @@ export class Locale { * @returns {Promise<Models.LanguageList>} */ listLanguages(): Promise<Models.LanguageList> { + const apiPath = '/locale/languages'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 07830ab..480bef4 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,5 +1,6 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { MessagePriority } from '../enums/message-priority'; import { SmtpEncryption } from '../enums/smtp-encryption'; @@ -13,12 +14,41 @@ export class Messaging { /** * Get a list of all messages from the current Appwrite project. * - * @param {string[]} queries - * @param {string} search + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.MessageList>} + */ + listMessages(params?: { queries?: string[], search?: string }): Promise<Models.MessageList>; + /** + * Get a list of all messages from the current Appwrite project. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.MessageList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listMessages(queries?: string[], search?: string): Promise<Models.MessageList> { + listMessages(queries?: string[], search?: string): Promise<Models.MessageList>; + listMessages( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.MessageList> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + const apiPath = '/messaging/messages'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -43,22 +73,80 @@ export class Messaging { /** * Create a new email message. * - * @param {string} messageId - * @param {string} subject - * @param {string} content - * @param {string[]} topics - * @param {string[]} users - * @param {string[]} targets - * @param {string[]} cc - * @param {string[]} bcc - * @param {string[]} attachments - * @param {boolean} draft - * @param {boolean} html - * @param {string} scheduledAt + * @param {string} params.messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.subject - Email Subject. + * @param {string} params.content - Email Content. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {string[]} params.cc - Array of target IDs to be added as CC. + * @param {string[]} params.bcc - Array of target IDs to be added as BCC. + * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {boolean} params.draft - Is message a draft + * @param {boolean} params.html - Is content of type HTML + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + createEmail(params: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }): Promise<Models.Message>; + /** + * Create a new email message. + * + * @param {string} messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} subject - Email Subject. + * @param {string} content - Email Content. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {string[]} cc - Array of target IDs to be added as CC. + * @param {string[]} bcc - Array of target IDs to be added as BCC. + * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {boolean} draft - Is message a draft + * @param {boolean} html - Is content of type HTML + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createEmail(messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string): Promise<Models.Message> { + createEmail(messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string): Promise<Models.Message>; + createEmail( + paramsOrFirst: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (string[])?, (string[])?, (string[])?, (string[])?, (string[])?, (boolean)?, (boolean)?, (string)?] + ): Promise<Models.Message> { + let params: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }; + } else { + params = { + messageId: paramsOrFirst as string, + subject: rest[0] as string, + content: rest[1] as string, + topics: rest[2] as string[], + users: rest[3] as string[], + targets: rest[4] as string[], + cc: rest[5] as string[], + bcc: rest[6] as string[], + attachments: rest[7] as string[], + draft: rest[8] as boolean, + html: rest[9] as boolean, + scheduledAt: rest[10] as string + }; + } + + const messageId = params.messageId; + const subject = params.subject; + const content = params.content; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const cc = params.cc; + const bcc = params.bcc; + const attachments = params.attachments; + const draft = params.draft; + const html = params.html; + const scheduledAt = params.scheduledAt; + if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } @@ -68,6 +156,7 @@ export class Messaging { if (typeof content === 'undefined') { throw new AppwriteException('Missing required parameter: "content"'); } + const apiPath = '/messaging/messages/email'; const payload: Payload = {}; if (typeof messageId !== 'undefined') { @@ -124,25 +213,85 @@ export class Messaging { * Update an email message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. * * - * @param {string} messageId - * @param {string[]} topics - * @param {string[]} users - * @param {string[]} targets - * @param {string} subject - * @param {string} content - * @param {boolean} draft - * @param {boolean} html - * @param {string[]} cc - * @param {string[]} bcc - * @param {string} scheduledAt - * @param {string[]} attachments + * @param {string} params.messageId - Message ID. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {string} params.subject - Email Subject. + * @param {string} params.content - Email Content. + * @param {boolean} params.draft - Is message a draft + * @param {boolean} params.html - Is content of type HTML + * @param {string[]} params.cc - Array of target IDs to be added as CC. + * @param {string[]} params.bcc - Array of target IDs to be added as BCC. + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + updateEmail(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }): Promise<Models.Message>; + /** + * Update an email message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} messageId - Message ID. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {string} subject - Email Subject. + * @param {string} content - Email Content. + * @param {boolean} draft - Is message a draft + * @param {boolean} html - Is content of type HTML + * @param {string[]} cc - Array of target IDs to be added as CC. + * @param {string[]} bcc - Array of target IDs to be added as BCC. + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @throws {AppwriteException} * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[]): Promise<Models.Message> { + updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[]): Promise<Models.Message>; + updateEmail( + paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] } | string, + ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (string)?, (boolean)?, (boolean)?, (string[])?, (string[])?, (string)?, (string[])?] + ): Promise<Models.Message> { + let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }; + } else { + params = { + messageId: paramsOrFirst as string, + topics: rest[0] as string[], + users: rest[1] as string[], + targets: rest[2] as string[], + subject: rest[3] as string, + content: rest[4] as string, + draft: rest[5] as boolean, + html: rest[6] as boolean, + cc: rest[7] as string[], + bcc: rest[8] as string[], + scheduledAt: rest[9] as string, + attachments: rest[10] as string[] + }; + } + + const messageId = params.messageId; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const subject = params.subject; + const content = params.content; + const draft = params.draft; + const html = params.html; + const cc = params.cc; + const bcc = params.bcc; + const scheduledAt = params.scheduledAt; + const attachments = params.attachments; + if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } + const apiPath = '/messaging/messages/email/{messageId}'.replace('{messageId}', messageId); const payload: Payload = {}; if (typeof topics !== 'undefined') { @@ -195,32 +344,112 @@ export class Messaging { /** * Create a new push notification. * - * @param {string} messageId - * @param {string} title - * @param {string} body - * @param {string[]} topics - * @param {string[]} users - * @param {string[]} targets - * @param {object} data - * @param {string} action - * @param {string} image - * @param {string} icon - * @param {string} sound - * @param {string} color - * @param {string} tag - * @param {number} badge - * @param {boolean} draft - * @param {string} scheduledAt - * @param {boolean} contentAvailable - * @param {boolean} critical - * @param {MessagePriority} priority + * @param {string} params.messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.title - Title for push notification. + * @param {string} params.body - Body for push notification. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {object} params.data - Additional key-value pair data for push notification. + * @param {string} params.action - Action for push notification. + * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string} params.icon - Icon for push notification. Available only for Android and Web Platform. + * @param {string} params.sound - Sound for push notification. Available only for Android and iOS Platform. + * @param {string} params.color - Color for push notification. Available only for Android Platform. + * @param {string} params.tag - Tag for push notification. Available only for Android Platform. + * @param {number} params.badge - Badge for push notification. Available only for iOS Platform. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + createPush(params: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }): Promise<Models.Message>; + /** + * Create a new push notification. + * + * @param {string} messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} title - Title for push notification. + * @param {string} body - Body for push notification. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {object} data - Additional key-value pair data for push notification. + * @param {string} action - Action for push notification. + * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string} icon - Icon for push notification. Available only for Android and Web Platform. + * @param {string} sound - Sound for push notification. Available only for Android and iOS Platform. + * @param {string} color - Color for push notification. Available only for Android Platform. + * @param {string} tag - Tag for push notification. Available only for Android Platform. + * @param {number} badge - Badge for push notification. Available only for iOS Platform. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. * @throws {AppwriteException} * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createPush(messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise<Models.Message> { + createPush(messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise<Models.Message>; + createPush( + paramsOrFirst: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority } | string, + ...rest: [(string)?, (string)?, (string[])?, (string[])?, (string[])?, (object)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?, (MessagePriority)?] + ): Promise<Models.Message> { + let params: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + } else { + params = { + messageId: paramsOrFirst as string, + title: rest[0] as string, + body: rest[1] as string, + topics: rest[2] as string[], + users: rest[3] as string[], + targets: rest[4] as string[], + data: rest[5] as object, + action: rest[6] as string, + image: rest[7] as string, + icon: rest[8] as string, + sound: rest[9] as string, + color: rest[10] as string, + tag: rest[11] as string, + badge: rest[12] as number, + draft: rest[13] as boolean, + scheduledAt: rest[14] as string, + contentAvailable: rest[15] as boolean, + critical: rest[16] as boolean, + priority: rest[17] as MessagePriority + }; + } + + const messageId = params.messageId; + const title = params.title; + const body = params.body; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const data = params.data; + const action = params.action; + const image = params.image; + const icon = params.icon; + const sound = params.sound; + const color = params.color; + const tag = params.tag; + const badge = params.badge; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + const contentAvailable = params.contentAvailable; + const critical = params.critical; + const priority = params.priority; + if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } + const apiPath = '/messaging/messages/push'; const payload: Payload = {}; if (typeof messageId !== 'undefined') { @@ -298,32 +527,113 @@ export class Messaging { * Update a push notification by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. * * - * @param {string} messageId - * @param {string[]} topics - * @param {string[]} users - * @param {string[]} targets - * @param {string} title - * @param {string} body - * @param {object} data - * @param {string} action - * @param {string} image - * @param {string} icon - * @param {string} sound - * @param {string} color - * @param {string} tag - * @param {number} badge - * @param {boolean} draft - * @param {string} scheduledAt - * @param {boolean} contentAvailable - * @param {boolean} critical - * @param {MessagePriority} priority + * @param {string} params.messageId - Message ID. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {string} params.title - Title for push notification. + * @param {string} params.body - Body for push notification. + * @param {object} params.data - Additional Data for push notification. + * @param {string} params.action - Action for push notification. + * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string} params.icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string} params.sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string} params.color - Color for push notification. Available only for Android platforms. + * @param {string} params.tag - Tag for push notification. Available only for Android platforms. + * @param {number} params.badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + updatePush(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }): Promise<Models.Message>; + /** + * Update a push notification by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} messageId - Message ID. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {string} title - Title for push notification. + * @param {string} body - Body for push notification. + * @param {object} data - Additional Data for push notification. + * @param {string} action - Action for push notification. + * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string} icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string} sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string} color - Color for push notification. Available only for Android platforms. + * @param {string} tag - Tag for push notification. Available only for Android platforms. + * @param {number} badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. * @throws {AppwriteException} * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updatePush(messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise<Models.Message> { + updatePush(messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise<Models.Message>; + updatePush( + paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority } | string, + ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (string)?, (object)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?, (MessagePriority)?] + ): Promise<Models.Message> { + let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + } else { + params = { + messageId: paramsOrFirst as string, + topics: rest[0] as string[], + users: rest[1] as string[], + targets: rest[2] as string[], + title: rest[3] as string, + body: rest[4] as string, + data: rest[5] as object, + action: rest[6] as string, + image: rest[7] as string, + icon: rest[8] as string, + sound: rest[9] as string, + color: rest[10] as string, + tag: rest[11] as string, + badge: rest[12] as number, + draft: rest[13] as boolean, + scheduledAt: rest[14] as string, + contentAvailable: rest[15] as boolean, + critical: rest[16] as boolean, + priority: rest[17] as MessagePriority + }; + } + + const messageId = params.messageId; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const title = params.title; + const body = params.body; + const data = params.data; + const action = params.action; + const image = params.image; + const icon = params.icon; + const sound = params.sound; + const color = params.color; + const tag = params.tag; + const badge = params.badge; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + const contentAvailable = params.contentAvailable; + const critical = params.critical; + const priority = params.priority; + if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } + const apiPath = '/messaging/messages/push/{messageId}'.replace('{messageId}', messageId); const payload: Payload = {}; if (typeof topics !== 'undefined') { @@ -397,23 +707,169 @@ export class Messaging { /** * Create a new SMS message. * - * @param {string} messageId - * @param {string} content - * @param {string[]} topics - * @param {string[]} users - * @param {string[]} targets - * @param {boolean} draft - * @param {string} scheduledAt + * @param {string} params.messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.content - SMS Content. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead. + */ + createSms(params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }): Promise<Models.Message>; + /** + * Create a new SMS message. + * + * @param {string} messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} content - SMS Content. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSms(messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise<Models.Message>; + createSms( + paramsOrFirst: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string } | string, + ...rest: [(string)?, (string[])?, (string[])?, (string[])?, (boolean)?, (string)?] + ): Promise<Models.Message> { + let params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + } else { + params = { + messageId: paramsOrFirst as string, + content: rest[0] as string, + topics: rest[1] as string[], + users: rest[2] as string[], + targets: rest[3] as string[], + draft: rest[4] as boolean, + scheduledAt: rest[5] as string + }; + } + + const messageId = params.messageId; + const content = params.content; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (typeof content === 'undefined') { + throw new AppwriteException('Missing required parameter: "content"'); + } + + const apiPath = '/messaging/messages/sms'; + const payload: Payload = {}; + if (typeof messageId !== 'undefined') { + payload['messageId'] = messageId; + } + if (typeof content !== 'undefined') { + payload['content'] = content; + } + if (typeof topics !== 'undefined') { + payload['topics'] = topics; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + if (typeof targets !== 'undefined') { + payload['targets'] = targets; + } + if (typeof draft !== 'undefined') { + payload['draft'] = draft; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new SMS message. + * + * @param {string} params.messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.content - SMS Content. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + createSMS(params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }): Promise<Models.Message>; + /** + * Create a new SMS message. + * + * @param {string} messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} content - SMS Content. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createSms(messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise<Models.Message> { + createSMS(messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise<Models.Message>; + createSMS( + paramsOrFirst: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string } | string, + ...rest: [(string)?, (string[])?, (string[])?, (string[])?, (boolean)?, (string)?] + ): Promise<Models.Message> { + let params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + } else { + params = { + messageId: paramsOrFirst as string, + content: rest[0] as string, + topics: rest[1] as string[], + users: rest[2] as string[], + targets: rest[3] as string[], + draft: rest[4] as boolean, + scheduledAt: rest[5] as string + }; + } + + const messageId = params.messageId; + const content = params.content; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } if (typeof content === 'undefined') { throw new AppwriteException('Missing required parameter: "content"'); } + const apiPath = '/messaging/messages/sms'; const payload: Payload = {}; if (typeof messageId !== 'undefined') { @@ -455,20 +911,163 @@ export class Messaging { * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. * * - * @param {string} messageId - * @param {string[]} topics - * @param {string[]} users - * @param {string[]} targets - * @param {string} content - * @param {boolean} draft - * @param {string} scheduledAt + * @param {string} params.messageId - Message ID. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {string} params.content - Email Content. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead. + */ + updateSms(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }): Promise<Models.Message>; + /** + * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} messageId - Message ID. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {string} content - Email Content. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSms(messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise<Models.Message>; + updateSms( + paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string } | string, + ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (boolean)?, (string)?] + ): Promise<Models.Message> { + let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + } else { + params = { + messageId: paramsOrFirst as string, + topics: rest[0] as string[], + users: rest[1] as string[], + targets: rest[2] as string[], + content: rest[3] as string, + draft: rest[4] as boolean, + scheduledAt: rest[5] as string + }; + } + + const messageId = params.messageId; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const content = params.content; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + + const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', messageId); + const payload: Payload = {}; + if (typeof topics !== 'undefined') { + payload['topics'] = topics; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + if (typeof targets !== 'undefined') { + payload['targets'] = targets; + } + if (typeof content !== 'undefined') { + payload['content'] = content; + } + if (typeof draft !== 'undefined') { + payload['draft'] = draft; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + 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, + ); + } + + /** + * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} params.messageId - Message ID. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {string} params.content - Email Content. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + updateSMS(params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }): Promise<Models.Message>; + /** + * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} messageId - Message ID. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {string} content - Email Content. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateSms(messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise<Models.Message> { + updateSMS(messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise<Models.Message>; + updateSMS( + paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string } | string, + ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (boolean)?, (string)?] + ): Promise<Models.Message> { + let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + } else { + params = { + messageId: paramsOrFirst as string, + topics: rest[0] as string[], + users: rest[1] as string[], + targets: rest[2] as string[], + content: rest[3] as string, + draft: rest[4] as boolean, + scheduledAt: rest[5] as string + }; + } + + const messageId = params.messageId; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const content = params.content; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } + const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', messageId); const payload: Payload = {}; if (typeof topics !== 'undefined') { @@ -507,14 +1106,40 @@ export class Messaging { * Get a message by its unique ID. * * - * @param {string} messageId + * @param {string} params.messageId - Message ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + getMessage(params: { messageId: string }): Promise<Models.Message>; + /** + * Get a message by its unique ID. + * + * + * @param {string} messageId - Message ID. * @throws {AppwriteException} * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getMessage(messageId: string): Promise<Models.Message> { + getMessage(messageId: string): Promise<Models.Message>; + getMessage( + paramsOrFirst: { messageId: string } | string + ): Promise<Models.Message> { + let params: { messageId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string }; + } else { + params = { + messageId: paramsOrFirst as string + }; + } + + const messageId = params.messageId; + if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } + const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', messageId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -533,14 +1158,39 @@ export class Messaging { /** * Delete a message. If the message is not a draft or scheduled, but has been sent, this will not recall the message. * - * @param {string} messageId + * @param {string} params.messageId - Message ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { messageId: string }): Promise<{}>; + /** + * Delete a message. If the message is not a draft or scheduled, but has been sent, this will not recall the message. + * + * @param {string} messageId - Message ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - delete(messageId: string): Promise<{}> { + delete(messageId: string): Promise<{}>; + delete( + paramsOrFirst: { messageId: string } | string + ): Promise<{}> { + let params: { messageId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string }; + } else { + params = { + messageId: paramsOrFirst as string + }; + } + + const messageId = params.messageId; + if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } + const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', messageId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -560,15 +1210,44 @@ export class Messaging { /** * Get the message activity logs listed by its unique ID. * - * @param {string} messageId - * @param {string[]} queries + * @param {string} params.messageId - Message ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + */ + listMessageLogs(params: { messageId: string, queries?: string[] }): Promise<Models.LogList>; + /** + * Get the message activity logs listed by its unique ID. + * + * @param {string} messageId - Message ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @throws {AppwriteException} * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listMessageLogs(messageId: string, queries?: string[]): Promise<Models.LogList> { + listMessageLogs(messageId: string, queries?: string[]): Promise<Models.LogList>; + listMessageLogs( + paramsOrFirst: { messageId: string, queries?: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.LogList> { + let params: { messageId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, queries?: string[] }; + } else { + params = { + messageId: paramsOrFirst as string, + queries: rest[0] as string[] + }; + } + + const messageId = params.messageId; + const queries = params.queries; + if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } + const apiPath = '/messaging/messages/{messageId}/logs'.replace('{messageId}', messageId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -590,15 +1269,44 @@ export class Messaging { /** * Get a list of the targets associated with a message. * - * @param {string} messageId - * @param {string[]} queries + * @param {string} params.messageId - Message ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType + * @throws {AppwriteException} + * @returns {Promise<Models.TargetList>} + */ + listTargets(params: { messageId: string, queries?: string[] }): Promise<Models.TargetList>; + /** + * Get a list of the targets associated with a message. + * + * @param {string} messageId - Message ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType * @throws {AppwriteException} * @returns {Promise<Models.TargetList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listTargets(messageId: string, queries?: string[]): Promise<Models.TargetList> { + listTargets(messageId: string, queries?: string[]): Promise<Models.TargetList>; + listTargets( + paramsOrFirst: { messageId: string, queries?: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.TargetList> { + let params: { messageId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, queries?: string[] }; + } else { + params = { + messageId: paramsOrFirst as string, + queries: rest[0] as string[] + }; + } + + const messageId = params.messageId; + const queries = params.queries; + if (typeof messageId === 'undefined') { throw new AppwriteException('Missing required parameter: "messageId"'); } + const apiPath = '/messaging/messages/{messageId}/targets'.replace('{messageId}', messageId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -620,12 +1328,41 @@ export class Messaging { /** * Get a list of all providers from the current Appwrite project. * - * @param {string[]} queries - * @param {string} search + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, provider, type, enabled + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.ProviderList>} + */ + listProviders(params?: { queries?: string[], search?: string }): Promise<Models.ProviderList>; + /** + * Get a list of all providers from the current Appwrite project. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, provider, type, enabled + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.ProviderList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listProviders(queries?: string[], search?: string): Promise<Models.ProviderList> { + listProviders(queries?: string[], search?: string): Promise<Models.ProviderList>; + listProviders( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.ProviderList> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + const apiPath = '/messaging/providers'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -650,24 +1387,72 @@ export class Messaging { /** * Create a new Apple Push Notification service provider. * - * @param {string} providerId - * @param {string} name - * @param {string} authKey - * @param {string} authKeyId - * @param {string} teamId - * @param {string} bundleId - * @param {boolean} sandbox - * @param {boolean} enabled + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.authKey - APNS authentication key. + * @param {string} params.authKeyId - APNS authentication key ID. + * @param {string} params.teamId - APNS team ID. + * @param {string} params.bundleId - APNS bundle ID. + * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead. + */ + createApnsProvider(params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Apple Push Notification service provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} authKey - APNS authentication key. + * @param {string} authKeyId - APNS authentication key ID. + * @param {string} teamId - APNS team ID. + * @param {string} bundleId - APNS bundle ID. + * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createApnsProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise<Models.Provider> { + createApnsProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise<Models.Provider>; + createApnsProvider( + paramsOrFirst: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + authKey: rest[1] as string, + authKeyId: rest[2] as string, + teamId: rest[3] as string, + bundleId: rest[4] as string, + sandbox: rest[5] as boolean, + enabled: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const authKey = params.authKey; + const authKeyId = params.authKeyId; + const teamId = params.teamId; + const bundleId = params.bundleId; + const sandbox = params.sandbox; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/messaging/providers/apns'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -709,31 +1494,81 @@ export class Messaging { } /** - * Update a Apple Push Notification service provider by its unique ID. + * Create a new Apple Push Notification service provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.authKey - APNS authentication key. + * @param {string} params.authKeyId - APNS authentication key ID. + * @param {string} params.teamId - APNS team ID. + * @param {string} params.bundleId - APNS bundle ID. + * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createAPNSProvider(params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Apple Push Notification service provider. * - * @param {string} providerId - * @param {string} name - * @param {boolean} enabled - * @param {string} authKey - * @param {string} authKeyId - * @param {string} teamId - * @param {string} bundleId - * @param {boolean} sandbox + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} authKey - APNS authentication key. + * @param {string} authKeyId - APNS authentication key ID. + * @param {string} teamId - APNS team ID. + * @param {string} bundleId - APNS bundle ID. + * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateApnsProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise<Models.Provider> { + createAPNSProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise<Models.Provider>; + createAPNSProvider( + paramsOrFirst: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + authKey: rest[1] as string, + authKeyId: rest[2] as string, + teamId: rest[3] as string, + bundleId: rest[4] as string, + sandbox: rest[5] as boolean, + enabled: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const authKey = params.authKey; + const authKeyId = params.authKeyId; + const teamId = params.teamId; + const bundleId = params.bundleId; + const sandbox = params.sandbox; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } - const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', providerId); + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/apns'; const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } if (typeof name !== 'undefined') { payload['name'] = name; } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } if (typeof authKey !== 'undefined') { payload['authKey'] = authKey; } @@ -749,6 +1584,9 @@ export class Messaging { if (typeof sandbox !== 'undefined') { payload['sandbox'] = sandbox; } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -756,7 +1594,7 @@ export class Messaging { } return this.client.call( - 'patch', + 'post', uri, apiHeaders, payload, @@ -764,22 +1602,263 @@ export class Messaging { } /** - * Create a new Firebase Cloud Messaging provider. + * Update a Apple Push Notification service provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.authKey - APNS authentication key. + * @param {string} params.authKeyId - APNS authentication key ID. + * @param {string} params.teamId - APNS team ID. + * @param {string} params.bundleId - APNS bundle ID. + * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. + */ + updateApnsProvider(params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }): Promise<Models.Provider>; + /** + * Update a Apple Push Notification service provider by its unique ID. * - * @param {string} providerId - * @param {string} name - * @param {object} serviceAccountJSON - * @param {boolean} enabled + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} authKey - APNS authentication key. + * @param {string} authKeyId - APNS authentication key ID. + * @param {string} teamId - APNS team ID. + * @param {string} bundleId - APNS bundle ID. + * @param {boolean} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createFcmProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise<Models.Provider> { + updateApnsProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise<Models.Provider>; + updateApnsProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + authKey: rest[2] as string, + authKeyId: rest[3] as string, + teamId: rest[4] as string, + bundleId: rest[5] as string, + sandbox: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const authKey = params.authKey; + const authKeyId = params.authKeyId; + const teamId = params.teamId; + const bundleId = params.bundleId; + const sandbox = params.sandbox; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); + + const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof authKey !== 'undefined') { + payload['authKey'] = authKey; + } + if (typeof authKeyId !== 'undefined') { + payload['authKeyId'] = authKeyId; + } + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + if (typeof bundleId !== 'undefined') { + payload['bundleId'] = bundleId; + } + if (typeof sandbox !== 'undefined') { + payload['sandbox'] = sandbox; + } + 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, + ); + } + + /** + * Update a Apple Push Notification service provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.authKey - APNS authentication key. + * @param {string} params.authKeyId - APNS authentication key ID. + * @param {string} params.teamId - APNS team ID. + * @param {string} params.bundleId - APNS bundle ID. + * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateAPNSProvider(params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }): Promise<Models.Provider>; + /** + * Update a Apple Push Notification service provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} authKey - APNS authentication key. + * @param {string} authKeyId - APNS authentication key ID. + * @param {string} teamId - APNS team ID. + * @param {string} bundleId - APNS bundle ID. + * @param {boolean} sandbox - Use APNS sandbox environment. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateAPNSProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise<Models.Provider>; + updateAPNSProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + authKey: rest[2] as string, + authKeyId: rest[3] as string, + teamId: rest[4] as string, + bundleId: rest[5] as string, + sandbox: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const authKey = params.authKey; + const authKeyId = params.authKeyId; + const teamId = params.teamId; + const bundleId = params.bundleId; + const sandbox = params.sandbox; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof authKey !== 'undefined') { + payload['authKey'] = authKey; + } + if (typeof authKeyId !== 'undefined') { + payload['authKeyId'] = authKeyId; + } + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + if (typeof bundleId !== 'undefined') { + payload['bundleId'] = bundleId; + } + if (typeof sandbox !== 'undefined') { + payload['sandbox'] = sandbox; + } + 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, + ); + } + + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. + */ + createFcmProvider(params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFcmProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise<Models.Provider>; + createFcmProvider( + paramsOrFirst: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean } | string, + ...rest: [(string)?, (object)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + serviceAccountJSON: rest[1] as object, + enabled: rest[2] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const serviceAccountJSON = params.serviceAccountJSON; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/messaging/providers/fcm'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -808,20 +1887,210 @@ export class Messaging { ); } + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createFCMProvider(params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFCMProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise<Models.Provider>; + createFCMProvider( + paramsOrFirst: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean } | string, + ...rest: [(string)?, (object)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + serviceAccountJSON: rest[1] as object, + enabled: rest[2] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const serviceAccountJSON = params.serviceAccountJSON; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/fcm'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof serviceAccountJSON !== 'undefined') { + payload['serviceAccountJSON'] = serviceAccountJSON; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a Firebase Cloud Messaging provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. + */ + updateFcmProvider(params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }): Promise<Models.Provider>; + /** + * Update a Firebase Cloud Messaging provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {object} serviceAccountJSON - FCM service account JSON. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateFcmProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise<Models.Provider>; + updateFcmProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object } | string, + ...rest: [(string)?, (boolean)?, (object)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + serviceAccountJSON: rest[2] as object + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const serviceAccountJSON = params.serviceAccountJSON; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/fcm/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof serviceAccountJSON !== 'undefined') { + payload['serviceAccountJSON'] = serviceAccountJSON; + } + 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, + ); + } + + /** + * Update a Firebase Cloud Messaging provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateFCMProvider(params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * - * @param {string} providerId - * @param {string} name - * @param {boolean} enabled - * @param {object} serviceAccountJSON + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {object} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateFcmProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise<Models.Provider> { + updateFCMProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise<Models.Provider>; + updateFCMProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object } | string, + ...rest: [(string)?, (boolean)?, (object)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + serviceAccountJSON: rest[2] as object + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const serviceAccountJSON = params.serviceAccountJSON; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/fcm/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -850,26 +2119,79 @@ export class Messaging { /** * Create a new Mailgun provider. * - * @param {string} providerId - * @param {string} name - * @param {string} apiKey - * @param {string} domain - * @param {boolean} isEuRegion - * @param {string} fromName - * @param {string} fromEmail - * @param {string} replyToName - * @param {string} replyToEmail - * @param {boolean} enabled + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.apiKey - Mailgun API Key. + * @param {string} params.domain - Mailgun Domain. + * @param {boolean} params.isEuRegion - Set as EU region. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createMailgunProvider(params: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Mailgun provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} apiKey - Mailgun API Key. + * @param {string} domain - Mailgun Domain. + * @param {boolean} isEuRegion - Set as EU region. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createMailgunProvider(providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider> { + createMailgunProvider(providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createMailgunProvider( + paramsOrFirst: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + apiKey: rest[1] as string, + domain: rest[2] as string, + isEuRegion: rest[3] as boolean, + fromName: rest[4] as string, + fromEmail: rest[5] as string, + replyToName: rest[6] as string, + replyToEmail: rest[7] as string, + enabled: rest[8] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const apiKey = params.apiKey; + const domain = params.domain; + const isEuRegion = params.isEuRegion; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/messaging/providers/mailgun'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -919,23 +2241,76 @@ export class Messaging { /** * Update a Mailgun provider by its unique ID. * - * @param {string} providerId - * @param {string} name - * @param {string} apiKey - * @param {string} domain - * @param {boolean} isEuRegion - * @param {boolean} enabled - * @param {string} fromName - * @param {string} fromEmail - * @param {string} replyToName - * @param {string} replyToEmail + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {string} params.apiKey - Mailgun API Key. + * @param {string} params.domain - Mailgun Domain. + * @param {boolean} params.isEuRegion - Set as EU region. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ - updateMailgunProvider(providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider> { + updateMailgunProvider(params: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise<Models.Provider>; + /** + * Update a Mailgun provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {string} apiKey - Mailgun API Key. + * @param {string} domain - Mailgun Domain. + * @param {boolean} isEuRegion - Set as EU region. + * @param {boolean} enabled - Set as enabled. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMailgunProvider(providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider>; + updateMailgunProvider( + paramsOrFirst: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?, (boolean)?, (string)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + apiKey: rest[1] as string, + domain: rest[2] as string, + isEuRegion: rest[3] as boolean, + enabled: rest[4] as boolean, + fromName: rest[5] as string, + fromEmail: rest[6] as string, + replyToName: rest[7] as string, + replyToEmail: rest[8] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const apiKey = params.apiKey; + const domain = params.domain; + const isEuRegion = params.isEuRegion; + const enabled = params.enabled; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/mailgun/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -982,22 +2357,63 @@ export class Messaging { /** * Create a new MSG91 provider. * - * @param {string} providerId - * @param {string} name - * @param {string} templateId - * @param {string} senderId - * @param {string} authKey - * @param {boolean} enabled + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.templateId - Msg91 template ID + * @param {string} params.senderId - Msg91 sender ID. + * @param {string} params.authKey - Msg91 auth key. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createMsg91Provider(params: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new MSG91 provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} templateId - Msg91 template ID + * @param {string} senderId - Msg91 sender ID. + * @param {string} authKey - Msg91 auth key. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider> { + createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider>; + createMsg91Provider( + paramsOrFirst: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + templateId: rest[1] as string, + senderId: rest[2] as string, + authKey: rest[3] as string, + enabled: rest[4] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const templateId = params.templateId; + const senderId = params.senderId; + const authKey = params.authKey; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/messaging/providers/msg91'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -1035,19 +2451,60 @@ export class Messaging { /** * Update a MSG91 provider by its unique ID. * - * @param {string} providerId - * @param {string} name - * @param {boolean} enabled - * @param {string} templateId - * @param {string} senderId - * @param {string} authKey + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.templateId - Msg91 template ID. + * @param {string} params.senderId - Msg91 sender ID. + * @param {string} params.authKey - Msg91 auth key. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateMsg91Provider(params: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }): Promise<Models.Provider>; + /** + * Update a MSG91 provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} templateId - Msg91 template ID. + * @param {string} senderId - Msg91 sender ID. + * @param {string} authKey - Msg91 auth key. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise<Models.Provider> { + updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise<Models.Provider>; + updateMsg91Provider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + templateId: rest[2] as string, + senderId: rest[3] as string, + authKey: rest[4] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const templateId = params.templateId; + const senderId = params.senderId; + const authKey = params.authKey; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -1082,24 +2539,71 @@ export class Messaging { /** * Create a new Sendgrid provider. * - * @param {string} providerId - * @param {string} name - * @param {string} apiKey - * @param {string} fromName - * @param {string} fromEmail - * @param {string} replyToName - * @param {string} replyToEmail - * @param {boolean} enabled + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.apiKey - Sendgrid API key. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ - createSendgridProvider(providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider> { + createSendgridProvider(params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Sendgrid provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} apiKey - Sendgrid API key. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSendgridProvider(providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createSendgridProvider( + paramsOrFirst: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + apiKey: rest[1] as string, + fromName: rest[2] as string, + fromEmail: rest[3] as string, + replyToName: rest[4] as string, + replyToEmail: rest[5] as string, + enabled: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const apiKey = params.apiKey; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/messaging/providers/sendgrid'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -1141,33 +2645,384 @@ export class Messaging { } /** - * Update a Sendgrid provider by its unique ID. + * Update a Sendgrid provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.apiKey - Sendgrid API key. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateSendgridProvider(params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise<Models.Provider>; + /** + * Update a Sendgrid provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} apiKey - Sendgrid API key. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSendgridProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider>; + updateSendgridProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + apiKey: rest[2] as string, + fromName: rest[3] as string, + fromEmail: rest[4] as string, + replyToName: rest[5] as string, + replyToEmail: rest[6] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const apiKey = params.apiKey; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + 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, + ); + } + + /** + * Create a new SMTP provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} params.port - The default SMTP server port. + * @param {string} params.username - Authentication username. + * @param {string} params.password - Authentication password. + * @param {SmtpEncryption} params.encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {string} params.mailer - The value to use for the X-Mailer header. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. + */ + createSmtpProvider(params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new SMTP provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} port - The default SMTP server port. + * @param {string} username - Authentication username. + * @param {string} password - Authentication password. + * @param {SmtpEncryption} encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {string} mailer - The value to use for the X-Mailer header. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSmtpProvider(providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createSmtpProvider( + paramsOrFirst: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + host: rest[1] as string, + port: rest[2] as number, + username: rest[3] as string, + password: rest[4] as string, + encryption: rest[5] as SmtpEncryption, + autoTLS: rest[6] as boolean, + mailer: rest[7] as string, + fromName: rest[8] as string, + fromEmail: rest[9] as string, + replyToName: rest[10] as string, + replyToEmail: rest[11] as string, + enabled: rest[12] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const host = params.host; + const port = params.port; + const username = params.username; + const password = params.password; + const encryption = params.encryption; + const autoTLS = params.autoTLS; + const mailer = params.mailer; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof host === 'undefined') { + throw new AppwriteException('Missing required parameter: "host"'); + } + + const apiPath = '/messaging/providers/smtp'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof host !== 'undefined') { + payload['host'] = host; + } + if (typeof port !== 'undefined') { + payload['port'] = port; + } + if (typeof username !== 'undefined') { + payload['username'] = username; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof encryption !== 'undefined') { + payload['encryption'] = encryption; + } + if (typeof autoTLS !== 'undefined') { + payload['autoTLS'] = autoTLS; + } + if (typeof mailer !== 'undefined') { + payload['mailer'] = mailer; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new SMTP provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} params.port - The default SMTP server port. + * @param {string} params.username - Authentication username. + * @param {string} params.password - Authentication password. + * @param {SmtpEncryption} params.encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {string} params.mailer - The value to use for the X-Mailer header. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createSMTPProvider(params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new SMTP provider. * - * @param {string} providerId - * @param {string} name - * @param {boolean} enabled - * @param {string} apiKey - * @param {string} fromName - * @param {string} fromEmail - * @param {string} replyToName - * @param {string} replyToEmail + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} port - The default SMTP server port. + * @param {string} username - Authentication username. + * @param {string} password - Authentication password. + * @param {SmtpEncryption} encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {string} mailer - The value to use for the X-Mailer header. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateSendgridProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider> { + createSMTPProvider(providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createSMTPProvider( + paramsOrFirst: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + host: rest[1] as string, + port: rest[2] as number, + username: rest[3] as string, + password: rest[4] as string, + encryption: rest[5] as SmtpEncryption, + autoTLS: rest[6] as boolean, + mailer: rest[7] as string, + fromName: rest[8] as string, + fromEmail: rest[9] as string, + replyToName: rest[10] as string, + replyToEmail: rest[11] as string, + enabled: rest[12] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const host = params.host; + const port = params.port; + const username = params.username; + const password = params.password; + const encryption = params.encryption; + const autoTLS = params.autoTLS; + const mailer = params.mailer; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } - const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace('{providerId}', providerId); + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof host === 'undefined') { + throw new AppwriteException('Missing required parameter: "host"'); + } + + const apiPath = '/messaging/providers/smtp'; const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } if (typeof name !== 'undefined') { payload['name'] = name; } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + if (typeof host !== 'undefined') { + payload['host'] = host; } - if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + if (typeof port !== 'undefined') { + payload['port'] = port; + } + if (typeof username !== 'undefined') { + payload['username'] = username; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof encryption !== 'undefined') { + payload['encryption'] = encryption; + } + if (typeof autoTLS !== 'undefined') { + payload['autoTLS'] = autoTLS; + } + if (typeof mailer !== 'undefined') { + payload['mailer'] = mailer; } if (typeof fromName !== 'undefined') { payload['fromName'] = fromName; @@ -1181,6 +3036,9 @@ export class Messaging { if (typeof replyToEmail !== 'undefined') { payload['replyToEmail'] = replyToEmail; } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1188,7 +3046,7 @@ export class Messaging { } return this.client.call( - 'patch', + 'post', uri, apiHeaders, payload, @@ -1196,40 +3054,97 @@ export class Messaging { } /** - * Create a new SMTP provider. + * Update a SMTP provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} params.port - SMTP port. + * @param {string} params.username - Authentication username. + * @param {string} params.password - Authentication password. + * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' + * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {string} params.mailer - The value to use for the X-Mailer header. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. + */ + updateSmtpProvider(params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Update a SMTP provider by its unique ID. * - * @param {string} providerId - * @param {string} name - * @param {string} host - * @param {number} port - * @param {string} username - * @param {string} password - * @param {SmtpEncryption} encryption - * @param {boolean} autoTLS - * @param {string} mailer - * @param {string} fromName - * @param {string} fromEmail - * @param {string} replyToName - * @param {string} replyToEmail - * @param {boolean} enabled + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} port - SMTP port. + * @param {string} username - Authentication username. + * @param {string} password - Authentication password. + * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' + * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {string} mailer - The value to use for the X-Mailer header. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createSmtpProvider(providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider> { + updateSmtpProvider(providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + updateSmtpProvider( + paramsOrFirst: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + host: rest[1] as string, + port: rest[2] as number, + username: rest[3] as string, + password: rest[4] as string, + encryption: rest[5] as SmtpEncryption, + autoTLS: rest[6] as boolean, + mailer: rest[7] as string, + fromName: rest[8] as string, + fromEmail: rest[9] as string, + replyToName: rest[10] as string, + replyToEmail: rest[11] as string, + enabled: rest[12] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const host = params.host; + const port = params.port; + const username = params.username; + const password = params.password; + const encryption = params.encryption; + const autoTLS = params.autoTLS; + const mailer = params.mailer; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof host === 'undefined') { - throw new AppwriteException('Missing required parameter: "host"'); - } - const apiPath = '/messaging/providers/smtp'; + + const apiPath = '/messaging/providers/smtp/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; - if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; - } if (typeof name !== 'undefined') { payload['name'] = name; } @@ -1276,7 +3191,7 @@ export class Messaging { } return this.client.call( - 'post', + 'patch', uri, apiHeaders, payload, @@ -1286,27 +3201,92 @@ export class Messaging { /** * Update a SMTP provider by its unique ID. * - * @param {string} providerId - * @param {string} name - * @param {string} host - * @param {number} port - * @param {string} username - * @param {string} password - * @param {SmtpEncryption} encryption - * @param {boolean} autoTLS - * @param {string} mailer - * @param {string} fromName - * @param {string} fromEmail - * @param {string} replyToName - * @param {string} replyToEmail - * @param {boolean} enabled + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} params.port - SMTP port. + * @param {string} params.username - Authentication username. + * @param {string} params.password - Authentication password. + * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' + * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {string} params.mailer - The value to use for the X-Mailer header. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateSMTPProvider(params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Update a SMTP provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} port - SMTP port. + * @param {string} username - Authentication username. + * @param {string} password - Authentication password. + * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' + * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {string} mailer - The value to use for the X-Mailer header. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateSmtpProvider(providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider> { + updateSMTPProvider(providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + updateSMTPProvider( + paramsOrFirst: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + host: rest[1] as string, + port: rest[2] as number, + username: rest[3] as string, + password: rest[4] as string, + encryption: rest[5] as SmtpEncryption, + autoTLS: rest[6] as boolean, + mailer: rest[7] as string, + fromName: rest[8] as string, + fromEmail: rest[9] as string, + replyToName: rest[10] as string, + replyToEmail: rest[11] as string, + enabled: rest[12] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const host = params.host; + const port = params.port; + const username = params.username; + const password = params.password; + const encryption = params.encryption; + const autoTLS = params.autoTLS; + const mailer = params.mailer; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/smtp/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -1365,22 +3345,63 @@ export class Messaging { /** * Create a new Telesign provider. * - * @param {string} providerId - * @param {string} name - * @param {string} from - * @param {string} customerId - * @param {string} apiKey - * @param {boolean} enabled + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.customerId - Telesign customer ID. + * @param {string} params.apiKey - Telesign API key. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createTelesignProvider(params: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Telesign provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} customerId - Telesign customer ID. + * @param {string} apiKey - Telesign API key. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createTelesignProvider(providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean): Promise<Models.Provider> { + createTelesignProvider(providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean): Promise<Models.Provider>; + createTelesignProvider( + paramsOrFirst: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + from: rest[1] as string, + customerId: rest[2] as string, + apiKey: rest[3] as string, + enabled: rest[4] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const from = params.from; + const customerId = params.customerId; + const apiKey = params.apiKey; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/messaging/providers/telesign'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -1418,19 +3439,60 @@ export class Messaging { /** * Update a Telesign provider by its unique ID. * - * @param {string} providerId - * @param {string} name - * @param {boolean} enabled - * @param {string} customerId - * @param {string} apiKey - * @param {string} from + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.customerId - Telesign customer ID. + * @param {string} params.apiKey - Telesign API key. + * @param {string} params.from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateTelesignProvider(params: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }): Promise<Models.Provider>; + /** + * Update a Telesign provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} customerId - Telesign customer ID. + * @param {string} apiKey - Telesign API key. + * @param {string} from - Sender number. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateTelesignProvider(providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string): Promise<Models.Provider> { + updateTelesignProvider(providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string): Promise<Models.Provider>; + updateTelesignProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + customerId: rest[2] as string, + apiKey: rest[3] as string, + from: rest[4] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const customerId = params.customerId; + const apiKey = params.apiKey; + const from = params.from; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/telesign/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -1465,22 +3527,63 @@ export class Messaging { /** * Create a new Textmagic provider. * - * @param {string} providerId - * @param {string} name - * @param {string} from - * @param {string} username - * @param {string} apiKey - * @param {boolean} enabled + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.username - Textmagic username. + * @param {string} params.apiKey - Textmagic apiKey. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createTextmagicProvider(params: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Textmagic provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} username - Textmagic username. + * @param {string} apiKey - Textmagic apiKey. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createTextmagicProvider(providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean): Promise<Models.Provider> { + createTextmagicProvider(providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean): Promise<Models.Provider>; + createTextmagicProvider( + paramsOrFirst: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + from: rest[1] as string, + username: rest[2] as string, + apiKey: rest[3] as string, + enabled: rest[4] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const from = params.from; + const username = params.username; + const apiKey = params.apiKey; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/messaging/providers/textmagic'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -1518,19 +3621,60 @@ export class Messaging { /** * Update a Textmagic provider by its unique ID. * - * @param {string} providerId - * @param {string} name - * @param {boolean} enabled - * @param {string} username - * @param {string} apiKey - * @param {string} from + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.username - Textmagic username. + * @param {string} params.apiKey - Textmagic apiKey. + * @param {string} params.from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateTextmagicProvider(params: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }): Promise<Models.Provider>; + /** + * Update a Textmagic provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} username - Textmagic username. + * @param {string} apiKey - Textmagic apiKey. + * @param {string} from - Sender number. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateTextmagicProvider(providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string): Promise<Models.Provider> { + updateTextmagicProvider(providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string): Promise<Models.Provider>; + updateTextmagicProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + username: rest[2] as string, + apiKey: rest[3] as string, + from: rest[4] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const username = params.username; + const apiKey = params.apiKey; + const from = params.from; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/textmagic/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -1565,22 +3709,63 @@ export class Messaging { /** * Create a new Twilio provider. * - * @param {string} providerId - * @param {string} name - * @param {string} from - * @param {string} accountSid - * @param {string} authToken - * @param {boolean} enabled + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.accountSid - Twilio account secret ID. + * @param {string} params.authToken - Twilio authentication token. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createTwilioProvider(params: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Twilio provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} accountSid - Twilio account secret ID. + * @param {string} authToken - Twilio authentication token. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createTwilioProvider(providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean): Promise<Models.Provider> { + createTwilioProvider(providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean): Promise<Models.Provider>; + createTwilioProvider( + paramsOrFirst: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + from: rest[1] as string, + accountSid: rest[2] as string, + authToken: rest[3] as string, + enabled: rest[4] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const from = params.from; + const accountSid = params.accountSid; + const authToken = params.authToken; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/messaging/providers/twilio'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -1618,19 +3803,60 @@ export class Messaging { /** * Update a Twilio provider by its unique ID. * - * @param {string} providerId - * @param {string} name - * @param {boolean} enabled - * @param {string} accountSid - * @param {string} authToken - * @param {string} from + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.accountSid - Twilio account secret ID. + * @param {string} params.authToken - Twilio authentication token. + * @param {string} params.from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateTwilioProvider(params: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }): Promise<Models.Provider>; + /** + * Update a Twilio provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} accountSid - Twilio account secret ID. + * @param {string} authToken - Twilio authentication token. + * @param {string} from - Sender number. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateTwilioProvider(providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string): Promise<Models.Provider> { + updateTwilioProvider(providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string): Promise<Models.Provider>; + updateTwilioProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + accountSid: rest[2] as string, + authToken: rest[3] as string, + from: rest[4] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const accountSid = params.accountSid; + const authToken = params.authToken; + const from = params.from; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/twilio/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -1665,22 +3891,63 @@ export class Messaging { /** * Create a new Vonage provider. * - * @param {string} providerId - * @param {string} name - * @param {string} from - * @param {string} apiKey - * @param {string} apiSecret - * @param {boolean} enabled + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.apiKey - Vonage API key. + * @param {string} params.apiSecret - Vonage API secret. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createVonageProvider(params: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Vonage provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} apiKey - Vonage API key. + * @param {string} apiSecret - Vonage API secret. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createVonageProvider(providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean): Promise<Models.Provider> { + createVonageProvider(providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean): Promise<Models.Provider>; + createVonageProvider( + paramsOrFirst: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + from: rest[1] as string, + apiKey: rest[2] as string, + apiSecret: rest[3] as string, + enabled: rest[4] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const from = params.from; + const apiKey = params.apiKey; + const apiSecret = params.apiSecret; + const enabled = params.enabled; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/messaging/providers/vonage'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { @@ -1718,19 +3985,60 @@ export class Messaging { /** * Update a Vonage provider by its unique ID. * - * @param {string} providerId - * @param {string} name - * @param {boolean} enabled - * @param {string} apiKey - * @param {string} apiSecret - * @param {string} from + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.apiKey - Vonage API key. + * @param {string} params.apiSecret - Vonage API secret. + * @param {string} params.from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateVonageProvider(params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }): Promise<Models.Provider>; + /** + * Update a Vonage provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} apiKey - Vonage API key. + * @param {string} apiSecret - Vonage API secret. + * @param {string} from - Sender number. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateVonageProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string): Promise<Models.Provider> { + updateVonageProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string): Promise<Models.Provider>; + updateVonageProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + apiKey: rest[2] as string, + apiSecret: rest[3] as string, + from: rest[4] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const apiKey = params.apiKey; + const apiSecret = params.apiSecret; + const from = params.from; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/vonage/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -1766,14 +4074,40 @@ export class Messaging { * Get a provider by its unique ID. * * - * @param {string} providerId + * @param {string} params.providerId - Provider ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + getProvider(params: { providerId: string }): Promise<Models.Provider>; + /** + * Get a provider by its unique ID. + * + * + * @param {string} providerId - Provider ID. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getProvider(providerId: string): Promise<Models.Provider> { + getProvider(providerId: string): Promise<Models.Provider>; + getProvider( + paramsOrFirst: { providerId: string } | string + ): Promise<Models.Provider> { + let params: { providerId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string }; + } else { + params = { + providerId: paramsOrFirst as string + }; + } + + const providerId = params.providerId; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1792,14 +4126,39 @@ export class Messaging { /** * Delete a provider by its unique ID. * - * @param {string} providerId + * @param {string} params.providerId - Provider ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteProvider(params: { providerId: string }): Promise<{}>; + /** + * Delete a provider by its unique ID. + * + * @param {string} providerId - Provider ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteProvider(providerId: string): Promise<{}> { + deleteProvider(providerId: string): Promise<{}>; + deleteProvider( + paramsOrFirst: { providerId: string } | string + ): Promise<{}> { + let params: { providerId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string }; + } else { + params = { + providerId: paramsOrFirst as string + }; + } + + const providerId = params.providerId; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1819,15 +4178,44 @@ export class Messaging { /** * Get the provider activity logs listed by its unique ID. * - * @param {string} providerId - * @param {string[]} queries + * @param {string} params.providerId - Provider ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + */ + listProviderLogs(params: { providerId: string, queries?: string[] }): Promise<Models.LogList>; + /** + * Get the provider activity logs listed by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @throws {AppwriteException} * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listProviderLogs(providerId: string, queries?: string[]): Promise<Models.LogList> { + listProviderLogs(providerId: string, queries?: string[]): Promise<Models.LogList>; + listProviderLogs( + paramsOrFirst: { providerId: string, queries?: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.LogList> { + let params: { providerId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, queries?: string[] }; + } else { + params = { + providerId: paramsOrFirst as string, + queries: rest[0] as string[] + }; + } + + const providerId = params.providerId; + const queries = params.queries; + if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + const apiPath = '/messaging/providers/{providerId}/logs'.replace('{providerId}', providerId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1849,15 +4237,44 @@ export class Messaging { /** * Get the subscriber activity logs listed by its unique ID. * - * @param {string} subscriberId - * @param {string[]} queries + * @param {string} params.subscriberId - Subscriber ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + */ + listSubscriberLogs(params: { subscriberId: string, queries?: string[] }): Promise<Models.LogList>; + /** + * Get the subscriber activity logs listed by its unique ID. + * + * @param {string} subscriberId - Subscriber ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @throws {AppwriteException} * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listSubscriberLogs(subscriberId: string, queries?: string[]): Promise<Models.LogList> { + listSubscriberLogs(subscriberId: string, queries?: string[]): Promise<Models.LogList>; + listSubscriberLogs( + paramsOrFirst: { subscriberId: string, queries?: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.LogList> { + let params: { subscriberId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { subscriberId: string, queries?: string[] }; + } else { + params = { + subscriberId: paramsOrFirst as string, + queries: rest[0] as string[] + }; + } + + const subscriberId = params.subscriberId; + const queries = params.queries; + if (typeof subscriberId === 'undefined') { throw new AppwriteException('Missing required parameter: "subscriberId"'); } + const apiPath = '/messaging/subscribers/{subscriberId}/logs'.replace('{subscriberId}', subscriberId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1879,12 +4296,41 @@ export class Messaging { /** * Get a list of all topics from the current Appwrite project. * - * @param {string[]} queries - * @param {string} search + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, description, emailTotal, smsTotal, pushTotal + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.TopicList>} + */ + listTopics(params?: { queries?: string[], search?: string }): Promise<Models.TopicList>; + /** + * Get a list of all topics from the current Appwrite project. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, description, emailTotal, smsTotal, pushTotal + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.TopicList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listTopics(queries?: string[], search?: string): Promise<Models.TopicList> { + listTopics(queries?: string[], search?: string): Promise<Models.TopicList>; + listTopics( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.TopicList> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + const apiPath = '/messaging/topics'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1909,19 +4355,51 @@ export class Messaging { /** * Create a new topic. * - * @param {string} topicId - * @param {string} name - * @param {string[]} subscribe + * @param {string} params.topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. + * @param {string} params.name - Topic Name. + * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.Topic>} + */ + createTopic(params: { topicId: string, name: string, subscribe?: string[] }): Promise<Models.Topic>; + /** + * Create a new topic. + * + * @param {string} topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. + * @param {string} name - Topic Name. + * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createTopic(topicId: string, name: string, subscribe?: string[]): Promise<Models.Topic> { + createTopic(topicId: string, name: string, subscribe?: string[]): Promise<Models.Topic>; + createTopic( + paramsOrFirst: { topicId: string, name: string, subscribe?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.Topic> { + let params: { topicId: string, name: string, subscribe?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, name: string, subscribe?: string[] }; + } else { + params = { + topicId: paramsOrFirst as string, + name: rest[0] as string, + subscribe: rest[1] as string[] + }; + } + + const topicId = params.topicId; + const name = params.name; + const subscribe = params.subscribe; + if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/messaging/topics'; const payload: Payload = {}; if (typeof topicId !== 'undefined') { @@ -1951,14 +4429,40 @@ export class Messaging { * Get a topic by its unique ID. * * - * @param {string} topicId + * @param {string} params.topicId - Topic ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Topic>} + */ + getTopic(params: { topicId: string }): Promise<Models.Topic>; + /** + * Get a topic by its unique ID. + * + * + * @param {string} topicId - Topic ID. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getTopic(topicId: string): Promise<Models.Topic> { + getTopic(topicId: string): Promise<Models.Topic>; + getTopic( + paramsOrFirst: { topicId: string } | string + ): Promise<Models.Topic> { + let params: { topicId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string }; + } else { + params = { + topicId: paramsOrFirst as string + }; + } + + const topicId = params.topicId; + if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } + const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1978,16 +4482,49 @@ export class Messaging { * Update a topic by its unique ID. * * - * @param {string} topicId - * @param {string} name - * @param {string[]} subscribe + * @param {string} params.topicId - Topic ID. + * @param {string} params.name - Topic Name. + * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.Topic>} + */ + updateTopic(params: { topicId: string, name?: string, subscribe?: string[] }): Promise<Models.Topic>; + /** + * Update a topic by its unique ID. + * + * + * @param {string} topicId - Topic ID. + * @param {string} name - Topic Name. + * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateTopic(topicId: string, name?: string, subscribe?: string[]): Promise<Models.Topic> { + updateTopic(topicId: string, name?: string, subscribe?: string[]): Promise<Models.Topic>; + updateTopic( + paramsOrFirst: { topicId: string, name?: string, subscribe?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.Topic> { + let params: { topicId: string, name?: string, subscribe?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, name?: string, subscribe?: string[] }; + } else { + params = { + topicId: paramsOrFirst as string, + name: rest[0] as string, + subscribe: rest[1] as string[] + }; + } + + const topicId = params.topicId; + const name = params.name; + const subscribe = params.subscribe; + if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } + const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -2013,14 +4550,39 @@ export class Messaging { /** * Delete a topic by its unique ID. * - * @param {string} topicId + * @param {string} params.topicId - Topic ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTopic(params: { topicId: string }): Promise<{}>; + /** + * Delete a topic by its unique ID. + * + * @param {string} topicId - Topic ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteTopic(topicId: string): Promise<{}> { + deleteTopic(topicId: string): Promise<{}>; + deleteTopic( + paramsOrFirst: { topicId: string } | string + ): Promise<{}> { + let params: { topicId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string }; + } else { + params = { + topicId: paramsOrFirst as string + }; + } + + const topicId = params.topicId; + if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } + const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2040,15 +4602,44 @@ export class Messaging { /** * Get the topic activity logs listed by its unique ID. * - * @param {string} topicId - * @param {string[]} queries + * @param {string} params.topicId - Topic ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + */ + listTopicLogs(params: { topicId: string, queries?: string[] }): Promise<Models.LogList>; + /** + * Get the topic activity logs listed by its unique ID. + * + * @param {string} topicId - Topic ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @throws {AppwriteException} * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listTopicLogs(topicId: string, queries?: string[]): Promise<Models.LogList> { + listTopicLogs(topicId: string, queries?: string[]): Promise<Models.LogList>; + listTopicLogs( + paramsOrFirst: { topicId: string, queries?: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.LogList> { + let params: { topicId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, queries?: string[] }; + } else { + params = { + topicId: paramsOrFirst as string, + queries: rest[0] as string[] + }; + } + + const topicId = params.topicId; + const queries = params.queries; + if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } + const apiPath = '/messaging/topics/{topicId}/logs'.replace('{topicId}', topicId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -2070,16 +4661,48 @@ export class Messaging { /** * Get a list of all subscribers from the current Appwrite project. * - * @param {string} topicId - * @param {string[]} queries - * @param {string} search + * @param {string} params.topicId - Topic ID. The topic ID subscribed to. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, provider, type, enabled + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.SubscriberList>} + */ + listSubscribers(params: { topicId: string, queries?: string[], search?: string }): Promise<Models.SubscriberList>; + /** + * Get a list of all subscribers from the current Appwrite project. + * + * @param {string} topicId - Topic ID. The topic ID subscribed to. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, provider, type, enabled + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.SubscriberList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listSubscribers(topicId: string, queries?: string[], search?: string): Promise<Models.SubscriberList> { + listSubscribers(topicId: string, queries?: string[], search?: string): Promise<Models.SubscriberList>; + listSubscribers( + paramsOrFirst: { topicId: string, queries?: string[], search?: string } | string, + ...rest: [(string[])?, (string)?] + ): Promise<Models.SubscriberList> { + let params: { topicId: string, queries?: string[], search?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, queries?: string[], search?: string }; + } else { + params = { + topicId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string + }; + } + + const topicId = params.topicId; + const queries = params.queries; + const search = params.search; + if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } + const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', topicId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -2104,13 +4727,44 @@ export class Messaging { /** * Create a new subscriber. * - * @param {string} topicId - * @param {string} subscriberId - * @param {string} targetId + * @param {string} params.topicId - Topic ID. The topic ID to subscribe to. + * @param {string} params.subscriberId - Subscriber ID. Choose a custom Subscriber ID or a new Subscriber ID. + * @param {string} params.targetId - Target ID. The target ID to link to the specified Topic ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Subscriber>} + */ + createSubscriber(params: { topicId: string, subscriberId: string, targetId: string }): Promise<Models.Subscriber>; + /** + * Create a new subscriber. + * + * @param {string} topicId - Topic ID. The topic ID to subscribe to. + * @param {string} subscriberId - Subscriber ID. Choose a custom Subscriber ID or a new Subscriber ID. + * @param {string} targetId - Target ID. The target ID to link to the specified Topic ID. * @throws {AppwriteException} * @returns {Promise<Models.Subscriber>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createSubscriber(topicId: string, subscriberId: string, targetId: string): Promise<Models.Subscriber> { + createSubscriber(topicId: string, subscriberId: string, targetId: string): Promise<Models.Subscriber>; + createSubscriber( + paramsOrFirst: { topicId: string, subscriberId: string, targetId: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.Subscriber> { + let params: { topicId: string, subscriberId: string, targetId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, subscriberId: string, targetId: string }; + } else { + params = { + topicId: paramsOrFirst as string, + subscriberId: rest[0] as string, + targetId: rest[1] as string + }; + } + + const topicId = params.topicId; + const subscriberId = params.subscriberId; + const targetId = params.targetId; + if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } @@ -2120,6 +4774,7 @@ export class Messaging { if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); } + const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', topicId); const payload: Payload = {}; if (typeof subscriberId !== 'undefined') { @@ -2146,18 +4801,48 @@ export class Messaging { * Get a subscriber by its unique ID. * * - * @param {string} topicId - * @param {string} subscriberId + * @param {string} params.topicId - Topic ID. The topic ID subscribed to. + * @param {string} params.subscriberId - Subscriber ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Subscriber>} + */ + getSubscriber(params: { topicId: string, subscriberId: string }): Promise<Models.Subscriber>; + /** + * Get a subscriber by its unique ID. + * + * + * @param {string} topicId - Topic ID. The topic ID subscribed to. + * @param {string} subscriberId - Subscriber ID. * @throws {AppwriteException} * @returns {Promise<Models.Subscriber>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getSubscriber(topicId: string, subscriberId: string): Promise<Models.Subscriber> { + getSubscriber(topicId: string, subscriberId: string): Promise<Models.Subscriber>; + getSubscriber( + paramsOrFirst: { topicId: string, subscriberId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Subscriber> { + let params: { topicId: string, subscriberId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, subscriberId: string }; + } else { + params = { + topicId: paramsOrFirst as string, + subscriberId: rest[0] as string + }; + } + + const topicId = params.topicId; + const subscriberId = params.subscriberId; + if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } if (typeof subscriberId === 'undefined') { throw new AppwriteException('Missing required parameter: "subscriberId"'); } + const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', topicId).replace('{subscriberId}', subscriberId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2176,18 +4861,47 @@ export class Messaging { /** * Delete a subscriber by its unique ID. * - * @param {string} topicId - * @param {string} subscriberId + * @param {string} params.topicId - Topic ID. The topic ID subscribed to. + * @param {string} params.subscriberId - Subscriber ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteSubscriber(topicId: string, subscriberId: string): Promise<{}> { + deleteSubscriber(params: { topicId: string, subscriberId: string }): Promise<{}>; + /** + * Delete a subscriber by its unique ID. + * + * @param {string} topicId - Topic ID. The topic ID subscribed to. + * @param {string} subscriberId - Subscriber ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteSubscriber(topicId: string, subscriberId: string): Promise<{}>; + deleteSubscriber( + paramsOrFirst: { topicId: string, subscriberId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { topicId: string, subscriberId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, subscriberId: string }; + } else { + params = { + topicId: paramsOrFirst as string, + subscriberId: rest[0] as string + }; + } + + const topicId = params.topicId; + const subscriberId = params.subscriberId; + if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } if (typeof subscriberId === 'undefined') { throw new AppwriteException('Missing required parameter: "subscriberId"'); } + const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', topicId).replace('{subscriberId}', subscriberId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); diff --git a/src/services/sites.ts b/src/services/sites.ts index d52a5ea..e8c0aed 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -1,9 +1,10 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { Framework } from '../enums/framework'; import { BuildRuntime } from '../enums/build-runtime'; import { Adapter } from '../enums/adapter'; -import { VCSDeploymentType } from '../enums/v-c-s-deployment-type'; +import { VCSDeploymentType } from '../enums/vcs-deployment-type'; import { DeploymentDownloadType } from '../enums/deployment-download-type'; export class Sites { @@ -14,14 +15,43 @@ export class Sites { } /** - * Get a list of all the project's sites. You can use the query params to filter your results. + * Get a list of all the project's sites. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, framework, deploymentId, buildCommand, installCommand, outputDirectory, installationId + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.SiteList>} + */ + list(params?: { queries?: string[], search?: string }): Promise<Models.SiteList>; + /** + * Get a list of all the project's sites. You can use the query params to filter your results. * - * @param {string[]} queries - * @param {string} search + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, framework, deploymentId, buildCommand, installCommand, outputDirectory, installationId + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.SiteList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string): Promise<Models.SiteList> { + list(queries?: string[], search?: string): Promise<Models.SiteList>; + list( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.SiteList> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + const apiPath = '/sites'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -46,28 +76,104 @@ export class Sites { /** * Create a new site. * - * @param {string} siteId - * @param {string} name - * @param {Framework} framework - * @param {BuildRuntime} buildRuntime - * @param {boolean} enabled - * @param {boolean} logging - * @param {number} timeout - * @param {string} installCommand - * @param {string} buildCommand - * @param {string} outputDirectory - * @param {Adapter} adapter - * @param {string} installationId - * @param {string} fallbackFile - * @param {string} providerRepositoryId - * @param {string} providerBranch - * @param {boolean} providerSilentMode - * @param {string} providerRootDirectory - * @param {string} specification + * @param {string} params.siteId - Site ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Site name. Max length: 128 chars. + * @param {Framework} params.framework - Sites framework. + * @param {BuildRuntime} params.buildRuntime - Runtime to use during build step. + * @param {boolean} params.enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. + * @param {boolean} params.logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * @param {number} params.timeout - Maximum request time in seconds. + * @param {string} params.installCommand - Install Command. + * @param {string} params.buildCommand - Build Command. + * @param {string} params.outputDirectory - Output Directory for site. + * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} params.fallbackFile - Fallback file for single page application sites. + * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string} params.providerBranch - Production branch for the repo linked to the site. + * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + * @param {string} params.providerRootDirectory - Path to site code in the linked repo. + * @param {string} params.specification - Framework specification for the site and builds. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + */ + create(params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }): Promise<Models.Site>; + /** + * Create a new site. + * + * @param {string} siteId - Site ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Site name. Max length: 128 chars. + * @param {Framework} framework - Sites framework. + * @param {BuildRuntime} buildRuntime - Runtime to use during build step. + * @param {boolean} enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. + * @param {boolean} logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * @param {number} timeout - Maximum request time in seconds. + * @param {string} installCommand - Install Command. + * @param {string} buildCommand - Build Command. + * @param {string} outputDirectory - Output Directory for site. + * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} fallbackFile - Fallback file for single page application sites. + * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string} providerBranch - Production branch for the repo linked to the site. + * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + * @param {string} providerRootDirectory - Path to site code in the linked repo. + * @param {string} specification - Framework specification for the site and builds. * @throws {AppwriteException} * @returns {Promise<Models.Site>} + * @deprecated Use the object parameter style method for a better developer experience. */ - create(siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Site> { + create(siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Site>; + create( + paramsOrFirst: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string } | string, + ...rest: [(string)?, (Framework)?, (BuildRuntime)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.Site> { + let params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + } else { + params = { + siteId: paramsOrFirst as string, + name: rest[0] as string, + framework: rest[1] as Framework, + buildRuntime: rest[2] as BuildRuntime, + enabled: rest[3] as boolean, + logging: rest[4] as boolean, + timeout: rest[5] as number, + installCommand: rest[6] as string, + buildCommand: rest[7] as string, + outputDirectory: rest[8] as string, + adapter: rest[9] as Adapter, + installationId: rest[10] as string, + fallbackFile: rest[11] as string, + providerRepositoryId: rest[12] as string, + providerBranch: rest[13] as string, + providerSilentMode: rest[14] as boolean, + providerRootDirectory: rest[15] as string, + specification: rest[16] as string + }; + } + + const siteId = params.siteId; + const name = params.name; + const framework = params.framework; + const buildRuntime = params.buildRuntime; + const enabled = params.enabled; + const logging = params.logging; + const timeout = params.timeout; + const installCommand = params.installCommand; + const buildCommand = params.buildCommand; + const outputDirectory = params.outputDirectory; + const adapter = params.adapter; + const installationId = params.installationId; + const fallbackFile = params.fallbackFile; + const providerRepositoryId = params.providerRepositoryId; + const providerBranch = params.providerBranch; + const providerSilentMode = params.providerSilentMode; + const providerRootDirectory = params.providerRootDirectory; + const specification = params.specification; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } @@ -80,6 +186,7 @@ export class Sites { if (typeof buildRuntime === 'undefined') { throw new AppwriteException('Missing required parameter: "buildRuntime"'); } + const apiPath = '/sites'; const payload: Payload = {}; if (typeof siteId !== 'undefined') { @@ -157,6 +264,7 @@ export class Sites { * @returns {Promise<Models.FrameworkList>} */ listFrameworks(): Promise<Models.FrameworkList> { + const apiPath = '/sites/frameworks'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -179,6 +287,7 @@ export class Sites { * @returns {Promise<Models.SpecificationList>} */ listSpecifications(): Promise<Models.SpecificationList> { + const apiPath = '/sites/specifications'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -197,14 +306,39 @@ export class Sites { /** * Get a site by its unique ID. * - * @param {string} siteId + * @param {string} params.siteId - Site ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + */ + get(params: { siteId: string }): Promise<Models.Site>; + /** + * Get a site by its unique ID. + * + * @param {string} siteId - Site ID. * @throws {AppwriteException} * @returns {Promise<Models.Site>} + * @deprecated Use the object parameter style method for a better developer experience. */ - get(siteId: string): Promise<Models.Site> { + get(siteId: string): Promise<Models.Site>; + get( + paramsOrFirst: { siteId: string } | string + ): Promise<Models.Site> { + let params: { siteId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string }; + } else { + params = { + siteId: paramsOrFirst as string + }; + } + + const siteId = params.siteId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } + const apiPath = '/sites/{siteId}'.replace('{siteId}', siteId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -223,28 +357,104 @@ export class Sites { /** * Update site by its unique ID. * - * @param {string} siteId - * @param {string} name - * @param {Framework} framework - * @param {boolean} enabled - * @param {boolean} logging - * @param {number} timeout - * @param {string} installCommand - * @param {string} buildCommand - * @param {string} outputDirectory - * @param {BuildRuntime} buildRuntime - * @param {Adapter} adapter - * @param {string} fallbackFile - * @param {string} installationId - * @param {string} providerRepositoryId - * @param {string} providerBranch - * @param {boolean} providerSilentMode - * @param {string} providerRootDirectory - * @param {string} specification + * @param {string} params.siteId - Site ID. + * @param {string} params.name - Site name. Max length: 128 chars. + * @param {Framework} params.framework - Sites framework. + * @param {boolean} params.enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. + * @param {boolean} params.logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * @param {number} params.timeout - Maximum request time in seconds. + * @param {string} params.installCommand - Install Command. + * @param {string} params.buildCommand - Build Command. + * @param {string} params.outputDirectory - Output Directory for site. + * @param {BuildRuntime} params.buildRuntime - Runtime to use during build step. + * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {string} params.fallbackFile - Fallback file for single page application sites. + * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string} params.providerBranch - Production branch for the repo linked to the site. + * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + * @param {string} params.providerRootDirectory - Path to site code in the linked repo. + * @param {string} params.specification - Framework specification for the site and builds. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + */ + update(params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }): Promise<Models.Site>; + /** + * Update site by its unique ID. + * + * @param {string} siteId - Site ID. + * @param {string} name - Site name. Max length: 128 chars. + * @param {Framework} framework - Sites framework. + * @param {boolean} enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. + * @param {boolean} logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * @param {number} timeout - Maximum request time in seconds. + * @param {string} installCommand - Install Command. + * @param {string} buildCommand - Build Command. + * @param {string} outputDirectory - Output Directory for site. + * @param {BuildRuntime} buildRuntime - Runtime to use during build step. + * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {string} fallbackFile - Fallback file for single page application sites. + * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string} providerBranch - Production branch for the repo linked to the site. + * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + * @param {string} providerRootDirectory - Path to site code in the linked repo. + * @param {string} specification - Framework specification for the site and builds. * @throws {AppwriteException} * @returns {Promise<Models.Site>} + * @deprecated Use the object parameter style method for a better developer experience. */ - update(siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Site> { + update(siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Site>; + update( + paramsOrFirst: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string } | string, + ...rest: [(string)?, (Framework)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (BuildRuntime)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.Site> { + let params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + } else { + params = { + siteId: paramsOrFirst as string, + name: rest[0] as string, + framework: rest[1] as Framework, + enabled: rest[2] as boolean, + logging: rest[3] as boolean, + timeout: rest[4] as number, + installCommand: rest[5] as string, + buildCommand: rest[6] as string, + outputDirectory: rest[7] as string, + buildRuntime: rest[8] as BuildRuntime, + adapter: rest[9] as Adapter, + fallbackFile: rest[10] as string, + installationId: rest[11] as string, + providerRepositoryId: rest[12] as string, + providerBranch: rest[13] as string, + providerSilentMode: rest[14] as boolean, + providerRootDirectory: rest[15] as string, + specification: rest[16] as string + }; + } + + const siteId = params.siteId; + const name = params.name; + const framework = params.framework; + const enabled = params.enabled; + const logging = params.logging; + const timeout = params.timeout; + const installCommand = params.installCommand; + const buildCommand = params.buildCommand; + const outputDirectory = params.outputDirectory; + const buildRuntime = params.buildRuntime; + const adapter = params.adapter; + const fallbackFile = params.fallbackFile; + const installationId = params.installationId; + const providerRepositoryId = params.providerRepositoryId; + const providerBranch = params.providerBranch; + const providerSilentMode = params.providerSilentMode; + const providerRootDirectory = params.providerRootDirectory; + const specification = params.specification; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } @@ -254,6 +464,7 @@ export class Sites { if (typeof framework === 'undefined') { throw new AppwriteException('Missing required parameter: "framework"'); } + const apiPath = '/sites/{siteId}'.replace('{siteId}', siteId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -324,14 +535,39 @@ export class Sites { /** * Delete a site by its unique ID. * - * @param {string} siteId + * @param {string} params.siteId - Site ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ - delete(siteId: string): Promise<{}> { + delete(params: { siteId: string }): Promise<{}>; + /** + * Delete a site by its unique ID. + * + * @param {string} siteId - Site ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(siteId: string): Promise<{}>; + delete( + paramsOrFirst: { siteId: string } | string + ): Promise<{}> { + let params: { siteId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string }; + } else { + params = { + siteId: paramsOrFirst as string + }; + } + + const siteId = params.siteId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } + const apiPath = '/sites/{siteId}'.replace('{siteId}', siteId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -351,18 +587,47 @@ export class Sites { /** * Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site. * - * @param {string} siteId - * @param {string} deploymentId + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. * @throws {AppwriteException} * @returns {Promise<Models.Site>} */ - updateSiteDeployment(siteId: string, deploymentId: string): Promise<Models.Site> { + updateSiteDeployment(params: { siteId: string, deploymentId: string }): Promise<Models.Site>; + /** + * Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSiteDeployment(siteId: string, deploymentId: string): Promise<Models.Site>; + updateSiteDeployment( + paramsOrFirst: { siteId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Site> { + let params: { siteId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/sites/{siteId}/deployment'.replace('{siteId}', siteId); const payload: Payload = {}; if (typeof deploymentId !== 'undefined') { @@ -383,18 +648,50 @@ export class Sites { } /** - * Get a list of all the site's code deployments. You can use the query params to filter your results. + * Get a list of all the site's code deployments. You can use the query params to filter your results. + * + * @param {string} params.siteId - Site ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.DeploymentList>} + */ + listDeployments(params: { siteId: string, queries?: string[], search?: string }): Promise<Models.DeploymentList>; + /** + * Get a list of all the site's code deployments. You can use the query params to filter your results. * - * @param {string} siteId - * @param {string[]} queries - * @param {string} search + * @param {string} siteId - Site ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.DeploymentList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listDeployments(siteId: string, queries?: string[], search?: string): Promise<Models.DeploymentList> { + listDeployments(siteId: string, queries?: string[], search?: string): Promise<Models.DeploymentList>; + listDeployments( + paramsOrFirst: { siteId: string, queries?: string[], search?: string } | string, + ...rest: [(string[])?, (string)?] + ): Promise<Models.DeploymentList> { + let params: { siteId: string, queries?: string[], search?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], search?: string }; + } else { + params = { + siteId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string + }; + } + + const siteId = params.siteId; + const queries = params.queries; + const search = params.search; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } + const apiPath = '/sites/{siteId}/deployments'.replace('{siteId}', siteId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -417,18 +714,61 @@ export class Sites { } /** - * Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the function's deployment to use your new deployment ID. + * Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the function's deployment to use your new deployment ID. * - * @param {string} siteId - * @param {File} code - * @param {boolean} activate - * @param {string} installCommand - * @param {string} buildCommand - * @param {string} outputDirectory + * @param {string} params.siteId - Site ID. + * @param {File} params.code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. + * @param {string} params.installCommand - Install Commands. + * @param {string} params.buildCommand - Build Commands. + * @param {string} params.outputDirectory - Output Directory. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ - createDeployment(siteId: string, code: File, activate: boolean, installCommand?: string, buildCommand?: string, outputDirectory?: string, onProgress = (progress: UploadProgress) => {}): Promise<Models.Deployment> { + createDeployment(params: { siteId: string, code: File, activate: boolean, installCommand?: string, buildCommand?: string, outputDirectory?: string , onProgress?: (progress: UploadProgress) => void }): Promise<Models.Deployment>; + /** + * Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the function's deployment to use your new deployment ID. + * + * @param {string} siteId - Site ID. + * @param {File} code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + * @param {boolean} activate - Automatically activate the deployment when it is finished building. + * @param {string} installCommand - Install Commands. + * @param {string} buildCommand - Build Commands. + * @param {string} outputDirectory - Output Directory. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDeployment(siteId: string, code: File, activate: boolean, installCommand?: string, buildCommand?: string, outputDirectory?: string, onProgress?: (progress: UploadProgress) => void): Promise<Models.Deployment>; + createDeployment( + paramsOrFirst: { siteId: string, code: File, activate: boolean, installCommand?: string, buildCommand?: string, outputDirectory?: string, onProgress?: (progress: UploadProgress) => void } | string, + ...rest: [(File)?, (boolean)?, (string)?, (string)?, (string)?,((progress: UploadProgress) => void)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, code: File, activate: boolean, installCommand?: string, buildCommand?: string, outputDirectory?: string }; + let onProgress: ((progress: UploadProgress) => void); + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, code: File, activate: boolean, installCommand?: string, buildCommand?: string, outputDirectory?: string }; + onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + } else { + params = { + siteId: paramsOrFirst as string, + code: rest[0] as File, + activate: rest[1] as boolean, + installCommand: rest[2] as string, + buildCommand: rest[3] as string, + outputDirectory: rest[4] as string + }; + onProgress = rest[5] as ((progress: UploadProgress) => void); + } + + const siteId = params.siteId; + const code = params.code; + const activate = params.activate; + const installCommand = params.installCommand; + const buildCommand = params.buildCommand; + const outputDirectory = params.outputDirectory; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } @@ -438,6 +778,7 @@ export class Sites { if (typeof activate === 'undefined') { throw new AppwriteException('Missing required parameter: "activate"'); } + const apiPath = '/sites/{siteId}/deployments'.replace('{siteId}', siteId); const payload: Payload = {}; if (typeof installCommand !== 'undefined') { @@ -471,20 +812,49 @@ export class Sites { } /** - * Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + * Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. * - * @param {string} siteId - * @param {string} deploymentId + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ - createDuplicateDeployment(siteId: string, deploymentId: string): Promise<Models.Deployment> { + createDuplicateDeployment(params: { siteId: string, deploymentId: string }): Promise<Models.Deployment>; + /** + * Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDuplicateDeployment(siteId: string, deploymentId: string): Promise<Models.Deployment>; + createDuplicateDeployment( + paramsOrFirst: { siteId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/sites/{siteId}/deployments/duplicate'.replace('{siteId}', siteId); const payload: Payload = {}; if (typeof deploymentId !== 'undefined') { @@ -509,16 +879,58 @@ export class Sites { * * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details. * - * @param {string} siteId - * @param {string} repository - * @param {string} owner - * @param {string} rootDirectory - * @param {string} version - * @param {boolean} activate + * @param {string} params.siteId - Site ID. + * @param {string} params.repository - Repository name of the template. + * @param {string} params.owner - The name of the owner of the template. + * @param {string} params.rootDirectory - Path to site code in the template repo. + * @param {string} params.version - Version (tag) for the repo linked to the site template. + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createTemplateDeployment(params: { siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }): Promise<Models.Deployment>; + /** + * Create a deployment based on a template. + * + * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details. + * + * @param {string} siteId - Site ID. + * @param {string} repository - Repository name of the template. + * @param {string} owner - The name of the owner of the template. + * @param {string} rootDirectory - Path to site code in the template repo. + * @param {string} version - Version (tag) for the repo linked to the site template. + * @param {boolean} activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createTemplateDeployment(siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean): Promise<Models.Deployment> { + createTemplateDeployment(siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean): Promise<Models.Deployment>; + createTemplateDeployment( + paramsOrFirst: { siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + repository: rest[0] as string, + owner: rest[1] as string, + rootDirectory: rest[2] as string, + version: rest[3] as string, + activate: rest[4] as boolean + }; + } + + const siteId = params.siteId; + const repository = params.repository; + const owner = params.owner; + const rootDirectory = params.rootDirectory; + const version = params.version; + const activate = params.activate; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } @@ -534,6 +946,7 @@ export class Sites { if (typeof version === 'undefined') { throw new AppwriteException('Missing required parameter: "version"'); } + const apiPath = '/sites/{siteId}/deployments/template'.replace('{siteId}', siteId); const payload: Payload = {}; if (typeof repository !== 'undefined') { @@ -570,14 +983,50 @@ export class Sites { * * This endpoint lets you create deployment from a branch, commit, or a tag. * - * @param {string} siteId - * @param {VCSDeploymentType} type - * @param {string} reference - * @param {boolean} activate + * @param {string} params.siteId - Site ID. + * @param {VCSDeploymentType} params.type - Type of reference passed. Allowed values are: branch, commit + * @param {string} params.reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ - createVcsDeployment(siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean): Promise<Models.Deployment> { + createVcsDeployment(params: { siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean }): Promise<Models.Deployment>; + /** + * Create a deployment when a site is connected to VCS. + * + * This endpoint lets you create deployment from a branch, commit, or a tag. + * + * @param {string} siteId - Site ID. + * @param {VCSDeploymentType} type - Type of reference passed. Allowed values are: branch, commit + * @param {string} reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + * @param {boolean} activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVcsDeployment(siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean): Promise<Models.Deployment>; + createVcsDeployment( + paramsOrFirst: { siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean } | string, + ...rest: [(VCSDeploymentType)?, (string)?, (boolean)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, type: VCSDeploymentType, reference: string, activate?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + type: rest[0] as VCSDeploymentType, + reference: rest[1] as string, + activate: rest[2] as boolean + }; + } + + const siteId = params.siteId; + const type = params.type; + const reference = params.reference; + const activate = params.activate; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } @@ -587,6 +1036,7 @@ export class Sites { if (typeof reference === 'undefined') { throw new AppwriteException('Missing required parameter: "reference"'); } + const apiPath = '/sites/{siteId}/deployments/vcs'.replace('{siteId}', siteId); const payload: Payload = {}; if (typeof type !== 'undefined') { @@ -615,18 +1065,47 @@ export class Sites { /** * Get a site deployment by its unique ID. * - * @param {string} siteId - * @param {string} deploymentId + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ - getDeployment(siteId: string, deploymentId: string): Promise<Models.Deployment> { + getDeployment(params: { siteId: string, deploymentId: string }): Promise<Models.Deployment>; + /** + * Get a site deployment by its unique ID. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDeployment(siteId: string, deploymentId: string): Promise<Models.Deployment>; + getDeployment( + paramsOrFirst: { siteId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}'.replace('{siteId}', siteId).replace('{deploymentId}', deploymentId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -645,18 +1124,47 @@ export class Sites { /** * Delete a site deployment by its unique ID. * - * @param {string} siteId - * @param {string} deploymentId + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteDeployment(params: { siteId: string, deploymentId: string }): Promise<{}>; + /** + * Delete a site deployment by its unique ID. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDeployment(siteId: string, deploymentId: string): Promise<{}> { + deleteDeployment(siteId: string, deploymentId: string): Promise<{}>; + deleteDeployment( + paramsOrFirst: { siteId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { siteId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}'.replace('{siteId}', siteId).replace('{deploymentId}', deploymentId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -674,21 +1182,53 @@ export class Sites { } /** - * Get a site deployment 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. + * Get a site deployment 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. * - * @param {string} siteId - * @param {string} deploymentId - * @param {DeploymentDownloadType} type + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. + * @param {DeploymentDownloadType} params.type - Deployment file to download. Can be: "source", "output". * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} */ - getDeploymentDownload(siteId: string, deploymentId: string, type?: DeploymentDownloadType): Promise<ArrayBuffer> { + getDeploymentDownload(params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType }): Promise<ArrayBuffer>; + /** + * Get a site deployment 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. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. + * @param {DeploymentDownloadType} type - Deployment file to download. Can be: "source", "output". + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDeploymentDownload(siteId: string, deploymentId: string, type?: DeploymentDownloadType): Promise<ArrayBuffer>; + getDeploymentDownload( + paramsOrFirst: { siteId: string, deploymentId: string, type?: DeploymentDownloadType } | string, + ...rest: [(string)?, (DeploymentDownloadType)?] + ): Promise<ArrayBuffer> { + let params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string, type?: DeploymentDownloadType }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string, + type: rest[1] as DeploymentDownloadType + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + const type = params.type; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}/download'.replace('{siteId}', siteId).replace('{deploymentId}', deploymentId); const payload: Payload = {}; if (typeof type !== 'undefined') { @@ -709,20 +1249,49 @@ export class Sites { } /** - * Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + updateDeploymentStatus(params: { siteId: string, deploymentId: string }): Promise<Models.Deployment>; + /** + * Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. * - * @param {string} siteId - * @param {string} deploymentId + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateDeploymentStatus(siteId: string, deploymentId: string): Promise<Models.Deployment> { + updateDeploymentStatus(siteId: string, deploymentId: string): Promise<Models.Deployment>; + updateDeploymentStatus( + paramsOrFirst: { siteId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof deploymentId === 'undefined') { throw new AppwriteException('Missing required parameter: "deploymentId"'); } + const apiPath = '/sites/{siteId}/deployments/{deploymentId}/status'.replace('{siteId}', siteId).replace('{deploymentId}', deploymentId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -742,15 +1311,44 @@ export class Sites { /** * Get a list of all site logs. You can use the query params to filter your results. * - * @param {string} siteId - * @param {string[]} queries + * @param {string} params.siteId - Site ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + * @throws {AppwriteException} + * @returns {Promise<Models.ExecutionList>} + */ + listLogs(params: { siteId: string, queries?: string[] }): Promise<Models.ExecutionList>; + /** + * Get a list of all site logs. You can use the query params to filter your results. + * + * @param {string} siteId - Site ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId * @throws {AppwriteException} * @returns {Promise<Models.ExecutionList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listLogs(siteId: string, queries?: string[]): Promise<Models.ExecutionList> { + listLogs(siteId: string, queries?: string[]): Promise<Models.ExecutionList>; + listLogs( + paramsOrFirst: { siteId: string, queries?: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.ExecutionList> { + let params: { siteId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, queries?: string[] }; + } else { + params = { + siteId: paramsOrFirst as string, + queries: rest[0] as string[] + }; + } + + const siteId = params.siteId; + const queries = params.queries; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } + const apiPath = '/sites/{siteId}/logs'.replace('{siteId}', siteId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -772,18 +1370,47 @@ export class Sites { /** * Get a site request log by its unique ID. * - * @param {string} siteId - * @param {string} logId + * @param {string} params.siteId - Site ID. + * @param {string} params.logId - Log ID. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} */ - getLog(siteId: string, logId: string): Promise<Models.Execution> { + getLog(params: { siteId: string, logId: string }): Promise<Models.Execution>; + /** + * Get a site request log by its unique ID. + * + * @param {string} siteId - Site ID. + * @param {string} logId - Log ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Execution>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getLog(siteId: string, logId: string): Promise<Models.Execution>; + getLog( + paramsOrFirst: { siteId: string, logId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Execution> { + let params: { siteId: string, logId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, logId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + logId: rest[0] as string + }; + } + + const siteId = params.siteId; + const logId = params.logId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof logId === 'undefined') { throw new AppwriteException('Missing required parameter: "logId"'); } + const apiPath = '/sites/{siteId}/logs/{logId}'.replace('{siteId}', siteId).replace('{logId}', logId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -802,18 +1429,47 @@ export class Sites { /** * Delete a site log by its unique ID. * - * @param {string} siteId - * @param {string} logId + * @param {string} params.siteId - Site ID. + * @param {string} params.logId - Log ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteLog(params: { siteId: string, logId: string }): Promise<{}>; + /** + * Delete a site log by its unique ID. + * + * @param {string} siteId - Site ID. + * @param {string} logId - Log ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteLog(siteId: string, logId: string): Promise<{}> { + deleteLog(siteId: string, logId: string): Promise<{}>; + deleteLog( + paramsOrFirst: { siteId: string, logId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { siteId: string, logId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, logId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + logId: rest[0] as string + }; + } + + const siteId = params.siteId; + const logId = params.logId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof logId === 'undefined') { throw new AppwriteException('Missing required parameter: "logId"'); } + const apiPath = '/sites/{siteId}/logs/{logId}'.replace('{siteId}', siteId).replace('{logId}', logId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -833,14 +1489,39 @@ export class Sites { /** * Get a list of all variables of a specific site. * - * @param {string} siteId + * @param {string} params.siteId - Site unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.VariableList>} + */ + listVariables(params: { siteId: string }): Promise<Models.VariableList>; + /** + * Get a list of all variables of a specific site. + * + * @param {string} siteId - Site unique ID. * @throws {AppwriteException} * @returns {Promise<Models.VariableList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listVariables(siteId: string): Promise<Models.VariableList> { + listVariables(siteId: string): Promise<Models.VariableList>; + listVariables( + paramsOrFirst: { siteId: string } | string + ): Promise<Models.VariableList> { + let params: { siteId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string }; + } else { + params = { + siteId: paramsOrFirst as string + }; + } + + const siteId = params.siteId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } + const apiPath = '/sites/{siteId}/variables'.replace('{siteId}', siteId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -859,14 +1540,48 @@ export class Sites { /** * Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. * - * @param {string} siteId - * @param {string} key - * @param {string} value - * @param {boolean} secret + * @param {string} params.siteId - Site unique ID. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ - createVariable(siteId: string, key: string, value: string, secret?: boolean): Promise<Models.Variable> { + createVariable(params: { siteId: string, key: string, value: string, secret?: boolean }): Promise<Models.Variable>; + /** + * Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. + * + * @param {string} siteId - Site unique ID. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVariable(siteId: string, key: string, value: string, secret?: boolean): Promise<Models.Variable>; + createVariable( + paramsOrFirst: { siteId: string, key: string, value: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise<Models.Variable> { + let params: { siteId: string, key: string, value: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, key: string, value: string, secret?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + key: rest[0] as string, + value: rest[1] as string, + secret: rest[2] as boolean + }; + } + + const siteId = params.siteId; + const key = params.key; + const value = params.value; + const secret = params.secret; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } @@ -876,6 +1591,7 @@ export class Sites { if (typeof value === 'undefined') { throw new AppwriteException('Missing required parameter: "value"'); } + const apiPath = '/sites/{siteId}/variables'.replace('{siteId}', siteId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -904,18 +1620,47 @@ export class Sites { /** * Get a variable by its unique ID. * - * @param {string} siteId - * @param {string} variableId + * @param {string} params.siteId - Site unique ID. + * @param {string} params.variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + */ + getVariable(params: { siteId: string, variableId: string }): Promise<Models.Variable>; + /** + * Get a variable by its unique ID. + * + * @param {string} siteId - Site unique ID. + * @param {string} variableId - Variable unique ID. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getVariable(siteId: string, variableId: string): Promise<Models.Variable> { + getVariable(siteId: string, variableId: string): Promise<Models.Variable>; + getVariable( + paramsOrFirst: { siteId: string, variableId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Variable> { + let params: { siteId: string, variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, variableId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + variableId: rest[0] as string + }; + } + + const siteId = params.siteId; + const variableId = params.variableId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof variableId === 'undefined') { throw new AppwriteException('Missing required parameter: "variableId"'); } + const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', siteId).replace('{variableId}', variableId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -934,15 +1679,52 @@ export class Sites { /** * Update variable by its unique ID. * - * @param {string} siteId - * @param {string} variableId - * @param {string} key - * @param {string} value - * @param {boolean} secret + * @param {string} params.siteId - Site unique ID. + * @param {string} params.variableId - Variable unique ID. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ - updateVariable(siteId: string, variableId: string, key: string, value?: string, secret?: boolean): Promise<Models.Variable> { + updateVariable(params: { siteId: string, variableId: string, key: string, value?: string, secret?: boolean }): Promise<Models.Variable>; + /** + * Update variable by its unique ID. + * + * @param {string} siteId - Site unique ID. + * @param {string} variableId - Variable unique ID. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateVariable(siteId: string, variableId: string, key: string, value?: string, secret?: boolean): Promise<Models.Variable>; + updateVariable( + paramsOrFirst: { siteId: string, variableId: string, key: string, value?: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Variable> { + let params: { siteId: string, variableId: string, key: string, value?: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, variableId: string, key: string, value?: string, secret?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + variableId: rest[0] as string, + key: rest[1] as string, + value: rest[2] as string, + secret: rest[3] as boolean + }; + } + + const siteId = params.siteId; + const variableId = params.variableId; + const key = params.key; + const value = params.value; + const secret = params.secret; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } @@ -952,6 +1734,7 @@ export class Sites { if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } + const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', siteId).replace('{variableId}', variableId); const payload: Payload = {}; if (typeof key !== 'undefined') { @@ -980,18 +1763,47 @@ export class Sites { /** * Delete a variable by its unique ID. * - * @param {string} siteId - * @param {string} variableId + * @param {string} params.siteId - Site unique ID. + * @param {string} params.variableId - Variable unique ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteVariable(siteId: string, variableId: string): Promise<{}> { + deleteVariable(params: { siteId: string, variableId: string }): Promise<{}>; + /** + * Delete a variable by its unique ID. + * + * @param {string} siteId - Site unique ID. + * @param {string} variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteVariable(siteId: string, variableId: string): Promise<{}>; + deleteVariable( + paramsOrFirst: { siteId: string, variableId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { siteId: string, variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, variableId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + variableId: rest[0] as string + }; + } + + const siteId = params.siteId; + const variableId = params.variableId; + if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } if (typeof variableId === 'undefined') { throw new AppwriteException('Missing required parameter: "variableId"'); } + const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', siteId).replace('{variableId}', variableId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); diff --git a/src/services/storage.ts b/src/services/storage.ts index 3571d89..c0f8377 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -1,5 +1,6 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { Compression } from '../enums/compression'; import { ImageGravity } from '../enums/image-gravity'; import { ImageFormat } from '../enums/image-format'; @@ -14,12 +15,41 @@ export class Storage { /** * Get a list of all the storage buckets. You can use the query params to filter your results. * - * @param {string[]} queries - * @param {string} search + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.BucketList>} + */ + listBuckets(params?: { queries?: string[], search?: string }): Promise<Models.BucketList>; + /** + * Get a list of all the storage buckets. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.BucketList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listBuckets(queries?: string[], search?: string): Promise<Models.BucketList> { + listBuckets(queries?: string[], search?: string): Promise<Models.BucketList>; + listBuckets( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.BucketList> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + const apiPath = '/storage/buckets'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -44,26 +74,79 @@ export class Storage { /** * Create a new storage bucket. * - * @param {string} bucketId - * @param {string} name - * @param {string[]} permissions - * @param {boolean} fileSecurity - * @param {boolean} enabled - * @param {number} maximumFileSize - * @param {string[]} allowedFileExtensions - * @param {Compression} compression - * @param {boolean} encryption - * @param {boolean} antivirus + * @param {string} params.bucketId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Bucket name + * @param {string[]} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. + * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 30MB. + * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. + * @param {Compression} params.compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @throws {AppwriteException} * @returns {Promise<Models.Bucket>} */ - createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket> { + createBucket(params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }): Promise<Models.Bucket>; + /** + * Create a new storage bucket. + * + * @param {string} bucketId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Bucket name + * @param {string[]} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. + * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 30MB. + * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. + * @param {Compression} compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + * @throws {AppwriteException} + * @returns {Promise<Models.Bucket>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket>; + createBucket( + paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?] + ): Promise<Models.Bucket> { + let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }; + } else { + params = { + bucketId: paramsOrFirst as string, + name: rest[0] as string, + permissions: rest[1] as string[], + fileSecurity: rest[2] as boolean, + enabled: rest[3] as boolean, + maximumFileSize: rest[4] as number, + allowedFileExtensions: rest[5] as string[], + compression: rest[6] as Compression, + encryption: rest[7] as boolean, + antivirus: rest[8] as boolean + }; + } + + const bucketId = params.bucketId; + const name = params.name; + const permissions = params.permissions; + const fileSecurity = params.fileSecurity; + const enabled = params.enabled; + const maximumFileSize = params.maximumFileSize; + const allowedFileExtensions = params.allowedFileExtensions; + const compression = params.compression; + const encryption = params.encryption; + const antivirus = params.antivirus; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/storage/buckets'; const payload: Payload = {}; if (typeof bucketId !== 'undefined') { @@ -113,14 +196,39 @@ export class Storage { /** * Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata. * - * @param {string} bucketId + * @param {string} params.bucketId - Bucket unique ID. * @throws {AppwriteException} * @returns {Promise<Models.Bucket>} */ - getBucket(bucketId: string): Promise<Models.Bucket> { + getBucket(params: { bucketId: string }): Promise<Models.Bucket>; + /** + * Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata. + * + * @param {string} bucketId - Bucket unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Bucket>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getBucket(bucketId: string): Promise<Models.Bucket>; + getBucket( + paramsOrFirst: { bucketId: string } | string + ): Promise<Models.Bucket> { + let params: { bucketId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string }; + } else { + params = { + bucketId: paramsOrFirst as string + }; + } + + const bucketId = params.bucketId; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } + const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -139,26 +247,79 @@ export class Storage { /** * Update a storage bucket by its unique ID. * - * @param {string} bucketId - * @param {string} name - * @param {string[]} permissions - * @param {boolean} fileSecurity - * @param {boolean} enabled - * @param {number} maximumFileSize - * @param {string[]} allowedFileExtensions - * @param {Compression} compression - * @param {boolean} encryption - * @param {boolean} antivirus + * @param {string} params.bucketId - Bucket unique ID. + * @param {string} params.name - Bucket name + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. + * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 30MB. + * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. + * @param {Compression} params.compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + * @throws {AppwriteException} + * @returns {Promise<Models.Bucket>} + */ + updateBucket(params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }): Promise<Models.Bucket>; + /** + * Update a storage bucket by its unique ID. + * + * @param {string} bucketId - Bucket unique ID. + * @param {string} name - Bucket name + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. + * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 30MB. + * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. + * @param {Compression} compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @throws {AppwriteException} * @returns {Promise<Models.Bucket>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket> { + updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket>; + updateBucket( + paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?] + ): Promise<Models.Bucket> { + let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean }; + } else { + params = { + bucketId: paramsOrFirst as string, + name: rest[0] as string, + permissions: rest[1] as string[], + fileSecurity: rest[2] as boolean, + enabled: rest[3] as boolean, + maximumFileSize: rest[4] as number, + allowedFileExtensions: rest[5] as string[], + compression: rest[6] as Compression, + encryption: rest[7] as boolean, + antivirus: rest[8] as boolean + }; + } + + const bucketId = params.bucketId; + const name = params.name; + const permissions = params.permissions; + const fileSecurity = params.fileSecurity; + const enabled = params.enabled; + const maximumFileSize = params.maximumFileSize; + const allowedFileExtensions = params.allowedFileExtensions; + const compression = params.compression; + const encryption = params.encryption; + const antivirus = params.antivirus; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -205,14 +366,39 @@ export class Storage { /** * Delete a storage bucket by its unique ID. * - * @param {string} bucketId + * @param {string} params.bucketId - Bucket unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteBucket(params: { bucketId: string }): Promise<{}>; + /** + * Delete a storage bucket by its unique ID. + * + * @param {string} bucketId - Bucket unique ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteBucket(bucketId: string): Promise<{}> { + deleteBucket(bucketId: string): Promise<{}>; + deleteBucket( + paramsOrFirst: { bucketId: string } | string + ): Promise<{}> { + let params: { bucketId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string }; + } else { + params = { + bucketId: paramsOrFirst as string + }; + } + + const bucketId = params.bucketId; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } + const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -232,16 +418,48 @@ export class Storage { /** * Get a list of all the user files. You can use the query params to filter your results. * - * @param {string} bucketId - * @param {string[]} queries - * @param {string} search + * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.FileList>} */ - listFiles(bucketId: string, queries?: string[], search?: string): Promise<Models.FileList> { + listFiles(params: { bucketId: string, queries?: string[], search?: string }): Promise<Models.FileList>; + /** + * Get a list of all the user files. You can use the query params to filter your results. + * + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.FileList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listFiles(bucketId: string, queries?: string[], search?: string): Promise<Models.FileList>; + listFiles( + paramsOrFirst: { bucketId: string, queries?: string[], search?: string } | string, + ...rest: [(string[])?, (string)?] + ): Promise<Models.FileList> { + let params: { bucketId: string, queries?: string[], search?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, queries?: string[], search?: string }; + } else { + params = { + bucketId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string + }; + } + + const bucketId = params.bucketId; + const queries = params.queries; + const search = params.search; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } + const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -268,19 +486,63 @@ export class Storage { * * 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. + * 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} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {File} params.file - Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). + * @param {string[]} params.permissions - An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Models.File>} + */ + createFile(params: { bucketId: string, fileId: string, file: File, permissions?: string[] , onProgress?: (progress: UploadProgress) => void }): Promise<Models.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) 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. + * 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 - * @param {File} file - * @param {string[]} permissions + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {File} file - Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). + * @param {string[]} permissions - An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise<Models.File> { + createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress?: (progress: UploadProgress) => void): Promise<Models.File>; + createFile( + paramsOrFirst: { bucketId: string, fileId: string, file: File, permissions?: string[], onProgress?: (progress: UploadProgress) => void } | string, + ...rest: [(string)?, (File)?, (string[])?,((progress: UploadProgress) => void)?] + ): Promise<Models.File> { + let params: { bucketId: string, fileId: string, file: File, permissions?: string[] }; + let onProgress: ((progress: UploadProgress) => void); + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, file: File, permissions?: string[] }; + onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string, + file: rest[1] as File, + permissions: rest[2] as string[] + }; + onProgress = rest[3] as ((progress: UploadProgress) => void); + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + const file = params.file; + const permissions = params.permissions; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -290,6 +552,7 @@ export class Storage { if (typeof file === 'undefined') { throw new AppwriteException('Missing required parameter: "file"'); } + const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); const payload: Payload = {}; if (typeof fileId !== 'undefined') { @@ -319,18 +582,47 @@ export class Storage { /** * Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata. * - * @param {string} bucketId - * @param {string} fileId + * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File ID. + * @throws {AppwriteException} + * @returns {Promise<Models.File>} + */ + getFile(params: { bucketId: string, fileId: string }): Promise<Models.File>; + /** + * Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata. + * + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File ID. * @throws {AppwriteException} * @returns {Promise<Models.File>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getFile(bucketId: string, fileId: string): Promise<Models.File> { + getFile(bucketId: string, fileId: string): Promise<Models.File>; + getFile( + paramsOrFirst: { bucketId: string, fileId: string } | string, + ...rest: [(string)?] + ): Promise<Models.File> { + let params: { bucketId: string, fileId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string }; + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string + }; + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -349,20 +641,55 @@ export class Storage { /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. * - * @param {string} bucketId - * @param {string} fileId - * @param {string} name - * @param {string[]} permissions + * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File unique ID. + * @param {string} params.name - Name of the file + * @param {string[]} params.permissions - An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} */ - updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise<Models.File> { + updateFile(params: { bucketId: string, fileId: string, name?: string, permissions?: string[] }): Promise<Models.File>; + /** + * Update a file by its unique ID. Only users with write permissions have access to update this resource. + * + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File unique ID. + * @param {string} name - Name of the file + * @param {string[]} permissions - An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Models.File>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise<Models.File>; + updateFile( + paramsOrFirst: { bucketId: string, fileId: string, name?: string, permissions?: string[] } | string, + ...rest: [(string)?, (string)?, (string[])?] + ): Promise<Models.File> { + let params: { bucketId: string, fileId: string, name?: string, permissions?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, name?: string, permissions?: string[] }; + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[] + }; + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + const name = params.name; + const permissions = params.permissions; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -388,18 +715,47 @@ export class Storage { /** * Delete a file by its unique ID. Only users with write permissions have access to delete this resource. * - * @param {string} bucketId - * @param {string} fileId + * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteFile(params: { bucketId: string, fileId: string }): Promise<{}>; + /** + * Delete a file by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteFile(bucketId: string, fileId: string): Promise<{}> { + deleteFile(bucketId: string, fileId: string): Promise<{}>; + deleteFile( + paramsOrFirst: { bucketId: string, fileId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { bucketId: string, fileId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string }; + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string + }; + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -417,21 +773,53 @@ export class Storage { } /** - * 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. + * 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. + * + * @param {string} params.bucketId - Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File ID. + * @param {string} params.token - File token for accessing this file. + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + */ + getFileDownload(params: { bucketId: string, fileId: string, token?: string }): Promise<ArrayBuffer>; + /** + * 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. * - * @param {string} bucketId - * @param {string} fileId - * @param {string} token + * @param {string} bucketId - Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File ID. + * @param {string} token - File token for accessing this file. * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getFileDownload(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer> { + getFileDownload(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer>; + getFileDownload( + paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<ArrayBuffer> { + let params: { bucketId: string, fileId: string, token?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, token?: string }; + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string, + token: rest[1] as string + }; + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + const token = params.token; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; if (typeof token !== 'undefined') { @@ -454,30 +842,95 @@ export class Storage { /** * 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. * - * @param {string} bucketId - * @param {string} fileId - * @param {number} width - * @param {number} height - * @param {ImageGravity} gravity - * @param {number} quality - * @param {number} borderWidth - * @param {string} borderColor - * @param {number} borderRadius - * @param {number} opacity - * @param {number} rotation - * @param {string} background - * @param {ImageFormat} output - * @param {string} token + * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File ID + * @param {number} params.width - Resize preview image width, Pass an integer between 0 to 4000. + * @param {number} params.height - Resize preview image height, Pass an integer between 0 to 4000. + * @param {ImageGravity} params.gravity - Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + * @param {number} params.quality - Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + * @param {number} params.borderWidth - Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. + * @param {string} params.borderColor - Preview image border color. Use a valid HEX color, no # is needed for prefix. + * @param {number} params.borderRadius - Preview image border radius in pixels. Pass an integer between 0 to 4000. + * @param {number} params.opacity - Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1. + * @param {number} params.rotation - Preview image rotation in degrees. Pass an integer between -360 and 360. + * @param {string} params.background - Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. + * @param {ImageFormat} params.output - Output format type (jpeg, jpg, png, gif and webp). + * @param {string} params.token - File token for accessing this file. * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} */ - getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): Promise<ArrayBuffer> { + getFilePreview(params: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }): Promise<ArrayBuffer>; + /** + * 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. + * + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File ID + * @param {number} width - Resize preview image width, Pass an integer between 0 to 4000. + * @param {number} height - Resize preview image height, Pass an integer between 0 to 4000. + * @param {ImageGravity} gravity - Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + * @param {number} quality - Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + * @param {number} borderWidth - Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. + * @param {string} borderColor - Preview image border color. Use a valid HEX color, no # is needed for prefix. + * @param {number} borderRadius - Preview image border radius in pixels. Pass an integer between 0 to 4000. + * @param {number} opacity - Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1. + * @param {number} rotation - Preview image rotation in degrees. Pass an integer between -360 and 360. + * @param {string} background - Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. + * @param {ImageFormat} output - Output format type (jpeg, jpg, png, gif and webp). + * @param {string} token - File token for accessing this file. + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): Promise<ArrayBuffer>; + getFilePreview( + paramsOrFirst: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string } | string, + ...rest: [(string)?, (number)?, (number)?, (ImageGravity)?, (number)?, (number)?, (string)?, (number)?, (number)?, (number)?, (string)?, (ImageFormat)?, (string)?] + ): Promise<ArrayBuffer> { + let params: { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string }; + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string, + width: rest[1] as number, + height: rest[2] as number, + gravity: rest[3] as ImageGravity, + quality: rest[4] as number, + borderWidth: rest[5] as number, + borderColor: rest[6] as string, + borderRadius: rest[7] as number, + opacity: rest[8] as number, + rotation: rest[9] as number, + background: rest[10] as string, + output: rest[11] as ImageFormat, + token: rest[12] as string + }; + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + const width = params.width; + const height = params.height; + const gravity = params.gravity; + const quality = params.quality; + const borderWidth = params.borderWidth; + const borderColor = params.borderColor; + const borderRadius = params.borderRadius; + const opacity = params.opacity; + const rotation = params.rotation; + const background = params.background; + const output = params.output; + const token = params.token; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; if (typeof width !== 'undefined') { @@ -531,21 +984,53 @@ export class Storage { } /** - * Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. + * Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. * - * @param {string} bucketId - * @param {string} fileId - * @param {string} token + * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File ID. + * @param {string} params.token - File token for accessing this file. * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} */ - getFileView(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer> { + getFileView(params: { bucketId: string, fileId: string, token?: string }): Promise<ArrayBuffer>; + /** + * Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. + * + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File ID. + * @param {string} token - File token for accessing this file. + * @throws {AppwriteException} + * @returns {Promise<ArrayBuffer>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getFileView(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer>; + getFileView( + paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<ArrayBuffer> { + let params: { bucketId: string, fileId: string, token?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, token?: string }; + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string, + token: rest[1] as string + }; + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + const token = params.token; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; if (typeof token !== 'undefined') { diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts new file mode 100644 index 0000000..dfe0e1b --- /dev/null +++ b/src/services/tables-db.ts @@ -0,0 +1,4122 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + +import { RelationshipType } from '../enums/relationship-type'; +import { RelationMutate } from '../enums/relation-mutate'; +import { IndexType } from '../enums/index-type'; + +export class TablesDB { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.DatabaseList>} + */ + list(params?: { queries?: string[], search?: string }): Promise<Models.DatabaseList>; + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.DatabaseList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[], search?: string): Promise<Models.DatabaseList>; + list( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.DatabaseList> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + + const apiPath = '/tablesdb'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new Database. + * + * + * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + */ + create(params: { databaseId: string, name: string, enabled?: boolean }): Promise<Models.Database>; + /** + * Create a new Database. + * + * + * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database>; + create( + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.Database> { + let params: { databaseId: string, name: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/tablesdb'; + const payload: Payload = {}; + if (typeof databaseId !== 'undefined') { + payload['databaseId'] = databaseId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + */ + get(params: { databaseId: string }): Promise<Models.Database>; + /** + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(databaseId: string): Promise<Models.Database>; + get( + paramsOrFirst: { databaseId: string } | string + ): Promise<Models.Database> { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a database by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + */ + update(params: { databaseId: string, name: string, enabled?: boolean }): Promise<Models.Database>; + /** + * Update a database by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database>; + update( + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.Database> { + let params: { databaseId: string, name: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { databaseId: string }): Promise<{}>; + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(databaseId: string): Promise<{}>; + delete( + paramsOrFirst: { databaseId: string } | string + ): Promise<{}> { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} params.databaseId - Database ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name, enabled, rowSecurity + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.TableList>} + */ + listTables(params: { databaseId: string, queries?: string[], search?: string }): Promise<Models.TableList>; + /** + * Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} databaseId - Database ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name, enabled, rowSecurity + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.TableList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listTables(databaseId: string, queries?: string[], search?: string): Promise<Models.TableList>; + listTables( + paramsOrFirst: { databaseId: string, queries?: string[], search?: string } | string, + ...rest: [(string[])?, (string)?] + ): Promise<Models.TableList> { + let params: { databaseId: string, queries?: string[], search?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + const search = params.search; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Table name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + */ + createTable(params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean }): Promise<Models.Table>; + /** + * Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Table name. Max length: 128 chars. + * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTable(databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean): Promise<Models.Table>; + createTable( + paramsOrFirst: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?] + ): Promise<Models.Table> { + let params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + rowSecurity: rest[3] as boolean, + enabled: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const name = params.name; + const permissions = params.permissions; + const rowSecurity = params.rowSecurity; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof tableId !== 'undefined') { + payload['tableId'] = tableId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof rowSecurity !== 'undefined') { + payload['rowSecurity'] = rowSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + */ + getTable(params: { databaseId: string, tableId: string }): Promise<Models.Table>; + /** + * Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getTable(databaseId: string, tableId: string): Promise<Models.Table>; + getTable( + paramsOrFirst: { databaseId: string, tableId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Table> { + let params: { databaseId: string, tableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a table by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.name - Table name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + */ + updateTable(params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean }): Promise<Models.Table>; + /** + * Update a table by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} name - Table name. Max length: 128 chars. + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTable(databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean): Promise<Models.Table>; + updateTable( + paramsOrFirst: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?] + ): Promise<Models.Table> { + let params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + rowSecurity: rest[3] as boolean, + enabled: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const name = params.name; + const permissions = params.permissions; + const rowSecurity = params.rowSecurity; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof rowSecurity !== 'undefined') { + payload['rowSecurity'] = rowSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a table by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTable(params: { databaseId: string, tableId: string }): Promise<{}>; + /** + * Delete a table by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteTable(databaseId: string, tableId: string): Promise<{}>; + deleteTable( + paramsOrFirst: { databaseId: string, tableId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { databaseId: string, tableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * List columns in the table. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, size, required, array, status, error + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnList>} + */ + listColumns(params: { databaseId: string, tableId: string, queries?: string[] }): Promise<Models.ColumnList>; + /** + * List columns in the table. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, size, required, array, status, error + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listColumns(databaseId: string, tableId: string, queries?: string[]): Promise<Models.ColumnList>; + listColumns( + paramsOrFirst: { databaseId: string, tableId: string, queries?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.ColumnList> { + let params: { databaseId: string, tableId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + queries: rest[1] as string[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const queries = params.queries; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a boolean column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBoolean>} + */ + createBooleanColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }): Promise<Models.ColumnBoolean>; + /** + * Create a boolean column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBoolean>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise<Models.ColumnBoolean>; + createBooleanColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (boolean)?] + ): Promise<Models.ColumnBoolean> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as boolean, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a boolean column. Changing the `default` value will not update already existing rows. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBoolean>} + */ + updateBooleanColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }): Promise<Models.ColumnBoolean>; + /** + * Update a boolean column. Changing the `default` value will not update already existing rows. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBoolean>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise<Models.ColumnBoolean>; + updateBooleanColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (string)?] + ): Promise<Models.ColumnBoolean> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as boolean, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + 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, + ); + } + + /** + * Create a date time column according to the ISO 8601 standard. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnDatetime>} + */ + createDatetimeColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.ColumnDatetime>; + /** + * Create a date time column according to the ISO 8601 standard. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnDatetime>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnDatetime>; + createDatetimeColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.ColumnDatetime> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a date time column. Changing the `default` value will not update already existing rows. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnDatetime>} + */ + updateDatetimeColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnDatetime>; + /** + * Update a date time column. Changing the `default` value will not update already existing rows. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnDatetime>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnDatetime>; + updateDatetimeColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnDatetime> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + 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, + ); + } + + /** + * Create an email column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEmail>} + */ + createEmailColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.ColumnEmail>; + /** + * Create an email column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEmail>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnEmail>; + createEmailColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.ColumnEmail> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/email'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an email column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEmail>} + */ + updateEmailColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnEmail>; + /** + * Update an email column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEmail>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnEmail>; + updateEmailColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnEmail> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + 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, + ); + } + + /** + * Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {string[]} params.elements - Array of enum values. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEnum>} + */ + createEnumColumn(params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }): Promise<Models.ColumnEnum>; + /** + * Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {string[]} elements - Array of enum values. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEnum>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnEnum>; + createEnumColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.ColumnEnum> { + let params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + elements: rest[2] as string[], + required: rest[3] as boolean, + xdefault: rest[4] as string, + array: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const elements = params.elements; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof elements === 'undefined') { + throw new AppwriteException('Missing required parameter: "elements"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof elements !== 'undefined') { + payload['elements'] = elements; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an enum column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {string[]} params.elements - Updated list of enum values. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEnum>} + */ + updateEnumColumn(params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnEnum>; + /** + * Update an enum column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {string[]} elements - Updated list of enum values. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEnum>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnEnum>; + updateEnumColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnEnum> { + let params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + elements: rest[2] as string[], + required: rest[3] as boolean, + xdefault: rest[4] as string, + newKey: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const elements = params.elements; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof elements === 'undefined') { + throw new AppwriteException('Missing required parameter: "elements"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof elements !== 'undefined') { + payload['elements'] = elements; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + 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, + ); + } + + /** + * Create a float column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number} params.min - Minimum value + * @param {number} params.max - Maximum value + * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnFloat>} + */ + createFloatColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise<Models.ColumnFloat>; + /** + * Create a float column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number} min - Minimum value + * @param {number} max - Maximum value + * @param {number} xdefault - Default value. Cannot be set when required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnFloat>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.ColumnFloat>; + createFloatColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + ): Promise<Models.ColumnFloat> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number, + max: rest[4] as number, + xdefault: rest[5] as number, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/float'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a float column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number} params.min - Minimum value + * @param {number} params.max - Maximum value + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnFloat>} + */ + updateFloatColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise<Models.ColumnFloat>; + /** + * Update a float column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number} min - Minimum value + * @param {number} max - Maximum value + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnFloat>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.ColumnFloat>; + updateFloatColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + ): Promise<Models.ColumnFloat> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number, + min: rest[4] as number, + max: rest[5] as number, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + 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, + ); + } + + /** + * Create an integer column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number} params.min - Minimum value + * @param {number} params.max - Maximum value + * @param {number} params.xdefault - Default value. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnInteger>} + */ + createIntegerColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise<Models.ColumnInteger>; + /** + * Create an integer column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number} min - Minimum value + * @param {number} max - Maximum value + * @param {number} xdefault - Default value. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnInteger>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.ColumnInteger>; + createIntegerColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + ): Promise<Models.ColumnInteger> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number, + max: rest[4] as number, + xdefault: rest[5] as number, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an integer column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number} params.xdefault - Default value. Cannot be set when column is required. + * @param {number} params.min - Minimum value + * @param {number} params.max - Maximum value + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnInteger>} + */ + updateIntegerColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise<Models.ColumnInteger>; + /** + * Update an integer column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number} xdefault - Default value. Cannot be set when column is required. + * @param {number} min - Minimum value + * @param {number} max - Maximum value + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnInteger>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.ColumnInteger>; + updateIntegerColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + ): Promise<Models.ColumnInteger> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number, + min: rest[4] as number, + max: rest[5] as number, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + 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, + ); + } + + /** + * Create IP address column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIp>} + */ + createIpColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.ColumnIp>; + /** + * Create IP address column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIp>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnIp>; + createIpColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.ColumnIp> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an ip column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIp>} + */ + updateIpColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnIp>; + /** + * Update an ip column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIp>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnIp>; + updateIpColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnIp> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + 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, + ); + } + + /** + * Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.relatedTableId - Related Table ID. + * @param {RelationshipType} params.type - Relation type + * @param {boolean} params.twoWay - Is Two Way? + * @param {string} params.key - Column Key. + * @param {string} params.twoWayKey - Two Way Column Key. + * @param {RelationMutate} params.onDelete - Constraints option + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnRelationship>} + */ + createRelationshipColumn(params: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }): Promise<Models.ColumnRelationship>; + /** + * Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} relatedTableId - Related Table ID. + * @param {RelationshipType} type - Relation type + * @param {boolean} twoWay - Is Two Way? + * @param {string} key - Column Key. + * @param {string} twoWayKey - Two Way Column Key. + * @param {RelationMutate} onDelete - Constraints option + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnRelationship>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRelationshipColumn(databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise<Models.ColumnRelationship>; + createRelationshipColumn( + paramsOrFirst: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate } | string, + ...rest: [(string)?, (string)?, (RelationshipType)?, (boolean)?, (string)?, (string)?, (RelationMutate)?] + ): Promise<Models.ColumnRelationship> { + let params: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + relatedTableId: rest[1] as string, + type: rest[2] as RelationshipType, + twoWay: rest[3] as boolean, + key: rest[4] as string, + twoWayKey: rest[5] as string, + onDelete: rest[6] as RelationMutate + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const relatedTableId = params.relatedTableId; + const type = params.type; + const twoWay = params.twoWay; + const key = params.key; + const twoWayKey = params.twoWayKey; + const onDelete = params.onDelete; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof relatedTableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "relatedTableId"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof relatedTableId !== 'undefined') { + payload['relatedTableId'] = relatedTableId; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof twoWay !== 'undefined') { + payload['twoWay'] = twoWay; + } + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof twoWayKey !== 'undefined') { + payload['twoWayKey'] = twoWayKey; + } + if (typeof onDelete !== 'undefined') { + payload['onDelete'] = onDelete; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a string column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.key - Column Key. + * @param {number} params.size - Column size for text columns, in number of characters. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnString>} + */ + createStringColumn(params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.ColumnString>; + /** + * Create a string column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} key - Column Key. + * @param {number} size - Column size for text columns, in number of characters. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnString>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createStringColumn(databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.ColumnString>; + createStringColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.ColumnString> { + let params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + size: rest[2] as number, + required: rest[3] as boolean, + xdefault: rest[4] as string, + array: rest[5] as boolean, + encrypt: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const size = params.size; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof size === 'undefined') { + throw new AppwriteException('Missing required parameter: "size"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/string'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a string column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number} params.size - Maximum size of the string column. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnString>} + */ + updateStringColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise<Models.ColumnString>; + /** + * Update a string column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number} size - Maximum size of the string column. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnString>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateStringColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise<Models.ColumnString>; + updateStringColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + ): Promise<Models.ColumnString> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + size: rest[4] as number, + newKey: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const size = params.size; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + 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, + ); + } + + /** + * Create a URL column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnUrl>} + */ + createUrlColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.ColumnUrl>; + /** + * Create a URL column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnUrl>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnUrl>; + createUrlColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.ColumnUrl> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an url column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnUrl>} + */ + updateUrlColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnUrl>; + /** + * Update an url column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnUrl>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnUrl>; + updateUrlColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnUrl> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + 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, + ); + } + + /** + * Get column by ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + getColumn(params: { databaseId: string, tableId: string, key: string }): Promise<{}>; + /** + * Get column by ID. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getColumn(databaseId: string, tableId: string, key: string): Promise<{}>; + getColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, tableId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Deletes a column. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteColumn(params: { databaseId: string, tableId: string, key: string }): Promise<{}>; + /** + * Deletes a column. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteColumn(databaseId: string, tableId: string, key: string): Promise<{}>; + deleteColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, tableId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {RelationMutate} params.onDelete - Constraints option + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnRelationship>} + */ + updateRelationshipColumn(params: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }): Promise<Models.ColumnRelationship>; + /** + * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {RelationMutate} onDelete - Constraints option + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnRelationship>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRelationshipColumn(databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.ColumnRelationship>; + updateRelationshipColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string } | string, + ...rest: [(string)?, (string)?, (RelationMutate)?, (string)?] + ): Promise<Models.ColumnRelationship> { + let params: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + onDelete: rest[2] as RelationMutate, + newKey: rest[3] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const onDelete = params.onDelete; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof onDelete !== 'undefined') { + payload['onDelete'] = onDelete; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + 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, + ); + } + + /** + * List indexes on the table. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, status, attributes, error + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndexList>} + */ + listIndexes(params: { databaseId: string, tableId: string, queries?: string[] }): Promise<Models.ColumnIndexList>; + /** + * List indexes on the table. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, status, attributes, error + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndexList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listIndexes(databaseId: string, tableId: string, queries?: string[]): Promise<Models.ColumnIndexList>; + listIndexes( + paramsOrFirst: { databaseId: string, tableId: string, queries?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.ColumnIndexList> { + let params: { databaseId: string, tableId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + queries: rest[1] as string[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const queries = params.queries; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Creates an index on the columns listed. Your index should include all the columns you will query in a single request. + * Type can be `key`, `fulltext`, or `unique`. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.key - Index Key. + * @param {IndexType} params.type - Index type. + * @param {string[]} params.columns - Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. + * @param {string[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} params.lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndex>} + */ + createIndex(params: { databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: string[], lengths?: number[] }): Promise<Models.ColumnIndex>; + /** + * Creates an index on the columns listed. Your index should include all the columns you will query in a single request. + * Type can be `key`, `fulltext`, or `unique`. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} key - Index Key. + * @param {IndexType} type - Index type. + * @param {string[]} columns - Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. + * @param {string[]} orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndex>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIndex(databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: string[], lengths?: number[]): Promise<Models.ColumnIndex>; + createIndex( + paramsOrFirst: { databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: string[], lengths?: number[] } | string, + ...rest: [(string)?, (string)?, (IndexType)?, (string[])?, (string[])?, (number[])?] + ): Promise<Models.ColumnIndex> { + let params: { databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: string[], lengths?: number[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: string[], lengths?: number[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + type: rest[2] as IndexType, + columns: rest[3] as string[], + orders: rest[4] as string[], + lengths: rest[5] as number[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const type = params.type; + const columns = params.columns; + const orders = params.orders; + const lengths = params.lengths; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof columns === 'undefined') { + throw new AppwriteException('Missing required parameter: "columns"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof columns !== 'undefined') { + payload['columns'] = columns; + } + if (typeof orders !== 'undefined') { + payload['orders'] = orders; + } + if (typeof lengths !== 'undefined') { + payload['lengths'] = lengths; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get index by ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndex>} + */ + getIndex(params: { databaseId: string, tableId: string, key: string }): Promise<Models.ColumnIndex>; + /** + * Get index by ID. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndex>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getIndex(databaseId: string, tableId: string, key: string): Promise<Models.ColumnIndex>; + getIndex( + paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.ColumnIndex> { + let params: { databaseId: string, tableId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete an index. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteIndex(params: { databaseId: string, tableId: string, key: string }): Promise<{}>; + /** + * Delete an index. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteIndex(databaseId: string, tableId: string, key: string): Promise<{}>; + deleteIndex( + paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, tableId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a list of all the user's rows in a given table. You can use the query params to filter your results. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + */ + listRows<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, queries?: string[] }): Promise<Models.RowList<Row>>; + /** + * Get a list of all the user's rows in a given table. You can use the query params to filter your results. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRows<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, queries?: string[]): Promise<Models.RowList<Row>>; + listRows<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, queries?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.RowList<Row>> { + let params: { databaseId: string, tableId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + queries: rest[1] as string[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const queries = params.queries; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. + * @param {string} params.rowId - Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} params.data - Row data as JSON object. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Row>} + */ + createRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[] }): Promise<Row>; + /** + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. + * @param {string} rowId - Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} data - Row data as JSON object. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Row>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[]): Promise<Row>; + createRow<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[] } | string, + ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, (string[])?] + ): Promise<Row> { + let params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rowId: rest[1] as string, + data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, + permissions: rest[3] as string[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rowId = params.rowId; + const data = params.data; + const permissions = params.permissions; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof rowId !== 'undefined') { + payload['rowId'] = rowId; + } + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. + * @param {object[]} params.rows - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + */ + createRows<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rows: object[] }): Promise<Models.RowList<Row>>; + /** + * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. + * @param {object[]} rows - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRows<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rows: object[]): Promise<Models.RowList<Row>>; + createRows<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, rows: object[] } | string, + ...rest: [(string)?, (object[])?] + ): Promise<Models.RowList<Row>> { + let params: { databaseId: string, tableId: string, rows: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rows: rest[1] as object[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rows = params.rows; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rows === 'undefined') { + throw new AppwriteException('Missing required parameter: "rows"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof rows !== 'undefined') { + payload['rows'] = rows; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {object[]} params.rows - Array of row data as JSON objects. May contain partial rows. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + */ + upsertRows<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rows: object[] }): Promise<Models.RowList<Row>>; + /** + * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {object[]} rows - Array of row data as JSON objects. May contain partial rows. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertRows<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rows: object[]): Promise<Models.RowList<Row>>; + upsertRows<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, rows: object[] } | string, + ...rest: [(string)?, (object[])?] + ): Promise<Models.RowList<Row>> { + let params: { databaseId: string, tableId: string, rows: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rows: rest[1] as object[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rows = params.rows; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rows === 'undefined') { + throw new AppwriteException('Missing required parameter: "rows"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof rows !== 'undefined') { + payload['rows'] = rows; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {object} params.data - Row data as JSON object. Include only column and value pairs to be updated. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + */ + updateRows<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, data?: object, queries?: string[] }): Promise<Models.RowList<Row>>; + /** + * Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {object} data - Row data as JSON object. Include only column and value pairs to be updated. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRows<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, data?: object, queries?: string[]): Promise<Models.RowList<Row>>; + updateRows<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, data?: object, queries?: string[] } | string, + ...rest: [(string)?, (object)?, (string[])?] + ): Promise<Models.RowList<Row>> { + let params: { databaseId: string, tableId: string, data?: object, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, data?: object, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + data: rest[1] as object, + queries: rest[2] as string[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const data = params.data; + const queries = params.queries; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + 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, + ); + } + + /** + * Bulk delete rows using queries, if no queries are passed then all rows are deleted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + */ + deleteRows<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, queries?: string[] }): Promise<Models.RowList<Row>>; + /** + * Bulk delete rows using queries, if no queries are passed then all rows are deleted. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRows<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, queries?: string[]): Promise<Models.RowList<Row>>; + deleteRows<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, queries?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.RowList<Row>> { + let params: { databaseId: string, tableId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + queries: rest[1] as string[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const queries = params.queries; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.rowId - Row ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Row>} + */ + getRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, queries?: string[] }): Promise<Row>; + /** + * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} rowId - Row ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Row>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, queries?: string[]): Promise<Row>; + getRow<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, queries?: string[] } | string, + ...rest: [(string)?, (string)?, (string[])?] + ): Promise<Row> { + let params: { databaseId: string, tableId: string, rowId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, queries?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rowId: rest[1] as string, + queries: rest[2] as string[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rowId = params.rowId; + const queries = params.queries; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.rowId - Row ID. + * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include all required columns of the row to be created or updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Row>} + */ + upsertRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] }): Promise<Row>; + /** + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} rowId - Row ID. + * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include all required columns of the row to be created or updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Row>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[]): Promise<Row>; + upsertRow<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] } | string, + ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, (string[])?] + ): Promise<Row> { + let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rowId: rest[1] as string, + data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, + permissions: rest[3] as string[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rowId = params.rowId; + const data = params.data; + const permissions = params.permissions; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.rowId - Row ID. + * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include only columns and value pairs to be updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Row>} + */ + updateRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] }): Promise<Row>; + /** + * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} rowId - Row ID. + * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include only columns and value pairs to be updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise<Row>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[]): Promise<Row>; + updateRow<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] } | string, + ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, (string[])?] + ): Promise<Row> { + let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rowId: rest[1] as string, + data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, + permissions: rest[3] as string[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rowId = params.rowId; + const data = params.data; + const permissions = params.permissions; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + 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, + ); + } + + /** + * Delete a row by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.rowId - Row ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRow(params: { databaseId: string, tableId: string, rowId: string }): Promise<{}>; + /** + * Delete a row by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} rowId - Row ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRow(databaseId: string, tableId: string, rowId: string): Promise<{}>; + deleteRow( + paramsOrFirst: { databaseId: string, tableId: string, rowId: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, tableId: string, rowId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rowId: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rowId = params.rowId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Decrement a specific column of a row by a given value. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.rowId - Row ID. + * @param {string} params.column - Column key. + * @param {number} params.value - Value to increment the column by. The value must be a number. + * @param {number} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @throws {AppwriteException} + * @returns {Promise<Row>} + */ + decrementRowColumn<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number }): Promise<Row>; + /** + * Decrement a specific column of a row by a given value. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} rowId - Row ID. + * @param {string} column - Column key. + * @param {number} value - Value to increment the column by. The value must be a number. + * @param {number} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @throws {AppwriteException} + * @returns {Promise<Row>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + decrementRowColumn<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number): Promise<Row>; + decrementRowColumn<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?] + ): Promise<Row> { + let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rowId: rest[1] as string, + column: rest[2] as string, + value: rest[3] as number, + min: rest[4] as number + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rowId = params.rowId; + const column = params.column; + const value = params.value; + const min = params.min; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + if (typeof column === 'undefined') { + throw new AppwriteException('Missing required parameter: "column"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId).replace('{column}', column); + const payload: Payload = {}; + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + 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 column of a row by a given value. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.rowId - Row ID. + * @param {string} params.column - Column key. + * @param {number} params.value - Value to increment the column by. The value must be a number. + * @param {number} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @throws {AppwriteException} + * @returns {Promise<Row>} + */ + incrementRowColumn<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number }): Promise<Row>; + /** + * Increment a specific column of a row by a given value. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} rowId - Row ID. + * @param {string} column - Column key. + * @param {number} value - Value to increment the column by. The value must be a number. + * @param {number} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @throws {AppwriteException} + * @returns {Promise<Row>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + incrementRowColumn<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number): Promise<Row>; + incrementRowColumn<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?] + ): Promise<Row> { + let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rowId: rest[1] as string, + column: rest[2] as string, + value: rest[3] as number, + max: rest[4] as number + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rowId = params.rowId; + const column = params.column; + const value = params.value; + const max = params.max; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + if (typeof column === 'undefined') { + throw new AppwriteException('Missing required parameter: "column"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId).replace('{column}', column); + const payload: Payload = {}; + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + 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/teams.ts b/src/services/teams.ts index fbb43d1..5db95e1 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + export class Teams { client: Client; @@ -11,12 +12,41 @@ export class 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. * - * @param {string[]} queries - * @param {string} search + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.TeamList<Preferences>>} + */ + list<Preferences extends Models.Preferences = Models.DefaultPreferences>(params?: { queries?: string[], search?: string }): Promise<Models.TeamList<Preferences>>; + /** + * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.TeamList<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - list<Preferences extends Models.Preferences = Models.DefaultPreferences>(queries?: string[], search?: string): Promise<Models.TeamList<Preferences>> { + list<Preferences extends Models.Preferences = Models.DefaultPreferences>(queries?: string[], search?: string): Promise<Models.TeamList<Preferences>>; + list<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.TeamList<Preferences>> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + const apiPath = '/teams'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -41,19 +71,51 @@ export class Teams { /** * 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. * - * @param {string} teamId - * @param {string} name - * @param {string[]} roles + * @param {string} params.teamId - Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Team name. Max length: 128 chars. + * @param {string[]} params.roles - Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.Team<Preferences>>} + */ + create<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { teamId: string, name: string, roles?: string[] }): Promise<Models.Team<Preferences>>; + /** + * 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. + * + * @param {string} teamId - Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Team name. Max length: 128 chars. + * @param {string[]} roles - Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @throws {AppwriteException} * @returns {Promise<Models.Team<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - create<Preferences extends Models.Preferences = Models.DefaultPreferences>(teamId: string, name: string, roles?: string[]): Promise<Models.Team<Preferences>> { + create<Preferences extends Models.Preferences = Models.DefaultPreferences>(teamId: string, name: string, roles?: string[]): Promise<Models.Team<Preferences>>; + create<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { teamId: string, name: string, roles?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.Team<Preferences>> { + let params: { teamId: string, name: string, roles?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, name: string, roles?: string[] }; + } else { + params = { + teamId: paramsOrFirst as string, + name: rest[0] as string, + roles: rest[1] as string[] + }; + } + + const teamId = params.teamId; + const name = params.name; + const roles = params.roles; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/teams'; const payload: Payload = {}; if (typeof teamId !== 'undefined') { @@ -82,14 +144,39 @@ export class Teams { /** * Get a team by its ID. All team members have read access for this resource. * - * @param {string} teamId + * @param {string} params.teamId - Team ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Team<Preferences>>} + */ + get<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { teamId: string }): Promise<Models.Team<Preferences>>; + /** + * Get a team by its ID. All team members have read access for this resource. + * + * @param {string} teamId - Team ID. * @throws {AppwriteException} * @returns {Promise<Models.Team<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - get<Preferences extends Models.Preferences = Models.DefaultPreferences>(teamId: string): Promise<Models.Team<Preferences>> { + get<Preferences extends Models.Preferences = Models.DefaultPreferences>(teamId: string): Promise<Models.Team<Preferences>>; + get<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { teamId: string } | string + ): Promise<Models.Team<Preferences>> { + let params: { teamId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string }; + } else { + params = { + teamId: paramsOrFirst as string + }; + } + + const teamId = params.teamId; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } + const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -106,20 +193,49 @@ export class Teams { } /** - * Update the team's name by its unique ID. + * Update the team's name by its unique ID. * - * @param {string} teamId - * @param {string} name + * @param {string} params.teamId - Team ID. + * @param {string} params.name - New team name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.Team<Preferences>>} */ - updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(teamId: string, name: string): Promise<Models.Team<Preferences>> { + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { teamId: string, name: string }): Promise<Models.Team<Preferences>>; + /** + * Update the team's name by its unique ID. + * + * @param {string} teamId - Team ID. + * @param {string} name - New team name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Team<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(teamId: string, name: string): Promise<Models.Team<Preferences>>; + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { teamId: string, name: string } | string, + ...rest: [(string)?] + ): Promise<Models.Team<Preferences>> { + let params: { teamId: string, name: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, name: string }; + } else { + params = { + teamId: paramsOrFirst as string, + name: rest[0] as string + }; + } + + const teamId = params.teamId; + const name = params.name; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -142,14 +258,39 @@ export class Teams { /** * Delete a team using its ID. Only team members with the owner role can delete the team. * - * @param {string} teamId + * @param {string} params.teamId - Team ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { teamId: string }): Promise<{}>; + /** + * Delete a team using its ID. Only team members with the owner role can delete the team. + * + * @param {string} teamId - Team ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - delete(teamId: string): Promise<{}> { + delete(teamId: string): Promise<{}>; + delete( + paramsOrFirst: { teamId: string } | string + ): Promise<{}> { + let params: { teamId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string }; + } else { + params = { + teamId: paramsOrFirst as string + }; + } + + const teamId = params.teamId; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } + const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -167,18 +308,50 @@ export class Teams { } /** - * 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. + * 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. * - * @param {string} teamId - * @param {string[]} queries - * @param {string} search + * @param {string} params.teamId - Team ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.MembershipList>} */ - listMemberships(teamId: string, queries?: string[], search?: string): Promise<Models.MembershipList> { + listMemberships(params: { teamId: string, queries?: string[], search?: string }): Promise<Models.MembershipList>; + /** + * 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. + * + * @param {string} teamId - Team ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.MembershipList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listMemberships(teamId: string, queries?: string[], search?: string): Promise<Models.MembershipList>; + listMemberships( + paramsOrFirst: { teamId: string, queries?: string[], search?: string } | string, + ...rest: [(string[])?, (string)?] + ): Promise<Models.MembershipList> { + let params: { teamId: string, queries?: string[], search?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, queries?: string[], search?: string }; + } else { + params = { + teamId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string + }; + } + + const teamId = params.teamId; + const queries = params.queries; + const search = params.search; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } + const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -201,32 +374,83 @@ export class Teams { } /** - * 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. + * 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. + * + * + * @param {string} params.teamId - Team ID. + * @param {string[]} params.roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + * @param {string} params.email - Email of the new team member. + * @param {string} params.userId - ID of the user to be added to a team. + * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @param {string} params.name - Name of the new team member. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Membership>} + */ + createMembership(params: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }): Promise<Models.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 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. + * 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 - * @param {string} email - * @param {string} userId - * @param {string} phone - * @param {string} url - * @param {string} name + * @param {string} teamId - Team ID. + * @param {string[]} roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + * @param {string} email - Email of the new team member. + * @param {string} userId - ID of the user to be added to a team. + * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @param {string} name - Name of the new team member. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createMembership(teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise<Models.Membership> { + createMembership(teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise<Models.Membership>; + createMembership( + paramsOrFirst: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string } | string, + ...rest: [(string[])?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise<Models.Membership> { + let params: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }; + } else { + params = { + teamId: paramsOrFirst as string, + roles: rest[0] as string[], + email: rest[1] as string, + userId: rest[2] as string, + phone: rest[3] as string, + url: rest[4] as string, + name: rest[5] as string + }; + } + + const teamId = params.teamId; + const roles = params.roles; + const email = params.email; + const userId = params.userId; + const phone = params.phone; + const url = params.url; + const name = params.name; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof roles === 'undefined') { throw new AppwriteException('Missing required parameter: "roles"'); } + const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); const payload: Payload = {}; if (typeof email !== 'undefined') { @@ -264,18 +488,47 @@ export class Teams { /** * 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. * - * @param {string} teamId - * @param {string} membershipId + * @param {string} params.teamId - Team ID. + * @param {string} params.membershipId - Membership ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Membership>} + */ + getMembership(params: { teamId: string, membershipId: string }): Promise<Models.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. + * + * @param {string} teamId - Team ID. + * @param {string} membershipId - Membership ID. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getMembership(teamId: string, membershipId: string): Promise<Models.Membership> { + getMembership(teamId: string, membershipId: string): Promise<Models.Membership>; + getMembership( + paramsOrFirst: { teamId: string, membershipId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Membership> { + let params: { teamId: string, membershipId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, membershipId: string }; + } else { + params = { + teamId: paramsOrFirst as string, + membershipId: rest[0] as string + }; + } + + const teamId = params.teamId; + const membershipId = params.membershipId; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof membershipId === 'undefined') { throw new AppwriteException('Missing required parameter: "membershipId"'); } + const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -295,13 +548,45 @@ export class Teams { * 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 - * @param {string[]} roles + * @param {string} params.teamId - Team ID. + * @param {string} params.membershipId - Membership ID. + * @param {string[]} params.roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.Membership>} + */ + updateMembership(params: { teamId: string, membershipId: string, roles: string[] }): Promise<Models.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). + * + * + * @param {string} teamId - Team ID. + * @param {string} membershipId - Membership ID. + * @param {string[]} roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembership(teamId: string, membershipId: string, roles: string[]): Promise<Models.Membership> { + updateMembership(teamId: string, membershipId: string, roles: string[]): Promise<Models.Membership>; + updateMembership( + paramsOrFirst: { teamId: string, membershipId: string, roles: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.Membership> { + let params: { teamId: string, membershipId: string, roles: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, membershipId: string, roles: string[] }; + } else { + params = { + teamId: paramsOrFirst as string, + membershipId: rest[0] as string, + roles: rest[1] as string[] + }; + } + + const teamId = params.teamId; + const membershipId = params.membershipId; + const roles = params.roles; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -311,6 +596,7 @@ export class Teams { if (typeof roles === 'undefined') { throw new AppwriteException('Missing required parameter: "roles"'); } + const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); const payload: Payload = {}; if (typeof roles !== 'undefined') { @@ -333,18 +619,47 @@ export class Teams { /** * 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. * - * @param {string} teamId - * @param {string} membershipId + * @param {string} params.teamId - Team ID. + * @param {string} params.membershipId - Membership ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteMembership(params: { teamId: string, membershipId: string }): Promise<{}>; + /** + * 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. + * + * @param {string} teamId - Team ID. + * @param {string} membershipId - Membership ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteMembership(teamId: string, membershipId: string): Promise<{}> { + deleteMembership(teamId: string, membershipId: string): Promise<{}>; + deleteMembership( + paramsOrFirst: { teamId: string, membershipId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { teamId: string, membershipId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, membershipId: string }; + } else { + params = { + teamId: paramsOrFirst as string, + membershipId: rest[0] as string + }; + } + + const teamId = params.teamId; + const membershipId = params.membershipId; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof membershipId === 'undefined') { throw new AppwriteException('Missing required parameter: "membershipId"'); } + const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -367,14 +682,51 @@ export class Teams { * If the request is successful, a session for the user is automatically created. * * - * @param {string} teamId - * @param {string} membershipId - * @param {string} userId - * @param {string} secret + * @param {string} params.teamId - Team ID. + * @param {string} params.membershipId - Membership ID. + * @param {string} params.userId - User ID. + * @param {string} params.secret - Secret key. + * @throws {AppwriteException} + * @returns {Promise<Models.Membership>} + */ + updateMembershipStatus(params: { teamId: string, membershipId: string, userId: string, secret: string }): Promise<Models.Membership>; + /** + * 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. + * + * + * @param {string} teamId - Team ID. + * @param {string} membershipId - Membership ID. + * @param {string} userId - User ID. + * @param {string} secret - Secret key. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateMembershipStatus(teamId: string, membershipId: string, userId: string, secret: string): Promise<Models.Membership> { + updateMembershipStatus(teamId: string, membershipId: string, userId: string, secret: string): Promise<Models.Membership>; + updateMembershipStatus( + paramsOrFirst: { teamId: string, membershipId: string, userId: string, secret: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<Models.Membership> { + let params: { teamId: string, membershipId: string, userId: string, secret: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, membershipId: string, userId: string, secret: string }; + } else { + params = { + teamId: paramsOrFirst as string, + membershipId: rest[0] as string, + userId: rest[1] as string, + secret: rest[2] as string + }; + } + + const teamId = params.teamId; + const membershipId = params.membershipId; + const userId = params.userId; + const secret = params.secret; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -387,6 +739,7 @@ export class Teams { if (typeof secret === 'undefined') { throw new AppwriteException('Missing required parameter: "secret"'); } + const apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -410,16 +763,41 @@ export class Teams { } /** - * 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). + * 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). * - * @param {string} teamId + * @param {string} params.teamId - Team ID. * @throws {AppwriteException} * @returns {Promise<Preferences>} */ - getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(teamId: string): Promise<Preferences> { + getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { teamId: string }): Promise<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). + * + * @param {string} teamId - Team ID. + * @throws {AppwriteException} + * @returns {Promise<Preferences>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(teamId: string): Promise<Preferences>; + getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { teamId: string } | string + ): Promise<Preferences> { + let params: { teamId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string }; + } else { + params = { + teamId: paramsOrFirst as string + }; + } + + const teamId = params.teamId; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } + const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -436,20 +814,49 @@ export class Teams { } /** - * 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. + * 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. * - * @param {string} teamId - * @param {object} prefs + * @param {string} params.teamId - Team ID. + * @param {object} params.prefs - Prefs key-value JSON object. * @throws {AppwriteException} * @returns {Promise<Preferences>} */ - updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(teamId: string, prefs: object): Promise<Preferences> { + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { teamId: string, prefs: object }): Promise<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. + * + * @param {string} teamId - Team ID. + * @param {object} prefs - Prefs key-value JSON object. + * @throws {AppwriteException} + * @returns {Promise<Preferences>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(teamId: string, prefs: object): Promise<Preferences>; + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { teamId: string, prefs: object } | string, + ...rest: [(object)?] + ): Promise<Preferences> { + let params: { teamId: string, prefs: object }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, prefs: object }; + } else { + params = { + teamId: paramsOrFirst as string, + prefs: rest[0] as object + }; + } + + const teamId = params.teamId; + const prefs = params.prefs; + if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } + const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId); const payload: Payload = {}; if (typeof prefs !== 'undefined') { diff --git a/src/services/tokens.ts b/src/services/tokens.ts index 8cde8ac..f021a0c 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + export class Tokens { client: Client; @@ -11,19 +12,51 @@ export class Tokens { /** * List all the tokens created for a specific file or bucket. You can use the query params to filter your results. * - * @param {string} bucketId - * @param {string} fileId - * @param {string[]} queries + * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceTokenList>} + */ + list(params: { bucketId: string, fileId: string, queries?: string[] }): Promise<Models.ResourceTokenList>; + /** + * List all the tokens created for a specific file or bucket. You can use the query params to filter your results. + * + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire * @throws {AppwriteException} * @returns {Promise<Models.ResourceTokenList>} + * @deprecated Use the object parameter style method for a better developer experience. */ - list(bucketId: string, fileId: string, queries?: string[]): Promise<Models.ResourceTokenList> { + list(bucketId: string, fileId: string, queries?: string[]): Promise<Models.ResourceTokenList>; + list( + paramsOrFirst: { bucketId: string, fileId: string, queries?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.ResourceTokenList> { + let params: { bucketId: string, fileId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, queries?: string[] }; + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string, + queries: rest[1] as string[] + }; + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + const queries = params.queries; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } + const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -45,19 +78,51 @@ export class Tokens { /** * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. * - * @param {string} bucketId - * @param {string} fileId - * @param {string} expire + * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File unique ID. + * @param {string} params.expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ - createFileToken(bucketId: string, fileId: string, expire?: string): Promise<Models.ResourceToken> { + createFileToken(params: { bucketId: string, fileId: string, expire?: string }): Promise<Models.ResourceToken>; + /** + * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. + * + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File unique ID. + * @param {string} expire - Token expiry date + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceToken>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFileToken(bucketId: string, fileId: string, expire?: string): Promise<Models.ResourceToken>; + createFileToken( + paramsOrFirst: { bucketId: string, fileId: string, expire?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.ResourceToken> { + let params: { bucketId: string, fileId: string, expire?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, expire?: string }; + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string, + expire: rest[1] as string + }; + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + const expire = params.expire; + if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } if (typeof fileId === 'undefined') { throw new AppwriteException('Missing required parameter: "fileId"'); } + const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; if (typeof expire !== 'undefined') { @@ -80,14 +145,39 @@ export class Tokens { /** * Get a token by its unique ID. * - * @param {string} tokenId + * @param {string} params.tokenId - Token ID. * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ - get(tokenId: string): Promise<Models.ResourceToken> { + get(params: { tokenId: string }): Promise<Models.ResourceToken>; + /** + * Get a token by its unique ID. + * + * @param {string} tokenId - Token ID. + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceToken>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(tokenId: string): Promise<Models.ResourceToken>; + get( + paramsOrFirst: { tokenId: string } | string + ): Promise<Models.ResourceToken> { + let params: { tokenId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { tokenId: string }; + } else { + params = { + tokenId: paramsOrFirst as string + }; + } + + const tokenId = params.tokenId; + if (typeof tokenId === 'undefined') { throw new AppwriteException('Missing required parameter: "tokenId"'); } + const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -104,17 +194,46 @@ export class Tokens { } /** - * Update a token by its unique ID. Use this endpoint to update a token's expiry date. + * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * - * @param {string} tokenId - * @param {string} expire + * @param {string} params.tokenId - Token unique ID. + * @param {string} params.expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ - update(tokenId: string, expire?: string): Promise<Models.ResourceToken> { + update(params: { tokenId: string, expire?: string }): Promise<Models.ResourceToken>; + /** + * Update a token by its unique ID. Use this endpoint to update a token's expiry date. + * + * @param {string} tokenId - Token unique ID. + * @param {string} expire - File token expiry date + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceToken>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(tokenId: string, expire?: string): Promise<Models.ResourceToken>; + update( + paramsOrFirst: { tokenId: string, expire?: string } | string, + ...rest: [(string)?] + ): Promise<Models.ResourceToken> { + let params: { tokenId: string, expire?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { tokenId: string, expire?: string }; + } else { + params = { + tokenId: paramsOrFirst as string, + expire: rest[0] as string + }; + } + + const tokenId = params.tokenId; + const expire = params.expire; + if (typeof tokenId === 'undefined') { throw new AppwriteException('Missing required parameter: "tokenId"'); } + const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId); const payload: Payload = {}; if (typeof expire !== 'undefined') { @@ -137,14 +256,39 @@ export class Tokens { /** * Delete a token by its unique ID. * - * @param {string} tokenId + * @param {string} params.tokenId - Token ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ - delete(tokenId: string): Promise<{}> { + delete(params: { tokenId: string }): Promise<{}>; + /** + * Delete a token by its unique ID. + * + * @param {string} tokenId - Token ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(tokenId: string): Promise<{}>; + delete( + paramsOrFirst: { tokenId: string } | string + ): Promise<{}> { + let params: { tokenId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { tokenId: string }; + } else { + params = { + tokenId: paramsOrFirst as string + }; + } + + const tokenId = params.tokenId; + if (typeof tokenId === 'undefined') { throw new AppwriteException('Missing required parameter: "tokenId"'); } + const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); diff --git a/src/services/users.ts b/src/services/users.ts index 5c89b4b..eddfa40 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,5 +1,6 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { PasswordHash } from '../enums/password-hash'; import { AuthenticatorType } from '../enums/authenticator-type'; import { MessagingProviderType } from '../enums/messaging-provider-type'; @@ -12,14 +13,43 @@ export class Users { } /** - * Get a list of all the project's users. You can use the query params to filter your results. + * Get a list of all the project's users. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.UserList<Preferences>>} + */ + list<Preferences extends Models.Preferences = Models.DefaultPreferences>(params?: { queries?: string[], search?: string }): Promise<Models.UserList<Preferences>>; + /** + * Get a list of all the project's users. You can use the query params to filter your results. * - * @param {string[]} queries - * @param {string} search + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.UserList<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - list<Preferences extends Models.Preferences = Models.DefaultPreferences>(queries?: string[], search?: string): Promise<Models.UserList<Preferences>> { + list<Preferences extends Models.Preferences = Models.DefaultPreferences>(queries?: string[], search?: string): Promise<Models.UserList<Preferences>>; + list<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.UserList<Preferences>> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + const apiPath = '/users'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -44,18 +74,56 @@ export class Users { /** * Create a new user. * - * @param {string} userId - * @param {string} email - * @param {string} phone - * @param {string} password - * @param {string} name + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.password - Plain text user password. Must be at least 8 chars. + * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - create<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email?: string, phone?: string, password?: string, name?: string): Promise<Models.User<Preferences>> { + create<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email?: string, phone?: string, password?: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} password - Plain text user password. Must be at least 8 chars. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email?: string, phone?: string, password?: string, name?: string): Promise<Models.User<Preferences>>; + create<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email?: string, phone?: string, password?: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email?: string, phone?: string, password?: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email?: string, phone?: string, password?: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + phone: rest[1] as string, + password: rest[2] as string, + name: rest[3] as string + }; + } + + const userId = params.userId; + const email = params.email; + const phone = params.phone; + const password = params.password; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -90,14 +158,48 @@ export class Users { /** * Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param {string} userId - * @param {string} email - * @param {string} password - * @param {string} name + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using Argon2. + * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - createArgon2User<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> { + createArgon2User<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using Argon2. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createArgon2User<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>>; + createArgon2User<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + name: rest[2] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -107,6 +209,7 @@ export class Users { if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/users/argon2'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -138,14 +241,48 @@ export class Users { /** * Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param {string} userId - * @param {string} email - * @param {string} password - * @param {string} name + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using Bcrypt. + * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - createBcryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> { + createBcryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using Bcrypt. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBcryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>>; + createBcryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + name: rest[2] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -155,6 +292,7 @@ export class Users { if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/users/bcrypt'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -186,12 +324,41 @@ export class Users { /** * Get identities for all users. * - * @param {string[]} queries - * @param {string} search + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.IdentityList>} */ - listIdentities(queries?: string[], search?: string): Promise<Models.IdentityList> { + listIdentities(params?: { queries?: string[], search?: string }): Promise<Models.IdentityList>; + /** + * Get identities for all users. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.IdentityList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listIdentities(queries?: string[], search?: string): Promise<Models.IdentityList>; + listIdentities( + paramsOrFirst?: { queries?: string[], search?: string } | string[], + ...rest: [(string)?] + ): Promise<Models.IdentityList> { + let params: { queries?: string[], search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string + }; + } + + const queries = params.queries; + const search = params.search; + + const apiPath = '/users/identities'; const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -216,14 +383,39 @@ export class Users { /** * Delete an identity by its unique ID. * - * @param {string} identityId + * @param {string} params.identityId - Identity ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteIdentity(identityId: string): Promise<{}> { + deleteIdentity(params: { identityId: string }): Promise<{}>; + /** + * Delete an identity by its unique ID. + * + * @param {string} identityId - Identity ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteIdentity(identityId: string): Promise<{}>; + deleteIdentity( + paramsOrFirst: { identityId: string } | string + ): Promise<{}> { + let params: { identityId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { identityId: string }; + } else { + params = { + identityId: paramsOrFirst as string + }; + } + + const identityId = params.identityId; + if (typeof identityId === 'undefined') { throw new AppwriteException('Missing required parameter: "identityId"'); } + const apiPath = '/users/identities/{identityId}'.replace('{identityId}', identityId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -243,14 +435,48 @@ export class Users { /** * Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param {string} userId - * @param {string} email - * @param {string} password - * @param {string} name + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using MD5. + * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - createMD5User<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> { + createMD5User<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using MD5. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMD5User<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>>; + createMD5User<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + name: rest[2] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -260,6 +486,7 @@ export class Users { if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/users/md5'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -291,14 +518,48 @@ export class Users { /** * Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param {string} userId - * @param {string} email - * @param {string} password - * @param {string} name + * @param {string} params.userId - User ID. Choose a custom ID or pass the string `ID.unique()`to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using PHPass. + * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - createPHPassUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> { + createPHPassUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or pass the string `ID.unique()`to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using PHPass. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPHPassUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>>; + createPHPassUser<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + name: rest[2] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -308,6 +569,7 @@ export class Users { if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/users/phpass'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -339,19 +601,68 @@ export class Users { /** * Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param {string} userId - * @param {string} email - * @param {string} password - * @param {string} passwordSalt - * @param {number} passwordCpu - * @param {number} passwordMemory - * @param {number} passwordParallel - * @param {number} passwordLength - * @param {string} name + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using Scrypt. + * @param {string} params.passwordSalt - Optional salt used to hash password. + * @param {number} params.passwordCpu - Optional CPU cost used to hash password. + * @param {number} params.passwordMemory - Optional memory cost used to hash password. + * @param {number} params.passwordParallel - Optional parallelization cost used to hash password. + * @param {number} params.passwordLength - Optional hash length used to hash password. + * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - createScryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string): Promise<Models.User<Preferences>> { + createScryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using Scrypt. + * @param {string} passwordSalt - Optional salt used to hash password. + * @param {number} passwordCpu - Optional CPU cost used to hash password. + * @param {number} passwordMemory - Optional memory cost used to hash password. + * @param {number} passwordParallel - Optional parallelization cost used to hash password. + * @param {number} passwordLength - Optional hash length used to hash password. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createScryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string): Promise<Models.User<Preferences>>; + createScryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (number)?, (number)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + passwordSalt: rest[2] as string, + passwordCpu: rest[3] as number, + passwordMemory: rest[4] as number, + passwordParallel: rest[5] as number, + passwordLength: rest[6] as number, + name: rest[7] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const passwordSalt = params.passwordSalt; + const passwordCpu = params.passwordCpu; + const passwordMemory = params.passwordMemory; + const passwordParallel = params.passwordParallel; + const passwordLength = params.passwordLength; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -376,6 +687,7 @@ export class Users { if (typeof passwordLength === 'undefined') { throw new AppwriteException('Missing required parameter: "passwordLength"'); } + const apiPath = '/users/scrypt'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -422,17 +734,60 @@ export class Users { /** * Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param {string} userId - * @param {string} email - * @param {string} password - * @param {string} passwordSalt - * @param {string} passwordSaltSeparator - * @param {string} passwordSignerKey - * @param {string} name + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using Scrypt Modified. + * @param {string} params.passwordSalt - Salt used to hash password. + * @param {string} params.passwordSaltSeparator - Salt separator used to hash password. + * @param {string} params.passwordSignerKey - Signer key used to hash password. + * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - createScryptModifiedUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string): Promise<Models.User<Preferences>> { + createScryptModifiedUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using Scrypt Modified. + * @param {string} passwordSalt - Salt used to hash password. + * @param {string} passwordSaltSeparator - Salt separator used to hash password. + * @param {string} passwordSignerKey - Signer key used to hash password. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createScryptModifiedUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string): Promise<Models.User<Preferences>>; + createScryptModifiedUser<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + passwordSalt: rest[2] as string, + passwordSaltSeparator: rest[3] as string, + passwordSignerKey: rest[4] as string, + name: rest[5] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const passwordSalt = params.passwordSalt; + const passwordSaltSeparator = params.passwordSaltSeparator; + const passwordSignerKey = params.passwordSignerKey; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -451,6 +806,7 @@ export class Users { if (typeof passwordSignerKey === 'undefined') { throw new AppwriteException('Missing required parameter: "passwordSignerKey"'); } + const apiPath = '/users/scrypt-modified'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -491,15 +847,52 @@ export class Users { /** * Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. * - * @param {string} userId - * @param {string} email - * @param {string} password - * @param {PasswordHash} passwordVersion - * @param {string} name + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using SHA. + * @param {PasswordHash} params.passwordVersion - Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512' + * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - createSHAUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string): Promise<Models.User<Preferences>> { + createSHAUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using SHA. + * @param {PasswordHash} passwordVersion - Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512' + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSHAUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string): Promise<Models.User<Preferences>>; + createSHAUser<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string } | string, + ...rest: [(string)?, (string)?, (PasswordHash)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + passwordVersion: rest[2] as PasswordHash, + name: rest[3] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const passwordVersion = params.passwordVersion; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -509,6 +902,7 @@ export class Users { if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/users/sha'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -543,14 +937,39 @@ export class Users { /** * Get a user by its unique ID. * - * @param {string} userId + * @param {string} params.userId - User ID. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - get<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string): Promise<Models.User<Preferences>> { + get<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string }): Promise<Models.User<Preferences>>; + /** + * Get a user by its unique ID. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string): Promise<Models.User<Preferences>>; + get<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string } | string + ): Promise<Models.User<Preferences>> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}'.replace('{userId}', userId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -567,16 +986,41 @@ export class Users { } /** - * Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. + * Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. * - * @param {string} userId + * @param {string} params.userId - User ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ - delete(userId: string): Promise<{}> { + delete(params: { userId: string }): Promise<{}>; + /** + * Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(userId: string): Promise<{}>; + delete( + paramsOrFirst: { userId: string } | string + ): Promise<{}> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}'.replace('{userId}', userId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -596,18 +1040,47 @@ export class Users { /** * Update the user email by its unique ID. * - * @param {string} userId - * @param {string} email + * @param {string} params.userId - User ID. + * @param {string} params.email - User email. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string }): Promise<Models.User<Preferences>>; + /** + * Update the user email by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} email - User email. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string): Promise<Models.User<Preferences>> { + updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string): Promise<Models.User<Preferences>>; + updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string + }; + } + + const userId = params.userId; + const email = params.email; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } + const apiPath = '/users/{userId}/email'.replace('{userId}', userId); const payload: Payload = {}; if (typeof email !== 'undefined') { @@ -630,16 +1103,48 @@ export class Users { /** * Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. * - * @param {string} userId - * @param {string} sessionId - * @param {number} duration + * @param {string} params.userId - User ID. + * @param {string} params.sessionId - Session ID. Use the string 'recent' to use the most recent session. Defaults to the most recent session. + * @param {number} params.duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Jwt>} + */ + createJWT(params: { userId: string, sessionId?: string, duration?: number }): Promise<Models.Jwt>; + /** + * Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. + * + * @param {string} userId - User ID. + * @param {string} sessionId - Session ID. Use the string 'recent' to use the most recent session. Defaults to the most recent session. + * @param {number} duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. * @throws {AppwriteException} * @returns {Promise<Models.Jwt>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createJWT(userId: string, sessionId?: string, duration?: number): Promise<Models.Jwt> { + createJWT(userId: string, sessionId?: string, duration?: number): Promise<Models.Jwt>; + createJWT( + paramsOrFirst: { userId: string, sessionId?: string, duration?: number } | string, + ...rest: [(string)?, (number)?] + ): Promise<Models.Jwt> { + let params: { userId: string, sessionId?: string, duration?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, sessionId?: string, duration?: number }; + } else { + params = { + userId: paramsOrFirst as string, + sessionId: rest[0] as string, + duration: rest[1] as number + }; + } + + const userId = params.userId; + const sessionId = params.sessionId; + const duration = params.duration; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}/jwts'.replace('{userId}', userId); const payload: Payload = {}; if (typeof sessionId !== 'undefined') { @@ -665,20 +1170,51 @@ export class Users { /** * Update the user labels by its unique ID. * - * Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. + * Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. + * + * @param {string} params.userId - User ID. + * @param {string[]} params.labels - Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateLabels<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, labels: string[] }): Promise<Models.User<Preferences>>; + /** + * Update the user labels by its unique ID. + * + * Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. * - * @param {string} userId - * @param {string[]} labels + * @param {string} userId - User ID. + * @param {string[]} labels - Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateLabels<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, labels: string[]): Promise<Models.User<Preferences>> { + updateLabels<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, labels: string[]): Promise<Models.User<Preferences>>; + updateLabels<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, labels: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, labels: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, labels: string[] }; + } else { + params = { + userId: paramsOrFirst as string, + labels: rest[0] as string[] + }; + } + + const userId = params.userId; + const labels = params.labels; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof labels === 'undefined') { throw new AppwriteException('Missing required parameter: "labels"'); } + const apiPath = '/users/{userId}/labels'.replace('{userId}', userId); const payload: Payload = {}; if (typeof labels !== 'undefined') { @@ -701,15 +1237,44 @@ export class Users { /** * Get the user activity logs list by its unique ID. * - * @param {string} userId - * @param {string[]} queries + * @param {string} params.userId - User ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @throws {AppwriteException} * @returns {Promise<Models.LogList>} */ - listLogs(userId: string, queries?: string[]): Promise<Models.LogList> { + listLogs(params: { userId: string, queries?: string[] }): Promise<Models.LogList>; + /** + * Get the user activity logs list by its unique ID. + * + * @param {string} userId - User ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listLogs(userId: string, queries?: string[]): Promise<Models.LogList>; + listLogs( + paramsOrFirst: { userId: string, queries?: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.LogList> { + let params: { userId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, queries?: string[] }; + } else { + params = { + userId: paramsOrFirst as string, + queries: rest[0] as string[] + }; + } + + const userId = params.userId; + const queries = params.queries; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}/logs'.replace('{userId}', userId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -731,16 +1296,48 @@ export class Users { /** * Get the user membership list by its unique ID. * - * @param {string} userId - * @param {string[]} queries - * @param {string} search + * @param {string} params.userId - User ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<Models.MembershipList>} */ - listMemberships(userId: string, queries?: string[], search?: string): Promise<Models.MembershipList> { + listMemberships(params: { userId: string, queries?: string[], search?: string }): Promise<Models.MembershipList>; + /** + * Get the user membership list by its unique ID. + * + * @param {string} userId - User ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.MembershipList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listMemberships(userId: string, queries?: string[], search?: string): Promise<Models.MembershipList>; + listMemberships( + paramsOrFirst: { userId: string, queries?: string[], search?: string } | string, + ...rest: [(string[])?, (string)?] + ): Promise<Models.MembershipList> { + let params: { userId: string, queries?: string[], search?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, queries?: string[], search?: string }; + } else { + params = { + userId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string + }; + } + + const userId = params.userId; + const queries = params.queries; + const search = params.search; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}/memberships'.replace('{userId}', userId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -765,18 +1362,48 @@ export class Users { /** * Enable or disable MFA on a user account. * - * @param {string} userId - * @param {boolean} mfa + * @param {string} params.userId - User ID. + * @param {boolean} params.mfa - Enable or disable MFA. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.updateMFA` instead. */ - updateMfa<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, mfa: boolean): Promise<Models.User<Preferences>> { + updateMfa<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, mfa: boolean }): Promise<Models.User<Preferences>>; + /** + * Enable or disable MFA on a user account. + * + * @param {string} userId - User ID. + * @param {boolean} mfa - Enable or disable MFA. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMfa<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, mfa: boolean): Promise<Models.User<Preferences>>; + updateMfa<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, mfa: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, mfa: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, mfa: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + mfa: rest[0] as boolean + }; + } + + const userId = params.userId; + const mfa = params.mfa; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } + const apiPath = '/users/{userId}/mfa'.replace('{userId}', userId); const payload: Payload = {}; if (typeof mfa !== 'undefined') { @@ -797,22 +1424,54 @@ export class Users { } /** - * Delete an authenticator app. + * Enable or disable MFA on a user account. * - * @param {string} userId - * @param {AuthenticatorType} type + * @param {string} params.userId - User ID. + * @param {boolean} params.mfa - Enable or disable MFA. * @throws {AppwriteException} - * @returns {Promise<{}>} + * @returns {Promise<Models.User<Preferences>>} + */ + updateMFA<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, mfa: boolean }): Promise<Models.User<Preferences>>; + /** + * Enable or disable MFA on a user account. + * + * @param {string} userId - User ID. + * @param {boolean} mfa - Enable or disable MFA. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteMfaAuthenticator(userId: string, type: AuthenticatorType): Promise<{}> { + updateMFA<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, mfa: boolean): Promise<Models.User<Preferences>>; + updateMFA<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, mfa: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, mfa: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, mfa: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + mfa: rest[0] as boolean + }; + } + + const userId = params.userId; + const mfa = params.mfa; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); + if (typeof mfa === 'undefined') { + throw new AppwriteException('Missing required parameter: "mfa"'); } - const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', userId).replace('{type}', type); + + const apiPath = '/users/{userId}/mfa'.replace('{userId}', userId); const payload: Payload = {}; + if (typeof mfa !== 'undefined') { + payload['mfa'] = mfa; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -820,7 +1479,7 @@ export class Users { } return this.client.call( - 'delete', + 'patch', uri, apiHeaders, payload, @@ -828,25 +1487,60 @@ export class Users { } /** - * List the factors available on the account to be used as a MFA challange. + * Delete an authenticator app. * - * @param {string} userId + * @param {string} params.userId - User ID. + * @param {AuthenticatorType} params.type - Type of authenticator. * @throws {AppwriteException} - * @returns {Promise<Models.MfaFactors>} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.deleteMFAAuthenticator` instead. + */ + deleteMfaAuthenticator(params: { userId: string, type: AuthenticatorType }): Promise<{}>; + /** + * Delete an authenticator app. + * + * @param {string} userId - User ID. + * @param {AuthenticatorType} type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - listMfaFactors(userId: string): Promise<Models.MfaFactors> { + deleteMfaAuthenticator(userId: string, type: AuthenticatorType): Promise<{}>; + deleteMfaAuthenticator( + paramsOrFirst: { userId: string, type: AuthenticatorType } | string, + ...rest: [(AuthenticatorType)?] + ): Promise<{}> { + let params: { userId: string, type: AuthenticatorType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, type: AuthenticatorType }; + } else { + params = { + userId: paramsOrFirst as string, + type: rest[0] as AuthenticatorType + }; + } + + const userId = params.userId; + const type = params.type; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', userId); + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', userId).replace('{type}', type); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', } return this.client.call( - 'get', + 'delete', uri, apiHeaders, payload, @@ -854,25 +1548,59 @@ export class Users { } /** - * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * Delete an authenticator app. * - * @param {string} userId + * @param {string} params.userId - User ID. + * @param {AuthenticatorType} params.type - Type of authenticator. * @throws {AppwriteException} - * @returns {Promise<Models.MfaRecoveryCodes>} + * @returns {Promise<{}>} + */ + deleteMFAAuthenticator(params: { userId: string, type: AuthenticatorType }): Promise<{}>; + /** + * Delete an authenticator app. + * + * @param {string} userId - User ID. + * @param {AuthenticatorType} type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> { + deleteMFAAuthenticator(userId: string, type: AuthenticatorType): Promise<{}>; + deleteMFAAuthenticator( + paramsOrFirst: { userId: string, type: AuthenticatorType } | string, + ...rest: [(AuthenticatorType)?] + ): Promise<{}> { + let params: { userId: string, type: AuthenticatorType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, type: AuthenticatorType }; + } else { + params = { + userId: paramsOrFirst as string, + type: rest[0] as AuthenticatorType + }; + } + + const userId = params.userId; + const type = params.type; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', userId).replace('{type}', type); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', } return this.client.call( - 'get', + 'delete', uri, apiHeaders, payload, @@ -880,26 +1608,51 @@ export class Users { } /** - * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * List the factors available on the account to be used as a MFA challange. * - * @param {string} userId + * @param {string} params.userId - User ID. * @throws {AppwriteException} - * @returns {Promise<Models.MfaRecoveryCodes>} + * @returns {Promise<Models.MfaFactors>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.listMFAFactors` instead. + */ + listMfaFactors(params: { userId: string }): Promise<Models.MfaFactors>; + /** + * List the factors available on the account to be used as a MFA challange. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaFactors>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> { + listMfaFactors(userId: string): Promise<Models.MfaFactors>; + listMfaFactors( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaFactors> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + + const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', userId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', } return this.client.call( - 'put', + 'get', uri, apiHeaders, payload, @@ -907,26 +1660,50 @@ export class Users { } /** - * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. + * List the factors available on the account to be used as a MFA challange. * - * @param {string} userId + * @param {string} params.userId - User ID. * @throws {AppwriteException} - * @returns {Promise<Models.MfaRecoveryCodes>} + * @returns {Promise<Models.MfaFactors>} + */ + listMFAFactors(params: { userId: string }): Promise<Models.MfaFactors>; + /** + * List the factors available on the account to be used as a MFA challange. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaFactors>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> { + listMFAFactors(userId: string): Promise<Models.MfaFactors>; + listMFAFactors( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaFactors> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + + const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', userId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', } return this.client.call( - 'patch', + 'get', uri, apiHeaders, payload, @@ -934,20 +1711,362 @@ export class Users { } /** - * Update the user name by its unique ID. + * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * - * @param {string} userId - * @param {string} name + * @param {string} params.userId - User ID. * @throws {AppwriteException} - * @returns {Promise<Models.User<Preferences>>} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.getMFARecoveryCodes` instead. */ - updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, name: string): Promise<Models.User<Preferences>> { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } + getMfaRecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + getMfaRecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + */ + getMFARecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getMFARecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + getMFARecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.updateMFARecoveryCodes` instead. + */ + updateMfaRecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + updateMfaRecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + */ + updateMFARecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMFARecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + updateMFARecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.createMFARecoveryCodes` instead. + */ + createMfaRecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + createMfaRecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + 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, + ); + } + + /** + * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + */ + createMFARecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMFARecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + createMFARecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + 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, + ); + } + + /** + * Update the user name by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, name: string }): Promise<Models.User<Preferences>>; + /** + * Update the user name by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, name: string): Promise<Models.User<Preferences>>; + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, name: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, name: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, name: string }; + } else { + params = { + userId: paramsOrFirst as string, + name: rest[0] as string + }; + } + + const userId = params.userId; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + const apiPath = '/users/{userId}/name'.replace('{userId}', userId); const payload: Payload = {}; if (typeof name !== 'undefined') { @@ -970,18 +2089,47 @@ export class Users { /** * Update the user password by its unique ID. * - * @param {string} userId - * @param {string} password + * @param {string} params.userId - User ID. + * @param {string} params.password - New user password. Must be at least 8 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, password: string }): Promise<Models.User<Preferences>>; + /** + * Update the user password by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} password - New user password. Must be at least 8 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, password: string): Promise<Models.User<Preferences>> { + updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, password: string): Promise<Models.User<Preferences>>; + updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, password: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, password: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, password: string }; + } else { + params = { + userId: paramsOrFirst as string, + password: rest[0] as string + }; + } + + const userId = params.userId; + const password = params.password; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } + const apiPath = '/users/{userId}/password'.replace('{userId}', userId); const payload: Payload = {}; if (typeof password !== 'undefined') { @@ -1004,18 +2152,47 @@ export class Users { /** * Update the user phone by its unique ID. * - * @param {string} userId - * @param {string} number + * @param {string} params.userId - User ID. + * @param {string} params.number - User phone number. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, number: string): Promise<Models.User<Preferences>> { + updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, number: string }): Promise<Models.User<Preferences>>; + /** + * Update the user phone by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} number - User phone number. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, number: string): Promise<Models.User<Preferences>>; + updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, number: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, number: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, number: string }; + } else { + params = { + userId: paramsOrFirst as string, + number: rest[0] as string + }; + } + + const userId = params.userId; + const number = params.number; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof number === 'undefined') { throw new AppwriteException('Missing required parameter: "number"'); } + const apiPath = '/users/{userId}/phone'.replace('{userId}', userId); const payload: Payload = {}; if (typeof number !== 'undefined') { @@ -1038,14 +2215,39 @@ export class Users { /** * Get the user preferences by its unique ID. * - * @param {string} userId + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Preferences>} + */ + getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string }): Promise<Preferences>; + /** + * Get the user preferences by its unique ID. + * + * @param {string} userId - User ID. * @throws {AppwriteException} * @returns {Promise<Preferences>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string): Promise<Preferences> { + getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string): Promise<Preferences>; + getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string } | string + ): Promise<Preferences> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}/prefs'.replace('{userId}', userId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1064,18 +2266,47 @@ export class Users { /** * Update the user 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 error if exceeded. * - * @param {string} userId - * @param {object} prefs + * @param {string} params.userId - User ID. + * @param {object} params.prefs - Prefs key-value JSON object. + * @throws {AppwriteException} + * @returns {Promise<Preferences>} + */ + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, prefs: object }): Promise<Preferences>; + /** + * Update the user 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 error if exceeded. + * + * @param {string} userId - User ID. + * @param {object} prefs - Prefs key-value JSON object. * @throws {AppwriteException} * @returns {Promise<Preferences>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, prefs: object): Promise<Preferences> { + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, prefs: object): Promise<Preferences>; + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, prefs: object } | string, + ...rest: [(object)?] + ): Promise<Preferences> { + let params: { userId: string, prefs: object }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, prefs: object }; + } else { + params = { + userId: paramsOrFirst as string, + prefs: rest[0] as object + }; + } + + const userId = params.userId; + const prefs = params.prefs; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } + const apiPath = '/users/{userId}/prefs'.replace('{userId}', userId); const payload: Payload = {}; if (typeof prefs !== 'undefined') { @@ -1098,14 +2329,39 @@ export class Users { /** * Get the user sessions list by its unique ID. * - * @param {string} userId + * @param {string} params.userId - User ID. * @throws {AppwriteException} * @returns {Promise<Models.SessionList>} */ - listSessions(userId: string): Promise<Models.SessionList> { + listSessions(params: { userId: string }): Promise<Models.SessionList>; + /** + * Get the user sessions list by its unique ID. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.SessionList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listSessions(userId: string): Promise<Models.SessionList>; + listSessions( + paramsOrFirst: { userId: string } | string + ): Promise<Models.SessionList> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1126,14 +2382,41 @@ export class Users { * * If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint. * - * @param {string} userId + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Session>} */ - createSession(userId: string): Promise<Models.Session> { + createSession(params: { userId: string }): Promise<Models.Session>; + /** + * Creates a session for a user. Returns an immediately usable session object. + * + * If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSession(userId: string): Promise<Models.Session>; + createSession( + paramsOrFirst: { userId: string } | string + ): Promise<Models.Session> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1151,16 +2434,41 @@ export class Users { } /** - * Delete all user's sessions by using the user's unique ID. + * Delete all user's sessions by using the user's unique ID. * - * @param {string} userId + * @param {string} params.userId - User ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteSessions(userId: string): Promise<{}> { + deleteSessions(params: { userId: string }): Promise<{}>; + /** + * Delete all user's sessions by using the user's unique ID. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteSessions(userId: string): Promise<{}>; + deleteSessions( + paramsOrFirst: { userId: string } | string + ): Promise<{}> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1180,18 +2488,47 @@ export class Users { /** * Delete a user sessions by its unique ID. * - * @param {string} userId - * @param {string} sessionId + * @param {string} params.userId - User ID. + * @param {string} params.sessionId - Session ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteSession(params: { userId: string, sessionId: string }): Promise<{}>; + /** + * Delete a user sessions by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} sessionId - Session ID. * @throws {AppwriteException} * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. */ - deleteSession(userId: string, sessionId: string): Promise<{}> { + deleteSession(userId: string, sessionId: string): Promise<{}>; + deleteSession( + paramsOrFirst: { userId: string, sessionId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { userId: string, sessionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, sessionId: string }; + } else { + params = { + userId: paramsOrFirst as string, + sessionId: rest[0] as string + }; + } + + const userId = params.userId; + const sessionId = params.sessionId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof sessionId === 'undefined') { throw new AppwriteException('Missing required parameter: "sessionId"'); } + const apiPath = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1209,20 +2546,49 @@ export class Users { } /** - * Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. + * Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. * - * @param {string} userId - * @param {boolean} status + * @param {string} params.userId - User ID. + * @param {boolean} params.status - User Status. To activate the user pass `true` and to block the user pass `false`. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} */ - updateStatus<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, status: boolean): Promise<Models.User<Preferences>> { + updateStatus<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, status: boolean }): Promise<Models.User<Preferences>>; + /** + * Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. + * + * @param {string} userId - User ID. + * @param {boolean} status - User Status. To activate the user pass `true` and to block the user pass `false`. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateStatus<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, status: boolean): Promise<Models.User<Preferences>>; + updateStatus<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, status: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, status: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, status: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + status: rest[0] as boolean + }; + } + + const userId = params.userId; + const status = params.status; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof status === 'undefined') { throw new AppwriteException('Missing required parameter: "status"'); } + const apiPath = '/users/{userId}/status'.replace('{userId}', userId); const payload: Payload = {}; if (typeof status !== 'undefined') { @@ -1245,15 +2611,44 @@ export class Users { /** * List the messaging targets that are associated with a user. * - * @param {string} userId - * @param {string[]} queries + * @param {string} params.userId - User ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType * @throws {AppwriteException} * @returns {Promise<Models.TargetList>} */ - listTargets(userId: string, queries?: string[]): Promise<Models.TargetList> { + listTargets(params: { userId: string, queries?: string[] }): Promise<Models.TargetList>; + /** + * List the messaging targets that are associated with a user. + * + * @param {string} userId - User ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType + * @throws {AppwriteException} + * @returns {Promise<Models.TargetList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listTargets(userId: string, queries?: string[]): Promise<Models.TargetList>; + listTargets( + paramsOrFirst: { userId: string, queries?: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.TargetList> { + let params: { userId: string, queries?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, queries?: string[] }; + } else { + params = { + userId: paramsOrFirst as string, + queries: rest[0] as string[] + }; + } + + const userId = params.userId; + const queries = params.queries; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}/targets'.replace('{userId}', userId); const payload: Payload = {}; if (typeof queries !== 'undefined') { @@ -1275,16 +2670,56 @@ export class Users { /** * Create a messaging target. * - * @param {string} userId - * @param {string} targetId - * @param {MessagingProviderType} providerType - * @param {string} identifier - * @param {string} providerId - * @param {string} name + * @param {string} params.userId - User ID. + * @param {string} params.targetId - Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {MessagingProviderType} params.providerType - The target provider type. Can be one of the following: `email`, `sms` or `push`. + * @param {string} params.identifier - The target identifier (token, email, phone etc.) + * @param {string} params.providerId - Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @param {string} params.name - Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. * @throws {AppwriteException} * @returns {Promise<Models.Target>} */ - createTarget(userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string): Promise<Models.Target> { + createTarget(params: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }): Promise<Models.Target>; + /** + * Create a messaging target. + * + * @param {string} userId - User ID. + * @param {string} targetId - Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {MessagingProviderType} providerType - The target provider type. Can be one of the following: `email`, `sms` or `push`. + * @param {string} identifier - The target identifier (token, email, phone etc.) + * @param {string} providerId - Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @param {string} name - Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. + * @throws {AppwriteException} + * @returns {Promise<Models.Target>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTarget(userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string): Promise<Models.Target>; + createTarget( + paramsOrFirst: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string } | string, + ...rest: [(string)?, (MessagingProviderType)?, (string)?, (string)?, (string)?] + ): Promise<Models.Target> { + let params: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + targetId: rest[0] as string, + providerType: rest[1] as MessagingProviderType, + identifier: rest[2] as string, + providerId: rest[3] as string, + name: rest[4] as string + }; + } + + const userId = params.userId; + const targetId = params.targetId; + const providerType = params.providerType; + const identifier = params.identifier; + const providerId = params.providerId; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -1297,6 +2732,7 @@ export class Users { if (typeof identifier === 'undefined') { throw new AppwriteException('Missing required parameter: "identifier"'); } + const apiPath = '/users/{userId}/targets'.replace('{userId}', userId); const payload: Payload = {}; if (typeof targetId !== 'undefined') { @@ -1329,20 +2765,49 @@ export class Users { } /** - * Get a user's push notification target by ID. + * Get a user's push notification target by ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.targetId - Target ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Target>} + */ + getTarget(params: { userId: string, targetId: string }): Promise<Models.Target>; + /** + * Get a user's push notification target by ID. * - * @param {string} userId - * @param {string} targetId + * @param {string} userId - User ID. + * @param {string} targetId - Target ID. * @throws {AppwriteException} * @returns {Promise<Models.Target>} + * @deprecated Use the object parameter style method for a better developer experience. */ - getTarget(userId: string, targetId: string): Promise<Models.Target> { + getTarget(userId: string, targetId: string): Promise<Models.Target>; + getTarget( + paramsOrFirst: { userId: string, targetId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Target> { + let params: { userId: string, targetId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, targetId: string }; + } else { + params = { + userId: paramsOrFirst as string, + targetId: rest[0] as string + }; + } + + const userId = params.userId; + const targetId = params.targetId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); } + const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1361,21 +2826,59 @@ export class Users { /** * Update a messaging target. * - * @param {string} userId - * @param {string} targetId - * @param {string} identifier - * @param {string} providerId - * @param {string} name + * @param {string} params.userId - User ID. + * @param {string} params.targetId - Target ID. + * @param {string} params.identifier - The target identifier (token, email, phone etc.) + * @param {string} params.providerId - Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @param {string} params.name - Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. * @throws {AppwriteException} * @returns {Promise<Models.Target>} */ - updateTarget(userId: string, targetId: string, identifier?: string, providerId?: string, name?: string): Promise<Models.Target> { + updateTarget(params: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }): Promise<Models.Target>; + /** + * Update a messaging target. + * + * @param {string} userId - User ID. + * @param {string} targetId - Target ID. + * @param {string} identifier - The target identifier (token, email, phone etc.) + * @param {string} providerId - Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @param {string} name - Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. + * @throws {AppwriteException} + * @returns {Promise<Models.Target>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTarget(userId: string, targetId: string, identifier?: string, providerId?: string, name?: string): Promise<Models.Target>; + updateTarget( + paramsOrFirst: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?] + ): Promise<Models.Target> { + let params: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + targetId: rest[0] as string, + identifier: rest[1] as string, + providerId: rest[2] as string, + name: rest[3] as string + }; + } + + const userId = params.userId; + const targetId = params.targetId; + const identifier = params.identifier; + const providerId = params.providerId; + const name = params.name; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); } + const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); const payload: Payload = {}; if (typeof identifier !== 'undefined') { @@ -1404,18 +2907,47 @@ export class Users { /** * Delete a messaging target. * - * @param {string} userId - * @param {string} targetId + * @param {string} params.userId - User ID. + * @param {string} params.targetId - Target ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteTarget(userId: string, targetId: string): Promise<{}> { + deleteTarget(params: { userId: string, targetId: string }): Promise<{}>; + /** + * Delete a messaging target. + * + * @param {string} userId - User ID. + * @param {string} targetId - Target ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteTarget(userId: string, targetId: string): Promise<{}>; + deleteTarget( + paramsOrFirst: { userId: string, targetId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { userId: string, targetId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, targetId: string }; + } else { + params = { + userId: paramsOrFirst as string, + targetId: rest[0] as string + }; + } + + const userId = params.userId; + const targetId = params.targetId; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); } + const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -1436,16 +2968,49 @@ export class Users { * Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. * * - * @param {string} userId - * @param {number} length - * @param {number} expire + * @param {string} params.userId - User ID. + * @param {number} params.length - Token length in characters. The default length is 6 characters + * @param {number} params.expire - Token expiration period in seconds. The default expiration is 15 minutes. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + */ + createToken(params: { userId: string, length?: number, expire?: number }): Promise<Models.Token>; + /** + * Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. + * + * + * @param {string} userId - User ID. + * @param {number} length - Token length in characters. The default length is 6 characters + * @param {number} expire - Token expiration period in seconds. The default expiration is 15 minutes. * @throws {AppwriteException} * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. */ - createToken(userId: string, length?: number, expire?: number): Promise<Models.Token> { + createToken(userId: string, length?: number, expire?: number): Promise<Models.Token>; + createToken( + paramsOrFirst: { userId: string, length?: number, expire?: number } | string, + ...rest: [(number)?, (number)?] + ): Promise<Models.Token> { + let params: { userId: string, length?: number, expire?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, length?: number, expire?: number }; + } else { + params = { + userId: paramsOrFirst as string, + length: rest[0] as number, + expire: rest[1] as number + }; + } + + const userId = params.userId; + const length = params.length; + const expire = params.expire; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } + const apiPath = '/users/{userId}/tokens'.replace('{userId}', userId); const payload: Payload = {}; if (typeof length !== 'undefined') { @@ -1471,18 +3036,47 @@ export class Users { /** * Update the user email verification status by its unique ID. * - * @param {string} userId - * @param {boolean} emailVerification + * @param {string} params.userId - User ID. + * @param {boolean} params.emailVerification - User email verification status. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateEmailVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, emailVerification: boolean }): Promise<Models.User<Preferences>>; + /** + * Update the user email verification status by its unique ID. + * + * @param {string} userId - User ID. + * @param {boolean} emailVerification - User email verification status. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, emailVerification: boolean): Promise<Models.User<Preferences>> { + updateEmailVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, emailVerification: boolean): Promise<Models.User<Preferences>>; + updateEmailVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, emailVerification: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, emailVerification: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, emailVerification: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + emailVerification: rest[0] as boolean + }; + } + + const userId = params.userId; + const emailVerification = params.emailVerification; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof emailVerification === 'undefined') { throw new AppwriteException('Missing required parameter: "emailVerification"'); } + const apiPath = '/users/{userId}/verification'.replace('{userId}', userId); const payload: Payload = {}; if (typeof emailVerification !== 'undefined') { @@ -1505,18 +3099,47 @@ export class Users { /** * Update the user phone verification status by its unique ID. * - * @param {string} userId - * @param {boolean} phoneVerification + * @param {string} params.userId - User ID. + * @param {boolean} params.phoneVerification - User phone verification status. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updatePhoneVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, phoneVerification: boolean }): Promise<Models.User<Preferences>>; + /** + * Update the user phone verification status by its unique ID. + * + * @param {string} userId - User ID. + * @param {boolean} phoneVerification - User phone verification status. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. */ - updatePhoneVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, phoneVerification: boolean): Promise<Models.User<Preferences>> { + updatePhoneVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, phoneVerification: boolean): Promise<Models.User<Preferences>>; + updatePhoneVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, phoneVerification: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, phoneVerification: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, phoneVerification: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + phoneVerification: rest[0] as boolean + }; + } + + const userId = params.userId; + const phoneVerification = params.phoneVerification; + if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } if (typeof phoneVerification === 'undefined') { throw new AppwriteException('Missing required parameter: "phoneVerification"'); } + const apiPath = '/users/{userId}/verification/phone'.replace('{userId}', userId); const payload: Payload = {}; if (typeof phoneVerification !== 'undefined') {