diff --git a/README.md b/README.md index e0a6459..3f78aa7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Deno SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-deno.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-deno/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-deno/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Deno SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -23,6 +23,7 @@ import * as sdk from "https://deno.land/x/appwrite/mod.ts"; ## 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 from project's API keys section. ```typescript @@ -48,6 +49,7 @@ console.log(user); ``` ### Full Example + ```typescript import * as sdk from "https://deno.land/x/appwrite/mod.ts"; @@ -66,6 +68,7 @@ console.log(user); ``` ### Error Handling + The Appwrite Deno 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. ```typescript @@ -79,6 +82,7 @@ try { ``` ### Learn more + You can use the following resources to learn more and get help - 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) - 📜 [Appwrite Docs](https://appwrite.io/docs) diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index d08a92d..ab71bc3 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 Client() const account = new Account(client); -const response = await account.createEmailPasswordSession( - 'email@example.com', // email - 'password' // password -); +const response = 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 384a3fb..daab356 100644 --- a/docs/examples/account/create-email-token.md +++ b/docs/examples/account/create-email-token.md @@ -6,8 +6,8 @@ const client = new Client() const account = new Account(client); -const response = await account.createEmailToken( - '', // userId - 'email@example.com', // email - false // phrase (optional) -); +const response = 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 58% rename from docs/examples/account/create-magic-u-r-l-token.md rename to docs/examples/account/create-magic-url-token.md index 29e552a..266aa8b 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 Client() const account = new Account(client); -const response = await account.createMagicURLToken( - '', // userId - 'email@example.com', // email - 'https://example.com', // url (optional) - false // phrase (optional) -); +const response = 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 52c193a..0e496e0 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.createMfaAuthenticator( - AuthenticatorType.Totp // type -); +const response = await account.createMFAAuthenticator({ + type: AuthenticatorType.Totp +}); diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index 296e36d..a36e286 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -6,6 +6,6 @@ const client = new Client() const account = new Account(client); -const response = await account.createMfaChallenge( - AuthenticationFactor.Email // factor -); +const response = await account.createMFAChallenge({ + factor: AuthenticationFactor.Email +}); diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index cfd9aa2..5a8f6a3 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 Client() const account = new Account(client); -const response = await account.createMfaRecoveryCodes(); +const response = 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 59% rename from docs/examples/account/create-o-auth2token.md rename to docs/examples/account/create-o-auth-2-token.md index 24e43a9..bc1f5fc 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 Client() const account = new Account(client); -account.createOAuth2Token( - OAuthProvider.Amazon, // provider - 'https://example.com', // success (optional) - 'https://example.com', // failure (optional) - [] // scopes (optional) -); +account.createOAuth2Token({ + provider: 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 77e4adc..f31ddee 100644 --- a/docs/examples/account/create-phone-token.md +++ b/docs/examples/account/create-phone-token.md @@ -6,7 +6,7 @@ const client = new Client() const account = new Account(client); -const response = await account.createPhoneToken( - '', // userId - '+12065550100' // phone -); +const response = await account.createPhoneToken({ + userId: '', + phone: '+12065550100' +}); diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index a3d92d8..cd08f64 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const response = await account.createRecovery( - 'email@example.com', // email - 'https://example.com' // url -); +const response = 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 888493a..ff238a8 100644 --- a/docs/examples/account/create-session.md +++ b/docs/examples/account/create-session.md @@ -6,7 +6,7 @@ const client = new Client() const account = new Account(client); -const response = await account.createSession( - '', // userId - '' // secret -); +const response = await account.createSession({ + userId: '', + secret: '' +}); diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index 438feee..002c3f6 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.createVerification( - 'https://example.com' // url -); +const response = await account.createVerification({ + url: 'https://example.com' +}); diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index c410a0f..025dad8 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -6,9 +6,9 @@ const client = new Client() const account = new Account(client); -const response = await account.create( - '', // userId - 'email@example.com', // email - '', // password - '' // name (optional) -); +const response = 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 359c7a3..26490a5 100644 --- a/docs/examples/account/delete-identity.md +++ b/docs/examples/account/delete-identity.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.deleteIdentity( - '' // identityId -); +const response = await account.deleteIdentity({ + identityId: '' +}); diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index f4b164b..777347d 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.deleteMfaAuthenticator( - AuthenticatorType.Totp // type -); +const response = await account.deleteMFAAuthenticator({ + type: AuthenticatorType.Totp +}); diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index a0b7d19..8472e57 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.deleteSession( - '' // sessionId -); +const response = 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 73fc143..6f631ac 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 Client() const account = new Account(client); -const response = await account.getMfaRecoveryCodes(); +const response = await account.getMFARecoveryCodes(); diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index c380b72..05d1782 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.getSession( - '' // sessionId -); +const response = await account.getSession({ + sessionId: '' +}); diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index 1c612f9..cbcac73 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.listIdentities( - [] // queries (optional) -); +const response = await account.listIdentities({ + queries: [] // optional +}); diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index 28ab351..6e7ce67 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.listLogs( - [] // queries (optional) -); +const response = await account.listLogs({ + queries: [] // optional +}); diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index 35fb749..0eb3d5d 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -7,4 +7,4 @@ const client = new Client() const account = new Account(client); -const response = await account.listMfaFactors(); +const response = await account.listMFAFactors(); diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index 0753cff..746309e 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const response = await account.updateEmail( - 'email@example.com', // email - 'password' // password -); +const response = 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 71% rename from docs/examples/account/update-magic-u-r-l-session.md rename to docs/examples/account/update-magic-url-session.md index a83c1d9..b40824b 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 Client() const account = new Account(client); -const response = await account.updateMagicURLSession( - '', // userId - '' // secret -); +const response = await account.updateMagicURLSession({ + userId: '', + secret: '' +}); diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index 6b95818..1049f6a 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const response = await account.updateMfaAuthenticator( - AuthenticatorType.Totp, // type - '' // otp -); +const response = await account.updateMFAAuthenticator({ + type: AuthenticatorType.Totp, + otp: '' +}); diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index 61a7b44..9ee0825 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const response = await account.updateMfaChallenge( - '', // challengeId - '' // otp -); +const response = 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 2030e1c..eae8560 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 Client() const account = new Account(client); -const response = await account.updateMfaRecoveryCodes(); +const response = await account.updateMFARecoveryCodes(); diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-mfa.md similarity index 84% rename from docs/examples/account/update-m-f-a.md rename to docs/examples/account/update-mfa.md index 24611aa..ab496cd 100644 --- a/docs/examples/account/update-m-f-a.md +++ b/docs/examples/account/update-mfa.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.updateMFA( - false // mfa -); +const response = await account.updateMFA({ + mfa: false +}); diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index a02591b..c62bcf1 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.updateName( - '' // name -); +const response = await account.updateName({ + name: '' +}); diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index 088bea8..1bd388a 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const response = await account.updatePassword( - '', // password - 'password' // oldPassword (optional) -); +const response = 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 4710a45..4a86183 100644 --- a/docs/examples/account/update-phone-session.md +++ b/docs/examples/account/update-phone-session.md @@ -6,7 +6,7 @@ const client = new Client() const account = new Account(client); -const response = await account.updatePhoneSession( - '', // userId - '' // secret -); +const response = await account.updatePhoneSession({ + userId: '', + secret: '' +}); diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index 3b150c8..30f9b40 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const response = await account.updatePhoneVerification( - '', // userId - '' // secret -); +const response = await account.updatePhoneVerification({ + userId: '', + secret: '' +}); diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index 9c1923c..821c279 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const response = await account.updatePhone( - '+12065550100', // phone - 'password' // password -); +const response = await account.updatePhone({ + phone: '+12065550100', + password: 'password' +}); diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 4b37a64..f7bb254 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.updatePrefs( - {} // prefs -); +const response = await account.updatePrefs({ + prefs: {} +}); diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 5d0d80f..031b6a3 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -7,8 +7,8 @@ const client = new Client() const account = new Account(client); -const response = await account.updateRecovery( - '', // userId - '', // secret - '' // password -); +const response = await account.updateRecovery({ + userId: '', + secret: '', + password: '' +}); diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index cb36b94..cccd5d2 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -7,6 +7,6 @@ const client = new Client() const account = new Account(client); -const response = await account.updateSession( - '' // sessionId -); +const response = await account.updateSession({ + sessionId: '' +}); diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 9637085..1ef9050 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const response = await account.updateVerification( - '', // userId - '' // secret -); +const response = await account.updateVerification({ + userId: '', + secret: '' +}); diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 5443200..fbef7ee 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -7,9 +7,9 @@ const client = new Client() const avatars = new Avatars(client); -const result = avatars.getBrowser( - Browser.AvantBrowser, // code - 0, // width (optional) - 0, // height (optional) - -1 // quality (optional) -); +const result = avatars.getBrowser({ + code: 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 8bcc67e..c4323c3 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -7,9 +7,9 @@ const client = new Client() const avatars = new Avatars(client); -const result = avatars.getCreditCard( - CreditCard.AmericanExpress, // code - 0, // width (optional) - 0, // height (optional) - -1 // quality (optional) -); +const result = avatars.getCreditCard({ + code: 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 cca313a..5a1a002 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -7,6 +7,6 @@ const client = new Client() const avatars = new Avatars(client); -const result = avatars.getFavicon( - 'https://example.com' // url -); +const result = avatars.getFavicon({ + url: 'https://example.com' +}); diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index 6837438..7032c48 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -7,9 +7,9 @@ const client = new Client() const avatars = new Avatars(client); -const result = avatars.getFlag( - Flag.Afghanistan, // code - 0, // width (optional) - 0, // height (optional) - -1 // quality (optional) -); +const result = avatars.getFlag({ + code: 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 2960dab..d4012ed 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -7,8 +7,8 @@ const client = new Client() const avatars = new Avatars(client); -const result = avatars.getImage( - 'https://example.com', // url - 0, // width (optional) - 0 // height (optional) -); +const result = 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 10eb2d8..c086997 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -7,9 +7,9 @@ const client = new Client() const avatars = new Avatars(client); -const result = avatars.getInitials( - '', // name (optional) - 0, // width (optional) - 0, // height (optional) - '' // background (optional) -); +const result = 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 70% rename from docs/examples/avatars/get-q-r.md rename to docs/examples/avatars/get-qr.md index d9ccc0d..096014b 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-qr.md @@ -7,9 +7,9 @@ const client = new Client() const avatars = new Avatars(client); -const result = avatars.getQR( - '', // text - 1, // size (optional) - 0, // margin (optional) - false // download (optional) -); +const result = 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 b216c2e..fbcdde4 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createBooleanAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - false, // default (optional) - false // array (optional) -); +const response = 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 c7e8026..9b2776a 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createCollection( - '', // databaseId - '', // collectionId - '', // name - ["read("any")"], // permissions (optional) - false, // documentSecurity (optional) - false // enabled (optional) -); +const response = 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 664da19..80dec8c 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createDatetimeAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - '', // default (optional) - false // array (optional) -); +const response = 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 be8a1bd..784b7dd 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -7,10 +7,10 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createDocument( - '', // databaseId - '', // collectionId - '', // documentId - {}, // data - ["read("any")"] // permissions (optional) -); +const response = 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 26c9796..71011da 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createDocuments( - '', // databaseId - '', // collectionId - [] // documents -); +const response = 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 6c667ed..6206a74 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createEmailAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - 'email@example.com', // default (optional) - false // array (optional) -); +const response = 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 6fdd277..b8555bf 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -7,12 +7,12 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createEnumAttribute( - '', // databaseId - '', // collectionId - '', // key - [], // elements - false, // required - '', // default (optional) - false // array (optional) -); +const response = 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 c5991d4..3cec0ee 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -7,13 +7,13 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createFloatAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - null, // min (optional) - null, // max (optional) - null, // default (optional) - false // array (optional) -); +const response = 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 3ab3c7a..b2be093 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -7,12 +7,12 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createIndex( - '', // databaseId - '', // collectionId - '', // key - IndexType.Key, // type - [], // attributes - [], // orders (optional) - [] // lengths (optional) -); +const response = await databases.createIndex({ + databaseId: '', + collectionId: '', + key: '', + type: 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 4a306cd..37ba43a 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -7,13 +7,13 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createIntegerAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - null, // min (optional) - null, // max (optional) - null, // default (optional) - false // array (optional) -); +const response = 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 c043b25..047622d 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createIpAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - '', // default (optional) - false // array (optional) -); +const response = 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 d96ee59..39c73d0 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -7,13 +7,13 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createRelationshipAttribute( - '', // databaseId - '', // collectionId - '', // relatedCollectionId - RelationshipType.OneToOne, // type - false, // twoWay (optional) - '', // key (optional) - '', // twoWayKey (optional) - RelationMutate.Cascade // onDelete (optional) -); +const response = await databases.createRelationshipAttribute({ + databaseId: '', + collectionId: '', + relatedCollectionId: '', + type: RelationshipType.OneToOne, + twoWay: false, // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: RelationMutate.Cascade // optional +}); diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index 5f8e955..17d4aa1 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -7,13 +7,13 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createStringAttribute( - '', // databaseId - '', // collectionId - '', // key - 1, // size - false, // required - '', // default (optional) - false, // array (optional) - false // encrypt (optional) -); +const response = 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 4639f75..f60423c 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.createUrlAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - 'https://example.com', // default (optional) - false // array (optional) -); +const response = 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 86795eb..63e5471 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.create( - '', // databaseId - '', // name - false // enabled (optional) -); +const response = 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 0142188..52d7192 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -3,15 +3,15 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject('') // Your project ID - .setKey(''); // Your secret API key + .setSession(''); // The user session to authenticate with const databases = new Databases(client); -const response = await databases.decrementDocumentAttribute( - '', // databaseId - '', // collectionId - '', // documentId - '', // attribute - null, // value (optional) - null // min (optional) -); +const response = 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 f7ad6b1..d41c512 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.deleteAttribute( - '', // databaseId - '', // collectionId - '' // key -); +const response = await databases.deleteAttribute({ + databaseId: '', + collectionId: '', + key: '' +}); diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md index 828d48a..d2a2b70 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -7,7 +7,7 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.deleteCollection( - '', // databaseId - '' // collectionId -); +const response = await databases.deleteCollection({ + databaseId: '', + collectionId: '' +}); diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 47d5df4..6efe03f 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.deleteDocument( - '', // databaseId - '', // collectionId - '' // documentId -); +const response = await databases.deleteDocument({ + databaseId: '', + collectionId: '', + documentId: '' +}); diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 4768ed4..b63a960 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.deleteDocuments( - '', // databaseId - '', // collectionId - [] // queries (optional) -); +const response = await databases.deleteDocuments({ + databaseId: '', + collectionId: '', + queries: [] // optional +}); diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index eee1613..c2f2969 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.deleteIndex( - '', // databaseId - '', // collectionId - '' // key -); +const response = await databases.deleteIndex({ + databaseId: '', + collectionId: '', + key: '' +}); diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index 39b3f53..e14a83c 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -7,6 +7,6 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.delete( - '' // databaseId -); +const response = await databases.delete({ + databaseId: '' +}); diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index f2b801b..efe2155 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.getAttribute( - '', // databaseId - '', // collectionId - '' // key -); +const response = await databases.getAttribute({ + databaseId: '', + collectionId: '', + key: '' +}); diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index b94f4fd..0745ad9 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -7,7 +7,7 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.getCollection( - '', // databaseId - '' // collectionId -); +const response = await databases.getCollection({ + databaseId: '', + collectionId: '' +}); diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 5cb02c4..fb84158 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -7,9 +7,9 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.getDocument( - '', // databaseId - '', // collectionId - '', // documentId - [] // queries (optional) -); +const response = 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 6c3a3de..235eed6 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.getIndex( - '', // databaseId - '', // collectionId - '' // key -); +const response = await databases.getIndex({ + databaseId: '', + collectionId: '', + key: '' +}); diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index 403e467..0891f72 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -7,6 +7,6 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.get( - '' // databaseId -); +const response = await databases.get({ + databaseId: '' +}); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 9202a94..c32c484 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -3,15 +3,15 @@ import { Client, Databases } from "https://deno.land/x/appwrite/mod.ts"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject('') // Your project ID - .setKey(''); // Your secret API key + .setSession(''); // The user session to authenticate with const databases = new Databases(client); -const response = await databases.incrementDocumentAttribute( - '', // databaseId - '', // collectionId - '', // documentId - '', // attribute - null, // value (optional) - null // max (optional) -); +const response = 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 2171ffe..39de5d4 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.listAttributes( - '', // databaseId - '', // collectionId - [] // queries (optional) -); +const response = await databases.listAttributes({ + databaseId: '', + collectionId: '', + queries: [] // optional +}); diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index 408ea2d..264be3c 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.listCollections( - '', // databaseId - [], // queries (optional) - '' // search (optional) -); +const response = 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 528e979..5c38998 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.listDocuments( - '', // databaseId - '', // collectionId - [] // queries (optional) -); +const response = await databases.listDocuments({ + databaseId: '', + collectionId: '', + queries: [] // optional +}); diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index 88af3b7..628a434 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.listIndexes( - '', // databaseId - '', // collectionId - [] // queries (optional) -); +const response = await databases.listIndexes({ + databaseId: '', + collectionId: '', + queries: [] // optional +}); diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index dcae151..4ba17dd 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -7,7 +7,7 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.list( - [], // queries (optional) - '' // search (optional) -); +const response = 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 fe1b800..28e4718 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateBooleanAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - false, // default - '' // newKey (optional) -); +const response = 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 47f1c02..89b2d0e 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateCollection( - '', // databaseId - '', // collectionId - '', // name - ["read("any")"], // permissions (optional) - false, // documentSecurity (optional) - false // enabled (optional) -); +const response = 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 ad18d93..9e9116b 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateDatetimeAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - '', // default - '' // newKey (optional) -); +const response = 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 31cce5e..2a59177 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -7,10 +7,10 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateDocument( - '', // databaseId - '', // collectionId - '', // documentId - {}, // data (optional) - ["read("any")"] // permissions (optional) -); +const response = 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 1eef779..15c4a90 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -7,9 +7,9 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateDocuments( - '', // databaseId - '', // collectionId - {}, // data (optional) - [] // queries (optional) -); +const response = 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 116fadc..ff6cf21 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateEmailAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - 'email@example.com', // default - '' // newKey (optional) -); +const response = 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 663e44b..60f84fd 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -7,12 +7,12 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateEnumAttribute( - '', // databaseId - '', // collectionId - '', // key - [], // elements - false, // required - '', // default - '' // newKey (optional) -); +const response = 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 d9eab5a..3a66407 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -7,13 +7,13 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateFloatAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - null, // default - null, // min (optional) - null, // max (optional) - '' // newKey (optional) -); +const response = 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 369b49d..679eeaa 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -7,13 +7,13 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateIntegerAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - null, // default - null, // min (optional) - null, // max (optional) - '' // newKey (optional) -); +const response = 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 049a527..d4145f4 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateIpAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - '', // default - '' // newKey (optional) -); +const response = 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 7fae26b..3c9e9ac 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -7,10 +7,10 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateRelationshipAttribute( - '', // databaseId - '', // collectionId - '', // key - RelationMutate.Cascade, // onDelete (optional) - '' // newKey (optional) -); +const response = await databases.updateRelationshipAttribute({ + databaseId: '', + collectionId: '', + key: '', + onDelete: RelationMutate.Cascade, // optional + newKey: '' // optional +}); diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index ec91d33..ec0dd8b 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -7,12 +7,12 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateStringAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - '', // default - 1, // size (optional) - '' // newKey (optional) -); +const response = 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 32f44b7..f59ae75 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -7,11 +7,11 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.updateUrlAttribute( - '', // databaseId - '', // collectionId - '', // key - false, // required - 'https://example.com', // default - '' // newKey (optional) -); +const response = 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 b87ad82..9df4fca 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.update( - '', // databaseId - '', // name - false // enabled (optional) -); +const response = 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 f05100e..27eb1e1 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -7,10 +7,10 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.upsertDocument( - '', // databaseId - '', // collectionId - '', // documentId - {}, // data - ["read("any")"] // permissions (optional) -); +const response = 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 0cd804b..ea6fea6 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -7,8 +7,8 @@ const client = new Client() const databases = new Databases(client); -const response = await databases.upsertDocuments( - '', // databaseId - '', // collectionId - [] // documents -); +const response = await databases.upsertDocuments({ + databaseId: '', + collectionId: '', + documents: [] +}); diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index a134a38..4f27138 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -7,10 +7,10 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.createDeployment( - '', // functionId - InputFile.fromPath('/path/to/file.png', 'file.png'), // code - false, // activate - '', // entrypoint (optional) - '' // commands (optional) -); +const response = await functions.createDeployment({ + functionId: '', + code: InputFile.fromPath('/path/to/file.png', 'file.png'), + 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 e22d1da..b8c7e43 100644 --- a/docs/examples/functions/create-duplicate-deployment.md +++ b/docs/examples/functions/create-duplicate-deployment.md @@ -7,8 +7,8 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.createDuplicateDeployment( - '', // functionId - '', // deploymentId - '' // buildId (optional) -); +const response = await functions.createDuplicateDeployment({ + functionId: '', + deploymentId: '', + buildId: '' // optional +}); diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index bec6a17..651a5c9 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -7,12 +7,12 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.createExecution( - '', // functionId - '', // body (optional) - false, // async (optional) - '', // path (optional) - ExecutionMethod.GET, // method (optional) - {}, // headers (optional) - '' // scheduledAt (optional) -); +const response = await functions.createExecution({ + functionId: '', + body: '', // optional + async: false, // optional + path: '', // optional + method: 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 69503da..6e8b932 100644 --- a/docs/examples/functions/create-template-deployment.md +++ b/docs/examples/functions/create-template-deployment.md @@ -7,11 +7,11 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.createTemplateDeployment( - '', // functionId - '', // repository - '', // owner - '', // rootDirectory - '', // version - false // activate (optional) -); +const response = 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 2864890..4e871c6 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -7,9 +7,9 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.createVariable( - '', // functionId - '', // key - '', // value - false // secret (optional) -); +const response = 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 d501b0e..7a10824 100644 --- a/docs/examples/functions/create-vcs-deployment.md +++ b/docs/examples/functions/create-vcs-deployment.md @@ -7,9 +7,9 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.createVcsDeployment( - '', // functionId - VCSDeploymentType.Branch, // type - '', // reference - false // activate (optional) -); +const response = await functions.createVcsDeployment({ + functionId: '', + type: VCSDeploymentType.Branch, + reference: '', + activate: false // optional +}); diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 32265de..4681bd6 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -7,23 +7,23 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.create( - '', // functionId - '', // name - .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 response = await functions.create({ + functionId: '', + name: '', + runtime: .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 179bbaf..11c2e92 100644 --- a/docs/examples/functions/delete-deployment.md +++ b/docs/examples/functions/delete-deployment.md @@ -7,7 +7,7 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.deleteDeployment( - '', // functionId - '' // deploymentId -); +const response = await functions.deleteDeployment({ + functionId: '', + deploymentId: '' +}); diff --git a/docs/examples/functions/delete-execution.md b/docs/examples/functions/delete-execution.md index 4ab7c37..95185ab 100644 --- a/docs/examples/functions/delete-execution.md +++ b/docs/examples/functions/delete-execution.md @@ -7,7 +7,7 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.deleteExecution( - '', // functionId - '' // executionId -); +const response = await functions.deleteExecution({ + functionId: '', + executionId: '' +}); diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md index 39a9428..d3387fd 100644 --- a/docs/examples/functions/delete-variable.md +++ b/docs/examples/functions/delete-variable.md @@ -7,7 +7,7 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.deleteVariable( - '', // functionId - '' // variableId -); +const response = await functions.deleteVariable({ + functionId: '', + variableId: '' +}); diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index 94d58c3..9270762 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -7,6 +7,6 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.delete( - '' // functionId -); +const response = await functions.delete({ + functionId: '' +}); diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md index d153036..3497111 100644 --- a/docs/examples/functions/get-deployment-download.md +++ b/docs/examples/functions/get-deployment-download.md @@ -7,8 +7,8 @@ const client = new Client() const functions = new Functions(client); -const result = functions.getDeploymentDownload( - '', // functionId - '', // deploymentId - DeploymentDownloadType.Source // type (optional) -); +const result = functions.getDeploymentDownload({ + functionId: '', + deploymentId: '', + type: DeploymentDownloadType.Source // optional +}); diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md index 339b99d..e125fa5 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -7,7 +7,7 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.getDeployment( - '', // functionId - '' // deploymentId -); +const response = await functions.getDeployment({ + functionId: '', + deploymentId: '' +}); diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index adeff02..d52b60e 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -7,7 +7,7 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.getExecution( - '', // functionId - '' // executionId -); +const response = await functions.getExecution({ + functionId: '', + executionId: '' +}); diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md index cbbdd2f..e5916c7 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -7,7 +7,7 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.getVariable( - '', // functionId - '' // variableId -); +const response = await functions.getVariable({ + functionId: '', + variableId: '' +}); diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index 8fec17e..c4678f0 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -7,6 +7,6 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.get( - '' // functionId -); +const response = await functions.get({ + functionId: '' +}); diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index 849fe23..6d1718d 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -7,8 +7,8 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.listDeployments( - '', // functionId - [], // queries (optional) - '' // search (optional) -); +const response = 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 cd597fb..101d4ec 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -7,7 +7,7 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.listExecutions( - '', // functionId - [] // queries (optional) -); +const response = await functions.listExecutions({ + functionId: '', + queries: [] // optional +}); diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index 173d5aa..6bc904b 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -7,6 +7,6 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.listVariables( - '' // functionId -); +const response = await functions.listVariables({ + functionId: '' +}); diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index ecc43d1..bb0475d 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -7,7 +7,7 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.list( - [], // queries (optional) - '' // search (optional) -); +const response = 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 4c7e805..d6b6cdd 100644 --- a/docs/examples/functions/update-deployment-status.md +++ b/docs/examples/functions/update-deployment-status.md @@ -7,7 +7,7 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.updateDeploymentStatus( - '', // functionId - '' // deploymentId -); +const response = await functions.updateDeploymentStatus({ + functionId: '', + deploymentId: '' +}); diff --git a/docs/examples/functions/update-function-deployment.md b/docs/examples/functions/update-function-deployment.md index 55196c1..1e0b554 100644 --- a/docs/examples/functions/update-function-deployment.md +++ b/docs/examples/functions/update-function-deployment.md @@ -7,7 +7,7 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.updateFunctionDeployment( - '', // functionId - '' // deploymentId -); +const response = await functions.updateFunctionDeployment({ + functionId: '', + deploymentId: '' +}); diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index 3da706d..cff5cc4 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -7,10 +7,10 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.updateVariable( - '', // functionId - '', // variableId - '', // key - '', // value (optional) - false // secret (optional) -); +const response = 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 399af05..0a74369 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -7,23 +7,23 @@ const client = new Client() const functions = new Functions(client); -const response = await functions.update( - '', // functionId - '', // name - .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 response = await functions.update({ + functionId: '', + name: '', + runtime: .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 200120f..67716b2 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -7,6 +7,6 @@ const client = new Client() const graphql = new Graphql(client); -const response = await graphql.mutation( - {} // query -); +const response = await graphql.mutation({ + query: {} +}); diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index bb01162..e80f795 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -7,6 +7,6 @@ const client = new Client() const graphql = new Graphql(client); -const response = await graphql.query( - {} // query -); +const response = await graphql.query({ + query: {} +}); diff --git a/docs/examples/health/get-certificate.md b/docs/examples/health/get-certificate.md index 828e53d..388fce9 100644 --- a/docs/examples/health/get-certificate.md +++ b/docs/examples/health/get-certificate.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getCertificate( - '' // domain (optional) -); +const response = 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 5e40f76..a820235 100644 --- a/docs/examples/health/get-failed-jobs.md +++ b/docs/examples/health/get-failed-jobs.md @@ -7,7 +7,7 @@ const client = new Client() const health = new Health(client); -const response = await health.getFailedJobs( - .V1Database, // name - null // threshold (optional) -); +const response = await health.getFailedJobs({ + name: .V1Database, + threshold: null // optional +}); diff --git a/docs/examples/health/get-queue-builds.md b/docs/examples/health/get-queue-builds.md index f6b9388..d247f48 100644 --- a/docs/examples/health/get-queue-builds.md +++ b/docs/examples/health/get-queue-builds.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueBuilds( - null // threshold (optional) -); +const response = 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 e783fa5..c43cffb 100644 --- a/docs/examples/health/get-queue-certificates.md +++ b/docs/examples/health/get-queue-certificates.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueCertificates( - null // threshold (optional) -); +const response = 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 e33c7a2..9c126dc 100644 --- a/docs/examples/health/get-queue-databases.md +++ b/docs/examples/health/get-queue-databases.md @@ -7,7 +7,7 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueDatabases( - '', // name (optional) - null // threshold (optional) -); +const response = 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 ea7da5b..240cfe3 100644 --- a/docs/examples/health/get-queue-deletes.md +++ b/docs/examples/health/get-queue-deletes.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueDeletes( - null // threshold (optional) -); +const response = 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 e075a65..333b5ab 100644 --- a/docs/examples/health/get-queue-functions.md +++ b/docs/examples/health/get-queue-functions.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueFunctions( - null // threshold (optional) -); +const response = 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 eb7ffb0..7877685 100644 --- a/docs/examples/health/get-queue-logs.md +++ b/docs/examples/health/get-queue-logs.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueLogs( - null // threshold (optional) -); +const response = 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 d9f61bc..3ec4b39 100644 --- a/docs/examples/health/get-queue-mails.md +++ b/docs/examples/health/get-queue-mails.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueMails( - null // threshold (optional) -); +const response = 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 8bc7639..6d5bf48 100644 --- a/docs/examples/health/get-queue-messaging.md +++ b/docs/examples/health/get-queue-messaging.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueMessaging( - null // threshold (optional) -); +const response = 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 e6f7bf5..520b92d 100644 --- a/docs/examples/health/get-queue-migrations.md +++ b/docs/examples/health/get-queue-migrations.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueMigrations( - null // threshold (optional) -); +const response = 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 ecc7ebd..8f22c23 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 Client() const health = new Health(client); -const response = await health.getQueueStatsResources( - null // threshold (optional) -); +const response = 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 46aa4db..69ab874 100644 --- a/docs/examples/health/get-queue-usage.md +++ b/docs/examples/health/get-queue-usage.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueUsage( - null // threshold (optional) -); +const response = 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 75a1c1f..0e14d7c 100644 --- a/docs/examples/health/get-queue-webhooks.md +++ b/docs/examples/health/get-queue-webhooks.md @@ -7,6 +7,6 @@ const client = new Client() const health = new Health(client); -const response = await health.getQueueWebhooks( - null // threshold (optional) -); +const response = 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 e2c33fe..b32386b 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -7,13 +7,13 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createApnsProvider( - '', // providerId - '', // name - '', // authKey (optional) - '', // authKeyId (optional) - '', // teamId (optional) - '', // bundleId (optional) - false, // sandbox (optional) - false // enabled (optional) -); +const response = 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 8db2879..8ba3db8 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -7,17 +7,17 @@ const client = new Client() const messaging = new Messaging(client); -const response = 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 response = 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 3f443d6..bea200d 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -7,9 +7,9 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createFcmProvider( - '', // providerId - '', // name - {}, // serviceAccountJSON (optional) - false // enabled (optional) -); +const response = 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 32f7c94..2eaa888 100644 --- a/docs/examples/messaging/create-mailgun-provider.md +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -7,15 +7,15 @@ const client = new Client() const messaging = new Messaging(client); -const response = 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 response = 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 54% rename from docs/examples/messaging/create-msg91provider.md rename to docs/examples/messaging/create-msg-91-provider.md index 57e9418..b9f3238 100644 --- a/docs/examples/messaging/create-msg91provider.md +++ b/docs/examples/messaging/create-msg-91-provider.md @@ -7,11 +7,11 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createMsg91Provider( - '', // providerId - '', // name - '', // templateId (optional) - '', // senderId (optional) - '', // authKey (optional) - false // enabled (optional) -); +const response = 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 7523c29..efa40ce 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -7,24 +7,24 @@ const client = new Client() const messaging = new Messaging(client); -const response = 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) - MessagePriority.Normal // priority (optional) -); +const response = 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: MessagePriority.Normal // optional +}); diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md index 15fe7b8..10ce45e 100644 --- a/docs/examples/messaging/create-sendgrid-provider.md +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -7,13 +7,13 @@ const client = new Client() const messaging = new Messaging(client); -const response = 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 response = 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 264203a..bf81ff9 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -7,12 +7,12 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createSms( - '<MESSAGE_ID>', // messageId - '<CONTENT>', // content - [], // topics (optional) - [], // users (optional) - [], // targets (optional) - false, // draft (optional) - '' // scheduledAt (optional) -); +const response = 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 2d6d33c..06307b3 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -7,19 +7,19 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createSmtpProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '<HOST>', // host - 1, // port (optional) - '<USERNAME>', // username (optional) - '<PASSWORD>', // password (optional) - 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 response = await messaging.createSMTPProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + host: '<HOST>', + port: 1, // optional + username: '<USERNAME>', // optional + password: '<PASSWORD>', // optional + encryption: 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 8be79f3..671c6ea 100644 --- a/docs/examples/messaging/create-subscriber.md +++ b/docs/examples/messaging/create-subscriber.md @@ -7,8 +7,8 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createSubscriber( - '<TOPIC_ID>', // topicId - '<SUBSCRIBER_ID>', // subscriberId - '<TARGET_ID>' // targetId -); +const response = 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 2bb95c4..0c9376b 100644 --- a/docs/examples/messaging/create-telesign-provider.md +++ b/docs/examples/messaging/create-telesign-provider.md @@ -7,11 +7,11 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createTelesignProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '+12065550100', // from (optional) - '<CUSTOMER_ID>', // customerId (optional) - '<API_KEY>', // apiKey (optional) - false // enabled (optional) -); +const response = 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 4657493..1bf61f9 100644 --- a/docs/examples/messaging/create-textmagic-provider.md +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -7,11 +7,11 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createTextmagicProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '+12065550100', // from (optional) - '<USERNAME>', // username (optional) - '<API_KEY>', // apiKey (optional) - false // enabled (optional) -); +const response = 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 c2ca3a4..a15699b 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -7,8 +7,8 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createTopic( - '<TOPIC_ID>', // topicId - '<NAME>', // name - ["any"] // subscribe (optional) -); +const response = 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 aa7bbf6..cd889f0 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -7,11 +7,11 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createTwilioProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '+12065550100', // from (optional) - '<ACCOUNT_SID>', // accountSid (optional) - '<AUTH_TOKEN>', // authToken (optional) - false // enabled (optional) -); +const response = 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 5fe734f..e03b0b6 100644 --- a/docs/examples/messaging/create-vonage-provider.md +++ b/docs/examples/messaging/create-vonage-provider.md @@ -7,11 +7,11 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.createVonageProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name - '+12065550100', // from (optional) - '<API_KEY>', // apiKey (optional) - '<API_SECRET>', // apiSecret (optional) - false // enabled (optional) -); +const response = 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 7bc99ef..2e0855a 100644 --- a/docs/examples/messaging/delete-provider.md +++ b/docs/examples/messaging/delete-provider.md @@ -7,6 +7,6 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.deleteProvider( - '<PROVIDER_ID>' // providerId -); +const response = await messaging.deleteProvider({ + providerId: '<PROVIDER_ID>' +}); diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md index 1474568..c48c9de 100644 --- a/docs/examples/messaging/delete-subscriber.md +++ b/docs/examples/messaging/delete-subscriber.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.deleteSubscriber( - '<TOPIC_ID>', // topicId - '<SUBSCRIBER_ID>' // subscriberId -); +const response = 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 aa1359c..5dd1317 100644 --- a/docs/examples/messaging/delete-topic.md +++ b/docs/examples/messaging/delete-topic.md @@ -7,6 +7,6 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.deleteTopic( - '<TOPIC_ID>' // topicId -); +const response = await messaging.deleteTopic({ + topicId: '<TOPIC_ID>' +}); diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md index 0442da1..8b4357f 100644 --- a/docs/examples/messaging/delete.md +++ b/docs/examples/messaging/delete.md @@ -7,6 +7,6 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.delete( - '<MESSAGE_ID>' // messageId -); +const response = await messaging.delete({ + messageId: '<MESSAGE_ID>' +}); diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md index 9565a61..f0e4c5b 100644 --- a/docs/examples/messaging/get-message.md +++ b/docs/examples/messaging/get-message.md @@ -7,6 +7,6 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.getMessage( - '<MESSAGE_ID>' // messageId -); +const response = await messaging.getMessage({ + messageId: '<MESSAGE_ID>' +}); diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md index 8e5d426..18ce92a 100644 --- a/docs/examples/messaging/get-provider.md +++ b/docs/examples/messaging/get-provider.md @@ -7,6 +7,6 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.getProvider( - '<PROVIDER_ID>' // providerId -); +const response = await messaging.getProvider({ + providerId: '<PROVIDER_ID>' +}); diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md index e9377a5..4916e27 100644 --- a/docs/examples/messaging/get-subscriber.md +++ b/docs/examples/messaging/get-subscriber.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.getSubscriber( - '<TOPIC_ID>', // topicId - '<SUBSCRIBER_ID>' // subscriberId -); +const response = 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 35f1853..baf1f39 100644 --- a/docs/examples/messaging/get-topic.md +++ b/docs/examples/messaging/get-topic.md @@ -7,6 +7,6 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.getTopic( - '<TOPIC_ID>' // topicId -); +const response = 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 f39a900..b470dbc 100644 --- a/docs/examples/messaging/list-message-logs.md +++ b/docs/examples/messaging/list-message-logs.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.listMessageLogs( - '<MESSAGE_ID>', // messageId - [] // queries (optional) -); +const response = 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 50b1a10..a1bd90a 100644 --- a/docs/examples/messaging/list-messages.md +++ b/docs/examples/messaging/list-messages.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.listMessages( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 c4b20a8..9784ff3 100644 --- a/docs/examples/messaging/list-provider-logs.md +++ b/docs/examples/messaging/list-provider-logs.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.listProviderLogs( - '<PROVIDER_ID>', // providerId - [] // queries (optional) -); +const response = 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 7c877c2..150de6f 100644 --- a/docs/examples/messaging/list-providers.md +++ b/docs/examples/messaging/list-providers.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.listProviders( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 0d14f85..ccc575c 100644 --- a/docs/examples/messaging/list-subscriber-logs.md +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.listSubscriberLogs( - '<SUBSCRIBER_ID>', // subscriberId - [] // queries (optional) -); +const response = 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 384bb8f..68614ec 100644 --- a/docs/examples/messaging/list-subscribers.md +++ b/docs/examples/messaging/list-subscribers.md @@ -7,8 +7,8 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.listSubscribers( - '<TOPIC_ID>', // topicId - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 5ce2082..6d269b7 100644 --- a/docs/examples/messaging/list-targets.md +++ b/docs/examples/messaging/list-targets.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.listTargets( - '<MESSAGE_ID>', // messageId - [] // queries (optional) -); +const response = 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 d2c771d..70b287a 100644 --- a/docs/examples/messaging/list-topic-logs.md +++ b/docs/examples/messaging/list-topic-logs.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.listTopicLogs( - '<TOPIC_ID>', // topicId - [] // queries (optional) -); +const response = 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 1d0ec43..073b78e 100644 --- a/docs/examples/messaging/list-topics.md +++ b/docs/examples/messaging/list-topics.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.listTopics( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 71bd038..160786f 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -7,13 +7,13 @@ const client = new Client() const messaging = new Messaging(client); -const response = 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 response = 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 c8b0558..0f281cd 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -7,17 +7,17 @@ const client = new Client() const messaging = new Messaging(client); -const response = 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 response = 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 eb71ddd..b76e037 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -7,9 +7,9 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.updateFcmProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - {} // serviceAccountJSON (optional) -); +const response = 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 f80d6a4..b4f88e8 100644 --- a/docs/examples/messaging/update-mailgun-provider.md +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -7,15 +7,15 @@ const client = new Client() const messaging = new Messaging(client); -const response = 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 response = 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 53% rename from docs/examples/messaging/update-msg91provider.md rename to docs/examples/messaging/update-msg-91-provider.md index 36943f2..5cf61cb 100644 --- a/docs/examples/messaging/update-msg91provider.md +++ b/docs/examples/messaging/update-msg-91-provider.md @@ -7,11 +7,11 @@ const client = new Client() const messaging = new Messaging(client); -const response = 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 response = 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 c7f0686..fb776fd 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -7,24 +7,24 @@ const client = new Client() const messaging = new Messaging(client); -const response = 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) - MessagePriority.Normal // priority (optional) -); +const response = 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: MessagePriority.Normal // optional +}); diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md index 0ec96db..edf82f6 100644 --- a/docs/examples/messaging/update-sendgrid-provider.md +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -7,13 +7,13 @@ const client = new Client() const messaging = new Messaging(client); -const response = 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 response = 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 9c1dc4a..9d7f3a3 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -7,12 +7,12 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.updateSms( - '<MESSAGE_ID>', // messageId - [], // topics (optional) - [], // users (optional) - [], // targets (optional) - '<CONTENT>', // content (optional) - false, // draft (optional) - '' // scheduledAt (optional) -); +const response = 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 9d59bb3..6fc0021 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -7,19 +7,19 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.updateSmtpProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - '<HOST>', // host (optional) - 1, // port (optional) - '<USERNAME>', // username (optional) - '<PASSWORD>', // password (optional) - 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 response = await messaging.updateSMTPProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + host: '<HOST>', // optional + port: 1, // optional + username: '<USERNAME>', // optional + password: '<PASSWORD>', // optional + encryption: 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 052d394..defb10e 100644 --- a/docs/examples/messaging/update-telesign-provider.md +++ b/docs/examples/messaging/update-telesign-provider.md @@ -7,11 +7,11 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.updateTelesignProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<CUSTOMER_ID>', // customerId (optional) - '<API_KEY>', // apiKey (optional) - '<FROM>' // from (optional) -); +const response = 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 2163792..c859643 100644 --- a/docs/examples/messaging/update-textmagic-provider.md +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -7,11 +7,11 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.updateTextmagicProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<USERNAME>', // username (optional) - '<API_KEY>', // apiKey (optional) - '<FROM>' // from (optional) -); +const response = 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 5f7f779..7dc9337 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -7,8 +7,8 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.updateTopic( - '<TOPIC_ID>', // topicId - '<NAME>', // name (optional) - ["any"] // subscribe (optional) -); +const response = 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 5abdd65..75940f5 100644 --- a/docs/examples/messaging/update-twilio-provider.md +++ b/docs/examples/messaging/update-twilio-provider.md @@ -7,11 +7,11 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.updateTwilioProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<ACCOUNT_SID>', // accountSid (optional) - '<AUTH_TOKEN>', // authToken (optional) - '<FROM>' // from (optional) -); +const response = 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 c8fa90d..fea4465 100644 --- a/docs/examples/messaging/update-vonage-provider.md +++ b/docs/examples/messaging/update-vonage-provider.md @@ -7,11 +7,11 @@ const client = new Client() const messaging = new Messaging(client); -const response = await messaging.updateVonageProvider( - '<PROVIDER_ID>', // providerId - '<NAME>', // name (optional) - false, // enabled (optional) - '<API_KEY>', // apiKey (optional) - '<API_SECRET>', // apiSecret (optional) - '<FROM>' // from (optional) -); +const response = 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 f674553..81a0527 100644 --- a/docs/examples/sites/create-deployment.md +++ b/docs/examples/sites/create-deployment.md @@ -7,11 +7,11 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.createDeployment( - '<SITE_ID>', // siteId - InputFile.fromPath('/path/to/file.png', 'file.png'), // code - false, // activate - '<INSTALL_COMMAND>', // installCommand (optional) - '<BUILD_COMMAND>', // buildCommand (optional) - '<OUTPUT_DIRECTORY>' // outputDirectory (optional) -); +const response = await sites.createDeployment({ + siteId: '<SITE_ID>', + code: InputFile.fromPath('/path/to/file.png', 'file.png'), + 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 317e80b..5152571 100644 --- a/docs/examples/sites/create-duplicate-deployment.md +++ b/docs/examples/sites/create-duplicate-deployment.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.createDuplicateDeployment( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>' // deploymentId -); +const response = 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 4ef245b..e9b569d 100644 --- a/docs/examples/sites/create-template-deployment.md +++ b/docs/examples/sites/create-template-deployment.md @@ -7,11 +7,11 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.createTemplateDeployment( - '<SITE_ID>', // siteId - '<REPOSITORY>', // repository - '<OWNER>', // owner - '<ROOT_DIRECTORY>', // rootDirectory - '<VERSION>', // version - false // activate (optional) -); +const response = 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 7b07a08..ab5e143 100644 --- a/docs/examples/sites/create-variable.md +++ b/docs/examples/sites/create-variable.md @@ -7,9 +7,9 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.createVariable( - '<SITE_ID>', // siteId - '<KEY>', // key - '<VALUE>', // value - false // secret (optional) -); +const response = 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 5c49808..7c7b7cc 100644 --- a/docs/examples/sites/create-vcs-deployment.md +++ b/docs/examples/sites/create-vcs-deployment.md @@ -7,9 +7,9 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.createVcsDeployment( - '<SITE_ID>', // siteId - VCSDeploymentType.Branch, // type - '<REFERENCE>', // reference - false // activate (optional) -); +const response = await sites.createVcsDeployment({ + siteId: '<SITE_ID>', + type: VCSDeploymentType.Branch, + reference: '<REFERENCE>', + activate: false // optional +}); diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index 420b362..7161da5 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -7,23 +7,23 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.create( - '<SITE_ID>', // siteId - '<NAME>', // name - .Analog, // framework - .Node145, // buildRuntime - false, // enabled (optional) - false, // logging (optional) - 1, // timeout (optional) - '<INSTALL_COMMAND>', // installCommand (optional) - '<BUILD_COMMAND>', // buildCommand (optional) - '<OUTPUT_DIRECTORY>', // outputDirectory (optional) - .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 response = await sites.create({ + siteId: '<SITE_ID>', + name: '<NAME>', + framework: .Analog, + buildRuntime: .Node145, + enabled: false, // optional + logging: false, // optional + timeout: 1, // optional + installCommand: '<INSTALL_COMMAND>', // optional + buildCommand: '<BUILD_COMMAND>', // optional + outputDirectory: '<OUTPUT_DIRECTORY>', // optional + adapter: .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 cd97673..4164f47 100644 --- a/docs/examples/sites/delete-deployment.md +++ b/docs/examples/sites/delete-deployment.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.deleteDeployment( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>' // deploymentId -); +const response = 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 0b70eb3..f70a8fb 100644 --- a/docs/examples/sites/delete-log.md +++ b/docs/examples/sites/delete-log.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.deleteLog( - '<SITE_ID>', // siteId - '<LOG_ID>' // logId -); +const response = 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 0bbc2e3..226b2f1 100644 --- a/docs/examples/sites/delete-variable.md +++ b/docs/examples/sites/delete-variable.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.deleteVariable( - '<SITE_ID>', // siteId - '<VARIABLE_ID>' // variableId -); +const response = await sites.deleteVariable({ + siteId: '<SITE_ID>', + variableId: '<VARIABLE_ID>' +}); diff --git a/docs/examples/sites/delete.md b/docs/examples/sites/delete.md index af5dbed..2af4f53 100644 --- a/docs/examples/sites/delete.md +++ b/docs/examples/sites/delete.md @@ -7,6 +7,6 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.delete( - '<SITE_ID>' // siteId -); +const response = 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 4c3ceca..40731b1 100644 --- a/docs/examples/sites/get-deployment-download.md +++ b/docs/examples/sites/get-deployment-download.md @@ -7,8 +7,8 @@ const client = new Client() const sites = new Sites(client); -const result = sites.getDeploymentDownload( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>', // deploymentId - DeploymentDownloadType.Source // type (optional) -); +const result = sites.getDeploymentDownload({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>', + type: DeploymentDownloadType.Source // optional +}); diff --git a/docs/examples/sites/get-deployment.md b/docs/examples/sites/get-deployment.md index 4e614b0..ed23bd1 100644 --- a/docs/examples/sites/get-deployment.md +++ b/docs/examples/sites/get-deployment.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.getDeployment( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>' // deploymentId -); +const response = 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 9495030..30cd601 100644 --- a/docs/examples/sites/get-log.md +++ b/docs/examples/sites/get-log.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.getLog( - '<SITE_ID>', // siteId - '<LOG_ID>' // logId -); +const response = 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 12ab553..e070d2e 100644 --- a/docs/examples/sites/get-variable.md +++ b/docs/examples/sites/get-variable.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.getVariable( - '<SITE_ID>', // siteId - '<VARIABLE_ID>' // variableId -); +const response = await sites.getVariable({ + siteId: '<SITE_ID>', + variableId: '<VARIABLE_ID>' +}); diff --git a/docs/examples/sites/get.md b/docs/examples/sites/get.md index 769f426..80cc792 100644 --- a/docs/examples/sites/get.md +++ b/docs/examples/sites/get.md @@ -7,6 +7,6 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.get( - '<SITE_ID>' // siteId -); +const response = await sites.get({ + siteId: '<SITE_ID>' +}); diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md index 09cc521..013b621 100644 --- a/docs/examples/sites/list-deployments.md +++ b/docs/examples/sites/list-deployments.md @@ -7,8 +7,8 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.listDeployments( - '<SITE_ID>', // siteId - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 3249903..6ab920a 100644 --- a/docs/examples/sites/list-logs.md +++ b/docs/examples/sites/list-logs.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.listLogs( - '<SITE_ID>', // siteId - [] // queries (optional) -); +const response = 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 0aac319..ed71762 100644 --- a/docs/examples/sites/list-variables.md +++ b/docs/examples/sites/list-variables.md @@ -7,6 +7,6 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.listVariables( - '<SITE_ID>' // siteId -); +const response = await sites.listVariables({ + siteId: '<SITE_ID>' +}); diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md index f21433d..87f9ef3 100644 --- a/docs/examples/sites/list.md +++ b/docs/examples/sites/list.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.list( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 83fe6f8..e634de9 100644 --- a/docs/examples/sites/update-deployment-status.md +++ b/docs/examples/sites/update-deployment-status.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.updateDeploymentStatus( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>' // deploymentId -); +const response = 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 1d9d697..c6ee03b 100644 --- a/docs/examples/sites/update-site-deployment.md +++ b/docs/examples/sites/update-site-deployment.md @@ -7,7 +7,7 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.updateSiteDeployment( - '<SITE_ID>', // siteId - '<DEPLOYMENT_ID>' // deploymentId -); +const response = 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 6776af7..5bc179d 100644 --- a/docs/examples/sites/update-variable.md +++ b/docs/examples/sites/update-variable.md @@ -7,10 +7,10 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.updateVariable( - '<SITE_ID>', // siteId - '<VARIABLE_ID>', // variableId - '<KEY>', // key - '<VALUE>', // value (optional) - false // secret (optional) -); +const response = 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 ba7d195..1f5235c 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -7,23 +7,23 @@ const client = new Client() const sites = new Sites(client); -const response = await sites.update( - '<SITE_ID>', // siteId - '<NAME>', // name - .Analog, // framework - false, // enabled (optional) - false, // logging (optional) - 1, // timeout (optional) - '<INSTALL_COMMAND>', // installCommand (optional) - '<BUILD_COMMAND>', // buildCommand (optional) - '<OUTPUT_DIRECTORY>', // outputDirectory (optional) - .Node145, // buildRuntime (optional) - .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 response = await sites.update({ + siteId: '<SITE_ID>', + name: '<NAME>', + framework: .Analog, + enabled: false, // optional + logging: false, // optional + timeout: 1, // optional + installCommand: '<INSTALL_COMMAND>', // optional + buildCommand: '<BUILD_COMMAND>', // optional + outputDirectory: '<OUTPUT_DIRECTORY>', // optional + buildRuntime: .Node145, // optional + adapter: .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 e7d3e90..1f996b1 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -7,15 +7,15 @@ const client = new Client() const storage = new Storage(client); -const response = await storage.createBucket( - '<BUCKET_ID>', // bucketId - '<NAME>', // name - ["read("any")"], // permissions (optional) - false, // fileSecurity (optional) - false, // enabled (optional) - 1, // maximumFileSize (optional) - [], // allowedFileExtensions (optional) - .None, // compression (optional) - false, // encryption (optional) - false // antivirus (optional) -); +const response = await storage.createBucket({ + bucketId: '<BUCKET_ID>', + name: '<NAME>', + permissions: ["read("any")"], // optional + fileSecurity: false, // optional + enabled: false, // optional + maximumFileSize: 1, // optional + allowedFileExtensions: [], // optional + compression: .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 d8912c6..4b6c1fd 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -7,9 +7,9 @@ const client = new Client() const storage = new Storage(client); -const response = await storage.createFile( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - InputFile.fromPath('/path/to/file.png', 'file.png'), // file - ["read("any")"] // permissions (optional) -); +const response = await storage.createFile({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + file: InputFile.fromPath('/path/to/file.png', 'file.png'), + permissions: ["read("any")"] // optional +}); diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md index f0d7146..d5f2e36 100644 --- a/docs/examples/storage/delete-bucket.md +++ b/docs/examples/storage/delete-bucket.md @@ -7,6 +7,6 @@ const client = new Client() const storage = new Storage(client); -const response = await storage.deleteBucket( - '<BUCKET_ID>' // bucketId -); +const response = await storage.deleteBucket({ + bucketId: '<BUCKET_ID>' +}); diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index 2a1f95e..3f9f2ac 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -7,7 +7,7 @@ const client = new Client() const storage = new Storage(client); -const response = await storage.deleteFile( - '<BUCKET_ID>', // bucketId - '<FILE_ID>' // fileId -); +const response = 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 a695021..ffb1913 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -7,6 +7,6 @@ const client = new Client() const storage = new Storage(client); -const response = await storage.getBucket( - '<BUCKET_ID>' // bucketId -); +const response = 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 df11f40..fa1b465 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -7,8 +7,8 @@ const client = new Client() const storage = new Storage(client); -const result = storage.getFileDownload( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - '<TOKEN>' // token (optional) -); +const result = 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 6457c78..884a84a 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -7,19 +7,19 @@ const client = new Client() const storage = new Storage(client); -const result = storage.getFilePreview( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - 0, // width (optional) - 0, // height (optional) - ImageGravity.Center, // gravity (optional) - -1, // quality (optional) - 0, // borderWidth (optional) - '', // borderColor (optional) - 0, // borderRadius (optional) - 0, // opacity (optional) - -360, // rotation (optional) - '', // background (optional) - ImageFormat.Jpg, // output (optional) - '<TOKEN>' // token (optional) -); +const result = storage.getFilePreview({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + width: 0, // optional + height: 0, // optional + gravity: ImageGravity.Center, // optional + quality: -1, // optional + borderWidth: 0, // optional + borderColor: '', // optional + borderRadius: 0, // optional + opacity: 0, // optional + rotation: -360, // optional + background: '', // optional + output: 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 5a1dbac..86a357a 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -7,8 +7,8 @@ const client = new Client() const storage = new Storage(client); -const result = storage.getFileView( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - '<TOKEN>' // token (optional) -); +const result = 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 5479dc5..604696a 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -7,7 +7,7 @@ const client = new Client() const storage = new Storage(client); -const response = await storage.getFile( - '<BUCKET_ID>', // bucketId - '<FILE_ID>' // fileId -); +const response = 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 9286bd4..56bba16 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -7,7 +7,7 @@ const client = new Client() const storage = new Storage(client); -const response = await storage.listBuckets( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 316875c..e2ea466 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -7,8 +7,8 @@ const client = new Client() const storage = new Storage(client); -const response = await storage.listFiles( - '<BUCKET_ID>', // bucketId - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 1e70f16..b0adba1 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -7,15 +7,15 @@ const client = new Client() const storage = new Storage(client); -const response = await storage.updateBucket( - '<BUCKET_ID>', // bucketId - '<NAME>', // name - ["read("any")"], // permissions (optional) - false, // fileSecurity (optional) - false, // enabled (optional) - 1, // maximumFileSize (optional) - [], // allowedFileExtensions (optional) - .None, // compression (optional) - false, // encryption (optional) - false // antivirus (optional) -); +const response = await storage.updateBucket({ + bucketId: '<BUCKET_ID>', + name: '<NAME>', + permissions: ["read("any")"], // optional + fileSecurity: false, // optional + enabled: false, // optional + maximumFileSize: 1, // optional + allowedFileExtensions: [], // optional + compression: .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 683b0b7..1a28c98 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -7,9 +7,9 @@ const client = new Client() const storage = new Storage(client); -const response = await storage.updateFile( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - '<NAME>', // name (optional) - ["read("any")"] // permissions (optional) -); +const response = 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..7407b58 --- /dev/null +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..f139666 --- /dev/null +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..a004a89 --- /dev/null +++ b/docs/examples/tablesdb/create-email-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..1f40abd --- /dev/null +++ b/docs/examples/tablesdb/create-enum-column.md @@ -0,0 +1,18 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..5d555a7 --- /dev/null +++ b/docs/examples/tablesdb/create-float-column.md @@ -0,0 +1,19 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..0e164ed --- /dev/null +++ b/docs/examples/tablesdb/create-index.md @@ -0,0 +1,18 @@ +import { Client, TablesDB, IndexType } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = await tablesDB.createIndex({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + type: 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..297b096 --- /dev/null +++ b/docs/examples/tablesdb/create-integer-column.md @@ -0,0 +1,19 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..95b20b8 --- /dev/null +++ b/docs/examples/tablesdb/create-ip-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..27952f7 --- /dev/null +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -0,0 +1,19 @@ +import { Client, TablesDB, RelationshipType, RelationMutate } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = await tablesDB.createRelationshipColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + relatedTableId: '<RELATED_TABLE_ID>', + type: RelationshipType.OneToOne, + twoWay: false, // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: 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..dadb5ec --- /dev/null +++ b/docs/examples/tablesdb/create-row.md @@ -0,0 +1,16 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..a3fafcf --- /dev/null +++ b/docs/examples/tablesdb/create-rows.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..ff0816a --- /dev/null +++ b/docs/examples/tablesdb/create-string-column.md @@ -0,0 +1,19 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..5dcaac4 --- /dev/null +++ b/docs/examples/tablesdb/create-table.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..f019bab --- /dev/null +++ b/docs/examples/tablesdb/create-url-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..5971eb1 --- /dev/null +++ b/docs/examples/tablesdb/create.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..68c2fa4 --- /dev/null +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..63b567a --- /dev/null +++ b/docs/examples/tablesdb/delete-column.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..15a98fb --- /dev/null +++ b/docs/examples/tablesdb/delete-index.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..2f63a91 --- /dev/null +++ b/docs/examples/tablesdb/delete-row.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..310b189 --- /dev/null +++ b/docs/examples/tablesdb/delete-rows.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..3f36527 --- /dev/null +++ b/docs/examples/tablesdb/delete-table.md @@ -0,0 +1,13 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..12249ab --- /dev/null +++ b/docs/examples/tablesdb/delete.md @@ -0,0 +1,12 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..16bb38a --- /dev/null +++ b/docs/examples/tablesdb/get-column.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..47e7a61 --- /dev/null +++ b/docs/examples/tablesdb/get-index.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..c662df2 --- /dev/null +++ b/docs/examples/tablesdb/get-row.md @@ -0,0 +1,15 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..6a46bbd --- /dev/null +++ b/docs/examples/tablesdb/get-table.md @@ -0,0 +1,13 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..4304258 --- /dev/null +++ b/docs/examples/tablesdb/get.md @@ -0,0 +1,12 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..a57683e --- /dev/null +++ b/docs/examples/tablesdb/increment-row-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..2a1cbe2 --- /dev/null +++ b/docs/examples/tablesdb/list-columns.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..7a0af70 --- /dev/null +++ b/docs/examples/tablesdb/list-indexes.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..2a09499 --- /dev/null +++ b/docs/examples/tablesdb/list-rows.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..0ffd1b9 --- /dev/null +++ b/docs/examples/tablesdb/list-tables.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..529bd64 --- /dev/null +++ b/docs/examples/tablesdb/list.md @@ -0,0 +1,13 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..ebc0bfb --- /dev/null +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..a2672c8 --- /dev/null +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..18fc845 --- /dev/null +++ b/docs/examples/tablesdb/update-email-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..e282ec8 --- /dev/null +++ b/docs/examples/tablesdb/update-enum-column.md @@ -0,0 +1,18 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..6ee1c5a --- /dev/null +++ b/docs/examples/tablesdb/update-float-column.md @@ -0,0 +1,19 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..1d99683 --- /dev/null +++ b/docs/examples/tablesdb/update-integer-column.md @@ -0,0 +1,19 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..d69e0f1 --- /dev/null +++ b/docs/examples/tablesdb/update-ip-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..3f361e0 --- /dev/null +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -0,0 +1,16 @@ +import { Client, TablesDB, RelationMutate } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = await tablesDB.updateRelationshipColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + onDelete: 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..53848c7 --- /dev/null +++ b/docs/examples/tablesdb/update-row.md @@ -0,0 +1,16 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..2a3e3f1 --- /dev/null +++ b/docs/examples/tablesdb/update-rows.md @@ -0,0 +1,15 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..ff532ae --- /dev/null +++ b/docs/examples/tablesdb/update-string-column.md @@ -0,0 +1,18 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..c0453f6 --- /dev/null +++ b/docs/examples/tablesdb/update-table.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..a594499 --- /dev/null +++ b/docs/examples/tablesdb/update-url-column.md @@ -0,0 +1,17 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..f309641 --- /dev/null +++ b/docs/examples/tablesdb/update.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..701e1a2 --- /dev/null +++ b/docs/examples/tablesdb/upsert-row.md @@ -0,0 +1,16 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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..a5fa731 --- /dev/null +++ b/docs/examples/tablesdb/upsert-rows.md @@ -0,0 +1,14 @@ +import { Client, TablesDB } from "https://deno.land/x/appwrite/mod.ts"; + +const client = new 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 TablesDB(client); + +const response = 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 d8e855f..27e4ec7 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -7,12 +7,12 @@ const client = new Client() const teams = new Teams(client); -const response = 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 response = 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 495f26e..0c92129 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -7,8 +7,8 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.create( - '<TEAM_ID>', // teamId - '<NAME>', // name - [] // roles (optional) -); +const response = 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 a5b0387..51fcd0c 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -7,7 +7,7 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.deleteMembership( - '<TEAM_ID>', // teamId - '<MEMBERSHIP_ID>' // membershipId -); +const response = await teams.deleteMembership({ + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>' +}); diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index 556fbb5..e300ad5 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -7,6 +7,6 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.delete( - '<TEAM_ID>' // teamId -); +const response = await teams.delete({ + teamId: '<TEAM_ID>' +}); diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index 75283bf..73b6a24 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -7,7 +7,7 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.getMembership( - '<TEAM_ID>', // teamId - '<MEMBERSHIP_ID>' // membershipId -); +const response = 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 442d8b1..d2cdd8a 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -7,6 +7,6 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.getPrefs( - '<TEAM_ID>' // teamId -); +const response = await teams.getPrefs({ + teamId: '<TEAM_ID>' +}); diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index 2e5803c..41c81bc 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -7,6 +7,6 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.get( - '<TEAM_ID>' // teamId -); +const response = await teams.get({ + teamId: '<TEAM_ID>' +}); diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 0b7e663..f781fff 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -7,8 +7,8 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.listMemberships( - '<TEAM_ID>', // teamId - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 6c08b5c..4bb0c41 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -7,7 +7,7 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.list( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 48fc9cd..22ac429 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -7,9 +7,9 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.updateMembershipStatus( - '<TEAM_ID>', // teamId - '<MEMBERSHIP_ID>', // membershipId - '<USER_ID>', // userId - '<SECRET>' // secret -); +const response = 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 be8651d..3524cc5 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -7,8 +7,8 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.updateMembership( - '<TEAM_ID>', // teamId - '<MEMBERSHIP_ID>', // membershipId - [] // roles -); +const response = 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 6e2144b..b7d7e0f 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -7,7 +7,7 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.updateName( - '<TEAM_ID>', // teamId - '<NAME>' // name -); +const response = 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 dea8a36..5c7eaec 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -7,7 +7,7 @@ const client = new Client() const teams = new Teams(client); -const response = await teams.updatePrefs( - '<TEAM_ID>', // teamId - {} // prefs -); +const response = 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 7c24738..e0d5b4d 100644 --- a/docs/examples/tokens/create-file-token.md +++ b/docs/examples/tokens/create-file-token.md @@ -7,8 +7,8 @@ const client = new Client() const tokens = new Tokens(client); -const response = await tokens.createFileToken( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - '' // expire (optional) -); +const response = 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 b5e3adf..6c41ea5 100644 --- a/docs/examples/tokens/delete.md +++ b/docs/examples/tokens/delete.md @@ -7,6 +7,6 @@ const client = new Client() const tokens = new Tokens(client); -const response = await tokens.delete( - '<TOKEN_ID>' // tokenId -); +const response = await tokens.delete({ + tokenId: '<TOKEN_ID>' +}); diff --git a/docs/examples/tokens/get.md b/docs/examples/tokens/get.md index 2bb827d..a7bf23a 100644 --- a/docs/examples/tokens/get.md +++ b/docs/examples/tokens/get.md @@ -7,6 +7,6 @@ const client = new Client() const tokens = new Tokens(client); -const response = await tokens.get( - '<TOKEN_ID>' // tokenId -); +const response = await tokens.get({ + tokenId: '<TOKEN_ID>' +}); diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md index 7208a53..a33ac66 100644 --- a/docs/examples/tokens/list.md +++ b/docs/examples/tokens/list.md @@ -7,8 +7,8 @@ const client = new Client() const tokens = new Tokens(client); -const response = await tokens.list( - '<BUCKET_ID>', // bucketId - '<FILE_ID>', // fileId - [] // queries (optional) -); +const response = 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 4464a0c..0524e05 100644 --- a/docs/examples/tokens/update.md +++ b/docs/examples/tokens/update.md @@ -7,7 +7,7 @@ const client = new Client() const tokens = new Tokens(client); -const response = await tokens.update( - '<TOKEN_ID>', // tokenId - '' // expire (optional) -); +const response = 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 65% rename from docs/examples/users/create-m-d5user.md rename to docs/examples/users/create-argon-2-user.md index 8cc63ce..b08fbb9 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 Client() const users = new Users(client); -const response = await users.createMD5User( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - '<NAME>' // name (optional) -); +const response = 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 ddfb7f3..6501c02 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -7,9 +7,9 @@ const client = new Client() const users = new Users(client); -const response = await users.createBcryptUser( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - '<NAME>' // name (optional) -); +const response = 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 69% rename from docs/examples/users/create-j-w-t.md rename to docs/examples/users/create-jwt.md index 4c433ae..6cd2f3d 100644 --- a/docs/examples/users/create-j-w-t.md +++ b/docs/examples/users/create-jwt.md @@ -7,8 +7,8 @@ const client = new Client() const users = new Users(client); -const response = await users.createJWT( - '<USER_ID>', // userId - '<SESSION_ID>', // sessionId (optional) - 0 // duration (optional) -); +const response = await users.createJWT({ + userId: '<USER_ID>', + sessionId: '<SESSION_ID>', // optional + duration: 0 // optional +}); diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-md-5-user.md similarity index 65% rename from docs/examples/users/create-argon2user.md rename to docs/examples/users/create-md-5-user.md index 7a6e0fb..4af161f 100644 --- a/docs/examples/users/create-argon2user.md +++ b/docs/examples/users/create-md-5-user.md @@ -7,9 +7,9 @@ const client = new Client() const users = new Users(client); -const response = await users.createArgon2User( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - '<NAME>' // name (optional) -); +const response = 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 98ba71a..fe8a4af 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 Client() const users = new Users(client); -const response = await users.createMfaRecoveryCodes( - '<USER_ID>' // userId -); +const response = await users.createMFARecoveryCodes({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-ph-pass-user.md similarity index 65% rename from docs/examples/users/create-p-h-pass-user.md rename to docs/examples/users/create-ph-pass-user.md index 750b299..d1f159a 100644 --- a/docs/examples/users/create-p-h-pass-user.md +++ b/docs/examples/users/create-ph-pass-user.md @@ -7,9 +7,9 @@ const client = new Client() const users = new Users(client); -const response = await users.createPHPassUser( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - '<NAME>' // name (optional) -); +const response = await users.createPHPassUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md index 0d6a65b..e382a4a 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 Client() const users = new Users(client); -const response = 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 response = 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 87f2dbb..7a6c874 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -7,14 +7,14 @@ const client = new Client() const users = new Users(client); -const response = 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 response = 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 37d6948..962d391 100644 --- a/docs/examples/users/create-session.md +++ b/docs/examples/users/create-session.md @@ -7,6 +7,6 @@ const client = new Client() const users = new Users(client); -const response = await users.createSession( - '<USER_ID>' // userId -); +const response = await users.createSession({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-sha-user.md similarity index 60% rename from docs/examples/users/create-s-h-a-user.md rename to docs/examples/users/create-sha-user.md index e243a1d..325da0e 100644 --- a/docs/examples/users/create-s-h-a-user.md +++ b/docs/examples/users/create-sha-user.md @@ -7,10 +7,10 @@ const client = new Client() const users = new Users(client); -const response = await users.createSHAUser( - '<USER_ID>', // userId - 'email@example.com', // email - 'password', // password - PasswordHash.Sha1, // passwordVersion (optional) - '<NAME>' // name (optional) -); +const response = await users.createSHAUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + passwordVersion: PasswordHash.Sha1, // optional + name: '<NAME>' // optional +}); diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md index a36072a..861c25a 100644 --- a/docs/examples/users/create-target.md +++ b/docs/examples/users/create-target.md @@ -7,11 +7,11 @@ const client = new Client() const users = new Users(client); -const response = await users.createTarget( - '<USER_ID>', // userId - '<TARGET_ID>', // targetId - MessagingProviderType.Email, // providerType - '<IDENTIFIER>', // identifier - '<PROVIDER_ID>', // providerId (optional) - '<NAME>' // name (optional) -); +const response = await users.createTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + providerType: 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 91885e1..b84d095 100644 --- a/docs/examples/users/create-token.md +++ b/docs/examples/users/create-token.md @@ -7,8 +7,8 @@ const client = new Client() const users = new Users(client); -const response = await users.createToken( - '<USER_ID>', // userId - 4, // length (optional) - 60 // expire (optional) -); +const response = 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 e0eb585..7da9b9a 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -7,10 +7,10 @@ const client = new Client() const users = new Users(client); -const response = await users.create( - '<USER_ID>', // userId - 'email@example.com', // email (optional) - '+12065550100', // phone (optional) - '', // password (optional) - '<NAME>' // name (optional) -); +const response = 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 7aea654..83efe6a 100644 --- a/docs/examples/users/delete-identity.md +++ b/docs/examples/users/delete-identity.md @@ -7,6 +7,6 @@ const client = new Client() const users = new Users(client); -const response = await users.deleteIdentity( - '<IDENTITY_ID>' // identityId -); +const response = 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 2d75950..5097cff 100644 --- a/docs/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.deleteMfaAuthenticator( - '<USER_ID>', // userId - AuthenticatorType.Totp // type -); +const response = await users.deleteMFAAuthenticator({ + userId: '<USER_ID>', + type: AuthenticatorType.Totp +}); diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index 0ce82fe..1d4adc8 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.deleteSession( - '<USER_ID>', // userId - '<SESSION_ID>' // sessionId -); +const response = 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 f80300b..ec44531 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -7,6 +7,6 @@ const client = new Client() const users = new Users(client); -const response = await users.deleteSessions( - '<USER_ID>' // userId -); +const response = await users.deleteSessions({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md index 9080a96..953ade1 100644 --- a/docs/examples/users/delete-target.md +++ b/docs/examples/users/delete-target.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.deleteTarget( - '<USER_ID>', // userId - '<TARGET_ID>' // targetId -); +const response = await users.deleteTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>' +}); diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index 7ac1bf1..5ab1f18 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -7,6 +7,6 @@ const client = new Client() const users = new Users(client); -const response = await users.delete( - '<USER_ID>' // userId -); +const response = 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 f78c0bf..c2e4752 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 Client() const users = new Users(client); -const response = await users.getMfaRecoveryCodes( - '<USER_ID>' // userId -); +const response = await users.getMFARecoveryCodes({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index ef1be1e..d252ffe 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -7,6 +7,6 @@ const client = new Client() const users = new Users(client); -const response = await users.getPrefs( - '<USER_ID>' // userId -); +const response = await users.getPrefs({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md index 301ee6e..7586fae 100644 --- a/docs/examples/users/get-target.md +++ b/docs/examples/users/get-target.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.getTarget( - '<USER_ID>', // userId - '<TARGET_ID>' // targetId -); +const response = await users.getTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>' +}); diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index 8e41ed6..c3e5863 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -7,6 +7,6 @@ const client = new Client() const users = new Users(client); -const response = await users.get( - '<USER_ID>' // userId -); +const response = await users.get({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index 6ac4395..f911007 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.listIdentities( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 983ffba..a039a74 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.listLogs( - '<USER_ID>', // userId - [] // queries (optional) -); +const response = 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 afdd4d4..538a635 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -7,8 +7,8 @@ const client = new Client() const users = new Users(client); -const response = await users.listMemberships( - '<USER_ID>', // userId - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 34b65af..c413011 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -7,6 +7,6 @@ const client = new Client() const users = new Users(client); -const response = await users.listMfaFactors( - '<USER_ID>' // userId -); +const response = await users.listMFAFactors({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index 314f277..46f4e5c 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -7,6 +7,6 @@ const client = new Client() const users = new Users(client); -const response = await users.listSessions( - '<USER_ID>' // userId -); +const response = await users.listSessions({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md index 9ed2dda..9eee79f 100644 --- a/docs/examples/users/list-targets.md +++ b/docs/examples/users/list-targets.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.listTargets( - '<USER_ID>', // userId - [] // queries (optional) -); +const response = await users.listTargets({ + userId: '<USER_ID>', + queries: [] // optional +}); diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index 488fbdc..df73463 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.list( - [], // queries (optional) - '<SEARCH>' // search (optional) -); +const response = 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 3243f21..df2fd03 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.updateEmailVerification( - '<USER_ID>', // userId - false // emailVerification -); +const response = 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 f609cab..fbf34ca 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.updateEmail( - '<USER_ID>', // userId - 'email@example.com' // email -); +const response = 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 5a23298..18cdca2 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.updateLabels( - '<USER_ID>', // userId - [] // labels -); +const response = 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 a74577e..ce1b875 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 Client() const users = new Users(client); -const response = await users.updateMfaRecoveryCodes( - '<USER_ID>' // userId -); +const response = await users.updateMFARecoveryCodes({ + userId: '<USER_ID>' +}); diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index 717f8d6..235357f 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.updateMfa( - '<USER_ID>', // userId - false // mfa -); +const response = 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 35fc853..304e833 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.updateName( - '<USER_ID>', // userId - '<NAME>' // name -); +const response = 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 8366b5c..8eecca4 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.updatePassword( - '<USER_ID>', // userId - '' // password -); +const response = 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 088fd1e..713cdac 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.updatePhoneVerification( - '<USER_ID>', // userId - false // phoneVerification -); +const response = 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 a8e47a6..1c3926b 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.updatePhone( - '<USER_ID>', // userId - '+12065550100' // number -); +const response = 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 cb8919a..555f9b4 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.updatePrefs( - '<USER_ID>', // userId - {} // prefs -); +const response = await users.updatePrefs({ + userId: '<USER_ID>', + prefs: {} +}); diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index 1c672a4..b6b692e 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const response = await users.updateStatus( - '<USER_ID>', // userId - false // status -); +const response = 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 4524748..ebc039b 100644 --- a/docs/examples/users/update-target.md +++ b/docs/examples/users/update-target.md @@ -7,10 +7,10 @@ const client = new Client() const users = new Users(client); -const response = await users.updateTarget( - '<USER_ID>', // userId - '<TARGET_ID>', // targetId - '<IDENTIFIER>', // identifier (optional) - '<PROVIDER_ID>', // providerId (optional) - '<NAME>' // name (optional) -); +const response = await users.updateTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + identifier: '<IDENTIFIER>', // optional + providerId: '<PROVIDER_ID>', // optional + name: '<NAME>' // optional +}); diff --git a/mod.ts b/mod.ts index 35c4e91..b228185 100644 --- a/mod.ts +++ b/mod.ts @@ -15,6 +15,7 @@ import { Locale } from "./src/services/locale.ts"; import { Messaging } from "./src/services/messaging.ts"; import { Sites } from "./src/services/sites.ts"; import { Storage } from "./src/services/storage.ts"; +import { TablesDB } from "./src/services/tables-db.ts"; import { Teams } from "./src/services/teams.ts"; import { Tokens } from "./src/services/tokens.ts"; import { Users } from "./src/services/users.ts"; @@ -28,7 +29,7 @@ import { RelationshipType } from "./src/enums/relationship-type.ts"; import { RelationMutate } from "./src/enums/relation-mutate.ts"; import { IndexType } from "./src/enums/index-type.ts"; import { Runtime } from "./src/enums/runtime.ts"; -import { VCSDeploymentType } from "./src/enums/v-c-s-deployment-type.ts"; +import { VCSDeploymentType } from "./src/enums/vcs-deployment-type.ts"; import { DeploymentDownloadType } from "./src/enums/deployment-download-type.ts"; import { ExecutionMethod } from "./src/enums/execution-method.ts"; import { Name } from "./src/enums/name.ts"; @@ -61,6 +62,7 @@ export { Messaging, Sites, Storage, + TablesDB, Teams, Tokens, Users, diff --git a/src/client.ts b/src/client.ts index 67e36f9..139c77b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -11,12 +11,12 @@ export class Client { endpoint: string = 'https://cloud.appwrite.io/v1'; headers: Payload = { 'content-type': '', - 'user-agent' : `AppwriteDenoSDK/15.1.0 (${Deno.build.os}; ${Deno.build.arch})`, + 'user-agent' : `AppwriteDenoSDK/16.0.0 (${Deno.build.os}; ${Deno.build.arch})`, 'x-sdk-name': 'Deno', 'x-sdk-platform': 'server', 'x-sdk-language': 'deno', - 'x-sdk-version': '15.1.0', - 'X-Appwrite-Response-Format':'1.7.0', + 'x-sdk-version': '16.0.0', + 'X-Appwrite-Response-Format':'1.8.0', }; /** diff --git a/src/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/models.d.ts b/src/models.d.ts index b47182e..cc6b414 100644 --- a/src/models.d.ts +++ b/src/models.d.ts @@ -1,10 +1,23 @@ export namespace Models { + /** + * Rows List + */ + export type RowList<Row extends Models.Row> = { + /** + * Total number of rows that matched your query. + */ + total: number; + /** + * List of rows. + */ + rows: Row[]; + } /** * Documents List */ export type DocumentList<Document extends Models.Document> = { /** - * Total number of documents documents that matched your query. + * Total number of documents that matched your query. */ total: number; /** @@ -12,12 +25,25 @@ 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; /** @@ -30,7 +56,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; /** @@ -43,7 +69,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; /** @@ -51,12 +77,25 @@ 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> = { /** - * Total number of users documents that matched your query. + * Total number of users that matched your query. */ total: number; /** @@ -69,7 +108,7 @@ export namespace Models { */ export type SessionList = { /** - * Total number of sessions documents that matched your query. + * Total number of sessions that matched your query. */ total: number; /** @@ -82,7 +121,7 @@ export namespace Models { */ export type IdentityList = { /** - * Total number of identities documents that matched your query. + * Total number of identities that matched your query. */ total: number; /** @@ -95,7 +134,7 @@ export namespace Models { */ export type LogList = { /** - * Total number of logs documents that matched your query. + * Total number of logs that matched your query. */ total: number; /** @@ -108,7 +147,7 @@ export namespace Models { */ export type FileList = { /** - * Total number of files documents that matched your query. + * Total number of files that matched your query. */ total: number; /** @@ -121,7 +160,7 @@ export namespace Models { */ export type BucketList = { /** - * Total number of buckets documents that matched your query. + * Total number of buckets that matched your query. */ total: number; /** @@ -134,7 +173,7 @@ export namespace Models { */ export type ResourceTokenList = { /** - * Total number of tokens documents that matched your query. + * Total number of tokens that matched your query. */ total: number; /** @@ -147,7 +186,7 @@ export namespace Models { */ export type TeamList<Preferences extends Models.Preferences> = { /** - * Total number of teams documents that matched your query. + * Total number of teams that matched your query. */ total: number; /** @@ -160,7 +199,7 @@ export namespace Models { */ export type MembershipList = { /** - * Total number of memberships documents that matched your query. + * Total number of memberships that matched your query. */ total: number; /** @@ -173,7 +212,7 @@ export namespace Models { */ export type SiteList = { /** - * Total number of sites documents that matched your query. + * Total number of sites that matched your query. */ total: number; /** @@ -186,7 +225,7 @@ export namespace Models { */ export type FunctionList = { /** - * Total number of functions documents that matched your query. + * Total number of functions that matched your query. */ total: number; /** @@ -199,7 +238,7 @@ export namespace Models { */ export type FrameworkList = { /** - * Total number of frameworks documents that matched your query. + * Total number of frameworks that matched your query. */ total: number; /** @@ -212,7 +251,7 @@ export namespace Models { */ export type RuntimeList = { /** - * Total number of runtimes documents that matched your query. + * Total number of runtimes that matched your query. */ total: number; /** @@ -225,7 +264,7 @@ export namespace Models { */ export type DeploymentList = { /** - * Total number of deployments documents that matched your query. + * Total number of deployments that matched your query. */ total: number; /** @@ -238,7 +277,7 @@ export namespace Models { */ export type ExecutionList = { /** - * Total number of executions documents that matched your query. + * Total number of executions that matched your query. */ total: number; /** @@ -251,7 +290,7 @@ export namespace Models { */ export type CountryList = { /** - * Total number of countries documents that matched your query. + * Total number of countries that matched your query. */ total: number; /** @@ -264,7 +303,7 @@ export namespace Models { */ export type ContinentList = { /** - * Total number of continents documents that matched your query. + * Total number of continents that matched your query. */ total: number; /** @@ -277,7 +316,7 @@ export namespace Models { */ export type LanguageList = { /** - * Total number of languages documents that matched your query. + * Total number of languages that matched your query. */ total: number; /** @@ -290,7 +329,7 @@ export namespace Models { */ export type CurrencyList = { /** - * Total number of currencies documents that matched your query. + * Total number of currencies that matched your query. */ total: number; /** @@ -303,7 +342,7 @@ export namespace Models { */ export type PhoneList = { /** - * Total number of phones documents that matched your query. + * Total number of phones that matched your query. */ total: number; /** @@ -316,7 +355,7 @@ export namespace Models { */ export type VariableList = { /** - * Total number of variables documents that matched your query. + * Total number of variables that matched your query. */ total: number; /** @@ -329,7 +368,7 @@ export namespace Models { */ export type LocaleCodeList = { /** - * Total number of localeCodes documents that matched your query. + * Total number of localeCodes that matched your query. */ total: number; /** @@ -342,7 +381,7 @@ export namespace Models { */ export type ProviderList = { /** - * Total number of providers documents that matched your query. + * Total number of providers that matched your query. */ total: number; /** @@ -355,7 +394,7 @@ export namespace Models { */ export type MessageList = { /** - * Total number of messages documents that matched your query. + * Total number of messages that matched your query. */ total: number; /** @@ -368,7 +407,7 @@ export namespace Models { */ export type TopicList = { /** - * Total number of topics documents that matched your query. + * Total number of topics that matched your query. */ total: number; /** @@ -381,7 +420,7 @@ export namespace Models { */ export type SubscriberList = { /** - * Total number of subscribers documents that matched your query. + * Total number of subscribers that matched your query. */ total: number; /** @@ -394,7 +433,7 @@ export namespace Models { */ export type TargetList = { /** - * Total number of targets documents that matched your query. + * Total number of targets that matched your query. */ total: number; /** @@ -407,7 +446,7 @@ export namespace Models { */ export type SpecificationList = { /** - * Total number of specifications documents that matched your query. + * Total number of specifications that matched your query. */ total: number; /** @@ -439,6 +478,10 @@ export namespace Models { * 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 @@ -976,12 +1019,560 @@ export namespace Models { */ side: string; } + /** + * Table + */ + export type Table = { + /** + * Table ID. + */ + $id: string; + /** + * Table creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Table update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * Database ID. + */ + databaseId: string; + /** + * Table name. + */ + name: string; + /** + * Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. + */ + enabled: boolean; + /** + * Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + rowSecurity: boolean; + /** + * Table columns. + */ + columns: (ColumnBoolean | ColumnInteger | ColumnFloat | ColumnEmail | ColumnEnum | ColumnUrl | ColumnIp | ColumnDatetime | ColumnRelationship | ColumnString)[]; + /** + * Table indexes. + */ + indexes: ColumnIndex[]; + } + /** + * Columns List + */ + export type ColumnList = { + /** + * Total number of columns in the given table. + */ + total: number; + /** + * List of columns. + */ + columns: (ColumnBoolean | ColumnInteger | ColumnFloat | ColumnEmail | ColumnEnum | ColumnUrl | ColumnIp | ColumnDatetime | ColumnRelationship | ColumnString)[]; + } + /** + * ColumnString + */ + export type ColumnString = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Column size. + */ + size: number; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + xdefault?: string; + /** + * Defines whether this column is encrypted or not. + */ + encrypt?: boolean; + } + /** + * ColumnInteger + */ + export type ColumnInteger = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number; + /** + * Maximum value to enforce for new documents. + */ + max?: number; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + xdefault?: number; + } + /** + * ColumnFloat + */ + export type ColumnFloat = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number; + /** + * Maximum value to enforce for new documents. + */ + max?: number; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + xdefault?: number; + } + /** + * ColumnBoolean + */ + export type ColumnBoolean = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + xdefault?: boolean; + } + /** + * ColumnEmail + */ + export type ColumnEmail = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + xdefault?: string; + } + /** + * ColumnEnum + */ + export type ColumnEnum = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Array of elements in enumerated type. + */ + elements: string[]; + /** + * String format. + */ + format: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + xdefault?: string; + } + /** + * ColumnIP + */ + export type ColumnIp = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + xdefault?: string; + } + /** + * ColumnURL + */ + export type ColumnUrl = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + xdefault?: string; + } + /** + * ColumnDatetime + */ + export type ColumnDatetime = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * ISO 8601 format. + */ + format: string; + /** + * Default value for column when not provided. Only null is optional + */ + xdefault?: string; + } + /** + * ColumnRelationship + */ + export type ColumnRelationship = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * The ID of the related table. + */ + relatedTable: string; + /** + * The type of the relationship. + */ + relationType: string; + /** + * Is the relationship two-way? + */ + twoWay: boolean; + /** + * The key of the two-way relationship. + */ + twoWayKey: string; + /** + * How deleting the parent document will propagate to child documents. + */ + onDelete: string; + /** + * Whether this is the parent or child side of the relationship + */ + side: string; + } /** * Index */ 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; /** @@ -1008,6 +1599,15 @@ export namespace Models { * Index orders. */ orders?: string[]; + } + /** + * Index + */ + export type ColumnIndex = { + /** + * Index ID. + */ + $id: string; /** * Index creation date in ISO 8601 format. */ @@ -1016,6 +1616,67 @@ 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[]; } /** * Document @@ -2250,7 +2911,7 @@ export namespace Models { */ $createdAt: string; /** - * Execution upate date in ISO 8601 format. + * Execution update date in ISO 8601 format. */ $updatedAt: string; /** @@ -2261,6 +2922,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`. */ diff --git a/src/query.ts b/src/query.ts index 98930a2..8788279 100644 --- a/src/query.ts +++ b/src/query.ts @@ -93,9 +93,104 @@ export class Query { static offset = (offset: number): string => new Query("offset", undefined, offset).toString(); + /** + * Filter resources where attribute contains the specified value. + * + * @param {string} attribute + * @param {string | string[]} value + * @returns {string} + */ 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(); + static or = (queries: string[]) => new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString(); diff --git a/src/services/account.ts b/src/services/account.ts index 8969794..857bb26 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -275,6 +275,7 @@ export class Account extends Service { * @param {AuthenticatorType} type * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead. */ async createMfaAuthenticator(type: AuthenticatorType): Promise<Models.MfaType> { if (typeof type === 'undefined') { @@ -294,6 +295,34 @@ export class Account extends Service { 'json' ); } + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async createMFAAuthenticator(type: AuthenticatorType): Promise<Models.MfaType> { + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); + const payload: Payload = {}; + + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Verify an authenticator app after adding it using the [add * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) @@ -303,6 +332,7 @@ export class Account extends Service { * @param {string} otp * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead. */ async updateMfaAuthenticator<Preferences extends Models.Preferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>> { if (typeof type === 'undefined') { @@ -329,12 +359,48 @@ export class Account extends Service { 'json' ); } + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateMFAAuthenticator<Preferences extends Models.Preferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>> { + 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; + } + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Delete an authenticator for a user by ID. * * @param {AuthenticatorType} type * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead. */ async deleteMfaAuthenticator(type: AuthenticatorType): Promise<Response> { if (typeof type === 'undefined') { @@ -354,6 +420,31 @@ export class Account extends Service { 'json' ); } + /** + * Delete an authenticator for a user by ID. + * + * @param {AuthenticatorType} type + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteMFAAuthenticator(type: AuthenticatorType): Promise<Response> { + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); + const payload: Payload = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Begin the process of MFA verification after sign-in. Finish the flow with * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) @@ -362,6 +453,7 @@ export class Account extends Service { * @param {AuthenticationFactor} factor * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead. */ async createMfaChallenge(factor: AuthenticationFactor): Promise<Models.MfaChallenge> { if (typeof factor === 'undefined') { @@ -384,6 +476,36 @@ export class Account extends Service { 'json' ); } + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async createMFAChallenge(factor: AuthenticationFactor): Promise<Models.MfaChallenge> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Complete the MFA challenge by providing the one-time password. Finish the * process of MFA verification by providing the one-time password. To begin @@ -395,6 +517,7 @@ export class Account extends Service { * @param {string} otp * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead. */ async updateMfaChallenge(challengeId: string, otp: string): Promise<Models.Session> { if (typeof challengeId === 'undefined') { @@ -424,11 +547,52 @@ export class Account extends Service { 'json' ); } + /** + * 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 + * @param {string} otp + * @throws {AppwriteException} + * @returns {Promise} + */ + async 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'; + const payload: Payload = {}; + + if (typeof challengeId !== 'undefined') { + payload['challengeId'] = challengeId; + } + if (typeof otp !== 'undefined') { + payload['otp'] = otp; + } + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * List the factors available on the account to be used as a MFA challange. * * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead. */ async listMfaFactors(): Promise<Models.MfaFactors> { const apiPath = '/account/mfa/factors'; @@ -443,6 +607,25 @@ export class Account extends Service { 'json' ); } + /** + * List the factors available on the account to be used as a MFA challange. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + async listMFAFactors(): Promise<Models.MfaFactors> { + const apiPath = '/account/mfa/factors'; + const payload: Payload = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } /** * Get recovery codes that can be used as backup for MFA flow. Before getting * codes, they must be generated using @@ -451,6 +634,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead. */ async getMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { const apiPath = '/account/mfa/recovery-codes'; @@ -465,6 +649,28 @@ export class Account extends Service { 'json' ); } + /** + * 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. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + async getMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + const apiPath = '/account/mfa/recovery-codes'; + const payload: Payload = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } /** * Generate recovery codes as backup for MFA flow. It's recommended to * generate and show then immediately after user successfully adds their @@ -474,6 +680,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead. */ async createMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { const apiPath = '/account/mfa/recovery-codes'; @@ -489,6 +696,30 @@ export class Account extends Service { 'json' ); } + /** + * 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} + */ + async createMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + const apiPath = '/account/mfa/recovery-codes'; + const payload: Payload = {}; + + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Regenerate recovery codes that can be used as backup for MFA flow. Before * regenerating codes, they must be first generated using @@ -497,6 +728,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead. */ async updateMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> { const apiPath = '/account/mfa/recovery-codes'; @@ -512,6 +744,29 @@ export class Account extends Service { 'json' ); } + /** + * 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} + */ + async updateMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + const apiPath = '/account/mfa/recovery-codes'; + const payload: Payload = {}; + + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Update currently logged in user account name. * @@ -876,6 +1131,7 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated. */ async updateMagicURLSession(userId: string, secret: string): Promise<Models.Session> { if (typeof userId === 'undefined') { @@ -914,6 +1170,7 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated. */ async updatePhoneSession(userId: string, secret: string): Promise<Models.Session> { if (typeof userId === 'undefined') { @@ -1086,8 +1343,11 @@ export class Account extends Service { } /** * 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 + * 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. @@ -1095,6 +1355,7 @@ export class Account extends Service { * 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 diff --git a/src/services/databases.ts b/src/services/databases.ts index 9881842..56ec236 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -32,6 +32,7 @@ export class Databases extends Service { * @param {string} search * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.list` instead. */ async list(queries?: string[], search?: string): Promise<Models.DatabaseList> { const apiPath = '/databases'; @@ -63,6 +64,7 @@ export class Databases extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createDatabase` instead. */ async create(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database> { if (typeof databaseId === 'undefined') { @@ -102,6 +104,7 @@ export class Databases extends Service { * @param {string} databaseId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.get` instead. */ async get(databaseId: string): Promise<Models.Database> { if (typeof databaseId === 'undefined') { @@ -128,6 +131,7 @@ export class Databases extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.update` instead. */ async update(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database> { if (typeof databaseId === 'undefined') { @@ -164,6 +168,7 @@ export class Databases extends Service { * @param {string} databaseId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.delete` instead. */ async delete(databaseId: string): Promise<Response> { if (typeof databaseId === 'undefined') { @@ -192,6 +197,7 @@ export class Databases extends Service { * @param {string} search * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listTables` instead. */ async listCollections(databaseId: string, queries?: string[], search?: string): Promise<Models.CollectionList> { if (typeof databaseId === 'undefined') { @@ -232,6 +238,7 @@ export class Databases extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead. */ async createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise<Models.Collection> { if (typeof databaseId === 'undefined') { @@ -282,6 +289,7 @@ export class Databases extends Service { * @param {string} collectionId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getTable` instead. */ async getCollection(databaseId: string, collectionId: string): Promise<Models.Collection> { if (typeof databaseId === 'undefined') { @@ -315,6 +323,7 @@ export class Databases extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTable` instead. */ async updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise<Models.Collection> { if (typeof databaseId === 'undefined') { @@ -362,6 +371,7 @@ export class Databases extends Service { * @param {string} collectionId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTable` instead. */ async deleteCollection(databaseId: string, collectionId: string): Promise<Response> { if (typeof databaseId === 'undefined') { @@ -393,6 +403,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listColumns` instead. */ async listAttributes(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.AttributeList> { if (typeof databaseId === 'undefined') { @@ -431,6 +442,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBooleanColumn` instead. */ async createBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise<Models.AttributeBoolean> { if (typeof databaseId === 'undefined') { @@ -486,6 +498,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead. */ async updateBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise<Models.AttributeBoolean> { if (typeof databaseId === 'undefined') { @@ -541,6 +554,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createDatetimeColumn` instead. */ async createDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeDatetime> { if (typeof databaseId === 'undefined') { @@ -596,6 +610,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead. */ async updateDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeDatetime> { if (typeof databaseId === 'undefined') { @@ -652,6 +667,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createEmailColumn` instead. */ async createEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeEmail> { if (typeof databaseId === 'undefined') { @@ -708,6 +724,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead. */ async updateEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeEmail> { if (typeof databaseId === 'undefined') { @@ -753,8 +770,8 @@ export class Databases extends Service { ); } /** - * Create an enumeration attribute. The `elements` param acts as a white-list - * of accepted values for this attribute. + * Create an enum attribute. The `elements` param acts as a white-list of + * accepted values for this attribute. * * * @param {string} databaseId @@ -766,6 +783,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createEnumColumn` instead. */ async createEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeEnum> { if (typeof databaseId === 'undefined') { @@ -830,6 +848,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead. */ async updateEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeEnum> { if (typeof databaseId === 'undefined') { @@ -896,6 +915,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createFloatColumn` instead. */ async createFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.AttributeFloat> { if (typeof databaseId === 'undefined') { @@ -960,6 +980,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead. */ async updateFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.AttributeFloat> { if (typeof databaseId === 'undefined') { @@ -1025,6 +1046,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIntegerColumn` instead. */ async createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.AttributeInteger> { if (typeof databaseId === 'undefined') { @@ -1089,6 +1111,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. */ async updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.AttributeInteger> { if (typeof databaseId === 'undefined') { @@ -1151,6 +1174,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIpColumn` instead. */ async createIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeIp> { if (typeof databaseId === 'undefined') { @@ -1207,6 +1231,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead. */ async updateIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeIp> { if (typeof databaseId === 'undefined') { @@ -1266,6 +1291,7 @@ export class Databases extends Service { * @param {RelationMutate} onDelete * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRelationshipColumn` instead. */ async createRelationshipAttribute(databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise<Models.AttributeRelationship> { if (typeof databaseId === 'undefined') { @@ -1329,6 +1355,7 @@ export class Databases extends Service { * @param {boolean} encrypt * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createStringColumn` instead. */ async createStringAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.AttributeString> { if (typeof databaseId === 'undefined') { @@ -1396,6 +1423,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead. */ async updateStringAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise<Models.AttributeString> { if (typeof databaseId === 'undefined') { @@ -1455,6 +1483,7 @@ export class Databases extends Service { * @param {boolean} array * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createUrlColumn` instead. */ async createUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeUrl> { if (typeof databaseId === 'undefined') { @@ -1511,6 +1540,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead. */ async updateUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeUrl> { if (typeof databaseId === 'undefined') { @@ -1563,6 +1593,7 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead. */ async getAttribute(databaseId: string, collectionId: string, key: string): Promise<Response> { if (typeof databaseId === 'undefined') { @@ -1597,6 +1628,7 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteColumn` instead. */ async deleteAttribute(databaseId: string, collectionId: string, key: string): Promise<Response> { if (typeof databaseId === 'undefined') { @@ -1636,6 +1668,7 @@ export class Databases extends Service { * @param {string} newKey * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. */ async updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.AttributeRelationship> { if (typeof databaseId === 'undefined') { @@ -1678,6 +1711,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead. */ async listDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.DocumentList<Document>> { if (typeof databaseId === 'undefined') { @@ -1717,6 +1751,7 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. */ async createDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise<Document> { if (typeof databaseId === 'undefined') { @@ -1758,10 +1793,6 @@ export class Databases extends Service { ); } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not - * yet officially supported. It may be subject to breaking changes or removal - * in future versions. - * * Create new Documents. Before using this route, you should create a new * collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1772,6 +1803,7 @@ export class Databases extends Service { * @param {object[]} documents * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead. */ async createDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, documents: object[]): Promise<Models.DocumentList<Document>> { if (typeof databaseId === 'undefined') { @@ -1803,10 +1835,6 @@ export class Databases extends Service { ); } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not - * yet officially supported. It may be subject to breaking changes or removal - * in future versions. - * * Create or update Documents. Before using this route, you should create a * new collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1818,6 +1846,7 @@ export class Databases extends Service { * @param {object[]} documents * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. */ async upsertDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, documents: object[]): Promise<Models.DocumentList<Document>> { if (typeof databaseId === 'undefined') { @@ -1849,10 +1878,6 @@ export class Databases extends Service { ); } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not - * yet officially supported. It may be subject to breaking changes or removal - * in future versions. - * * Update all documents that match your queries, if no queries are submitted * then all documents are updated. You can pass only specific fields to be * updated. @@ -1863,6 +1888,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. */ async updateDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, data?: object, queries?: string[]): Promise<Models.DocumentList<Document>> { if (typeof databaseId === 'undefined') { @@ -1893,10 +1919,6 @@ export class Databases extends Service { ); } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not - * yet officially supported. It may be subject to breaking changes or removal - * in future versions. - * * Bulk delete documents using queries, if no queries are passed then all * documents are deleted. * @@ -1905,6 +1927,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRows` instead. */ async deleteDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.DocumentList<Document>> { if (typeof databaseId === 'undefined') { @@ -1941,6 +1964,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead. */ async getDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Document> { if (typeof databaseId === 'undefined') { @@ -1972,10 +1996,6 @@ export class Databases extends Service { ); } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not - * yet officially supported. It may be subject to breaking changes or removal - * in future versions. - * * Create or update 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) @@ -1988,6 +2008,7 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. */ async upsertDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise<Document> { if (typeof databaseId === 'undefined') { @@ -2036,6 +2057,7 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead. */ async updateDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data?: object, permissions?: string[]): Promise<Document> { if (typeof databaseId === 'undefined') { @@ -2077,6 +2099,7 @@ export class Databases extends Service { * @param {string} documentId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead. */ async deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<Response> { if (typeof databaseId === 'undefined') { @@ -2115,6 +2138,7 @@ export class Databases extends Service { * @param {number} min * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead. */ async decrementDocumentAttribute<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise<Document> { if (typeof databaseId === 'undefined') { @@ -2163,6 +2187,7 @@ export class Databases extends Service { * @param {number} max * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead. */ async incrementDocumentAttribute<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise<Document> { if (typeof databaseId === 'undefined') { @@ -2208,6 +2233,7 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listIndexes` instead. */ async listIndexes(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.IndexList> { if (typeof databaseId === 'undefined') { @@ -2248,6 +2274,7 @@ export class Databases extends Service { * @param {number[]} lengths * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIndex` instead. */ async createIndex(databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: string[], lengths?: number[]): Promise<Models.Index> { if (typeof databaseId === 'undefined') { @@ -2306,6 +2333,7 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getIndex` instead. */ async getIndex(databaseId: string, collectionId: string, key: string): Promise<Models.Index> { if (typeof databaseId === 'undefined') { @@ -2340,6 +2368,7 @@ export class Databases extends Service { * @param {string} key * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteIndex` instead. */ async deleteIndex(databaseId: string, collectionId: string, key: string): Promise<Response> { if (typeof databaseId === 'undefined') { diff --git a/src/services/functions.ts b/src/services/functions.ts index 2a5b345..6c30109 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -6,7 +6,7 @@ import { AppwriteException } from '../exception.ts'; import type { Models } from '../models.d.ts'; import { Query } from '../query.ts'; import { Runtime } from '../enums/runtime.ts'; -import { VCSDeploymentType } from '../enums/v-c-s-deployment-type.ts'; +import { VCSDeploymentType } from '../enums/vcs-deployment-type.ts'; import { DeploymentDownloadType } from '../enums/deployment-download-type.ts'; import { ExecutionMethod } from '../enums/execution-method.ts'; diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 5b9d0ee..0e89fef 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -416,6 +416,7 @@ export class Messaging extends Service { * @param {string} scheduledAt * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead. */ async createSms(messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise<Models.Message> { if (typeof messageId === 'undefined') { @@ -460,6 +461,62 @@ export class Messaging extends Service { 'json' ); } + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async createSMS(messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise<Models.Message> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Update an SMS message by its unique ID. This endpoint only works on * messages that are in draft status. Messages that are already processing, @@ -475,6 +532,7 @@ export class Messaging extends Service { * @param {string} scheduledAt * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead. */ async updateSms(messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise<Models.Message> { if (typeof messageId === 'undefined') { @@ -512,6 +570,58 @@ export class Messaging extends Service { 'json' ); } + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateSMS(messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise<Models.Message> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Get a message by its unique ID. * @@ -663,6 +773,7 @@ export class Messaging extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead. */ async createApnsProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise<Models.Provider> { if (typeof providerId === 'undefined') { @@ -710,6 +821,66 @@ export class Messaging extends Service { 'json' ); } + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async createAPNSProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise<Models.Provider> { + 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') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + 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; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Update a Apple Push Notification service provider by its unique ID. * @@ -723,6 +894,7 @@ export class Messaging extends Service { * @param {boolean} sandbox * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. */ async updateApnsProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise<Models.Provider> { if (typeof providerId === 'undefined') { @@ -763,6 +935,59 @@ export class Messaging extends Service { 'json' ); } + /** + * Update a Apple Push Notification service provider by its unique ID. + * + * @param {string} providerId + * @param {string} name + * @param {boolean} enabled + * @param {string} authKey + * @param {string} authKeyId + * @param {string} teamId + * @param {string} bundleId + * @param {boolean} sandbox + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateAPNSProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise<Models.Provider> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Create a new Firebase Cloud Messaging provider. * @@ -772,6 +997,7 @@ export class Messaging extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. */ async createFcmProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise<Models.Provider> { if (typeof providerId === 'undefined') { @@ -807,6 +1033,50 @@ export class Messaging extends Service { 'json' ); } + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} providerId + * @param {string} name + * @param {object} serviceAccountJSON + * @param {boolean} enabled + * @throws {AppwriteException} + * @returns {Promise} + */ + async createFCMProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise<Models.Provider> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Update a Firebase Cloud Messaging provider by its unique ID. * @@ -816,6 +1086,7 @@ export class Messaging extends Service { * @param {object} serviceAccountJSON * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. */ async updateFcmProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise<Models.Provider> { if (typeof providerId === 'undefined') { @@ -844,6 +1115,43 @@ export class Messaging extends Service { 'json' ); } + /** + * Update a Firebase Cloud Messaging provider by its unique ID. + * + * @param {string} providerId + * @param {string} name + * @param {boolean} enabled + * @param {object} serviceAccountJSON + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateFCMProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise<Models.Provider> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Create a new Mailgun provider. * @@ -1202,6 +1510,7 @@ export class Messaging extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. */ async 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> { if (typeof providerId === 'undefined') { @@ -1271,6 +1580,94 @@ export class Messaging extends Service { 'json' ); } + /** + * Create a new SMTP provider. + * + * @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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async 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> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Update a SMTP provider by its unique ID. * @@ -1290,6 +1687,7 @@ export class Messaging extends Service { * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. */ async 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> { if (typeof providerId === 'undefined') { @@ -1348,6 +1746,83 @@ export class Messaging extends Service { 'json' ); } + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async 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> { + 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') { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Create a new Telesign provider. * diff --git a/src/services/sites.ts b/src/services/sites.ts index f0b06b9..e02e99b 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -8,7 +8,7 @@ import { Query } from '../query.ts'; import { Framework } from '../enums/framework.ts'; import { BuildRuntime } from '../enums/build-runtime.ts'; import { Adapter } from '../enums/adapter.ts'; -import { VCSDeploymentType } from '../enums/v-c-s-deployment-type.ts'; +import { VCSDeploymentType } from '../enums/vcs-deployment-type.ts'; import { DeploymentDownloadType } from '../enums/deployment-download-type.ts'; export type UploadProgress = { diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts new file mode 100644 index 0000000..c7d79c7 --- /dev/null +++ b/src/services/tables-db.ts @@ -0,0 +1,2344 @@ +import { basename } from "https://deno.land/std@0.122.0/path/mod.ts"; +import { Service } from '../service.ts'; +import { Payload, Client } from '../client.ts'; +import { InputFile } from '../inputFile.ts'; +import { AppwriteException } from '../exception.ts'; +import type { Models } from '../models.d.ts'; +import { Query } from '../query.ts'; +import { RelationshipType } from '../enums/relationship-type.ts'; +import { RelationMutate } from '../enums/relation-mutate.ts'; +import { IndexType } from '../enums/index-type.ts'; + +export type UploadProgress = { + $id: string; + progress: number; + sizeUploaded: number; + chunksTotal: number; + chunksUploaded: number; +} + +export class TablesDB extends Service { + + constructor(client: Client) + { + super(client); + } + + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async list(queries?: string[], search?: string): Promise<Models.DatabaseList> { + const apiPath = '/tablesdb'; + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + + if (typeof search !== 'undefined') { + payload['search'] = search; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Create a new Database. + * + * + * @param {string} databaseId + * @param {string} name + * @param {boolean} enabled + * @throws {AppwriteException} + * @returns {Promise} + */ + async create(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get a database by its unique ID. This endpoint response returns a JSON + * object with the database metadata. + * + * @param {string} databaseId + * @throws {AppwriteException} + * @returns {Promise} + */ + async get(databaseId: string): Promise<Models.Database> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Update a database by its unique ID. + * + * @param {string} databaseId + * @param {string} name + * @param {boolean} enabled + * @throws {AppwriteException} + * @returns {Promise} + */ + async update(databaseId: string, name: string, enabled?: boolean): Promise<Models.Database> { + 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; + } + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Delete a database by its unique ID. Only API keys with with databases.write + * scope can delete a database. + * + * @param {string} databaseId + * @throws {AppwriteException} + * @returns {Promise} + */ + async delete(databaseId: string): Promise<Response> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get a list of all tables that belong to the provided databaseId. You can + * use the search parameter to filter your results. + * + * @param {string} databaseId + * @param {string[]} queries + * @param {string} search + * @throws {AppwriteException} + * @returns {Promise} + */ + async listTables(databaseId: string, queries?: string[], search?: string): Promise<Models.TableList> { + 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; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Create a new Table. Before using this route, you should create a new + * database resource using either a [server + * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} name + * @param {string[]} permissions + * @param {boolean} rowSecurity + * @param {boolean} enabled + * @throws {AppwriteException} + * @returns {Promise} + */ + async createTable(databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean): Promise<Models.Table> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get a table by its unique ID. This endpoint response returns a JSON object + * with the table metadata. + * + * @param {string} databaseId + * @param {string} tableId + * @throws {AppwriteException} + * @returns {Promise} + */ + async getTable(databaseId: string, tableId: string): Promise<Models.Table> { + 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 = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Update a table by its unique ID. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} name + * @param {string[]} permissions + * @param {boolean} rowSecurity + * @param {boolean} enabled + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateTable(databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean): Promise<Models.Table> { + 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; + } + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Delete a table by its unique ID. Only users with write permissions have + * access to delete this resource. + * + * @param {string} databaseId + * @param {string} tableId + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteTable(databaseId: string, tableId: string): Promise<Response> { + 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 = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * List columns in the table. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async listColumns(databaseId: string, tableId: string, queries?: string[]): Promise<Models.ColumnList> { + 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; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Create a boolean column. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {boolean} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise<Models.ColumnBoolean> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update a boolean column. Changing the `default` value will not update + * already existing rows. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {boolean} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateBooleanColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise<Models.ColumnBoolean> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create a date time column according to the ISO 8601 standard. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnDatetime> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update a date time column. Changing the `default` value will not update + * already existing rows. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateDatetimeColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnDatetime> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create an email column. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnEmail> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update an email column. Changing the `default` value will not update + * already existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateEmailColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnEmail> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create an enumeration column. The `elements` param acts as a white-list of + * accepted values for this column. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {string[]} elements + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnEnum> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update an enum column. Changing the `default` value will not update already + * existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {string[]} elements + * @param {boolean} required + * @param {string} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateEnumColumn(databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnEnum> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create a float column. Optionally, minimum and maximum values can be + * provided. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {number} min + * @param {number} max + * @param {number} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.ColumnFloat> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update a float column. Changing the `default` value will not update already + * existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {number} xdefault + * @param {number} min + * @param {number} max + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateFloatColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.ColumnFloat> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create an integer column. Optionally, minimum and maximum values can be + * provided. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {number} min + * @param {number} max + * @param {number} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.ColumnInteger> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update an integer column. Changing the `default` value will not update + * already existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {number} xdefault + * @param {number} min + * @param {number} max + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.ColumnInteger> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create IP address column. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnIp> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update an ip column. Changing the `default` value will not update already + * existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateIpColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnIp> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} relatedTableId + * @param {RelationshipType} type + * @param {boolean} twoWay + * @param {string} key + * @param {string} twoWayKey + * @param {RelationMutate} onDelete + * @throws {AppwriteException} + * @returns {Promise} + */ + async createRelationshipColumn(databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise<Models.ColumnRelationship> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create a string column. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {number} size + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @param {boolean} encrypt + * @throws {AppwriteException} + * @returns {Promise} + */ + async createStringColumn(databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.ColumnString> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update a string column. Changing the `default` value will not update + * already existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {number} size + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateStringColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise<Models.ColumnString> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create a URL column. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {boolean} array + * @throws {AppwriteException} + * @returns {Promise} + */ + async createUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnUrl> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update an url column. Changing the `default` value will not update already + * existing rows. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {boolean} required + * @param {string} xdefault + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateUrlColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnUrl> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get column by ID. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @throws {AppwriteException} + * @returns {Promise} + */ + async getColumn(databaseId: string, tableId: string, key: string): Promise<Response> { + 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 = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Deletes a column. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteColumn(databaseId: string, tableId: string, key: string): Promise<Response> { + 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 = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @param {RelationMutate} onDelete + * @param {string} newKey + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateRelationshipColumn(databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.ColumnRelationship> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * List indexes on the table. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async listIndexes(databaseId: string, tableId: string, queries?: string[]): Promise<Models.ColumnIndexList> { + 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; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * 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 + * @param {string} tableId + * @param {string} key + * @param {IndexType} type + * @param {string[]} columns + * @param {string[]} orders + * @param {number[]} lengths + * @throws {AppwriteException} + * @returns {Promise} + */ + async createIndex(databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: string[], lengths?: number[]): Promise<Models.ColumnIndex> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get index by ID. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @throws {AppwriteException} + * @returns {Promise} + */ + async getIndex(databaseId: string, tableId: string, key: string): Promise<Models.ColumnIndex> { + 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 = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Delete an index. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} key + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteIndex(databaseId: string, tableId: string, key: string): Promise<Response> { + 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 = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get a list of all the user's rows in a given table. You can use the query + * params to filter your results. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async listRows<Row extends Models.Row>(databaseId: string, tableId: string, queries?: string[]): Promise<Models.RowList<Row>> { + 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; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Create a new Row. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {object} data + * @param {string[]} permissions + * @throws {AppwriteException} + * @returns {Promise} + */ + async createRow<Row extends Models.Row>(databaseId: string, tableId: string, rowId: string, data: object, permissions?: string[]): Promise<Row> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create new Rows. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {object[]} rows + * @throws {AppwriteException} + * @returns {Promise} + */ + async createRows<Row extends Models.Row>(databaseId: string, tableId: string, rows: object[]): Promise<Models.RowList<Row>> { + 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; + } + return await this.client.call( + 'post', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Create or update Rows. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * API or directly from your database console. + * + * + * @param {string} databaseId + * @param {string} tableId + * @param {object[]} rows + * @throws {AppwriteException} + * @returns {Promise} + */ + async upsertRows<Row extends Models.Row>(databaseId: string, tableId: string, rows: object[]): Promise<Models.RowList<Row>> { + 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; + } + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update all rows that match your queries, if no queries are submitted then + * all rows are updated. You can pass only specific fields to be updated. + * + * @param {string} databaseId + * @param {string} tableId + * @param {object} data + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateRows<Row extends Models.Row>(databaseId: string, tableId: string, data?: object, queries?: string[]): Promise<Models.RowList<Row>> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Bulk delete rows using queries, if no queries are passed then all rows are + * deleted. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteRows<Row extends Models.Row>(databaseId: string, tableId: string, queries?: string[]): Promise<Models.RowList<Row>> { + 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; + } + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Get a row by its unique ID. This endpoint response returns a JSON object + * with the row data. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + async getRow<Row extends Models.Row>(databaseId: string, tableId: string, rowId: string, queries?: string[]): Promise<Row> { + 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; + } + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } + /** + * Create or update a Row. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {object} data + * @param {string[]} permissions + * @throws {AppwriteException} + * @returns {Promise} + */ + async upsertRow<Row extends Models.Row>(databaseId: string, tableId: string, rowId: string, data?: object, permissions?: string[]): Promise<Row> { + 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; + } + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Update a row by its unique ID. Using the patch method you can pass only + * specific fields that will get updated. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {object} data + * @param {string[]} permissions + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateRow<Row extends Models.Row>(databaseId: string, tableId: string, rowId: string, data?: object, permissions?: string[]): Promise<Row> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Delete a row by its unique ID. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteRow(databaseId: string, tableId: string, rowId: string): Promise<Response> { + 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 = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Decrement a specific column of a row by a given value. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {string} column + * @param {number} value + * @param {number} min + * @throws {AppwriteException} + * @returns {Promise} + */ + async decrementRowColumn<Row extends Models.Row>(databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number): Promise<Row> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } + /** + * Increment a specific column of a row by a given value. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {string} column + * @param {number} value + * @param {number} max + * @throws {AppwriteException} + * @returns {Promise} + */ + async incrementRowColumn<Row extends Models.Row>(databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number): Promise<Row> { + 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; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } +} diff --git a/src/services/users.ts b/src/services/users.ts index 3805fe1..339a5d0 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -808,6 +808,7 @@ export class Users extends Service { * @param {boolean} mfa * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.updateMFA` instead. */ async updateMfa<Preferences extends Models.Preferences>(userId: string, mfa: boolean): Promise<Models.User<Preferences>> { if (typeof userId === 'undefined') { @@ -834,6 +835,39 @@ export class Users extends Service { 'json' ); } + /** + * Enable or disable MFA on a user account. + * + * @param {string} userId + * @param {boolean} mfa + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateMFA<Preferences extends Models.Preferences>(userId: string, mfa: boolean): Promise<Models.User<Preferences>> { + 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') { + payload['mfa'] = mfa; + } + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Delete an authenticator app. * @@ -841,6 +875,7 @@ export class Users extends Service { * @param {AuthenticatorType} type * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.deleteMFAAuthenticator` instead. */ async deleteMfaAuthenticator(userId: string, type: AuthenticatorType): Promise<Response> { if (typeof userId === 'undefined') { @@ -864,12 +899,43 @@ export class Users extends Service { 'json' ); } + /** + * Delete an authenticator app. + * + * @param {string} userId + * @param {AuthenticatorType} type + * @throws {AppwriteException} + * @returns {Promise} + */ + async deleteMFAAuthenticator(userId: string, type: AuthenticatorType): Promise<Response> { + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "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 = {}; + + return await this.client.call( + 'delete', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * List the factors available on the account to be used as a MFA challange. * * @param {string} userId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.listMFAFactors` instead. */ async listMfaFactors(userId: string): Promise<Models.MfaFactors> { if (typeof userId === 'undefined') { @@ -888,6 +954,30 @@ export class Users extends Service { 'json' ); } + /** + * List the factors available on the account to be used as a MFA challange. + * + * @param {string} userId + * @throws {AppwriteException} + * @returns {Promise} + */ + async listMFAFactors(userId: string): Promise<Models.MfaFactors> { + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', userId); + const payload: Payload = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } /** * Get recovery codes that can be used as backup for MFA flow by User ID. * Before getting codes, they must be generated using @@ -897,6 +987,7 @@ export class Users extends Service { * @param {string} userId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.getMFARecoveryCodes` instead. */ async getMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> { if (typeof userId === 'undefined') { @@ -915,6 +1006,33 @@ export class Users extends Service { 'json' ); } + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async getMFARecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> { + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + + return await this.client.call( + 'get', + apiPath, + { + }, + payload, + 'json' + ); + } /** * Regenerate recovery codes that can be used as backup for MFA flow by User * ID. Before regenerating codes, they must be first generated using @@ -924,6 +1042,7 @@ export class Users extends Service { * @param {string} userId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.updateMFARecoveryCodes` instead. */ async updateMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> { if (typeof userId === 'undefined') { @@ -943,6 +1062,34 @@ export class Users extends Service { 'json' ); } + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async updateMFARecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> { + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + + return await this.client.call( + 'put', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Generate recovery codes used as backup for MFA flow for User ID. Recovery * codes can be used as a MFA verification type in @@ -952,6 +1099,7 @@ export class Users extends Service { * @param {string} userId * @throws {AppwriteException} * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.createMFARecoveryCodes` instead. */ async createMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> { if (typeof userId === 'undefined') { @@ -971,6 +1119,34 @@ export class Users extends Service { 'json' ); } + /** + * 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 + * @throws {AppwriteException} + * @returns {Promise} + */ + async createMFARecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> { + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + + return await this.client.call( + 'patch', + apiPath, + { + 'content-type': 'application/json', + }, + payload, + 'json' + ); + } /** * Update the user name by its unique ID. * diff --git a/test/query.test.ts b/test/query.test.ts index d1fac7f..823078b 100644 --- a/test/query.test.ts +++ b/test/query.test.ts @@ -172,4 +172,59 @@ describe('Query', () => { Query.offset(1).toString(), `{"method":"offset","values":[1]}`, )); + + test('notContains', () => assertEquals( + Query.notContains('attr', 'value').toString(), + `{"method":"notContains","attribute":"attr","values":["value"]}`, + )); + + test('notSearch', () => assertEquals( + Query.notSearch('attr', 'keyword1 keyword2').toString(), + '{"method":"notSearch","attribute":"attr","values":["keyword1 keyword2"]}', + )); + + describe('notBetween', () => { + test('with integers', () => assertEquals( + Query.notBetween('attr', 1, 2).toString(), + `{"method":"notBetween","attribute":"attr","values":[1,2]}`, + )); + test('with doubles', () => assertEquals( + Query.notBetween('attr', 1.2, 2.2).toString(), + `{"method":"notBetween","attribute":"attr","values":[1.2,2.2]}`, + )); + test('with strings', () => assertEquals( + Query.notBetween('attr', "a", "z").toString(), + `{"method":"notBetween","attribute":"attr","values":["a","z"]}`, + )); + }); + + test('notStartsWith', () => assertEquals( + Query.notStartsWith('attr', 'prefix').toString(), + `{"method":"notStartsWith","attribute":"attr","values":["prefix"]}`, + )); + + test('notEndsWith', () => assertEquals( + Query.notEndsWith('attr', 'suffix').toString(), + `{"method":"notEndsWith","attribute":"attr","values":["suffix"]}`, + )); + + test('createdBefore', () => assertEquals( + Query.createdBefore('2023-01-01').toString(), + `{"method":"createdBefore","values":["2023-01-01"]}`, + )); + + test('createdAfter', () => assertEquals( + Query.createdAfter('2023-01-01').toString(), + `{"method":"createdAfter","values":["2023-01-01"]}`, + )); + + test('updatedBefore', () => assertEquals( + Query.updatedBefore('2023-01-01').toString(), + `{"method":"updatedBefore","values":["2023-01-01"]}`, + )); + + test('updatedAfter', () => assertEquals( + Query.updatedAfter('2023-01-01').toString(), + `{"method":"updatedAfter","values":["2023-01-01"]}`, + )); }) diff --git a/test/services/account.test.ts b/test/services/account.test.ts index f558689..a6df744 100644 --- a/test/services/account.test.ts +++ b/test/services/account.test.ts @@ -209,6 +209,22 @@ describe('Account service', () => { }); + test('test method createMFAAuthenticator()', async () => { + const data = { + 'secret': '1', + 'uri': '1',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await account.createMFAAuthenticator( + 'totp', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateMfaAuthenticator()', async () => { const data = { '\$id': '5e5ea5c16897e', @@ -240,6 +256,37 @@ describe('Account service', () => { }); + test('test method updateMFAAuthenticator()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await account.updateMFAAuthenticator( + 'totp', + '<OTP>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method deleteMfaAuthenticator()', async () => { const data = ''; @@ -255,6 +302,21 @@ describe('Account service', () => { }); + test('test method deleteMFAAuthenticator()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await account.deleteMFAAuthenticator( + 'totp', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + test('test method createMfaChallenge()', async () => { const data = { '\$id': 'bb8ea5c16897e', @@ -273,6 +335,24 @@ describe('Account service', () => { }); + test('test method createMFAChallenge()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await account.createMFAChallenge( + 'email', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateMfaChallenge()', async () => { const data = { '\$id': '5e5ea5c16897e', @@ -317,6 +397,50 @@ describe('Account service', () => { }); + test('test method updateMFAChallenge()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await account.updateMFAChallenge( + '<CHALLENGE_ID>', + '<OTP>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method listMfaFactors()', async () => { const data = { 'totp': true, @@ -334,6 +458,23 @@ describe('Account service', () => { }); + test('test method listMFAFactors()', async () => { + const data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await account.listMFAFactors( + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method getMfaRecoveryCodes()', async () => { const data = { 'recoveryCodes': [],}; @@ -348,6 +489,20 @@ describe('Account service', () => { }); + test('test method getMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await account.getMFARecoveryCodes( + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method createMfaRecoveryCodes()', async () => { const data = { 'recoveryCodes': [],}; @@ -362,6 +517,20 @@ describe('Account service', () => { }); + test('test method createMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await account.createMFARecoveryCodes( + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateMfaRecoveryCodes()', async () => { const data = { 'recoveryCodes': [],}; @@ -376,6 +545,20 @@ describe('Account service', () => { }); + test('test method updateMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await account.updateMFARecoveryCodes( + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateName()', async () => { const data = { '\$id': '5e5ea5c16897e', diff --git a/test/services/databases.test.ts b/test/services/databases.test.ts index a2d03e0..2826d66 100644 --- a/test/services/databases.test.ts +++ b/test/services/databases.test.ts @@ -33,7 +33,8 @@ describe('Databases service', () => { 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true,}; + 'enabled': true, + 'type': 'legacy',}; const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); @@ -53,7 +54,8 @@ describe('Databases service', () => { 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true,}; + 'enabled': true, + 'type': 'legacy',}; const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); @@ -72,7 +74,8 @@ describe('Databases service', () => { 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true,}; + 'enabled': true, + 'type': 'legacy',}; const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); @@ -1043,14 +1046,15 @@ describe('Databases service', () => { test('test method createIndex()', async () => { const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'key': 'index1', 'type': 'primary', 'status': 'available', 'error': 'string', 'attributes': [], - 'lengths': [], - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + 'lengths': [],}; const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); @@ -1069,14 +1073,15 @@ describe('Databases service', () => { test('test method getIndex()', async () => { const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'key': 'index1', 'type': 'primary', 'status': 'available', 'error': 'string', 'attributes': [], - 'lengths': [], - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + 'lengths': [],}; const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); diff --git a/test/services/functions.test.ts b/test/services/functions.test.ts index cd16ee0..edce7f2 100644 --- a/test/services/functions.test.ts +++ b/test/services/functions.test.ts @@ -572,6 +572,7 @@ describe('Functions service', () => { '\$updatedAt': '2020-10-15T06:38:00.000+00:00', '\$permissions': [], 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', 'trigger': 'http', 'status': 'processing', 'requestMethod': 'GET', @@ -602,6 +603,7 @@ describe('Functions service', () => { '\$updatedAt': '2020-10-15T06:38:00.000+00:00', '\$permissions': [], 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', 'trigger': 'http', 'status': 'processing', 'requestMethod': 'GET', diff --git a/test/services/messaging.test.ts b/test/services/messaging.test.ts index 0631ffd..f427559 100644 --- a/test/services/messaging.test.ts +++ b/test/services/messaging.test.ts @@ -150,6 +150,31 @@ describe('Messaging service', () => { }); + test('test method createSMS()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await messaging.createSMS( + '<MESSAGE_ID>', + '<CONTENT>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateSms()', async () => { const data = { '\$id': '5e5ea5c16897e', @@ -174,6 +199,30 @@ describe('Messaging service', () => { }); + test('test method updateSMS()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await messaging.updateSMS( + '<MESSAGE_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method getMessage()', async () => { const data = { '\$id': '5e5ea5c16897e', @@ -283,6 +332,29 @@ describe('Messaging service', () => { }); + test('test method createAPNSProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await messaging.createAPNSProvider( + '<PROVIDER_ID>', + '<NAME>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateApnsProvider()', async () => { const data = { '\$id': '5e5ea5c16897e', @@ -305,6 +377,28 @@ describe('Messaging service', () => { }); + test('test method updateAPNSProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await messaging.updateAPNSProvider( + '<PROVIDER_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method createFcmProvider()', async () => { const data = { '\$id': '5e5ea5c16897e', @@ -328,6 +422,29 @@ describe('Messaging service', () => { }); + test('test method createFCMProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await messaging.createFCMProvider( + '<PROVIDER_ID>', + '<NAME>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateFcmProvider()', async () => { const data = { '\$id': '5e5ea5c16897e', @@ -350,6 +467,28 @@ describe('Messaging service', () => { }); + test('test method updateFCMProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await messaging.updateFCMProvider( + '<PROVIDER_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method createMailgunProvider()', async () => { const data = { '\$id': '5e5ea5c16897e', @@ -509,6 +648,30 @@ describe('Messaging service', () => { }); + test('test method createSMTPProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await messaging.createSMTPProvider( + '<PROVIDER_ID>', + '<NAME>', + '<HOST>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateSmtpProvider()', async () => { const data = { '\$id': '5e5ea5c16897e', @@ -531,6 +694,28 @@ describe('Messaging service', () => { }); + test('test method updateSMTPProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await messaging.updateSMTPProvider( + '<PROVIDER_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method createTelesignProvider()', async () => { const data = { '\$id': '5e5ea5c16897e', diff --git a/test/services/sites.test.ts b/test/services/sites.test.ts index 1dd1116..a1c1a8c 100644 --- a/test/services/sites.test.ts +++ b/test/services/sites.test.ts @@ -578,6 +578,7 @@ describe('Sites service', () => { '\$updatedAt': '2020-10-15T06:38:00.000+00:00', '\$permissions': [], 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', 'trigger': 'http', 'status': 'processing', 'requestMethod': 'GET', diff --git a/test/services/tables-db.test.ts b/test/services/tables-db.test.ts new file mode 100644 index 0000000..25f7054 --- /dev/null +++ b/test/services/tables-db.test.ts @@ -0,0 +1,1114 @@ +import {afterEach, describe, it as test} from "https://deno.land/std@0.204.0/testing/bdd.ts"; +import {restore, stub} from "https://deno.land/std@0.204.0/testing/mock.ts"; +import {assertEquals} from "https://deno.land/std@0.204.0/assert/assert_equals.ts"; +import { TablesDB } from "../../src/services/tablesDB.ts"; +import {Client} from "../../src/client.ts"; +import {InputFile} from "../../src/inputFile.ts" + +describe('TablesDB service', () => { + const client = new Client(); + const tablesDB = new TablesDB(client); + + afterEach(() => restore()) + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'databases': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.list( + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.create( + '<DATABASE_ID>', + '<NAME>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.get( + '<DATABASE_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method update()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.update( + '<DATABASE_ID>', + '<NAME>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method delete()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tablesDB.delete( + '<DATABASE_ID>', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method listTables()', async () => { + const data = { + 'total': 5, + 'tables': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.listTables( + '<DATABASE_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createTable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createTable( + '<DATABASE_ID>', + '<TABLE_ID>', + '<NAME>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method getTable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.getTable( + '<DATABASE_ID>', + '<TABLE_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateTable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateTable( + '<DATABASE_ID>', + '<TABLE_ID>', + '<NAME>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method deleteTable()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tablesDB.deleteTable( + '<DATABASE_ID>', + '<TABLE_ID>', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method listColumns()', async () => { + const data = { + 'total': 5, + 'columns': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.listColumns( + '<DATABASE_ID>', + '<TABLE_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createBooleanColumn()', async () => { + const data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createBooleanColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateBooleanColumn()', async () => { + const data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateBooleanColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createDatetimeColumn()', async () => { + const data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'datetime',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createDatetimeColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateDatetimeColumn()', async () => { + const data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'datetime',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateDatetimeColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createEmailColumn()', async () => { + const data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'email',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createEmailColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateEmailColumn()', async () => { + const data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'email',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateEmailColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + 'email@example.com', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createEnumColumn()', async () => { + const data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'elements': [], + 'format': 'enum',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createEnumColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + [], + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateEnumColumn()', async () => { + const data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'elements': [], + 'format': 'enum',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateEnumColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + [], + true, + '<DEFAULT>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createFloatColumn()', async () => { + const data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createFloatColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateFloatColumn()', async () => { + const data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateFloatColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + 1.0, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createIntegerColumn()', async () => { + const data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createIntegerColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateIntegerColumn()', async () => { + const data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateIntegerColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + 1, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createIpColumn()', async () => { + const data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'ip',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createIpColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateIpColumn()', async () => { + const data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'ip',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateIpColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createRelationshipColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'relatedTable': 'table', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createRelationshipColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '<RELATED_TABLE_ID>', + 'oneToOne', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createStringColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createStringColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + 1, + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateStringColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateStringColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + '<DEFAULT>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createUrlColumn()', async () => { + const data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'url',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createUrlColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateUrlColumn()', async () => { + const data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'url',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateUrlColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + true, + 'https://example.com', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method getColumn()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tablesDB.getColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method deleteColumn()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tablesDB.deleteColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method updateRelationshipColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'relatedTable': 'table', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateRelationshipColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method listIndexes()', async () => { + const data = { + 'total': 5, + 'indexes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.listIndexes( + '<DATABASE_ID>', + '<TABLE_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createIndex()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'columns': [], + 'lengths': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createIndex( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + 'key', + [], + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method getIndex()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'columns': [], + 'lengths': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.getIndex( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method deleteIndex()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tablesDB.deleteIndex( + '<DATABASE_ID>', + '<TABLE_ID>', + '', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method listRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.listRows( + '<DATABASE_ID>', + '<TABLE_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createRow( + '<DATABASE_ID>', + '<TABLE_ID>', + '<ROW_ID>', + {}, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method createRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.createRows( + '<DATABASE_ID>', + '<TABLE_ID>', + [], + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method upsertRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.upsertRows( + '<DATABASE_ID>', + '<TABLE_ID>', + [], + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateRows( + '<DATABASE_ID>', + '<TABLE_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method deleteRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.deleteRows( + '<DATABASE_ID>', + '<TABLE_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method getRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.getRow( + '<DATABASE_ID>', + '<TABLE_ID>', + '<ROW_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method upsertRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.upsertRow( + '<DATABASE_ID>', + '<TABLE_ID>', + '<ROW_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method updateRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.updateRow( + '<DATABASE_ID>', + '<TABLE_ID>', + '<ROW_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method deleteRow()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await tablesDB.deleteRow( + '<DATABASE_ID>', + '<TABLE_ID>', + '<ROW_ID>', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + + test('test method decrementRowColumn()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.decrementRowColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '<ROW_ID>', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + + test('test method incrementRowColumn()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': 1, + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await tablesDB.incrementRowColumn( + '<DATABASE_ID>', + '<TABLE_ID>', + '<ROW_ID>', + '', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + }) diff --git a/test/services/users.test.ts b/test/services/users.test.ts index 374732e..f5e0de6 100644 --- a/test/services/users.test.ts +++ b/test/services/users.test.ts @@ -504,6 +504,37 @@ describe('Users service', () => { }); + test('test method updateMFA()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await users.updateMFA( + '<USER_ID>', + true, + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method deleteMfaAuthenticator()', async () => { const data = ''; @@ -520,6 +551,22 @@ describe('Users service', () => { }); + test('test method deleteMFAAuthenticator()', async () => { + const data = ''; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(new Response(data))) + + const response = await users.deleteMFAAuthenticator( + '<USER_ID>', + 'totp', + ); + + const text = await response.text(); + assertEquals(text, data); + stubbedFetch.restore(); + }); + + test('test method listMfaFactors()', async () => { const data = { 'totp': true, @@ -538,6 +585,24 @@ describe('Users service', () => { }); + test('test method listMFAFactors()', async () => { + const data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await users.listMFAFactors( + '<USER_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method getMfaRecoveryCodes()', async () => { const data = { 'recoveryCodes': [],}; @@ -553,6 +618,21 @@ describe('Users service', () => { }); + test('test method getMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await users.getMFARecoveryCodes( + '<USER_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateMfaRecoveryCodes()', async () => { const data = { 'recoveryCodes': [],}; @@ -568,6 +648,21 @@ describe('Users service', () => { }); + test('test method updateMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await users.updateMFARecoveryCodes( + '<USER_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method createMfaRecoveryCodes()', async () => { const data = { 'recoveryCodes': [],}; @@ -583,6 +678,21 @@ describe('Users service', () => { }); + test('test method createMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + + const stubbedFetch = stub(globalThis, 'fetch', () => Promise.resolve(Response.json(data))); + + const response = await users.createMFARecoveryCodes( + '<USER_ID>', + ); + + assertEquals(response, data); + stubbedFetch.restore(); + }); + + test('test method updateName()', async () => { const data = { '\$id': '5e5ea5c16897e',