diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 48121d67..9f7045da 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Use Node.js - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: '24.14.1' registry-url: 'https://registry.npmjs.org' diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b9de72a..fc358534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## 27.1.0 + +* Added: `Apps` service for managing OAuth2 applications, keys, and installations +* Added: `OAuth2` service with authorize, grant, device authorization, and consent flows +* Added: account OAuth2 consent methods `listConsents`, `getConsent`, `deleteConsent`, and consent token methods +* Added: app installation management methods to `Organization` and `Teams` services +* Added: `installationAccessTokenDuration` parameter to `project.updateOAuth2Server` +* Added: `token` parameter to `sites.getDeploymentDownload` +* Added: `oauth2.introspect` and organization installation key scopes + ## 27.0.0 * Breaking: removed `Health` service, health enums, and health response models diff --git a/docs/examples/account/delete-consent-token.md b/docs/examples/account/delete-consent-token.md new file mode 100644 index 00000000..3b45b092 --- /dev/null +++ b/docs/examples/account/delete-consent-token.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.deleteConsentToken({ + consentId: '', + tokenId: '' +}); +``` diff --git a/docs/examples/account/delete-consent.md b/docs/examples/account/delete-consent.md new file mode 100644 index 00000000..eb93abad --- /dev/null +++ b/docs/examples/account/delete-consent.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.deleteConsent({ + consentId: '' +}); +``` diff --git a/docs/examples/account/get-consent-token.md b/docs/examples/account/get-consent-token.md new file mode 100644 index 00000000..3ae6c1ea --- /dev/null +++ b/docs/examples/account/get-consent-token.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.getConsentToken({ + consentId: '', + tokenId: '' +}); +``` diff --git a/docs/examples/account/get-consent.md b/docs/examples/account/get-consent.md new file mode 100644 index 00000000..fc7cb6c7 --- /dev/null +++ b/docs/examples/account/get-consent.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.getConsent({ + consentId: '' +}); +``` diff --git a/docs/examples/account/list-consent-tokens.md b/docs/examples/account/list-consent-tokens.md new file mode 100644 index 00000000..d271066f --- /dev/null +++ b/docs/examples/account/list-consent-tokens.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.listConsentTokens({ + consentId: '', + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/account/list-consents.md b/docs/examples/account/list-consents.md new file mode 100644 index 00000000..12ec54ef --- /dev/null +++ b/docs/examples/account/list-consents.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.listConsents({ + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/apps/create-installation-token.md b/docs/examples/apps/create-installation-token.md new file mode 100644 index 00000000..f60d495b --- /dev/null +++ b/docs/examples/apps/create-installation-token.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const apps = new sdk.Apps(client); + +const result = await apps.createInstallationToken({ + appId: '', + installationId: '' +}); +``` diff --git a/docs/examples/apps/create-key.md b/docs/examples/apps/create-key.md new file mode 100644 index 00000000..0b358162 --- /dev/null +++ b/docs/examples/apps/create-key.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.createKey({ + appId: '' +}); +``` diff --git a/docs/examples/apps/create-secret.md b/docs/examples/apps/create-secret.md new file mode 100644 index 00000000..1f851041 --- /dev/null +++ b/docs/examples/apps/create-secret.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.createSecret({ + appId: '' +}); +``` diff --git a/docs/examples/apps/create.md b/docs/examples/apps/create.md new file mode 100644 index 00000000..80339c51 --- /dev/null +++ b/docs/examples/apps/create.md @@ -0,0 +1,32 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.create({ + appId: '', + name: '', + redirectUris: [], + description: '', // optional + clientUri: 'https://example.com', // optional + logoUri: 'https://example.com', // optional + privacyPolicyUrl: 'https://example.com', // optional + termsUrl: 'https://example.com', // optional + contacts: [], // optional + tagline: '', // optional + tags: [], // optional + images: [], // optional + supportUrl: 'https://example.com', // optional + dataDeletionUrl: 'https://example.com', // optional + postLogoutRedirectUris: [], // optional + enabled: false, // optional + type: 'public', // optional + deviceFlow: false, // optional + teamId: '' // optional +}); +``` diff --git a/docs/examples/apps/delete-key.md b/docs/examples/apps/delete-key.md new file mode 100644 index 00000000..f4f0bb5e --- /dev/null +++ b/docs/examples/apps/delete-key.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.deleteKey({ + appId: '', + keyId: '' +}); +``` diff --git a/docs/examples/apps/delete-secret.md b/docs/examples/apps/delete-secret.md new file mode 100644 index 00000000..eeb1e439 --- /dev/null +++ b/docs/examples/apps/delete-secret.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.deleteSecret({ + appId: '', + secretId: '' +}); +``` diff --git a/docs/examples/apps/delete-tokens.md b/docs/examples/apps/delete-tokens.md new file mode 100644 index 00000000..757af7d4 --- /dev/null +++ b/docs/examples/apps/delete-tokens.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.deleteTokens({ + appId: '' +}); +``` diff --git a/docs/examples/apps/delete.md b/docs/examples/apps/delete.md new file mode 100644 index 00000000..fd9138cd --- /dev/null +++ b/docs/examples/apps/delete.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.delete({ + appId: '' +}); +``` diff --git a/docs/examples/apps/get-installation.md b/docs/examples/apps/get-installation.md new file mode 100644 index 00000000..eb483b23 --- /dev/null +++ b/docs/examples/apps/get-installation.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const apps = new sdk.Apps(client); + +const result = await apps.getInstallation({ + appId: '', + installationId: '' +}); +``` diff --git a/docs/examples/apps/get-key.md b/docs/examples/apps/get-key.md new file mode 100644 index 00000000..afc83ccc --- /dev/null +++ b/docs/examples/apps/get-key.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.getKey({ + appId: '', + keyId: '' +}); +``` diff --git a/docs/examples/apps/get-secret.md b/docs/examples/apps/get-secret.md new file mode 100644 index 00000000..4d6a0ec0 --- /dev/null +++ b/docs/examples/apps/get-secret.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.getSecret({ + appId: '', + secretId: '' +}); +``` diff --git a/docs/examples/apps/get.md b/docs/examples/apps/get.md new file mode 100644 index 00000000..660c4f42 --- /dev/null +++ b/docs/examples/apps/get.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.get({ + appId: '' +}); +``` diff --git a/docs/examples/apps/list-installation-scopes.md b/docs/examples/apps/list-installation-scopes.md new file mode 100644 index 00000000..299d7b70 --- /dev/null +++ b/docs/examples/apps/list-installation-scopes.md @@ -0,0 +1,12 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.listInstallationScopes(); +``` diff --git a/docs/examples/apps/list-installations.md b/docs/examples/apps/list-installations.md new file mode 100644 index 00000000..e410f666 --- /dev/null +++ b/docs/examples/apps/list-installations.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const apps = new sdk.Apps(client); + +const result = await apps.listInstallations({ + appId: '', + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/apps/list-keys.md b/docs/examples/apps/list-keys.md new file mode 100644 index 00000000..3a2198fd --- /dev/null +++ b/docs/examples/apps/list-keys.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.listKeys({ + appId: '', + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/apps/list-o-auth-2-scopes.md b/docs/examples/apps/list-o-auth-2-scopes.md new file mode 100644 index 00000000..6f925395 --- /dev/null +++ b/docs/examples/apps/list-o-auth-2-scopes.md @@ -0,0 +1,12 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.listOAuth2Scopes(); +``` diff --git a/docs/examples/apps/list-secrets.md b/docs/examples/apps/list-secrets.md new file mode 100644 index 00000000..d1155a5d --- /dev/null +++ b/docs/examples/apps/list-secrets.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.listSecrets({ + appId: '', + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/apps/list.md b/docs/examples/apps/list.md new file mode 100644 index 00000000..d5942933 --- /dev/null +++ b/docs/examples/apps/list.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.list({ + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/apps/update-labels.md b/docs/examples/apps/update-labels.md new file mode 100644 index 00000000..67a98fc7 --- /dev/null +++ b/docs/examples/apps/update-labels.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const apps = new sdk.Apps(client); + +const result = await apps.updateLabels({ + appId: '', + labels: [] +}); +``` diff --git a/docs/examples/apps/update-team.md b/docs/examples/apps/update-team.md new file mode 100644 index 00000000..65828dce --- /dev/null +++ b/docs/examples/apps/update-team.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.updateTeam({ + appId: '', + teamId: '' +}); +``` diff --git a/docs/examples/apps/update.md b/docs/examples/apps/update.md new file mode 100644 index 00000000..2ac2e585 --- /dev/null +++ b/docs/examples/apps/update.md @@ -0,0 +1,33 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const apps = new sdk.Apps(client); + +const result = await apps.update({ + appId: '', + name: '', + description: '', // optional + clientUri: 'https://example.com', // optional + logoUri: 'https://example.com', // optional + privacyPolicyUrl: 'https://example.com', // optional + termsUrl: 'https://example.com', // optional + contacts: [], // optional + tagline: '', // optional + tags: [], // optional + images: [], // optional + supportUrl: 'https://example.com', // optional + dataDeletionUrl: 'https://example.com', // optional + enabled: false, // optional + redirectUris: [], // optional + postLogoutRedirectUris: [], // optional + type: 'public', // optional + deviceFlow: false, // optional + installationScopes: [], // optional + installationRedirectUrl: 'https://example.com' // optional +}); +``` diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md index 6a8096ac..f41a2344 100644 --- a/docs/examples/backups/create-restoration.md +++ b/docs/examples/backups/create-restoration.md @@ -12,7 +12,6 @@ const result = await backups.createRestoration({ archiveId: '', services: [sdk.BackupServices.Databases], newResourceId: '', // optional - newResourceName: '', // optional - newSpecification: 'serverless' // optional + newResourceName: '' // optional }); ``` diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md new file mode 100644 index 00000000..64f473bc --- /dev/null +++ b/docs/examples/oauth2/approve.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.approve({ + grantId: '', + authorizationDetails: '', // optional + scope: '' // optional +}); +``` diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md new file mode 100644 index 00000000..9d9317e9 --- /dev/null +++ b/docs/examples/oauth2/authorize-post.md @@ -0,0 +1,27 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.authorizePost({ + clientId: '', // optional + redirectUri: 'https://example.com', // optional + responseType: '', // optional + scope: '', // optional + state: '', // optional + nonce: '', // optional + codeChallenge: '', // optional + codeChallengeMethod: 's256', // optional + prompt: '', // optional + maxAge: 0, // optional + authorizationDetails: '', // optional + resource: '', // optional + audience: '', // optional + requestUri: '' // optional +}); +``` diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md new file mode 100644 index 00000000..10b6f612 --- /dev/null +++ b/docs/examples/oauth2/authorize.md @@ -0,0 +1,27 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.authorize({ + clientId: '', // optional + redirectUri: 'https://example.com', // optional + responseType: '', // optional + scope: '', // optional + state: '', // optional + nonce: '', // optional + codeChallenge: '', // optional + codeChallengeMethod: 's256', // optional + prompt: '', // optional + maxAge: 0, // optional + authorizationDetails: '', // optional + resource: '', // optional + audience: '', // optional + requestUri: '' // optional +}); +``` diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md new file mode 100644 index 00000000..19710c71 --- /dev/null +++ b/docs/examples/oauth2/create-device-authorization.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.createDeviceAuthorization({ + clientId: '', // optional + scope: '', // optional + authorizationDetails: '', // optional + resource: '', // optional + audience: '' // optional +}); +``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md new file mode 100644 index 00000000..0f644eef --- /dev/null +++ b/docs/examples/oauth2/create-grant.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.createGrant({ + userCode: '' +}); +``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md new file mode 100644 index 00000000..70623e93 --- /dev/null +++ b/docs/examples/oauth2/create-par.md @@ -0,0 +1,26 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.createPAR({ + clientId: '', + redirectUri: 'https://example.com', + responseType: 'code', + scope: '', // optional + state: '', // optional + nonce: '', // optional + codeChallenge: '', // optional + codeChallengeMethod: 's256', // optional + prompt: '', // optional + maxAge: 0, // optional + authorizationDetails: '', // optional + resource: '', // optional + audience: '' // optional +}); +``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md new file mode 100644 index 00000000..e27883d7 --- /dev/null +++ b/docs/examples/oauth2/create-token.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.createToken({ + grantType: '', + code: '', // optional + refreshToken: '', // optional + deviceCode: '', // optional + clientId: '', // optional + clientSecret: '', // optional + codeVerifier: '', // optional + redirectUri: 'https://example.com', // optional + resource: '', // optional + audience: '' // optional +}); +``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md new file mode 100644 index 00000000..b6198128 --- /dev/null +++ b/docs/examples/oauth2/get-grant.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.getGrant({ + grantId: '' +}); +``` diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md new file mode 100644 index 00000000..b9503c21 --- /dev/null +++ b/docs/examples/oauth2/list-organizations.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.listOrganizations({ + limit: 1, // optional + offset: 0, // optional + search: '' // optional +}); +``` diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md new file mode 100644 index 00000000..95e89e92 --- /dev/null +++ b/docs/examples/oauth2/list-projects.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.listProjects({ + limit: 1, // optional + offset: 0, // optional + search: '' // optional +}); +``` diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md new file mode 100644 index 00000000..5e5a8ffb --- /dev/null +++ b/docs/examples/oauth2/reject.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.reject({ + grantId: '' +}); +``` diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md new file mode 100644 index 00000000..e853410a --- /dev/null +++ b/docs/examples/oauth2/revoke.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setProject(''); // Your project ID + +const oauth2 = new sdk.Oauth2(client); + +const result = await oauth2.revoke({ + token: '', + tokenTypeHint: 'access_token', // optional + clientId: '', // optional + clientSecret: '' // optional +}); +``` diff --git a/docs/examples/organization/create-installation.md b/docs/examples/organization/create-installation.md new file mode 100644 index 00000000..56558fd0 --- /dev/null +++ b/docs/examples/organization/create-installation.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const organization = new sdk.Organization(client); + +const result = await organization.createInstallation({ + appId: '', + authorizationDetails: '' // optional +}); +``` diff --git a/docs/examples/organization/delete-installation.md b/docs/examples/organization/delete-installation.md new file mode 100644 index 00000000..afc3be5a --- /dev/null +++ b/docs/examples/organization/delete-installation.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const organization = new sdk.Organization(client); + +const result = await organization.deleteInstallation({ + installationId: '' +}); +``` diff --git a/docs/examples/organization/get-installation.md b/docs/examples/organization/get-installation.md new file mode 100644 index 00000000..e5ed10ee --- /dev/null +++ b/docs/examples/organization/get-installation.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const organization = new sdk.Organization(client); + +const result = await organization.getInstallation({ + installationId: '' +}); +``` diff --git a/docs/examples/organization/list-installations.md b/docs/examples/organization/list-installations.md new file mode 100644 index 00000000..91f6b666 --- /dev/null +++ b/docs/examples/organization/list-installations.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const organization = new sdk.Organization(client); + +const result = await organization.listInstallations({ + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/organization/update-installation.md b/docs/examples/organization/update-installation.md new file mode 100644 index 00000000..59ccac7b --- /dev/null +++ b/docs/examples/organization/update-installation.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const organization = new sdk.Organization(client); + +const result = await organization.updateInstallation({ + installationId: '', + authorizationDetails: '' // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-server.md b/docs/examples/project/update-o-auth-2-server.md index 0cd95aee..a34a5fc6 100644 --- a/docs/examples/project/update-o-auth-2-server.md +++ b/docs/examples/project/update-o-auth-2-server.md @@ -17,6 +17,7 @@ const result = await project.updateOAuth2Server({ refreshTokenDuration: 60, // optional publicAccessTokenDuration: 60, // optional publicRefreshTokenDuration: 60, // optional + installationAccessTokenDuration: 60, // optional confidentialPkce: false, // optional verificationUrl: 'https://example.com', // optional userCodeLength: 6, // optional diff --git a/docs/examples/sites/get-deployment-download.md b/docs/examples/sites/get-deployment-download.md index 6e7ee4aa..1d62d288 100644 --- a/docs/examples/sites/get-deployment-download.md +++ b/docs/examples/sites/get-deployment-download.md @@ -11,6 +11,7 @@ const sites = new sdk.Sites(client); const result = await sites.getDeploymentDownload({ siteId: '', deploymentId: '', - type: sdk.DeploymentDownloadType.Source // optional + type: sdk.DeploymentDownloadType.Source, // optional + token: '' // optional }); ``` diff --git a/docs/examples/tablesdb/create-failover.md b/docs/examples/tablesdb/create-failover.md new file mode 100644 index 00000000..0ad64376 --- /dev/null +++ b/docs/examples/tablesdb/create-failover.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createFailover({ + databaseId: '', + targetReplicaId: '' // optional +}); +``` diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index 280db025..27bf661f 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -12,6 +12,7 @@ const result = await tablesDB.create({ databaseId: '', name: '', enabled: false, // optional - specification: 'serverless' // optional + specification: 'serverless', // optional + replicas: 0 // optional }); ``` diff --git a/docs/examples/tablesdb/get-replicas.md b/docs/examples/tablesdb/get-replicas.md new file mode 100644 index 00000000..ab402963 --- /dev/null +++ b/docs/examples/tablesdb/get-replicas.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.getReplicas({ + databaseId: '' +}); +``` diff --git a/docs/examples/tablesdb/get-status.md b/docs/examples/tablesdb/get-status.md new file mode 100644 index 00000000..3b858219 --- /dev/null +++ b/docs/examples/tablesdb/get-status.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.getStatus({ + databaseId: '' +}); +``` diff --git a/docs/examples/tablesdb/list-specifications.md b/docs/examples/tablesdb/list-specifications.md new file mode 100644 index 00000000..c5e11ea9 --- /dev/null +++ b/docs/examples/tablesdb/list-specifications.md @@ -0,0 +1,12 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.listSpecifications(); +``` diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 7cbf6f58..034eb940 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -11,6 +11,7 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.update({ databaseId: '', name: '', // optional - enabled: false // optional + enabled: false, // optional + replicas: 0 // optional }); ``` diff --git a/docs/examples/teams/create-installation.md b/docs/examples/teams/create-installation.md new file mode 100644 index 00000000..e84f9d89 --- /dev/null +++ b/docs/examples/teams/create-installation.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const teams = new sdk.Teams(client); + +const result = await teams.createInstallation({ + teamId: '', + appId: '', + authorizationDetails: '' // optional +}); +``` diff --git a/docs/examples/teams/delete-installation.md b/docs/examples/teams/delete-installation.md new file mode 100644 index 00000000..d3631290 --- /dev/null +++ b/docs/examples/teams/delete-installation.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const teams = new sdk.Teams(client); + +const result = await teams.deleteInstallation({ + teamId: '', + installationId: '' +}); +``` diff --git a/docs/examples/teams/get-installation.md b/docs/examples/teams/get-installation.md new file mode 100644 index 00000000..47c71f3a --- /dev/null +++ b/docs/examples/teams/get-installation.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const teams = new sdk.Teams(client); + +const result = await teams.getInstallation({ + teamId: '', + installationId: '' +}); +``` diff --git a/docs/examples/teams/list-installations.md b/docs/examples/teams/list-installations.md new file mode 100644 index 00000000..ecd4c420 --- /dev/null +++ b/docs/examples/teams/list-installations.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const teams = new sdk.Teams(client); + +const result = await teams.listInstallations({ + teamId: '', + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/teams/update-installation.md b/docs/examples/teams/update-installation.md new file mode 100644 index 00000000..f62bdfc7 --- /dev/null +++ b/docs/examples/teams/update-installation.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const teams = new sdk.Teams(client); + +const result = await teams.updateInstallation({ + teamId: '', + installationId: '', + authorizationDetails: '' // optional +}); +``` diff --git a/package-lock.json b/package-lock.json index 6a102920..5e4de244 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "27.0.0", + "version": "27.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "27.0.0", + "version": "27.1.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index a791caee..898eb6bd 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "27.0.0", + "version": "27.1.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 960612ed..8051af74 100644 --- a/src/client.ts +++ b/src/client.ts @@ -73,7 +73,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/27.0.0'; + let ua = 'AppwriteNodeJSSDK/27.1.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -129,7 +129,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '27.0.0', + 'x-sdk-version': '27.1.0', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.9.5', }; diff --git a/src/enums/database-status.ts b/src/enums/database-status.ts index 9e9cb51b..8a01e3b7 100644 --- a/src/enums/database-status.ts +++ b/src/enums/database-status.ts @@ -1,5 +1,16 @@ export enum DatabaseStatus { Provisioning = 'provisioning', Ready = 'ready', + Inactive = 'inactive', + Paused = 'paused', Failed = 'failed', + Deleting = 'deleting', + Deleted = 'deleted', + Restoring = 'restoring', + Scaling = 'scaling', + Upgrading = 'upgrading', + Migrating = 'migrating', + Pausing = 'pausing', + Resuming = 'resuming', + Failingover = 'failing-over', } \ No newline at end of file diff --git a/src/enums/database-type.ts b/src/enums/database-type.ts index 8ccd9699..b39f921e 100644 --- a/src/enums/database-type.ts +++ b/src/enums/database-type.ts @@ -3,4 +3,7 @@ export enum DatabaseType { Tablesdb = 'tablesdb', Documentsdb = 'documentsdb', Vectorsdb = 'vectorsdb', + Mysql = 'mysql', + Postgresql = 'postgresql', + Mongodb = 'mongodb', } \ No newline at end of file diff --git a/src/enums/organization-key-scopes.ts b/src/enums/organization-key-scopes.ts index a4ff3fb7..eb18181d 100644 --- a/src/enums/organization-key-scopes.ts +++ b/src/enums/organization-key-scopes.ts @@ -5,6 +5,8 @@ export enum OrganizationKeyScopes { DevKeysWrite = 'devKeys.write', OrganizationKeysRead = 'organization.keys.read', OrganizationKeysWrite = 'organization.keys.write', + OrganizationInstallationsRead = 'organization.installations.read', + OrganizationInstallationsWrite = 'organization.installations.write', OrganizationMembershipsRead = 'organization.memberships.read', OrganizationMembershipsWrite = 'organization.memberships.write', OrganizationRead = 'organization.read', diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index 7f97ba9c..b0ac3cdf 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -94,10 +94,13 @@ export enum ProjectKeyScopes { DedicatedDatabasesExecute = 'dedicatedDatabases.execute', DomainsRead = 'domains.read', DomainsWrite = 'domains.write', + WafRulesRead = 'wafRules.read', + WafRulesWrite = 'wafRules.write', EventsRead = 'events.read', AppsRead = 'apps.read', AppsWrite = 'apps.write', Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', + Oauth2Introspect = 'oauth2.introspect', UsageRead = 'usage.read', } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index efa797e2..0226923d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ export { Client, Query, AppwriteException } from './client'; export { Account } from './services/account'; export { Activities } from './services/activities'; +export { Apps } from './services/apps'; export { Avatars } from './services/avatars'; export { Backups } from './services/backups'; export { Databases } from './services/databases'; @@ -8,6 +9,7 @@ export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Locale } from './services/locale'; export { Messaging } from './services/messaging'; +export { Oauth2 } from './services/oauth-2'; export { Organization } from './services/organization'; export { Presences } from './services/presences'; export { Project } from './services/project'; diff --git a/src/models.ts b/src/models.ts index 5e56cfa7..91002847 100644 --- a/src/models.ts +++ b/src/models.ts @@ -697,17 +697,29 @@ export namespace Models { */ type: DatabaseType; /** - * Database status. Possible values: `provisioning`, `ready` or `failed` + * Dedicated database lifecycle status. Null when the database has no valid dedicated backing. */ status?: DatabaseStatus; + /** + * Underlying engine of the dedicated backing: postgresql, mysql, mariadb, or mongodb. A managed product (tablesdb, documentsdb, vectorsdb) reports the engine it runs on, so its type and engine can differ. Null when the database has no dedicated backing. + */ + engine?: string; + /** + * Compute specification identifier of the dedicated backing, e.g. s-2vcpu-2gb. Null when the database has no dedicated backing. + */ + specification?: string; + /** + * Number of secondary high availability replicas, excluding the primary. Null when backing configuration is unavailable. + */ + replicas?: number; /** * Database backup policies. */ - policies: BackupPolicy[]; + policies?: BackupPolicy[]; /** * Database backup archives. */ - archives: BackupArchive[]; + archives?: BackupArchive[]; } /** @@ -4311,6 +4323,10 @@ export namespace Models { * Last time the project was accessed via console. Used with plan's projectInactivityDays to determine if project is paused. */ consoleAccessedAt: string; + /** + * Whether WAF enforcement is enabled for the project. + */ + wafEnabled: boolean; /** * Billing limits reached */ @@ -4351,6 +4367,10 @@ export namespace Models { * OAuth2 server refresh token duration in seconds for public clients (SPAs, mobile, native) */ oAuth2ServerPublicRefreshTokenDuration?: number; + /** + * OAuth2 server access token duration in seconds for app installation access tokens + */ + oAuth2ServerInstallationAccessTokenDuration?: number; /** * When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. */ @@ -6755,6 +6775,42 @@ export namespace Models { * Location. */ country: string; + /** + * Continent code. + */ + continentCode: string; + /** + * City name. + */ + city: string; + /** + * Region/state chain. + */ + subdivisions: string; + /** + * Internet service provider. + */ + isp: string; + /** + * Autonomous System Number (ASN). + */ + autonomousSystemNumber: string; + /** + * Organization that owns the ASN. + */ + autonomousSystemOrganization: string; + /** + * Connection type (e.g. cable, cellular, corporate). + */ + connectionType: string; + /** + * User type (e.g. residential, business, hosting). + */ + connectionUsageType: string; + /** + * Registered organization of the IP. + */ + connectionOrganization: string; /** * Log creation date in ISO 8601 format. */ @@ -6771,6 +6827,14 @@ export namespace Models { * Hostname. */ hostname: string; + /** + * Name of the SDK that triggered the event. + */ + sdk: string; + /** + * Version of the SDK that triggered the event. + */ + sdkVersion: string; } /** @@ -6947,6 +7011,10 @@ export namespace Models { * Webhooks */ webhooks: number; + /** + * Maximum WAF rules per project + */ + wafRules: number; /** * Projects */ @@ -7389,6 +7457,286 @@ export namespace Models { billingPlan: string; } + /** + * DedicatedDatabase + */ + export type DedicatedDatabase = { + /** + * Dedicated database ID. + */ + $id: string; + /** + * Database creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Database update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Project ID that owns this database. + */ + projectId: string; + /** + * Database display name. + */ + name: string; + /** + * Product API that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. + */ + api: string; + /** + * Database engine: postgresql, mysql, mariadb, or mongodb. + */ + engine: string; + /** + * Database engine version. + */ + version: string; + /** + * Specification identifier. + */ + specification: string; + /** + * Database backend provider. Possible values: prisma, edge. + */ + backend: string; + /** + * Database hostname for connections. + */ + hostname: string; + /** + * Database port for connections. + */ + connectionPort: number; + /** + * Database username for connections. + */ + connectionUser: string; + /** + * Database password for connections. + */ + connectionPassword: string; + /** + * Full database connection string (URI format). + */ + connectionString: string; + /** + * Whether SSL/TLS is required for client connections. + */ + ssl: boolean; + /** + * Database status. Possible values: provisioning, ready, inactive, paused, failed, deleted, restoring, scaling. + */ + status: string; + /** + * Container status for lifecycle-managed database runtimes: active or inactive. + */ + containerStatus: string; + /** + * Last activity timestamp in ISO 8601 format. + */ + lastAccessedAt?: string; + /** + * Display-only timestamp when the database is expected to be considered idle (ISO 8601 format). Derived from last activity; lifecycle transitions are driven by lifecycleState. + */ + idleUntil?: string; + /** + * Idle-lifecycle state of the database. Possible values: active, warm, cold, hibernated. + */ + lifecycleState: string; + /** + * Minutes of inactivity before container scales to zero. + */ + idleTimeoutMinutes: number; + /** + * CPU allocated in millicores. + */ + cpu: number; + /** + * Memory allocated in MB. + */ + memory: number; + /** + * Storage allocated in GB. + */ + storage: number; + /** + * Storage class. Currently always 'ssd'; DigitalOcean exposes a single block-storage class. + */ + storageClass: string; + /** + * Maximum storage allowed in GB. 0 means use system default. + */ + storageMaxGb: number; + /** + * Kubernetes node pool where the database is scheduled. + */ + nodePool: string; + /** + * Number of high availability replicas. High availability is enabled when greater than 0. + */ + replicas: number; + /** + * Replication sync mode: async, sync, or quorum. + */ + syncMode: string; + /** + * Number of cross-region replicas. Cross-region availability is enabled when greater than 0. + */ + crossRegionReplicas: number; + /** + * Maximum concurrent connections. + */ + networkMaxConnections: number; + /** + * Connection idle timeout in seconds. + */ + networkIdleTimeoutSeconds: number; + /** + * IP addresses/CIDR ranges allowed to connect. + */ + networkIPAllowlist: string[]; + /** + * Whether automatic backups are enabled. + */ + backupEnabled: boolean; + /** + * Whether point-in-time recovery is enabled. + */ + pitr: boolean; + /** + * Number of days to retain PITR data. + */ + pitrRetentionDays: number; + /** + * Whether automatic storage expansion is enabled. + */ + storageAutoscaling: boolean; + /** + * Storage usage percentage that triggers automatic expansion. + */ + storageAutoscalingThresholdPercent: number; + /** + * Maximum storage size in GB for autoscaling. 0 means no limit. + */ + storageAutoscalingMaxGb: number; + /** + * Day of the week for the maintenance window. Possible values: sun, mon, tue, wed, thu, fri, sat. + */ + maintenanceWindowDay: string; + /** + * Hour in UTC (0-23) when the maintenance window starts. + */ + maintenanceWindowHourUtc: number; + /** + * Whether metrics collection is enabled. + */ + metricsEnabled: boolean; + /** + * Whether the SQL API sidecar is enabled for this database. + */ + sqlApiEnabled: boolean; + /** + * Statement types accepted by the SQL API. Defaults to read/write DML only; DDL/DCL types (CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE) are opt-in per database. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + */ + sqlApiAllowedStatements: string[]; + /** + * Maximum rows returned per SQL API execution. Results larger than this are truncated. + */ + sqlApiMaxRows: number; + /** + * Maximum serialised SQL API result payload in bytes. Results larger than this are truncated. + */ + sqlApiMaxBytes: number; + /** + * Maximum server-side SQL API execution time in seconds before the query is cancelled. + */ + sqlApiTimeoutSeconds: number; + /** + * Error message if status is failed. + */ + error: string; + } + + /** + * Status + */ + export type DatabaseStatus = { + /** + * Overall health status: healthy, degraded, or unhealthy. + */ + health: string; + /** + * Whether the database is ready to accept connections. + */ + ready: boolean; + /** + * Database engine: postgresql, mysql, mariadb, or mongodb. + */ + engine: string; + /** + * Database engine version. + */ + version: string; + /** + * Database uptime in seconds. + */ + uptime: number; + /** + * Connection statistics. + */ + connections: DatabaseStatusConnections; + /** + * List of database replicas and their status. + */ + replicas: DatabaseStatusReplica[]; + /** + * Storage volume information. + */ + volumes: DatabaseStatusVolume[]; + } + + /** + * Member + */ + export type DedicatedDatabaseMember = { + /** + * Member identifier. + */ + $id: string; + /** + * Member role. Possible values: primary (accepts reads and writes), replica (read-only follower). + */ + role: string; + /** + * Member pod status. Possible values: provisioning (pod missing or Pending), starting (Running but not Ready), active (Running and Ready), failed (Failed phase or CrashLoopBackOff container), or the lowercased pod phase reported by the cluster. + */ + status: string; + /** + * Replication lag in seconds. + */ + lagSeconds: number; + } + + /** + * Replicas + */ + export type DedicatedDatabaseReplicas = { + /** + * Number of configured replicas. Zero means high availability is disabled. + */ + replicas: number; + /** + * Replication sync mode. Possible values: async (asynchronous, fastest), sync (synchronous, strong consistency), quorum (quorum-based, majority of replicas must confirm). + */ + syncMode: string; + /** + * Per-pod statuses for the primary and every replica. + */ + members: DedicatedDatabaseMember[]; + } + /** * Organization */ @@ -7738,99 +8086,897 @@ export namespace Models { } /** - * usageBillingPlan + * Specification */ - export type UsageBillingPlan = { - /** - * Bandwidth additional resources - */ - bandwidth: AdditionalResource; - /** - * Executions additional resources - */ - executions: AdditionalResource; + export type DedicatedDatabaseSpecification = { /** - * Member additional resources + * Specification slug. Use this value when creating a dedicated database. */ - member: AdditionalResource; + slug: string; /** - * Realtime additional resources + * Human readable specification name. */ - realtime: AdditionalResource; + name: string; /** - * Realtime messages additional resources + * Monthly price of the specification in USD. */ - realtimeMessages: AdditionalResource; + price: number; /** - * Realtime bandwidth additional resources + * Allocated CPU in millicores. */ - realtimeBandwidth: AdditionalResource; + cpu: number; /** - * Storage additional resources + * Allocated memory in MB. */ - storage: AdditionalResource; + memory: number; /** - * User additional resources + * Maximum number of concurrent connections. */ - users: AdditionalResource; + maxConnections: number; /** - * GBHour additional resources + * Included storage in GB before overage charges apply. */ - GBHours: AdditionalResource; + includedStorage: number; /** - * Image transformation additional resources + * Included bandwidth in GB before overage charges apply. */ - imageTransformations: AdditionalResource; + includedBandwidth: number; /** - * Credits additional resources + * Whether the specification is available on the current plan. */ - credits: AdditionalResource; + enabled: boolean; } /** - * Activity event list + * SpecificationList */ - export type ActivityEventList = { + export type DedicatedDatabaseSpecificationList = { /** - * Total number of events that matched your query. + * List of dedicated database specifications. + */ + specifications: DedicatedDatabaseSpecification[]; + /** + * Total number of specifications. */ total: number; /** - * List of events. + * Overage and add-on pricing shared across all specifications. */ - events: ActivityEvent[]; + pricing: DedicatedDatabaseSpecificationPricing; } /** - * Backup archive list + * SpecificationPricing */ - export type BackupArchiveList = { + export type DedicatedDatabaseSpecificationPricing = { /** - * Total number of archives that matched your query. + * Price per GB of storage above the included amount, per month, in USD. */ - total: number; + storageOverageRate: number; /** - * List of archives. + * Price per GB of bandwidth above the included amount, per month, in USD. */ - archives: BackupArchive[]; + bandwidthOverageRate: number; + /** + * High availability replica price as a fraction of the specification cost. + */ + replicaRate: number; + /** + * Cross-region replica price as a fraction of the specification cost. + */ + crossRegionReplicaRate: number; + /** + * Point-in-time recovery price as a fraction of the specification cost. + */ + pitrRate: number; } /** - * Backup policy list + * Connections */ - export type BackupPolicyList = { + export type DatabaseStatusConnections = { /** - * Total number of policies that matched your query. + * Current number of active connections. */ - total: number; + current: number; /** - * List of policies. + * Maximum allowed connections. */ - policies: BackupPolicy[]; + max: number; } /** - * Backup restoration list + * Replica + */ + export type DatabaseStatusReplica = { + /** + * StatefulSet pod index (0 = primary, 1+ = replicas). + */ + index: number; + /** + * Replica role: primary or replica. + */ + role: string; + /** + * Whether the replica is healthy. + */ + healthy: boolean; + /** + * Replication lag in seconds (null for primary). + */ + lagSeconds?: number; + } + + /** + * Volume + */ + export type DatabaseStatusVolume = { + /** + * Mount path of the volume. + */ + path: string; + /** + * Percentage of storage used. + */ + usedPercent: string; + /** + * Available storage space. + */ + available: string; + /** + * Whether the volume is mounted. + */ + mounted: boolean; + } + + /** + * usageBillingPlan + */ + export type UsageBillingPlan = { + /** + * Bandwidth additional resources + */ + bandwidth: AdditionalResource; + /** + * Executions additional resources + */ + executions: AdditionalResource; + /** + * Member additional resources + */ + member: AdditionalResource; + /** + * Realtime additional resources + */ + realtime: AdditionalResource; + /** + * Realtime messages additional resources + */ + realtimeMessages: AdditionalResource; + /** + * Realtime bandwidth additional resources + */ + realtimeBandwidth: AdditionalResource; + /** + * Storage additional resources + */ + storage: AdditionalResource; + /** + * User additional resources + */ + users: AdditionalResource; + /** + * GBHour additional resources + */ + GBHours: AdditionalResource; + /** + * Image transformation additional resources + */ + imageTransformations: AdditionalResource; + /** + * Credits additional resources + */ + credits: AdditionalResource; + } + + /** + * App + */ + export type App = { + /** + * App ID. + */ + $id: string; + /** + * App creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * App update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Application name. + */ + name: string; + /** + * Application description shown to users during OAuth2 consent. + */ + description: string; + /** + * Application homepage URL shown to users during OAuth2 consent. + */ + clientUri: string; + /** + * Application logo URL shown to users during OAuth2 consent. + */ + logoUri: string; + /** + * Application privacy policy URL shown to users during OAuth2 consent. + */ + privacyPolicyUrl: string; + /** + * Application terms of service URL shown to users during OAuth2 consent. + */ + termsUrl: string; + /** + * Application support or security contact emails. + */ + contacts: string[]; + /** + * Application tagline shown to users during OAuth2 consent. + */ + tagline: string; + /** + * Application tags shown to users during OAuth2 consent. + */ + tags: string[]; + /** + * Application labels. Read-only for clients; only a server SDK using a project API key can update them. + */ + labels: string[]; + /** + * Application image URLs shown to users during OAuth2 consent. + */ + images: string[]; + /** + * Application support URL shown to users during OAuth2 consent. + */ + supportUrl: string; + /** + * Application data deletion URL shown to users during OAuth2 consent. + */ + dataDeletionUrl: string; + /** + * List of authorized redirect URIs. These URIs can be used to redirect users after they authenticate. + */ + redirectUris: string[]; + /** + * List of authorized post-logout redirect URIs for OpenID Connect RP-Initiated Logout. The logout endpoint only redirects users to URIs in this list after ending their session. + */ + postLogoutRedirectUris: string[]; + /** + * Whether the app is enabled or not. + */ + enabled: boolean; + /** + * OAuth2 client type. `public` for SPAs, mobile, and native apps that cannot keep a client secret (PKCE required); `confidential` for server-side clients that authenticate with a client secret. + */ + type: string; + /** + * Whether this client may use the OAuth2 Device Authorization Grant (RFC 8628). + */ + deviceFlow: boolean; + /** + * ID of team that owns the application, if owned by team. Otherwise, user ID will be used. + */ + teamId: string; + /** + * ID of user who owns the application, if owned by user. Otherwise, team ID will be used. + */ + userId: string; + /** + * Scopes the application requests when installed on a team. Organization-level and project-level scopes only. + */ + installationScopes: string[]; + /** + * URL users are redirected to after creating or updating an installation of this application. Empty for no redirect. + */ + installationRedirectUrl: string; + /** + * List of application secrets. + */ + secrets: AppSecret[]; + } + + /** + * AppSecret + */ + export type AppSecret = { + /** + * Secret ID. + */ + $id: string; + /** + * Secret creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Secret update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Application ID this secret belongs to. + */ + appId: string; + /** + * Always empty. The application client secret is returned only once, in the response of the createSecret method. + */ + secret: string; + /** + * Last few characters of the client secret, used to help identify it. + */ + hint: string; + /** + * ID of the user who created the secret. + */ + createdById: string; + /** + * Name of the user who created the secret. + */ + createdByName: string; + /** + * Time the secret was last used for authentication in ISO 8601 format. Null if never used. + */ + lastAccessedAt?: string; + } + + /** + * AppSecretPlaintext + */ + export type AppSecretPlaintext = { + /** + * Secret ID. + */ + $id: string; + /** + * Secret creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Secret update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Application ID this secret belongs to. + */ + appId: string; + /** + * Application client secret. Returned only when the secret is created; subsequent reads always return an empty value. + */ + secret: string; + /** + * Last few characters of the client secret, used to help identify it. + */ + hint: string; + /** + * ID of the user who created the secret. + */ + createdById: string; + /** + * Name of the user who created the secret. + */ + createdByName: string; + /** + * Time the secret was last used for authentication in ISO 8601 format. Null if never used. + */ + lastAccessedAt?: string; + } + + /** + * AppScope + */ + export type AppScope = { + /** + * Scope value as requested by apps. + */ + value: string; + /** + * Human-readable description of what the scope grants. + */ + description: string; + /** + * What the scope grants access to. One of `account`, `project`, or `organization`. Only `project` and `organization` scopes are installable. + */ + type: string; + /** + * Scope category, used to group scopes on consent and installation screens. + */ + category: string; + /** + * Whether the scope is deprecated. Deprecated scopes can still be requested but should not be offered for new grants. + */ + deprecated: boolean; + } + + /** + * AppInstallation + */ + export type AppInstallation = { + /** + * Installation ID. + */ + $id: string; + /** + * Installation creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Installation update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * ID of the installed application. + */ + appId: string; + /** + * ID of the team the application is installed on. + */ + teamId: string; + /** + * Scopes granted to the application. Snapshot of the application's installation scopes taken when the installation was created or last updated. + */ + scopes: string[]; + /** + * Authorization details granted to the application. Rich authorization request (RFC 9396) style entries; the Appwrite Console stores authorized project IDs here. + */ + authorizationDetails: object; + /** + * ID of the user who created the installation. + */ + createdById: string; + /** + * Name of the user who created the installation. + */ + createdByName: string; + /** + * Time an access token was last issued for the installation in ISO 8601 format. Null if never used. + */ + lastAccessedAt?: string; + } + + /** + * AppKey + */ + export type AppKey = { + /** + * App key ID. + */ + $id: string; + /** + * App key creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * App key update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Application ID this app key belongs to. + */ + appId: string; + /** + * App key secret. + */ + secret: string; + /** + * Last few characters of the app key secret, used to help identify it. + */ + hint: string; + /** + * ID of the user who created the app key. + */ + createdById: string; + /** + * Name of the user who created the app key. + */ + createdByName: string; + /** + * Time the app key was last used for authentication in ISO 8601 format. Null if never used. + */ + lastAccessedAt?: string; + } + + /** + * OAuth2 Authorize + */ + export type Oauth2Authorize = { + /** + * OAuth2 grant ID. Set when the user must give explicit consent; pass it to the approve or reject endpoint. Empty when a redirect URL is returned instead. + */ + grantId: string; + /** + * URL the end user should be redirected to when the flow can complete without consent. Empty when consent is still required. + */ + redirectUrl: string; + } + + /** + * OAuth2 Approve + */ + export type Oauth2Approve = { + /** + * URL the end user should be redirected to after the grant is approved, carrying the authorization `code` and/or `id_token` along with the original `state`. + */ + redirectUrl: string; + } + + /** + * OAuth2 Reject + */ + export type Oauth2Reject = { + /** + * URL the end user should be redirected to after the grant is rejected, carrying an `access_denied` error. + */ + redirectUrl: string; + } + + /** + * OAuth2 Grant + */ + export type Oauth2Grant = { + /** + * Grant ID. + */ + $id: string; + /** + * Grant creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Grant update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * ID of the user the grant belongs to. + */ + userId: string; + /** + * ID of the OAuth2 client (app) the grant was requested for. + */ + appId: string; + /** + * Requested OAuth2 scopes the user is being asked to consent to. + */ + scopes: string[]; + /** + * Requested RFC 8707 resource indicators the user is being asked to consent to. + */ + resources: string[]; + /** + * Requested authorization_details the user is being asked to consent to, as a JSON string. Each entry has a `type` plus project-defined fields. + */ + authorizationDetails: string; + /** + * OIDC prompt directive the consent screen should honor. Space-separated list of: login, consent, select_account. + */ + prompt: string; + /** + * Redirect URI the user will be sent to after the flow completes. + */ + redirectUri: string; + /** + * Unix timestamp of when the user last authenticated. + */ + authTime: number; + /** + * Grant expiration time in ISO 8601 format. + */ + expire: string; + } + + /** + * OAuth2 Device Authorization + */ + export type Oauth2DeviceAuthorization = { + /** + * Device verification code used by the client to poll the token endpoint. + */ + device_code: string; + /** + * Short code the end user enters on the verification page. + */ + user_code: string; + /** + * URL where the end user enters the user code. + */ + verification_uri: string; + /** + * Verification URL with the user code prefilled as a query parameter. + */ + verification_uri_complete: string; + /** + * Lifetime of the device code and user code in seconds. + */ + expires_in: number; + /** + * Minimum polling interval for the token endpoint in seconds. + */ + interval: number; + } + + /** + * OAuth2 PAR + */ + export type Oauth2PAR = { + /** + * Authorization request handle to pass to the authorize endpoint. + */ + request_uri: string; + /** + * Lifetime of the authorization request handle in seconds. + */ + expires_in: number; + } + + /** + * OAuth2 Token + */ + export type Oauth2Token = { + /** + * OAuth2 access token. + */ + access_token: string; + /** + * OAuth2 token type. + */ + token_type: string; + /** + * Access token lifetime in seconds. + */ + expires_in: number; + /** + * OAuth2 refresh token. + */ + refresh_token: string; + /** + * Space-separated scopes granted to the access token. + */ + scope: string; + /** + * Granted RFC 9396 authorization details as a JSON string. + */ + authorization_details?: string; + /** + * OpenID Connect ID token. Returned when the `openid` scope is granted. + */ + id_token?: string; + } + + /** + * OAuth2 Consent + */ + export type Oauth2Consent = { + /** + * Consent ID. + */ + $id: string; + /** + * Consent creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Consent update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * ID of the user the consent belongs to. + */ + userId: string; + /** + * ID of the registered app the consent was given to. Empty for URL-form (CIMD) clients. + */ + appId: string; + /** + * Client ID metadata document URL of the client the consent was given to. Empty for registered apps. + */ + cimdUrl: string; + /** + * OAuth2 scopes the user consented to. + */ + scopes: string[]; + /** + * RFC 8707 resource indicators the user consented to. + */ + resources: string[]; + /** + * Authorization details the user consented to, as a JSON string. Each entry has a `type` plus project-defined fields. + */ + authorizationDetails: string; + /** + * Consent expiration time in ISO 8601 format. Empty when the consent has no token-bound expiry yet. + */ + expire: string; + } + + /** + * OAuth2 Consent Token + */ + export type Oauth2ConsentToken = { + /** + * Token family ID. + */ + $id: string; + /** + * Token creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Token update date in ISO 8601 format. Refreshing the token family updates this. + */ + $updatedAt: string; + /** + * ID of the consent the token family was issued under. + */ + consentId: string; + /** + * ID of the user the token family belongs to. + */ + userId: string; + /** + * ID of the registered app the token family was issued to. Empty for URL-form (CIMD) clients. + */ + appId: string; + /** + * Client ID metadata document URL of the client the token family was issued to. Empty for registered apps. + */ + cimdUrl: string; + /** + * OAuth2 scopes granted on the token family. + */ + scopes: string[]; + /** + * RFC 8707 resource indicators granted on the token family. + */ + resources: string[]; + /** + * Authorization details granted on the token family, as a JSON string. Each entry has a `type` plus project-defined fields. + */ + authorizationDetails: string; + /** + * Expiration time of the current access token of this family in ISO 8601 format. + */ + expire: string; + } + + /** + * OAuth2 Project + */ + export type Oauth2Project = { + /** + * Project ID. + */ + $id: string; + /** + * Region ID the project is deployed in. + */ + region: string; + /** + * API endpoint of the region the project is deployed in. Empty when the region has no public hostname configured. + */ + endpoint: string; + } + + /** + * OAuth2 Organization + */ + export type Oauth2Organization = { + /** + * Organization ID. + */ + $id: string; + } + + /** + * OAuth2 accessible projects list + */ + export type Oauth2ProjectList = { + /** + * Total number of projects that matched your query. + */ + total: number; + /** + * List of projects. + */ + projects: Oauth2Project[]; + } + + /** + * OAuth2 accessible organizations list + */ + export type Oauth2OrganizationList = { + /** + * Total number of organizations that matched your query. + */ + total: number; + /** + * List of organizations. + */ + organizations: Oauth2Organization[]; + } + + /** + * OAuth2 consents list + */ + export type Oauth2ConsentList = { + /** + * Total number of consents that matched your query. + */ + total: number; + /** + * List of consents. + */ + consents: Oauth2Consent[]; + } + + /** + * OAuth2 consent tokens list + */ + export type Oauth2ConsentTokenList = { + /** + * Total number of tokens that matched your query. + */ + total: number; + /** + * List of tokens. + */ + tokens: Oauth2ConsentToken[]; + } + + /** + * Activity event list + */ + export type ActivityEventList = { + /** + * Total number of events that matched your query. + */ + total: number; + /** + * List of events. + */ + events: ActivityEvent[]; + } + + /** + * Backup archive list + */ + export type BackupArchiveList = { + /** + * Total number of archives that matched your query. + */ + total: number; + /** + * List of archives. + */ + archives: BackupArchive[]; + } + + /** + * Backup policy list + */ + export type BackupPolicyList = { + /** + * Total number of policies that matched your query. + */ + total: number; + /** + * List of policies. + */ + policies: BackupPolicy[]; + } + + /** + * Backup restoration list */ export type BackupRestorationList = { /** @@ -7842,4 +8988,74 @@ export namespace Models { */ restorations: BackupRestoration[]; } + + /** + * Apps list + */ + export type AppsList = { + /** + * Total number of apps that matched your query. + */ + total: number; + /** + * List of apps. + */ + apps: App[]; + } + + /** + * App secrets list + */ + export type AppSecretList = { + /** + * Total number of secrets that matched your query. + */ + total: number; + /** + * List of secrets. + */ + secrets: AppSecret[]; + } + + /** + * App scopes list + */ + export type AppScopeList = { + /** + * Total number of scopes that matched your query. + */ + total: number; + /** + * List of scopes. + */ + scopes: AppScope[]; + } + + /** + * App installations list + */ + export type AppInstallationList = { + /** + * Total number of installations that matched your query. + */ + total: number; + /** + * List of installations. + */ + installations: AppInstallation[]; + } + + /** + * App keys list + */ + export type AppKeyList = { + /** + * Total number of keys that matched your query. + */ + total: number; + /** + * List of keys. + */ + keys: AppKey[]; + } } diff --git a/src/services/account.ts b/src/services/account.ts index 57aadebf..3443e136 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -123,6 +123,365 @@ export class Account { ); } + /** + * Get a list of the OAuth2 consents the current user has given to third-party apps. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listConsents(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Get a list of the OAuth2 consents the current user has given to third-party apps. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listConsents(queries?: string[], total?: boolean): Promise; + listConsents( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/account/consents'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get an OAuth2 consent the current user has given to a third-party app by its unique ID. + * + * @param {string} params.consentId - Consent unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getConsent(params: { consentId: string }): Promise; + /** + * Get an OAuth2 consent the current user has given to a third-party app by its unique ID. + * + * @param {string} consentId - Consent unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getConsent(consentId: string): Promise; + getConsent( + paramsOrFirst: { consentId: string } | string + ): Promise { + let params: { consentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { consentId: string }; + } else { + params = { + consentId: paramsOrFirst as string + }; + } + + const consentId = params.consentId; + + if (typeof consentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + const apiPath = '/account/consents/{consentId}'.replace('{consentId}', encodeURIComponent(String(consentId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete an OAuth2 consent by its unique ID. All token families issued under the consent are revoked, and the app must ask for consent again to regain access. + * + * @param {string} params.consentId - Consent unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteConsent(params: { consentId: string }): Promise<{}>; + /** + * Delete an OAuth2 consent by its unique ID. All token families issued under the consent are revoked, and the app must ask for consent again to regain access. + * + * @param {string} consentId - Consent unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteConsent(consentId: string): Promise<{}>; + deleteConsent( + paramsOrFirst: { consentId: string } | string + ): Promise<{}> { + let params: { consentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { consentId: string }; + } else { + params = { + consentId: paramsOrFirst as string + }; + } + + const consentId = params.consentId; + + if (typeof consentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + const apiPath = '/account/consents/{consentId}'.replace('{consentId}', encodeURIComponent(String(consentId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a list of the token families issued under an OAuth2 consent. Each entry represents one authorized device or session; the token secrets themselves are never returned. + * + * @param {string} params.consentId - Consent unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listConsentTokens(params: { consentId: string, queries?: string[], total?: boolean }): Promise; + /** + * Get a list of the token families issued under an OAuth2 consent. Each entry represents one authorized device or session; the token secrets themselves are never returned. + * + * @param {string} consentId - Consent unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listConsentTokens(consentId: string, queries?: string[], total?: boolean): Promise; + listConsentTokens( + paramsOrFirst: { consentId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise { + let params: { consentId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { consentId: string, queries?: string[], total?: boolean }; + } else { + params = { + consentId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const consentId = params.consentId; + const queries = params.queries; + const total = params.total; + + if (typeof consentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + const apiPath = '/account/consents/{consentId}/tokens'.replace('{consentId}', encodeURIComponent(String(consentId))); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a token family issued under an OAuth2 consent by its unique ID. The token secrets themselves are never returned. + * + * @param {string} params.consentId - Consent unique ID. + * @param {string} params.tokenId - Token unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getConsentToken(params: { consentId: string, tokenId: string }): Promise; + /** + * Get a token family issued under an OAuth2 consent by its unique ID. The token secrets themselves are never returned. + * + * @param {string} consentId - Consent unique ID. + * @param {string} tokenId - Token unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getConsentToken(consentId: string, tokenId: string): Promise; + getConsentToken( + paramsOrFirst: { consentId: string, tokenId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { consentId: string, tokenId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { consentId: string, tokenId: string }; + } else { + params = { + consentId: paramsOrFirst as string, + tokenId: rest[0] as string + }; + } + + const consentId = params.consentId; + const tokenId = params.tokenId; + + if (typeof consentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + if (typeof tokenId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + + const apiPath = '/account/consents/{consentId}/tokens/{tokenId}'.replace('{consentId}', encodeURIComponent(String(consentId))).replace('{tokenId}', encodeURIComponent(String(tokenId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a token family issued under an OAuth2 consent by its unique ID. The access and refresh tokens of the family stop working immediately; other token families and the consent itself are unaffected. + * + * @param {string} params.consentId - Consent unique ID. + * @param {string} params.tokenId - Token unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteConsentToken(params: { consentId: string, tokenId: string }): Promise<{}>; + /** + * Delete a token family issued under an OAuth2 consent by its unique ID. The access and refresh tokens of the family stop working immediately; other token families and the consent itself are unaffected. + * + * @param {string} consentId - Consent unique ID. + * @param {string} tokenId - Token unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteConsentToken(consentId: string, tokenId: string): Promise<{}>; + deleteConsentToken( + paramsOrFirst: { consentId: string, tokenId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { consentId: string, tokenId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { consentId: string, tokenId: string }; + } else { + params = { + consentId: paramsOrFirst as string, + tokenId: rest[0] as string + }; + } + + const consentId = params.consentId; + const tokenId = params.tokenId; + + if (typeof consentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + if (typeof tokenId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + + const apiPath = '/account/consents/{consentId}/tokens/{tokenId}'.replace('{consentId}', encodeURIComponent(String(consentId))).replace('{tokenId}', encodeURIComponent(String(tokenId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + /** * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. * This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. diff --git a/src/services/apps.ts b/src/services/apps.ts new file mode 100644 index 00000000..bdee84f4 --- /dev/null +++ b/src/services/apps.ts @@ -0,0 +1,1476 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + + +export class Apps { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List applications. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + list(params?: { queries?: string[], total?: boolean }): Promise; + /** + * List applications. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[], total?: boolean): Promise; + list( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/apps'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new application. + * + * @param {string} params.appId - Application ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Application name. + * @param {string[]} params.redirectUris - Redirect URIs. Each must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI (e.g. com.example.app:/oauth), and must not contain a fragment. + * @param {string} params.description - Application description shown to users during OAuth2 consent. + * @param {string} params.clientUri - Application homepage URL shown to users during OAuth2 consent. + * @param {string} params.logoUri - Application logo URL shown to users during OAuth2 consent. + * @param {string} params.privacyPolicyUrl - Application privacy policy URL shown to users during OAuth2 consent. + * @param {string} params.termsUrl - Application terms of service URL shown to users during OAuth2 consent. + * @param {string[]} params.contacts - Application support or security contact emails. Maximum of 100 contacts are allowed. + * @param {string} params.tagline - Application tagline shown to users during OAuth2 consent. + * @param {string[]} params.tags - Application tags shown to users during OAuth2 consent. Maximum of 100 tags are allowed, each up to 64 characters long. + * @param {string[]} params.images - Application image URLs shown to users during OAuth2 consent. Maximum of 100 images are allowed. + * @param {string} params.supportUrl - Application support URL shown to users during OAuth2 consent. + * @param {string} params.dataDeletionUrl - Application data deletion URL shown to users during OAuth2 consent. + * @param {string[]} params.postLogoutRedirectUris - Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list. + * @param {boolean} params.enabled - Is application enabled? + * @param {string} params.type - OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. + * @param {boolean} params.deviceFlow - Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. + * @param {string} params.teamId - Team unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + create(params: { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string }): Promise; + /** + * Create a new application. + * + * @param {string} appId - Application ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Application name. + * @param {string[]} redirectUris - Redirect URIs. Each must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI (e.g. com.example.app:/oauth), and must not contain a fragment. + * @param {string} description - Application description shown to users during OAuth2 consent. + * @param {string} clientUri - Application homepage URL shown to users during OAuth2 consent. + * @param {string} logoUri - Application logo URL shown to users during OAuth2 consent. + * @param {string} privacyPolicyUrl - Application privacy policy URL shown to users during OAuth2 consent. + * @param {string} termsUrl - Application terms of service URL shown to users during OAuth2 consent. + * @param {string[]} contacts - Application support or security contact emails. Maximum of 100 contacts are allowed. + * @param {string} tagline - Application tagline shown to users during OAuth2 consent. + * @param {string[]} tags - Application tags shown to users during OAuth2 consent. Maximum of 100 tags are allowed, each up to 64 characters long. + * @param {string[]} images - Application image URLs shown to users during OAuth2 consent. Maximum of 100 images are allowed. + * @param {string} supportUrl - Application support URL shown to users during OAuth2 consent. + * @param {string} dataDeletionUrl - Application data deletion URL shown to users during OAuth2 consent. + * @param {string[]} postLogoutRedirectUris - Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list. + * @param {boolean} enabled - Is application enabled? + * @param {string} type - OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. + * @param {boolean} deviceFlow - Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. + * @param {string} teamId - Team unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string): Promise; + create( + paramsOrFirst: { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string } | string, + ...rest: [(string)?, (string[])?, (string)?, (string)?, (string)?, (string)?, (string)?, (string[])?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?, (string)?] + ): Promise { + let params: { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, name: string, redirectUris: string[], description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, postLogoutRedirectUris?: string[], enabled?: boolean, type?: string, deviceFlow?: boolean, teamId?: string }; + } else { + params = { + appId: paramsOrFirst as string, + name: rest[0] as string, + redirectUris: rest[1] as string[], + description: rest[2] as string, + clientUri: rest[3] as string, + logoUri: rest[4] as string, + privacyPolicyUrl: rest[5] as string, + termsUrl: rest[6] as string, + contacts: rest[7] as string[], + tagline: rest[8] as string, + tags: rest[9] as string[], + images: rest[10] as string[], + supportUrl: rest[11] as string, + dataDeletionUrl: rest[12] as string, + postLogoutRedirectUris: rest[13] as string[], + enabled: rest[14] as boolean, + type: rest[15] as string, + deviceFlow: rest[16] as boolean, + teamId: rest[17] as string + }; + } + + const appId = params.appId; + const name = params.name; + const redirectUris = params.redirectUris; + const description = params.description; + const clientUri = params.clientUri; + const logoUri = params.logoUri; + const privacyPolicyUrl = params.privacyPolicyUrl; + const termsUrl = params.termsUrl; + const contacts = params.contacts; + const tagline = params.tagline; + const tags = params.tags; + const images = params.images; + const supportUrl = params.supportUrl; + const dataDeletionUrl = params.dataDeletionUrl; + const postLogoutRedirectUris = params.postLogoutRedirectUris; + const enabled = params.enabled; + const type = params.type; + const deviceFlow = params.deviceFlow; + const teamId = params.teamId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof redirectUris === 'undefined') { + throw new AppwriteException('Missing required parameter: "redirectUris"'); + } + + const apiPath = '/apps'; + const payload: Payload = {}; + if (typeof appId !== 'undefined') { + payload['appId'] = appId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof description !== 'undefined') { + payload['description'] = description; + } + if (typeof clientUri !== 'undefined') { + payload['clientUri'] = clientUri; + } + if (typeof logoUri !== 'undefined') { + payload['logoUri'] = logoUri; + } + if (typeof privacyPolicyUrl !== 'undefined') { + payload['privacyPolicyUrl'] = privacyPolicyUrl; + } + if (typeof termsUrl !== 'undefined') { + payload['termsUrl'] = termsUrl; + } + if (typeof contacts !== 'undefined') { + payload['contacts'] = contacts; + } + if (typeof tagline !== 'undefined') { + payload['tagline'] = tagline; + } + if (typeof tags !== 'undefined') { + payload['tags'] = tags; + } + if (typeof images !== 'undefined') { + payload['images'] = images; + } + if (typeof supportUrl !== 'undefined') { + payload['supportUrl'] = supportUrl; + } + if (typeof dataDeletionUrl !== 'undefined') { + payload['dataDeletionUrl'] = dataDeletionUrl; + } + if (typeof redirectUris !== 'undefined') { + payload['redirectUris'] = redirectUris; + } + if (typeof postLogoutRedirectUris !== 'undefined') { + payload['postLogoutRedirectUris'] = postLogoutRedirectUris; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof deviceFlow !== 'undefined') { + payload['deviceFlow'] = deviceFlow; + } + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * List scopes an application can request when installed on a team. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + listInstallationScopes(): Promise { + + const apiPath = '/apps/scopes/installations'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * List scopes an application can request during the OAuth2 flow. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + listOAuth2Scopes(): Promise { + + const apiPath = '/apps/scopes/oauth2'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get an application by its unique ID. + * + * @param {string} params.appId - Application unique ID or HTTPS client ID metadata document URL. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { appId: string }): Promise; + /** + * Get an application by its unique ID. + * + * @param {string} appId - Application unique ID or HTTPS client ID metadata document URL. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(appId: string): Promise; + get( + paramsOrFirst: { appId: string } | string + ): Promise { + let params: { appId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string }; + } else { + params = { + appId: paramsOrFirst as string + }; + } + + const appId = params.appId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + const apiPath = '/apps/{appId}'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an application by its unique ID. + * + * @param {string} params.appId - Application unique ID. + * @param {string} params.name - Application name. + * @param {string} params.description - Application description shown to users during OAuth2 consent. + * @param {string} params.clientUri - Application homepage URL shown to users during OAuth2 consent. + * @param {string} params.logoUri - Application logo URL shown to users during OAuth2 consent. + * @param {string} params.privacyPolicyUrl - Application privacy policy URL shown to users during OAuth2 consent. + * @param {string} params.termsUrl - Application terms of service URL shown to users during OAuth2 consent. + * @param {string[]} params.contacts - Application support or security contact emails. Maximum of 100 contacts are allowed. + * @param {string} params.tagline - Application tagline shown to users during OAuth2 consent. + * @param {string[]} params.tags - Application tags shown to users during OAuth2 consent. Maximum of 100 tags are allowed, each up to 64 characters long. + * @param {string[]} params.images - Application image URLs shown to users during OAuth2 consent. Maximum of 100 images are allowed. + * @param {string} params.supportUrl - Application support URL shown to users during OAuth2 consent. + * @param {string} params.dataDeletionUrl - Application data deletion URL shown to users during OAuth2 consent. + * @param {boolean} params.enabled - Is application enabled? + * @param {string[]} params.redirectUris - Redirect URIs. Each must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI (e.g. com.example.app:/oauth), and must not contain a fragment. + * @param {string[]} params.postLogoutRedirectUris - Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list. + * @param {string} params.type - OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. + * @param {boolean} params.deviceFlow - Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. + * @param {string[]} params.installationScopes - Scopes the application requests when installed on a team. Organization-level and project-level scopes only; use the list scopes endpoint with `type=installation` to discover available values. Maximum of 100 scopes are allowed. + * @param {string} params.installationRedirectUrl - URL users are redirected to after creating or updating an installation of this application. Must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI, and must not contain a fragment. Leave empty for no redirect. + * @throws {AppwriteException} + * @returns {Promise} + */ + update(params: { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string }): Promise; + /** + * Update an application by its unique ID. + * + * @param {string} appId - Application unique ID. + * @param {string} name - Application name. + * @param {string} description - Application description shown to users during OAuth2 consent. + * @param {string} clientUri - Application homepage URL shown to users during OAuth2 consent. + * @param {string} logoUri - Application logo URL shown to users during OAuth2 consent. + * @param {string} privacyPolicyUrl - Application privacy policy URL shown to users during OAuth2 consent. + * @param {string} termsUrl - Application terms of service URL shown to users during OAuth2 consent. + * @param {string[]} contacts - Application support or security contact emails. Maximum of 100 contacts are allowed. + * @param {string} tagline - Application tagline shown to users during OAuth2 consent. + * @param {string[]} tags - Application tags shown to users during OAuth2 consent. Maximum of 100 tags are allowed, each up to 64 characters long. + * @param {string[]} images - Application image URLs shown to users during OAuth2 consent. Maximum of 100 images are allowed. + * @param {string} supportUrl - Application support URL shown to users during OAuth2 consent. + * @param {string} dataDeletionUrl - Application data deletion URL shown to users during OAuth2 consent. + * @param {boolean} enabled - Is application enabled? + * @param {string[]} redirectUris - Redirect URIs. Each must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI (e.g. com.example.app:/oauth), and must not contain a fragment. + * @param {string[]} postLogoutRedirectUris - Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list. + * @param {string} type - OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. + * @param {boolean} deviceFlow - Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. + * @param {string[]} installationScopes - Scopes the application requests when installed on a team. Organization-level and project-level scopes only; use the list scopes endpoint with `type=installation` to discover available values. Maximum of 100 scopes are allowed. + * @param {string} installationRedirectUrl - URL users are redirected to after creating or updating an installation of this application. Must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI, and must not contain a fragment. Leave empty for no redirect. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string): Promise; + update( + paramsOrFirst: { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string[])?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (boolean)?, (string[])?, (string[])?, (string)?, (boolean)?, (string[])?, (string)?] + ): Promise { + let params: { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, name: string, description?: string, clientUri?: string, logoUri?: string, privacyPolicyUrl?: string, termsUrl?: string, contacts?: string[], tagline?: string, tags?: string[], images?: string[], supportUrl?: string, dataDeletionUrl?: string, enabled?: boolean, redirectUris?: string[], postLogoutRedirectUris?: string[], type?: string, deviceFlow?: boolean, installationScopes?: string[], installationRedirectUrl?: string }; + } else { + params = { + appId: paramsOrFirst as string, + name: rest[0] as string, + description: rest[1] as string, + clientUri: rest[2] as string, + logoUri: rest[3] as string, + privacyPolicyUrl: rest[4] as string, + termsUrl: rest[5] as string, + contacts: rest[6] as string[], + tagline: rest[7] as string, + tags: rest[8] as string[], + images: rest[9] as string[], + supportUrl: rest[10] as string, + dataDeletionUrl: rest[11] as string, + enabled: rest[12] as boolean, + redirectUris: rest[13] as string[], + postLogoutRedirectUris: rest[14] as string[], + type: rest[15] as string, + deviceFlow: rest[16] as boolean, + installationScopes: rest[17] as string[], + installationRedirectUrl: rest[18] as string + }; + } + + const appId = params.appId; + const name = params.name; + const description = params.description; + const clientUri = params.clientUri; + const logoUri = params.logoUri; + const privacyPolicyUrl = params.privacyPolicyUrl; + const termsUrl = params.termsUrl; + const contacts = params.contacts; + const tagline = params.tagline; + const tags = params.tags; + const images = params.images; + const supportUrl = params.supportUrl; + const dataDeletionUrl = params.dataDeletionUrl; + const enabled = params.enabled; + const redirectUris = params.redirectUris; + const postLogoutRedirectUris = params.postLogoutRedirectUris; + const type = params.type; + const deviceFlow = params.deviceFlow; + const installationScopes = params.installationScopes; + const installationRedirectUrl = params.installationRedirectUrl; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/apps/{appId}'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof description !== 'undefined') { + payload['description'] = description; + } + if (typeof clientUri !== 'undefined') { + payload['clientUri'] = clientUri; + } + if (typeof logoUri !== 'undefined') { + payload['logoUri'] = logoUri; + } + if (typeof privacyPolicyUrl !== 'undefined') { + payload['privacyPolicyUrl'] = privacyPolicyUrl; + } + if (typeof termsUrl !== 'undefined') { + payload['termsUrl'] = termsUrl; + } + if (typeof contacts !== 'undefined') { + payload['contacts'] = contacts; + } + if (typeof tagline !== 'undefined') { + payload['tagline'] = tagline; + } + if (typeof tags !== 'undefined') { + payload['tags'] = tags; + } + if (typeof images !== 'undefined') { + payload['images'] = images; + } + if (typeof supportUrl !== 'undefined') { + payload['supportUrl'] = supportUrl; + } + if (typeof dataDeletionUrl !== 'undefined') { + payload['dataDeletionUrl'] = dataDeletionUrl; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof redirectUris !== 'undefined') { + payload['redirectUris'] = redirectUris; + } + if (typeof postLogoutRedirectUris !== 'undefined') { + payload['postLogoutRedirectUris'] = postLogoutRedirectUris; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof deviceFlow !== 'undefined') { + payload['deviceFlow'] = deviceFlow; + } + if (typeof installationScopes !== 'undefined') { + payload['installationScopes'] = installationScopes; + } + if (typeof installationRedirectUrl !== 'undefined') { + payload['installationRedirectUrl'] = installationRedirectUrl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete an application by its unique ID. + * + * @param {string} params.appId - Application unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { appId: string }): Promise<{}>; + /** + * Delete an application by its unique ID. + * + * @param {string} appId - Application unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(appId: string): Promise<{}>; + delete( + paramsOrFirst: { appId: string } | string + ): Promise<{}> { + let params: { appId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string }; + } else { + params = { + appId: paramsOrFirst as string + }; + } + + const appId = params.appId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + const apiPath = '/apps/{appId}'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * List installations of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. + * + * @param {string} params.appId - Application unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listInstallations(params: { appId: string, queries?: string[], total?: boolean }): Promise; + /** + * List installations of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. + * + * @param {string} appId - Application unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listInstallations(appId: string, queries?: string[], total?: boolean): Promise; + listInstallations( + paramsOrFirst: { appId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise { + let params: { appId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, queries?: string[], total?: boolean }; + } else { + params = { + appId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const appId = params.appId; + const queries = params.queries; + const total = params.total; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + const apiPath = '/apps/{appId}/installations'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get an installation of an application by its unique ID. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. + * + * @param {string} params.appId - Application unique ID. + * @param {string} params.installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getInstallation(params: { appId: string, installationId: string }): Promise; + /** + * Get an installation of an application by its unique ID. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. + * + * @param {string} appId - Application unique ID. + * @param {string} installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getInstallation(appId: string, installationId: string): Promise; + getInstallation( + paramsOrFirst: { appId: string, installationId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { appId: string, installationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, installationId: string }; + } else { + params = { + appId: paramsOrFirst as string, + installationId: rest[0] as string + }; + } + + const appId = params.appId; + const installationId = params.installationId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + if (typeof installationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + + const apiPath = '/apps/{appId}/installations/{installationId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{installationId}', encodeURIComponent(String(installationId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a token for an installation of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. The returned token carries the scopes and authorization details granted to the installation, and can be used as an `Authorization: Bearer` header everywhere OAuth2 access tokens are accepted. Multiple tokens can be active for the same installation at once; each token stays valid until it expires or the installation is updated or deleted. + * + * @param {string} params.appId - Application unique ID. + * @param {string} params.installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + createInstallationToken(params: { appId: string, installationId: string }): Promise; + /** + * Create a token for an installation of an application. Requires an app key sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. The returned token carries the scopes and authorization details granted to the installation, and can be used as an `Authorization: Bearer` header everywhere OAuth2 access tokens are accepted. Multiple tokens can be active for the same installation at once; each token stays valid until it expires or the installation is updated or deleted. + * + * @param {string} appId - Application unique ID. + * @param {string} installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createInstallationToken(appId: string, installationId: string): Promise; + createInstallationToken( + paramsOrFirst: { appId: string, installationId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { appId: string, installationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, installationId: string }; + } else { + params = { + appId: paramsOrFirst as string, + installationId: rest[0] as string + }; + } + + const appId = params.appId; + const installationId = params.installationId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + if (typeof installationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + + const apiPath = '/apps/{appId}/installations/{installationId}/tokens'.replace('{appId}', encodeURIComponent(String(appId))).replace('{installationId}', encodeURIComponent(String(installationId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * List app keys for an application. + * + * @param {string} params.appId - Application unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listKeys(params: { appId: string, queries?: string[], total?: boolean }): Promise; + /** + * List app keys for an application. + * + * @param {string} appId - Application unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listKeys(appId: string, queries?: string[], total?: boolean): Promise; + listKeys( + paramsOrFirst: { appId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise { + let params: { appId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, queries?: string[], total?: boolean }; + } else { + params = { + appId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const appId = params.appId; + const queries = params.queries; + const total = params.total; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + const apiPath = '/apps/{appId}/keys'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new app key for an application. App keys carry no scopes; send one in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header to list the application's installations and create installation access tokens. + * + * @param {string} params.appId - Application unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + createKey(params: { appId: string }): Promise; + /** + * Create a new app key for an application. App keys carry no scopes; send one in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header to list the application's installations and create installation access tokens. + * + * @param {string} appId - Application unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createKey(appId: string): Promise; + createKey( + paramsOrFirst: { appId: string } | string + ): Promise { + let params: { appId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string }; + } else { + params = { + appId: paramsOrFirst as string + }; + } + + const appId = params.appId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + const apiPath = '/apps/{appId}/keys'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get an app key by its unique ID. + * + * @param {string} params.appId - Application unique ID. + * @param {string} params.keyId - App key unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getKey(params: { appId: string, keyId: string }): Promise; + /** + * Get an app key by its unique ID. + * + * @param {string} appId - Application unique ID. + * @param {string} keyId - App key unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getKey(appId: string, keyId: string): Promise; + getKey( + paramsOrFirst: { appId: string, keyId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { appId: string, keyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, keyId: string }; + } else { + params = { + appId: paramsOrFirst as string, + keyId: rest[0] as string + }; + } + + const appId = params.appId; + const keyId = params.keyId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + + const apiPath = '/apps/{appId}/keys/{keyId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{keyId}', encodeURIComponent(String(keyId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete an app key by its unique ID. + * + * @param {string} params.appId - Application unique ID. + * @param {string} params.keyId - App key unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteKey(params: { appId: string, keyId: string }): Promise<{}>; + /** + * Delete an app key by its unique ID. + * + * @param {string} appId - Application unique ID. + * @param {string} keyId - App key unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteKey(appId: string, keyId: string): Promise<{}>; + deleteKey( + paramsOrFirst: { appId: string, keyId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { appId: string, keyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, keyId: string }; + } else { + params = { + appId: paramsOrFirst as string, + keyId: rest[0] as string + }; + } + + const appId = params.appId; + const keyId = params.keyId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + + const apiPath = '/apps/{appId}/keys/{keyId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{keyId}', encodeURIComponent(String(keyId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the labels of an application. Labels are read-only for clients; only a server SDK using a project API key can set them. Replaces the previous labels. + * + * @param {string} params.appId - Application unique ID. + * @param {string[]} params.labels - Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateLabels(params: { appId: string, labels: string[] }): Promise; + /** + * Update the labels of an application. Labels are read-only for clients; only a server SDK using a project API key can set them. Replaces the previous labels. + * + * @param {string} appId - Application unique ID. + * @param {string[]} labels - Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateLabels(appId: string, labels: string[]): Promise; + updateLabels( + paramsOrFirst: { appId: string, labels: string[] } | string, + ...rest: [(string[])?] + ): Promise { + let params: { appId: string, labels: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, labels: string[] }; + } else { + params = { + appId: paramsOrFirst as string, + labels: rest[0] as string[] + }; + } + + const appId = params.appId; + const labels = params.labels; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + if (typeof labels === 'undefined') { + throw new AppwriteException('Missing required parameter: "labels"'); + } + + const apiPath = '/apps/{appId}/labels'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + if (typeof labels !== 'undefined') { + payload['labels'] = labels; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * List client secrets for an application. + * + * @param {string} params.appId - Application unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listSecrets(params: { appId: string, queries?: string[], total?: boolean }): Promise; + /** + * List client secrets for an application. + * + * @param {string} appId - Application unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listSecrets(appId: string, queries?: string[], total?: boolean): Promise; + listSecrets( + paramsOrFirst: { appId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise { + let params: { appId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, queries?: string[], total?: boolean }; + } else { + params = { + appId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const appId = params.appId; + const queries = params.queries; + const total = params.total; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + const apiPath = '/apps/{appId}/secrets'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new client secret for an application. + * + * @param {string} params.appId - Application unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + createSecret(params: { appId: string }): Promise; + /** + * Create a new client secret for an application. + * + * @param {string} appId - Application unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSecret(appId: string): Promise; + createSecret( + paramsOrFirst: { appId: string } | string + ): Promise { + let params: { appId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string }; + } else { + params = { + appId: paramsOrFirst as string + }; + } + + const appId = params.appId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + const apiPath = '/apps/{appId}/secrets'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get an application client secret by its unique ID. + * + * @param {string} params.appId - Application unique ID. + * @param {string} params.secretId - Secret unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getSecret(params: { appId: string, secretId: string }): Promise; + /** + * Get an application client secret by its unique ID. + * + * @param {string} appId - Application unique ID. + * @param {string} secretId - Secret unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getSecret(appId: string, secretId: string): Promise; + getSecret( + paramsOrFirst: { appId: string, secretId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { appId: string, secretId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, secretId: string }; + } else { + params = { + appId: paramsOrFirst as string, + secretId: rest[0] as string + }; + } + + const appId = params.appId; + const secretId = params.secretId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + if (typeof secretId === 'undefined') { + throw new AppwriteException('Missing required parameter: "secretId"'); + } + + const apiPath = '/apps/{appId}/secrets/{secretId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{secretId}', encodeURIComponent(String(secretId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete an application client secret by its unique ID. + * + * @param {string} params.appId - Application unique ID. + * @param {string} params.secretId - Secret unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteSecret(params: { appId: string, secretId: string }): Promise<{}>; + /** + * Delete an application client secret by its unique ID. + * + * @param {string} appId - Application unique ID. + * @param {string} secretId - Secret unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteSecret(appId: string, secretId: string): Promise<{}>; + deleteSecret( + paramsOrFirst: { appId: string, secretId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { appId: string, secretId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, secretId: string }; + } else { + params = { + appId: paramsOrFirst as string, + secretId: rest[0] as string + }; + } + + const appId = params.appId; + const secretId = params.secretId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + if (typeof secretId === 'undefined') { + throw new AppwriteException('Missing required parameter: "secretId"'); + } + + const apiPath = '/apps/{appId}/secrets/{secretId}'.replace('{appId}', encodeURIComponent(String(appId))).replace('{secretId}', encodeURIComponent(String(secretId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Transfer an application to another team by its unique ID. + * + * @param {string} params.appId - Application unique ID. + * @param {string} params.teamId - Team ID of the team to transfer application to. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateTeam(params: { appId: string, teamId: string }): Promise; + /** + * Transfer an application to another team by its unique ID. + * + * @param {string} appId - Application unique ID. + * @param {string} teamId - Team ID of the team to transfer application to. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTeam(appId: string, teamId: string): Promise; + updateTeam( + paramsOrFirst: { appId: string, teamId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { appId: string, teamId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, teamId: string }; + } else { + params = { + appId: paramsOrFirst as string, + teamId: rest[0] as string + }; + } + + const appId = params.appId; + const teamId = params.teamId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + if (typeof teamId === 'undefined') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + const apiPath = '/apps/{appId}/team'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Revoke all tokens for an application by its unique ID. + * + * @param {string} params.appId - Application unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTokens(params: { appId: string }): Promise<{}>; + /** + * Revoke all tokens for an application by its unique ID. + * + * @param {string} appId - Application unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteTokens(appId: string): Promise<{}>; + deleteTokens( + paramsOrFirst: { appId: string } | string + ): Promise<{}> { + let params: { appId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string }; + } else { + params = { + appId: paramsOrFirst as string + }; + } + + const appId = params.appId; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + const apiPath = '/apps/{appId}/tokens'.replace('{appId}', encodeURIComponent(String(appId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } +} diff --git a/src/services/backups.ts b/src/services/backups.ts index 38b5cc08..ee83d6ad 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -591,49 +591,58 @@ export class Backups { /** * Create and trigger a new restoration for a backup on a project. * - * When restoring a DocumentsDB or VectorsDB database to a new resource, pass `newSpecification` to provision the restored database on a different specification than the archived one (for example, restoring onto a larger or smaller dedicated database). Use `serverless` to restore onto the shared pool, or a dedicated specification slug to restore onto a dedicated database of that size. The specification must be permitted by the organization's plan. `newSpecification` is not supported for legacy/TablesDB databases or for bucket restores. + * For a backup of one database, the restoration resolves its destination before it is queued. Pass `newResourceId` to restore into that database ID, including the archived database ID to overwrite it. When `newResourceId` is omitted, a new database ID is generated and returned in `options`. + * + * The restoration migration records the archived database in `resourceId` and `resourceType`, and the resolved database in `destinationResourceId` and `destinationResourceType`. Database types are stored canonically as `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave these fields empty because they do not have a single source or destination database. + * + * To list every migration related to one database, use its canonical type in a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and destination relation pairs: `(resourceType, resourceId)`, `(parentResourceType, parentResourceId)`, and `(destinationResourceType, destinationResourceId)`. Legacy and TablesDB databases use `database`; the operational `resourceType` of a table migration is not rewritten to `tablesdb`. + * + * When restoring a DocumentsDB or VectorsDB database to a new resource from a dedicated source, the restore provisions a fresh dedicated backing database at the source database's own specification. * * * @param {string} params.archiveId - Backup archive ID to restore * @param {BackupServices[]} params.services - Array of services to restore - * @param {string} params.newResourceId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.newResourceId - Destination resource ID. Omit to generate a new ID, or pass the archived resource ID to overwrite it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.newResourceName - Database name. Max length: 128 chars. - * @param {string} params.newSpecification - Specification to provision the restored database on, when restoring a DocumentsDB or VectorsDB database to a new resource. Defaults to the archived database's specification. Use `serverless` for the shared pool or a dedicated specification slug. * @throws {AppwriteException} * @returns {Promise} */ - createRestoration(params: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string, newSpecification?: string }): Promise; + createRestoration(params: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }): Promise; /** * Create and trigger a new restoration for a backup on a project. * - * When restoring a DocumentsDB or VectorsDB database to a new resource, pass `newSpecification` to provision the restored database on a different specification than the archived one (for example, restoring onto a larger or smaller dedicated database). Use `serverless` to restore onto the shared pool, or a dedicated specification slug to restore onto a dedicated database of that size. The specification must be permitted by the organization's plan. `newSpecification` is not supported for legacy/TablesDB databases or for bucket restores. + * For a backup of one database, the restoration resolves its destination before it is queued. Pass `newResourceId` to restore into that database ID, including the archived database ID to overwrite it. When `newResourceId` is omitted, a new database ID is generated and returned in `options`. + * + * The restoration migration records the archived database in `resourceId` and `resourceType`, and the resolved database in `destinationResourceId` and `destinationResourceType`. Database types are stored canonically as `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave these fields empty because they do not have a single source or destination database. + * + * To list every migration related to one database, use its canonical type in a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and destination relation pairs: `(resourceType, resourceId)`, `(parentResourceType, parentResourceId)`, and `(destinationResourceType, destinationResourceId)`. Legacy and TablesDB databases use `database`; the operational `resourceType` of a table migration is not rewritten to `tablesdb`. + * + * When restoring a DocumentsDB or VectorsDB database to a new resource from a dedicated source, the restore provisions a fresh dedicated backing database at the source database's own specification. * * * @param {string} archiveId - Backup archive ID to restore * @param {BackupServices[]} services - Array of services to restore - * @param {string} newResourceId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} newResourceId - Destination resource ID. Omit to generate a new ID, or pass the archived resource ID to overwrite it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} newResourceName - Database name. Max length: 128 chars. - * @param {string} newSpecification - Specification to provision the restored database on, when restoring a DocumentsDB or VectorsDB database to a new resource. Defaults to the archived database's specification. Use `serverless` for the shared pool or a dedicated specification slug. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createRestoration(archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string, newSpecification?: string): Promise; + createRestoration(archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string): Promise; createRestoration( - paramsOrFirst: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string, newSpecification?: string } | string, - ...rest: [(BackupServices[])?, (string)?, (string)?, (string)?] + paramsOrFirst: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string } | string, + ...rest: [(BackupServices[])?, (string)?, (string)?] ): Promise { - let params: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string, newSpecification?: string }; + let params: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string, newSpecification?: string }; + params = (paramsOrFirst || {}) as { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }; } else { params = { archiveId: paramsOrFirst as string, services: rest[0] as BackupServices[], newResourceId: rest[1] as string, - newResourceName: rest[2] as string, - newSpecification: rest[3] as string + newResourceName: rest[2] as string }; } @@ -641,7 +650,6 @@ export class Backups { const services = params.services; const newResourceId = params.newResourceId; const newResourceName = params.newResourceName; - const newSpecification = params.newSpecification; if (typeof archiveId === 'undefined') { throw new AppwriteException('Missing required parameter: "archiveId"'); @@ -664,9 +672,6 @@ export class Backups { if (typeof newResourceName !== 'undefined') { payload['newResourceName'] = newResourceName; } - if (typeof newSpecification !== 'undefined') { - payload['newSpecification'] = newSpecification; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts new file mode 100644 index 00000000..4458be3b --- /dev/null +++ b/src/services/oauth-2.ts @@ -0,0 +1,1097 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + + +export class Oauth2 { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Approve an OAuth2 grant after the user gives consent. Returns the `redirectUrl` the end user should be sent to. The consent screen may optionally pass enriched `authorization_details` to record the concrete resources the user selected. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param {string} params.grantId - Grant ID made during authorization, provided to consent screen in URL search params. + * @param {string} params.authorizationDetails - Enriched `authorization_details` the user consented to, replacing what the client requested. Each entry must use a `type` the project accepts. Optional; omit to keep the originally requested details. + * @param {string} params.scope - Space-separated scopes the user consented to. Must be a subset of the scopes originally requested; identity scopes such as `openid` are always retained. Optional; omit to keep the originally requested scopes. + * @throws {AppwriteException} + * @returns {Promise} + */ + approve(params: { grantId: string, authorizationDetails?: string, scope?: string }): Promise; + /** + * Approve an OAuth2 grant after the user gives consent. Returns the `redirectUrl` the end user should be sent to. The consent screen may optionally pass enriched `authorization_details` to record the concrete resources the user selected. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param {string} grantId - Grant ID made during authorization, provided to consent screen in URL search params. + * @param {string} authorizationDetails - Enriched `authorization_details` the user consented to, replacing what the client requested. Each entry must use a `type` the project accepts. Optional; omit to keep the originally requested details. + * @param {string} scope - Space-separated scopes the user consented to. Must be a subset of the scopes originally requested; identity scopes such as `openid` are always retained. Optional; omit to keep the originally requested scopes. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + approve(grantId: string, authorizationDetails?: string, scope?: string): Promise; + approve( + paramsOrFirst: { grantId: string, authorizationDetails?: string, scope?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { grantId: string, authorizationDetails?: string, scope?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { grantId: string, authorizationDetails?: string, scope?: string }; + } else { + params = { + grantId: paramsOrFirst as string, + authorizationDetails: rest[0] as string, + scope: rest[1] as string + }; + } + + const grantId = params.grantId; + const authorizationDetails = params.authorizationDetails; + const scope = params.scope; + + if (typeof grantId === 'undefined') { + throw new AppwriteException('Missing required parameter: "grantId"'); + } + + const apiPath = '/oauth2/{project_id}/approve'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof grantId !== 'undefined') { + payload['grant_id'] = grantId; + } + if (typeof authorizationDetails !== 'undefined') { + payload['authorization_details'] = authorizationDetails; + } + if (typeof scope !== 'undefined') { + payload['scope'] = scope; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} params.redirectUri - Redirect URI where visitor will be redirected after authorization, whether successful or not. + * @param {string} params.responseType - OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow). + * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`. + * @param {string} params.state - OAuth2 state. You receive this back in the redirect URI. + * @param {string} params.nonce - OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. + * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. + * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. + * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. + * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. + * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. + * @throws {AppwriteException} + * @returns {Promise} + */ + authorize(params?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }): Promise; + /** + * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} redirectUri - Redirect URI where visitor will be redirected after authorization, whether successful or not. + * @param {string} responseType - OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow). + * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`. + * @param {string} state - OAuth2 state. You receive this back in the redirect URI. + * @param {string} nonce - OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. + * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. + * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. + * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. + * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. + * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + authorize(clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string): Promise; + authorize( + paramsOrFirst?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (string)?, (string)?] + ): Promise { + let params: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; + } else { + params = { + clientId: paramsOrFirst as string, + redirectUri: rest[0] as string, + responseType: rest[1] as string, + scope: rest[2] as string, + state: rest[3] as string, + nonce: rest[4] as string, + codeChallenge: rest[5] as string, + codeChallengeMethod: rest[6] as string, + prompt: rest[7] as string, + maxAge: rest[8] as number, + authorizationDetails: rest[9] as string, + resource: rest[10] as string, + audience: rest[11] as string, + requestUri: rest[12] as string + }; + } + + const clientId = params.clientId; + const redirectUri = params.redirectUri; + const responseType = params.responseType; + const scope = params.scope; + const state = params.state; + const nonce = params.nonce; + const codeChallenge = params.codeChallenge; + const codeChallengeMethod = params.codeChallengeMethod; + const prompt = params.prompt; + const maxAge = params.maxAge; + const authorizationDetails = params.authorizationDetails; + const resource = params.resource; + const audience = params.audience; + const requestUri = params.requestUri; + + + const apiPath = '/oauth2/{project_id}/authorize'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['client_id'] = clientId; + } + if (typeof redirectUri !== 'undefined') { + payload['redirect_uri'] = redirectUri; + } + if (typeof responseType !== 'undefined') { + payload['response_type'] = responseType; + } + if (typeof scope !== 'undefined') { + payload['scope'] = scope; + } + if (typeof state !== 'undefined') { + payload['state'] = state; + } + if (typeof nonce !== 'undefined') { + payload['nonce'] = nonce; + } + if (typeof codeChallenge !== 'undefined') { + payload['code_challenge'] = codeChallenge; + } + if (typeof codeChallengeMethod !== 'undefined') { + payload['code_challenge_method'] = codeChallengeMethod; + } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } + if (typeof maxAge !== 'undefined') { + payload['max_age'] = maxAge; + } + if (typeof authorizationDetails !== 'undefined') { + payload['authorization_details'] = authorizationDetails; + } + if (typeof resource !== 'undefined') { + payload['resource'] = resource; + } + if (typeof audience !== 'undefined') { + payload['audience'] = audience; + } + if (typeof requestUri !== 'undefined') { + payload['request_uri'] = requestUri; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} params.redirectUri - Redirect URI where visitor will be redirected after authorization, whether successful or not. + * @param {string} params.responseType - OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow). + * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`. + * @param {string} params.state - OAuth2 state. You receive this back in the redirect URI. + * @param {string} params.nonce - OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. + * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. + * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. + * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. + * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. + * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. + * @throws {AppwriteException} + * @returns {Promise} + */ + authorizePost(params?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }): Promise; + /** + * Begin the OAuth2 authorization flow. When called without a session, the user is redirected to the consent screen without grant ID. When called with a session, the redirect URL includes param for grant ID. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} redirectUri - Redirect URI where visitor will be redirected after authorization, whether successful or not. + * @param {string} responseType - OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow). + * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`. + * @param {string} state - OAuth2 state. You receive this back in the redirect URI. + * @param {string} nonce - OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. + * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. + * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. + * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. + * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. + * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + authorizePost(clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string): Promise; + authorizePost( + paramsOrFirst?: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (string)?, (string)?] + ): Promise { + let params: { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, redirectUri?: string, responseType?: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string, requestUri?: string }; + } else { + params = { + clientId: paramsOrFirst as string, + redirectUri: rest[0] as string, + responseType: rest[1] as string, + scope: rest[2] as string, + state: rest[3] as string, + nonce: rest[4] as string, + codeChallenge: rest[5] as string, + codeChallengeMethod: rest[6] as string, + prompt: rest[7] as string, + maxAge: rest[8] as number, + authorizationDetails: rest[9] as string, + resource: rest[10] as string, + audience: rest[11] as string, + requestUri: rest[12] as string + }; + } + + const clientId = params.clientId; + const redirectUri = params.redirectUri; + const responseType = params.responseType; + const scope = params.scope; + const state = params.state; + const nonce = params.nonce; + const codeChallenge = params.codeChallenge; + const codeChallengeMethod = params.codeChallengeMethod; + const prompt = params.prompt; + const maxAge = params.maxAge; + const authorizationDetails = params.authorizationDetails; + const resource = params.resource; + const audience = params.audience; + const requestUri = params.requestUri; + + + const apiPath = '/oauth2/{project_id}/authorize'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['client_id'] = clientId; + } + if (typeof redirectUri !== 'undefined') { + payload['redirect_uri'] = redirectUri; + } + if (typeof responseType !== 'undefined') { + payload['response_type'] = responseType; + } + if (typeof scope !== 'undefined') { + payload['scope'] = scope; + } + if (typeof state !== 'undefined') { + payload['state'] = state; + } + if (typeof nonce !== 'undefined') { + payload['nonce'] = nonce; + } + if (typeof codeChallenge !== 'undefined') { + payload['code_challenge'] = codeChallenge; + } + if (typeof codeChallengeMethod !== 'undefined') { + payload['code_challenge_method'] = codeChallengeMethod; + } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } + if (typeof maxAge !== 'undefined') { + payload['max_age'] = maxAge; + } + if (typeof authorizationDetails !== 'undefined') { + payload['authorization_details'] = authorizationDetails; + } + if (typeof resource !== 'undefined') { + payload['resource'] = resource; + } + if (typeof audience !== 'undefined') { + payload['audience'] = audience; + } + if (typeof requestUri !== 'undefined') { + payload['request_uri'] = requestUri; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Start the OAuth2 Device Authorization Grant. Returns the device code, user code, verification URL, expiration, and polling interval. + * + * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. + * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. + * @throws {AppwriteException} + * @returns {Promise} + */ + createDeviceAuthorization(params?: { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string }): Promise; + /** + * Start the OAuth2 Device Authorization Grant. Returns the device code, user code, verification URL, expiration, and polling interval. + * + * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. + * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDeviceAuthorization(clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string): Promise; + createDeviceAuthorization( + paramsOrFirst?: { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?] + ): Promise { + let params: { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, scope?: string, authorizationDetails?: string, resource?: string, audience?: string }; + } else { + params = { + clientId: paramsOrFirst as string, + scope: rest[0] as string, + authorizationDetails: rest[1] as string, + resource: rest[2] as string, + audience: rest[3] as string + }; + } + + const clientId = params.clientId; + const scope = params.scope; + const authorizationDetails = params.authorizationDetails; + const resource = params.resource; + const audience = params.audience; + + + const apiPath = '/oauth2/{project_id}/device_authorization'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['client_id'] = clientId; + } + if (typeof scope !== 'undefined') { + payload['scope'] = scope; + } + if (typeof authorizationDetails !== 'undefined') { + payload['authorization_details'] = authorizationDetails; + } + if (typeof resource !== 'undefined') { + payload['resource'] = resource; + } + if (typeof audience !== 'undefined') { + payload['audience'] = audience; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Exchange a device flow user code for an OAuth2 grant. The authenticated user is bound to the pending grant. Pass the returned grant ID to the get grant endpoint to render the consent screen, then to the approve or reject endpoint to complete the flow. + * + * @param {string} params.userCode - User code displayed on the device. + * @throws {AppwriteException} + * @returns {Promise} + */ + createGrant(params: { userCode: string }): Promise; + /** + * Exchange a device flow user code for an OAuth2 grant. The authenticated user is bound to the pending grant. Pass the returned grant ID to the get grant endpoint to render the consent screen, then to the approve or reject endpoint to complete the flow. + * + * @param {string} userCode - User code displayed on the device. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createGrant(userCode: string): Promise; + createGrant( + paramsOrFirst: { userCode: string } | string + ): Promise { + let params: { userCode: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userCode: string }; + } else { + params = { + userCode: paramsOrFirst as string + }; + } + + const userCode = params.userCode; + + if (typeof userCode === 'undefined') { + throw new AppwriteException('Missing required parameter: "userCode"'); + } + + const apiPath = '/oauth2/{project_id}/grants'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof userCode !== 'undefined') { + payload['user_code'] = userCode; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get an OAuth2 grant by its ID. Used by the consent screen to display the details of the authorization the user is being asked to approve. A grant can only be read by the user it belongs to, or by server SDK. + * + * @param {string} params.grantId - Grant ID made during authorization, provided to consent screen in URL search params. + * @throws {AppwriteException} + * @returns {Promise} + */ + getGrant(params: { grantId: string }): Promise; + /** + * Get an OAuth2 grant by its ID. Used by the consent screen to display the details of the authorization the user is being asked to approve. A grant can only be read by the user it belongs to, or by server SDK. + * + * @param {string} grantId - Grant ID made during authorization, provided to consent screen in URL search params. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getGrant(grantId: string): Promise; + getGrant( + paramsOrFirst: { grantId: string } | string + ): Promise { + let params: { grantId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { grantId: string }; + } else { + params = { + grantId: paramsOrFirst as string + }; + } + + const grantId = params.grantId; + + if (typeof grantId === 'undefined') { + throw new AppwriteException('Missing required parameter: "grantId"'); + } + + const apiPath = '/oauth2/{project_id}/grants/{grant_id}'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))).replace('{grant_id}', encodeURIComponent(String(grantId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * List the organizations the OAuth2 access token can access. Resolves the token's `organization` authorization details, expanding the `*` wildcard into the concrete set of organizations the user can see. + * + * @param {number} params.limit - Maximum number of organizations to return. Between 1 and 5000. + * @param {number} params.offset - Number of organizations to skip before returning results. Used for pagination. + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + listOrganizations(params?: { limit?: number, offset?: number, search?: string }): Promise; + /** + * List the organizations the OAuth2 access token can access. Resolves the token's `organization` authorization details, expanding the `*` wildcard into the concrete set of organizations the user can see. + * + * @param {number} limit - Maximum number of organizations to return. Between 1 and 5000. + * @param {number} offset - Number of organizations to skip before returning results. Used for pagination. + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listOrganizations(limit?: number, offset?: number, search?: string): Promise; + listOrganizations( + paramsOrFirst?: { limit?: number, offset?: number, search?: string } | number, + ...rest: [(number)?, (string)?] + ): Promise { + let params: { limit?: number, offset?: number, search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { limit?: number, offset?: number, search?: string }; + } else { + params = { + limit: paramsOrFirst as number, + offset: rest[0] as number, + search: rest[1] as string + }; + } + + const limit = params.limit; + const offset = params.offset; + const search = params.search; + + + const apiPath = '/oauth2/{project_id}/organizations'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof limit !== 'undefined') { + payload['limit'] = limit; + } + if (typeof offset !== 'undefined') { + payload['offset'] = offset; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Store an OAuth2 authorization request server-side and receive a short-lived request_uri handle for the authorize endpoint. + * + * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} params.redirectUri - Redirect URI where visitor will be redirected after authorization, whether successful or not. + * @param {string} params.responseType - OAuth2 / OIDC response type. + * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`. + * @param {string} params.state - OAuth2 state. You receive this back in the redirect URI. + * @param {string} params.nonce - OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. + * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. + * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. + * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. + * @param {number} params.maxAge - OIDC max_age parameter for customization of consent screen. + * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. + * @throws {AppwriteException} + * @returns {Promise} + */ + createPAR(params: { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string }): Promise; + /** + * Store an OAuth2 authorization request server-side and receive a short-lived request_uri handle for the authorize endpoint. + * + * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} redirectUri - Redirect URI where visitor will be redirected after authorization, whether successful or not. + * @param {string} responseType - OAuth2 / OIDC response type. + * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`. + * @param {string} state - OAuth2 state. You receive this back in the redirect URI. + * @param {string} nonce - OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. + * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. + * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. + * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. + * @param {number} maxAge - OIDC max_age parameter for customization of consent screen. + * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPAR(clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string): Promise; + createPAR( + paramsOrFirst: { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (string)?, (string)?, (string)?] + ): Promise { + let params: { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId: string, redirectUri: string, responseType: string, scope?: string, state?: string, nonce?: string, codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, maxAge?: number, authorizationDetails?: string, resource?: string, audience?: string }; + } else { + params = { + clientId: paramsOrFirst as string, + redirectUri: rest[0] as string, + responseType: rest[1] as string, + scope: rest[2] as string, + state: rest[3] as string, + nonce: rest[4] as string, + codeChallenge: rest[5] as string, + codeChallengeMethod: rest[6] as string, + prompt: rest[7] as string, + maxAge: rest[8] as number, + authorizationDetails: rest[9] as string, + resource: rest[10] as string, + audience: rest[11] as string + }; + } + + const clientId = params.clientId; + const redirectUri = params.redirectUri; + const responseType = params.responseType; + const scope = params.scope; + const state = params.state; + const nonce = params.nonce; + const codeChallenge = params.codeChallenge; + const codeChallengeMethod = params.codeChallengeMethod; + const prompt = params.prompt; + const maxAge = params.maxAge; + const authorizationDetails = params.authorizationDetails; + const resource = params.resource; + const audience = params.audience; + + if (typeof clientId === 'undefined') { + throw new AppwriteException('Missing required parameter: "clientId"'); + } + if (typeof redirectUri === 'undefined') { + throw new AppwriteException('Missing required parameter: "redirectUri"'); + } + if (typeof responseType === 'undefined') { + throw new AppwriteException('Missing required parameter: "responseType"'); + } + + const apiPath = '/oauth2/{project_id}/par'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['client_id'] = clientId; + } + if (typeof redirectUri !== 'undefined') { + payload['redirect_uri'] = redirectUri; + } + if (typeof responseType !== 'undefined') { + payload['response_type'] = responseType; + } + if (typeof scope !== 'undefined') { + payload['scope'] = scope; + } + if (typeof state !== 'undefined') { + payload['state'] = state; + } + if (typeof nonce !== 'undefined') { + payload['nonce'] = nonce; + } + if (typeof codeChallenge !== 'undefined') { + payload['code_challenge'] = codeChallenge; + } + if (typeof codeChallengeMethod !== 'undefined') { + payload['code_challenge_method'] = codeChallengeMethod; + } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } + if (typeof maxAge !== 'undefined') { + payload['max_age'] = maxAge; + } + if (typeof authorizationDetails !== 'undefined') { + payload['authorization_details'] = authorizationDetails; + } + if (typeof resource !== 'undefined') { + payload['resource'] = resource; + } + if (typeof audience !== 'undefined') { + payload['audience'] = audience; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * List the projects the OAuth2 access token can access. Resolves the token's `project` authorization details, expanding the `*` wildcard into the concrete set of projects the user can see. + * + * @param {number} params.limit - Maximum number of projects to return. Between 1 and 5000. + * @param {number} params.offset - Number of projects to skip before returning results. Used for pagination. + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + listProjects(params?: { limit?: number, offset?: number, search?: string }): Promise; + /** + * List the projects the OAuth2 access token can access. Resolves the token's `project` authorization details, expanding the `*` wildcard into the concrete set of projects the user can see. + * + * @param {number} limit - Maximum number of projects to return. Between 1 and 5000. + * @param {number} offset - Number of projects to skip before returning results. Used for pagination. + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listProjects(limit?: number, offset?: number, search?: string): Promise; + listProjects( + paramsOrFirst?: { limit?: number, offset?: number, search?: string } | number, + ...rest: [(number)?, (string)?] + ): Promise { + let params: { limit?: number, offset?: number, search?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { limit?: number, offset?: number, search?: string }; + } else { + params = { + limit: paramsOrFirst as number, + offset: rest[0] as number, + search: rest[1] as string + }; + } + + const limit = params.limit; + const offset = params.offset; + const search = params.search; + + + const apiPath = '/oauth2/{project_id}/projects'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof limit !== 'undefined') { + payload['limit'] = limit; + } + if (typeof offset !== 'undefined') { + payload['offset'] = offset; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Reject an OAuth2 grant when the user denies consent. Returns the `redirectUrl` the end user should be sent to with an `access_denied` error. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param {string} params.grantId - Grant ID made during authorization, provided to consent screen in URL search params. + * @throws {AppwriteException} + * @returns {Promise} + */ + reject(params: { grantId: string }): Promise; + /** + * Reject an OAuth2 grant when the user denies consent. Returns the `redirectUrl` the end user should be sent to with an `access_denied` error. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. + * + * @param {string} grantId - Grant ID made during authorization, provided to consent screen in URL search params. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + reject(grantId: string): Promise; + reject( + paramsOrFirst: { grantId: string } | string + ): Promise { + let params: { grantId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { grantId: string }; + } else { + params = { + grantId: paramsOrFirst as string + }; + } + + const grantId = params.grantId; + + if (typeof grantId === 'undefined') { + throw new AppwriteException('Missing required parameter: "grantId"'); + } + + const apiPath = '/oauth2/{project_id}/reject'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof grantId !== 'undefined') { + payload['grant_id'] = grantId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Revoke an OAuth2 access token or refresh token. + * + * @param {string} params.token - The access or refresh token to revoke. + * @param {string} params.tokenTypeHint - Type of token to revoke (access_token or refresh_token). + * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} params.clientSecret - OAuth2 client secret. Required for confidential apps; omitted for public apps. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + revoke(params: { token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string }): Promise<{}>; + /** + * Revoke an OAuth2 access token or refresh token. + * + * @param {string} token - The access or refresh token to revoke. + * @param {string} tokenTypeHint - Type of token to revoke (access_token or refresh_token). + * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} clientSecret - OAuth2 client secret. Required for confidential apps; omitted for public apps. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + revoke(token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string): Promise<{}>; + revoke( + paramsOrFirst: { token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<{}> { + let params: { token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { token: string, tokenTypeHint?: string, clientId?: string, clientSecret?: string }; + } else { + params = { + token: paramsOrFirst as string, + tokenTypeHint: rest[0] as string, + clientId: rest[1] as string, + clientSecret: rest[2] as string + }; + } + + const token = params.token; + const tokenTypeHint = params.tokenTypeHint; + const clientId = params.clientId; + const clientSecret = params.clientSecret; + + if (typeof token === 'undefined') { + throw new AppwriteException('Missing required parameter: "token"'); + } + + const apiPath = '/oauth2/{project_id}/revoke'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof token !== 'undefined') { + payload['token'] = token; + } + if (typeof tokenTypeHint !== 'undefined') { + payload['token_type_hint'] = tokenTypeHint; + } + if (typeof clientId !== 'undefined') { + payload['client_id'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['client_secret'] = clientSecret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Exchange an OAuth2 authorization code, refresh token, or device code for access and refresh tokens. + * + * @param {string} params.grantType - OAuth2 grant type. Can be one of: `authorization_code`, `refresh_token`, `urn:ietf:params:oauth:grant-type:device_code`. + * @param {string} params.code - Authorization code to be exchanged for access and refresh tokens. Required for `authorization_code` grant type. + * @param {string} params.refreshToken - Refresh token to be exchanged for a new access and refresh tokens. Required for `refresh_token` grant type. + * @param {string} params.deviceCode - Device code obtained from the device authorization endpoint. Required for `urn:ietf:params:oauth:grant-type:device_code` grant type. + * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} params.clientSecret - OAuth2 client secret. Required for confidential apps. + * @param {string} params.codeVerifier - PKCE code verifier. Required for public apps. + * @param {string} params.redirectUri - Redirect URI. Required for `authorization_code` grant type. + * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. + * @throws {AppwriteException} + * @returns {Promise} + */ + createToken(params: { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string }): Promise; + /** + * Exchange an OAuth2 authorization code, refresh token, or device code for access and refresh tokens. + * + * @param {string} grantType - OAuth2 grant type. Can be one of: `authorization_code`, `refresh_token`, `urn:ietf:params:oauth:grant-type:device_code`. + * @param {string} code - Authorization code to be exchanged for access and refresh tokens. Required for `authorization_code` grant type. + * @param {string} refreshToken - Refresh token to be exchanged for a new access and refresh tokens. Required for `refresh_token` grant type. + * @param {string} deviceCode - Device code obtained from the device authorization endpoint. Required for `urn:ietf:params:oauth:grant-type:device_code` grant type. + * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + * @param {string} clientSecret - OAuth2 client secret. Required for confidential apps. + * @param {string} codeVerifier - PKCE code verifier. Required for public apps. + * @param {string} redirectUri - Redirect URI. Required for `authorization_code` grant type. + * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createToken(grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string): Promise; + createToken( + paramsOrFirst: { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise { + let params: { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { grantType: string, code?: string, refreshToken?: string, deviceCode?: string, clientId?: string, clientSecret?: string, codeVerifier?: string, redirectUri?: string, resource?: string, audience?: string }; + } else { + params = { + grantType: paramsOrFirst as string, + code: rest[0] as string, + refreshToken: rest[1] as string, + deviceCode: rest[2] as string, + clientId: rest[3] as string, + clientSecret: rest[4] as string, + codeVerifier: rest[5] as string, + redirectUri: rest[6] as string, + resource: rest[7] as string, + audience: rest[8] as string + }; + } + + const grantType = params.grantType; + const code = params.code; + const refreshToken = params.refreshToken; + const deviceCode = params.deviceCode; + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const codeVerifier = params.codeVerifier; + const redirectUri = params.redirectUri; + const resource = params.resource; + const audience = params.audience; + + if (typeof grantType === 'undefined') { + throw new AppwriteException('Missing required parameter: "grantType"'); + } + + const apiPath = '/oauth2/{project_id}/token'.replace('{project_id}', encodeURIComponent(String(this.client.config.project))); + const payload: Payload = {}; + if (typeof grantType !== 'undefined') { + payload['grant_type'] = grantType; + } + if (typeof code !== 'undefined') { + payload['code'] = code; + } + if (typeof refreshToken !== 'undefined') { + payload['refresh_token'] = refreshToken; + } + if (typeof deviceCode !== 'undefined') { + payload['device_code'] = deviceCode; + } + if (typeof clientId !== 'undefined') { + payload['client_id'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['client_secret'] = clientSecret; + } + if (typeof codeVerifier !== 'undefined') { + payload['code_verifier'] = codeVerifier; + } + if (typeof redirectUri !== 'undefined') { + payload['redirect_uri'] = redirectUri; + } + if (typeof resource !== 'undefined') { + payload['resource'] = resource; + } + if (typeof audience !== 'undefined') { + payload['audience'] = audience; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } +} diff --git a/src/services/organization.ts b/src/services/organization.ts index 83d49771..e2866085 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -119,6 +119,301 @@ export class Organization { ); } + /** + * List app installations on the organization. Any organization member can read installations. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listInstallations(params?: { queries?: string[], total?: boolean }): Promise; + /** + * List app installations on the organization. Any organization member can read installations. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listInstallations(queries?: string[], total?: boolean): Promise; + listInstallations( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/organization/installations'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Install an app on the organization. Only organization members with the owner role can install apps. The installation is granted the scopes the app currently requests. + * + * @param {string} params.appId - Application unique ID. + * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. The Appwrite Console stores authorized project IDs here. + * @throws {AppwriteException} + * @returns {Promise} + */ + createInstallation(params: { appId: string, authorizationDetails?: string }): Promise; + /** + * Install an app on the organization. Only organization members with the owner role can install apps. The installation is granted the scopes the app currently requests. + * + * @param {string} appId - Application unique ID. + * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. The Appwrite Console stores authorized project IDs here. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createInstallation(appId: string, authorizationDetails?: string): Promise; + createInstallation( + paramsOrFirst: { appId: string, authorizationDetails?: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { appId: string, authorizationDetails?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId: string, authorizationDetails?: string }; + } else { + params = { + appId: paramsOrFirst as string, + authorizationDetails: rest[0] as string + }; + } + + const appId = params.appId; + const authorizationDetails = params.authorizationDetails; + + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + const apiPath = '/organization/installations'; + const payload: Payload = {}; + if (typeof appId !== 'undefined') { + payload['appId'] = appId; + } + if (typeof authorizationDetails !== 'undefined') { + payload['authorizationDetails'] = authorizationDetails; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get an app installation on the organization by its unique ID. Any organization member can read installations. + * + * @param {string} params.installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getInstallation(params: { installationId: string }): Promise; + /** + * Get an app installation on the organization by its unique ID. Any organization member can read installations. + * + * @param {string} installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getInstallation(installationId: string): Promise; + getInstallation( + paramsOrFirst: { installationId: string } | string + ): Promise { + let params: { installationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { installationId: string }; + } else { + params = { + installationId: paramsOrFirst as string + }; + } + + const installationId = params.installationId; + + if (typeof installationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + + const apiPath = '/organization/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an app installation on the organization. Only organization members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. + * + * @param {string} params.installationId - Installation unique ID. + * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateInstallation(params: { installationId: string, authorizationDetails?: string }): Promise; + /** + * Update an app installation on the organization. Only organization members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. + * + * @param {string} installationId - Installation unique ID. + * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateInstallation(installationId: string, authorizationDetails?: string): Promise; + updateInstallation( + paramsOrFirst: { installationId: string, authorizationDetails?: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { installationId: string, authorizationDetails?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { installationId: string, authorizationDetails?: string }; + } else { + params = { + installationId: paramsOrFirst as string, + authorizationDetails: rest[0] as string + }; + } + + const installationId = params.installationId; + const authorizationDetails = params.authorizationDetails; + + if (typeof installationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + + const apiPath = '/organization/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); + const payload: Payload = {}; + if (typeof authorizationDetails !== 'undefined') { + payload['authorizationDetails'] = authorizationDetails; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Uninstall an app from the organization by its installation ID. Only organization members with the owner role can remove installations. Previously issued installation access tokens are revoked. + * + * @param {string} params.installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteInstallation(params: { installationId: string }): Promise<{}>; + /** + * Uninstall an app from the organization by its installation ID. Only organization members with the owner role can remove installations. Previously issued installation access tokens are revoked. + * + * @param {string} installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteInstallation(installationId: string): Promise<{}>; + deleteInstallation( + paramsOrFirst: { installationId: string } | string + ): Promise<{}> { + let params: { installationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { installationId: string }; + } else { + params = { + installationId: paramsOrFirst as string + }; + } + + const installationId = params.installationId; + + if (typeof installationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + + const apiPath = '/organization/installations/{installationId}'.replace('{installationId}', encodeURIComponent(String(installationId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + /** * Get a list of all API keys from the current organization. * diff --git a/src/services/project.ts b/src/services/project.ts index 1d79f2f7..747b5410 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -974,6 +974,7 @@ export class Project { * @param {number} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. * @param {number} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. * @param {number} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. * @param {boolean} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} params.verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. * @param {number} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. @@ -983,7 +984,7 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateOAuth2Server(params: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] }): Promise; + updateOAuth2Server(params: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] }): Promise; /** * Update the OAuth2 server (OIDC provider) configuration. * @@ -995,6 +996,7 @@ export class Project { * @param {number} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. * @param {number} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. * @param {number} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. * @param {boolean} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. * @param {number} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. @@ -1005,15 +1007,15 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateOAuth2Server(enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[]): Promise; + updateOAuth2Server(enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[]): Promise; updateOAuth2Server( - paramsOrFirst: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] } | boolean, - ...rest: [(string)?, (string[])?, (string[])?, (number)?, (number)?, (number)?, (number)?, (boolean)?, (string)?, (number)?, (string)?, (number)?, (string[])?] + paramsOrFirst: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] } | boolean, + ...rest: [(string)?, (string[])?, (string[])?, (number)?, (number)?, (number)?, (number)?, (number)?, (boolean)?, (string)?, (number)?, (string)?, (number)?, (string[])?] ): Promise { - let params: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] }; + let params: { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] }; + params = (paramsOrFirst || {}) as { enabled: boolean, authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], accessTokenDuration?: number, refreshTokenDuration?: number, publicAccessTokenDuration?: number, publicRefreshTokenDuration?: number, installationAccessTokenDuration?: number, confidentialPkce?: boolean, verificationUrl?: string, userCodeLength?: number, userCodeFormat?: string, deviceCodeDuration?: number, defaultScopes?: string[] }; } else { params = { enabled: paramsOrFirst as boolean, @@ -1024,12 +1026,13 @@ export class Project { refreshTokenDuration: rest[4] as number, publicAccessTokenDuration: rest[5] as number, publicRefreshTokenDuration: rest[6] as number, - confidentialPkce: rest[7] as boolean, - verificationUrl: rest[8] as string, - userCodeLength: rest[9] as number, - userCodeFormat: rest[10] as string, - deviceCodeDuration: rest[11] as number, - defaultScopes: rest[12] as string[] + installationAccessTokenDuration: rest[7] as number, + confidentialPkce: rest[8] as boolean, + verificationUrl: rest[9] as string, + userCodeLength: rest[10] as number, + userCodeFormat: rest[11] as string, + deviceCodeDuration: rest[12] as number, + defaultScopes: rest[13] as string[] }; } @@ -1041,6 +1044,7 @@ export class Project { const refreshTokenDuration = params.refreshTokenDuration; const publicAccessTokenDuration = params.publicAccessTokenDuration; const publicRefreshTokenDuration = params.publicRefreshTokenDuration; + const installationAccessTokenDuration = params.installationAccessTokenDuration; const confidentialPkce = params.confidentialPkce; const verificationUrl = params.verificationUrl; const userCodeLength = params.userCodeLength; @@ -1081,6 +1085,9 @@ export class Project { if (typeof publicRefreshTokenDuration !== 'undefined') { payload['publicRefreshTokenDuration'] = publicRefreshTokenDuration; } + if (typeof installationAccessTokenDuration !== 'undefined') { + payload['installationAccessTokenDuration'] = installationAccessTokenDuration; + } if (typeof confidentialPkce !== 'undefined') { payload['confidentialPkce'] = confidentialPkce; } diff --git a/src/services/sites.ts b/src/services/sites.ts index 314650f8..8fde491b 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -1337,40 +1337,44 @@ export class Sites { * @param {string} params.siteId - Site ID. * @param {string} params.deploymentId - Deployment ID. * @param {DeploymentDownloadType} params.type - Deployment file to download. Can be: "source", "output". + * @param {string} params.token - Presigned source-download token for accessing this deployment without a session (jobs-service). * @throws {AppwriteException} * @returns {Promise} */ - getDeploymentDownload(params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType }): Promise; + getDeploymentDownload(params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }): Promise; /** * Get a site deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. * * @param {string} siteId - Site ID. * @param {string} deploymentId - Deployment ID. * @param {DeploymentDownloadType} type - Deployment file to download. Can be: "source", "output". + * @param {string} token - Presigned source-download token for accessing this deployment without a session (jobs-service). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getDeploymentDownload(siteId: string, deploymentId: string, type?: DeploymentDownloadType): Promise; + getDeploymentDownload(siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string): Promise; getDeploymentDownload( - paramsOrFirst: { siteId: string, deploymentId: string, type?: DeploymentDownloadType } | string, - ...rest: [(string)?, (DeploymentDownloadType)?] + paramsOrFirst: { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string } | string, + ...rest: [(string)?, (DeploymentDownloadType)?, (string)?] ): Promise { - let params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType }; + let params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string, type?: DeploymentDownloadType }; + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string, type?: DeploymentDownloadType, token?: string }; } else { params = { siteId: paramsOrFirst as string, deploymentId: rest[0] as string, - type: rest[1] as DeploymentDownloadType + type: rest[1] as DeploymentDownloadType, + token: rest[2] as string }; } const siteId = params.siteId; const deploymentId = params.deploymentId; const type = params.type; + const token = params.token; if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); @@ -1384,6 +1388,9 @@ export class Sites { if (typeof type !== 'undefined') { payload['type'] = type; } + if (typeof token !== 'undefined') { + payload['token'] = token; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 57baaf22..70bfec60 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -90,10 +90,11 @@ export class TablesDB { * @param {string} params.name - Database name. Max length: 128 chars. * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} params.specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. + * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string }): Promise; + create(params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }): Promise; /** * Create a new Database. * @@ -102,25 +103,27 @@ export class TablesDB { * @param {string} name - Database name. Max length: 128 chars. * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. * @param {string} specification - Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. + * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(databaseId: string, name: string, enabled?: boolean, specification?: string): Promise; + create(databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number): Promise; create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?] + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number } | string, + ...rest: [(string)?, (boolean)?, (string)?, (number)?] ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean, specification?: string }; + let params: { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean, specification?: string, replicas?: number }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, enabled: rest[1] as boolean, - specification: rest[2] as string + specification: rest[2] as string, + replicas: rest[3] as number }; } @@ -128,6 +131,7 @@ export class TablesDB { const name = params.name; const enabled = params.enabled; const specification = params.specification; + const replicas = params.replicas; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -150,6 +154,9 @@ export class TablesDB { if (typeof specification !== 'undefined') { payload['specification'] = specification; } + if (typeof replicas !== 'undefined') { + payload['replicas'] = replicas; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -166,6 +173,31 @@ export class TablesDB { ); } + /** + * List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + listSpecifications(): Promise { + + const apiPath = '/tablesdb/specifications'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + /** * List transactions across all databases. * @@ -569,40 +601,44 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.name - Database name. Max length: 128 chars. * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {number} params.replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { databaseId: string, name?: string, enabled?: boolean }): Promise; + update(params: { databaseId: string, name?: string, enabled?: boolean, replicas?: number }): Promise; /** * Update a database by its unique ID. * * @param {string} databaseId - Database ID. * @param {string} name - Database name. Max length: 128 chars. * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @param {number} replicas - Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(databaseId: string, name?: string, enabled?: boolean): Promise; + update(databaseId: string, name?: string, enabled?: boolean, replicas?: number): Promise; update( - paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] + paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean, replicas?: number } | string, + ...rest: [(string)?, (boolean)?, (number)?] ): Promise { - let params: { databaseId: string, name?: string, enabled?: boolean }; + let params: { databaseId: string, name?: string, enabled?: boolean, replicas?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean }; + params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean, replicas?: number }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean + enabled: rest[1] as boolean, + replicas: rest[2] as number }; } const databaseId = params.databaseId; const name = params.name; const enabled = params.enabled; + const replicas = params.replicas; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -616,6 +652,9 @@ export class TablesDB { if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } + if (typeof replicas !== 'undefined') { + payload['replicas'] = replicas; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -685,6 +724,174 @@ export class TablesDB { ); } + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + */ + createFailover(params: { databaseId: string, targetReplicaId?: string }): Promise; + /** + * Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. + * + * @param {string} databaseId - Database ID. + * @param {string} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFailover(databaseId: string, targetReplicaId?: string): Promise; + createFailover( + paramsOrFirst: { databaseId: string, targetReplicaId?: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { databaseId: string, targetReplicaId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, targetReplicaId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + targetReplicaId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const targetReplicaId = params.targetReplicaId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}/failovers'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const payload: Payload = {}; + if (typeof targetReplicaId !== 'undefined') { + payload['targetReplicaId'] = targetReplicaId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getReplicas(params: { databaseId: string }): Promise; + /** + * Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getReplicas(databaseId: string): Promise; + getReplicas( + paramsOrFirst: { databaseId: string } | string + ): Promise { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}/replicas'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getStatus(params: { databaseId: string }): Promise; + /** + * Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getStatus(databaseId: string): Promise; + getStatus( + paramsOrFirst: { databaseId: string } | string + ): Promise { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}/status'.replace('{databaseId}', encodeURIComponent(String(databaseId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + /** * Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. * diff --git a/src/services/teams.ts b/src/services/teams.ts index 28a9533a..a194b2a2 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -324,6 +324,338 @@ export class Teams { ); } + /** + * List app installations on a team. Any team member can read installations. + * + * @param {string} params.teamId - Team ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listInstallations(params: { teamId: string, queries?: string[], total?: boolean }): Promise; + /** + * List app installations on a team. Any team member can read installations. + * + * @param {string} teamId - Team ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listInstallations(teamId: string, queries?: string[], total?: boolean): Promise; + listInstallations( + paramsOrFirst: { teamId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise { + let params: { teamId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, queries?: string[], total?: boolean }; + } else { + params = { + teamId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const teamId = params.teamId; + const queries = params.queries; + const total = params.total; + + if (typeof teamId === 'undefined') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + const apiPath = '/teams/{teamId}/installations'.replace('{teamId}', encodeURIComponent(String(teamId))); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Install an app on a team. When authenticated as a user, only team members with the owner role can install apps. Requests using an API key or in admin mode can install apps on any team. The installation is granted the scopes the app currently requests. + * + * @param {string} params.teamId - Team ID. + * @param {string} params.appId - Application unique ID. + * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. The Appwrite Console stores authorized project IDs here. + * @throws {AppwriteException} + * @returns {Promise} + */ + createInstallation(params: { teamId: string, appId: string, authorizationDetails?: string }): Promise; + /** + * Install an app on a team. When authenticated as a user, only team members with the owner role can install apps. Requests using an API key or in admin mode can install apps on any team. The installation is granted the scopes the app currently requests. + * + * @param {string} teamId - Team ID. + * @param {string} appId - Application unique ID. + * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. The Appwrite Console stores authorized project IDs here. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createInstallation(teamId: string, appId: string, authorizationDetails?: string): Promise; + createInstallation( + paramsOrFirst: { teamId: string, appId: string, authorizationDetails?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { teamId: string, appId: string, authorizationDetails?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, appId: string, authorizationDetails?: string }; + } else { + params = { + teamId: paramsOrFirst as string, + appId: rest[0] as string, + authorizationDetails: rest[1] as string + }; + } + + const teamId = params.teamId; + const appId = params.appId; + const authorizationDetails = params.authorizationDetails; + + if (typeof teamId === 'undefined') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (typeof appId === 'undefined') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + const apiPath = '/teams/{teamId}/installations'.replace('{teamId}', encodeURIComponent(String(teamId))); + const payload: Payload = {}; + if (typeof appId !== 'undefined') { + payload['appId'] = appId; + } + if (typeof authorizationDetails !== 'undefined') { + payload['authorizationDetails'] = authorizationDetails; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get an app installation on a team by its unique ID. Any team member can read installations. + * + * @param {string} params.teamId - Team ID. + * @param {string} params.installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getInstallation(params: { teamId: string, installationId: string }): Promise; + /** + * Get an app installation on a team by its unique ID. Any team member can read installations. + * + * @param {string} teamId - Team ID. + * @param {string} installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getInstallation(teamId: string, installationId: string): Promise; + getInstallation( + paramsOrFirst: { teamId: string, installationId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { teamId: string, installationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, installationId: string }; + } else { + params = { + teamId: paramsOrFirst as string, + installationId: rest[0] as string + }; + } + + const teamId = params.teamId; + const installationId = params.installationId; + + if (typeof teamId === 'undefined') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (typeof installationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + + const apiPath = '/teams/{teamId}/installations/{installationId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{installationId}', encodeURIComponent(String(installationId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'accept': 'application/json', + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an app installation on a team. Only team members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. + * + * @param {string} params.teamId - Team ID. + * @param {string} params.installationId - Installation unique ID. + * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateInstallation(params: { teamId: string, installationId: string, authorizationDetails?: string }): Promise; + /** + * Update an app installation on a team. Only team members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. + * + * @param {string} teamId - Team ID. + * @param {string} installationId - Installation unique ID. + * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateInstallation(teamId: string, installationId: string, authorizationDetails?: string): Promise; + updateInstallation( + paramsOrFirst: { teamId: string, installationId: string, authorizationDetails?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { teamId: string, installationId: string, authorizationDetails?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, installationId: string, authorizationDetails?: string }; + } else { + params = { + teamId: paramsOrFirst as string, + installationId: rest[0] as string, + authorizationDetails: rest[1] as string + }; + } + + const teamId = params.teamId; + const installationId = params.installationId; + const authorizationDetails = params.authorizationDetails; + + if (typeof teamId === 'undefined') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (typeof installationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + + const apiPath = '/teams/{teamId}/installations/{installationId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{installationId}', encodeURIComponent(String(installationId))); + const payload: Payload = {}; + if (typeof authorizationDetails !== 'undefined') { + payload['authorizationDetails'] = authorizationDetails; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Uninstall an app from a team by its installation ID. Only team members with the owner role can remove installations. Previously issued installation access tokens are revoked. + * + * @param {string} params.teamId - Team ID. + * @param {string} params.installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteInstallation(params: { teamId: string, installationId: string }): Promise<{}>; + /** + * Uninstall an app from a team by its installation ID. Only team members with the owner role can remove installations. Previously issued installation access tokens are revoked. + * + * @param {string} teamId - Team ID. + * @param {string} installationId - Installation unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteInstallation(teamId: string, installationId: string): Promise<{}>; + deleteInstallation( + paramsOrFirst: { teamId: string, installationId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { teamId: string, installationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { teamId: string, installationId: string }; + } else { + params = { + teamId: paramsOrFirst as string, + installationId: rest[0] as string + }; + } + + const teamId = params.teamId; + const installationId = params.installationId; + + if (typeof teamId === 'undefined') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (typeof installationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + + const apiPath = '/teams/{teamId}/installations/{installationId}'.replace('{teamId}', encodeURIComponent(String(teamId))).replace('{installationId}', encodeURIComponent(String(installationId))); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + 'accept': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + /** * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. * diff --git a/test/services/account.test.js b/test/services/account.test.js index 21537bee..e541ba35 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -71,6 +71,116 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method listConsents()', async () => { + const data = { + 'total': 5, + 'consents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.listConsents( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getConsent()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'appId': '5e5ea5c16897e', + 'cimdUrl': 'https://example.com/.well-known/client-metadata.json', + 'scopes': [], + 'resources': [], + 'authorizationDetails': '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.getConsent( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteConsent()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.deleteConsent( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listConsentTokens()', async () => { + const data = { + 'total': 5, + 'tokens': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.listConsentTokens( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getConsentToken()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'consentId': '5e5ea5c16897e', + 'userId': '5e5ea5c16897e', + 'appId': '5e5ea5c16897e', + 'cimdUrl': 'https://example.com/.well-known/client-metadata.json', + 'scopes': [], + 'resources': [], + 'authorizationDetails': '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.getConsentToken( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteConsentToken()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.deleteConsentToken( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateEmail()', async () => { const data = { '\$id': '5e5ea5c16897e', diff --git a/test/services/activities.test.js b/test/services/activities.test.js index 2823e415..61bc5967 100644 --- a/test/services/activities.test.js +++ b/test/services/activities.test.js @@ -41,10 +41,21 @@ describe('Activities', () => { 'ip': '127.0.0.1', 'mode': 'admin', 'country': 'US', + 'continentCode': 'NA', + 'city': 'Mountain View', + 'subdivisions': 'California', + 'isp': 'Google', + 'autonomousSystemNumber': '15169', + 'autonomousSystemOrganization': 'GOOGLE', + 'connectionType': 'cable', + 'connectionUsageType': 'residential', + 'connectionOrganization': 'Google LLC', 'time': '2020-10-15T06:38:00.000+00:00', 'projectId': '610fc2f985ee0', 'teamId': '610fc2f985ee0', - 'hostname': 'appwrite.io',}; + 'hostname': 'appwrite.io', + 'sdk': 'web', + 'sdkVersion': '14.0.0',}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await activities.getEvent( diff --git a/test/services/apps.test.js b/test/services/apps.test.js new file mode 100644 index 00000000..34305b36 --- /dev/null +++ b/test/services/apps.test.js @@ -0,0 +1,502 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Apps } = require("../../dist/services/apps"); + +const { fetch: mockedFetch, Response } = require("undici"); +jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); + +describe('Apps', () => { + const client = new Client(); + const apps = new Apps(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'apps': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.list( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Application', + 'description': 'Connect your workspace to My Application.', + 'clientUri': 'https://example.com', + 'logoUri': 'https://example.com/logo.png', + 'privacyPolicyUrl': 'https://example.com/privacy', + 'termsUrl': 'https://example.com/terms', + 'contacts': [], + 'tagline': 'Automate your workspace.', + 'tags': [], + 'labels': [], + 'images': [], + 'supportUrl': 'https://example.com/support', + 'dataDeletionUrl': 'https://example.com/data-deletion', + 'redirectUris': [], + 'postLogoutRedirectUris': [], + 'enabled': true, + 'type': 'confidential', + 'deviceFlow': true, + 'teamId': '5e5ea5c16897e', + 'userId': '5e5ea5c16897e', + 'installationScopes': [], + 'installationRedirectUrl': 'https://example.com/setup', + 'secrets': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.create( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listInstallationScopes()', async () => { + const data = { + 'total': 5, + 'scopes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.listInstallationScopes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listOAuth2Scopes()', async () => { + const data = { + 'total': 5, + 'scopes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.listOAuth2Scopes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Application', + 'description': 'Connect your workspace to My Application.', + 'clientUri': 'https://example.com', + 'logoUri': 'https://example.com/logo.png', + 'privacyPolicyUrl': 'https://example.com/privacy', + 'termsUrl': 'https://example.com/terms', + 'contacts': [], + 'tagline': 'Automate your workspace.', + 'tags': [], + 'labels': [], + 'images': [], + 'supportUrl': 'https://example.com/support', + 'dataDeletionUrl': 'https://example.com/data-deletion', + 'redirectUris': [], + 'postLogoutRedirectUris': [], + 'enabled': true, + 'type': 'confidential', + 'deviceFlow': true, + 'teamId': '5e5ea5c16897e', + 'userId': '5e5ea5c16897e', + 'installationScopes': [], + 'installationRedirectUrl': 'https://example.com/setup', + 'secrets': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method update()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Application', + 'description': 'Connect your workspace to My Application.', + 'clientUri': 'https://example.com', + 'logoUri': 'https://example.com/logo.png', + 'privacyPolicyUrl': 'https://example.com/privacy', + 'termsUrl': 'https://example.com/terms', + 'contacts': [], + 'tagline': 'Automate your workspace.', + 'tags': [], + 'labels': [], + 'images': [], + 'supportUrl': 'https://example.com/support', + 'dataDeletionUrl': 'https://example.com/data-deletion', + 'redirectUris': [], + 'postLogoutRedirectUris': [], + 'enabled': true, + 'type': 'confidential', + 'deviceFlow': true, + 'teamId': '5e5ea5c16897e', + 'userId': '5e5ea5c16897e', + 'installationScopes': [], + 'installationRedirectUrl': 'https://example.com/setup', + 'secrets': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.update( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listInstallations()', async () => { + const data = { + 'total': 5, + 'installations': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.listInstallations( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getInstallation()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'teamId': '5e5ea5c16897e', + 'scopes': [], + 'authorizationDetails': {}, + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.getInstallation( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createInstallationToken()', async () => { + const data = { + 'access_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...', + 'token_type': 'Bearer', + 'expires_in': 3600, + 'refresh_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...', + 'scope': 'openid email profile',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.createInstallationToken( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listKeys()', async () => { + const data = { + 'total': 5, + 'keys': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.listKeys( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createKey()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'secret': '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', + 'hint': 'f5c6c7', + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.createKey( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getKey()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'secret': '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', + 'hint': 'f5c6c7', + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.getKey( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteKey()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.deleteKey( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateLabels()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Application', + 'description': 'Connect your workspace to My Application.', + 'clientUri': 'https://example.com', + 'logoUri': 'https://example.com/logo.png', + 'privacyPolicyUrl': 'https://example.com/privacy', + 'termsUrl': 'https://example.com/terms', + 'contacts': [], + 'tagline': 'Automate your workspace.', + 'tags': [], + 'labels': [], + 'images': [], + 'supportUrl': 'https://example.com/support', + 'dataDeletionUrl': 'https://example.com/data-deletion', + 'redirectUris': [], + 'postLogoutRedirectUris': [], + 'enabled': true, + 'type': 'confidential', + 'deviceFlow': true, + 'teamId': '5e5ea5c16897e', + 'userId': '5e5ea5c16897e', + 'installationScopes': [], + 'installationRedirectUrl': 'https://example.com/setup', + 'secrets': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.updateLabels( + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listSecrets()', async () => { + const data = { + 'total': 5, + 'secrets': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.listSecrets( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSecret()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'secret': '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', + 'hint': 'f5c6c7', + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.createSecret( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getSecret()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'secret': '', + 'hint': 'f5c6c7', + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.getSecret( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteSecret()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.deleteSecret( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTeam()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Application', + 'description': 'Connect your workspace to My Application.', + 'clientUri': 'https://example.com', + 'logoUri': 'https://example.com/logo.png', + 'privacyPolicyUrl': 'https://example.com/privacy', + 'termsUrl': 'https://example.com/terms', + 'contacts': [], + 'tagline': 'Automate your workspace.', + 'tags': [], + 'labels': [], + 'images': [], + 'supportUrl': 'https://example.com/support', + 'dataDeletionUrl': 'https://example.com/data-deletion', + 'redirectUris': [], + 'postLogoutRedirectUris': [], + 'enabled': true, + 'type': 'confidential', + 'deviceFlow': true, + 'teamId': '5e5ea5c16897e', + 'userId': '5e5ea5c16897e', + 'installationScopes': [], + 'installationRedirectUrl': 'https://example.com/setup', + 'secrets': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.updateTeam( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteTokens()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await apps.deleteTokens( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/backups.test.js b/test/services/backups.test.js index 46f5814c..b37c790a 100644 --- a/test/services/backups.test.js +++ b/test/services/backups.test.js @@ -203,7 +203,7 @@ describe('Backups', () => { 'migrationId': 'did8jx6ws45jana098ab7', 'services': [], 'resources': [], - 'options': '{databases.database[{oldId, newId, newName, newSpecification}]}',}; + 'options': '{databases.database[{oldId, newId, newName}]}',}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await backups.createRestoration( @@ -244,7 +244,7 @@ describe('Backups', () => { 'migrationId': 'did8jx6ws45jana098ab7', 'services': [], 'resources': [], - 'options': '{databases.database[{oldId, newId, newName, newSpecification}]}',}; + 'options': '{databases.database[{oldId, newId, newName}]}',}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await backups.getRestoration( diff --git a/test/services/databases.test.js b/test/services/databases.test.js index 2b20a4fc..e4172d2f 100644 --- a/test/services/databases.test.js +++ b/test/services/databases.test.js @@ -32,9 +32,7 @@ describe('Databases', () => { '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; + 'type': 'legacy',}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await databases.create( @@ -163,9 +161,7 @@ describe('Databases', () => { '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; + 'type': 'legacy',}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await databases.get( @@ -185,9 +181,7 @@ describe('Databases', () => { '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; + 'type': 'legacy',}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await databases.update( diff --git a/test/services/oauth2.test.js b/test/services/oauth2.test.js new file mode 100644 index 00000000..b1bf4c4f --- /dev/null +++ b/test/services/oauth2.test.js @@ -0,0 +1,224 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Oauth2 } = require("../../dist/services/oauth-2"); + +const { fetch: mockedFetch, Response } = require("undici"); +jest.mock('undici', () => ({ ...jest.requireActual('undici'), fetch: jest.fn() })); + +describe('Oauth2', () => { + const client = new Client(); + const oauth2 = new Oauth2(client); + + + test('test method approve()', async () => { + const data = { + 'redirectUrl': 'https://example.com/callback?code=abcde&state=fghij',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.approve( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method authorize()', async () => { + const data = { + 'grantId': '5e5ea5c16897e', + 'redirectUrl': 'https://example.com/callback?code=abcde&state=fghij',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.authorize( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method authorizePost()', async () => { + const data = { + 'grantId': '5e5ea5c16897e', + 'redirectUrl': 'https://example.com/callback?code=abcde&state=fghij',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.authorizePost( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDeviceAuthorization()', async () => { + const data = { + 'device_code': '5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a', + 'user_code': 'ABCD-EFGH', + 'verification_uri': 'https://cloud.appwrite.io/console/oauth2/device', + 'verification_uri_complete': 'https://cloud.appwrite.io/console/oauth2/device?user_code=ABCD-EFGH', + 'expires_in': 900, + 'interval': 5,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.createDeviceAuthorization( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createGrant()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'appId': '5e5ea5c16897e', + 'scopes': [], + 'resources': [], + 'authorizationDetails': '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', + 'prompt': 'login', + 'redirectUri': 'https://example.com/callback', + 'authTime': 1592981250, + 'expire': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.createGrant( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getGrant()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'appId': '5e5ea5c16897e', + 'scopes': [], + 'resources': [], + 'authorizationDetails': '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', + 'prompt': 'login', + 'redirectUri': 'https://example.com/callback', + 'authTime': 1592981250, + 'expire': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.getGrant( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listOrganizations()', async () => { + const data = { + 'total': 5, + 'organizations': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.listOrganizations( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createPAR()', async () => { + const data = { + 'request_uri': 'urn:appwrite:oauth2:request:5e5ea5c16897e', + 'expires_in': 600,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.createPAR( + '', + 'https://example.com', + 'code', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listProjects()', async () => { + const data = { + 'total': 5, + 'projects': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.listProjects( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method reject()', async () => { + const data = { + 'redirectUrl': 'https://example.com/callback?error=access_denied&state=fghij',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.reject( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method revoke()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.revoke( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createToken()', async () => { + const data = { + 'access_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...', + 'token_type': 'Bearer', + 'expires_in': 3600, + 'refresh_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...', + 'scope': 'openid email profile',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await oauth2.createToken( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/organization.test.js b/test/services/organization.test.js index 69a6ea47..e4d05321 100644 --- a/test/services/organization.test.js +++ b/test/services/organization.test.js @@ -118,6 +118,104 @@ describe('Organization', () => { expect(response).toEqual(data); }); + test('test method listInstallations()', async () => { + const data = { + 'total': 5, + 'installations': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await organization.listInstallations( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createInstallation()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'teamId': '5e5ea5c16897e', + 'scopes': [], + 'authorizationDetails': {}, + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await organization.createInstallation( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getInstallation()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'teamId': '5e5ea5c16897e', + 'scopes': [], + 'authorizationDetails': {}, + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await organization.getInstallation( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateInstallation()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'teamId': '5e5ea5c16897e', + 'scopes': [], + 'authorizationDetails': {}, + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await organization.updateInstallation( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteInstallation()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await organization.deleteInstallation( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listKeys()', async () => { const data = { 'total': 5, @@ -380,7 +478,8 @@ describe('Organization', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await organization.createProject( @@ -422,7 +521,8 @@ describe('Organization', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await organization.getProject( @@ -463,7 +563,8 @@ describe('Organization', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await organization.updateProject( diff --git a/test/services/project.test.js b/test/services/project.test.js index 48aaf8e9..3f535e93 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -38,7 +38,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.get( @@ -91,7 +92,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateAuthMethod( @@ -259,7 +261,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateLabels( @@ -400,7 +403,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateOAuth2Server( @@ -1493,7 +1497,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateDenyAliasedEmailPolicy( @@ -1534,7 +1539,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateDenyCorporateEmailPolicy( @@ -1575,7 +1581,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateDenyDisposableEmailPolicy( @@ -1616,7 +1623,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateDenyFreeEmailPolicy( @@ -1657,7 +1665,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateMembershipPrivacyPolicy( @@ -1697,7 +1706,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updatePasswordDictionaryPolicy( @@ -1738,7 +1748,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updatePasswordHistoryPolicy( @@ -1779,7 +1790,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updatePasswordPersonalDataPolicy( @@ -1839,7 +1851,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateSessionAlertPolicy( @@ -1880,7 +1893,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateSessionDurationPolicy( @@ -1921,7 +1935,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateSessionInvalidationPolicy( @@ -1962,7 +1977,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateSessionLimitPolicy( @@ -2003,7 +2019,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateUserLimitPolicy( @@ -2060,7 +2077,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateProtocol( @@ -2102,7 +2120,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateService( @@ -2144,7 +2163,8 @@ describe('Project', () => { 'services': [], 'protocols': [], 'blocks': [], - 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'wafEnabled': true,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateSMTP( diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js index 513c5b7c..654a20a7 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -32,9 +32,7 @@ describe('TablesDB', () => { '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; + 'type': 'legacy',}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tablesDB.create( @@ -48,6 +46,22 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); + test('test method listSpecifications()', async () => { + const data = { + 'specifications': [], + 'total': 9, + 'pricing': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.listSpecifications( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listTransactions()', async () => { const data = { 'total': 5, @@ -163,9 +177,7 @@ describe('TablesDB', () => { '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; + 'type': 'legacy',}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tablesDB.get( @@ -185,9 +197,7 @@ describe('TablesDB', () => { '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; + 'type': 'legacy',}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tablesDB.update( @@ -214,6 +224,106 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); + test('test method createFailover()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'projectId': '5e5ea5c16897e', + 'name': 'My Production Database', + 'api': 'postgresql', + 'engine': 'postgresql', + 'version': '16', + 'specification': 's-2vcpu-2gb', + 'backend': 'edge', + 'hostname': 'db-myproject-mydb.fra.appwrite.center', + 'connectionPort': 5432, + 'connectionUser': 'appwrite_user', + 'connectionPassword': '••••••••', + 'connectionString': 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', + 'ssl': true, + 'status': 'ready', + 'containerStatus': 'active', + 'lifecycleState': 'active', + 'idleTimeoutMinutes': 15, + 'cpu': 2000, + 'memory': 4096, + 'storage': 100, + 'storageClass': 'ssd', + 'storageMaxGb': 100, + 'nodePool': 'db-pool-4vcpu-8gb', + 'replicas': 2, + 'syncMode': 'async', + 'crossRegionReplicas': 1, + 'networkMaxConnections': 500, + 'networkIdleTimeoutSeconds': 900, + 'networkIPAllowlist': [], + 'backupEnabled': true, + 'pitr': true, + 'pitrRetentionDays': 14, + 'storageAutoscaling': true, + 'storageAutoscalingThresholdPercent': 85, + 'storageAutoscalingMaxGb': 500, + 'maintenanceWindowDay': 'sun', + 'maintenanceWindowHourUtc': 3, + 'metricsEnabled': true, + 'sqlApiEnabled': true, + 'sqlApiAllowedStatements': [], + 'sqlApiMaxRows': 10000, + 'sqlApiMaxBytes': 10485760, + 'sqlApiTimeoutSeconds': 30, + 'error': '',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createFailover( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getReplicas()', async () => { + const data = { + 'replicas': 2, + 'syncMode': 'async', + 'members': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.getReplicas( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getStatus()', async () => { + const data = { + 'health': 'healthy', + 'ready': true, + 'engine': 'postgresql', + 'version': '17', + 'uptime': 86400, + 'connections': {}, + 'replicas': [], + 'volumes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.getStatus( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listTables()', async () => { const data = { 'total': 5, diff --git a/test/services/teams.test.js b/test/services/teams.test.js index 0054c3e3..dfa5365b 100644 --- a/test/services/teams.test.js +++ b/test/services/teams.test.js @@ -101,6 +101,109 @@ describe('Teams', () => { expect(response).toEqual(data); }); + test('test method listInstallations()', async () => { + const data = { + 'total': 5, + 'installations': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.listInstallations( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createInstallation()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'teamId': '5e5ea5c16897e', + 'scopes': [], + 'authorizationDetails': {}, + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.createInstallation( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getInstallation()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'teamId': '5e5ea5c16897e', + 'scopes': [], + 'authorizationDetails': {}, + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.getInstallation( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateInstallation()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'appId': '5e5ea5c16897e', + 'teamId': '5e5ea5c16897e', + 'scopes': [], + 'authorizationDetails': {}, + 'createdById': '5e5ea5c16897e', + 'createdByName': 'Walter White',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.updateInstallation( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteInstallation()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.deleteInstallation( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listMemberships()', async () => { const data = { 'total': 5,